From 3939da211728e14f9716f99503070e884e30c5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E9=A3=9E?= Date: Wed, 14 May 2025 20:16:52 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../idm/service/Impl/MESToWMSServiceImpl.java | 1 + .../service/Impl/MaterialShipServiceImpl.java | 255 +++++++++++++++++- .../resources/com/cim/idm/dao/ToSapDao.xml | 2 +- 3 files changed, 255 insertions(+), 3 deletions(-) diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java index a106e91..556fbab 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MESToWMSServiceImpl.java @@ -562,6 +562,7 @@ public class MESToWMSServiceImpl implements MESToWMSService { productSpecName); } }else if ("0".equals(operationType) && "CBT".equals(stockInType)){ + String insertBS_MES_SHIP_PEDSql = SystemPropHelper.CR + "INSERT INTO BS_MES_SHIPPED(LOTNAME,QTY, UNIT, REQUESTNAME, AREA, " + "PRODUCTSPECNAME, PRODUCTNAME, SDK_ID, PHASE, RECEIVE_FLAG, REMARK, SHIPTIME, " + "SHIPUSER, SITENAME, MATERIALSPECTYPE," diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java index a04e893..9590fc3 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/MaterialShipServiceImpl.java @@ -8,17 +8,20 @@ import com.cim.idm.framework.IDMFrameServiceProxy; import com.cim.idm.framework.data.EventInfo; import com.cim.idm.framework.util.time.TimeStampUtil; import com.cim.idm.model.OutStockDto; +import com.cim.idm.mwmsextend.materialpacking.service.MaterialPackingServiceImpl; import com.cim.idm.service.IMaterialShipService; import com.cim.idm.service.impl.MESServiceImpl; import com.cim.idm.util.MessageLogUtil; import com.cim.idm.util.ToSAPMessageUtil; import com.cim.idm.utils.AjaxResult; +import com.cim.idm.utils.CodeGenerator; import com.cim.idm.utils.CommonUtils; import com.cim.idm.utils.EventInfoUtil; import com.cim.idm.wmsextend.generic.errorHandler.CustomException; import com.cim.idm.wmspackage.materialpacking.MaterialPackingServiceProxy; import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking; import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPackingKey; +import com.cim.idm.wmspackage.materialpacking.management.info.CreateInfo; import com.cim.idm.wmspackage.materialpacking.management.info.SetEventInfo; import com.cim.idm.wmspackage.materialshiprequest.MaterialShipRequestServiceProxy; import com.cim.idm.wmspackage.materialshiprequest.management.info.CreateMaterialShipRequestInfo; @@ -40,6 +43,8 @@ public class MaterialShipServiceImpl implements IMaterialShipService { @Autowired private ToSAPMessageUtil toSAPMessageUtil; + + private EventInfo makeEventInfo; /** * 出库方法实现 */ @@ -753,18 +758,85 @@ public class MaterialShipServiceImpl implements IMaterialShipService { //判断会有多少个仓库发货,不同仓库需要分开走账 StringBuffer cklx = new StringBuffer(); - cklx.append("SELECT DISTINCT m.ERPLOCATION FROM MATERIALPACKING m WHERE m.MATERIALPACKINGNAME IN "); + cklx.append("SELECT m.MATERIALPACKINGNAME,m.SITENAME,m2.MATERIALTYPE FROM MATERIALPACKING m LEFT JOIN MATERIALSPEC m2 ON m2.MATERIALSPECNAME = m.MATERIALSPECNAME WHERE m.MATERIALPACKINGNAME IN "); String str = ""; str += "("; for (String materialPacking : materialPackingKeyList) { str += "'" + materialPacking + "',"; } str += "'')"; - List> queryForList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(cklx.toString() + str, hashMap); + List> packingQueryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(cklx.toString() + str, hashMap); String billCode = ""; switch (shipRequestType) { case "NLCC" : //STO调拨出库 +// 拆条码,查询MATERIALQUANTITY 与 MATERIALQUANTITY2是否相等,如果相等则未修改了数量,不相等则修改了数量 +// 如果已修改数量,则进行拆条码 + for (int z = 0; z < packingQueryForList.size(); z++) { + String MATERIALPACKINGNAME = packingQueryForList.get(z).get("MATERIALPACKINGNAME").toString(); + Object[] bindSet = {MATERIALPACKINGNAME}; + String qtysql = "WHERE MATERIALPACKINGNAME = ?"; + List qtyQueryForList = MaterialPackingServiceProxy.getMaterialPackingService().select(qtysql, bindSet); + + String qty = String.valueOf(qtyQueryForList.get(z).getMaterialQuantity()); + + String qty2 = new Double(qtyQueryForList.get(z).getMaterialQuantity2()) == null ? "0" : String.valueOf(qtyQueryForList.get(z).getMaterialQuantity2()); + String materialPackingName = qtyQueryForList.get(z).getMaterialPackingName(); +// String charge = qtyQueryForList.get(z).getCharge(); // 辅材出库无批次 + List boxId = MaterialPackingServiceImpl.generateBoxID("LabelId", siteName, + "100", qtyQueryForList.get(z).getMakeDate().toString(),packingQueryForList.get(z).get("MATERIALTYPE").toString(),qtyQueryForList.get(z).getErpFactory()); + BigDecimal bigQty = new BigDecimal(qty); + // 已拆数量 + BigDecimal bigQty2 = new BigDecimal(qty2); + + // 如果已拆数量不等于原数量,并且已拆数量为0(未拆分数量) + if(bigQty.compareTo(bigQty2) != 0 && !"0".equals(qty2)) { + // 剩余数量 + BigDecimal restQty = bigQty.subtract(bigQty2); + + // 生成新的拆分条码 + String stringBigQty2 = bigQty2.toString(); + String newPalletNo = CodeGenerator.packingGenerateCode(materialPackingName,stringBigQty2,boxId.get(0)); + + // 写入拆分的新条码,更新原数据库 + List boxList2 = new ArrayList(); +// MaterialPackingKey materialpackingKey = new MaterialPackingKey(); + MaterialPacking materialpackingNew = new MaterialPacking(); +// materialpackingKey.setSiteName("SDK"); +// materialpackingKey.setMaterialPackingName(newPalletNo); +// materialpackingNew.setKey(materialpackingKey); + + // 复制一个当前的原标签数据 + materialpackingNew.setKey(qtyQueryForList.get(z).getKey()); +// MaterialPacking materialpackingNew = qtyQueryForList.get(z); + // 设置新为标签和数量 + materialpackingNew.setMaterialPackingName(newPalletNo); + // bigQty2 转double类型 + materialpackingNew.setMaterialQuantity(bigQty2.doubleValue()); + boxList2.add(qtyQueryForList.get(z)); + boxList2.add(materialpackingNew); + boolean moveTransformOut = packingChargeSplit(boxList2, user); + if (moveTransformOut != true) { + throw new RuntimeException("修改数量拆分失败"); + } + + // 原条码扣减拆出的数量,用剩余数量更新原条码,条码不变,数量更新 + SetEventInfo setEventInfo = new SetEventInfo(); + Map pakHashMap = new HashMap<>(); + pakHashMap.put("materialQuantity", restQty.doubleValue()); + + EventInfo eventInfo2 = new EventInfoUtil().makeEventInfo("备货出库拆分修改数量拆分条码", user, "修改数量拆分条码"); + setEventInfo.setUserColumns(pakHashMap); + MaterialPackingServiceProxy.getMaterialPackingService().setEvent(new MaterialPackingKey( queryForList.get(z).get("SITENAME").toString(), + queryForList.get(z).get("MATERIALPACKINGNAME").toString()), eventInfo2, setEventInfo); + + // 删除被拆分的原条码数据,用拆分出的新条码覆盖,进行后面的过账,现场仓过账只过账已拆分出的数量,剩余数量的原条码不过账 + boolean deletePacking = materialPackingKeyList.remove(MATERIALPACKINGNAME); + if (deletePacking) { + materialPackingKeyList.add(newPalletNo); + } + } + } billCode=TransferStockOut_NLCC(shipRequestName, "SDK", user,materialPackingKeyList); //makeEventInfo = eventInfoUtil.makeEventInfo("CompleteShipRequest", eventUser, "CompleteShipRequest:"+shipRequestType); untils.SaveUnDoInfo_ForSap(materialPackingKeyList, billCode, eventInfo); @@ -1770,4 +1842,183 @@ public class MaterialShipServiceImpl implements IMaterialShipService { } } + @Transactional + public boolean packingChargeSplit(List boxList, String user) { + + String condition=""; + String newBoxId1 = boxList.get(1).getMaterialPackingName(); +// String pc = "('" + materialpackingname + "')"; + String sql = "SELECT 1 FROM MATERIALPACKING WHERE MATERIALPACKINGNAME IN (:MATERIALPACKINGNAME1)"; + Map hashMap2 = new HashMap (); + hashMap2.put("MATERIALPACKINGNAME1", newBoxId1); + List> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap2); + List MaterialPackingList = null; + if (queryForList != null && queryForList.size() > 0) { + String[] bindSet={newBoxId1}; + condition="WHERE MATERIALPACKINGNAME IN (?)"; + MaterialPackingList = MaterialPackingServiceProxy.getMaterialPackingService().select(condition, bindSet); + } + //解析条码,根据远条码信息更新目标条码数量和库存状态 + SetEventInfo setEventInfo = new SetEventInfo(); + EventInfoUtil eventInfoUtil = new EventInfoUtil(); + makeEventInfo = eventInfoUtil.makeEventInfo("ChargeSplit", user, "ChargeSplit" ); + //找到原来标签的相关信息 +// String receiveTime = ""; +// String makeDate = ""; +// String expireDate = ""; + String holdState = ""; + String oqaResult = ""; + String oqaResultState = ""; + String packingGrade = ""; + String trueGg = ""; + String erpFactory = ""; + String erpLocation = ""; + String locationName = ""; + String shelfName = ""; + String areaName = ""; + String durableName = "";; + String CAREER_ASSISTANCE = ""; + String SALESPERSON = ""; + String CUSTOMNO = ""; + String DEVIATION = ""; + String DIAMETER = ""; + String WIDTH = ""; + String WEIGHT = ""; + String PRODUCTLINE = ""; + String UNIT = ""; + String MJPC = ""; + String BUSINESS_UNIT = ""; + + String MATERIALSPECNAME = ""; +// String SUBPACKINGQUANTITY = ""; +// String MATERIALCREATEQUANTITY = ""; + String CHARGE = ""; + String SDK_ID = ""; + String PHASE = ""; + String RECEIVEREQUESTNAME = ""; + String RECEIVEREQUESTDETAILNAME = ""; + String REMARK = ""; + String SHIPREQUESTNAME = ""; + String SHIPREQUESTDETAILNAME = ""; + + String ypcSql = "SELECT M.RECEIVETIME,M.MAKEDATE,M.EXPIRINGDATE,M.HOLDSTATE,M.OQARESULTSTATE ,\r\n" + + " M.OQARESULT ,M.PACKINGGRADE ,M.TRUEGG ,M.ERPFACTORY ,M.ERPLOCATION ,M.LOCATIONNAME ,\r\n" + + " M.SHELFNAME ,M.AREANAME ,M.DURABLENAME ,M.CAREER_ASSISTANCE ,M.SALESPERSON ,M.CUSTOMNO,M.SDK_ID,M.PHASE,M.SHIPREQUESTNAME,M.SHIPREQUESTDETAILNAME,M.RECEIVEREQUESTNAME,M.RECEIVEREQUESTDETAILNAME," + + " M.DEVIATION ,M.DIAMETER ,M.WIDTH ,M.WEIGHT ,M.PRODUCTLINE,UNIT ,MJPC,BUSINESS_UNIT,M.MATERIALSPECNAME, M.SUBPACKINGQUANTITY, M.MATERIALCREATEQUANTITY, M.MATERIALQUANTITY, M.CHARGE, M.REMARK" + + " FROM MATERIALPACKING M WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME AND M.CHARGE = :CHARGE "; + Map hashMap4 = new HashMap (); + hashMap4.put("MATERIALPACKINGNAME", boxList.get(0).getMaterialPackingName()); + hashMap4.put("CHARGE", boxList.get(0).getCharge()); + List> queryForList3 = IDMFrameServiceProxy.getSqlTemplate().queryForList(ypcSql, hashMap4); + + if (queryForList3 != null && queryForList3.size() > 0) { + Map map = queryForList3.get(0); + holdState = map.get("HOLDSTATE") == null ? "N" : map.get("HOLDSTATE").toString(); + oqaResult = map.get("OQARESULT") == null ? "" : map.get("OQARESULT").toString(); + oqaResultState = map.get("OQARESULTSTATE") == null ? "END" : map.get("OQARESULTSTATE").toString(); + packingGrade = map.get("PACKINGGRADE") == null ? "" : map.get("PACKINGGRADE").toString(); + trueGg = map.get("TRUEGG") == null ? "" : map.get("TRUEGG").toString(); + erpFactory = map.get("ERPFACTORY") == null ? "" : map.get("ERPFACTORY").toString(); + erpLocation = map.get("ERPLOCATION") == null ? "" : map.get("ERPLOCATION").toString(); + locationName = map.get("LOCATIONNAME") == null ? "" : map.get("LOCATIONNAME").toString(); + shelfName = map.get("SHELFNAME") == null ? "" : map.get("SHELFNAME").toString(); + areaName = map.get("AREANAME") == null ? "" : map.get("AREANAME").toString(); + durableName = map.get("DURABLENAME") == null ? "" : map.get("DURABLENAME").toString(); + CAREER_ASSISTANCE = map.get("CAREER_ASSISTANCE") == null ? "" : map.get("CAREER_ASSISTANCE").toString(); + SALESPERSON = map.get("SALESPERSON") == null ? "" : map.get("SALESPERSON").toString(); + CUSTOMNO = map.get("CUSTOMNO") == null ? "" : map.get("CUSTOMNO").toString(); + DEVIATION = map.get("DEVIATION") == null ? "" : map.get("DEVIATION").toString(); + DIAMETER = map.get("DIAMETER") == null ? "" : map.get("DIAMETER").toString(); + WIDTH = map.get("WIDTH") == null ? "" : map.get("WIDTH").toString(); + WEIGHT = map.get("WEIGHT") == null ? "" : map.get("WEIGHT").toString(); + PRODUCTLINE = map.get("PRODUCTLINE") == null ? "" : map.get("PRODUCTLINE").toString(); + UNIT = map.get("UNIT") == null ? "" : map.get("UNIT").toString(); + MJPC = map.get("MJPC") == null ? "" : map.get("MJPC").toString(); + BUSINESS_UNIT = map.get("BUSINESS_UNIT") == null ? "" : map.get("BUSINESS_UNIT").toString(); + MATERIALSPECNAME = map.get("MATERIALSPECNAME") == null ? "" : map.get("MATERIALSPECNAME").toString(); +// SUBPACKINGQUANTITY = map.get("SUBPACKINGQUANTITY") == null ? "" : map.get("SUBPACKINGQUANTITY").toString(); +// MATERIALCREATEQUANTITY = map.get("MATERIALCREATEQUANTITY") == null ? "" : map.get("MATERIALCREATEQUANTITY").toString(); + CHARGE = map.get("CHARGE") == null ? "" : map.get("CHARGE").toString(); + SDK_ID = map.get("SDK_ID") == null ? "" : map.get("SDK_ID").toString(); + PHASE = map.get("PHASE") == null ? "" : map.get("PHASE").toString(); + REMARK = map.get("REMARK") == null ? "" : map.get("REMARK").toString(); + SHIPREQUESTNAME = map.get("SHIPREQUESTNAME") == null ? "" : map.get("SHIPREQUESTNAME").toString(); + SHIPREQUESTDETAILNAME = map.get("SHIPREQUESTDETAILNAME") == null ? "" : map.get("SHIPREQUESTDETAILNAME").toString(); + + } + + if (MaterialPackingList != null && MaterialPackingList.size() > 0) { + throw new RuntimeException("拆分批次的标签已存在!"); + }else { +// 创建标签1 + CreateInfo createInfo1 = new CreateInfo(); + createInfo1.setSiteName("SDK"); + createInfo1.setMaterialPackingName(newBoxId1);// 新生成的box id + createInfo1.setMaterialPackingType("Box"); + createInfo1.setContentMaterialType(""); + + Map bindMap = new HashMap(); + bindMap.put("MaterialSpecName", MATERIALSPECNAME); + bindMap.put("PackingGrade", packingGrade); + bindMap.put("oqaResult", oqaResult); + bindMap.put("oqaResultState", oqaResultState); + bindMap.put("SubPackingQuantity",boxList.get(1).getMaterialQuantity()); + bindMap.put("MaterialCreateQuantity",boxList.get(1).getMaterialQuantity()); + bindMap.put("MaterialQuantity", boxList.get(1).getMaterialQuantity());// 数量 + bindMap.put("PackingState", "Released"); + bindMap.put("OldPackingState", "Released"); + bindMap.put("stockState", "Stocked"); + bindMap.put("OldStockState", "Created"); + bindMap.put("HoldState", holdState); + bindMap.put("LocationName", locationName); + bindMap.put("charge",CHARGE); + bindMap.put("MaterialProcessGroupName",""); + bindMap.put("LastEventTimeKey",TimeStampUtil.getCurrentEventTimeKey()); + + bindMap.put("MakeDate", queryForList3.get(0).get("MAKEDATE")); + bindMap.put("expiringDate", queryForList3.get(0).get("EXPIRINGDATE")); + bindMap.put("ReceiveTime", queryForList3.get(0).get("RECEIVETIME")); + bindMap.put("unit", queryForList3.get(0).get("UNIT")); + + bindMap.put("ReceiveUser", makeEventInfo.getEventUser()); + bindMap.put("ErpLocation", erpLocation); + bindMap.put("ErpFactory", erpFactory); + bindMap.put("locationName", locationName); + bindMap.put("StockInType", "Normal"); + bindMap.put("SDK_ID", SDK_ID); + bindMap.put("PHASE", PHASE); + bindMap.put("remark", REMARK); + + bindMap.put("shipRequestName", SHIPREQUESTNAME); + bindMap.put("shipRequestDetailName",SHIPREQUESTDETAILNAME); + + bindMap.put("ReceiveRequestName", RECEIVEREQUESTNAME); + bindMap.put("ReceiveRequestDetailName",RECEIVEREQUESTDETAILNAME); + + bindMap.put("CAREER_ASSISTANCE", CAREER_ASSISTANCE);//业助信息 + bindMap.put("BUSINESS_UNIT", BUSINESS_UNIT);//业务 + bindMap.put("SALESPERSON", SALESPERSON);//事业部 + bindMap.put("MJPC", MJPC);//母卷批次 + bindMap.put("truegg", trueGg); + bindMap.put("durableName", durableName); + bindMap.put("areaName", areaName); + bindMap.put("PRODUCTLINE", PRODUCTLINE); + bindMap.put("WIDTH", WIDTH); + bindMap.put("DEVIATION", DEVIATION); + bindMap.put("WEIGHT", WEIGHT); + bindMap.put("DIAMETER", DIAMETER); + bindMap.put("shelfName", shelfName); + createInfo1.setUserColumns(bindMap); + + MaterialPackingServiceProxy.getMaterialPackingService().create(makeEventInfo, createInfo1); + + //更新原标签批次的库位状态为出库 +// MaterialPackingKey materialPackingKey = new MaterialPackingKey("SDK",boxList.get(0).getMaterialPackingName()); +// Map hashMap3 = new HashMap (); +// hashMap3.put("stockState", "StockOut"); +// setEventInfo.setUserColumns(hashMap3); +// MaterialPackingServiceProxy.getMaterialPackingService().setEvent(materialPackingKey, makeEventInfo, setEventInfo); + } + return true; + } } diff --git a/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml b/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml index 4bd58e9..eee9275 100644 --- a/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml +++ b/zi-wms-pda/src/main/resources/com/cim/idm/dao/ToSapDao.xml @@ -58,7 +58,7 @@ UPDATE MATERIALPACKINGHISTORY - SET STOCKSTATE = #{stockState},UNDOID = #{undoId}, ERPLOCATION = #{aimErpLocation}, LOCATIONNAME = #{aimLOcationName}, ERPFACTORY = #{aimErpFactory}, + SET STOCKSTATE = #{stockState},UNDOID = #{undoId}, EVENTTIME = SYSDATE, EVENTUSER = #{user}, EVENTNAME = '产成品入库FGStockIn'