Преглед на файлове

新增异常状态的更新逻辑

车车 преди 6 месеца
родител
ревизия
84056cee76

+ 11 - 1
ktg-iscs/src/main/java/com/ktg/iscs/controller/HardwareApiController.java

@@ -4,6 +4,7 @@ import com.ktg.common.annotation.Log;
 import com.ktg.common.core.controller.BaseController;
 import com.ktg.common.enums.BusinessType;
 import com.ktg.common.pojo.CommonResult;
+import com.ktg.iscs.domain.dto.exUpdate.ExDTO;
 import com.ktg.iscs.domain.dto.hardwareApi.*;
 import com.ktg.iscs.domain.vo.hardwareApi.JobTicketVO;
 import com.ktg.iscs.service.HardwareApiService;
@@ -123,7 +124,7 @@ public class HardwareApiController extends BaseController
     }
 
     @ApiOperation("批量更新隔离点开关状态")
-    @Log(title = "更新隔离点开关状态", businessType = BusinessType.UPDATE)
+    @Log(title = "批量更新隔离点开关状态", businessType = BusinessType.UPDATE)
     @PostMapping("/updateSwitchList")
     public CommonResult<Boolean> updateSwitchList(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") UpdateSwitchParam dto)
     {
@@ -148,6 +149,15 @@ public class HardwareApiController extends BaseController
         return CommonResult.success(hardwareApiService.checkBeforeToUnlock(ticketId));
     }
 
+    // ----------------------------------批量更新硬件状态-------------------------------------------------------
+    @ApiOperation("批量更新硬件状态")
+    @Log(title = "批量更新硬件状态", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateHardwareEsStatus")
+    public CommonResult<Boolean> updateHardwareEsStatus(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") ExDTO dto)
+    {
+        return CommonResult.success(hardwareApiService.updateHardwareEsStatus(dto));
+    }
+
 
 
 }

+ 24 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/exUpdate/ExDTO.java

@@ -0,0 +1,24 @@
+package com.ktg.iscs.domain.dto.exUpdate;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.List;
+
+@EqualsAndHashCode(callSuper = false)
+@Data
+public class ExDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "钥匙状态")
+    private List<IsKeyExDTO> keyExDTOList;
+
+    @ApiModelProperty(value = "挂锁状态")
+    private List<IsLockExDTO> lockExDTOList;
+
+    @ApiModelProperty(value = "工卡状态")
+    private List<IsJobCardExDTO> jobCardExDTOList;
+
+}

+ 30 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/exUpdate/IsJobCardExDTO.java

@@ -0,0 +1,30 @@
+package com.ktg.iscs.domain.dto.exUpdate;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 工作卡对象 is_job_card
+ *
+ * @author cgj
+ * @date 2024-11-12
+ */
+@EqualsAndHashCode(callSuper = false)
+@Data
+public class IsJobCardExDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "工作卡NFC")
+    private String cardNfc;
+
+    @ApiModelProperty(value = "异常状态(0-异常 1-正常)")
+    private String exStatus;
+
+    @ApiModelProperty(value = "异常备注")
+    private String exRemark;
+
+}

+ 29 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/exUpdate/IsKeyExDTO.java

@@ -0,0 +1,29 @@
+package com.ktg.iscs.domain.dto.exUpdate;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 钥匙对象 is_key
+ *
+ * @author cgj
+ * @date 2024-11-19
+ */
+@EqualsAndHashCode(callSuper = false)
+@Data
+public class IsKeyExDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "钥匙NFC")
+    private String keyNfc;
+
+    @ApiModelProperty(value = "异常状态(0-异常 1-正常)")
+    private String exStatus;
+
+    @ApiModelProperty(value = "异常备注")
+    private String exRemark;
+
+}

+ 29 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/exUpdate/IsLockExDTO.java

@@ -0,0 +1,29 @@
+package com.ktg.iscs.domain.dto.exUpdate;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 挂锁对象 is_lock
+ *
+ * @author cgj
+ * @date 2024-11-19
+ */
+@EqualsAndHashCode(callSuper = false)
+@Data
+public class IsLockExDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "挂锁NFC")
+    private String lockNfc;
+
+    @ApiModelProperty(value = "异常状态(0-异常 1-正常)")
+    private String exStatus;
+
+    @ApiModelProperty(value = "异常备注")
+    private String exRemark;
+
+}

+ 6 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/key/IsKeyVO.java

@@ -53,4 +53,10 @@ public class IsKeyVO extends BaseBean
     @ApiModelProperty(value = "规格型号")
     private String keySpec;
 
+    @ApiModelProperty(value = "异常状态(0-异常 1-正常)")
+    private String exStatus;
+
+    @ApiModelProperty(value = "异常备注")
+    private String exRemark;
+
 }

+ 6 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/lock/IsLockVO.java

@@ -56,4 +56,10 @@ public class IsLockVO extends BaseBean
     @ApiModelProperty(value = "规格型号")
     private String lockSpec;
 
+    @ApiModelProperty(value = "异常状态(0-异常 1-正常)")
+    private String exStatus;
+
+    @ApiModelProperty(value = "异常备注")
+    private String exRemark;
+
 }

+ 2 - 0
ktg-iscs/src/main/java/com/ktg/iscs/mapper/IsJobTicketPointsMapper.java

@@ -68,4 +68,6 @@ public interface IsJobTicketPointsMapper extends BaseMapperX<IsJobTicketPoints>
     List<IsJobTicketPointsVO> getListByTicketId(@Param(value = "ticketId") Long ticketId);
 
     List<IsJobTicketPoints> getFinishConflictJob(@Param(value = "pointId") Long pointId, @Param(value = "lockId") Long lockId);
+
+    List<IsJobTicketPoints> getNotFinishConflictJob(@Param(value = "pointId") Long pointId, @Param(value = "lockId") Long lockId);
 }

+ 8 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/HardwareApiService.java

@@ -1,5 +1,6 @@
 package com.ktg.iscs.service;
 
+import com.ktg.iscs.domain.dto.exUpdate.ExDTO;
 import com.ktg.iscs.domain.dto.hardwareApi.*;
 import com.ktg.iscs.domain.vo.hardwareApi.JobTicketVO;
 
@@ -115,5 +116,12 @@ public interface HardwareApiService {
      */
     Boolean checkBeforeToUnlock(Long ticketId);
 
+    /**
+     * 批量更新硬件状态
+     * @param dto
+     * @return
+     */
+    Boolean updateHardwareEsStatus(ExDTO dto);
+
 
 }

+ 8 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/IIsJobTicketPointsService.java

@@ -71,4 +71,12 @@ public interface IIsJobTicketPointsService extends IService<IsJobTicketPoints>
      * @return
      */
     List<IsJobTicketPoints> getFinishConflictJob(Long pointId, Long lockId);
+
+    /**
+     * 查询未完成的作业,但是去了钥匙去解锁
+     * @param pointId
+     * @param lockId  点位的上锁属性
+     * @return
+     */
+    List<IsJobTicketPoints> getNotFinishConflictJob(Long pointId, Long lockId);
 }

+ 64 - 4
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/HardwareApiServiceImpl.java

@@ -6,6 +6,10 @@ import com.ktg.common.core.redis.RedisCache;
 import com.ktg.common.utils.SecurityUtils;
 import com.ktg.common.utils.bean.BeanUtils;
 import com.ktg.iscs.domain.*;
+import com.ktg.iscs.domain.dto.exUpdate.ExDTO;
+import com.ktg.iscs.domain.dto.exUpdate.IsJobCardExDTO;
+import com.ktg.iscs.domain.dto.exUpdate.IsKeyExDTO;
+import com.ktg.iscs.domain.dto.exUpdate.IsLockExDTO;
 import com.ktg.iscs.domain.dto.hardwareApi.*;
 import com.ktg.iscs.domain.enums.*;
 import com.ktg.iscs.domain.vo.hardwareApi.*;
@@ -14,14 +18,15 @@ import com.ktg.iscs.domain.vo.ticket.JobTicketDetailVO;
 import com.ktg.iscs.domain.vo.ticket.JobTicketUpdateProgressReqVO;
 import com.ktg.iscs.domain.vo.ticketPoints.IsJobTicketPointsVO;
 import com.ktg.iscs.service.*;
-import com.ktg.system.domain.vo.IsSystemAttributeVO;
-import com.sun.org.apache.bcel.internal.generic.NEW;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -493,10 +498,15 @@ public class HardwareApiServiceImpl implements HardwareApiService {
      * 解锁时,解除因为点位冲突而没有被解除的点位数据
      */
     public void updateConflictPoints(Long pointId, Long unlockedByKeyId, Date date, Long lockId) {
+        // 查询当前点位是否有取了钥匙去解锁的作业票,如果有则更新
+        List<IsJobTicketPoints> notFinishConflictJob = iIsJobTicketPointsService.getNotFinishConflictJob(pointId, lockId);
         // 查询当前点位是否有已经完成的作业票,但是该点位没有解锁的
         List<IsJobTicketPoints> finishConflictJob = iIsJobTicketPointsService.getFinishConflictJob(pointId, lockId);
+        finishConflictJob.addAll(notFinishConflictJob);
+        HashSet<IsJobTicketPoints> isJobTicketPoints1 = new HashSet<>(finishConflictJob);
+        // 查询都是去解锁的
         if (!finishConflictJob.isEmpty()) {
-            for (IsJobTicketPoints isJobTicketPoints : finishConflictJob) {
+            for (IsJobTicketPoints isJobTicketPoints : isJobTicketPoints1) {
                 // 2.1.1更新隔离点解锁信息
                 iIsJobTicketPointsService.update(Wrappers.<IsJobTicketPoints>lambdaUpdate()
                         .eq(IsJobTicketPoints::getRecordId, isJobTicketPoints.getRecordId())
@@ -901,4 +911,54 @@ public class HardwareApiServiceImpl implements HardwareApiService {
         }
         return true;
     }
+
+    @Override
+    public Boolean updateHardwareEsStatus(ExDTO dto) {
+        // 1.开始更新钥匙
+        if (!dto.getKeyExDTOList().isEmpty()) {
+            List<String> keyNfcList = dto.getKeyExDTOList().stream().map(IsKeyExDTO::getKeyNfc).collect(Collectors.toList());
+            List<IsKey> isKeyList = isKeyService.list(Wrappers.<IsKey>lambdaQuery()
+                    .in(IsKey::getKeyNfc, keyNfcList));
+            for (IsKey isKey : isKeyList) {
+                for (IsKeyExDTO isKeyExDTO : dto.getKeyExDTOList()) {
+                    if (isKey.getKeyNfc().equals(isKeyExDTO.getKeyNfc())) {
+                        isKey.setExStatus(isKeyExDTO.getExStatus());
+                        isKey.setExRemark(isKeyExDTO.getExRemark());
+                    }
+                }
+            }
+            isKeyService.updateBatchById(isKeyList);
+        }
+        // 2.开始更新挂锁
+        if (!dto.getLockExDTOList().isEmpty()) {
+            List<String> lockNfcList = dto.getLockExDTOList().stream().map(IsLockExDTO::getLockNfc).collect(Collectors.toList());
+            List<IsLock> isLockList = iIsLockService.list(Wrappers.<IsLock>lambdaQuery()
+                    .in(IsLock::getLockNfc, lockNfcList));
+            for (IsLock isLock : isLockList) {
+                for (IsLockExDTO isLockExDTO : dto.getLockExDTOList()) {
+                    if (isLock.getLockNfc().equals(isLockExDTO.getLockNfc())) {
+                        isLock.setExStatus(isLockExDTO.getExStatus());
+                        isLock.setExRemark(isLockExDTO.getExRemark());
+                    }
+                }
+            }
+            iIsLockService.updateBatchById(isLockList);
+        }
+        // 3.开始更新挂锁
+        if (!dto.getJobCardExDTOList().isEmpty()) {
+            List<String> cardNfcList = dto.getJobCardExDTOList().stream().map(IsJobCardExDTO::getCardNfc).collect(Collectors.toList());
+            List<IsJobCard> cardList = iIsJobCardService.list(Wrappers.<IsJobCard>lambdaQuery()
+                    .in(IsJobCard::getCardNfc, cardNfcList));
+            for (IsJobCard isJobCard : cardList) {
+                for (IsJobCardExDTO isJobCardExDTO : dto.getJobCardExDTOList()) {
+                    if (isJobCard.getCardNfc().equals(isJobCardExDTO.getCardNfc())) {
+                        isJobCard.setExStatus(isJobCardExDTO.getExStatus());
+                        isJobCard.setExRemark(isJobCardExDTO.getExRemark());
+                    }
+                }
+            }
+            iIsJobCardService.updateBatchById(cardList);
+        }
+        return true;
+    }
 }

+ 5 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsJobTicketPointsServiceImpl.java

@@ -110,4 +110,9 @@ public class IsJobTicketPointsServiceImpl extends ServiceImpl<IsJobTicketPointsM
     public List<IsJobTicketPoints> getFinishConflictJob(Long pointId, Long lockId) {
         return isJobTicketPointsMapper.getFinishConflictJob(pointId, lockId);
     }
+
+    @Override
+    public List<IsJobTicketPoints> getNotFinishConflictJob(Long pointId, Long lockId) {
+        return isJobTicketPointsMapper.getNotFinishConflictJob(pointId, lockId);
+    }
 }

+ 1 - 1
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsJobTicketServiceImpl.java

@@ -574,7 +574,7 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
                     handleJobStatus(isJobTicket, jobUserList, reqVO.userId, false, reqVO.equipStatus);
                 } else {
                     log.warn("Job ticket status is processing, cannot update progress, ticketId: {}, userId : {}", reqVO.ticketId, reqVO.userId);
-                    throw exception(JOB_TICKET_STATUS_NOT_PERMITTED);
+                    //throw exception(JOB_TICKET_STATUS_NOT_PERMITTED);
                 }
             }
         } else if (matchUserList.stream().anyMatch(user -> Objects.equals(user.getUserRole(), isSystemAttributeService.getIsSystemAttributeByKey("role.jtcolocker").getSysAttrValue()))) {

+ 9 - 1
ktg-iscs/src/main/resources/mapper/IsJobCardMapper.xml

@@ -18,10 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
         <result property="updateBy"    column="update_by"    />
+        <result property="exStatus"    column="ex_status"    />
+        <result property="exRemark"    column="ex_remark"    />
     </resultMap>
 
     <sql id="selectIsJobCardVo">
-        select card_id, card_code, hardware_id, card_nfc, card_type, user_id, user_name, remark, del_flag, create_by, create_time, update_time, update_by from is_job_card
+        select * from is_job_card
     </sql>
 
     <select id="selectIsJobCardList" parameterType="IsJobCard" resultMap="IsJobCardResult">
@@ -56,6 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="updateBy != null">update_by,</if>
+            <if test="exStatus != null and exStatus != ''">ex_status,</if>
+            <if test="exRemark != null and exRemark != ''">ex_remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="cardCode != null and cardCode != ''">#{cardCode},</if>
@@ -70,6 +74,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
+            <if test="exStatus != null and exStatus != ''">#{exStatus},</if>
+            <if test="exRemark != null and exRemark != ''">#{exRemark},</if>
          </trim>
     </insert>
 
@@ -88,6 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="exStatus != null and exStatus != ''">ex_status = #{exStatus},</if>
+            <if test="exRemark != null and exRemark != ''">ex_remark = #{exRemark},</if>
         </trim>
         where card_id = #{cardId}
     </update>

+ 16 - 0
ktg-iscs/src/main/resources/mapper/IsJobTicketPointsMapper.xml

@@ -147,5 +147,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND p.point_id = #{pointId}
           AND p.lock_id = #{lockId}
     </select>
+    <select id="getNotFinishConflictJob" resultType="com.ktg.iscs.domain.IsJobTicketPoints">
+        SELECT
+            p.*
+        FROM
+            is_job_ticket_points p
+                LEFT JOIN is_job_ticket t ON t.ticket_id = p.ticket_id
+                LEFT JOIN is_job_ticket_key k ON k.ticket_id = p.ticket_id and k.ticket_type = "1"
+        WHERE
+            t.ticket_status &lt; 5
+          AND p.point_status = "1"
+          AND p.unlocked_by_key_id IS NULL
+          AND p.point_id = #{pointId}
+          AND p.lock_id = #{lockId}
+          AND k.collect_time IS NOT NULL
+
+    </select>
 
 </mapper>

+ 9 - 1
ktg-iscs/src/main/resources/mapper/IsKeyMapper.xml

@@ -17,7 +17,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="remark"    column="remark"    />
-        <result property="keySpec"    column="keySpec"    />
+        <result property="keySpec"    column="key_spec"    />
+        <result property="exStatus"    column="ex_status"    />
+        <result property="exRemark"    column="ex_remark"    />
     </resultMap>
 
     <sql id="selectIsKeyVo">
@@ -55,6 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="remark != null and remark != ''">remark,</if>
             <if test="keySpec != null and keySpec != ''">key_spec,</if>
+            <if test="exStatus != null and exStatus != ''">ex_status,</if>
+            <if test="exRemark != null and exRemark != ''">ex_remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="keyCode != null and keyCode != ''">#{keyCode},</if>
@@ -69,6 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="remark != null and remark != ''">#{remark},</if>
             <if test="keySpec != null and keySpec != ''">#{keySpec},</if>
+            <if test="exStatus != null and exStatus != ''">#{exStatus},</if>
+            <if test="exRemark != null and exRemark != ''">#{exRemark},</if>
          </trim>
     </insert>
 
@@ -87,6 +93,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="remark != null and remark != ''">remark = #{remark},</if>
             <if test="keySpec != null and keySpec != ''">key_spec = #{keySpec},</if>
+            <if test="exStatus != null and exStatus != ''">ex_status = #{exStatus},</if>
+            <if test="exRemark != null and exRemark != ''">ex_remark = #{exRemark},</if>
         </trim>
         where key_id = #{keyId}
     </update>

+ 8 - 0
ktg-iscs/src/main/resources/mapper/IsLockMapper.xml

@@ -18,6 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="remark"    column="remark"    />
         <result property="lockSpec"    column="lock_spec"    />
+        <result property="exStatus"    column="ex_status"    />
+        <result property="exRemark"    column="ex_remark"    />
     </resultMap>
 
     <sql id="selectIsLockVo">
@@ -55,6 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="remark != null and remark != ''">remark,</if>
             <if test="lockSpec != null and lockSpec != ''">lock_spec,</if>
+            <if test="exStatus != null and exStatus != ''">ex_status,</if>
+            <if test="exRemark != null and exRemark != ''">ex_remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="lockCode != null and lockCode != ''">#{lockCode},</if>
@@ -69,6 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="remark != null and remark != ''">#{remark},</if>
             <if test="lockSpec != null and lockSpec != ''">#{lockSpec},</if>
+            <if test="exStatus != null and exStatus != ''">#{exStatus},</if>
+            <if test="exRemark != null and exRemark != ''">#{exRemark},</if>
          </trim>
     </insert>
 
@@ -87,6 +93,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="remark != null and remark != ''">remark = #{remark},</if>
             <if test="lockSpec != null and lockSpec != ''">lock_spec = #{lockSpec},</if>
+            <if test="exStatus != null and exStatus != ''">ex_status = #{exStatus},</if>
+            <if test="exRemark != null and exRemark != ''">ex_remark = #{exRemark},</if>
         </trim>
         where lock_id = #{lockId}
     </update>