| | |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.constant.AsrsConstants; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.service.*; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | //查看工作档是否有相同货架,存在则抛出异常 |
| | | if (!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))) { |
| | | throw new CoolException(param.getBarcode() + "货架码已存在AGV工作档中"); |
| | | } |
| | | //判断是否有相同明细 |
| | | List<CombParam.CombMat> combMats = param.getCombMats(); |
| | | Map<String, String> data = new HashMap<>(); |
| | | for (CombParam.CombMat combMat : combMats) { |
| | | String matnr = combMat.getMatnr(); |
| | | String csocode = combMat.getCsocode(); |
| | | if (data.get(matnr + csocode) != null) { |
| | | throw new CoolException("明细中存在相同物料号和订单号"); |
| | | } |
| | | data.put(matnr + csocode, matnr + csocode); |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | |
| | | // 更新订单 |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode())); |
| | | orderDetl.setQty(orderDetl.getQty() + pick.getCount()); |
| | | orderDetl.setUpdateTime(new Date()); |
| | | if (!orderDetlService.update(orderDetl, new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()))) { |
| | | throw new CoolException("修改订单明细失败,请联系管理员" + pick.getOrderNo() + pick.getMatnr()); |
| | | } |
| | |
| | | |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode)); |
| | | |
| | | if (agvBasDevp == null) { |
| | | throw new CoolException(stationCode + "站点信息错误"); |
| | | } |
| | | |
| | | if (Cools.eq(agvBasDevp.getBarcode(), barcode)) { |
| | | return; |
| | | } |
| | |
| | | throw new CoolException(barcode + "已经绑定在" + agvBasDevp.getDevNo() + "站点"); |
| | | } |
| | | |
| | | if (agvBasDevp == null) { |
| | | throw new CoolException(stationCode + "站点信息错误"); |
| | | } |
| | | |
| | | if (!"O".equals(agvBasDevp.getLocSts())) { |
| | | throw new CoolException(stationCode + "该站点货位状态非空"); |
| | | } |
| | |
| | | @Transactional |
| | | public String allocationIn(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | throw new CoolException("请输入货架码"); |
| | | } |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("暂无当前货架码的任务"); |
| | |
| | | throw new CoolException("请输入货架码"); |
| | | } |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("source_loc_no", param.getDevNo())); |
| | | if (agvWrkMast == null) { |
| | | throw new CoolException("当前货架码没有任务"); |
| | | } |
| | | Integer oldWrkNo = agvWrkMast.getWrkNo(); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("工作档中没有此站点任务"); |
| | |
| | | @Synchronized |
| | | public String empIn(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | throw new CoolException("请输入货架码"); |
| | | } |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("工作档中没有此站点任务"); |
| | |
| | | public String handBack(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("source_loc_no", param.getDevNo())); |
| | | if (agvWrkMast == null) { |
| | | throw new CoolException("工作档中没有此站点任务"); |
| | | } |
| | | agvWrkMast.setIoType(113); |
| | | agvWrkMast.setModiUser(userId); |
| | | agvWrkMast.setModiTime(now); |
| | |
| | | agvWrkDetlLogService.save(agvWrkMast.getWrkNo()); |
| | | String sourceLocNo = agvWrkMast.getSourceLocNo(); |
| | | AgvLocMast newLocMast = agvCommonService.getLocNo(3, 1, false, false); |
| | | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", param.getBarcode())); |
| | | if (newLocMast == null) { |
| | | throw new CoolException("无可用库位"); |
| | | } |
| | | agvWrkMast.setSourceLocNo(agvWrkMast.getLocNo()); |
| | | agvWrkMast.setLocNo(newLocMast.getLocNo()); |
| | | agvWrkMast.setIoType(57); |
| | |
| | | agvLocMastService.updateLocStsByLocNo(sourceLocNo, "O", "", (short) 30); |
| | | agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no", sourceLocNo)); |
| | | |
| | | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", param.getBarcode())); |
| | | agvWrkDetls.forEach(agvWrkDetl -> { |
| | | for (AgvWrkDetl wrkDetl : param.getWrkDetls()) { |
| | | if (wrkDetl.getMatnr().equals(agvWrkDetl.getMatnr()) && wrkDetl.getThreeCode().equals(agvWrkDetl.getThreeCode())) { |
| | |
| | | return "ok"; |
| | | } |
| | | |
| | | /* |
| | | * 确认加工完成 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public String processedV2(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode()).eq("loc_no", param.getDevNo())); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("暂无当前货架的工作档"); |
| | | } |
| | | if (agvWrkMast.getWrkSts() != 205) { |
| | | throw new CoolException("当前任务未完成,请确认"); |
| | | } |
| | | //生成AGV工作历史档 + 生成AGV工作明细历史档 |
| | | agvWrkMastLogService.save(agvWrkMast); |
| | | agvWrkDetlLogService.save(agvWrkMast.getWrkNo()); |
| | | String sourceLocNo = agvWrkMast.getSourceLocNo(); |
| | | // TODO: 四期 |
| | | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", param.getBarcode())); |
| | | String factory = param.getFactory(); |
| | | AgvLocMast newLocMast = agvCommonService.getLocByLocRule(3, 1, factory); |
| | | if (newLocMast == null) { |
| | | throw new CoolException("无可用库位"); |
| | | } |
| | | agvWrkMast.setSourceLocNo(agvWrkMast.getLocNo()); |
| | | agvWrkMast.setLocNo(newLocMast.getLocNo()); |
| | | agvWrkMast.setIoType(57); |
| | | agvWrkMast.setWrkSts(201L); |
| | | agvWrkMast.setModiUser(userId); |
| | | agvWrkMast.setModiTime(now); |
| | | agvWrkMast.setIoTime(now); |
| | | // 打标记,若库位不够,入库到别的楼层,那么需要跨层移库 |
| | | if (!Cools.isEmpty(factory)) { |
| | | if (newLocMast.getLev1() == 1 && !factory.equals(AsrsConstants.SANCHANG)) { |
| | | agvWrkMast.setCtnNo("1"); |
| | | } else if (newLocMast.getLev1() == 2 && !factory.equals(AsrsConstants.ERCHANG)) { |
| | | agvWrkMast.setCtnNo("2"); |
| | | } |
| | | } |
| | | if (!agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", agvWrkMast.getWrkNo()))) { |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | |
| | | // 更新源站点 + 目标库位状态 + 历史源库位 |
| | | agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(), "R", param.getBarcode(), agvWrkMast.getWhsType().shortValue()); |
| | | agvLocMastService.updateLocStsByLocNo(newLocMast.getLocNo(), "S", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue()); |
| | | agvLocMastService.updateLocStsByLocNo(sourceLocNo, "O", "", (short) 30); |
| | | agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no", sourceLocNo)); |
| | | |
| | | agvWrkDetls.forEach(agvWrkDetl -> { |
| | | for (AgvWrkDetl wrkDetl : param.getWrkDetls()) { |
| | | if (wrkDetl.getMatnr().equals(agvWrkDetl.getMatnr()) && wrkDetl.getThreeCode().equals(agvWrkDetl.getThreeCode())) { |
| | | agvWrkDetl.setAnfme(wrkDetl.getAnfme()); |
| | | break; |
| | | } |
| | | } |
| | | agvWrkDetl.setProcessSts(2); |
| | | agvWrkDetl.setOrderNo(agvWrkDetl.getOrderNo().substring(2)); |
| | | agvWrkDetl.setModiUser(userId); |
| | | agvWrkDetl.setModiTime(now); |
| | | agvWrkDetl.setIoTime(now); |
| | | if (!agvWrkDetlService.update(agvWrkDetl, new EntityWrapper<AgvWrkDetl>() |
| | | .eq("matnr", agvWrkDetl.getMatnr()) |
| | | .eq("three_code", agvWrkDetl.getThreeCode()) |
| | | .eq("supp_code", param.getBarcode()))) { |
| | | throw new CoolException("更新工作明细失败"); |
| | | } |
| | | }); |
| | | return "ok"; |
| | | } |
| | | |
| | | /* |
| | | * 站点回退 |
| | |
| | | } else { |
| | | orderDetl = orderDetls.get(0); |
| | | } |
| | | orderDetl.setQty(orderDetl.getQty() - agvWrkDetl.getAnfme()); |
| | | double v = orderDetl.getQty() - agvWrkDetl.getAnfme(); |
| | | orderDetl.setQty(v < 0 ? 0 : v); |
| | | if (!orderDetlService.updateById(orderDetl)) { |
| | | throw new CoolException("修改订单明细失败,请联系管理员" + orderDetl.getOrderNo() + orderDetl.getMatnr()); |
| | | } |