Merge remote-tracking branch 'origin/wansheng' into wansheng

This commit is contained in:
yuqh 2025-04-17 08:42:35 +08:00
commit 71e82ff166
2 changed files with 224 additions and 125 deletions

View File

@ -12,9 +12,9 @@ import com.hzya.frame.plugin.wscustomersynchronizationevent.entity.WsCustomerSyn
import com.hzya.frame.plugin.wscustomersynchronizationevent.service.IWsCustomerSynchronizationEventService;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.sun.org.apache.xerces.internal.dom.DeferredEntityReferenceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.Map;
/***
@ -26,7 +26,9 @@ import java.util.Map;
* @return
**/
public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCustomerSynchronizationEventEntity, String> implements IWsCustomerSynchronizationEventService {
//定义两个环境属性根据环境绑定OA参数
private final String TEST = "TEST";
private final String DEV = "DEV";
private IWsCustomerSynchronizationEventDao wsCustomerSynchronizationEventDao;
@Autowired
@ -69,7 +71,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
private JsonResultEntity validateCustomerName(JSONObject data) {
JSONObject formBean = data.getJSONObject("formmain_4389");
//客商名称
String field0006 = formBean.getString("field0006");
String field0006 = formBean.getString("field0006").trim();
//纳税人登记号
String field0007 = formBean.getString("field0007");
JSONObject requestJson = new JSONObject();
@ -87,7 +89,11 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
return BaseResult.getFailureMessageEntity("客商名称重复!");
} else {
requestJson = new JSONObject();
requestJson.put("taxpayer",field0007);
if(null != field0007 && !"".equals(field0007)){
if(field0007.trim().length()>18){
return BaseResult.getFailureMessageEntity("纳税人识别号不允许超过18位");
}
requestJson.put("taxpayer", field0007.trim());
body = requestApi("validateCustomerName", requestJson, "800054", "8000540095", null);
req = JSON.parseObject(body);
flag = req.getBoolean("flag");
@ -108,6 +114,9 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
} else {
return BaseResult.getFailureMessageEntity("转发失败!" + req.getString("msg"));
}
}else{
return BaseResult.getSuccessMessageEntity("纳税人识别号为空,不校验!");
}
}
} else {
return BaseResult.getFailureMessageEntity("转发失败!");
@ -118,9 +127,6 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
}
}
@ -140,7 +146,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
//纳税人登记号
String field0007 = formBean.getString("field0007");
//绑定客商参数
JSONObject requestJson = bindMerchantParameters(data);
JSONObject requestJson = bindMerchantParameters(data, DEV);
String apiCode = "8000540093";
String body = requestApi("optionCustomerSynchronization客商新增", requestJson, "800054", apiCode, null);
JSONObject req = JSON.parseObject(body);
@ -155,7 +161,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
pk_cubasdoc = returnData.getJSONObject(0).getJSONObject("parentvo").getString("pk_cubasdoc");
String custcode = returnData.getJSONObject(0).getJSONObject("parentvo").getString("custcode");
//执行客商档案编码回传OA
updateCustomerCode(formBean.getString("id"),custcode);
updateCustomerCode(formBean.getString("id"), custcode,DEV);
}
logger.info("客商新增成功!返回数据", body);
@ -166,7 +172,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
return BaseResult.getFailureMessageEntity("转发失败!" + req.getJSONObject("attribute").getString("errormsg"));
}
//绑定客商分配参数
requestJson = bindMerchantDefineParameters(data,pk_cubasdoc);
requestJson = bindMerchantDefineParameters(data, pk_cubasdoc,DEV);
body = requestApi("optionCustomerSynchronization客商分配", requestJson, "800054", "8000540094", null);
req = JSON.parseObject(body);
flag = req.getBoolean("flag");
@ -193,15 +199,25 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* @param
* @return com.alibaba.fastjson.JSONObject
**/
private JSONObject updateCustomerCode(String id,String custcode) {
private JSONObject updateCustomerCode(String id, String custcode,String environment ) {
String sql = "update formmain_4389 set field0005 = '" + custcode + "' where id = " + id;
String md5 = SecureUtil.md5(sql);
System.out.println("明文摘要" + md5);
String key = "`o7eotan9ws8c:aj";
String encrypt = SecureUtil.aes(key.getBytes()).encryptHex(sql);
JSONObject requestJson = new JSONObject();
requestJson.put("userName", "hzya_rest");
/** 生产环境和测试环境字段不一致,根据环境切换绑定*/
String pk_currtype = null;
if(DEV.equals(environment)){
//所属地区编码
requestJson.put("password", "1742a2f4-6cc2-44cd-af75-d67c885b4dc1");
// requestJson.put("password", "2d6dd7fb-239a-4a0b-8c0a-5003647e9238");
}else{
requestJson.put("password", "45562434-8459-47b4-8df0-78fad8405bc4");
}
requestJson.put("data", encrypt);
requestJson.put("sign", md5);
String tokenRest = requestApi("获取token", requestJson, "800055", "8000550010", null);
@ -222,17 +238,27 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* @param pk_cubasdoc
* @return com.alibaba.fastjson.JSONObject
**/
private JSONObject bindMerchantDefineParameters(JSONObject data, String pk_cubasdoc) {
private JSONObject bindMerchantDefineParameters(JSONObject data, String pk_cubasdoc,String environment) {
JSONObject formBean = data.getJSONObject("formmain_4389");
JSONObject returnData = new JSONObject();
JSONArray custbasvo = new JSONArray();
//客商档案
JSONObject customer = new JSONObject();
if(DEV.equals(environment)){
//分配公司
customer.put("pk_corp", formBean.getString("field0058"));
//币种类别
String pk_currtype = formBean.getString("field0057");
customer.put("pk_currtype1",pk_currtype);
customer.put("pk_currtype1", formBean.getString("field0062"));
}else{
//分配公司
customer.put("pk_corp", formBean.getString("field0064"));
//币种类别
customer.put("pk_currtype1", formBean.getString("field0057"));
}
String custprop = formBean.getString("field0027");
//客商属性 0客户1供应商2 客商
switch (custprop) {
@ -255,6 +281,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
customer.put("custprop", custprop);
//客商ID
customer.put("pk_cubasdoc", pk_cubasdoc);
customer.put("creator", "admin");
custbasvo.add(customer);
returnData.put("custbasvo", custbasvo);
return returnData;
@ -279,7 +306,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
if (null != token) {
headerMap.put("token", token);
}
String body = HttpRequest.post("http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(requestJson.toJSONString()).timeout(60000).execute().body();
String body = HttpRequest.post("http://127.0.0.1:10085/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(requestJson.toJSONString()).timeout(60000).execute().body();
logger.info("中台转发到ESB" + method + ":{}", body);
return body;
}
@ -292,7 +319,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* @param
* @return com.alibaba.fastjson.JSONObject
**/
private JSONObject bindMerchantParameters(JSONObject data) {
private JSONObject bindMerchantParameters(JSONObject data,String environment) {
JSONObject formBean = data.getJSONObject("formmain_4389");
JSONObject returnData = new JSONObject();
JSONArray cbdocvo = new JSONArray();
@ -300,9 +327,28 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
JSONObject customer = new JSONObject();
JSONArray banks = new JSONArray();
JSONObject bank = new JSONObject();
JSONObject parentvo = new JSONObject();
bank.put("accaddr", "银行地址");
String accountproperty = formBean.getString("field0042");
/** 生产环境和测试环境字段不一致,根据环境切换绑定*/
String pk_currtype = null;
if(DEV.equals(environment)){
//所属地区编码
parentvo.put("pk_areacl", formBean.getString("field0060"));
//币种类别
pk_currtype = formBean.getString("field0062");
//银行类别
bank.put("banktypename", formBean.getString("field0064"));
}else{
//所属地区编码
parentvo.put("pk_areacl", formBean.getString("field0062"));
//币种类别
pk_currtype = formBean.getString("field0057");
//银行类别 TODO 修改为取编码
bank.put("banktypename", formBean.getString("field0036"));
}
//账户属性
String accountproperty = formBean.getString("field0042")== null?"":formBean.getString("field0042");
switch (accountproperty) {
case "-3164025096780690930":
accountproperty = "电汇账户";
@ -325,26 +371,25 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
bank.put("accountname", formBean.getString("field0012"));
bank.put("defflag", "Y");
bank.put("memo", formBean.getString("field0054"));
//开户银行
bank.put("pk_bankdoc", formBean.getString("field0013"));
//银行类别 TODO 修改为取编码
// bank.put("banktypename", formBean.getString("field0014"));
bank.put("banktypename", formBean.getString("field0036"));
//开户银行 传递以后名称
bank.put("accname", formBean.getString("field0013"));
// bank.put("pk_bankdoc", formBean.getString("field0013"));
//新增固定传递集团
bank.put("pk_corp", formBean.getString("0001"));
//币种类别
String pk_currtype = formBean.getString("field0057");
bank.put("pk_currtype", pk_currtype);
banks.add(bank);
JSONObject parentvo = new JSONObject();
//创建人 TODO 修改为取编码
//创建人 U8C 制单人 admin
// parentvo.put("creator",formBean.getString("field0019"));
parentvo.put("creator","20200124");
parentvo.put("creator", "admin");
//客商名称
parentvo.put("custname",formBean.getString("field0006"));
parentvo.put("custname", formBean.getString("field0006").trim());
//客商类型0 - 外部单位1 - 内部核算单位2 - 内部法人单位3 - 内部渠道成员
String custprop = formBean.getString("field0026");
String custprop = formBean.getString("field0026")== null?"":formBean.getString("field0026");
switch (custprop) {
case "-5116388890160378443":
custprop = "0";
@ -367,7 +412,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
//客商简称
parentvo.put("custshortname", formBean.getString("field0001"));
//销售方式
String def1 = formBean.getString("field0024");
String def1 = formBean.getString("field0024")== null?"":formBean.getString("field0024");
switch (def1) {
case "-285414580163689148":
@ -383,6 +428,59 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
//销售方式
parentvo.put("def1", def1);
// 运输 自定义项8 001 002
String def8 = formBean.getString("field0048")== null?"":formBean.getString("field0048");
switch (def8) {
case "-8661769604040273924":
def8 = "001";
break;
case "-5350125814390239390":
def8 = "002";
break;
default:
def8 = null;
break;
}
parentvo.put("def8", def8);
//货代 自定义项7 001 002
String def7 = formBean.getString("field0050") == null?"":formBean.getString("field0050");
switch (def7) {
case "-8661769604040273924":
def7 = "001";
break;
case "-5350125814390239390":
def7 = "002";
break;
default:
def7 = null;
break;
}
parentvo.put("def7", def7);
//供应商类型 自定义项9 01 生产商 02 贸易商 03 服务商
String def9 = formBean.getString("field0065") == null?"":formBean.getString("field0065");
switch (def9) {
case "4599320723300108944":
def9 = "01";
break;
case "-2027733563790049244":
def9 = "02";
break;
case "-2468198780444524154":
def9 = "03";
break;
default:
def9 = null;
break;
}
parentvo.put("def9", def9 );
//邮箱
parentvo.put("email", formBean.getString("field0052"));
//联系人1
@ -392,8 +490,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
parentvo.put("conaddr", formBean.getString("field0038"));
//电话1 电话手机
parentvo.put("phone1", formBean.getString("field0008"));
//所属地区编码 TODO 修改为取编码
parentvo.put("pk_areacl",formBean.getString("field0062"));
//总公司名称 TODO 修改为取编码
parentvo.put("pk_cubasdoc1", formBean.getString("field0034"));
//纳税人识别号
@ -405,6 +502,4 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
return returnData;
}
}

View File

@ -545,6 +545,10 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
// logger.info("调用中台返回的参数:{}",body);
// return body;
}
}else{
// StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)
logger.info("jsonStr,formAppId,eventType为空执行错误"+jsonStr+formAppId+eventType);
throw new BaseSystemException("jsonStr,formAppId,eventType为空执行错误");
}
return null;
}