Compare commits
2 Commits
8fc39fbfa8
...
4a261b8774
Author | SHA1 | Date | |
---|---|---|---|
4a261b8774 | |||
3e47923e84 |
@ -16,8 +16,6 @@ import com.fasterxml.jackson.databind.JsonMappingException;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -335,6 +333,48 @@ public class ToSAPServiceImpl {
|
|||||||
return undoId;
|
return undoId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 取消物料入库凭证冲销
|
||||||
|
public String cancelShipInter(String undoId, String user) throws Exception {
|
||||||
|
|
||||||
|
String makeFGStockIn = matailInReverse(user, undoId);
|
||||||
|
String sapreturn = "";
|
||||||
|
String rcode = "";
|
||||||
|
String rmsg = "";
|
||||||
|
String undoId2 = "";
|
||||||
|
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)) {
|
||||||
|
undoId2 = 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.setSendMsg2(makeFGStockIn);
|
||||||
|
erplog.setSendMsg(makeFGStockIn);
|
||||||
|
erplog.setReturnMsg2(sapreturn);
|
||||||
|
erplog.setResultCode(rcode);
|
||||||
|
MessageLogUtil.writeMessageLog(erplog);
|
||||||
|
}
|
||||||
|
if (!"S".equals(rcode)) {
|
||||||
|
throw new RuntimeException("SAP返回" + rmsg);
|
||||||
|
}
|
||||||
|
return undoId2;
|
||||||
|
}
|
||||||
|
|
||||||
public String FGStockIn2(String RECEIVEACTNO, String user) throws Exception {
|
public String FGStockIn2(String RECEIVEACTNO, String user) throws Exception {
|
||||||
StringBuffer sql = new StringBuffer();
|
StringBuffer sql = new StringBuffer();
|
||||||
sql.append(SystemPropHelper.CR)
|
sql.append(SystemPropHelper.CR)
|
||||||
@ -627,6 +667,82 @@ public class ToSAPServiceImpl {
|
|||||||
return sendData;
|
return sendData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消物料入库冲销
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
* @throws JsonMappingException
|
||||||
|
* @throws JsonProcessingException
|
||||||
|
*/
|
||||||
|
public String matailInReverse(String user, String undoId) throws JsonMappingException, JsonProcessingException {
|
||||||
|
|
||||||
|
// if (list == null || list.size() < 1) {
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Map<String,Object> bodyData = new HashMap<>();
|
||||||
|
// List<Map<String,Object>> itemsData = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// for (Map<String, Object> mm : list) {
|
||||||
|
// Map<String,Object> item = new HashMap<>();
|
||||||
|
// //UMWRK 收货工厂
|
||||||
|
// //LGORT 发货库存地点
|
||||||
|
// //UMLOG 收货库存地点
|
||||||
|
// //MATNR 发货物料号
|
||||||
|
// //UMMAT 收货物料
|
||||||
|
//
|
||||||
|
// item.put("MATNR", mm.get("MATERIALSPECNAME"));
|
||||||
|
// item.put("LGORT", mm.get("ERPLOCATION"));
|
||||||
|
// item.put("WERKS", mm.get("ERPFACTORY"));
|
||||||
|
// if("FG".equals((String)mm.get("MATERIALSPECTYPE")) ) {
|
||||||
|
// item.put("BWART", "101"); //产成品,移动类型 101
|
||||||
|
// }else if("BFG".equals((String)mm.get("MATERIALSPECTYPE")) ) {
|
||||||
|
// item.put("BWART", "531"); //副产品, 移动类型 531
|
||||||
|
// }else if("FGDEV".equals((String)mm.get("MATERIALSPECTYPE")) ) {
|
||||||
|
// item.put("BWART", "511"); //研发品, 移动类型 511
|
||||||
|
// }else {
|
||||||
|
// item.put("BWART", "101"); //为了兼容之前的未提到的成品,统一暂用 101
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// item.put("MENGE", mm.get("MATERIALQUANTITY"));
|
||||||
|
// item.put("MEINS", mm.get("UNIT"));
|
||||||
|
// item.put("AUFNR", mm.get("PRODUCTORDER"));
|
||||||
|
// item.put("BPMNG", "");
|
||||||
|
// item.put("BPRME", "");
|
||||||
|
// item.put("SGTXT", mm.get("REMARK"));
|
||||||
|
// String insmk = "";
|
||||||
|
// if (StringUtils.isEmpty((String)mm.get("PACKINGGRADE"))) {
|
||||||
|
// insmk = "2";
|
||||||
|
// }else if ("NG".equals((String)mm.get("PACKINGGRADE"))) {
|
||||||
|
// insmk = "3";
|
||||||
|
// }
|
||||||
|
//// String insmk = StringUtils.equals(mm.get("OQARESULTSTATE").toString(),"END")?"":"X";
|
||||||
|
// item.put("INSMK", insmk);
|
||||||
|
// itemsData.add(item);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData);
|
||||||
|
|
||||||
|
Map<String,Object> headData = new HashMap<>();
|
||||||
|
Map<String,Object> bodyData = new HashMap<>();
|
||||||
|
Map<String,String> headJSonData = new HashMap<>();
|
||||||
|
Map<String,String> bodyJSonData = new HashMap<>();
|
||||||
|
headData.put("HEAD",headJSonData);
|
||||||
|
bodyData.put("BODY",bodyJSonData);
|
||||||
|
headJSonData.put("INTF_ID","");
|
||||||
|
headJSonData.put("SRC_SYSTEM","");
|
||||||
|
headJSonData.put("SRC_MSGID","");
|
||||||
|
headJSonData.put("BACKUP1","");
|
||||||
|
headJSonData.put("BACKUP2","");
|
||||||
|
|
||||||
|
bodyJSonData.put("MBLNR", "");
|
||||||
|
bodyJSonData.put("MJAHR", "");
|
||||||
|
|
||||||
|
String sendData = "";
|
||||||
|
return sendData;
|
||||||
|
}
|
||||||
public String qtrNoInvoice(String receiveRequestName, String siteName, String reActo, String user) {
|
public String qtrNoInvoice(String receiveRequestName, String siteName, String reActo, String user) {
|
||||||
|
|
||||||
String rcode;
|
String rcode;
|
||||||
|
@ -54,8 +54,17 @@ public class FGStockInController {
|
|||||||
String erpLocation = materialPacking.getErpLocation();
|
String erpLocation = materialPacking.getErpLocation();
|
||||||
String locationName = materialPacking.getLocationName();
|
String locationName = materialPacking.getLocationName();
|
||||||
String materialSpecName = materialPacking.getMaterialSpecName();
|
String materialSpecName = materialPacking.getMaterialSpecName();
|
||||||
//判断条码是否存在且状态是在库
|
//判断条码是否存在且状态是在库,且仓库只能为线边仓(MDC_FLAG = 'Y')
|
||||||
String sql = "SELECT M.STOCKSTATE,M.RECEIVEACTNO FROM MATERIALPACKING M WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
|
String sql = "SELECT\n" +
|
||||||
|
"\tM.STOCKSTATE,\n" +
|
||||||
|
"\tM.RECEIVEACTNO\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
"\tMATERIALPACKING M\n" +
|
||||||
|
"LEFT JOIN BS_ERPLOCATION be ON\n" +
|
||||||
|
"\tM.ERPLOCATION = be.ERPLOCATIONNAME\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
"\tbe.MDC_FLAG = 'Y'\n" +
|
||||||
|
"\tAND M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
|
||||||
|
|
||||||
Map<String, Object> bindMap = new HashMap<String, Object>();
|
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||||
bindMap.put("MATERIALPACKINGNAME",materialPackingName);
|
bindMap.put("MATERIALPACKINGNAME",materialPackingName);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.cim.idm.controller;
|
package com.cim.idm.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.cim.idm.service.Impl.MaterialUndoServiceImpl;
|
||||||
import com.cim.idm.service.MESToWMSService;
|
import com.cim.idm.service.MESToWMSService;
|
||||||
import com.cim.idm.service.Impl.MESToWMSServiceImpl;
|
import com.cim.idm.service.Impl.MESToWMSServiceImpl;
|
||||||
import com.cim.idm.utils.AjaxResult;
|
import com.cim.idm.utils.AjaxResult;
|
||||||
@ -22,6 +23,7 @@ public class MESToWMSController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MESToWMSServiceImpl mesToWMSService;
|
private MESToWMSServiceImpl mesToWMSService;
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "物料消耗请求")
|
@ApiOperation(value = "物料消耗请求")
|
||||||
@RequestMapping(value = "/meswms_materialconsume_request", method = RequestMethod.POST)
|
@RequestMapping(value = "/meswms_materialconsume_request", method = RequestMethod.POST)
|
||||||
public AjaxResult materialConsume_Request(@RequestBody JSONArray in) {
|
public AjaxResult materialConsume_Request(@RequestBody JSONArray in) {
|
||||||
@ -46,9 +48,12 @@ public class MESToWMSController {
|
|||||||
|
|
||||||
@ApiOperation(value = "取消物料入库请求")
|
@ApiOperation(value = "取消物料入库请求")
|
||||||
@RequestMapping(value = "/meswms_cancelship_request", method = RequestMethod.POST)
|
@RequestMapping(value = "/meswms_cancelship_request", method = RequestMethod.POST)
|
||||||
public AjaxResult cancelShipByMES(@RequestBody JSONArray in) {
|
public AjaxResult cancelShipByMES(@RequestBody JSONArray in) throws Exception {
|
||||||
log.info("Received cancel ship request: {}", in.toJSONString());
|
log.info("Received cancel ship request: {}", in.toJSONString());
|
||||||
return mesToWMSService.cancelShipByMES(in);
|
String undoId = in.getJSONObject(0).getString("undoId");
|
||||||
|
String userId = in.getJSONObject(0).getString("userId");
|
||||||
|
// return mesToWMSService.cancelShipByMES(in);
|
||||||
|
return mesToWMSService.sapcprkUndo(undoId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "物料入库请求")
|
@ApiOperation(value = "物料入库请求")
|
||||||
|
@ -10,8 +10,6 @@ import com.cim.idm.framework.orm.SqlTemplate;
|
|||||||
import com.cim.idm.framework.util.sys.SystemPropHelper;
|
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.materialpacking.service.MaterialPackingServiceImpl;
|
import com.cim.idm.mwmsextend.materialpacking.service.MaterialPackingServiceImpl;
|
||||||
import com.cim.idm.service.Impl.ProductIntoServiceImpl;
|
|
||||||
import com.cim.idm.service.Impl.ReturnStockIntoServiceImpl;
|
|
||||||
import com.cim.idm.service.MESToWMSService;
|
import com.cim.idm.service.MESToWMSService;
|
||||||
import com.cim.idm.service.QMSService;
|
import com.cim.idm.service.QMSService;
|
||||||
import com.cim.idm.service.impl.ToSAPServiceImpl;
|
import com.cim.idm.service.impl.ToSAPServiceImpl;
|
||||||
@ -19,19 +17,18 @@ import com.cim.idm.util.MessageLogUtil;
|
|||||||
import com.cim.idm.utils.AjaxResult;
|
import com.cim.idm.utils.AjaxResult;
|
||||||
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.wmspackage.materialpacking.MaterialPackingServiceProxy;
|
||||||
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.RemoveInfo;
|
||||||
|
import com.cim.idm.wmspackage.materialpacking.management.info.SetEventInfo;
|
||||||
import com.cim.idm.wmspackage.name.NameServiceProxy;
|
import com.cim.idm.wmspackage.name.NameServiceProxy;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service("MESToWMS")
|
@Service("MESToWMS")
|
||||||
@ -175,6 +172,91 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成品入库SAP冲销
|
||||||
|
* @param undoId
|
||||||
|
* @param user
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult sapcprkUndo(String undoId, String user) throws Exception {
|
||||||
|
|
||||||
|
String billCode = toSAPService.cancelShipInter(undoId, user);
|
||||||
|
if (billCode == null) {
|
||||||
|
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AjaxResult result = new AjaxResult();
|
||||||
|
|
||||||
|
EventInfo makeEventInfo = new EventInfoUtil ().makeEventInfo("MakeUndo", user, "MakeUndo");
|
||||||
|
String condition="SELECT MATERIALPACKINGNAME FROM MATERIALPACKING WHERE UNDOID = :UNDOID ";
|
||||||
|
// String[] bindSet={undoId};
|
||||||
|
Map<String, Object> hashMap = new HashMap<String, Object> ();
|
||||||
|
hashMap.put("UNDOID", undoId);
|
||||||
|
//根据物料凭证找到所有的待冲销数据,更新库存状态为创建
|
||||||
|
List<Map<String, Object>> MPlIST = IDMFrameServiceProxy.getSqlTemplate().queryForList(condition, hashMap);
|
||||||
|
SetEventInfo setEventInfo = new SetEventInfo();
|
||||||
|
setEventInfo.setUserColumns(hashMap);
|
||||||
|
RemoveInfo removeInfo = new RemoveInfo();
|
||||||
|
for (Map<String, Object> MP : MPlIST) {
|
||||||
|
//根据当前的数据跟新完工报告且删除入库表的数据
|
||||||
|
String sql = "SELECT M.RECEIVEREQUESTNAME,M.RECEIVEREQUESTDETAILNAME,M.QTY FROM MATERIALPACKINGSUB M WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME\r\n" +
|
||||||
|
"UNION \r\n" +
|
||||||
|
"SELECT M.RECEIVEREQUESTNAME,M.RECEIVEREQUESTDETAILNAME,M.QTY FROM MATERIALPACKINGSUBHISTORY M WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
|
||||||
|
String MATERIALPACKINGNAME = MP.get("MATERIALPACKINGNAME").toString();
|
||||||
|
hashMap.put("MATERIALPACKINGNAME", MATERIALPACKINGNAME);
|
||||||
|
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);
|
||||||
|
for (int i = 0; i < queryForList.size(); i++) {
|
||||||
|
String dh = queryForList.get(i).get("RECEIVEREQUESTNAME").toString();
|
||||||
|
hashMap.put("RECEIVEREQUESTNAME", dh);
|
||||||
|
String hh = queryForList.get(i).get("RECEIVEREQUESTDETAILNAME").toString();
|
||||||
|
hashMap.put("RECEIVEREQUESTDETAILNAME", hh);
|
||||||
|
// String sl = queryForList.get(i).get("QTY").toString();
|
||||||
|
String updateSql = "UPDATE MATERIALRECEIVEREQUESTDETAIL T \r\n" +
|
||||||
|
"SET T.RECEIVEDQUANTITY = T.RECEIVEDQUANTITY - ( \r\n" +
|
||||||
|
" SELECT NVL(SUM(M.QTY),0) \r\n" +
|
||||||
|
" FROM MATERIALPACKINGSUB M \r\n" +
|
||||||
|
" WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME \r\n" +
|
||||||
|
" AND M.RECEIVEREQUESTNAME = T.RECEIVEREQUESTNAME \r\n" +
|
||||||
|
" AND M.RECEIVEREQUESTDETAILNAME = T.RECEIVEREQUESTDETAILNAME \r\n" +
|
||||||
|
") \r\n" +
|
||||||
|
"WHERE T.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME \r\n" +
|
||||||
|
" AND T.RECEIVEREQUESTDETAILNAME = :RECEIVEREQUESTDETAILNAME";
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(updateSql, hashMap);
|
||||||
|
|
||||||
|
|
||||||
|
String updateSql2 = "UPDATE MATERIALRECEIVEREQUESTDETAIL T \r\n" +
|
||||||
|
"SET T.RECEIVEDQUANTITY = T.RECEIVEDQUANTITY - ( \r\n" +
|
||||||
|
" SELECT NVL(SUM(M.QTY),0) \r\n" +
|
||||||
|
" FROM MATERIALPACKINGSUBHISTORY M \r\n" +
|
||||||
|
" WHERE M.MATERIALPACKINGNAME = :MATERIALPACKINGNAME \r\n" +
|
||||||
|
" AND M.RECEIVEREQUESTNAME = T.RECEIVEREQUESTNAME \r\n" +
|
||||||
|
" AND M.RECEIVEREQUESTDETAILNAME = T.RECEIVEREQUESTDETAILNAME \r\n" +
|
||||||
|
") \r\n" +
|
||||||
|
"WHERE T.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME \r\n" +
|
||||||
|
" AND T.RECEIVEREQUESTDETAILNAME = :RECEIVEREQUESTDETAILNAME";
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(updateSql2, hashMap);
|
||||||
|
|
||||||
|
String deleteSql = " DELETE FROM MATERIALPACKINGSUB T WHERE T.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME AND "
|
||||||
|
+ "T.RECEIVEREQUESTDETAILNAME = :RECEIVEREQUESTDETAILNAME AND T.MATERIALPACKINGNAME = :MATERIALPACKINGNAME";
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(deleteSql, hashMap);
|
||||||
|
|
||||||
|
String MESsQL = " UPDATE BS_MES_SHIPPED T SET T.RECEIVE_FLAG = 'N' WHERE T.LOTNAME = :MATERIALPACKINGNAME ";
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(MESsQL, hashMap);
|
||||||
|
}
|
||||||
|
MaterialPackingServiceProxy.getMaterialPackingService().remove(new MaterialPackingKey("SDK", MATERIALPACKINGNAME), makeEventInfo, removeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
String sql = "UPDATE IF_ERPUNDO T SET T.FLAG = 'Y' WHERE T.UNDOID = :UNDOID ";
|
||||||
|
Map<String, Object> hashMap2 = new HashMap<String, Object> ();
|
||||||
|
hashMap2.put("UNDOID", undoId);
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(sql, hashMap2);
|
||||||
|
|
||||||
|
result = AjaxResult.me().setSuccess(true).setErrorCode(200).setMessage("执行成功");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public AjaxResult shipByMES(JSONArray in) throws Exception {
|
public AjaxResult shipByMES(JSONArray in) throws Exception {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.cim.idm.service.Impl;
|
package com.cim.idm.service.Impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
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.service.IMaterialUndoService;
|
import com.cim.idm.service.IMaterialUndoService;
|
||||||
|
import com.cim.idm.utils.AjaxResult;
|
||||||
import com.cim.idm.utils.EventInfoUtil;
|
import com.cim.idm.utils.EventInfoUtil;
|
||||||
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;
|
||||||
|
@ -134,6 +134,147 @@ public class ProductIntoServiceImpl implements FGStockInService {
|
|||||||
bindMapFU.put("ReceiveRequestDetailName", ReceiveRequestDetailName);
|
bindMapFU.put("ReceiveRequestDetailName", ReceiveRequestDetailName);
|
||||||
IDMFrameServiceProxy.getSqlTemplate().update(sqlFU, bindMapFU);
|
IDMFrameServiceProxy.getSqlTemplate().update(sqlFU, bindMapFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void fgStockInNew (List<MaterialPacking> boxList, String user, String ReceiveRequestActNo,
|
||||||
|
String commitDate, String opCode) throws Exception {
|
||||||
|
|
||||||
|
List<MaterialPackingKey> arrayList = new ArrayList<MaterialPackingKey> ();
|
||||||
|
|
||||||
|
String pc = "(";
|
||||||
|
|
||||||
|
for (MaterialPacking materialPacking : boxList) {
|
||||||
|
String materialPackingName = materialPacking.getMaterialPackingName();
|
||||||
|
pc += "'" + materialPackingName + "', ";
|
||||||
|
String locationName = materialPacking.getLocationName();
|
||||||
|
String erpFactory = materialPacking.getErpFactory();
|
||||||
|
String erpLocation = materialPacking.getErpLocation();
|
||||||
|
String materialspec=materialPacking.getMaterialSpecName();
|
||||||
|
String sql2 = "SELECT\r\n" +
|
||||||
|
" BMS.LOTNAME ,\r\n" +
|
||||||
|
" BMS.PRODUCTSPECNAME ,\r\n" +
|
||||||
|
" BMS.PHASE ,\r\n" +
|
||||||
|
" SS.SPECNAME ,\r\n" +
|
||||||
|
" m.DESC_CN ,\r\n" +
|
||||||
|
" BMS.QTY ,\r\n" +
|
||||||
|
" BMS.SHIPTIME ,\r\n" +
|
||||||
|
" SS.SDK_ID ,BMS .REQUESTNAME ,\r\n" +
|
||||||
|
" REGEXP_SUBSTR(BMS.LOTNAME , '[^|]+', 1, 5) AS CHARGE\r\n" +
|
||||||
|
"FROM\r\n" +
|
||||||
|
" BS_MES_SHIPPED BMS LEFT JOIN MATERIALSPEC m ON m.MATERIALSPECNAME = BMS.PRODUCTSPECNAME \r\n" +
|
||||||
|
" LEFT JOIN SDK_SPEC SS ON SS.SDK_ID = BMS.SDK_ID \r\n" +
|
||||||
|
"WHERE\r\n" +
|
||||||
|
" BMS.LOTNAME = :LOTNAME\r\n" +
|
||||||
|
" AND (BMS.RECEIVE_FLAG IS NULL\r\n" +
|
||||||
|
" OR BMS.RECEIVE_FLAG <> 'Y')";
|
||||||
|
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||||
|
bindMap.put("LOTNAME",materialPackingName);
|
||||||
|
List<Map<String,Object>> list2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql2, bindMap);
|
||||||
|
if(list2.size() < 1) {
|
||||||
|
throw new GlobalException( materialPackingName + "生产未完成入库,请联系生产确认!");
|
||||||
|
}
|
||||||
|
String phase = (list2.get(0).get("PHASE") == null || "".equals(list2.get(0).get("PHASE"))) ? "" : list2.get(0).get("PHASE").toString();
|
||||||
|
String sdk_id = (list2.get(0).get("SDK_ID") == null || "~".equals(list2.get(0).get("SDK_ID"))) ? "" : list2.get(0).get("SDK_ID").toString();
|
||||||
|
//根据入库信息获取完工报告
|
||||||
|
StringBuffer sql3 = new StringBuffer();
|
||||||
|
sql3.append(" ");
|
||||||
|
sql3.append(" SELECT ");
|
||||||
|
sql3.append(" M.RECEIVEREQUESTNAME, ");
|
||||||
|
sql3.append(" (M.REQUESTQUANTITY - M.RECEIVEDQUANTITY) MINUSQTY, ");
|
||||||
|
sql3.append(" M.RECEIVEREQUESTDETAILNAME ");
|
||||||
|
sql3.append(" FROM ");
|
||||||
|
sql3.append(" MATERIALRECEIVEREQUESTDETAIL M LEFT JOIN MATERIALRECEIVEREQUEST T ON M.RECEIVEREQUESTNAME = T.RECEIVEREQUESTNAME");
|
||||||
|
sql3.append(" WHERE ");
|
||||||
|
sql3.append(" (M.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME ");
|
||||||
|
sql3.append(" OR M.PRODUCTORDER = :RECEIVEREQUESTNAME ");
|
||||||
|
sql3.append(" OR M.PLANORDER = :RECEIVEREQUESTNAME) ");
|
||||||
|
sql3.append(" AND M.MATERIALSPECNAME = :MATERIALSPECNAME AND T.STOCKORGNO IS NOT NULL ");
|
||||||
|
if (!"".equals(sdk_id) && !"~".equals(sdk_id)) {
|
||||||
|
sql3.append(" AND M.SDK_ID = :SDK_ID ");
|
||||||
|
} else {
|
||||||
|
sql3.append(" AND M.SDK_ID is null ");
|
||||||
|
}
|
||||||
|
if (!"".equals(phase)) {
|
||||||
|
sql3.append(" AND M.PHASE = :PHASE ");
|
||||||
|
} else {
|
||||||
|
sql3.append(" AND M.PHASE is null ");
|
||||||
|
}
|
||||||
|
sql3.append(" AND M.REQUESTQUANTITY - M.RECEIVEDQUANTITY > 0 ORDER BY M.RECEIVEREQUESTNAME ASC ,M.RECEIVEREQUESTDETAILNAME ASC ");
|
||||||
|
|
||||||
|
bindMap.put("RECEIVEREQUESTNAME",list2.get(0).get("REQUESTNAME"));
|
||||||
|
bindMap.put("MATERIALSPECNAME",list2.get(0).get("PRODUCTSPECNAME"));
|
||||||
|
bindMap.put("PHASE",phase);
|
||||||
|
bindMap.put("SDK_ID",sdk_id);
|
||||||
|
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql3.toString(), bindMap);
|
||||||
|
if (queryForList == null || queryForList.size() < 1) {
|
||||||
|
throw new RuntimeException(materialPackingName.split("\\|")[0] + materialPackingName.split("\\|")[4] + "生产报告未完成,请联系生产确认!");
|
||||||
|
}
|
||||||
|
EventInfo makeEventInfo = new EventInfoUtil().makeEventInfo("createfgBoxInfo", user, "createfgBoxInfo");
|
||||||
|
//IDMFrameServiceProxy.getTransactionManager().beginTransaction();
|
||||||
|
//更新订单数量
|
||||||
|
String qty=list2.get(0).get("QTY").toString();//批次数量
|
||||||
|
BigDecimal pcqty = new BigDecimal(qty);
|
||||||
|
// 获取订单号,订单行项,剩余数量
|
||||||
|
for (int i =0 ; i < queryForList.size(); ++ i) {
|
||||||
|
String rqn = queryForList.get(i).get("RECEIVEREQUESTNAME").toString(); //订单
|
||||||
|
String rqdn =queryForList.get(i).get("RECEIVEREQUESTDETAILNAME").toString(); //行项
|
||||||
|
String minusQty = queryForList.get(i).get("MINUSQTY").toString(); //剩余数量
|
||||||
|
// String rqn = map.get("RECEIVEREQUESTNAME").toString(); //订单
|
||||||
|
// String rqdn = map.get("RECEIVEREQUESTDETAILNAME").toString(); //行项
|
||||||
|
// String minusQty = map.get("MINUSQTY").toString(); //剩余数量
|
||||||
|
BigDecimal mqty = new BigDecimal(minusQty);
|
||||||
|
System.out.println(i + "****" + (queryForList.size() - 1));
|
||||||
|
if (i == queryForList.size() - 1 && mqty.compareTo(pcqty) < 0) {
|
||||||
|
throw new RuntimeException(materialPackingName + "报工单数量不足,无法入库 报工单号 : " + rqn + "数量:" + minusQty + "批次数量: " + pcqty);
|
||||||
|
}
|
||||||
|
String insertSql = "INSERT INTO MATERIALPACKINGSUB T (T.MATERIALPACKINGNAME,T.RECEIVEREQUESTNAME,T.RECEIVEREQUESTDETAILNAME,T.QTY) "
|
||||||
|
+ "VALUES (:MATERIALPACKINGNAME, :RECEIVEREQUESTNAME,:RECEIVEREQUESTDETAILNAME,:QTY)";
|
||||||
|
String updateSql = "UPDATE MATERIALRECEIVEREQUESTDETAIL T SET T.RECEIVEDQUANTITY = T.RECEIVEDQUANTITY + :QTY "
|
||||||
|
+ "WHERE T.RECEIVEREQUESTNAME = :RECEIVEREQUESTNAME AND T.RECEIVEREQUESTDETAILNAME = :RECEIVEREQUESTDETAILNAME";
|
||||||
|
//如果当前行项剩余数量满足,则只绑定当前订单和行项
|
||||||
|
if(mqty.compareTo(pcqty)>=0)
|
||||||
|
{
|
||||||
|
Map<String,Object> bp=new HashMap<>();
|
||||||
|
bp.put("RECEIVEREQUESTNAME", rqn);
|
||||||
|
bp.put("RECEIVEREQUESTDETAILNAME", rqdn);
|
||||||
|
bp.put("QTY", pcqty);
|
||||||
|
bp.put("MATERIALPACKINGNAME", materialPackingName);
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(insertSql, bp);
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(updateSql, bp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//如果当前行项数量不满足
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pcqty=pcqty.subtract(mqty);
|
||||||
|
Map<String,Object> bp=new HashMap<>();
|
||||||
|
bp.put("RECEIVEREQUESTNAME", rqn);
|
||||||
|
bp.put("RECEIVEREQUESTDETAILNAME", rqdn);
|
||||||
|
bp.put("QTY", mqty);
|
||||||
|
bp.put("MATERIALPACKINGNAME", materialPackingName);
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(insertSql, bp);
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(updateSql, bp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialPackingKey materialPackingKey = new MaterialPackingKey("SDK",materialPackingName);
|
||||||
|
arrayList.add(materialPackingKey);
|
||||||
|
|
||||||
|
receiveMesShippInfo(makeEventInfo, "SDK", materialPackingName, "", user,
|
||||||
|
materialPackingName, ReceiveRequestActNo, erpLocation, erpFactory, locationName,queryForList.get(0).get("RECEIVEREQUESTNAME").toString(), "","");
|
||||||
|
}
|
||||||
|
pc += "'')";
|
||||||
|
// boolean fgStockIn = fgStockInBySplitCharge(pc, user,commitDate,opCode);
|
||||||
|
|
||||||
|
// boolean fgStockInBySplitCharge20241118 = fgStockInBySplitCharge20241118(pc, user, commitDate, opCode);
|
||||||
|
String aimErpFactory = boxList.get(0).getErpFactory();
|
||||||
|
String aimErpLocation = boxList.get(0).getErpLocation();
|
||||||
|
String aimLOcationName = boxList.get(0).getLocationName();
|
||||||
|
String billCode = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory,
|
||||||
|
aimErpLocation, aimLOcationName, user );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动入库,非自动入库包含转库和自动入库
|
* 手动入库,非自动入库包含转库和自动入库
|
||||||
@ -413,8 +554,89 @@ public class ProductIntoServiceImpl implements FGStockInService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成品入库不拆完工报告
|
||||||
|
* @param pc
|
||||||
|
* @param eventUser
|
||||||
|
* @param commitDate
|
||||||
|
* @param opCode
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public boolean fgStockInBySplitCharge20241118 (String pc, String eventUser,String commitDate,String opCode) throws Exception {
|
||||||
|
//根据入库单号查询有多少个完工报告,完工报告分开过账
|
||||||
|
String wgs = "SELECT DISTINCT t.ERPLOCATION FROM MATERIALPACKINGSUB m \r\n" +
|
||||||
|
" LEFT JOIN MATERIALPACKING T ON m.MATERIALPACKINGNAME =t.MATERIALPACKINGNAME \r\n" +
|
||||||
|
" WHERE m.MATERIALPACKINGNAME IN " + pc;
|
||||||
|
Map<String, Object> hashMap3 = new HashMap<String,Object> ();
|
||||||
|
List<Map<String, Object>> queryForList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(wgs, hashMap3);
|
||||||
|
for (int i = 0; i < queryForList2.size(); i++) {
|
||||||
|
String erpLocation = queryForList2.get(i).get("ERPLOCATION").toString();
|
||||||
|
|
||||||
|
String billCode = toSAPService.FGStockIn(pc, eventUser,commitDate,opCode + i);
|
||||||
|
|
||||||
|
if (billCode == null) {
|
||||||
|
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
||||||
|
}
|
||||||
|
EventInfo makeEventInfo = new EventInfoUtil().makeEventInfo("FGStockIn", eventUser, "FGStockIn");
|
||||||
|
//更新抬头文本状态和Box状态
|
||||||
|
String sql = " SELECT DISTINCT M2.SITENAME ,M.MATERIALPACKINGNAME FROM MATERIALPACKINGSUB M \r\n" +
|
||||||
|
" LEFT JOIN MATERIALPACKING m2 ON m.MATERIALPACKINGNAME = m2.MATERIALPACKINGNAME \r\n" +
|
||||||
|
" WHERE 1 = 1 \r\n" +
|
||||||
|
" AND m2.ERPLOCATION = :ERPLOCATION AND m.MATERIALPACKINGNAME IN " + pc;
|
||||||
|
Map<String, Object> hashMap = new HashMap<String,Object> ();
|
||||||
|
hashMap.put("ERPLOCATION", erpLocation);
|
||||||
|
List<Map<String, Object>> queryForList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, hashMap);
|
||||||
|
for (Map<String, Object> map : queryForList) {
|
||||||
|
MaterialPackingKey materialPackingKey = new MaterialPackingKey(map.get("SITENAME").toString(),map.get("MATERIALPACKINGNAME").toString());
|
||||||
|
SetEventInfo setEventInfo = new SetEventInfo();
|
||||||
|
Map<String, Object> bindMap = new HashMap<String, Object>();
|
||||||
|
bindMap.put("unDoID", billCode);
|
||||||
|
//bindMap.put("StockState", "Stocked");
|
||||||
|
setEventInfo.setUserColumns(bindMap);
|
||||||
|
MaterialPackingServiceProxy.getMaterialPackingService().setEvent(materialPackingKey, makeEventInfo, setEventInfo);
|
||||||
|
|
||||||
|
//更新MES标识
|
||||||
|
String sql2 = "UPDATE BS_MES_SHIPPED T SET T.RECEIVE_FLAG = 'Y', T.RECEIVE_TIME = SYSDATE WHERE T.LOTNAME = :LOTNAME";
|
||||||
|
Map<String, Object> hashMap2 = new HashMap<String,Object> ();
|
||||||
|
hashMap2.put("LOTNAME", map.get("MATERIALPACKINGNAME").toString());
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(sql2, hashMap2);
|
||||||
|
}
|
||||||
|
untils.SaveUnDoInfoBySplitCharge(billCode,commitDate);
|
||||||
|
}
|
||||||
|
//更新Box状态为Stocked
|
||||||
|
String sqlu=" UPDATE MATERIALPACKING m SET m.STOCKSTATE =:STOCKSTATE\r\n" +
|
||||||
|
" WHERE m.SITENAME =:SITENAME AND MATERIALPACKINGNAME IN " + pc;
|
||||||
|
Map<String, Object> bpu=new HashMap<String, Object>();
|
||||||
|
bpu.put("STOCKSTATE", "Stocked");
|
||||||
|
bpu.put("SITENAME", "SDK");
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(sqlu, bpu);
|
||||||
|
|
||||||
|
|
||||||
|
//备份过账条码表的信息,并删除
|
||||||
|
String bfSql = "INSERT\r\n" +
|
||||||
|
" INTO\r\n" +
|
||||||
|
" MATERIALPACKINGSUBHISTORY T (T.MATERIALPACKINGNAME,\r\n" +
|
||||||
|
" T.RECEIVEREQUESTNAME,\r\n" +
|
||||||
|
" T.RECEIVEREQUESTDETAILNAME,\r\n" +
|
||||||
|
" T.QTY)\r\n" +
|
||||||
|
"SELECT\r\n" +
|
||||||
|
" M.MATERIALPACKINGNAME,\r\n" +
|
||||||
|
" M.RECEIVEREQUESTNAME,\r\n" +
|
||||||
|
" M.RECEIVEREQUESTDETAILNAME,\r\n" +
|
||||||
|
" M.QTY\r\n" +
|
||||||
|
"FROM\r\n" +
|
||||||
|
" MATERIALPACKINGSUB M\r\n" +
|
||||||
|
"WHERE M.MATERIALPACKINGNAME IN " + pc;
|
||||||
|
//删除拆分表MATERIALPACKINGSUB
|
||||||
|
String sqld=" DELETE FROM MATERIALPACKINGSUB m WHERE m.MATERIALPACKINGNAME IN " + pc;
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(bfSql, bpu);
|
||||||
|
IDMFrameServiceProxy.getSqlTemplate().update(sqld, bpu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.cim.idm.service;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.cim.idm.utils.AjaxResult;
|
import com.cim.idm.utils.AjaxResult;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
public interface MESToWMSService {
|
public interface MESToWMSService {
|
||||||
|
|
||||||
@ -23,6 +24,10 @@ public interface MESToWMSService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult cancelShipByMES(JSONArray in);
|
AjaxResult cancelShipByMES(JSONArray in);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
AjaxResult sapcprkUndo(String undoId, String user) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接收MES请求物料入库请求
|
* 接收MES请求物料入库请求
|
||||||
* @param in
|
* @param in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user