From a46a0b8a347879e11044f74bedaf8ac0ec861abd Mon Sep 17 00:00:00 2001 From: zpl Date: Mon, 9 Aug 2021 08:23:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mesnac/common/constant/Constants.java | 2 + .../service/impl/PrintLogServiceImpl.java | 19 ++++++++- .../impl/SurplusReturnServiceImpl.java | 40 ++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java index 31e2ec81..1b000e8b 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java @@ -160,6 +160,8 @@ public interface Constants { String PRINT_TYPE_INV = "INV"; // 在制品标签 String PRINT_TYPE_SFC = "SFC"; + // 余料标签 + String PRINT_TYPE_EXM = "EXM"; /** * 刀具状态,Y-使用,N-报废/删除 diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrintLogServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrintLogServiceImpl.java index 11a53c8a..d1f4a09e 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrintLogServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrintLogServiceImpl.java @@ -61,14 +61,31 @@ public class PrintLogServiceImpl extends ServiceImpl i @Override public void labelPrint(String site, String user, List printList) { List labelPrintDtoList = new ArrayList<>(); + StringBuffer stringBuffer = new StringBuffer(""); for (PrintLog printLog : printList) { LabelPrintDto labelPrintDto = new LabelPrintDto(); + // 打印机名称、打印模板 labelPrintDto.setPrinter(printLog.getPrintName()); labelPrintDto.setPrintTemplate(printLog.getPrintTemplate()); + // {"ITEM":"500100010001","INVENTORY":"500100010001*20210721","ITEM_DESC":"测试物料","SUPPLIER":"BA002"} + // 打印参数:物料编号、物料描述、供应商、批次号 + String printParam = printLog.getPrintParam(); + JSONObject jsonObject = JSONObject.parseObject(printParam); + String item = jsonObject.getString("ITEM"); + String item_desc = jsonObject.getString("ITEM_DESC"); + String supplier = jsonObject.getString("SUPPLIER"); + String inventory = jsonObject.getString("INVENTORY"); + labelPrintDto.setItem(item); + labelPrintDto.setItemDescription(item_desc); + labelPrintDto.setSupplier(supplier); + labelPrintDto.setBatch(inventory); + /* labelPrintDto.setItem(printLog.getItem()); - labelPrintDto.setItemDescription(printLog.getItemDescription()); + labelPrintDto.setItemDescription(printLog.getItemDescription());*/ labelPrintDtoList.add(labelPrintDto); + stringBuffer.append(printParam).append(","); } + String jsonList = JSON.toJSONString(labelPrintDtoList); String post = HttpUtil.post(printServer, JSON.toJSONString(labelPrintDtoList), 30000); /** * {"msg":"打印成功","code":0} diff --git a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusReturnServiceImpl.java b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusReturnServiceImpl.java index b1a578b6..8f25066c 100644 --- a/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusReturnServiceImpl.java +++ b/dispatch/src/main/java/com/foreverwin/mesnac/dispatch/service/impl/SurplusReturnServiceImpl.java @@ -1,12 +1,17 @@ package com.foreverwin.mesnac.dispatch.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.foreverwin.mesnac.common.constant.Constants; import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.model.PrintLog; +import com.foreverwin.mesnac.common.service.PrintLogService; import com.foreverwin.mesnac.common.util.ExceptionUtil; import com.foreverwin.mesnac.common.util.NumberUtil; import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.dispatch.model.SurplusInventory; import com.foreverwin.mesnac.dispatch.service.SurplusInventoryService; import com.foreverwin.mesnac.meapi.model.Inventory; +import com.foreverwin.mesnac.meapi.model.InventoryAssyData; import com.foreverwin.mesnac.meapi.service.InventoryAssyDataService; import com.foreverwin.mesnac.meapi.service.InventoryService; import com.foreverwin.modular.core.exception.BusinessException; @@ -51,7 +56,10 @@ public class SurplusReturnServiceImpl extends ServiceImpl getInventoryData(String site, String inventory) { @@ -181,5 +189,35 @@ public class SurplusReturnServiceImpl extends ServiceImpl inventoryAssyDataList = inventoryAssyDataService.selectList(inventoryAssyData); + if (inventoryAssyDataList.size() == 1){ + jsonObject.put("SUPPLIER", inventoryAssyDataList.get(0).getDataAttr()); // 供应商 + }else { + throw BusinessException.build("未正确找到当前批次的供应商!"); + } + jsonObject.put("INVENTORY", surplusInventory); // 批次号 + printLog.setPrintParam(jsonObject.toString()); + printLog.setInventory(surplusInventory); + printLog.setItemBo(inventoryModel.getItemBo()); + //printLog.setIsPrint("false"); + printLog.setCreateUser(user); + printLog.setCreatedDateTime(dateTime); + printLogService.save(printLog); } } \ No newline at end of file