OA单据、档案 同步BIP和主数据中心

This commit is contained in:
yuqh 2024-06-21 17:06:04 +08:00
parent 6b0120eb23
commit 0f8ba6400d
24 changed files with 924 additions and 4 deletions

View File

@ -0,0 +1,15 @@
package com.hzya.frame.plugin.a8bill.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.a8bill.entity.PayBillEntity;
/**
* 组织档案(mdm_org: table)表数据库访问层
*
* @author makejava
* @since 2024-06-07 18:30:04
*/
public interface IPayBillDao extends IBaseDao<PayBillEntity, String> {
}

View File

@ -0,0 +1,16 @@
package com.hzya.frame.plugin.a8bill.dao.impl;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.plugin.a8bill.dao.IPayBillDao;
import com.hzya.frame.plugin.a8bill.entity.PayBillEntity;
/**
* 组织档案(MdmOrg)表数据库访问层
*
* @author makejava
* @since 2024-06-07 18:30:04
*/
public class PayBillDaoImpl extends MybatisGenericDao<PayBillEntity, String> implements IPayBillDao {
}

View File

@ -0,0 +1,14 @@
package com.hzya.frame.plugin.a8bill.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
* 付款单
*
* @author makejava
* @since 2024-06-07 18:30:04
*/
public class PayBillEntity extends BaseEntity {
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.plugin.a8bill.dao.impl.PayBillDaoImpl">
<resultMap id="get-PayBillEntity-result" type="com.hzya.frame.plugin.a8bill.entity.PayBillEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "PayBillEntity_Base_Column_List">
id
</sql>
</mapper>

View File

@ -0,0 +1,64 @@
package com.hzya.frame.plugin.a8bill.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.seeyon.paybill.service.IPayBillService;
import com.hzya.frame.sysnew.comparison.masterData.service.impl.MasterDataOrgsServiceImpl;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 组织档案(PayBill)表服务接口
*
* @author makejava
* @since 2024-06-07 18:30:05
*/
public class PayBillPluginInitializer extends PluginBaseEntity{
Logger logger = LoggerFactory.getLogger(PayBillPluginInitializer.class);
@Autowired
private IPayBillService payBillService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "PayBillPlugin";
}
@Override
public String getPluginName() {
return "PayBillPlugin插件";
}
@Override
public String getPluginLabel() {
return "PayBillPlugin";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行付款单据信息同步========");
return payBillService.sendEngineerPayBillToBip(requestJson);
}catch (Exception e){
logger.info("======执行付款单据同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,13 @@
package com.hzya.frame.plugin.a8bill.service;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.plugin.a8bill.entity.PayBillEntity;
/**
* 付款单
*
* @author makejava
* @since 2024-06-07 18:30:05
*/
public interface IPayBillService extends IBaseService<PayBillEntity, String>{
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.plugin.a8bill.service.impl;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.plugin.a8bill.entity.PayBillEntity;
import com.hzya.frame.plugin.a8bill.service.IPayBillService;
import com.hzya.frame.plugin.masterData.org.service.IMdmOrgService;
/**
* private IMdmOrgDao mdmOrgDao;
*
* @Autowired
* public void setMdmOrgDao(IMdmOrgDao dao) {
* this.mdmOrgDao = dao;
* this.dao = dao;
* }
*
* @author makejava
* @since 2024-06-07 18:30:05
*/
public class PayBillServiceImpl extends BaseService<PayBillEntity, String> implements IPayBillService {
}

View File

@ -1,9 +1,12 @@
package com.hzya.frame.plugin.masterData.customer.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataCustoMermanageService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 客户档案(MdmCustomer)表服务接口
*
@ -12,6 +15,8 @@ import org.slf4j.LoggerFactory;
*/
public class MdmCustomerPluginInitializer extends PluginBaseEntity{
Logger logger = LoggerFactory.getLogger(MdmCustomerPluginInitializer.class);
@Autowired
private IMasterDataCustoMermanageService masterDataCustoMermanageService;
@Override
public void initialize() {
@ -44,7 +49,13 @@ public class MdmCustomerPluginInitializer extends PluginBaseEntity{
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
logger.info("执行业务代码逻辑");
try {
logger.info("======开始执行客户信息同步========");
return masterDataCustoMermanageService.queryCustoMermanageArchives(requestJson);
}catch (Exception e){
logger.info("======执行客户同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -1,9 +1,12 @@
package com.hzya.frame.plugin.masterData.user.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataMemberService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 用户档案(MdmUser)表服务接口
*
@ -12,6 +15,8 @@ import org.slf4j.LoggerFactory;
*/
public class MdmUserPluginInitializer extends PluginBaseEntity{
Logger logger = LoggerFactory.getLogger(MdmUserPluginInitializer.class);
@Autowired
private IMasterDataMemberService masterDataMemberService;
@Override
public void initialize() {
@ -44,7 +49,13 @@ public class MdmUserPluginInitializer extends PluginBaseEntity{
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
logger.info("执行业务代码逻辑");
try {
logger.info("======开始执行用户信息同步========");
return masterDataMemberService.queryMemberArchives(requestJson);
}catch (Exception e){
logger.info("======执行用户同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -26,9 +26,9 @@
#ax:
# url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
logging:
#日志级别 指定目录级别
#日志级别 指定目录级别warn
level:
root: warn
root: info
encodings: UTF-8
file:
# 日志保存路径

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>PayBillPlugin</id>
<name>OA付款单插件</name>
<category>202406210001</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="PayBillPluginInitializer" class="com.hzya.frame.plugin.a8bill.plugin.PayBillPluginInitializer" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="PayBillPluginService" class="com.hzya.frame.plugin.a8bill.service.impl.PayBillServiceImpl" />
</beans>

View File

@ -1,5 +1,10 @@
package com.hzya.frame.bip.v3.v2207.util;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* com.hzya.frame.bip.v3.v2207.util
*
@ -8,5 +13,53 @@ package com.hzya.frame.bip.v3.v2207.util;
*/
public class BipUtil {
/**
*
* @content 发送单据到BIP系统
* @author laborer
* @date 2024/6/21 0021 10:51
*
*/
public static String sendU9cTOBipEsb(String parm, String apiCode,String token){
String baseUrl = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
System.out.println("推送参数"+parm);
String result = HttpRequest.post(baseUrl)
.header("appId", "800023")//头信息多个头信息多次调用此方法即可
.header("access_token", token)//头信息多个头信息多次调用此方法即可
.header("apiCode", apiCode)//头信息多个头信息多次调用此方法即可
.header("publicKey", "ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")//头信息多个头信息多次调用此方法即可
.header("secretKey", "7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息多个头信息多次调用此方法即可
.body(parm)//表单内容
.timeout(20000)//超时毫秒
.execute().body();
System.out.println("返回参数"+result);
if(StrUtil.isNotEmpty(result)){
return analytic(result);
}
return null;
}
public static String getBipToken(String userCode, String apiCode){
String baseUrl = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
String result = HttpRequest.post(baseUrl)
.header("appId", "800023")//头信息多个头信息多次调用此方法即可
.header("apiCode", apiCode)//头信息多个头信息多次调用此方法即可
.header("usercode", userCode)//头信息多个头信息多次调用此方法即可
.header("publicKey", "ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")//头信息多个头信息多次调用此方法即可
.header("secretKey", "7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息多个头信息多次调用此方法即可
.body("")//表单内容
.timeout(20000)//超时毫秒
.execute().body();
System.out.println("返回参数"+result);
if(StrUtil.isNotEmpty(result)){
JSONObject obj = JSON.parseObject( analytic(result));
JSONObject data = obj.getJSONObject("data");
return data.getString("access_token");
}
return null;
}
public static String analytic(String parm){
JSONObject main = JSON.parseObject(parm);
return main.getString("attribute");
}
}

View File

@ -0,0 +1,33 @@
package com.hzya.frame.seeyon.paybill.dao;
import com.hzya.frame.seeyon.entity.SeeYonInterFaceEntity;
import com.hzya.frame.seeyon.paybill.entity.PayBillEntity;
import java.util.List;
import java.util.Map;
/**
* @author 👻👻👻👻👻👻👻👻👻👻 gjh
* @version 1.0
* @content
* @date 2023-08-30 10:27
*/
public interface IPayBillDao {
/**
*
* @content 获取OA工程付款单数据
* @author laborer
* @date 2024/6/20 0020 11:30
*
*/
List<PayBillEntity> getOaEngineerPay(PayBillEntity entity);
/**
*
* @content 修改推送状态
* @author laborer
* @date 2024/6/21 0021 11:15
*
*/
int updateState(PayBillEntity pay);
}

View File

@ -0,0 +1,32 @@
package com.hzya.frame.seeyon.paybill.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.seeyon.entity.SeeYonInterFaceEntity;
import com.hzya.frame.seeyon.paybill.dao.IPayBillDao;
import com.hzya.frame.seeyon.paybill.entity.PayBillEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @author 👻👻👻👻👻👻👻👻👻👻 gjh
* @version 1.0
* @content
* @date 2023-08-30 10:27
*/
@Repository(value = "PayBillDaoImpl")
public class PayBillDaoImpl extends MybatisGenericDao implements IPayBillDao {
@DS("#entity.dataSourceCode")
@Override
public List<PayBillEntity> getOaEngineerPay(PayBillEntity entity) {
return super.selectList("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_list_base",entity);
}
@DS("#pay.dataSourceCode")
@Override
public int updateState(PayBillEntity pay) {
return super.update("com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl.PayBillEntity_update",pay);
}
}

View File

@ -0,0 +1,80 @@
package com.hzya.frame.seeyon.paybill.entity;
import com.hzya.frame.web.entity.BaseEntity;
import java.util.List;
import java.util.Map;
/**
*
* @content 付款結算單
* @author laborer
* @date 2024/6/20 0020 11:07
*
*/
public class PayBillEntity extends BaseEntity {
private String billDate;//付款日期
private String primalMoney;//付款金额信息
private String pkOppaccount;//付款银行信息
private String pkSupplier;//供应商信息
private String tableName;//表名称
private String fieldName;//字段名称
private String state;//推送状态
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getBillDate() {
return billDate;
}
public void setBillDate(String billDate) {
this.billDate = billDate;
}
public String getPrimalMoney() {
return primalMoney;
}
public void setPrimalMoney(String primalMoney) {
this.primalMoney = primalMoney;
}
public String getPkOppaccount() {
return pkOppaccount;
}
public void setPkOppaccount(String pkOppaccount) {
this.pkOppaccount = pkOppaccount;
}
public String getPkSupplier() {
return pkSupplier;
}
public void setPkSupplier(String pkSupplier) {
this.pkSupplier = pkSupplier;
}
}

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.seeyon.paybill.dao.impl.PayBillDaoImpl">
<resultMap id="get-PayBillEntity-result" type="com.hzya.frame.seeyon.paybill.entity.PayBillEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="billDate" column="bill_date" jdbcType="VARCHAR"/>
<result property="primalMoney" column="primal_money" jdbcType="VARCHAR"/>
<result property="pkOppaccount" column="pk_oppaccount" jdbcType="VARCHAR"/>
<result property="pkSupplier" column="pk_supplier" jdbcType="VARCHAR"/>
<result property="tableName" column="table_name" jdbcType="VARCHAR"/>
<result property="fieldName" column="field_name" jdbcType="VARCHAR"/>
</resultMap>
<!--工程项目查询-->
<select id="PayBillEntity_list_base" resultMap="get-PayBillEntity-result" parameterType="com.hzya.frame.seeyon.paybill.entity.PayBillEntity">
SELECT
body.id as id,
field0070 AS bill_date,
field0057 AS primal_money,
field0019 AS pk_oppaccount,
field0082 AS pk_supplier,
'formson_0222' as table_name,
'field0084' as field_name
FROM formmain_0093 main
LEFT JOIN formson_0222 body ON main.id = body.formmain_id
WHERE field0070 IS NOT null and field0084 is null
union all
SELECT
body.id as id,
field0073 AS bill_date,
field0031 AS primal_money,
field0042 AS pk_oppaccount,
field0077 AS pk_supplier,
'formson_0210' as table_name,
'field0078' as field_name
FROM formmain_0209 main
LEFT JOIN formson_0210 body ON main.id = body.formmain_id
WHERE field0073 IS NOT null and field0078 is null
union all
SELECT
body.id as id,
field0053 AS bill_date,
field0041 AS primal_money,
field0024 AS pk_oppaccount,
field0057 AS pk_supplier,
'formson_0223' as table_name,
'field0058' as field_name
FROM formmain_0094 main
LEFT JOIN formson_0223 body ON main.id = body.formmain_id
WHERE field0053 IS NOT NULL and field0058 is null
</select>
<!--通过主键修改方法-->
<update id="PayBillEntity_update" parameterType = "java.util.Map" >
update ${tableName} set ${fieldName} = #{state} where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,29 @@
package com.hzya.frame.seeyon.paybill.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
import com.hzya.frame.seeyon.paybill.entity.PayBillEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
import java.util.List;
/**
*
* @content huoqu
* @author laborer获取OA付款单数据并推送BIP生成付款结算单
* @date 2024/6/20 0020 11:19
*
*/
public interface IPayBillService extends IBaseService<PaymentEntity,String> {
/**
*
* @content 工程付款单数据同步BIP
* @author laborer
* @date 2024/6/20 0020 11:24
*
*/
JsonResultEntity sendEngineerPayBillToBip(JSONObject requestJson);
}

View File

@ -0,0 +1,103 @@
package com.hzya.frame.seeyon.paybill.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.bip.v3.v2207.util.BipUtil;
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
import com.hzya.frame.seeyon.paybill.dao.IPayBillDao;
import com.hzya.frame.seeyon.paybill.entity.PayBillEntity;
import com.hzya.frame.seeyon.paybill.service.IPayBillService;
import com.hzya.frame.seeyon.service.impl.SeeYonInterFaceImpl;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
* @content 付款单同步BIP
* @author laborer
* @date 2024/6/20 0020 15:20
*
*/
@Service("PayBillServiceImpl")
public class PayBillServiceImpl extends BaseService<PaymentEntity,String> implements IPayBillService {
private static final Logger logger = LoggerFactory.getLogger(PayBillServiceImpl.class);
@Autowired
private IPayBillDao payBillDao;
/**
*
* @content 工程付款单数据同步BIP
* @author laborer
* @date 2024/6/20 0020 11:24
*
*/
@Override
public JsonResultEntity sendEngineerPayBillToBip(JSONObject requestJson) {
PayBillEntity entity = new PayBillEntity();
requestJson.put("db_code","OA");
entity.setDataSourceCode(requestJson.getString("db_code"));
List<PayBillEntity>payBillEntityList = payBillDao.getOaEngineerPay(entity);
if(CollectionUtils.isNotEmpty(payBillEntityList)){
for(PayBillEntity pay : payBillEntityList){
String token = BipUtil.getBipToken("yonyou","8000230000");
JSONObject main = bindingAdd(pay);
logger.info("工程付款单调用中台生成BIP付款结算单推送报文{}",main.toString());
String result = BipUtil.sendU9cTOBipEsb(main.toString(),"8000230014",token);
logger.info("工程付款单调用中台生成BIP付款结算单返回结果{}",result);
JSONObject resultObj = JSON.parseObject(result);
boolean flag = resultObj.getBoolean("success");
if(flag){
pay.setState("Y");
}else{
pay.setState("N");
}
pay.setDataSourceCode(requestJson.getString("db_code"));
payBillDao.updateState(pay);
// todo 后续在写吧没字段等OA开了外网在创建修改推送状态避免再次查询
}
}
return null;
}
@NotNull
private JSONObject bindingAdd(PayBillEntity pay) {
JSONObject head = new JSONObject();
head.put("pk_org","");//所属组织
head.put("pk_group","");//集团
head.put("bill_type","F5");//单据类型 默认F5
head.put("trade_type","D5");//付款结算类型 默认D5
head.put("source_flag","2");//付款结算类型 默认2
head.put("bill_date",pay.getBillDate());//单据日期
head.put("primal_money",pay.getPrimalMoney());//付款原币金额
head.put("pk_currtype","CNY");//币种
head.put("billmaker","");//制单人
//处理明细数据按照明细付款 多个明细生成多个付款结算单
JSONArray detailsArr = new JSONArray();
JSONObject body = new JSONObject();
body.put("pk_org","");//所属组织
body.put("pk_group","");//集团
body.put("bill_type","F5");//单据类型 默认F5
body.put("trade_type","D5");//付款结算类型 默认D5
body.put("pk_currtype","CNY");//币种
body.put("bill_date",pay.getBillDate());//单据日期
body.put("pay_primal",pay.getPrimalMoney());//付款原币金额
body.put("creationtime",pay.getBillDate());//创建时间
body.put("direction","-1");//方向 :1=;-1=;
body.put("objecttype","");//交易对象
detailsArr.add(body);
JSONObject main = new JSONObject();
main.put("head",head);//表头
main.put("body",detailsArr);//明细数据
return main;
}
}

View File

@ -0,0 +1,18 @@
package com.hzya.frame.sysnew.comparison.masterData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IMasterDataCustoMermanageService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询客户档案同步中台主数据中心
* @author laborer
* @date 2024/6/20 0020 9:54
*
*/
JsonResultEntity queryCustoMermanageArchives(JSONObject jsonObject);
}

View File

@ -0,0 +1,19 @@
package com.hzya.frame.sysnew.comparison.masterData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IMasterDataMemberService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询项目档案
* @Param
* @Return
* @Author hecan
* @Date 2024/6/6 16:10
* **/
JsonResultEntity queryMemberArchives(JSONObject jsonObject);
}

View File

@ -0,0 +1,149 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.dateutil.DateUtil;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.sysnew.comparison.masterData.dao.impl.MasterDataDaoImpl;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataCustoMermanageService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("MasterDataCustoMermanageServiceImpl")
public class MasterDataCustoMermanageServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataCustoMermanageService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//同步客户档案到主数据
public JsonResultEntity queryCustoMermanageArchives(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("数据来源表中没有类型为插件得数据,无法获取来源名称和来源编码");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
//通过不同的应用类型用于拼接sql
String appTyp = mdmModuleSourceEntity.getAppType();
String dbCode = mdmModuleSourceEntity.getDbCode();
switch (appTyp) {
case "1":
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("SELECT id as id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 WHERE 1=1 AND id = '1706533959075383844' " );
mdmModuleSourceEntity.setDataSourceCode(dbCode);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10004");
} else {
logger.info("U8C主数据档案客商档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案客商档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("客商档案同步成功");
}
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//查询明细信息
Long formmainId = (Long) hashMap.get("id");
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("SELECT field0023 AS pk_bankdoc,field0024 AS accnum,field0025 AS combinenum FROM formson_0229 WHERE formmain_id = '"+formmainId+"' " );
List<HashMap<String, Object>> hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
//先查询编码和名称查询是否存在
JsonResultEntity jsonResultEntity = comparisonServiceimpl.queryEntityPage(jsonStr);
Object attribute = jsonResultEntity.getAttribute();
logger.info("得到的attribute值为{}", attribute);
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list");
//如果jsonArrayList为null说明没有值在表中不存在
if (jsonArrayList == null || jsonArrayList.size() == 0) {
//将查询出来得数据调用通用接口新增保存到表中
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("details", hashMapsDetails);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage());
}
} else {
for (Object o : jsonArrayList) {
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o));
String id = jsonObjectUpdate.getString("id");
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
main.put("id",id);
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,144 @@
package com.hzya.frame.sysnew.comparison.masterData.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.dateutil.DateUtil;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.sysnew.comparison.masterData.dao.impl.MasterDataDaoImpl;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataMemberService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("MasterDataMemberServiceImpl")
public class MasterDataMemberServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataMemberService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//同步用户信息到主数据
public JsonResultEntity queryMemberArchives(JSONObject json){
JSONObject jsonObject = json.getJSONObject("jsonStr");
//查询主数据来源表根据来源类型为插件得进行分类获取来源名称和编码
List<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("数据来源表中没有类型为插件得数据,无法获取来源名称和来源编码");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
//通过不同的应用类型用于拼接sql
String appTyp = mdmModuleSourceEntity.getAppType();
String dbCode = mdmModuleSourceEntity.getDbCode();
switch (appTyp) {
case "1":
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select a.id as id, a.name as user_name, e.LOGIN_NAME as user_code FROM org_member a left join org_principal e on a.id = e.MEMBER_ID" +
" WHERE 1=1 " + sb.toString());
mdmModuleSourceEntity.setDataSourceCode(dbCode);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10003");
} else {
logger.info("U8C主数据用户档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案用户档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("用户档案同步成功");
}
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
JsonResultEntity jsonResultEntity = comparisonServiceimpl.queryEntityPage(jsonStr);
Object attribute = jsonResultEntity.getAttribute();
logger.info("得到的attribute值为{}", attribute);
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
JSONArray jsonArrayList = jsonObjectAttribute.getJSONArray("list");
//如果jsonArrayList为null说明没有值在表中不存在
if (jsonArrayList == null || jsonArrayList.size() == 0) {
//将查询出来得数据调用通用接口新增保存到表中
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.saveEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案新增用户档案失败,失败原因:{}",e.getMessage());
}
} else {
for (Object o : jsonArrayList) {
JSONObject jsonObjectUpdate = JSON.parseObject(String.valueOf(o));
String id = jsonObjectUpdate.getString("id");
JSONObject main = new JSONObject();
for(String key:hashMap.keySet()) {
main.put(key, hashMap.get(key));
main.put("id",id);
}
jsonObjectUser.put("main", main);
jsonObjectUser.put("appName","数智中台");
jsonObjectUser.put("appCode","800004");
jsonObjectUser.put("optionName", "数智中台");
jsonStr.put("jsonStr", jsonObjectUser);
try {
comparisonServiceimpl.updateEntity(jsonStr);
} catch (Exception e) {
logger.info("U8C主数据档案更新用户档案失败,失败原因:{}", e.getMessage());
}
}
}
}
return null;
}
}