1
luxiaotao1123
2021-09-23 ff8ae23da4205f072c823ea2a5e095386c6672db
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -179,11 +179,11 @@
        List<FullStoreParam.MatCodeStore> erpMatList = param.getList();
        for (FullStoreParam.MatCodeStore es : erpMatList) {
            if (Cools.isEmpty(es.getStr6())) {
                String maxKeySql = "select max(FInterID) as num from CPICMO";
                String maxKeySql = "select min(FInterID) as num from CPICMO";
                List<ERPselectParam> maxKeyList = erpSqlServer.select(maxKeySql, ERPselectParam.class);
                Integer maxKey = maxKeyList.get(0).getNum();
                String ErpSql = "insert into CPICMO(FBrNo, FSourceBillNo, FBillNo, FTranType, FStatus, FMRP, FItemID, FQty, FCommitQty, FSourceEntryID, FClosed, FUnitID, FAuxCommitQty, FCancellation, FQtyFinish, FQtyScrap, FQtyLost, FAuxQtyFinish, FAuxQtyScrap, FAuxQtyLost, FMrpClosed, FBomInterID, FQtyPass, FAuxQtyPass, FQtyBack, FAuxQtyBack, FFinishTime, FReadyTIme, FPowerCutTime, FFixTime, FWaitItemTime, FWaitToolTime, FTaskID, FWorkTypeID, FCostObjID, FStockQty, FAuxStockQty, FSuspend, FReleasedQty, FReleasedAuxQty, FUnScheduledQty, FUnScheduledAuxQty, FSubEntryID, FScheduleID, FPlanOrderInterID, FProcessPrice, FProcessFee, FGMPBatchNo, FGMPCollectRate, FGMPItemBalance, FGMPBulkQty, FCustID, FMRPLockFlag, FHandworkClose, FInHighLimit, FInHighLimitQty, FInLowLimit, FInLowLimitQty, FChangeTimes, FCheckCommitQty, FAuxCheckCommitQty, FPlanConfirmed, FPlanMode, FMTONo, FPrintCount, FFinClosed, FStockFlag, FStartFlag, FVchBillNo, FVchInterID, FCardClosed, FHRReadyTime, FSourceTranType, FSourceInterId, FInterID, FAuxQty, FAuxInHighLimitQty, FAuxInLowLimitQty, Fnumber, FWorkShop) values (0, 0, '0', 85, 0, 1052, 0, 0, 0, 0, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14036, '0', 0, 0, 14215, 0, '0', 0, 1059, 0, 0, 0, 0, {0,number,#}, {1,number,#}, {2,number,#}, {3,number,#}, ''{4}'', 11378)";
                ErpSql = MessageFormat.format(ErpSql, maxKey + 1, es.getCount(), es.getCount(), es.getCount(), es.getMatNo());
                String ErpSql = "insert into CPICMO(FBrNo, FSourceBillNo, FBillNo, FTranType, FStatus, FMRP, FItemID, FQty, FCommitQty, FSourceEntryID, FClosed, FUnitID, FAuxCommitQty, FCancellation, FQtyFinish, FQtyScrap, FQtyLost, FAuxQtyFinish, FAuxQtyScrap, FAuxQtyLost, FMrpClosed, FBomInterID, FQtyPass, FAuxQtyPass, FQtyBack, FAuxQtyBack, FFinishTime, FReadyTIme, FPowerCutTime, FFixTime, FWaitItemTime, FWaitToolTime, FTaskID, FWorkTypeID, FCostObjID, FStockQty, FAuxStockQty, FSuspend, FReleasedQty, FReleasedAuxQty, FUnScheduledQty, FUnScheduledAuxQty, FSubEntryID, FScheduleID, FPlanOrderInterID, FProcessPrice, FProcessFee, FGMPBatchNo, FGMPCollectRate, FGMPItemBalance, FGMPBulkQty, FCustID, FMRPLockFlag, FHandworkClose, FInHighLimit, FInHighLimitQty, FInLowLimit, FInLowLimitQty, FChangeTimes, FCheckCommitQty, FAuxCheckCommitQty, FPlanConfirmed, FPlanMode, FMTONo, FPrintCount, FFinClosed, FStockFlag, FStartFlag, FVchBillNo, FVchInterID, FCardClosed, FHRReadyTime, FSourceTranType, FSourceInterId, FInterID, FAuxQty, FAuxInHighLimitQty, FAuxInLowLimitQty, Fnumber, FWorkShop) values (0, ''{6}'', '0', 85, 0, 1052, 0, 0, 0, 0, 0, 250, {5,number,#}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14036, '0', 0, 0, 14215, 0, '0', 0, 1059, 0, 0, 0, 0, {0,number,#}, {1,number,#}, {2,number,#}, {3,number,#}, ''{4}'', 11378)";
                ErpSql = MessageFormat.format(ErpSql, maxKey - 1, es.getCount(), es.getCount(), es.getCount(), es.getMatNo(), es.getCount(), es.getStr5());
                erpSqlServer.update(ErpSql);
            }
        }
@@ -285,6 +285,13 @@
            }
            // 生成工作档明细
            for (LocDetlDto detlDto : dto.getLocDetlDtos()) {
                // 如果为捡料出库需要判断托盘码是否为空
                if (ioType == 103) {
                    String zpallet = detlDto.getLocDetl().getZpallet();
                    if (Cools.isEmpty(zpallet)) {
                        throw new CoolException("拣料出库必须含有托盘码");
                    }
                }
                // 出库时,数量为0的直接忽略
                if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) {
                    continue;
@@ -327,30 +334,35 @@
        BasDevp staNo = basDevpService.checkSiteStatus(devpNo);
        if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) {
            // 小车入库搬运命令 ----------------------------------------------------
            BasAgv idleAgv = basAgvService.selectIdleAgv();
            AgvCommand command = new AgvCommand();
            command.setAgvId(idleAgv.getAgvId());
            command.setInterCode(basAgvService.getEmptyAgvWorkNo());
            command.setBeginLoc(String.valueOf(devpNo));
            command.setEndLoc("1088");
            log.info(JSON.toJSONString(command));
            String result;
            try {
                result = new HttpHandler.Builder()
                        .setUri(agvUrl + "/api/interfaceTask/SendTaskByThirdParty")
                        .setJson(JSON.toJSONString(command))
                        .build()
                        .doPost();
            } catch (IOException e) {
                e.printStackTrace();
                throw new CoolException("访问AGV接口失败");
            // 判断是否有空闲小车
            if (basAgvService.haveIdleAgv()) {
                AgvCommand command = new AgvCommand();
                command.setAgvId(0);
                command.setInterCode(basAgvService.getEmptyAgvWorkNo());
                command.setBeginLoc(String.valueOf(devpNo));
                command.setEndLoc("1088");
                log.info(JSON.toJSONString(command));
                String result;
                try {
                    result = new HttpHandler.Builder()
                            .setUri(agvUrl + "/api/interfaceTask/SendTaskByThirdParty")
                            .setJson(JSON.toJSONString(command))
                            .build()
                            .doPost();
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new CoolException("访问AGV接口失败");
                }
                AgvResult agvResult = JSON.parseObject(result, AgvResult.class);
                log.info(JSON.toJSONString(agvResult));
                if (!agvResult.getResult()) {
                    log.error("agv命令发送失败[agvId={}],错误信息={}", command.getAgvId(), agvResult.getExplain());
                    throw new CoolException("agv命令发送失败[agvId=" + command.getAgvId() + "],错误信息=" + agvResult.getExplain());
                }
            } else {
                throw new CoolException("没有空闲小车");
            }
            AgvResult agvResult = JSON.parseObject(result, AgvResult.class);
            log.info(JSON.toJSONString(agvResult));
            if (!agvResult.getResult()) {
                log.error("agv命令发送失败[agvId={}],错误信息={}", command.getAgvId(), agvResult.getExplain());
                throw new CoolException("agv命令发送失败[agvId=" + command.getAgvId() + "],错误信息=" + agvResult.getExplain());
            }
            return "待定";
        } else {
            // 源站点状态检测
@@ -474,6 +486,13 @@
        if (Cools.isEmpty(param.getOutSite())) {
            throw new CoolException("站点不存在");
        }
        // 目标站点状态检测
        BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
        int agvSite = 0;
        if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) {
            agvSite = staNo.getDevNo();
            staNo = basDevpService.checkSiteStatus(201);
        }
        for (String locNo : param.getLocNos()) {
            // 获取工作号
            int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE);
@@ -482,10 +501,13 @@
            if (Cools.isEmpty(locMast)) {
                throw new CoolException(locNo + "库位不存在");
            }
            if(!locMast.getLocSts().equals("D")){ //非在库状态
                continue;
            }
            // 获取源站
            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                    .eq("type_no", 110)
                    .eq("stn_no", param.getOutSite())
                    .eq("stn_no", staNo.getDevNo())
                    .eq("crn_no", locMast.getCrnNo());
            StaDesc staDesc = staDescService.selectOne(wrapper);
            Integer sourceStaNo = staDesc.getCrnStn();
@@ -500,7 +522,7 @@
            wrkMast.setIoType(110); // 入出库状态: 110.空板出库
            wrkMast.setIoPri(10D);
            wrkMast.setSourceStaNo(sourceStaNo); // 源站
            wrkMast.setStaNo(param.getOutSite()); // 目标站
            wrkMast.setStaNo(staNo.getDevNo()); // 目标站
            wrkMast.setCrnNo(locMast.getCrnNo());
            wrkMast.setSourceLocNo(locNo); // 源库位
            wrkMast.setFullPlt("N"); // 满板:Y
@@ -508,6 +530,8 @@
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk("Y"); // 空板
            wrkMast.setLinkMis("N");
            wrkMast.setCtnKind(agvSite); // 出库下的小车工作区站好
            wrkMast.setExitMk("N"); // 小车是否搬运
            wrkMast.setAppeUser(userId);
            wrkMast.setAppeTime(new Date());
            wrkMast.setModiUser(userId);