自动化立体仓库 - WCS系统
whycq
2022-03-18 afe777a76ae3448a53986aac22b3a667a21c64c7
Merge remote-tracking branch 'origin/xgmwcs' into xgmwcs
12个文件已修改
262 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/ConsoleController.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/BasDevp.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/WrkMastService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 82 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/WrkMastServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/StaProtocol.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LedThread.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/MelsecCrnThread.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/crn.html 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -9,8 +9,10 @@
import com.zy.asrs.domain.enums.SiteStatusType;
import com.zy.asrs.domain.param.SystemSwitchParam;
import com.zy.asrs.domain.vo.*;
import com.zy.asrs.entity.BasCrnError;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.WrkMastService;
@@ -54,6 +56,8 @@
    private BasDevpService basDevpService;
    @Autowired
    private LocMastMapper locMastMapper;
    @Autowired
    private BasCrnErrorMapper basCrnErrorMapper;
    @PostMapping("/system/running/status")
    @ManagerAuth(memo = "系统运行状态")
@@ -130,7 +134,7 @@
            /**
             * 堆垛机状态判断
             */
            if (crn.getId() == 1 && crnProtocol.getAlarm() > 0) {
            if (crnProtocol.getAlarm() > 0) {
                vo.setCrnStatus(CrnStatusType.MACHINE_ERROR);
            } else {
                if (crnProtocol.getTaskNo()>0) {
@@ -246,6 +250,13 @@
                CrnProtocol crnProtocol = crnThread.getCrnProtocol();
                vo.setCrnNo(crnNo);
                vo.setWorkNo(crnProtocol.getTaskNo());
                vo.setCrnStatus(crnProtocol.getStatusType().desc);
                if (crnProtocol.getAlarm() > 0) {
                    BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
                    vo.setError(crnError == null ? "未知异常" : crnError.getErrName());
                }
                if (crnProtocol.getTaskNo() > 0) {
                    WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo());
                    if (wrkMast != null) {
src/main/java/com/zy/asrs/entity/BasDevp.java
@@ -129,7 +129,7 @@
    @ApiModelProperty(value= "条形码")
    private String barcode;
    @ApiModelProperty(value= "")
    @ApiModelProperty(value= "入库暂存数")
    @TableField("in_qty")
    private Integer inQty;
src/main/java/com/zy/asrs/service/WrkMastService.java
@@ -13,4 +13,6 @@
    List<WrkMast> selectToBeHistoryData();
    int getOutToStn182(Integer devpNo);
}
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -105,14 +105,14 @@
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
//                if(!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
//                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        continue;
//                    }
//                } else {
//                    continue;
//                }
                if(!Cools.isEmpty(barcode)) {
                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        continue;
                    }
                } else {
                    continue;
                }
                // 获取入库站信息
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
@@ -132,18 +132,18 @@
                        && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999)
                        && staProtocol.isPakMk()){// && !Cools.isEmpty(barcode)) {
                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                        //条码为空或者不符合,退库到172站点
                        staProtocol.setWorkNo((short)9999);
                        staProtocol.setStaNo((short)172);
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
                        }
                        continue;
                    }
//                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
//                        //条码为空或者不符合,退库到172站点
//                        staProtocol.setWorkNo((short)9999);
//                        staProtocol.setStaNo((short)172);
//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                        if (!result) {
//                            throw new CoolException("更新plc站点信息失败");
//                        }
//                        continue;
//                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
@@ -328,14 +328,14 @@
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
//                if(!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
//                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        continue;
//                    }
//                } else {
//                    continue;
//                }
                if(!Cools.isEmpty(barcode)) {
                    log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        continue;
                    }
                } else {
                    continue;
                }
                // 获取拣料入库站信息
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
@@ -351,18 +351,18 @@
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){
                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                        //条码为空或者不符合,退库到172站点
                        staProtocol.setWorkNo((short)9999);
                        staProtocol.setStaNo((short)172);
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
                        }
                        continue;
                    }
//                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
//                        //条码为空或者不符合,退库到172站点
//                        staProtocol.setWorkNo((short)9999);
//                        staProtocol.setStaNo((short)172);
//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                        if (!result) {
//                            throw new CoolException("更新plc站点信息失败");
//                        }
//                        continue;
//                    }
                    WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
                    if (wrkMast == null) {
@@ -835,7 +835,7 @@
        }
        // 已经存在吊车执行任务时,则过滤
        if (wrkMastMapper.selectLocMoving(slave.getId()) != null) {
        if (wrkMastMapper.selectWorking(slave.getId()) != null) {
            return;
        }
src/main/java/com/zy/asrs/service/impl/WrkMastServiceImpl.java
@@ -27,4 +27,8 @@
        return this.baseMapper.selectToBeHistoryData();
    }
    @Override
    public int getOutToStn182(Integer devpNo) {
        return selectCount(new EntityWrapper<WrkMast>().eq("sta_no", devpNo).eq("wrk_sts",12));
    }
}
src/main/java/com/zy/core/MainProcess.java
@@ -42,7 +42,7 @@
                    // 演示
                    mainService.crnDemoOfLocMove1();
                    // 入出库模式切换函数
                    mainService.ioConvert();
//                    mainService.ioConvert();
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
                    mainService.generateStoreWrkFile0(); // WMS入库
src/main/java/com/zy/core/model/protocol/StaProtocol.java
@@ -49,6 +49,8 @@
    // 锁定标记
    private boolean pakMk = true;
    // 入库暂存数
    private Short inQty;
    public BasDevp toSqlModel(){
        BasDevp basDevp = new BasDevp();
@@ -62,6 +64,7 @@
        basDevp.setLocType2((short) 0);  // 宽窄类型{0:未知,1:窄库位,2:宽库位}
        basDevp.setLocType3((short) 0);  // 轻重类型{0:未知,1:轻库位,2:重库位}
        basDevp.setLocType1(high != low && low ? (short) 1 : (short) 2);
        basDevp.setInQty(inQty !=null ?(int)inQty : 0);
        return basDevp;
    }
src/main/java/com/zy/core/thread/LedThread.java
@@ -100,14 +100,21 @@
            page.newLine("目标站:"+command.getStaNo());
            if (!command.isEmptyMk()) {
                for (MatDto matDto : command.getMatDtos()) {
                    page.newLine(matDto.getMaknx() + "【数量" + matDto.getCount() +"】");
                    //去掉小数点
                    String strQty = matDto.getCount().toString();
                    int idx = strQty.lastIndexOf(".");
                    if(idx >= 0){
                        strQty.substring(0,idx);
                    }
                    page.newLine(matDto.getMaknx() + "[数量" + strQty +"]");
//                    page.newLine(matDto.getMaknx() + "【数量" + matDto.getCount() +"】");
                }
            }
            page.newLine("\n");
        }
        // 设置字体
        page.setFont(new Font("宋体",Font.PLAIN,12));
        page.setFont(new Font("宋体",Font.PLAIN,10));
        // 设置文本颜色
        page.setForeground(Color.red);
        // 设置显示特技为快速打出
@@ -198,6 +205,13 @@
    public static void main(String[] args) throws Exception {
        String strQty = "1234";
        int index = strQty.lastIndexOf(".");
        if(index>=0) {
            strQty=strQty.substring(0, index);
        }
        System.out.println("2==>>"+strQty);
        Bx5GEnv.initial(3000);
        Bx5GScreenClient screen = new Bx5GScreenClient("my");
        DisplayStyleFactory.DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyleFactory.DisplayStyle[0]);
src/main/java/com/zy/core/thread/MelsecCrnThread.java
@@ -229,6 +229,55 @@
            log.error("堆垛机写入命令为空");
            return false;
        }
//        OperateResult result = null;
//        try{
//            Integer exeCount=0;
//            do{
//                command.setCrnNo(slave.getId());
//                short[] array = new short[10];
//                array[0] = command.getAckFinish();
//                array[1] = command.getTaskNo();
//                array[2] = command.getTaskMode();
//                array[3] = command.getSourcePosX();
//                array[4] = command.getSourcePosY();
//                array[5] = command.getSourcePosZ();
//                array[6] = command.getDestinationPosX();
//                array[7] = command.getDestinationPosY();
//                array[8] = command.getDestinationPosZ();
//                array[9] = command.getCommand();
//                result = melsecMcNet.Write("D0", array);
//                if(result.IsSuccess) {
//                    if (command.getAckFinish() == 0) {
//                        short commandFinish = 1;
//                        result = melsecMcNet.Write("D9", commandFinish);
//                        if(result.IsSuccess){
//                            //写任务确认返回成功后,查询确认一次
//                            Thread.sleep(200);
//                            OperateResultExOne<byte[]> result1 = melsecMcNet.Read("D9", (short)2);
//                            if(result1.IsSuccess){
//                                short commandVal = melsecMcNet.getByteTransform().TransInt16(result1.Content,2);
//                                if(commandVal==1){
//                                    break;
//                                } else {
//                                    exeCount++;
//                                }
//                            } else{
//                                exeCount++;
//                            }
//                        }else{
//                            exeCount++;
//                        }
//                    }
//                }else{
//                    exeCount++;
//                }
//                Thread.sleep(200);
//            }while(exeCount>3);
//        }catch (Exception e){
//
//        }
        command.setCrnNo(slave.getId());
        short[] array = new short[10];
        array[0] = command.getAckFinish();
@@ -271,7 +320,7 @@
            bean.insert(basCrnOpt);
        } catch (Exception ignore) {}
        if (result.IsSuccess) {
        if (result != null && result.IsSuccess) {
            log.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            return true;
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -9,6 +9,7 @@
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.WrkMastService;
import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
@@ -48,7 +49,8 @@
        add(150);add(151);add(152);add(153);add(154);add(155);add(156);add(157);add(158);add(159);
        add(160);add(161);add(162);add(163);add(164);add(165);add(166);add(167);add(168);add(169);
        add(170);add(171);add(172);add(173);add(174);add(175);add(176);add(177);add(178);add(179);
        add(180);add(181);add(182);add(183);add(184);add(185);add(186);add(187);add(188);add(189);
        add(180);add(181);add(182);
        add(183);add(184);add(185);add(186);add(187);add(188);add(189);
        add(190);add(191);add(192);
    }};
@@ -118,7 +120,7 @@
//        updateIoMode();
        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 186);
        if (result.IsSuccess) {
            for (int i = 0; i < 83; i++) {
            for (int i = 0; i < 93; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
@@ -132,7 +134,7 @@
        Thread.sleep(200);
        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
        if (result0.IsSuccess) {
            for (int i = 0; i < 83; i++) {
            for (int i = 0; i < 93; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
@@ -146,7 +148,7 @@
        Thread.sleep(200);
        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 186);
        if (result1.IsSuccess) {
            for (int i = 0; i < 83; i++) {
            for (int i = 0; i < 93; i++) {
                Integer siteId = staNos.get(i); // 站点编号
                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1);
                StaProtocol staProtocol = station.get(siteId);
@@ -162,6 +164,40 @@
                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                    staProtocol.setPakMk(true);
                }
            }
        }
        Thread.sleep(200);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB300.0", (short) 10);
        if (result3.IsSuccess) {
//            Integer siteId = staNos.get(i); // 站点编号
            Integer siteId = 0;
            for (int i = 0; i < 5; i++) {
                switch (i){
                    case 0:
                        siteId = 100;
                        break;
                    case 1:
                        siteId = 102;
                        break;
                    case 2:
                        siteId = 104;
                        break;
                    case 3:
                        siteId = 106;
                        break;
                    case 4:
                        siteId = 108;
                        break;
                }
                StaProtocol staProtocol = station.get(siteId);
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    station.put(siteId, staProtocol);
                }
                short value = siemensS7Net.getByteTransform().TransInt16(result3.Content, i*2);
                staProtocol.setInQty(value);     // 入库暂存数
            }
        }
@@ -181,15 +217,28 @@
                    StaProtocol staProtocol = station.get(siteId);
                    basDevps.add(staProtocol.toSqlModel());
                }
                BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
                if (!basDevpService.updateBatchById(basDevps)) {
                if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) {
                    throw new Exception("更新数据库数据失败");
                }
            } catch (Exception e) {
                e.printStackTrace();
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】更新数据库数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
                log.error("更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            }
            //出库到182站堆垛机任务数据发送给PLC
            try{
                WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class);
                if(null != wrkMastService){
                    int count = wrkMastService.getOutToStn182(182);
                    OperateResult write = siemensS7Net.Write("DB200.2",(short)count);
                }
            }catch (Exception e) {
                log.error("更新数据库数据失败");
            }
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
//            log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
src/main/resources/application.yml
@@ -11,8 +11,8 @@
    #    url: jdbc:sqlserver://47.97.1.152:51433;databasename=xgmasrs
    #    username: sa
    #    password: Zoneyung@zy56$
#    url: jdbc:sqlserver://10.10.10.238:1433;databasename=xgmasrs
    url: jdbc:sqlserver://localhost:1433;databasename=xgmasrs
    url: jdbc:sqlserver://10.10.10.238:1433;databasename=xgmasrs
#    url: jdbc:sqlserver://localhost:1433;databasename=xgmasrs
    username: sa
    password: sa@123
  mvc:
@@ -170,9 +170,9 @@
    inSta[0]:
      staNo: 176
      barcode: ${wcs-slave.barcode[0].id}
    inSta[1]:
      staNo: 180
      barcode: ${wcs-slave.barcode[1].id}
#    inSta[1]:
#      staNo: 180
#      barcode: ${wcs-slave.barcode[1].id}
    # 空板入库口1
    emptyInSta[0]:
      staNo: 176
@@ -191,10 +191,10 @@
    id: 1
    ip: 10.10.10.52
    port: 51236
  barcode[1]:
    id: 2
    ip: 10.10.10.53
    port: 51236
#  barcode[1]:
#    id: 2
#    ip: 10.10.10.53
#    port: 51236
   # LED1
  led[0]:
    id: 1
src/main/webapp/views/crn.html
@@ -122,10 +122,10 @@
                    <th>走行速度(m/min)</th>
                    <th>升降速度(m/min)</th>
                    <th>叉牙速度(m/min)</th>
                    <th>走行距离(m)</th>
                    <th>升降距离(m)</th>
                    <th>走行时长(s)</th>
                    <th>升降时长(s)</th>
                    <th>走行距离(Km)</th>
                    <th>升降距离(Km)</th>
                    <th>走行时长(H)</th>
                    <th>升降时长(H)</th>
                </tr>
                </thead>
                <tbody>