From 53e7dce8d55487cbac64e4374ec9aa1b52a6c6ed Mon Sep 17 00:00:00 2001
From: SZH <szh_hello@163.com>
Date: Thu, 09 Mar 2023 21:16:43 +0800
Subject: [PATCH] 解决npe问题
---
equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/EquipmentInfoServiceImpl.java | 442 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 367 insertions(+), 75 deletions(-)
diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/EquipmentInfoServiceImpl.java b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/EquipmentInfoServiceImpl.java
index 6aab315..436069c 100644
--- a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/EquipmentInfoServiceImpl.java
+++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/EquipmentInfoServiceImpl.java
@@ -10,20 +10,37 @@
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
+import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.equipment.entity.*;
+import com.gkhy.safePlatform.equipment.enums.EquipmentLifeCycleEnum;
+import com.gkhy.safePlatform.equipment.enums.EquipmentRepairStatusEnum;
+import com.gkhy.safePlatform.equipment.enums.EquipmentResultCodes;
+import com.gkhy.safePlatform.equipment.enums.EquipmentStopStatusEnum;
+import com.gkhy.safePlatform.equipment.excepiton.EquipmentException;
import com.gkhy.safePlatform.equipment.model.dto.req.*;
import com.gkhy.safePlatform.equipment.model.dto.resp.EquipmentInfoDto;
+import com.gkhy.safePlatform.equipment.model.dto.resp.EquipmentInfoExcel;
import com.gkhy.safePlatform.equipment.repository.EquipmentInfoRepository;
+import com.gkhy.safePlatform.equipment.repository.EquipmentTypeMngRepository;
import com.gkhy.safePlatform.equipment.service.*;
+import com.gkhy.safePlatform.equipment.service.baseService.*;
+import com.gkhy.safePlatform.equipment.utils.DateUtils;
import com.gkhy.safePlatform.equipment.utils.QueryHelpPlus;
+import com.gkhy.safePlatform.equipment.utils.poihelper.ExcelLogs;
+import com.gkhy.safePlatform.equipment.utils.poihelper.ExcelUtil;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
import java.io.Serializable;
+import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
@@ -34,36 +51,48 @@
* @since 2022-07-19 14:02:50
*/
@Service("equipmentInfoService")
-public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoRepository, EquipmentInfo> implements EquipmentInfoService {
+public class EquipmentInfoServiceImpl implements EquipmentInfoService {
@Autowired
- private EquipmentInfoRepository equipmentInfoRepository;
+ private EquipmentInfoBaseService equipmentInfoBaseService;
@Autowired
- private EquipmentTakecareDetailService equipmentTakecareDetailService;
+ private EquipmentTakecareDetailBaseService equipmentTakecareDetailBaseService;
@Autowired
- private EquipmentTestDetailService equipmentTestDetailService;
+ private EquipmentTestDetailBaseService equipmentTestDetailBaseService;
@Autowired
- private EquipmentRepairDetailService equipmentRepairDetailService;
+ private EquipmentRepairDetailBaseService equipmentRepairDetailBaseService;
@Autowired
- private EquipmentTakecareStardardDetailService equipmentTakecareStardardDetailService;
+ private EquipmentTakecareStardardDetailBaseService equipmentTakecareStardardDetailBaseService;
@Autowired
- private EquipmentCheckStandardDetailService equipmentCheckStandardDetailService;
+ private EquipmentCheckStandardDetailBaseService equipmentCheckStandardDetailBaseService;
@DubboReference(check = false)
private AccountDepartmentService accountDepartmentService;
+ @Autowired
+ private EquipmentTypeMngRepository equipmentTypeMngRepository;
+
+ @Autowired
+ public HttpServletResponse response;
+
@Override
public ResultVO queryAll(PageQuery<EquipmentInfoQueryCriteria> pageQuery) {
+ if(pageQuery.getSearchParams().getInfoType() == null){
+ return new ResultVO<>(ResultCodes.CLIENT_PARAM_ILLEGAL,"缺少infoType");
+ }
+
+ PageUtils.checkCheck(pageQuery);
+
Long pageIndex = pageQuery.getPageIndex();
Long pageSize = pageQuery.getPageSize();
IPage<EquipmentInfo> page = new Page<>(pageIndex, pageSize);
- page = baseMapper.selectPage(page,
+ page = equipmentInfoBaseService.selectPage(page,
QueryHelpPlus.getPredicate(EquipmentInfo.class, pageQuery.getSearchParams()));
List<EquipmentInfoDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), EquipmentInfoDto.class);
@@ -73,15 +102,15 @@
EquipmentTakecareDetailQueryCriteria criteria = new EquipmentTakecareDetailQueryCriteria();
criteria.setEquipmentId(f.getId());
criteria.setInfoTpe(pageQuery.getSearchParams().getInfoType());
- List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailService.queryAll(criteria);
+ List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailBaseService.queryAll(criteria);
f.setTakecareDetailList(takecareDetailList);
//设备检测
EquipmentTestDetailQueryCriteria criteria1 = new EquipmentTestDetailQueryCriteria();
criteria1.setEquipmentId(f.getId());
criteria1.setInfoTpe(pageQuery.getSearchParams().getInfoType());
- List<EquipmentTestDetail> checkDetailList = equipmentTestDetailService.queryAll(criteria1);
- f.setCheckDetailList(checkDetailList);
+ List<EquipmentTestDetail> testDetailList = equipmentTestDetailBaseService.queryAll(criteria1);
+ f.setTestDetailList(testDetailList);
//设备检查 TODO
@@ -90,7 +119,7 @@
EquipmentRepairDetailQueryCriteria criteria2 = new EquipmentRepairDetailQueryCriteria();
criteria2.setEquipmentId(f.getId());
criteria2.setInfoTpe(pageQuery.getSearchParams().getInfoType());
- List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailService.queryAll(criteria2);
+ List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailBaseService.queryAll(criteria2);
f.setRepaireDetailList(repairDetailList);
@@ -101,7 +130,7 @@
collectDepIdSet.add(f.getLeadingDepartmentId());
collectDepIdSet.add(f.getLeadingPersonDepartmentId());
takecareDetailList.forEach(info->{collectDepIdSet.add(info.getLeadingPersonDepartmentId());});
- checkDetailList.forEach(info->{collectDepIdSet.add(info.getTestPersonDepartmentId());});
+ testDetailList.forEach(info->{collectDepIdSet.add(info.getTestPersonDepartmentId());});
repairDetailList.forEach(info->{collectDepIdSet.add(info.getRepairPersonDepartmentId());});
//获取部门名集合
@@ -112,7 +141,7 @@
f.setLeadingDepartmentName(depNameMap.get(f.getLeadingDepartmentId()));
f.setLeadingPersonDepartmentName(depNameMap.get(f.getLeadingPersonDepartmentId()));
takecareDetailList.forEach(info->{info.setLeadingPersonDepartmentName(depNameMap.get(info.getLeadingPersonDepartmentId()));});
- checkDetailList.forEach(info->{info.setTestPersonDepartmentName(depNameMap.get(info.getTestPersonDepartmentId()));});
+ testDetailList.forEach(info->{info.setTestPersonDepartmentName(depNameMap.get(info.getTestPersonDepartmentId()));});
repairDetailList.forEach(info->{info.setRepairPersonDepartmentName(depNameMap.get(info.getRepairPersonDepartmentId()));});
});
@@ -129,12 +158,12 @@
@Override
public List<EquipmentInfo> queryAll(EquipmentInfoQueryCriteria criteria) {
- return baseMapper.selectList(QueryHelpPlus.getPredicate(EquipmentInfo.class, criteria));
+ return equipmentInfoBaseService.queryAll(criteria);
}
@Override
public EquipmentInfoDto selectOne(Serializable id) {
- EquipmentInfo equipmentInfo = baseMapper.selectById(id);
+ EquipmentInfo equipmentInfo = equipmentInfoBaseService.getById(id);
if(equipmentInfo == null){
return null;
}
@@ -145,15 +174,15 @@
EquipmentTakecareDetailQueryCriteria criteria = new EquipmentTakecareDetailQueryCriteria();
criteria.setEquipmentId(infoDto.getId());
criteria.setInfoTpe(infoDto.getInfoType());
- List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailService.queryAll(criteria);
+ List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailBaseService.queryAll(criteria);
infoDto.setTakecareDetailList(takecareDetailList);
//设备检测
EquipmentTestDetailQueryCriteria criteria1 = new EquipmentTestDetailQueryCriteria();
criteria1.setEquipmentId(infoDto.getId());
criteria1.setInfoTpe(infoDto.getInfoType());
- List<EquipmentTestDetail> checkDetailList = equipmentTestDetailService.queryAll(criteria1);
- infoDto.setCheckDetailList(checkDetailList);
+ List<EquipmentTestDetail> testDetailList = equipmentTestDetailBaseService.queryAll(criteria1);
+ infoDto.setTestDetailList(testDetailList);
//设备检查 TODO
@@ -162,21 +191,21 @@
EquipmentRepairDetailQueryCriteria criteria2 = new EquipmentRepairDetailQueryCriteria();
criteria2.setEquipmentId(infoDto.getId());
criteria2.setInfoTpe(infoDto.getInfoType());
- List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailService.queryAll(criteria2);
+ List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailBaseService.queryAll(criteria2);
infoDto.setRepaireDetailList(repairDetailList);
//检查标准
EquipmentCheckStandardDetailQueryCriteria criteria3 = new EquipmentCheckStandardDetailQueryCriteria();
criteria3.setEquipmentId(infoDto.getId());
criteria3.setInfoTpe(infoDto.getInfoType());
- List<EquipmentCheckStandardDetail> checkStandardDetailList = equipmentCheckStandardDetailService.queryAll(criteria3);
+ List<EquipmentCheckStandardDetail> checkStandardDetailList = equipmentCheckStandardDetailBaseService.queryAll(criteria3);
infoDto.setCheckStandardeDetailList(checkStandardDetailList);
//保养标准
EquipmentTakecareStardardDetailQueryCriteria criteria4 = new EquipmentTakecareStardardDetailQueryCriteria();
criteria4.setEquipmentId(infoDto.getId());
criteria4.setInfoTpe(infoDto.getInfoType());
- List<EquipmentTakecareStardardDetail> takecareStardardDetailList = equipmentTakecareStardardDetailService.queryAll(criteria4);
+ List<EquipmentTakecareStardardDetail> takecareStardardDetailList = equipmentTakecareStardardDetailBaseService.queryAll(criteria4);
infoDto.setTakecareStardardeDetailList(takecareStardardDetailList);
@@ -187,7 +216,7 @@
collectDepIdSet.add(infoDto.getLeadingDepartmentId());
collectDepIdSet.add(infoDto.getLeadingPersonDepartmentId());
takecareDetailList.forEach(info->{collectDepIdSet.add(info.getLeadingPersonDepartmentId());});
- checkDetailList.forEach(info->{collectDepIdSet.add(info.getTestPersonDepartmentId());});
+ testDetailList.forEach(info->{collectDepIdSet.add(info.getTestPersonDepartmentId());});
repairDetailList.forEach(info->{collectDepIdSet.add(info.getRepairPersonDepartmentId());});
//获取部门名集合
@@ -198,48 +227,89 @@
infoDto.setLeadingDepartmentName(depNameMap.get(infoDto.getLeadingDepartmentId()));
infoDto.setLeadingPersonDepartmentName(depNameMap.get(infoDto.getLeadingPersonDepartmentId()));
takecareDetailList.forEach(info->{info.setLeadingPersonDepartmentName(depNameMap.get(info.getLeadingPersonDepartmentId()));});
- checkDetailList.forEach(info->{info.setTestPersonDepartmentName(depNameMap.get(info.getTestPersonDepartmentId()));});
+ testDetailList.forEach(info->{info.setTestPersonDepartmentName(depNameMap.get(info.getTestPersonDepartmentId()));});
repairDetailList.forEach(info->{info.setRepairPersonDepartmentName(depNameMap.get(info.getRepairPersonDepartmentId()));});
+
+ EquipmentTypeMng typeMng = equipmentTypeMngRepository.selectOne(new QueryWrapper<EquipmentTypeMng>().eq("id",infoDto.getEquipmentTypeId()));
+ if(typeMng != null){
+ infoDto.setEquipmentTypeName(typeMng.getTypeName());
+ }
return infoDto;
}
@Override
public void addOrUpdate(EquipmentInfoSaveOrUpdate infoDto) {
+
+ // 验证枚举
+ checkEnum(infoDto);
+
+ if(infoDto.getInfoType() == null || infoDto.getEquipmentTypeId() == null){
+ throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL);
+ }
+ if(infoDto.getInfoType() == 3){
+ throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL);
+ }
+
EquipmentInfo equipmentInfo = BeanCopyUtils.copyBean(infoDto, EquipmentInfo.class);
//保存主数据
if (infoDto.getId() == null) { //新增
- this.save(equipmentInfo);
+ equipmentInfoBaseService.save(equipmentInfo);
} else {
- this.update(equipmentInfo,new UpdateWrapper<EquipmentInfo>().eq("id",infoDto.getId()));
+ equipmentInfoBaseService.update(equipmentInfo,new UpdateWrapper<EquipmentInfo>().eq("id",infoDto.getId()));
}
//保存设备保养
List<EquipmentTakecareDetail> takecareDetailList = infoDto.getTakecareDetailList();
- takecareDetailList.forEach(f->{
- f.setEquipmentId(equipmentInfo.getId());
- f.setInfoTpe(equipmentInfo.getInfoType());
- });
- equipmentTakecareDetailService.saveOrUpdateBatch(takecareDetailList);
- if(StringUtils.hasText(infoDto.getDelTakecareDetails())){
- List<Long> idList = Arrays.stream(infoDto.getDelTakecareDetails().split(",")).map(s-> Long.parseLong(s.trim()))
- .collect(Collectors.toList());
- equipmentTakecareDetailService.removeByIds(idList);
+ if(takecareDetailList != null && !takecareDetailList.isEmpty()){
+ takecareDetailList.forEach(f->{
+ f.setEquipmentId(equipmentInfo.getId());
+ f.setInfoTpe(equipmentInfo.getInfoType());
+ });
+ equipmentTakecareDetailBaseService.saveOrUpdateBatch(takecareDetailList);
+ }
+ if(infoDto.getTakecareDetailList() != null){
+ if(StringUtils.hasText(infoDto.getDelTakecareDetails())){
+ List<Long> idList = Arrays.stream(infoDto.getDelTakecareDetails().split(",")).map(s-> Long.parseLong(s.trim()))
+ .collect(Collectors.toList());
+
+ if(idList != null && !idList.isEmpty()){
+ List<EquipmentTakecareDetail> delList = new ArrayList<>();
+ idList.forEach(f->{
+ EquipmentTakecareDetail info = new EquipmentTakecareDetail();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ equipmentTakecareDetailBaseService.updateBatchById(delList);
+ }
+ }
}
//保存设备检测
List<EquipmentTestDetail> testDetailList = infoDto.getTestDetailList();
- testDetailList.forEach(f->{
- f.setEquipmentId(equipmentInfo.getId());
- f.setInfoTpe(equipmentInfo.getInfoType());
- });
- equipmentTestDetailService.saveOrUpdateBatch(testDetailList);
- if(StringUtils.hasText(infoDto.getDelTestDetails())){
- List<Long> idList = Arrays.stream(infoDto.getDelTestDetails().split(",")).map(s-> Long.parseLong(s.trim()))
- .collect(Collectors.toList());
- equipmentTestDetailService.removeByIds(idList);
+ if(testDetailList != null && !testDetailList.isEmpty()){
+ testDetailList.forEach(f->{
+ f.setEquipmentId(equipmentInfo.getId());
+ f.setInfoTpe(equipmentInfo.getInfoType());
+ });
+ equipmentTestDetailBaseService.saveOrUpdateBatch(testDetailList);
+ }
+ if(infoDto.getDelTestDetails() != null && !infoDto.getDelTestDetails().isEmpty()){
+ if(StringUtils.hasText(infoDto.getDelTestDetails())){
+ List<Long> idList = Arrays.stream(infoDto.getDelTestDetails().split(",")).map(s-> Long.parseLong(s.trim()))
+ .collect(Collectors.toList());
+ List<EquipmentTestDetail> delList = new ArrayList<>();
+ idList.forEach(f->{
+ EquipmentTestDetail info = new EquipmentTestDetail();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ equipmentTestDetailBaseService.updateBatchById(delList);
+ }
}
//设备检查 TODO
@@ -247,43 +317,77 @@
//保存设备维修
List<EquipmentRepairDetail> repaireDetailList = infoDto.getRepaireDetailList();
- repaireDetailList.forEach(f->{
- f.setEquipmentId(equipmentInfo.getId());
- f.setInfoTpe(equipmentInfo.getInfoType());
- });
- equipmentRepairDetailService.saveOrUpdateBatch(repaireDetailList);
- if(StringUtils.hasText(infoDto.getDelRepaireDetails())){
- List<Long> idList = Arrays.stream(infoDto.getDelRepaireDetails().split(",")).map(s-> Long.parseLong(s.trim()))
- .collect(Collectors.toList());
- equipmentRepairDetailService.removeByIds(idList);
+ if(repaireDetailList != null && !repaireDetailList.isEmpty()){
+ repaireDetailList.forEach(f->{
+ f.setEquipmentId(equipmentInfo.getId());
+ f.setInfoTpe(equipmentInfo.getInfoType());
+ });
+ equipmentRepairDetailBaseService.saveOrUpdateBatch(repaireDetailList);
}
+ if(infoDto.getDelRepaireDetails() != null && !infoDto.getDelRepaireDetails().isEmpty()){
+ if(StringUtils.hasText(infoDto.getDelRepaireDetails())){
+ List<Long> idList = Arrays.stream(infoDto.getDelRepaireDetails().split(",")).map(s-> Long.parseLong(s.trim()))
+ .collect(Collectors.toList());
+ List<EquipmentRepairDetail> delList = new ArrayList<>();
+ idList.forEach(f->{
+ EquipmentRepairDetail info = new EquipmentRepairDetail();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ equipmentRepairDetailBaseService.updateBatchById(delList);
+ }
+ }
+
//保存检查标准
List<EquipmentCheckStandardDetail> checkStandardeDetailList = infoDto.getCheckStandardeDetailList();
- checkStandardeDetailList.forEach(f->{
- f.setEquipmentId(equipmentInfo.getId());
- f.setInfoTpe(equipmentInfo.getInfoType());
- });
- equipmentCheckStandardDetailService.saveOrUpdateBatch(checkStandardeDetailList);
- if(StringUtils.hasText(infoDto.getDelCheckStandardeDetails())){
- List<Long> idList = Arrays.stream(infoDto.getDelCheckStandardeDetails().split(",")).map(s-> Long.parseLong(s.trim()))
- .collect(Collectors.toList());
- equipmentCheckStandardDetailService.removeByIds(idList);
+ if(checkStandardeDetailList != null && !checkStandardeDetailList.isEmpty()){
+ checkStandardeDetailList.forEach(f->{
+ f.setEquipmentId(equipmentInfo.getId());
+ f.setInfoTpe(equipmentInfo.getInfoType());
+ });
+ equipmentCheckStandardDetailBaseService.saveOrUpdateBatch(checkStandardeDetailList);
}
+ if(infoDto.getDelCheckStandardeDetails() != null && !infoDto.getDelCheckStandardeDetails().isEmpty()){
+ if(StringUtils.hasText(infoDto.getDelCheckStandardeDetails())){
+ List<Long> idList = Arrays.stream(infoDto.getDelCheckStandardeDetails().split(",")).map(s-> Long.parseLong(s.trim()))
+ .collect(Collectors.toList());
+ List<EquipmentCheckStandardDetail> delList = new ArrayList<>();
+ idList.forEach(f->{
+ EquipmentCheckStandardDetail info = new EquipmentCheckStandardDetail();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ equipmentCheckStandardDetailBaseService.updateBatchById(delList);
+ }
+ }
+
//保存保养标准
List<EquipmentTakecareStardardDetail> takecareStardardeDetailList = infoDto.getTakecareStardardeDetailList();
- takecareStardardeDetailList.forEach(f->{
- f.setEquipmentId(equipmentInfo.getId());
- f.setInfoTpe(equipmentInfo.getInfoType());
- });
- equipmentTakecareStardardDetailService.saveOrUpdateBatch(takecareStardardeDetailList);
- if(StringUtils.hasText(infoDto.getDelTakecareStardardeDetails())){
- List<Long> idList = Arrays.stream(infoDto.getDelTakecareStardardeDetails().split(",")).map(s-> Long.parseLong(s.trim()))
- .collect(Collectors.toList());
- equipmentTakecareStardardDetailService.removeByIds(idList);
+ if(takecareStardardeDetailList != null && !takecareStardardeDetailList.isEmpty()){
+ takecareStardardeDetailList.forEach(f->{
+ f.setEquipmentId(equipmentInfo.getId());
+ f.setInfoTpe(equipmentInfo.getInfoType());
+ });
+ equipmentTakecareStardardDetailBaseService.saveOrUpdateBatch(takecareStardardeDetailList);
}
-
+ if(infoDto.getDelTakecareStardardeDetails() != null && !infoDto.getDelTakecareStardardeDetails().isEmpty()){
+ if(StringUtils.hasText(infoDto.getDelTakecareStardardeDetails())){
+ List<Long> idList = Arrays.stream(infoDto.getDelTakecareStardardeDetails().split(",")).map(s-> Long.parseLong(s.trim()))
+ .collect(Collectors.toList());
+ List<EquipmentTakecareStardardDetail> delList = new ArrayList<>();
+ idList.forEach(f->{
+ EquipmentTakecareStardardDetail info = new EquipmentTakecareStardardDetail();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ equipmentTakecareStardardDetailBaseService.updateBatchById(delList);
+ }
+ }
}
@@ -293,7 +397,12 @@
.select("stop_status as stopStatus,count(0) as count")
.groupBy("stop_status");
- return this.listMaps(wrapper);
+ List<Map<String, Object>> list = equipmentInfoBaseService.listMaps(wrapper);
+
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("-1",equipmentInfoBaseService.countOverTime());//超时未保养
+ return list;
}
@Override
@@ -311,10 +420,193 @@
}
}
} catch (Exception e) {
- log.error("exception",e);
+ System.out.println("exception"+e);
}
}
});
return depPool;
}
-}
\ No newline at end of file
+
+ @Override
+ public void importData(MultipartFile file) throws IOException {
+ String contentType = file.getContentType();
+ if(!"application/vnd.ms-excel".equals(contentType)
+ && !"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) {
+ throw new EquipmentException("上传的excel格式错误");
+ }
+
+ Collection<EquipmentInfoImportExcel> importExcel = ExcelUtil.importExcel(EquipmentInfoImportExcel.class, file.getInputStream(), "yyyy-MM-dd HH:mm:ss", new ExcelLogs() , 0);
+
+ if (CollectionUtils.isEmpty(importExcel)) {
+ return ;
+ }
+
+ List<EquipmentInfo> respList = BeanCopyUtils.copyBeanList((List<EquipmentInfoImportExcel>)importExcel, EquipmentInfo.class);
+
+ equipmentInfoBaseService.saveBatch(respList);
+ }
+
+ @Override
+ public void delete(Long[] ids) {
+ if(ids == null){
+ throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL);
+ }
+ List<Long> idList = Arrays.asList(ids);
+
+ List<EquipmentInfo> delList = new ArrayList<>();
+ idList.forEach(f->{
+ EquipmentInfo info = new EquipmentInfo();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+
+ equipmentInfoBaseService.updateBatchById(delList);
+
+ }
+
+ @Override
+ public void exportTemplate() throws IOException {
+ Map<String,String> map = new LinkedHashMap<>();
+ map.put("1", "类型/类别外键");
+ map.put("2", "具体类型(页面左侧的导航栏使用) 0:仪器仪表信息 1:生产设备设施 2:安全设备设施 ");
+ map.put("3", "名称");
+ map.put("4", "位号");
+ map.put("5", "用途");
+ map.put("6", "型号");
+ map.put("7", "单位部门外键");
+ map.put("8", "设置部位");
+ map.put("9", "生产日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("10", "使用期限(天)");
+ map.put("11", "生命周期 1:已使用 2:库存中 3:报废");
+ map.put("12", "投用日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("13", "维修状态 1:维修中 2:已修好");
+ map.put("14", "停用状态 1:停用 2.在用 3.维修 4.报废");
+ map.put("15", "上次检查日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("16", "上次检测日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("17", "上次保养日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("18", "下次检查日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("19", "下次检测日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("20", "下次保养日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("21", "负责人ID外键");
+ map.put("22", "负责人部门外键");
+ map.put("23", "供应商");
+ map.put("24", "使用说明");
+ map.put("25", "是否检查 1:是 2:否");
+ map.put("26", "检查周期");
+ map.put("27", "检查提前提醒");
+ map.put("28", "是否检测 1:是 2:否");
+ map.put("29", "检测周期");
+ map.put("30", "检测提前提醒");
+ map.put("31", "是否保养 1:是 2:否");
+ map.put("32", "检查内容");
+ map.put("33", "负责部门/外键");
+ map.put("34", "检查指标");
+ map.put("35", "预警值");
+ map.put("36", "联锁值");
+ map.put("37", "停用理由");
+ map.put("38", "停用后措施");
+ map.put("39", "实际停用日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("40", "停用提交人/外键");
+ map.put("41", "停用提交日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("42", "恢复理由");
+ map.put("43", "恢复填报日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("44", "实际恢复日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("45", "报废理由");
+ map.put("46", "报废填报日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("47", "实际报废日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("48", "保养周期");
+ String fileName = URLEncoder.encode("设备设施管理数据导入模板.xls", "UTF-8");
+ response.setContentType("application/vnd.ms-excel");
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
+
+ ExcelUtil.exportExcel(map,new ArrayList<>() , response.getOutputStream());
+ response.getOutputStream().close();
+ }
+
+ @Override
+ public void exportData(EquipmentInfoQueryCriteria queryCriteria) throws IOException {
+ Map<String,String> map = new LinkedHashMap<>();
+ map.put("0", "ID");
+ map.put("1", "类型/类别外键");
+ map.put("2", "具体类型(页面左侧的导航栏使用) 0:仪器仪表信息 1:生产设备设施 2:安全设备设施 ");
+ map.put("3", "名称");
+ map.put("4", "位号");
+ map.put("5", "用途");
+ map.put("6", "型号");
+ map.put("7", "单位部门外键");
+ map.put("8", "设置部位");
+ map.put("9", "生产日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("10", "使用期限(天)");
+ map.put("11", "生命周期 1:已使用 2:库存中 3:报废");
+ map.put("12", "投用日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("13", "维修状态 1:维修中 2:已修好");
+ map.put("14", "停用状态 1:停用 2.在用 3.维修 4.报废");
+ map.put("15", "上次检查日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("16", "上次检测日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("17", "上次保养日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("18", "下次检查日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("19", "下次检测日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("20", "下次保养日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("21", "负责人ID外键");
+ map.put("22", "负责人部门外键");
+ map.put("23", "供应商");
+ map.put("24", "使用说明");
+ map.put("25", "是否检查 1:是 2:否");
+ map.put("26", "检查周期");
+ map.put("27", "检查提前提醒");
+ map.put("28", "是否检测 1:是 2:否");
+ map.put("29", "检测周期");
+ map.put("30", "检测提前提醒");
+ map.put("31", "是否保养 1:是 2:否");
+ map.put("32", "检查内容");
+ map.put("33", "负责部门/外键");
+ map.put("34", "检查指标");
+ map.put("35", "预警值");
+ map.put("36", "联锁值");
+ map.put("37", "停用理由");
+ map.put("38", "停用后措施");
+ map.put("39", "实际停用日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("40", "停用提交人/外键");
+ map.put("41", "停用提交日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("42", "恢复理由");
+ map.put("43", "恢复填报日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("44", "实际恢复日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("45", "报废理由");
+ map.put("46", "报废填报日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("47", "实际报废日期(yyyy-MM-dd HH:mm:ss)");
+ map.put("48", "保养周期");
+
+ String key = DateUtils.date2String(new Date(), DateUtils.PATTERN_ALLTIME_NOSIGN) ;
+ String fileName = URLEncoder.encode("设备设施管理"+key+".xls", "UTF-8");
+ response.setContentType("application/vnd.ms-excel");
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
+ response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
+
+ queryCriteria.setDelFlag(0);
+ List<EquipmentInfoExcel> respList = BeanCopyUtils.copyBeanList(this.queryAll(queryCriteria), EquipmentInfoExcel.class);
+
+ ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD);
+ response.getOutputStream().close();
+ }
+
+
+ /**
+ * 枚举验证
+ * @param infoDto
+ */
+ public void checkEnum(EquipmentInfoSaveOrUpdate infoDto){
+ if (EquipmentLifeCycleEnum.getByCode(infoDto.getLifeCycle()) == null) {
+ throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_LIFE_CYCLE_NOT_EXIST);
+ }
+
+ if (EquipmentRepairStatusEnum.getByCode(infoDto.getRepairStatus()) == null) {
+ throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_STOP_STATUS_NOT_EXIST);
+ }
+
+ if (EquipmentStopStatusEnum.getByCode(infoDto.getStopStatus()) == null) {
+ throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_REPAIR_STATUS_NOT_EXIST);
+ }
+ }
+}
--
Gitblit v1.9.2