From c4ca7de4e8230eacc833b3b7c761c467ca4ea7d0 Mon Sep 17 00:00:00 2001
From: “linengliang” <vanSuperEnergy@163.com>
Date: 星期一, 18 十二月 2023 14:25:52 +0800
Subject: [PATCH] 三保养

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentMaintenancePlanService.java         |    3 +
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentMaintenancePlanMapper.java            |    4 ++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentMaintenancePlanMapper.xml         |   13 ++++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentMaintenancePlanServiceImpl.java |   48 +++++++++++++++++++++++-
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentMaintenancePlanController.java    |   10 ++++-
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/MaintenanceStandard.java                       |    7 +++
 6 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentMaintenancePlanController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentMaintenancePlanController.java
index 849cf67..d002a74 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentMaintenancePlanController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentMaintenancePlanController.java
@@ -33,6 +33,7 @@
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -408,9 +409,14 @@
 		 }
 		 return Result.error("鏂囦欢瀵煎叆澶辫触锛�");
     }
-
+    @GetMapping("/getStandards")
+	 public Result<?> getStandards(@RequestParam(name="ids",required=true) String ids,
+								   @RequestParam(name="maintenanceType",required=true) String maintenanceType
+	){
+    	 List<String> equipmentIds = Arrays.asList(ids.split(","));
+         return Result.OK(equipmentMaintenancePlanService.getStandards(equipmentIds,maintenanceType));
+	}
     /*--------------------------------瀛愯〃澶勭悊-淇濆吇璁″垝鏄庣粏-end----------------------------------------------*/
-
 
 
 
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/MaintenanceStandard.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/MaintenanceStandard.java
index f4fd1f6..e9a86e8 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/MaintenanceStandard.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/MaintenanceStandard.java
@@ -147,5 +147,12 @@
 
     @TableField(exist = false)
     private List<MaintenanceStandardDetail> maintenanceStandardDetaillist;
+    @TableField(exist = false)
+    private String equipmentNum;
+    @TableField(exist = false)
+    private String equipmentName;
+    @TableField(exist = false)
+    private String equipmentModel;
+
 
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentMaintenancePlanMapper.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentMaintenancePlanMapper.java
index 4ad29b2..3f4552a 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentMaintenancePlanMapper.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentMaintenancePlanMapper.java
@@ -3,6 +3,7 @@
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.eam.entity.EquipmentMaintenancePlan;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.eam.entity.MaintenanceStandard;
 import org.jeecg.modules.eam.entity.MaintenanceStandardDetail;
 
 import java.util.List;
@@ -14,5 +15,8 @@
  * @Version: V1.0
  */
 public interface EquipmentMaintenancePlanMapper extends BaseMapper<EquipmentMaintenancePlan> {
+
     List<MaintenanceStandardDetail> getCycle(@Param("mainId") String mainId,@Param("type") String type);
+
+    List<MaintenanceStandard> getStandards(@Param("equipmentId") String equipmentId,@Param("maintenanceType") String maintenanceType);
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentMaintenancePlanMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentMaintenancePlanMapper.xml
index 61b1f95..c471c33 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentMaintenancePlanMapper.xml
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentMaintenancePlanMapper.xml
@@ -12,5 +12,18 @@
         and t2.maintenance_type = #{type}
         and t1.del_flag = 0
     </select>
+    <select id="getStandards" resultType="org.jeecg.modules.eam.entity.MaintenanceStandard">
+        select t1.*,
+               t2.id euipmentId,
+               t2.name equipmentName,
+               t2.num equipmentNum,
+               t2.model equipmentModel
+        from mom_eam_maintenance_standard t1
+        left join mom_eam_equipment t2 on t1.equipment_id = t2.id
+        where t1.del_flag = 0
+        and t1.version_status = '2'
+        and t1.maintenance_type = #{maintenanceType}
+        and t1.equipment_id = #{equipmentId}
+    </select>
 
 </mapper>
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentMaintenancePlanService.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentMaintenancePlanService.java
index b5b2c23..f48d968 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentMaintenancePlanService.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentMaintenancePlanService.java
@@ -3,11 +3,13 @@
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.eam.entity.EquipmentMaintenancePlan;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.eam.entity.MaintenanceStandard;
 import org.jeecg.modules.eam.entity.MaintenanceStandardDetail;
 
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 淇濆吇璁″垝
@@ -32,6 +34,7 @@
 	public void delBatchMain (Collection<? extends Serializable> idList);
 
 	List<MaintenanceStandardDetail> getCycle(String mainId,String type);
+	Map<String,Object> getStandards(List<String> equipmentIds, String maintenanceType);
 
 
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentMaintenancePlanServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentMaintenancePlanServiceImpl.java
index bbd193c..82c5df4 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentMaintenancePlanServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentMaintenancePlanServiceImpl.java
@@ -1,7 +1,11 @@
 package org.jeecg.modules.eam.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import org.jeecg.modules.eam.entity.Equipment;
 import org.jeecg.modules.eam.entity.EquipmentMaintenancePlan;
+import org.jeecg.modules.eam.entity.MaintenanceStandard;
 import org.jeecg.modules.eam.entity.MaintenanceStandardDetail;
+import org.jeecg.modules.eam.mapper.EamEquipmentMapper;
 import org.jeecg.modules.eam.mapper.EquipmentMaintenancePlanDetailMapper;
 import org.jeecg.modules.eam.mapper.EquipmentMaintenancePlanMapper;
 import org.jeecg.modules.eam.service.IEquipmentMaintenancePlanService;
@@ -10,8 +14,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
 
 /**
  * @Description: 淇濆吇璁″垝
@@ -26,6 +29,8 @@
 	private EquipmentMaintenancePlanMapper equipmentMaintenancePlanMapper;
 	@Autowired
 	private EquipmentMaintenancePlanDetailMapper equipmentMaintenancePlanDetailMapper;
+	@Autowired
+	private EamEquipmentMapper equipmentMapper;
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
@@ -48,4 +53,43 @@
 		return baseMapper.getCycle(mainId,type);
 	}
 
+	@Override
+	public Map<String,Object> getStandards(List<String> equipmentIds, String maintenanceType) {
+		String msg = "";
+		Map<String,Object> map = new HashMap<>(2);
+		List<MaintenanceStandard> maintenanceStandards = new ArrayList<>();
+		for(String equipmentId:equipmentIds){
+			Equipment equipment = equipmentMapper.selectById(equipmentId);
+			List<MaintenanceStandard> list = baseMapper.getStandards(equipmentId,maintenanceType);
+			if(list.size()==0){
+				msg = msg+"缁熶竴缂栫爜涓�"+equipment.getNum()+"鐨勮澶囦笉瀛樺湪鐢熸晥淇濆吇鏍囨敞;";
+			}else if(list.size()>1){
+				msg = msg+"缁熶竴缂栫爜涓�"+equipment.getNum()+"鐨勮澶囧瓨鍦ㄥ鏉$敓鏁堜繚鍏绘爣娉�;";
+			}else {
+				if(equipment.getIsLineEquip().equals("yes")&&maintenanceType.equals("3")){
+                    String lineId = equipment.getLineId();
+                    if(StringUtils.isNotBlank(lineId)){
+                      List<MaintenanceStandard> lineStandard = baseMapper.getStandards(lineId,maintenanceType);
+						if(lineStandard.size()==0){
+							msg = msg+"缁熶竴缂栫爜涓�"+equipment.getNum()+"鐨勮澶囦笉瀛樺湪鐢熸晥淇濆吇鏍囨敞;";
+						}else if(list.size()>1){
+							msg = msg+"缁熶竴缂栫爜涓�"+equipment.getNum()+"鐨勮澶囧瓨鍦ㄥ鏉$敓鏁堜繚鍏绘爣娉�;";
+						}else{
+							maintenanceStandards.add(lineStandard.get(0));
+						}
+					}else {
+						msg = msg+"缁熶竴缂栫爜涓�"+equipment.getNum()+"鐨勮澶囦笉瀛樺湪鐢熸晥淇濆吇鏍囨敞;";
+					}
+				}else{
+					maintenanceStandards.add(list.get(0));
+				}
+			}
+
+		}
+		map.put("records",maintenanceStandards);
+		map.put("message",msg);
+		return map ;
+	}
+
+
 }

--
Gitblit v1.9.3