|
@@ -3,6 +3,9 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.platform.common.cache.DictCache;
|
|
|
+import com.platform.common.enums.DictTypeEnum;
|
|
|
+import com.platform.common.enums.DictValueTypeEnum;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.util.*;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
@@ -37,6 +40,7 @@ import com.platform.dao.util.CustomExcelImportUtil;
|
|
|
import com.platform.dao.util.ExcelUtil;
|
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
|
import com.platform.dao.vo.export.check.ExportCheckStandardVO;
|
|
|
+import com.platform.dao.vo.export.check.ExportCheckStandardVO2;
|
|
|
import com.platform.dao.vo.query.check.CheckStandardSpareVO;
|
|
|
import com.platform.dao.vo.query.check.CheckStandardVO;
|
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
@@ -60,6 +64,7 @@ import java.io.IOException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
@@ -82,6 +87,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
private CheckStandardSpareService spareService;
|
|
|
private CheckJobMapper checkJobMapper;
|
|
|
private PartInfoService partInfoService;
|
|
|
+ private CheckStandardSpareMapper checkStandardSpareMapper;
|
|
|
private final SysFileMapper sysFileMapper;
|
|
|
|
|
|
private final SysUserMapper sysUserMapper;
|
|
@@ -593,14 +599,14 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void packageSbInfoAndCheckStandard(SbInfo sbInfo,ExportCheckStandardVO vo,String sbId,CheckStandard checkStandard ) {
|
|
|
- if (sbId == null) {
|
|
|
- sbInfo.setNo(vo.getSbNo());
|
|
|
- sbInfo = sbInfoMapper.selectOne(sbInfo);
|
|
|
- if (sbInfo==null){
|
|
|
- throw new BusinessException("未找到设备编号为"+vo.getSbNo()+"的编号!");
|
|
|
- }
|
|
|
- }
|
|
|
+ private void packageSbInfoAndCheckStandard(SbInfo sbInfo,ExportCheckStandardVO2 vo,String sbId,CheckStandard checkStandard ) {
|
|
|
+// if (sbId == null) {
|
|
|
+// sbInfo.setNo(vo.getSbNo());
|
|
|
+// sbInfo = sbInfoMapper.selectOne(sbInfo);
|
|
|
+// if (sbInfo==null){
|
|
|
+// throw new BusinessException("未找到设备编号为"+vo.getSbNo()+"的编号!");
|
|
|
+// }
|
|
|
+// }
|
|
|
// if (vo.getSbLevel().trim().equals("A级")){
|
|
|
// sbInfo.setLevel(1);
|
|
|
// }else if (vo.getSbLevel().trim().equals("B级")){
|
|
@@ -608,15 +614,28 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
// }else if (vo.getSbLevel().trim().equals("C级")){
|
|
|
// sbInfo.setLevel(3);
|
|
|
// }
|
|
|
- sbInfo.setLevel(vo.getSbLevel());
|
|
|
- SysUser user = new SysUser();
|
|
|
- user.setRealName(vo.getRepairUserName());
|
|
|
- user = sysUserMapper.selectOne(user);
|
|
|
- if (user==null){
|
|
|
- throw new BusinessException("未找到名为为"+vo.getRepairUserName()+"的维修负责人!");
|
|
|
+// sbInfo.setLevel(vo.getSbLevel());
|
|
|
+// SysUser user = new SysUser();
|
|
|
+// user.setRealName(vo.getRepairUserName());
|
|
|
+// user = sysUserMapper.selectOne(user);
|
|
|
+// if (user==null){
|
|
|
+// throw new BusinessException("未找到名为为"+vo.getRepairUserName()+"的维修负责人!");
|
|
|
+// }
|
|
|
+// sbInfo.setRepairUser(user.getUserId());
|
|
|
+ if ("使用人".equals(vo.getCheckUserType().trim())){
|
|
|
+ checkStandard.setCheckUserType(1);
|
|
|
+ }else if ("维修人".equals(vo.getCheckUserType())){
|
|
|
+ checkStandard.setCheckUserType(2);
|
|
|
+ }else if ("厂家".equals(vo.getCheckUserType())){
|
|
|
+ checkStandard.setCheckUserType(3);
|
|
|
}
|
|
|
- sbInfo.setRepairUser(user.getUserId());
|
|
|
-
|
|
|
+ if (StringUtils.isNotBlank(vo.getLastDate())) {
|
|
|
+ checkStandard.setLastDate(LocalDate.parse(vo.getLastDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(vo.getNextDate())) {
|
|
|
+ checkStandard.setNextDate(LocalDate.parse(vo.getNextDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+ }
|
|
|
+ checkStandard.setPeriodType(DictCache.getValueByLabel("PERIOD_TYPE",vo.getPeriodType()));
|
|
|
checkStandard.setCreatedTime(LocalDateTime.now());
|
|
|
checkStandard.setCheckUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
checkStandard.setUpdateTime(LocalDateTime.now());
|
|
@@ -625,8 +644,9 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
checkStandard.setNo(vo.getNo());
|
|
|
checkStandard.setRequirement(vo.getRequirement());
|
|
|
checkStandard.setRemark(vo.getRemark());
|
|
|
- checkStandard.setPeriod(vo.getPeriod());
|
|
|
- checkStandard.setPeriodType(vo.getPeriodType());
|
|
|
+ checkStandard.setPeriod(Integer.parseInt(vo.getPeriod()));
|
|
|
+
|
|
|
+// checkStandard.setPeriodType(vo.getPeriodType());
|
|
|
checkStandard.setStandardHours(vo.getStandardHours());
|
|
|
|
|
|
if (checkStandard.getCheckUserType() == 1) {
|
|
@@ -648,33 +668,56 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
sb.append(standard.getId()).append(",");
|
|
|
}
|
|
|
String idStr = sb.toString();
|
|
|
- List<ExportCheckStandardVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO.class, 0);
|
|
|
+// List<CheckStandard> list = CustomExcelImportUtil.importCheckStandardList(file.getInputStream());
|
|
|
+ List<ExportCheckStandardVO2> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO2.class, 1);
|
|
|
String sbId=null;
|
|
|
SbInfo sbInfo = new SbInfo();
|
|
|
- CheckStandard checkStandard = new CheckStandard();
|
|
|
- for (ExportCheckStandardVO vo:list){
|
|
|
+ CheckStandard checkStandard ;
|
|
|
+ List<CheckStandard> updates = new ArrayList<>();
|
|
|
+ List<CheckStandard> adds = new ArrayList<>();
|
|
|
+ List<CheckStandard> deletes = new ArrayList<>();
|
|
|
+ for (ExportCheckStandardVO2 vo:list){
|
|
|
+ checkStandard = new CheckStandard();
|
|
|
+ checkStandard.setId(vo.getId());
|
|
|
if (StringUtils.isNotBlank(vo.getId()) && idStr.contains(vo.getId())){
|
|
|
if (StringUtils.isNotBlank(vo.getNo())){
|
|
|
+
|
|
|
//修改
|
|
|
+
|
|
|
packageSbInfoAndCheckStandard(sbInfo,vo,sbId,checkStandard);
|
|
|
- sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
- mapper.updateByPrimaryKey(checkStandard);
|
|
|
+ updates.add(checkStandard);
|
|
|
+// sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
+// mapper.updateByPrimaryKey(checkStandard);
|
|
|
}
|
|
|
else{
|
|
|
//no为空,删除
|
|
|
- CheckStandard standard = new CheckStandard();
|
|
|
- standard.setId(vo.getId());
|
|
|
- mapper.delete(standard);
|
|
|
+ checkStandard.setId(vo.getId());
|
|
|
+ deletes.add(checkStandard);
|
|
|
+// mapper.delete(standard);
|
|
|
}
|
|
|
|
|
|
- }else if (StringUtils.isNotBlank(vo.getId()) && !idStr.contains(vo.getId())){
|
|
|
+ }else if (StringUtils.isNotBlank(vo.getSbNo()) && StringUtils.isBlank(vo.getId())){
|
|
|
//新增
|
|
|
+
|
|
|
packageSbInfoAndCheckStandard(sbInfo,vo,sbId,checkStandard);
|
|
|
- mapper.insert(checkStandard);
|
|
|
+ adds.add(checkStandard);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
+ if (adds.size()>0){
|
|
|
+ mapper.insertListforComplex(adds);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (updates.size()>0){
|
|
|
+ mapper.updateBatch(updates);
|
|
|
+ }
|
|
|
+ if (deletes.size()>0){
|
|
|
+ //先删除外键表数据
|
|
|
+ checkStandardSpareMapper.deleteBatch(deletes);
|
|
|
+ mapper.deleteBatch(deletes);
|
|
|
+ }
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|