This commit is contained in:
xiang2lin 2025-04-08 13:45:30 +08:00
commit 5edaa85c41
18 changed files with 1637 additions and 71 deletions

View File

@ -2,10 +2,12 @@ package com.hzya.frame.plugin.ht.plugin;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity; 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.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity; import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* @Description * @Description
@ -13,6 +15,9 @@ import org.slf4j.LoggerFactory;
* @Date 2024/8/22 16:39 * @Date 2024/8/22 16:39
**/ **/
public class MakeInvoicePluginInitializer extends PluginBaseEntity { public class MakeInvoicePluginInitializer extends PluginBaseEntity {
@Autowired
private InvoiceServiceImpl invoiceService;
Logger logger = LoggerFactory.getLogger(getClass()); Logger logger = LoggerFactory.getLogger(getClass());
/*** /***
* 插件初始化方法 * 插件初始化方法
@ -91,7 +96,13 @@ public class MakeInvoicePluginInitializer extends PluginBaseEntity {
**/ **/
@Override @Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
try {
return BaseResult.getSuccessMessageEntity("操作成功"); logger.info("======开始执行杭泰开票申请单同步========");
return invoiceService.queryArchives(requestJson);
}catch (Exception e){
logger.info("======执行杭泰开票申请单同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
} }
} }

View File

@ -12,7 +12,7 @@ spring:
dynamic: dynamic:
datasource: datasource:
master: 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 username: root
password: bd993088e8a7c3dc5f44441617f9b4bf password: bd993088e8a7c3dc5f44441617f9b4bf
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置 driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
@ -39,7 +39,7 @@ cbs8:
OA: OA:
data_source_code: yc_oa data_source_code: yc_oa
zt: zt:
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
zx: zx:
# 测试用这个 这个是银行给的 # 测试用这个 这个是银行给的
privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0 privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0

View File

@ -4,4 +4,5 @@
<bean name="ZxBankPluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankPluginInitializer" /> <bean name="ZxBankPluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankPluginInitializer" />
<bean name="ZxBankResultPluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankResultPluginInitializer" /> <bean name="ZxBankResultPluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankResultPluginInitializer" />
<bean name="ZxBankDistributePluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankDistributePluginInitializer" /> <bean name="ZxBankDistributePluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankDistributePluginInitializer" />
<bean name="ZxBankElecPluginInitializer" class="com.hzya.frame.plugin.zxBank.plugin.ZxBankElecPluginInitializer" />
</beans> </beans>

View File

@ -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<InvoiceEntity,String> {
/**
*
* @content 查询需要推送税务的数据
* @Param
* @Return
* @Author hecan
* @Date 2025-04-01 15:33
* **/
List<HashMap<String, Object>> queryInvoice(String str , MdmModuleSourceEntity entity);
/**
*
* @content 查询申请单详情
* @Param
* @Return
* @Author hecan
* @Date 2025-04-07 14:05
* **/
List<InvoiceEntity> queryInvoiceResult(InvoiceEntity entity);
}

View File

@ -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<InvoiceDetailsEntity,String> {
/**
*
* @content 查询需要推送税务的数据
* @Param
* @Return
* @Author hecan
* @Date 2025-04-01 15:33
* **/
List<HashMap<String, Object>> queryInvoiceDetails(String str , MdmModuleSourceEntity entity);
}

View File

@ -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<InvoiceEntity,String> implements IInvoiceDao {
@Autowired
private IExecSqlService execSqlService;
private Logger logger = LogManager.getLogger(super.getClass());
@DS("#entity.dataSourceCode")
@Override
public List<HashMap<String, Object>> queryInvoice(String str, MdmModuleSourceEntity entity) {
try {
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
return hashMaps;
}catch (Exception e){
logger.info("没有需要推送税务的数据");
return null;
}
}
@DS("#entity.dataSourceCode")
@Override
public List<InvoiceEntity> queryInvoiceResult(InvoiceEntity entity) {
return (List<InvoiceEntity>) super.selectList("queryInvoiceResult",entity);
}
}

View File

@ -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<InvoiceDetailsEntity,String> implements IInvoiceDetailsDao {
@Autowired
private IExecSqlService execSqlService;
private Logger logger = LogManager.getLogger(super.getClass());
@DS("#entity.dataSourceCode")
@Override
public List<HashMap<String, Object>> queryInvoiceDetails(String str, MdmModuleSourceEntity entity) {
try {
List<HashMap<String, Object>> hashMaps = execSqlService.execSelectSql(str, "");
return hashMaps;
}catch (Exception e){
logger.info("没有需要推送税务的明细数据");
return null;
}
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.seeyon.invoice.dao.impl.InvoiceDetailsDaoImpl">
<resultMap id="get-InvoiceDetailsEntity-result" type="com.hzya.frame.seeyon.invoice.entity.InvoiceDetailsEntity">
<result property="item_no" column="item_no" />
<result property="item_name" column="item_name" />
<result property="tax_cate_code" column="tax_cate_code" />
<result property="spec" column="spec" />
<result property="unit" column="unit" />
<result property="quantity" column="quantity" />
<result property="unit_price" column="unit_price" />
<result property="price" column="price" />
<result property="tax_rate" column="tax_rate" />
<result property="zero_flag" column="zero_flag" />
<result property="tax" column="tax" />
<result property="include_tax_tag" column="include_tax_tag" />
<result property="detail_type" column="detail_type" />
<result property="enjoy_preferential_flag" column="enjoy_preferential_flag" />
<result property="preferential_policy_type" column="preferential_policy_type" />
</resultMap>
<sql id="InvoiceDetailsEntity_Base_Column_List">
*
</sql>
<select id="queryZxBank" resultMap="get-InvoiceDetailsEntity-result" parameterType="com.hzya.frame.seeyon.invoice.entity.InvoiceDetailsEntity">
select
*
from v_hzya_invoice_details
</select>
</mapper>

View File

@ -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;
}
}

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.seeyon.invoice.dao.impl.InvoiceDaoImpl">
<resultMap id="get-InvoiceEntity-result" type="com.hzya.frame.seeyon.invoice.entity.InvoiceEntity">
<result property="sfhc" column="sfhc" />
<result property="xf" column="xf" />
<result property="access_key" column="access_key" />
<result property="sign" column="sign" />
<result property="timestamp" column="timestamp" />
<result property="serial_number" column="serial_number" />
<result property="company_code" column="company_code" />
<result property="seller_tax_no" column="seller_tax_no" />
<result property="template_id" column="template_id" />
<result property="business_no" column="business_no" />
<result property="superior_business_no" column="superior_business_no" />
<result property="buyer_name" column="buyer_name" />
<result property="buyer_tax_no" column="buyer_tax_no" />
<result property="buyer_addr_phone" column="buyer_addr_phone" />
<result property="buyer_bank_account" column="buyer_bank_account" />
<result property="apply_person" column="apply_person" />
<result property="apply_email_notice" column="apply_email_notice" />
<result property="buyer_email_notice" column="buyer_email_notice" />
<result property="workcode" column="workcode" />
<result property="other_email" column="other_email" />
<result property="buyer_contact" column="buyer_contact" />
<result property="buyer_mobile" column="buyer_mobile" />
<result property="buyer_recv_address" column="buyer_recv_address" />
<result property="application_remark" column="application_remark" />
<result property="attachments" column="attachments" />
<result property="notify_url" column="notify_url" />
<result property="special_invoice_mark" column="special_invoice_mark" />
<result property="seller_name" column="seller_name" />
<result property="seller_addr_phone" column="seller_addr_phone" />
<result property="seller_bank_account" column="seller_bank_account" />
<result property="extend_fields" column="extend_fields" />
<result property="invoice_type" column="invoice_type" />
<result property="is_person" column="is_person" />
<result property="levy_tax_type" column="levy_tax_type" />
<result property="deduction" column="deduction" />
<result property="remark" column="remark" />
<result property="place" column="place" />
<result property="place_of_detail" column="place_of_detail" />
<result property="construction_project_name" column="construction_project_name" />
<result property="kqysssxbgglbm" column="kqysssxbgglbm" />
<result property="product_no" column="product_no" />
<result property="cross_distinct_city_flag" column="cross_distinct_city_flag" />
<result property="certificate_of_title" column="certificate_of_title" />
<result property="area_unit" column="area_unit" />
<result property="start_date" column="start_date" />
<result property="end_date" column="end_date" />
<result property="original_seller_name" column="original_seller_name" />
<result property="original_seller_tax_no" column="original_seller_tax_no" />
<result property="applicant" column="applicant" />
<result property="deduction_status" column="deduction_status" />
<result property="original_invoice_code" column="original_invoice_code" />
<result property="original_invoice_number" column="original_invoice_number" />
<result property="original_invoice_date" column="original_invoice_date" />
<result property="original_invoice_price" column="original_invoice_price" />
<result property="red_flush_reason" column="red_flush_reason" />
<result property="original_superior_business_no" column="original_superior_business_no" />
<result property="red_letter_info_sheet_no" column="red_letter_info_sheet_no" />
<result property="original_invoice_check_ode" column="original_invoice_check_ode" />
<result property="push_status_filed" column="push_status_filed" />
<result property="invoice_code_field" column="invoice_code_field" />
<result property="invoice_number_field" column="invoice_number_field" />
<result property="url_field" column="url_field" />
<result property="result_status_field" column="result_status_field" />
<result property="push_status" column="push_status" />
<result property="invoice_code" column="invoice_code" />
<result property="invoice_number" column="invoice_number" />
<result property="url" column="url" />
<result property="result_status" column="result_status" />
</resultMap>
<sql id="InvoiceEntity_Base_Column_List">
*
</sql>
<select id="queryInvoiceResult" resultMap="get-InvoiceEntity-result" parameterType="com.hzya.frame.seeyon.invoice.entity.InvoiceEntity">
select
*
from v_hzya_invoice where push_status is not null and url is null and (result_status is null or result_status='申请单处理中')
</select>
</mapper>

View File

@ -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<InvoiceEntity,String> {
/**
*
* @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);
}

View File

@ -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<InvoiceEntity, String> 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<MdmModuleSourceEntity> list = mdmModuleSourceDaoImpl.MdmModuleSourceentityGroupByType();
if (CollectionUtils.isEmpty(list)) {
logger.info("没有类型为插件得数据,无法获取数据");
return BaseResult.getFailureMessageEntity("数据来源表无插件类型");
}
for (MdmModuleSourceEntity mdmModuleSourceEntity : list) {
String tableName = "";
List<Object> object=new ArrayList<>();
List<JSONObject> listAll = new ArrayList<>();
try {
String appTyp = mdmModuleSourceEntity.getAppType();//系统类型 1致远OA 2用友U8C 3用友BIP
String dbCode = mdmModuleSourceEntity.getDbCode();//数据源编码
String mdmCode = mdmModuleSourceEntity.getMdmCode();//主数据编码
switch (appTyp){
case "1":
switch (mdmCode){
case "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<InvoiceEntity> invoiceEntities = invoiceDao.queryInvoiceResult(invoiceEntity);
if(CollectionUtils.isEmpty(invoiceEntities)){
logger.info("=====杭泰税务中没有需要查询申请单详情得数据========");
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (InvoiceEntity entity : invoiceEntities) {
long timestamp = System.currentTimeMillis();
Map<String, Object> 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<JSONObject> bindingInvoice(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
List<JSONObject> list = new ArrayList<>();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("select * from v_hzya_invoice where push_status is null ");
mdmModuleSourceEntity.setDataSourceCode(dbCode);
List<HashMap<String, Object>> hashMaps = invoiceDao.queryInvoice(stringBuffer.toString(), mdmModuleSourceEntity);
int i = 0;
if (CollectionUtils.isNotEmpty(hashMaps)) {
for (HashMap<String, Object> 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<HashMap<String, Object>> hashMapsDetails = invoiceDetailsDao.queryInvoiceDetails(stringBufferDetails.toString(),mdmModuleSourceEntity);
JSONArray invoiceDetails = new JSONArray();
if(CollectionUtils.isNotEmpty(hashMapsDetails)){
for (HashMap<String, Object> detailsMap : hashMapsDetails) {
JSONObject details = new JSONObject();
for (String key : detailsMap.keySet()) {
details.put(key.toLowerCase(), detailsMap.get(key));
}
invoiceDetails.add(details);
}
}
main.put("mdm_invoice_application_details", invoiceDetails);
main.put("mdm_invoice_application", invoice);
list.add(main);
}
}
return list;
}
private List<Object> ParametricDocument(List<JSONObject> hashMaps,String mdmCode,String tableName){
JSONObject jsonObjectUser = new JSONObject();
List<Object> result=new ArrayList<>();
try {
for (JSONObject hashMap : hashMaps) {
JSONObject main = hashMap.getJSONObject(tableName);
JSONObject jsonStr = new JSONObject();
jsonObjectUser.put("data_id", main.get("data_id"));
jsonObjectUser.put("mdmCode", mdmCode);
jsonStr.put("jsonStr", jsonObjectUser);
//先查询编码和名称查询是否存在
Object attribute = comparisonServiceimpl.queryEntityPage(jsonStr);
logger.info("得到的attribute值为{}", jsonStr.toJSONString(attribute));
JSONObject jsonObjectAttribute = (JSONObject) JSON.toJSON(attribute);
JSONObject pageInfo = jsonObjectAttribute.getJSONObject("pageInfo");
JSONArray jsonArrayList = pageInfo.getJSONArray("list");
//如果jsonArrayList为null说明没有值在表中不存在
if (jsonArrayList == null || jsonArrayList.size() == 0) {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
Object object = comparisonServiceimpl.saveEntity(jsonStr);
logger.info("应付单新增结果为:{}", JSON.toJSONString(object));
result.add(object);
} else {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
hashMap.put("optionName", "数智中台");
jsonStr.put("jsonStr", hashMap);
Object object = comparisonServiceimpl.updateEntity(jsonStr);
logger.info("应付单更新结果为:{}", JSON.toJSONString(result));
result.add(object);
}
}
return result;
}catch (Exception e){
logger.info("将数据查询之后进行组装调用通用方法错误:{}",e.getMessage());
//保存业务数据日志
saveTaskLivingDetails(jsonObjectUser.getString("data_id"),hashMaps.get(0).getString("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();
}
}
}

View File

@ -28,7 +28,7 @@ public interface IZxBankDao extends IBaseDao<ZxBankEntity, String> {
* @Author hecan * @Author hecan
* @Date 2024-12-05 17:58 * @Date 2024-12-05 17:58
* **/ * **/
Integer updatePushStatus(ZxBankEntity entity); Integer updatePushStatusZX(ZxBankEntity entity);
/** /**
* *
@ -38,7 +38,7 @@ public interface IZxBankDao extends IBaseDao<ZxBankEntity, String> {
* @Author hecan * @Author hecan
* @Date 2025-03-18 17:44 * @Date 2025-03-18 17:44
* **/ * **/
List<ZxBankEntity> queryResultIsNull(ZxBankEntity zxBankEntity); List<ZxBankEntity> queryResultIsNullZX(ZxBankEntity zxBankEntity);
/** /**
* *
@ -58,5 +58,15 @@ public interface IZxBankDao extends IBaseDao<ZxBankEntity, String> {
* @Author hecan * @Author hecan
* @Date 2025-03-19 14:15 * @Date 2025-03-19 14:15
* **/ * **/
List<ZxBankEntity> queryElecIsNull(ZxBankEntity entity); List<ZxBankEntity> queryElecIsNullZX(ZxBankEntity entity);
/**
*
* @content 更新电子回单
* @Param
* @Return
* @Author hecan
* @Date 2025-04-07 17:06
* **/
Integer updateElecStatusZX(ZxBankEntity entity);
} }

View File

@ -36,14 +36,14 @@ public class ZxBankDaoImpl extends MybatisGenericDao<ZxBankEntity,String> implem
@DS("#entity.dataSourceCode") @DS("#entity.dataSourceCode")
@Override @Override
public Integer updatePushStatus(ZxBankEntity entity) { public Integer updatePushStatusZX(ZxBankEntity entity) {
return super.update("updatePushStatus",entity); return super.update("updatePushStatusZX",entity);
} }
@DS("#entity.dataSourceCode") @DS("#entity.dataSourceCode")
@Override @Override
public List<ZxBankEntity> queryResultIsNull(ZxBankEntity entity) { public List<ZxBankEntity> queryResultIsNullZX(ZxBankEntity entity) {
return super.queryList(entity,"queryResultIsNull"); return super.queryList(entity,"queryResultIsNullZX");
} }
@DS("#entity.dataSourceCode") @DS("#entity.dataSourceCode")
@ -54,7 +54,13 @@ public class ZxBankDaoImpl extends MybatisGenericDao<ZxBankEntity,String> implem
@DS("#entity.dataSourceCode") @DS("#entity.dataSourceCode")
@Override @Override
public List<ZxBankEntity> queryElecIsNull(ZxBankEntity entity) { public List<ZxBankEntity> queryElecIsNullZX(ZxBankEntity entity) {
return super.queryList(entity,"queryElecIsNull"); return super.queryList(entity,"queryElecIsNullZX");
}
@DS("#entity.dataSourceCode")
@Override
public Integer updateElecStatusZX(ZxBankEntity entity) {
return super.update("updateElecStatusZX",entity);
} }
} }

View File

@ -30,7 +30,15 @@ public class ZxBankEntity extends BaseEntity {
private String payResult;//支付结果 private String payResult;//支付结果
private String receipt;//电子回单 private String receipt;//电子回单
private String pushStatus;//推送标识 private String pushStatus;//推送标识
private String summaryId;//
public String getSummaryId() {
return summaryId;
}
public void setSummaryId(String summaryId) {
this.summaryId = summaryId;
}
public String getTabName() { public String getTabName() {
return tabName; return tabName;

View File

@ -29,6 +29,7 @@
<result property="payResult" column="payResult" /> <result property="payResult" column="payResult" />
<result property="receipt" column="receipt" /> <result property="receipt" column="receipt" />
<result property="pushStatus" column="pushStatus" /> <result property="pushStatus" column="pushStatus" />
<result property="summaryId" column="summaryId" />
</resultMap> </resultMap>
@ -60,6 +61,7 @@
,pay_result as payResult ,pay_result as payResult
,receipt as receipt ,receipt as receipt
,push_status as pushStatus ,push_status as pushStatus
,summary_id as summaryId
</sql> </sql>
@ -71,20 +73,20 @@
from v_hzya_pay where push_status is null from v_hzya_pay where push_status is null
</select> </select>
<select id="queryResultIsNull" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity"> <select id="queryResultIsNullZX" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity">
select select
<include refid="ZxBankEntity_Base_Column_List" /> <include refid="ZxBankEntity_Base_Column_List" />
from v_hzya_pay where push_status is not null and pay_result is null from v_hzya_pay where push_status is not null and pay_result is null
</select> </select>
<select id="queryElecIsNull" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity"> <select id="queryElecIsNullZX" resultMap="get-ZxBankEntity-result" parameterType="com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity">
select select
<include refid="ZxBankEntity_Base_Column_List" /> <include refid="ZxBankEntity_Base_Column_List" />
from v_hzya_pay where pay_result='已支付' and receipt is null from v_hzya_pay where pay_result='已支付' and receipt is null
</select> </select>
<!--通过主键修改方法--> <!--通过主键修改方法-->
<update id="updatePushStatus" parameterType = "com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity" > <update id="updatePushStatusZX" parameterType = "com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity" >
update ${tabName} set ${pushStatusField} =#{pushStatus} where id=#{id} update ${tabName} set ${pushStatusField} =#{pushStatus} where id=#{id}
</update> </update>
@ -93,6 +95,11 @@
update ${tabName} set ${payResultField} =#{payResult} where id=#{id} update ${tabName} set ${payResultField} =#{payResult} where id=#{id}
</update> </update>
<!--通过主键修改方法-->
<update id="updateElecStatusZX" parameterType = "com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity" >
update ${tabName} set ${receiptFiled} =#{receipt} where id=#{id}
</update>
</mapper> </mapper>

View File

@ -2,17 +2,26 @@ package com.hzya.frame.seeyon.zxbank.service.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.log.Log;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService; import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl; import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity; 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.util.SM2Util;
import com.hzya.frame.seeyon.zxbank.dao.IZxBankDao; import com.hzya.frame.seeyon.zxbank.dao.IZxBankDao;
import com.hzya.frame.seeyon.zxbank.entity.PayState; import com.hzya.frame.seeyon.zxbank.entity.PayState;
import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity; import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity;
import com.hzya.frame.seeyon.zxbank.service.IZxBankService; 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.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; 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.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult; import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity; import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.io.*;
import java.util.Date; import java.net.HttpURLConnection;
import java.util.HashMap; import java.net.URL;
import java.util.List; 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") @Service("ZxBankServiceImpl")
public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> implements IZxBankService { public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> implements IZxBankService {
@ -42,6 +57,11 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
private IIntegrationTaskLivingDetailsService taskLivingDetailsService; private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Autowired @Autowired
private ComparisonServiceImpl comparisonServiceimpl; private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private ICtpAttachmentDao ctpAttachmentDao;
@Autowired
private ISysApplicationDatabaseDao sysApplicationDatabaseDao;
@Value("${zt.url}") @Value("${zt.url}")
private String url; private String url;
@ -108,7 +128,7 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
zxBankEntity.setPushStatus("1"); zxBankEntity.setPushStatus("1");
zxBankEntity.setId(dataId); zxBankEntity.setId(dataId);
zxBankEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode()); zxBankEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode());
zxBankDao.updatePushStatus(zxBankEntity); zxBankDao.updatePushStatusZX(zxBankEntity);
//保存业务数据日志 //保存业务数据日志
saveTaskLivingDetails(dataId, jsonObjectCmpApply.getString("document_no"), listAll.get(0).toString(), object.toString(), true,"ZxBankPluginInitializer"); saveTaskLivingDetails(dataId, jsonObjectCmpApply.getString("document_no"), listAll.get(0).toString(), object.toString(), true,"ZxBankPluginInitializer");
} }
@ -134,11 +154,10 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
@Override @Override
public JsonResultEntity queryArchivesResult(JSONObject json) { public JsonResultEntity queryArchivesResult(JSONObject json) {
try { try {
JSONObject jsonObject = json.getJSONObject("jsonStr"); ZxBankEntity zxBankEntity = json.toJavaObject(ZxBankEntity.class);
ZxBankEntity zxBankEntity = jsonObject.toJavaObject(ZxBankEntity.class);
zxBankEntity.setDataSourceCode("HT-OA"); zxBankEntity.setDataSourceCode("HT-OA");
logger.info("======开始查询中信返回的支付结果====="); logger.info("======开始查询中信返回的支付结果=====");
List<ZxBankEntity> zxBankEntities = zxBankDao.queryResultIsNull(zxBankEntity); List<ZxBankEntity> zxBankEntities = zxBankDao.queryResultIsNullZX(zxBankEntity);
if(CollectionUtils.isEmpty(zxBankEntities)){ if(CollectionUtils.isEmpty(zxBankEntities)){
logger.info("=====杭泰付款单中没有已推送并且支付结果为空的数据========"); logger.info("=====杭泰付款单中没有已推送并且支付结果为空的数据========");
return BaseResult.getSuccessMessageEntity("查询成功"); return BaseResult.getSuccessMessageEntity("查询成功");
@ -146,8 +165,15 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
for (ZxBankEntity bankEntity : zxBankEntities) { for (ZxBankEntity bankEntity : zxBankEntities) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(bankEntity.getDocumentNo()); list.add(bankEntity.getDocumentNo());
String params = String.join(", ", list); JSONObject jsonObject=new JSONObject();
logger.info("=======杭泰付款单调用中信支付结果查询请求参数为:{}", params); 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). String result = HttpRequest.post(url).
header("appId", "800058"). header("appId", "800058").
@ -155,16 +181,19 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
//header("access_token", tokenBody). //header("access_token", tokenBody).
header("publicKey", "ZJYALA1PchEI1s2D5vaapO9RZ6CiDFv/pJAV88lRYg0oBwBCe7eDIk+3zDUT+v578prj"). header("publicKey", "ZJYALA1PchEI1s2D5vaapO9RZ6CiDFv/pJAV88lRYg0oBwBCe7eDIk+3zDUT+v578prj").
header("secretKey", "jcoATYyty05KgDwL4O0xD+Ulq5ExYWkGvZGf2bhKrMaCehb3NIm5DUnJSK/r2SUaj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). header("secretKey", "jcoATYyty05KgDwL4O0xD+Ulq5ExYWkGvZGf2bhKrMaCehb3NIm5DUnJSK/r2SUaj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(params). body(jsonData.toJSONString()).
execute(). execute().
body(); body();
logger.info("========杭泰付款单调用中信支付结果查询返回参数为:{}==========", result); logger.info("========杭泰付款单调用中信支付结果查询返回参数为:{}==========", result);
JSONObject resultJson = JSONObject.parseObject(result); JSONObject resultJson = JSONObject.parseObject(result);
if (!resultJson.getBoolean("flag")) { 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 { } else {
String data = resultJson.getString("data"); JSONObject attribute = resultJson.getJSONObject("attribute");
JSONObject jsonObjectData = JSONObject.parseObject(data); String data = attribute.getString("data");
logger.info("=======杭泰付款单调用中信支付结果查询返回参数密文为:{}", data);
String decrypt = SM2Util.decrypt(data, privateKey);
JSONObject jsonObjectData = JSONObject.parseObject(decrypt);
JSONArray jsonArray = jsonObjectData.getJSONArray("list"); JSONArray jsonArray = jsonObjectData.getJSONArray("list");
if(CollectionUtils.isNotEmpty(jsonArray)){ if(CollectionUtils.isNotEmpty(jsonArray)){
for (Object o : jsonArray) { for (Object o : jsonArray) {
@ -176,8 +205,10 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
if(documentNo.equals(bankEntity.getDocumentNo())){ if(documentNo.equals(bankEntity.getDocumentNo())){
//修改支付状态 //修改支付状态
bankEntity.setPayResult(PayState.payStateGetValue(payStatus)); bankEntity.setPayResult(PayState.payStateGetValue(payStatus));
bankEntity.setDataSourceCode("HT-OA");
bankEntity.setId(bankEntity.getDataId());
zxBankDao.updateResultStatus(bankEntity); 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{ }else{
@ -194,14 +225,15 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
return BaseResult.getFailureMessageEntity("支付结果查询失败"); return BaseResult.getFailureMessageEntity("支付结果查询失败");
} }
@Override @Override
public JsonResultEntity queryArchivesElec(JSONObject json) { public JsonResultEntity queryArchivesElec(JSONObject json) {
try { try {
JSONObject jsonObject = json.getJSONObject("jsonStr"); ZxBankEntity zxBankEntity = json.toJavaObject(ZxBankEntity.class);
ZxBankEntity zxBankEntity = jsonObject.toJavaObject(ZxBankEntity.class);
zxBankEntity.setDataSourceCode("HT-OA"); zxBankEntity.setDataSourceCode("HT-OA");
logger.info("======开始查询中信电子回单====="); logger.info("======开始查询中信电子回单=====");
List<ZxBankEntity> zxBankEntities = zxBankDao.queryElecIsNull(zxBankEntity); List<ZxBankEntity> zxBankEntities = zxBankDao.queryElecIsNullZX(zxBankEntity);
if(CollectionUtils.isEmpty(zxBankEntities)){ if(CollectionUtils.isEmpty(zxBankEntities)){
logger.info("=====杭泰付款单中没有已支付并且电子回单为空的数据========"); logger.info("=====杭泰付款单中没有已支付并且电子回单为空的数据========");
return BaseResult.getSuccessMessageEntity("查询成功"); return BaseResult.getSuccessMessageEntity("查询成功");
@ -210,8 +242,14 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
JSONObject jsonParam=new JSONObject(); JSONObject jsonParam=new JSONObject();
jsonParam.put("companyCode",bankEntity.getCompanyCode());//公司编码 jsonParam.put("companyCode",bankEntity.getCompanyCode());//公司编码
jsonParam.put("documentNo",bankEntity.getDocumentNo());//单据号 jsonParam.put("documentNo",bankEntity.getDocumentNo());//单据号
String params = jsonParam.toJSONString(); JSONObject jsonData=new JSONObject();
logger.info("======杭泰付款单调用中信电子回单查询请求参数为:{}========",params); 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). String result = HttpRequest.post(url).
header("appId", "800058"). header("appId", "800058").
@ -219,7 +257,7 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
//header("access_token", tokenBody). //header("access_token", tokenBody).
header("publicKey", "ZJYALA1PchEI1s2D5vaapO9RZ6CiDFv/pJAV88lRYg0oBwBCe7eDIk+3zDUT+v578prj"). header("publicKey", "ZJYALA1PchEI1s2D5vaapO9RZ6CiDFv/pJAV88lRYg0oBwBCe7eDIk+3zDUT+v578prj").
header("secretKey", "jcoATYyty05KgDwL4O0xD+Ulq5ExYWkGvZGf2bhKrMaCehb3NIm5DUnJSK/r2SUaj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). header("secretKey", "jcoATYyty05KgDwL4O0xD+Ulq5ExYWkGvZGf2bhKrMaCehb3NIm5DUnJSK/r2SUaj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
body(params). body(objectData.toJSONString()).
execute(). execute().
body(); body();
logger.info("======杭泰付款单调用中信电子回单查询返回参数为:{}========",result); logger.info("======杭泰付款单调用中信电子回单查询返回参数为:{}========",result);
@ -227,16 +265,22 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
if (!resultJson.getBoolean("flag")) { if (!resultJson.getBoolean("flag")) {
saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), false,"ZxBankElecPluginInitializer"); saveTaskLivingDetails(bankEntity.getDataId(), bankEntity.getDocumentNo(), params, resultJson.toJSONString(), false,"ZxBankElecPluginInitializer");
} else { } else {
String data = resultJson.getString("data"); JSONObject attribute = resultJson.getJSONObject("attribute");
JSONObject jsonObjectData = JSONObject.parseObject(data); 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 电子回单下载需要 String billId = jsonObjectData.getString("billId"); //电子回单id 电子回单下载需要
logger.info("======中信电子回单返回的电子回单id为:{}====",billId); logger.info("======中信电子回单返回的电子回单id为:{}====",billId);
if(StrUtil.isNotEmpty(billId)){ if(StrUtil.isNotEmpty(billId)){
List<String> list=new ArrayList<>(); List<String> list=new ArrayList<>();
list.add(billId); list.add(billId);
String paramList = String.join(", ", list); JSONObject billIds=new JSONObject();
logger.info("====调用中信电子回单下载得请求参数为:{}=======",paramList); billIds.put("billIds",list);
elecDownlod(paramList); 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<ZxBankEntity, String> impleme
return null; return null;
} }
private JsonResultEntity elecDownlod(String params){ private JsonResultEntity elecDownlod(String params,ZxBankEntity zxBankEntity){
try { try {
//发送数据 String encrypt = SM2Util.encrypt(params, publicKey);
String result = HttpRequest.post(url). JSONObject objectData=new JSONObject();
header("appId", ""). objectData.put("data",encrypt);
header("apiCode", ""). logger.info("====调用中信电子回单下载得请求参数密文为:{}=======",objectData.toJSONString());
//header("access_token", tokenBody). //因为电子回单下载返回的只有文件流所以无法在中台上注册接口只能代码中调用第三方接口
header("publicKey", "ZJYAQ/VtQ66PqKXlV0EowrrlKkhBHYgS/Zk39Q5ezIQne51Ce7eDIk+3zDUT+v578prj"). //将文件流的zip下载到文件夹中之后解压该文件夹得到pdf文件上传OA
header("secretKey", "iLLk424Bmzknbu+ROeJoiVDMYY5EFXtbZY/aU13HmVYIiQrIw9c0Ag4ipxbfpUqqj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="). String downloadFolder ="D:\\yongansystem\\pdf\\";
body(params). String destinationFolder ="D:\\yongansystem\\pdf\\";
execute().
body(); URL url = new URL("http://202.108.57.65:11370/access/treasury/hangtai/bill/down");
logger.info("======杭泰付款单调用中信电子回单下载返回参数为:{}========",result); 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<CtpAttachmentEntity> 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){ }catch (Exception e){
logger.info("=======中信电子回单下载失败:{}======",e.getMessage()); logger.info("=======中信电子回单下载失败:{}======",e.getMessage());
e.printStackTrace(); e.printStackTrace();
@ -267,6 +413,88 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
return null; return null;
} }
public JSONObject fileUpload(File file) {
if (null != file) {
try {
HashMap<String, Object> 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<String, String> 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<JSONObject> bindingZxBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { private List<JSONObject> bindingZxBank(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();