Sfoglia il codice sorgente

完善附件上传公共接口
修改手机端安全检查实体类中附件实体信息。

Memory_LG 1 anno fa
parent
commit
e19a114a10

+ 15 - 8
src/main/java/com/sooka/sponest/data/housingconstruction/service/ICenterdataTHousingconstructionAttachService.java

@@ -12,19 +12,26 @@ import java.util.Map;
  * @date 2024-07-29
  */
 public interface ICenterdataTHousingconstructionAttachService {
-    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 addAttach(List<Map<String, Object>> attachList, String busId);
-
+    //删除附件
     int delAttachByBusId(String busId);
 
+    //新增附件;参数:List<CenterdataTHousingconstructionAttach>
+    int addAttach(List<CenterdataTHousingconstructionAttach> attachList);
+    //查询附件;响应:List<CenterdataTHousingconstructionAttach>
     List<CenterdataTHousingconstructionAttach> getAttachPathToEntityArray(String busId);
 
+    //新增附件;参数:List<String>
+    int addAttach(List<String> attachList, String busId, String dictType, String dictValue);
+    //查询附件;响应:List<String>
     List<String> getAttachPathToStrArray(String busId);
 
+    //新增附件;参数:String
+    int addAttach(String attachStr, String busId, String dictType, String dictValue);
+    //查询附件;响应:String
     String getAttachPathToStr(String busId);
+
+    //新增附件;参数:List<Map<String, Object>>
+    int addAttach(List<Map<String, Object>> attachList, String busId);
+    //查询附件;响应:List<Map<String>>
+    Map<String, Object> getAttachToMap(String busId);
 }

+ 125 - 52
src/main/java/com/sooka/sponest/data/housingconstruction/service/impl/CenterdataTHousingconstructionAttachServiceImpl.java

@@ -1,16 +1,16 @@
 package com.sooka.sponest.data.housingconstruction.service.impl;
 
+import com.ruoyi.common.core.utils.SpringUtils;
+import com.ruoyi.system.api.RemoteConfigService;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionAttach;
+import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSafetyinspectionrecords;
 import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionAttachMapper;
 import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionAttachService;
 import org.apache.commons.collections4.MapUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 住建-附件Service业务层处理
@@ -23,9 +23,20 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
     @Autowired
     private CenterdataTHousingconstructionAttachMapper centerdataTHousingconstructionAttachMapper;
 
+    //*******************************************删除*****************************************************/
+    /**
+     * 根据业务数据id删除附件信息
+     */
+    @Override
+    public int delAttachByBusId(String busId) {
+        return centerdataTHousingconstructionAttachMapper.delAttachByBusId(busId);
+    }
 
+    //*******************************************新增List<CenterdataTHousingconstructionAttach>*****************************************************/
     /**
-     * 附件写入
+     * 新增附件
+     * @param attachList 参数为附件实体的集合
+     * @return int 写入的数据条数
      */
     @Override
     public int addAttach(List<CenterdataTHousingconstructionAttach> attachList) {
@@ -33,6 +44,30 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
         return centerdataTHousingconstructionAttachMapper.insertAttachByList(attachList);
     }
 
+    /**
+     * 根据业务id获取附件集合
+     * @return List<CenterdataTHousingconstructionAttach> 附件实体集合
+     */
+    @Override
+    public List<CenterdataTHousingconstructionAttach> getAttachPathToEntityArray(String busId) {
+        List<CenterdataTHousingconstructionAttach> attachListByBusId = centerdataTHousingconstructionAttachMapper.getAttachListByBusId(busId);
+        String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
+        attachListByBusId.forEach(attach->{
+            attach.setAttachPath(fileUrl + attach.getAttachPath());
+        });
+        return attachListByBusId;
+    }
+
+
+    //*******************************************新增List<String>*****************************************************/
+    /**
+     * 新增附件
+     * @param attachList 参数为附件路径集合
+     * @param busId 业务数据id
+     * @param dictType 字典key,可以为null
+     * @param dictValue 字典值,可以为null
+     * @return int 写入的数据条数
+     */
     @Override
     public int addAttach(List<String> attachList, String busId, String dictType, String dictValue) {
         List<CenterdataTHousingconstructionAttach> dataList = new ArrayList<>();
@@ -43,16 +78,78 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
         return addAttach(dataList);
     }
 
+    /**
+     * 根据业务id获取附件集合
+     * @return List<String> 附件路径集合
+     */
+    @Override
+    public List<String> getAttachPathToStrArray(String busId) {
+        List<CenterdataTHousingconstructionAttach> attachPathToEntityArray = getAttachPathToEntityArray(busId);
+        String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
+        List<String> resultList = new ArrayList<>();
+        if (!attachPathToEntityArray.isEmpty()) {
+            attachPathToEntityArray.forEach(attach -> {
+                resultList.add(fileUrl + attach.getAttachPath());
+            });
+        }
+        return resultList;
+    }
+
+    //*******************************************新增String*****************************************************/
+    /**
+     * 新增附件
+     * @param attachStr 参数为附件路径字符串拼接,以英文逗号分隔
+     * @param busId 业务数据id
+     * @param dictType 字典key,可以为null
+     * @param dictValue 字典值,可以为null
+     * @return int 写入的数据条数
+     */
     @Override
     public int addAttach(String attachStr, String busId, String dictType, String dictValue) {
         return addAttach(Arrays.asList(attachStr.split(",")), busId, dictType, dictValue);
     }
 
+    /**
+     * 根据业务id获取附件集合
+     * @return String 附件路径拼接字符串,以英文逗号分隔
+     */
+    @Override
+    public String getAttachPathToStr(String busId) {
+        List<CenterdataTHousingconstructionAttach> attachPathToEntityArray = getAttachPathToEntityArray(busId);
+        String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
+        StringBuilder result = new StringBuilder();
+        if (!attachPathToEntityArray.isEmpty()) {
+            attachPathToEntityArray.forEach(attach -> {
+                result.append(fileUrl).append(attach.getAttachPath()).append(",");
+            });
+        }
+
+        // 确保 StringBuilder 不为空
+        if (result.length() > 0) {
+            // 删除最后一个字符
+            result.deleteCharAt(result.length() - 1);
+        }
+        return result.toString();
+    }
+
+    //*******************************************新增List<Map<String, Object>>*****************************************************/
+    /**
+     * 新增附件
+     * @param attachList 新增的附件集合
+     * 请求样例:[{
+     *  "key":"字段名",
+     *  "value":"附件路径"
+     * },{
+     *  "key":"字段名",
+     *  "value":"附件路径"
+     * }]
+     * @param busId 业务id
+     * @return int 新增的数据条数
+     */
     @Override
     public int addAttach(List<Map<String, Object>> attachList, String busId) {
         List<CenterdataTHousingconstructionAttach> dataList = new ArrayList<>();
         attachList.forEach(map -> {
-            //{"key":"字段名", "value":"路径"}
             String path = MapUtils.getString(map, "value");
             String type = MapUtils.getString(map, "key");
             String[] split = path.split("/");
@@ -62,9 +159,30 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
     }
 
     /**
-     * 路径处理
+     * 根据业务id获取附件
+     * @param busId 业务id
+     * @return Map<String, Object>
+     * 返回样例:{
+     *  "新增时设置的key":"附件路径",
+     *  "新增时设置的key":"附件路径"
+     * }
      */
+    @Override
+    public Map<String, Object> getAttachToMap(String busId){
+        List<CenterdataTHousingconstructionAttach> attachPathToEntityArray = getAttachPathToEntityArray(busId);
+        String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
+        HashMap<String, Object> result = new HashMap<>();
+        attachPathToEntityArray.forEach(attach->{
+            result.put(attach.getDictType(), fileUrl + attach.getAttachPath());
+        });
+        return result;
+    }
+
 
+
+    /**
+     * 新增时路径处理(私有方法)
+     */
     private void disposeAttachPath(List<CenterdataTHousingconstructionAttach> attachList) {
         attachList.forEach(attach -> {
             String attachPath = attach.getAttachPath();
@@ -91,49 +209,4 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
             }
         });
     }
-
-    /**
-     * 根据业务数据id删除附件信息
-     */
-    @Override
-    public int delAttachByBusId(String busId) {
-        return centerdataTHousingconstructionAttachMapper.delAttachByBusId(busId);
-    }
-
-    /**
-     * 根据业务id获取附件集合
-     */
-    @Override
-    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();
-    }
-
 }

+ 12 - 1
src/main/java/com/sooka/sponest/data/housingconstruction/service/impl/CenterdataTHousingconstructionSafetyinspectionrecordsServiceImpl.java

@@ -1,8 +1,10 @@
 package com.sooka.sponest.data.housingconstruction.service.impl;
 
 import com.ruoyi.common.core.utils.DateUtils;
+import com.ruoyi.common.core.utils.SpringUtils;
 import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.system.api.RemoteConfigService;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionAttach;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSafetyinspectionrecords;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSafetyinspectionrecordsdetail;
@@ -57,7 +59,16 @@ public class CenterdataTHousingconstructionSafetyinspectionrecordsServiceImpl im
      */
     @Override
     public CenterdataTHousingconstructionSafetyinspectionrecords selectCenterdataTHousingconstructionSafetyinspectionrecordsById(String id) {
-        return recordsMapper.queryRedordDetails(id);
+        String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
+        CenterdataTHousingconstructionSafetyinspectionrecords resultData = recordsMapper.queryRedordDetails(id);
+        List<CenterdataTHousingconstructionSafetyinspectionrecordsdetail> detailList = resultData.getDetailList();
+        detailList.forEach(detail->{
+            List<CenterdataTHousingconstructionAttach> attachList = detail.getAttachList();
+            attachList.forEach(attach->{
+                attach.setAttachPath(fileUrl + attach.getAttachPath());
+            });
+        });
+        return resultData;
     }