From 1d6d68d6643f845f8894294d7ee2269670222e6e Mon Sep 17 00:00:00 2001
From: “linengliang” <vanSuperEnergy@163.com>
Date: 星期三, 23 八月 2023 18:03:42 +0800
Subject: [PATCH] lnl,设备台账导入+页面调整

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/ProcessParametersTemplateController.java |   11 +
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentImportVo.java                       |  115 +++++++++++++++++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java              |  161 ++++++++++++++++++++++++--
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Equipment.java                               |   32 +++++
 4 files changed, 301 insertions(+), 18 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
index 93ed2a8..deb81e9 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -7,12 +7,16 @@
 import javax.servlet.http.HttpServletResponse;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.dto.message.MessageDTO;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.base.entity.SysUpload;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.eam.entity.*;
 import org.jeecg.modules.eam.model.DepartVo;
 import org.jeecg.modules.eam.service.*;
@@ -24,10 +28,14 @@
 
 import org.jeecg.common.system.base.controller.JeecgController;
 
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -88,6 +96,9 @@
 
 	 @Autowired
 	 private ICalibrationOrderReportService calibrationOrderReportService;
+
+	 @Autowired
+	 private IEquipmentCategoryService equipmentCategoryService;
 	/**
 	 * 鍒嗛〉鍒楄〃鏌ヨ
 	 *
@@ -179,7 +190,7 @@
 		 IPage<Equipment> pageList = equipmentService.page(page, queryWrapper);
 		 return Result.OK(pageList);
 	 }
-	
+
 	/**
 	 *   娣诲姞
 	 *
@@ -222,7 +233,7 @@
 		}
 		return Result.OK("娣诲姞鎴愬姛锛�");
 	}
-	
+
 	/**
 	 *  缂栬緫
 	 *
@@ -281,7 +292,7 @@
 		}
 		return Result.OK("缂栬緫鎴愬姛!");
 	}
-	
+
 	/**
 	 *   閫氳繃id鍒犻櫎
 	 *
@@ -298,7 +309,7 @@
 		equipmentService.updateById(equipment);
 		return Result.OK("鍒犻櫎鎴愬姛!");
 	}
-	
+
 	/**
 	 *  鎵归噺鍒犻櫎
 	 *
@@ -319,7 +330,7 @@
 //		this.equipmentService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
 	}
-	
+
 	/**
 	 * 閫氳繃id鏌ヨ
 	 *
@@ -349,18 +360,18 @@
         return super.exportXls(request, equipment, Equipment.class, "mom_eam_equipment");
     }
 
-    /**
-      * 閫氳繃excel瀵煎叆鏁版嵁
-    *
-    * @param request
-    * @param response
-    * @return
-    */
-    //@RequiresPermissions("mom_eam_equipment:importExcel")
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, Equipment.class);
-    }
+//    /**
+//      * 閫氳繃excel瀵煎叆鏁版嵁
+//    *
+//    * @param request
+//    * @param response
+//    * @return
+//    */
+//    //@RequiresPermissions("mom_eam_equipment:importExcel")
+//    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+//    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+//        return super.importExcel(request, response, Equipment.class);
+//    }
 
 
 	 /**
@@ -391,6 +402,7 @@
 	 @GetMapping(value = "/getResumeInspectionRecordList")
 	 public Result<?> getResumeInspectionRecordList(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam Map<String, Object> params) {
 		 IPage<Map<String, Object>> resumeInspectionRecordList = equipmentService.getResumeInspectionRecordList(pageNo, pageSize, params);
+		 LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		 for (Map<String, Object> record : resumeInspectionRecordList.getRecords()) {
 			 String id = (String)record.get("id");
 			 String inspectionType = (String)record.get("inspectionType");
@@ -503,6 +515,121 @@
 		 queryWrapper.in("equipment_status",statusList);
 		 IPage<Equipment> pageList = equipmentService.page(page, queryWrapper);
 		 return Result.OK(pageList);
+	 }/**
+	  * 瀵煎叆
+	  * @return
+	  */
+	 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+	 @Transactional(rollbackFor = Exception.class)
+	 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+		 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+		 LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+		 String exceptionInfo = "";
+		 int exceptionNum = 0;
+		 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+			 MultipartFile file = entity.getValue();
+			 ImportParams params = new ImportParams();
+			 params.setNeedSave(true);
+			 try {
+				 List<EquipmentImportVo> list = ExcelImportUtil.importExcel(file.getInputStream(), EquipmentImportVo.class, params);
+				 for(int i = 0;i<list.size();i++){
+                     EquipmentImportVo equipmentImportVo = list.get(i);
+					 EquipmentCategory equipmentCategory = equipmentCategoryService.getOne(new QueryWrapper<EquipmentCategory>().eq("name",equipmentImportVo.getEquipmentCategoryName()),false);
+                     if(
+                     		StringUtils.isBlank(equipmentImportVo.getNum())
+									|| StringUtils.isBlank(equipmentImportVo.getName())
+									|| StringUtils.isBlank(equipmentImportVo.getUseId())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentUda1())
+									|| StringUtils.isBlank(equipmentImportVo.getManageId())
+									|| StringUtils.isBlank(equipmentImportVo.getTeamId())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentImportanceId())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentCategoryName())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentStatus())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentUda3())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentUda5())
+									|| StringUtils.isBlank(equipmentImportVo.getEquipmentUda2())
+									|| StringUtils.isBlank(equipmentImportVo.getLeaveFactoryDate())
+									|| StringUtils.isBlank(equipmentImportVo.getProjectApprovalNo())
+									|| StringUtils.isBlank(equipmentImportVo.getFundSource())
+									|| StringUtils.isBlank(equipmentImportVo.getAcceptanceCheckDate())
+									|| StringUtils.isBlank(equipmentImportVo.getLeaveFactoryDate())
+									|| StringUtils.isBlank(equipmentImportVo.getFactoryNo())
+									|| StringUtils.isBlank(equipmentImportVo.getConstructorId())
+									|| StringUtils.isBlank(equipmentImportVo.getSourceCountry())
+									|| StringUtils.isBlank(equipmentImportVo.getModel())
+									|| StringUtils.isBlank(equipmentImportVo.getSpecification())
+									|| StringUtils.isBlank(equipmentImportVo.getGpo())
+					 ){
+						 exceptionInfo = exceptionInfo+"绗�"+(i+2)+"琛屽鍏ュけ璐�,鍘熷洜:鏁版嵁鏈夋湭濉」,璇峰~鍐欏繀濉」鍚庡啀瀵煎叆;";
+						 exceptionNum++;
+					 }else if(ObjectUtils.isNull(equipmentCategory))
+					       {
+							  exceptionInfo = exceptionInfo+"绗�"+(i+2)+"琛屽鍏ュけ璐�,鍘熷洜:璇ヨ澶囨墍灞炵被鍒笉瀛樺湪锛岃鍏堢淮鎶よ澶囩被鍒�;";
+							  exceptionNum++;
+						   }
+                      else{
+						 Equipment oriEquipment = equipmentService.getOne(new QueryWrapper<Equipment>().eq("num",equipmentImportVo.getNum()),false);
+						 if(ObjectUtils.isNull(oriEquipment)){
+							 Equipment equipment = new Equipment();
+							 equipment.setNum(equipmentImportVo.getNum())
+									 .setName(equipmentImportVo.getName())
+									 .setUseId(equipmentImportVo.getUseId())
+									 .setEquipmentUda1(equipmentImportVo.getEquipmentUda1())
+									 .setManageId(equipmentImportVo.getManageId())
+									 .setTeamId(equipmentImportVo.getTeamId())
+									 .setEquipmentImportanceId(equipmentImportVo.getEquipmentImportanceId())
+									 .setEquipmentCategoryId(equipmentCategory.getId())
+									 .setKeyEquipmentIdentification(equipmentImportVo.getKeyEquipmentIdentification())
+									 .setSecurityConfiguration(equipmentImportVo.getSecurityConfiguration())
+									 .setCoolingSystem(equipmentImportVo.getCoolingSystem())
+									 .setFireExtinguisher(equipmentImportVo.getFireExtinguisher())
+									 .setFireExtinguisherValidityPeriod(equipmentImportVo.getFireExtinguisherValidityPeriod())
+									 .setOperatingSystem(equipmentImportVo.getOperatingSystem())
+									 .setSystem(equipmentImportVo.getSystem())
+									 .setPort(equipmentImportVo.getPort())
+									 .setCoordinateNum(equipmentImportVo.getCoordinateNum())
+									 .setEquipmentStatus(equipmentImportVo.getEquipmentStatus())
+									 .setEquipmentUda3(equipmentImportVo.getEquipmentUda3())
+									 .setEquipmentUda4(equipmentImportVo.getEquipmentUda4())
+									 .setEquipmentUda5(equipmentImportVo.getEquipmentUda5())
+									 .setEquipmentUda2(equipmentImportVo.getEquipmentUda2())
+									 .setLastVerificationDate(equipmentImportVo.getLeaveFactoryDate())
+									 .setProjectApprovalNo(equipmentImportVo.getProjectApprovalNo())
+									 .setFundSource(equipmentImportVo.getFundSource())
+									 .setAcceptanceCheckDate(equipmentImportVo.getAcceptanceCheckDate())
+									 .setFactoryNo(equipmentImportVo.getFactoryNo())
+									 .setConstructorId(equipmentImportVo.getConstructorId())
+									 .setSourceCountry(equipmentImportVo.getSourceCountry())
+									 .setModel(equipmentImportVo.getModel())
+									 .setSpecification(equipmentImportVo.getSpecification())
+									 .setGpo(equipmentImportVo.getGpo());
+							 equipmentService.save(equipment);
+						 }else {
+							 exceptionInfo = exceptionInfo+"绗�"+(i+2)+"琛屽鍏ュけ璐ワ紝鍘熷洜锛氱粺涓�缂栫爜宸插瓨鍦紝鏁版嵁閲嶅瀵煎叆;";
+							 exceptionNum++;
+						 }
+					 }
+				 }
+				 if(exceptionNum!=0){
+					 String headInfo = "灏忓鎻愰啋鎮�!璁惧鍙拌处锛氬鍏ユ垚鍔�"+(list.size()-exceptionNum)+"鏉�,澶辫触"+exceptionNum+"鏉�";
+					 MessageDTO messageDTO = new MessageDTO();
+					 messageDTO.setTitle(headInfo);
+					 messageDTO.setFromUser("鏁版嵁瀵煎叆灏忓姪鎵�-灏忓");
+					 messageDTO.setCategory("瀵煎叆鎿嶄綔闄勫姞淇℃伅");
+					 messageDTO.setContent(exceptionInfo);
+					 messageDTO.setToUser(user.getUsername());
+					 sysBaseApi.sendSysAnnouncement(messageDTO);
+					 return Result.OK(headInfo+",鍙湪-绯荤粺娑堟伅-鏌ョ湅瀵煎叆璇︽儏");
+				 }
+				 return Result.OK("瀵煎叆鎴愬姛锛屽凡瀵煎叆鍏ㄩ儴鏁版嵁銆�");
+			 } catch (Exception e) {
+				 log.error(e.getMessage(), e);
+				 return Result.error("鏂囦欢瀵煎叆澶辫触:" + e.getMessage());
+			 }
+		 }
+		 return Result.error("鏂囦欢瀵煎叆澶辫触锛�");
 	 }
 
+
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/ProcessParametersTemplateController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/ProcessParametersTemplateController.java
index 09656ff..c56a186 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/ProcessParametersTemplateController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/ProcessParametersTemplateController.java
@@ -4,6 +4,8 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -15,6 +17,7 @@
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.eam.entity.ProcessParameters;
+import org.jeecg.modules.eam.entity.ProcessParametersCategory;
 import org.jeecg.modules.eam.entity.ProcessParametersTemplate;
 import org.jeecg.modules.eam.entity.ProcessParametersTemplateDetail;
 import org.jeecg.modules.eam.service.IProcessParametersCategoryService;
@@ -81,7 +84,13 @@
                     processParametersTemplateDetail.setProcessParametersNum(processParameters.getNum());
                     processParametersTemplateDetail.setProcessParametersName(processParameters.getName());
                     if(processParameters != null){
-                        processParametersTemplateDetail.setProcessParametersCategory(processParametersCategoryService.getById(processParameters.getProcessParametersCategoryId()).getName());
+                        String id = processParameters.getProcessParametersCategoryId();
+                        if(StringUtils.isNotBlank(id)){
+                            ProcessParametersCategory processParametersCategory = processParametersCategoryService.getById(id);
+                            if(ObjectUtils.isNotNull(processParametersCategory)&&StringUtils.isNotBlank(processParametersCategory.getName())){
+                                processParametersTemplateDetail.setProcessParametersCategory(processParametersCategory.getName());
+                            }
+                        }
                     }else{
                         processParametersTemplateDetail.setProcessParametersCategory("/");
                     }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Equipment.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Equipment.java
index 7a0fa9f..700f0e7 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Equipment.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Equipment.java
@@ -1,6 +1,7 @@
 package org.jeecg.modules.eam.entity;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -238,5 +239,36 @@
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date sealDate;
+    @ApiModelProperty(value = "璧勯噾鏉ユ簮")
+    private String  fundSource;
+    @ApiModelProperty(value = "鍑哄巶缂栧彿")
+    private String  factoryNo;
+    @ApiModelProperty(value = "鍒堕�犲晢")
+    private String  mfr;
+    @ApiModelProperty(value = "璧勪骇鏉ユ簮鍥藉")
+    private String  sourceCountry;
+    @ApiModelProperty(value = "鎬诲姛鐜�")
+    private String  gpo;
+    @ApiModelProperty(value = "鍏抽敭璁惧鏍囪瘑")
+    private String  keyEquipmentIdentification;
+    @ApiModelProperty(value = "瀹夊叏閰嶇疆")
+    private String  securityConfiguration;
+    @ApiModelProperty(value = "鍐峰嵈绯荤粺")
+    private String  coolingSystem;
+    @ApiModelProperty(value = "鐏伀鍣�")
+    private String  fireExtinguisher;
+    @ApiModelProperty(value = "鐏伀鍣ㄦ湁鏁堟湡")
+    private String  fireExtinguisherValidityPeriod;
+    @ApiModelProperty(value = "鎿嶄綔绯荤粺")
+    private String  operatingSystem;
+    @ApiModelProperty(value = "绯荤粺")
+    private String  system;
+    @ApiModelProperty(value = "绔彛")
+    private String  port;
+    @ApiModelProperty(value = "鍧愭爣鏁伴噺")
+    private BigDecimal coordinateNum;
+    @ApiModelProperty(value = "绔嬮」鍗″彿")
+    private String  projectApprovalNo;
+
 
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentImportVo.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentImportVo.java
new file mode 100644
index 0000000..882e779
--- /dev/null
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentImportVo.java
@@ -0,0 +1,115 @@
+package org.jeecg.modules.eam.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+
+/**
+ * @author lnl
+ */
+@Data
+@Accessors(chain = true)
+public class EquipmentImportVo {
+    @Excel(name="缁熶竴缂栫爜")
+    private String num;
+
+    @Excel(name = "璁惧鍚嶇О")
+    private String name;
+
+    @Excel(name = "浣跨敤閮ㄩ棬",dictTable = "sys_depart",dicCode = "id",dicText = "depart_name")
+    private String useId;
+
+    @Excel(name = "宸ュ尯")
+    private String equipmentUda1;
+
+    @Excel(name = "缁存姢閮ㄩ棬",dictTable = "sys_depart",dicCode = "id",dicText = "depart_name")
+    private String manageId;
+
+    @Excel(name = "缁翠慨鐝粍",dictTable = "mom_base_team",dicCode = "id",dicText = "name")
+    private String teamId;
+
+    @Excel(name = "ABC鏍囪瘑",dicCode = "id",dictTable="mom_eam_equipment_importance",dicText="name")
+    private String equipmentImportanceId;
+
+    @Excel(name = "璁惧鎵�灞炲垎绫�")
+    private String equipmentCategoryName;
+
+    @Excel(name = "鍏抽敭璁惧鏍囪瘑")
+    private String keyEquipmentIdentification;
+
+    @Excel(name = "瀹夊叏閰嶇疆")
+    private String securityConfiguration;
+
+    @Excel(name = "鍐峰嵈绯荤粺")
+    private String coolingSystem;
+
+    @Excel(name = "鐏伀鍣�")
+    private String fireExtinguisher;
+
+    @Excel(name = "鐏伀鍣ㄦ湁鏁堟湡")
+    private String fireExtinguisherValidityPeriod;
+
+    @Excel(name = "鎿嶄綔绯荤粺")
+    private String operatingSystem;
+
+    @Excel(name = "绯荤粺")
+    private String system;
+
+    @Excel(name = "璁惧绔彛")
+    private String port;
+
+    @Excel(name = "鍧愭爣鏁伴噺")
+    private BigDecimal coordinateNum;
+
+    @Excel(name = "璁惧鐘舵��")
+    private String equipmentStatus;
+
+    @Excel(name = "閲嶉噺")
+    private String equipmentUda3;
+
+    @Excel(name = "閲嶉噺璁¢噺鍗曚綅",dicCode = "id",dicText = "name",dictTable = "mom_base_unit")
+    private String equipmentUda4;
+
+    @Excel(name = "鍔熻兘浣嶇疆")
+    private String equipmentUda5;
+
+    @Excel(name = "瀹夎浣嶇疆")
+    private String equipmentUda2;
+
+    @Excel(name = "鍑哄巶鏃ユ湡",importFormat = "yyyyMMdd")
+    private String leaveFactoryDate;
+
+    @Excel(name = "绔嬮」鍗″彿")
+    private String projectApprovalNo;
+
+    @Excel(name = "璧勯噾鏉ユ簮")
+    private String fundSource;
+
+    @Excel(name = "楠屾敹鏃ユ湡",importFormat = "yyyyMMdd")
+    private String acceptanceCheckDate;
+
+    @Excel(name = "鍑哄巶缂栧彿")
+    private String factoryNo;
+
+    @Excel(name = "璧勪骇鍒堕�犲晢",dicCode = "id",dictTable="mom_base_constructor",dicText="name")
+    private String constructorId;
+
+    @Excel(name = "璧勪骇鐨勬潵婧愬浗瀹�")
+    private String sourceCountry;
+
+    @Excel(name = "鍨嬪彿")
+    private String model;
+
+    @Excel(name = "瑙勬牸")
+    private String specification;
+
+    @Excel(name = "鎬诲姛鐜�")
+    private String gpo;
+
+
+
+
+
+}

--
Gitblit v1.9.3