|
@@ -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");
|