库存合并批次添加打印功能

This commit is contained in:
彭枝刚 2024-11-29 17:25:32 +08:00
parent 81784e9782
commit 9f2f0a80ef
3 changed files with 35 additions and 11 deletions

View File

@ -388,13 +388,8 @@ public class ZWmsInventoryController {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
List<String> inventoryIdList = (List<String>) request.get("inventoryIdList");
//打印
/*String printer = request.get("printer").toString();
if (StringUtil.isEmpty(printer)) {
throw BusinessException.build("打印机未维护");
} else {*/
String mergeInventoryId = inventoryService.mergeInventory(site, user, inventoryIdList);
//barCodeQueryService.batchPrint(Collections.singletonList(mergeInventoryId), printer);
String printer = request.get("printer").toString();
String mergeInventoryId = inventoryService.mergeInventory(site, user, inventoryIdList,printer);
return R.ok(mergeInventoryId);
//}
}

View File

@ -97,7 +97,7 @@ public interface ZWmsInventoryService extends IService<Inventory> {
* @param inventoryIList 库存ID集合
* @return 新库存ID
*/
String mergeInventory(String site, String user, List<String> inventoryIList);
String mergeInventory(String site, String user, List<String> inventoryIList,String printer);
IPage fetchItemList(Page page, String item);

View File

@ -492,7 +492,7 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
//@GlobalTransactional
@Override
public String mergeInventory(String site, String user, List<String> inventoryIdList) {
public String mergeInventory(String site, String user, List<String> inventoryIdList,String printer) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
//查询并校验库存
List<Inventory> inventoryList = listByIds(inventoryBoList);
@ -525,9 +525,14 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
inventoryLogService.saveLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE,
inventory.getWmsStorageBinBo(), qtyOnHand, null);
}
String itemBo = inventoryList.get(0).getItemBo();
Item itemObj = itemService.getById(itemBo);
if(itemObj==null){
throw BusinessException.build("根据物料主键"+itemBo+"未找到对象");
}
//创建新库存并绑定
Map<String, String> map = new HashMap<>();
map.put("ITEM", HandleBoProcessor.trimHandle(inventoryList.get(0).getItemBo()));
map.put("ITEM", itemObj.getItem());
map.put("BATCH", inventoryList.get(0).getBatchNo());
String inventoryId = generatorDocumentNo("RAW_MATERIAL_ID", map, 1).get(0);
Inventory inventory = new Inventory();
@ -545,8 +550,32 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
save(inventory);
inventoryLogService.saveLog(user, inventoryId, null, null, Constant.CHANGE_TYPE_MERGE,
null, null, inventoryList.get(0).getWmsStorageBinBo());
// 执行打印,单独开个线程去跑
List<JSONObject> printData = new ArrayList<>();
// 添加打印参数
JSONObject paramMap = new JSONObject();
paramMap.put("ITEM", itemObj.getItem());
paramMap.put("DES", itemObj.getDescription());
paramMap.put("DATE", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
paramMap.put("BATCH", inventory.getBatchNo());
paramMap.put("QTY", inventory.getQtyOnHand());
paramMap.put("INV_ID", inventoryId);
paramMap.put("DOCUMENT_NO", "");
paramMap.put("CODE", inventoryId);
printData.add(paramMap);
if (!StringUtil.isEmpty(printer)) {
ThreadPoolUtil.execute(() -> {
for (JSONObject jsonObject : printData) {
jsonObject.put("LABEL_QTY", 1);
jsonObject.put("PRINT_NAME", printer);
jsonObject.put("QUEUE_NAME", "");
jsonObject.put("TEMPLATE", "RAM_LABEL_001.lab");
remotePrintService.remotePrintSaveLog(jsonObject);
}
});
}
return inventoryId;
//}
}
}