diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/serviceData/plugin/ServiceDataDistributePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/serviceData/plugin/ServiceDataDistributePluginInitializer.java index e9e75a77..a103bdb1 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/serviceData/plugin/ServiceDataDistributePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/serviceData/plugin/ServiceDataDistributePluginInitializer.java @@ -27,6 +27,8 @@ import com.hzya.frame.sysnew.application.dao.ISysApplicationDao; import com.hzya.frame.sysnew.application.entity.SysApplicationEntity; import com.hzya.frame.sysnew.application.script.dao.ISysApplicationScriptDao; import com.hzya.frame.sysnew.application.script.entity.SysApplicationScriptEntity; +import com.hzya.frame.sysnew.comparison.serviceData.dao.IServiceDataDao; +import com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity; import com.hzya.frame.sysnew.comparison.serviceData.service.IServiceDataService; import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService; import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; @@ -34,6 +36,7 @@ import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTa import com.hzya.frame.uuid.UUIDUtils; import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.JsonResultEntity; +import org.apache.commons.collections.CollectionUtils; import org.apache.http.HttpEntity; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; @@ -81,6 +84,8 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{ private IMdmServiceCache mdmServiceCache; @Resource private IMdmModuleSendLogDao mdmModuleSendLogDao; + @Autowired + private IServiceDataDao serviceDataDao; @Resource private IMdmModuleDistributeTripartiteDao mdmModuleDistributeTripartiteDao; @Value("${zt.url}") @@ -123,6 +128,7 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{ @Override public JsonResultEntity executeBusiness(JSONObject requestJson) { try{ + //重试方法 //重试方法 if (null != requestJson) { //如果这个id不为空,说明是重试的 @@ -389,7 +395,7 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{ } } Map headers = new HashMap<>(); - headers.put("publicKey","/ObJxb7dT7sD8HPRDZJYAWb7lhAUTYqekPkU+uHJv1GAgyhCe7eDIk+3zDUT+v578prj"); + headers.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); headers.put("appId",sysApplicationEntity.getAppId().toString()); headers.put("apiCode",apiEntity.getApiCode().toString()); @@ -449,8 +455,27 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{ mdmModuleDistributeTripartiteEntity.setMdmId(mdmModuleEntity.getId()); mdmModuleDistributeTripartiteEntity.setDataId(object.getString("id")); mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); - mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); + mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("vbillno")); mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); + //根据OA单据编号更新BIP付款申请单号 + JSONObject jsonObjectBody = JSONObject.parseObject(bodys); + String parent = jsonObjectBody.getString("parent"); + JSONObject jsonObjectParent = JSONObject.parseObject(parent); + ServiceDataEntity serviceDataEntity=new ServiceDataEntity(); + serviceDataEntity.setBillCode(jsonObjectParent.getString("vdef1")); + serviceDataEntity.setDataSourceCode("SW-OA"); + List query = serviceDataDao.query(serviceDataEntity); + if(CollectionUtils.isNotEmpty(query)){ + logger.info("===下发时候,开始根据OA单据编号:{}更新BIP付款申请单号:{}",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno")); + serviceDataEntity.setTabName(query.get(0).getTabName()); + serviceDataEntity.setBipPaymentNumberField(query.get(0).getBipPaymentNumberField()); + serviceDataEntity.setBipPaymentNumber(query.get(0).getBipPaymentNumber()); + serviceDataEntity.setId(query.get(0).getId()); + serviceDataDao.updateBipPaymentNumber(serviceDataEntity); + logger.info("===下发时候,根据OA单据编号:{}更新BIP付款申请单号:{}完毕",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno")); + }else{ + logger.info("======下发时候根据单据编号:{}未能在三维OA查询到数据,Bip付款申请单号不回写",jsonObjectParent.getString("vdef1")); + } } } } catch (Exception e) { @@ -515,9 +540,9 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{ //新增 doAdd(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); //修改 - doUpdate(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + //doUpdate(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); //删除 - doDelete(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); + //doDelete(mdmModuleEntities.get(i).getId(),mdmCode,mdmModuleDbEntities,mdmModuleDistributeEntities,mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); } @@ -1115,8 +1140,27 @@ public class ServiceDataDistributePluginInitializer extends PluginBaseEntity{ mdmModuleDistributeTripartiteEntity.setMdmId(mdmId); mdmModuleDistributeTripartiteEntity.setDataId(objects.get(i).getString("id")); mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); - mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); + mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("vbillno")); mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); + //根据OA单据编号更新BIP付款申请单号 + JSONObject jsonObjectBody = JSONObject.parseObject(bodys); + String parent = jsonObjectBody.getString("parent"); + JSONObject jsonObjectParent = JSONObject.parseObject(parent); + ServiceDataEntity serviceDataEntity=new ServiceDataEntity(); + serviceDataEntity.setBillCode(jsonObjectParent.getString("vdef1")); + serviceDataEntity.setDataSourceCode("SW-OA"); + List query = serviceDataDao.query(serviceDataEntity); + if(CollectionUtils.isNotEmpty(query)){ + logger.info("===下发时候,开始根据OA单据编号:{}更新BIP付款申请单号:{}",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno")); + serviceDataEntity.setTabName(query.get(0).getTabName()); + serviceDataEntity.setBipPaymentNumberField(query.get(0).getBipPaymentNumberField()); + serviceDataEntity.setBipPaymentNumber(backJsonResultEntity.getString("vbillno")); + serviceDataEntity.setId(query.get(0).getId()); + serviceDataDao.updateBipPaymentNumber(serviceDataEntity); + logger.info("===下发时候,根据OA单据编号:{}更新BIP付款申请单号:{}完毕",jsonObjectParent.getString("vdef1"),backJsonResultEntity.getString("vbillno")); + }else{ + logger.info("======下发时候根据单据编号:{}未能在三维OA查询到数据,Bip付款申请单号不回写",jsonObjectParent.getString("vdef1")); + } } } } catch (Exception e) { diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/ICtpAttachmentDao.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/ICtpAttachmentDao.java new file mode 100644 index 00000000..fe2503ea --- /dev/null +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/ICtpAttachmentDao.java @@ -0,0 +1,7 @@ +package com.hzya.frame.sysnew.comparison.serviceData.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.sysnew.comparison.serviceData.entity.CtpAttachmentEntity; + +public interface ICtpAttachmentDao extends IBaseDao { +} diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/IServiceDataDao.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/IServiceDataDao.java index f5060e18..b3a30953 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/IServiceDataDao.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/IServiceDataDao.java @@ -2,12 +2,12 @@ package com.hzya.frame.sysnew.comparison.serviceData.dao; import com.hzya.frame.basedao.dao.IBaseDao; import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; -import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity; +import com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity; import java.util.HashMap; import java.util.List; -public interface IServiceDataDao extends IBaseDao { +public interface IServiceDataDao extends IBaseDao { /** * * @content 查询三维单据视图 @@ -17,4 +17,64 @@ public interface IServiceDataDao extends IBaseDao { * @Date 2024-11-28 14:50 * **/ List> queryListBySWSource(String str , MdmModuleSourceEntity entity); + + /** + * + * @content 数据抽取成功更新推送标识 + * @Param + * @Return + * @Author hecan + * @Date 2024-12-05 17:58 + * **/ + Integer updatePushStatus(ServiceDataEntity entity); + + /** + * + * @content 数据下发成功将Bip付款申请单回写 + * @Param + * @Return + * @Author hecan + * @Date 2024-12-07 9:34 + * **/ + Integer updateBipPaymentNumber(ServiceDataEntity entity); + + /** + * + * @content 付款申请单支付状态和支付时间回写 + * @Param + * @Return + * @Author hecan + * @Date 2024-12-07 9:32 + * **/ + Integer updatePayResult(ServiceDataEntity entity); + + /** + * + * @content 查询支付结果不为成功,失败等状态得数据 + * @Param + * @Return + * @Author hecan + * @Date 2024-12-07 9:55 + * **/ + List querySeriveDateResult(ServiceDataEntity entity); + + /** + * + * @content 查询电子回单为空,并且支付状态为成功的数据 + * @Param + * @Return + * @Author hecan + * @Date 2024-12-09 10:20 + * **/ + List queryServiceElectronic(ServiceDataEntity entity); + + /** + * + * @content 更新电子回单数据 + * @Param + * @Return + * @Author hecan + * @Date 2024-12-09 11:56 + * **/ + Integer updateElectronic(ServiceDataEntity entity); } diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/CtpAttachmentDaoImpl.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/CtpAttachmentDaoImpl.java new file mode 100644 index 00000000..4661361b --- /dev/null +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/CtpAttachmentDaoImpl.java @@ -0,0 +1,11 @@ +package com.hzya.frame.sysnew.comparison.serviceData.dao.impl; + +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.sysnew.comparison.serviceData.dao.ICtpAttachmentDao; +import com.hzya.frame.sysnew.comparison.serviceData.dao.IServiceDataDao; +import com.hzya.frame.sysnew.comparison.serviceData.entity.CtpAttachmentEntity; +import org.springframework.stereotype.Repository; + +@Repository(value = "CtpAttachmentDaoImpl") +public class CtpAttachmentDaoImpl extends MybatisGenericDao implements ICtpAttachmentDao { +} diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/ServiceDataDaoImpl.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/ServiceDataDaoImpl.java index 617ba55a..c870cc31 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/ServiceDataDaoImpl.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/dao/impl/ServiceDataDaoImpl.java @@ -6,6 +6,7 @@ import com.hzya.frame.execsql.service.IExecSqlService; import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity; import com.hzya.frame.sysnew.comparison.serviceData.dao.IServiceDataDao; +import com.hzya.frame.sysnew.comparison.serviceData.entity.ServiceDataEntity; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -14,7 +15,7 @@ import org.springframework.stereotype.Repository; import java.util.HashMap; import java.util.List; @Repository(value = "ServiceDataDaoImpl") -public class ServiceDataDaoImpl extends MybatisGenericDao implements IServiceDataDao { +public class ServiceDataDaoImpl extends MybatisGenericDao implements IServiceDataDao { @Autowired private IExecSqlService execSqlService; @@ -31,4 +32,39 @@ public class ServiceDataDaoImpl extends MybatisGenericDao querySeriveDateResult(ServiceDataEntity entity) { + return (List) super.selectList("querySeriveDateResult",entity); + } + + @DS("#entity.dataSourceCode") + @Override + public List queryServiceElectronic(ServiceDataEntity entity) { + return (List) super.selectList("queryServiceElectronic",entity); + } + + @Override + public Integer updateElectronic(ServiceDataEntity entity) { + return super.update("updateElectronic",entity); + } } diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/CtpAttachmentEntity.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/CtpAttachmentEntity.java new file mode 100644 index 00000000..63a02dab --- /dev/null +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/CtpAttachmentEntity.java @@ -0,0 +1,129 @@ +package com.hzya.frame.sysnew.comparison.serviceData.entity; + + +import com.hzya.frame.web.entity.BaseEntity; + +import java.util.Date; + +/** + * + * @content OA附件业务表 + * @Param + * @Return + * @Author hecan + * @Date 2023/11/30 16:04 + * **/ +public class CtpAttachmentEntity extends BaseEntity { + private String id;//主键ID + private String sub_reference;//次数据ID此id为真正写在流程表单中的ID + private String category; //应用分类、 + private String type;//分类 + private String filename;//附件名称 + private String file_url;//附件链接 + private String mime_type;// + private Date createdate;//创建时间 + private String attachment_size;//附件大小 + private String sort;//序号 + private String att_reference;//流程表的ID(col_summary) + private String uuid; + + @Override + public String getId() { + return id; + } + + @Override + public void setId(String id) { + this.id = id; + } + + public String getSub_reference() { + return sub_reference; + } + + public void setSub_reference(String sub_reference) { + this.sub_reference = sub_reference; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public String getFile_url() { + return file_url; + } + + public void setFile_url(String file_url) { + this.file_url = file_url; + } + + public String getMime_type() { + return mime_type; + } + + public void setMime_type(String mime_type) { + this.mime_type = mime_type; + } + + public Date getCreatedate() { + return createdate; + } + + public void setCreatedate(Date createdate) { + this.createdate = createdate; + } + + public String getAttachment_size() { + return attachment_size; + } + + public void setAttachment_size(String attachment_size) { + this.attachment_size = attachment_size; + } + + @Override + public String getSort() { + return sort; + } + + @Override + public void setSort(String sort) { + this.sort = sort; + } + + public String getAtt_reference() { + return att_reference; + } + + public void setAtt_reference(String att_reference) { + this.att_reference = att_reference; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } +} diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/CtpAttachmentEntity.xml b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/CtpAttachmentEntity.xml new file mode 100644 index 00000000..60e32bb5 --- /dev/null +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/CtpAttachmentEntity.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + id, + sub_reference, + category, + type, + filename, + file_url, + mime_type, + createdate, + attachment_size, + sort, + att_reference + + + + + + + + + + insert into CTP_ATTACHMENT( + + id, + sub_reference, + category, + type, + filename, + file_url, + mime_type, + attachment_size, + sort, + att_reference, + createdate + + )values + ( + + #{id}, + #{sub_reference}, + #{category}, + #{type}, + #{filename}, + #{file_url}, + #{mime_type}, + #{attachment_size}, + #{sort}, + #{att_reference}, + #{createdate} + + ) + + + + + update CTP_ATTACHMENT set + + sub_reference = #{sub_reference}, + att_reference = #{att_reference} + + where file_url = #{file_url} + + + + diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/ServiceDataEntity.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/ServiceDataEntity.java new file mode 100644 index 00000000..eeb4c0cf --- /dev/null +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/ServiceDataEntity.java @@ -0,0 +1,126 @@ +package com.hzya.frame.sysnew.comparison.serviceData.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +public class ServiceDataEntity extends BaseEntity { + private String tabName;//表名 + private String pushStatusField;//推送标识字段 + private String pushStatus;//推送标识值 + private String bipPaymentNumber;//Bip付款申请单号字段 + private String bipPaymentNumberField;//bip付款申请单号值 + private String payResult;//支付结果值 + private String payDate;//支付时间值 + private String payResultFiled;//支付结果字段 + private String payDateFiled;//支付时间字段 + private String receiptFiled;//电子回单字段 + private String receipt;//电子回单值 + private String billCode;//单据编号 + + private String summary_id;//summary_id + + + + public String getSummary_id() { + return summary_id; + } + + public void setSummary_id(String summary_id) { + this.summary_id = summary_id; + } + + public String getTabName() { + return tabName; + } + + public void setTabName(String tabName) { + this.tabName = tabName; + } + + public String getPushStatusField() { + return pushStatusField; + } + + public void setPushStatusField(String pushStatusField) { + this.pushStatusField = pushStatusField; + } + + public String getPushStatus() { + return pushStatus; + } + + public void setPushStatus(String pushStatus) { + this.pushStatus = pushStatus; + } + + public String getBipPaymentNumber() { + return bipPaymentNumber; + } + + public void setBipPaymentNumber(String bipPaymentNumber) { + this.bipPaymentNumber = bipPaymentNumber; + } + + public String getBipPaymentNumberField() { + return bipPaymentNumberField; + } + + public void setBipPaymentNumberField(String bipPaymentNumberField) { + this.bipPaymentNumberField = bipPaymentNumberField; + } + + public String getPayResult() { + return payResult; + } + + public void setPayResult(String payResult) { + this.payResult = payResult; + } + + public String getPayDate() { + return payDate; + } + + public void setPayDate(String payDate) { + this.payDate = payDate; + } + + public String getPayResultFiled() { + return payResultFiled; + } + + public void setPayResultFiled(String payResultFiled) { + this.payResultFiled = payResultFiled; + } + + public String getPayDateFiled() { + return payDateFiled; + } + + public void setPayDateFiled(String payDateFiled) { + this.payDateFiled = payDateFiled; + } + + public String getReceiptFiled() { + return receiptFiled; + } + + public void setReceiptFiled(String receiptFiled) { + this.receiptFiled = receiptFiled; + } + + public String getReceipt() { + return receipt; + } + + public void setReceipt(String receipt) { + this.receipt = receipt; + } + + public String getBillCode() { + return billCode; + } + + public void setBillCode(String billCode) { + this.billCode = billCode; + } +} diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/ServiceDataEntity.xml b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/ServiceDataEntity.xml new file mode 100644 index 00000000..99051fda --- /dev/null +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/entity/ServiceDataEntity.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + oa_id as id + ,tab_name as tabName + ,pay_result_field as payResultFiled + ,pay_result as payResult + ,pay_date_field as payDateFiled + ,receipt_filed as receiptFiled + ,receipt as receipt + ,vdef1 as billCode + ,summary_id + ,bip_payment_number_field as bipPaymentNumberField + ,bip_payment_number as bipPaymentNumber + + + + + + + + + + + + + update ${tabName} set ${pushStatusField} =#{pushStatus} where id=#{id} + + + + + update ${tabName} set ${bipPaymentNumberField} =#{bipPaymentNumber} where id=#{id} + + + + + update ${tabName} set + + ${payDateFiled} = #{payDate}, + ${payResultFiled} = #{payResult} + + where id=#{id} + + + + + update ${tabName} set + set ${receiptFiled} = #{receipt} + where id=#{id} + + + + + + diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/service/IServiceDataService.java b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/service/IServiceDataService.java index fbb1e285..70403758 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/service/IServiceDataService.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/comparison/serviceData/service/IServiceDataService.java @@ -2,6 +2,7 @@ package com.hzya.frame.sysnew.comparison.serviceData.service; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity; import com.hzya.frame.web.entity.JsonResultEntity; @@ -9,11 +10,34 @@ public interface IServiceDataService extends IBaseService implements IServiceDataService { @@ -32,6 +51,12 @@ public class ServiceDataServiceImpl extends BaseService private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; @Autowired private ComparisonServiceImpl comparisonServiceimpl; + @Autowired + private IIntegrationTaskLivingDetailsService taskLivingDetailsService; + @Autowired + private ISysApplicationDatabaseDao sysApplicationDatabaseDao; + @Autowired + private ICtpAttachmentDao ctpAttachmentDao; @Override public JsonResultEntity queryDocumentView(JSONObject json) { JSONObject jsonObject = json.getJSONObject("jsonStr"); @@ -43,11 +68,12 @@ public class ServiceDataServiceImpl extends BaseService } for (MdmModuleSourceEntity mdmModuleSourceEntity : list) { String tableName = ""; + List object=new ArrayList<>(); + List listAll = new ArrayList<>(); try { String appTyp = mdmModuleSourceEntity.getAppType();//系统类型 1、致远OA 2、用友U8C 3、用友BIP String dbCode = mdmModuleSourceEntity.getDbCode();//数据源编码 String mdmCode = mdmModuleSourceEntity.getMdmCode();//主数据编码 - List listAll = new ArrayList<>(); switch (appTyp){ case "1": switch (mdmCode){ @@ -64,26 +90,212 @@ public class ServiceDataServiceImpl extends BaseService } //将查询出来的数据进行组装,调用通用方法新增或者更新 if (null != listAll && listAll.size() > 0) { - ParametricDocument(listAll, mdmCode, tableName); + object = ParametricDocument(listAll, mdmCode, tableName); + if (CollectionUtils.isNotEmpty(object)) { + for (Object obj : object) { + //更新单据视图推送标识,不再抽取 + JSONObject attributeResult = (JSONObject) JSON.toJSON(obj); + if (attributeResult.getString("status").equals("200")) { + String resultString = attributeResult.getString("list"); + if ("10045".equals(mdmCode)) { + JSONArray jsonArray = JSONArray.parseArray(resultString); + if (CollectionUtils.isNotEmpty(jsonArray)) { + for (Object o : jsonArray) { + JSONObject attributeArray = (JSONObject) JSON.toJSON(o); + String cmpApply = attributeArray.getString(tableName); + JSONObject jsonObjectCmpApply = JSONObject.parseObject(cmpApply); + String pushStatusField = jsonObjectCmpApply.getString("push_status_field");//推送标识字段 + String id = jsonObjectCmpApply.getString("data_id");//主表id + String vdef1 = jsonObjectCmpApply.getString("vdef1");//主表id + logger.info("=====开始根据单据id:{},单据号:{},更新表:{}的推送标识", id, vdef1, tableName); + ServiceDataEntity serviceDataEntity = new ServiceDataEntity(); + serviceDataEntity.setTabName(jsonObjectCmpApply.getString("tab_name")); + serviceDataEntity.setPushStatusField(pushStatusField); + serviceDataEntity.setPushStatus("1"); + serviceDataEntity.setId(id); + serviceDataEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode()); + serviceDataDao.updatePushStatus(serviceDataEntity); + //保存业务数据日志 + saveTaskLivingDetails(id, jsonObjectCmpApply.getString("vdef1"), listAll.get(0).toString(), object.toString(), true); + } + } + } + } else { + saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("cmp_apply")).getString("data_id"), JSONObject.parseObject(listAll.get(0).getString("cmp_apply")).getString("vdef1"), listAll.get(0).toString(), JSON.parseObject(JSON.toJSONString(object)).getString("msg"), false); + } + } + } } else { - logger.info("U8C主数据档案没有需要同步中台的数据"); + logger.info("三维单据视图数据没有需要同步中台的数据"); } }catch (Exception e){ logger.info("业务数据同步失败:{}",e.getMessage()); + saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("cmp_apply")).getString("data_id"),JSONObject.parseObject(listAll.get(0).getString("cmp_apply")).getString("vdef1"),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 bindingDocument(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { + @Override + public JsonResultEntity queryResultIsNull(JSONObject json) { + try { + JSONObject jsonObject = json.getJSONObject("jsonStr"); + if (!checkStr(jsonObject.getString("billCode"))) { + logger.info("====传递的单据编号为空===="); + return BaseResult.getFailureMessageEntity("请传递单据编码"); + } + if(null==jsonObject.getString("fileUrl")) { + if (!checkStr(jsonObject.getString("payResult"))) { + logger.info("====传递的支付状态为空===="); + return BaseResult.getFailureMessageEntity("请传递支付状态"); + } + //查询支付状态为空的数据 + ServiceDataEntity serviceData = new ServiceDataEntity(); + serviceData.setBillCode(jsonObject.getString("billCode")); + serviceData.setDataSourceCode(jsonObject.getString("dataSourceCode")); + List serviceDataEntities = serviceDataDao.querySeriveDateResult(serviceData); + Integer integer = null; + if (CollectionUtils.isNotEmpty(serviceDataEntities)) { + for (ServiceDataEntity serviceDataEntity : serviceDataEntities) { + //判断传递的单据号与查询的单据号是否相同 + if (jsonObject.getString("billCode").equals(serviceDataEntity.getBillCode())) { + serviceDataEntity.setPayResult(jsonObject.getString("payResult")); + serviceDataEntity.setPayDate(jsonObject.getString("payDate")); + serviceDataEntity.setDataSourceCode(jsonObject.getString("dataSourceCode")); + logger.info("====开始根据单据号:{},表名称:{},表单id:{}更新支付状态和时间======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId()); + integer = serviceDataDao.updatePayResult(serviceDataEntity); + logger.info("====根据单据号:{},表名称:{},表单id:{}更新支付状态和时间完成======", serviceDataEntity.getBillCode(), serviceDataEntity.getTabName(), serviceDataEntity.getId()); + } + } + return BaseResult.getSuccessMessageEntity("更新成功", integer); + } else { + logger.info("=========没有支付状态为空的数据======="); + return BaseResult.getSuccessMessageEntity("查询成功,没有支付结果需要更新得数据"); + } + }else{ + if (null != jsonObject.getString("fileUrl")) { + //根据单据编号查询电子回单为空并且支付状态为成功得 + ServiceDataEntity serviceData=new ServiceDataEntity(); + serviceData.setBillCode(jsonObject.getString("billCode")); + serviceData.setDataSourceCode(jsonObject.getString("dataSourceCode")); + List serviceDataEntities = serviceDataDao.queryServiceElectronic(serviceData); + if(CollectionUtils.isEmpty(serviceDataEntities)){ + logger.info("======根据单据编号:{}未查询到支付成功并且电子回单为空的数据",jsonObject.getString("billCode")); + return BaseResult.getSuccessMessageEntity("查询成功,没有电子回单需要更新得数据"); + }else { + for (ServiceDataEntity serviceDataEntity : serviceDataEntities) { + //表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference + String sub_reference = String.valueOf(UUIDLong.longUUID()); + serviceDataEntity.setReceipt(sub_reference);//将sub_reference赋值给电子回单 + serviceDataEntity.setDataSourceCode(jsonObject.getString("dataSourceCode")); + logger.info("更新电子回单的表名称为:{},字段名称为:{},字段值为:{},oaid为:{}", serviceDataEntity.getTabName(), serviceDataEntity.getReceiptFiled(), serviceDataEntity.getReceipt(), serviceDataEntity.getId()); + serviceDataDao.updateElectronic(serviceDataEntity); + logger.info("表单电子回单字段更新成功"); + //根据附件id查询附件业务数据 + String file_url = jsonObject.getString("fileUrl"); + CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); + ctpAttachmentEntity.setFile_url(file_url); + String att_reference = serviceDataEntity.getSummary_id();//Summary_id + ctpAttachmentEntity.setSub_reference(sub_reference); + ctpAttachmentEntity.setAtt_reference(att_reference); + List ctpAttachmentEntityListBase = ctpAttachmentDao.query(ctpAttachmentEntity); + //如果没有查询到数据,就新增附件业务,否则更新 + if (ctpAttachmentEntityListBase.size() == 0) { + String category = jsonObject.getString("category"); + String type = jsonObject.getString("type"); + String filename = jsonObject.getString("filename"); + String mime_type = jsonObject.getString("mimeType"); + String attachment_size = jsonObject.getString("size"); + String id = String.valueOf(UUIDLong.longUUID()); + ctpAttachmentEntity.setCategory(category); + ctpAttachmentEntity.setFilename(filename); + ctpAttachmentEntity.setType(type); + ctpAttachmentEntity.setMime_type(mime_type); + ctpAttachmentEntity.setAttachment_size(attachment_size); + ctpAttachmentEntity.setId(id); + ctpAttachmentEntity.setCategory("2"); + ctpAttachmentEntity.setCreatedate(new Date()); + ctpAttachmentEntity.setDataSourceCode(jsonObject.getString("dataSourceCode")); + ctpAttachmentDao.save(ctpAttachmentEntity); + logger.info("OA附件新增成功"); + } else { + if (ctpAttachmentEntityListBase.size() > 1) { + throw new BaseSystemException("OA附件业务表中查到多条记录"); + } + //更新数据到OA附件业务表中 + ctpAttachmentDao.save(ctpAttachmentEntity); + logger.info("OA附件更新成功"); + } + } + } + } + } + }catch (Exception e){ + logger.info("查询三维付款申请单支付状态和时间失败:{}",e.getMessage()); + } + return null; + } + + @Override + public SysExtensionApiEntity addDataSourceCode(SysExtensionApiEntity entity) { + try { + SysApplicationEntity applicationEntity = entity.getReceiveApp(); + SysApplicationDatabaseEntity sysApplicationDatabaseEntity = new SysApplicationDatabaseEntity(); + sysApplicationDatabaseEntity.setSts("Y"); + sysApplicationDatabaseEntity.setDbStatus("1"); + sysApplicationDatabaseEntity.setAppId(applicationEntity.getId()); + sysApplicationDatabaseEntity.setDataSourceCode("master"); + List sysDataSourceEntities = sysApplicationDatabaseDao.queryDSBase(sysApplicationDatabaseEntity); + if(sysDataSourceEntities != null && sysDataSourceEntities.size() > 0){ + String parm = entity.getBodys(); + JSONObject jsonObject = JSONObject.parseObject(parm); + jsonObject.put("dataSourceCode",sysDataSourceEntities.get(0).getSourceCode()); + entity.setBodys(jsonObject.toJSONString()); + } + } catch (Exception e) { + e.printStackTrace(); + } + return entity; + } + + @Override + public SysExtensionApiEntity getToken(SysExtensionApiEntity entity) { + try { + logger.info("==========开始获取token============"); + //获取oatoken + HashMap hashMap = new HashMap<>(); + hashMap.put("userName", "hzyaRestUser"); + hashMap.put("password", "hzya1314"); + hashMap.put("loginName","fkmanager"); + String result = HttpUtil.post("https://swoa.sunwave.com.cn:9999" + "/seeyon/rest/token", JSON.toJSONString(hashMap)); + logger.info("===========获取token结果为:{}=========",result); + JSONObject jsonObject = JSONObject.parseObject(result); + if (null != jsonObject) { + logger.info(result); + logger.info("======token:{}======" + jsonObject.getString("id")); + StringBuffer querys = new StringBuffer(); + querys.append("token="+jsonObject.getString("id")); + entity.setQuerys(querys.toString()); + } + }catch (Exception e){ + logger.info("======扩展类获取token失败:{}",e.getMessage()); + e.printStackTrace(); + } + return entity; + } + + private List bindingDocument(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { + String formmainId=null; + String vdef1=null; + List list = new ArrayList<>(); try { - List list = new ArrayList<>(); - StringBuffer sb = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append("select oa_id as data_id,vdef1 as vdef1,applysum,pk_acceptorg,pk_group,pk_trantypecode,pk_busitype,\n" + - " pk_supplier,pk_bankacc_r as pk_bankacc_r\n" + - " from v_OA_TO_BIP where 1=1 " + sb.toString()); + stringBuffer.append("select oa_id as data_id,tab_name,title,pay_company,bill_name,pay_result_field,pay_date_field,receipt_filed,\n" + + "push_status_field,summary_id,bip_payment_number_field,\n" + + "vdef1,pk_acceptorg,creator,pk_group,pk_org,applydate,pk_trantypecode,pk_busitype,vdef2,pk_currtype,\n" + + "pk_supplier,pk_bankacc_r,pk_bankacc_p,pk_decidedept,vdef10,vdef12,vdef3,vdef4,vdef5,vdef6,applysum,\n" + + "vdef7,vdef8,vdef9 from v_cmp_apply where 1=1 and vdef1 is not null and push_status is null "); mdmModuleSourceEntity.setDataSourceCode(dbCode); List> hashMaps = serviceDataDao.queryListBySWSource(stringBuffer.toString(), mdmModuleSourceEntity); int i = 0; @@ -92,20 +304,22 @@ public class ServiceDataServiceImpl extends BaseService JSONObject main = new JSONObject(); JSONObject cmp_apply = new JSONObject(); for (String key : hashMap.keySet()) { - cmp_apply.put(key, hashMap.get(key)); + cmp_apply.put(key.toLowerCase(), hashMap.get(key)); } //获取明细信息 - String formmainId = (String) hashMap.get("data_id"); + formmainId = cmp_apply.getString("data_id"); + vdef1=cmp_apply.getString("vdef1"); StringBuffer stringBufferDetails = new StringBuffer(); - stringBufferDetails.append("select d_id as data_id,tab_name,pk_supplier,pk_bankacc_r,pk_currtype,vdef1,vdef2,vdef3,vdef4\n" + - " from v_OA_TO_BIP_DETAILS where formmain_id= '"+formmainId+"' " ); + stringBufferDetails.append("select d_id as data_id,tab_name,pk_balatype,pk_acceptorg,pk_org,pk_group,pk_busitype,rowno,\n" + + "pk_supplier,pk_bankacc_r,pk_currtype,pk_decidedept,gllcrate,applysum,applymny,vdef1,pk_project,vdef2,vdef3,\n" + + "vdef4 from v_cmp_apply_b where formmain_id= '"+formmainId+"' " ); List> hashMapsDetails = serviceDataDao.queryListBySWSource(stringBufferDetails.toString(),mdmModuleSourceEntity); JSONArray cmp_apply_b = new JSONArray(); if(CollectionUtils.isNotEmpty(hashMapsDetails)){ for (HashMap detailsMap : hashMapsDetails) { JSONObject details = new JSONObject(); for (String key : detailsMap.keySet()) { - details.put(key, detailsMap.get(key)); + details.put(key.toLowerCase(), detailsMap.get(key)); } cmp_apply_b.add(details); } @@ -118,16 +332,19 @@ public class ServiceDataServiceImpl extends BaseService return list; } catch (Exception e) { logger.info("组装单据是图查询参数失败:{}", e.getMessage()); + //保存业务数据日志 + saveTaskLivingDetails(formmainId,vdef1,list.toString(),null,false); e.printStackTrace(); } return null; } - private JsonResultEntity ParametricDocument(List hashMaps,String mdmCode,String tableName){ + private List ParametricDocument(List hashMaps,String mdmCode,String tableName){ + JSONObject jsonObjectUser = new JSONObject(); + List result=new ArrayList<>(); try { for (JSONObject hashMap : hashMaps) { JSONObject main = hashMap.getJSONObject(tableName); - JSONObject jsonObjectUser = new JSONObject(); JSONObject jsonStr = new JSONObject(); jsonObjectUser.put("data_id", main.get("data_id")); jsonObjectUser.put("mdmCode", mdmCode); @@ -145,23 +362,56 @@ public class ServiceDataServiceImpl extends BaseService hashMap.put("mdmCode", mdmCode); hashMap.put("optionName", "数智中台"); jsonStr.put("jsonStr", hashMap); - Object result = comparisonServiceimpl.saveEntity(jsonStr); - logger.info("单据视图新增结果为:{}", JSON.toJSONString(result)); + 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 result = comparisonServiceimpl.updateEntity(jsonStr); + 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("vdef1"),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("ServiceDataPluginInitializer"); + integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo); + if(flag){ + taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity); + }else { + taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity); + } + }catch (Exception e){ + logger.info("业务数据抽取保存日志到集成任务日志明细中失败:{}",e.getMessage()); + e.printStackTrace(); + } + } + + }