Merge branch 'yuecheng-project' of http://192.168.2.237:3000/root/kangarooDataCenterV3 into yuecheng-project

This commit is contained in:
xiang2lin 2024-06-25 16:46:46 +08:00
commit 5991883e53
37 changed files with 1054 additions and 1026 deletions

View File

@ -4,14 +4,13 @@ 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)表服务接口
* 付款单(PayBill)表服务接口
*
* @author makejava
* @since 2024-06-07 18:30:05

View File

@ -0,0 +1,63 @@
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.seeyon.recbill.service.IRecBillService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 收款单(RecBill)表服务接口
*
* @author makejava
* @since 2024-06-07 18:30:05
*/
public class RecBillPluginInitializer extends PluginBaseEntity{
Logger logger = LoggerFactory.getLogger(RecBillPluginInitializer.class);
@Autowired
private IRecBillService recBillService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "RecBillPluginInitializer";
}
@Override
public String getPluginName() {
return "RecBillPluginInitializer插件";
}
@Override
public String getPluginLabel() {
return "RecBillPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行收款单据信息同步========");
return recBillService.sendRecBillToBip(requestJson);
}catch (Exception e){
logger.info("======执行收款单据同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -1,7 +1,6 @@
package com.hzya.frame.plugin.masterData.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.sysnew.comparison.masterData.service.IMasterDataService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;

View File

@ -91,8 +91,7 @@ mybatis-plus:
db-config:
id-type: auto # 主键策略
zt:
url:
# 积木报表工具
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
#JimuReport[minidao配置]
minidao :
base-package: org.jeecg.modules.jmreport.desreport.dao*

View File

@ -2,4 +2,5 @@
<!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" />
<bean name="RecBillPluginInitializer" class="com.hzya.frame.plugin.a8bill.plugin.RecBillPluginInitializer" />
</beans>

31
pom.xml
View File

@ -29,7 +29,7 @@
<gson.version>2.8.5</gson.version>
<zxing.version>3.3.0</zxing.version>
<hutool.version>5.8.19</hutool.version>
<druid.version>1.2.0</druid.version>
<druid.version>1.1.22</druid.version>
<!-- <mybatis-spring-boot-starter.version>2.2.2</mybatis-spring-boot-starter.version>-->
<mybatis-plus-boot-starter.version>3.5.6</mybatis-plus-boot-starter.version>
<!-- <mysql-connector-j.version>8.0.33</mysql-connector-j.version>-->
@ -235,8 +235,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.23</version>
<!-- <version>${druid-spring-boot-starter.version}</version>-->
<version>${druid-spring-boot-starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
@ -246,12 +245,6 @@
</dependency>
<!-- 添加dm8 jdbc jar 包依赖-->
<!-- <dependency>-->
<!-- <groupId>com.dameng</groupId>-->
<!-- <artifactId>DmJdbcDriver18</artifactId>-->
<!-- <version>8.1.1.193</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.dameng</groupId>
<artifactId>Dm8JdbcDriver18</artifactId>
@ -259,7 +252,6 @@
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
@ -346,21 +338,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<!-- JimuReport 积木报表 -->
<dependency>
<groupId>org.jeecgframework.jimureport</groupId>
<artifactId>jimureport-spring-boot-starter</artifactId>
<version>${jimureport.version}</version>
</dependency>
<!-- minio oss-->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>${minio.version}</version>
<optional>true</optional>
</dependency>
<!-- postgresql驱动 -->
<!-- postgresql驱动 -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
@ -391,7 +369,6 @@
<artifactId>flyway-mysql</artifactId>
<version>8.5.13</version>
</dependency>
</dependencies>
<build>
@ -441,7 +418,6 @@
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.jar</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.xmreport</include>
@ -460,7 +436,6 @@
<directory>src/</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.jar</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.json</include>

View File

@ -342,6 +342,7 @@ where id = #{id}
`sts` varchar(1) DEFAULT NULL COMMENT '状态(Y正常N删除)',
`org_id` varchar(50) DEFAULT NULL COMMENT '组织机构ID',
`company_id` varchar(50) DEFAULT NULL COMMENT '公司id',
`data_id` varchar(100) DEFAULT NULL COMMENT 'data_id',
</when>
<when test="tableType == '2'.toString()">
`id` varchar(50) NOT NULL COMMENT '唯一标识码',
@ -355,6 +356,7 @@ where id = #{id}
`sts` varchar(1) DEFAULT NULL COMMENT '状态(Y正常N删除)',
`org_id` varchar(50) DEFAULT NULL COMMENT '组织机构ID',
`company_id` varchar(50) DEFAULT NULL COMMENT '公司id',
`data_id` varchar(100) DEFAULT NULL COMMENT 'data_id',
</when>
<when test="tableType == '3'.toString()">
`id` varchar(50) NOT NULL COMMENT '唯一标识码',
@ -372,6 +374,8 @@ where id = #{id}
`sts` varchar(1) DEFAULT NULL COMMENT '状态(Y正常N删除)',
`org_id` varchar(50) DEFAULT NULL COMMENT '组织机构ID',
`company_id` varchar(50) DEFAULT NULL COMMENT '公司id',
`data_type` varchar(255) DEFAULT NULL COMMENT '状态 1、成功2、失败',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
</when>
<when test="tableType == '4'.toString()">
`id` varchar(50) NOT NULL COMMENT '唯一标识码',
@ -388,6 +392,8 @@ where id = #{id}
`sts` varchar(1) DEFAULT NULL COMMENT '状态(Y正常N删除)',
`org_id` varchar(50) DEFAULT NULL COMMENT '组织机构ID',
`company_id` varchar(50) DEFAULT NULL COMMENT '公司id',
`data_type` varchar(50) DEFAULT NULL COMMENT '状态 1、成功2、失败',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
</when>
</choose>
PRIMARY KEY (`sorts`,`id`) USING BTREE
@ -812,7 +818,7 @@ where id = #{id}
<if test="mdmModuleDistributeDetailEntities != null and mdmModuleDistributeDetailEntities.size>0">
AND
<foreach collection="mdmModuleDistributeDetailEntities" item="item" index="index" open="(" close=")" >
${item.leftBracket} ${item.filedName}
${item.leftBracket} ${item.filedId}
<choose>
<when test="item.compareType == '1'.toString() ">
=

View File

@ -582,6 +582,24 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
document_rule_num.setCreate();
document_rule_num.setDataType("1");
mdmModuleDbFiledsEntities.add(document_rule_num);
MdmModuleDbFiledsEntity data_id = new MdmModuleDbFiledsEntity();
data_id.setMdmId(entity.getMdmId());
data_id.setDbId(entity.getId());
data_id.setEnName("data_id");
data_id.setChName("第三方主键ID");
data_id.setFiledType("1");
data_id.setAddType("2");
data_id.setUpdateType("2");
data_id.setShowType("2");
data_id.setQueryType("2");
data_id.setListType("2");
data_id.setViewType("2");
data_id.setFiledLength("255");
data_id.setCreate();
data_id.setDataType("1");
mdmModuleDbFiledsEntities.add(data_id);
}
if ("2".equals(entity.getDbType()) || "3".equals(entity.getDbType()) || "4".equals(entity.getDbType())) {
MdmModuleDbFiledsEntity formmain_id = new MdmModuleDbFiledsEntity();
@ -600,6 +618,24 @@ public class MdmModuleServiceImpl extends BaseService<MdmModuleEntity, String> i
formmain_id.setCreate();
formmain_id.setDataType("1");
mdmModuleDbFiledsEntities.add(formmain_id);
MdmModuleDbFiledsEntity data_id = new MdmModuleDbFiledsEntity();
data_id.setMdmId(entity.getMdmId());
data_id.setDbId(entity.getId());
data_id.setEnName("data_id");
data_id.setChName("第三方主键ID");
data_id.setFiledType("1");
data_id.setAddType("2");
data_id.setUpdateType("2");
data_id.setShowType("2");
data_id.setQueryType("2");
data_id.setListType("2");
data_id.setViewType("2");
data_id.setFiledLength("255");
data_id.setCreate();
data_id.setDataType("1");
mdmModuleDbFiledsEntities.add(data_id);
}
//写入日志字段操作人
if ("3".equals(entity.getDbType())) {

View File

@ -173,25 +173,28 @@
<!-- 根据数据来源内类型是插件的应用类型做分组 -->
<select id="queryMdmModuleSourceentityGroupByType" resultMap="get-MdmModuleSourceEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity">
SELECT
plug.plugin_code,
plug.plugin_name,
source.source_name,
source.source_code ,
application.app_type,
applicationdatabase.source_code as db_code
FROM
mdm_module_source source
LEFT JOIN sys_application_plugin plug ON plug.id = source.source_code
LEFT JOIN sys_application application ON source.source_name = application.id
left join sys_application_database applicationdatabase on applicationdatabase.app_id = source.source_name
WHERE
source.source_type = '1'
AND source.sts = 'Y'
AND plug.sts = 'Y'
and application.sts = 'Y'
AND applicationdatabase.sts = 'Y'
AND applicationdatabase.db_status = '1'
SELECT
plug.plugin_code,
plug.plugin_name,
application.name as app_name,
source.source_name,
source.source_code ,
application.app_type,
model.mdm_code,
applicationdatabase.source_code as db_code
FROM
mdm_module_source source
LEFT JOIN sys_application_plugin plug ON plug.id = source.source_code
LEFT JOIN sys_application application ON source.source_name = application.id
left join sys_application_database applicationdatabase on applicationdatabase.app_id = source.source_name
LEFT JOIN mdm_module model on source.mdm_id = model.id
WHERE
source.source_type = '1'
AND source.sts = 'Y'
AND plug.sts = 'Y'
and application.sts = 'Y'
AND applicationdatabase.sts = 'Y'
AND applicationdatabase.db_status = '1'
</select>
@ -329,32 +332,7 @@ update mdm_module_source set sts= 'N' ,modify_time = #{modify_time},modify_user
<delete id="entity_delete">
delete from mdm_module_source where id = #{id}
</delete>
<!-- 根据数据来源内类型是插件的应用类型做分组 -->
<select id="queryMdmModuleSourceentityGroupByType" resultMap="get-MdmModuleSourceEntity-result" parameterType = "com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity">
SELECT
plug.plugin_code,
plug.plugin_name,
application.name as app_name,
source.source_name,
source.source_code ,
application.app_type,
model.mdm_code,
applicationdatabase.source_code as db_code
FROM
mdm_module_source source
LEFT JOIN sys_application_plugin plug ON plug.id = source.source_code
LEFT JOIN sys_application application ON source.source_name = application.id
left join sys_application_database applicationdatabase on applicationdatabase.app_id = source.source_name
LEFT JOIN mdm_module model on source.mdm_id = model.id
WHERE
source.source_type = '1'
AND source.sts = 'Y'
AND plug.sts = 'Y'
and application.sts = 'Y'
AND applicationdatabase.sts = 'Y'
AND applicationdatabase.db_status = '1'
</select>
</mapper>

View File

@ -1688,7 +1688,7 @@ public class MdmServiceImpl implements IMdmService {
checkData.put("id", id);
checkData.put("mdmModuleDistributeDetailEntities", mdmModuleDistributeDetailEntities);
JSONObject object1 = mdmModuleDao.queryMdmST(checkData);
if (object1.getString("id") == null || "".equals(object1.getString("id"))) {
if (object1 == null || object1.getString("id") == null || "".equals(object1.getString("id"))) {
return BaseResult.getFailureMessageEntity("当前数据不符合规则不发送");
}
}
@ -2511,35 +2511,84 @@ public class MdmServiceImpl implements IMdmService {
mdmDataDto.setTableName(mdmModuleDbEntityList.get(i).getDbName());
List<MdmDataFiledDto> mdmDataFiledDtos = new ArrayList<>();
for (int i1 = 0; i1 < fileds.size(); i1++) {
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
mdmDataFiledDto.setFiledsName(fileds.get(i1).getEnName());
mdmDataFiledDto.setFiledsValue(jsonObject.getString(fileds.get(i1).getEnName()));
mdmDataFiledDtos.add(mdmDataFiledDto);
if("id".equals(fileds.get(i1).getEnName())){
if (jsonObject.getString("id") != null) {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("id");
ids.setFiledsValue(jsonObject.getString("id"));
mdmDataFiledDtos.add(ids);
} else {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("id");
ids.setFiledsValue(UUIDUtils.getUUID());
mdmDataFiledDtos.add(ids);
}
}else if("formmain_id".equals(fileds.get(i1).getEnName())){
MdmDataFiledDto formain_id = new MdmDataFiledDto();
formain_id.setFiledsName("formmain_id");
formain_id.setFiledsValue(id);
mdmDataFiledDtos.add(formain_id);
}else if("data_status".equals(fileds.get(i1).getEnName())){
if (jsonObject.getString("id") != null) {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("data_status");
ids.setFiledsValue("F");
mdmDataFiledDtos.add(ids);
} else {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("data_status");
ids.setFiledsValue("Y");
mdmDataFiledDtos.add(ids);
}
}else if("sorts".equals(fileds.get(i1).getEnName())){
}else if("create_user_id".equals(fileds.get(i1).getEnName())){
//if (jsonObject.getString("id") != null) {
//
//} else {
// MdmDataFiledDto ids = new MdmDataFiledDto();
// ids.setFiledsName("create_user_id");
// ids.setFiledsValue(UUIDUtils.getUUID());
// mdmDataFiledDtos.add(ids);
//}
}else if("create_time".equals(fileds.get(i1).getEnName())){
}else if("modify_user_id".equals(fileds.get(i1).getEnName())){
//MdmDataFiledDto ids = new MdmDataFiledDto();
//ids.setFiledsName("modify_user_id");
//ids.setFiledsValue(UUIDUtils.getUUID());
//mdmDataFiledDtos.add(ids);
}else if("company_id".equals(fileds.get(i1).getEnName())){
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("company_id");
ids.setFiledsValue("0");
mdmDataFiledDtos.add(ids);
}else if("org_id".equals(fileds.get(i1).getEnName())){
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("org_id");
ids.setFiledsValue("0");
mdmDataFiledDtos.add(ids);
}else if("modify_time".equals(fileds.get(i1).getEnName())){
}else if("sts".equals(fileds.get(i1).getEnName())){
}else {
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
mdmDataFiledDto.setFiledsName(fileds.get(i1).getEnName());
mdmDataFiledDto.setFiledsValue(jsonObject.getString(fileds.get(i1).getEnName()));
mdmDataFiledDtos.add(mdmDataFiledDto);
}
}
MdmDataFiledDto mdmDataFiledDto = new MdmDataFiledDto();
mdmDataFiledDto.setFiledsName("logid");
mdmDataFiledDto.setFiledsValue(StpUtil.getLoginIdAsString());
mdmDataFiledDtos.add(mdmDataFiledDto);
MdmDataFiledDto formain_id = new MdmDataFiledDto();
formain_id.setFiledsName("formmain_id");
formain_id.setFiledsValue(id);
mdmDataFiledDtos.add(formain_id);
mdmDataDto.setMdmDataFiledDtos(mdmDataFiledDtos);
if (jsonObject.getString("id") != null) {
MdmDataFiledDto sts = new MdmDataFiledDto();
sts.setFiledsName("sts");
sts.setFiledsValue("Y");
mdmDataFiledDtos.add(sts);
mdmDataDto.setId(jsonObject.getString("id"));
int a = mdmModuleDao.updateForm(mdmDataDto);
} else {
MdmDataFiledDto ids = new MdmDataFiledDto();
ids.setFiledsName("id");
ids.setFiledsValue(UUIDUtils.getUUID());
mdmDataFiledDtos.add(ids);
mdmDataDto.setMdmDataFiledDtos(mdmDataFiledDtos);
mdmDataDto.setDbType(mdmModuleDbEntityList.get(i).getDbType());
int a = mdmModuleDao.saveForm(mdmDataDto);
}
@ -2547,9 +2596,7 @@ public class MdmServiceImpl implements IMdmService {
}
}
}
saveOption(dbname,mdmCode,saveData,id,msg);
}
return str.toString();
}

View File

@ -21,6 +21,33 @@ public class PayBillEntity extends BaseEntity {
private String tableName;//表名称
private String fieldName;//字段名称
private String state;//推送状态
private String pkOrg;//组织
private String pkCustomer;//客户
private String pk_oppaccount;//付款账户
public String getPkCustomer() {
return pkCustomer;
}
public void setPkCustomer(String pkCustomer) {
this.pkCustomer = pkCustomer;
}
public String getPk_oppaccount() {
return pk_oppaccount;
}
public void setPk_oppaccount(String pk_oppaccount) {
this.pk_oppaccount = pk_oppaccount;
}
public String getPkOrg() {
return pkOrg;
}
public void setPkOrg(String pkOrg) {
this.pkOrg = pkOrg;
}
public String getState() {
return state;

View File

@ -3,6 +3,7 @@
<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="pkOrg" column="pk_org" 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"/>

View File

@ -93,7 +93,9 @@ public class PayBillServiceImpl extends BaseService<PaymentEntity,String> implem
body.put("pay_primal",pay.getPrimalMoney());//付款原币金额
body.put("creationtime",pay.getBillDate());//创建时间
body.put("direction","-1");//方向 :1=;-1=;
body.put("objecttype","");//交易对象
body.put("objecttype","0");//交易对象
body.put("pk_customer",pay.getPkCustomer());//客户
body.put("pk_account",pay.getPkOppaccount());//付款银行账号
detailsArr.add(body);
JSONObject main = new JSONObject();
main.put("head",head);//表头

View File

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

View File

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

View File

@ -0,0 +1,104 @@
package com.hzya.frame.seeyon.recbill.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @content 付款結算單
* @author laborer
* @date 2024/6/20 0020 11:07
*
*/
public class RecBillEntity extends BaseEntity {
private String billDate;//付款日期
private String primalMoney;//付款金额信息
private String pkOppaccount;//付款银行信息
private String pkSupplier;//供应商信息
private String tableName;//表名称
private String fieldName;//字段名称
private String state;//推送状态
private String pkCustomer;//客户
private String pkAccount;//收款账户
private String pkOrg;//组织
public String getPkCustomer() {
return pkCustomer;
}
public void setPkCustomer(String pkCustomer) {
this.pkCustomer = pkCustomer;
}
public String getPkAccount() {
return pkAccount;
}
public void setPkAccount(String pkAccount) {
this.pkAccount = pkAccount;
}
public String getPkOrg() {
return pkOrg;
}
public void setPkOrg(String pkOrg) {
this.pkOrg = pkOrg;
}
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,40 @@
<?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.recbill.dao.impl.RecBillDaoImpl">
<resultMap id="get-RecBillEntity-result" type="com.hzya.frame.seeyon.recbill.entity.RecBillEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="pkOrg" column="pk_org" jdbcType="VARCHAR"/>
<result property="billDate" column="bill_date" jdbcType="VARCHAR"/>
<result property="primalMoney" column="primal_money" jdbcType="VARCHAR"/>
<result property="pkAccount" column="pk_account" jdbcType="VARCHAR"/>
<result property="pkCustomer" column="pk_customer" 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="RecBillEntity_list_base" resultMap="get-RecBillEntity-result" parameterType="com.hzya.frame.seeyon.recbill.entity.RecBillEntity">
SELECT
field0002 AS pk_org,
field0006 AS bill_date,
field0009 AS primal_money,
field0001 AS pk_account,
field0013 AS pk_customer,
field0012 AS pk_oppaccount,
'formmain_0233' as table_name,
'field0016' as field_name
FROM formmain_0233
WHERE field0016 IS null
</select>
<!--通过主键修改方法-->
<update id="RecBillEntity_update" parameterType = "java.util.Map" >
update ${tableName} set ${fieldName} = #{state} where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,26 @@
package com.hzya.frame.seeyon.recbill.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.web.entity.JsonResultEntity;
/**
*
* @content huoqu
* @author laborer获取OA付款单数据并推送BIP生成付款结算单
* @date 2024/6/20 0020 11:19
*
*/
public interface IRecBillService extends IBaseService<PaymentEntity,String> {
/**
*
* @content 工程付款单数据同步BIP
* @author laborer
* @date 2024/6/20 0020 11:24
*
*/
JsonResultEntity sendRecBillToBip(JSONObject requestJson);
}

View File

@ -0,0 +1,104 @@
package com.hzya.frame.seeyon.recbill.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.recbill.dao.IRecBillDao;
import com.hzya.frame.seeyon.recbill.entity.RecBillEntity;
import com.hzya.frame.seeyon.recbill.service.IRecBillService;
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("RecBillServiceImpl")
public class RecBillServiceImpl extends BaseService<PaymentEntity,String> implements IRecBillService {
private static final Logger logger = LoggerFactory.getLogger(RecBillServiceImpl.class);
@Autowired
private IRecBillDao payBillDao;
/**
*
* @content 工程付款单数据同步BIP
* @author laborer
* @date 2024/6/20 0020 11:24
*
*/
@Override
public JsonResultEntity sendRecBillToBip(JSONObject requestJson) {
RecBillEntity entity = new RecBillEntity();
requestJson.put("db_code","OA");
entity.setDataSourceCode(requestJson.getString("db_code"));
List<RecBillEntity>payBillEntityList = payBillDao.getOaRecBill(entity);
if(CollectionUtils.isNotEmpty(payBillEntityList)){
for(RecBillEntity pay : payBillEntityList){
String token = BipUtil.getBipToken("yonyou","8000230000");
JSONObject main = bindingAdd(pay);
logger.info("银行流水收款信息数据{}",main.toString());
String result = BipUtil.sendU9cTOBipEsb(main.toString(),"8000230016",token);
logger.info("银行流水收款信息数据{}",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(RecBillEntity pay) {
JSONObject head = new JSONObject();
head.put("pk_org","");//所属组织
head.put("pk_group","");//集团
head.put("bill_type","F4");//单据类型 默认F5
head.put("trade_type","D4");//付款结算类型 默认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","F4");//单据类型 默认F5
body.put("trade_type","D4");//付款结算类型 默认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","0");//交易对象
body.put("pk_customer",pay.getPkCustomer());//客户
body.put("pk_account",pay.getPkAccount());//收款银行账号
detailsArr.add(body);
JSONObject main = new JSONObject();
main.put("head",head);//表头
main.put("body",detailsArr);//明细数据
return main;
}
}

View File

@ -147,7 +147,7 @@ public class DsDataSourceUtil {
driveClass = DataSourceUtilProperties.SQL2000DRIVER;
} else if ("2".equalsIgnoreCase(dataSourceEntity.getSourceType())) {
driveClass = DataSourceUtilProperties.SQL2005DRIVER;
} else if ("4".equalsIgnoreCase(dataSourceEntity.getSourceType())) {
}else if ("4".equalsIgnoreCase(dataSourceEntity.getSourceType())) {
driveClass = DataSourceUtilProperties.dm;
}
try {

View File

@ -225,8 +225,8 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
//接口环境参数表 sys_application_api_para
saveApiPara(entity, olderAppId);
//数据源表 sys_application_database
saveDatabase(entity, olderAppId);
//数据源表不保存可能出现数据源编号重复问题 sys_application_database
//saveDatabase(entity, olderAppId);
//插件表 sys_application_plugin
savePlugin(entity, olderAppId);
@ -517,6 +517,27 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
if (entity.getUpdateType() == null || "".equals(entity.getUpdateType())) {
return BaseResult.getFailureMessageEntity("系统错误");
}
//查看数据源编码是否存在
SysApplicationDatabaseEntity detailEntity = entity.getDatabaseEntity();
if(detailEntity != null && detailEntity.getSourceCode() != null && !"".equals(detailEntity.getSourceCode())){
SysApplicationDatabaseEntity checkData = new SysApplicationDatabaseEntity();
checkData.setSourceCode(detailEntity.getSourceCode());
checkData.setSts("Y");
List<SysApplicationDatabaseEntity> sysApplicationDatabaseEntities = sysApplicationDatabaseDao.queryBase(checkData);
if(detailEntity.getId() != null && !"".equals(detailEntity.getId())){
if(sysApplicationDatabaseEntities != null && sysApplicationDatabaseEntities.size() > 0){
for (int i = 0; i < sysApplicationDatabaseEntities.size(); i++) {
if(!detailEntity.getId().equals(sysApplicationDatabaseEntities.get(i).getId())){
return BaseResult.getFailureMessageEntity("数据源编码已经存在,请修改");
}
}
}
}else {
if(sysApplicationDatabaseEntities != null && sysApplicationDatabaseEntities.size() > 0){
return BaseResult.getFailureMessageEntity("数据源编码已经存在,请修改");
}
}
}
//修改应用基本信息
SysApplicationEntity sysApplicationEntity = doUpdateApp(entity);
if ("2".equals(entity.getUpdateType())) {//开发管理界面需要保存 接口参数和数据源
@ -1691,7 +1712,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
SysApplicationApiEntity receiveApi = getApiByAppIdApiCode(receiveApp.getId(), apiCode);
if (receiveApi == null) {
saveLog(sendApp, receiveApp, receiveApi, oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + ":" + apiCode + "未启用或者未创建" );
saveLog(sendApp, receiveApp, new SysApplicationApiEntity(), oldbodys, null, oldheaderMap, null, null, oldquerys, null, null, false,receiveApp.getName() + ":" + apiCode + "未启用或者未创建" );
return BaseResult.getFailureMessageEntity(receiveApp.getName() + ":" + apiCode + "未启用或者未创建");
}

View File

@ -31,6 +31,16 @@ public class ComparisonDetailsEntity extends BaseEntity {
private String filedType;//字段类型 1BIGINT 2DECIMAL 3VARCHAR 4DATETIME
private String formmainId;//上级id
private String dataId;//第三方主键id
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public String getFormmainId() {
return formmainId;
}

View File

@ -20,7 +20,7 @@
<select id="queryComparisonDetailsPage" resultType="java.util.Map"
parameterType="com.hzya.frame.sysnew.comparison.entity.ComparisonDetailsEntity">
select * from ${dbName}
where formmain_id=#{formmainId} and sts='Y'
where formmain_id=#{formmainId} and sts='Y' and (data_status='Y' or data_status='F')
</select>
@ -48,19 +48,19 @@
${key} =#{value}
</foreach>
</set>
where formmain_id=#{formmainId} and sts='Y'
where data_id=#{dataId} and formmain_id= #{formmainId} and sts='Y' and (data_status='Y' or data_status='F')
</update>
<!-- 多条件逻辑删除 -->
<update id="deleteComparisonDetails" parameterType = "java.util.Map" >
update
${dbName}
set sts= 'N' ,modify_time = now(),modify_user_id = #{modify_user_id}, data_status= 'N',delete_status='0'
set modify_time = now(),modify_user_id = #{modify_user_id}, data_status= 'N'
<trim prefix="where" prefixOverrides="and">
<!--<foreach collection="mapDetails.entrySet()" item="value" index="key">
${key} =#{value}
</foreach>-->
and formmain_id=#{formmainId} and sts='Y'
and formmain_id=#{formmainId} and sts='Y' and (data_status='Y' or data_status='F')
</trim>
</update>

View File

@ -44,6 +44,16 @@ public class ComparisonEntity extends BaseEntity {
private String listType;//显示类型列表
private String viewType;//显示类型显示
private String dataId;//第三方主键id
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public String getAddType() {
return addType;
}

View File

@ -106,7 +106,7 @@
${key} =#{value}
</foreach>
</set>
where id=#{id} and sts='Y'
where id=#{id} and sts='Y' and (data_status='Y' or data_status='F')
</update>
@ -119,7 +119,7 @@
<foreach collection="map.entrySet()" item="value" index="key">
and ${key} =#{value}
</foreach>
and id=#{id} and sts='Y'
and id=#{id} and sts='Y' and (data_status='Y' or data_status='F')
</trim>
</update>

View File

@ -1,18 +0,0 @@
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

@ -1,19 +0,0 @@
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

@ -1,19 +0,0 @@
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 IMasterDataOrgsService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询组织档案
* @Param
* @Return
* @Author hecan
* @Date 2024/6/4 16:57
* **/
JsonResultEntity queryOrgsArchives(JSONObject jsonObject);
}

View File

@ -1,19 +0,0 @@
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 IMasterDataProjectService extends IBaseService<ComparisonEntity, String> {
/**
*
* @content 查询项目档案
* @Param
* @Return
* @Author hecan
* @Date 2024/6/6 16:10
* **/
JsonResultEntity queryProjectArchives(JSONObject jsonObject);
}

View File

@ -1,149 +0,0 @@
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

@ -1,144 +0,0 @@
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;
}
}

View File

@ -1,138 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.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.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.IMasterDataOrgsService;
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("masterDataOrgsServiceImpl")
public class MasterDataOrgsServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataOrgsService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//查询用户档案并同步中台
@Override
public JsonResultEntity queryOrgsArchives(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) {
//此处应该根据来源编码进行case 暂时测试使用U8C
switch (mdmModuleSourceEntity.getPluginCode()) {
case "MdmOrgPlugin":
if (null == ts || "".equals(ts)) {
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
}
ts = "'" + ts + "'";
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select pk_corp as id,unitcode as org_code,unitname as org_name,");
stringBuffer.append("saleaddr as org_address,countryarea as org_countryzone,memo as org_memo,");
stringBuffer.append("industry as org_ncindustry,fathercorp as org_fatherorg,legalbodycode as org_principal,");
stringBuffer.append("phone1 as org_tel from bd_corp where dr='0' and ts>"+ts);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchives(stringBuffer.toString());
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10001");
} else {
logger.info("U8C主数据档案组织档案没有需要同步中台的数据");
return null;
}
} catch (Exception e) {
logger.info("查询主数据档案组织档案错误:{}", e.getMessage());
}
break;
default:
break;
}
}
return BaseResult.getSuccessMessageEntity("组织档案同步成功");
}
//查询档案参数组装
private void 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());
}
}
}
}
}
}

View File

@ -1,132 +0,0 @@
package com.hzya.frame.sysnew.comparison.masterData.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.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.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("masterDataProjectServiceImpl")
public class MasterDataProjectServiceImpl extends BaseService<ComparisonEntity, String> implements IMasterDataProjectService {
@Autowired
private MasterDataDaoImpl masterDataDaoImpl;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
private String ts = "";
//同步项目档案
public JsonResultEntity queryProjectArchives(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) {
//此处应该根据来源编码进行case 暂时测试使用U8C
switch (mdmModuleSourceEntity.getPluginCode()) {
case "MdmProjectPlugin":
if (null == ts || "".equals(ts)) {
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
}
ts = "'" + ts + "'";
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select pk_jobbasfil as id,jobcode as project_code, jobname as project_name from bd_jobbasfil where dr='0' and ts>" + ts);
try {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchives(stringBuffer.toString());
logger.info("查询出来的值为:{}",hashMaps);
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,"10002");
} 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;
}
}

View File

@ -10,11 +10,11 @@ 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.IMasterDataProjectService;
import com.hzya.frame.sysnew.comparison.masterData.service.IMasterDataService;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -54,30 +54,31 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
String tableName = "";
try {
//通过不同的应用类型用于拼接sql
String appTyp = mdmModuleSourceEntity.getAppType();
String dbCode = mdmModuleSourceEntity.getDbCode();
String mdmCode = mdmModuleSourceEntity.getMdmCode();
List<HashMap<String, Object>>hashMaps = new ArrayList<>();
List<HashMap<String, Object>> hashMapsDetails = new ArrayList<>();
List<JSONObject> listAll = new ArrayList<>();
if(!"10004".equals(mdmCode)){
continue;
}
switch (appTyp) {//1致远OA 2用友U8C 3用友BIP
case "1":
//通过主数据编码判断不同的接口走不通的查询逻辑
switch (mdmCode){
case "10003"://致远用户信息
bindingUser(jsonObject, mdmModuleSourceEntity, dbCode);
tableName = "mdm_user";
listAll = bindingUser(jsonObject, mdmModuleSourceEntity, dbCode);
break;
case "10004"://致远客商信息
hashMaps = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode);
//查询明细数据
for (HashMap<String, Object> hashMap : hashMaps) {
//查询明细信息
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+"' " );
hashMapsDetails = masterDataDaoImpl.queryArchivesByDataSource(stringBufferDetails.toString(),mdmModuleSourceEntity);
}
tableName = "mdm_customer";
listAll = binDingCust(jsonObject, mdmModuleSourceEntity, dbCode);
break;
case "10007"://致远客商信息
tableName = "mdm_bank";
listAll = binDingBank(jsonObject, mdmModuleSourceEntity, dbCode);
break;
default:
logger.info("未匹配到主数据的编码,请检查");
@ -85,8 +86,8 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
}
}
//调用主数据接口进行数据推送或更新
if (null != hashMaps && hashMaps.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity,hashMaps,mdmCode,hashMapsDetails);
if (null != listAll && listAll.size() > 0) {
ParametricAssembly(mdmModuleSourceEntity, listAll, mdmCode, tableName);
} else {
logger.info("U8C主数据档案没有需要同步中台的数据");
}
@ -95,52 +96,123 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
e.printStackTrace();
}
}
return BaseResult.getSuccessMessageEntity("项目档案同步成功");
return BaseResult.getSuccessMessageEntity("主数据同步成功");
}
//绑定客户档案
private List<HashMap<String, Object>> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
List<HashMap<String, Object>> hashMap;
StringBuffer sbCust = new StringBuffer();
//绑定银行
private List<JSONObject> binDingBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sbCust.append(" and a.code = '"+code+"'");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sbCust.append(" and a.update_time >= '"+ts+"'");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBufferCust = new StringBuffer();
stringBufferCust.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 "+ sbCust.toString());
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select id as data_id,a.* from bank a");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
return masterDataDaoImpl.queryArchivesByDataSource(stringBufferCust.toString(),mdmModuleSourceEntity);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm = new JSONObject();
for(String key:hashMap.keySet()) {
mdm.put(key, hashMap.get(key));
}
main.put("mdm_bank",mdm);
list.add(main);
}
}
return list;
}
//绑定客户档案
private List<JSONObject> binDingCust(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
List<JSONObject> list = new ArrayList<>();
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 data_id,field0013 AS code,field0014 AS name,field0016 AS pk_custclass,field0015 AS shortname,field0012 AS pk_org FROM formmain_0226 a WHERE 1=1 ");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm_cust = new JSONObject();
for(String key:hashMap.keySet()) {
mdm_cust.put(key, hashMap.get(key));
}
//获取明细信息
Long formmainId = (Long) hashMap.get("data_id");
StringBuffer stringBufferDetails = new StringBuffer();
stringBufferDetails.append("SELECT id as data_id ,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);
JSONArray mdm_customer_bank = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
for (HashMap<String, Object> detailsMap : hashMapsDetails) {
JSONObject details = new JSONObject();
for (String key : detailsMap.keySet()) {
details.put(key, detailsMap.get(key));
}
mdm_customer_bank.add(details);
}
}
main.put("mdm_customer_bank",mdm_customer_bank);
main.put("mdm_customer",mdm_cust);
list.add(main);
}
}
return list;
}
//绑定OA用户参数
private JSONArray bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
StringBuffer sbUser = new StringBuffer();
private List<JSONObject> bindingUser(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode)throws Exception {
List<JSONObject> list = new ArrayList<>();
StringBuffer sb = new StringBuffer();
if(null != jsonObject && StrUtil.isNotEmpty(jsonObject.getString("code"))){
String code = jsonObject.getString("code");
sbUser.append(" and a.code = '"+code+"'");
sb.append(" and a.code = '"+code+"'");
}else{
ts = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
sbUser.append(" and a.update_time >= '"+ts+"'");
sb.append(" and a.update_time >= '"+ts+"'");
}
StringBuffer stringBufferUser = new StringBuffer();
stringBufferUser.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 "+ sbUser.toString());
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select a.id as data_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);
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBufferUser.toString(),mdmModuleSourceEntity);
for (HashMap<String, Object> hashMap : hashMaps) {
List<HashMap<String, Object>> hashMaps = masterDataDaoImpl.queryArchivesByDataSource(stringBuffer.toString(),mdmModuleSourceEntity);
int i = 0;
if(CollectionUtils.isNotEmpty(hashMaps)){
for (HashMap<String, Object> hashMap : hashMaps) {
JSONObject main = new JSONObject();
JSONObject mdm_user = new JSONObject();
for(String key:hashMap.keySet()) {
mdm_user.put(key, hashMap.get(key));
}
main.put("mdm_user",mdm_user);
list.add(main);
}
}
return null;
return list;
}
//查询档案参数组装
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<HashMap<String, Object>> hashMaps,String mdmCode,List<HashMap<String, Object>> hashMapsDetails){
for (HashMap<String, Object> hashMap : hashMaps) {
public JsonResultEntity ParametricAssembly(MdmModuleSourceEntity mdmModuleSourceEntity,List<JSONObject> hashMaps,String mdmCode,String tableName)throws Exception{
for (JSONObject hashMap : hashMaps) {
JSONObject main = hashMap.getJSONObject(tableName);
JSONObject jsonObjectUser = new JSONObject();
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("id", hashMap.get("id"));
jsonObjectUser.put("data_id", main.get("data_id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
@ -151,40 +223,30 @@ public class MasterDataServiceImpl extends BaseService<ComparisonEntity, String>
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());
// //将查询出来得数据调用通用接口新增保存到表中
// JSONObject main = new JSONObject();
// for(String key:hashMap.keySet()) {
// main.put(key, hashMap.get(key));
// }
// jsonObjectUser.put("main", main);
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
JsonResultEntity result = comparisonServiceimpl.saveEntity(jsonStr);
if(!result.isFlag()){
throw new BaseSystemException("主数据保存失败"+ result.getMsg());
}
} 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());
}
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
JsonResultEntity result = comparisonServiceimpl.updateEntity(jsonStr);
if(!result.isFlag()){
throw new BaseSystemException("主数据更新失败"+ result.getMsg());
}
}
}

View File

@ -18,6 +18,7 @@ import com.hzya.frame.sysnew.comparison.dao.IComparisonDetailsDao;
import com.hzya.frame.sysnew.comparison.entity.ComparisonDetailsEntity;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
import com.hzya.frame.sysnew.comparison.service.IComparisonService;
import com.hzya.frame.uuid.UUIDLong;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
import sun.java2d.pipe.AAShapePipe;
import java.util.*;
import java.util.stream.Collectors;
@Service(value = "comparisonServiceImpl")
public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String> implements IComparisonService {
@ -50,7 +52,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
//分页查询通用数据数据
@DS("master")
@Override
public JsonResultEntity queryEntityPage(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
@ -100,13 +101,15 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
for (Map<String, Object> comparisonEntitiePage : comparisonEntitiePages) {
JSONObject jsonObjects=new JSONObject();
jsonObjects.put(comparisonEntity.getDbName(),comparisonEntitiePage);
comparisonDetailsEntity.setFormmainId(String.valueOf(comparisonEntitiePage.get("id")));
//查询明细表数据
List<Map<String, Object>> maps = comparisonDetailsDao.queryComparisonDetailsPage(comparisonDetailsEntity);
if(CollectionUtils.isNotEmpty(maps)){
jsonObjects.put(comparisonDetailsEntity.getDbName(),maps);
}else {
jsonObjects.put(comparisonDetailsEntity.getDbName(),new JSONArray());
if(comparisonDetailsEntity.getDbName()!=null){
comparisonDetailsEntity.setFormmainId(String.valueOf(comparisonEntitiePage.get("id")));
//查询明细表数据
List<Map<String, Object>> maps = comparisonDetailsDao.queryComparisonDetailsPage(comparisonDetailsEntity);
if(CollectionUtils.isNotEmpty(maps)){
jsonObjects.put(comparisonDetailsEntity.getDbName(),maps);
}else {
jsonObjects.put(comparisonDetailsEntity.getDbName(),new JSONArray());
}
}
list.add(jsonObjects);
}
@ -122,7 +125,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
//新增通用数据数据
@DS("master")
@Override
public JsonResultEntity saveEntity(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr");
@ -135,9 +137,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
if (!checkStr(jsonObject.getString("optionName"))) {
return BaseResult.getFailureMessageEntity("操作人为空");
}
/*if (!checkStr(jsonObject.getString("rulePrefix"))) {
return BaseResult.getFailureMessageEntity("规则为空");
}*/
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
@ -151,99 +150,138 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
String main = jsonObject.getString("main");//获取主表数据
JSONArray jsonArray = jsonObject.getJSONArray("details");//获取子表数据
JSONObject jsonObjectMain = JSONObject.parseObject(main);
if(jsonObjectMain != null ) {
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
Map<String, Object> mapDetails = new HashMap<>();//将子表数据存到map中
if (comparisonEntities != null && comparisonEntities.size() > 0) {
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity);
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, comparisonDetailsEntity, jsonArray);
String uuid = null;
if (jsonObjectMain.getString("id") == null) {
uuid = UUIDUtils.getUUID();
map.put("id", uuid);
} else {
uuid = jsonObjectMain.getString("id");
map.put("id", jsonObjectMain.getString("id"));
}
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("org_id", "0");
map.put("create_time", new Date());
map.put("modify_time", new Date());
map.put("sts", "Y");
map.put("data_status", "Y");//新增状态
map.put("add_status", "0");//新增状态
map.put("update_status", "1");//修改状态
map.put("delete_status", "1");//删除状态
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
//查询单据规则 只查询主表得明细表不用
try {
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
String documentRule = comparisonEntityRules.getDocumentRule();
; //"KH-2024-05-30-1";
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
if (documentRule != null) {
//获取规则前缀 CK
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
//获取规则中间日期 yyyy-MM-dd
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
String ruleMiddle = getRuleDate(ruleDate);
//获取规则后缀
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
int ruleSuffix = ruleSuffixLength.length();
//生成单据规则
comparisonEntityRule.setRulePrefix(rulePrefix);
comparisonEntityRule.setRuleMiddle(ruleMiddle);
comparisonEntityRule.setRuleSuffix(ruleSuffix);
try {
//新生成单据规则保存到数据库
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
comparisonEntityRule.setMap(map);
} catch (Exception e) {
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
}
} catch (Exception e) {
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
try {
//保存主表数据
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
//保存子表数据
if (mapDetails != null && mapDetails.size() > 0) {
String uuidDetail = UUIDUtils.getUUID();
mapDetails.put("id", uuidDetail);
mapDetails.put("formmain_id", uuid);
mapDetails.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
mapDetails.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
mapDetails.put("org_id", "0");
mapDetails.put("create_time", new Date());
mapDetails.put("modify_time", new Date());
mapDetails.put("sts", "Y");
mapDetails.put("data_status","Y");//新增状态
comparisonDetailsEntity.setMapDetails(mapDetails);
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity);
//comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne);
map.put("details",mapDetails);
//保存操作日志
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
}
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonEntityRule.getDbName()+"_option_log");
return BaseResult.getSuccessMessageEntity("保存成功", map);
} catch (Exception e) {
logger.info("保存通用数据时候错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
}
}
JSONObject jsonObjectMain=new JSONObject();
JSONArray jsonArray=new JSONArray();
List<JSONArray> arrayList=new ArrayList<>();
//根据dbtype和dbname分组拿到表名称和表类型
Map<String, Map<String, List<ComparisonEntity>>> collect = comparisonEntities.stream().collect(Collectors.groupingBy(ComparisonEntity::getDbName, Collectors.groupingBy(ComparisonEntity::getDbType)));
List<Map.Entry<String, String>> keyPairs = collect.entrySet().stream()
.flatMap(e1 -> e1.getValue().keySet().stream()
.map(dbname -> new AbstractMap.SimpleEntry<>(e1.getKey(), dbname)))
.collect(Collectors.toList());
// keyPairs 得值为键值对键是表名称值是类型避免多个子表得键一样比如mdm_customer:1,mdm_customer_bank:2,mdm_customer_option_log:2
for (Map.Entry<String, String> keyPair : keyPairs) {
//如果是1就是主表根据查询出来得主表是否是传输传递得主表
if(keyPair.getValue().equals("1")){
String main = jsonObject.getString(keyPair.getKey());
if(main!=null){
jsonObjectMain = JSONObject.parseObject(main);
if(!checkStr(jsonObjectMain.getString("data_id"))){
return BaseResult.getFailureMessageEntity("新增时候主表data_id不能为空");
}
}
}
//如果是2就是明细表根据查询出来得子表是否是传输传递得子表
if(keyPair.getValue().equals("2")){
jsonArray= jsonObject.getJSONArray(keyPair.getKey());
if(jsonArray!= null) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObjectDetails = jsonArray.getJSONObject(i);
jsonObjectDetails.put("table_name", keyPair.getKey());
if(!checkStr(jsonObjectDetails.getString("data_id"))){
return BaseResult.getFailureMessageEntity("新增时候明细data_id不能为空");
}
}
arrayList.add(jsonArray);
}
}
}
if(jsonObjectMain!=null && jsonObjectMain.size()>0) {
Map<String, Object> map = new HashMap<>();//将主表数据存到map中
List<List<Map<String, Object>>> mapDetails = new ArrayList<>();//将子表数据存到map中
if (comparisonEntities != null && comparisonEntities.size() > 0) {
map = spliceMainMap(comparisonEntities, jsonObjectMain, map, comparisonEntity, comparisonDetailsEntity);
String uuid= String.valueOf(UUIDLong.longUUID());
map.put("id", uuid);
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("org_id", "0");
map.put("create_time", new Date());
map.put("modify_time", new Date());
map.put("sts", "Y");
map.put("data_status", "Y");//新增状态
map.put("add_status", "0");//新增状态
map.put("update_status", "1");//修改状态
map.put("delete_status", "1");//删除状态
ComparisonEntity comparisonEntityRule = comparisonEntities.get(0);
//查询单据规则 只查询主表得明细表不用
try {
ComparisonEntity comparisonEntityRules = comparisonDao.queryComparisonById(comparisonEntityRule);
String documentRule = comparisonEntityRules.getDocumentRule();//"KH-2024-05-30-1";
logger.info("通用数据保存接口中根据mId查询出来的单据规则为:{}", documentRule);
if (documentRule != null) {
//获取规则前缀 CK
String rulePrefix = documentRule.substring(0, documentRule.indexOf("-"));
//获取规则中间日期 yyyy-MM-dd
String ruleDate = documentRule.substring(documentRule.indexOf("-") + 1, documentRule.lastIndexOf("-"));
String ruleMiddle = getRuleDate(ruleDate);
//获取规则后缀
String ruleSuffixLength = documentRule.substring(documentRule.lastIndexOf("-") + 1);
int ruleSuffix = ruleSuffixLength.length();
//生成单据规则
comparisonEntityRule.setRulePrefix(rulePrefix);
comparisonEntityRule.setRuleMiddle(ruleMiddle);
comparisonEntityRule.setRuleSuffix(ruleSuffix);
try {
//新生成单据规则保存到数据库
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
map.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
map.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
comparisonEntityRule.setMap(map);
} catch (Exception e) {
logger.info("保存通用数据时候生成单据规则错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
}
} catch (Exception e) {
logger.info("通用数据保存接口中查询单据规则错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
try {
List<JSONObject> list = new ArrayList<>();
JSONObject jsonObjectList = new JSONObject();
//保存主表数据
ComparisonEntity comparisonEntityOne = comparisonDao.saveComparison(comparisonEntityRule);
jsonObjectList.put(comparisonEntityOne.getDbName(),map);
//保存子表数据
if (arrayList != null && arrayList.size() > 0) {
mapDetails = spliceDetailMap(comparisonEntities, mapDetails, arrayList);
if(mapDetails.size()>0 && mapDetails!=null ){
for (List<Map<String, Object>> mapDetail : mapDetails) {
for (Map<String, Object> stringObjectMap : mapDetail) {
stringObjectMap.put("id", UUIDLong.longUUID());
stringObjectMap.put("formmain_id", uuid);
stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
stringObjectMap.put("org_id", "0");
stringObjectMap.put("create_time", new Date());
stringObjectMap.put("modify_time", new Date());
stringObjectMap.put("sts", "Y");
stringObjectMap.put("data_status", "Y");//新增状态
comparisonDetailsEntity.setMapDetails(stringObjectMap);
comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name")));
stringObjectMap.remove("table_name");
ComparisonDetailsEntity comparisonDetailsEntityOne = comparisonDetailsDao.saveComparisonDetails(comparisonDetailsEntity);
comparisonEntityOne.setComparisonDetailsEntity(comparisonDetailsEntityOne);
//保存操作日志
//controlsLogDaoimpl.saveControlsLog(uuidDetail,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
}
}
jsonObjectList.put(comparisonDetailsEntity.getDbName(), mapDetails);
}
} else {
jsonObjectList.put(comparisonDetailsEntity.getDbName(), new ArrayList<>());
}
list.add(jsonObjectList);
//保存操作日志
controlsLogDaoimpl.saveControlsLog(uuid,jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口新增",jsonObject.getString("optionName"),comparisonEntityRule.getDbName()+"_option_log");
return BaseResult.getSuccessMessageEntity("保存成功", list);
} catch (Exception e) {
logger.info("保存通用数据时候错误:{}", e.getMessage());
return BaseResult.getFailureMessageEntity("保存失败");
}
}
}
return BaseResult.getFailureMessageEntity("查询失败","请检查传递参数");
}
@ -262,11 +300,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
JSONObject jsonObjectMain=jsonObject.getJSONObject("main");//获取主表数据
JSONArray jsonArray = jsonObject.getJSONArray("details");//获取子表数据
if(!checkStr(jsonObjectMain.getString("id"))){
return BaseResult.getFailureMessageEntity("更新时候主表id不能为空");
}
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
//根据主数据编码查询表名称字段名称等信息 10001
try {
@ -278,12 +311,57 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("更新失败");
}
JSONObject jsonObjectMain=new JSONObject();
JSONArray jsonArray=new JSONArray();
List<JSONArray> arrayList=new ArrayList<>();
//根据dbtype和dbname分组拿到表名称和表类型
Map<String, Map<String, List<ComparisonEntity>>> collect = comparisonEntities.stream().collect(Collectors.groupingBy(ComparisonEntity::getDbName, Collectors.groupingBy(ComparisonEntity::getDbType)));
List<Map.Entry<String, String>> keyPairs = collect.entrySet().stream()
.flatMap(e1 -> e1.getValue().keySet().stream()
.map(dbname -> new AbstractMap.SimpleEntry<>(e1.getKey(), dbname)))
.collect(Collectors.toList());
for (Map.Entry<String, String> keyPair : keyPairs) {
if(keyPair.getValue().equals("1")){
String main = jsonObject.getString(keyPair.getKey());
if(main!=null){
jsonObjectMain = JSONObject.parseObject(main);
if(!checkStr(jsonObjectMain.getString("data_id"))){
return BaseResult.getFailureMessageEntity("更新时候主表data_id不能为空");
}
}
}
if(keyPair.getValue().equals("2")){
jsonArray= jsonObject.getJSONArray(keyPair.getKey());
if(jsonArray!= null) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObjectDetails = jsonArray.getJSONObject(i);
if(!checkStr(jsonObjectDetails.getString("data_id"))){
return BaseResult.getFailureMessageEntity("更新明细表时候明细表data_id不能为空");
}
jsonObjectDetails.put("table_name", keyPair.getKey());
}
arrayList.add(jsonArray);
}
}
}
Map<String,Object> map=new HashMap<>();//将主表数据存到map中
Map<String,Object> mapDetails=new HashMap<>();//将子表数据存到map中
List<List<Map<String,Object>>> mapDetails=new ArrayList<>();//将子表数据存到map中
if(comparisonEntities !=null && comparisonEntities.size()>0) {
map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity);
mapDetails=spliceDetailMap(comparisonEntities,mapDetails,comparisonDetailsEntity,jsonArray);
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map=spliceMainMap(comparisonEntities,jsonObjectMain,map,comparisonEntity,comparisonDetailsEntity);
//根据data_id查询id.根据id更新主表数据,然后再根据主表id和明细表的data_id,删除明细表数据
Map<String,Object> mapId=new HashMap<>();
mapId.put("data_id",jsonObjectMain.getString("data_id"));
ComparisonEntity comparison=new ComparisonEntity();
comparison.setDbName(comparisonEntity.getDbName());
comparison.setMap(mapId);
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparison);
if(CollectionUtils.isEmpty(comparisonEntitiePages)){
return BaseResult.getFailureMessageEntity("根据data_id查询id数据为空请检查data_id");
}
String id = String.valueOf(comparisonEntitiePages.get(0).get("id"));
map.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
map.put("org_id", "0");
map.put("modify_time", new Date());
@ -291,7 +369,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
map.put("data_status","F");//数据状态
map.put("update_status","0");//修改状态
comparisonEntity.setMap(map);
comparisonEntity.setId(jsonObjectMain.getString("id"));
comparisonEntity.setId(id);
/*//生成单据规则
comparisonEntity.setRulePrefix(jsonObject.getString("rulePrefix"));
try {
@ -303,26 +381,41 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
return BaseResult.getFailureMessageEntity("更新失败",e.getMessage());
}*/
try {
//保存主表数据
List<JSONObject> jsonObjects=new ArrayList<>();
JSONObject jsonObjectList=new JSONObject();
//更新主表数据
Integer integer = comparisonDao.updateComparisonByType(comparisonEntity);
if (integer > 0) {
jsonObjectList.put(comparisonEntity.getDbName(),map);
if (integer>0) {
//保存子表数据
if (mapDetails != null && mapDetails.size() > 0) {
mapDetails.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
mapDetails.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
mapDetails.put("org_id", "0");
mapDetails.put("modify_time", new Date());
mapDetails.put("sts", "Y");
mapDetails.put("data_status","F");//数据状态
comparisonDetailsEntity.setFormmainId(jsonObjectMain.getString("id"));
comparisonDetailsEntity.setMapDetails(mapDetails);
comparisonDetailsDao.updateComparisonDetailsByType(comparisonDetailsEntity);
//保存操作日志
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
if (arrayList != null && arrayList.size() > 0) {
mapDetails=spliceDetailMap(comparisonEntities,mapDetails,arrayList);
for (List<Map<String, Object>> mapDetail : mapDetails) {
for (Map<String, Object> stringObjectMap : mapDetail) {
stringObjectMap.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
stringObjectMap.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
stringObjectMap.put("org_id", "0");
stringObjectMap.put("modify_time", new Date());
stringObjectMap.put("sts", "Y");
stringObjectMap.put("data_status","F");//数据状态
comparisonDetailsEntity.setDataId(String.valueOf(stringObjectMap.get("data_id")));
comparisonDetailsEntity.setFormmainId(id);
comparisonDetailsEntity.setMapDetails(stringObjectMap);
comparisonDetailsEntity.setDbName(String.valueOf(stringObjectMap.get("table_name")));
stringObjectMap.remove("table_name");
comparisonDetailsDao.updateComparisonDetailsByType(comparisonDetailsEntity);
//保存操作日志
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonDetailsEntity.getDbName()+"_option_log");
}
}
jsonObjectList.put(comparisonDetailsEntity.getDbName(),mapDetails);
}else{
jsonObjectList.put(comparisonDetailsEntity.getDbName(),new ArrayList<>());
}
jsonObjects.add(jsonObjectList);
//保存操作日志
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口更新",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log");
return BaseResult.getSuccessMessageEntity("更新成功", integer);
return BaseResult.getSuccessMessageEntity("更新成功", jsonObjects);
}else{
return BaseResult.getFailureMessageEntity("更新失败");
}
@ -349,10 +442,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
ComparisonEntity comparisonEntity = jsonObject.toJavaObject(ComparisonEntity.class);
ComparisonDetailsEntity comparisonDetailsEntity=new ComparisonDetailsEntity();
JSONObject jsonObjectMain=jsonObject.getJSONObject("main");//获取主表数据
if(!checkStr(jsonObjectMain.getString("id"))){
return BaseResult.getFailureMessageEntity("删除时候主表id不能为空");
}
List<ComparisonEntity> comparisonEntities=new ArrayList<>();
//根据主数据编码查询表名称字段名称等信息 10001
try {
@ -364,6 +453,25 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
logger.info("根据主数据编码查询信息错误:{}",e.getMessage());
return BaseResult.getFailureMessageEntity("删除失败");
}
JSONObject jsonObjectMain=new JSONObject();
//根据dbtype和dbname分组拿到表名称和表类型
Map<String, Map<String, List<ComparisonEntity>>> collect = comparisonEntities.stream().collect(Collectors.groupingBy(ComparisonEntity::getDbName, Collectors.groupingBy(ComparisonEntity::getDbType)));
List<Map.Entry<String, String>> keyPairs = collect.entrySet().stream()
.flatMap(e1 -> e1.getValue().keySet().stream()
.map(dbname -> new AbstractMap.SimpleEntry<>(e1.getKey(), dbname)))
.collect(Collectors.toList());
for (Map.Entry<String, String> keyPair : keyPairs) {
if(keyPair.getValue().equals("1")){
String main = jsonObject.getString(keyPair.getKey());
if(main!=null){
jsonObjectMain = JSONObject.parseObject(main);
if(!checkStr(jsonObjectMain.getString("data_id"))){
return BaseResult.getFailureMessageEntity("更新时候主表data_id不能为空");
}
}
}
}
Map<String,Object> map=new HashMap<>();
if(comparisonEntities !=null && comparisonEntities.size()>0) {
for (ComparisonEntity entity : comparisonEntities) {
@ -380,14 +488,27 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
}
}
comparisonEntity.setId(jsonObjectMain.getString("id"));
//根据data_id查询主表id.根据id删除主表数据然后再根据主表id和明细表data_id删除明细表数据
Map<String,Object> mapId=new HashMap<>();
mapId.put("data_id",jsonObjectMain.getString("data_id"));
ComparisonEntity comparison=new ComparisonEntity();
comparison.setDbName(comparisonEntity.getDbName());
comparison.setMap(mapId);
List<Map<String,Object>> comparisonEntitiePages = comparisonDao.queryComparisonPage(comparison);
if(CollectionUtils.isEmpty(comparisonEntitiePages)){
return BaseResult.getFailureMessageEntity("根据data_id查询id数据为空请检查data_id");
}
String id = String.valueOf(comparisonEntitiePages.get(0).get("id"));
comparisonEntity.setId(id);
comparisonEntity.setModify_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
comparisonEntity.setMap(map);
try {
Integer integer = comparisonDao.deleteComparison(comparisonEntity);
if(integer>0){
if(comparisonDetailsEntity.getDbName()!=null){
comparisonDetailsEntity.setFormmainId(jsonObjectMain.getString("id"));
comparisonDetailsEntity.setFormmainId(id);
comparisonDetailsEntity.setModify_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
comparisonDetailsDao.deleteComparisonDetails(comparisonDetailsEntity);
// controlsLogDaoimpl.saveControlsLog(comparisonDetailsEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口删除",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log");
@ -395,7 +516,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
controlsLogDaoimpl.saveControlsLog(comparisonEntity.getId(),jsonObject.getString("appName"),jsonObject.getString("appCode"),jsonObject.toJSONString(),"接口删除",jsonObject.getString("optionName"),comparisonEntity.getDbName()+"_option_log");
return BaseResult.getSuccessMessageEntity("删除成功",integer);
}else{
return BaseResult.getFailureMessageEntity("删除失败","请查看id是否在表中存在");
return BaseResult.getFailureMessageEntity("删除失败","请查看data_id是否在表中存在");
}
}catch (Exception e){
logger.info("删除通用数据数据错误:{}",e.getMessage());
@ -436,7 +557,7 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
//得到主表数据
private Map<String,Object> spliceMainMap(List<ComparisonEntity> comparisonEntities,JSONObject jsonObjectMain,Map<String, Object> map,ComparisonEntity comparisonEntity){
private Map<String,Object> spliceMainMap(List<ComparisonEntity> comparisonEntities,JSONObject jsonObjectMain,Map<String, Object> map,ComparisonEntity comparisonEntity,ComparisonDetailsEntity comparisonDetailsEntity){
for (ComparisonEntity entity : comparisonEntities) {
//遍历主表下面的所有key,字段名
for (String key : jsonObjectMain.keySet()) {
@ -447,27 +568,36 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
map.put(key, jsonObjectMain.getString(key));
}
}
if(entity.getDbType().equals("2")){
comparisonDetailsEntity.setDbName(entity.getDbName());
}
}
}
return map;
}
//得到明细表数据
private Map<String,Object> spliceDetailMap(List<ComparisonEntity> comparisonEntities,Map<String, Object> mapDetails,ComparisonDetailsEntity comparisonDetailsEntity,JSONArray jsonArray){
if (jsonArray != null && jsonArray.size() > 0) {
for (Object object : jsonArray) {
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
for (ComparisonEntity entity : comparisonEntities) {
private List<List<Map<String, Object>>> spliceDetailMap(List<ComparisonEntity> comparisonEntities,List<List<Map<String, Object>>> mapDetails,List<JSONArray> arrayList){
if (arrayList != null && arrayList.size() > 0) {
for (JSONArray jsonArray : arrayList) {
List<Map<String,Object>> list=new ArrayList<>();
for (Object object : jsonArray) {
JSONObject jsonObject = new JSONObject();
JSONObject jsonObjectDetails = (JSONObject) JSON.toJSON(object);
//遍历主表下面的所有key,字段名
for (String key : jsonObjectDetails.keySet()) {
if (entity.getDbType().equals("2")) {
comparisonDetailsEntity.setDbName(entity.getDbName());
if(entity.getEnName().equals(key)){
mapDetails.put(key, jsonObjectDetails.getString(key));
for (ComparisonEntity entity : comparisonEntities) {
if (entity.getDbType().equals("2") && entity.getEnName().equals(key)) {
jsonObject.put(key, jsonObjectDetails.getString(key));
}
if(key.equals("table_name")){
jsonObject.put(key,jsonObjectDetails.getString(key));
}
}
}
list.add(jsonObject);
}
mapDetails.add(list);
}
}
return mapDetails;
@ -518,7 +648,6 @@ public class ComparisonServiceImpl extends BaseService<ComparisonEntity, String>
}
break;
case "option":
//获取主表和明细表的字段信息
if(moduleDbEntity.getDbType().equals("3")){
MdmModuleDbFiledsEntity mdmModuleDbFiledsEntity=new MdmModuleDbFiledsEntity();
mdmModuleDbFiledsEntity.setDbId(moduleDbEntity.getId());

View File

@ -31,74 +31,24 @@ public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService {
}
public static void main(String[] args) {
java.lang.String str = "{\"data\":{\"pk_group\":\"00\",\"enablestate\":\"2\",\"code\":\"20240621001\",\"modify_time\":1718935555000,\"document_rule_num\":2,\"mdm_customer_bank\":[],\"add_status\":\"0\",\"custprop\":\"0\",\"delete_status\":\"1\",\"custstate\":\"1\",\"id\":\"d3d20ea680dc4bffaa7e5bf84764d62a\",\"data_status\":\"Y\",\"modify_user_id\":\"1\",\"sorts\":24,\"document_rule\":\"KH-2024-06-21-00002\",\"create_user_id\":\"1\",\"create_time\":1718935555000,\"company_id\":\"Y\",\"pk_country\":\"CN\",\"update_status\":\"1\",\"sts\":\"Y\",\"pk_custclass\":\"K01\",\"org_id\":\"Y\",\"name\":\"测试下发客户\",\"taxpayerid\":\"087982419238904359\"},\"query\":\"[]\",\"header\":\"[{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"500\\\",\\\"index\\\":0,\\\"concreteType\\\":\\\"String\\\",\\\"description\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNR\\\",\\\"id\\\":\\\"421b73f0-5562-4bfe-b770-c8aca8878bfd\\\",\\\"parameterName\\\":\\\"pubKey\\\",\\\"required\\\":true,\\\"example\\\":\\\"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA87rrNREgMNeOEOwlvM2iqqEfshDadRHziDSB2PbRnoMqSv1nGr3XBlZuseNj5HmxDEkLhOdfyw0yjzoz3wK7XhFpeN4Iyf7NT7hps5jAQMEpnul9Qwmj5qUr/eK5SaO9H8n7sh9BvCdrX9oRUh+U2/ceA3O+y/MUHk5DRvSadc8FhpqbOaNBbAzPnyYAwpVUPvaJ90jcGN1ZG99HR1GEzC+Cn9s6vgt7dYL6ysMs36bSP47xraDSxpfr0CLwa6JV/9KjLIeqL1ZaMtK0CJ1zJGCBA6O6kgxeE9Ul7q2lSS6mPAEJ78izaTYsrjhLpKT+eTtFBOLFbiCrbLp8tVE5kwIDAQAB\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"length\\\":\\\"100\\\",\\\"index\\\":1,\\\"concreteType\\\":\\\"String\\\",\\\"description\\\":\\\"OA\\\",\\\"id\\\":\\\"5659424d-261d-43ed-9fff-657bd15c7a64\\\",\\\"parameterName\\\":\\\"client_id\\\",\\\"required\\\":true,\\\"example\\\":\\\"OA\\\"},{\\\"parameterType\\\":\\\"authport\\\",\\\"length\\\":\\\"100\\\",\\\"index\\\":2,\\\"concreteType\\\":\\\"String\\\",\\\"id\\\":\\\"d2c4477e-a0bb-4daa-97b4-3cf0b8445001\\\",\\\"parameterName\\\":\\\"access_token\\\",\\\"required\\\":true,\\\"example\\\":[\\\"attribute\\\",\\\"data\\\",\\\"access_token\\\"]}]\",\"body\":\"[{\\\"index\\\":0,\\\"id\\\":\\\"5ac44a3b-c0d5-4ae9-aec6-af6c4c8f59cc\\\",\\\"parameterName\\\":\\\"body\\\",\\\"first\\\":true}]\"}";
java.lang.String str1 = "com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject();\n" +
" com.alibaba.fastjson.JSONObject bodys = new com.alibaba.fastjson.JSONObject();\n" +
"\n" +
" com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr);\n" +
" com.alibaba.fastjson.JSONObject data = reqData.getJSONObject(\"data\");\n" +
" com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject();\n" +
" ufinterfaceObject.put(\"billtype\", \"customer\");\n" +
" ufinterfaceObject.put(\"isexchange\", \"Y\");\n" +
" ufinterfaceObject.put(\"replace\", \"Y\");\n" +
" ufinterfaceObject.put(\"sender\", \"OA\");\n" +
" ufinterfaceObject.put(\"account\", \"01\");\n" +
" ufinterfaceObject.put(\"groupcode\", \"00\");\n" +
" com.alibaba.fastjson.JSONObject billObject = new com.alibaba.fastjson.JSONObject();\n" +
" com.alibaba.fastjson.JSONObject billheadObject = new com.alibaba.fastjson.JSONObject();\n" +
" billheadObject.put(\"code\", data.get(\"code\"));\n" +
" billheadObject.put(\"custprop\", data.get(\"custprop\"));\n" +
" billheadObject.put(\"custstate\", data.get(\"custstate\"));\n" +
" billheadObject.put(\"pk_custclass\", data.get(\"pk_custclass\"));\n" +
" billheadObject.put(\"pk_country\", data.get(\"pk_country\"));\n" +
" billheadObject.put(\"pk_timezone\", \"P0800\");\n" +
" billheadObject.put(\"pk_format\", \"ZH-CN\");\n" +
" billheadObject.put(\"enablestate\", data.get(\"enablestate\"));\n" +
" billheadObject.put(\"name\", data.get(\"name\"));\n" +
" billheadObject.put(\"pk_group\", data.get(\"pk_group\"));\n" +
" billheadObject.put(\"pk_org\", data.get(\"pk_org\"));\n" +
" billheadObject.put(\"taxpayerid\", data.get(\"taxpayerid\"));\n" +
" billObject.put(\"billhead\", billheadObject);\n" +
" ufinterfaceObject.put(\"bill\", billObject);\n" +
" bodys.put(\"ufinterface\", ufinterfaceObject);\n" +
" returnObject.put(\"bodys\",bodys.toJSONString());\n" +
" return returnObject.toJSONString();".trim();
String newString =str1.replaceAll("\\s+", "");
java.lang.String str = "{\"data\":{\"document_rule\":\"RY-2024-06-25-00001\",\"create_user_id\":\"1\",\"mdm_psnjobs\":[],\"create_time\":1719287779000,\"company_id\":\"Y\",\"modify_time\":1719287779000,\"sex\":\"\",\"mobile\":\"13758050335\",\"document_rule_num\":1,\"add_status\":\"0\",\"update_status\":\"1\",\"sts\":\"Y\",\"delete_status\":\"1\",\"org_id\":\"Y\",\"name\":\"张三1\",\"id\":\"ba0ed50f82e94f8e8a0d000d09795961\",\"data_status\":\"Y\",\"modify_user_id\":\"1\",\"sorts\":5},\"query\":\"[]\",\"header\":\"[]\",\"body\":\"[{\\\"parameterType\\\":\\\"complex\\\",\\\"children\\\":[{\\\"parameterType\\\":\\\"fundamental\\\",\\\"concreteType\\\":\\\"String\\\",\\\"index\\\":1,\\\"description\\\":\\\"用户名\\\",\\\"parameterName\\\":\\\"userName\\\",\\\"id\\\":\\\"3e5627fd-97a8-40ec-bb54-a973de695ad7\\\",\\\"example\\\":\\\"137000000\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"concreteType\\\":\\\"String\\\",\\\"index\\\":2,\\\"description\\\":\\\"性别 男 女\\\",\\\"parameterName\\\":\\\"gender\\\",\\\"id\\\":\\\"e7ec2721-8fa0-4301-9d71-64c93558efdf\\\",\\\"example\\\":\\\"\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"concreteType\\\":\\\"String\\\",\\\"index\\\":3,\\\"description\\\":\\\"用户真实姓名\\\",\\\"parameterName\\\":\\\"userTrueName\\\",\\\"id\\\":\\\"fb760309-f24c-4638-ba19-f15a0fdba653\\\",\\\"example\\\":\\\"张三\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"concreteType\\\":\\\"String\\\",\\\"index\\\":4,\\\"description\\\":\\\"密码\\\",\\\"parameterName\\\":\\\"userPwd\\\",\\\"id\\\":\\\"a651ce81-f7ee-4aa2-ad48-4afa35fb584c\\\",\\\"example\\\":\\\"123456\\\"},{\\\"parameterType\\\":\\\"fundamental\\\",\\\"concreteType\\\":\\\"String\\\",\\\"index\\\":5,\\\"description\\\":\\\"电话\\\",\\\"parameterName\\\":\\\"mobile\\\",\\\"id\\\":\\\"dad12b91-0c9f-45f2-9dc2-294bb50d5a29\\\",\\\"example\\\":\\\"137000000\\\"}],\\\"concreteType\\\":\\\"Object\\\",\\\"index\\\":0,\\\"id\\\":\\\"d643e859-fd5b-4b40-ab68-7092739dc2b9\\\",\\\"parameterName\\\":\\\"body\\\",\\\"first\\\":true}]\"}";
A88772 s = new A88772();
s.execute(str);
}
static class A88772 {
String execute(String jsonStr) {
com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject bodys = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject reqData = com.alibaba.fastjson.JSON.parseObject(jsonStr);
com.alibaba.fastjson.JSONObject data = reqData.getJSONObject("data");
com.alibaba.fastjson.JSONObject ufinterfaceObject = new com.alibaba.fastjson.JSONObject();
ufinterfaceObject.put("billtype", "customer");
ufinterfaceObject.put("isexchange", "Y");
ufinterfaceObject.put("replace", "Y");
ufinterfaceObject.put("sender", "OA");
ufinterfaceObject.put("account", "01");
ufinterfaceObject.put("groupcode", "00");
com.alibaba.fastjson.JSONObject billObject = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject billheadObject = new com.alibaba.fastjson.JSONObject();
billheadObject.put("code", data.get("code"));
billheadObject.put("custprop", data.get("custprop"));
billheadObject.put("custstate", data.get("custstate"));
billheadObject.put("pk_custclass", data.get("pk_custclass"));
billheadObject.put("pk_country", data.get("pk_country"));
billheadObject.put("pk_timezone", "P0800");
billheadObject.put("pk_format", "ZH-CN");
billheadObject.put("enablestate", data.get("enablestate"));
billheadObject.put("name", data.get("name"));
billheadObject.put("pk_group", data.get("pk_group"));
billheadObject.put("pk_org", data.get("pk_org"));
billheadObject.put("taxpayerid", data.get("taxpayerid"));
billObject.put("billhead", billheadObject);
ufinterfaceObject.put("bill", billObject);
bodys.put("ufinterface", ufinterfaceObject);
com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject bodys = new com.alibaba.fastjson.JSONObject();
bodys.put("userName", data.get("login_name"));
if(data.get("gender") != null){
bodys.put("gender", data.get("gender"));
}
bodys.put("userTrueName", data.get("user_name"));
bodys.put("userPwd", "Hzya@1314");
bodys.put("mobile", data.get("mobile"));
returnObject.put("bodys",bodys.toJSONString());
return returnObject.toJSONString();
}

View File

@ -4,6 +4,8 @@ package com.hzya.frame.web.quartz;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.sysnew.application.database.dao.ISysApplicationDatabaseDao;
import com.hzya.frame.sysnew.application.database.entity.SysApplicationDatabaseEntity;
import com.hzya.frame.sysnew.application.plugin.entity.SysApplicationPluginEntity;
import com.hzya.frame.sysnew.integtationTask.IIntegrationTaskCacheableService;
import com.hzya.frame.sysnew.integtationTask.entity.IntegrationTaskEntity;
@ -19,6 +21,7 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -31,6 +34,8 @@ public class QuartzJobFactory implements Job {
private IIntegrationTaskCacheableService iIntegrationTaskCacheableService;
@Resource
private IIntegrationTaskLogDao integrationTaskLogDao;
@Resource
private ISysApplicationDatabaseDao sysApplicationDatabaseDao;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
//当前开始时间
@ -103,6 +108,16 @@ public class QuartzJobFactory implements Job {
"2","3","插件未启用,不执行任务",startTime,startTime,new Date());
return;
}
String sourceCode = null;
//查找应用的数据源编码
SysApplicationDatabaseEntity sysApplicationDatabaseEntity = new SysApplicationDatabaseEntity();
sysApplicationDatabaseEntity.setAppId(sysApplicationPluginEntity.getAppId());
sysApplicationDatabaseEntity.setSts("Y");
List<SysApplicationDatabaseEntity> sysApplicationDatabaseEntities = sysApplicationDatabaseDao.queryBase(sysApplicationDatabaseEntity);
if(sysApplicationDatabaseEntities != null && sysApplicationDatabaseEntities.size() == 1){
sourceCode = sysApplicationDatabaseEntities.get(0).getSourceCode();
}
//查找插件
PluginBaseEntity pluginBaseEntity = PluginUtils.getPluginsById(sysApplicationPluginEntity.getPluginCode());
if(pluginBaseEntity == null ){
@ -114,6 +129,7 @@ public class QuartzJobFactory implements Job {
JSONObject req = new JSONObject();
req.put("startTime",oldStartTime);
req.put("endTime",startTime);
req.put("sourceCode",sourceCode);
try {
JsonResultEntity jsonResultEntity = pluginBaseEntity.executeBusiness(req);
if(jsonResultEntity.isFlag()){