|
@@ -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();
|
|
|
- }
|
|
|
-
|
|
|
}
|