| | |
| | | import com.zy.asrs.mapper.LocMastMapper; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.AgvConstant; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.erp.kingdee.utils.PostMesDataUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | |
| | | boolean allEmpty = true; |
| | | if (param.getCombMats() != null) { |
| | | for (CombParam.CombMat mat : param.getCombMats()) { |
| | | if (!Cools.isEmpty(mat.getOrderNo())) { |
| | | allEmpty = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | if (allEmpty) { |
| | | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), |
| | | elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); |
| | | detlDto.setMemo(elem.getMemo()); |
| | | detlDto.setSupp(elem.getSupp()); |
| | | detlDto.setManu(elem.getManu()); |
| | | detlDto.setSuppCode(elem.getSuppCode()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.findDto(detlDtos, detlDto); |
| | | assert one != null; |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setMemo(detlDto.getMemo()); |
| | | waitPakin.setSupp(detlDto.getSupp()); |
| | | waitPakin.setSuppCode(detlDto.getSuppCode()); |
| | | waitPakin.setManu(detlDto.getManu()); |
| | | waitPakin.setStandby1(detlDto.getStandby1()); |
| | | waitPakin.setStandby2(detlDto.getStandby2()); |
| | | waitPakin.setStandby3(detlDto.getStandby3()); |
| | |
| | | // 关联组托 |
| | | } else { |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo()); |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getCombMats().get(0).getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单作业数量 |
| | | // if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { |
| | | // throw new CoolException("修改单据作业数量失败"); |
| | | // } |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE,order.getId(), elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), |
| | | elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), |
| | | elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); |
| | | detlDto.setMemo(elem.getMemo()); |
| | | detlDto.setSupp(elem.getSupp()); |
| | | detlDto.setManu(elem.getManu()); |
| | | detlDto.setSuppCode(elem.getSuppCode()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.findDto(detlDtos, detlDto); |
| | | assert one != null; |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setMemo(detlDto.getMemo()); |
| | | waitPakin.setSupp(detlDto.getSupp()); |
| | | waitPakin.setSuppCode(detlDto.getSuppCode()); |
| | | waitPakin.setManu(detlDto.getManu()); |
| | | waitPakin.setStandby1(detlDto.getStandby1()); |
| | | waitPakin.setStandby2(detlDto.getStandby2()); |
| | | waitPakin.setStandby3(detlDto.getStandby3()); |
| | |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | |
| | | // orderService.updateSettle(order.getId(), 2L, userId); |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId); |
| | | } |
| | |
| | | @Override |
| | | @Transactional |
| | | public void combAgv(CombParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats(),param.getLocNo())) { |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | // if(param.getCombMats().size()>1){ |
| | |
| | | if (countLoc > 0 || countWrk > 0 || countwait > 0) { |
| | | throw new CoolException("组托档/工作档/库存条码数据已存在===>>" + param.getBarcode()); |
| | | } |
| | | if(locMast == null){ |
| | | throw new CoolException("不存在该库位" + param.getLocNo()); |
| | | } |
| | | |
| | | |
| | | Date now = new Date(); |
| | | |
| | | boolean allEmpty = true; |
| | | if (param.getCombMats() != null) { |
| | | for (CombParam.CombMat mat : param.getCombMats()) { |
| | | if (!Cools.isEmpty(mat.getOrderNo())) { |
| | | allEmpty = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | if (allEmpty) { |
| | | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), |
| | | elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); |
| | | detlDto.setMemo(elem.getMemo()); |
| | | detlDto.setSupp(elem.getSupp()); |
| | | detlDto.setManu(elem.getManu()); |
| | | detlDto.setSuppCode(elem.getSuppCode()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.findDto(detlDtos, detlDto); |
| | | assert one != null; |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setMemo(detlDto.getMemo()); |
| | | waitPakin.setSupp(detlDto.getSupp()); |
| | | waitPakin.setSuppCode(detlDto.getSuppCode()); |
| | | waitPakin.setManu(detlDto.getManu()); |
| | | waitPakin.setStandby1(detlDto.getStandby1()); |
| | | waitPakin.setStandby2(detlDto.getStandby2()); |
| | | waitPakin.setStandby3(detlDto.getStandby3()); |
| | |
| | | // 关联组托 |
| | | } else { |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo()); |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getCombMats().get(0).getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单作业数量 |
| | | // if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { |
| | | // throw new CoolException("修改单据作业数量失败"); |
| | | // } |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE,order.getId(), elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), |
| | | elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), |
| | | elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); |
| | | detlDto.setMemo(elem.getMemo()); |
| | | detlDto.setSupp(elem.getSupp()); |
| | | detlDto.setManu(elem.getManu()); |
| | | detlDto.setSuppCode(elem.getSuppCode()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.findDto(detlDtos, detlDto); |
| | | assert one != null; |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setMemo(detlDto.getMemo()); |
| | | waitPakin.setSupp(detlDto.getSupp()); |
| | | waitPakin.setSuppCode(detlDto.getSuppCode()); |
| | | waitPakin.setManu(detlDto.getManu()); |
| | | waitPakin.setStandby1(detlDto.getStandby1()); |
| | | waitPakin.setStandby2(detlDto.getStandby2()); |
| | | waitPakin.setStandby3(detlDto.getStandby3()); |
| | |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | locMast.setLocSts("R"); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | // orderService.updateSettle(order.getId(), 2L, userId); |
| | | |
| | | BasAgvLocNoService basAgvLocNoService = SpringUtils.getBean(BasAgvLocNoService.class); |
| | | BasAgvLocNo basAgvLocNoSou = basAgvLocNoService.selectOne(new EntityWrapper<BasAgvLocNo>().eq("loc_no", param.getLocNo())); |
| | | AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam(); |
| | | agvBindCtnrAndBinParam.setCtnrCode(param.getBarcode()); |
| | | agvBindCtnrAndBinParam.setCtnrTyp("1"); |
| | | agvBindCtnrAndBinParam.setStgBinCode(basAgvLocNoSou.getAgvLocNo()); |
| | | agvBindCtnrAndBinParam.setReqCode(String.valueOf(System.currentTimeMillis())); |
| | | agvBindCtnrAndBinParam.setIndBind("1"); |
| | | ReturnT<String> resultBind = new PostMesDataUtils().postMesDataArmGrating("AGV容器解绑", |
| | | AgvConstant.AGV_URL+"/"+AgvConstant.AGV_1LBind,AgvConstant.getAGVADAPTOR(1), agvBindCtnrAndBinParam); |
| | | if(resultBind.getCode() != 200){ |
| | | throw new CoolException("agv入库绑定失败"); |
| | | } |
| | | locMast.setBarcode(param.getBarcode()); |
| | | locMast.setLocSts("R"); |
| | | if(!locMastService.updateById(locMast)){ |
| | | throw new CoolException("新增agv入库任务失败"); |
| | | } |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId); |
| | | } |
| | | } |