Compare commits

...

2 Commits

4 changed files with 159 additions and 9 deletions

View File

@ -5022,12 +5022,13 @@ public class ToSAPServiceImpl {
return sendData; return sendData;
} }
public String iqcResultFeekback(String siteName, String receiveActNumber, String materialCode, String pqcResult, public String iqcResultFeekback(List<String> sapBoxList,String siteName, String receiveActNumber, String materialCode, String pqcResult,
String pqcResultDate, String user, String exceptionHandling, String specialState) { String pqcResultDate, String user, String exceptionHandling, String specialState) {
String moveType= ""; String moveType= "";
String rcode; String rcode;
String undoId = ""; String undoId = "";
String rmsg = null; String rmsg = null;
//依据采购订单查询待入库的物料(MATERIALPACKING) //依据采购订单查询待入库的物料(MATERIALPACKING)
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append("SELECT m.MATERIALSPECNAME ,").append(SystemPropHelper.CR) sql.append("SELECT m.MATERIALSPECNAME ,").append(SystemPropHelper.CR)
@ -5038,9 +5039,10 @@ public class ToSAPServiceImpl {
.append(" sum(m.MATERIALQUANTITY) MATERIALQUANTITY").append(SystemPropHelper.CR) .append(" sum(m.MATERIALQUANTITY) MATERIALQUANTITY").append(SystemPropHelper.CR)
.append(" FROM MATERIALPACKING m ").append(SystemPropHelper.CR) .append(" FROM MATERIALPACKING m ").append(SystemPropHelper.CR)
// .append(" WHERE m.RECEIVEACTNO = :RECEIVEACTNO AND m.SITENAME = :SITENAME ").append(SystemPropHelper.CR) // .append(" WHERE m.RECEIVEACTNO = :RECEIVEACTNO AND m.SITENAME = :SITENAME ").append(SystemPropHelper.CR)
.append(" WHERE m.MESSAGEID = :RECEIVEACTNO AND m.SITENAME = :SITENAME").append(SystemPropHelper.CR) .append(" WHERE m.MATERIALPACKINGNAME IN (:BOXLIST) AND m.SITENAME = :SITENAME").append(SystemPropHelper.CR)
.append(" AND m.MATERIALSPECNAME = :MATERIALSPECNAME ").append(SystemPropHelper.CR) .append(" AND m.MATERIALSPECNAME = :MATERIALSPECNAME ").append(SystemPropHelper.CR)
.append(" AND ( m.PACKINGGRADE IS NULL or m.PACKINGGRADE <> :pqcResult ) ").append(SystemPropHelper.CR) // .append(" AND ( m.PACKINGGRADE IS NULL or m.PACKINGGRADE <> :pqcResult ) ").append(SystemPropHelper.CR)
// .append(" AND ( m.PACKINGGRADE IS NULL or m.PACKINGGRADE <> :pqcResult ) ").append(SystemPropHelper.CR)
.append("GROUP BY m.MATERIALSPECNAME ,m.ERPFACTORY ,m.ERPLOCATION ,m.PACKINGGRADE,m.UNIT "); .append("GROUP BY m.MATERIALSPECNAME ,m.ERPFACTORY ,m.ERPLOCATION ,m.PACKINGGRADE,m.UNIT ");
Map<String, Object> hashMap = new HashMap<String, Object>(); Map<String, Object> hashMap = new HashMap<String, Object>();
@ -5049,6 +5051,7 @@ public class ToSAPServiceImpl {
hashMap.put("MATERIALSPECNAME", materialCode); hashMap.put("MATERIALSPECNAME", materialCode);
hashMap.put("SITENAME", siteName); hashMap.put("SITENAME", siteName);
hashMap.put("pqcResult", pqcResult); hashMap.put("pqcResult", pqcResult);
hashMap.put("BOXLIST", sapBoxList);
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql.toString(), hashMap); List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql.toString(), hashMap);
try { try {
@ -5120,6 +5123,7 @@ public class ToSAPServiceImpl {
erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT)); erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
erplog.setMessageId(UUID.randomUUID().toString()); erplog.setMessageId(UUID.randomUUID().toString());
erplog.setSendMsg2(sendData); erplog.setSendMsg2(sendData);
erplog.setSendMsg(sendData);
erplog.setReturnMsg2(sapreturn); erplog.setReturnMsg2(sapreturn);
erplog.setResultCode(rcode); erplog.setResultCode(rcode);
MessageLogUtil.writeMessageLog(erplog); MessageLogUtil.writeMessageLog(erplog);

View File

@ -23,6 +23,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -258,6 +259,7 @@ public class QMSController {
// @Transactional(isolation= Isolation.READ_COMMITTED)
@Transactional @Transactional
@RequestMapping(value = "/pqcSyncdata2", method = RequestMethod.POST) @RequestMapping(value = "/pqcSyncdata2", method = RequestMethod.POST)
public AjaxResult pqcSyncdata2(@RequestBody JSONArray in) throws CustomException { public AjaxResult pqcSyncdata2(@RequestBody JSONArray in) throws CustomException {
@ -343,6 +345,7 @@ public class QMSController {
setEventInfo.setUserColumns(bindMap); setEventInfo.setUserColumns(bindMap);
//eventInfo.setEventTime(Timestamp.valueOf(pqcResultDate)); //eventInfo.setEventTime(Timestamp.valueOf(pqcResultDate));
eventInfo.setEventUser(user); eventInfo.setEventUser(user);
List<String> sapBoxList = new ArrayList<> ();
if ("0".equals(tpType)) {//采购到货单, 领料退库产成品入库 if ("0".equals(tpType)) {//采购到货单, 领料退库产成品入库
// 获取JSON数组 // 获取JSON数组
@ -363,6 +366,7 @@ public class QMSController {
queryForList.get(0).get("MATERIALPACKINGNAME").toString())); queryForList.get(0).get("MATERIALPACKINGNAME").toString()));
// MaterialPackingServiceProxy.getMaterialPackingService().setEvent(new MaterialPackingKey(queryForList.get(j).get("SITENAME").toString(), // MaterialPackingServiceProxy.getMaterialPackingService().setEvent(new MaterialPackingKey(queryForList.get(j).get("SITENAME").toString(),
// queryForList.get(j).get("MATERIALPACKINGNAME").toString()), makeEventInfo, setEventInfo); // queryForList.get(j).get("MATERIALPACKINGNAME").toString()), makeEventInfo, setEventInfo);
sapBoxList.add( queryForList.get(0).get("MATERIALPACKINGNAME").toString());
success ++; success ++;
} }
} }
@ -381,15 +385,22 @@ public class QMSController {
queryForList.get(j).get("MATERIALPACKINGNAME").toString())); queryForList.get(j).get("MATERIALPACKINGNAME").toString()));
// MaterialPackingServiceProxy.getMaterialPackingService().setEvent(new MaterialPackingKey(queryForList.get(j).get("SITENAME").toString(), // MaterialPackingServiceProxy.getMaterialPackingService().setEvent(new MaterialPackingKey(queryForList.get(j).get("SITENAME").toString(),
// queryForList.get(j).get("MATERIALPACKINGNAME").toString()), makeEventInfo, setEventInfo); // queryForList.get(j).get("MATERIALPACKINGNAME").toString()), makeEventInfo, setEventInfo);
sapBoxList.add(queryForList.get(j).get("MATERIALPACKINGNAME").toString());
success ++; success ++;
} }
} }
} else { } else {
throw new CustomException("Common","无单据信息和批次信息"); throw new CustomException("Common","无单据信息和批次信息");
} }
// 将订单的质检结果传给SAP // 将订单的质检结果传给SAP
String undoId = toSAPService.iqcResultFeekback(siteName,commonNumber,materialCode,pqcResult,pqcResultDate,user, String undoId = toSAPService.iqcResultFeekback(sapBoxList,siteName,commonNumber,materialCode,pqcResult,pqcResultDate,user,
exceptionHandling,specialState); exceptionHandling,specialState);
if(mpList.size()>0)
{
MaterialPackingServiceProxy.getMaterialPackingService().setEvent(mpList, eventInfo, setEventInfo);
}
} }
else if ("6".equals(tpType)) {//投放计划单 else if ("6".equals(tpType)) {//投放计划单

View File

@ -6,6 +6,7 @@ import com.cim.idm.data.ErpMessageLog;
import com.cim.idm.framework.IDMFrameServiceProxy; 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.exception.IDMFrameDBErrorSignal; import com.cim.idm.framework.exception.IDMFrameDBErrorSignal;
import com.cim.idm.framework.util.sys.SystemPropHelper;
import com.cim.idm.framework.util.time.TimeStampUtil; import com.cim.idm.framework.util.time.TimeStampUtil;
import com.cim.idm.mwmsextend.generic.util.CommonValidation; import com.cim.idm.mwmsextend.generic.util.CommonValidation;
import com.cim.idm.mwmsextend.materialpacking.service.MaterialPackingServiceImpl; import com.cim.idm.mwmsextend.materialpacking.service.MaterialPackingServiceImpl;
@ -373,7 +374,7 @@ public class InvoiceServiceImpl implements InvoiceService {
// 转库到线边仓 // 转库到线边仓
billCode = toSAPService.NoSourceChangeLocation(arrayList,ERPRECEIVEFACTORY, billCode = UnSourcedChangeLocation(arrayList,ERPRECEIVEFACTORY,
ERPRECEIVELOCATION, "", eventUser ); ERPRECEIVELOCATION, "", eventUser );
List<MaterialPackingKey> mpKeyList = new ArrayList<MaterialPackingKey> (); List<MaterialPackingKey> mpKeyList = new ArrayList<MaterialPackingKey> ();
@ -394,7 +395,7 @@ public class InvoiceServiceImpl implements InvoiceService {
//抛送MES数据 //抛送MES数据
untils.sendMaterialInfoToMES_NEW(shipRequestName, "", materialPackingKeyList); untils.sendMaterialInfoToMES_NEW(shipRequestName, "", materialPackingKeyList);
//billCode = NCWServiceImpl.SaleOut2(shipRequestName, "SDK", eventUser,materialPackingKeyList,""); //billCode = NCWServiceImpl.SaleOut2(shipRequestName, "SDK", eventUser,materialPackingKeyList,"");
untils.SaveUnDoInfo_ForSap(materialPackingKeyList, billCode, makeEventInfo); // untils.SaveUnDoInfo_ForSap(materialPackingKeyList, billCode, makeEventInfo);
} }
else else
{ {
@ -441,8 +442,142 @@ public class InvoiceServiceImpl implements InvoiceService {
} }
return billCode; return billCode;
} }
//无来源转库过账-转现场仓 311
public String UnSourcedChangeLocation(List<MaterialPackingKey> all,
String aimFactory,
String aimERPlocation,
String aimLocationName,
String user) throws Exception {
String rcode;
String undoId = "";
String rmsg = null;
StringBuffer sql = new StringBuffer();
sql
.append(" SELECT ").append(SystemPropHelper.CR)
.append(" MP.MATERIALSPECNAME, ").append(SystemPropHelper.CR)
.append(" MP.ERPFACTORY , ").append(SystemPropHelper.CR)
.append(" :AIMFACTORY AS UMWRK_RECIEVEFACTORY, ").append(SystemPropHelper.CR)
.append(" MP.ERPLOCATION, ").append(SystemPropHelper.CR)
.append(" :AIMERPLOCATION AS UMLGO_RECIEVEERPLOCATION, ").append(SystemPropHelper.CR)
.append(" MP.MATERIALQUANTITY , ").append(SystemPropHelper.CR)
.append(" MP.UNIT, ").append(SystemPropHelper.CR)
.append(" :AIMLOCATIONNAME AS NULL_RECIVELOCAITONNAME ").append(SystemPropHelper.CR)
.append(" FROM ").append(SystemPropHelper.CR)
.append(" MATERIALPACKING MP ").append(SystemPropHelper.CR)
.append(" WHERE ").append(SystemPropHelper.CR)
.append(" MP.MATERIALPACKINGNAME IN ").append(SystemPropHelper.CR);
Map<String, Object> hashMap = new HashMap<String,Object> ();
hashMap.put("AIMFACTORY", aimFactory);
hashMap.put("AIMLOCATIONNAME", aimLocationName);
hashMap.put("AIMERPLOCATION", aimERPlocation);
String str = "";
str += "(";
for (MaterialPackingKey materialPackingKey : all) {
str += "'" + materialPackingKey.getMaterialPackingName() + "',";
}
str += "'')";
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql.toString() + str, hashMap);
if (queryForList == null || queryForList.size() < 1) {
return "";
}
try {
JSONObject sendData = new JSONObject(true);
JSONObject header = new JSONObject(true);
sendData.put("HEAD", header);
JSONObject body = new JSONObject(true);
sendData.put("BODY", body);
JSONArray itemArray = new JSONArray();
/*
HEAD
*/
header.put("INTF_ID", "MM067");
String uniqueID = UUID.randomUUID().toString();
header.put("REQ_KEYID", uniqueID);
header.put("SRC_MSGID", uniqueID);
header.put("SRC_SYSTEM", "WMS");
header.put("DEST_SYSTEM", "SAP");
header.put("REQUSER", user);
/*
BODY
*/
body.put("ITEM", itemArray);
body.put("ITEMID", uniqueID);
//过账日期
body.put("BUDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
//凭证日期
body.put("BLDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
//凭证抬头文本
body.put("BKTXT", uniqueID);
//用户名
body.put("USNAM", user);
for (Map<String, Object> mm : queryForList) {
JSONObject item = new JSONObject(true);
// MATNR 发货物料号
item.put("MATNR", mm.get("MATERIALSPECNAME"));
//UMMAT 收货物料
item.put("UMMAT", mm.get("MATERIALSPECNAME"));
// WERKS 发货工厂
item.put("WERKS", mm.get("ERPFACTORY"));
// LGORT 发货库存地点
item.put("LGORT", mm.get("ERPLOCATION"));
//UMWRK 收货工厂
item.put("UMWRK", mm.get("UMWRK_RECIEVEFACTORY"));
//UMLGO 收货库存地点
item.put("UMLGO", mm.get("UMLGO_RECIEVEERPLOCATION"));
//MENGE 数量
item.put("MENGE", mm.get("MATERIALQUANTITY"));
//MENGE 单位
item.put("MEINS", mm.get("UNIT"));
//BWART 移动类型
item.put("BWART", "311");
// //ZLLORDER 自定义领料单号
// item.put("ZLLORDER", mm.get("SHIPREQUESTNAME"));
// //ZLLITEM 自定义领料单行号
// item.put("ZLLITEM", mm.get("SHIPREQUESTDETAILNAME"));
itemArray.add(item);
}
// log.info("SendTOSAP >>>>" + sendData);
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendData.toJSONString());
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();//将物料凭证号与凭证年度拼在一起
}
//将log写到表里
UUID uuid = UUID.randomUUID();
ErpMessageLog erplog = new ErpMessageLog();
erplog.setEventUser("");
erplog.setServerName("WmsToErp");
erplog.setEventName("无来源转库-311");
erplog.setId(uuid.toString());
erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
erplog.setMessageId(UUID.randomUUID().toString());
erplog.setSendMsg(sendData.toJSONString());
erplog.setSendMsg2(sendData.toJSONString());
erplog.setReturnMsg2(sapreturn);
erplog.setResultCode(rcode);
MessageLogUtil.writeMessageLog(erplog);
} catch (Exception e) {
// log.info(e.getMessage(), e);
throw new RuntimeException("SAP返回" + rmsg);
}
if (!"S".equals(rcode)) {
throw new RuntimeException("SAP返回" + rmsg);
}
return undoId;
}
/** /**

View File

@ -136,7 +136,7 @@
m2.STOCKORGNO AS ERPFACTORY, m2.SUPPLIERNO, m2.STOCKORGNO AS ERPFACTORY, m2.SUPPLIERNO,
m3.WIDTH AS DESCRIPTION, m3.MATERIALUNITDESC, m3.WIDTH SPECNAME, m3.PHASE, m3.DESC_CN, DECODE( m3.IS_BATCH, 'Y', '是' , '否' ) IS_BATCH, m3.WIDTH AS DESCRIPTION, m3.MATERIALUNITDESC, m3.WIDTH SPECNAME, m3.PHASE, m3.DESC_CN, DECODE( m3.IS_BATCH, 'Y', '是' , '否' ) IS_BATCH,
CASE WHEN m3.EXPIRATION_RULES = '0' THEN '入厂保质期' WHEN m3.EXPIRATION_RULES = '1' THEN '出厂保质期' ELSE '未定义' END AS REPLACED_VALUE, CASE WHEN m3.EXPIRATION_RULES = '0' THEN '入厂保质期' WHEN m3.EXPIRATION_RULES = '1' THEN '出厂保质期' ELSE '未定义' END AS REPLACED_VALUE,
DECODE( m4.IQCFLAG, 'Y', '是', '否' ) IQCFLAG, DECODE( m3.IQCFLAG, 'Y', '是', '否' ) IQCFLAG,
be.DESCRIPTION AS ERPLOCATION2, o.ORGNAME AS ERPFACTORY2, sss.DESCRIPTION AS LOCATIONNAME2, be.DESCRIPTION AS ERPLOCATION2, o.ORGNAME AS ERPFACTORY2, sss.DESCRIPTION AS LOCATIONNAME2,
NVL( BB.QTY, 0 ) CREATEQTY, NVL( AA.QTY, 0 ) STOCKINQTY NVL( BB.QTY, 0 ) CREATEQTY, NVL( AA.QTY, 0 ) STOCKINQTY
FROM MAIN FROM MAIN