提交 a0121dcc authored 作者: 李炎's avatar 李炎

二改

上级 7276a45e
package com.santos.iost.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.santos.iost.dao.SoSsDao;
import com.santos.iost.dto.SoSsResponseDate;
import com.santos.iost.utils.HttpUtil;
import com.santos.iost.utils.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HeaderElement;
import org.apache.http.HeaderElementIterator;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeaderElementIterator;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.TextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.*;
//
//@SpringBootTest
//@Slf4j
//@RunWith(SpringJUnit4ClassRunner.class)
//@EnableScheduling
@RestController
//@RequestMapping("/api")
@Slf4j
class JintaiDomeApplicationTests {
String getTokenUrl = "http://123.58.109.39:86/K3API/Token/Create?authorityCode=606d25b51be50949e768241934225bc05bfd6db0bae63e82";
String getGetMaterialUrl = "http://123.58.109.39:86/K3API/Material/GetList?token=";
String includeDetailUrl = "http://123.58.109.39:86/K3API/SO/GetDetail?token=";
String token;
@Autowired
SoSsDao soSsDao;
public void sd() {
ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
HeaderElementIterator it = new BasicHeaderElementIterator
(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
HeaderElement he = it.nextElement();
String param = he.getName();
String value = he.getValue();
if (value != null && param.equalsIgnoreCase
("timeout")) {
return Long.parseLong(value) * 1000;
}
}
return 60 * 1000;//如果没有约定,则默认定义时长为60s
}
};
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(500);
connectionManager.setDefaultMaxPerRoute(50);//例如默认每路由最高50并发,具体依据业务来定
HttpClient httpClient = HttpClients.custom()
.setConnectionManager(connectionManager)
.setKeepAliveStrategy(myStrategy)
.setDefaultRequestConfig(RequestConfig.custom().setStaleConnectionCheckEnabled(true).build())
.build();
}
@GetMapping(value = "/test")
String contextLoads() throws Exception {
String s = HttpUtil.get(getTokenUrl);
Map map = JSON.parseObject(s, Map.class);
String D = map.get("Data").toString();
Map mapDate = JSON.parseObject(D, Map.class);
token = mapDate.get("Token").toString();
// System.out.println(token);
Map paramsMap = new HashMap();
Map Data = new LinkedHashMap();
Data.put("Top", "100");
Data.put("PageSize", "17");
Data.put("PageIndex", "1");
// Data.put("Filter","FNumber like '%003%' ");
Data.put("OrderBy", "FNumber asc");
Data.put("Fields", "FNumber,FName,F_101,FUnitID,FSalePrice");
paramsMap.put("Data", Data);
Map<String, String> hreader = new HashMap<>();
hreader.put("Content-Type", "application/json");
String post = HttpUtil.post(getGetMaterialUrl + token, JsonUtil.Mapjson(paramsMap), hreader);
// System.out.println(post);
return post;
}
}
...@@ -38,6 +38,7 @@ import java.util.*; ...@@ -38,6 +38,7 @@ import java.util.*;
* @Date: 2021-12-02 * @Date: 2021-12-02
* @Version: V1.0 * @Version: V1.0
*/ */
@CrossOrigin
@RestController @RestController
//@RequestMapping("/api") //@RequestMapping("/api")
@Slf4j @Slf4j
...@@ -45,7 +46,7 @@ public class WebApi { ...@@ -45,7 +46,7 @@ public class WebApi {
@Autowired @Autowired
SoSsMaterialService materialService; SoSsMaterialService materialService;
@Autowired @Autowired
SpSsSalesOrderService salesOrderService; SoSsSalesOrderService salesOrderService;
@Autowired @Autowired
SoSsSalesDeliveryService salesDeliveryService; SoSsSalesDeliveryService salesDeliveryService;
@Autowired @Autowired
...@@ -58,9 +59,10 @@ public class WebApi { ...@@ -58,9 +59,10 @@ public class WebApi {
SoSsInventoryService inventoryService; SoSsInventoryService inventoryService;
@ApiOperation(value = "查询通用接口", notes = "查询通用接口") @ApiOperation(value = "查询通用接口", notes = "查询通用接口")
@PostMapping(value = "/create") @PostMapping(value = "/create")
public Result<?> SetData(SoSsCreateVo soSsCreateVo) throws Exception { public Result<?> SetData(@RequestBody SoSsCreateVo soSsCreateVo) throws Exception {
Result result = new Result(); Result result = new Result();
try { try {
if (null == soSsCreateVo.getObjAPIName()) { if (null == soSsCreateVo.getObjAPIName()) {
......
...@@ -3,7 +3,7 @@ package com.santos.iost.service; ...@@ -3,7 +3,7 @@ package com.santos.iost.service;
import com.santos.iost.dto.Result; import com.santos.iost.dto.Result;
import com.santos.iost.vo.SoSsRequestVo; import com.santos.iost.vo.SoSsRequestVo;
public interface SpSsSalesOrderService { public interface SoSsSalesOrderService {
String apiName ="SO"; String apiName ="SO";
public Result getData(SoSsRequestVo soSsRequestVo); public Result getData(SoSsRequestVo soSsRequestVo);
} }
...@@ -20,7 +20,7 @@ public class SoSsCustomerServiceImpl implements SoSsCustomerService { ...@@ -20,7 +20,7 @@ public class SoSsCustomerServiceImpl implements SoSsCustomerService {
SoSsDao soSsDao; SoSsDao soSsDao;
String Url;//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token}) String Url;//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token})
String setData;
/** /**
* 请求字段 * 请求字段
*/ */
...@@ -35,21 +35,52 @@ public class SoSsCustomerServiceImpl implements SoSsCustomerService { ...@@ -35,21 +35,52 @@ public class SoSsCustomerServiceImpl implements SoSsCustomerService {
public SoSsCustomerServiceImpl() { public SoSsCustomerServiceImpl() {
this.Url = "/K3API/Customer/Save";//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token}) this.Url = "/K3API/Customer/Save";//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token})
this.setData = "{\n" +
" \"F_109\": {\n" +
" \"FID\": \"001\",\n" +
" \"FName\": \"月结客户\"\n" +
" },\n" +
" \"FIsCreditMgr\": false,\n" +
" \"FlastRPAmount\": 0,\n" +
" \"FlastTradeAmount\": 0,\n" +
" \"FmaxDealAmount\": 0,\n" +
" \"FminForeReceiveRate\": 0,\n" +
" \"FminReserverate\": 0,\n" +
" \"FSaleMode\": {\n" +
" \"FID\": \"SIN\",\n" +
" \"FName\": \"内销\"\n" +
" },\n" +
" \"FStatus\": {\n" +
" \"FID\": \"ZT01\",\n" +
" \"FName\": \"使用\"\n" +
" },\n" +
" \"FValueAddRate\": 0\n" +
" }";
} }
@Override @Override
public Result setData(SoSsCreateVo soSsRequestVo) throws Exception { public Result setData(SoSsCreateVo soSsRequestVo) throws Exception {
Map map = JSON.parseObject(setData, Map.class, Feature.OrderedField);//固定格式
Map params = new HashMap<>(); Map params = new HashMap<>();
Map<Object, Object> Data = new LinkedHashMap<>(); Map<Object, Object> Data = new LinkedHashMap<>();
Map masterFieldVal = soSsRequestVo.getMasterFieldVal(); Map masterFieldVal = soSsRequestVo.getMasterFieldVal();
// Map masterFieldVal = new HashMap();
Data.putAll(map);
Data.put(FNumber, masterFieldVal.get("ERPNumber")); Data.put(FNumber, masterFieldVal.get("ERPNumber"));
Data.put(FName, masterFieldVal.get("customerName")); Data.put(FName, masterFieldVal.get("customerName"));
Data.put(FAddress, masterFieldVal.get("detailedAddress")); Data.put(FAddress, masterFieldVal.get("detailedAddress"));
Data.put(FRegionID, new HashMap(){{put("FID",masterFieldVal.get("customerLevel"));}});//二级结构 Data.put(FRegionID, new HashMap() {{
put("FID", masterFieldVal.get("customerLevel"));
put("FName", masterFieldVal.get("customerLevel"));
}});//二级结构
Data.put(FContact, masterFieldVal.get("contacts")); Data.put(FContact, masterFieldVal.get("contacts"));
Data.put(FPhone, masterFieldVal.get("phone")); Data.put(FPhone, masterFieldVal.get("phone"));
Data.put(Femployee, new HashMap(){{put("FNumber",masterFieldVal.get("personCharge"));}});//二级结构 Data.put(Femployee, new HashMap() {{
put("FName", masterFieldVal.get("personCharge"));
put("FNumber", masterFieldVal.get("personCharge"));
}});//二级结构
params.put("Data", Data); params.put("Data", Data);
String s = soSsDao.setK3Api(Url, JsonUtil.Mapjson(params)); String s = soSsDao.setK3Api(Url, JsonUtil.Mapjson(params));
...@@ -62,7 +93,18 @@ public class SoSsCustomerServiceImpl implements SoSsCustomerService { ...@@ -62,7 +93,18 @@ public class SoSsCustomerServiceImpl implements SoSsCustomerService {
public Result changeResponse(SoSsResponseDate soSsRequestVo) { public Result changeResponse(SoSsResponseDate soSsRequestVo) {
Map<Object, Object> map = new HashMap<>(); Map<Object, Object> map = new HashMap<>();
Result result = new Result(); Result result = new Result();
try {//字段转换-变化soSsRequestVo的data参数格式 为CRM规定格式
List data = (List) soSsRequestVo.getData();
Object o = data.get(0);
Map dataMap = JSON.parseObject(o.toString(), Map.class);
Boolean fStatus = Boolean.parseBoolean(dataMap.get("FStatus").toString());
if (fStatus.equals(true)) {
map.put("masterDataId", dataMap.get("FItemID"));
soSsRequestVo.setData(map);
}
} catch (Exception e) {
e.printStackTrace();
}
//将ERP格式变换为CRM格式 //将ERP格式变换为CRM格式
......
...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
//客户 //客户
@Service @Service
public class SoSsMaterialServiceImpl implements SoSsMaterialService { public class SoSsMaterialServiceImpl implements SoSsMaterialService {
...@@ -35,7 +36,9 @@ public class SoSsMaterialServiceImpl implements SoSsMaterialService { ...@@ -35,7 +36,9 @@ public class SoSsMaterialServiceImpl implements SoSsMaterialService {
String FUnitID_FName = "FUnitID_FName"; String FUnitID_FName = "FUnitID_FName";
String FUnitID_FNumber = "FUnitID_FNumber"; String FUnitID_FNumber = "FUnitID_FNumber";
String F_116 = "F_116"; String F_116 = "F_116";
String F_117="F_117"; String F_116_FName = "F_116_FName";
String F_117 = "F_117";
String F_117_FName = "F_117_FName";
public SoSsMaterialServiceImpl() { public SoSsMaterialServiceImpl() {
this.Url = "/K3API/Material/GetList";//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token}) this.Url = "/K3API/Material/GetList";//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token})
...@@ -104,8 +107,8 @@ public class SoSsMaterialServiceImpl implements SoSsMaterialService { ...@@ -104,8 +107,8 @@ public class SoSsMaterialServiceImpl implements SoSsMaterialService {
masterFieldVal.put("remarks", listDateMap.get(F_101));//备注 masterFieldVal.put("remarks", listDateMap.get(F_101));//备注
masterFieldVal.put("company", listDateMap.get(FUnitID_FName));//单位 masterFieldVal.put("company", listDateMap.get(FUnitID_FName));//单位
masterFieldVal.put("standardPrice", listDateMap.get(FSalePrice));//标准价格 masterFieldVal.put("standardPrice", listDateMap.get(FSalePrice));//标准价格
masterFieldVal.put("classification", listDateMap.get(F_116));//分类 masterFieldVal.put("classification", listDateMap.get(F_116_FName));//分类
masterFieldVal.put("subspecies", listDateMap.get(F_117));//子种类 masterFieldVal.put("subspecies", listDateMap.get(F_117_FName));//子种类
masterField.put("masterFieldVal", masterFieldVal); masterField.put("masterFieldVal", masterFieldVal);
dataList.add(masterField); dataList.add(masterField);
} }
......
...@@ -29,6 +29,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService { ...@@ -29,6 +29,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService {
* K3金蝶方请求字段 * K3金蝶方请求字段
*/ */
String FCustomer = "FCustomer";//核算项目 String FCustomer = "FCustomer";//核算项目
String FCustomer_DSPName ="FCustomer_DSPName";//
String FAmountFor = "FAmountFor";//单据金额 String FAmountFor = "FAmountFor";//单据金额
String FDate = "FDate";//单据日期 String FDate = "FDate";//单据日期
String FBillNo = "FBillNo"; String FBillNo = "FBillNo";
...@@ -67,7 +68,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService { ...@@ -67,7 +68,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService {
public Map changeGeta(SoSsRequestVo soSsRequestVo) { public Map changeGeta(SoSsRequestVo soSsRequestVo) {
Map paramsMap = new HashMap(); Map paramsMap = new HashMap();
Map Data = new LinkedHashMap(); Map Data = new LinkedHashMap();
Data.put("Top", soSsRequestVo.getLimit());//返回行数 Data.put("Top", "100");//返回行数
Data.put("PageSize", soSsRequestVo.getLimit());//每页行数 Data.put("PageSize", soSsRequestVo.getLimit());//每页行数
Data.put("PageIndex", soSsRequestVo.getOffset());//第几页 Data.put("PageIndex", soSsRequestVo.getOffset());//第几页
if (checkFilter(soSsRequestVo)) { if (checkFilter(soSsRequestVo)) {
...@@ -102,7 +103,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService { ...@@ -102,7 +103,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FCustomer));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FCustomer_DSPName));//客户名称
masterFieldVal.put("MSBsTotalAmount", listDateMap.get(FAmountFor));//本次回款总金额 masterFieldVal.put("MSBsTotalAmount", listDateMap.get(FAmountFor));//本次回款总金额
masterFieldVal.put("MSBsDate", listDateMap.get(FDate));//回款日期 masterFieldVal.put("MSBsDate", listDateMap.get(FDate));//回款日期
masterField.put("masterFieldVal", masterFieldVal); masterField.put("masterFieldVal", masterFieldVal);
...@@ -118,7 +119,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService { ...@@ -118,7 +119,7 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FCustomer));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FCustomer_DSPName));//客户名称
masterFieldVal.put("MSBsTotalAmount", listDateMap.get(FAmountFor));//本次回款总金额 masterFieldVal.put("MSBsTotalAmount", listDateMap.get(FAmountFor));//本次回款总金额
masterFieldVal.put("MSBsDate", listDateMap.get(FDate));//回款日期 masterFieldVal.put("MSBsDate", listDateMap.get(FDate));//回款日期
masterField.put("masterFieldVal", masterFieldVal); masterField.put("masterFieldVal", masterFieldVal);
...@@ -139,13 +140,14 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService { ...@@ -139,13 +140,14 @@ public class SoSsReceiptServiceImpl implements SoSsReceiptService {
String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap)); String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap));
SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型 SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型
if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) { if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) {
Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);//转换数据类型 JSONObject fromObject = JSONObject.fromObject(soSsResponseDate.getData().toString());//转换数据类型
List list = JSON.parseObject(Data.get("Page3").toString(), List.class, Feature.OrderedField); // Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);//转换数据类型
List list = JSON.parseObject(fromObject.get("Page3").toString(), List.class, Feature.OrderedField);
int i = 1; int i = 1;
for (Object o : list) { for (Object o : list) {
Map listDateMap = JSON.parseObject(o.toString(), Map.class); Map listDateMap = JSON.parseObject(o.toString(), Map.class);
Map<String, Object> map = new LinkedHashMap(); Map<String, Object> map = new LinkedHashMap();
map.put("ERPUniCode", code+"_"+listDateMap.get("FIndex3"));
map.put("salesOrderNo", listDateMap.get(FEntryOrderNo));//销售订单编号 map.put("salesOrderNo", listDateMap.get(FEntryOrderNo));//销售订单编号
map.put("currentRemittanceAmount", listDateMap.get(FSettleAmountFor_3));//本次汇款金额 map.put("currentRemittanceAmount", listDateMap.get(FSettleAmountFor_3));//本次汇款金额
returnDate.put(apiName + i, new ArrayList<Map>() {{ returnDate.put(apiName + i, new ArrayList<Map>() {{
......
...@@ -28,6 +28,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService { ...@@ -28,6 +28,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService {
* K3金蝶方请求字段 * K3金蝶方请求字段
*/ */
String FSupplyID = "FSupplyID";//购货单位 String FSupplyID = "FSupplyID";//购货单位
String FSupplyID_DSPName ="FSupplyID_DSPName";
String FHeadSelfB0162 = "FHeadSelfB0162";//地址 String FHeadSelfB0162 = "FHeadSelfB0162";//地址
String FBillNo = "FBillNo";//编号 String FBillNo = "FBillNo";//编号
String Fdate = "Fdate";//日期 String Fdate = "Fdate";//日期
...@@ -74,7 +75,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService { ...@@ -74,7 +75,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService {
public Map changeGeta(SoSsRequestVo soSsRequestVo) { public Map changeGeta(SoSsRequestVo soSsRequestVo) {
Map paramsMap = new HashMap(); Map paramsMap = new HashMap();
Map Data = new LinkedHashMap(); Map Data = new LinkedHashMap();
Data.put("Top",soSsRequestVo.getLimit());//返回行数 Data.put("Top", "100");//返回行数
Data.put("PageSize", soSsRequestVo.getLimit());//每页行数 Data.put("PageSize", soSsRequestVo.getLimit());//每页行数
Data.put("PageIndex", soSsRequestVo.getOffset());//第几页 Data.put("PageIndex", soSsRequestVo.getOffset());//第几页
if (checkFilter(soSsRequestVo)) { if (checkFilter(soSsRequestVo)) {
...@@ -108,7 +109,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService { ...@@ -108,7 +109,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FSupplyID));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FSupplyID_DSPName));//客户名称
masterFieldVal.put("customerAddress", listDateMap.get(FHeadSelfB0162));//客户地址 masterFieldVal.put("customerAddress", listDateMap.get(FHeadSelfB0162));//客户地址
masterFieldVal.put("erpNumber", listDateMap.get(FBillNo));//erp编号 masterFieldVal.put("erpNumber", listDateMap.get(FBillNo));//erp编号
masterFieldVal.put("orderDate", listDateMap.get(Fdate));//下单日期 masterFieldVal.put("orderDate", listDateMap.get(Fdate));//下单日期
...@@ -128,7 +129,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService { ...@@ -128,7 +129,7 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FSupplyID));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FSupplyID_DSPName));//客户名称
masterFieldVal.put("customerAddress", listDateMap.get(FHeadSelfB0162));//客户地址 masterFieldVal.put("customerAddress", listDateMap.get(FHeadSelfB0162));//客户地址
masterFieldVal.put("erpNumber", listDateMap.get(FBillNo));//erp编号 masterFieldVal.put("erpNumber", listDateMap.get(FBillNo));//erp编号
masterFieldVal.put("orderDate", listDateMap.get(Fdate));//下单日期 masterFieldVal.put("orderDate", listDateMap.get(Fdate));//下单日期
...@@ -153,13 +154,17 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService { ...@@ -153,13 +154,17 @@ public class SoSsSalesDeliveryServiceImpl implements SoSsSalesDeliveryService {
String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap)); String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap));
SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型 SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型
if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) { if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) {
Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);//转换数据类型 JSONObject fromObject = JSONObject.fromObject(soSsResponseDate.getData().toString());//转换数据类型
List list = JSON.parseObject(Data.get("Page2").toString(), List.class, Feature.OrderedField); // Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);
List list = JSON.parseObject(fromObject.get("Page2").toString(), List.class, Feature.OrderedField);
int i = 1; int i = 1;
for (Object o : list) { for (Object o : list) {
// if (code.equals("1420200311111")){
// System.out.println(fromObject);
// }
Map listDateMap = JSON.parseObject(o.toString(), Map.class); Map listDateMap = JSON.parseObject(o.toString(), Map.class);
Map<String, Object> map = new LinkedHashMap(); Map<String, Object> map = new LinkedHashMap();
map.put("ERPUniCode", listDateMap.get("FDetailID2"));
map.put("productCode", JSONObject.fromObject(listDateMap.get(FItemID)).get("FNumber"));//产品编号 map.put("productCode", JSONObject.fromObject(listDateMap.get(FItemID)).get("FNumber"));//产品编号
map.put("productName", listDateMap.get(FItemName));//产品名称 map.put("productName", listDateMap.get(FItemName));//产品名称
map.put("chineseDescription", listDateMap.get(FEntrySelfB0164));//中文描述 map.put("chineseDescription", listDateMap.get(FEntrySelfB0164));//中文描述
......
...@@ -29,6 +29,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService { ...@@ -29,6 +29,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService {
* K3金蝶方请求字段 * K3金蝶方请求字段
*/ */
String FCustID = "FCustID";//购货单位 String FCustID = "FCustID";//购货单位
String FCustID_DSPName="FCustID_DSPName";
String SJKPRQ80 = "SJKPRQ80";//实际开票日期 String SJKPRQ80 = "SJKPRQ80";//实际开票日期
String Fdate = "Fdate";//日期 String Fdate = "Fdate";//日期
String FBillNo = "FBillNo";//FBillNo String FBillNo = "FBillNo";//FBillNo
...@@ -52,11 +53,13 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService { ...@@ -52,11 +53,13 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService {
public Result getData(SoSsRequestVo soSsRequestVo) { public Result getData(SoSsRequestVo soSsRequestVo) {
String s = new String(); String s = new String();
Map map = changeGeta(soSsRequestVo); Map map = changeGeta(soSsRequestVo);
System.out.println(map);
try { try {
s = soSsDao.requestK3Api(Url, JsonUtil.Mapjson(map)); s = soSsDao.requestK3Api(Url, JsonUtil.Mapjson(map));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println(s);
SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class, Feature.OrderedField);//转换数据类型 SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class, Feature.OrderedField);//转换数据类型
Result result = changeResponse(soSsResponseDate, soSsRequestVo);//转换返回的数据格式 Result result = changeResponse(soSsResponseDate, soSsRequestVo);//转换返回的数据格式
return result; return result;
...@@ -67,7 +70,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService { ...@@ -67,7 +70,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService {
public Map changeGeta(SoSsRequestVo soSsRequestVo) { public Map changeGeta(SoSsRequestVo soSsRequestVo) {
Map paramsMap = new HashMap(); Map paramsMap = new HashMap();
Map Data = new LinkedHashMap(); Map Data = new LinkedHashMap();
Data.put("Top", soSsRequestVo.getLimit());//返回行数 Data.put("Top", "100");//返回行数
Data.put("PageSize", soSsRequestVo.getLimit());//每页行数 Data.put("PageSize", soSsRequestVo.getLimit());//每页行数
Data.put("PageIndex", soSsRequestVo.getOffset());//第几页 Data.put("PageIndex", soSsRequestVo.getOffset());//第几页
if (checkFilter(soSsRequestVo)) { if (checkFilter(soSsRequestVo)) {
...@@ -101,7 +104,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService { ...@@ -101,7 +104,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FCustID));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FCustID_DSPName));//客户名称
masterFieldVal.put("billingDate", listDateMap.get(SJKPRQ80));//开票日期 masterFieldVal.put("billingDate", listDateMap.get(SJKPRQ80));//开票日期
// masterFieldVal.put("billingDate", listDateMap.get(Fdate));//开票日期 // masterFieldVal.put("billingDate", listDateMap.get(Fdate));//开票日期
masterFieldVal.put("invoiceNumber", listDateMap.get(FBillNo));//发票号码 masterFieldVal.put("invoiceNumber", listDateMap.get(FBillNo));//发票号码
...@@ -119,7 +122,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService { ...@@ -119,7 +122,7 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FCustID));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FCustID_DSPName));//客户名称
masterFieldVal.put("billingDate", listDateMap.get(SJKPRQ80));//开票日期 masterFieldVal.put("billingDate", listDateMap.get(SJKPRQ80));//开票日期
// masterFieldVal.put("billingDate", listDateMap.get(Fdate));//开票日期 // masterFieldVal.put("billingDate", listDateMap.get(Fdate));//开票日期
masterFieldVal.put("invoiceNumber", listDateMap.get(FBillNo));//发票号码 masterFieldVal.put("invoiceNumber", listDateMap.get(FBillNo));//发票号码
...@@ -143,13 +146,14 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService { ...@@ -143,13 +146,14 @@ public class SoSsSalesInvoiceServiceImpl implements SoSsSalesInvoiceService {
String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap)); String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap));
SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型 SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型
if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) { if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) {
Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);//转换数据类型 // Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);//转换数据类型
List list = JSON.parseObject(Data.get("Page2").toString(), List.class, Feature.OrderedField); JSONObject fromObject = JSONObject.fromObject(soSsResponseDate.getData().toString());//转换数据类型
List list = JSON.parseObject(fromObject.get("Page2").toString(), List.class, Feature.OrderedField);
int i = 1; int i = 1;
for (Object o : list) { for (Object o : list) {
Map listDateMap = JSON.parseObject(o.toString(), Map.class); Map listDateMap = JSON.parseObject(o.toString(), Map.class);
Map<String,Object> map = new LinkedHashMap(); Map<String,Object> map = new LinkedHashMap();
map.put("ERPUniCode", listDateMap.get("FDetailID2"));
map.put("productCode", JSONObject.fromObject(listDateMap.get(FItemID)).get("FNumber"));//产品编码 map.put("productCode", JSONObject.fromObject(listDateMap.get(FItemID)).get("FNumber"));//产品编码
map.put("quantity", listDateMap.get(Fauxqty));//数量 map.put("quantity", listDateMap.get(Fauxqty));//数量
map.put("salesUnitPrice", listDateMap.get(FAuxPriceDiscount));//销售单价 map.put("salesUnitPrice", listDateMap.get(FAuxPriceDiscount));//销售单价
......
...@@ -5,7 +5,7 @@ import com.alibaba.fastjson.parser.Feature; ...@@ -5,7 +5,7 @@ import com.alibaba.fastjson.parser.Feature;
import com.santos.iost.dao.SoSsDao; import com.santos.iost.dao.SoSsDao;
import com.santos.iost.dto.Result; import com.santos.iost.dto.Result;
import com.santos.iost.dto.SoSsResponseDate; import com.santos.iost.dto.SoSsResponseDate;
import com.santos.iost.service.SpSsSalesOrderService; import com.santos.iost.service.SoSsSalesOrderService;
import com.santos.iost.utils.JsonUtil; import com.santos.iost.utils.JsonUtil;
import com.santos.iost.utils.StringUtil; import com.santos.iost.utils.StringUtil;
import com.santos.iost.vo.SoSsRequestVo; import com.santos.iost.vo.SoSsRequestVo;
...@@ -14,9 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,9 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
//订单 //订单
@Service @Service
public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { public class SoSsSalesOrderServiceImpl implements SoSsSalesOrderService {
@Autowired @Autowired
SoSsDao soSsDao; SoSsDao soSsDao;
...@@ -28,6 +29,7 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { ...@@ -28,6 +29,7 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService {
* K3金蝶方请求字段 * K3金蝶方请求字段
*/ */
String FCustID = "FCustID";//客户名称 String FCustID = "FCustID";//客户名称
String FCustID_DSPName ="FCustID_DSPName";//
String FHeadSelfS0166 = "FHeadSelfS0166";//整单价税合计 String FHeadSelfS0166 = "FHeadSelfS0166";//整单价税合计
String FBillNo = "FBillNo";//编号 String FBillNo = "FBillNo";//编号
String FHeadSelfS0157 = "FHeadSelfS0157";//客户订单编号 String FHeadSelfS0157 = "FHeadSelfS0157";//客户订单编号
...@@ -44,9 +46,9 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { ...@@ -44,9 +46,9 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService {
String FEntrySelfS0163 = "FEntrySelfS0163";//中文描述 String FEntrySelfS0163 = "FEntrySelfS0163";//中文描述
String FUnitID = "FUnitID";//单位 String FUnitID = "FUnitID";//单位
String FAuxPriceDiscount = "FAuxPriceDiscount";//实际含税单价 String FAuxPriceDiscount = "FAuxPriceDiscount";//实际含税单价
String FAllAmount="FAllAmount";//价税合计 String FAllAmount = "FAllAmount";//价税合计
public SpSsSalesOrderServiceImpl() { public SoSsSalesOrderServiceImpl() {
this.Url = "/K3API/SO/GetList";//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token}) this.Url = "/K3API/SO/GetList";//拼接用请求地址-(http://127.0.0.1/K3API/Material/GetList?token=${token})
this.includeDetailUrl = "/K3API/SO/GetDetail"; this.includeDetailUrl = "/K3API/SO/GetDetail";
this.fields = "FHeadSelfS0166,FHeadSelfS0157,Fdate";//需要查询出的字段 this.fields = "FHeadSelfS0166,FHeadSelfS0157,Fdate";//需要查询出的字段
...@@ -105,7 +107,7 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { ...@@ -105,7 +107,7 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FCustID));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FCustID_DSPName));//客户名称
masterFieldVal.put("salesOrderAmount", listDateMap.get(FHeadSelfS0166));//销售订单金额 masterFieldVal.put("salesOrderAmount", listDateMap.get(FHeadSelfS0166));//销售订单金额
masterFieldVal.put("erpSystemNumber", listDateMap.get(FBillNo));//erp系统编号 masterFieldVal.put("erpSystemNumber", listDateMap.get(FBillNo));//erp系统编号
masterFieldVal.put("customerOrderNumber", listDateMap.get(FHeadSelfS0157));//客户订单编号 masterFieldVal.put("customerOrderNumber", listDateMap.get(FHeadSelfS0157));//客户订单编号
...@@ -122,7 +124,7 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { ...@@ -122,7 +124,7 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService {
Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField); Map listDateMap = JSON.parseObject(o.toString(), Map.class, Feature.OrderedField);
Map masterField = new LinkedHashMap<>(); Map masterField = new LinkedHashMap<>();
Map masterFieldVal = new LinkedHashMap<>(); Map masterFieldVal = new LinkedHashMap<>();
masterFieldVal.put("customerName", listDateMap.get(FCustID));//客户名称 masterFieldVal.put("customerName", listDateMap.get(FCustID_DSPName));//客户名称
masterFieldVal.put("salesOrderAmount", listDateMap.get(FHeadSelfS0166));//销售订单金额 masterFieldVal.put("salesOrderAmount", listDateMap.get(FHeadSelfS0166));//销售订单金额
masterFieldVal.put("erpSystemNumber", listDateMap.get(FBillNo));//erp系统编号 masterFieldVal.put("erpSystemNumber", listDateMap.get(FBillNo));//erp系统编号
masterFieldVal.put("customerOrderNumber", listDateMap.get(FHeadSelfS0157));//客户订单编号 masterFieldVal.put("customerOrderNumber", listDateMap.get(FHeadSelfS0157));//客户订单编号
...@@ -145,13 +147,13 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { ...@@ -145,13 +147,13 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService {
String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap)); String s = soSsDao.requestK3ApiDetail(includeDetailUrl, JsonUtil.Mapjson(paramsMap));
SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型 SoSsResponseDate soSsResponseDate = JSON.parseObject(s, SoSsResponseDate.class);//转换数据类型
if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) { if (null != soSsResponseDate.getStatusCode() && soSsResponseDate.getStatusCode().equals("200")) {
Map Data = JSON.parseObject(soSsResponseDate.getData().toString(), Map.class);//转换数据类型 JSONObject fromObject = JSONObject.fromObject(soSsResponseDate.getData().toString());//转换数据类型
List list = JSON.parseObject(Data.get("Page2").toString(), List.class, Feature.OrderedField); List list = JSON.parseObject(fromObject.get("Page2").toString(), List.class, Feature.OrderedField);
int i = 1; int i = 1;
for (Object o : list) { for (Object o : list) {
Map listDateMap = JSON.parseObject(o.toString(), Map.class); Map listDateMap = JSON.parseObject(o.toString(), Map.class);
Map<String,Object> map = new LinkedHashMap(); Map<String, Object> map = new LinkedHashMap();
map.put("ERPUniCode", listDateMap.get("FDetailID2"));
map.put("productNumber", JSONObject.fromObject(listDateMap.get(FItemID)).get("FNumber"));//产品编号 map.put("productNumber", JSONObject.fromObject(listDateMap.get(FItemID)).get("FNumber"));//产品编号
map.put("quantity", listDateMap.get(Fauxqty));//数量 map.put("quantity", listDateMap.get(Fauxqty));//数量
map.put("transportTypeNumber", JSONObject.fromObject(listDateMap.get(FEntrySelfS0170)).get("FNumber"));//运输方式 map.put("transportTypeNumber", JSONObject.fromObject(listDateMap.get(FEntrySelfS0170)).get("FNumber"));//运输方式
...@@ -160,16 +162,16 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService { ...@@ -160,16 +162,16 @@ public class SpSsSalesOrderServiceImpl implements SpSsSalesOrderService {
map.put("chineseDescription", listDateMap.get(FEntrySelfS0163));//中文描述 map.put("chineseDescription", listDateMap.get(FEntrySelfS0163));//中文描述
map.put("companyNumber", JSONObject.fromObject(listDateMap.get(FUnitID)).get("FName"));//单位 map.put("companyNumber", JSONObject.fromObject(listDateMap.get(FUnitID)).get("FName"));//单位
map.put("actualUnitPriceIncludingTax", listDateMap.get(FAuxPriceDiscount));//实际含税单价 map.put("actualUnitPriceIncludingTax", listDateMap.get(FAuxPriceDiscount));//实际含税单价
map.put("totalPriceAndTax",listDateMap.get(FAllAmount));//价税合计 map.put("totalPriceAndTax", listDateMap.get(FAllAmount));//价税合计
returnDate.put(apiName + i, new ArrayList<Map>() {{ returnDate.put(apiName + i, new ArrayList<Map>() {{
add(map); add(map);
}}); }});
i++; i++;
} }
} else { } else {
Map<String,Object> map = new LinkedHashMap(); Map<String, Object> map = new LinkedHashMap();
map.put("message",soSsResponseDate.getMessage()); map.put("message", soSsResponseDate.getMessage());
map.put("data",soSsResponseDate.getData()); map.put("data", soSsResponseDate.getData());
returnDate.put("error", new ArrayList<Map>() {{ returnDate.put("error", new ArrayList<Map>() {{
add(map); add(map);
}}); }});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论