fix:拆分

This commit is contained in:
郭飞 2025-05-14 20:16:52 +08:00
parent f3b5f88608
commit 3939da2117
3 changed files with 255 additions and 3 deletions

View File

@ -562,6 +562,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
productSpecName); productSpecName);
} }
}else if ("0".equals(operationType) && "CBT".equals(stockInType)){ }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, " 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, " + "PRODUCTSPECNAME, PRODUCTNAME, SDK_ID, PHASE, RECEIVE_FLAG, REMARK, SHIPTIME, "
+ "SHIPUSER, SITENAME, MATERIALSPECTYPE," + "SHIPUSER, SITENAME, MATERIALSPECTYPE,"

View File

@ -8,17 +8,20 @@ import com.cim.idm.framework.IDMFrameServiceProxy;
import com.cim.idm.framework.data.EventInfo; import com.cim.idm.framework.data.EventInfo;
import com.cim.idm.framework.util.time.TimeStampUtil; import com.cim.idm.framework.util.time.TimeStampUtil;
import com.cim.idm.model.OutStockDto; 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.IMaterialShipService;
import com.cim.idm.service.impl.MESServiceImpl; import com.cim.idm.service.impl.MESServiceImpl;
import com.cim.idm.util.MessageLogUtil; import com.cim.idm.util.MessageLogUtil;
import com.cim.idm.util.ToSAPMessageUtil; import com.cim.idm.util.ToSAPMessageUtil;
import com.cim.idm.utils.AjaxResult; import com.cim.idm.utils.AjaxResult;
import com.cim.idm.utils.CodeGenerator;
import com.cim.idm.utils.CommonUtils; import com.cim.idm.utils.CommonUtils;
import com.cim.idm.utils.EventInfoUtil; import com.cim.idm.utils.EventInfoUtil;
import com.cim.idm.wmsextend.generic.errorHandler.CustomException; import com.cim.idm.wmsextend.generic.errorHandler.CustomException;
import com.cim.idm.wmspackage.materialpacking.MaterialPackingServiceProxy; import com.cim.idm.wmspackage.materialpacking.MaterialPackingServiceProxy;
import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking; 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.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.materialpacking.management.info.SetEventInfo;
import com.cim.idm.wmspackage.materialshiprequest.MaterialShipRequestServiceProxy; import com.cim.idm.wmspackage.materialshiprequest.MaterialShipRequestServiceProxy;
import com.cim.idm.wmspackage.materialshiprequest.management.info.CreateMaterialShipRequestInfo; import com.cim.idm.wmspackage.materialshiprequest.management.info.CreateMaterialShipRequestInfo;
@ -40,6 +43,8 @@ public class MaterialShipServiceImpl implements IMaterialShipService {
@Autowired @Autowired
private ToSAPMessageUtil toSAPMessageUtil; private ToSAPMessageUtil toSAPMessageUtil;
private EventInfo makeEventInfo;
/** /**
* 出库方法实现 * 出库方法实现
*/ */
@ -753,18 +758,85 @@ public class MaterialShipServiceImpl implements IMaterialShipService {
//判断会有多少个仓库发货不同仓库需要分开走账 //判断会有多少个仓库发货不同仓库需要分开走账
StringBuffer cklx = new StringBuffer(); 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 = ""; String str = "";
str += "("; str += "(";
for (String materialPacking : materialPackingKeyList) { for (String materialPacking : materialPackingKeyList) {
str += "'" + materialPacking + "',"; str += "'" + materialPacking + "',";
} }
str += "'')"; str += "'')";
List<Map<String, Object>> queryForList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(cklx.toString() + str, hashMap); List<Map<String, Object>> packingQueryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(cklx.toString() + str, hashMap);
String billCode = ""; String billCode = "";
switch (shipRequestType) { switch (shipRequestType) {
case "NLCC" : //STO调拨出库 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<MaterialPacking> 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<String> 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<MaterialPacking> boxList2 = new ArrayList<MaterialPacking>();
// 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<String, Object> 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); billCode=TransferStockOut_NLCC(shipRequestName, "SDK", user,materialPackingKeyList);
//makeEventInfo = eventInfoUtil.makeEventInfo("CompleteShipRequest", eventUser, "CompleteShipRequest:"+shipRequestType); //makeEventInfo = eventInfoUtil.makeEventInfo("CompleteShipRequest", eventUser, "CompleteShipRequest:"+shipRequestType);
untils.SaveUnDoInfo_ForSap(materialPackingKeyList, billCode, eventInfo); untils.SaveUnDoInfo_ForSap(materialPackingKeyList, billCode, eventInfo);
@ -1770,4 +1842,183 @@ public class MaterialShipServiceImpl implements IMaterialShipService {
} }
} }
@Transactional
public boolean packingChargeSplit(List<MaterialPacking> 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<String, Object> hashMap2 = new HashMap<String,Object> ();
hashMap2.put("MATERIALPACKINGNAME1", newBoxId1);
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap2);
List<MaterialPacking> 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<String, Object> hashMap4 = new HashMap<String,Object> ();
hashMap4.put("MATERIALPACKINGNAME", boxList.get(0).getMaterialPackingName());
hashMap4.put("CHARGE", boxList.get(0).getCharge());
List<Map<String, Object>> queryForList3 = IDMFrameServiceProxy.getSqlTemplate().queryForList(ypcSql, hashMap4);
if (queryForList3 != null && queryForList3.size() > 0) {
Map<String, Object> 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<String, Object> bindMap = new HashMap<String, Object>();
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<String, Object> hashMap3 = new HashMap<String,Object> ();
// hashMap3.put("stockState", "StockOut");
// setEventInfo.setUserColumns(hashMap3);
// MaterialPackingServiceProxy.getMaterialPackingService().setEvent(materialPackingKey, makeEventInfo, setEventInfo);
}
return true;
}
} }

View File

@ -58,7 +58,7 @@
<!-- 更新history --> <!-- 更新history -->
<update id="updateStockStateHistory" parameterType="map"> <update id="updateStockStateHistory" parameterType="map">
UPDATE MATERIALPACKINGHISTORY UPDATE MATERIALPACKINGHISTORY
SET STOCKSTATE = #{stockState},UNDOID = #{undoId}, ERPLOCATION = #{aimErpLocation}, LOCATIONNAME = #{aimLOcationName}, ERPFACTORY = #{aimErpFactory}, SET STOCKSTATE = #{stockState},UNDOID = #{undoId},
EVENTTIME = SYSDATE, EVENTTIME = SYSDATE,
EVENTUSER = #{user}, EVENTUSER = #{user},
EVENTNAME = '产成品入库FGStockIn' EVENTNAME = '产成品入库FGStockIn'