|
@@ -20,6 +20,7 @@ import com.platform.dao.entity.maintain.MaintainStandardParam;
|
|
|
import com.platform.dao.entity.part.PartInfo;
|
|
|
import com.platform.dao.entity.repair.RepairApplicationForm;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
+import com.platform.dao.entity.sb.SbInspectionFill;
|
|
|
import com.platform.dao.entity.sb.SbType;
|
|
|
import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
|
|
|
import com.platform.dao.entity.store.InStoreDetail;
|
|
@@ -33,7 +34,9 @@ import com.platform.dao.mapper.sb.SbInfoMapper;
|
|
|
import com.platform.dao.mapper.upms.SysFileMapper;
|
|
|
import com.platform.dao.mapper.upms.SysUserMapper;
|
|
|
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.query.check.CheckStandardSpareVO;
|
|
|
import com.platform.dao.vo.query.check.CheckStandardVO;
|
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
@@ -43,6 +46,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 org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -52,6 +56,7 @@ import tk.mybatis.mapper.weekend.Weekend;
|
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
@@ -588,6 +593,94 @@ 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()+"的编号!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+// 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());
|
|
|
+
|
|
|
+ checkStandard.setCreatedTime(LocalDateTime.now());
|
|
|
+ checkStandard.setCheckUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ checkStandard.setUpdateTime(LocalDateTime.now());
|
|
|
+ checkStandard.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+
|
|
|
+ checkStandard.setNo(vo.getNo());
|
|
|
+ checkStandard.setRequirement(vo.getRequirement());
|
|
|
+ checkStandard.setRemark(vo.getRemark());
|
|
|
+ checkStandard.setPeriod(vo.getPeriod());
|
|
|
+ checkStandard.setPeriodType(vo.getPeriodType());
|
|
|
+ checkStandard.setStandardHours(vo.getStandardHours());
|
|
|
+
|
|
|
+ if (checkStandard.getCheckUserType() == 1) {
|
|
|
+ checkStandard.setSbId(sbInfo.getId());
|
|
|
+ checkStandard.setCheckUserId(sbInfo.getSaveUser());
|
|
|
+ }
|
|
|
+ if (checkStandard.getCheckUserType() == 2 || checkStandard.getCheckUserType() == 3) {// 设备的维修员
|
|
|
+ checkStandard.setSbId(sbInfo.getId());
|
|
|
+ checkStandard.setCheckUserId(sbInfo.getRepairUser());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String importList(MultipartFile file) throws Exception{
|
|
|
+ //查询所有的保养任务标准id
|
|
|
+ List<CheckStandard> standards = mapper.select(null);
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (CheckStandard standard:standards){
|
|
|
+ sb.append(standard.getId()).append(",");
|
|
|
+ }
|
|
|
+ String idStr = sb.toString();
|
|
|
+ List<ExportCheckStandardVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportCheckStandardVO.class, 0);
|
|
|
+ String sbId=null;
|
|
|
+ SbInfo sbInfo = new SbInfo();
|
|
|
+ CheckStandard checkStandard = new CheckStandard();
|
|
|
+ for (ExportCheckStandardVO vo:list){
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //no为空,删除
|
|
|
+ CheckStandard standard = new CheckStandard();
|
|
|
+ standard.setId(vo.getId());
|
|
|
+ mapper.delete(standard);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if (StringUtils.isNotBlank(vo.getId()) && !idStr.contains(vo.getId())){
|
|
|
+ //新增
|
|
|
+ packageSbInfoAndCheckStandard(sbInfo,vo,sbId,checkStandard);
|
|
|
+ mapper.insert(checkStandard);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询备件预警
|
|
|
* @param month 距离当前时间的几个月
|