自动化立体仓库 - WCS系统
luxiaotao1123
2020-09-28 5090e469d6428e4508db52b49b4e34d9ba6198ea
Merge branch 'jswcs' of https://gitee.com/luxiaotao1123/zy-wcs into jswcs
6个文件已修改
93 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/StaProtocol.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/BarcodeThread.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/DevpThread.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/console.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/crn.html 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -107,9 +107,12 @@
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
                String barcode = barcodeThread.getBarcode();
                if(!Cools.isEmpty(barcode)) {
                    System.err.println(barcode);
                }
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()).clone();
                if (staProtocol == null) {
                    continue;
                }
@@ -178,15 +181,18 @@
                        // 命令下发区 --------------------------------------------------------------------------
                        // 更新站点信息 且 下发plc命令
                        barcodeThread.setBarcode("");
                        staProtocol.setWorkNo((short) workNo);
                        staProtocol.setStaNo(startupDto.getStaNo().shortValue());
                        staProtocol.setPakMk(false);
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
                        }
                    } catch (Exception e) {
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -212,7 +218,7 @@
            for (DevpSlave.Sta inSta : devp.getInSta()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()).clone();
                if (staProtocol == null) { continue; }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading()
@@ -227,7 +233,7 @@
                    // 更新站点信息 且 下发plc命令
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                    staProtocol.setPakMk(false);
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (result) {
                        // 更新工作主档
@@ -258,7 +264,7 @@
            for (DevpSlave.Sta pickSta : devp.getPickSta()) {
                // 获取拣料入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()).clone();
                if (staProtocol == null) { continue; }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
                    && staProtocol.getWorkNo() > 0 && staProtocol.isPakMk()){
@@ -321,7 +327,7 @@
                    // 更新站点信息 且 下发plc命令
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                    staProtocol.setPakMk(false);
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (!result) {
                        log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
@@ -344,7 +350,7 @@
            for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
                // 获取堆垛机出库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
                StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
                StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone();
                if (staProtocol == null) { continue; }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                    // 查询工作档
@@ -446,7 +452,7 @@
            boolean flag = false;
            // 获取堆垛机入库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone();
            if (staProtocol == null) { continue; }
            // 查询站点详细信息
            BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
@@ -454,7 +460,7 @@
                log.error("入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
                continue;
            }
            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0
            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
                    && staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) {
                flag = true;
            }
@@ -534,7 +540,7 @@
            }
            // 获取堆垛机出库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()).clone();
            if (staProtocol == null) { continue; }
            // 查询站点详细信息
            BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
@@ -544,7 +550,7 @@
            }
            // 判断堆垛机出库站状态
            if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y")
                    && staProtocol.getWorkNo() == 0) {
                    && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
                // 命令下发区 --------------------------------------------------------------------------
                // 堆垛机控制过滤
@@ -706,7 +712,7 @@
            for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) {
                // 获取空板入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo());
                StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()).clone();
                if (staProtocol == null) { continue; }
                // 站点条件判断
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
@@ -753,7 +759,7 @@
                        // 更新站点信息 且 下发plc命令
                        staProtocol.setWorkNo((short) workNo);
                        staProtocol.setStaNo(startupDto.getStaNo().shortValue());
                        staProtocol.setPakMk(false);
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
@@ -784,7 +790,7 @@
            List<WrkMast> wrkMasts = new ArrayList<>();
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                StaProtocol staProtocol = devpThread.getStation().get(staNo).clone();
                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { continue; }
                // 获取工作档数据
                WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
@@ -871,7 +877,7 @@
            boolean reset = true;
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                StaProtocol staProtocol = devpThread.getStation().get(staNo).clone();
                if (staProtocol == null) {continue;}
                if (staProtocol.getWorkNo() != 0) {
                    reset = false;
src/main/java/com/zy/core/model/protocol/StaProtocol.java
@@ -8,7 +8,7 @@
 * Created by vincent on 2020/8/6
 */
@Data
public class StaProtocol {
public class StaProtocol implements Cloneable {
    // 站点编号
    private Integer siteId;
@@ -44,7 +44,7 @@
    private boolean pakMk = true;
    // 台车位置
    private Integer position;
    private Short position;
    public BasDevp toSqlModel(){
        BasDevp basDevp = new BasDevp();
@@ -59,5 +59,14 @@
        return basDevp;
    }
    @Override
    public StaProtocol clone() {
        try {
            return (StaProtocol) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}
src/main/java/com/zy/core/thread/BarcodeThread.java
@@ -1,5 +1,6 @@
package com.zy.core.thread;
import com.core.common.Cools;
import com.zy.core.Slave;
import com.zy.core.ThreadHandler;
import lombok.Data;
@@ -41,7 +42,7 @@
                if (null != read) {
                    barcode = new String(read);
                }
                Thread.sleep(1000);
                Thread.sleep(100);
            } catch (Exception e) {
                e.printStackTrace();
            }
@@ -124,6 +125,16 @@
        return true;
    }
    public String getBarcode() {
        if (Cools.isEmpty(barcode)) {
            return null;
        } else if("NG".endsWith(barcode)) {
            return null;
        } else  {
            return barcode.trim();
        }
    }
    public static void main(String[] args) throws Exception {
        BarcodeThread barcodeThread = new BarcodeThread(new Slave());
        barcodeThread.getSlave().setIp("192.168.2.150");
src/main/java/com/zy/core/thread/DevpThread.java
@@ -139,7 +139,7 @@
            }
        }
        // 台车位置
        OperateResultExOne<Integer> result2 = siemensS7Net.ReadInt32("DB100.48");
        OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB100.48");
        if (result2.IsSuccess) {
            StaProtocol staProtocol = station.get(8);
            staProtocol.setPosition(result2.Content);
@@ -192,6 +192,7 @@
//        status[4] = staProtocol.isEmptyMk();
//        OperateResult write2 = siemensS7Net.Write("DB100." + ((staProtocol.getSiteId() - 1) + 40), status);     //  状态
        if (!write.IsSuccess || !write1.IsSuccess) {
            staProtocol = station.get(staProtocol.getSiteId());
            if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) {
                staProtocol.setPakMk(true);
            }
@@ -250,6 +251,16 @@
        }
    }
    /**
     * 设置入库标记
     */
    public void setPakMk(Integer siteId, boolean pakMk) {
        StaProtocol staProtocol = station.get(siteId);
        if (null != staProtocol) {
            staProtocol.setPakMk(pakMk);
        }
    }
    @Override
    public void close() {
        siemensS7Net.ConnectClose();
src/main/webapp/views/console.html
@@ -512,8 +512,8 @@
                        } else {
                            siteEl.html(sites[i].siteId);
                        }
                        if (i===8) {
                            carAnimate(i, Number(sites[i].nearbySta));
                        if (i+1===8) {
                            carAnimate(i+1, Number(sites[i].nearbySta));
                        }
                    }
                } else if (res.code === 403){
src/main/webapp/views/crn.html
@@ -108,15 +108,15 @@
                </div>
                <div class="select-container-item">
                    <span>排</span>
                    <label><input id="sourceRow" type="number" name="points" min="0" style="background-color: #a9eeff" /></label>
                    <label><input id="sourceRow" type="number" name="points" min="0" style="background-color: #a9eeff" value="0" /></label>
                </div>
                <div class="select-container-item">
                    <span>列</span>
                    <label><input id="sourceBay" type="number" name="points" min="0" style="background-color: #a9eeff" /></label>
                    <label><input id="sourceBay" type="number" name="points" min="0" style="background-color: #a9eeff" value="0" /></label>
                </div>
                <div class="select-container-item">
                    <span>层</span>
                    <label><input id="sourceLev" type="number" name="points" min="0" style="background-color: #a9eeff" /></label>
                    <label><input id="sourceLev" type="number" name="points" min="0" style="background-color: #a9eeff" value="0" /></label>
                </div>
            </div>
        </div>
@@ -130,15 +130,15 @@
                </div>
                <div class="select-container-item">
                    <span>排</span>
                    <label><input id="row" type="number" name="points" min="0" style="background-color: #a9eeff" /></label>
                    <label><input id="row" type="number" name="points" min="0" style="background-color: #a9eeff" value="0" /></label>
                </div>
                <div class="select-container-item">
                    <span>列</span>
                    <label><input id="bay" type="number" name="points" min="0" style="background-color: #a9eeff" /></label>
                    <label><input id="bay" type="number" name="points" min="0" style="background-color: #a9eeff" value="0" /></label>
                </div>
                <div class="select-container-item">
                    <span>层</span>
                    <label><input id="lev" type="number" name="points" min="0" style="background-color: #a9eeff" /></label>
                    <label><input id="lev" type="number" name="points" min="0" style="background-color: #a9eeff" value="0" /></label>
                </div>
            </div>
        </div>
@@ -417,7 +417,7 @@
    // 手动复位
    function handleReset() {
        http.post(baseUrl+"/crn/operator/clearCommand", getReqParam(), function (res) {
        http.post(baseUrl+"/crn/operator/handleReset", getReqParam(), function (res) {
            layer.msg(res.msg);
        });
    }