转工单-没做完
This commit is contained in:
parent
24c0270ea7
commit
8d1fa52a66
@ -6472,7 +6472,8 @@ public class ToSAPServiceImpl {
|
||||
|
||||
}
|
||||
|
||||
public String StockOutByOrder(List<com.cim.idm.data.changeOrder.changeOrderDto> materialPackingList, String mes) {{
|
||||
public String StockOutByOrder(List<com.cim.idm.data.changeOrder.changeOrderDto> materialPackingList, String mes,
|
||||
String bwart) {{
|
||||
|
||||
String rcode;
|
||||
String undoId = "";
|
||||
@ -6535,7 +6536,7 @@ public class ToSAPServiceImpl {
|
||||
// //GRUND 移动原因 (201,202回传)
|
||||
// item.put("GRUND", mm.get("SHIPREQUESTDETAILTYPE"));
|
||||
|
||||
item.put("BWART", "261");
|
||||
item.put("BWART", bwart);
|
||||
//ZLLORDER 自定义领料单号
|
||||
// item.put("ZLLORDER", "LL1010250408001");
|
||||
item.put("ZLLORDER", mm.getZLLORDER());
|
||||
@ -6583,6 +6584,124 @@ public class ToSAPServiceImpl {
|
||||
return undoId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转工单-新
|
||||
* @param materialPackingList
|
||||
* @param mes
|
||||
* @param bwart
|
||||
* @return
|
||||
*/
|
||||
public String StockOutByOrder_new(List<Map<String, Object>> mapList, String mes,
|
||||
String bwart) {
|
||||
|
||||
String rcode;
|
||||
String undoId = "";
|
||||
String rmsg = null;
|
||||
|
||||
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", mes);
|
||||
|
||||
/*
|
||||
BODY
|
||||
*/
|
||||
body.put("ITEM", mapList);
|
||||
body.put("ITEMID", uniqueID);
|
||||
//过账日期
|
||||
body.put("BUDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
|
||||
//凭证日期
|
||||
body.put("BLDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
|
||||
//凭证抬头文本
|
||||
body.put("BKTXT", uniqueID);
|
||||
//用户名
|
||||
body.put("USNAM", mes);
|
||||
|
||||
|
||||
if (mapList == null || mapList.size() < 1) {
|
||||
throw new RuntimeException("不存在需要发送的数据");
|
||||
}
|
||||
for (Map<String, Object> mm : mapList) {
|
||||
mm.put("BWART", bwart);
|
||||
JSONObject item = new JSONObject(true);
|
||||
/*if(materialPackingList.size()>0) {
|
||||
// MATNR 发货物料号
|
||||
item.put("MATNR", mm.getMATNR());
|
||||
|
||||
// WERKS 发货工厂
|
||||
item.put("WERKS", mm.getWERKS());
|
||||
// LGORT 发货库存地点
|
||||
item.put("LGORT", mm.getLGORT());
|
||||
//MENGE 数量
|
||||
item.put("MENGE",mm.getMENGE());
|
||||
//MENGE 单位
|
||||
item.put("MEINS",mm.getMEINS());
|
||||
item.put("BWART", bwart);
|
||||
//ZLLORDER 自定义领料单号
|
||||
// item.put("ZLLORDER", "LL1010250408001");
|
||||
item.put("ZLLORDER", mm.getZLLORDER());
|
||||
//ZLLITEM 自定义领料单行号
|
||||
|
||||
// item.put("ZLLITEM", "0001");
|
||||
item.put("ZLLITEM", mm.getZLLITEM());
|
||||
//AUFNR 订单号
|
||||
item.put("AUFNR", mm.getAUFNR());
|
||||
|
||||
}
|
||||
itemArray.add(item);*/
|
||||
}
|
||||
|
||||
System.out.println(mapList);
|
||||
/*log.info("SendTOSAP >>>>" + sendData);
|
||||
String sendDatas = sendData.toJSONString();
|
||||
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendDatas);
|
||||
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写到表里
|
||||
ErpMessageLog erplog = new ErpMessageLog();
|
||||
erplog.setEventUser("");
|
||||
erplog.setServerName("WmsToErp");
|
||||
erplog.setEventName("MES物料消耗261和转工单");
|
||||
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返回" + e.toString());
|
||||
}
|
||||
/* if (!"S".equals(rcode)) {
|
||||
throw new RuntimeException("SAP返回" + rmsg);
|
||||
}*/
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成品入库
|
||||
*
|
||||
|
@ -34,7 +34,7 @@ public class MESToWMSController {
|
||||
public AjaxResult workOrder_Request(@RequestBody JSONArray in) {
|
||||
log.info("Received work order request: {}", in.toJSONString());
|
||||
try {
|
||||
return mesToWMSService.workOrder_Request(in);
|
||||
return mesToWMSService.workOrder_Request_new(in);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -660,6 +660,45 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult workOrder_Request_new(JSONArray in) throws Exception {
|
||||
log.info("Received work order request: {}", in.toJSONString());
|
||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||
for (int i = 0; i < in.size(); i++) {
|
||||
JSONObject jsonObject = in.getJSONObject(i);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 料号
|
||||
String materialSpecname = jsonObject.getString("materialSpecname");
|
||||
// 组织
|
||||
String WERKS = jsonObject.getString("WERKS");
|
||||
// 仓库
|
||||
String LGORT = jsonObject.getString("LGORT");
|
||||
// 数量
|
||||
String MENGE = jsonObject.getString("MENGE");
|
||||
// 单位
|
||||
String MEINS = jsonObject.getString("MEINS");
|
||||
// 自定义领料单号
|
||||
String ZLLORDER = jsonObject.getString("ZLLORDER");
|
||||
// 自定义领料单行号
|
||||
String ZLLITEM = jsonObject.getString("ZLLITEM");
|
||||
// 工单
|
||||
String AUFNR = jsonObject.getString("AUFNR");
|
||||
|
||||
map.put("MATNR", materialSpecname);
|
||||
map.put("WERKS", WERKS);
|
||||
map.put("LGORT", LGORT);
|
||||
map.put("MENGE", MENGE);
|
||||
map.put("MEINS", MEINS);
|
||||
map.put("ZLLORDER", ZLLORDER);
|
||||
map.put("ZLLITEM", ZLLITEM);
|
||||
map.put("AUFNR", AUFNR);
|
||||
mapList.add(map);
|
||||
}
|
||||
// 出库
|
||||
String undoid = toSAPService.StockOutByOrder_new(mapList, "MES", "262");
|
||||
return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + undoid);
|
||||
}
|
||||
/**
|
||||
* 接收MES请求工单请求
|
||||
*
|
||||
@ -701,6 +740,15 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
String s = materialOutByMES(materialSpecnameList, chargeList);
|
||||
//调用入库方法
|
||||
String s1 = materialIntoByMES(materialSpecnameList, chargeList,wo);
|
||||
if (StringUtils.isEmpty(s1)) {
|
||||
// 冲销
|
||||
String undo = invoiceService.cancelShipInter(s, "MES");
|
||||
if (undo == null || undo.isEmpty()) {
|
||||
throw new GlobalException("下发mes失败后冲销失败!");
|
||||
} else {
|
||||
throw new GlobalException("发送到mes失败!");
|
||||
}
|
||||
}
|
||||
String message = "工单转换成功 物料凭证 {}";
|
||||
return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + s1);
|
||||
}
|
||||
@ -716,17 +764,9 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
//出库过账
|
||||
String undoid = toSAPService.StockOutByOrder(
|
||||
materialPackingList,
|
||||
"MES"
|
||||
"MES",
|
||||
"262"
|
||||
);
|
||||
if (undoid != null) {
|
||||
// 冲销
|
||||
String undo = invoiceService.cancelShipInter(undoid, "MES");
|
||||
if (undo == null || undo.isEmpty()) {
|
||||
throw new GlobalException("下发mes失败后冲销失败!");
|
||||
} else {
|
||||
throw new GlobalException("发送到mes失败!");
|
||||
}
|
||||
}
|
||||
//更新MDC表状态
|
||||
mesToWmsDao.updateMDCFlag(materialSpecnameList, chargeList, "T");
|
||||
return undoid;
|
||||
@ -743,7 +783,8 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
//入库过账
|
||||
String undoid = toSAPService.StockOutByOrder(
|
||||
materialPackingListByRK,
|
||||
"MES"
|
||||
"MES",
|
||||
"261"
|
||||
);
|
||||
mesToWmsDao.updateMDCFlag(materialSpecnameList, chargeList, "S");
|
||||
return undoid;
|
||||
|
@ -35,6 +35,13 @@ public interface MESToWMSService {
|
||||
*/
|
||||
AjaxResult shipByMES(JSONArray in) throws Exception;
|
||||
|
||||
/**
|
||||
* 接收MES请求工单请求
|
||||
* @param in
|
||||
* @return
|
||||
*/
|
||||
AjaxResult workOrder_Request_new(JSONArray in) throws Exception;
|
||||
|
||||
/**
|
||||
* 接收MES请求工单请求
|
||||
* @param in
|
||||
|
Loading…
x
Reference in New Issue
Block a user