Преглед изворни кода

材料出库,委外订单。采购订单调整

zengtx пре 3 година
родитељ
комит
37603ecd95

+ 94 - 80
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/MOMainController.java

@@ -71,91 +71,105 @@ public class MOMainController implements ApplicationContextAware {
             //委外订单调用时间
             String lasttimeSf = sf.format(lastTiem);
              //mo.cVenCode,ven.cVenName
-            String sql = "select top 1 mo.MOID as 'headerAttributeString6','903' as accId,mo.cState as 'poStatus',mo.cCode as 'poNum'," +
-                    "'SUBCONTRACTOR_PO' as 'poType','0085' as 'supplierNumber'" +
-                    ",'森鑫' as 'supplierName',ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone'" +
-                    ",mo.cMaker as 'buyerCode',mo.cVenPerson as 'customerContacts','' as 'customerContactsPhone','0.00' as 'totalAmount'," +
-                    "'0.00' as 'exTaxAmount', mo.cexch_name as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
-                    "mo.dDate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
-                    "'' as 'buyerCode',mo.cMaker as 'buyerName',mo.dCreateTime  as 'publishDate',0 as 'tenantId',0 as 'totalAmount','' as 'headerAttributeString1', '' as 'headerAttributeString2','' as 'headerAttributeString3','' as 'headerAttributeString4' " +
-                    " from OM_MOMain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
-                    "where ( mo.iVerifyStateNew = 2 or mo.cState = 2) and mo.cCode = 'SYM713-森鑫'  order by mo.dCreateTime desc";
+            for (String str : pkorgSplit) {
+                String pkorgStr = str;
+                String pkorgValue[] = pkorgStr.split(":");
+                String ac = pkorgValue[1];
+                if (pkorgValue[0].equals("one")) {
+                    String sql = "select top 1 mo.MOID as 'headerAttributeString6',mo.MOID as 'moId','903' as accId,mo.cState as 'poStatus',mo.cCode as 'poNum'," +
+                            "'SUBCONTRACTOR_PO' as 'poType','0085' as 'supplierNumber'" +
+                            ",'森鑫' as 'supplierName',ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone'" +
+                            ",mo.cMaker as 'buyerCode',mo.cVenPerson as 'customerContacts','' as 'customerContactsPhone','0.00' as 'totalAmount'," +
+                            "'0.00' as 'exTaxAmount', mo.cexch_name as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
+                            "mo.dDate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
+                            "'' as 'buyerCode',mo.cMaker as 'buyerName',mo.dCreateTime  as 'publishDate',0 as 'tenantId',0 as 'totalAmount','' as 'headerAttributeString1', '' as 'headerAttributeString2','' as 'headerAttributeString3','' as 'headerAttributeString4' " +
+                            " from OM_MOMain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
+                            "where ( mo.iVerifyStateNew = 2 or mo.cState = 2) and mo.cCode = 'SYM713-森鑫'  order by mo.dCreateTime desc";
 
 //            String sql1 = "select top 2 '903' as accId,MOID as MOID,cPersonCode as buyerCode,cexch_name as currencyCode,cVenPerson as customerContacts,'联系人电话' as customerContactsPhone,'123' as customerNumber,cVenAccount as headerAttributeString1," +
 //                    "'合同号' as headerAttributeString2,'0097' as headerAttributeString3,'' as headerAttributeString4,'3' as headerTaxRate,cCode as poNum,'01' as poType,'0085' as supplierNumber " +
 //                    " from OM_MOMain where iVerifyStateNew = 2 or cState = 2 order by dCreateTime desc";
 
-            List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
-            sumlist.addAll(list);
-            //转JSON且赋值
-            Gson userGson=new GsonBuilder().create();
-            result.put("payload", userGson.toJson(JsonChangeUtils.toMoMainJson(sumlist)));
-            log.info("查询到的数据:" + result);
-
-            //获取当前接口同步信息,对方接口地址
-            //拼接url
-            String url = resultList.get(0).getItemIp() + resultList.get(0).getItemUrl();
-            //调用doPost
-            InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
-            //处理返回信息
-            JSONObject informationJson = interfaceConnUtils.doPostToBearer(result, url, "委外订单接口-");
-
-//            JSONArray jsonArray = informationJson.getJSONArray("head");
-//            if (jsonArray.size() != 0) {
-//                //获取4个账套值
-//                String yi = "";
-//                String er = "";
-//                String san = "";
-//                String si = "";
-//                for (String str : pkorgSplit) {
-//                    String pkorgStr = str;
-//                    String pkorgValue[] = pkorgStr.split(":");
-//                    if (pkorgValue[0].equals("one")) {
-//                        yi = pkorgValue[1];
-//                    }
-//                    if (pkorgValue[0].equals("two")) {
-//                        er = pkorgValue[1];
-//                    }
-//                    if (pkorgValue[0].equals("three")) {
-//                        san = pkorgValue[1];
-//                    }
-//                    if (pkorgValue[0].equals("four")) {
-//                        si = pkorgValue[1];
-//                    }
-//                }
-//                //回写U8物料信息表是否同步成功字段
-//                Iterator<Object> it = jsonArray.iterator();
-//                while (it.hasNext()) {
-//                    JSONObject jo = (JSONObject) it.next();
-//                    //获取是否成功
-//                    String code = jo.getString("code");
-//                    //获取返回消息
-//                    String message = jo.getString("message");
-//                    //获取businessCode
-//                    String businessCode = jo.getString("businessCode");
-//                    String busSplit[] = businessCode.split("#");
-//                    //账套666
-//                    if (busSplit[1].equals(yi)) {
-//                        if (code.equals("S")) {
-//                            //普通采购回写
-//                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
-//                            sixdxpDataSourceOne.updatePomain(sql, "true," + message, busSplit[0]);
-//                            //订单委外
-//                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
-//                            sixdxpDataSourceOne.updateMomain(sql1, "true," + message, busSplit[0]);
-//                        } else {
-//                            //普通采购回写
-//                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
-//                            sixdxpDataSourceOne.updatePomain(sql, "false," + message, busSplit[0]);
-//                            //订单委外
-//                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
-//                            sixdxpDataSourceOne.updateMomain(sql1, "false," + message, busSplit[0]);
-//                        }
-//                    }
-//                    //账套012
-//
-//                }
-//            }
+                    List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
+                    for(Map<String, Object> map:list){
+                        sumlist.add(map);
+                    }
+                }else if(pkorgValue[0].equals("two")){
+
+                }
+            }
+            //循环集合,一条一条传
+            for(Map<String, Object> map:sumlist) {
+                //转JSON且赋值
+                Gson userGson = new GsonBuilder().create();
+                result.put("payload", userGson.toJson(JsonChangeUtils.toMoMainJson(map)));
+                log.info("查询到的数据:" + result);
+
+                //获取当前接口同步信息,对方接口地址
+                //拼接url
+                String url = resultList.get(0).getItemIp() + resultList.get(0).getItemUrl();
+                //调用doPost
+                InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
+                //处理返回信息
+                JSONObject informationJson = interfaceConnUtils.doPostToBearer(result, url, "委外订单接口-");
+
+            JSONArray jsonArray = informationJson.getJSONArray("head");
+            if (jsonArray.size() != 0) {
+                //获取4个账套值
+                String yi = "";
+                String er = "";
+                String san = "";
+                String si = "";
+                for (String str : pkorgSplit) {
+                    String pkorgStr = str;
+                    String pkorgValue[] = pkorgStr.split(":");
+                    if (pkorgValue[0].equals("one")) {
+                        yi = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("two")) {
+                        er = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("three")) {
+                        san = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("four")) {
+                        si = pkorgValue[1];
+                    }
+                }
+                //回写U8物料信息表是否同步成功字段
+                Iterator<Object> it = jsonArray.iterator();
+                while (it.hasNext()) {
+                    JSONObject jo = (JSONObject) it.next();
+                    //获取是否成功
+                    String code = jo.getString("code");
+                    //获取返回消息
+                    String message = jo.getString("message");
+                    //获取businessCode
+                    String businessCode = jo.getString("businessCode");
+                    String busSplit[] = businessCode.split("#");
+                    //账套666
+                    if (busSplit[1].equals(yi)) {
+                        if (code.equals("S")) {
+                            //普通采购回写
+                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
+                            senYuDataSourceOne.updateMOMain(sql, "true," + message, busSplit[0]);
+                            //订单委外
+                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
+                            senYuDataSourceOne.updateMOMain(sql1, "true," + message, busSplit[0]);
+                        } else {
+                            //普通采购回写
+                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
+                            senYuDataSourceOne.updateMOMain(sql, "false," + message, busSplit[0]);
+                            //订单委外
+                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
+                            senYuDataSourceOne.updateMOMain(sql1, "false," + message, busSplit[0]);
+                        }
+                    }
+                    //账套012
+
+                }
+            }
+            }
 
             //回写委外订单接口最后时间
             Date datetome = sf.parse(beginTime);

+ 85 - 83
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/POPomainController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.openApi.controller;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -23,11 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
+import java.util.*;
 
 
 @RestController
@@ -65,30 +62,40 @@ public class POPomainController implements ApplicationContextAware {
             SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             //委外订单调用时间
             String lasttimeSf = sf.format(lastTiem);
-
-//            String sql = "select top 1 '666' as cAccId,POID as 'POID',cPOID as cCode,cBusType as iOrderType,cVenCode,'1' as cVenName,'1' as cVenPerson,'1' as cVenTelephone," +
-//                    "cMaker,'1' as cPersonName,'1' as cPersonPhone,'1' as totalPurchasePrice,'1' as totalNetPrice," +
-//                    "cexch_name as cexchName,iTaxRate,dPODate as demandDate,'2022-01-01' as promiseDate,cMemo,'' as sourceDocNo," +
-//                    "'1' as createByCode,'' as createByCode,cmaketime as createTime,cVenAccount as itemNumber,cPOID as contractNo," +
-//                    "'' as upstreamSupplier,'' as downstreamSupplier  from PO_Pomain where iverifystateex = 2  order by dCreateTime desc";
-//ven.cVenName,mo.cVenCode
-//cAuditTime>'"+lasttimeSf+"' and mo.iverifystateex = 2
-             String sql = "select top 1 mo.POID as 'MOID','903' as accId,mo.cState as 'poStatus',mo.cPOID as 'poNum'," +
-                     "'STANDARD_PO' as 'poType', '0085' as 'supplierNumber'," +
-                     "'森鑫' as 'supplierName',ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone'," +
-                     "mo.cMaker as 'buyerCode',mo.cVenPerson as 'customerContacts','' as 'customerContactsPhone','0.00' as 'totalAmount'," +
-                     "'0.00' as 'exTotalAmount', mo.cexch_name as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
-                     "mo.dPODate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
-                     "'' as 'buyerCode',mo.cMaker as 'buyerName',mo.cmaketime  as 'publishDate','' as 'headerAttributeString1', '' as 'headerAttributeString2','' as 'headerAttributeString3','' as 'headerAttributeString4'  " +
-                     "from PO_Pomain mo " +
-                     "left join Vendor ven " +
-                     "on mo.cVenCode = ven.cVenCode where cPOID = 'SYE小周样1' order by mo.cAuditTime desc";
-            List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
-            sumlist.addAll(list);
+            for (String str : pkorgSplit) {
+                String pkorgStr = str;
+                String pkorgValue[] = pkorgStr.split(":");
+                String ac = pkorgValue[1];
+                if (pkorgValue[0].equals("one")) {
+                    //ven.cVenName,mo.cVenCode
+                    //cAuditTime>'"+lasttimeSf+"' and mo.iverifystateex = 2
+                    String sql = "select top 1 mo.POID as 'MOID','"+ac+"' as accId,mo.cState as 'poStatus',mo.cPOID as 'poNum'," +
+                            "'STANDARD_PO' as 'poType', '0085' as 'supplierNumber'," +
+                            "'森鑫' as 'supplierName',ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone'," +
+                            "mo.cMaker as 'buyerCode',mo.cVenPerson as 'customerContacts','' as 'customerContactsPhone','0.00' as 'totalAmount'," +
+                            "'0.00' as 'exTotalAmount', mo.cexch_name as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
+                            "mo.dPODate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
+                            "'' as 'buyerCode',mo.cMaker as 'buyerName',mo.cmaketime  as 'publishDate','' as 'headerAttributeString1', '' as 'headerAttributeString2','' as 'headerAttributeString3','' as 'headerAttributeString4'  " +
+                            "from PO_Pomain mo " +
+                            "left join Vendor ven " +
+                            "on mo.cVenCode = ven.cVenCode where cPOID = 'SYE小周样1' order by mo.cAuditTime desc";
+                    List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
+                    for(Map<String, Object> map:list){
+                        sumlist.add(map);
+                    }
+
+                }else if(pkorgValue[0].equals("two")){
+
+
+                }
+            }
+
+            //循环集合,一条一条传
+            for(Map<String, Object> map:sumlist){
             //转JSON且赋值
             //转JSON且赋值
             Gson userGson=new GsonBuilder().create();
-            result.put("payload", userGson.toJson(JsonChangeUtils.toPoMainJson(sumlist)));
+            result.put("payload", userGson.toJson(JsonChangeUtils.toPoMainJson(map)));
 
             log.info("查询到的数据:" + result);
 
@@ -100,63 +107,58 @@ public class POPomainController implements ApplicationContextAware {
             //处理返回信息
             JSONObject informationJson = interfaceConnUtils.doPostToBearer(result, url, "采购订单接口-");
 
-//            JSONArray jsonArray = informationJson.getJSONArray("head");
-//            if (jsonArray.size() != 0) {
-//                //获取4个账套值
-//                String yi = "";
-//                String er = "";
-//                String san = "";
-//                String si = "";
-//                for (String str : pkorgSplit) {
-//                    String pkorgStr = str;
-//                    String pkorgValue[] = pkorgStr.split(":");
-//                    if (pkorgValue[0].equals("one")) {
-//                        yi = pkorgValue[1];
-//                    }
-//                    if (pkorgValue[0].equals("two")) {
-//                        er = pkorgValue[1];
-//                    }
-//                    if (pkorgValue[0].equals("three")) {
-//                        san = pkorgValue[1];
-//                    }
-//                    if (pkorgValue[0].equals("four")) {
-//                        si = pkorgValue[1];
-//                    }
-//                }
-//                //回写U8物料信息表是否同步成功字段
-//                Iterator<Object> it = jsonArray.iterator();
-//                while (it.hasNext()) {
-//                    JSONObject jo = (JSONObject) it.next();
-//                    //获取是否成功
-//                    String code = jo.getString("code");
-//                    //获取返回消息
-//                    String message = jo.getString("message");
-//                    //获取businessCode
-//                    String businessCode = jo.getString("businessCode");
-//                    String busSplit[] = businessCode.split("#");
-//                    //账套666
-//                    if (busSplit[1].equals(yi)) {
-//                        if (code.equals("S")) {
-//                            //普通采购回写
-//                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
-//                            sixdxpDataSourceOne.updatePomain(sql, "true," + message, busSplit[0]);
-//                            //订单委外
-//                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
-//                            sixdxpDataSourceOne.updateMomain(sql1, "true," + message, busSplit[0]);
-//                        } else {
-//                            //普通采购回写
-//                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
-//                            sixdxpDataSourceOne.updatePomain(sql, "false," + message, busSplit[0]);
-//                            //订单委外
-//                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
-//                            sixdxpDataSourceOne.updateMomain(sql1, "false," + message, busSplit[0]);
-//                        }
-//                    }
-//                    //账套012
-//
-//                }
-//            }
-
+            JSONArray jsonArray = informationJson.getJSONArray("headers");
+            if (jsonArray.size() != 0) {
+                //获取4个账套值
+                String yi = "";
+                String er = "";
+                String san = "";
+                String si = "";
+                for (String str : pkorgSplit) {
+                    String pkorgStr = str;
+                    String pkorgValue[] = pkorgStr.split(":");
+                    if (pkorgValue[0].equals("one")) {
+                        yi = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("two")) {
+                        er = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("three")) {
+                        san = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("four")) {
+                        si = pkorgValue[1];
+                    }
+                }
+                //回写U8物料信息表是否同步成功字段
+                Iterator<Object> it = jsonArray.iterator();
+                while (it.hasNext()) {
+                    JSONObject jo = (JSONObject) it.next();
+                    //获取是否成功
+                    String code = jo.getString("code");
+                    //获取返回消息
+                    String message = jo.getString("message");
+                    //获取moId
+                    String moId = jo.getString("moId");
+                    //账套号
+                    String accId = jo.getString("accId");
+                    //账套666
+                    if (accId.equals(yi)) {
+                        if (code.equals("S")) {
+                            //普通采购回写
+                            String sql = "update PO_Pomain set cDefine10 = ? where POID = ?";
+                            senYuDataSourceOne.updatePOMain(sql, "true," + message, moId);
+                        } else {
+                            //普通采购回写
+                            String sql = "update PO_Pomain set cDefine10 = ? where POID = ?";
+                            senYuDataSourceOne.updatePOMain(sql, "false," + message, moId);
+                        }
+                    }
+                    //账套012
+
+                }
+            }
+            }
             //回写委外订单接口最后时间
             Date datetome = sf.parse(beginTime);
             dxpDataPlanService.updateLastTime(datetome,"senYu_poMain");

+ 28 - 34
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/PurchaseWarehousingController.java

@@ -171,41 +171,35 @@ public class PurchaseWarehousingController extends JeecgController<PurchaseWareh
   public Result saveBath(@RequestBody JSONArray json){
   	Result result=new Result();
 
-	  try {
-		  if(json!=null&&json.size()>0){
-              //账套1
-              List<Map<String,Object>> mapListOne=new ArrayList<>();
-              //账套2
-              List<Map<String,Object>> mapListTwo=new ArrayList<>();
-              //账套3
-              List<Map<String,Object>> mapListThree=new ArrayList<>();
-              for(int i=0;i<json.size();i++){
-                  //获取对象
-                  JSONObject jsonObject=json.getJSONObject(i);
-                  //获取账套
-                  String cAccId=jsonObject.get("cAccId").toString();
-                  //转map
-                  Map<String,Object> map=updateMap(jsonObject);
-                  if(cAccId.equals("101")){
-                      mapListOne.add(map);
-                  }else if(cAccId.equals("102")){
-                      mapListTwo.add(map);
-                  }else if(cAccId.equals("103")){
-                      mapListThree.add(map);
-                  }
-              }
-      //		purchaseWarehousingService.aa();
-      //		purchaseWarehousingService.bb();
-              purchaseWarehousingService.savaOne(mapListOne);
-      //		result.setResult(mapList);
-			  result.success("操作成功");
-          }
-	  } catch (Exception e) {
-		  e.printStackTrace();
-		  result.error500("操作失败:"+e.getMessage());
-	  }
+	if(json!=null&&json.size()>0){
+		//账套1
+		List<Map<String,Object>> mapListOne=new ArrayList<>();
+		//账套2
+		List<Map<String,Object>> mapListTwo=new ArrayList<>();
+		//账套3
+		List<Map<String,Object>> mapListThree=new ArrayList<>();
+		for(int i=0;i<json.size();i++){
+			//获取对象
+			JSONObject jsonObject=json.getJSONObject(i);
+			//获取账套
+			String cAccId=jsonObject.get("cAccId").toString();
+			//转map
+			Map<String,Object> map=updateMap(jsonObject);
+			if(cAccId.equals("101")){
+				mapListOne.add(map);
+			}else if(cAccId.equals("102")){
+				mapListTwo.add(map);
+			}else if(cAccId.equals("103")){
+				mapListThree.add(map);
+			}
+		}
+//		purchaseWarehousingService.aa();
+//		purchaseWarehousingService.bb();
+		purchaseWarehousingService.savaOne(mapListOne);
+//		result.setResult(mapList);
+	}
 
-	  return result;
+  	return result;
   }
 
   public Map<String,Object> updateMap(JSONObject jsonObject){

+ 170 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/RdrecordController.java

@@ -0,0 +1,170 @@
+package org.jeecg.modules.openApi.controller;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import lombok.extern.log4j.Log4j2;
+import org.jeecg.modules.openApi.entity.DxpDataPlan;
+import org.jeecg.modules.openApi.service.IDxpDataPlanService;
+import org.jeecg.modules.openApi.service.ISenYuDataSourceOne;
+import org.jeecg.modules.system.util.InterfaceConnUtils;
+import org.jeecg.modules.system.util.JsonChangeUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Log4j2
+@RestController
+@RequestMapping("/openApi/rdrecord")
+@Component
+public class RdrecordController implements ApplicationContextAware {
+
+    private static IDxpDataPlanService dxpDataPlanService;
+    //数据源one
+    private static ISenYuDataSourceOne senYuDataSourceOne;
+
+
+    @PostMapping(value = "/QueryRdrecord")
+    public JSONObject QueryRdrecord(String time) {
+        //传出JSON
+        JSONObject result = new JSONObject();
+        //定义集合
+        List<Map<String, Object>> sumlist = new ArrayList<>();
+        //记录定时任务开始时间
+        String beginTime = time;
+
+        try {
+
+            //查询IP及账套信息、时间戳
+            QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("code", "senYu_rdrecord");
+            Page<DxpDataPlan> page = new Page<DxpDataPlan>(1, 100);
+            IPage<DxpDataPlan> pageList = dxpDataPlanService.page(page, queryWrapper);
+            List<DxpDataPlan> resultList = pageList.getRecords();
+
+            String pkorg = resultList.get(0).getPkOrg();
+            String pkorgSplit[] = pkorg.split(",");
+            Date lastTiem = resultList.get(0).getLastTime();
+            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            //委外订单调用时间
+            String lasttimeSf = sf.format(lastTiem);
+            for (String str : pkorgSplit) {
+                String pkorgStr = str;
+                String pkorgValue[] = pkorgStr.split(":");
+                String ac = pkorgValue[1];
+                if (pkorgValue[0].equals("one")) {
+                    String sql = "select top 1 ID as ID,'903' as cAccId,ID as ID,cCode as cCode,cBusType as cBusType,iverifystate as cState," +
+                            "cVenCode as cVenCode,'903' as cCusCode,dDate as dDate,cWhCode as cWhCode,cMemo as cMemo " +
+                            " from rdrecord11";
+                    //            String sql1 = "select top 2 '903' as accId,MOID as MOID,cPersonCode as buyerCode,cexch_name as currencyCode,cVenPerson as customerContacts,'联系人电话' as customerContactsPhone,'123' as customerNumber,cVenAccount as headerAttributeString1," +
+                    //                    "'合同号' as headerAttributeString2,'0097' as headerAttributeString3,'' as headerAttributeString4,'3' as headerTaxRate,cCode as poNum,'01' as poType,'0085' as supplierNumber " +
+                    //                    " from OM_MOMain where iVerifyStateNew = 2 or cState = 2 order by dCreateTime desc";
+
+                    List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
+                    sumlist.addAll(list);
+                } else if (pkorgValue[0].equals("two")) {
+
+
+                }
+                //转JSON且赋值
+                Gson userGson = new GsonBuilder().create();
+                result.put("payload", userGson.toJson(JsonChangeUtils.toRdrecordJson(sumlist)));
+                log.info("查询到的数据:" + result);
+
+            }
+            //获取当前接口同步信息,对方接口地址
+            //拼接url
+            String url = resultList.get(0).getItemIp() + resultList.get(0).getItemUrl();
+            //调用doPost
+            InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
+            //处理返回信息
+            JSONObject informationJson = interfaceConnUtils.doPostToBearer(result, url, "委外订单接口-");
+
+            JSONArray jsonArray = informationJson.getJSONArray("head");
+            if (jsonArray.size() != 0) {
+                //获取4个账套值
+                String yi = "";
+                String er = "";
+                String san = "";
+                String si = "";
+                for (String str : pkorgSplit) {
+                    String pkorgStr = str;
+                    String pkorgValue[] = pkorgStr.split(":");
+                    if (pkorgValue[0].equals("one")) {
+                        yi = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("two")) {
+                        er = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("three")) {
+                        san = pkorgValue[1];
+                    }
+                    if (pkorgValue[0].equals("four")) {
+                        si = pkorgValue[1];
+                    }
+                }
+                //回写U8物料信息表是否同步成功字段
+                Iterator<Object> it = jsonArray.iterator();
+                while (it.hasNext()) {
+                    JSONObject jo = (JSONObject) it.next();
+                    //获取是否成功
+                    String code = jo.getString("code");
+                    //获取返回消息
+                    String message = jo.getString("message");
+                    //获取businessCode
+                    String businessCode = jo.getString("businessCode");
+                    String busSplit[] = businessCode.split("#");
+                    //账套666
+                    if (busSplit[1].equals(yi)) {
+                        if (code.equals("S")) {
+                            //普通采购回写
+                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
+                            senYuDataSourceOne.updateRdrecord(sql, "true," + message, busSplit[0]);
+                            //订单委外
+                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
+                            senYuDataSourceOne.updateRdrecord(sql1, "true," + message, busSplit[0]);
+                        } else {
+                            //普通采购回写
+                            String sql = "update PO_Pomain set cDefine12 = ? where cPOID = ?";
+                            senYuDataSourceOne.updateRdrecord(sql, "false," + message, busSplit[0]);
+                            //订单委外
+                            String sql1 = "update HY_MOMain set cDefine10 = ? where cCode = ?";
+                            senYuDataSourceOne.updateRdrecord(sql1, "false," + message, busSplit[0]);
+                        }
+                    }
+                    //账套012
+
+                }
+            }
+
+            //回写委外订单接口最后时间
+            Date datetome = sf.parse(beginTime);
+            dxpDataPlanService.updateLastTime(datetome,"senYu_rdrecord");
+
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.dxpDataPlanService = applicationContext.getBean(IDxpDataPlanService.class);
+        this.senYuDataSourceOne = applicationContext.getBean(ISenYuDataSourceOne.class);
+    }
+
+}

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/ISenYuDataSourceOne.java

@@ -19,4 +19,7 @@ public interface ISenYuDataSourceOne {
     //修改委外订单是否同步成功!
     public boolean updatePOMain(String sql,String cDefine10,String moId);
 
+    //修改材料出库单是否同步成功!
+    public boolean updateRdrecord(String sql,String cDefine10,String id);
+
 }

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/impl/SenYuDataSourceOneServiceImpl.java

@@ -79,4 +79,27 @@ public class SenYuDataSourceOneServiceImpl implements ISenYuDataSourceOne {
         return flag;
     }
 
+    /**
+     * 修改材料出库单是否同步成功!
+     * @param sql
+     * @param cDefine10
+     * @param id
+     * @return
+     */
+    @Override
+    public boolean updateRdrecord(String sql, String cDefine10, String id) {
+        // 定义返回结果
+        boolean flag = false;
+        try {
+            int i = jdbcTemplate.update(sql, cDefine10, id);
+            if (i > 0) {
+                flag = true;
+            }
+
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+        return flag;
+    }
+
 }

+ 19 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/JsonChangeUtils.java

@@ -33,13 +33,12 @@ public class JsonChangeUtils implements ApplicationContextAware{
      * @param result
      * @return
      */
-    public static List<JSONObject> toMoMainJson(List<Map<String, Object>> result) {
+    public static List<JSONObject> toMoMainJson(Map<String, Object> result) {
         List<JSONObject> pljf = new ArrayList<JSONObject>();// 表数据json集合
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
-       // String lasttimeSf = sf.format(lastTiem);
         JSONObject jf = new JSONObject();
-        for (int i = 0; i < result.size(); i++) {
-            Map<String, Object> map = result.get(i);
+       // for (int i = 0; i < result.size(); i++) {
+            Map<String, Object> map = result;//.get(i);
             Set<String> keys = map.keySet();
             jf = new JSONObject();
             for (String key : keys) {
@@ -65,12 +64,12 @@ public class JsonChangeUtils implements ApplicationContextAware{
 //                        "'56' as lineAttributeString3,'78' as lineAttributeString4,cbMemo as lineAttributeString5 " +
 //                        "from OM_MODetails where MOID = "+map.get("MOID");
                 //mo.cInvCode,inv.cInvName
-                String sql = "select mo.iVouchRowNo as 'poLineNum',mo.MODetailsID as MODetailsID,mo.MODetailsID as ' moDetailId','"+map.get("headerAttributeString6")+"' as MOID,'"+map.get("accId")+"' as 'accId'" +
+                String sql = "select mo.iVouchRowNo as 'poLineNum',mo.MODetailsID as MODetailsID,mo.MODetailsID as 'moDetailId','"+map.get("headerAttributeString6")+"' as MOID,'"+map.get("accId")+"' as 'accId'" +
                         ",'"+map.get("poNum")+"' as poNum,'N0201002142' as 'customerItemCode','35%棉65%涤 平纹汗布' as 'itemName','' as 'poLineStatus', " +
                         "mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2',mo.cFree3 as 'attributeValue3'," +
                         "mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2'," +
                         "'cfree3'  as 'attributeCode3','cfree4'  as 'attributeCode4'," +
-                        "mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode','"+map.get("customerDemandDate")+"' as 'customerDemandDate'," +
+                        "mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode','"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
                         "mo.iUnitPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount'," +
                         "mo.cDefine28 as 'lineAttributeString1',mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3'," +
                         "mo.cDefine30 as 'lineAttributeString4',mo.cbMemo as 'lineAttributeString5',cFree1 as 'color','' as 'customerNumber','' as externalLineNum," +
@@ -83,10 +82,11 @@ public class JsonChangeUtils implements ApplicationContextAware{
                 //子表转JSON
                 List<JSONObject> json = toMOListJson(list);
                 jf.put("poLineList",json);
-            }
+                jf.remove("MODetailsID");
+                jf.remove("MOID");
+            //}
+
 
-            jf.remove("MODetailsID");
-            jf.remove("MOID");
             pljf.add(jf);
         }
         return pljf;
@@ -97,12 +97,12 @@ public class JsonChangeUtils implements ApplicationContextAware{
      * @param result
      * @return
      */
-    public static List<JSONObject> toPoMainJson(List<Map<String, Object>> result) {
+    public static List<JSONObject> toPoMainJson(Map<String, Object> result) {
         List<JSONObject> pljf = new ArrayList<JSONObject>();// 表数据json集合
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
         JSONObject jf = new JSONObject();
-        for (int i = 0; i < result.size(); i++) {
-            Map<String, Object> map = result.get(i);
+        //for (int i = 0; i < result.size(); i++) {
+            Map<String, Object> map = result;//.get(i);
             Set<String> keys = map.keySet();
             jf = new JSONObject();
             for (String key : keys) {
@@ -127,7 +127,7 @@ public class JsonChangeUtils implements ApplicationContextAware{
                         "'' as 'poLineStatus',mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2'," +
                         "mo.cFree3 as 'attributeValue3',mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1'," +
                         "'cfree2'  as 'attributeCode2','cfree3'  as 'attributeCode3','cfree4'  as 'attributeCode4'," +
-                        "mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode','"+map.get("customerDemandDate")+"' as 'customerDemandDate'," +
+                        "mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode','"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
                         "mo.iUnitPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount'," +
                         "'' as 'lineAttributeString1','' as 'lineAttributeString2','' as 'lineAttributeString3','' as 'attributeString1'," +
                         "'' as 'lineAttributeString4','' as 'color','' as 'externalLineNum',0 as 'itemAttrId' " +
@@ -142,7 +142,7 @@ public class JsonChangeUtils implements ApplicationContextAware{
             }
 
             pljf.add(jf);
-        }
+        //}
         return pljf;
     }
 
@@ -221,6 +221,7 @@ public class JsonChangeUtils implements ApplicationContextAware{
      */
     public static List<JSONObject> toMOListJson(List<Map<String, Object>> result) {
         List<JSONObject> pljf = new ArrayList<JSONObject>();// 表数据json集合
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
         JSONObject jf = new JSONObject();
         for (int i = 0; i < result.size(); i++) {
             Map<String, Object> map = result.get(i);
@@ -233,6 +234,8 @@ public class JsonChangeUtils implements ApplicationContextAware{
                     jf.put(key, map.get(key));
                 }
             }
+            String customerPromiseDate = sf.format(map.get("customerPromiseDate"));
+            jf.put("customerPromiseDate",customerPromiseDate+" 00:00:00");
             //查询委外用料子表数据
             if(map.get("accId").equals("903")){
 //                String sql = "select '' as poOutsourceNum,''as poNum,'903' as cAccId,"+map.get("MOID")+" as MOID,'YU-02' as customerItemCode,'' as itemAttrId," +
@@ -253,7 +256,8 @@ public class JsonChangeUtils implements ApplicationContextAware{
                 List<JSONObject> json = toListJson(list);
                 jf.put("outSourceList",json);
             }
-
+            jf.remove("MODetailsID");
+            jf.remove("MOID");
             pljf.add(jf);
         }
         return pljf;