Compare commits

...

2 Commits

10 changed files with 124 additions and 46 deletions

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.type.TypeReference;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
@Service
@ -116,7 +117,8 @@ public class ToSAPServiceImpl {
itemData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData, TimeStampUtil.getCurrentTime("yyyyMMdd"));
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData);
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
@ -236,7 +238,7 @@ public class ToSAPServiceImpl {
itemData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData);
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
@ -522,7 +524,7 @@ public class ToSAPServiceImpl {
* @return 返回物料凭证相关的ID
* @throws Exception 如果与SAP系统的通信或其他错误发生时抛出异常
*/
public String FGStockInByManulIn( String bodyJson, String user, String RECEIVEACTNO) throws Exception {
public String FGStockInByManulIn( String bodyJson, String user, String RECEIVEACTNO, String commitDate) throws Exception {
// 初始化SAP返回信息结果代码消息文本和撤销ID
String sapreturn = "";
String rcode = "";
@ -535,7 +537,7 @@ public class ToSAPServiceImpl {
new TypeReference<List<Map<String, Object>>>() {}
);
String makeFGStockIn = makeFGStockIn2(objList, user, RECEIVEACTNO);
String makeFGStockIn = makeFGStockIn2(objList, user, RECEIVEACTNO,commitDate);
try {
// 发送物料信息到SAP系统
@ -703,10 +705,10 @@ public class ToSAPServiceImpl {
itemsData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData);
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
return sendData;
}
public String makeFGStockIn2(List<Map<String, Object>> list, String eventUser, String receiveRequestName) throws JsonMappingException, JsonProcessingException {
public String makeFGStockIn2(List<Map<String, Object>> list, String eventUser, String receiveRequestName,String commitDate) throws JsonMappingException, JsonProcessingException {
if (list == null || list.size() < 1) {
return "";
@ -755,7 +757,7 @@ public class ToSAPServiceImpl {
itemsData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData);
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData, commitDate);
return sendData;
}
//取消成品入库接口字段zd.2024.8.29
@ -804,7 +806,7 @@ public class ToSAPServiceImpl {
itemsData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData);
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
return sendData;
}
@ -1176,7 +1178,7 @@ public class ToSAPServiceImpl {
item.put("UMMAT_KDPOS", mm.get("SENDSALESORDERDETAILNO"));
itemData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
return sendData;
}
@ -1311,7 +1313,7 @@ public class ToSAPServiceImpl {
itemData.put("INSMK", "");
items.add(itemData);
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, items);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, items,TimeStampUtil.getCurrentTime("yyyyMMdd"));
return sendData;
}
@ -3824,7 +3826,7 @@ public class ToSAPServiceImpl {
}
//采购退货Z008 跨月新单据退货(Z001~Z007 原单据)
public String OrderStockBackOut(String shipRequestName, String siteName, String user) throws Exception {
public String OrderStockBackOut(String shipRequestName, String siteName, String user, String commitDate) throws Exception {
String rcode;
String undoId = "";
@ -3917,10 +3919,14 @@ public class ToSAPServiceImpl {
*/
body.put("ITEM", itemArray);
body.put("ITEMID", uniqueID);
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
Date date = inputFormat.parse(commitDate);
String outputDate = outputFormat.format(date);
//过账日期
body.put("BUDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("BUDAT", outputDate);
//凭证日期
body.put("BLDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("BLDAT", outputDate);
//凭证抬头文本
body.put("BKTXT", uniqueID);
//用户名
@ -4766,7 +4772,7 @@ public class ToSAPServiceImpl {
String aimFactory,
String aimERPlocation,
String aimLocationName,
String user) throws Exception {
String user, String commitDate) throws Exception {
String rcode;
String undoId = "";
String rmsg = null;
@ -4780,6 +4786,7 @@ public class ToSAPServiceImpl {
.append(" :AIMERPLOCATION AS UMLGO_RECIEVEERPLOCATION, ").append(SystemPropHelper.CR)
.append(" MP.MATERIALQUANTITY , ").append(SystemPropHelper.CR)
.append(" MP.UNIT, ").append(SystemPropHelper.CR)
.append(" MP.PACKINGGRADE, ").append(SystemPropHelper.CR)
.append(" :AIMLOCATIONNAME AS NULL_RECIVELOCAITONNAME ").append(SystemPropHelper.CR)
.append(" FROM ").append(SystemPropHelper.CR)
.append(" MATERIALPACKING MP ").append(SystemPropHelper.CR)
@ -4824,10 +4831,21 @@ public class ToSAPServiceImpl {
*/
body.put("ITEM", itemArray);
body.put("ITEMID", uniqueID);
String outputDate = "";
if(commitDate.isEmpty()) {
outputDate = TimeStampUtil.getCurrentTime("yyyyMMdd");
}else {
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
Date date = inputFormat.parse(commitDate);
outputDate = outputFormat.format(date);
}
//过账日期
body.put("BUDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("BUDAT", outputDate);
//凭证日期
body.put("BLDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("BLDAT", outputDate);
//凭证抬头文本
body.put("BKTXT", uniqueID);
//用户名
@ -4854,6 +4872,15 @@ public class ToSAPServiceImpl {
item.put("MEINS", mm.get("UNIT"));
//BWART 移动类型
item.put("BWART", "311");
String insmk = "";
if (StringUtils.isEmpty((String)mm.get("PACKINGGRADE"))) {
insmk = "2";
}
// String insmk = StringUtils.equals(mm.get("OQARESULTSTATE").toString(),"END")?"":"X";
item.put("INSMK", insmk);
item.put("BWART", "311");
// //ZLLORDER 自定义领料单号
// item.put("ZLLORDER", mm.get("SHIPREQUESTNAME"));
// //ZLLITEM 自定义领料单行号
@ -5152,7 +5179,7 @@ public class ToSAPServiceImpl {
itemsData.add(item);
}
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData);
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemsData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
return sendData;
}
@ -5360,7 +5387,7 @@ public class ToSAPServiceImpl {
//质检批如何判定 如果是质检批 INSMK 值为2
items.add(itemData);
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, items);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, items,TimeStampUtil.getCurrentTime("yyyyMMdd"));
return sendData;
}
@ -5446,7 +5473,7 @@ public class ToSAPServiceImpl {
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData);
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
@ -5545,7 +5572,7 @@ public class ToSAPServiceImpl {
}
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData);
String sendData = ToSAPMessageUtil.mm067(user, bodyData, itemData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData);
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
@ -5646,7 +5673,7 @@ public class ToSAPServiceImpl {
}
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemData);
String sendData = ToSAPMessageUtil.mm067(eventUser, bodyData, itemData,TimeStampUtil.getCurrentTime("yyyyMMdd"));
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl,"",sendData);
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);

View File

@ -21,10 +21,9 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
@Service(value = "ToSAPMessageUtil")
public class ToSAPMessageUtil {
@ -169,7 +168,26 @@ public class ToSAPMessageUtil {
* @param itemsData
* @return JSON消息字符串
*/
public static String mm067(String user, Map<String,?> bodyData, List<Map<String,Object>> itemsData){
public static String mm067(String user, Map<String,?> bodyData, List<Map<String,Object>> itemsData,String commitDate){
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);
@ -224,10 +242,12 @@ public class ToSAPMessageUtil {
*/
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",StringUtils.isEmpty((String)bodyData.get("BKTXT"))?uniqueID:bodyData.get("BKTXT"));
//用户名

View File

@ -376,10 +376,11 @@ public class PurchaseReturnController {
public AjaxResult completeShipRequest(@RequestBody JSONObject in ){
StockOutDto ms = JSON.toJavaObject(in, StockOutDto.class);
String shipRequestName = ms.getShipRequestName();
String commitDate = ms.getCommitDate();
String siteName = "SDK";
String user = ms.getUser();
try {
purchaseReturnService.completeReceiveRequest(siteName, user, shipRequestName);
purchaseReturnService.completeReceiveRequest(siteName, user, shipRequestName, commitDate);
} catch (Exception e) {
return AjaxResult.me().setErrorCode(500).setMessage(e.toString());
}

View File

@ -679,6 +679,26 @@ public class SAPToWMSController {
String zzywy = MapUtils.getString(item, "ZZYWY"); // 业务员
String zzywzl = MapUtils.getString(item, "ZZYWZL"); // 业务助理
String zzsyb = MapUtils.getString(item, "ZZSYB"); // 事业部
// 如果是采购退货的单据把相关行项对应的批次记录到单独的ORDERCHARGE表
if("Z008".equals(receiveRequestType)) {
String rtOrdersql ="SELECT * FROM ORDERCHARGE WHERE RECEIVEREQUESTNAME =:receiverequestname";
Map<String, Object> selectRTMap= new HashMap<String, Object>();
selectRTMap.put("receiverequestname", receiveRequestName);
List<Map<String, Object>> rtResultList = IDMFrameServiceProxy.getSqlTemplate().queryForList(rtOrdersql, selectRTMap);
if(rtResultList.size() > 0) {
String sql="DELETE FROM ORDERCHARGE WHERE RECEIVEREQUESTNAME=?";
Object[] obj=new Object[] {receiveRequestName};
IDMFrameServiceProxy.getSqlTemplate().update(sql, obj);
}
// String[] chargeList = new String[]{};
// chargeList = zwmscharg.split(";");
String rtSql="INSERT INTO ORDERCHARGE(RECEIVEREQUESTNAME, RECEIVEREQUESTDETAILNAME, CHARGELIST) VALUES(?,?,?)";
Object[] obj=new Object[] {receiveRequestName, receiveRequestDetailName, zwmscharg};
IDMFrameServiceProxy.getSqlTemplate().update(rtSql, obj);
}
if("X".equals(loekz)) {
String sql="DELETE FROM materialreceivedetail WHERE receiverequestname=? AND receiverequestdetailname=?";
Object[] obj=new Object[] {receiveRequestName, receiveRequestDetailName};

View File

@ -72,7 +72,7 @@ public class ERPLocationMoveNoInvoiceServiceImpl implements ERPLocationMoveNoInv
arrayList.add(materialPackingKey);
}
String billCode = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory, aimErpLocation, aimLOcationName, user);
String billCode = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory, aimErpLocation, aimLOcationName, user, "");
List<MaterialPackingKey> mpKeyList = new ArrayList<MaterialPackingKey> ();
SetEventInfo setEventInfo = new SetEventInfo();
for (MaterialPacking materialPacking : all) {
@ -169,7 +169,7 @@ public class ERPLocationMoveNoInvoiceServiceImpl implements ERPLocationMoveNoInv
}
String billCode = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory,
aimErpLocation, aimLOcationName, user );
aimErpLocation, aimLOcationName, user,timesString );
List<MaterialPackingKey> mpKeyList = new ArrayList<MaterialPackingKey> ();
SetEventInfo setEventInfo = new SetEventInfo();
for (MaterialPacking materialPacking : all) {

View File

@ -555,7 +555,7 @@ public class InvoiceServiceImpl implements InvoiceService {
else
{
billCode=ProductionStockOut_NEW(shipRequestName, "SDK", eventUser,materialPackingKeyList);
billCode=ProductionStockOut_NEW(shipRequestName, "SDK", eventUser,materialPackingKeyList,commitDate);
if (billCode.isEmpty()) {
throw new CustomException("SAP过账异常");
}
@ -595,7 +595,7 @@ public class InvoiceServiceImpl implements InvoiceService {
case "ZLF7":
case "ZLF8":
// billCode=toSAPService.saleStockOut_NEW(shipRequestName, "SDK", eventUser,materialPackingKeyList);
billCode=saleStockOut_NEW(shipRequestName, "SDK", eventUser,materialPackingKeyList);
billCode=saleStockOut_NEW(shipRequestName, "SDK", eventUser,materialPackingKeyList,commitDate);
untils.SaveUnDoInfo_ForSap(materialPackingKeyList, billCode, makeEventInfo);
break;
@ -2078,7 +2078,7 @@ public class InvoiceServiceImpl implements InvoiceService {
}
}
public String ProductionStockOut_NEW(String shipRequestName, String siteName, String user,List<String> boxList) throws Exception {
public String ProductionStockOut_NEW(String shipRequestName, String siteName, String user,List<String> boxList,String commitDate) throws Exception {
String rcode;
String undoId = "";
@ -2179,10 +2179,14 @@ public class InvoiceServiceImpl implements InvoiceService {
*/
body.put("ITEM", itemArray);
body.put("ITEMID", uniqueID);
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
Date date = inputFormat.parse(commitDate);
String outputDate = outputFormat.format(date);
//过账日期
body.put("BUDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("BUDAT", outputDate);
//凭证日期
body.put("BLDAT", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("BLDAT", outputDate);
//凭证抬头文本
body.put("BKTXT", uniqueID);
//用户名
@ -2419,7 +2423,7 @@ public class InvoiceServiceImpl implements InvoiceService {
}
//重写销售交货单过账zd.2024.8.14
public String saleStockOut_NEW(String shipRequestName, String siteName, String user,List<String> boxList) throws Exception {
public String saleStockOut_NEW(String shipRequestName, String siteName, String user,List<String> boxList,String commitDate) throws Exception {
String rcode;
String undoId = "";
String rmsg = null;
@ -2477,10 +2481,15 @@ public class InvoiceServiceImpl implements InvoiceService {
*/
//交货单号
body.put("VBELN", shipRequestName);
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
Date date = inputFormat.parse(commitDate);
String outputDate = outputFormat.format(date);
//实际过账日期
body.put("WADAT_IST", TimeStampUtil.getCurrentTime("yyyyMMdd"));//yyyyMMddhhmmss
body.put("WADAT_IST", outputDate);//yyyyMMddhhmmss
//发送日期
body.put("Z_SENDDATE", TimeStampUtil.getCurrentTime("yyyyMMdd"));
body.put("Z_SENDDATE", outputDate);
//操作类型过账
body.put("Z_OPTION", "1");

View File

@ -274,7 +274,7 @@ public class ProductIntoServiceImpl implements FGStockInService {
String aimErpLocation = boxList.get(0).getErpLocation();
String aimLOcationName = boxList.get(0).getLocationName();
String billCode = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory,
aimErpLocation, aimLOcationName, user );
aimErpLocation, aimLOcationName, user, "" );
}
/**
@ -327,7 +327,7 @@ public class ProductIntoServiceImpl implements FGStockInService {
String aimErpLocation = boxList.get(0).getErpLocation();
String aimLOcationName = boxList.get(0).getLocationName();
undoID = toSAPService.NoSourceChangeLocation(arrayList,aimErpFactory,
aimErpLocation, aimLOcationName, user );
aimErpLocation, aimLOcationName, user, commitDate);
//更新物料凭证和库存状态
toSapDao.updateLocationStockState(boxList, "Stocked", undoID,aimErpFactory,aimErpLocation,aimLOcationName,user);
}else {
@ -336,7 +336,7 @@ public class ProductIntoServiceImpl implements FGStockInService {
// String json = JSON.toJSONString(fgStockInInfo);
String json = JSON.toJSONString(fgStockInInfo);
undoID = toSAPService.FGStockInByManulIn(json, user,receiveRequestActNo);
undoID = toSAPService.FGStockInByManulIn(json, user,receiveRequestActNo,commitDate);
// String pc = "(";
// for (MaterialPacking materialPacking : boxList) {

View File

@ -19,6 +19,7 @@ public class PurchaseReturnServiceImpl implements PurchaseReturnService {
@Autowired
private PurchaseReturnServiceDao purchaseReturnServiceDao;
@Autowired
private ToSapDao toSapDao;
@Autowired
@ -87,7 +88,7 @@ public class PurchaseReturnServiceImpl implements PurchaseReturnService {
*/
@Override
@Transactional
public String completeReceiveRequest(String siteName, String user, String receiverequestname) throws Exception {
public String completeReceiveRequest(String siteName, String user, String receiverequestname, String commitDate) throws Exception {
//查找需要过账的采购退库信息
List<MaterialPacking> purchaseReturnBoxList = purchaseReturnServiceDao.getPurchaseReturnBoxList(siteName, receiverequestname);
// MaterialPacking的MaterialPackingName放入一个List<String>
@ -97,7 +98,7 @@ public class PurchaseReturnServiceImpl implements PurchaseReturnService {
}
//过账SAP
// String undoId = toSAPServiceImpl.orderStockOut(receiverequestname, siteName, user, purchaseReturnBoxListName);
String undoId = toSAPServiceImpl.OrderStockBackOut(receiverequestname, siteName, user);
String undoId = toSAPServiceImpl.OrderStockBackOut(receiverequestname, siteName, user,commitDate);
// String undoId = "111";
//更新库存状态
toSapDao.updateStockState(purchaseReturnBoxList, "StockOut", undoId, user);

View File

@ -813,7 +813,7 @@ public class ReturnStockIntoServiceImpl implements ReturnStockInService {
aimErpLocation = boxList.get(0).getErpLocation();
aimLOcationName = boxList.get(0).getLocationName();
billCode = ToSAPServiceImpl.NoSourceChangeLocation(arrayList,aimErpFactory,
aimErpLocation, aimLOcationName, eventUser );
aimErpLocation, aimLOcationName, eventUser, "");
if (billCode.length() == 0) {
throw new GlobalException("报送ERP失败,请联系IT处理");

View File

@ -15,5 +15,5 @@ public interface PurchaseReturnService {
public String getPurPackingInfo(String siteName, String user, String receiverequestname) throws Exception;
public String completeReceiveRequest(String siteName, String user, String receiverequestname) throws Exception;
public String completeReceiveRequest(String siteName, String user, String receiverequestname, String commitDate) throws Exception;
}