| | |
| | | mat.setCode(matnr.getMatnr()).setName(matnr.getMaktx()); |
| | | if (!Objects.isNull(matnr.getGroupName())) { |
| | | MatnrGroup matnrGroup = matnrGroupService.getOne(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getName, matnr.getGroupName()).last("limit 1"), false); |
| | | if (Objects.isNull(matnrGroup)) { |
| | | if (!Objects.isNull(matnrGroup)) { |
| | | mat.setGroupCode(matnrGroup.getCode()).setGroupId(matnrGroup.getId()); |
| | | } |
| | | } |
| | |
| | | companyParams.forEach(param -> { |
| | | Companys companys = new Companys(); |
| | | BeanUtils.copyProperties(param, companys); |
| | | if (Objects.isNull(companys.getCode())) { |
| | | if (Objects.isNull(companys.getCode()) || StringUtils.isBlank(companys.getCode())) { |
| | | throw new CoolException("企业编码不能为空!!"); |
| | | } |
| | | Companys one = companysService.getOne(new LambdaQueryWrapper<Companys>().eq(Companys::getName, param.getName()).last("limit 1")); |
| | | if (Objects.isNull(one)) { |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_COMPANYS_CODE, null); |
| | | companys.setCode(ruleCode); |
| | | } else { |
| | | throw new CoolException(one.getName() + ",企业名重复!!"); |
| | | if (Objects.isNull(companys.getName()) || StringUtils.isBlank(companys.getName())) { |
| | | throw new CoolException("企业名称不能为空!!"); |
| | | } |
| | | companys.setType(CompanysType.getCustomVal(param.getType())) |
| | | .setId(null); |
| | | if (!companysService.save(companys)) { |
| | | throw new CoolException("企业保存失败!!"); |
| | | |
| | | // 幂等同步:优先按编码匹配,找不到再按名称匹配 |
| | | Companys one = companysService.getOne(new LambdaQueryWrapper<Companys>() |
| | | .eq(Companys::getCode, param.getCode()) |
| | | .last("limit 1")); |
| | | if (Objects.isNull(one)) { |
| | | one = companysService.getOne(new LambdaQueryWrapper<Companys>() |
| | | .eq(Companys::getName, param.getName()) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | companys.setType(CompanysType.getCustomVal(param.getType())); |
| | | if (!Objects.isNull(one)) { |
| | | companys.setId(one.getId()); |
| | | // 已存在则更新,不重复报错 |
| | | if (!companysService.saveOrUpdate(companys)) { |
| | | throw new CoolException("企业更新失败!!"); |
| | | } |
| | | } else { |
| | | companys.setId(null); |
| | | // 新增时保留ERP传入编码,不再覆盖生成 |
| | | if (!companysService.save(companys)) { |
| | | throw new CoolException("企业保存失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | return R.ok(); |
| | |
| | | // 立即触发异步任务,不等待结果 |
| | | if (!Cools.isEmpty(palletId.get()) && StringUtils.isNotBlank(syncOrder.getOrderNo()) && !Cools.isEmpty(syncOrder.getStationId())) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, palletId.get())); |
| | | if (!Cools.isEmpty(loc)) { |
| | | if (!Cools.isEmpty(loc) && loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) { |
| | | // outStockService.getOrderOutTaskItem(orderOutTaskParam,param.getOrderItemId()); |
| | | //出库 |
| | | // boolean itemsCheck = waitPakinService.mergeItemsCheck(pakinParam, loginUserId); |
| | | // if (true) { |
| | | CompletableFuture.runAsync(() -> { |
| | | try { |
| | | asyncOutboundExecutionWcs(syncOrder.getStationId(), wkOrder.getId(), loginUserId); |
| | | asyncOutboundExecutionWcs(syncOrder.getStationId(), wkOrder.getId(), loginUserId,loc.getCode()); |
| | | } catch (Exception e) { |
| | | log.warn("订单 {} 开始自动出库", syncOrder.getOrderNo()); |
| | | } |
| | | }); |
| | | // } |
| | | } else { |
| | | log.warn("订单 {} 自动出库失败!!未查询到指定库存!!", syncOrder.getOrderNo()); |
| | | throw new CoolException("自动出库失败!!未查询到指定库存!!"); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Async |
| | | public void asyncOutboundExecutionWcs(String stationId ,Long orderId, Long loginUserId) { |
| | | public void asyncOutboundExecutionWcs(String stationId ,Long orderId, Long loginUserId,String locCode) { |
| | | try { |
| | | int i = 0; |
| | | while (true) { |
| | | i++; |
| | | if (i > 5) return; |
| | | Thread.sleep(3000); |
| | | WkOrder byId = asnOrderService.getById(orderId); |
| | | if (Cools.isEmpty(byId)) { |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | GenWaveParams genWaveParams = new GenWaveParams(); |
| | | List<Long> ids = new ArrayList<>(); |
| | |
| | | // return; |
| | | // } |
| | | // outStockService.genOutStockTask(tasks, loginUserId, orderId); |
| | | outStockService.generateWaves(genWaveParams); |
| | | R r = outStockService.generateWavesOrderAuto(genWaveParams, stationId,locCode); |
| | | |
| | | log.info("订单ID {} 自动转波次", orderId); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |