Browse Source

feature 增加换线获取可选设备的接口

xiahan 1 year ago
parent
commit
cdf182e2f6

+ 3 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/dao/ApsProcessOperationProcessEquDao.java

@@ -5,6 +5,7 @@ import com.rongwei.bsentity.domain.ApsProcessOperationProcessEquDo;
 import com.rongwei.bsentity.domain.ApsProductDetailDo;
 import com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq;
 import com.rongwei.bsentity.vo.GanttVos;
+import com.rongwei.bsentity.vo.OptionalEquipmentVo;
 import com.rongwei.bsentity.vo.ProcessIdRelationVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -72,6 +73,8 @@ public interface ApsProcessOperationProcessEquDao extends BaseMapper<ApsProcessO
     void publish(@Param("productIdList") List<String> productIdList);
 
     void publishCancel(@Param("productIdList") List<String> productIdList);
+
+    List<OptionalEquipmentVo> getOptionalEquipmentById(@Param("idList")List<String> id);
 }
 
 

+ 6 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/ApsProcessOperationProcessEquService.java

@@ -2,9 +2,12 @@ package com.rongwei.bscommon.sys.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.ApsProcessOperationProcessEquDo;
+import com.rongwei.bsentity.vo.ChangingWiresVo;
 import com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq;
 import com.rongwei.rwcommon.base.R;
 
+import java.util.List;
+
 /**
  *
  */
@@ -14,4 +17,7 @@ public interface ApsProcessOperationProcessEquService extends IService<ApsProces
 
     String updateProcessByProcessEquId(String processOperationEquId);
 
+    R changingWires(List<ChangingWiresVo> changingWiresVos);
+
+    R getOptionalEquipment(List<String> operationJobDetailsId);
 }

+ 34 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProcessOperationProcessEquServiceImpl.java

@@ -7,7 +7,9 @@ import com.google.common.collect.Lists;
 import com.rongwei.bscommon.sys.dao.ApsProcessOperationProcessEquDao;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bsentity.domain.*;
+import com.rongwei.bsentity.vo.ChangingWiresVo;
 import com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq;
+import com.rongwei.bsentity.vo.OptionalEquipmentVo;
 import com.rongwei.bsentity.vo.ProcessIdRelationVo;
 import com.rongwei.rwcommon.base.R;
 import org.slf4j.Logger;
@@ -183,6 +185,38 @@ public class ApsProcessOperationProcessEquServiceImpl extends ServiceImpl<ApsPro
         return one.getProcessOperationId();
     }
 
+    /**
+     * 换线作业
+     * @param changingWiresVos
+     * @return
+     */
+    @Override
+    public R changingWires(List<ChangingWiresVo> changingWiresVos) {
+        return null;
+    }
+
+    /**
+     * 根据工序作业明细 获取可选设备
+     * @param operationJobDetailsId
+     * @return
+     */
+    @Override
+    public R getOptionalEquipment(List<String> operationJobDetailsId) {
+        if(operationJobDetailsId.isEmpty()){
+            log.error("工序作业明细必选");
+            return R.error("工序作业明细必选");
+        }
+        log.debug("根据工序作业明细:{},获取可选设备",operationJobDetailsId);
+        // 防止工序作业ID重复
+        operationJobDetailsId= operationJobDetailsId.stream().distinct().collect(Collectors.toList());
+        List<OptionalEquipmentVo> optionalEquipment = this.baseMapper.getOptionalEquipmentById(operationJobDetailsId);
+        if(optionalEquipment.isEmpty()){
+            log.error("当前所选作业不存在共同的加工设备");
+            return R.error("没有可共用的加工设备,无法合并换线");
+        }
+        return R.ok(optionalEquipment);
+    }
+
     private void updateBlank(String processOperationId) {
         //查询此工序的所属订单ID
         String orderId = this.baseMapper.selectOrderIdByProcessOperationId(processOperationId);

+ 2 - 2
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProcessOperationDao.xml

@@ -24,8 +24,8 @@
             ACTUALFINISHDATE = (select IF(COUNT(ID) !=0 ,NULL,NOW()) from aps_process_operation_process_equ where
             PROCESSID =#{id} and CLOSESTATUS !='已完工'),
             <!-- 完工状态-->
-            CLOSESTATUS = (select IF(COUNT(ID) !=0 ,'未完工','已完工') from aps_process_operation_process_equ where
-            PROCESSID =#{id} and CLOSESTATUS !='已完工'),
+#             CLOSESTATUS = (select IF(COUNT(ID) !=0 ,'未完工','已完工') from aps_process_operation_process_equ where
+#             PROCESSID =#{id} and CLOSESTATUS !='已完工'),
             <!-- 作业状态-->
             WORKSTATUS = (select IF(COUNT(ID) !=0 ,'加工中','已完工') from aps_process_operation_process_equ where
             PROCESSID =#{id} and CLOSESTATUS !='已完工'),

+ 46 - 17
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProcessOperationProcessEquDao.xml

@@ -66,10 +66,10 @@
                 <when test="previousprocessid == null and previousprocessid == ''">
                     <!-- 不存在上一个工序 未完工卷数等于0时 更新 为已完工  -->
                     <!-- 完工状态-->
-                    apope.CLOSESTATUS= CASE
-                    WHEN (apope.PLANPROCESSRALL - #{currentCheckNum}) = 0 THEN '已完工'
-                    ELSE '未完工'
-                    END,
+#                     apope.CLOSESTATUS= CASE
+#                     WHEN (apope.PLANPROCESSRALL - #{currentCheckNum}) = 0 THEN '已完工'
+#                     ELSE '未完工'
+#                     END,
                     <!--  作业状态-->
                     apope.WORKSTATUS= CASE
                     WHEN (apope.PLANPROCESSRALL -#{currentCheckNum}) = 0 THEN '已完工'
@@ -83,19 +83,19 @@
                 </when>
                 <otherwise>
                     <!-- 存在上一个工序 上道工序作业已完工 当前工序作业明细的已开工卷数=已检验卷数-->
-                    apope.CLOSESTATUS =
-                    CASE
-                    <!--并且当前工序明细的已开工卷数=已检验卷数-->
-                        WHEN
-                        (
-                        <!--并且上道工序作业已完工状态=已完工-->
-                         select (select apo.CLOSESTATUS='已完工' from aps_process_operation apo where apo.ID =#{previousprocessid} )
-                        <!--并且作业明细待加工料卷批次号数量-工序作业已取消卷数<=0-->
-                        and (select IFNULL(LENGTH(apope.BACHMATERIALPROCESS) - LENGTH(REPLACE(apope.BACHMATERIALPROCESS, ',',
-                        '')) + 1 ,0)-IFNULL(apo.CANCELROLL,0)&lt;=0 from aps_process_operation apo where apo.ID =#{processOperationId}
-                        ) and apope.STARTINGROLL = apope.CHECKOUTROLL+#{currentCheckNum}  from dual )THEN '已完工'
-                        ELSE '未完工'
-                    END,
+<!--                    apope.CLOSESTATUS =-->
+<!--                    CASE-->
+<!--                    &lt;!&ndash;并且当前工序明细的已开工卷数=已检验卷数&ndash;&gt;-->
+<!--                        WHEN-->
+<!--                        (-->
+<!--                        &lt;!&ndash;并且上道工序作业已完工状态=已完工&ndash;&gt;-->
+<!--                         select (select apo.CLOSESTATUS='已完工' from aps_process_operation apo where apo.ID =#{previousprocessid} )-->
+<!--                        &lt;!&ndash;并且作业明细待加工料卷批次号数量-工序作业已取消卷数<=0&ndash;&gt;-->
+<!--                        and (select IFNULL(LENGTH(apope.BACHMATERIALPROCESS) - LENGTH(REPLACE(apope.BACHMATERIALPROCESS, ',',-->
+<!--                        '')) + 1 ,0)-IFNULL(apo.CANCELROLL,0)&lt;=0 from aps_process_operation apo where apo.ID =#{processOperationId}-->
+<!--                        ) and apope.STARTINGROLL = apope.CHECKOUTROLL+#{currentCheckNum}  from dual )THEN '已完工'-->
+<!--                        ELSE '未完工'-->
+<!--                    END,-->
                     apope.WORKSTATUS =
                     CASE
                         WHEN  (select (select apo.CLOSESTATUS='已完工' from aps_process_operation apo where apo.ID =#{previousprocessid} )
@@ -317,4 +317,33 @@
             )
         </where>
     </update>
+    <select id="getOptionalEquipmentById" resultType="com.rongwei.bsentity.vo.OptionalEquipmentVo">
+        SELECT
+            CONCAT(IFNULL( aci.USEDEPTID, arg.RESOURCEWORKSHOPID ),'/',aci.ID) AS value,
+            CONCAT(IFNULL( aci.USEDEPTNAME, arg.RESOURCEWORKSHOP ),'/',aci.CHECKITEMNAME) as label
+        FROM
+            aps_process_operation_process_equ apope
+                LEFT JOIN aps_process_operation apo ON apope.PROCESSID = apo.ID
+                AND apo.DELETED = '0'
+                LEFT JOIN aps_process_operation_equ apoe ON apoe.MAINID = apo.ID
+                AND apoe.DELETED = '0'
+                LEFT JOIN asp_check_items aci ON apoe.RESOURCEID = aci.ID
+                AND aci.DELETED = '0'
+                LEFT JOIN aps_resource_group arg ON apoe.RESOURCEID = arg.ID
+        <where>
+            apope.DELETED = '0'
+            <if test="idList !=null and idList.size() >0">
+            AND apope.ID IN
+                <foreach collection="idList" item="id" open="(" close=")" separator=",">
+                    #{id}
+                </foreach>
+            </if>
+            GROUP BY IFNULL( aci.USEDEPTID, arg.RESOURCEWORKSHOPID ),aci.ID
+            <if test="idList !=null and idList.size() >1">
+                <!-- 存在多选工序作业时 筛选共有的设备 -->
+                <bind name="idLength" value="idList.size()" />
+                HAVING count(*)>=#{idLength}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 51 - 0
cx-aps/cx-aps-entity/src/main/java/com/rongwei/bsentity/vo/ChangingWiresVo.java

@@ -0,0 +1,51 @@
+package com.rongwei.bsentity.vo;
+
+import lombok.Data;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.constraints.Future;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+/**
+ * ChangingWiresVo class
+ *
+ * @author XH
+ * @date 2024/04/26
+ */
+@Data
+@Validated
+public class ChangingWiresVo {
+    /**
+     * 工序作业明细ID
+     */
+    @NotBlank(message = "工序作业必填")
+    private String id;
+    /**
+     * 设备ID
+     */
+    @NotBlank(message = "设备必填")
+    private String equId;
+    /**
+     * 设备名称
+     */
+    @NotBlank(message = "设备必填")
+    private String equName;
+    /**
+     * 车间ID
+     */
+    @NotBlank(message = "车间必填")
+    private String workshopId;
+    /**
+     * 车间名称
+     */
+    @NotBlank(message = "车间必填")
+    private String workshopName;
+    /**
+     * 加工时间必填
+     */
+    @NotNull(message = "加工时间必填")
+    @Future(message = "加工时间必须大于当前时间")
+    private Date processingTime;
+}

+ 21 - 0
cx-aps/cx-aps-entity/src/main/java/com/rongwei/bsentity/vo/OptionalEquipmentVo.java

@@ -0,0 +1,21 @@
+package com.rongwei.bsentity.vo;
+
+import lombok.Data;
+
+/**
+ * OptionalEquipmentVo class
+ *
+ * @author XH
+ * @date 2024/04/26
+ */
+@Data
+public class OptionalEquipmentVo {
+    /**
+     * 车间名/设备名
+     */
+    private String label;
+    /**
+     * 车间ID/设备ID
+     */
+    private String value;
+}

+ 27 - 1
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/ApsProcessOperationProcessEquController.java

@@ -2,20 +2,23 @@ package com.rongwei.bsserver.controller;
 
 
 import com.rongwei.bscommon.sys.service.ApsProcessOperationProcessEquService;
+import com.rongwei.bsentity.vo.ChangingWiresVo;
 import com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq;
 import com.rongwei.rwcommon.base.R;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 /**
  * <p>
- * 生产订单-坯料计划-工序作业加工设备 前端控制器
+ * 生产订单-坯料计划-工序作业明细 前端控制器
  * </p>
  *
  * @author fpy
@@ -43,5 +46,28 @@ public class ApsProcessOperationProcessEquController {
             return R.error("更新生产状态失败");
         }
     }
+
+    /**
+     * 换线作业
+     * @param changingWiresVos
+     * @return
+     */
+    @PostMapping("/changing-wires")
+    public R changingWires(@RequestBody @Validated List<ChangingWiresVo> changingWiresVos){
+        log.info("开始进行换线作业");
+        return  apsProcessOperationProcessEquService.changingWires(changingWiresVos);
+    }
+
+    /**
+     * 换线获取可选设备
+     * @param operationJobDetailsId
+     * @return
+     */
+    @PostMapping("/optional/equipment")
+    public R getOptionalEquipment(@RequestBody List<String> operationJobDetailsId){
+        log.info("开始进行换线作业");
+        return  apsProcessOperationProcessEquService.getOptionalEquipment(operationJobDetailsId);
+    }
+
 }