| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.enums.MatLocType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.*; |
| | |
| | | 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 com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.*; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | if (Objects.isNull(params.getOrgSite())) { |
| | | throw new CoolException("源站点不能为空!!"); |
| | | } |
| | | BasAreas basAreas = basAreasService |
| | | .selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type)); |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("frozen", 0) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | if (Objects.isNull(locCache)) { |
| | | throw new CoolException("请检查目标库位是否闲置中!!"); |
| | | } |
| | | if (!Objects.isNull(params.getTaskType()) && params.getTaskType().equals("XM1")) { |
| | | String taskType = params.getTaskType(); |
| | | generateXAgvTask(params.getOrgSite(), params.getTarSite(), userId, taskType); |
| | | } else { |
| | | String taskType = "M2"; |
| | | if (!params.getIsNewIn().isEmpty()) { |
| | | taskType = "M1"; |
| | | int cacheCount = locCacheService.selectCount(new EntityWrapper<LocCache>().eq("barcode", params.getBarcode())); |
| | | if (cacheCount > 0) { |
| | | throw new CoolException("台车已入库,不能勾选新台车!!"); |
| | | } |
| | | } |
| | | |
| | | String taskType = "M2"; |
| | | if (!params.getIsNewIn().isEmpty()) { |
| | | taskType = "M1"; |
| | | } |
| | | try { |
| | | generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId, taskType); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | BasAreas basAreas = basAreasService |
| | | .selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type)); |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("frozen", 0) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | if (Objects.isNull(locCache)) { |
| | | throw new CoolException("请检查目标库位是否闲置中!!"); |
| | | } |
| | | |
| | | try { |
| | | generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId, taskType); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateXAgvTask(String orgSite, String tarSite, Long userId, String taskType) { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(4); |
| | | // 保存工作档 |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(201L) // 工作状态:11.生成出库ID |
| | | .setIoType(1) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setIsNewIn(taskType) |
| | | .setFullPlt("Y") // 满板:Y |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setSourceStaNo(orgSite) |
| | | .setStaNo(tarSite) |
| | | .setLinkMis("N") |
| | | .setAppeUser(userId) |
| | | .setAppeTime(new Date()) |
| | | .setModiUser(userId) |
| | | .setModiTime(new Date()); |
| | | if (!taskService.insert(task)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R callEmptyCar(AgvCallParams params, Long userId) { |
| | | |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getOrgSite())); |
| | | |
| | | BasStation station1 = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(station1) || Objects.isNull(basAreas)) { |
| | | return R.error("目标站点或库区不存在,请联系管理!!"); |
| | | } |
| | | |
| | | List<String> list = Arrays.asList("SSX01", "SSX02", "SSX03", "SSX04", "SSX05", "SSX06", "SSX07", "SSX08", "SSX09", "SSX10"); |
| | | if (Long.parseLong(station1.getAreaId()) != basAreas.getId() && !list.contains(params.getTarSite())) { |
| | | return R.error("起始区和目标站点不在同一个库区,请重新操作!!"); |
| | | } |
| | | |
| | | List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>() |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | |
| | | } |
| | | generateCacheOutTask(station, locCaches.get(0), userId); |
| | | |
| | | // HIKApiDTO hikApiDTO =new HIKApiDTO() |
| | | // .setOrg(locCaches.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(); |
| | | } |
| | |
| | | } |
| | | |
| | | BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite())); |
| | | if (Objects.isNull(basAreas)) { |
| | | return R.error("站点不存在,请检查站点是否输入正确!!"); |
| | | } |
| | | |
| | | List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>() |
| | | .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateSOEOInTask(String type, LocCache loc, String orgSite, String barcode, Long userId) { |
| | | List<BasStationDetl> basStationDetls = basStationDetlService |
| | | .selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(basStationDetls) || basStationDetls.isEmpty()) { |
| | | throw new CoolException("站点信息不存在!!"); |
| | | } |
| | | |
| | | List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode)); |
| | | if (!tasks.isEmpty()) { |
| | | throw new CoolException("托盘已在任务执行中.."); |
| | | } |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | int workNo = commonService.getWorkNo(4); |
| | | // 保存工作档 |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | for (BasStationDetl basStationDetl : basStationDetls) { |
| | | List<BasStationDetl> basStationDetls = basStationDetlService |
| | | .selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite)); |
| | | basStationDetls.forEach(basStationDetl -> { |
| | | TaskDetl wrkDetl = new TaskDetl(); |
| | | BeanUtils.copyProperties(basStationDetl, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo) |
| | |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | // 修改目标库位状态 |
| | | 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)) { |
| | | if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | |
| | | // 修改目标站点信息 |
| | | // 修改原站点信息 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) { |
| | | station.setLocSts("R"); // S.入库预约 |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标站点状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | | station.setLocSts("R"); // S.入库预约 |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标站点状态失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 缓存区上架组托 |
| | | * 缓存区并板上架组托 |
| | | * |
| | | * @param param |
| | | * @param userId |
| | |
| | | if (Objects.isNull(param.getCombMats()) || param.getCombMats().isEmpty()) { |
| | | throw new CoolException("组托明细不能为空!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("wrk_sts", 14) |
| | | .eq("io_type", 104) |
| | | .eq("wrk_sts", 14) |
| | | .eq("io_type", 104) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | throw new CoolException("任务档信息不存在!!"); |
| | | throw new CoolException("任务档信息不存在,请检查托盘:" + param.getBarcode() + "任务档是否已完成出库 !!"); |
| | | } |
| | | |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("zpallet", param.getCarBarcode()) |
| | | .eq("three_code", combMat.getThreeCode())); |
| | | .eq(!Objects.isNull(combMat.getMatnr()), "matnr", combMat.getMatnr()) |
| | | .eq(!Objects.isNull(combMat.getThreeCode()), "three_code", combMat.getThreeCode())); |
| | | if (Objects.isNull(stationDetl)) { |
| | | throw new CoolException("明细内容不存在!!"); |
| | | } |
| | | WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>() |
| | | .eq("matnr", stationDetl.getMatnr()) |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | .eq("supp_code", stationDetl.getSuppCode())); |
| | | |
| | | if (Objects.isNull(wrkDetl)) { |
| | | //TODO 新插入 |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", stationDetl.getMatnr()) |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("matnr", stationDetl.getMatnr()) |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | if (Objects.isNull(mat)) { |
| | | throw new CoolException("物料基础信息已不存在!!"); |
| | | } |
| | |
| | | BeanUtils.copyProperties(stationDetl, detl); |
| | | detl.setAnfme(combMat.getAnfme()); |
| | | detl.setBarcode(wrkMast.getBarcode()); |
| | | detl.setBoxType1(combMat.getBoxType1()); |
| | | detl.setZpallet(param.getBarcode()); |
| | | detl.setBoxType1(param.getBoxType1()); |
| | | detl.setStandby1(combMat.getSuppCode()); |
| | | detl.setThreeCode(combMat.getThreeCode()); |
| | | detl.setAdjustQty(combMat.getAdjustQty()); |
| | | detl.setSplusQty(combMat.getSplusQty()); |
| | | detl.setWrkNo(wrkMast.getWrkNo()); |
| | | |
| | | if (!wrkDetlService.insert(detl)) { |
| | | throw new CoolException("任务明细保存失败!!"); |
| | | } |
| | | } else { |
| | | if (Objects.isNull(combMat.getAnfme())) { |
| | | throw new CoolException("数量不能为空!!"); |
| | | } |
| | | double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0; |
| | | if (!wrkDetlService.updateAnfme(val, wrkMast.getWrkNo(), wrkDetl.getMatnr(), |
| | | wrkDetl.getSuppCode())) { |
| | | WrkDetl detl = new WrkDetl(); |
| | | detl.setOrderNo(stationDetl.getOrderNo()); |
| | | detl.setBoxType1(param.getBoxType1()); |
| | | detl.setZpallet(param.getBarcode()); |
| | | detl.setBarcode(param.getBarcode()); |
| | | detl.setThreeCode(combMat.getThreeCode()); |
| | | detl.setStandby1(combMat.getSuppCode()); |
| | | detl.setAdjustQty(combMat.getAdjustQty()); |
| | | detl.setSplusQty(combMat.getSplusQty()); |
| | | detl.setAnfme(val); |
| | | detl.setModiTime(new Date()); |
| | | if (!wrkDetlService.update(detl, new EntityWrapper<WrkDetl>() |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("supp_code", stationDetl.getSuppCode()) |
| | | .eq("matnr", stationDetl.getMatnr()))) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," |
| | | + wrkDetl.getBatch() + "批号修改数量失败"); |
| | | } |
| | | } |
| | | |
| | | BasStationDetl stationDetl1 = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("zpallet", param.getCarBarcode()) |
| | | .eq("three_code", combMat.getThreeCode())); |
| | | |
| | | if (!Objects.isNull(stationDetl1)) { |
| | | Double v = Math.round((stationDetl1.getAnfme() - combMat.getAnfme()) * 10000) / 10000.0; |
| | | if (v.compareTo(0.0) == 0) { |
| | | if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>() |
| | | .eq("zpallet", param.getCarBarcode()) |
| | | .eq("three_code", combMat.getThreeCode()))) { |
| | | throw new CoolException("站点信息更新失败!!"); |
| | | } |
| | | } else { |
| | | stationDetl1.setAnfme(v); |
| | | if (!basStationDetlService.update(stationDetl1, new EntityWrapper<BasStationDetl>() |
| | | .eq("zpallet", param.getCarBarcode()) |
| | | .eq("three_code", combMat.getThreeCode()))) { |
| | | throw new CoolException("站点信息更新失败!!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | throw new CoolException("容器编码未维护,请维护后再操作!!"); |
| | | } |
| | | |
| | | Integer whsType = 2; |
| | | Integer whsType = 1; |
| | | Short lcoType = 1; |
| | | //用于判断料箱托盘,料箱,笼框 |
| | | if (!container.getType().equals(ContainerType.CONTAINER_TYPE_BOX.type)) { |
| | |
| | | if (Cools.isEmpty(basStation)) { |
| | | throw new CoolException("请输入正确的站点号"); |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", params.getOrgBarcode())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | throw new CoolException("出库任务档信息不存在!!"); |
| | | } |
| | | |
| | | for (CollectionPakinParams.CombMat combMat : params.getCombMats()) { |
| | | if (combMat.getWorkQty().compareTo(BigDecimal.ZERO) == 0) { |
| | | continue; |
| | |
| | | BasStationDetl basStationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("dev_no", basStation.getDevNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("batch", combMat.getBatch()) |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq(!Cools.isEmpty(combMat.getBatch()), "batch", combMat.getBatch()) |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "standby1", combMat.getStandby1())); |
| | | |
| | | |
| | | Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>() |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_coode", combMat.getStandby1()); |
| | | //// .eq(!Objects.isNull(params.getBoxType1()), "boxType1", params.getBoxType1()) |
| | | // |
| | | // if (!Objects.isNull(params.getBoxType1())) { |
| | | // wrapper.eq("box_type1", params.getBoxType1()); |
| | | // } |
| | | |
| | | // WrkDetl wrkDetl = wrkDetlService.selectOne(wrapper); |
| | | |
| | | if (Cools.isEmpty(basStationDetl)) { |
| | | basStationDetl = new BasStationDetl(); |
| | | Mat mat = matService.selectByMatnr(combMat.getMatnr()); |
| | |
| | | .setBarcode(params.getTarBarcode()) |
| | | .setZpallet(params.getTarBarcode()) |
| | | .setBatch(combMat.getBatch()) |
| | | .setBoxType1(params.getBoxType1()) |
| | | .setSuppCode(combMat.getStandby1()) |
| | | .setStandby1(combMat.getStandby1()) |
| | | .setAnfme(combMat.getWorkQty().doubleValue()); |
| | | |
| | | // if (!Objects.isNull(wrkDetl) && !wrkDetl.getMatnr().equals(combMat.getMatnr())) { |
| | | // throw new CoolException("请检查隔层是否绑定正确!!"); |
| | | // } |
| | | if (!basStationDetlService.insert(basStationDetl)) { |
| | | throw new CoolException("插入明细失败"); |
| | | } |
| | | |
| | | } else { |
| | | BigDecimal anfme = new BigDecimal(basStationDetl.getAnfme().toString()).add(combMat.getWorkQty()); |
| | | basStationDetl.setAnfme(anfme.doubleValue()); |
| | |
| | | OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_id", orderPakin.getId()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq(!Cools.isEmpty(combMat.getBatch()),"batch", combMat.getBatch()) |
| | | .eq(!Cools.isEmpty(combMat.getBatch()), "batch", combMat.getBatch()) |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "supp_code", combMat.getStandby1())); |
| | | if (Cools.isEmpty(orderDetlPakin)) { |
| | | throw new CoolException("检索单据明细数据失败"); |
| | |
| | | |
| | | @Override |
| | | public R collectionPakinView(CollectionPakinParams params) { |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(params.getOrgBarcode()); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException("未找到任务"); |
| | |
| | | |
| | | if (wrkMast.getIoType().equals(TaskIOType.ALL_OUT.type) |
| | | && wrkMast.getIoType().equals(TaskIOType.PICK_OUT.type)) { |
| | | throw new CoolException("人物类型错误"); |
| | | throw new CoolException("任务类型错误"); |
| | | } |
| | | |
| | | wrkDetlService.selectList(new EntityWrapper<WrkDetl>() |
| | | .eq(!Objects.isNull(params.getMatnr()), "matnr", params.getMatnr()) |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>() |
| | | .like(!Objects.isNull(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq(!Objects.isNull(params.getBoxType1()), "box_type1", params.getBoxType1()) |
| | | .eq("wrk_no", wrkMast.getWrkNo())); |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | // List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | if (Cools.isEmpty(wrkDetls)) { |
| | | throw new CoolException("未找到任务明细"); |
| | | } |
| | |
| | | AtomicReference<Double> totalOut = new AtomicReference<>(0.0); |
| | | listMap.forEach((matnr, detls) -> { |
| | | Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1)); |
| | | supIds.forEach((supId, sups) -> { |
| | | for (String supId : supIds.keySet()) { |
| | | List<LocDetl> sups = supIds.get(supId); |
| | | // } |
| | | // supIds.forEach((supId, sups) -> { |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("supp_code", supId) |
| | | .eq("matnr", matnr)); |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料不存在!!"); |
| | | } |
| | | // 根据supId(供应商)分类,得到需要存放的总空库存数量 |
| | | Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum(); |
| | | AtomicReference<Double> itemed = new AtomicReference<>(0.0); |
| | |
| | | if (container.getMixMax() > sets.size()) { |
| | | //余下可混放种类 |
| | | long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000; |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("supp_code", supId) |
| | | .eq("matnr", matnr)); |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料不存在!!"); |
| | | } |
| | | //余下最大可放数量 |
| | | Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0; |
| | | // 入库数量小于零且入库数量减去已计划出数量大于零() |
| | |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | // 获取当前供应商+ 物料在库 |
| | | LocMast notFullList = locMastService.selectNotFull(mats.getLocType(), one.getId()); |
| | | if (Objects.isNull(notFullList)) { |
| | | continue; |
| | | } |
| | | BasContainer container = basContainerService |
| | | .selectOne(new EntityWrapper<BasContainer>().eq("barcode", notFullList.getBarcode())); |
| | | if (Objects.isNull(container)) { |
| | | throw new CoolException("数据错误,容器不存在!!"); |
| | | } |
| | | List<LocDetl> adetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", notFullList.getLocNo())); |
| | | Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | | List<LocDetl> locDtls = new ArrayList<>(); |
| | | // 判断容器是否还可混放,及当前物料可放多少 |
| | | if (container.getMixMax() > sets.size()) { |
| | | //余下可混放种类 |
| | | long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000; |
| | | //余下最大可放数量 |
| | | Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0; |
| | | // 入库数量小于零且入库数量减去已计划出数量大于零() |
| | | if (sum.compareTo(v) <= 0 && sum.compareTo(itemed.get()) > 0) { |
| | | itemed.set(Math.round((itemed.get() + v) * 10000) / 10000.0); |
| | | // 可放下 |
| | | LocDetl locDetl = new LocDetl(); |
| | | BeanUtils.copyProperties(mats, locDetl); |
| | | locDetl.setLocNo(notFullList.getLocNo()); |
| | | locDetl.setAnfme(0.0); |
| | | locDetl.setMatnr(mats.getMatnr()); |
| | | locDetl.setZpallet(notFullList.getBarcode()); |
| | | locDetl.setSuppCode(mats.getSuppCode()); |
| | | locDetl.setMaktx(mats.getMaktx()); |
| | | locDtls.add(locDetl); |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(notFullList.getLocNo()).setLocDetlList(locDtls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | totalOut.set(Math.round((totalOut.get() + itemed.get()) * 10000) / 10000.0); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | /**是否优先空板出库*/ |
| | |
| | | if (Objects.isNull(locMast)) { |
| | | throw new CoolException("未查询到可用的空板信息!!"); |
| | | } |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>()); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } else { |
| | |
| | | if (Objects.isNull(locMast)) { |
| | | throw new CoolException("未查询到可用的空板信息!!"); |
| | | } |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>()); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | if (Cools.isEmpty(wrkMast1)) { |
| | | // Integer outSta = devp.getDevNo(); |
| | | Integer outSta = devp.getDevNo(); |
| | | // 获取路径 |
| | | // StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); |
| | | |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | // wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站 |
| | | // wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | //小松项目,缓存出库AGV站点,用于清空缓存区库存 |
| | | wrkMast.setPauseMk(station.getDevNo()); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateCacheOutTask(BasStation station, LocCache loc, Long userId) { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | int workNo = commonService.getWorkNo(4); |
| | | // 保存工作档 |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | |
| | | loc.setModiUser(userId); |
| | | loc.setModiTime(new Date()); |
| | | |
| | | if (!locCacheService.updateById(loc)) { |
| | | throw new CoolException("更新库位状态信息!!"); |
| | | } |
| | | // if (!) { |
| | | // throw new CoolException("更新库位状态信息!!"); |
| | | // } |
| | | locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo())); |
| | | |
| | | // 修改目标站点信息 |
| | | if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | | log.error("移转失败,目标库位状态:" + station.getLocSts()); |
| | | // throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | | } |
| | | } |
| | | |
| | |
| | | throw new CoolException("托盘已在任务执行中.."); |
| | | } |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | int workNo = commonService.getWorkNo(4); |
| | | // 保存工作档 |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(201L) // 工作状态:11.生成出库ID |
| | | .setIoType(1) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setTaskType(type) |
| | | .setIoPri(10D) |
| | | .setIsNewIn(isNewIn) |
| | | .setLocNo(loc.getLocNo()) // 目标库位 |
| | |
| | | throw new CoolException("更新组托信息失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 修改目标库位状态 |
| | | 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("更新目标库位状态失败"); |
| | | // 修改目标库位状态 |
| | | 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.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | |
| | | // 修改目标站点信息 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | // 修改目标站点信息 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type) || station.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) { |
| | | station.setLocSts("R"); // S.入库预约 |
| | | station.setLocSts("R"); // R.入库预约 |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + station.getLocSts()); |
| | | // 修改目标库位状态 |
| | | loc.setLocSts(LocStsType.LOC_STS_TYPE_D.type); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | loc.setModiUser(userId); |
| | | if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | |
| | | // 修改目标站点信息 |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite)); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | station.setLocSts("O"); |
| | | station.setBarcode(barcode); |
| | | station.setModiTime(new Date()); |
| | | station.setModiUser(userId); |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo())); |
| | | } |
| | | } |
| | | |
| | |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | |
| | | try { |
| | | //空台车回库 |
| | | generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | | log.error(e.getMessage()); |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | | return R.ok(locCache); |
| | |
| | | |
| | | /** |
| | | * 获取缓存站点信息 |
| | | * |
| | | * @param type |
| | | * @return |
| | | */ |
| | |
| | | return R.error("站点不存在!"); |
| | | } |
| | | return R.ok("查询成功").add(stations); |
| | | } |
| | | |
| | | /** |
| | | * 获取捆包明细信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getAllBindInfo(AgvCallParams params) { |
| | | if (Objects.isNull(params.getCarBarcode())) { |
| | | return R.error("台车编码不能为空!"); |
| | | } |
| | | List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>() |
| | | .eq("zpallet", params.getCarBarcode())); |
| | | |
| | | taskDetls.forEach(taskDetl -> { |
| | | OrderPakout orderDetlPakout = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>() |
| | | .eq("order_no", taskDetl.getOrderNo())); |
| | | taskDetl.setMemo(orderDetlPakout.getShipCode()); |
| | | }); |
| | | |
| | | return R.ok("查询成功").add(taskDetls); |
| | | } |
| | | |
| | | /** |
| | | * 按台车出库 |
| | | * |
| | | * @param params |
| | | * @return com.core.common.R |
| | | * @author Ryan |
| | | * @date 2026/3/28 8:41 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R outStockByTc(AgvCallParams params) { |
| | | if (Objects.isNull(params.getCarBarcode())) { |
| | | return R.error("台车码不能为空!!"); |
| | | } |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("barcode", params.getCarBarcode())); |
| | | if (Objects.isNull(locCache)) { |
| | | return R.error("当前台车不在缓冲库区!!"); |
| | | } |
| | | if (Objects.isNull(params.getTarSite())) { |
| | | return R.error("目标站点不能为空!!"); |
| | | } |
| | | BasStation devNo = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getTarSite())); |
| | | if (Objects.isNull(devNo) || !devNo.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | return R.error("目标站点忙碌中!!"); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locCache.getLocNo())); |
| | | if (Objects.isNull(locDetls) || locDetls.isEmpty()) { |
| | | return R.error("台车上没有对应明细信息!!"); |
| | | } |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | locDetls.forEach(locDetl -> { |
| | | List<OrderPakout> orderPakouts = orderPakoutService.selectList(new EntityWrapper<OrderPakout>() |
| | | .eq("doc_type", 5) |
| | | .eq("number", locDetl.getOrderNo())); |
| | | if (Objects.isNull(orderPakouts) || orderPakouts.isEmpty()) { |
| | | throw new CoolException("单据信息不存在或已上报完成!!"); |
| | | } |
| | | for (OrderPakout orderPakout : orderPakouts) { |
| | | OrderDetlPakout orderDetl = orderDetlPakoutService.selectOne(new EntityWrapper<OrderDetlPakout>() |
| | | .eq("matnr", locDetl.getMatnr()) |
| | | .eq("supp_code", locDetl.getSuppCode()) |
| | | .eq("order_no", orderPakout.getOrderNo())); |
| | | if (Objects.isNull(orderDetl)) { |
| | | continue; |
| | | } |
| | | locDetl.setMemo(orderPakout.getShipCode()); |
| | | locDetl.setOrderNo(orderPakout.getOrderNo()); |
| | | |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), locDetl.getAnfme()); |
| | | locDto.setFrozen(locDetl.getFrozen()); |
| | | locDto.setFrozenLoc(locCache.getFrozen()); |
| | | locDto.setAgvStaNo(params.getTarSite()); |
| | | locDto.setBrand(orderDetl.getBrand()); |
| | | locDto.setSuppCode(orderDetl.getSuppCode()); |
| | | locDto.setStandby1(orderDetl.getStandby1()); |
| | | locDto.setStandby2(orderDetl.getStandby2()); |
| | | locDto.setStandby3(orderDetl.getStandby3()); |
| | | locDto.setBoxType1(orderDetl.getBoxType1()); |
| | | locDto.setBoxType2(orderDetl.getBoxType2()); |
| | | locDto.setBoxType3(orderDetl.getBoxType3()); |
| | | locDtos.add(locDto); |
| | | |
| | | } |
| | | // exist.add(locDetl.getLocNo()); |
| | | }); |
| | | |
| | | generateAgvTaskByTc(locDtos); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 获取站点明细信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getStationInfos(AgvCallParams params) { |
| | | if (Objects.isNull(params.getOrgSite())) { |
| | | return R.error("站点不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getCarBarcode())) { |
| | | return R.error("站点台车不能为空!!"); |
| | | } |
| | | // if (!Cools.isEmpty(params.getMatnr())) { |
| | | // return R.error("物料信息不能为空!!"); |
| | | // } |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .eq("dev_no", params.getOrgSite()) |
| | | .eq("barcode", params.getCarBarcode())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("台车与站点绑定关系不存在,请联系管理员!"); |
| | | } |
| | | List<BasStationDetl> stationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>() |
| | | .like(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq("dev_no", station.getDevNo())); |
| | | if (!stationDetls.isEmpty()) { |
| | | return R.ok().add(stationDetls); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 站点物料解绑 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R unbindMatnr(CombParam params) { |
| | | if (Objects.isNull(params.getCombMats()) || params.getCombMats().isEmpty()) { |
| | | return R.error("明细不能为空!!"); |
| | | } |
| | | for (CombParam.CombMat combMat : params.getCombMats()) { |
| | | if (Objects.isNull(combMat)) { |
| | | continue; |
| | | } |
| | | OrderPakin order = orderPakinService.selectOne(new EntityWrapper<OrderPakin>() |
| | | .lt("settle", 4) |
| | | .eq("order_no", combMat.getOrderNo())); |
| | | if (Objects.isNull(order)) { |
| | | return R.error("未查询到订单,请确认是否为库口组托信息!!"); |
| | | } |
| | | //入库 |
| | | OrderDetlPakin detlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()) |
| | | .last("AND anfme != qty")); |
| | | |
| | | if (!Objects.isNull(detlPakin)) { |
| | | Double v = Math.round((detlPakin.getWorkQty() - combMat.getAnfme()) * 10000) / 10000.0; |
| | | detlPakin.setWorkQty(v); |
| | | if (!orderDetlPakinService.update(detlPakin, new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("订单明细更新失败!!"); |
| | | } |
| | | |
| | | BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | if (!Objects.isNull(stationDetl)) { |
| | | if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | 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("站点查询失败,请联系管理员!!"); |
| | | } |
| | | |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | if (!Objects.isNull(locDetl)) { |
| | | if (!locDetlService.delete(new EntityWrapper<LocDetl>() |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("解绑失败,缓冲库区库存删除失败!"); |
| | | } |
| | | } |
| | | |
| | | WaitPakin waitPakin = waitPakinService.selectOne(new EntityWrapper<WaitPakin>() |
| | | .eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1())); |
| | | if (!Objects.isNull(waitPakin)) { |
| | | if (!waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("order_no", combMat.getOrderNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("supp_code", combMat.getStandby1()))) { |
| | | throw new CoolException("原组托档删除失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | throw new CoolException("订单明细绑定关系不存在或已完成入库!!"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateAgvTaskByTc(List<LocDto> locDtos) { |
| | | List<LocDto> locDtoArrayList = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.getFrozen() != 1 && locDto.getFrozenLoc() != 1) { |
| | | locDtoArrayList.add(locDto); |
| | | } |
| | | } |
| | | locDtos = locDtoArrayList; |
| | | if (Cools.isEmpty(locDtos)) { |
| | | throw new CoolException("库存/库位被冻结,请处理后出库!!!"); |
| | | } |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | if (!locDto.isLack()) { |
| | | lack = false; |
| | | break; |
| | | } |
| | | } |
| | | if (lack) { |
| | | throw new CoolException("库存不足"); |
| | | } |
| | | |
| | | try { |
| | | Thread.sleep(300L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { |
| | | continue; |
| | | } |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getAgvStaNo(), locDto); |
| | | if (TaskDto.hasAgv(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.findAgv(taskDtos, taskDto); |
| | | assert dto != null; |
| | | dto.getLocDtos().addAll(taskDto.getLocDtos()); |
| | | } else { |
| | | taskDtos.add(taskDto); |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | Map<String, List<TaskDto>> listMap = taskDtos.stream().collect(Collectors.groupingBy(TaskDto::getLocNo)); |
| | | listMap.keySet().forEach(locNo -> { |
| | | listMap.get(locNo).forEach(taskDto -> { |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>() |
| | | .in("loc_sts", Arrays.asList(LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_O.type)) |
| | | .eq("dev_no", taskDto.getAgvStaNo())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("数据错误,站点不存在或已使用!!"); |
| | | } |
| | | workService.agvStockOut(station, taskDto, 9527L); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 确认捆包出库 |
| | | * |
| | | * @param combParam |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R confirmOutstock(CombParam combParam) { |
| | | if (Objects.isNull(combParam.getCombMats()) || combParam.getCombMats().isEmpty()) { |
| | | return R.error("捆包信息不能为空!!"); |
| | | } |
| | | Task task = taskService.selectOne(new EntityWrapper<Task>() |
| | | .eq("wrk_sts", 304) |
| | | .eq("barcode", combParam.getBarcode())); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("任务信息不存在!!"); |
| | | } |
| | | if (task.getIoType().equals(103)) { |
| | | List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>() |
| | | .eq("wrk_no", task.getWrkNo())); |
| | | |
| | | int workNo = commonService.getWorkNo(4); |
| | | Task task1 = new Task(); |
| | | BeanUtils.copyProperties(task, task1); |
| | | task1.setIoType(53); |
| | | task1.setLocNo(task.getSourceLocNo()); |
| | | task1.setSourceStaNo(task.getStaNo()); |
| | | task1.setWrkNo(workNo); |
| | | task1.setWrkSts(TaskStatusType.AGV_IN_START.type); |
| | | |
| | | if (!taskService.insert(task1)) { |
| | | throw new CoolException("入库任务生成失败!!"); |
| | | } |
| | | if (!Objects.isNull(taskDetls) && !taskDetls.isEmpty()) { |
| | | for (CombParam.CombMat combMat : combParam.getCombMats()) { |
| | | taskDetls.forEach(taskDetl -> { |
| | | if (taskDetl.getMatnr().equals(combMat.getMatnr()) && taskDetl.getSuppCode().equals(combMat.getSuppCode())) { |
| | | //TODO |
| | | if (!taskDetl.getAnfme().equals(combMat.getAnfme())) { |
| | | throw new CoolException("物料--->" + combMat.getMatnr() + "未拣料完成,请确认完成后再尝试!!"); |
| | | } |
| | | List<TaskDetl> taskDetls1 = taskDetlService.selectList(new EntityWrapper<TaskDetl>().eq("wrk_no", task.getWrkNo())); |
| | | if (!Objects.isNull(taskDetls1) && !taskDetls1.isEmpty()) { |
| | | taskDetls1.forEach(detl -> { |
| | | detl.setWrkNo(workNo); |
| | | detl.setBoxType1(combMat.getBoxType1()); |
| | | detl.setSupp(combMat.getSuppCode()); |
| | | if (!taskDetlService.update(detl, new EntityWrapper<TaskDetl>() |
| | | .eq("matnr", detl.getMatnr()) |
| | | .eq("order_no", detl.getOrderNo()) |
| | | .eq("supp_code", detl.getSuppCode()) |
| | | .eq("wrk_no", task.getWrkNo()))) { |
| | | throw new CoolException("任务号信息更新失败!!"); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | task.setWrkSts(TaskStatusType.AGV_INVENTORY_UPDATED_OUT.type); |
| | | if (!taskService.update(task, new EntityWrapper<Task>().eq("wrk_no", task.getWrkNo()))) { |
| | | throw new CoolException("任务信息更新失败!!"); |
| | | } |
| | | } |
| | | return R.ok("呼叫成功!!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 空板出库任务 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R getEmptyOutStock(AgvCallParams params) { |
| | | if (Objects.isNull(params.getOrgSite())) { |
| | | return R.error("托盘类型不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getTarSite())) { |
| | | return R.error("目标站点不能为空!!"); |
| | | } |
| | | Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type); |
| | | if (params.getOrgSite().equals(MatLocType.AUTOMATED.type)) { |
| | | wrapper.like("barcode", "LX80"); |
| | | } else if (params.getOrgSite().equals(MatLocType.SO_HOLDING.type)) { |
| | | wrapper.like("barcode", "TP80"); |
| | | } else { |
| | | wrapper.like("barcode", "TP88"); |
| | | } |
| | | wrapper.orderAsc(Arrays.asList("row1", "lev1")); |
| | | LocMast locMast = locMastService.selectOne(wrapper); |
| | | if (Objects.isNull(locMast)) { |
| | | return R.error("没有可用空板!!"); |
| | | } |
| | | |
| | | locMast.setLocSts(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", locMast.getLocNo()))) { |
| | | throw new CoolException(locMast.getLocNo() + "出库预约失败!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_loc_no", locMast.getLocNo())); |
| | | if (!Objects.isNull(wrkMast1)) { |
| | | throw new CoolException("任务档已生成,请不要重复操作!!"); |
| | | } |
| | | int workNo = commonService.getWorkNo(0); |
| | | //TODO 生成并板出库任务 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setIoType(104); |
| | | wrkMast.setWrkSts(11L); |
| | | wrkMast.setStaNo(params.getTarSite()); |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setIoPri(14.0); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkDate(new Date()); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setTaskType("crn"); |
| | | |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("新建任务失败!!"); |
| | | } |
| | | |
| | | return R.ok().add(wrkMast); |
| | | } |
| | | |
| | | /** |
| | | * 获取出库台车所有信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R getTcAllInfos(AgvCallParams params) { |
| | | if (Objects.isNull(params.getCarBarcode())) { |
| | | return R.error("台车码不能为空!!"); |
| | | } |
| | | // Task task = taskService.selectOne(new EntityWrapper<Task>().eq("barcode", params.getCarBarcode())); |
| | | // if (Objects.isNull(task)) { |
| | | // throw new CoolException("任务档不存在!!"); |
| | | // } |
| | | // if (Objects.isNull(task.getSourceLocNo())) { |
| | | // throw new CoolException("请检查任务类型是否属于出库捆绑!!"); |
| | | // } |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("barcode", params.getCarBarcode())); |
| | | if (Objects.isNull(locCache)) { |
| | | return R.error("当前台车不在缓冲库区!!"); |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locCache.getLocNo())); |
| | | if (!Objects.isNull(locDetls) && !locDetls.isEmpty()) { |
| | | locDetls.forEach(locDetl -> { |
| | | OrderPakout orderPakout = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>() |
| | | .eq("number", locDetl.getOrderNo())); |
| | | if (!Objects.isNull(orderPakout)) { |
| | | locDetl.setMemo(orderPakout.getShipCode()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | try { |
| | | Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMemo)); |
| | | if (!Cools.isEmpty(params.getShipCode())) { |
| | | List<LocDetl> detlList = listMap.get(params.getShipCode()); |
| | | return R.ok().add(detlList); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | |
| | | return R.ok().add(locDetls); |
| | | // Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMemo)); |
| | | // if (!Objects.isNull(params.getShipCode())) { |
| | | // List<LocDetl> detlList = listMap.get(params.getShipCode()); |
| | | // return R.ok().add(detlList); |
| | | // } else { |
| | | // return R.ok().add(locDetls); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | LocCache loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_IN_CACHE); |
| | | if (loc != null) return loc; |
| | | |
| | | // 2. Try SO Area |
| | | loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_SO); |
| | | if (loc != null) return loc; |
| | | |
| | | // 3. Try EO Area |
| | | loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_EO); |
| | | // // 2. Try SO Area |
| | | // loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_SO); |
| | | // if (loc != null) return loc; |
| | | // |
| | | // // 3. Try EO Area |
| | | // loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_EO); |
| | | return loc; |
| | | } |
| | | |
| | |
| | | } |
| | | return locCacheService.selectOne(new EntityWrapper<LocCache>() |
| | | .eq("area_id", area.getId()) |
| | | .eq("frozen", 0) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | .orderAsc(Arrays.asList("loc_no"))); |
| | | } |
| | | } |