| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.ForwardAGVTaskDTO; |
| | | import com.zy.asrs.entity.result.HIKApiDTO; |
| | | import com.zy.asrs.entity.result.HIKResultDTO; |
| | | import com.zy.asrs.enums.LocAreaType; |
| | | import com.zy.asrs.enums.LocStsType; |
| | | import com.zy.asrs.enums.OrderSettle; |
| | | import com.zy.asrs.mapper.LocMastMapper; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.common.constant.HIKApiConstant; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 移动端服务核心类 |
| | |
| | | |
| | | @Resource |
| | | private OrderDetlPakoutService orderDetlPakoutService; |
| | | |
| | | @Autowired |
| | | private LocCacheService locCacheService; |
| | | |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | @Autowired |
| | | private TaskDetlService taskDetlService; |
| | | @Autowired |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private BasContainerService basContainerService; |
| | | @Autowired |
| | | private BasAreasService basAreasService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | eq("zpallet", param.getBarcode()) |
| | | .eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | // 生成入库通知档 |
| | |
| | | } |
| | | }); |
| | | |
| | | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) { |
| | | throw new CoolException("物料:" + detlDto.getMatnr() + "单次最大组托上限为:" + mat.getUpQty()); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | BeanUtils.copyProperties(mat, waitPakin); |
| | | waitPakin.setBatch(detlDto.getBatch()); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setZpallet(param.getBarcode()); |
| | | waitPakin.setIoStatus("N"); |
| | | waitPakin.setAnfme(detlDto.getAnfme()); |
| | | waitPakin.setStatus("Y"); |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | |
| | | // 关联组托 |
| | | } else { |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, elem.getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 订单明细数量校验 |
| | | // OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), |
| | | // elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3()); |
| | |
| | | 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.setOrderId(order.getId()); |
| | | detlDto.setOrderNo(order.getOrderNo()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.findDto(detlDtos, detlDto); |
| | | assert one != null; |
| | |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | |
| | | BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(container)) { |
| | | throw new CoolException("数据错误:容器码不存在!!"); |
| | | } |
| | | if (container.getMixMax() < detlDtos.size()) { |
| | | throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | } |
| | | Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet()); |
| | | List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs)); |
| | | Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | if (tagIds.size() > 1) { |
| | | throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | | //还可以放入多少种物料 |
| | | Integer suplus = container.getMixMax(); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | //最多可放数量 |
| | | Double singleMax = mat.getUpQty() * suplus; |
| | | if (singleMax.compareTo(detlDto.getAnfme()) < 0) { |
| | | throw new CoolException("物料:" + detlDto.getMatnr() + "单次组托上限为:" + mat.getUpQty() + ",当前总量超出托盘装载上限!!"); |
| | | } |
| | | BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty()); |
| | | //当前物料需要占用料箱格数 |
| | | Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue(); |
| | | suplus = suplus - curr; |
| | | if (suplus < 0) { |
| | | throw new CoolException("物料:" + detlDto.getMatnr() + ", 超出当前托盘装载上限!!"); |
| | | } |
| | | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | BeanUtils.copyProperties(mat, waitPakin); |
| | | // waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setOrderId(order.getId()); |
| | | waitPakin.setOrderNo(detlDto.getOrderNo()); // 单据编号 |
| | | waitPakin.setOrderId(detlDto.getOrderId()); |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | // orderService.updateSettle(order.getId(), 2L, userId); |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId); |
| | | |
| | | Set<String> stringSet = param.getCombMats().stream().map(CombParam.CombMat::getOrderNo).collect(Collectors.toSet()); |
| | | stringSet.forEach(orderNo -> { |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, orderNo); |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | log.error("", e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 生成入库单据 |
| | |
| | | .eq("frozen", 0) |
| | | .ne("full_plt", "Y") |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type).orderAsc(Arrays.asList("row1")))); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/22 |
| | | * @description: 呼叫AGV搬运 |
| | | * @description: 呼叫空车 |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/24 |
| | | * @description: 获取订单物料信息 |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | public R getMatsByQRcode(PakinMatsByQRParams params) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getOrderNo())) { |
| | | throw new CoolException("单号不能为空!!"); |
| | | } |
| | | OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", params.getOrderNo())); |
| | | if (Objects.isNull(orderPakin)) { |
| | | throw new CoolException("数据错误:单据不存在!!"); |
| | | } |
| | | List<OrderDetlPakin> detlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>() |
| | | .eq(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq("order_id", orderPakin.getId())); |
| | | if (Objects.isNull(detlPakins) || detlPakins.isEmpty()) { |
| | | throw new CoolException("数据错误: 单据明细不存在!!"); |
| | | } |
| | | |
| | | return R.ok().add(detlPakins); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/24 |
| | | * @description: AGV呼叫搬运 |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | public R OutCallAgv(AgvCallParams params, Long userId) { |
| | | /**获取入库最早的一条数据**/ |
| | | LocCache locCaches = locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_F.type) |
| | | .eq("frozen", 0) |
| | | .orderDesc(Arrays.asList("sort", "first_time")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | if (Objects.isNull(locCaches)) { |
| | | throw new CoolException("暂无满足需求库位!"); |
| | | } |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点正在执行任务!!"); |
| | | } |
| | | |
| | | /**生成缓存区出库任务*/ |
| | | generateCacheOutTask(station, locCaches, userId); |
| | | |
| | | /**生成立库出库任务*/ |
| | | generateCRNOutTask(locCaches); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R callEmptyCar(AgvCallParams params) { |
| | | List<LocCache> locSts = locCacheService.selectList(new EntityWrapper<LocCache>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)); |
| | | if (locSts.isEmpty()){ |
| | | throw new CoolException("暂无空板库位"); |
| | | } |
| | | |
| | | HIKApiDTO hikApiDTO =new HIKApiDTO() |
| | | .setOrg(locSts.get(0).getLocNo()) |
| | | .setOrgType("05") |
| | | .setTar(params.getTarSite()) |
| | | .setTarType("05") |
| | | .setTaskType("GT5") |
| | | .setPriority("1") |
| | | .setCtnrType("2") |
| | | ; |
| | | HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH); |
| | | if (!hikResultDTO.isSuccess()){ |
| | | return R.error(hikResultDTO.getMessage()); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 生成立库出库任务 |
| | | * @author Ryan |
| | | * @date 2025/12/3 8:06 |
| | | * @param locCaches |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateCRNOutTask(LocCache locCaches) { |
| | | if (Objects.isNull(locCaches)) { |
| | | throw new CoolException("库位不能为空!!"); |
| | | } |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type)); |
| | | if (Objects.isNull(basAreas)) { |
| | | throw new CoolException("库区不存在!!"); |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("area_id", basAreas.getAreaNo()) |
| | | .eq("loc_id", locCaches.getId())); |
| | | |
| | | if (Objects.isNull(locDetls)) { |
| | | throw new CoolException("库存明细不存在!!"); |
| | | } |
| | | |
| | | //按物料编码分类 |
| | | Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMatnr)); |
| | | listMap.forEach((key, detls) -> { |
| | | |
| | | }); |
| | | |
| | | locDetls.forEach(locDetl -> { |
| | | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/25 |
| | | * @description: 呼叫AGV生成出库任务 |
| | | * @version 1.0 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateCacheOutTask(BasStation station, LocCache loc, Long userId) { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // 保存工作档 |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(11L) // 工作状态:11.生成出库ID |
| | | .setIoType(101) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setFullPlt("Y") // 满板:Y |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setStaNo(station.getDevNo()) |
| | | .setSourceLocNo(loc.getLocNo()) |
| | | .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 空板 |
| | | .setBarcode(loc.getBarcode())// 托盘码 |
| | | .setLinkMis("N") |
| | | .setAppeUser(userId) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId) |
| | | .setModiTime(new Date()); |
| | | if (!taskService.insert(task)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_id", loc.getId())); |
| | | if (Objects.isNull(detls) || detls.isEmpty()) { |
| | | throw new CoolException("数据错误:库位明细为空!!"); |
| | | } |
| | | List<TaskDetl> taskDetls = new ArrayList<>(); |
| | | detls.forEach(pakin -> { |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(pakin, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setOrderNo(pakin.getOrderNo()) |
| | | .setAnfme(pakin.getAnfme()) |
| | | .setZpallet(pakin.getZpallet()) |
| | | .setBatch(pakin.getBatch()) |
| | | .setMatnr(pakin.getMatnr()) |
| | | .setMaktx(pakin.getMaktx()) |
| | | .setAppeUser(userId) |
| | | .setUnit(pakin.getUnit()) |
| | | .setModel(pakin.getModel()) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId); |
| | | taskDetls.add(wrkDetl); |
| | | }); |
| | | |
| | | |
| | | |
| | | //保存工作档明细 |
| | | if (!taskDetlService.insertBatch(taskDetls)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | loc.setLocSts(LocStsType.LOC_STS_TYPE_R.type); |
| | | loc.setModiUser(userId); |
| | | loc.setModiTime(new Date()); |
| | | |
| | | if (!locCacheService.updateById(loc)) { |
| | | throw new CoolException("更新库位状态信息!!"); |
| | | } |
| | | |
| | | // 修改目标站点信息 |
| | | if (station.getLocSts().equals("O")) { |
| | | station.setLocSts("S"); // S.入库预约 |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/22 |
| | | * @description: 生成AGV搬运任务 |
| | | * @version 1.0 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) { |
| | | WaitPakin pakin = waitPakinService.selectOne(new EntityWrapper<WaitPakin>().eq("zpallet", barcode)); |
| | | if (Objects.isNull(pakin)) { |
| | | List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode)); |
| | | if (Objects.isNull(pakins) || pakins.isEmpty()) { |
| | | throw new CoolException("组托信息不存在!!"); |
| | | } |
| | | OrderPakin orderPakin = orderPakinService.selectById(pakin.getOrderId()); |
| | | if (Objects.isNull(orderPakin)) { |
| | | throw new CoolException("单据不能为空!!"); |
| | | } |
| | | |
| | | List<OrderDetlPakin> detls = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>().eq("order_id", pakin.getOrderId())); |
| | | if (Objects.isNull(detls) || detls.isEmpty()) { |
| | | throw new CoolException("数据错误:单据明细不存在!!"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setTaskType("agv"); |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setLocNo(loc.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setSourceLocNo(orgSite); |
| | | wrkMast.setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(barcode); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(1L) // 工作状态:11.生成出库ID |
| | | .setIoType(1) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setLocNo(loc.getLocNo()) // 目标库位 |
| | | .setFullPlt("Y") // 满板:Y |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setSourceStaNo(orgSite) |
| | | .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 空板 |
| | | .setBarcode(barcode)// 托盘码 |
| | | .setLinkMis("N") |
| | | .setAppeUser(userId) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId) |
| | | .setModiTime(new Date()); |
| | | if (!taskService.insert(task)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | List<WrkDetl> taskDetls = new ArrayList<>(); |
| | | detls.forEach(detl -> { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | BeanUtils.copyProperties(detl, wrkDetl); |
| | | List<TaskDetl> taskDetls = new ArrayList<>(); |
| | | pakins.forEach(pakin -> { |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(pakin, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setAnfme(detl.getAnfme()) |
| | | .setOrderNo(pakin.getOrderNo()) |
| | | .setAnfme(pakin.getAnfme()) |
| | | .setZpallet(pakin.getZpallet()) |
| | | .setBatch(detl.getBatch()) |
| | | .setMatnr(detl.getMatnr()) |
| | | .setMaktx(detl.getMaktx()) |
| | | .setBatch(pakin.getBatch()) |
| | | .setMatnr(pakin.getMatnr()) |
| | | .setMaktx(pakin.getMaktx()) |
| | | .setAppeUser(userId) |
| | | .setUnit(detl.getUnit()) |
| | | .setModel(detl.getModel()) |
| | | .setUnit(pakin.getUnit()) |
| | | .setModel(pakin.getModel()) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId); |
| | | taskDetls.add(wrkDetl); |
| | | }); |
| | | |
| | | //保存工作档明细 |
| | | if (!wrkDetlService.insertBatch(taskDetls)) { |
| | | if (!taskDetlService.insertBatch(taskDetls)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(now); |
| | | if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | loc.setModiUser(userId); |
| | | if (!locCacheService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | } |
| | | |
| | | |
| | | public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO,String path){ |
| | | HIKResultDTO result = new HIKResultDTO(); |
| | | |
| | | ForwardAGVTaskDTO forwardAGVTaskParam = new ForwardAGVTaskDTO(); |
| | | forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", "")); |
| | | forwardAGVTaskParam.setClientCode("IWMS"); |
| | | forwardAGVTaskParam.setTaskTyp(haiKangApiDTO.getTaskType()); |
| | | forwardAGVTaskParam.setCtnrTyp(haiKangApiDTO.getCtnrType()); |
| | | forwardAGVTaskParam.setPriority(haiKangApiDTO.getPriority()); |
| | | List<ForwardAGVTaskDTO.PositionCodePaths> positionCodePathsList = new ArrayList<>(); |
| | | positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType())); |
| | | positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType())); |
| | | forwardAGVTaskParam.setPositionCodePath(positionCodePathsList); |
| | | |
| | | String body = JSON.toJSONString(forwardAGVTaskParam); |
| | | String response = ""; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(HIKApiConstant.AGV_IP) |
| | | .setPath(path) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(0)) { |
| | | result.setSuccess(true); |
| | | } else { |
| | | result.setMessage(jsonObject.getString("message")); |
| | | log.error("发送agv任务失败!!!url:{};request:{};response:{}", HIKApiConstant.AGV_IP + path, body, response); |
| | | } |
| | | // {"code":"1","data":"","interrupt":false,"message":"重复提交","msgErrCode":"0x3a80D012","reqCode":"fa92b49481a44627ae4d80c1400f28f6"} |
| | | } catch (Exception e) { |
| | | result.setMessage(e.getMessage()); |
| | | log.error("发送agv任务异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "发送agv任务", |
| | | HIKApiConstant.AGV_IP + path, |
| | | null, |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | result.isSuccess() |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |