|
@@ -1,4 +1,5 @@
|
|
|
package com.platform.service.check.impl;
|
|
|
+
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
@@ -50,6 +51,7 @@ import com.platform.service.check.CheckStandardSpareService;
|
|
|
import com.platform.service.event.WorkplaceBacklogEvent;
|
|
|
import com.platform.service.part.PartInfoService;
|
|
|
import com.platform.service.util.SysFileUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
@@ -79,6 +81,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@AllArgsConstructor
|
|
|
@Service("checkStandardService")
|
|
|
+@Slf4j
|
|
|
public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMapper, CheckStandard, CheckStandardDTO> implements CheckStandardService {
|
|
|
private CheckStandardParamService paramService;
|
|
|
private CheckProjectStandardRelationMapper relationMapper;
|
|
@@ -164,19 +167,19 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public CheckStandard saveModelByDTO(CheckStandardDTO model) {
|
|
|
- if(model.getType() == null){
|
|
|
+ if (model.getType() == null) {
|
|
|
model.setType(CheckStandardTypeEnum.POLLING.getValue());
|
|
|
}
|
|
|
- if(model.getEnable() == null){
|
|
|
+ if (model.getEnable() == null) {
|
|
|
model.setEnable(1);
|
|
|
}
|
|
|
// 设置编码
|
|
|
Weekend<CheckStandard> weekend = new Weekend<>(CheckStandard.class);
|
|
|
weekend.weekendCriteria().andIsNotNull(CheckStandard::getId);
|
|
|
String selectMaxNo = mapper.selectMaxNo();
|
|
|
- if(StringUtils.isBlank(selectMaxNo)){
|
|
|
+ if (StringUtils.isBlank(selectMaxNo)) {
|
|
|
model.setNo("00001");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
String newStr = selectMaxNo.replaceFirst("^0*", "");
|
|
|
int count = Integer.valueOf(newStr) + 1;
|
|
|
String str1 = String.format("%05d", count);
|
|
@@ -208,8 +211,8 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
System.out.println(newStr);
|
|
|
}
|
|
|
|
|
|
- public String setNo(int no){
|
|
|
- return String.format("%05d", no);
|
|
|
+ public String setNo(int no) {
|
|
|
+ return String.format("%05d", no);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -223,10 +226,10 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
Weekend<CheckStandardSpare> detailWeekend = new Weekend<>(CheckStandardSpare.class);
|
|
|
List<String> ids = detailList.stream().map(CheckStandardSpareDTO::getId).collect(Collectors.toList());
|
|
|
ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(ids) && ids.size()>0) {
|
|
|
+ if (!CollectionUtils.isEmpty(ids) && ids.size() > 0) {
|
|
|
detailWeekend.weekendCriteria().andNotIn(CheckStandardSpare::getId, ids);
|
|
|
spareService.deleteByExample(detailWeekend);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 全部刪除
|
|
|
detailWeekend.weekendCriteria().andEqualTo(CheckStandardSpare::getCheckId, model.getId());
|
|
|
spareService.deleteByExample(detailWeekend);
|
|
@@ -235,27 +238,28 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
List<CheckStandardSpare> updateDetailList = new ArrayList<CheckStandardSpare>();
|
|
|
List<CheckStandardSpare> addDetailList = new ArrayList<CheckStandardSpare>();
|
|
|
|
|
|
- for(CheckStandardSpareDTO detail:detailList) {
|
|
|
- if(ObjectUtil.isNull(detail.getId())){
|
|
|
+ for (CheckStandardSpareDTO detail : detailList) {
|
|
|
+ if (ObjectUtil.isNull(detail.getId())) {
|
|
|
detail.setCheckId(model.getId());
|
|
|
CheckStandardSpare realDetail = new CheckStandardSpare();
|
|
|
realDetail = BeanConverterUtil.copyObjectProperties(detail, CheckStandardSpare.class);
|
|
|
realDetail.setId(IdGeneratorUtils.getObjectId());
|
|
|
realDetail.setCheckId(model.getId());
|
|
|
addDetailList.add(realDetail);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Weekend<CheckStandardSpare> weekend = new Weekend<>(CheckStandardSpare.class);
|
|
|
weekend.weekendCriteria().andEqualTo(CheckStandardSpare::getId, detail.getId());
|
|
|
CheckStandardSpare realDetail = spareService.selectOneByExample(weekend);
|
|
|
realDetail.setNum(detail.getNum());
|
|
|
updateDetailList.add(realDetail);
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
+ ;
|
|
|
|
|
|
- if(!CollectionUtils.isEmpty(addDetailList)){
|
|
|
+ if (!CollectionUtils.isEmpty(addDetailList)) {
|
|
|
spareService.insertListforComplex(addDetailList);
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(updateDetailList)){
|
|
|
+ if (!CollectionUtils.isEmpty(updateDetailList)) {
|
|
|
spareService.updateBatch(updateDetailList);
|
|
|
}
|
|
|
this.saveFile(model);
|
|
@@ -273,7 +277,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.CHECK_STANDARD_FILES.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
sysFileMapper.deleteByExample(weekend);
|
|
|
- List<SysFile> list = SysFileUtils.changeFileList(model.getCheckFileList(), model.getId(), SysFileTypeEnum.CHECK_STANDARD_FILES.getValue());
|
|
|
+ List<SysFile> list = SysFileUtils.changeFileList(model.getCheckFileList(), model.getId(), SysFileTypeEnum.CHECK_STANDARD_FILES.getValue());
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
sysFileMapper.insertListforComplex(list);
|
|
|
}
|
|
@@ -285,7 +289,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.CHECK_STANDARD_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
sysFileMapper.deleteByExample(weekend);
|
|
|
- List<SysFile> list = SysFileUtils.changeFileList(model.getCheckImgList(), model.getId(), SysFileTypeEnum.CHECK_STANDARD_IMGS.getValue());
|
|
|
+ List<SysFile> list = SysFileUtils.changeFileList(model.getCheckImgList(), model.getId(), SysFileTypeEnum.CHECK_STANDARD_IMGS.getValue());
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
sysFileMapper.insertListforComplex(list);
|
|
|
}
|
|
@@ -300,7 +304,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
List<CheckStandardParam> paramList = paramMapper.selectByExample(weekend);
|
|
|
checkStandard.setParamList(paramList);*/
|
|
|
|
|
|
- if(checkStandard == null){
|
|
|
+ if (checkStandard == null) {
|
|
|
throw new BusinessException("保养标准已经删除,该任务无需执行,请删除该任务");
|
|
|
}
|
|
|
Weekend<SysFile> weekendFile = new Weekend<>(SysFile.class);
|
|
@@ -309,10 +313,10 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
List<SysFile> checkImgList = ListUtils.newArrayList();
|
|
|
List<SysFile> checkFileList = ListUtils.newArrayList();
|
|
|
sysFiles.forEach(item -> {
|
|
|
- if (item.getType().equals( SysFileTypeEnum.CHECK_STANDARD_IMGS.getValue())) {
|
|
|
+ if (item.getType().equals(SysFileTypeEnum.CHECK_STANDARD_IMGS.getValue())) {
|
|
|
checkImgList.add(item);
|
|
|
}
|
|
|
- if (item.getType().equals( SysFileTypeEnum.CHECK_STANDARD_FILES.getValue())) {
|
|
|
+ if (item.getType().equals(SysFileTypeEnum.CHECK_STANDARD_FILES.getValue())) {
|
|
|
checkFileList.add(item);
|
|
|
}
|
|
|
});
|
|
@@ -330,6 +334,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
* 设置时间直接生成任务
|
|
|
* 1:需要判断该日期之前是否有未完成的任务,如果有,则抛出提示,不能生成,直接提示去完成改任务即可
|
|
|
* 2:在当前日没有的任务,则直接生成,这个不会影响后期任务的生成。后期任务会根据这个来重新生成
|
|
|
+ *
|
|
|
* @param checkJobDTO
|
|
|
*/
|
|
|
@Override
|
|
@@ -340,7 +345,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
CheckJob checkJob = new CheckJob();
|
|
|
checkJob.setSbId(standard.getSbId());
|
|
|
checkJob.setStatus(CheckJobStatusEnum.NOT_EXECUTE.getValue());
|
|
|
- if(checkJobDTO.getStartTime() == null){
|
|
|
+ if (checkJobDTO.getStartTime() == null) {
|
|
|
// 计算计划开始时间和结束时间
|
|
|
calcTime(checkJob, currentDate, standard);
|
|
|
} else {
|
|
@@ -367,7 +372,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
|
|
|
/**
|
|
|
* 从一个设备复制保养内容,保养内容是关联到设备的,不会重复,所以不需要判断重复,而备件需要判断是否重复了
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 注意:保养是关联的部位,如果设备还没有部位,则同时新建部位。如果部位名称已经存在了,则不新增。
|
|
|
*
|
|
|
* @param model
|
|
@@ -391,15 +396,15 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
|
|
|
// 复制保养内容,刨除已经存在的:根据名称判断
|
|
|
int i = 1;
|
|
|
- for(CheckStandardVO copyCheckStandardVO:copyList){
|
|
|
+ for (CheckStandardVO copyCheckStandardVO : copyList) {
|
|
|
boolean find = false;
|
|
|
- for(CheckStandardVO checkStandardVO:list){
|
|
|
- if(copyCheckStandardVO.getName().equals(checkStandardVO.getName())){
|
|
|
+ for (CheckStandardVO checkStandardVO : list) {
|
|
|
+ if (copyCheckStandardVO.getName().equals(checkStandardVO.getName())) {
|
|
|
find = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(!find){
|
|
|
+ if (!find) {
|
|
|
CheckStandardVO checkStandardVO = copyCheckStandardVO;
|
|
|
checkStandardVO.setId(IdGeneratorUtils.getObjectId());
|
|
|
checkStandardVO.setSbId(model.getSbId());
|
|
@@ -408,9 +413,9 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
Weekend<CheckStandard> weekend = new Weekend<>(CheckStandard.class);
|
|
|
weekend.weekendCriteria().andIsNotNull(CheckStandard::getId);
|
|
|
String selectMaxNo = mapper.selectMaxNo();
|
|
|
- if(StringUtils.isBlank(selectMaxNo)){
|
|
|
+ if (StringUtils.isBlank(selectMaxNo)) {
|
|
|
checkStandardVO.setNo("00001");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
String newStr = selectMaxNo.replaceFirst("^0*", "");
|
|
|
int count = Integer.valueOf(newStr) + i++;
|
|
|
String str1 = String.format("%05d", count);
|
|
@@ -428,12 +433,12 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
PartInfoDTO copyDTO = new PartInfoDTO();
|
|
|
copyDTO.setSbId(model.getCopySbId());
|
|
|
List<PartInfo> copyPartList = partInfoService.getModelListByDTO(copyDTO);
|
|
|
- if(CollectionUtil.isNotEmpty(addList)){
|
|
|
- for(CheckStandardVO copyCheckStandardVO:addList){
|
|
|
- for(PartInfo copyPart:copyPartList){
|
|
|
- if(copyPart.getId().equals(copyCheckStandardVO.getPart())){
|
|
|
- for(PartInfo part:partList){
|
|
|
- if(part.getName().equals(copyPart.getName())){
|
|
|
+ if (CollectionUtil.isNotEmpty(addList)) {
|
|
|
+ for (CheckStandardVO copyCheckStandardVO : addList) {
|
|
|
+ for (PartInfo copyPart : copyPartList) {
|
|
|
+ if (copyPart.getId().equals(copyCheckStandardVO.getPart())) {
|
|
|
+ for (PartInfo part : partList) {
|
|
|
+ if (part.getName().equals(copyPart.getName())) {
|
|
|
copyCheckStandardVO.setPart(part.getId());
|
|
|
}
|
|
|
}
|
|
@@ -481,12 +486,12 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
WeekendCriteria<SbInfo, Object> weekendCriteria2 = weekend2.weekendCriteria();
|
|
|
weekendCriteria2.andEqualTo(SbInfo::getZbh, fileSbNo);
|
|
|
SbInfo sbInfo = sbInfoMapper.selectOneByExample(weekend2);
|
|
|
- if(sbInfo == null){
|
|
|
- Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
|
|
|
- WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
- weekendCriteria.andEqualTo(SbInfo::getNo, fileSbNo);
|
|
|
- sbInfo = sbInfoMapper.selectOneByExample(weekend);
|
|
|
- if(sbInfo == null){
|
|
|
+ if (sbInfo == null) {
|
|
|
+ Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
|
|
|
+ WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andEqualTo(SbInfo::getNo, fileSbNo);
|
|
|
+ sbInfo = sbInfoMapper.selectOneByExample(weekend);
|
|
|
+ if (sbInfo == null) {
|
|
|
throw new BusinessException("旧号查不到,新号也查不到,请确保编号正确" + ", 导入文件中的编号-" + fileSbNo);
|
|
|
}
|
|
|
}
|
|
@@ -501,24 +506,24 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
item.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
// 根据负责人类型查找用户,使用人员的名称查抄
|
|
|
boolean findSaveUser = false;
|
|
|
- if(item.getCheckUserType() == 1){
|
|
|
+ if (item.getCheckUserType() == 1) {
|
|
|
item.setSbId(sbInfo.getId());
|
|
|
item.setCheckUserId(sbInfo.getSaveUser());
|
|
|
}
|
|
|
- if(item.getCheckUserType() == 2 || item.getCheckUserType() == 3){// 设备的维修员
|
|
|
+ if (item.getCheckUserType() == 2 || item.getCheckUserType() == 3) {// 设备的维修员
|
|
|
item.setSbId(sbInfo.getId());
|
|
|
item.setCheckUserId(sbInfo.getRepairUser());
|
|
|
}
|
|
|
addItems.add(item);
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addItems)){
|
|
|
+ if (!CollectionUtils.isEmpty(addItems)) {
|
|
|
mapper.insertListforComplex(addItems);
|
|
|
}
|
|
|
}
|
|
|
- return "成功: " + file.getOriginalFilename()+ ";";
|
|
|
+ return "成功: " + file.getOriginalFilename() + ";";
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println("file.getOriginalFilename():" + file.getOriginalFilename() );
|
|
|
- return ("失败:" + file.getOriginalFilename() + ":"+ e.getMessage()+ ";");
|
|
|
+ System.out.println("file.getOriginalFilename():" + file.getOriginalFilename());
|
|
|
+ return ("失败:" + file.getOriginalFilename() + ":" + e.getMessage() + ";");
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -531,14 +536,14 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
try {
|
|
|
List<CheckStandard> items = CustomExcelImportUtil.importCheckStandardListByUpdate(file.getInputStream());
|
|
|
if (!CollectionUtils.isEmpty(items)) {
|
|
|
- if(!CollectionUtils.isEmpty(items)){
|
|
|
+ if (!CollectionUtils.isEmpty(items)) {
|
|
|
mapper.updateBatch(items);
|
|
|
}
|
|
|
}
|
|
|
- return "成功: " + file.getOriginalFilename()+ ";";
|
|
|
+ return "成功: " + file.getOriginalFilename() + ";";
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println("file.getOriginalFilename():" + file.getOriginalFilename() );
|
|
|
- return ("失败:" + file.getOriginalFilename() + ":"+ e.getMessage()+ ";");
|
|
|
+ System.out.println("file.getOriginalFilename():" + file.getOriginalFilename());
|
|
|
+ return ("失败:" + file.getOriginalFilename() + ":" + e.getMessage() + ";");
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -557,12 +562,12 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
WeekendCriteria<SbInfo, Object> weekendCriteria2 = weekend2.weekendCriteria();
|
|
|
weekendCriteria2.andEqualTo(SbInfo::getZbh, fileSbNo);
|
|
|
SbInfo sbInfo = sbInfoMapper.selectOneByExample(weekend2);
|
|
|
- if(sbInfo == null){
|
|
|
+ if (sbInfo == null) {
|
|
|
Weekend<SbInfo> weekend = new Weekend<>(SbInfo.class);
|
|
|
WeekendCriteria<SbInfo, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
weekendCriteria.andEqualTo(SbInfo::getNo, fileSbNo);
|
|
|
sbInfo = sbInfoMapper.selectOneByExample(weekend);
|
|
|
- if(sbInfo == null){
|
|
|
+ if (sbInfo == null) {
|
|
|
throw new BusinessException("旧号查不到,新号也查不到,请确保编号正确" + ", 导入文件中的编号-" + fileSbNo);
|
|
|
}
|
|
|
}
|
|
@@ -577,57 +582,37 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
item.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
// 根据负责人类型查找用户,使用人员的名称查抄
|
|
|
boolean findSaveUser = false;
|
|
|
- if(item.getCheckUserType() == 1){
|
|
|
+ if (item.getCheckUserType() == 1) {
|
|
|
item.setSbId(sbInfo.getId());
|
|
|
item.setCheckUserId(sbInfo.getSaveUser());
|
|
|
}
|
|
|
- if(item.getCheckUserType() == 2 || item.getCheckUserType() == 3){// 设备的维修员
|
|
|
+ if (item.getCheckUserType() == 2 || item.getCheckUserType() == 3) {// 设备的维修员
|
|
|
item.setSbId(sbInfo.getId());
|
|
|
item.setCheckUserId(sbInfo.getRepairUser());
|
|
|
}
|
|
|
addItems.add(item);
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addItems)){
|
|
|
+ if (!CollectionUtils.isEmpty(addItems)) {
|
|
|
mapper.insertListforComplex(addItems);
|
|
|
}
|
|
|
}
|
|
|
- return "成功: " + file.getOriginalFilename()+ ";";
|
|
|
+ return "成功: " + file.getOriginalFilename() + ";";
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println("file.getOriginalFilename():" + file.getOriginalFilename() );
|
|
|
- return ("失败:" + file.getOriginalFilename() + ":"+ e.getMessage()+ ";");
|
|
|
+ System.out.println("file.getOriginalFilename():" + file.getOriginalFilename());
|
|
|
+ return ("失败:" + file.getOriginalFilename() + ":" + e.getMessage() + ";");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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级")){
|
|
|
-// sbInfo.setLevel(2);
|
|
|
-// }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.setRepairUser(user.getUserId());
|
|
|
- if ("使用人".equals(vo.getCheckUserType().trim())){
|
|
|
+ private void packageSbInfoAndCheckStandard(SbInfo sbInfo, ExportCheckStandardVO2 vo, CheckStandard checkStandard) {
|
|
|
+ if ("使用人".equals(vo.getCheckUserType().trim())) {
|
|
|
checkStandard.setCheckUserType(1);
|
|
|
- }else if ("维修人".equals(vo.getCheckUserType())){
|
|
|
+ } else if ("维修人".equals(vo.getCheckUserType())) {
|
|
|
checkStandard.setCheckUserType(2);
|
|
|
- }else if ("厂家".equals(vo.getCheckUserType())){
|
|
|
+ } else if ("厂家".equals(vo.getCheckUserType())) {
|
|
|
checkStandard.setCheckUserType(3);
|
|
|
+ }else{
|
|
|
+ checkStandard.setCheckUserType(2);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(vo.getLastDate())) {
|
|
|
checkStandard.setLastDate(LocalDate.parse(vo.getLastDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
@@ -635,7 +620,7 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
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.setPeriodType(DictCache.getValueByLabel("PERIOD_TYPE", vo.getPeriodType()));
|
|
|
checkStandard.setCreatedTime(LocalDateTime.now());
|
|
|
checkStandard.setCheckUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
checkStandard.setUpdateTime(LocalDateTime.now());
|
|
@@ -659,75 +644,113 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 一次只能导入一个设备的
|
|
|
+ * 1:可以修改:id存在
|
|
|
+ * 2:可以删除:数据库查询出来的不在excel里面了
|
|
|
+ * 3:可以新增:id =null
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
@Override
|
|
|
- public String importList(MultipartFile file) throws Exception{
|
|
|
+ public String importList(MultipartFile file) throws Exception {
|
|
|
+ List<ExportCheckStandardVO2> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO2.class, 1);
|
|
|
+
|
|
|
+ List<String> sbNoList = list.stream().map(item -> item.getSbNo()).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(sbNoList) && sbNoList.size() > 1) {
|
|
|
+ sbNoList = sbNoList.stream().distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(sbNoList) && sbNoList.size() > 1) {
|
|
|
+ throw new BusinessException("一次只能导致一个设备的标准");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//查询所有的保养任务标准id
|
|
|
List<CheckStandard> standards = mapper.select(null);
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
- for (CheckStandard standard:standards){
|
|
|
+ for (CheckStandard standard : standards) {
|
|
|
sb.append(standard.getId()).append(",");
|
|
|
}
|
|
|
String idStr = sb.toString();
|
|
|
// List<CheckStandard> list = CustomExcelImportUtil.importCheckStandardList(file.getInputStream());
|
|
|
- List<ExportCheckStandardVO2> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO2.class, 1);
|
|
|
- String sbId=null;
|
|
|
+ String sbId = null;
|
|
|
SbInfo sbInfo = new SbInfo();
|
|
|
- CheckStandard checkStandard ;
|
|
|
+ CheckStandard checkStandard;
|
|
|
List<CheckStandard> updates = new ArrayList<>();
|
|
|
List<CheckStandard> adds = new ArrayList<>();
|
|
|
List<CheckStandard> deletes = new ArrayList<>();
|
|
|
- for (ExportCheckStandardVO2 vo:list){
|
|
|
+ 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);
|
|
|
- updates.add(checkStandard);
|
|
|
-// sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
-// mapper.updateByPrimaryKey(checkStandard);
|
|
|
- }
|
|
|
- else{
|
|
|
- //no为空,删除
|
|
|
- checkStandard.setId(vo.getId());
|
|
|
- deletes.add(checkStandard);
|
|
|
-// mapper.delete(standard);
|
|
|
- }
|
|
|
-
|
|
|
- }else if (StringUtils.isNotBlank(vo.getSbNo()) && StringUtils.isBlank(vo.getId())){
|
|
|
+ checkStandard.setPeriodType(DictCache.getValueByLabel("PERIOD_TYPE", vo.getPeriodType()));
|
|
|
+ if (StringUtils.isNotBlank(vo.getId())) {
|
|
|
+ //修改
|
|
|
+ checkStandard.setId(vo.getId());
|
|
|
+ packageSbInfoAndCheckStandard(sbInfo, vo, checkStandard);
|
|
|
+ updates.add(checkStandard);
|
|
|
+ } else {
|
|
|
//新增
|
|
|
-
|
|
|
- packageSbInfoAndCheckStandard(sbInfo,vo,sbId,checkStandard);
|
|
|
+ packageSbInfoAndCheckStandard(sbInfo, vo, checkStandard);
|
|
|
+ checkStandard.setId(IdGeneratorUtils.getObjectId());
|
|
|
adds.add(checkStandard);
|
|
|
}
|
|
|
+ }
|
|
|
+ for (CheckStandard standard : standards) {
|
|
|
+ boolean find = false;
|
|
|
+ for (ExportCheckStandardVO2 vo : list) {
|
|
|
+ if (standard.getId().equals(vo.getId())) {
|
|
|
+ find = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!find) {
|
|
|
+ CheckStandard del = new CheckStandard();
|
|
|
+ del.setId(standard.getId());
|
|
|
+ deletes.add(del);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ for (ExportCheckStandardVO2 vo : list) {
|
|
|
+ if (vo.getPeriodType().trim().equals("天")) {
|
|
|
+ CheckStandard del = new CheckStandard();
|
|
|
+ del.setId(vo.getId());
|
|
|
+ deletes.add(del);
|
|
|
}
|
|
|
- if (adds.size()>0){
|
|
|
+ }
|
|
|
+
|
|
|
+ if (adds.size() > 0) {
|
|
|
+ log.info("新增:" + adds.size());
|
|
|
mapper.insertListforComplex(adds);
|
|
|
}
|
|
|
|
|
|
- if (updates.size()>0){
|
|
|
+ if (updates.size() > 0) {
|
|
|
+ log.info("修改:" + updates.size());
|
|
|
mapper.updateBatch(updates);
|
|
|
}
|
|
|
- if (deletes.size()>0){
|
|
|
+ if (deletes.size() > 0) {
|
|
|
+ log.info("删除:" + deletes.size());
|
|
|
//先删除外键表数据
|
|
|
checkStandardSpareMapper.deleteBatch(deletes);
|
|
|
mapper.deleteBatch(deletes);
|
|
|
- }
|
|
|
+ for (CheckStandard standard : deletes) {
|
|
|
+ CheckJob checkJob = new CheckJob();
|
|
|
+ checkJob.setStandardId(standard.getId());
|
|
|
+ checkJob.setRemark("标准被删除,无需执行任务");
|
|
|
+ // 删除已经生成的任务数据:变成完成(执行中的2,未完成的1)
|
|
|
+ checkJobMapper.updateBatchByDelStandard(checkJob);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询备件预警
|
|
|
+ *
|
|
|
* @param month 距离当前时间的几个月
|
|
|
- * @param type 类型:1点检,2保养
|
|
|
+ * @param type 类型:1点检,2保养
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -742,25 +765,25 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
LocalDate afterSixMonth = DateUtils.plus(now, month, ChronoUnit.MONTHS);
|
|
|
Weekend<CheckJob> weekend = new Weekend<>(CheckJob.class);
|
|
|
weekend.weekendCriteria().andNotEqualTo(CheckJob::getStatus, CheckJobStatusEnum.FINISHED.getValue())
|
|
|
- .andBetween(CheckJob::getStartTime, now, afterSixMonth);
|
|
|
+ .andBetween(CheckJob::getStartTime, now, afterSixMonth);
|
|
|
List<CheckJob> checkJobs = checkJobMapper.selectByExample(weekend);
|
|
|
|
|
|
// 获取未执行的标准id,不能用stream获取id列表,会覆盖重复的标准id(不会重复,因为一个标准对应一个任务。)
|
|
|
- if(CollectionUtil.isNotEmpty(checkJobs)){
|
|
|
+ if (CollectionUtil.isNotEmpty(checkJobs)) {
|
|
|
List<String> ids = checkJobs.stream().map(CheckJob::getStandardId).collect(Collectors.toList());
|
|
|
ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(ids) && ids.size()>0) {
|
|
|
+ if (!CollectionUtils.isEmpty(ids) && ids.size() > 0) {
|
|
|
CheckStandardSpareDTO dto = new CheckStandardSpareDTO();
|
|
|
dto.setCheckIds(ids);
|
|
|
List<CheckStandardSpareVO> voList = spareMapper.selectSpareWarn(dto);
|
|
|
List<CheckStandardSpareVO> warnList = new ArrayList<CheckStandardSpareVO>();
|
|
|
- if(CollectionUtil.isNotEmpty(voList)){
|
|
|
- for(CheckStandardSpareVO vo: voList){
|
|
|
- if(vo.getNum().compareTo(vo.getStoreNum())>0){
|
|
|
+ if (CollectionUtil.isNotEmpty(voList)) {
|
|
|
+ for (CheckStandardSpareVO vo : voList) {
|
|
|
+ if (vo.getNum().compareTo(vo.getStoreNum()) > 0) {
|
|
|
warnList.add(vo);
|
|
|
}
|
|
|
}
|
|
|
- if(CollectionUtil.isNotEmpty(warnList)){
|
|
|
+ if (CollectionUtil.isNotEmpty(warnList)) {
|
|
|
List<SysUser> users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.WXZG.getValue()}));
|
|
|
sendOverTimeNotice(month, users, warnList);
|
|
|
}
|
|
@@ -791,10 +814,10 @@ public class CheckStandardServiceImpl extends BaseServiceImpl<CheckStandardMappe
|
|
|
|
|
|
// 获取未执行的标准id,不能用stream获取id列表,会覆盖重复的标准id(不会重复,因为一个标准对应一个任务。)
|
|
|
List<CheckStandardSpareVO> voList = new ArrayList<CheckStandardSpareVO>();
|
|
|
- if(CollectionUtil.isNotEmpty(checkJobs)){
|
|
|
+ if (CollectionUtil.isNotEmpty(checkJobs)) {
|
|
|
List<String> ids = checkJobs.stream().map(CheckJob::getStandardId).collect(Collectors.toList());
|
|
|
ids = ids.stream().filter(item -> StringUtils.isNotBlank(item)).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(ids) && ids.size()>0) {
|
|
|
+ if (!CollectionUtils.isEmpty(ids) && ids.size() > 0) {
|
|
|
CheckStandardSpareDTO dto = new CheckStandardSpareDTO();
|
|
|
dto.setCheckIds(ids);
|
|
|
PageHelper.startPage(pageNum, pageSize);
|