调整客商档案传递开户行名称

This commit is contained in:
476474485@qq.com 2025-03-21 09:51:33 +08:00
parent 72ca4731ea
commit 916a9b9e25
1 changed files with 131 additions and 116 deletions

View File

@ -12,21 +12,23 @@ 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;
/***
* 万盛客商档案同步插件
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-03 10:56
* @date 2025-03-03 10:56
* @param
* @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
@ -37,90 +39,87 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
@Override
public JsonResultEntity customerSynchronization(JSONObject requestJson) {
JSONObject reqJson = new JSONObject();
JSONObject reqJson = new JSONObject();
JSONObject jsonStr = requestJson.getJSONObject("jsonStr");
JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr");
String formAppId = requestJson.getString("formAppId");
String eventType = requestJson.getString("eventType");
switch (eventType){
switch (eventType) {
case "onBeforeStart":
//发起前事件验证供应商重复
return validateCustomerName( businessDataStr);
return validateCustomerName(businessDataStr);
case "onBeforeFinishWorkitem":
//发起前事件OA插件错误,临时配置事件
return validateCustomerName( businessDataStr);
return validateCustomerName(businessDataStr);
case "onProcessFinished":
//流程结束事件同步客商到U8C
return optionCustomerSynchronization(businessDataStr);
return optionCustomerSynchronization(businessDataStr);
default:
return BaseResult.getFailureMessageEntity("未匹配到流程监听事件当前传入的eventType"+eventType);
return BaseResult.getFailureMessageEntity("未匹配到流程监听事件当前传入的eventType" + eventType);
}
}
}
/****
* 验证客商档案重复
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-03 15:22
* @date 2025-03-03 15:22
* @param
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
private JsonResultEntity validateCustomerName(JSONObject data){
private JsonResultEntity validateCustomerName(JSONObject data) {
JSONObject formBean = data.getJSONObject("formmain_4389");
//客商名称
String field0006 = formBean.getString("field0006");
String field0006 = formBean.getString("field0006");
//纳税人登记号
String field0007 = formBean.getString("field0007");
String field0007 = formBean.getString("field0007");
JSONObject requestJson = new JSONObject();
requestJson.put("custname",field0006);
String body = requestApi("validateCustomerName",requestJson, "800054","8000540095",null);
requestJson.put("custname", field0006);
String body = requestApi("validateCustomerName", requestJson, "800054", "8000540095", null);
JSONObject req = JSON.parseObject(body);
boolean flag = req.getBoolean("flag");
if(flag){
JSONObject attribute = req.getJSONObject("attribute");
if (flag) {
JSONObject attribute = req.getJSONObject("attribute");
String status = attribute.getString("status");
if("success".equals(status)){
if ("success".equals(status)) {
JSONObject detailsData = attribute.getJSONObject("data");
Integer allcount = detailsData.getInteger("allcount");
if(allcount>0){
if (allcount > 0) {
return BaseResult.getFailureMessageEntity("客商名称重复!");
}else{
} else {
requestJson = new JSONObject();
requestJson.put("taxpayer",field0007);
body = requestApi("validateCustomerName",requestJson, "800054","8000540095",null);
requestJson.put("taxpayer", field0007);
body = requestApi("validateCustomerName", requestJson, "800054", "8000540095", null);
req = JSON.parseObject(body);
flag = req.getBoolean("flag");
if(flag){
flag = req.getBoolean("flag");
if (flag) {
attribute = req.getJSONObject("attribute");
status = attribute.getString("status");
if("success".equals(status)){
detailsData = attribute.getJSONObject("data");
allcount = detailsData.getInteger("allcount");
if(allcount>0){
status = attribute.getString("status");
if ("success".equals(status)) {
detailsData = attribute.getJSONObject("data");
allcount = detailsData.getInteger("allcount");
if (allcount > 0) {
return BaseResult.getFailureMessageEntity("纳税人识别号重复!");
}else{
return BaseResult.getSuccessMessageEntity("客商未重复!");
} else {
return BaseResult.getSuccessMessageEntity("客商未重复!");
}
}else{
} else {
return BaseResult.getFailureMessageEntity("转发失败!");
}
}else{
return BaseResult.getFailureMessageEntity("转发失败!"+req.getString("msg"));
} else {
return BaseResult.getFailureMessageEntity("转发失败!" + req.getString("msg"));
}
}
}else{
} else {
return BaseResult.getFailureMessageEntity("转发失败!");
}
}else{
} else {
return BaseResult.getFailureMessageEntity("转发失败!"+req.getString("msg"));
return BaseResult.getFailureMessageEntity("转发失败!" + req.getString("msg"));
}
}
@ -128,7 +127,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* 执行客商同步新增和分配
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-04 10:45
* @date 2025-03-04 10:45
* @param
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@ -140,9 +139,9 @@ 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);
String body = requestApi("optionCustomerSynchronization客商新增", requestJson, "800054", apiCode, null);
JSONObject req = JSON.parseObject(body);
boolean flag = req.getBoolean("flag");
String pk_cubasdoc = null;
@ -151,32 +150,32 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
String status = attribute.getString("status");
if ("success".equals(status)) {
JSONArray returnData = attribute.getJSONArray("data");
if(null != returnData && returnData.size() >0){
if (null != returnData && returnData.size() > 0) {
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);
logger.info("客商新增成功!返回数据", body);
} else {
logger.info("客商新增失败!返回数据",body);
logger.info("客商新增失败!返回数据", body);
}
} else {
return BaseResult.getFailureMessageEntity("转发失败!" + req.getJSONObject("attribute").getString("errormsg"));
}
//绑定客商分配参数
requestJson = bindMerchantDefineParameters(data,pk_cubasdoc);
body = requestApi("optionCustomerSynchronization客商分配",requestJson, "800054","8000540094",null);
requestJson = bindMerchantDefineParameters(data, pk_cubasdoc,DEV);
body = requestApi("optionCustomerSynchronization客商分配", requestJson, "800054", "8000540094", null);
req = JSON.parseObject(body);
flag = req.getBoolean("flag");
if (flag) {
JSONObject attribute = req.getJSONObject("attribute");
String status = attribute.getString("status");
if ("success".equals(status)) {
logger.info("客商分配成功!返回数据",body);
logger.info("客商分配成功!返回数据", body);
} else {
logger.info("客商分配失败!返回数据",body);
logger.info("客商分配失败!返回数据", body);
}
} else {
return BaseResult.getFailureMessageEntity("转发失败!" + req.getJSONObject("attribute").getString("errormsg"));
@ -189,40 +188,40 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* 更新OA客商编码
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-07 16:43
* @date 2025-03-07 16:43
* @param
* @return com.alibaba.fastjson.JSONObject
**/
private JSONObject updateCustomerCode(String id,String custcode) {
String sql="update formmain_4389 set field0005 = '"+custcode+"' where id = "+id;
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);
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");
requestJson.put("password","45562434-8459-47b4-8df0-78fad8405bc4");
requestJson.put("data",encrypt);
requestJson.put("sign",md5);
String tokenRest = requestApi("获取token", requestJson,"800055", "8000550010",null);
requestJson.put("userName", "hzya_rest");
requestJson.put("password", "45562434-8459-47b4-8df0-78fad8405bc4");
requestJson.put("data", encrypt);
requestJson.put("sign", md5);
String tokenRest = requestApi("获取token", requestJson, "800055", "8000550010", null);
String token = JSON.parseObject(tokenRest).getJSONObject("attribute").getString("id");
String result = requestApi("更新A8客商档案", requestJson,"800055", "8000550000",token);
String result = requestApi("更新A8客商档案", requestJson, "800055", "8000550000", token);
//调用OArest接口
logger.info("更新A8客商档案结果:"+result);
logger.info("更新A8客商档案结果:" + result);
return null;
return null;
}
/***
* 绑定客商分配参数
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-05 15:02
* @date 2025-03-05 15:02
* @param
* @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();
@ -230,12 +229,12 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
JSONObject customer = new JSONObject();
//币种类别
String pk_currtype = formBean.getString("field0057");
customer.put("pk_currtype1",pk_currtype);
customer.put("pk_currtype1", pk_currtype);
//分配公司
customer.put("pk_corp",formBean.getString("field0064"));
customer.put("pk_corp", formBean.getString("field0064"));
String custprop = formBean.getString("field0027");
//客商属性 0客户1供应商2 客商
switch (custprop){
switch (custprop) {
case "4109154014131407336":
//客户
custprop = "0";
@ -252,11 +251,11 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
custprop = null;
break;
}
customer.put("custprop",custprop);
customer.put("custprop", custprop);
//客商ID
customer.put("pk_cubasdoc",pk_cubasdoc);
customer.put("pk_cubasdoc", pk_cubasdoc);
custbasvo.add(customer);
returnData.put("custbasvo",custbasvo);
returnData.put("custbasvo", custbasvo);
return returnData;
}
@ -264,23 +263,23 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* 请求API
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-04 16:52
* @date 2025-03-04 16:52
* @param
* @return java.lang.String
**/
private String requestApi(String method, JSONObject requestJson, String appId,String apiCode,String token) {
private String requestApi(String method, JSONObject requestJson, String appId, String apiCode, String token) {
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", String.valueOf(apiCode))
//这里用中台做为发送方
.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")
.put("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
.put("appId",appId)
.put("appId", appId)
.build();
if(null != token){
headerMap .put("token",token);
}
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();
logger.info("中台转发到ESB"+method+":{}", body);
logger.info("中台转发到ESB" + method + ":{}", body);
return body;
}
@ -288,11 +287,11 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
* 绑定客商新增OA和U8C客商参数
* @content:
* @author 👻👻👻👻👻👻👻👻 gjh
* @date 2025-03-04 10:53
* @date 2025-03-04 10:53
* @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,10 +299,29 @@ 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");
switch (accountproperty){
/** 生产环境和测试环境字段不一致,根据环境切换绑定*/
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");
switch (accountproperty) {
case "-3164025096780690930":
accountproperty = "电汇账户";
break;
@ -318,7 +336,7 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
break;
}
//账户性质 field0042
bank.put("remcode",accountproperty);
bank.put("remcode", accountproperty);
//银行账号
bank.put("account", formBean.getString("field0011"));
//账户名称
@ -328,25 +346,22 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
//开户银行 传递以后名称
bank.put("accname", formBean.getString("field0013"));
// bank.put("pk_bankdoc", formBean.getString("field0013"));
//银行类别 TODO 修改为取编码
// bank.put("banktypename", formBean.getString("field0014"));
bank.put("banktypename", formBean.getString("field0036"));
//新增固定传递集团
bank.put("pk_corp",formBean.getString("0001"));
//币种类别
String pk_currtype = formBean.getString("field0057");
bank.put("pk_currtype",pk_currtype);
bank.put("pk_corp", formBean.getString("0001"));
bank.put("pk_currtype", pk_currtype);
banks.add(bank);
JSONObject parentvo = new JSONObject();
//创建人 U8C 制单人 admin
// parentvo.put("creator",formBean.getString("field0019"));
parentvo.put("creator","admin");
parentvo.put("creator", "admin");
//客商名称
parentvo.put("custname",formBean.getString("field0006"));
parentvo.put("custname", formBean.getString("field0006"));
//客商类型0 - 外部单位1 - 内部核算单位2 - 内部法人单位3 - 内部渠道成员
String custprop = formBean.getString("field0026");
switch (custprop){
switch (custprop) {
case "-5116388890160378443":
custprop = "0";
break;
@ -365,12 +380,12 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
}
parentvo.put("custprop", custprop);
//客商简称
parentvo.put("custshortname",formBean.getString("field0001"));
//客商简称
parentvo.put("custshortname", formBean.getString("field0001"));
//销售方式
String def1 = formBean.getString("field0024");
switch (def1){
switch (def1) {
case "-285414580163689148":
def1 = "经销";
break;
@ -382,13 +397,13 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
break;
}
//销售方式
parentvo.put("def1",def1);
parentvo.put("def1", def1);
// 运输 自定义项8 001 002
// 运输 自定义项8 001 002
String def8 = formBean.getString("field0048");
switch (def8){
switch (def8) {
case "-8661769604040273924":
def8 = "001";
break;
@ -399,11 +414,11 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
def8 = null;
break;
}
parentvo.put("def8",def8);
parentvo.put("def8", def8);
//货代 自定义项7 001 002
String def7 = formBean.getString("field0050");
switch (def7){
switch (def7) {
case "-8661769604040273924":
def7 = "001";
break;
@ -414,29 +429,29 @@ public class WsCustomerSynchronizationEventServiceImpl extends BaseService<WsCus
def7 = null;
break;
}
parentvo.put("def7",def7);
parentvo.put("def7", def7);
//邮箱
parentvo.put("email",formBean.getString("field0052"));
parentvo.put("email", formBean.getString("field0052"));
//联系人1
parentvo.put("linkman1",formBean.getString("field0010"));
parentvo.put("memo",formBean.getString("field0054"));
parentvo.put("linkman1", formBean.getString("field0010"));
parentvo.put("memo", formBean.getString("field0054"));
//通信地址
parentvo.put("conaddr",formBean.getString("field0038"));
parentvo.put("conaddr", formBean.getString("field0038"));
//电话1 电话手机
parentvo.put("phone1",formBean.getString("field0008"));
//所属地区编码 TODO 修改为取编码
parentvo.put("pk_areacl",formBean.getString("field0062"));
parentvo.put("phone1", formBean.getString("field0008"));
//总公司名称 TODO 修改为取编码
parentvo.put("pk_cubasdoc1",formBean.getString("field0034"));
parentvo.put("pk_cubasdoc1", formBean.getString("field0034"));
//纳税人识别号
parentvo.put("taxpayerid",formBean.getString("field0007"));
customer.put("parentvo",parentvo);
customer.put("banks",banks);
parentvo.put("taxpayerid", formBean.getString("field0007"));
customer.put("parentvo", parentvo);
customer.put("banks", banks);
cbdocvo.add(customer);
returnData.put("cbdocvo",cbdocvo);
returnData.put("cbdocvo", cbdocvo);
return returnData;
}
}