|
@@ -5,10 +5,8 @@ import com.jeeplus.common.utils.IdGen;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
|
import com.jeeplus.core.persistence.Page;
|
|
|
import com.jeeplus.core.service.CrudService;
|
|
|
-import com.jeeplus.modules.supply.materialLibrary.entity.MaterialLibrary;
|
|
|
import com.jeeplus.modules.supply.materialLibrary.service.MaterialLibraryService;
|
|
|
import com.jeeplus.modules.supply.projectInformation.entity.ProjectInformation;
|
|
|
-import com.jeeplus.modules.supply.projectInformation.entity.RealProjectInformation;
|
|
|
import com.jeeplus.modules.supply.projectInformation.mapper.ProjectInformationMapper;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -22,8 +20,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
+/**
|
|
|
+ * 项目信息Service
|
|
|
+ * @author: 黄俊杰
|
|
|
+ * @create: 2022-02-28 16:00
|
|
|
+ */
|
|
|
@Service
|
|
|
@Transactional(readOnly = true)
|
|
|
public class ProjectInformationService extends CrudService<ProjectInformationMapper, ProjectInformation> {
|
|
@@ -56,12 +58,12 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
ProjectInformation info = its.next();
|
|
|
if(StringUtils.isBlank(info.getSubmissionFormId())){
|
|
|
returnMap.put("success",false);
|
|
|
- returnMap.put("msg","存在审定单id为空的数据,请重新提交");
|
|
|
+ returnMap.put("msg","存在审定单id为空的数据,请确认后重新提交!");
|
|
|
return returnMap;
|
|
|
// its.remove(); //根据主键 送审单id做判断,防止空值
|
|
|
}else if(StringUtils.isBlank(info.getProjectDefinitionNumber())){
|
|
|
returnMap.put("success",false);
|
|
|
- returnMap.put("msg","存在项目定义号为空的数据,请重新提交");
|
|
|
+ returnMap.put("msg","存在项目定义号为空的数据,请确认后重新提交!");
|
|
|
return returnMap;
|
|
|
}
|
|
|
}
|
|
@@ -74,18 +76,18 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
//将去重后的set转换为list 方便比较
|
|
|
List<String> submissionFormIdList = new ArrayList<>(submissionFormIdSet);
|
|
|
|
|
|
- //判断物流编码list长度和导入数据的list长度是否一样,不一样则说明导入数据中项目名存在重复数据
|
|
|
+ //判断审定单idlist长度和导入数据的list长度是否一样,不一样则说明导入数据中项目名存在重复数据
|
|
|
if(submissionFormIdList.size() != list.size()){
|
|
|
returnMap.keySet().removeIf(key -> key == "msg");
|
|
|
returnMap.put("success",false);
|
|
|
- returnMap.put("msg","数据中存在重复审定单id");
|
|
|
+ returnMap.put("msg","存在审定单id重复的数据,请确认后重新提交!");
|
|
|
}
|
|
|
|
|
|
|
|
|
//将项目信息的内容去重 遍历
|
|
|
List<ProjectInformation> projectInformationList = new ArrayList();
|
|
|
Set<String> projectDefinitionNumberSet = new HashSet<>();//去重后的项目定义号
|
|
|
- for(int i=0;i<list.size();i++){ //遍历取出项目定义号 这里需要优化吗?
|
|
|
+ for(int i=0;i<list.size();i++){ //遍历取出项目定义号
|
|
|
projectDefinitionNumberSet.add(list.get(i).getProjectDefinitionNumber());
|
|
|
}
|
|
|
Iterator<String> projectDefinitionNumberIt = projectDefinitionNumberSet.iterator();//将项目定义号加入迭代器
|
|
@@ -100,7 +102,6 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
//方便快捷删除 找到对应重复数据,以便最后批量操作使用 审定单id
|
|
|
List<String> codeList = projectInformationMapper.getSubmissionFormIdListBysubmissionFormIdList(submissionFormIdList); //即为重复数据的审定单id集合
|
|
|
Iterator<ProjectInformation> it = list.iterator();
|
|
@@ -113,7 +114,7 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
returnMap.put("repeat","3");
|
|
|
returnMap.keySet().removeIf(key -> key == "msg");
|
|
|
returnMap.put("success",true);
|
|
|
- returnMap.put("msg","已存在物料数据,是否覆盖?");
|
|
|
+ returnMap.put("msg","已存在项目数据,是否覆盖?");
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
@@ -145,12 +146,12 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
|
|
|
returnMap.keySet().removeIf(key -> key == "msg");
|
|
|
returnMap.put("success",true);
|
|
|
- returnMap.put("msg","已成功导入 "+list.size()+" 条项目表单记录");
|
|
|
+ returnMap.put("msg","已成功导入 "+list.size()+" 条项目信息记录");
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 批量修改手工上传数据信息
|
|
|
+ * 批量新增审定单信息表数据
|
|
|
* @param projectBasicsList
|
|
|
* @return
|
|
|
*/
|
|
@@ -194,7 +195,7 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 批量修改手工上传数据信息 删除
|
|
|
+ * 批量项目信息表数据
|
|
|
* @param projectBasicsList
|
|
|
* @return
|
|
|
*/
|
|
@@ -238,7 +239,7 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 批量修改手工上传数据信息
|
|
|
+ * 批量删除(项目信息表+审定单信息表)
|
|
|
* @param projectBasicsList
|
|
|
* @return
|
|
|
*/
|
|
@@ -269,9 +270,13 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- //文件的操作
|
|
|
+ /**
|
|
|
+ * 文件的操作
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public String saveFile(File file){
|
|
|
- String filePath = "";
|
|
|
+ String filePath = "";//最终文件存放路径
|
|
|
try {
|
|
|
if(StringUtils.isNotBlank(host) && ("127.0.0.1".equals(host) || "localhost".equals(host))){
|
|
|
String path = null;
|
|
@@ -306,7 +311,11 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
return filePath;
|
|
|
}
|
|
|
|
|
|
- //文件的删除操作
|
|
|
+ /**
|
|
|
+ * 文件的删除操作
|
|
|
+ * @param file
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
public void deleteFileContent(File file) throws IOException {
|
|
|
String filePath = file.getAbsolutePath();
|
|
|
File deleteFile = new File(filePath);
|
|
@@ -375,8 +384,10 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
return multipartFile;
|
|
|
}
|
|
|
|
|
|
- //定时任务删除前两天数据
|
|
|
- @Scheduled(cron = "0 2 * * * ?")
|
|
|
+ /**
|
|
|
+ * 定时任务删除两天前的数据 待验证
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0/2 * * * ?")
|
|
|
public void deleteFileByCron(){
|
|
|
try{
|
|
|
System.out.println("开始了!");
|
|
@@ -412,8 +423,4 @@ public class ProjectInformationService extends CrudService<ProjectInformationMap
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// public void delete(String id){
|
|
|
-// projectInformationMapper.deletex(id);
|
|
|
-// }
|
|
|
-
|
|
|
}
|