应付单
This commit is contained in:
parent
bdbcd96bf4
commit
3c637e911d
|
@ -0,0 +1,56 @@
|
||||||
|
package com.hzya.frame.plugin.payables.plugin;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.base.PluginBaseEntity;
|
||||||
|
import com.hzya.frame.sysnew.payables.service.IPayablesService;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class PayablesPluginInitializer extends PluginBaseEntity {
|
||||||
|
Logger logger = LoggerFactory.getLogger(PayablesPluginInitializer.class);
|
||||||
|
@Autowired
|
||||||
|
private IPayablesService payablesService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginId() {
|
||||||
|
return "PayablesPluginInitializer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginName() {
|
||||||
|
return "应付单抽取";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginLabel() {
|
||||||
|
return "PayablesPluginInitializer";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPluginType() {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||||
|
try {
|
||||||
|
logger.info("======开始执行应付单同步========");
|
||||||
|
return payablesService.queryPayables(requestJson);
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("======执行应付单失败:{}========",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<plugin>
|
||||||
|
<id>PayablesPluginInitializer</id>
|
||||||
|
<name>PayablesPluginInitializer插件</name>
|
||||||
|
<category>90000009</category>
|
||||||
|
</plugin>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||||
|
<beans default-autowire="byName">
|
||||||
|
<bean name="PayablesPluginInitializer" class="com.hzya.frame.plugin.payables.plugin.PayablesPluginInitializer" />
|
||||||
|
</beans>
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.hzya.frame.sysnew.payables.dao;
|
||||||
|
|
||||||
|
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
|
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
|
||||||
|
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IPayablesDao extends IBaseDao<PayablesEntity,String> {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 查询三维应付单数据
|
||||||
|
* @Param
|
||||||
|
* @Return
|
||||||
|
* @Author hecan
|
||||||
|
* @Date 2024-11-28 14:50
|
||||||
|
* **/
|
||||||
|
List<HashMap<String, Object>> queryListByPayables(String str , MdmModuleSourceEntity entity);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.hzya.frame.sysnew.payables.dao.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.execsql.service.IExecSqlService;
|
||||||
|
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
|
||||||
|
import com.hzya.frame.sysnew.payables.dao.IPayablesDao;
|
||||||
|
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository(value = "PayablesDaoImpl")
|
||||||
|
public class PayablesDaoImpl extends MybatisGenericDao<PayablesEntity,String> implements IPayablesDao {
|
||||||
|
@Autowired
|
||||||
|
private IExecSqlService execSqlService;
|
||||||
|
|
||||||
|
private Logger logger = LogManager.getLogger(super.getClass());
|
||||||
|
|
||||||
|
@DS("#entity.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> queryListByPayables(String str, MdmModuleSourceEntity entity) {
|
||||||
|
try {
|
||||||
|
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
|
||||||
|
return hashMaps;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("三维应付单中没有需要同步中台的数据");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.hzya.frame.sysnew.payables.entity;
|
||||||
|
|
||||||
|
import com.hzya.frame.web.entity.BaseEntity;
|
||||||
|
|
||||||
|
public class PayablesEntity extends BaseEntity {
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.hzya.frame.sysnew.payables.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.basedao.service.IBaseService;
|
||||||
|
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
|
||||||
|
public interface IPayablesService extends IBaseService<PayablesEntity,String> {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 查询需要抽取得数据
|
||||||
|
* @Param
|
||||||
|
* @Return
|
||||||
|
* @Author hecan
|
||||||
|
* @Date 2024-11-28 14:54
|
||||||
|
* **/
|
||||||
|
JsonResultEntity queryPayables(JSONObject json);
|
||||||
|
}
|
|
@ -0,0 +1,221 @@
|
||||||
|
package com.hzya.frame.sysnew.payables.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
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.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
|
||||||
|
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
|
||||||
|
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
|
||||||
|
import com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity;
|
||||||
|
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||||
|
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
||||||
|
import com.hzya.frame.sysnew.payables.dao.impl.PayablesDaoImpl;
|
||||||
|
import com.hzya.frame.sysnew.payables.entity.PayablesEntity;
|
||||||
|
import com.hzya.frame.sysnew.payables.service.IPayablesService;
|
||||||
|
import com.hzya.frame.uuid.UUIDUtils;
|
||||||
|
import com.hzya.frame.web.entity.BaseResult;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import lombok.Value;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service(value = "PayablesServiceImpl")
|
||||||
|
public class PayablesServiceImpl extends BaseService<PayablesEntity,String> implements IPayablesService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PayablesDaoImpl payablesDao;
|
||||||
|
@Autowired
|
||||||
|
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||||
|
@Autowired
|
||||||
|
private ComparisonServiceImpl comparisonServiceimpl;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity queryPayables(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) {
|
||||||
|
String startTime = DateUtil.format(json.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的开始时间
|
||||||
|
String endTime = DateUtil.format(json.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的结束时间
|
||||||
|
String tableName = "";
|
||||||
|
List<Object> object=new ArrayList<>();
|
||||||
|
List<JSONObject> listAll = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
String appTyp = mdmModuleSourceEntity.getAppType();//系统类型 1、致远OA 2、用友U8C 3、用友BIP
|
||||||
|
String dbCode = mdmModuleSourceEntity.getDbCode();//数据源编码
|
||||||
|
String mdmCode = mdmModuleSourceEntity.getMdmCode();//主数据编码
|
||||||
|
switch (appTyp){
|
||||||
|
case "1":
|
||||||
|
switch (mdmCode){
|
||||||
|
case "10050"://应付单
|
||||||
|
tableName = "mdm_payables";
|
||||||
|
listAll = bindingPayables(jsonObject, mdmModuleSourceEntity, dbCode,startTime,endTime);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//将查询出来的数据进行组装,调用通用方法新增或者更新
|
||||||
|
if (null != listAll && listAll.size() > 0) {
|
||||||
|
ParametricDocument(listAll, mdmCode, tableName);
|
||||||
|
} else {
|
||||||
|
logger.info("三维应付单没有需要同步中台的数据");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("应付单同步失败:{}",e.getMessage());
|
||||||
|
saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_payables")).getString("data_id"),JSONObject.parseObject(listAll.get(0).getString("mdm_payables")).getString("sourcecode"),listAll.get(0).toString(),JSON.parseObject(JSON.toJSONString(object)).getString("msg")==null?JSON.parseObject(JSON.toJSONString(object)).getString("list"):JSON.parseObject(JSON.toJSONString(object)).getString("msg"),false);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BaseResult.getSuccessMessageEntity("业务数据同步成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<JSONObject> bindingPayables(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode,String startTime,String endTime) {
|
||||||
|
String formmainId=null;
|
||||||
|
String vdef1=null;
|
||||||
|
List<JSONObject> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
if(StrUtil.isNotEmpty(startTime) && StrUtil.isNotEmpty(endTime)){
|
||||||
|
sb.append(" AND MODIFY_DATE >= TO_DATE('"+startTime+"','yyyy-MM-dd HH24:mi:ss') ");
|
||||||
|
sb.append(" AND MODIFY_DATE <> TO_DATE('"+endTime+"','yyyy-MM-dd HH24:mi:ss') ");
|
||||||
|
}
|
||||||
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
stringBuffer.append("select * from v_hzya_payables where 1=1 "+sb.toString());
|
||||||
|
mdmModuleSourceEntity.setDataSourceCode(dbCode);
|
||||||
|
List<HashMap<String, Object>> hashMaps = payablesDao.queryListByPayables(stringBuffer.toString(), mdmModuleSourceEntity);
|
||||||
|
int i = 0;
|
||||||
|
if (CollectionUtils.isNotEmpty(hashMaps)) {
|
||||||
|
for (HashMap<String, Object> hashMap : hashMaps) {
|
||||||
|
JSONObject main = new JSONObject();
|
||||||
|
JSONObject payables = new JSONObject();
|
||||||
|
for (String key : hashMap.keySet()) {
|
||||||
|
payables.put(key.toLowerCase(), hashMap.get(key));
|
||||||
|
}
|
||||||
|
//获取明细信息
|
||||||
|
formmainId = payables.getString("data_id");
|
||||||
|
StringBuffer stringBufferDetails = new StringBuffer();
|
||||||
|
stringBufferDetails.append("select * from v_hzya_payables_details where f_id= '"+formmainId+"' " );
|
||||||
|
List<HashMap<String, Object>> hashMapsDetails = payablesDao.queryListByPayables(stringBufferDetails.toString(),mdmModuleSourceEntity);
|
||||||
|
JSONArray payables_details = new JSONArray();
|
||||||
|
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
|
||||||
|
for (HashMap<String, Object> detailsMap : hashMapsDetails) {
|
||||||
|
JSONObject details = new JSONObject();
|
||||||
|
for (String key : detailsMap.keySet()) {
|
||||||
|
details.put(key.toLowerCase(), detailsMap.get(key));
|
||||||
|
}
|
||||||
|
payables_details.add(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main.put("mdm_payables_details",payables_details);
|
||||||
|
main.put("mdm_payables", payables);
|
||||||
|
list.add(main);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("组装单据是图查询参数失败:{}", e.getMessage());
|
||||||
|
//保存业务数据日志
|
||||||
|
saveTaskLivingDetails(formmainId,vdef1,list.toString(),null,false);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<Object> ParametricDocument(List<JSONObject> hashMaps,String mdmCode,String tableName){
|
||||||
|
JSONObject jsonObjectUser = new JSONObject();
|
||||||
|
List<Object> result=new ArrayList<>();
|
||||||
|
try {
|
||||||
|
for (JSONObject hashMap : hashMaps) {
|
||||||
|
JSONObject main = hashMap.getJSONObject(tableName);
|
||||||
|
JSONObject jsonStr = new JSONObject();
|
||||||
|
jsonObjectUser.put("data_id", main.get("data_id"));
|
||||||
|
jsonObjectUser.put("mdmCode", mdmCode);
|
||||||
|
jsonStr.put("jsonStr", jsonObjectUser);
|
||||||
|
//先查询编码和名称查询是否存在
|
||||||
|
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
|
||||||
|
logger.info("得到的attribute值为:{}", jsonStr.toJSONString(attribute));
|
||||||
|
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
|
||||||
|
JSONObject pageInfo = jsonObjectAttribute.getJSONObject("pageInfo");
|
||||||
|
JSONArray jsonArrayList = pageInfo.getJSONArray("list");
|
||||||
|
//如果jsonArrayList为null,说明没有值,在表中不存在
|
||||||
|
if (jsonArrayList == null || jsonArrayList.size() == 0) {
|
||||||
|
hashMap.put("appName","数智中台");
|
||||||
|
hashMap.put("appCode","800004");
|
||||||
|
hashMap.put("mdmCode", mdmCode);
|
||||||
|
hashMap.put("optionName", "数智中台");
|
||||||
|
jsonStr.put("jsonStr", hashMap);
|
||||||
|
Object object = comparisonServiceimpl.saveEntity(jsonStr);
|
||||||
|
logger.info("应付单新增结果为:{}", JSON.toJSONString(object));
|
||||||
|
result.add(object);
|
||||||
|
} else {
|
||||||
|
hashMap.put("appName","数智中台");
|
||||||
|
hashMap.put("appCode","800004");
|
||||||
|
hashMap.put("mdmCode", mdmCode);
|
||||||
|
hashMap.put("optionName", "数智中台");
|
||||||
|
jsonStr.put("jsonStr", hashMap);
|
||||||
|
Object object = comparisonServiceimpl.updateEntity(jsonStr);
|
||||||
|
logger.info("应付单更新结果为:{}", JSON.toJSONString(result));
|
||||||
|
result.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage());
|
||||||
|
//保存业务数据日志
|
||||||
|
saveTaskLivingDetails(jsonObjectUser.getString("data_id"),hashMaps.get(0).getString("sourcecode"),hashMaps.get(0).toString(),result.toString(),false);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
|
||||||
|
try {
|
||||||
|
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
|
||||||
|
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
|
||||||
|
integrationTaskLivingDetailsEntity.setSts("Y");
|
||||||
|
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
|
||||||
|
integrationTaskLivingDetailsEntity.setModify_user_id("1");
|
||||||
|
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
|
||||||
|
integrationTaskLivingDetailsEntity.setModify_time(new Date());
|
||||||
|
integrationTaskLivingDetailsEntity.setOrg_id("0");
|
||||||
|
integrationTaskLivingDetailsEntity.setCompanyId("0");
|
||||||
|
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
|
||||||
|
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
|
||||||
|
integrationTaskLivingDetailsEntity.setPluginId("PayablesPluginInitializer");
|
||||||
|
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
|
||||||
|
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
|
||||||
|
if(flag){
|
||||||
|
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
|
||||||
|
}else {
|
||||||
|
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.info("应付单抽取保存日志到集成任务日志明细中失败:{}",e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue