|
@@ -10,12 +10,15 @@ import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-
|
|
|
|
public class DataAttachUtil {
|
|
public class DataAttachUtil {
|
|
|
|
|
|
- public static void dataAttachUpload(String busId, String newAttachPaths, String busIndx, String busSource){
|
|
|
|
|
|
+ private DataAttachUtil() {
|
|
|
|
+ throw new IllegalStateException("Utility class");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void dataAttachUpload(String busId, String newAttachPaths, String busIndx, String busSource) {
|
|
ICenterdataTAttachService bean = SpringUtils.getBean(ICenterdataTAttachService.class);
|
|
ICenterdataTAttachService bean = SpringUtils.getBean(ICenterdataTAttachService.class);
|
|
- if (newAttachPaths != null){
|
|
|
|
|
|
+ if (newAttachPaths != null) {
|
|
String[] pathArray = newAttachPaths.split(",");
|
|
String[] pathArray = newAttachPaths.split(",");
|
|
List<String> pathList = new ArrayList<>();
|
|
List<String> pathList = new ArrayList<>();
|
|
for (String path : pathArray) {
|
|
for (String path : pathArray) {
|
|
@@ -33,43 +36,34 @@ public class DataAttachUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
List<String> oldAttachList = bean.selectDataAttachPathByBusId(busId);
|
|
List<String> oldAttachList = bean.selectDataAttachPathByBusId(busId);
|
|
-
|
|
|
|
// 计算新增加的列表
|
|
// 计算新增加的列表
|
|
- List<String> addList = pathList.stream()
|
|
|
|
- .filter(id -> !oldAttachList.contains(id))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
+ List<String> addList = pathList.stream().filter(id -> !oldAttachList.contains(id)).collect(Collectors.toList());
|
|
// 计算删除的列表
|
|
// 计算删除的列表
|
|
- List<String> delList = oldAttachList.stream()
|
|
|
|
- .filter(id -> !pathList.contains(id))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
|
|
+ List<String> delList = oldAttachList.stream().filter(id -> !pathList.contains(id)).collect(Collectors.toList());
|
|
// 批量添加附件地址
|
|
// 批量添加附件地址
|
|
- if (StringUtils.isNotEmpty(addList)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(addList)) {
|
|
List<CenterdataTAttach> attachList = toAttachList(busId, addList, busIndx, busSource);
|
|
List<CenterdataTAttach> attachList = toAttachList(busId, addList, busIndx, busSource);
|
|
bean.insertListCenterdataTAttach(attachList);
|
|
bean.insertListCenterdataTAttach(attachList);
|
|
}
|
|
}
|
|
// 批量删除附件地址
|
|
// 批量删除附件地址
|
|
- if (StringUtils.isNotEmpty(delList)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(delList)) {
|
|
List<CenterdataTAttach> attachList = toAttachList(busId, delList, busIndx, busSource);
|
|
List<CenterdataTAttach> attachList = toAttachList(busId, delList, busIndx, busSource);
|
|
- bean.deleteListCenterdataTAttach(busId,attachList);
|
|
|
|
|
|
+ bean.deleteListCenterdataTAttach(busId, attachList);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private static List<CenterdataTAttach> toAttachList(String busId, List<String> addList, String busIndx, String busSource) {
|
|
private static List<CenterdataTAttach> toAttachList(String busId, List<String> addList, String busIndx, String busSource) {
|
|
List<CenterdataTAttach> list = new ArrayList<>();
|
|
List<CenterdataTAttach> list = new ArrayList<>();
|
|
- for (String addPath : addList){
|
|
|
|
|
|
+ for (String addPath : addList) {
|
|
CenterdataTAttach centerdataTAttach = new CenterdataTAttach();
|
|
CenterdataTAttach centerdataTAttach = new CenterdataTAttach();
|
|
centerdataTAttach.setBusId(busId);
|
|
centerdataTAttach.setBusId(busId);
|
|
centerdataTAttach.setAttachPath(addPath);
|
|
centerdataTAttach.setAttachPath(addPath);
|
|
centerdataTAttach.setBusIndx(busIndx);
|
|
centerdataTAttach.setBusIndx(busIndx);
|
|
- if (StringUtils.isNotEmpty(busSource)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(busSource)) {
|
|
centerdataTAttach.setBusSource(busSource);
|
|
centerdataTAttach.setBusSource(busSource);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
centerdataTAttach.setBusSource("PC");
|
|
centerdataTAttach.setBusSource("PC");
|
|
}
|
|
}
|
|
centerdataTAttach.setFileName(null);
|
|
centerdataTAttach.setFileName(null);
|
|
@@ -79,18 +73,15 @@ public class DataAttachUtil {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
- public static String getDataAttachUpload(String busId){
|
|
|
|
|
|
+ public static String getDataAttachUpload(String busId) {
|
|
ICenterdataTAttachService bean = SpringUtils.getBean(ICenterdataTAttachService.class);
|
|
ICenterdataTAttachService bean = SpringUtils.getBean(ICenterdataTAttachService.class);
|
|
List<String> list = bean.selectDataAttachPathByBusId(busId);
|
|
List<String> list = bean.selectDataAttachPathByBusId(busId);
|
|
String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
|
|
String fileUrl = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("fileUrl").getData();
|
|
String delimiter = ",";
|
|
String delimiter = ",";
|
|
-
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
-
|
|
|
|
for (String item : list) {
|
|
for (String item : list) {
|
|
sb.append(fileUrl).append(item).append(delimiter);
|
|
sb.append(fileUrl).append(item).append(delimiter);
|
|
}
|
|
}
|
|
-
|
|
|
|
// 移除最后一个逗号
|
|
// 移除最后一个逗号
|
|
if (sb.length() > 0) {
|
|
if (sb.length() > 0) {
|
|
sb.deleteCharAt(sb.length() - 1);
|
|
sb.deleteCharAt(sb.length() - 1);
|