#
lty
昨天 276d837c0bb808e6d93ac7c7ba6abe654c75552e
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -10,6 +10,7 @@
import com.zy.asrs.domain.enums.LedErrorAreaType;
import com.zy.asrs.domain.enums.TaskStatusType;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.InboundTaskApplyParam;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.*;
@@ -82,6 +83,8 @@
    private BasDevpPositionService basDevpPositionService;
    @Autowired
    private TaskWrkService taskWrkService;
    @Autowired
    private OpenService openService;
    @Value("${wms.url}")
    private String wmsUrl;
@@ -258,45 +261,31 @@
                    try {
                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
                        SearchLocParam param = new SearchLocParam();
                        param.setBarcode(barcode);
                        param.setIoType(1);
                        param.setSourceStaNo(inSta.getStaNo());
                        param.setLocType1(locTypeDto.getLocType1());
                        // 替换为新的任务申请接口
                        InboundTaskApplyParam applyParam = new InboundTaskApplyParam();
                        applyParam.setBarcode(barcode);
                        applyParam.setStationCode(String.valueOf(inSta.getStaNo()));
                        applyParam.setStatus(1); // 1:满板
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
                                .setJson(JSON.toJSONString(param))
                                .setPath("/inboundTaskApply")
                                .setJson(JSON.toJSONString(applyParam))
                                .build()
                                .doPost();
                        // 解析响应,只确认申请是否成功
                        JSONObject jsonObject = JSON.parseObject(response);
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
//                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                            barcodeThread.setBarcode("");
                            staProtocol.setWorkNo(dto.getWorkNo());
//                            if(Cools.isEmpty(dto.getRgvNo()) || dto.getRgvNo() <= 0) {
//                                staProtocol.setStaNo(607);//607
//                            } else {//如果存在RGV编号,说明需要RGV接驳,先下发任务到RGV源站
//                            staProtocol.setStaNo(dto.getRgvSstaNo().shortValue());
                            staProtocol.setStaNo(wrkMast.getStaNoSou$().shortValue());
//                            }
                            devpThread.setPakMk(staProtocol.getSiteId(), false,283);
                        if (jsonObject != null && jsonObject.getInteger("code") != null && jsonObject.getInteger("code") == 200) {
                            log.info("入库任务申请成功,等待WMS下发任务。条码:{},站点:{}", barcode, inSta.getStaNo());
                            staProtocol.setWorkNo(9998);//设置为9998等待上位机下发任务/9997是空板入库判断,待下发时也写入9998
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                LedErrorThreadUtil.ledErrorThread("更新plc站点信息失败!站点号:"+inSta.getStaNo(),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc());
                                throw new CoolException("更新plc站点信息失败");
                            }
                        } else {
                            // 获取工作号
                            //                            // 获取工作号
                            int workNo = commonService.getWorkNo(3);
                            staProtocol.setWorkNo(workNo);
@@ -306,8 +295,50 @@
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            LedErrorThreadUtil.ledErrorThread("入库请求失败"+jsonObject.getInteger("code"),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc());
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/inboundTaskApply", JSON.toJSONString(applyParam), response);
                        }
                        // 原有逻辑注释掉
//                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
//
//                        SearchLocParam param = new SearchLocParam();
//                        param.setBarcode(barcode);
//                        param.setIoType(1);
//                        param.setSourceStaNo(inSta.getStaNo());
//                        param.setLocType1(locTypeDto.getLocType1());
//                        String response = new HttpHandler.Builder()
//                                .setUri(wmsUrl)
//                                .setPath("/rpc/pakin/loc/v1")
//                                .setJson(JSON.toJSONString(param))
//                                .build()
//                                .doPost();
//                        JSONObject jsonObject = JSON.parseObject(response);
//                        if (jsonObject.getInteger("code").equals(200)) {
//                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
//
//                            barcodeThread.setBarcode("");
//                            staProtocol.setWorkNo(dto.getWorkNo());
//                            staProtocol.setStaNo(wrkMast.getStaNoSou$().shortValue());
//
//                            devpThread.setPakMk(staProtocol.getSiteId(), false,283);
//                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                            if (!result) {
//                                LedErrorThreadUtil.ledErrorThread("更新plc站点信息失败!站点号:"+inSta.getStaNo(),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc());
//                                throw new CoolException("更新plc站点信息失败");
//                            }
//                        } else {
//                            // 获取工作号
//                            int workNo = commonService.getWorkNo(3);
//
//                            staProtocol.setWorkNo(workNo);
//                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
//
//                            devpThread.setPakMk(staProtocol.getSiteId(), false,201);
//                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                            // led 异常显示
//                            LedErrorThreadUtil.ledErrorThread("入库请求失败"+jsonObject.getInteger("code"),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc());
//                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
//                        }
                    } catch (Exception e) {
                        e.printStackTrace();
@@ -337,36 +368,35 @@
                }
                // 站点条件判断
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
                        && staProtocol.isEmptyMk() && ((staProtocol.getWorkNo() > 9000 && staProtocol.getWorkNo() <= 9999) || staProtocol.getWorkNo()==0)  && staProtocol.isPakMk()) {
                        && staProtocol.isEmptyMk() && ((staProtocol.getWorkNo() > 9000 && staProtocol.getWorkNo() <= 9997) || staProtocol.getWorkNo()==0)  && staProtocol.isPakMk()) {
                    try {
                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
                        SearchLocParam param = new SearchLocParam();
                        param.setIoType(10);
                        param.setSourceStaNo(emptyInSta.getStaNo());
                        param.setLocType1(locTypeDto.getLocType1());
                        InboundTaskApplyParam applyParam = new InboundTaskApplyParam();
                        applyParam.setBarcode(null);
                        applyParam.setStationCode(String.valueOf(emptyInSta.getStaNo()));
                        applyParam.setStatus(0); // 1:满板
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
                                .setJson(JSON.toJSONString(param))
                                .setPath("/inboundTaskApply")
                                .setJson(JSON.toJSONString(applyParam))
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                            // 更新站点信息 且 下发plc命令
                            staProtocol.setWorkNo(dto.getWorkNo());
                            staProtocol.setStaNo(dto.getStaNoSou$(dto.getStaNo(),staProtocol.getSiteId()).shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false,4087);
                        // 解析响应,只确认申请是否成功
                        JSONObject jsonObject = JSON.parseObject(response);
                        if (jsonObject != null && jsonObject.getInteger("code") != null && jsonObject.getInteger("code") == 200) {
                            log.info("入库任务申请成功,等待WMS下发任务,站点:{}",emptyInSta.getStaNo());
                            staProtocol.setWorkNo(9998);//设置为9998等待上位机下发任务
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                LedErrorThreadUtil.ledErrorThread("更新plc站点信息失败!站点号:"+emptyInSta.getStaNo(),emptyInSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc());
                                throw new CoolException("更新plc站点信息失败");
                            }
                        } else {
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/inboundTaskApply", JSON.toJSONString(applyParam), response);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
@@ -545,6 +575,10 @@
                        if (wrkMastMapper.updateById(wrkMast) != 0) {
                            // 复位堆垛机
                            crnThread.setResetFlag(true);
                            if(wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107) { //拣料出库任务状态上报,其他上报在wms任务完成定时任务中
                                openService.reportTaskStatus(String.valueOf(wrkMast.getWrkNo()),3,1,wrkMast.getBarcode());
                            }
                        } else {
                            log.error("更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
                        }