diff --git a/base-buildpackage/pom.xml b/base-buildpackage/pom.xml index 70760ee0..a745746a 100644 --- a/base-buildpackage/pom.xml +++ b/base-buildpackage/pom.xml @@ -49,6 +49,12 @@ xel + + llg + + llg + + kangarooDataCenterV3 diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/dao/IIncomeInvoiceDao.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/dao/IIncomeInvoiceDao.java new file mode 100644 index 00000000..8fb161da --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/dao/IIncomeInvoiceDao.java @@ -0,0 +1,36 @@ +package com.hzya.frame.plugin.incomeInvoiceData.dao; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity; + +import java.util.List; + +/** + * 客户档案(mdm_customer: table)表数据库访问层 + * + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public interface IIncomeInvoiceDao extends IBaseDao { + + + List queryData(JSONObject saveData); + + int saveDetailData(JSONObject saveDetailData); + + int saveData(JSONObject saveData); + + List queryOaZb(IncomeInvoiceEntity incomeInvoiceEntity); + + List queryOaMx(IncomeInvoiceEntity incomeInvoiceEntity); + + int updateMx(IncomeInvoiceEntity incomeInvoiceEntity); + + int saveMx(IncomeInvoiceEntity incomeInvoiceEntity); + + List queryZtzz(IncomeInvoiceEntity entity); + + List queryByAloneId(IncomeInvoiceEntity jnquerydata); +} + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/dao/impl/IncomeInvoiceDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/dao/impl/IncomeInvoiceDaoImpl.java new file mode 100644 index 00000000..8582aab4 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/dao/impl/IncomeInvoiceDaoImpl.java @@ -0,0 +1,70 @@ +package com.hzya.frame.plugin.incomeInvoiceData.dao.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.plugin.incomeInvoiceData.dao.IIncomeInvoiceDao; +import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity; + +import java.util.List; + + +/** + * + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public class IncomeInvoiceDaoImpl extends MybatisGenericDao implements IIncomeInvoiceDao { + + @Override + public List queryData(JSONObject saveData) { + List o = (List) super.selectList(getSqlIdPrifx() + "queryData", saveData); + return o; + } + @Override + public int saveData(JSONObject saveData) { + return super.insert(getSqlIdPrifx() + "saveData", saveData); + } + @Override + public int saveDetailData(JSONObject saveData) { + return super.insert(getSqlIdPrifx() + "saveDetailData", saveData); + } + + @DS("#entity.dataSourceCode") + @Override + public List queryOaZb(IncomeInvoiceEntity entity) { + List o = (List) super.selectList(getSqlIdPrifx() + "queryOaZb", entity); + return o; + } + @DS("#entity.dataSourceCode") + @Override + public List queryOaMx(IncomeInvoiceEntity entity) { + List o = (List) super.selectList(getSqlIdPrifx() + "queryOaMx", entity); + return o; + } + @DS("#entity.dataSourceCode") + @Override + public int updateMx(IncomeInvoiceEntity entity) { + return super.update(getSqlIdPrifx() + "updateMx", entity); + } + @DS("#entity.dataSourceCode") + @Override + public int saveMx(IncomeInvoiceEntity entity) { + return super.insert(getSqlIdPrifx() + "saveMx", entity); + } + + @DS("#entity.dataSourceCode") + @Override + public List queryZtzz(IncomeInvoiceEntity entity) { + List o = (List) super.selectList(getSqlIdPrifx() + "queryZtzz", entity); + return o; + } + + @DS("#entity.dataSourceCode") + @Override + public List queryByAloneId(IncomeInvoiceEntity entity) { + List o = (List) super.selectList(getSqlIdPrifx() + "queryByAloneId", entity); + return o; + } +} + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/entity/IncomeInvoiceEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/entity/IncomeInvoiceEntity.java new file mode 100644 index 00000000..27f90943 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/entity/IncomeInvoiceEntity.java @@ -0,0 +1,125 @@ +package com.hzya.frame.plugin.incomeInvoiceData.entity; + +import com.hzya.frame.web.entity.BaseEntity; +/** + * + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public class IncomeInvoiceEntity extends BaseEntity { + + //发票字段 + private Integer dataId; + private Integer formmainId; + private String field0127; + private String field0128; + private String field0129; + private String field0130; + private String field0003; + + + //财报数据 字段 + private String aloneId; + private String sysData; + private String orgCode; + private String orgName; + private String iufoVer; + + + public String getAloneId() { + return aloneId; + } + + public void setAloneId(String aloneId) { + this.aloneId = aloneId; + } + + public String getSysData() { + return sysData; + } + + public void setSysData(String sysData) { + this.sysData = sysData; + } + + public String getOrgCode() { + return orgCode; + } + + public void setOrgCode(String orgCode) { + this.orgCode = orgCode; + } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public String getIufoVer() { + return iufoVer; + } + + public void setIufoVer(String iufoVer) { + this.iufoVer = iufoVer; + } + + public Integer getDataId() { + return dataId; + } + + public void setDataId(Integer dataId) { + this.dataId = dataId; + } + + public Integer getFormmainId() { + return formmainId; + } + + public void setFormmainId(Integer formmainId) { + this.formmainId = formmainId; + } + + public String getField0127() { + return field0127; + } + + public void setField0127(String field0127) { + this.field0127 = field0127; + } + + public String getField0128() { + return field0128; + } + + public void setField0128(String field0128) { + this.field0128 = field0128; + } + + public String getField0129() { + return field0129; + } + + public void setField0129(String field0129) { + this.field0129 = field0129; + } + + public String getField0130() { + return field0130; + } + + public void setField0130(String field0130) { + this.field0130 = field0130; + } + + public String getField0003() { + return field0003; + } + + public void setField0003(String field0003) { + this.field0003 = field0003; + } +} + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/entity/IncomeInvoiceEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/entity/IncomeInvoiceEntity.xml new file mode 100644 index 00000000..4fc5953d --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/entity/IncomeInvoiceEntity.xml @@ -0,0 +1,538 @@ + + + + + + + + insert into mdm_fp( + + id , + document_rule , + document_rule_num , + data_status , + add_status , + update_status , + delete_status , + sorts , + create_user_id , + create_time , + modify_user_id , + modify_time , + sts , + org_id , + company_id , + + fphm , + fpdm , + kprq , + xfsh , + xfmc , + gfsh , + gfmc , + hjje , + hjse , + jshj , + jym , + xfdzdh , + xfyhzh , + gfdzdh , + gfyhzh , + mmq , + bz , + jqbh , + jdhm , + kpr , + skr , + fhr , + url , + ofdurl , + xmlurl , + htbh , + + + + )values + ( + + #{id} , + #{document_rule} , + #{document_rule_num} , + #{data_status} , + #{add_status} , + #{update_status} , + #{delete_status} , + #{sorts} , + #{create_user_id} , + #{create_time} , + #{modify_user_id} , + #{modify_time} , + #{sts} , + #{org_id} , + #{company_id} , + + #{fphm} , + #{fpdm} , + #{kprq} , + #{xfsh} , + #{xfmc} , + #{gfsh} , + #{gfmc} , + #{hjje} , + #{hjse} , + #{jshj} , + #{jym} , + #{xfdzdh} , + #{xfyhzh} , + #{gfdzdh} , + #{gfyhzh} , + #{mmq} , + #{bz} , + #{jqbh} , + #{jdhm} , + #{kpr} , + #{skr} , + #{fhr} , + #{url} , + #{ofdurl} , + #{xmlurl} , + #{htbh} , + + + ) + + + insert into mdm_fp_detail( + + id , + formmain_id , + data_status , + sorts , + create_user_id , + create_time , + modify_user_id , + modify_time , + sts , + org_id , + company_id , + remark , + + xh , + ssflbm , + xmmc , + ggxh , + dw , + sl , + dj , + je , + slv , + se , + + + + + )values + ( + + #{id} , + #{formmain_id} , + #{data_status}, + #{sorts} , + #{create_user_id} , + #{create_time} , + #{modify_user_id} , + #{modify_time} , + #{sts} , + #{org_id} , + #{company_id} , + #{remark} , + + #{xh} , + #{ssflbm} , + #{xmmc} , + #{ggxh} , + #{dw} , + #{sl} , + #{dj} , + #{je} , + #{slv} , + #{se} , + + + ) + + + + + + + update formson_0702 set + + field0127 = #{field0127}, + field0128 = #{field0128}, + field0129 = #{field0129}, + field0130 = #{field0130}, + + where id = #{dataId} + + + + insert into formson_0702( + + id , + formmain_id , + field0127 , + field0128 , + field0129 , + field0130 , + + + )values( + + #{dataId} , + #{formmainId} , + #{field0127} , + #{field0128} , + #{field0129} , + #{field0130} , + + ) + + + + + + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/plugin/FinancialReportPluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/plugin/FinancialReportPluginInitializer.java new file mode 100644 index 00000000..81153779 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/plugin/FinancialReportPluginInitializer.java @@ -0,0 +1,63 @@ +package com.hzya.frame.plugin.incomeInvoiceData.plugin; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.incomeInvoiceData.service.IIncomeInvoiceService; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * 主数据同步 + * + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public class FinancialReportPluginInitializer extends PluginBaseEntity{ + Logger logger = LoggerFactory.getLogger(FinancialReportPluginInitializer.class); + + @Autowired + private IIncomeInvoiceService incomeInvoiceService; + + @Override + public void initialize() { + logger.info(getPluginLabel() + "执行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "执行销毁方法destroy()"); + } + + @Override + public String getPluginId() { + return "FinancialReportPlugin"; + } + + @Override + public String getPluginName() { + return "FinancialReportPlugin插件"; + } + + @Override + public String getPluginLabel() { + return "FinancialReportPlugin"; + } + + @Override + public String getPluginType() { + return "1"; + } + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) { + try { + logger.info("======开始执行财务信息同步========"); + return incomeInvoiceService.sendFinancialReportPlugin(requestJson); + }catch (Exception e){ + logger.info("======执行财务同步失败:{}========",e.getMessage()); + e.printStackTrace(); + } + return null; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/plugin/IncomeInvoicePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/plugin/IncomeInvoicePluginInitializer.java new file mode 100644 index 00000000..8c966920 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/plugin/IncomeInvoicePluginInitializer.java @@ -0,0 +1,63 @@ +package com.hzya.frame.plugin.incomeInvoiceData.plugin; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.incomeInvoiceData.service.IIncomeInvoiceService; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * 主数据同步 + * + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public class IncomeInvoicePluginInitializer extends PluginBaseEntity{ + Logger logger = LoggerFactory.getLogger(IncomeInvoicePluginInitializer.class); + + @Autowired + private IIncomeInvoiceService incomeInvoiceService; + + @Override + public void initialize() { + logger.info(getPluginLabel() + "执行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "执行销毁方法destroy()"); + } + + @Override + public String getPluginId() { + return "IncomeInvoicePlugin"; + } + + @Override + public String getPluginName() { + return "IncomeInvoicePlugin插件"; + } + + @Override + public String getPluginLabel() { + return "IncomeInvoicePlugin"; + } + + @Override + public String getPluginType() { + return "1"; + } + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) { + try { + logger.info("======开始执行进项全量发票主数据信息同步========"); + return incomeInvoiceService.getIncomeInvoiceData(requestJson); + }catch (Exception e){ + logger.info("======执行进项全量发票主数据同步失败:{}========",e.getMessage()); + e.printStackTrace(); + } + return null; + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/IIncomeInvoiceService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/IIncomeInvoiceService.java new file mode 100644 index 00000000..2276deeb --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/IIncomeInvoiceService.java @@ -0,0 +1,26 @@ +package com.hzya.frame.plugin.incomeInvoiceData.service; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity; +import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; +import com.hzya.frame.web.entity.JsonResultEntity; + +/** + * + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public interface IIncomeInvoiceService extends IBaseService { + /** + * @Author lvleigang + * @Description 全量发票数据 + * @Date 4:28 下午 2025/4/16 + * @param requestJson + * @return com.hzya.frame.web.entity.JsonResultEntity + **/ + JsonResultEntity getIncomeInvoiceData(JSONObject requestJson); + SysExtensionApiEntity setData(SysExtensionApiEntity entity) throws Exception; + + JsonResultEntity sendFinancialReportPlugin(JSONObject requestJson); +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/impl/IncomeInvoiceServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/impl/IncomeInvoiceServiceImpl.java new file mode 100644 index 00000000..916c69a3 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/impl/IncomeInvoiceServiceImpl.java @@ -0,0 +1,894 @@ +package com.hzya.frame.plugin.incomeInvoiceData.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.plugin.incomeInvoiceData.dao.IIncomeInvoiceDao; +import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity; +import com.hzya.frame.plugin.incomeInvoiceData.service.IIncomeInvoiceService; +import com.hzya.frame.seeyon.util.YzfSignUtil; +import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; +import com.hzya.frame.sysnew.comparison.controlsLog.dao.impl.ControlsLogDaoImpl; +import com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity; +import com.hzya.frame.sysnew.comparison.dao.IComparisonDao; +import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity; +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; +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; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.TrustAllStrategy; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; +import org.checkerframework.checker.units.qual.A; +import org.springframework.beans.factory.annotation.Autowired; +import com.hzya.frame.basedao.service.impl.BaseService; + +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author makejava + * @since 2024-06-21 13:52:35 + */ +public class IncomeInvoiceServiceImpl extends BaseService implements IIncomeInvoiceService { + + private IIncomeInvoiceDao incomeInvoiceDao; + @Autowired + private ControlsLogDaoImpl controlsLogDaoimpl; + @Autowired + private IComparisonDao comparisonDao; + @Autowired + public void setIncomeInvoiceDao(IIncomeInvoiceDao dao) { + this.incomeInvoiceDao = dao; + this.dao = dao; + } + String cbUrl = "http://oapi.nanofintax.com/api/collect/uploadFinancialReport?accessToken="; + String dataUrl = "http://oapi.nanofintax.com/api/invoice_receive/fp/v1/query?accessToken="; + String tokenUrl = "http://oapi.nanofintax.com/api/getToken"; + String accessKey = "6X3B526P5HqE6ums"; + String accessSecret = "34e5fc32ac894a2ba2ade8c3852c7a0a"; + String taxNo = "91330110MAC5FPUY2U"; + Integer size = 50; + + /** + * @Author lvleigang + * @Description 全量发票数据 + * @Date 4:28 下午 2025/4/16 + * @param requestJson + * @return com.hzya.frame.web.entity.JsonResultEntity + **/ + @Override + public JsonResultEntity getIncomeInvoiceData(JSONObject requestJson) { + //1、调用token + String access_token = getToken(); + if (access_token == null) { + return BaseResult.getFailureMessageEntity("token获取失败"); + } + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String times = sdf.format(date); + //2、调用接口获取数据 + Integer queryCursor = 1; + JSONArray datalist = new JSONArray(); + sendBusinessData(datalist, access_token, queryCursor,times); + + if(datalist != null && datalist.size() > 0){ + for (int i = 0; i < datalist.size(); i++) { + JSONObject saveData = new JSONObject(); + //3、对照数据 + JSONObject jsonObject = datalist.getJSONObject(i); + JSONObject content = jsonObject.getJSONObject("content"); + + //发票号码 + String fphm = jsonObject.getString("fphm"); + if(fphm == null || "".equals(fphm) ){ + continue; + } + saveData.put("fphm",fphm); + //判断是否有这个数据 + List checkData = incomeInvoiceDao.queryData(saveData); + if(checkData != null && checkData.size() > 0){ + continue; + } + saveData.put("id", String.valueOf(UUIDLong.longUUID())); + saveData.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); + saveData.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); + saveData.put("org_id", "0"); + saveData.put("create_time", new Date()); + saveData.put("modify_time", new Date()); + saveData.put("sts", "Y"); + saveData.put("data_status", "Y");//新增状态 + saveData.put("add_status", "0");//新增状态 + saveData.put("update_status", "1");//修改状态 + saveData.put("delete_status", "1");//删除状态 + ComparisonEntity comparisonEntityRule = new ComparisonEntity(); + comparisonEntityRule.setRulePrefix("FP"); + comparisonEntityRule.setRuleMiddle("%Y-%m-%d"); + comparisonEntityRule.setRuleSuffix(5); + comparisonEntityRule.setDbName("mdm_fp"); + ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule); + saveData.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则 + saveData.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号 + + saveData.put("fphm",fphm); + saveData.put("fpdm",content.getString("fpdm")); + saveData.put("kprq",jsonObject.getString("kprq")); + saveData.put("xfsh",content.getString("xfsh")); + saveData.put("xfmc",content.getString("xfmc")); + saveData.put("gfsh",content.getString("gfsh")); + saveData.put("gfmc",content.getString("gfmc")); + saveData.put("hjje",content.getString("hjje")); + saveData.put("hjse",content.getString("hjse")); + saveData.put("jshj",content.getString("jshj")); + saveData.put("jym",content.getString("jym")); + saveData.put("xfdzdh",content.getString("xfdzdh")); + saveData.put("xfyhzh",content.getString("xfyhzh")); + saveData.put("gfdzdh",content.getString("gfdzdh")); + saveData.put("gfyhzh",content.getString("gfyhzh")); + saveData.put("mmq",content.getString("mmq")); + saveData.put("bz",content.getString("bz")); + saveData.put("jqbh",content.getString("jqbh")); + saveData.put("jdhm",content.getString("jdhm")); + saveData.put("kpr",content.getString("kpr")); + saveData.put("skr",content.getString("skr")); + saveData.put("fhr",content.getString("fhr")); + saveData.put("url",content.getString("url")); + saveData.put("ofdurl",content.getString("ofdUrl")); + saveData.put("xmlurl",content.getString("xmlUrl")); + saveData.put("htbh",content.getString("contraceNumber")); + + JSONArray detaildata = content.getJSONArray("items"); + if(detaildata != null && detaildata.size() > 0){ + for (int i1 = 0; i1 < detaildata.size(); i1++) { + JSONObject saveDetailData = new JSONObject(); + + saveDetailData.put("id", String.valueOf(UUIDLong.longUUID())); + saveDetailData.put("formmain_id", saveData.getString("id")); + saveDetailData.put("data_status", "Y");//新增状态 + + saveDetailData.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); + saveDetailData.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443"); + saveDetailData.put("org_id", "0"); + saveDetailData.put("create_time", new Date()); + saveDetailData.put("modify_time", new Date()); + saveDetailData.put("sts", "Y"); + saveDetailData.put("xh", detaildata.getJSONObject(i1).getString("xh")); + saveDetailData.put("ssflbm", detaildata.getJSONObject(i1).getString("ssflbm")); + saveDetailData.put("xmmc", detaildata.getJSONObject(i1).getString("xmmc")); + saveDetailData.put("ggxh", detaildata.getJSONObject(i1).getString("ggxh")); + saveDetailData.put("dw", detaildata.getJSONObject(i1).getString("dw")); + saveDetailData.put("sl", detaildata.getJSONObject(i1).getString("sl")); + saveDetailData.put("dj", detaildata.getJSONObject(i1).getString("dj")); + saveDetailData.put("je", detaildata.getJSONObject(i1).getString("je")); + saveDetailData.put("slv", detaildata.getJSONObject(i1).getString("slv")); + saveDetailData.put("se", detaildata.getJSONObject(i1).getString("se")); + + incomeInvoiceDao.saveDetailData(saveDetailData); + } + } + incomeInvoiceDao.saveData(saveData); + + //5、保存写入日志 + ControlsLogEntity controlsLogEntity=new ControlsLogEntity(); + controlsLogEntity.setId(UUIDUtils.getUUID()); + controlsLogEntity.setFormmainId(saveData.getString("id")); + controlsLogEntity.setSourceName("数智中台"); + controlsLogEntity.setCode("800004"); + controlsLogEntity.setSourceData(jsonObject.toString()); + controlsLogEntity.setOptionType("接口新增"); + controlsLogEntity.setOptionName("数智中台"); + controlsLogEntity.setDbName("mdm_fp_option_log"); + controlsLogEntity.setDataType("1"); + controlsLogEntity.setCreate_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443"); + controlsLogEntity.setModify_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443"); + controlsLogEntity.setOrg_id("0"); + controlsLogEntity.setRemark("插件新增"); + controlsLogDaoimpl.saveControlsLog(saveData.getString("id"), "数智中台", "800004", jsonObject.toJSONString(), "接口新增", "数智中台", "mdm_fp_option_log", "1"); + } + } + return BaseResult.getSuccessMessageEntity("处理成功"); + } + + + /** + * @Author lvleigang + * @Description 获取业务数据 + * @Date 4:31 下午 2025/4/9 + * @param datalist + * @param access_token + * @param queryCursor + * @param dataTime + * @return void + **/ + private void sendBusinessData(JSONArray datalist, String access_token, Integer queryCursor, String dataTime) { + String url = dataUrl+access_token; + JSONObject dayabody = new JSONObject(); + dayabody.put("accessKey",accessKey); + long timestamp = System.currentTimeMillis(); + dayabody.put("timestamp",timestamp); + JSONObject queryParams = new JSONObject(); + queryParams.put("page",queryCursor); + queryParams.put("size",size); + //queryParams.put("kprqq",dataTime); + //queryParams.put("kprqz",dataTime); + queryParams.put("taxNo",taxNo); + dayabody.put("queryParams",queryParams); + Map parametersMap = new HashMap<>(); + parametersMap.put("accessKey",accessKey); + parametersMap.put("timestamp",timestamp); + String a = YzfSignUtil.signRequest(parametersMap,accessSecret); + dayabody.put("sign",a); + Map headers = new HashMap<>(); + headers.put("Content-Type", "application/json; charset=utf-8"); + String returndata = sendPost(url, headers, dayabody.toJSONString()); + + if (returndata != null && JSONObject.isValidObject(returndata)) { + JSONObject dataJson = JSONObject.parseObject(returndata); + if(dataJson != null && dataJson.getString("code") != null && "0".equals( dataJson.getString("code"))){ + JSONObject data = dataJson.getJSONObject("result"); + if(data != null ){ + JSONArray businessList = data.getJSONArray("data"); + if(data.getInteger("total") > queryCursor*size){ + queryCursor = queryCursor+1; + sendBusinessData(datalist, access_token, queryCursor, dataTime); + } + if(businessList != null && businessList.size() > 0){ + datalist.addAll(businessList); + } + } + } + } + } + + private String getOAToken(String name) { + String url = "http://60.204.152.210/seeyon/rest/token"; + Map headers = null; + String bodys = "{\"password\":\"a5ce21b8-91db-4cec-b3e3-3e44719655fd\",\"userName\":\"hzyaRest\",\"loginName\":\""+name+"\"}"; + String tokenData = sendPost(url, headers, bodys); + String access_token = null; + if (tokenData != null && JSONObject.isValidObject(tokenData)) { + JSONObject tokendataJson = JSONObject.parseObject(tokenData); + if (tokendataJson != null && tokendataJson.getString("id") != null) { + access_token = tokendataJson.getString("id"); + } + } + return access_token; + } + /** + * @Author lvleigang + * @Description 获取token + * @Date 4:18 下午 2025/4/9 + * @param + * @return java.lang.String + **/ + private String getToken() { + String url = tokenUrl; + JSONObject tokenJson = new JSONObject(); + tokenJson.put("accessKey",accessKey); + tokenJson.put("accessSecret",accessSecret); + String bodys = tokenJson.toJSONString(); + StringBuilder body = new StringBuilder(); + SSLContext sslContext = null; + try { + sslContext = new SSLContextBuilder() + .loadTrustMaterial(null, TrustAllStrategy.INSTANCE) + .build(); + } catch (Exception e) { + return null; + } + CloseableHttpClient closeableHttpClient = HttpClients.custom() + .setSSLContext(sslContext) + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .build(); + + HttpPost post = new HttpPost(url); + CloseableHttpResponse response = null; + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(6000).build(); + post.setConfig(requestConfig);//设置请求参数【超时时间】 + post.setHeader("Content-Type", "application/json; charset=utf-8"); + try { + if (bodys != null && !"".equals(bodys)) { + ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8")); + entity.setContentType("application/json"); + post.setEntity(entity); + } + response = closeableHttpClient.execute(post); + + HttpEntity entity = response.getEntity(); + body.append(EntityUtils.toString(entity, "UTF-8")); + } catch (Exception e) { + body.append(e.getMessage()); + } finally { + try { + // 关闭响应对象 + if (response != null) { + response.close(); + } + // 关闭响应对象 + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } + logger.info("token返回结果{}",body); + JSONObject bodyJson = JSONObject.parseObject(body.toString()); + if(bodyJson.getString("code") == null || !"0".equals(bodyJson.getString("code"))){ + return null; + } + JSONObject resultJson = bodyJson.getJSONObject("result"); + if(resultJson == null){ + return null; + } + if(resultJson.getString("accessToken") != null && !"".equals(resultJson.getString("accessToken"))){ + return resultJson.getString("accessToken"); + } + return null; + } + + private String sendPost(String url, Map headers, String bodys) { + logger.info("url:"+url+"。bodys:"+bodys); + + SSLContext sslContext = null; + try { + sslContext = new SSLContextBuilder() + .loadTrustMaterial(null, TrustAllStrategy.INSTANCE) + .build(); + } catch (Exception e) { + + } + CloseableHttpClient closeableHttpClient = HttpClients.custom() + .setSSLContext(sslContext) + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .build(); + HttpPost post = new HttpPost(url); + CloseableHttpResponse response = null; + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build(); + post.setConfig(requestConfig);//设置请求参数【超时时间】 + if (headers != null && headers.size() > 0) { + for (String key : headers.keySet()) { + post.setHeader(key, headers.get(key)); + } + } + StringBuilder body = new StringBuilder(); + try { + if (bodys != null && !"".equals(bodys)) { + ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8")); + entity.setContentType("application/json"); + post.setEntity(entity); + } + response = closeableHttpClient.execute(post); + HttpEntity entity = response.getEntity(); + body.append(EntityUtils.toString(entity, "UTF-8")); + logger.info("返回结果:" + body); + } catch (Exception e) { + logger.error("请求错误:" + e.getMessage()); + body = new StringBuilder(); + } finally { + try { + // 关闭响应对象 + if (response != null) { + response.close(); + } + // 关闭响应对象 + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } + logger.info("url:"+url+"。bodys:"+bodys+"。body"+body); + + return body.toString(); + } + private String sendGet(String url, Map headers) { + SSLContext sslContext = null; + try { + sslContext = new SSLContextBuilder() + .loadTrustMaterial(null, TrustAllStrategy.INSTANCE) + .build(); + } catch (Exception e) { + + } + CloseableHttpClient closeableHttpClient = HttpClients.custom() + .setSSLContext(sslContext) + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .build(); + // HttpClient + HttpGet get = new HttpGet(url); + CloseableHttpResponse response = null; + + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build(); + get.setConfig(requestConfig);//设置请求参数【超时时间】 + if (headers != null && headers.size() > 0) { + for (String key : headers.keySet()) { + get.setHeader(key, headers.get(key)); + } + } + StringBuilder body = new StringBuilder(); + + try { + response = closeableHttpClient.execute(get); + HttpEntity entity = response.getEntity(); + body.append(EntityUtils.toString(entity,"UTF-8")); + logger.info("返回结果:" + body); + } catch (Exception e) { + logger.error("请求错误:" + e.getMessage()); + body.append(e.getMessage()); + } finally { + try { + // 关闭响应对象 + if (response != null) { + response.close(); + } + // 关闭响应对象 + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return body.toString(); + } + + + /** + * seeyon流程事件监听前置方法,绑定数据源 + * @param entity + * @return + * @throws Exception + */ + @Override + public SysExtensionApiEntity setData(SysExtensionApiEntity entity) throws Exception { + try { + JSONObject sendBody = new JSONObject(); + String bodys = entity.getBodys(); + Map headers = entity.getHeaders(); + JSONObject jsonObject = JSONObject.parseObject(bodys); + String loginName = "hzya"; + String dataXml = getXml(jsonObject); + //处理xml数据 + String oaToken = getOAToken(loginName); + headers.put("token",oaToken); + sendBody.put("token",oaToken); + sendBody.put("loginName",loginName); + sendBody.put("dataXml",dataXml); + entity.setBodys(sendBody.toJSONString()); + //修改明细表 + if(jsonObject.getString("htbh") != null){ + IncomeInvoiceEntity incomeInvoiceEntity = new IncomeInvoiceEntity(); + incomeInvoiceEntity.setDataSourceCode("master");//todo + //incomeInvoiceEntity.setDataSourceCode("HT-OA");//todo + incomeInvoiceEntity.setField0003(jsonObject.getString("htbh"));//合同号 + incomeInvoiceEntity.setField0127(jsonObject.getString("fpdm"));//发票代码 + incomeInvoiceEntity.setField0128(jsonObject.getString("fphm"));//发票号码 + incomeInvoiceEntity.setField0129(jsonObject.getString("jshj"));//发票总额 + incomeInvoiceEntity.setField0130(jsonObject.getString("fpwj"));//发票文件 todo + List list = incomeInvoiceDao.queryOaZb(incomeInvoiceEntity); + if(list != null && list.size() == 1){ + incomeInvoiceEntity.setFormmainId(list.get(0).getDataId()); + } + List mxlist = incomeInvoiceDao.queryOaMx(incomeInvoiceEntity); + if(mxlist != null && mxlist.size() == 1){ + incomeInvoiceEntity.setDataId(mxlist.get(0).getDataId()); + incomeInvoiceDao.updateMx(incomeInvoiceEntity); + } + if(mxlist == null || mxlist.size() == 0){ + incomeInvoiceEntity.setDataId(1); + incomeInvoiceDao.saveMx(incomeInvoiceEntity); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return entity; + } + + + + private String getXml(JSONObject jsonObject) { + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("fpdm") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("fphm") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("kprq") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("xfsh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("xfmc") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("gfsh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("gfmc") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("hjje") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("hjse") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("jshj") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("jym") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("xfdzdh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("xfyhzh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("gfdzdh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("gfyhzh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("bz") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("jqbh") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("jdhm") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("kpr") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("skr") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("fhr") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("htbm") != null?"":""); + stringBuffer.append("").append(""); + + stringBuffer.append("").append(""); + stringBuffer.append(jsonObject.getString("fpwj") != null?"":""); + stringBuffer.append("").append(""); + + + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + + JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("mdm_fp_detail")); + if(jsonArray != null&& jsonArray.size() > 0){ + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject detailObject = jsonArray.getJSONObject(i); + stringBuffer.append(""); + stringBuffer.append("").append(detailObject.getString("xh") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("ssflbm") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("xmmc") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("ggxh") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("dw") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("sl") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("dj") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("je") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("slv") != null?"":"").append(""); + stringBuffer.append("").append(detailObject.getString("se") != null?"":"").append(""); + stringBuffer.append(""); + } + } + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + stringBuffer.append(""); + + return stringBuffer.toString(); + } + + + /** + * @Author lvleigang + * @Description 财报数据推送 + * @Date 4:28 下午 2025/4/16 + * @param requestJson + * @return com.hzya.frame.web.entity.JsonResultEntity + **/ + @Override + public JsonResultEntity sendFinancialReportPlugin(JSONObject requestJson) { + + logger.error("财报数据推送入参"+requestJson.toJSONString()); + JSONObject jsonStr = requestJson.getJSONObject("jsonStr"); + JSONObject businessDataStr = jsonStr.getJSONObject("businessDataStr"); + String eventType = jsonStr.getString("eventType"); + switch (eventType) { + case "onProcessFinished"://流程结束事件,同步物料到U8C + JSONObject businessData = businessDataStr.getJSONObject("formmain_0708"); + if(businessData.getString("field0007") == null){//数据类型 + return BaseResult.getFailureMessageEntity("数据类型为空"); + } + if(businessData.getString("field0007").equals("1")){//科目余额 + + } + if(businessData.getString("field0007").equals("2")){//财报 + return sendFinancialReport(businessData); + } + if(businessData.getString("field0007").equals("3")){//进项发票 + return BaseResult.getFailureMessageEntity("数据类型错误"); + } + if(businessData.getString("field0007").equals("4")){//销项发票 + return BaseResult.getFailureMessageEntity("数据类型错误"); + } + return BaseResult.getSuccessMessageEntity("推送数据成功"); + default: + return BaseResult.getFailureMessageEntity("未匹配到流程监听事件!当前传入的eventType:" + eventType); + } + + + + } + + /** + * @Author lvleigang + * @Description 发送财报数据 + * @Date 5:28 下午 2025/4/22 + * @param businessData + * @return com.hzya.frame.web.entity.JsonResultEntity + **/ + private JsonResultEntity sendFinancialReport(JSONObject businessData) { + String access_token = getToken(); + if (access_token == null) { + return BaseResult.getFailureMessageEntity("token获取失败"); + } + String url = cbUrl+access_token; + String ztbm = businessData.getString("field0005");//账套编码 + String sh = businessData.getString("field0006");//税号 + String sjlx = businessData.getString("field0007");//数据类型 + String cjzq = businessData.getString("field0008");//采集账期 + String rwbm = businessData.getString("field0009");//任务编码 + if(ztbm == null || "".equals(ztbm)){ + return BaseResult.getSuccessMessageEntity("账套编码为空"); + } + if(cjzq == null || "".equals(cjzq)){ + return BaseResult.getSuccessMessageEntity("采集账期为空"); + } + if(rwbm == null || "".equals(rwbm)){ + return BaseResult.getSuccessMessageEntity("任务编码为空"); + } + + + + Date date = null; + String qncjzq = null; + + IncomeInvoiceEntity dyAloneId = null; + JSONObject dydata = null; + JSONObject qndata = null; + IncomeInvoiceEntity qnAloneId = null; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + try { + date = sdf.parse(cjzq); + } catch (ParseException e) { + return BaseResult.getSuccessMessageEntity("采集账期格式错误"); + } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.YEAR, -1); + Date qn = calendar.getTime(); + qncjzq = sdf.format(qn); + + //查询当月帐套组织 + IncomeInvoiceEntity jnentity = new IncomeInvoiceEntity(); + jnentity.setDataSourceCode(""); + jnentity.setSysData(cjzq); + jnentity.setOrgCode(ztbm); + List jnlist = incomeInvoiceDao.queryZtzz(jnentity); + if(jnlist != null && jnlist.size() == 1){ + dyAloneId = jnlist.get(0); + }else { + return BaseResult.getSuccessMessageEntity("未查询到当月的财报数据,不推送"); + } + //查询去年当帐套组织 + IncomeInvoiceEntity qnentity = new IncomeInvoiceEntity(); + qnentity.setDataSourceCode(""); + qnentity.setSysData(qncjzq); + qnentity.setOrgCode(ztbm); + List qnlist = incomeInvoiceDao.queryZtzz(qnentity); + if(qnlist != null && qnlist.size() == 1){ + qnAloneId = qnlist.get(0); + }else { + logger.info("未查询到去年当期的财报数据"); + } + + //查询当月的财报数据 + IncomeInvoiceEntity jnquerydata = new IncomeInvoiceEntity(); + jnquerydata.setDataSourceCode(""); + jnquerydata.setAloneId(dyAloneId.getAloneId()); + List dydataList = incomeInvoiceDao.queryByAloneId(jnquerydata); + if(dydataList != null && dydataList.size() == 1){ + dydata = dydataList.get(0); + }else { + return BaseResult.getSuccessMessageEntity("未查询到当月的财报数据,不推送"); + } + //查询去年当期的财报数据 + if(qnAloneId != null){ + //查找去年数据 + IncomeInvoiceEntity qnquerydata = new IncomeInvoiceEntity(); + qnquerydata.setDataSourceCode(""); + qnquerydata.setAloneId(qnAloneId.getAloneId()); + List qndataList = incomeInvoiceDao.queryByAloneId(qnquerydata); + if(qndataList != null && qndataList.size() == 1){ + qndata = qndataList.get(0); + } + } + //拼接数据 + JSONObject sendData = new JSONObject(); + sendData.put("accessKey",accessKey); + long timestamp = System.currentTimeMillis(); + sendData.put("timestamp",timestamp); + sendData.put("taskNo",rwbm); + sendData.put("period",cjzq); + + JSONArray reportList = new JSONArray(); + + JSONObject zcfzb = new JSONObject();//资产负债表 + zcfzb.put("period",cjzq); + zcfzb.put("reportType",1); + JSONArray reportSubjects1 = new JSONArray(); + setDataToArray("subjectName","12312",1,reportSubjects1); + zcfzb.put("reportSubjects",reportSubjects1); + + JSONObject llb = new JSONObject();//利润表 + llb.put("period",cjzq); + llb.put("reportType",2); + JSONArray reportSubjects2 = new JSONArray(); + llb.put("reportSubjects",reportSubjects2); + + JSONObject xjll = new JSONObject();//现金流量表 + xjll.put("period",cjzq); + xjll.put("reportType",3); + JSONArray reportSubjects3 = new JSONArray(); + xjll.put("reportSubjects",reportSubjects3); + + + + + + reportList.add(zcfzb); + reportList.add(llb); + reportList.add(xjll); + + sendData.put("reportList",reportList); + String a = YzfSignUtil.signRequest(sendData,accessSecret); + sendData.put("sign",a); + + Map headers = new HashMap<>(); + headers.put("Content-Type", "application/json; charset=utf-8"); + String returndata = sendPost(url, headers, sendData.toJSONString()); + + if (returndata != null && JSONObject.isValidObject(returndata)) { + JSONObject dataJson = JSONObject.parseObject(returndata); + if(dataJson != null && dataJson.getString("code") != null && "0".equals( dataJson.getString("code"))){ + JSONObject data = dataJson.getJSONObject("result"); + if(data != null ){ + if(data != null && data.getString("resultCode") != null && "0".equals( data.getString("resultCode"))){ + return BaseResult.getSuccessMessageEntity("执行成功"); + }else { + return BaseResult.getFailureMessageEntity("发送失败:"+returndata); + } + }else { + return BaseResult.getFailureMessageEntity("发送失败:"+returndata); + } + }else { + return BaseResult.getFailureMessageEntity("发送失败:"+returndata); + } + }else { + return BaseResult.getFailureMessageEntity("发送失败:"+returndata); + } + } + + private void setDataToArray(String subjectName, String value, Integer valueType, JSONArray reportSubjects) { + if(value != null && !"".equals(value)){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("subjectName",subjectName); + jsonObject.put("value",new BigDecimal(value)); + jsonObject.put("valueType",valueType); + reportSubjects.add(jsonObject); + } + } +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java index beb4c48e..f79b7098 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/mdmDistribute/plugin/MdmModulePluginInitializer.java @@ -470,9 +470,10 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { } } }else {//执行正常下发 - + logger.info("==========开始执行正常主数据下发============="); //查询主数据 MdmModuleEntity queryMdmModuleEntity = new MdmModuleEntity(); + queryMdmModuleEntity.setMdmCode(10050L); queryMdmModuleEntity.setSts("Y"); List mdmModuleEntities = mdmModuleDao.queryBase(queryMdmModuleEntity); if(mdmModuleEntities == null || mdmModuleEntities.size() == 0){ @@ -509,13 +510,17 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { queryFildRule.setRuleCode("service"); List mdmModuleDbFiledsRuleEntities = mdmModuleDbFiledsRuleDao.queryBase(queryFildRule); - //新增 - doAdd(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); - + if(mdmModuleEntities.get(i).getMdmCode()!= 10045L){ + //新增 + doAdd(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); + }else{ + logger.info("主数据编码为10045,已经在业务数据下发执行,主数据下发不执行"); + continue; + } } } @@ -739,7 +744,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { map1.put("tableName",mainDb); //map1.put("dataStatus", "F"); map1.put("updateStatus", "0"); - map1.put("size", 50); + //map1.put("size", 50); objects = mdmModuleDao.queryMdmSTs(map1); objects = toLowerCaseKeys(objects); @@ -827,6 +832,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { /** body */ String bodys = doObjects.get(i).toJSONString(); if(scriptEntity != null && scriptEntity.getId() != null ){ + logger.info("=========开始执行正常主数据修改下发脚本,第一次=============="); groovy.put("code",scriptEntity.getScriptCode()); groovy.put("className",scriptEntity.getClassName()); groovy.put("name",scriptEntity.getScriptName()); @@ -854,6 +860,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { headers.putAll(header); } if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + logger.info("=========正常主数据修改开始执行登录接口=============="); //找到登陆接口 SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); if (null == loginApi) { @@ -874,12 +881,15 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { continue; } JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + logger.info("=======主数据正常修改下发登录返回数据:{}========",attritube.toJSONString()); querys = getQuery(apiEntity,querys,attritube); headers = getHeaders(apiEntity,headers,attritube); bodys = getBodys(apiEntity,bodys,attritube); } //组装数据发送 + logger.info("=========开始执行主业务修改数据下发脚本,第二次=============="); JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); + logger.info("=====主数据修改下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); if(jsonResultEntity.isFlag()){ //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); @@ -911,7 +921,8 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { * @param mdmModuleDistributeEntities * @return void **/ - private void doAdd(String mdmId,Long mainCode,List mdmModuleDbEntities, List mdmModuleDistributeEntities,List mdmModuleDbFiledsRuleEntities,List mdmModuleDbFiledsEntities ) throws Exception { + private void + doAdd(String mdmId,Long mainCode,List mdmModuleDbEntities, List mdmModuleDistributeEntities,List mdmModuleDbFiledsRuleEntities,List mdmModuleDbFiledsEntities ) throws Exception { //查询一千条数据 String mainDb = null; List objects = new ArrayList<>(); @@ -927,7 +938,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { map1.put("tableName",mainDb); //map1.put("dataStatus", "Y"); map1.put("addStatus", "0"); - map1.put("size", 50); + //map1.put("size", 50); objects = mdmModuleDao.queryMdmSTs(map1); objects = toLowerCaseKeys(objects); @@ -999,6 +1010,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { mdmModuleSendLogEntity.setOptionType("1"); Integer num = mdmModuleSendLogDao.getCount(mdmModuleSendLogEntity); if(num > 0){//已经新增过不发送 + objects.get(i).put("sendsanfzt123",true); continue; } getDetailData(mdmModuleDbEntities,doObjects.get(i),mdmModuleDbFiledsRuleEntities,mdmModuleDbFiledsEntities); @@ -1029,6 +1041,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { /** body */ String bodys = doObjects.get(i).toJSONString(); if(scriptEntity != null && scriptEntity.getId() != null ){ + logger.info("=========开始执行正常主数据新增下发脚本,第一次=============="); groovy.put("code",scriptEntity.getScriptCode()); groovy.put("className",scriptEntity.getClassName()); groovy.put("name",scriptEntity.getScriptName()); @@ -1056,6 +1069,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { headers.putAll(header); } if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { + logger.info("=========正常主数据新增开始执行登录接口=============="); //找到登陆接口 SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); if (null == loginApi) { @@ -1076,15 +1090,19 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { continue; } JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + logger.info("=======主数据正常新增下发登录返回数据:{}========",attritube.toJSONString()); querys = getQuery(apiEntity,querys,attritube); headers = getHeaders(apiEntity,headers,attritube); bodys = getBodys(apiEntity,bodys,attritube); } //组装数据发送 + logger.info("=========开始执行主业务新增数据下发脚本,第二次=============="); JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); + logger.info("=====主数据新增下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); if(jsonResultEntity.isFlag()){ if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) { + logger.info("=========开始执行主数据新增返回脚本=============="); JSONObject backScriptJson = new JSONObject(); backScriptJson.put("data", jsonResultEntity.getAttribute()); groovy.put("code", scriptEntity.getScriptCode()+"back"); @@ -1124,11 +1142,13 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); objects.get(i).put("sendsanfzt123",true); + logger.info("========主数据新增下发完成,日志保存为成功============"); continue; }else { //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); objects.get(i).put("sendsanfzt123",false); + logger.info("========主数据新增下发完成,日志保存为失败============"); continue; } } @@ -1136,7 +1156,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { //所有下发发送完成,修改数据状态 for (int i = 0; i < objects.size(); i++) { - if(objects.get(i).getBoolean("sendsanfzt123")){ + if(objects.get(i).getString("sendsanfzt123") != null && objects.get(i).getBoolean("sendsanfzt123")){ Map updateMap = new HashMap<>(); updateMap.put("tableName",mainDb); //updateMap.put("dataStatus", "Y"); @@ -1490,4 +1510,4 @@ public class MdmModulePluginInitializer extends PluginBaseEntity { } return jsonObjects; } -} +} \ No newline at end of file diff --git a/base-buildpackage/src/main/resources/application-llg.yml b/base-buildpackage/src/main/resources/application-llg.yml new file mode 100644 index 00000000..03cdf7ee --- /dev/null +++ b/base-buildpackage/src/main/resources/application-llg.yml @@ -0,0 +1,82 @@ +#######################本地环境####################### +logging: + #日志级别 指定目录级别 + level: + root: info + encodings: UTF-8 + file: + # 日志保存路径 + path: /Users/apple/Desktop/log/local +spring: + data: + mongodb: +# host: 192.168.2.237 +# port: 27017 +# database: businesscenter +# auto-index-creation: true +# password: hzya1314 +# username: hzya + flyway: + # 启动flyway migration, 默认为true + enabled: false + datasource: + dynamic: + druid: + filters: stat,log4j2 + datasource: + master: +# url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle +# username: hzyazt +# password: 62e4295b615a30dbf3b8ee96f41c820b +# driver-class-name: dm.jdbc.driver.DmDriver +# type: com.alibaba.druid.pool.DruidDataSource + url: jdbc:mysql://ufidahz.com.cn:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true + username: root + password: bd993088e8a7c3dc5f44441617f9b4bf + driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 +# url: jdbc:dm://hzya.ufyct.com:9040/businesscenter?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 +# url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle +# username: hzyazt +# password: 62e4295b615a30dbf3b8ee96f41c820b +# driver-class-name: dm.jdbc.driver.DmDriver +savefile: + # 文件保存路径 + path: /Users/apple/Desktop/log/local + tomcatpath: /Users/apple/Desktop/log/local + pluginpath: /Users/apple/Desktop/log/local +zt: + url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface +cbs8: + appId: 1P4AGrpz + appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a + url: https://cbs8-openapi-reprd.csuat.cmburl.cn + # 测试用这个 这个是银行给的,和下面的公钥不是一对密钥 + ya_private_key: 83BA7EC821D35F4CB31FF9A51C1EFA520FC52AF828C2337F88E91CF119B07F44 + # 这个私钥到时候上传到cbs,和下面到是同一对 + #ya_private_key: e1eacfdee9b8d4184437d5a2071e17ce31befc3d93395f9f05709ed562e8dc46 + ya_public_key: 044fa399d2223760f17b81b863cb482b009294c4516f8a605dea1475ec09e720eaa98468715e5ad509a592a0b426061551c5a3df236966c23253a7d894eac0dcde + cbs_public_key: 0469146F06BF3B01236E84632441E826 + #电子回单下载临时存放位置 + elec_path: /Users/xiangerlin/Downloads/ +OA: + data_source_code: yc_oa +server: + port: 10086 + +# mysqldump -d mylm -hhzya.ufyct.com -p9096 -uroot -phzya1314 >%dirName%\table_view.sql + + +database: + databaseName: businesscenter + host: 192.168.2.237 + port: 3306 + username: root + password: hzya@1314 + filePase: /Users/apple/Desktop/log + fileName: data.sql +#sftp: +# host: 192.168.2.237 +# port: 9091 +# username: cs237 +# password: hzya@1314 +# filePase: /databaseBack diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/pluginCfg.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/pluginCfg.xml new file mode 100644 index 00000000..4fe837f2 --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/pluginCfg.xml @@ -0,0 +1,6 @@ + + +IncomeInvoicePlugin +IncomeInvoicePlugin插件 +202404080001 + diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-dao.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-dao.xml new file mode 100644 index 00000000..52a288d1 --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-dao.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-plugin.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-plugin.xml new file mode 100644 index 00000000..2c2856fe --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-plugin.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-service.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-service.xml new file mode 100644 index 00000000..68ce3bce --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/incomeInvoiceData/spring/spring-buildpackage-service.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/ApplicationCache.java b/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/ApplicationCache.java index 16daadce..e8482db9 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/ApplicationCache.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/ApplicationCache.java @@ -64,6 +64,9 @@ public class ApplicationCache { case "2": // o = applicationApiMap.get(key); break; + case "5": // + o = applicationApiMap.get(key); + break; case "3": // o = applicationApiAuthMap.get(key); break; @@ -96,6 +99,7 @@ public class ApplicationCache { if(receiveApiList != null && receiveApiList.size() > 0){ for (int i = 0; i < receiveApiList.size(); i++) { applicationApiMap.put("appId"+receiveApiList.get(i).getAppId()+"apiCode"+receiveApiList.get(i).getApiCode(), receiveApiList.get(i)); + applicationApiMap.put("apiId"+receiveApiList.get(i).getId(), receiveApiList.get(i)); } } break; diff --git a/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java b/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java index ad9976a0..caf670cc 100644 --- a/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java +++ b/base-service/src/main/java/com/hzya/frame/sysnew/application/service/impl/SysApplicationServiceImpl.java @@ -3055,8 +3055,13 @@ public class SysApplicationServiceImpl extends BaseService headers = entity.getHeaders(); + SysApplicationApiEntity sysApplicationEntity = entity.getReceiveApi(); + SysApplicationEntity sendApp = entity.getSendApp(); + SysApplicationEntity receiveApp = entity.getReceiveApp(); + if("1".equals(sysApplicationEntity.getNeedLogin()) && sysApplicationEntity.getAuthenticationPort() != null){ + SysApplicationApiEntity loginApi = getApiByAppIdApiCode(sysApplicationEntity.getAuthenticationPort()); + if (null == loginApi) { + return entity; + } + String rzquerys = getQuery(loginApi,null,null); + Map headersa = new HashMap<>(); + headersa.put("publicKey", sendApp.getPublicKey()); + headersa.put("secretKey", sendApp.getSecretKey()); + headersa.put("appId", receiveApp.getAppId().toString()); + headersa.put("apiCode", loginApi.getApiCode().toString()); + Map rzheaders = getHeaders(loginApi,headersa,null); + String rzbodys = getBodys(loginApi,null,null); + JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); + if (!rzjsonResultEntity.isFlag()) { + return entity; + } + JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); + headers.put("token",attritube.getJSONObject("attribute").getString("id")); + } + entity.setHeaders(headers); + return entity; + } + private SysApplicationApiEntity getApiByAppIdApiCode(String apiId) { + + String str = "apiId" + apiId ; + Object o = applicationCache.get("5", str); + if (o != null) { + return (SysApplicationApiEntity) o; + } + return null; + } + private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map headers ,String bodys ,String querys) { + StringBuffer urls = new StringBuffer(url); + if (querys != null) { + urls.append("?"); + urls.append(querys); + } + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build(); + HttpPost post = new HttpPost(urls.toString()); + CloseableHttpResponse response = null; + + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(Integer.valueOf(applicationApiEntity.getTimeoutPeriod())).build(); + post.setConfig(requestConfig);//设置请求参数【超时时间】 + + if (headers != null && headers.size() > 0) { + for (String key : headers.keySet()) { + post.setHeader(key, headers.get(key)); + } + } + StringBuilder body = new StringBuilder(); + boolean flag = true; + try { + if (bodys != null && !"".equals(bodys)) { + ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8")); + entity.setContentType("application/json"); + post.setEntity(entity); + } + response = closeableHttpClient.execute(post); + + HttpEntity entity = response.getEntity(); + body.append(EntityUtils.toString(entity,"UTF-8")); + flag = true; + logger.info("返回结果:" + body); + } catch (Exception e) { + logger.error("请求错误:" + e.getMessage()); + body.append(e.getMessage()); + flag = false; + } finally { + try { + // 关闭响应对象 + if (response != null) { + response.close(); + } + // 关闭响应对象 + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } + if (flag) { + if (JSONUtil.isTypeJSON(body.toString())) { + JsonResultEntity jsonResultEntity = JSONObject.parseObject(body.toString(),JsonResultEntity.class); + if(jsonResultEntity.isFlag()){ + return BaseResult.getSuccessMessageEntity("转发成功", body); + }else { + return BaseResult.getFailureMessageEntity("转发失败", body); + } + }else { + return BaseResult.getFailureMessageEntity("转发失败", body); + } + } else { + return BaseResult.getFailureMessageEntity("转发失败", body); + } + } + + private String getBodys(SysApplicationApiEntity loginApi,String sendDatastr, JSONObject loginData) { + JSONObject sendData = new JSONObject(); + if(sendDatastr != null ){ + sendData = JSONObject.parseObject(sendDatastr); + } + if(loginData == null){ + loginData = new JSONObject(); + } + if (loginApi.getBodyIn() != null && !"".equals(loginApi.getBodyIn())) { + if (JSONUtil.isTypeJSONArray(loginApi.getBodyIn())) { + JSONArray headerbodyArray = JSON.parseArray(loginApi.getBodyIn()); + JSONObject bodyjson = headerbodyArray.getJSONObject(0); + JSONArray headerArray = bodyjson.getJSONArray("children"); + for (int i = 0; i < headerArray.size(); i++) { + //获取到第一个数据 + JSONObject querys = headerArray.getJSONObject(i); + if (SysEnum.FUNDAMENTAL.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 + String query = querys.getString(SysEnum.EXAMPLE.getValue()); + if (query != null && !"".equals(query)) { + sendData.put(querys.getString(SysEnum.PARAMETERNAME.getValue()),query); + } + } + } + } + } + return sendData.toString(); + } + + private Map getHeaders(SysApplicationApiEntity loginApi,Map map,JSONObject loginData) { + if(loginData == null){ + loginData = new JSONObject(); + } + if (loginApi.getHeaderIn() != null && !"".equals(loginApi.getHeaderIn())) { + if (JSONUtil.isTypeJSONArray(loginApi.getHeaderIn())) { + JSONArray headerArray = JSON.parseArray(loginApi.getHeaderIn()); + for (int i = 0; i < headerArray.size(); i++) { + JSONObject querys = headerArray.getJSONObject(i); + //query 只有基本类型,不用循环判断下级 + //判断参数是否有值 + //获取对象下面的层级数据 + if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 + String query = querys.getString(SysEnum.EXAMPLE.getValue()); + if (query != null && !"".equals(query)) { + JSONArray example = JSONArray.parseArray(query); + String logValue = getObjectValue(loginData, example); + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue); + } + } else { + if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), querys.getString(SysEnum.EXAMPLE.getValue())); + } + } else {//没有值直接拼接 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), ""); + } + } + } + } + } + } + return map; + + + + + } + + /** + * @param loginData + * @param example + * @return java.lang.String + * @Author lvleigang + * @Description 根据jsonArray 获取jsonobject中的值 + * @Date 11:47 上午 2023/8/31 + **/ + private String getObjectValue(JSONObject loginData, JSONArray example) { + String values = ""; + if (example != null && example.size() > 0) { + for (int i = 0; i < example.size(); i++) { + if (loginData.getString(example.getString(i)) != null && !"".equals(loginData.getString(example.getString(i)))) { + if (i == (example.size() - 1)) { + values = loginData.getString(example.getString(i)); + } else { + loginData = JSONObject.parseObject(loginData.getString(example.getString(i))); + } + } else { + return values; + } + } + } + return values; + } + private String getQuery(SysApplicationApiEntity loginApi,String sendDatastr,JSONObject loginData) { + Map map = new HashMap<>(); + if(sendDatastr != null){ + String[] parts = sendDatastr.split("&"); + if(parts != null && parts.length > 0){ + for (int i = 0; i < parts.length; i++) { + String[] part = parts[i].split("="); + if(part != null && part.length >=2 ){ + for (int a = 0; a < part.length; a++) { + map.put(part[0],part[1]); + } + } + } + } + } + if(loginData == null){ + loginData = new JSONObject(); + } + if (loginApi.getQueryIn() != null && !"".equals(loginApi.getQueryIn())) { + if (JSONUtil.isTypeJSONArray(loginApi.getQueryIn())) { + JSONArray headerArray = JSON.parseArray(loginApi.getQueryIn()); + for (int i = 0; i < headerArray.size(); i++) { + JSONObject querys = headerArray.getJSONObject(i); + //query 只有基本类型,不用循环判断下级 + //判断参数是否有值 + //获取对象下面的层级数据 + if (SysEnum.AUTHPORT.getValue().equals(querys.getString(SysEnum.PARAMETERTYPE.getValue()))) {//认证类型 + String query = querys.getString(SysEnum.EXAMPLE.getValue()); + if (query != null && !"".equals(query)) { + JSONArray example = JSONArray.parseArray(query); + String logValue = getObjectValue(loginData, example); + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), logValue); + } + } else { + //不是认证类型直接取值 + if (querys.getString(SysEnum.EXAMPLE.getValue()) != null && !"".equals(querys.getString(SysEnum.EXAMPLE.getValue()))) {//入参没有值用实例值,如果没有不添加 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), querys.getString(SysEnum.EXAMPLE.getValue())); + } + } else {//没有值直接拼接 + if(map.get(querys.getString(SysEnum.PARAMETERNAME.getValue())) == null){ + map.put(querys.getString(SysEnum.PARAMETERNAME.getValue()), ""); + } + } + } + } + } + } + StringBuffer returnStr = new StringBuffer(); + if(map != null && map.size() > 0){ + for (String key : map.keySet()) { + if("".equals(returnStr)){ + returnStr.append(key).append("=").append(map.get(key)); + }else { + returnStr.append("&").append(key).append("=").append(map.get(key)); + } + } + } + return returnStr.toString(); + } } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/service/impl/ZxBankServiceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/service/impl/ZxBankServiceImpl.java index db95ea38..20d0b981 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/service/impl/ZxBankServiceImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/service/impl/ZxBankServiceImpl.java @@ -67,11 +67,10 @@ public class ZxBankServiceImpl extends BaseService impleme @Value("${zt.url}") private String url; - - @Value("${zx.privateKey}") + @Value("${zx.privateKey:}") private String privateKey; - @Value("${zx.publicKey}") + @Value("${zx.publicKey:}") private String publicKey; @Override public JsonResultEntity queryArchives(JSONObject json) {