|
@@ -1,12 +1,13 @@
|
|
package com.sooka.sponest.data.housingconstruction.service.impl;
|
|
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.domain.CenterdataTHousingconstructionAttach;
|
|
import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionAttachMapper;
|
|
import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionAttachMapper;
|
|
import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionAttachService;
|
|
import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionAttachService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -20,71 +21,104 @@ public class CenterdataTHousingconstructionAttachServiceImpl implements ICenterd
|
|
@Autowired
|
|
@Autowired
|
|
private CenterdataTHousingconstructionAttachMapper centerdataTHousingconstructionAttachMapper;
|
|
private CenterdataTHousingconstructionAttachMapper centerdataTHousingconstructionAttachMapper;
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 查询住建-附件
|
|
|
|
- *
|
|
|
|
- * @param id 住建-附件主键
|
|
|
|
- * @return 住建-附件
|
|
|
|
|
|
+ * 附件写入
|
|
*/
|
|
*/
|
|
@Override
|
|
@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
|
|
@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
|
|
@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
|
|
@Override
|
|
- public int deleteCenterdataTHousingconstructionAttachByIds(Long[] ids) {
|
|
|
|
- return centerdataTHousingconstructionAttachMapper.deleteCenterdataTHousingconstructionAttachByIds(ids);
|
|
|
|
|
|
+ public int delAttachByBusId(String busId) {
|
|
|
|
+ return centerdataTHousingconstructionAttachMapper.delAttachByBusId(busId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 删除住建-附件信息
|
|
|
|
- *
|
|
|
|
- * @param id 住建-附件主键
|
|
|
|
- * @return 结果
|
|
|
|
|
|
+ * 根据业务id获取附件集合
|
|
*/
|
|
*/
|
|
@Override
|
|
@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();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|