自动化立体仓库 - WMS系统
1
ZY
2024-10-29 52f2306fe8e8f0760b32f33371adf4037e031bcf
src/main/java/com/zy/asrs/task/AutoMoveScheduler.java
@@ -1,7 +1,11 @@
package com.zy.asrs.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.AgvBasDevp;
import com.zy.asrs.entity.AgvLocMast;
import com.zy.asrs.entity.AgvWrkMast;
@@ -10,11 +14,15 @@
import com.zy.asrs.service.AgvWrkMastService;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.AutoMoveHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -31,6 +39,8 @@
    private AgvWrkMastService agvWrkMastService;
    @Autowired
    private AgvBasDevpService agvBasDevpService;
    @Autowired
    private ConfigService configService;
    // 调拨出库
//    @Scheduled(cron = "0/2 * * * * ? ")
@@ -56,14 +66,14 @@
     * ioType 108.自动调拨
     * crnNo :2目标楼层
     */
    @Scheduled(cron = "0/2 * * * * ? ")
    private void execute2(){
    @Scheduled(cron = "0/1 * * * * ? ")
    private synchronized void execute2(){
        List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                .eq("wrk_sts", 22)
                .andNew().eq("io_type",108)
                        .andNew()
                        .eq("crn_no",2).or().eq("crn_no",3)
                        .orderBy("appe_time",true)
                        .orderBy("io_pri",false).orderBy("appe_time",true)
                );
        if (agvWrkMastList.isEmpty()) {
            return;
@@ -72,7 +82,7 @@
            try{
                autoMoveHandler.start2(agvWrkMast);
            } catch (Exception e){
                log.error("工作号"+agvWrkMast.getWrkNo()+"调拨出库,处理失败:===》异常原因:"+e.getMessage());
                //log.error("工作号"+agvWrkMast.getWrkNo()+"调拨出库,处理失败:===》异常原因:"+e.getMessage());
            }
        }
@@ -110,6 +120,7 @@
        List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                .eq("wrk_sts", 22)
                .andNew().eq("io_type",111)
                .orderBy("io_pri",false)
                .orderBy("appe_time",true)
        );
        if (agvWrkMastList.isEmpty()) {
@@ -118,6 +129,27 @@
        for (AgvWrkMast agvWrkMast : agvWrkMastList) {
            try{
                autoMoveHandler.start3(agvWrkMast);
            } catch (Exception e){
                //log.error("工作号"+agvWrkMast.getWrkNo()+"调拨出库,处理失败:===》异常原因:"+e.getMessage());
            }
        }
    }
    @Scheduled(cron = "0/2 * * * * ? ")
    private void execute4(){
        List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                .eq("wrk_sts", 22)
                .andNew().eq("io_type",114)
                .orderBy("io_pri",false)
                .orderBy("appe_time",true)
        );
        if (agvWrkMastList.isEmpty()) {
            return;
        }
        for (AgvWrkMast agvWrkMast : agvWrkMastList) {
            try{
                autoMoveHandler.start4(agvWrkMast);
            } catch (Exception e){
                log.error("工作号"+agvWrkMast.getWrkNo()+"调拨出库,处理失败:===》异常原因:"+e.getMessage());
            }
@@ -158,7 +190,8 @@
        List<AgvWrkMast> agvWrkMastList = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>()
                .eq("wrk_sts", 214)
                .eq("loc_no","")
                .eq("io_type",113));
                .eq("io_type",113)
                .orderBy("io_pri",false));
        if (agvWrkMastList.isEmpty()) {
            return;
        }
@@ -197,8 +230,8 @@
     * 库位-接驳点  库位-吸塑车间
     * 每层最大 在 回库数量限制5条
     * 优先选择先到接驳位(接驳位可入) 后选择直接回库
     * 2楼或3楼站点可入信号全部没有,代表走电梯自动搬运模式
     */
    @Scheduled(cron = "0/2 * * * * ? ")
    private void autoEmptyBack4(){
        // 查询 不为1楼的空货架
@@ -219,11 +252,29 @@
        }
    }
    private boolean determineFloorConnection(Integer floor){
        try{
            List<AgvBasDevp> agvBasDevps = agvBasDevpService.selectList(new EntityWrapper<AgvBasDevp>().eq("floor", floor).like("dev_no", "DB_"));
            if (!agvBasDevps.isEmpty()){
                for (AgvBasDevp agvBasDevp:agvBasDevps){
                    if (agvBasDevp.getInEnable().equals("Y")){
                        return false;
                    }
                }
                return true;
            }
        }catch (Exception e){
            log.error("判断当前楼层接驳位是否全部关闭,异常"+e.getMessage());
        }
        return false;
    }
    /**
     * 站点是否自动
     * 自动: 生成 109 自动回流
     * 手动: 生成 113 手动回流
     * 优先选择先到接驳位(接驳位可入) 后选择直接回库
     *
     */
    @Scheduled(cron = "0/2 * * * * ? ")
    private void autoEmptyBack5(){
@@ -264,4 +315,57 @@
            }
        }
    }
    /**
     * 自动移库
     *
     */
    @Scheduled(cron = "0/2 * * * * ? ")
    private void autoEmptyBack7() throws ParseException {
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDay = sdf.format(now);
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "autoTime"));
        if (Cools.isEmpty(config)) {
        } else {
            if (config.getStatus().intValue() == 0) {
                return;
            }
            JSONObject jsonObject = JSON.parseObject(config.getValue().toString());
            Integer maxTansk = jsonObject.getInteger("maxTansk");
            //Integer startTime = jsonObject.getInteger("startTime");
            String startTime = jsonObject.getString("startTime");
            long time1 = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(currentDay + " " + startTime).getTime();
            long time = now.getTime();
            long time3 = time - time1;
            if (time3 > 0 && time3 < (1000* 60 * 10)) {
                List<AgvWrkMast> agvWrkMasts = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>().like("loc_no", "02F1").like("source_loc_no", "F1").eq("io_type",12));
                if (maxTansk <= agvWrkMasts.size()){
                    return;
                }
                List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(
                        new EntityWrapper<AgvLocMast>()
                                .eq("floor", 1)
                                .eq("lev1", 1)
                                .eq("loc_sts","F")
                                .eq("loc_type1",3));
                if (agvLocMasts.isEmpty()) {
                    return;
                }
                for (AgvLocMast agvLocMast : agvLocMasts) {
                    try{
                        autoMoveHandler.autoTransfers(agvLocMast,maxTansk);
                    } catch (Exception e){
                        log.error("库位号"+agvLocMast.getLocNo()+"定时移库任务 吸塑一楼 --> 吸塑二楼,处理失败:===》异常原因:"+e.getMessage());
                    }
                }
            }
        }
    }
}