Browse Source

新增作业票时新增挂锁、钥匙、锁具等数据

车车 11 tháng trước cách đây
mục cha
commit
1a92ff6419

+ 8 - 5
ktg-iscs/src/main/java/com/ktg/iscs/domain/IsJobTicketKey.java

@@ -1,14 +1,15 @@
 package com.ktg.iscs.domain;
 
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import io.swagger.annotations.ApiModelProperty;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.IdType;
-import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ktg.common.annotation.Excel;
 import com.ktg.common.core.domain.model.BaseBean;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
 
 /**
  * 作业票钥匙对象 is_job_ticket_key
@@ -59,5 +60,7 @@ public class IsJobTicketKey extends BaseBean
     @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
     private String delFlag;
 
+    @ApiModelProperty(value = "作业锁类型(0-上锁 1-解锁)")
+    private Integer ticketType;
 
 }

+ 9 - 9
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/materialsReminder/MaterialsReminderVO.java

@@ -58,13 +58,13 @@ public class MaterialsReminderVO extends BaseBean
     private String loanFromName;
 
     @ApiModelProperty(value = "领取时间")
-    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
-    @Excel(name = "领取时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "领取时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date loanTime;
 
     @ApiModelProperty(value = "提醒时间")
-    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
-    @Excel(name = "提醒时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "提醒时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date reminderTime;
 
     @ApiModelProperty(value = "归还人ID")
@@ -76,18 +76,18 @@ public class MaterialsReminderVO extends BaseBean
     private Long restitutionToId;
 
     @ApiModelProperty(value = "理应归还时间")
-    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
-    @Excel(name = "理应归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "理应归还时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date restitutionTime;
 
     @ApiModelProperty(value = "实际归还时间")
     @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
-    @Excel(name = "实际归还时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "实际归还时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date actualRestitutionTime;
 
     @ApiModelProperty(value = "超时报警")
-    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
-    @Excel(name = "超时报警", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "超时报警", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date timeoutAlarm;
 
     @ApiModelProperty(value = "是否需要归还")

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

@@ -7,9 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
 import com.ktg.common.utils.DateUtils;
 import com.ktg.common.utils.bean.BeanUtils;
-import com.ktg.iscs.domain.IsJobTicket;
-import com.ktg.iscs.domain.IsJobTicketPoints;
-import com.ktg.iscs.domain.IsJobTicketUser;
+import com.ktg.iscs.domain.*;
 import com.ktg.iscs.domain.dto.ticket.AddJobTicketDTO;
 import com.ktg.iscs.domain.dto.ticket.AddTicketUserDTO;
 import com.ktg.iscs.domain.dto.ticket.PageTicketDTO;
@@ -20,19 +18,14 @@ import com.ktg.iscs.domain.vo.ticket.JobTicketDetailVO;
 import com.ktg.iscs.domain.vo.ticket.JobTicketUpdateProgressReqVO;
 import com.ktg.iscs.domain.vo.ticket.PageTicketVO;
 import com.ktg.iscs.mapper.IsJobTicketMapper;
-import com.ktg.iscs.service.IIsIsolationPointService;
-import com.ktg.iscs.service.IIsJobTicketPointsService;
-import com.ktg.iscs.service.IIsJobTicketService;
-import com.ktg.iscs.service.IIsJobTicketUserService;
+import com.ktg.iscs.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static com.ktg.iscs.domain.constant.ErrorCodeConstants.*;
@@ -59,6 +52,13 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
     private IIsJobTicketUserService iIsJobTicketUserService;
     @Autowired
     private IIsIsolationPointService iIsIsolationPointService;
+    @Autowired
+    private IIsJobTicketKeyService iIsJobTicketKeyService;
+    @Autowired
+    private IIsJobTicketLockService iIsJobTicketLockService;
+    @Autowired
+    private IIsJobTicketLocksetService iIsJobTicketLocksetService;
+
 
     /**
      * 查询作业票
@@ -115,7 +115,6 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
         // 1.断言判断必填
         Assert.isTrue(StringUtils.isNotBlank(dto.getTicketCode()), "作业票编号不可为空!");
         Assert.isTrue(StringUtils.isNotBlank(dto.getTicketName()), "作业票名称不可为空!");
-        Assert.notNull(dto.getWorkshopId(), "所属车间不可为空!");
         Assert.isTrue(StringUtils.isNotBlank(dto.getPointIds()), "请选择隔离点!");
         Assert.isFalse(dto.getTicketUserDTOList().isEmpty(), "人员信息不可为空!");
         // 1.1检查作业票编码是否唯一
@@ -133,17 +132,15 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
         for (Long pointId : pointIds) {
             IsJobTicketPoints isJobTicketPoints = new IsJobTicketPoints();
             isJobTicketPoints.setTicketId(jobTicket.getTicketId());
-            isJobTicketPoints.setWorkshopId(dto.getWorkshopId());
             isJobTicketPoints.setWorkareaId(dto.getWorkareaId());
             isJobTicketPoints.setPointId(pointId);
             iIsJobTicketPointsService.save(isJobTicketPoints);
         }
-        // 3.1新增作业票和钥匙的关联关系
-        
-        // 3.2新增作业票和挂锁的关联关系
-
-        // 3.3新增作业票和锁具的关联关系
-
+        // 3.1新增作业票和钥匙的关联关系(两条数据,一条上锁,一条解锁)
+        saveJobTicketKet(jobTicket.getTicketId());
+        // 3.2新增作业票和挂锁的关联关// 3.3新增作业票和锁具的关联关系
+        List<IsIsolationPoint> pointList = iIsIsolationPointService.listByIds(Arrays.asList(pointIds));
+        saveJobTicketLockAndSet(pointList, jobTicket.getTicketId());
 
         // 4.新增人员信息
         for (AddTicketUserDTO addTicketUserDTO : dto.getTicketUserDTOList()) {
@@ -157,6 +154,49 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
         return true;
     }
 
+    /**
+     * 3.1新增作业票和钥匙的关联关系(两条数据,一条上锁,一条解锁)
+     * @return b
+     */
+    private boolean saveJobTicketKet(Long ticketId) {
+        IsJobTicketKey isJobTicketKey = new IsJobTicketKey();
+        isJobTicketKey.setTicketId(ticketId);
+        isJobTicketKey.setTicketType(0);
+
+        IsJobTicketKey jobTicketKey = new IsJobTicketKey();
+        jobTicketKey.setTicketId(ticketId);
+        jobTicketKey.setTicketType(1);
+
+        List<IsJobTicketKey> isJobTicketKeys = new ArrayList<>();
+        isJobTicketKeys.add(isJobTicketKey);
+        isJobTicketKeys.add(jobTicketKey);
+        return iIsJobTicketKeyService.saveBatch(isJobTicketKeys);
+    }
+
+    private boolean saveJobTicketLockAndSet(List<IsIsolationPoint> pointList, Long ticketId) {
+        ArrayList<IsJobTicketLock> isJobTicketLocks = new ArrayList<>();
+        ArrayList<IsJobTicketLockset> isJobTicketLocksets = new ArrayList<>();
+        for (IsIsolationPoint point : pointList) {
+            if (point.getLockTypeId() != null) {
+                IsJobTicketLock isJobTicketLock = new IsJobTicketLock();
+                isJobTicketLock.setTicketId(ticketId);
+                isJobTicketLock.setLockStatus("0");
+                isJobTicketLocks.add(isJobTicketLock);
+            }
+            if (point.getLocksetTypeId() != null) {
+                IsJobTicketLockset isJobTicketLockset = new IsJobTicketLockset();
+                isJobTicketLockset.setJobTicketId(ticketId);
+                isJobTicketLockset.setLocksetStatus("0");
+                isJobTicketLockset.setLocksetTypeId(point.getLocksetTypeId());
+                isJobTicketLocksets.add(isJobTicketLockset);
+            }
+        }
+        // 开始批量新增
+        iIsJobTicketLockService.saveBatch(isJobTicketLocks);
+        iIsJobTicketLocksetService.saveBatch(isJobTicketLocksets);
+        return true;
+    }
+
     /**
      * 修改作业票
      *

+ 11 - 7
ktg-iscs/src/main/resources/mapper/IsJobTicketKeyMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ktg.iscs.mapper.IsJobTicketKeyMapper">
-    
+
     <resultMap type="IsJobTicketKey" id="IsJobTicketKeyResult">
         <result property="recordId"    column="record_id"    />
         <result property="ticketId"    column="ticket_id"    />
@@ -19,15 +19,16 @@ 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="ticketType"    column="ticket_Type"    />
     </resultMap>
 
     <sql id="selectIsJobTicketKeyVo">
-        select record_id, ticket_id, key_id, from_hardware_id, to_hardware_id, collect_time, give_back_time, key_status, del_flag, create_by, create_time, update_time, update_by, remark from is_job_ticket_key
+        select * from is_job_ticket_key
     </sql>
 
     <select id="selectIsJobTicketKeyList" parameterType="IsJobTicketKey" resultMap="IsJobTicketKeyResult">
         <include refid="selectIsJobTicketKeyVo"/>
-        <where>  
+        <where>
             <if test="ticketId != null "> and ticket_id = #{ticketId}</if>
             <if test="keyId != null "> and key_id = #{keyId}</if>
             <if test="fromHardwareId != null "> and from_hardware_id = #{fromHardwareId}</if>
@@ -37,12 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="keyStatus != null  and keyStatus != ''"> and key_status = #{keyStatus}</if>
         </where>
     </select>
-    
+
     <select id="selectIsJobTicketKeyByRecordId" parameterType="Long" resultMap="IsJobTicketKeyResult">
         <include refid="selectIsJobTicketKeyVo"/>
         where record_id = #{recordId}
     </select>
-        
+
     <insert id="insertIsJobTicketKey" parameterType="IsJobTicketKey" useGeneratedKeys="true" keyProperty="recordId">
         insert into is_job_ticket_key
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -59,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="remark != null">remark,</if>
+            <if test="ticketType != null">ticket_Type,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="ticketId != null">#{ticketId},</if>
@@ -74,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">#{updateTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="remark != null">#{remark},</if>
+            <if test="ticketType != null">#{ticketType},</if>
          </trim>
     </insert>
 
@@ -93,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="ticketType != null">ticket_Type = #{ticketType},</if>
         </trim>
         where record_id = #{recordId}
     </update>
@@ -102,9 +106,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteIsJobTicketKeyByRecordIds" parameterType="String">
-        delete from is_job_ticket_key where record_id in 
+        delete from is_job_ticket_key where record_id in
         <foreach item="recordId" collection="array" open="(" separator="," close=")">
             #{recordId}
         </foreach>
     </delete>
-</mapper>
+</mapper>