From 6f0c9cf45c855e0420a0c1e5ebd0ed8429968bd0 Mon Sep 17 00:00:00 2001 From: hecan <1718492867@qq.com> Date: Tue, 8 Apr 2025 10:51:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E7=94=B3=E8=AF=B7=E5=92=8C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=94=B3=E8=AF=B7=E5=8D=95=E8=AF=A6=E6=83=85?= =?UTF-8?q?,=E4=BB=A5=E5=8F=8A=E4=B8=AD=E4=BF=A1=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E5=9B=9E=E5=8D=95=E4=B8=8A=E4=BC=A0OA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/MakeInvoicePluginInitializer.java | 15 +- .../src/main/resources/application-ht.yml | 4 +- .../spring/spring-buildpackage-plugin.xml | 1 + .../frame/seeyon/invoice/dao/IInvoiceDao.java | 32 + .../invoice/dao/IInvoiceDetailsDao.java | 20 + .../invoice/dao/impl/InvoiceDaoImpl.java | 41 ++ .../dao/impl/InvoiceDetailsDaoImpl.java | 35 + .../invoice/entity/InvoiceDetailsEntity.java | 141 ++++ .../invoice/entity/InvoiceDetailsEntity.xml | 41 ++ .../seeyon/invoice/entity/InvoiceEntity.java | 618 ++++++++++++++++++ .../seeyon/invoice/entity/InvoiceEntity.xml | 92 +++ .../invoice/service/IInvoiceService.java | 29 + .../service/impl/InvoiceServiceImpl.java | 246 +++++++ .../frame/seeyon/zxbank/dao/IZxBankDao.java | 16 +- .../seeyon/zxbank/dao/impl/ZxBankDaoImpl.java | 18 +- .../seeyon/zxbank/entity/ZxBankEntity.java | 8 + .../seeyon/zxbank/entity/ZxBankEntity.xml | 13 +- .../service/impl/ZxBankServiceImpl.java | 338 ++++++++-- 18 files changed, 1637 insertions(+), 71 deletions(-) create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDetailsDao.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDetailsDaoImpl.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.xml create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java create mode 100644 fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/MakeInvoicePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/MakeInvoicePluginInitializer.java index 4736a39c..6ce63b2d 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/MakeInvoicePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/MakeInvoicePluginInitializer.java @@ -2,10 +2,12 @@ package com.hzya.frame.plugin.ht.plugin; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.seeyon.invoice.service.impl.InvoiceServiceImpl; import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.JsonResultEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; /** * @Description @@ -13,6 +15,9 @@ import org.slf4j.LoggerFactory; * @Date 2024/8/22 16:39 **/ public class MakeInvoicePluginInitializer extends PluginBaseEntity { + + @Autowired + private InvoiceServiceImpl invoiceService; Logger logger = LoggerFactory.getLogger(getClass()); /*** * 插件初始化方法 @@ -91,7 +96,13 @@ public class MakeInvoicePluginInitializer extends PluginBaseEntity { **/ @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { - - return BaseResult.getSuccessMessageEntity("操作成功"); + try { + logger.info("======开始执行杭泰开票申请单同步========"); + return invoiceService.queryArchives(requestJson); + }catch (Exception e){ + logger.info("======执行杭泰开票申请单同步失败:{}========",e.getMessage()); + e.printStackTrace(); + } + return null; } } diff --git a/base-buildpackage/src/main/resources/application-ht.yml b/base-buildpackage/src/main/resources/application-ht.yml index 744db85b..85d1b848 100644 --- a/base-buildpackage/src/main/resources/application-ht.yml +++ b/base-buildpackage/src/main/resources/application-ht.yml @@ -12,7 +12,7 @@ spring: dynamic: datasource: master: - url: jdbc:mysql://127.0.0.1:3307/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 + 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可省略此配置 @@ -39,7 +39,7 @@ cbs8: OA: data_source_code: yc_oa zt: - url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface + url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface zx: # 测试用这个 这个是银行给的 privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0 diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/zxBank/spring/spring-buildpackage-plugin.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/zxBank/spring/spring-buildpackage-plugin.xml index cb28c7ce..845017ce 100644 --- a/base-buildpackage/src/main/resources/cfgHome/plugin/zxBank/spring/spring-buildpackage-plugin.xml +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/zxBank/spring/spring-buildpackage-plugin.xml @@ -4,4 +4,5 @@ + diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java new file mode 100644 index 00000000..50747bc2 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDao.java @@ -0,0 +1,32 @@ +package com.hzya.frame.seeyon.invoice.dao; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; + +import java.util.HashMap; +import java.util.List; + +public interface IInvoiceDao extends IBaseDao { + + /** + * + * @content 查询需要推送税务的数据 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-01 15:33 + * **/ + List> queryInvoice(String str , MdmModuleSourceEntity entity); + + /** + * + * @content 查询申请单详情 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-07 14:05 + * **/ + List queryInvoiceResult(InvoiceEntity entity); +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDetailsDao.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDetailsDao.java new file mode 100644 index 00000000..8a61f896 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/IInvoiceDetailsDao.java @@ -0,0 +1,20 @@ +package com.hzya.frame.seeyon.invoice.dao; + +import com.hzya.frame.basedao.dao.IBaseDao; +import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.invoice.entity.InvoiceDetailsEntity; + +import java.util.HashMap; +import java.util.List; + +public interface IInvoiceDetailsDao extends IBaseDao { + /** + * + * @content 查询需要推送税务的数据 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-01 15:33 + * **/ + List> queryInvoiceDetails(String str , MdmModuleSourceEntity entity); +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java new file mode 100644 index 00000000..92743132 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDaoImpl.java @@ -0,0 +1,41 @@ +package com.hzya.frame.seeyon.invoice.dao.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.execsql.service.IExecSqlService; +import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao; +import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.List; + +@Repository(value = "InvoiceDaoImpl") +public class InvoiceDaoImpl extends MybatisGenericDao implements IInvoiceDao { + @Autowired + private IExecSqlService execSqlService; + + private Logger logger = LogManager.getLogger(super.getClass()); + + @DS("#entity.dataSourceCode") + @Override + public List> queryInvoice(String str, MdmModuleSourceEntity entity) { + try { + List> hashMaps = execSqlService.execSelectSql(str, ""); + return hashMaps; + }catch (Exception e){ + logger.info("没有需要推送税务的数据"); + return null; + } + } + + @DS("#entity.dataSourceCode") + @Override + public List queryInvoiceResult(InvoiceEntity entity) { + return (List) super.selectList("queryInvoiceResult",entity); + } +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDetailsDaoImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDetailsDaoImpl.java new file mode 100644 index 00000000..55b1b481 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/dao/impl/InvoiceDetailsDaoImpl.java @@ -0,0 +1,35 @@ +package com.hzya.frame.seeyon.invoice.dao.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.hzya.frame.basedao.dao.MybatisGenericDao; +import com.hzya.frame.execsql.service.IExecSqlService; +import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao; +import com.hzya.frame.seeyon.invoice.entity.InvoiceDetailsEntity; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.List; + +@Repository(value ="InvoiceDetailsDaoImpl") +public class InvoiceDetailsDaoImpl extends MybatisGenericDao implements IInvoiceDetailsDao { + @Autowired + private IExecSqlService execSqlService; + + private Logger logger = LogManager.getLogger(super.getClass()); + + @DS("#entity.dataSourceCode") + @Override + public List> queryInvoiceDetails(String str, MdmModuleSourceEntity entity) { + try { + List> hashMaps = execSqlService.execSelectSql(str, ""); + return hashMaps; + }catch (Exception e){ + logger.info("没有需要推送税务的明细数据"); + return null; + } + } +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.java new file mode 100644 index 00000000..a7bc58fd --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.java @@ -0,0 +1,141 @@ +package com.hzya.frame.seeyon.invoice.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +public class InvoiceDetailsEntity extends BaseEntity { + private String item_no;//明细行编号 + private String item_name;//商品名称 + private String tax_cate_code;//税收分类编码,19位 + private String spec;//规格型号 + private String unit;//单位 + private String quantity;//数量 + private String unit_price;//单价 + private String price;//金额 + private String tax_rate;//税率 + private String zero_flag;//零税率 + private String tax;//税额 + private String include_tax_tag;//含税标识 + private String detail_type;//明细行性质 + private String enjoy_preferential_flag;//是否享受优惠0 否1是 + private String preferential_policy_type;//优惠政策类型 + + public String getItem_no() { + return item_no; + } + + public void setItem_no(String item_no) { + this.item_no = item_no; + } + + public String getItem_name() { + return item_name; + } + + public void setItem_name(String item_name) { + this.item_name = item_name; + } + + public String getTax_cate_code() { + return tax_cate_code; + } + + public void setTax_cate_code(String tax_cate_code) { + this.tax_cate_code = tax_cate_code; + } + + public String getSpec() { + return spec; + } + + public void setSpec(String spec) { + this.spec = spec; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getUnit_price() { + return unit_price; + } + + public void setUnit_price(String unit_price) { + this.unit_price = unit_price; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getTax_rate() { + return tax_rate; + } + + public void setTax_rate(String tax_rate) { + this.tax_rate = tax_rate; + } + + public String getZero_flag() { + return zero_flag; + } + + public void setZero_flag(String zero_flag) { + this.zero_flag = zero_flag; + } + + public String getTax() { + return tax; + } + + public void setTax(String tax) { + this.tax = tax; + } + + public String getInclude_tax_tag() { + return include_tax_tag; + } + + public void setInclude_tax_tag(String include_tax_tag) { + this.include_tax_tag = include_tax_tag; + } + + public String getDetail_type() { + return detail_type; + } + + public void setDetail_type(String detail_type) { + this.detail_type = detail_type; + } + + public String getEnjoy_preferential_flag() { + return enjoy_preferential_flag; + } + + public void setEnjoy_preferential_flag(String enjoy_preferential_flag) { + this.enjoy_preferential_flag = enjoy_preferential_flag; + } + + public String getPreferential_policy_type() { + return preferential_policy_type; + } + + public void setPreferential_policy_type(String preferential_policy_type) { + this.preferential_policy_type = preferential_policy_type; + } +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.xml new file mode 100644 index 00000000..4238f173 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceDetailsEntity.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + * + + + + + + + + + + + + + diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java new file mode 100644 index 00000000..c3afa017 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.java @@ -0,0 +1,618 @@ +package com.hzya.frame.seeyon.invoice.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +public class InvoiceEntity extends BaseEntity { + private String sfhc;// 是否红冲 + private String xf;// 销方 + private String access_key;// 申请开放平台分配的accessKey + private String sign;// 加密签名 + private String timestamp;// 用户发起请求的时间 + private String serial_number;// 请求唯一流水号 + private String company_code;// 企业编码 + private String seller_tax_no;// 企业纳税人识别号 + private String template_id;// 模版ID,固定值: + private String business_no;// 业务单号 + private String superior_business_no;// 上级业务单号 + private String buyer_name;// 购买方名称 + private String buyer_tax_no;// 购买方纳税人识别号 + private String buyer_addr_phone;// 购买方地址、电话 + private String buyer_bank_account;// 购买方开户行及账号 + private String apply_person;// 申请人 + private String apply_email_notice;// 是否邮件通知申请人 1 是0 否 + private String buyer_email_notice;// 是否邮件通知购买方 1 是0 否 + private String workcode;// 申请人工号 + private String other_email;// 其他发票接收邮箱 + private String buyer_contact;// 购买方发票邮寄接收联系人名称 + private String buyer_mobile;// 购买方发票邮寄接收手机号 + private String buyer_recv_address;// 购买方发票邮寄接收地址 + private String application_remark;// 申请单其他说明 + private String attachments;// 附件,文件Url地址列表 + private String notify_url;// 回调通知地址 + private String special_invoice_mark;// 特殊票种标识 + private String seller_name;// 销售方名称 + private String seller_addr_phone;// 销售方地址、电话 + private String seller_bank_account;// 销售方银行账号 + private String extend_fields;// 自定义扩展字段 + private String invoice_type;// 发票种类示例值 + private String is_person;// 是否自然人1是默认为否 + private String levy_tax_type;// 征税方式 + private String deduction;// 扣除额,差额征税时必填 + private String remark;// 发票备注 + private String place;// 地址 + private String place_of_detail;// 详细地址 + private String construction_project_name;// 建筑项目名称 + private String kqysssxbgglbm;// 跨区域涉税事项报验管理編号 + private String product_no;// 土地增值税项目编号 + private String cross_distinct_city_flag;// 跨地(市)标志:是,否 + private String certificate_of_title;// 产权证书/不动产权证号 + private String area_unit;// 面积 + private String start_date;// 租赁开始,格式yyyy-MM-dd + private String end_date;// 租赁结束,格式yyyy-MM-dd + private String original_seller_name;// 原开票企业-销售方名称 + private String original_seller_tax_no;// 原开票企业-销售方纳税人识别号 + private String applicant;// 申请方 + private String deduction_status;// 抵扣状态 + private String original_invoice_code;// 原发票代码 + private String original_invoice_number;// 原发票号码 + private String original_invoice_date;// 原发票开票日期 + private String original_invoice_price;// 原发票不含税总金额 + private String red_flush_reason;// 红冲原因 + private String original_superior_business_no;// 原上级业务单号 + private String red_letter_info_sheet_no;// 红字信息表编号 + private String original_invoice_check_ode;// 原发票校验码 + private String push_status_filed;// 推送标识字段 + private String invoice_code_field;// 发票代码字段 + private String invoice_number_field;// 发票号码字段 + private String url_field;// 发票文件字段 + private String result_status_field;// 开票结果字段 + private String push_status;// 推送标识 + private String invoice_code;// 发票代码 + private String invoice_number;// 发票号码 + private String url;// 发票文件 + private String result_status;// 开票结果 + + public String getPush_status_filed() { + return push_status_filed; + } + + public void setPush_status_filed(String push_status_filed) { + this.push_status_filed = push_status_filed; + } + + public String getInvoice_code_field() { + return invoice_code_field; + } + + public void setInvoice_code_field(String invoice_code_field) { + this.invoice_code_field = invoice_code_field; + } + + public String getInvoice_number_field() { + return invoice_number_field; + } + + public void setInvoice_number_field(String invoice_number_field) { + this.invoice_number_field = invoice_number_field; + } + + public String getUrl_field() { + return url_field; + } + + public void setUrl_field(String url_field) { + this.url_field = url_field; + } + + public String getResult_status_field() { + return result_status_field; + } + + public void setResult_status_field(String result_status_field) { + this.result_status_field = result_status_field; + } + + public String getPush_status() { + return push_status; + } + + public void setPush_status(String push_status) { + this.push_status = push_status; + } + + public String getInvoice_code() { + return invoice_code; + } + + public void setInvoice_code(String invoice_code) { + this.invoice_code = invoice_code; + } + + public String getInvoice_number() { + return invoice_number; + } + + public void setInvoice_number(String invoice_number) { + this.invoice_number = invoice_number; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getResult_status() { + return result_status; + } + + public void setResult_status(String result_status) { + this.result_status = result_status; + } + + public String getSfhc() { + return sfhc; + } + + public void setSfhc(String sfhc) { + this.sfhc = sfhc; + } + + public String getXf() { + return xf; + } + + public void setXf(String xf) { + this.xf = xf; + } + + public String getAccess_key() { + return access_key; + } + + public void setAccess_key(String access_key) { + this.access_key = access_key; + } + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getSerial_number() { + return serial_number; + } + + public void setSerial_number(String serial_number) { + this.serial_number = serial_number; + } + + public String getCompany_code() { + return company_code; + } + + public void setCompany_code(String company_code) { + this.company_code = company_code; + } + + public String getSeller_tax_no() { + return seller_tax_no; + } + + public void setSeller_tax_no(String seller_tax_no) { + this.seller_tax_no = seller_tax_no; + } + + public String getTemplate_id() { + return template_id; + } + + public void setTemplate_id(String template_id) { + this.template_id = template_id; + } + + public String getBusiness_no() { + return business_no; + } + + public void setBusiness_no(String business_no) { + this.business_no = business_no; + } + + public String getSuperior_business_no() { + return superior_business_no; + } + + public void setSuperior_business_no(String superior_business_no) { + this.superior_business_no = superior_business_no; + } + + public String getBuyer_name() { + return buyer_name; + } + + public void setBuyer_name(String buyer_name) { + this.buyer_name = buyer_name; + } + + public String getBuyer_tax_no() { + return buyer_tax_no; + } + + public void setBuyer_tax_no(String buyer_tax_no) { + this.buyer_tax_no = buyer_tax_no; + } + + public String getBuyer_addr_phone() { + return buyer_addr_phone; + } + + public void setBuyer_addr_phone(String buyer_addr_phone) { + this.buyer_addr_phone = buyer_addr_phone; + } + + public String getBuyer_bank_account() { + return buyer_bank_account; + } + + public void setBuyer_bank_account(String buyer_bank_account) { + this.buyer_bank_account = buyer_bank_account; + } + + public String getApply_person() { + return apply_person; + } + + public void setApply_person(String apply_person) { + this.apply_person = apply_person; + } + + public String getApply_email_notice() { + return apply_email_notice; + } + + public void setApply_email_notice(String apply_email_notice) { + this.apply_email_notice = apply_email_notice; + } + + public String getBuyer_email_notice() { + return buyer_email_notice; + } + + public void setBuyer_email_notice(String buyer_email_notice) { + this.buyer_email_notice = buyer_email_notice; + } + + public String getWorkcode() { + return workcode; + } + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } + + public String getOther_email() { + return other_email; + } + + public void setOther_email(String other_email) { + this.other_email = other_email; + } + + public String getBuyer_contact() { + return buyer_contact; + } + + public void setBuyer_contact(String buyer_contact) { + this.buyer_contact = buyer_contact; + } + + public String getBuyer_mobile() { + return buyer_mobile; + } + + public void setBuyer_mobile(String buyer_mobile) { + this.buyer_mobile = buyer_mobile; + } + + public String getBuyer_recv_address() { + return buyer_recv_address; + } + + public void setBuyer_recv_address(String buyer_recv_address) { + this.buyer_recv_address = buyer_recv_address; + } + + public String getApplication_remark() { + return application_remark; + } + + public void setApplication_remark(String application_remark) { + this.application_remark = application_remark; + } + + public String getAttachments() { + return attachments; + } + + public void setAttachments(String attachments) { + this.attachments = attachments; + } + + public String getNotify_url() { + return notify_url; + } + + public void setNotify_url(String notify_url) { + this.notify_url = notify_url; + } + + public String getSpecial_invoice_mark() { + return special_invoice_mark; + } + + public void setSpecial_invoice_mark(String special_invoice_mark) { + this.special_invoice_mark = special_invoice_mark; + } + + public String getSeller_name() { + return seller_name; + } + + public void setSeller_name(String seller_name) { + this.seller_name = seller_name; + } + + public String getSeller_addr_phone() { + return seller_addr_phone; + } + + public void setSeller_addr_phone(String seller_addr_phone) { + this.seller_addr_phone = seller_addr_phone; + } + + public String getSeller_bank_account() { + return seller_bank_account; + } + + public void setSeller_bank_account(String seller_bank_account) { + this.seller_bank_account = seller_bank_account; + } + + public String getExtend_fields() { + return extend_fields; + } + + public void setExtend_fields(String extend_fields) { + this.extend_fields = extend_fields; + } + + public String getInvoice_type() { + return invoice_type; + } + + public void setInvoice_type(String invoice_type) { + this.invoice_type = invoice_type; + } + + public String getIs_person() { + return is_person; + } + + public void setIs_person(String is_person) { + this.is_person = is_person; + } + + public String getLevy_tax_type() { + return levy_tax_type; + } + + public void setLevy_tax_type(String levy_tax_type) { + this.levy_tax_type = levy_tax_type; + } + + public String getDeduction() { + return deduction; + } + + public void setDeduction(String deduction) { + this.deduction = deduction; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getPlace() { + return place; + } + + public void setPlace(String place) { + this.place = place; + } + + public String getPlace_of_detail() { + return place_of_detail; + } + + public void setPlace_of_detail(String place_of_detail) { + this.place_of_detail = place_of_detail; + } + + public String getConstruction_project_name() { + return construction_project_name; + } + + public void setConstruction_project_name(String construction_project_name) { + this.construction_project_name = construction_project_name; + } + + public String getKqysssxbgglbm() { + return kqysssxbgglbm; + } + + public void setKqysssxbgglbm(String kqysssxbgglbm) { + this.kqysssxbgglbm = kqysssxbgglbm; + } + + public String getProduct_no() { + return product_no; + } + + public void setProduct_no(String product_no) { + this.product_no = product_no; + } + + public String getCross_distinct_city_flag() { + return cross_distinct_city_flag; + } + + public void setCross_distinct_city_flag(String cross_distinct_city_flag) { + this.cross_distinct_city_flag = cross_distinct_city_flag; + } + + public String getCertificate_of_title() { + return certificate_of_title; + } + + public void setCertificate_of_title(String certificate_of_title) { + this.certificate_of_title = certificate_of_title; + } + + public String getArea_unit() { + return area_unit; + } + + public void setArea_unit(String area_unit) { + this.area_unit = area_unit; + } + + public String getStart_date() { + return start_date; + } + + public void setStart_date(String start_date) { + this.start_date = start_date; + } + + public String getEnd_date() { + return end_date; + } + + public void setEnd_date(String end_date) { + this.end_date = end_date; + } + + public String getOriginal_seller_name() { + return original_seller_name; + } + + public void setOriginal_seller_name(String original_seller_name) { + this.original_seller_name = original_seller_name; + } + + public String getOriginal_seller_tax_no() { + return original_seller_tax_no; + } + + public void setOriginal_seller_tax_no(String original_seller_tax_no) { + this.original_seller_tax_no = original_seller_tax_no; + } + + public String getApplicant() { + return applicant; + } + + public void setApplicant(String applicant) { + this.applicant = applicant; + } + + public String getDeduction_status() { + return deduction_status; + } + + public void setDeduction_status(String deduction_status) { + this.deduction_status = deduction_status; + } + + public String getOriginal_invoice_code() { + return original_invoice_code; + } + + public void setOriginal_invoice_code(String original_invoice_code) { + this.original_invoice_code = original_invoice_code; + } + + public String getOriginal_invoice_number() { + return original_invoice_number; + } + + public void setOriginal_invoice_number(String original_invoice_number) { + this.original_invoice_number = original_invoice_number; + } + + public String getOriginal_invoice_date() { + return original_invoice_date; + } + + public void setOriginal_invoice_date(String original_invoice_date) { + this.original_invoice_date = original_invoice_date; + } + + public String getOriginal_invoice_price() { + return original_invoice_price; + } + + public void setOriginal_invoice_price(String original_invoice_price) { + this.original_invoice_price = original_invoice_price; + } + + public String getRed_flush_reason() { + return red_flush_reason; + } + + public void setRed_flush_reason(String red_flush_reason) { + this.red_flush_reason = red_flush_reason; + } + + public String getOriginal_superior_business_no() { + return original_superior_business_no; + } + + public void setOriginal_superior_business_no(String original_superior_business_no) { + this.original_superior_business_no = original_superior_business_no; + } + + public String getRed_letter_info_sheet_no() { + return red_letter_info_sheet_no; + } + + public void setRed_letter_info_sheet_no(String red_letter_info_sheet_no) { + this.red_letter_info_sheet_no = red_letter_info_sheet_no; + } + + public String getOriginal_invoice_check_ode() { + return original_invoice_check_ode; + } + + public void setOriginal_invoice_check_ode(String original_invoice_check_ode) { + this.original_invoice_check_ode = original_invoice_check_ode; + } +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml new file mode 100644 index 00000000..89fbf6c3 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + + + + + + + + + + + diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java new file mode 100644 index 00000000..45f34f2c --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/IInvoiceService.java @@ -0,0 +1,29 @@ +package com.hzya.frame.seeyon.invoice.service; + +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.service.IBaseService; +import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; +import com.hzya.frame.web.entity.JsonResultEntity; + +public interface IInvoiceService extends IBaseService { + + /** + * + * @content 查询需要推送税务的数据 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-01 15:25 + * **/ + JsonResultEntity queryArchives(JSONObject jsonObject); + + /** + * + * @content 根据申请单查询开票结果 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-02 14:10 + * **/ + JsonResultEntity queryInvoiceResult(JSONObject json); +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java new file mode 100644 index 00000000..f27b78c5 --- /dev/null +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/invoice/service/impl/InvoiceServiceImpl.java @@ -0,0 +1,246 @@ +package com.hzya.frame.seeyon.invoice.service.impl; + +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.basedao.service.impl.BaseService; +import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl; +import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao; +import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao; +import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; +import com.hzya.frame.seeyon.invoice.service.IInvoiceService; +import com.hzya.frame.seeyon.util.YzfSignUtil; +import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity; +import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service(value = "InvoiceServiceImpl") +public class InvoiceServiceImpl extends BaseService implements IInvoiceService { + @Autowired + private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; + + @Autowired + private IInvoiceDao invoiceDao; + @Autowired + private IInvoiceDetailsDao invoiceDetailsDao; + + @Autowired + private IIntegrationTaskLivingDetailsService taskLivingDetailsService; + @Autowired + private ComparisonServiceImpl comparisonServiceimpl; + + @Value("${zt.url}") + private String url; + + @Override + public JsonResultEntity queryArchives(JSONObject json) { + JSONObject jsonObject = json.getJSONObject("jsonStr"); + //根据插件分类查询主数据来源表 + List list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType(); + if (CollectionUtils.isEmpty(list)) { + logger.info("没有类型为插件得数据,无法获取数据"); + return BaseResult.getFailureMessageEntity("数据来源表无插件类型"); + } + 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();//主数据编码 + switch (appTyp){ + case "1": + switch (mdmCode){ + case "10049"://杭泰开票申请单 + tableName = "mdm_invoice_application"; + listAll = bindingInvoice(jsonObject, mdmModuleSourceEntity, dbCode); + break; + default: + break; + } + break; + default: + break; + } + //将查询出来的数据进行组装,调用通用方法新增或者更新 + if (null != listAll && listAll.size() > 0) { + object = ParametricDocument(listAll, mdmCode, tableName); + } else { + logger.info("三维单据视图数据没有需要同步中台的数据"); + } + }catch (Exception e){ + logger.info("杭泰付款单同步失败:{}",e.getMessage()); + saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_invoice_application")).getString("data_id"),JSONObject.parseObject(listAll.get(0).getString("mdm_invoice_application")).getString("business_no"),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,"MakeInvoicePluginInitializer"); + e.printStackTrace(); + } + } + return BaseResult.getSuccessMessageEntity("开票申请单同步成功"); + } + + @Override + public JsonResultEntity queryInvoiceResult(JSONObject json) { + try { + InvoiceEntity invoiceEntity = json.toJavaObject(InvoiceEntity.class); + invoiceEntity.setDataSourceCode("HT-OA"); + logger.info("=======开始查询杭泰税务的开票申请单返回结果========="); + List invoiceEntities = invoiceDao.queryInvoiceResult(invoiceEntity); + if(CollectionUtils.isEmpty(invoiceEntities)){ + logger.info("=====杭泰税务中没有需要查询申请单详情得数据========"); + return BaseResult.getSuccessMessageEntity("查询成功"); + } + for (InvoiceEntity entity : invoiceEntities) { + long timestamp = System.currentTimeMillis(); + Map parametersMap = new HashMap<>(); + parametersMap.put("accessKey","6X3B526P5HqE6ums"); + parametersMap.put("timestamp",timestamp); + String sign = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a"); + JSONObject jsonObject=new JSONObject(); + jsonObject.put("serialNumber",entity.getBusiness_no()); + jsonObject.put("accessKey","6X3B526P5HqE6ums"); + jsonObject.put("sign",sign); + jsonObject.put("timestamp",timestamp); + logger.info("=======调用杭泰税务查询申请单详情的请求参数为:{}=======",jsonObject.toJSONString()); + //发送数据 + String result = HttpRequest.post(url). + header("appId", "800060"). + header("apiCode", "8000600003"). + header("publicKey", "ZJYAmRjjYEDgqw4UXWHZNicYclErG0hsrwKQcHukPlP0K1pCe7eDIk+3zDUT+v578prj"). + header("secretKey", "D6AHU3PL8UsNfK6A8I6mL4X1ma2NXckX/vM7AOzI/jmzJf+R1aY06Q6SBz7Y7drHj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). + body(jsonObject.toJSONString()). + execute(). + body(); + logger.info("=====调用杭泰税务查询申请单详情的返回参数为:{}===========",result); + + } + }catch (Exception e){ + logger.info("======查询杭泰税务申请单详情失败====",e.getMessage()); + e.printStackTrace(); + } + return null; + } + + private List bindingInvoice(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { + List list = new ArrayList<>(); + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("select * from v_hzya_invoice where push_status is null "); + mdmModuleSourceEntity.setDataSourceCode(dbCode); + List> hashMaps = invoiceDao.queryInvoice(stringBuffer.toString(), mdmModuleSourceEntity); + int i = 0; + if (CollectionUtils.isNotEmpty(hashMaps)) { + for (HashMap hashMap : hashMaps) { + JSONObject main = new JSONObject(); + JSONObject invoice = new JSONObject(); + for (String key : hashMap.keySet()) { + invoice.put(key.toLowerCase(), hashMap.get(key)); + } + //获取明细信息 + Long formmainId = (Long) hashMap.get("data_id"); + StringBuffer stringBufferDetails = new StringBuffer(); + stringBufferDetails.append("SELECT * FROM v_hzya_invoice_details WHERE f_id = '"+formmainId+"' " ); + List> hashMapsDetails = invoiceDetailsDao.queryInvoiceDetails(stringBufferDetails.toString(),mdmModuleSourceEntity); + JSONArray invoiceDetails = new JSONArray(); + if(CollectionUtils.isNotEmpty(hashMapsDetails)){ + for (HashMap detailsMap : hashMapsDetails) { + JSONObject details = new JSONObject(); + for (String key : detailsMap.keySet()) { + details.put(key.toLowerCase(), detailsMap.get(key)); + } + invoiceDetails.add(details); + } + } + main.put("mdm_invoice_application_details", invoiceDetails); + main.put("mdm_invoice_application", invoice); + list.add(main); + } + } + return list; + } + + 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 jsonStr = new JSONObject(); + jsonObjectUser.put("data_id", main.get("data_id")); + jsonObjectUser.put("mdmCode", mdmCode); + jsonStr.put("jsonStr", jsonObjectUser); + //先查询编码和名称查询是否存在 + Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr); + logger.info("得到的attribute值为:{}", jsonStr.toJSONString(attribute)); + JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute); + JSONObject pageInfo = jsonObjectAttribute.getJSONObject("pageInfo"); + JSONArray jsonArrayList = pageInfo.getJSONArray("list"); + //如果jsonArrayList为null,说明没有值,在表中不存在 + if (jsonArrayList == null || jsonArrayList.size() == 0) { + hashMap.put("appName","数智中台"); + hashMap.put("appCode","800004"); + hashMap.put("mdmCode", mdmCode); + hashMap.put("optionName", "数智中台"); + jsonStr.put("jsonStr", hashMap); + Object object = comparisonServiceimpl.saveEntity(jsonStr); + logger.info("应付单新增结果为:{}", JSON.toJSONString(object)); + result.add(object); + } else { + hashMap.put("appName","数智中台"); + hashMap.put("appCode","800004"); + hashMap.put("mdmCode", mdmCode); + hashMap.put("optionName", "数智中台"); + jsonStr.put("jsonStr", hashMap); + Object object = comparisonServiceimpl.updateEntity(jsonStr); + logger.info("应付单更新结果为:{}", JSON.toJSONString(result)); + result.add(object); + } + } + return result; + }catch (Exception e){ + logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage()); + //保存业务数据日志 + saveTaskLivingDetails(jsonObjectUser.getString("data_id"),hashMaps.get(0).getString("business_no"),hashMaps.get(0).toString(),result.toString(),false,"MakeInvoicePluginInitializer"); + e.printStackTrace(); + } + return null; + } + + private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag,String plugin) { + 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(plugin); + integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo); + if(flag){ + taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity); + }else { + taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity); + } + }catch (Exception e){ + logger.info("抽取杭泰付款单保存日志到集成任务日志明细中失败:{}",e.getMessage()); + e.printStackTrace(); + } + } + +} diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/IZxBankDao.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/IZxBankDao.java index ed0e0cec..ceb11fe5 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/IZxBankDao.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/IZxBankDao.java @@ -28,7 +28,7 @@ public interface IZxBankDao extends IBaseDao { * @Author hecan * @Date 2024-12-05 17:58 * **/ - Integer updatePushStatus(ZxBankEntity entity); + Integer updatePushStatusZX(ZxBankEntity entity); /** * @@ -38,7 +38,7 @@ public interface IZxBankDao extends IBaseDao { * @Author hecan * @Date 2025-03-18 17:44 * **/ - List queryResultIsNull(ZxBankEntity zxBankEntity); + List queryResultIsNullZX(ZxBankEntity zxBankEntity); /** * @@ -58,5 +58,15 @@ public interface IZxBankDao extends IBaseDao { * @Author hecan * @Date 2025-03-19 14:15 * **/ - List queryElecIsNull(ZxBankEntity entity); + List queryElecIsNullZX(ZxBankEntity entity); + + /** + * + * @content 更新电子回单 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-07 17:06 + * **/ + Integer updateElecStatusZX(ZxBankEntity entity); } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/impl/ZxBankDaoImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/impl/ZxBankDaoImpl.java index 192305c1..bb092c8c 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/impl/ZxBankDaoImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/dao/impl/ZxBankDaoImpl.java @@ -36,14 +36,14 @@ public class ZxBankDaoImpl extends MybatisGenericDao implem @DS("#entity.dataSourceCode") @Override - public Integer updatePushStatus(ZxBankEntity entity) { - return super.update("updatePushStatus",entity); + public Integer updatePushStatusZX(ZxBankEntity entity) { + return super.update("updatePushStatusZX",entity); } @DS("#entity.dataSourceCode") @Override - public List queryResultIsNull(ZxBankEntity entity) { - return super.queryList(entity,"queryResultIsNull"); + public List queryResultIsNullZX(ZxBankEntity entity) { + return super.queryList(entity,"queryResultIsNullZX"); } @DS("#entity.dataSourceCode") @@ -54,7 +54,13 @@ public class ZxBankDaoImpl extends MybatisGenericDao implem @DS("#entity.dataSourceCode") @Override - public List queryElecIsNull(ZxBankEntity entity) { - return super.queryList(entity,"queryElecIsNull"); + public List queryElecIsNullZX(ZxBankEntity entity) { + return super.queryList(entity,"queryElecIsNullZX"); + } + + @DS("#entity.dataSourceCode") + @Override + public Integer updateElecStatusZX(ZxBankEntity entity) { + return super.update("updateElecStatusZX",entity); } } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.java index 160af0b7..e648cac2 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.java @@ -30,7 +30,15 @@ public class ZxBankEntity extends BaseEntity { private String payResult;//支付结果 private String receipt;//电子回单 private String pushStatus;//推送标识 + private String summaryId;// + public String getSummaryId() { + return summaryId; + } + + public void setSummaryId(String summaryId) { + this.summaryId = summaryId; + } public String getTabName() { return tabName; diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml index 4087d5c5..b8c383c8 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/zxbank/entity/ZxBankEntity.xml @@ -29,6 +29,7 @@ + @@ -60,6 +61,7 @@ ,pay_result as payResult ,receipt as receipt ,push_status as pushStatus + ,summary_id as summaryId @@ -71,20 +73,20 @@ from v_hzya_pay where push_status is null - select from v_hzya_pay where push_status is not null and pay_result is null - select from v_hzya_pay where pay_result='已支付' and receipt is null - + update ${tabName} set ${pushStatusField} =#{pushStatus} where id=#{id} @@ -93,6 +95,11 @@ update ${tabName} set ${payResultField} =#{payResult} where id=#{id} + + + update ${tabName} set ${receiptFiled} =#{receipt} where id=#{id} + + 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 9cb5bcc7..6be14686 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 @@ -2,17 +2,26 @@ package com.hzya.frame.seeyon.zxbank.service.impl; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import cn.hutool.log.Log; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.basedao.service.impl.BaseService; import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl; import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; +import com.hzya.frame.seeyon.dao.ICtpAttachmentDao; +import com.hzya.frame.seeyon.entity.CtpAttachmentEntity; +import com.hzya.frame.seeyon.util.OARestUtil; import com.hzya.frame.seeyon.util.SM2Util; import com.hzya.frame.seeyon.zxbank.dao.IZxBankDao; import com.hzya.frame.seeyon.zxbank.entity.PayState; import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity; import com.hzya.frame.seeyon.zxbank.service.IZxBankService; +import com.hzya.frame.sysnew.application.database.dao.ISysApplicationDatabaseDao; +import com.hzya.frame.sysnew.application.database.entity.SysApplicationDatabaseEntity; +import com.hzya.frame.sysnew.application.entity.SysApplicationEntity; +import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity; import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl; import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; @@ -20,15 +29,21 @@ 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 com.hzya.frame.web.exception.BaseSystemException; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; @Service("ZxBankServiceImpl") public class ZxBankServiceImpl extends BaseService implements IZxBankService { @@ -36,12 +51,17 @@ public class ZxBankServiceImpl extends BaseService impleme @Autowired private MdmModuleSourceDaoImpl mdmModuleSourceDaoImpl; - @Autowired - private IZxBankDao zxBankDao; + @Autowired + private IZxBankDao zxBankDao; @Autowired private IIntegrationTaskLivingDetailsService taskLivingDetailsService; @Autowired private ComparisonServiceImpl comparisonServiceimpl; + @Autowired + private ICtpAttachmentDao ctpAttachmentDao; + + @Autowired + private ISysApplicationDatabaseDao sysApplicationDatabaseDao; @Value("${zt.url}") private String url; @@ -108,7 +128,7 @@ public class ZxBankServiceImpl extends BaseService impleme zxBankEntity.setPushStatus("1"); zxBankEntity.setId(dataId); zxBankEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode()); - zxBankDao.updatePushStatus(zxBankEntity); + zxBankDao.updatePushStatusZX(zxBankEntity); //保存业务数据日志 saveTaskLivingDetails(dataId, jsonObjectCmpApply.getString("document_no"), listAll.get(0).toString(), object.toString(), true,"ZxBankPluginInitializer"); } @@ -134,11 +154,10 @@ public class ZxBankServiceImpl extends BaseService impleme @Override public JsonResultEntity queryArchivesResult(JSONObject json) { try { - JSONObject jsonObject = json.getJSONObject("jsonStr"); - ZxBankEntity zxBankEntity = jsonObject.toJavaObject(ZxBankEntity.class); + ZxBankEntity zxBankEntity = json.toJavaObject(ZxBankEntity.class); zxBankEntity.setDataSourceCode("HT-OA"); logger.info("======开始查询中信返回的支付结果====="); - List zxBankEntities = zxBankDao.queryResultIsNull(zxBankEntity); + List zxBankEntities = zxBankDao.queryResultIsNullZX(zxBankEntity); if(CollectionUtils.isEmpty(zxBankEntities)){ logger.info("=====杭泰付款单中没有已推送并且支付结果为空的数据========"); return BaseResult.getSuccessMessageEntity("查询成功"); @@ -146,8 +165,15 @@ public class ZxBankServiceImpl extends BaseService impleme for (ZxBankEntity bankEntity : zxBankEntities) { List list = new ArrayList<>(); list.add(bankEntity.getDocumentNo()); - String params = String.join(", ", list); - logger.info("=======杭泰付款单调用中信支付结果查询请求参数为:{}", params); + JSONObject jsonObject=new JSONObject(); + jsonObject.put("documentNoList",list); + JSONObject objectData=new JSONObject(); + objectData.put("data",jsonObject); + logger.info("=======杭泰付款单调用中信支付结果查询请求参数明文为:{}", objectData.toJSONString()); + String encrypt = SM2Util.encrypt(objectData.toJSONString(), publicKey); + JSONObject jsonData=new JSONObject(); + jsonData.put("data",encrypt); + logger.info("=======杭泰付款单调用中信支付结果查询请求参数密文为:{}", jsonData.toJSONString()); //发送数据 String result = HttpRequest.post(url). header("appId", "800058"). @@ -155,16 +181,19 @@ public class ZxBankServiceImpl extends BaseService impleme //header("access_token", tokenBody). header("publicKey", "ZJYALA1PchEI1s2D5vaapO9RZ6CiDFv/pJAV88lRYg0oBwBCe7eDIk+3zDUT+v578prj"). header("secretKey", "jcoATYyty05KgDwL4O0xD+Ulq5ExYWkGvZGf2bhKrMaCehb3NIm5DUnJSK/r2SUaj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). - body(params). + body(jsonData.toJSONString()). execute(). body(); logger.info("========杭泰付款单调用中信支付结果查询返回参数为:{}==========", result); JSONObject resultJson = JSONObject.parseObject(result); if (!resultJson.getBoolean("flag")) { - saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), false,"ZxBankResultPluginInitializer"); + saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), jsonData.toJSONString(), resultJson.toJSONString(), false,"ZxBankResultPluginInitializer"); } else { - String data = resultJson.getString("data"); - JSONObject jsonObjectData = JSONObject.parseObject(data); + JSONObject attribute = resultJson.getJSONObject("attribute"); + String data = attribute.getString("data"); + logger.info("=======杭泰付款单调用中信支付结果查询返回参数密文为:{}", data); + String decrypt = SM2Util.decrypt(data, privateKey); + JSONObject jsonObjectData = JSONObject.parseObject(decrypt); JSONArray jsonArray = jsonObjectData.getJSONArray("list"); if(CollectionUtils.isNotEmpty(jsonArray)){ for (Object o : jsonArray) { @@ -176,8 +205,10 @@ public class ZxBankServiceImpl extends BaseService impleme if(documentNo.equals(bankEntity.getDocumentNo())){ //修改支付状态 bankEntity.setPayResult(PayState.payStateGetValue(payStatus)); + bankEntity.setDataSourceCode("HT-OA"); + bankEntity.setId(bankEntity.getDataId()); zxBankDao.updateResultStatus(bankEntity); - saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), true,"ZxBankResultPluginInitializer"); + saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), jsonData.toJSONString(), resultJson.toJSONString(), true,"ZxBankResultPluginInitializer"); } } }else{ @@ -194,14 +225,15 @@ public class ZxBankServiceImpl extends BaseService impleme return BaseResult.getFailureMessageEntity("支付结果查询失败"); } + + @Override public JsonResultEntity queryArchivesElec(JSONObject json) { try { - JSONObject jsonObject = json.getJSONObject("jsonStr"); - ZxBankEntity zxBankEntity = jsonObject.toJavaObject(ZxBankEntity.class); + ZxBankEntity zxBankEntity = json.toJavaObject(ZxBankEntity.class); zxBankEntity.setDataSourceCode("HT-OA"); logger.info("======开始查询中信电子回单====="); - List zxBankEntities = zxBankDao.queryElecIsNull(zxBankEntity); + List zxBankEntities = zxBankDao.queryElecIsNullZX(zxBankEntity); if(CollectionUtils.isEmpty(zxBankEntities)){ logger.info("=====杭泰付款单中没有已支付并且电子回单为空的数据========"); return BaseResult.getSuccessMessageEntity("查询成功"); @@ -210,8 +242,14 @@ public class ZxBankServiceImpl extends BaseService impleme JSONObject jsonParam=new JSONObject(); jsonParam.put("companyCode",bankEntity.getCompanyCode());//公司编码 jsonParam.put("documentNo",bankEntity.getDocumentNo());//单据号 - String params = jsonParam.toJSONString(); - logger.info("======杭泰付款单调用中信电子回单查询请求参数为:{}========",params); + JSONObject jsonData=new JSONObject(); + jsonData.put("data",jsonParam); + String params = jsonData.toJSONString(); + logger.info("======杭泰付款单调用中信电子回单查询请求参数明文为:{}========",params); + String encrypt = SM2Util.encrypt(params, publicKey); + JSONObject objectData=new JSONObject(); + objectData.put("data",encrypt); + logger.info("======杭泰付款单调用中信电子回单查询请求参数密文为:{}========",objectData.toJSONString()); //发送数据 String result = HttpRequest.post(url). header("appId", "800058"). @@ -219,7 +257,7 @@ public class ZxBankServiceImpl extends BaseService impleme //header("access_token", tokenBody). header("publicKey", "ZJYALA1PchEI1s2D5vaapO9RZ6CiDFv/pJAV88lRYg0oBwBCe7eDIk+3zDUT+v578prj"). header("secretKey", "jcoATYyty05KgDwL4O0xD+Ulq5ExYWkGvZGf2bhKrMaCehb3NIm5DUnJSK/r2SUaj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). - body(params). + body(objectData.toJSONString()). execute(). body(); logger.info("======杭泰付款单调用中信电子回单查询返回参数为:{}========",result); @@ -227,16 +265,22 @@ public class ZxBankServiceImpl extends BaseService impleme if (!resultJson.getBoolean("flag")) { saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), false,"ZxBankElecPluginInitializer"); } else { - String data = resultJson.getString("data"); - JSONObject jsonObjectData = JSONObject.parseObject(data); + JSONObject attribute = resultJson.getJSONObject("attribute"); + String data = attribute.getString("data"); + logger.info("=======杭泰付款单调用中信支付结果查询返回参数密文为:{}", data); + String decrypt = SM2Util.decrypt(data, privateKey); + JSONObject jsonObjectData = JSONObject.parseObject(decrypt); String billId = jsonObjectData.getString("billId"); //电子回单id 电子回单下载需要 logger.info("======中信电子回单返回的电子回单id为:{}====",billId); if(StrUtil.isNotEmpty(billId)){ List list=new ArrayList<>(); list.add(billId); - String paramList = String.join(", ", list); - logger.info("====调用中信电子回单下载得请求参数为:{}=======",paramList); - elecDownlod(paramList); + JSONObject billIds=new JSONObject(); + billIds.put("billIds",list); + JSONObject elecdata=new JSONObject(); + elecdata.put("data",billIds); + logger.info("====调用中信电子回单下载得请求参数明文为:{}=======",elecdata.toJSONString()); + elecDownlod(elecdata.toJSONString(),bankEntity); } } } @@ -247,19 +291,121 @@ public class ZxBankServiceImpl extends BaseService impleme return null; } - private JsonResultEntity elecDownlod(String params){ + private JsonResultEntity elecDownlod(String params,ZxBankEntity zxBankEntity){ try { - //发送数据 - String result = HttpRequest.post(url). - header("appId", ""). - header("apiCode", ""). - //header("access_token", tokenBody). - header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj"). - header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). - body(params). - execute(). - body(); - logger.info("======杭泰付款单调用中信电子回单下载返回参数为:{}========",result); + String encrypt = SM2Util.encrypt(params, publicKey); + JSONObject objectData=new JSONObject(); + objectData.put("data",encrypt); + logger.info("====调用中信电子回单下载得请求参数密文为:{}=======",objectData.toJSONString()); + //因为电子回单下载返回的只有文件流,所以无法在中台上注册接口,只能代码中调用第三方接口 + //将文件流的zip下载到文件夹中,之后解压该文件夹,得到pdf文件,上传OA + String downloadFolder ="D:\\yongansystem\\pdf\\"; + String destinationFolder ="D:\\yongansystem\\pdf\\"; + + URL url = new URL("http://202.108.57.65:11370/access/treasury/hangtai/bill/down"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setDoOutput(true); + + // 写入 JSON 请求体 + try (OutputStream os = connection.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8")) { + osw.write(objectData.toJSONString()); + osw.flush(); + } + + // 获取响应状态码 + int responseCode = connection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + // 获取响应头中的 Content-Disposition + String contentDisposition = connection.getHeaderField("Content-Disposition"); + String fileName = parseFileName(contentDisposition); + // 拼接指定文件夹和文件名 + File outputFile = new File(downloadFolder, fileName); + // 确保文件夹存在 + File parentDir = outputFile.getParentFile(); + if (!parentDir.exists()) { + if (!parentDir.mkdirs()) { + logger.info("无法创建目录: {}" , parentDir); + return null; + } + } + + // 获取响应的输入流 + try (InputStream inputStream = connection.getInputStream(); + FileOutputStream outputStream = new FileOutputStream(outputFile)) { + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + logger.info("文件下载成功,保存路径: {}" ,outputFile.getAbsolutePath()); + //开始解压得到的zip文件 + File sourceFolder = new File(outputFile.getAbsolutePath()); + if (!sourceFolder.exists()) { + logger.info("源文件夹不存在或不是一个有效的文件夹"); + return null; + } + + if (sourceFolder.isFile() && sourceFolder.getName().endsWith(".zip")) { + unzipFile(sourceFolder.getAbsolutePath(), destinationFolder); + + //将pdf文件上传OA + File fileOut = new File(sourceFolder.getAbsolutePath()); + if (fileOut.exists()) { + logger.info("=====开始上传中信司库回单到杭泰OA======"); + JSONObject jsonObject = fileUpload(fileOut); + if (jsonObject.getString("fileUrl") != null) { + //表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference + String sub_reference = String.valueOf(UUIDLong.longUUID()); + zxBankEntity.setReceipt(sub_reference); + zxBankEntity.setDataSourceCode("HT-OA"); + zxBankDao.updateElecStatusZX(zxBankEntity); + //根据附件id查询附件业务数据 + String file_url = jsonObject.getString("fileUrl"); + CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); + ctpAttachmentEntity.setFile_url(file_url); + String att_reference = zxBankEntity.getSummaryId();//Summary_id + ctpAttachmentEntity.setSub_reference(sub_reference); + ctpAttachmentEntity.setAtt_reference(att_reference); + ctpAttachmentEntity.setDataSourceCode("HT-OA"); + List ctpAttachmentEntities = ctpAttachmentDao.queryCtpAttachment(ctpAttachmentEntity); + //如果没有查询到数据,就新增附件业务,否则更新 + if (ctpAttachmentEntities.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("66"); + ctpAttachmentEntity.setCreatedate(new Date()); + ctpAttachmentEntity.setDataSourceCode("HT-OA"); + ctpAttachmentDao.saveCtpAttachment(ctpAttachmentEntity); + } else { + if (ctpAttachmentEntities.size() > 1) { + throw new BaseSystemException("OA附件业务表中查到多条记录"); + } + //更新数据到OA附件业务表中 + ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity); + } + logger.info("=====电子回单执行完毕======="); + } + fileOut.delete(); + } + } + } + } else { + logger.info("请求失败,响应状态码:{} " , responseCode); + } + connection.disconnect(); }catch (Exception e){ logger.info("=======中信电子回单下载失败:{}======",e.getMessage()); e.printStackTrace(); @@ -267,26 +413,108 @@ public class ZxBankServiceImpl extends BaseService impleme return null; } + public JSONObject fileUpload(File file) { + if (null != file) { + try { + HashMap paramMap = new HashMap<>(); + paramMap.put("file", file); + String url = "/seeyon/rest/attachment?token=@token@";//如果后面加上applicationCategory=1&extensions=&firstSave=true,附件业务自动生成一条记录 + url = url.replaceAll("@token@", getToken()); + String result = HttpUtil.post("http://60.204.152.210" + url, paramMap); + if (StrUtil.isNotBlank(result)) { + logger.info("附件上传结果"+result); + JSONObject jsonObject = JSONObject.parseObject(result); + String atts = jsonObject.get("atts").toString(); + if (StrUtil.isNotEmpty(atts)) { + JSONArray jsonArray = JSONArray.parseArray(atts); + JSONObject res = (JSONObject) jsonArray.get(0); + String fileUrl = res.getString("fileUrl"); + logger.info("附件id:" + fileUrl); + return res; + } + } + }catch (Exception e){ + logger.error("附件上传失败"+e.getMessage()); + } + } + return null; + } + + private String getToken() { + //获取oatoken + HashMap hashMap = new HashMap<>(); + hashMap.put("userName", "hzyaRest"); + hashMap.put("password", "a5ce21b8-91db-4cec-b3e3-3e44719655fd"); + hashMap.put("loginName","bdmanager"); + String result = HttpUtil.post("http://60.204.152.210" + "/seeyon/rest/token", JSON.toJSONString(hashMap)); + JSONObject jsonObject = JSONObject.parseObject(result); + if (null != jsonObject) { + logger.info(result); + logger.info("======token:{}======" + jsonObject.getString("id")); + return jsonObject.getString("id"); + } + return null; + } + + private static String parseFileName(String contentDisposition) { + if (contentDisposition == null) { + return "unknown.zip"; + } + // 匹配 filename*=utf-8'' 后面的文件名 + Pattern pattern = Pattern.compile("filename\\*=utf-8''([^;]+)"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + return matcher.group(1); + } + return "unknown.zip"; + } + + private void unzipFile(String zipFilePath, String destinationFolderPath) { + try (FileInputStream fis = new FileInputStream(zipFilePath); + ZipInputStream zis = new ZipInputStream(fis)) { + + ZipEntry zipEntry = zis.getNextEntry(); + while (zipEntry != null) { + if (zipEntry.getName().endsWith(".pdf")) { + String pdfFilePath = destinationFolderPath + zipEntry.getName();//File.separator:文件路径中增加一个斜杠 + try (FileOutputStream fos = new FileOutputStream(pdfFilePath)) { + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = zis.read(buffer)) != -1) { + fos.write(buffer, 0, bytesRead); + } + } + logger.info("已提取 PDF 文件:{} " ,pdfFilePath); + } + zis.closeEntry(); + zipEntry = zis.getNextEntry(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + private List bindingZxBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { List list = new ArrayList<>(); - StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append("select * from v_hzya_pay where 1=1 and push_status is null "); - mdmModuleSourceEntity.setDataSourceCode(dbCode); - List> hashMaps = zxBankDao.queryListByBank(stringBuffer.toString(), mdmModuleSourceEntity); - int i = 0; - if (CollectionUtils.isNotEmpty(hashMaps)) { - for (HashMap hashMap : hashMaps) { - JSONObject main = new JSONObject(); - JSONObject bank = new JSONObject(); - for (String key : hashMap.keySet()) { - bank.put(key.toLowerCase(), hashMap.get(key)); - } - main.put("mdm_zxbank", bank); - list.add(main); + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("select * from v_hzya_pay where 1=1 and push_status is null "); + mdmModuleSourceEntity.setDataSourceCode(dbCode); + List> hashMaps = zxBankDao.queryListByBank(stringBuffer.toString(), mdmModuleSourceEntity); + int i = 0; + if (CollectionUtils.isNotEmpty(hashMaps)) { + for (HashMap hashMap : hashMaps) { + JSONObject main = new JSONObject(); + JSONObject bank = new JSONObject(); + for (String key : hashMap.keySet()) { + bank.put(key.toLowerCase(), hashMap.get(key)); } + main.put("mdm_zxbank", bank); + list.add(main); } - return list; + } + return list; }