fix:修改mes回收例子
This commit is contained in:
parent
3e52e45424
commit
c1e5fa1c33
@ -444,6 +444,69 @@ public class ToSAPServiceImpl {
|
|||||||
return undoId;
|
return undoId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String FGStockIn3(String RECEIVEACTNO, String user, String stockInType) throws Exception {
|
||||||
|
StringBuffer sql = new StringBuffer();
|
||||||
|
sql.append(SystemPropHelper.CR)
|
||||||
|
.append("SELECT m.MATERIALSPECNAME ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.PRODUCTORDER ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.PACKINGGRADE ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.ERPFACTORY ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.ERPLOCATION ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.UNIT ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.PACKINGGRADE,").append(SystemPropHelper.CR)
|
||||||
|
.append(" :MATERIALSPECTYPE MATERIALSPECTYPE,").append(SystemPropHelper.CR)
|
||||||
|
.append(" sum(m.MATERIALQUANTITY ) MATERIALQUANTITY ").append(SystemPropHelper.CR)
|
||||||
|
.append(" FROM MATERIALPACKING m ").append(SystemPropHelper.CR)
|
||||||
|
.append("LEFT JOIN BS_MES_SHIPPED bms ON m.materialpackingname = bms.lotname ").append(SystemPropHelper.CR)
|
||||||
|
.append(" WHERE bms.RECEIVE_FLAG <> 'Y' ").append(SystemPropHelper.CR)
|
||||||
|
.append(" AND m.STOCKSTATE = 'Created' ").append(SystemPropHelper.CR)
|
||||||
|
.append(" AND m.RECEIVEACTNO = :RECEIVEACTNO ").append(SystemPropHelper.CR)
|
||||||
|
.append("GROUP BY m.MATERIALSPECNAME ,m.PRODUCTORDER ,m.PACKINGGRADE ,m.ERPFACTORY ,m.ERPLOCATION ,m.UNIT ,").append(SystemPropHelper.CR)
|
||||||
|
.append(" m.PACKINGGRADE,m.MATERIALSPECTYPE ");
|
||||||
|
Map<String, Object> hashMap = new HashMap<String, Object>();
|
||||||
|
hashMap.put("RECEIVEACTNO", RECEIVEACTNO);
|
||||||
|
hashMap.put("MATERIALSPECTYPE", stockInType);
|
||||||
|
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql.toString(), hashMap);
|
||||||
|
String makeFGStockIn = makeFGStockIn(queryForList, user, RECEIVEACTNO);
|
||||||
|
String sapreturn = "";
|
||||||
|
String rcode = "";
|
||||||
|
String rmsg = "";
|
||||||
|
String undoId = "";
|
||||||
|
try {
|
||||||
|
sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "",
|
||||||
|
makeFGStockIn);
|
||||||
|
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
|
||||||
|
|
||||||
|
org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN");
|
||||||
|
rcode = returnJsonObject.get("STATUS").toString();
|
||||||
|
rmsg = returnJsonObject.get("MSGTXT").toString();
|
||||||
|
if ("S".equals(rcode)) {
|
||||||
|
undoId = returnJsonObject.get("MBLNR").toString()+"_"+returnJsonObject.get("MJAHR").toString();//将物料凭证号与凭证年度拼在一起
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("WMS请求SAP异常:" + e.getMessage(), e);
|
||||||
|
throw new RuntimeException("WMS请求SAP异常:" + rmsg);
|
||||||
|
} finally {
|
||||||
|
// 将消息记录log表
|
||||||
|
ErpMessageLog erplog = new ErpMessageLog();
|
||||||
|
erplog.setEventUser(user);
|
||||||
|
erplog.setServerName("WmsToErp");
|
||||||
|
erplog.setEventName("FGStockIn");
|
||||||
|
erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
|
||||||
|
erplog.setMessageId(RECEIVEACTNO);
|
||||||
|
erplog.setSendMsg(makeFGStockIn);
|
||||||
|
erplog.setSendMsg2(makeFGStockIn);
|
||||||
|
erplog.setSendMsg(makeFGStockIn);
|
||||||
|
erplog.setReturnMsg2(sapreturn);
|
||||||
|
erplog.setResultCode(rcode);
|
||||||
|
MessageLogUtil.writeMessageLog(erplog);
|
||||||
|
}
|
||||||
|
if (!"S".equals(rcode)) {
|
||||||
|
throw new RuntimeException("SAP返回" + rmsg);
|
||||||
|
}
|
||||||
|
return undoId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动入库处理FGStockIn请求
|
* 手动入库处理FGStockIn请求
|
||||||
* 该方法负责将特定的物料信息发送到SAP系统,并处理返回的结果
|
* 该方法负责将特定的物料信息发送到SAP系统,并处理返回的结果
|
||||||
|
@ -417,7 +417,6 @@ public class QMSController {
|
|||||||
MaterialPackingServiceProxy.getMaterialPackingService().setEvent(mpList, eventInfo, setEventInfo2);
|
MaterialPackingServiceProxy.getMaterialPackingService().setEvent(mpList, eventInfo, setEventInfo2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ("6".equals(tpType)) {//投放计划单
|
else if ("6".equals(tpType)) {//投放计划单
|
||||||
String sql = "SELECT M.SITENAME ,M.MATERIALPACKINGNAME FROM MATERIALPACKING M "
|
String sql = "SELECT M.SITENAME ,M.MATERIALPACKINGNAME FROM MATERIALPACKING M "
|
||||||
+ "WHERE M.MESSAGEID = :RECEIVEREQUESTNAME";
|
+ "WHERE M.MESSAGEID = :RECEIVEREQUESTNAME";
|
||||||
|
@ -18,6 +18,7 @@ import com.cim.idm.service.impl.MESServiceImpl;
|
|||||||
import com.cim.idm.service.impl.ToSAPServiceImpl;
|
import com.cim.idm.service.impl.ToSAPServiceImpl;
|
||||||
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.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;
|
||||||
@ -377,22 +378,28 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||||||
|
|
||||||
// 查询MATERIALQUANTITY 与 MATERIALQUANTITY2是否相等,如果相等则未修改数量,不相等则修改数量
|
// 查询MATERIALQUANTITY 与 MATERIALQUANTITY2是否相等,如果相等则未修改数量,不相等则修改数量
|
||||||
// 如果已修改数量,则进行拆单
|
// 如果已修改数量,则进行拆单
|
||||||
for (int z = 0; z < qtyQueryForList.size(); z++) {
|
// for (int z = 0; z < qtyQueryForList.size(); z++) {
|
||||||
String qty = qtyQueryForList.get(z).get("MATERIALQUANTITY").toString();
|
// String qty = qtyQueryForList.get(z).get("MATERIALQUANTITY").toString();
|
||||||
String qty2 = qtyQueryForList.get(z).get("MATERIALQUANTITY2") == null ? "0" : qtyQueryForList.get(z).get("MATERIALQUANTITY2").toString();
|
// String qty2 = qtyQueryForList.get(z).get("MATERIALQUANTITY2") == null ? "0" : qtyQueryForList.get(z).get("MATERIALQUANTITY2").toString();
|
||||||
BigDecimal bigQty = new BigDecimal(qty);
|
// String materialPackingName = qtyQueryForList.get(z).get("MATERIALPACKINGNAME").toString();
|
||||||
// 已拆数量
|
// BigDecimal bigQty = new BigDecimal(qty);
|
||||||
BigDecimal bigQty2 = new BigDecimal(qty2);
|
// // 已拆数量
|
||||||
|
// BigDecimal bigQty2 = new BigDecimal(qty2);
|
||||||
if(bigQty.compareTo(bigQty2) != 0) {
|
//
|
||||||
// 剩余数量
|
// if(bigQty.compareTo(bigQty2) != 0) {
|
||||||
BigDecimal restQty = bigQty.subtract(bigQty2);
|
// // 剩余数量
|
||||||
|
// BigDecimal restQty = bigQty.subtract(bigQty2);
|
||||||
|
// // 生成新的拆分条码
|
||||||
|
// String stringBigQty2 = bigQty2.toString();
|
||||||
}
|
// String newPalletNo = CodeGenerator.packingGenerateCode(materialPackingName,stringBigQty2);
|
||||||
|
//
|
||||||
}
|
// // 原条码扣减
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // 写入拆分的新条码,更新原数据库
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
//new MESServiceImpl().NeedReceiveMaterialInfoSend_NEW(shipRequestName, "SDK", materialPackingKeyList);
|
//new MESServiceImpl().NeedReceiveMaterialInfoSend_NEW(shipRequestName, "SDK", materialPackingKeyList);
|
||||||
|
@ -507,7 +507,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
|||||||
}
|
}
|
||||||
if ("1".equals(operationType)) { // 自动入库
|
if ("1".equals(operationType)) { // 自动入库
|
||||||
if ("FG".equals(stockInType) || "BFG".equals(stockInType)) { // 产成品入库 增加回收粒子入库
|
if ("FG".equals(stockInType) || "BFG".equals(stockInType)) { // 产成品入库 增加回收粒子入库
|
||||||
fgStockIn = productIntoServiceImpl.outoFgStockIn(receiveActNo, "MES");
|
fgStockIn = productIntoServiceImpl.outoFgStockIn(receiveActNo, "MES",stockInType);
|
||||||
if (fgStockIn.isEmpty()) {
|
if (fgStockIn.isEmpty()) {
|
||||||
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
||||||
}
|
}
|
||||||
|
@ -773,9 +773,9 @@ public class ProductIntoServiceImpl implements FGStockInService {
|
|||||||
return billCode;
|
return billCode;
|
||||||
}
|
}
|
||||||
//自动成品入库到现场仓
|
//自动成品入库到现场仓
|
||||||
public String outoFgStockIn (String RECEIVEACTNO, String eventUser) throws Exception {
|
public String outoFgStockIn (String RECEIVEACTNO, String eventUser, String stockInType) throws Exception {
|
||||||
|
|
||||||
String billCode = toSAPService.FGStockIn2(RECEIVEACTNO, eventUser);
|
String billCode = toSAPService.FGStockIn3(RECEIVEACTNO, eventUser,stockInType);
|
||||||
if (billCode == null) {
|
if (billCode == null) {
|
||||||
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改数量,条码里批次拆分获取流水码
|
// 修改数量,条码里批次拆分获取流水码
|
||||||
public static String packingGenerateCode(String materialpackingname) throws CustomException {
|
public static String packingGenerateCode(String materialpackingname,String qty2) throws CustomException {
|
||||||
|
|
||||||
// 3. 遍历结果集,生成新条码并更新数据库
|
// 3. 遍历结果集,生成新条码并更新数据库
|
||||||
List<Integer> idsToUpdate = new ArrayList<Integer>();
|
List<Integer> idsToUpdate = new ArrayList<Integer>();
|
||||||
@ -69,55 +69,24 @@ public class CodeGenerator {
|
|||||||
if (parts.length < 7) {
|
if (parts.length < 7) {
|
||||||
throw new IllegalArgumentException("Invalid barcode format: " + materialpackingname);
|
throw new IllegalArgumentException("Invalid barcode format: " + materialpackingname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建新的条码部分,假设在第五部分(索引4,因为索引从0开始)后添加流水码
|
// 构建新的条码部分,假设在第五部分(索引4,因为索引从0开始)后添加流水码
|
||||||
StringBuilder newBasePart = new StringBuilder();
|
StringBuilder newBasePart = new StringBuilder();
|
||||||
for (int i = 0; i < parts.length - 2; i++) { // 不包括最后两个部分
|
for (int i = 0; i < parts.length - 2; i++) { // 不包括最后两个部分
|
||||||
newBasePart.append(parts[i]).append("|");
|
newBasePart.append(parts[i]).append("|");
|
||||||
}
|
}
|
||||||
newBasePart.append(parts[4]).append("-").append(sequence++); // 在第五部分后添加流水码
|
newBasePart.append(parts[4]).append("-").append(sequence++); // 在第五部分后添加流水码
|
||||||
for (int i = 6; i < parts.length; i++) { // 添加最后两个部分
|
// for (int i = 6; i < parts.length; i++) { // 添加最后两个部分
|
||||||
newBasePart.append("|").append(parts[i]);
|
// newBasePart.append("|").append(parts[i]);
|
||||||
}
|
// }
|
||||||
|
// 添加倒数第二个部分(假设是日期)
|
||||||
|
newBasePart.append("|").append(parts[5]);
|
||||||
|
// 添加新的数量部分
|
||||||
|
newBasePart.append("|").append(qty2); // 使用传入的新数量值
|
||||||
|
|
||||||
// idsToUpdate.add(id);
|
// idsToUpdate.add(id);
|
||||||
// newNames.add(newBasePart.toString());
|
newNames.add(newBasePart.toString());
|
||||||
|
|
||||||
|
return newBasePart.toString();
|
||||||
String currentDateStr = new SimpleDateFormat(DATE_FORMAT).format(new Date());
|
|
||||||
String newPalletNo = null;
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
while (!success) {
|
|
||||||
|
|
||||||
String maxSeqNoQuery = "SELECT NVL(MAX(TO_NUMBER(SUBSTR(PALLETNO, " +
|
|
||||||
"(LENGTH('" + PREFIX + "') + LENGTH(:dateStr) + 1), 3))), 0) + 1 AS new_seq " +
|
|
||||||
"FROM MATERIALPACKINGPALLET " +
|
|
||||||
"WHERE SUBSTR(PALLETNO, 1, LENGTH('" + PREFIX + "') + LENGTH(:dateStr)) = '" + PREFIX + "' || :dateStr";
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("maxSeqNoQuery: " + maxSeqNoQuery);
|
|
||||||
Map<String, String> bindMap = new HashMap<String, String>();
|
|
||||||
bindMap.put("dateStr", currentDateStr);
|
|
||||||
Map<String, Object> maxSeqNoResult = IDMFrameServiceProxy.getSqlTemplate().queryForMap(maxSeqNoQuery,bindMap);
|
|
||||||
|
|
||||||
int newSeqNo = 0;
|
|
||||||
if (maxSeqNoResult != null && maxSeqNoResult.containsKey("new_seq")) {
|
|
||||||
newSeqNo = Integer.parseInt(maxSeqNoResult.get("new_seq").toString());
|
|
||||||
}
|
|
||||||
// 确保流水码不超过999
|
|
||||||
if (newSeqNo > 999) {
|
|
||||||
throw new CustomException("流水码超过了数字999");
|
|
||||||
}
|
|
||||||
String newSeqNoStr = String.format("%03d", newSeqNo);
|
|
||||||
newPalletNo = PREFIX + currentDateStr + newSeqNoStr;
|
|
||||||
|
|
||||||
success = true;
|
|
||||||
}catch (Exception e) {
|
|
||||||
log.error("Failed to generate pallet number: " + e.getMessage());
|
|
||||||
throw new CustomException("生成流水码错误: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return newPalletNo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user