diff --git a/zi-wms-data/src/main/java/com/cim/idm/wmspackage/materialshiprequest/management/data/MaterialShipRequest.java b/zi-wms-data/src/main/java/com/cim/idm/wmspackage/materialshiprequest/management/data/MaterialShipRequest.java index 9afdb76..f5a512b 100644 --- a/zi-wms-data/src/main/java/com/cim/idm/wmspackage/materialshiprequest/management/data/MaterialShipRequest.java +++ b/zi-wms-data/src/main/java/com/cim/idm/wmspackage/materialshiprequest/management/data/MaterialShipRequest.java @@ -86,6 +86,18 @@ public class MaterialShipRequest extends FieldAccessor implements DataInfo all, String aimERPlocation, String user, - String pqcResult) throws Exception { + String pqcResult, String commitDate) throws Exception { String rcode; String undoId = ""; String rmsg = null; @@ -4665,6 +4665,26 @@ public class ToSAPServiceImpl { if (queryForList == null || queryForList.size() < 1) { return ""; } + + String outputDate = ""; + try { + + if(commitDate.contains("-")) { + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd"); + Date date = inputFormat.parse(commitDate); + outputDate = outputFormat.format(date); + }else { + outputDate = commitDate; + } + } catch (IllegalArgumentException e) { + log.error("commitDate 参数无效: " + e.getMessage(), e); + throw e; + } catch (Exception e) { + log.error("日期解析失败: " + e.getMessage(), e); + throw new RuntimeException("日期解析失败,请检查 commitDate 格式是否为 yyyy-MM-dd", e); + } + try { JSONObject sendData = new JSONObject(true); @@ -4690,10 +4710,11 @@ public class ToSAPServiceImpl { */ body.put("ITEM", itemArray); body.put("ITEMID", uniqueID); + //过账日期 - body.put("BUDAT", TimeStampUtil.getCurrentTime("yyyyMMdd")); + body.put("BUDAT", outputDate); //凭证日期 - body.put("BLDAT", TimeStampUtil.getCurrentTime("yyyyMMdd")); + body.put("BLDAT", outputDate); //凭证抬头文本 body.put("BKTXT", uniqueID); //用户名 @@ -5476,8 +5497,8 @@ public class ToSAPServiceImpl { itemData.add(item); } - - String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData,TimeStampUtil.getCurrentTime("yyyyMMdd")); +// TimeStampUtil.getCurrentTime("yyyyMMdd") + String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData,"2025-04-30"); String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData); org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java index dcc10ac..a8dfdfc 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/NoChargeStockIn.java @@ -256,10 +256,12 @@ public class NoChargeStockIn { if (ReceiveTypeEnums.isPurchase(request.getReceiveRequestType())) { Map args = new HashMap<>(); billcode = toSAPServiceImpl.PurStockIn(request.getReceiveRequestName(), siteName, user, args,commitDate); + }else { + } // @TODO 其他类型 if (billcode == null || "".equals(billcode)) { - return AjaxResult.me().setErrorCode(500).setSuccess(false).setMessage("NC过账失败"); + return AjaxResult.me().setErrorCode(500).setSuccess(false).setMessage("SAP过账失败"); } //8、更新物料凭证 SDKMP.updateUndoID(receiveAct,makeEventInfo,billcode); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/QMSController.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/QMSController.java index 760b0f4..ed30bd1 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/QMSController.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/QMSController.java @@ -978,9 +978,9 @@ public class QMSController { MpKeyList.add(mpkey); } - String commitDate=TimeStampUtil.getCurrentTime("yyyy-MM-dd") + " 00:00:00"; +// String commitDate=TimeStampUtil.getCurrentTime("yyyy-MM-dd"); UUID uuid = UUID.randomUUID(); - billCode = toSAPService.autoTurnWareAndQms(MpKeyList,ERPLOCATION,user,pqcResult); + billCode = toSAPService.autoTurnWareAndQms(MpKeyList,ERPLOCATION,user,pqcResult,"2025-04-30"); // }else { // billCode = NCWServiceImpl.OQZkNoInvoice(LocationBoxList, sendUser); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/controller/SAPToWMSController.java b/zi-wms-pda/src/main/java/com/cim/idm/controller/SAPToWMSController.java index c0b44f0..1b6ac1e 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/controller/SAPToWMSController.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/controller/SAPToWMSController.java @@ -567,28 +567,28 @@ public class SAPToWMSController { selectMap.put("receiverequestname", receiveRequestName); List> isResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); // 检验单据是否已存在,并且未被使用过账 - String isSql = "SELECT\n" + - "m.RECEIVEREQUESTNAME,\n" + - "SUM(md.RECEIVEDQUANTITY)\n" + - "FROM\n" + - "MATERIALRECEIVEREQUEST m\n" + - "LEFT JOIN MATERIALRECEIVEREQUESTDETAIL md ON\n" + - "md.RECEIVEREQUESTNAME = m.RECEIVEREQUESTNAME\n" + - "WHERE\n" + - "m.RECEIVEREQUESTNAME =:receiverequestname\n" + - "AND md.RECEIVEDQUANTITY > 0\n" + - "GROUP BY m.RECEIVEREQUESTNAME"; +// String isSql = "SELECT\n" + +// "m.RECEIVEREQUESTNAME,\n" + +// "SUM(md.RECEIVEDQUANTITY)\n" + +// "FROM\n" + +// "MATERIALRECEIVEREQUEST m\n" + +// "LEFT JOIN MATERIALRECEIVEREQUESTDETAIL md ON\n" + +// "md.RECEIVEREQUESTNAME = m.RECEIVEREQUESTNAME\n" + +// "WHERE\n" + +// "m.RECEIVEREQUESTNAME =:receiverequestname\n" + +// "AND md.RECEIVEDQUANTITY > 0\n" + +// "GROUP BY m.RECEIVEREQUESTNAME"; - List> isList = IDMFrameServiceProxy.getSqlTemplate().queryForList(isSql, selectMap); - if (isList != null && isList.size() > 0) { - throw new CustomException("ERROR","单据已存在,并且已存在过账,不能更新或删除!"); - }else if(isResultList != null && isResultList.size() > 0) { - String shipquestSql="DELETE FROM MATERIALRECEIVEREQUEST WHERE receiveRequestName =?"; - String shipDetailSql="DELETE FROM MATERIALRECEIVEREQUESTDETAIL WHERE receiveRequestName =?"; - Object[] obj=new Object[] {receiveRequestName}; - IDMFrameServiceProxy.getSqlTemplate().update(shipquestSql, obj); - IDMFrameServiceProxy.getSqlTemplate().update(shipDetailSql, obj); - } +// List> isList = IDMFrameServiceProxy.getSqlTemplate().queryForList(isSql, selectMap); +// if (isList != null && isList.size() > 0) { +// throw new CustomException("ERROR","单据已存在,并且已存在过账,不能更新或删除!"); +// }else if(isResultList != null && isResultList.size() > 0) { +// String shipquestSql="DELETE FROM MATERIALRECEIVEREQUEST WHERE receiveRequestName =?"; +// String shipDetailSql="DELETE FROM MATERIALRECEIVEREQUESTDETAIL WHERE receiveRequestName =?"; +// Object[] obj=new Object[] {receiveRequestName}; +// IDMFrameServiceProxy.getSqlTemplate().update(shipquestSql, obj); +// IDMFrameServiceProxy.getSqlTemplate().update(shipDetailSql, obj); +// } List> checkResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); @@ -699,7 +699,7 @@ public class SAPToWMSController { } - if("X".equals(loekz)) { + if("X".equals(loekz)) { String sql="DELETE FROM materialreceivedetail WHERE receiverequestname=? AND receiverequestdetailname=?"; Object[] obj=new Object[] {receiveRequestName, receiveRequestDetailName}; IDMFrameServiceProxy.getSqlTemplate().update(sql, obj); @@ -1076,85 +1076,166 @@ public class SAPToWMSController { String createDate = MapUtils.getString(data, "CRDAT"); // 创建日期 String createTime = MapUtils.getString(data, "CRTIM"); // 创建时间 String moveState = MapUtils.getString(data, "BWART"); //移动类型 BWART - String areaName = MapUtils.getString(data, "AREANAME"); //车间 - String sqlCheck =" SELECT * FROM materialshiprequest m WHERE shiprequestname =:SHIPREQUESTNAME "; + String areaName = MapUtils.getString(data, "FEVOR"); //车间 + + List> checkResultList1 = new ArrayList<>(); + List> checkResultList2 = new ArrayList<>(); + Map selectMap= new HashMap(); selectMap.put("SHIPREQUESTNAME", shipRequestName); - List> isResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); - String isSql = "SELECT\n" + - "m.SHIPREQUESTNAME ,\n" + - "SUM(md.SALEOUTQUANTITY) \n" + - "FROM\n" + - "MATERIALSHIPREQUEST m\n" + - "LEFT JOIN MATERIALSHIPREQUESTDETAIL md ON\n" + - "md.SHIPREQUESTNAME = m.SHIPREQUESTNAME\n" + - "WHERE\n" + - "m.SHIPREQUESTNAME =:SHIPREQUESTNAME\n" + - "AND md.SALEOUTQUANTITY > 0\n" + - "GROUP BY m.SHIPREQUESTNAME"; + // 如果是成品中心退货 + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + String sqlCheck =" SELECT * FROM MATERIALRECEIVEREQUEST m WHERE RECEIVEREQUESTNAME =:SHIPREQUESTNAME "; + checkResultList1 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); - List> isList = IDMFrameServiceProxy.getSqlTemplate().queryForList(isSql, selectMap); - if (isList != null && isList.size() > 0) { - throw new CustomException("ERROR","单据已存在,并且已存在过账!"); - }else if (isResultList != null && isResultList.size() > 0) { - String shipquestSql="DELETE FROM MATERIALSHIPREQUEST WHERE shiprequestname =?"; - String shipDetailSql="DELETE FROM materialshiprequestdetail WHERE shiprequestname =?"; - Object[] obj=new Object[] {shipRequestName}; - IDMFrameServiceProxy.getSqlTemplate().update(shipquestSql, obj); - IDMFrameServiceProxy.getSqlTemplate().update(shipDetailSql, obj); + if(checkResultList1 != null && checkResultList1.size() > 0) { + String sql="DELETE FROM MATERIALRECEIVEREQUEST WHERE RECEIVEREQUESTNAME =?"; + String shipDetailSql="DELETE FROM MATERIALRECEIVEREQUESTDETAIL WHERE RECEIVEREQUESTNAME =?"; + Object[] obj=new Object[] {shipRequestName}; + IDMFrameServiceProxy.getSqlTemplate().update(sql, obj); + IDMFrameServiceProxy.getSqlTemplate().update(shipDetailSql, obj); + } + checkResultList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); + }else { + String sqlCheck =" SELECT * FROM materialshiprequest m WHERE shiprequestname =:SHIPREQUESTNAME "; + + List> isResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); + + String isSql = "SELECT\n" + + "m.SHIPREQUESTNAME ,\n" + + "SUM(md.SALEOUTQUANTITY) \n" + + "FROM\n" + + "MATERIALSHIPREQUEST m\n" + + "LEFT JOIN MATERIALSHIPREQUESTDETAIL md ON\n" + + "md.SHIPREQUESTNAME = m.SHIPREQUESTNAME\n" + + "WHERE\n" + + "m.SHIPREQUESTNAME =:SHIPREQUESTNAME\n" + + "AND md.SALEOUTQUANTITY > 0\n" + + "GROUP BY m.SHIPREQUESTNAME"; + + List> isList = IDMFrameServiceProxy.getSqlTemplate().queryForList(isSql, selectMap); + if (isList != null && isList.size() > 0) { + throw new CustomException("ERROR","单据已存在,并且已存在过账!"); + }else if (isResultList != null && isResultList.size() > 0) { + String shipquestSql="DELETE FROM MATERIALSHIPREQUEST WHERE shiprequestname =?"; + String shipDetailSql="DELETE FROM materialshiprequestdetail WHERE shiprequestname =?"; + Object[] obj=new Object[] {shipRequestName}; + IDMFrameServiceProxy.getSqlTemplate().update(shipquestSql, obj); + IDMFrameServiceProxy.getSqlTemplate().update(shipDetailSql, obj); + } + + checkResultList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); } - List> checkResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); - if(checkResultList == null || checkResultList.size() == 0) { - CreateMaterialShipRequestInfo createInfo = new CreateMaterialShipRequestInfo(); - createInfo.setSiteName(sitename); - createInfo.setShipRequestName(shipRequestName); - createInfo.setShipRequestType(shipRequestType); + if(checkResultList2 == null || checkResultList2.size() == 0) { + + // 如果是成品中心退货 + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + CreateReceiveRequestInfo reCreateInfo = new CreateReceiveRequestInfo(); + reCreateInfo.setSiteName(sitename); + reCreateInfo.setReceiveRequestName(shipRequestName); + reCreateInfo.setReceiveRequestType(shipRequestType); + reCreateInfo.setReceiveRequestState("Created"); + reCreateInfo.setSupplierNO(createUser); + reCreateInfo.setSystemType("ERP"); + + Map bindMap = new HashMap(); + bindMap.put("createUser", createUser); + bindMap.put("createTime", createDate+" "+createTime); + bindMap.put("erpFactory", erpFactory); + bindMap.put("areaName", areaName); + reCreateInfo.setUserColumns(bindMap); + EventInfo reEventInfo = new EventInfo(); + reEventInfo.setEventName("CreateReceiveRequest"); + reEventInfo.setEventUser(createUser); + + MaterialReceiveRequestServiceProxy.getMaterialReceiveRequestService().create(reEventInfo, reCreateInfo); + }else { + CreateMaterialShipRequestInfo createInfo = new CreateMaterialShipRequestInfo(); + createInfo.setSiteName(sitename); + createInfo.setShipRequestName(shipRequestName); + createInfo.setShipRequestType(shipRequestType); // createInfo.setShipRequestDetailType(shiprequesttype); - createInfo.setShipRequestDetailType(moveState); - createInfo.setShipRequestState("Created"); - createInfo.setSystemType("ERP"); - Map bindMap = new HashMap(); - bindMap.put("createUser", createUser); - bindMap.put("createTime", createDate+" "+createTime); - bindMap.put("erpFactory", erpFactory); - bindMap.put("areaName", areaName); - createInfo.setUserColumns(bindMap); - - EventInfo eventInfo = new EventInfo(); - eventInfo.setEventName("MaterialShipRequestSAPToWMS"); - eventInfo.setEventUser(createUser); - - MaterialShipRequestServiceProxy.getMaterialShipRequestService().create(eventInfo, createInfo); - }else { - MaterialShipRequestSetEventInfo info = new MaterialShipRequestSetEventInfo(); - MaterialShipRequestKey key = new MaterialShipRequestKey(); - key.setSiteName(sitename); - key.setShipRequestName(shipRequestName); - - MaterialShipRequest shipRequest=MaterialShipRequestServiceProxy.getMaterialShipRequestService().selectByKey(key); - - if (!shipRequest.getShipRequestState().equalsIgnoreCase("Created")) { - throw new CustomException("ERROR","交货单已确认,禁止修改!"); - } - - Map bindMap = new HashMap(); - //bindMap.put("salesGroup", saleGroup); - bindMap.put("shipRequestType", shipRequestType); - bindMap.put("shipRequestDetailType", moveState); - bindMap.put("createUser", createUser); - bindMap.put("createTime", createTime); - bindMap.put("erpFactory", erpFactory); - bindMap.put("areaName", areaName); + createInfo.setShipRequestDetailType(moveState); + createInfo.setShipRequestState("Created"); + createInfo.setSystemType("ERP"); + Map bindMap = new HashMap(); + bindMap.put("createUser", createUser); + bindMap.put("createTime", createDate+" "+createTime); + bindMap.put("erpFactory", erpFactory); + bindMap.put("areaName", areaName); + createInfo.setUserColumns(bindMap); + + EventInfo eventInfo = new EventInfo(); + eventInfo.setEventName("MaterialShipRequestSAPToWMS"); + eventInfo.setEventUser(createUser); + MaterialShipRequestServiceProxy.getMaterialShipRequestService().create(eventInfo, createInfo); + } - info.setUserColumns(bindMap); - EventInfo eventInfo = new EventInfo(); - eventInfo.setEventName("UpdateMaterialShipRequest"); - eventInfo.setEventUser(createUser); - MaterialShipRequestServiceProxy.getMaterialShipRequestService().setEvent(key, eventInfo, info); + + }else { + //如果是成品中心退货 + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + SetEventInfo reInfo = new SetEventInfo(); + MaterialReceiveRequestKey key = new MaterialReceiveRequestKey(); + + key.setSiteName(sitename); + key.setReceiveRequestName(shipRequestName); + + MaterialReceiveRequest shipRequest = MaterialReceiveRequestServiceProxy.getMaterialReceiveRequestService().selectByKey(key); + + if (!shipRequest.getReceiveRequestState().equalsIgnoreCase("Created")) { + throw new CustomException("ERROR", "交货单已确认,禁止修改!"); + } + + Map bindMap = new HashMap(); + //bindMap.put("salesGroup", saleGroup); + bindMap.put("shipRequestType", shipRequestType); + bindMap.put("shipRequestDetailType", moveState); + bindMap.put("createUser", createUser); + bindMap.put("createTime", createDate+" "+createTime); + bindMap.put("erpFactory", erpFactory); + bindMap.put("areaName", areaName); + + reInfo.setUserColumns(bindMap); + EventInfo reEventInfo = new EventInfo(); + reEventInfo.setEventName("UpDateMaterialtReceiveRequest"); + reEventInfo.setEventUser(createUser); + + MaterialReceiveRequestServiceProxy.getMaterialReceiveRequestService().setEvent(key, reEventInfo, reInfo); + + }else { + MaterialShipRequestSetEventInfo info = new MaterialShipRequestSetEventInfo(); + MaterialShipRequestKey key = new MaterialShipRequestKey(); + key.setSiteName(sitename); + key.setShipRequestName(shipRequestName); + + MaterialShipRequest shipRequest=MaterialShipRequestServiceProxy.getMaterialShipRequestService().selectByKey(key); + + if (!shipRequest.getShipRequestState().equalsIgnoreCase("Created")) { + throw new CustomException("ERROR","交货单已确认,禁止修改!"); + } + + Map bindMap = new HashMap(); + //bindMap.put("salesGroup", saleGroup); + bindMap.put("shipRequestType", shipRequestType); + bindMap.put("shipRequestDetailType", moveState); + bindMap.put("createUser", createUser); + bindMap.put("createTime", createDate+" "+createTime); + bindMap.put("erpFactory", erpFactory); + bindMap.put("areaName", areaName); + + info.setUserColumns(bindMap); + + EventInfo eventInfo = new EventInfo(); + eventInfo.setEventName("UpdateMaterialShipRequest"); + eventInfo.setEventUser(createUser); + MaterialShipRequestServiceProxy.getMaterialShipRequestService().setEvent(key, eventInfo, info); + } + } String bwart="";//移动类型。因领料单下发未发送移动类型,故再单独更新,当LGORT2为空时更新为261,否则更新为311。zd.2024.8.7 if (data.containsKey("ITEM")) { @@ -1203,22 +1284,42 @@ public class SAPToWMSController { String ummat = MapUtils.getString(item, "UMMAT"); // 形态转换->目标物料类型 String xloek= MapUtils.getString(item, "xloek"); // 删除标识 - + + MaterialShipRequestDetail mrd =new MaterialShipRequestDetail(); MaterialShipRequestDetailKey mrdk=new MaterialShipRequestDetailKey(); - mrdk.setSiteName(sitename); - mrdk.setShipRequestName(shipRequestName); - mrdk.setShipRequestDetailName(shipRequestDetailName); - - try { - mrd=MaterialShipRequestDetailServiceProxy.getMaterialShipRequestDetailService().selectByKey(mrdk); - if (mrd.getAssignedQuantity()!=0) { - throw new CustomException("ERROR","行项目已在拣配途中!"); + + MaterialReceiveRequestDetail mrdrc = new MaterialReceiveRequestDetail(); + MaterialReceiveRequestDetailKey receiveKey = new MaterialReceiveRequestDetailKey(); + + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + + receiveKey.setSiteName(sitename); + receiveKey.setReceiveRequestName(shipRequestName); + receiveKey.setReceiveRequestDetailName(shipRequestDetailName); + try { + mrdrc = ReceiveRequestDetailServiceProxy.getReceiveRequestDetailService().selectByKey(receiveKey); + if (mrdrc.getReceivedQuantity() != 0) { + throw new CustomException("ERROR", "行项目已在拣配途中!"); + } + } catch (Exception e) { + // TODO: handle exception + } + }else { + + mrdk.setSiteName(sitename); + mrdk.setShipRequestName(shipRequestName); + mrdk.setShipRequestDetailName(shipRequestDetailName); + try { + mrd=MaterialShipRequestDetailServiceProxy.getMaterialShipRequestDetailService().selectByKey(mrdk); + if (mrd.getAssignedQuantity()!=0) { + throw new CustomException("ERROR","行项目已在拣配途中!"); + } + } catch (Exception e) { + // TODO: handle exception } - } catch (Exception e) { - // TODO: handle exception } - + if("X".equals(xloek)) { String sql="DELETE FROM materialshiprequestdetail WHERE shiprequestname =? and shiprequestdetailname =?"; @@ -1232,33 +1333,38 @@ public class SAPToWMSController { materialMap.put("MATERIALSPECNAME", materialSpecName); List> phaseList = IDMFrameServiceProxy.getSqlTemplate().queryForList(materialSql, materialMap); String phase= ""; - if(phaseList == null || phaseList.size() == 0) { - throw new CustomException("ERROR","料号在基础数据里没找到!"); - }else { - phase = phaseList.get(0).get("PHASE") != null ? phaseList.get(0).get("PHASE").toString() : ""; + try { + if(phaseList == null || phaseList.size() == 0) { + throw new CustomException("ERROR","料号在基础数据里没找到!"); + }else { + phase = phaseList.get(0).get("PHASE") != null ? phaseList.get(0).get("PHASE").toString() : ""; + } + } catch (Exception e) { + // TODO: handle exception + } + + + List> checkItemResultList = new ArrayList>(); + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + String sqlItemCheck ="SELECT * FROM MATERIALRECEIVEREQUESTDETAIL " + + "WHERE RECEIVEREQUESTNAME =:RECEIVEREQUESTNAME and RECEIVEREQUESTDETAILNAME = :RECEIVEREQUESTDETAILNAME"; + Map selectItemMap= new HashMap(); + selectItemMap.put("RECEIVEREQUESTNAME", shipRequestName); + selectItemMap.put("RECEIVEREQUESTDETAILNAME", shipRequestDetailName); + checkItemResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlItemCheck, selectItemMap); + } else { + String sqlItemCheck ="SELECT * FROM materialshiprequestdetail WHERE shiprequestname =:SHIPREQUESTNAME and shiprequestdetailname = :SHIPREQUESTDETAILNAME"; + + Map selectItemMap= new HashMap(); + selectItemMap.put("SHIPREQUESTNAME", shipRequestName); + selectItemMap.put("SHIPREQUESTDETAILNAME", shipRequestDetailName); + + checkItemResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlItemCheck, selectItemMap); } - String sqlItemCheck ="SELECT * FROM materialshiprequestdetail WHERE shiprequestname =:SHIPREQUESTNAME and shiprequestdetailname = :SHIPREQUESTDETAILNAME"; - - Map selectItemMap= new HashMap(); - selectItemMap.put("SHIPREQUESTNAME", shipRequestName); - selectItemMap.put("SHIPREQUESTDETAILNAME", shipRequestDetailName); - - List> checkItemResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlItemCheck, selectItemMap); if (checkItemResultList == null || checkItemResultList.size() == 0) { - CreateMaterialShipRequestDetailInfo createInfo = new CreateMaterialShipRequestDetailInfo(); - - createInfo.setSiteName(sitename); - createInfo.setShipRequestName(shipRequestName); - createInfo.setShipRequestDetailName(shipRequestDetailName); - createInfo.setMaterialSpecName(materialSpecName); - // 精度丢失处理 - BigDecimal bigRequestQuantity = new BigDecimal(requestQuantity.trim()); - createInfo.setRequestQuantity(bigRequestQuantity.doubleValue()); - createInfo.setAssignedQuantity(0); - - + Map bindMapItem = new HashMap(); bindMapItem.put("erpFactory", werks1); // 工厂 bindMapItem.put("erpLocation", lgort1); // 库位 @@ -1287,14 +1393,51 @@ public class SAPToWMSController { bindMapItem.put("causeOfMovement", causeOfMovement); bindMapItem.put("goalMaterialSpec", ummat); bindMapItem.put("phase", phase); + bindMapItem.put("saleOutQuantity", 0); + + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + bindMapItem.put("receiveRequestDetailType", shipRequestType); // 原单号 + CreateReceiveRequestDetailInfo createReceiveInfo = new CreateReceiveRequestDetailInfo(); + createReceiveInfo.setSiteName(sitename); + createReceiveInfo.setReceiveRequestName(shipRequestName); + createReceiveInfo.setReceiveRequestDetailName(shipRequestDetailName); + createReceiveInfo.setMaterialSpecName(materialSpecName); + BigDecimal bigRequestQuantity2 = new BigDecimal(requestQuantity.trim()); + createReceiveInfo.setRequestQuantity(bigRequestQuantity2.doubleValue()); + createReceiveInfo.setReceivedQuantity(0); + createReceiveInfo.setUserColumns(bindMapItem); + EventInfo eventReciveInfo = new EventInfo(); + eventReciveInfo.setEventUser(createUser); + eventReciveInfo.setEventName("Create"); + + MaterialReceiveRequestDetailKey key = new MaterialReceiveRequestDetailKey(); + + key.setSiteName(sitename); + key.setReceiveRequestName(shipRequestName); + key.setReceiveRequestDetailName(shipRequestDetailName); + ReceiveRequestDetailServiceProxy.getReceiveRequestDetailService().create(key,eventReciveInfo, createReceiveInfo); + }else { + CreateMaterialShipRequestDetailInfo createInfo = new CreateMaterialShipRequestDetailInfo(); + + createInfo.setSiteName(sitename); + createInfo.setShipRequestName(shipRequestName); + createInfo.setShipRequestDetailName(shipRequestDetailName); + createInfo.setMaterialSpecName(materialSpecName); + // 精度丢失处理 + BigDecimal bigRequestQuantity = new BigDecimal(requestQuantity.trim()); + createInfo.setRequestQuantity(bigRequestQuantity.doubleValue()); + createInfo.setAssignedQuantity(0); + + createInfo.setUserColumns(bindMapItem); + EventInfo eventInfo = new EventInfo(); + eventInfo.setEventTime(TimeStampUtil.getCurrentTimestamp()); + eventInfo.setEventUser(createUser); + eventInfo.setEventName("CreateMaterialShipRequest"); + + MaterialShipRequestDetailServiceProxy.getMaterialShipRequestDetailService().create(createInfo); + } + - createInfo.setUserColumns(bindMapItem); - EventInfo eventInfo = new EventInfo(); - eventInfo.setEventTime(TimeStampUtil.getCurrentTimestamp()); - eventInfo.setEventUser(createUser); - eventInfo.setEventName("CreateMaterialShipRequest"); - - MaterialShipRequestDetailServiceProxy.getMaterialShipRequestDetailService().create(createInfo); }else { NonPrimaryKeyValueInfo nonPrimaryKeyValueInfo = new NonPrimaryKeyValueInfo(); @@ -1329,14 +1472,33 @@ public class SAPToWMSController { bindMapItem.put("causeOfMovement", causeOfMovement); bindMapItem.put("goalMaterialSpec", ummat); bindMapItem.put("phase", phase); + bindMapItem.put("saleOutQuantity", 0); nonPrimaryKeyValueInfo.setUserColumns(bindMapItem); EventInfo eventInfo = new EventInfo(); eventInfo.setEventTime(TimeStampUtil.getCurrentTimestamp()); eventInfo.setEventUser(createUser); eventInfo.setEventName("updateMaterialShipRequest"); - - MaterialShipRequestDetailServiceProxy.getMaterialShipRequestDetailService().setEvent(mrdk, nonPrimaryKeyValueInfo); + + + + // 如果是成本退 + if("07".equals(shipRequestType) || "03".equals(shipRequestType)) { + com.cim.idm.wmspackage.receiverequestdetail.management.info.SetEventInfo setReciveInfo = new com.cim.idm.wmspackage.receiverequestdetail.management.info.SetEventInfo(); + MaterialReceiveRequestDetailKey receiveRequestDetailKey = new MaterialReceiveRequestDetailKey(); + MaterialReceiveRequestDetail receiveRequestDetail = new MaterialReceiveRequestDetail(); + receiveRequestDetailKey.setReceiveRequestDetailName(shipRequestDetailName); + receiveRequestDetailKey.setReceiveRequestName(shipRequestName); + receiveRequestDetailKey.setSiteName(sitename); + setReciveInfo.setUserColumns(bindMapItem); + + ReceiveRequestDetailServiceProxy.getReceiveRequestDetailService().setEvent(receiveRequestDetailKey, eventInfo, setReciveInfo); + }else { + MaterialShipRequestDetailServiceProxy.getMaterialShipRequestDetailService().setEvent(mrdk, nonPrimaryKeyValueInfo); + } + + + } } @@ -1384,6 +1546,7 @@ public class SAPToWMSController { IDMFrameServiceProxy.getTransactionManager().rollbackTransaction(); Map errorReturn = new HashMap<>(); errorReturn.put("STATUS", "E"); + log.info(e.toString()); errorReturn.put("MSGTXT", "预留单/领料单下发失败 " + e.getMessage()); errorReturn.put("HEAD", request.getHEAD()); //errorReturn.put("BODY", request.getBODY()); @@ -1524,19 +1687,36 @@ public class SAPToWMSController { String carFlag = MapUtils.getString(data, "Z_SSEND");//是否需要专车派送 String factoryName = MapUtils.getString(data, "WERKS"); //工厂 + + List> checkResultList = new ArrayList<>(); + List> checkResultList2 = new ArrayList<>(); Map selectMap= new HashMap(); selectMap.put("SHIPREQUESTNAME", shipRequestName); // 如果是销售退货 if("ZLR1".equals(shipRequestType)) { String sqlCheck =" SELECT * FROM MATERIALRECEIVEREQUEST m WHERE RECEIVEREQUESTNAME =:SHIPREQUESTNAME "; checkResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); + + if(checkResultList != null && checkResultList.size() > 0) { + String sql="DELETE FROM MATERIALRECEIVEREQUEST WHERE RECEIVEREQUESTNAME =?"; + Object[] obj=new Object[] {shipRequestName}; + IDMFrameServiceProxy.getSqlTemplate().update(sql, obj); + } + checkResultList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); }else { String sqlCheck =" SELECT * FROM materialshiprequest m WHERE shiprequestname =:SHIPREQUESTNAME "; checkResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); + + if(checkResultList != null && checkResultList.size() > 0) { + String sql="DELETE FROM materialshiprequest WHERE shiprequestname =?"; + Object[] obj=new Object[] {shipRequestName}; + IDMFrameServiceProxy.getSqlTemplate().update(sql, obj); + } + checkResultList2 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlCheck, selectMap); } - if(checkResultList == null || checkResultList.size() == 0) { + if(checkResultList2 == null || checkResultList2.size() == 0) { Map bindMap = new HashMap(); bindMap.put("shipRequestDec", shiprequestdec); @@ -1547,6 +1727,7 @@ public class SAPToWMSController { bindMap.put("orderDateStr", orderDate); bindMap.put("erpFactory", factoryName); bindMap.put("planDate", planDate);//计划交货日期 + //NEW bindMap.put("customerOrder", customerOrder);//客户订单号 bindMap.put("customerArea", customerArea);//客户大区 @@ -1582,6 +1763,7 @@ public class SAPToWMSController { // shipRequestList.add(shipRequestName); createInfo.setSystemType("ERP"); + bindMap.put("createTime", orderDate);//创建日期 createInfo.setUserColumns(bindMap); EventInfo eventInfo = new EventInfo(); @@ -1665,7 +1847,10 @@ public class SAPToWMSController { EventInfo eventInfo = new EventInfo(); eventInfo.setEventName("ModifyMaterialShipRequest"); eventInfo.setEventUser(createUser); + MaterialShipRequestServiceProxy.getMaterialShipRequestService().setEvent(key, eventInfo, info); + + } } @@ -1775,6 +1960,7 @@ public class SAPToWMSController { bindMapItem.put("sendSalesOrder", sendSaleOrder); // 销售订单 bindMapItem.put("sendSalesOrderDetailNo", sendSaleOrderDetailNo); // 销售订单行号 bindMapItem.put("sourceNo", sourceNo); // 原单号 + bindMapItem.put("saleOutQuantity", 0); // 根据料号获取阶段 String materialSql = "SELECT m.PHASE FROM MATERIALSPEC m WHERE MATERIALSPECNAME = :MATERIALSPECNAME"; @@ -1851,6 +2037,7 @@ public class SAPToWMSController { bindMapItem.put("sendSalesOrder", sendSaleOrder); // 销售订单 bindMapItem.put("sendSalesOrderDetailNo", sendSaleOrderDetailNo); // 销售订单行号 bindMapItem.put("sourceNo", sourceNo); // 原单号 + bindMapItem.put("saleOutQuantity", 0); nonPrimaryKeyValueInfo.setUserColumns(bindMapItem); setReciveInfo.setUserColumns(bindMapItem); diff --git a/zi-wms-pda/src/main/java/com/cim/idm/dao/FgStockInDao.java b/zi-wms-pda/src/main/java/com/cim/idm/dao/FgStockInDao.java index 870ca56..ccdb331 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/dao/FgStockInDao.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/dao/FgStockInDao.java @@ -14,7 +14,7 @@ public interface FgStockInDao { //调用接口查询当前Box是否都是在库需要转库,传入List public List getBoxList(@Param("boxList") List boxList,@Param("erpFactory") String erpFactory - ,@Param("erpLocation") String erpLocation,@Param("locationName") String locationName) throws Exception; + ,@Param("erpLocation") String erpLocation,@Param("locationName") String locationName,@Param("user") String user) throws Exception; //批量更新BS_MES_SHIPPED表的ReceiveFlag和ReceiveTime public void updateBsMesShipped(@Param("boxList") List boxList) throws Exception; diff --git a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java index ac4fea2..470722d 100644 --- a/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java +++ b/zi-wms-pda/src/main/java/com/cim/idm/service/Impl/ProductIntoServiceImpl.java @@ -290,7 +290,7 @@ public class ProductIntoServiceImpl implements FGStockInService { @Transactional public void fgStockInByManul(List boxList, String user, String receiveRequestActNo, String commitDate, String opCode) throws Exception { //调用mybatis查询当前要入库的信息是否是同一类型转库Or入库 - List packingList = fgStockInDao.getBoxList(boxList,boxList.get(0).getErpFactory(),boxList.get(0).getErpLocation(),boxList.get(0).getLocationName()); + List packingList = fgStockInDao.getBoxList(boxList,boxList.get(0).getErpFactory(),boxList.get(0).getErpLocation(),boxList.get(0).getLocationName(),user); if(packingList.size()==0){ throw new Exception("请选择正确的入库信息"); } @@ -330,6 +330,10 @@ public class ProductIntoServiceImpl implements FGStockInService { aimErpLocation, aimLOcationName, user, commitDate); //更新物料凭证和库存状态 toSapDao.updateLocationStockState(boxList, "Stocked", undoID,aimErpFactory,aimErpLocation,aimLOcationName,user); + + // + MESServiceImpl mesService=new MESServiceImpl() ; + mesService.CCPRK_deleteMaterialPackingInfo(chargeList); }else { // 直接入库 //封装为Json的字符串 @@ -353,9 +357,6 @@ public class ProductIntoServiceImpl implements FGStockInService { toSapDao.saveUnDoInfo( boxList, undoID, commitDate); //更新接口表的标记和 fgStockInDao.updateBsMesShipped(boxList); - - MESServiceImpl mesService=new MESServiceImpl() ; - mesService.CCPRK_deleteMaterialPackingInfo(chargeList); } diff --git a/zi-wms-pda/src/main/resources/com/cim/idm/dao/DeliveryDao.xml b/zi-wms-pda/src/main/resources/com/cim/idm/dao/DeliveryDao.xml index 9255241..870ac32 100644 --- a/zi-wms-pda/src/main/resources/com/cim/idm/dao/DeliveryDao.xml +++ b/zi-wms-pda/src/main/resources/com/cim/idm/dao/DeliveryDao.xml @@ -167,6 +167,7 @@ #{name} AND m.SITENAME = #{siteName} + AND m.DELETEDETAILFLAG !='L' AND m3.IS_BATCH != 'N' @@ -235,10 +236,10 @@ AND m.SITENAME = #{siteName} AND (m.REQUESTQUANTITY - m.RECEIVEDQUANTITY) > 0 - AND m2.RECEIVEREQUESTTYPE IN - - #{type} - + + + + AND (m2.RETURNFLAG IS NULL OR m2.RETURNFLAG != 'Y') AND (m3.IS_BATCH IS NULL OR m3.IS_BATCH != 'Y') diff --git a/zi-wms-pda/src/main/resources/com/cim/idm/dao/FgStockInDao.xml b/zi-wms-pda/src/main/resources/com/cim/idm/dao/FgStockInDao.xml index 17d0414..217d351 100644 --- a/zi-wms-pda/src/main/resources/com/cim/idm/dao/FgStockInDao.xml +++ b/zi-wms-pda/src/main/resources/com/cim/idm/dao/FgStockInDao.xml @@ -30,6 +30,8 @@ 'SDK' siteName, 'Released' PackingState, 'Created' stockState, + 'Created' OldStockState, + 'N' HoldState, T.DURABLETYPE durableType, #{erpFactory} ERPFactory, #{erpLocation} ERPLOCATION, @@ -38,6 +40,7 @@ NVL(T.MAKEDATE, SYSDATE ) MAKEDATE , NVL(T.MAKEDATE, SYSDATE ) + NVL(M3.EXPIRATIONDAY, '9999') expiringDate, SYSDATE ReceiveTime, + #{user} ReceiveUser, T.REQUESTNAME productOrder, T.CAREER_ASSISTANCE , M3.MATERIALSPECTYPE , @@ -56,6 +59,9 @@ M3.MATERIALTYPE , T.PHASE, T.GXID, + T.CHARGE, + T.TRUEGG, + T.MJPC, T.MATERIALSPECTYPE FROM BS_MES_SHIPPED T