From 279a149dd1ff4ef7a7a9353469532332d3fdcb5f Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期四, 20 六月 2024 14:28:35 +0800
Subject: [PATCH] check user and station relation

---
 pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml         |    2 
 pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java         |    4 
 pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml                                |   13 +-
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java               |    2 
 pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java           |  143 ++++++++++++++++++++++------
 pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml                            |   24 ++++
 pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml                   |   63 ++++++++++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java      |    3 
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java |    3 
 9 files changed, 218 insertions(+), 39 deletions(-)

diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
index eadc2a7..59d4077 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPlt/PltStationMapper.java
@@ -32,4 +32,6 @@
     List<PltStation> selectAll();
 
     String selectMaxCode();
+
+    List<PltStation> selectStationList(PltStation record);
 }
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java
index 2d41956..7b8c1b0 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoSta/StaAssemblyWorkLastMapper.java
@@ -3,6 +3,8 @@
 import com.dy.pmsGlobal.pojoSta.StaAssemblyWorkLast;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
 * @author User
 * @description 閽堝琛ㄣ�恠ta_assembly_work_last(鐢熶骇绾跨敓浜т换鍔¤棰嗚〃)銆戠殑鏁版嵁搴撴搷浣淢apper
@@ -24,4 +26,5 @@
 
     int updateByPrimaryKey(StaAssemblyWorkLast record);
 
+    List<StaAssemblyWorkLast> selectList(StaAssemblyWorkLast record);
 }
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java
index 9c056ff..03020de 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoPlt/PltProductTestInspectionItems.java
@@ -38,6 +38,9 @@
     @NotNull(message = "浜у搧瀹炰綋缂栧彿涓嶈兘涓虹┖")
     public Long proId;
 
+    @TableField(exist = false)
+    public String proName;
+
     /**
      * 娴嬭瘯椤圭洰
      */
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
index 6062cef..ab18a26 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaUserMapper.xml
@@ -50,6 +50,11 @@
   <select id="selectNameByUserId" parameterType="java.lang.Long" resultType="java.lang.String">
     select name from ba_user where id=#{id}
   </select>
+
+  <select id="selectNameById" parameterType="java.lang.Long" resultType="java.lang.String">
+    select name from ba_user where id=#{id}
+  </select>
+
   <select id="selectCount" resultType="java.lang.Long">
     select
       count(*)
@@ -68,9 +73,8 @@
     select 
     <include refid="Base_Column_List" />
     from ba_user
-    where id = #{id}
+    where id = #{id} and disabled!=1 and deleted!=1
   </select>
-
 
   <select id="selectSomeCount" parameterType="java.util.Map" resultType="java.lang.Long">
     select
@@ -122,11 +126,6 @@
       </if>
     </trim>
   </select>
-
-  <select id="selectNameById" parameterType="java.lang.Long" resultType="java.lang.String">
-    select name from ba_user where id=#{id}
-  </select>
-
 
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     <!--@mbg.generated-->
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml
index 3340f44..f4e0ffc 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/PltProductTestInspectionItemsMapper.xml
@@ -11,6 +11,8 @@
             <result property="deleted" column="deleted" jdbcType="TINYINT"/>
             <result property="disabled" column="disabled" jdbcType="TINYINT"/>
             <result property="sort" column="sort" jdbcType="INTEGER"/>
+            <association property="proName" column="pro_id" javaType="java.lang.Long"
+                     select="com.dy.pmsGlobal.daoPlt.PltProductMapper.selectProNameById" fetchType="eager" />
     </resultMap>
 
     <sql id="Base_Column_List">
diff --git a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
index 5e4c28c..aa94d68 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/PltStationMapper.xml
@@ -94,6 +94,30 @@
         </trim>
     </select>
 
+    <select id="selectStationList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from plt_station where deleted!=1
+        <trim prefix="and" suffixOverrides="and">
+            <if test="id != null and id !=''">
+                id = #{id,jdbcType=BIGINT} and
+            </if>
+            <if test="code != null and code !=''">
+                code = #{code,jdbcType=VARCHAR} and
+            </if>
+            <if test="name != null and name !=''">
+                name  like concat('%', #{name}, '%') and
+            </if>
+            <if test="disabled != null and disabled !=''">
+                disabled = #{disabled,jdbcType=TINYINT} and
+            </if>
+            <if test="lineId != null and lineId !=''">
+                line_id = #{lineId,jdbcType=BIGINT} and
+            </if>
+        </trim>
+        order by id desc
+    </select>
+
     <select id="selectSomeCount" resultType="java.lang.Long">
         select count(1)
         from plt_station where deleted!=1
diff --git a/pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml
index c307fd9..eb7476b 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/StaAssemblyWorkLastMapper.xml
@@ -33,6 +33,69 @@
         where  id = #{id,jdbcType=BIGINT} 
     </select>
 
+    <select id="selectByUserAndStation" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from plt_station where status ==1
+        <trim prefix="and" suffixOverrides="and">
+            <if test="id != null and id !=''">
+                id = #{id,jdbcType=BIGINT} and
+            </if>
+            <if test="code != null and code !=''">
+                code = #{code,jdbcType=VARCHAR} and
+            </if>
+            <if test="name != null and name !=''">
+                name  like concat('%', #{name}, '%') and
+            </if>
+            <if test="disabled != null and disabled !=''">
+                disabled = #{disabled,jdbcType=TINYINT} and
+            </if>
+            <if test="lineId != null and lineId !=''">
+                line_id = #{lineId,jdbcType=BIGINT} and
+            </if>
+        </trim>
+        order by id desc
+    </select>
+
+    <select id="selectList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from sta_assembly_work_last
+        <where>
+            <if test="userId != null and userId !=''">
+              and user_id = #{userId,jdbcType=BIGINT}
+            </if>
+            <if test="lineId != null and lineId !=''">
+              and line_id = #{lineId,jdbcType=BIGINT}
+            </if>
+            <if test="stationId != null and stationId !=''">
+              and station_id = #{stationId,jdbcType=BIGINT}
+            </if>
+            <if test="planId != null and planId !=''">
+              and plan_id = #{planId,jdbcType=BIGINT}
+            </if>
+            <if test="processId != null and processId !=''">
+              and process_id = #{processId,jdbcType=BIGINT}
+            </if>
+            <if test="nodeId != null and nodeId !=''">
+              and node_id = #{nodeId,jdbcType=BIGINT}
+            </if>
+            <if test="status != null and status !=''">
+              and status = #{status,jdbcType=TINYINT}
+            </if>
+            <if test="startTime != null and startTime !=''">
+                and start_time = #{startTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="endTime != null and userId !=''">
+                and  end_time = #{endTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="assistants != null and assistants !=''">
+                and assistants = #{assistants,jdbcType=VARCHAR}
+            </if>
+        </where>
+        order by id desc
+    </select>
+
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
         delete from sta_assembly_work_last
         where  id = #{id,jdbcType=BIGINT} 
diff --git a/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java b/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java
index 4991de4..eecee9a 100644
--- a/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java
+++ b/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderCtrl.java
@@ -29,8 +29,8 @@
      */
     @GetMapping(path="isStationUsed")
     public BaseResponse<Boolean> isStationUsed(StaAssemblyWorkLast last){
-        String message = sv.isStationUsed(last);
-        if ("".equals(message)) {
+        String message = sv.checkStationIsUsed(last);
+        if ("OK".equals(message.split("^")[0])) {
             return BaseResponseUtils.buildSuccess(true);
         } else {
             return BaseResponseUtils.buildFail(message);
diff --git a/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java b/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java
index da4baf5..1e56963 100644
--- a/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java
+++ b/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java
@@ -2,7 +2,12 @@
 
 import com.alibaba.excel.util.StringUtils;
 import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.pmsGlobal.daoBa.BaUserMapper;
+import com.dy.pmsGlobal.daoPlt.PltStationMapper;
 import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
+import com.dy.pmsGlobal.daoSta.StaAssemblyWorkLastMapper;
+import com.dy.pmsGlobal.pojoBa.BaUser;
+import com.dy.pmsGlobal.pojoPlt.PltStation;
 import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
 import com.dy.pmsGlobal.pojoSta.StaAssemblyWorkLast;
 import lombok.extern.slf4j.Slf4j;
@@ -15,42 +20,120 @@
 @Service
 public class WorkOrderSv {
     private PrAssemblyPlanMapper assemblyDao;
+    private BaUserMapper baUserDao;
+    private PltStationMapper pltStationDao;
+    private StaAssemblyWorkLastMapper assemblyWorkLastDao;
+
     @Autowired
     public void setAssemblyDao(PrAssemblyPlanMapper assemblyDao) {
         this.assemblyDao = assemblyDao;
     }
-
-    public String isStationUsed(StaAssemblyWorkLast last){
-        String stationId = "";
-        String userId = "";
-        //鍒ゆ柇鍝釜鏄汉鍛�, 鍝釜鏄伐绔欎俊鎭�
-       /* if(last.getStationId() != null && last.getStationId().toString().startsWith("103")){
-
-        }
-        if(last.getUserId() != null && last.getStationId().toString().startsWith("103")){
-
-        }
-        PrAssemblyPlan params = new PrAssemblyPlan();
-        params.setStatus(1);
-        List<PrAssemblyPlan> list = sv.selectList(params);
-        return BaseResponseUtils.buildSuccess(list);
-
-
-        log.info("鑾峰彇宸ョ珯缂栧彿");
-        String maxCode = dao.selectMaxCode();
-        if (StringUtils.isBlank(maxCode)) {
-            return DEFAULT_CODE;
-        } else {
-            int nextCode = Integer.parseInt(maxCode) + 1;
-            // 妫�鏌ユ孩鍑�
-            if (nextCode > 9999) {
-                throw new RuntimeException("宸ョ珯缂栧彿婧㈠嚭");
-            }
-            return String.format(CODE_FORMAT, nextCode);
-        }*/
-        return "OK";
+    @Autowired
+    private void setBaUserDao(BaUserMapper baUserDao){
+        this.baUserDao = baUserDao;
+    }
+    @Autowired
+    private void setPltStationDao(PltStationMapper pltStationDao){
+        this.pltStationDao = pltStationDao;
+    }
+    @Autowired
+    private void setStaAssemblyWorkLastDao(StaAssemblyWorkLastMapper assemblyWorkLastDao){
+        this.assemblyWorkLastDao = assemblyWorkLastDao;
     }
 
+    public String checkUser(Long id){
+        Long userId = id;
+        String message = "USER";
+        //宸ョ珯103
+        if(userId != null && userId.toString().startsWith("103")){
+            message = checkStation(id);
+            return message;
+        }
+        if(userId == null){
+            message = "FALSE^鍛樺伐缂栫爜涓嶈兘涓虹┖";
+            return message;
+        }
+        //鐢ㄦ埛101
+        if(userId.toString().startsWith("101")){
+            userId = Long.parseLong(userId.toString().substring(3));
+        }
+        BaUser userInfo = baUserDao.selectByPrimaryKey(userId);
+        if(userInfo == null){
+            message = "FALSE^鍛樺伐缂栫爜涓嶅湪绯荤粺涓�,璇峰厛缁存姢鍛樺伐淇℃伅";
+        }
+        message += "^"+ userId;
+        return message;
+    }
+
+    public String checkStation(Long id){
+        Long stationId = id;
+        String message = "STATION";
+        //鐢ㄦ埛101
+        if(stationId != null && stationId.toString().startsWith("101")){
+            message = checkUser(id);
+            return message;
+        }
+        if(stationId == null){
+            message = "FALSE^宸ョ珯缂栫爜涓嶈兘涓虹┖";
+            return message;
+        }
+        //宸ョ珯103
+        if(stationId.toString().startsWith("103")){
+            stationId = Long.parseLong(stationId.toString().substring(3));
+        }
+        PltStation record = new PltStation();
+        record.setId(stationId);
+        List<PltStation> stationInfo = pltStationDao.selectStationList(record);
+        if(stationInfo.size() == 0){
+            message = "FALSE^宸ョ珯缂栫爜涓嶅湪绯荤粺涓�,璇峰厛缁存姢宸ョ珯淇℃伅";
+            return message;
+        }
+       //妫�鏌ュ伐绔�
+        message += "^"+ stationId;
+        return message;
+    }
+    public String checkStationIsUsed(StaAssemblyWorkLast last){
+        String message = "OK";
+        Long userId = null;
+        Long stationId = null;
+        String userMsg = checkUser(last.getUserId());
+        String stationMsg = checkStation(last.getStationId());
+        if(userMsg.startsWith("FALSE") || stationMsg.startsWith("FALSE")){
+            if(userMsg.startsWith("FALSE") && stationMsg.startsWith("FALSE")){
+                message = userMsg +","+ stationMsg.split("^")[1];
+            }else if(userMsg.startsWith("FALSE")){
+                message = userMsg;
+            }else if(stationMsg.startsWith("FALSE")){
+                message = stationMsg;
+            }
+            return message;
+        }else{//鏍规嵁缁撴灉 鎵惧埌瀵瑰簲鐨処D鍊�
+            if(userMsg.startsWith("USER")){
+                userId =  Long.parseLong(userMsg.split("^")[1]);
+            }else if(userMsg.startsWith("STATION")){
+                stationId = Long.parseLong(userMsg.split("^")[1]);
+            }
+            if(stationMsg.startsWith("USER")){
+                userId =  Long.parseLong(stationMsg.split("^")[1]);
+            }else if(stationMsg.startsWith("STATION")){
+                stationId = Long.parseLong(stationMsg.split("^")[1]);
+            }
+        }
+        if(userId == null || stationId == null){
+            message = "FALSE^鍛樺伐缂栫爜:"+ last.getUserId() + "鎴栧伐绔欑紪鐮�:" + last.getStationId() + "涓嶆纭�,璇锋鏌�";
+            return message;
+        }
+        //妫�鏌ヨ〃涓槸涓嶆槸宸茬粡瀛樺湪
+        StaAssemblyWorkLast param = new StaAssemblyWorkLast();
+        param.setUserId(userId);
+        param.setStationId(stationId);
+        param.setStatus(1);
+        List<StaAssemblyWorkLast> userStationList = assemblyWorkLastDao.selectList(param);
+        if(userStationList.size() > 0){
+            message = "FALSE^鍛樺伐缂栫爜:"+ userStationList.get(0).getUserId() + "宸茬粡缁戝畾璇ュ伐绔欑紪鐮�:" + userStationList.get(0).getStationId() + ".璇峰厛璁╁叾瑙g粦";
+        }//message = "OK^鍛樺伐缂栫爜:"+ userId+ "宸茬粡缁戝畾璇ュ伐绔欑紪鐮�:" + stationId + ".楠岃瘉閫氳繃";
+        return message;
+    }
     public List<PrAssemblyPlan> selectList(PrAssemblyPlan params){
         List<PrAssemblyPlan> planList = assemblyDao.selectList(params);
         return planList;

--
Gitblit v1.8.0