|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.dxhy.order.consumer.openapi.service.impl; |
|
|
|
package com.dxhy.order.consumer.openapi.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpRequest; |
|
|
|
|
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.dxhy.order.baseservice.module.base.service.BaseService; |
|
|
|
import com.dxhy.order.baseservice.module.base.service.BaseService; |
|
|
|
import com.dxhy.order.baseservice.module.buyer.dao.BuyerMapper; |
|
|
|
import com.dxhy.order.baseservice.module.buyer.dao.BuyerMapper; |
|
|
@ -13,17 +15,18 @@ import com.dxhy.order.consumer.openapi.protocol.AjaxResult; |
|
|
|
import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.*; |
|
|
|
import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.*; |
|
|
|
import com.dxhy.order.model.R; |
|
|
|
import com.dxhy.order.model.R; |
|
|
|
import com.dxhy.order.utils.DistributedKeyMaker; |
|
|
|
import com.dxhy.order.utils.DistributedKeyMaker; |
|
|
|
|
|
|
|
import com.dxhy.order.utils.HttpUtils; |
|
|
|
import com.dxhy.order.utils.JsonUtils; |
|
|
|
import com.dxhy.order.utils.JsonUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description |
|
|
|
* @Description |
|
|
@ -48,6 +51,26 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BaseService baseService; |
|
|
|
private BaseService baseService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 物料主动查询接口
|
|
|
|
|
|
|
|
@Value("${mdm.groupTaxCode.url}") |
|
|
|
|
|
|
|
private String groupTaxCodeUrl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 物料主动查询用户名
|
|
|
|
|
|
|
|
@Value("${mdm.groupTaxCode.usercode}") |
|
|
|
|
|
|
|
private String groupTaxCodeUsercode; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 物料主动查询密码
|
|
|
|
|
|
|
|
@Value("${mdm.groupTaxCode.password}") |
|
|
|
|
|
|
|
private String groupTaxCodePassword; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 客商主动查询接口
|
|
|
|
|
|
|
|
// @Value("${mdm.buyerUrl}")
|
|
|
|
|
|
|
|
// private String buyerUrl;
|
|
|
|
|
|
|
|
// // 人员主动查询接口
|
|
|
|
|
|
|
|
// @Value("${mdm.userUrl}")
|
|
|
|
|
|
|
|
// private String userUrl;
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public AjaxResult syncBuyerMessage(List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS, String requestBody) { |
|
|
|
public AjaxResult syncBuyerMessage(List<MdmGmfxxtbReqBO> mdmGmfxxtbReqBOS, String requestBody) { |
|
|
|
// 存表
|
|
|
|
// 存表
|
|
|
@ -243,4 +266,68 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
String resp = JsonUtils.getInstance().toJsonStringNullToEmpty(result); |
|
|
|
String resp = JsonUtils.getInstance().toJsonStringNullToEmpty(result); |
|
|
|
return AjaxResult.success("success", resp); |
|
|
|
return AjaxResult.success("success", resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 主动同步物料库 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R proactiveSyncMdmGroupTax(String code) { |
|
|
|
|
|
|
|
// 向mdm主动发送请求
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(groupTaxCodeUrl)) { |
|
|
|
|
|
|
|
return R.error("请配置物料主动查询地址"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String requestBody = " \n" + |
|
|
|
|
|
|
|
"{\n" + |
|
|
|
|
|
|
|
" \"ESB\":{\n" + |
|
|
|
|
|
|
|
" \"DATA\":{\n" + |
|
|
|
|
|
|
|
" \"DATAINFOS\":{\n" + |
|
|
|
|
|
|
|
" \"DATAINFO\":[\n" + |
|
|
|
|
|
|
|
" {\n" + |
|
|
|
|
|
|
|
" \"CODE\":\"" + code + "\"\n" + |
|
|
|
|
|
|
|
" }\n" + |
|
|
|
|
|
|
|
" ],\n" + |
|
|
|
|
|
|
|
" \"PUUID\":\"" + UUID.randomUUID().toString() + "\"\n" + |
|
|
|
|
|
|
|
" },\n" + |
|
|
|
|
|
|
|
" \"SPLITPAGE\":{\n" + |
|
|
|
|
|
|
|
" \"COUNTPERPAGE\":\"100\",\n" + |
|
|
|
|
|
|
|
" \"CURRENTPAGE\":\"1\"\n" + |
|
|
|
|
|
|
|
" }\n" + |
|
|
|
|
|
|
|
" }\n" + |
|
|
|
|
|
|
|
" }\n" + |
|
|
|
|
|
|
|
"}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 发送POST请求
|
|
|
|
|
|
|
|
HttpResponse response = HttpRequest.post(groupTaxCodeUrl) |
|
|
|
|
|
|
|
.timeout(20000) // 设置请求超时时间
|
|
|
|
|
|
|
|
.header("Content-Type", "application/json") |
|
|
|
|
|
|
|
.header("usercode", groupTaxCodeUsercode) |
|
|
|
|
|
|
|
.header("password", groupTaxCodePassword) |
|
|
|
|
|
|
|
.body(requestBody) // 设置请求体内容
|
|
|
|
|
|
|
|
.execute(); |
|
|
|
|
|
|
|
String resp = response.body(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SDEnergyMdmBaseBO baseBO = JSONObject.parseObject(resp, SDEnergyMdmBaseBO.class); |
|
|
|
|
|
|
|
List<MdmSyncGroupTaxCodeReqBO> mdmGmfxxtbReqBOS = (List<MdmSyncGroupTaxCodeReqBO>) Optional.of(baseBO) |
|
|
|
|
|
|
|
.map(SDEnergyMdmBaseBO::getESB) |
|
|
|
|
|
|
|
.map(ESBBO::getDATA) |
|
|
|
|
|
|
|
.map(DATABO::getDATAINFOS) |
|
|
|
|
|
|
|
.map(DATAINFOSBO::getDATAINFO) |
|
|
|
|
|
|
|
.map(i -> { |
|
|
|
|
|
|
|
// 转成List<MdmSyncGroupTaxCodeReqBO>
|
|
|
|
|
|
|
|
return i.stream().map(j -> { |
|
|
|
|
|
|
|
return JSONObject.parseObject(JSONObject.toJSONString(j), MdmSyncGroupTaxCodeReqBO.class); |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.orElse(new ArrayList<MdmSyncGroupTaxCodeReqBO>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AjaxResult syncResult = this.syncMdmGroupTax(mdmGmfxxtbReqBOS, resp); |
|
|
|
|
|
|
|
if (syncResult.isSuccess()) { |
|
|
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return R.error(syncResult.getMsg()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|