| | |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.MatnrServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.DictTypeCode; |
| | | import com.vincent.rsf.server.system.constant.GlobalConfigCode; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | |
| | | @Autowired |
| | | private MatnrGroupService matnrGroupService; |
| | | @Autowired |
| | | private MatnrServiceImpl matnrService; |
| | | private MatnrService matnrService; |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | @Autowired |
| | |
| | | private TaskItemService taskItemService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private CusBarcodeSyncMatnrService cusBarcodeSyncMatnrService; |
| | | |
| | | /** |
| | | * 云仓改单/取消前:任务明细已关联该单据且主任务未逻辑删除则不允许 |
| | |
| | | return; |
| | | } |
| | | assertWkOrderExceStatusUnexecuted(order, "取消"); |
| | | } |
| | | |
| | | private void syncMatnrFromCusItemSyncViewByConfig(List<SyncOrdersItem> orderItems, Long loginUserId) { |
| | | cusBarcodeSyncMatnrService.syncFromOrderItems(orderItems, loginUserId); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void syncMatnrs(List<BaseMatParms> matnrs) { |
| | | List<Matnr> syncMatnrs = new ArrayList<>(); |
| | | if (!matnrs.isEmpty()) { |
| | | assertUniqueMatnrInSyncList(matnrs); |
| | | matnrs.forEach(matnr -> { |
| | | Matnr mat = new Matnr(); |
| | | if (Objects.isNull(matnr.getMatnr())) { |
| | | throw new RuntimeException("物料编码不能为空!!"); |
| | | } |
| | | BeanUtils.copyProperties(matnr, mat); |
| | | mat.setCode(matnr.getMatnr()).setName(matnr.getMaktx()); |
| | | mat.setCode(matnr.getMatnr()).setName(matnr.getMaktx()) |
| | | .setBatch(matnrService.normalizeMatnrBatchValue(matnr.getBatch())); |
| | | if (!Objects.isNull(matnr.getGroupName())) { |
| | | MatnrGroup matnrGroup = matnrGroupService.getOne(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getName, matnr.getGroupName()), false); |
| | | if (Objects.isNull(matnrGroup)) { |
| | | if (!Objects.isNull(matnrGroup)) { |
| | | mat.setGroupCode(matnrGroup.getCode()).setGroupId(matnrGroup.getId()); |
| | | } |
| | | } |
| | |
| | | |
| | | if (!matnrService.saveOrUpdateBatch(syncMatnrs)) { |
| | | throw new CoolException("物料信息保存成功!!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void assertUniqueMatnrInSyncList(List<BaseMatParms> matnrs) { |
| | | Set<String> keys = new HashSet<>(); |
| | | for (BaseMatParms p : matnrs) { |
| | | if (StringUtils.isBlank(p.getMatnr())) { |
| | | continue; |
| | | } |
| | | String key = p.getMatnr().trim() + "\u0000" + matnrService.normalizeMatnrBatchValue(p.getBatch()); |
| | | if (!keys.add(key)) { |
| | | throw new CoolException("同步列表中物料编码与批次重复:" + p.getMatnr().trim() |
| | | + (StringUtils.isNotBlank(matnrService.normalizeMatnrBatchValue(p.getBatch())) |
| | | ? " / " + matnrService.normalizeMatnrBatchValue(p.getBatch()) : "")); |
| | | } |
| | | } |
| | | } |
| | |
| | | public R syncLocsDetl(PageParam<Loc, BaseParam> pageParam, QueryWrapper<Loc> wrapper) { |
| | | Page<Object> page = new Page<>(); |
| | | page.setCurrent(pageParam.getCurrent()).setSize(pageParam.getSize()); |
| | | IPage<LocStockDto> locStocks = locService.getLocDetls(page); |
| | | BaseParam bp = pageParam.getWhere(); |
| | | Map<String, Object> conds = bp != null && bp.getMap() != null ? bp.getMap() : Collections.emptyMap(); |
| | | IPage<LocStockDto> locStocks = locService.getLocDetls(page, conds); |
| | | return R.ok().add(locStocks); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | // 按配置同步物料主数据(none 时不影响通知档写入主流程) |
| | | syncMatnrFromCusItemSyncViewByConfig(syncOrder.getOrderItems(), loginUserId); |
| | | WkOrder wkOrder = new WkOrder(); |
| | | String wkTypeInput = syncOrder.getWkType(); |
| | | String typeCode = StringUtils.isBlank(wkTypeInput) ? null : orderWorkTypeService.getTypeByLabel(wkTypeInput); |
| | |
| | | Integer operateType = baseMatParms.getOperateType(); |
| | | // 3 禁用 / 4 启用:仅更新状态(status 1 正常 0 冻结) |
| | | if (Integer.valueOf(3).equals(operateType) || Integer.valueOf(4).equals(operateType)) { |
| | | Matnr matnr = matnrService.getOne(new LambdaQueryWrapper<Matnr>().eq(Matnr::getCode, baseMatParms.getMatnr())); |
| | | Matnr matnr = matnrService.getOneByCodeAndBatch(baseMatParms.getMatnr(), baseMatParms.getBatch()); |
| | | if (matnr == null) { |
| | | throw new CoolException("物料不存在,无法执行禁用/启用!!"); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | // 1 新增 / 2 修改 / 不传:有则更新、无则新增 |
| | | Matnr matnr = matnrService.getOne(new LambdaQueryWrapper<Matnr>().eq(Matnr::getCode, baseMatParms.getMatnr())); |
| | | Matnr matnr = matnrService.getOneByCodeAndBatch(baseMatParms.getMatnr(), baseMatParms.getBatch()); |
| | | if (Objects.isNull(matnr)) { |
| | | Matnr matnr1 = new Matnr(); |
| | | BeanUtils.copyProperties(baseMatParms, matnr1); |
| | | matnr1.setCode(baseMatParms.getMatnr()); |
| | | matnr1.setName(baseMatParms.getMaktx()); |
| | | matnr1.setBatch(matnrService.normalizeMatnrBatchValue(baseMatParms.getBatch())); |
| | | if (!Objects.isNull(baseMatParms.getGroupName())) { |
| | | MatnrGroup matnrGroup = matnrGroupService.getOne(new LambdaQueryWrapper<MatnrGroup>() |
| | | .eq(MatnrGroup::getName, baseMatParms.getGroupName())); |
| | |
| | | matnr.setName(baseMatParms.getMaktx()) |
| | | .setColor(baseMatParms.getColor()) |
| | | .setModel(baseMatParms.getModel()) |
| | | .setSpec(baseMatParms.getSpec()); |
| | | .setSpec(baseMatParms.getSpec()) |
| | | .setBatch(matnrService.normalizeMatnrBatchValue(baseMatParms.getBatch())); |
| | | |
| | | if (!matnrService.updateById(matnr)) { |
| | | throw new CoolException("物料更新失败!!"); |
| | |
| | | if (!Cools.isEmpty(param.getPlanNo())) { |
| | | wrapper.eq(LocItem::getPlatWorkCode, param.getPlanNo()); |
| | | } |
| | | // 仓库、料箱码按库位 id 交集过滤 |
| | | List<Long> allowedLocIds = null; |
| | | if (!Cools.isEmpty(param.getWareHouseId())) { |
| | | Warehouse wh = warehouseService.getOne(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getCode, param.getWareHouseId())); |
| | | if (wh != null) { |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, wh.getId())); |
| | | if (!locs.isEmpty()) { |
| | | wrapper.in(LocItem::getLocId, locs.stream().map(Loc::getId).collect(Collectors.toList())); |
| | | } else { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | } else { |
| | | if (wh == null) { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, wh.getId())); |
| | | if (locs.isEmpty()) { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | allowedLocIds = locs.stream().map(Loc::getId).collect(Collectors.toList()); |
| | | } |
| | | if (!Cools.isEmpty(param.getBarcode())) { |
| | | LambdaQueryWrapper<Loc> lw = new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, param.getBarcode()); |
| | | if (allowedLocIds != null) { |
| | | lw.in(Loc::getId, allowedLocIds); |
| | | } |
| | | List<Loc> locs = locService.list(lw); |
| | | if (locs.isEmpty()) { |
| | | return R.ok().add(Collections.emptyList()); |
| | | } |
| | | allowedLocIds = locs.stream().map(Loc::getId).collect(Collectors.toList()); |
| | | } |
| | | if (allowedLocIds != null) { |
| | | wrapper.in(LocItem::getLocId, allowedLocIds); |
| | | } |
| | | List<LocItem> list = locItemService.list(wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | |
| | | row.put("wareHouseId", null); |
| | | row.put("wareHouseName", null); |
| | | } |
| | | row.put("barcode", loc != null ? loc.getBarcode() : null); |
| | | row.put("palletId", item.getTrackCode()); |
| | | row.put("matNr", item.getMatnrCode()); |
| | | row.put("makTx", item.getMaktx()); |