1
zhang
2025-08-08 8309cebcb060d6146a716d5d7fa10e9699711603
1
2个文件已添加
5个文件已修改
347 ■■■■ 已修改文件
pom.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/CtuMainServiceImpl.java 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/CtuMainProcess.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/ServerBootstrap.java 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/common.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/console.map.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -185,7 +185,7 @@
    </dependencies>
    <build>
        <finalName>xgmFlwcs</finalName>
        <finalName>whxrwcs</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
src/main/java/com/zy/asrs/service/impl/CtuMainServiceImpl.java
New file
@@ -0,0 +1,142 @@
package com.zy.asrs.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.common.service.CommonService;
import com.zy.common.utils.News;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.Task;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.SiemensDevpThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
 * 立体仓库WCS系统主流程业务
 * Created by vincent on 2020/8/6
 */
@Slf4j
@Service("mainService")
@Transactional
public class CtuMainServiceImpl {
    public static final long COMMAND_TIMEOUT = 5 * 1000;
    @Autowired
    private SlaveProperties slaveProperties;
    @Autowired
    private WrkMastMapper wrkMastMapper;
    @Autowired
    private WrkMastService wrkMastService;
    public Integer wrkNo = 10000;
    /**
     * 入库,从拣料站到入库站(CTU取货站)
     */
    public synchronized void generateStoreWrkFile(Integer mark) {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
            for (DevpSlave.Sta inSta : devp.getInSta()) {
                // 获取入库站信息
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 判断是否满足条件
                if (!staProtocol.isLoading()) {
                    continue;
                }
                if (staProtocol.isAutoing() && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999)
                        && staProtocol.isPakMk()) {
                    WrkMast wrkMast = wrkMastMapper.selectByWrkNo(staProtocol.getWorkNo());
                    if (wrkMast.getWrkSts() == 106) {
                        //下发移动任务,并生成入库工作档
                    } else {
                        log.info("" + mark + " - " + staProtocol.getWorkNo() + " - 找不到对应的工作档");
                    }
                }
            }
        }
    }
    /**
     * 出库站到拣料站
     */
    public synchronized void generateStoreWrkFile0(Integer mark) {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
            for (DevpSlave.Sta inSta : devp.getOutSta()) {
                // 获取入库站信息
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 判断是否满足条件
                if (!staProtocol.isLoading()) {
                    continue;
                }
                if (staProtocol.isAutoing() && staProtocol.isOutEnable()
                        && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999)
                        && staProtocol.isPakMk()) {
                    News.warnNoLog("" + mark + " - 0" + " - 开始执行");
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_sta_no", staProtocol.getSiteId()).eq("wrk_sts", 105));
                    if (wrkMast == null) {
                        continue;
                    }
                    // 命令下发区 --------------------------------------------------------------------------
                    // 更新站点信息 且 下发plc命令
                    staProtocol.setWorkNo(wrkMast.getWrkNo());
                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    log.info("输送线下发3:{},{}", wrkMast.getWrkNo(), wrkMast.getStaNo());
                    if (result) {
                        // 更新工作主档
                        wrkMast.setWrkSts(106L);
                        wrkMast.setModiTime(new Date());
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            News.error("" + mark + " - 1" + " - 更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo());
                        }
                    } else {
                        News.error("" + mark + " - 2" + " - 发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                    }
                } else {
                    News.errorNoLog("" + mark + " - 6" + " - 站点信息不符合入库条件!!!" + " 自动信号:" + staProtocol.isLoading() + "、可入信号:" + staProtocol.isInEnable()
                            + "、空板信号:" + staProtocol.isEmptyMk() + "、工作号:" + staProtocol.getWorkNo()
                            + "、锁定标记" + staProtocol.isPakMk() + "、入库印记:" + staProtocol.getStamp());
                }
            }
        }
    }
}
src/main/java/com/zy/core/CtuMainProcess.java
New file
@@ -0,0 +1,65 @@
package com.zy.core;
import com.zy.asrs.service.impl.CtuMainServiceImpl;
import com.zy.core.properties.SystemProperties;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
/**
 * WCS主流程
 * Created by vincent on 2020/8/6
 */
@Data
@Slf4j
@Component
public class CtuMainProcess {
    @Autowired
    private CtuMainServiceImpl ctuMainService;
    // 所属线程
    private Thread thread;
    // 频率
    private int i = 0;
    private boolean rgcWrk = true;
    /**
     * =====>>  开始工作
     */
    public void start() {
        thread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    // 间隔
                    Thread.sleep(1000);
                    // 系统运行状态判断
                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
                        continue;
                    }
                    // 入库
                    ctuMainService.generateStoreWrkFile(1);
                    // 拣料完成
                    //ctuMainService.checkCpm(1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
    }
    @PreDestroy
    public void shutDown() {
        if (thread != null) thread.interrupt();
    }
}
src/main/java/com/zy/core/ServerBootstrap.java
@@ -33,7 +33,7 @@
    @Autowired
    private SlaveProperties slaveProperties;
    @Autowired
    private MainProcess mainProcess;
    private CtuMainProcess ctuMainProcess;
    public static final Map<CrnThread, Thread> map = new ConcurrentHashMap<>();
@@ -52,15 +52,15 @@
        // 初始化下位机线程
        initThread();
        // 开始主流程进程
        mainProcess.start();
        ctuMainProcess.start();
        News.info("核心控制层已启动...............................................");
    }
    private void initMq(){
        // 初始化堆垛机mq
        for (Slave crn : slaveProperties.getCrn()) {
            MessageQueue.init(SlaveType.Crn, crn);
        }
//        for (Slave crn : slaveProperties.getCrn()) {
//            MessageQueue.init(SlaveType.Crn, crn);
//        }
        // 初始化Rgv小车mq
//        for (Slave rgv : slaveProperties.getRgv()) {
//            MessageQueue.init(SlaveType.Rgv, rgv);
@@ -70,13 +70,13 @@
            MessageQueue.init(SlaveType.Devp, devp);
        }
        // 初始化条码扫描仪mq
        for (Slave barcode : slaveProperties.getBarcode()) {
            MessageQueue.init(SlaveType.Barcode, barcode);
        }
//        for (Slave barcode : slaveProperties.getBarcode()) {
//            MessageQueue.init(SlaveType.Barcode, barcode);
//        }
        // 初始化Led灯mq
        for (Slave led : slaveProperties.getLed()) {
            MessageQueue.init(SlaveType.Led, led);
        }
//        for (Slave led : slaveProperties.getLed()) {
//            MessageQueue.init(SlaveType.Led, led);
//        }
        // 初始化磅称mq
//        for (Slave scale : slaveProperties.getScale()) {
//            MessageQueue.init(SlaveType.Scale, scale);
@@ -89,12 +89,12 @@
    private void initThread(){
        // 初始化堆垛机线程
        News.info("初始化堆垛机线程...................................................");
        for (CrnSlave crn : slaveProperties.getCrn()) {
            CrnThread crnThread = new SiemensCrnThread(crn);
            new Thread((Runnable) crnThread).start();
            SlaveConnection.put(SlaveType.Crn, crn.getId(), crnThread);
        }
//        News.info("初始化堆垛机线程...................................................");
//        for (CrnSlave crn : slaveProperties.getCrn()) {
//            CrnThread crnThread = new SiemensCrnThread(crn);
//            new Thread((Runnable) crnThread).start();
//            SlaveConnection.put(SlaveType.Crn, crn.getId(), crnThread);
//        }
        // 初始化穿梭车线程
//        log.info("初始化RGV线程...................................................");
//        for (RgvSlave rgv : slaveProperties.getRgv()) {
@@ -110,19 +110,19 @@
            SlaveConnection.put(SlaveType.Devp, devp.getId(), devpThread);
        }
        // 初始化条码扫描仪线程
        News.info("初始化条码扫描仪线程...................................................");
        for (Slave barcode : slaveProperties.getBarcode()) {
            BarcodeThread barcodeThread = new BarcodeThread(barcode);
//            new Thread(barcodeThread).start();
            SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread);
        }
        // 初始化LED线程
        News.info("初始化LED线程...................................................");
        for (LedSlave led : slaveProperties.getLed()) {
            LedThread ledThread = new LedThread(led);
            new Thread(ledThread).start();
            SlaveConnection.put(SlaveType.Led, led.getId(), ledThread);
        }
//        News.info("初始化条码扫描仪线程...................................................");
//        for (Slave barcode : slaveProperties.getBarcode()) {
//            BarcodeThread barcodeThread = new BarcodeThread(barcode);
////            new Thread(barcodeThread).start();
//            SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread);
//        }
//        // 初始化LED线程
//        News.info("初始化LED线程...................................................");
//        for (LedSlave led : slaveProperties.getLed()) {
//            LedThread ledThread = new LedThread(led);
//            new Thread(ledThread).start();
//            SlaveConnection.put(SlaveType.Led, led.getId(), ledThread);
//        }
        // 初始化磅秤线程
//        News.info("初始化磅秤线程...................................................");
//        for (Slave scale : slaveProperties.getScale()) {
src/main/resources/application.yml
@@ -8,7 +8,7 @@
    name: @pom.build.finalName@
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://192.168.11.30:1433;databasename=xgmFlasrs
    url: jdbc:sqlserver://127.0.0.1:1433;databasename=whxrasrs
    username: sa
    password: sa@123
  mvc:
@@ -34,7 +34,7 @@
  enable: false
wms:
  url: 192.168.11.30:8080/xgmFlwms
  url: 127.0.0.1:8080/whxrwms
# 下位机配置
wcs-slave:
@@ -167,45 +167,45 @@
    slot: 0
    # 入库口1
    inSta[0]:
      staNo: 101
      staNo: 1004
      barcode: ${wcs-slave.barcode[0].id}
      backSta: 100
      backSta: 1004
      led: ${wcs-slave.led[0].id}
    # 入库口1
    inSta[1]:
      staNo: 201
      barcode: ${wcs-slave.barcode[1].id}
      backSta: 200
      led: ${wcs-slave.led[1].id}
    # 拣料入库口1
    pickSta[0]:
      staNo: 101
      barcode: ${wcs-slave.barcode[0].id}
      led: ${wcs-slave.led[0].id}
      backSta: 100
    # 拣料入库口1
    pickSta[1]:
      staNo: 201
      barcode: ${wcs-slave.barcode[1].id}
      led: ${wcs-slave.led[1].id}
      backSta: 200
    # 空板入库口1
    emptyInSta[0]:
      staNo: 101
      barcode: ${wcs-slave.barcode[0].id}
      backSta: 100
      led: ${wcs-slave.led[0].id}
    # 空板入库口2
    emptyInSta[1]:
      staNo: 201
      barcode: ${wcs-slave.barcode[1].id}
      backSta: 200
      led: ${wcs-slave.led[1].id}
#    # 入库口1
#    inSta[1]:
#      staNo: 201
#      barcode: ${wcs-slave.barcode[1].id}
#      backSta: 200
#      led: ${wcs-slave.led[1].id}
#    # 拣料入库口1
#    pickSta[0]:
#      staNo: 101
#      barcode: ${wcs-slave.barcode[0].id}
#      led: ${wcs-slave.led[0].id}
#      backSta: 100
#    # 拣料入库口1
#    pickSta[1]:
#      staNo: 201
#      barcode: ${wcs-slave.barcode[1].id}
#      led: ${wcs-slave.led[1].id}
#      backSta: 200
#    # 空板入库口1
#    emptyInSta[0]:
#      staNo: 101
#      barcode: ${wcs-slave.barcode[0].id}
#      backSta: 100
#      led: ${wcs-slave.led[0].id}
#    # 空板入库口2
#    emptyInSta[1]:
#      staNo: 201
#      barcode: ${wcs-slave.barcode[1].id}
#      backSta: 200
#      led: ${wcs-slave.led[1].id}
    # 出库口1
    outSta[0]:
      staNo: 123
    outSta[1]:
      staNo: 223
      staNo: 1001
#    outSta[1]:
#      staNo: 223
  # 条码扫描仪1
  barcode[0]:
    id: 1
src/main/webapp/static/js/common.js
@@ -1,4 +1,4 @@
var baseUrl = "/xgmFlwcs";
var baseUrl = "/whxrwcs";
// 赋值
function setVal(el, val) {
src/main/webapp/static/js/console.map.js
@@ -1,5 +1,5 @@
mapInfo ={
    "mapName": "xgmFlwcs",
    "mapName": "whxrwcs",
    "rackCount": 6,
    "crnCount": 3,
    "stbCount": 48,