自动化立体仓库 - WCS系统
#
18516761980
2022-08-11 0a78e1b883668873f5fc4f33866fc4bb64a4f473
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -9,15 +9,13 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.TestMastMapper;
import com.zy.asrs.mapper.WaitPakinMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.MatDto;
import com.zy.common.model.SearchLocParam;
import com.zy.common.model.StartupDto;
import com.zy.common.model.*;
import com.zy.common.service.CommonService;
import com.zy.common.utils.CollectionUtils;
import com.zy.common.utils.HttpHandler;
@@ -87,9 +85,14 @@
    private BasErrLogService basErrLogService;
    @Autowired
    private BasCrnErrorMapper basCrnErrorMapper;
    @Autowired
    private TestMastService testMastService;
    @Value("${wms.url}")
    private String wmsUrl;
    @Value("${test.url}")
    private String testUrl;
    /**
     * 组托
@@ -561,7 +564,7 @@
            }
            // 库位移转
            this.locToLoc(crn, crnProtocol);
            this.crnRebackHp(crnProtocol, crnThread);
//            this.crnRebackHp(crnProtocol, crnThread);
        }
    }
@@ -601,6 +604,7 @@
                if (wrkMastMapper.selectDevWorking(crnProtocol.getCrnNo()) == null) {
                    return;
                }
                log.info("堆垛机召回原点==>>" + crnProtocol.getCrnNo() + "号堆垛机有入库任务,召回原点");
                // 命令下发区 --------------------------------------------------------------------------
                CrnCommand crnCommand = new CrnCommand();
@@ -673,7 +677,7 @@
            // 已经存在吊车执行任务时,则过滤
            if (wrkMastMapper.selectWorking(slave.getId()) != null) {
                return;
                continue;
            }
            // 双深库位且浅库位有货,则需先对浅库位进行库位移转
@@ -1499,7 +1503,7 @@
                }
            }
            // 获取led线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
            // led显示默认内容
            if (reset && !ledThread.isLedMk()) {
                ledThread.setLedMk(true);
@@ -1885,8 +1889,6 @@
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void outOfDevp() {
@@ -1902,5 +1904,87 @@
        }
    }
    /**
     * 根据PLC按钮测试信号,发送启动申请到测试系统
     */
    @Transactional
    public void startTest() {
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                if(null != devpThread){
                    int channel = 0;
                    for (int i = 0; i < 4; i++){
                        switch (i){
                            case 0:
                                channel = devpThread.startSignal1;
                                break;
                            case 1:
                                channel = devpThread.startSignal2;
                                break;
                            case 2:
                                channel = devpThread.startSignal3;
                                break;
                            case 3:
                                channel = devpThread.startSignal4;
                                break;
                        }
                        if (channel == 1){
                            TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                                    .eq("channel",(i+1)).eq("status",0));
                            if(null != testMast){
                                Date now = new Date();
                                //http请求测试
                                TestDto testDto = new TestDto();
                                testDto.setLocNo(testMast.getLocNo());
                                testDto.setBarcode(testMast.getBarcode());
                                testDto.setUserId(testMast.getUserId());
                                testDto.setRequestTime(DateUtils.convert(now));
                                String response = new HttpHandler.Builder()
                                        .setUri(testUrl)
                                        .setPath("/testUrlPath")
                                        .setJson(JSON.toJSONString(testDto))
                                        .build()
                                        .doPost();
                                JSONObject jsonObject = JSON.parseObject(response);
                                if (jsonObject.getInteger("code").equals(200)) {
                                    //更新测试表状态
                                    testMast.setStatus(1);
                                    testMast.setModiTime(now);
                                    if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
                                            .eq("channel",1).eq("status",0))){
                                        throw new CoolException("更新产品测试状态失败");
                                    }
//                                    //更新库位状态,锁定pack状态,禁止入出库作业
//                                    LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()));
//                                    if(null != locMast){
//                                        locMast.setPackStatus(2);//测试中
//                                        locMast.setModiTime(now);
//                                        if(!locMastService.update(locMast,new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()))){
//                                            throw new CoolException("产品开始测试,更新目标库位锁定状态失败");
//                                        }
//                                    }
                                    //复位PLC信号
                                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, i*2));
                                } else {
                                    log.error("请求接口失败!!!url:{},request:{},response:{}", testUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(testDto), response);
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("启动测试  ===>> 启动测试失败", e);
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
    }
}