瀏覽代碼

住建-附件公共services

Memory_LG 11 月之前
父節點
當前提交
ea8e0df23c

+ 30 - 13
src/main/java/com/sooka/sponest/data/housingconstruction/controller/CenterdataTHousingconstructionAttachController.java

@@ -1,3 +1,4 @@
+/*
 package com.sooka.sponest.data.housingconstruction.controller;
 
 import com.ruoyi.common.core.utils.poi.ExcelUtil;
@@ -15,21 +16,26 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
+*/
 /**
  * 住建-附件Controller
  *
  * @author lg
  * @date 2024-07-29
- */
+ *//*
+
 @RestController
 @RequestMapping("/attach")
 public class CenterdataTHousingconstructionAttachController extends BaseController {
     @Autowired
     private ICenterdataTHousingconstructionAttachService centerdataTHousingconstructionAttachService;
 
-    /**
+
+    */
+/**
      * 查询住建-附件列表
-     */
+     *//*
+
     @RequiresPermissions("housingconstruction:attach:list")
     @GetMapping("/list")
     public TableDataInfo list(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach) {
@@ -38,9 +44,11 @@ public class CenterdataTHousingconstructionAttachController extends BaseControll
         return getDataTable(list);
     }
 
-    /**
+    */
+/**
      * 导出住建-附件列表
-     */
+     *//*
+
     @RequiresPermissions("housingconstruction:attach:export")
     @Log(title = "住建-附件", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
@@ -50,18 +58,22 @@ public class CenterdataTHousingconstructionAttachController extends BaseControll
         util.exportExcel(response, list, "住建-附件数据");
     }
 
-    /**
+    */
+/**
      * 获取住建-附件详细信息
-     */
+     *//*
+
     @RequiresPermissions("housingconstruction:attach:query")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(centerdataTHousingconstructionAttachService.selectCenterdataTHousingconstructionAttachById(id));
     }
 
-    /**
+    */
+/**
      * 新增住建-附件
-     */
+     *//*
+
     @RequiresPermissions("housingconstruction:attach:add")
     @Log(title = "住建-附件", businessType = BusinessType.INSERT)
     @PostMapping
@@ -69,9 +81,11 @@ public class CenterdataTHousingconstructionAttachController extends BaseControll
         return toAjax(centerdataTHousingconstructionAttachService.insertCenterdataTHousingconstructionAttach(centerdataTHousingconstructionAttach));
     }
 
-    /**
+    */
+/**
      * 修改住建-附件
-     */
+     *//*
+
     @RequiresPermissions("housingconstruction:attach:edit")
     @Log(title = "住建-附件", businessType = BusinessType.UPDATE)
     @PutMapping
@@ -79,9 +93,11 @@ public class CenterdataTHousingconstructionAttachController extends BaseControll
         return toAjax(centerdataTHousingconstructionAttachService.updateCenterdataTHousingconstructionAttach(centerdataTHousingconstructionAttach));
     }
 
-    /**
+    */
+/**
      * 删除住建-附件
-     */
+     *//*
+
     @RequiresPermissions("housingconstruction:attach:remove")
     @Log(title = "住建-附件", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
@@ -89,3 +105,4 @@ public class CenterdataTHousingconstructionAttachController extends BaseControll
         return toAjax(centerdataTHousingconstructionAttachService.deleteCenterdataTHousingconstructionAttachByIds(ids));
     }
 }
+*/

+ 8 - 0
src/main/java/com/sooka/sponest/data/housingconstruction/domain/CenterdataTHousingconstructionAttach.java

@@ -75,6 +75,14 @@ public class CenterdataTHousingconstructionAttach extends BaseBusinessEntity {
     private String deptName;
 
 
+    public CenterdataTHousingconstructionAttach(String busId, String dictType, String dictValue, String attachPath, String fileName, Long attachSorts) {
+        this.busId = busId;
+        this.dictType = dictType;
+        this.dictValue = dictValue;
+        this.attachPath = attachPath;
+        this.fileName = fileName;
+        this.attachSorts = attachSorts;
+    }
 
     @Override
     public String toString() {

+ 4 - 0
src/main/java/com/sooka/sponest/data/housingconstruction/mapper/CenterdataTHousingconstructionAttachMapper.java

@@ -60,4 +60,8 @@ public interface CenterdataTHousingconstructionAttachMapper {
     int deleteCenterdataTHousingconstructionAttachByIds(Long[] ids);
 
     int insertAttachByList(List<CenterdataTHousingconstructionAttach> attachList);
+
+    int delAttachByBusId(String busId);
+
+    List<CenterdataTHousingconstructionAttach> getAttachListByBusId(String busId);
 }

+ 13 - 47
src/main/java/com/sooka/sponest/data/housingconstruction/service/ICenterdataTHousingconstructionAttachService.java

@@ -11,51 +11,17 @@ import java.util.List;
  * @date 2024-07-29
  */
 public interface ICenterdataTHousingconstructionAttachService {
-    /**
-     * 查询住建-附件
-     *
-     * @param id 住建-附件主键
-     * @return 住建-附件
-     */
-    CenterdataTHousingconstructionAttach selectCenterdataTHousingconstructionAttachById(Long id);
-
-    /**
-     * 查询住建-附件列表
-     *
-     * @param centerdataTHousingconstructionAttach 住建-附件
-     * @return 住建-附件集合
-     */
-    List<CenterdataTHousingconstructionAttach> selectCenterdataTHousingconstructionAttachList(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach);
-
-    /**
-     * 新增住建-附件
-     *
-     * @param centerdataTHousingconstructionAttach 住建-附件
-     * @return 结果
-     */
-    int insertCenterdataTHousingconstructionAttach(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach);
-
-    /**
-     * 修改住建-附件
-     *
-     * @param centerdataTHousingconstructionAttach 住建-附件
-     * @return 结果
-     */
-    int updateCenterdataTHousingconstructionAttach(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach);
-
-    /**
-     * 批量删除住建-附件
-     *
-     * @param ids 需要删除的住建-附件主键集合
-     * @return 结果
-     */
-    int deleteCenterdataTHousingconstructionAttachByIds(Long[] ids);
-
-    /**
-     * 删除住建-附件信息
-     *
-     * @param id 住建-附件主键
-     * @return 结果
-     */
-    int deleteCenterdataTHousingconstructionAttachById(Long id);
+    int addAttach(List<CenterdataTHousingconstructionAttach> attachList);
+
+    int addAttach(List<String> attachList, String busId, String dictType, String dictValue);
+
+    int addAttach(String attachStr, String busId, String dictType, String dictValue);
+
+    int delAttachByBusId(String busId);
+
+    List<CenterdataTHousingconstructionAttach> getAttachPathToEntityArray(String busId);
+
+    List<String> getAttachPathToStrArray(String busId);
+
+    String getAttachPathToStr(String busId);
 }

+ 78 - 44
src/main/java/com/sooka/sponest/data/housingconstruction/service/impl/CenterdataTHousingconstructionAttachServiceImpl.java

@@ -1,12 +1,13 @@
 package com.sooka.sponest.data.housingconstruction.service.impl;
 
-import com.ruoyi.common.core.utils.DateUtils;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionAttach;
 import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionAttachMapper;
 import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionAttachService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -20,71 +21,104 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
     @Autowired
     private CenterdataTHousingconstructionAttachMapper centerdataTHousingconstructionAttachMapper;
 
+
     /**
-     * 查询住建-附件
-     *
-     * @param id 住建-附件主键
-     * @return 住建-附件
+     * 附件写入
      */
     @Override
-    public CenterdataTHousingconstructionAttach selectCenterdataTHousingconstructionAttachById(Long id) {
-        return centerdataTHousingconstructionAttachMapper.selectCenterdataTHousingconstructionAttachById(id);
+    public int addAttach(List<CenterdataTHousingconstructionAttach> attachList) {
+        disposeAttachPath(attachList);
+        return centerdataTHousingconstructionAttachMapper.insertAttachByList(attachList);
     }
 
-    /**
-     * 查询住建-附件列表
-     *
-     * @param centerdataTHousingconstructionAttach 住建-附件
-     * @return 住建-附件
-     */
     @Override
-    public List<CenterdataTHousingconstructionAttach> selectCenterdataTHousingconstructionAttachList(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach) {
-        return centerdataTHousingconstructionAttachMapper.selectCenterdataTHousingconstructionAttachList(centerdataTHousingconstructionAttach);
+    public int addAttach(List<String> attachList, String busId, String dictType, String dictValue) {
+        List<CenterdataTHousingconstructionAttach> dataList = new ArrayList<>();
+        attachList.forEach(s -> {
+            String[] split = s.split("/");
+            dataList.add(new CenterdataTHousingconstructionAttach(busId, dictType, dictValue, s, split[split.length - 1], 0L));
+        });
+        return addAttach(dataList);
     }
 
-    /**
-     * 新增住建-附件
-     *
-     * @param centerdataTHousingconstructionAttach 住建-附件
-     * @return 结果
-     */
     @Override
-    public int insertCenterdataTHousingconstructionAttach(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach) {
-        centerdataTHousingconstructionAttach.setCreateTime(DateUtils.getNowDate());
-        return centerdataTHousingconstructionAttachMapper.insertCenterdataTHousingconstructionAttach(centerdataTHousingconstructionAttach);
+    public int addAttach(String attachStr, String busId, String dictType, String dictValue) {
+        return addAttach(Arrays.asList(attachStr.split(",")), busId, dictType, dictValue);
     }
 
     /**
-     * 修改住建-附件
-     *
-     * @param centerdataTHousingconstructionAttach 住建-附件
-     * @return 结果
+     * 路径处理
      */
-    @Override
-    public int updateCenterdataTHousingconstructionAttach(CenterdataTHousingconstructionAttach centerdataTHousingconstructionAttach) {
-        centerdataTHousingconstructionAttach.setUpdateTime(DateUtils.getNowDate());
-        return centerdataTHousingconstructionAttachMapper.updateCenterdataTHousingconstructionAttach(centerdataTHousingconstructionAttach);
+
+    private void disposeAttachPath(List<CenterdataTHousingconstructionAttach> attachList) {
+        attachList.forEach(attach -> {
+            String attachPath = attach.getAttachPath();
+            // 如果路径以 "http" 开头
+            if (attachPath.startsWith("http")) {
+                // 检查路径中是否包含 "Download"
+                if (attachPath.contains("Download")) {
+                    // 找到 "group=" 的位置
+                    int i1 = attachPath.indexOf("group=");
+                    // 将路径中的 "&&path=" 替换为 "/"
+                    attachPath = attachPath.replace("&&path=", "/");
+                    // 从 "group=" 之后的位置截取子字符串,并将其添加到 pathList 中
+                    attachPath = attachPath.substring(i1 + 6);
+                    attach.setAttachPath(attachPath);
+                } else {
+                    // 找到路径中第一个 '/' 的位置
+                    int i1 = attachPath.indexOf('/'); //5
+                    // 找到路径中第二个 '/' 的位置
+                    int i2 = attachPath.indexOf('/', i1 + 1); //
+                    // 找到路径中第三个 '/' 的位置
+                    int i3 = attachPath.indexOf('/', i2 + 1);
+                    attach.setAttachPath(attachPath.substring(i3 + 1));
+                }
+            }
+        });
     }
 
     /**
-     * 批量删除住建-附件
-     *
-     * @param ids 需要删除的住建-附件主键
-     * @return 结果
+     * 根据业务数据id删除附件信息
      */
     @Override
-    public int deleteCenterdataTHousingconstructionAttachByIds(Long[] ids) {
-        return centerdataTHousingconstructionAttachMapper.deleteCenterdataTHousingconstructionAttachByIds(ids);
+    public int delAttachByBusId(String busId) {
+        return centerdataTHousingconstructionAttachMapper.delAttachByBusId(busId);
     }
 
     /**
-     * 删除住建-附件信息
-     *
-     * @param id 住建-附件主键
-     * @return 结果
+     * 根据业务id获取附件集合
      */
     @Override
-    public int deleteCenterdataTHousingconstructionAttachById(Long id) {
-        return centerdataTHousingconstructionAttachMapper.deleteCenterdataTHousingconstructionAttachById(id);
+    public List<CenterdataTHousingconstructionAttach> getAttachPathToEntityArray(String busId) {
+        return centerdataTHousingconstructionAttachMapper.getAttachListByBusId(busId);
     }
+
+    @Override
+    public List<String> getAttachPathToStrArray(String busId) {
+        List<CenterdataTHousingconstructionAttach> attachPathToEntityArray = getAttachPathToEntityArray(busId);
+        List<String> resultList = new ArrayList<>();
+        if (!attachPathToEntityArray.isEmpty()) {
+            attachPathToEntityArray.forEach(attach -> {
+                resultList.add(attach.getAttachPath());
+            });
+        }
+        return resultList;
+    }
+
+    @Override
+    public String getAttachPathToStr(String busId) {
+        List<CenterdataTHousingconstructionAttach> attachPathToEntityArray = getAttachPathToEntityArray(busId);
+        StringBuilder result = new StringBuilder();
+        if (!attachPathToEntityArray.isEmpty()) {
+            attachPathToEntityArray.forEach(attach -> {
+                result.append(attach.getAttachPath()).append(",");
+            });
+        }
+        // 删除最后一个字符
+        if (result.length() > 0) {  // 确保 StringBuilder 不为空
+            result.deleteCharAt(result.length() - 1);
+        }
+        return result.toString();
+    }
+
 }

+ 15 - 0
src/main/java/com/sooka/sponest/data/utils/DataAttachUtil.java

@@ -18,20 +18,35 @@ public class DataAttachUtil {
 
     public static void dataAttachUpload(String busId, String newAttachPaths, String busIndx, String busSource) {
         ICenterdataTAttachService bean = SpringUtils.getBean(ICenterdataTAttachService.class);
+
+        //非空判断
         if (newAttachPaths != null) {
+
+            //截取附件信息
             String[] pathArray = newAttachPaths.split(",");
             List<String> pathList = new ArrayList<>();
+
+            // 遍历每个路径信息
             for (String path : pathArray) {
+                // 如果路径以 "http" 开头
                 if (path.startsWith("http")) {
+                    // 检查路径中是否包含 "Download"
                     if (path.contains("Download")) {
+                        // 找到 "group=" 的位置
                         int i1 = path.indexOf("group=");
+                        // 将路径中的 "&&path=" 替换为 "/"
                         path = path.replace("&&path=", "/");
+                        // 从 "group=" 之后的位置截取子字符串,并将其添加到 pathList 中
                         path = path.substring(i1 + 6);
                         pathList.add(path);
                     } else {
+                        // 找到路径中第一个 '/' 的位置
                         int i1 = path.indexOf('/');
+                        // 找到路径中第二个 '/' 的位置
                         int i2 = path.indexOf('/', i1 + 1);
+                        // 找到路径中第三个 '/' 的位置
                         int i3 = path.indexOf('/', i2 + 1);
+                        // 将路径从第三个 '/' 之后的部分截取出来,并添加到 pathList 中
                         pathList.add(path.substring(i3 + 1));
                     }
                 }

+ 8 - 0
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionAttachMapper.xml

@@ -106,4 +106,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{attach.createTime}
         </foreach>
     </insert>
+
+    <delete id="delAttachByBusId" parameterType="string">
+        delete from centerdata_t_housingconstruction_attach where bus_id = #{busId}
+    </delete>
+
+    <select id="getAttachListByBusId" parameterType="string" resultMap="CenterdataTHousingconstructionAttachResult">
+        select * from centerdata_t_housingconstruction_attach where bus_id = #{busId}
+    </select>
 </mapper>