Quellcode durchsuchen

Merge remote-tracking branch 'origin/mode-min-unit' into mode-min-unit

fangpy vor 6 Monaten
Ursprung
Commit
4effd27eeb

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

@@ -153,4 +153,10 @@ public interface ApsBlankOrderDao extends BaseMapper<ApsBlankOrderDo> {
     String selectIsWaitGetMaterialById(@Param("id") String id);
 
     String selectPlanEndProductionWorkshopsById(@Param("productionorderid") String productionorderid);
+
+    void updateFinishDateAboutProcessEqu();
+
+    void removeLockNextDayProcessEqu(@Param("needScheduleDate") String needScheduleDate);
+
+    void removeLockNextTwoDayProcessEqu(@Param("needScheduleDate") String needScheduleDate);
 }

+ 2 - 2
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/dao/ApsProcessOperationDao.java

@@ -111,7 +111,7 @@ public interface ApsProcessOperationDao extends BaseMapper<ApsProcessOperationDo
             "left join aps_process_operation o on e.MAINID=o.ID\n" +
             "set e.ROLLERID=#{rollerid},e.ROLLERTYPE=#{rollertype}\n" +
             "where e.DELETED='0' and o.BLANKID=#{blanckid} and IFNULL(o.LEVEL,'')>${level} \n" +
-            "\tand e.RESOURCEID=#{resourceid} and IFNULL(e.ROLLERID,#{option})=#{option}")
-    void updateZJProcessEqu(@Param("blanckid") String blanckid, @Param("resourceid") String resourceid, @Param("option") String option, @Param("rollerid") String rollerid, @Param("rollertype") String rollertype, @Param("level") String level);
+            "\tand e.RESOURCEID=#{resourceid} ${levelStr}")
+    void updateZJProcessEqu(@Param("blanckid") String blanckid, @Param("resourceid") String resourceid, @Param("levelStr") String levelStr, @Param("rollerid") String rollerid, @Param("rollertype") String rollertype, @Param("level") String level);
 
 }

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

@@ -80,7 +80,8 @@ public interface ApsProcessOperationProcessEquDao extends BaseMapper<ApsProcessO
     void publishCancel(@Param("productIdList") List<String> productIdList);
 
     List<OptionalEquipmentVo> getOptionalEquipmentById(@Param("idList")List<String> id,
-                                                       @Param("factoryId") String factoryId);
+                                                       @Param("factoryId") String factoryId,
+                                                       @Param("typeList") List<String> typeList);
 
     List<String> checkConflict(@Param("checkConflictVos") List<CheckConflictVo> checkConflictVos);
 
@@ -113,6 +114,8 @@ public interface ApsProcessOperationProcessEquDao extends BaseMapper<ApsProcessO
 
     @Select("select count(1) from aps_process_operation_process_equ where DELETED = 0 AND PROCESSDEVICEID = #{processdeviceid} AND ID != #{apsProcessOperationProcessEquDoId} AND WAITREPORTID IS NOT NULL AND WAITREPORTID != '' AND PLANSTARTDATE != #{planstartdate}")
     int selectOtherDeviceCount(@Param("processdeviceid") String processdeviceid,@Param("apsProcessOperationProcessEquDoId") String apsProcessOperationProcessEquDoId, @Param("planstartdate") Date planstartdate);
+
+    String getNeedSelectEquTypes(@Param("operationJobDetailsId") List<String> operationJobDetailsId);
 }
 
 

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

@@ -66,4 +66,6 @@ public interface ApsBlankOrderService extends IService<ApsBlankOrderDo> {
     R addMaterial(AddMaterialReq req);
 
     R checkAddMaterial(AddMaterialReq req);
+
+    void apsScheduleRestart();
 }

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

@@ -3,6 +3,7 @@ package com.rongwei.bscommon.sys.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.StopWatch;
 import cn.hutool.core.util.ObjectUtil;
@@ -3939,4 +3940,33 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
         }
         return R.ok(res);
     }
+
+    @Override
+    public void apsScheduleRestart() {
+        String needScheduleDate = "";
+        DateTime nowDate = DateUtil.date();
+        String time1 = DateUtil.format(nowDate, "yyyy-MM-dd 00:00:00");
+        String time2 = DateUtil.format(nowDate, "yyyy-MM-dd 12:00:00");
+        String time3 = DateUtil.format(nowDate, "yyyy-MM-dd 23:59:59");
+        String now = DateUtil.format(nowDate, "yyyy-MM-dd HH:mm:ss");
+        //如果当前时间在0-12点,重排明天的
+        //如果当前时间在12-24点,重排后天的
+        if (now.compareTo(time1) >= 0 && now.compareTo(time2) < 0) {
+            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 1), "yyyy-MM-dd");
+        }
+        if (now.compareTo(time2) >= 0 && now.compareTo(time3) <= 0) {
+            needScheduleDate = DateUtil.format(DateUtil.offsetDay(nowDate, 2), "yyyy-MM-dd");
+        }
+
+        if (ObjectUtil.isNotEmpty(needScheduleDate)) {
+            //将实际完工时间大于明天的作业挪到实际完工时间
+            this.baseMapper.updateFinishDateAboutProcessEqu();
+            //解锁明天有开工作业明细的坯料计划的所有作业明细
+            this.baseMapper.removeLockNextDayProcessEqu(needScheduleDate);
+            //解锁后天开工的所有作业明细
+            this.baseMapper.removeLockNextTwoDayProcessEqu(needScheduleDate);
+            //重新排程
+            apsService.apsSchedule(new ArrayList<>(), null, null);
+        }
+    }
 }

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

@@ -603,12 +603,20 @@ public class ApsProcessOperationProcessEquServiceImpl extends ServiceImpl<ApsPro
             return R.error("工序作业明细必选");
         }
         log.debug("根据工序作业明细:{},获取可选设备", operationJobDetailsId);
-        // 防止工序作业ID重复
-        operationJobDetailsId = operationJobDetailsId.stream().distinct().filter(StringUtils::isNotBlank).collect(Collectors.toList());
-        List<OptionalEquipmentVo> optionalEquipment = this.baseMapper.getOptionalEquipmentById(null, currentUserFactoryId);
+        //根据工序作业明细查询对应的工序的设备类型
+        String needSelectEquTypes = this.baseMapper.getNeedSelectEquTypes(operationJobDetailsId);
+        //过滤重复设备类型
+        HashSet<String> needSelectEquTypeSet = new HashSet<>();
+        if (StringUtils.isNotBlank(needSelectEquTypes)) {
+            needSelectEquTypeSet.addAll(Arrays.asList(needSelectEquTypes.split(",")));
+        }
+
+//        // 防止工序作业ID重复
+//        operationJobDetailsId = operationJobDetailsId.stream().distinct().filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        List<OptionalEquipmentVo> optionalEquipment = this.baseMapper.getOptionalEquipmentById(null, currentUserFactoryId, new LinkedList<>(needSelectEquTypeSet));
         if (optionalEquipment.isEmpty()) {
-            log.error("当前所选作业不存在共同的加工设备");
-            return R.error("没有可共用的加工设备,无法合并换线");
+            log.error("当前所选作业不存在对应的可加工设备");
+            return R.error("当前所选作业不存在对应的可加工设备,无法合并换线");
         }
         return R.ok(optionalEquipment);
     }
@@ -1164,7 +1172,7 @@ public class ApsProcessOperationProcessEquServiceImpl extends ServiceImpl<ApsPro
                         if (two.getMinProductionStatus().equals(TO_BE_SCHEDULED)) {
                             blankOrderDo.setSchedulingstatus(SaveConstans.SchedulingStatus.TO_BE_SCHEDULED);
                             //存储日志
-                            apsConflictLogService.recordLog("","更新坯料计划状态为待排程,坯料计划ID为:"+blankOrderDo.getId(),"",2,null);
+                            apsConflictLogService.recordLog("", "更新坯料计划状态为待排程,坯料计划ID为:" + blankOrderDo.getId(), "", 2, null);
                         } else if (two.getMinProductionStatus().equals(TO_BE_PUBLISHED)) {
                             blankOrderDo.setSchedulingstatus(SaveConstans.SchedulingStatus.TO_BE_PUBLISHED);
                         } else {

+ 14 - 1
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProcessOperationServiceImpl.java

@@ -761,6 +761,8 @@ public class ApsProcessOperationServiceImpl extends ServiceImpl<ApsProcessOperat
                         processOperationDo.setStartingroll(0);
                         processOperationDo.setReportroll(0);
                         processOperationDo.setCheckoutroll(0);
+                        processOperationDo.setInputunqualifiednum(0);
+                        processOperationDo.setCancelrollsum(0);
 
                         //更新前道工序的后道工序
                         ApsProcessOperationDo aDo = apsProcessOperationDoList.stream().filter(hqtr -> processVo.get(0).getProcessId().equals(hqtr.getId())).findAny().orElse(null);
@@ -954,6 +956,8 @@ public class ApsProcessOperationServiceImpl extends ServiceImpl<ApsProcessOperat
                     processOperationDo.setStartingroll(0);
                     processOperationDo.setReportroll(0);
                     processOperationDo.setCheckoutroll(0);
+                    processOperationDo.setInputunqualifiednum(0);
+                    processOperationDo.setCancelrollsum(0);
 
 //                    if (!processOperationDo.getProcessway().equals("合并加工")) {
                     BigDecimal loadingmin = processOperationDo.getLoadingmin() == null ? BigDecimal.valueOf(0) : processOperationDo.getLoadingmin();
@@ -1231,6 +1235,10 @@ public class ApsProcessOperationServiceImpl extends ServiceImpl<ApsProcessOperat
 
         //遍历工序作业
         for (ApsProcessOperationDo apsProcessOperationDo : apsProcessOperationList) {
+            if (apsProcessOperationDo.getPlanprocessrall() == null || apsProcessOperationDo.getPlanprocessrall().equals(BigDecimal.valueOf(0))) {
+                return R.error(apsProcessOperationDo.getProcess() + apsProcessOperationDo.getProcessname() + "的计划加工卷数必须大于零");
+            }
+
             //如果有前道工序
             if (ObjectUtil.isNotEmpty(apsProcessOperationDo.getPreviousprocessid())) {
                 //获取当前工序的输入物料ID
@@ -1448,7 +1456,12 @@ public class ApsProcessOperationServiceImpl extends ServiceImpl<ApsProcessOperat
             List<ApsProcessOperationOutMaterDo> processOperationOutMaterDoList = apsProcessOperationOutMaterService.listByMap(map).stream().collect(Collectors.toList());
             if (changeZJEquDoList != null && changeZJEquDoList.size() > 0) {
                 for (ApsProcessOperationEquDo zjequ : changeZJEquDoList) {
-                    apsProcessOperationDao.updateZJProcessEqu(params.getBlankid(), zjequ.getResourceid(), zjequ.getRoption() == null ? "" : zjequ.getRoption(), zjequ.getRollerid(), zjequ.getRollertype(), params.getLevel());
+                    String levelStr = "";
+                    if (StringUtils.isNotBlank(zjequ.getRemark()) && !zjequ.getRemark().equals("add")) {
+                        String rollerid = zjequ.getRoption() == null ? "" : zjequ.getRoption();
+                        levelStr = String.format(" and IFNULL(e.ROLLERID,'%s')='%s'", rollerid, rollerid);
+                    }
+                    apsProcessOperationDao.updateZJProcessEqu(params.getBlankid(), zjequ.getResourceid(), levelStr, zjequ.getRollerid(), zjequ.getRollertype(), params.getLevel());
                 }
             }
 

+ 39 - 0
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsBlankOrderDao.xml

@@ -189,6 +189,45 @@
             </foreach>
         </where>
     </update>
+    <update id="updateFinishDateAboutProcessEqu">
+        update
+            aps_process_operation_process_equ apope
+            join aps_process_operation apo on apo.id = apope.PROCESSID
+            set
+                apope.PLANSTARTDATE=DATE_SUB(apope.ACTUALFINISHDATE,INTERVAL TIMESTAMPdiff(SECOND, apope.PLANSTARTDATE, apope.PLANENDDATE) SECOND),
+                apope.PLANENDDATE=apope.ACTUALFINISHDATE
+        where
+            apo.DELETED='0' and apope.deleted='0'
+          and apope.ACTUALFINISHDATE > DATE_ADD(CURRENT_DATE,INTERVAL 1 DAY)
+          and apo.PROCESS != '铸轧'
+    </update>
+    <update id="removeLockNextDayProcessEqu">
+        with tomorroworder as(
+            select DISTINCT apope.blankid
+            from aps_process_operation_process_equ apope
+            where apope.deleted='0'
+              and DATE(apope.PLANSTARTDATE) = #{needScheduleDate}
+            )
+        update
+            aps_process_operation_process_equ apope
+            join aps_process_operation apo on apo.id = apope.PROCESSID
+            join aps_blank_order abo on apo.BLANKID = abo.id
+            join tomorroworder on apope.blankid=tomorroworder.blankid
+            set apope.LOCKMARKDETAIL = 'n',apo.LOCKMARK='n',abo.SCHEDULINGSTATUS = '20'
+        where apope.deleted='0' and apo.deleted='0'
+          and apo.PROCESS != '铸轧' and apope.WORKSTATUS = '待开工'
+          and apope.PLANSTARTDATE > #{needScheduleDate}
+    </update>
+    <update id="removeLockNextTwoDayProcessEqu">
+        update
+        aps_process_operation_process_equ apope
+        join aps_process_operation apo on apo.id = apope.PROCESSID
+        join aps_blank_order abo on apo.BLANKID = abo.id
+        set apope.LOCKMARKDETAIL = 'n',apo.LOCKMARK='n',abo.SCHEDULINGSTATUS = '20'
+        where apope.deleted='0' and apo.deleted='0'
+        and apo.PROCESS != '铸轧' and apope.WORKSTATUS = '待开工'
+        and apope.PLANSTARTDATE >= DATE_ADD(#{needScheduleDate},INTERVAL 2 DAY) and apope.PLANSTARTDATE &lt; DATE_ADD(#{needScheduleDate},INTERVAL 3 DAY)
+    </update>
     <select id="checkConflictByBlankId" resultType="java.lang.Integer">
         select count(*) from aps_process_operation_process_equ
             <where>

+ 18 - 0
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProcessOperationProcessEquDao.xml

@@ -396,6 +396,14 @@
         aci.DELETED='0'
         and aci.TENANTID=#{factoryId}
         and IFNULL(DEVICESTATUS,'正常使用')!='停用' and IFNULL(DEVICESTATUS,'正常使用')!='报废'  and  PRODUCETYPE='1'
+        and aci.USEDEPTID != '' and aci.USEDEPTID is not null
+        <if test="typeList != null and typeList.size > 0">
+            and aci.CHECKITEMTYPE IN
+            <foreach collection="typeList" separator="," item="item" open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
         GROUP BY aci.ID
         ORDER BY aci.USEDEPTNAME,aci.CHECKITEMNAME,aci.CHECKITEMNAME ASC
         <!--        SELECT-->
@@ -542,4 +550,14 @@
             ORDER BY PLANSTARTDATE desc
         </where>
     </select>
+    <select id="getNeedSelectEquTypes" resultType="java.lang.String">
+        select GROUP_CONCAT(app.EQUIPMENTTYPE) AS 'needSelectEquTypes'
+        from aps_process_operation_process_equ apope
+                 LEFT JOIN aps_process_operation apo ON apo.DELETED = 0 AND apope.PROCESSID = apo.ID
+                 LEFT JOIN aps_production_processes app ON app.DELETED = 0 AND app.ID = apo.PROCESSID
+        where apope.DELETED = 0 AND apope.ID in
+        <foreach collection="operationJobDetailsId" open="(" close=")" item="item" separator=",">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

+ 9 - 0
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/ApsBlankOrderController.java

@@ -57,6 +57,15 @@ public class ApsBlankOrderController {
         return R.ok();
     }
 
+    /**
+     * 自动调度
+     */
+    @GetMapping("/apsScheduleRestart")
+    public R apsScheduleRestart() throws Exception {
+        apsBlankOrderService.apsScheduleRestart();
+        return R.ok();
+    }
+
     /**
      * 坯料计划锁定解锁
      *

+ 11 - 0
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/ApsProcessOperationProcessEquController.java

@@ -56,6 +56,17 @@ public class ApsProcessOperationProcessEquController {
         log.info("开始进行换线作业");
         return apsProcessOperationProcessEquService.changingWires(changingWiresVos);
     }
+    /**
+     * 换线作业2,区分甘特图和车间作业跟踪
+     *
+     * @param changingWiresVos
+     * @return
+     */
+    @PostMapping("/changing-wires2")
+    public R changingWires2(@RequestBody @Validated List<ChangingWiresVo> changingWiresVos) {
+        log.info("开始进行换线作业");
+        return apsProcessOperationProcessEquService.changingWires(changingWiresVos);
+    }
 
     /**
      * 换线获取可选设备