MES物料消耗
This commit is contained in:
parent
df74f03a55
commit
c306eed4fe
@ -116,7 +116,7 @@ public class MESServiceImpl implements MESService{
|
||||
//根据单据获取要发送MES的信息
|
||||
String sql="SELECT * from(\r\n" +
|
||||
" SELECT m.CHARGE,m.MATERIALPACKINGNAME,m.MATERIALSPECNAME,to_char(m.EXPIRINGDATE,'YYYY-MM-DD HH24:MI')EXPIRINGDATE,m.PHASE, \r\n" +
|
||||
" m.TRUEGG ,m.FQTY ,m.FUNIT ,m.GXID,m.LASTEVENTUSER ,m.REMARK , m3.SHIPREQUESTTYPE, \r\n" +
|
||||
" m.TRUEGG ,m.FQTY ,m.FUNIT ,m.GXID,m.LASTEVENTUSER ,m.REMARK , m3.SHIPREQUESTTYPE, \r\n" +
|
||||
" m3.SHIPREQUESTDETAILTYPE ,m2.MATERIALUNIT ,bm.DENOMINATOR/bm.MODULECULE CONVERSIONSCALE, \r\n" +
|
||||
" m4.DESCRIPTION ,m2.MATERIALTYPE ,(SELECT RECEIVEPRODUCTIONORDERNUMBER FROM MATERIALSHIPREQUESTDETAIL m5 \r\n" +
|
||||
" WHERE m5.SHIPREQUESTNAME=:SHIPREQUESTNAME AND m5.MATERIALSPECNAME=m.MATERIALSPECNAME \r\n" +
|
||||
|
@ -2384,7 +2384,7 @@ public class ToSAPServiceImpl {
|
||||
}
|
||||
|
||||
//MES上报工单消耗数据-261工单投料
|
||||
public String mesMaterialConsume(List<String> boxIdList, List<String> qtyList, String user,String wo) throws Exception {
|
||||
public String mesMaterialConsume( String user,String wo) throws Exception {
|
||||
|
||||
String rcode;
|
||||
String undoId = "";
|
||||
@ -2423,27 +2423,22 @@ public class ToSAPServiceImpl {
|
||||
body.put("BKTXT", uniqueID);
|
||||
//用户名
|
||||
body.put("USNAM", user);
|
||||
|
||||
for (int i=0;i<boxIdList.size();i++) {
|
||||
|
||||
String sql="SELECT m.MATERIALSPECNAME,m.ERPFACTORY,m.ERPLOCATION,m.MATERIALUNIT FROM MATERIALPACKINGMDC m \r\n" +
|
||||
" WHERE m.CHARGE =:CHARGE";
|
||||
|
||||
Map<String, Object> bp = new HashMap<String, Object>();
|
||||
bp.put("CHARGE", boxIdList.get(i));
|
||||
List<Map<String, Object>> mm = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bp);
|
||||
//查询临时表TEMP_MESCONSUME,从里面取数据
|
||||
String sql = "SELECT MATERIALSPECNAME, ERPFACTORY, ERPLOCATION, QTY, UNIT FROM TEMP_MESCONSUME";
|
||||
List<Map<String, Object>> maps = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, new HashMap<String,Object>());
|
||||
for (int i=0;i<maps.size();i++) {
|
||||
JSONObject item = new JSONObject(true);
|
||||
if(mm.size()>0) {
|
||||
if(maps.size()>0) {
|
||||
// MATNR 发货物料号
|
||||
item.put("MATNR", mm.get(0).get("MATERIALSPECNAME"));
|
||||
item.put("MATNR", maps.get(i).get("MATERIALSPECNAME"));
|
||||
// WERKS 发货工厂
|
||||
item.put("WERKS", mm.get(0).get("ERPFACTORY"));
|
||||
item.put("WERKS", maps.get(i).get("ERPFACTORY"));
|
||||
// LGORT 发货库存地点
|
||||
item.put("LGORT", mm.get(0).get("ERPLOCATION"));
|
||||
item.put("LGORT", maps.get(i).get("ERPLOCATION"));
|
||||
//MENGE 数量
|
||||
item.put("MENGE", qtyList.get(i));
|
||||
item.put("MENGE", maps.get(i).get("QTY"));
|
||||
//MENGE 单位
|
||||
item.put("MEINS", mm.get(0).get("MATERIALUNIT"));
|
||||
item.put("MEINS", maps.get(i).get("UNIT"));
|
||||
// //KOSTL 成本中心
|
||||
// item.put("KOSTL", mm.get("COSTCENTER"));
|
||||
// //GRUND 移动原因 (201,202回传)
|
||||
|
@ -62,7 +62,6 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
ErpMessageLog loginfo = new ErpMessageLog();
|
||||
loginfo.setServerName("MESToWms");
|
||||
loginfo.setMessageId("");
|
||||
|
||||
loginfo.setEventUser("MES");
|
||||
loginfo.setId(TimeStampUtil.getCurrentEventTimeKey());
|
||||
loginfo.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
|
||||
@ -77,31 +76,29 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
int success = 0;
|
||||
String errorCode = "";
|
||||
String wo = "";
|
||||
//根据wo,qty,materialSpecName生成物料消耗
|
||||
/**
|
||||
* 1. 从MATERIALPACKINGMDC该要求先进先出取出满足消耗的charge
|
||||
* 2. 写入接口临时表
|
||||
* 3. 过账
|
||||
* 4. 更新MATERIALPACKINGMDC表库存
|
||||
*/
|
||||
|
||||
for (int i = 0; i < in.size(); i++) {
|
||||
JSONObject jb = in.getJSONObject(i);
|
||||
|
||||
String charge = jb.get("charge").toString(); // 批号
|
||||
String materialSpecName = jb.get("materialSpecName").toString();
|
||||
String qty = jb.get("qty").toString(); // 消耗数量
|
||||
wo = jb.get("requestName") == null ? "" : jb.get("requestName").toString(); // 工单
|
||||
boxIdList.add(charge);
|
||||
qtyList.add(qty);
|
||||
String flag = jb.get("flag") == null ? "" : jb.get("flag").toString();
|
||||
//调用存储MES_CONSUME
|
||||
String procedureName = "CALL MES_CONSUME('" + wo + "', '" + materialSpecName + "','" + qty + "','" + flag + "' )";
|
||||
// 调用存储过程返回参数
|
||||
IDMFrameServiceProxy.getSqlTemplate().getJdbcTemplate().execute(procedureName);
|
||||
|
||||
|
||||
}
|
||||
// 将工单的物料消耗数据传给SAP
|
||||
String undoId = toSAPService.mesMaterialConsume(boxIdList, qtyList, "MES", wo);
|
||||
|
||||
// 更新MATERIALPACKINGMDC表库存
|
||||
for (int j = 0; j < boxIdList.size(); j++) {
|
||||
|
||||
String sqlu = "update MATERIALPACKINGMDC m SET m.MATERIALQUANTITY =m.MATERIALQUANTITY-:QTY,m.EVENTTIME =SYSDATE ,\r\n" +
|
||||
" m.EVENTNAME =:EVENTNAME\r\n" +
|
||||
" WHERE m.CHARGE =:CHARGE";
|
||||
Map<String, Object> bp = new HashMap<>();
|
||||
bp.put("CHARGE", boxIdList.get(j));
|
||||
bp.put("QTY", qtyList.get(j));
|
||||
bp.put("EVENTNAME", "MESCONSUME");
|
||||
IDMFrameServiceProxy.getSqlTemplate().update(sqlu, bp);
|
||||
|
||||
}
|
||||
String undoId = toSAPService.mesMaterialConsume("MES", wo);
|
||||
result = AjaxResult.me().setSuccess(true).setErrorCode(200).setMessage("执行成功");
|
||||
loginfo.setResultCode("0");
|
||||
loginfo.setReturnMsg(JSONObject.toJSONString(result));
|
||||
@ -380,6 +377,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
String unit = jo.getString("unit");
|
||||
String requestName = jo.getString("requestName");
|
||||
String area = jo.getString("area");
|
||||
//recycledParticlesSpec表示回收粒子
|
||||
productSpecName = jo.getString("productSpecName");
|
||||
String productName = jo.getString("productName");
|
||||
String sdkId = jo.getString("sdkId");
|
||||
@ -401,6 +399,16 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
List<String> args = Arrays.asList(new String[]{"SH", "F", TimeStampUtil.getCurrentTime("yyyyMMdd")});
|
||||
receiveActNo = NameServiceProxy.getNameRuleDefService().generateName("ReceiveActNo", args, 1).get(0);
|
||||
}
|
||||
String recycledParticlesSpec = jo.get("recycledParticlesSpec") == null ? "" : jo.get("recycledParticlesSpec").toString();
|
||||
//如果是回收例子,料号修改为recycledParticlesSpec
|
||||
if ("BFG".equals(stockInType)) {
|
||||
productSpecName = recycledParticlesSpec;
|
||||
//回收粒子需要生成新的Box ID
|
||||
List<String> boxIDs = MaterialPackingServiceImpl.generateBoxID("LabelId", "SDK",
|
||||
1 + ""
|
||||
, shipTimeStr, "SH", erpFactory);
|
||||
lotname = boxIDs.get(0);
|
||||
}
|
||||
Map<String, Object> bindMap = new HashMap<>();
|
||||
bindMap.put("LOTNAME", lotname);
|
||||
bindMap.put("QTY", qty);
|
||||
@ -426,7 +434,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
bindMap.put("GXID", gxId);
|
||||
|
||||
if ("1".equals(operationType)) { // 自动入库
|
||||
if ("FG".equals(stockInType)) { // 产成品入库
|
||||
if ("FG".equals(stockInType) || "BFG".equals(stockInType)) { // 产成品入库 增加回收例子入库
|
||||
sqlTemplate.update(insertSql, bindMap);
|
||||
MaterialPackingServiceImpl.checkMaterialPackingExist(lotname);
|
||||
|
||||
@ -460,7 +468,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
||||
|
||||
}
|
||||
if ("1".equals(operationType)) { // 自动入库
|
||||
if ("FG".equals(stockInType)) { // 产成品入库
|
||||
if ("FG".equals(stockInType) || "BFG".equals(stockInType)) { // 产成品入库 增加回收粒子入库
|
||||
fgStockIn = productIntoServiceImpl.fgStockIn(receiveActNo, "MES");
|
||||
if (fgStockIn.isEmpty()) {
|
||||
throw new GlobalException("报送ERP失败,请联系IT处理!");
|
||||
|
@ -7111,7 +7111,7 @@ public void updateComplete(EventInfo eventInfo,String siteName,String invoiceNo,
|
||||
// java.util.Calendar c=java.util.Calendar.getInstance();
|
||||
|
||||
|
||||
if ("103".equals(erpFactory)) {
|
||||
if ("1030".equals(erpFactory)) {
|
||||
args.add("TC");
|
||||
} else {
|
||||
args.add("SH");
|
||||
|
Loading…
x
Reference in New Issue
Block a user