From d3e79914a4657bf39bb4e59cc7bf35cf6492da58 Mon Sep 17 00:00:00 2001
From: cuijian <cuijian@xalxzn.com>
Date: 星期四, 02 十一月 2023 18:05:41 +0800
Subject: [PATCH] 操作证管理、设备点检工单自动生成

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/OperationCertificateApplyDetailServiceImpl.java |   25 ++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/OperationCertificateApplyController.java          |   14 ++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IInspectionCycleService.java                         |    7 +
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/InspectionCycle.java                                  |   29 ++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/InspectionCycleServiceImpl.java                 |    6 +
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/InspectionCycleMapper.java                            |    4 
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/OperationCertificateJob.java                             |   46 +++++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/InspectionCycleMapper.xml                         |   14 ++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/DailyInspectionOrderJob.java                             |  168 ++++++++++++++++++++++++++++
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/OperationCertificateApplyDetailMapper.xml         |    5 
 10 files changed, 314 insertions(+), 4 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/OperationCertificateApplyController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/OperationCertificateApplyController.java
index 336cd01..085fe34 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/OperationCertificateApplyController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/OperationCertificateApplyController.java
@@ -12,6 +12,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.jeecg.modules.eam.vo.EquipmentDisposalPage;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -262,4 +263,17 @@
       return Result.OK("鏂囦欢瀵煎叆澶辫触锛�");
     }
 
+	 /**
+	  * 鎻愪氦銆佸鏍搞�佸鎵�
+	  *
+	  * @param operationCertificateApply
+	  * @return
+	  */
+	 @AutoLog(value = "鎻愪氦銆佸鏍搞�佸鎵�")
+	 @PostMapping(value = "/approve")
+	 public Result<String> submit(@RequestBody OperationCertificateApply operationCertificateApply) {
+		 this.operationCertificateApplyService.updateById(operationCertificateApply);
+		 return Result.OK("鎿嶄綔鎴愬姛锛�");
+	 }
+
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/InspectionCycle.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/InspectionCycle.java
index 35803c0..7db1f5b 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/InspectionCycle.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/InspectionCycle.java
@@ -54,6 +54,11 @@
     @ApiModelProperty(value = "棣栨鐐规鏃堕棿")
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     private Date firstInspectionTime;
+    /**涓婃鐐规鏃堕棿*/
+    @Excel(name = "涓婃鐐规鏃堕棿", width = 15)
+    @ApiModelProperty(value = "涓婃鐐规鏃堕棿")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date lastInspectionTime;
     /**鎻愬墠鏃堕棿*/
     @Excel(name = "鎻愬墠鏃堕棿", width = 15)
     @ApiModelProperty(value = "鎻愬墠鏃堕棿")
@@ -152,4 +157,28 @@
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private java.util.Date loseEfficacyTime;
 
+    @TableField(exist = false)
+    private String equipmentId;
+    @TableField(exist = false)
+    private String teamId;
+    @TableField(exist = false)
+    private String inspectionStandardId;
+    @TableField(exist = false)
+    private String inspectionStandardNum;
+    @TableField(exist = false)
+    private String inspectionProjectId;
+    @TableField(exist = false)
+    private String inspectionProjectName;
+    @TableField(exist = false)
+    private String detectionStandard;
+    @TableField(exist = false)
+    private String inspectionStandardDetailId;
+    @TableField(exist = false)
+    private String location;
+    @TableField(exist = false)
+    private String photo;
+    @TableField(exist = false)
+    private String inspectionMethod;
+
+
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/DailyInspectionOrderJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/DailyInspectionOrderJob.java
new file mode 100644
index 0000000..57944ce
--- /dev/null
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/DailyInspectionOrderJob.java
@@ -0,0 +1,168 @@
+package org.jeecg.modules.eam.job;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.eam.entity.*;
+import org.jeecg.modules.eam.service.*;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.time.DayOfWeek;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 鑷富缁存姢宸ュ崟鑷姩鐢熸垚
+ */
+@Slf4j
+public class DailyInspectionOrderJob implements Job {
+
+    @Autowired
+    private IInspectionCycleService inspectionCycleService;
+    @Autowired
+    private IdentityService identityService;
+    @Autowired
+    private IInspectionOrderService inspectionOrderService;
+    @Autowired
+    private IInspectionOrderDetailService inspectionOrderDetailService;
+    @Autowired
+    private IDailyInspectionStandardDetailService dailyInspectionStandardDetailService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        /*//閬嶅巻鐐规鏍囧噯锛岄�氳繃鐐规鏍囧噯鐢熸垚鐐规宸ュ崟
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<InspectionCycle> inspectionCycleList = inspectionCycleService.getInspectionOrder();
+        //褰撳墠鏃堕棿
+        String currentDateTime = formatter.format(LocalDateTime.now());
+        for(InspectionCycle inspectionCycle : inspectionCycleList){
+            //鎻愬墠鏃堕棿
+            BigDecimal leadTime = new BigDecimal("0");
+            //鏈夋晥鏃堕棿
+            BigDecimal effectiveTime = new BigDecimal("0");
+            //鏈鐐规鏃堕棿
+            Date newInspecttionTime = null;
+            if("min".equals(inspectionCycle.getUnit())){
+                leadTime = inspectionCycle.getLeadTime().multiply(new BigDecimal("60"));
+                effectiveTime = inspectionCycle.getEffectiveTime().multiply(new BigDecimal("60"));
+            }else if("hour".equals(inspectionCycle.getUnit())){
+                leadTime = inspectionCycle.getLeadTime().multiply(new BigDecimal("3600"));
+                effectiveTime = inspectionCycle.getEffectiveTime().multiply(new BigDecimal("3600"));
+            }else if("day".equals(inspectionCycle.getUnit())){
+                leadTime = inspectionCycle.getLeadTime().multiply(new BigDecimal("86400"));
+                effectiveTime = inspectionCycle.getEffectiveTime().multiply(new BigDecimal("86400"));
+            }
+            if("day".equals(inspectionCycle.getCycleUnit())){
+                Calendar calendar = Calendar.getInstance();
+                if(inspectionCycle.getLastInspectionTime() != null){
+                    calendar.setTime(inspectionCycle.getLastInspectionTime());
+                }else {
+                    calendar.setTime(inspectionCycle.getFirstInspectionTime());
+                }
+                calendar.add(Calendar.DAY_OF_YEAR, inspectionCycle.getCycle().intValue());
+                Date inspecttionTime = calendar.getTime();
+                Instant instant = inspecttionTime.toInstant();
+                instant = instant.minusSeconds(leadTime.intValue());
+                newInspecttionTime = Date.from(instant);
+            }else if("week".equals(inspectionCycle.getCycleUnit())){
+                Calendar calendar = Calendar.getInstance();
+                if(inspectionCycle.getLastInspectionTime() != null){
+                    calendar.setTime(inspectionCycle.getLastInspectionTime());
+                }else {
+                    calendar.setTime(inspectionCycle.getFirstInspectionTime());
+                }
+                calendar.add(Calendar.WEEK_OF_MONTH, inspectionCycle.getCycle().intValue());
+                Date inspecttionTime = calendar.getTime();
+                Instant instant = inspecttionTime.toInstant();
+                instant = instant.minusSeconds(leadTime.intValue());
+                newInspecttionTime = Date.from(instant);
+            }
+            Instant instant = newInspecttionTime.toInstant();
+            instant = instant.plusSeconds(effectiveTime.intValue());
+            //鏈鐐规鎴鏃堕棿
+            Date newnspectionDeadline = Date.from(instant);
+            String newDate = formatter.format(newInspecttionTime);
+            if(currentDateTime.equals(newDate)){
+                //淇濆瓨鐐规宸ュ崟涓昏〃鏁版嵁
+                InspectionOrder inspectionOrder = new InspectionOrder();
+                inspectionOrder.setNum(identityService.getNumByTypeAndLength("DailylnspectionOrder",4));
+                inspectionOrder.setInspectionCycleId(inspectionCycle.getId());
+                inspectionOrder.setInspectionStandardId(inspectionCycle.getInspectionStandardId());
+                inspectionOrder.setInspectionTime(newInspecttionTime);
+                inspectionOrder.setInspectionStandardType("1");
+                inspectionOrder.setInspectionDeadline(newnspectionDeadline);
+                inspectionOrder.setEquipmentId(inspectionCycle.getEquipmentId());
+                inspectionOrder.setTeamId(inspectionCycle.getTeamId());
+                inspectionOrderService.save(inspectionOrder);
+                //鏇存柊涓婃鐐规鏃堕棿
+                inspectionCycle.setLastInspectionTime(newInspecttionTime);
+                inspectionCycleService.updateById(inspectionCycle);
+                //鏍规嵁鏍囧噯鍜屽懆鏈熸煡璇㈢偣妫�椤圭洰
+                //淇濆瓨鐐规宸ュ崟瀛愯〃鏁版嵁
+            }
+        }*/
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<InspectionCycle> inspectionCycleList = inspectionCycleService.getInspectionOrder();
+        LocalDate today = LocalDate.now();
+        DayOfWeek dayOfWeek = today.getDayOfWeek();
+        for(InspectionCycle inspectionCycle : inspectionCycleList){
+            if("day".equals(inspectionCycle.getCycleUnit())){
+                //淇濆瓨鐐规宸ュ崟涓昏〃鏁版嵁
+                InspectionOrder inspectionOrder = new InspectionOrder();
+                inspectionOrder.setNum(identityService.getNumByTypeAndLength("DailylnspectionOrder",4));
+                inspectionOrder.setInspectionCycleId(inspectionCycle.getId());
+                inspectionOrder.setInspectionStandardId(inspectionCycle.getInspectionStandardId());
+                inspectionOrder.setInspectionTime(new Date());
+                inspectionOrder.setInspectionStandardType("1");
+                inspectionOrder.setEquipmentId(inspectionCycle.getEquipmentId());
+                inspectionOrder.setTeamId(inspectionCycle.getTeamId());
+                inspectionOrderService.save(inspectionOrder);
+                //淇濆瓨鐐规宸ュ崟瀛愯〃鏁版嵁
+                List<DailyInspectionStandardDetail> dailyInspectionStandardDetailList = dailyInspectionStandardDetailService.lambdaQuery()
+                        .eq(DailyInspectionStandardDetail::getDailyInspectionStandardId,inspectionOrder.getInspectionStandardId())
+                        .eq(DailyInspectionStandardDetail::getInspectionCycleId,inspectionOrder.getInspectionCycleId()).list();
+                for(DailyInspectionStandardDetail dailyInspectionStandardDetail : dailyInspectionStandardDetailList){
+                    InspectionOrderDetail inspectionOrderDetail = new InspectionOrderDetail();
+                    inspectionOrderDetail.setInspectionOrderId(inspectionOrder.getId());
+                    inspectionOrderDetail.setInspectionProjectId(dailyInspectionStandardDetail.getInspectionProjectId());
+                    inspectionOrderDetail.setInspectionStandardDetailId(dailyInspectionStandardDetail.getId());
+                    inspectionOrderDetail.setLocation(dailyInspectionStandardDetail.getLocation());
+                    inspectionOrderDetail.setPhoto(dailyInspectionStandardDetail.getPhoto());
+                    inspectionOrderDetailService.save(inspectionOrderDetail);
+                }
+            }else if("week".equals(inspectionCycle.getCycleUnit()) && dayOfWeek == DayOfWeek.FRIDAY){
+                //淇濆瓨鐐规宸ュ崟涓昏〃鏁版嵁
+                InspectionOrder inspectionOrder = new InspectionOrder();
+                inspectionOrder.setNum(identityService.getNumByTypeAndLength("DailylnspectionOrder",4));
+                inspectionOrder.setInspectionCycleId(inspectionCycle.getId());
+                inspectionOrder.setInspectionStandardId(inspectionCycle.getInspectionStandardId());
+                inspectionOrder.setInspectionTime(new Date());
+                inspectionOrder.setInspectionStandardType("1");
+                inspectionOrder.setEquipmentId(inspectionCycle.getEquipmentId());
+                inspectionOrder.setTeamId(inspectionCycle.getTeamId());
+                inspectionOrderService.save(inspectionOrder);
+                //淇濆瓨鐐规宸ュ崟瀛愯〃鏁版嵁
+                List<DailyInspectionStandardDetail> dailyInspectionStandardDetailList = dailyInspectionStandardDetailService.lambdaQuery()
+                        .eq(DailyInspectionStandardDetail::getDailyInspectionStandardId,inspectionOrder.getInspectionStandardId())
+                        .eq(DailyInspectionStandardDetail::getInspectionCycleId,inspectionOrder.getInspectionCycleId()).list();
+                for(DailyInspectionStandardDetail dailyInspectionStandardDetail : dailyInspectionStandardDetailList){
+                    InspectionOrderDetail inspectionOrderDetail = new InspectionOrderDetail();
+                    inspectionOrderDetail.setInspectionOrderId(inspectionOrder.getId());
+                    inspectionOrderDetail.setInspectionProjectId(dailyInspectionStandardDetail.getInspectionProjectId());
+                    inspectionOrderDetail.setInspectionStandardDetailId(dailyInspectionStandardDetail.getId());
+                    inspectionOrderDetail.setLocation(dailyInspectionStandardDetail.getLocation());
+                    inspectionOrderDetail.setPhoto(dailyInspectionStandardDetail.getPhoto());
+                    inspectionOrderDetailService.save(inspectionOrderDetail);
+                }
+            }
+        }
+    }
+}
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/OperationCertificateJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/OperationCertificateJob.java
new file mode 100644
index 0000000..eed8e89
--- /dev/null
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/OperationCertificateJob.java
@@ -0,0 +1,46 @@
+package org.jeecg.modules.eam.job;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.eam.entity.OperationCertificate;
+import org.jeecg.modules.eam.service.IOperationCertificateService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 鎿嶄綔璇佹洿鏂拌鍒嗗懆鏈�
+ */
+@Slf4j
+public class OperationCertificateJob implements Job {
+
+    @Resource
+    private IOperationCertificateService operationCertificateService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        //閬嶅巻鎵�鏈夋搷浣滆瘉淇℃伅
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        List<OperationCertificate> operationCertificateList = operationCertificateService.list();
+        for(OperationCertificate operationCertificate : operationCertificateList){
+            String endTime = formatter.format(operationCertificate.getEndTime());
+            String newDate = formatter.format(new Date());
+            if(endTime.equals(newDate)){
+                Date currentDate = operationCertificate.getEndTime();
+                operationCertificate.setStartTime(operationCertificate.getEndTime());
+                Calendar c = Calendar.getInstance();
+                c.setTime(currentDate);
+                c.add(Calendar.YEAR, 1);
+                currentDate = c.getTime();
+                operationCertificate.setEndTime(currentDate);
+                operationCertificate.setCurrentCycleScore(12);
+                operationCertificateService.updateById(operationCertificate);
+            }
+        }
+    }
+}
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/InspectionCycleMapper.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/InspectionCycleMapper.java
index e2900ee..0aced0c 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/InspectionCycleMapper.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/InspectionCycleMapper.java
@@ -37,4 +37,8 @@
 
     @Select("<script> select dbo.F_GET_SEQ_ID('InspectionCycleNum') </script>")
     public String getInspectionCycleNum();
+
+    public List<InspectionCycle> getInspectionOrder();
+
+    public List<InspectionCycle> getInspectionProject(String inspectionStandardId,String inspectionCycleId);
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/InspectionCycleMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/InspectionCycleMapper.xml
index ecb67cd..582757a 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/InspectionCycleMapper.xml
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/InspectionCycleMapper.xml
@@ -82,4 +82,18 @@
 		where t2.version_status='2'
 		and t1.del_flag=0
 	</select>
+
+    <select id="getInspectionOrder" resultType="org.jeecg.modules.eam.entity.InspectionCycle">
+		select DISTINCT t1.num inspectionStandardNum,
+		t1.equipment_id,
+		t2.daily_inspection_standard_id inspectionStandardId,
+		t3.*,
+		t4.team_id teamId
+		from mom_eam_daily_inspection_standard t1
+            left join mom_eam_daily_inspection_standard_detail t2 on t1.id = t2.daily_inspection_standard_id
+            left join mom_eam_inspection_cycle t3 on t3.id = t2.inspection_cycle_id
+            left join mom_eam_equipment t4 on t4.id = t1.equipment_id
+            where t1.version_status = 2 and t1.status = 1 and t1.del_flag=0 and t3.name is not NULL
+	</select>
+
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/OperationCertificateApplyDetailMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/OperationCertificateApplyDetailMapper.xml
index 18fa8bd..651e5b9 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/OperationCertificateApplyDetailMapper.xml
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/OperationCertificateApplyDetailMapper.xml
@@ -9,10 +9,9 @@
 			 operation_certificate_apply_id = #{mainId} 	</delete>
 	
 	<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.eam.entity.OperationCertificateApplyDetail">
-		SELECT t1.*,t2.realname,t3.name equipmentNames
+		SELECT t1.*,t2.realname
 		FROM  mom_eam_operation_certificate_apply_detail t1
-		left join (select * from sys_user where del_flag = 0) t2 on t1.user_id = t2.username
-		left join (select * from mom_eam_equipment where del_flag = 0) t3 on t1.equipment_ids = t3.id
+		left join (select * from sys_user where del_flag = 0) t2 on t1.user_id = t2.id
 		WHERE
 			 operation_certificate_apply_id = #{mainId} 	</select>
 </mapper>
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IInspectionCycleService.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IInspectionCycleService.java
index 7b74006..3e0396f 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IInspectionCycleService.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IInspectionCycleService.java
@@ -30,4 +30,11 @@
      * @return
      */
     List<Integer> getUsableVersion();
+
+    /**
+     * 鑾峰彇闇�瑕佺敓鎴愬伐鍗曠殑鏁版嵁
+     * @return
+     */
+    List<InspectionCycle> getInspectionOrder();
+
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/InspectionCycleServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/InspectionCycleServiceImpl.java
index bf181c2..328e4f4 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/InspectionCycleServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/InspectionCycleServiceImpl.java
@@ -35,4 +35,10 @@
     public List<Integer> getUsableVersion() {
         return baseMapper.getUsableVersion();
     }
+
+    @Override
+    public List<InspectionCycle> getInspectionOrder(){
+        return baseMapper.getInspectionOrder();
+    }
+
 }
diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/OperationCertificateApplyDetailServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/OperationCertificateApplyDetailServiceImpl.java
index 71ca6e7..41916c0 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/OperationCertificateApplyDetailServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/OperationCertificateApplyDetailServiceImpl.java
@@ -1,10 +1,18 @@
 package org.jeecg.modules.eam.service.impl;
 
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.modules.eam.entity.Equipment;
 import org.jeecg.modules.eam.entity.OperationCertificateApplyDetail;
 import org.jeecg.modules.eam.mapper.OperationCertificateApplyDetailMapper;
+import org.jeecg.modules.eam.service.IEamEquipmentService;
 import org.jeecg.modules.eam.service.IOperationCertificateApplyDetailService;
 import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
+
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -19,9 +27,24 @@
 	
 	@Autowired
 	private OperationCertificateApplyDetailMapper operationCertificateApplyDetailMapper;
+	@Autowired
+	private IEamEquipmentService equipmentService;
 	
 	@Override
 	public List<OperationCertificateApplyDetail> selectByMainId(String mainId) {
-		return operationCertificateApplyDetailMapper.selectByMainId(mainId);
+		List<OperationCertificateApplyDetail> operationCertificateApplyDetailList = operationCertificateApplyDetailMapper.selectByMainId(mainId);
+		for(OperationCertificateApplyDetail operationCertificateApplyDetail : operationCertificateApplyDetailList){
+			List<String> equipmentIdLsit = Arrays.asList(operationCertificateApplyDetail.getEquipmentIds().split(","));
+			List<String> equipmentNameLsit = new ArrayList<>();
+			for(String equipmentId : equipmentIdLsit){
+				Equipment equipment = equipmentService.lambdaQuery().eq(Equipment::getId,equipmentId).eq(Equipment::getDelFlag, CommonConstant.DEL_FLAG_0).one();
+				if(equipment != null){
+					equipmentNameLsit.add(equipment.getNum());
+				}
+			}
+			String equipmentNames = equipmentNameLsit.stream().map(String::toString).collect(Collectors.joining(","));
+			operationCertificateApplyDetail.setEquipmentNames(equipmentNames);
+		}
+		return operationCertificateApplyDetailList;
 	}
 }

--
Gitblit v1.9.3