From 915317d4c75c2de778bd168c9c917e0ecf7553ae Mon Sep 17 00:00:00 2001 From: hecan <1718492867@qq.com> Date: Mon, 28 Apr 2025 11:07:48 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=B8=AD=E4=BF=A1=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=92=8C=E6=9C=89=E5=BA=A6=E5=BC=80=E7=A5=A8=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InvoiceDistributePluginInitializer.java | 48 +-- .../ZxBankDistributePluginInitializer.java | 70 +++- .../hzya/frame/seeyon/dao/ICtpFileDao.java | 11 + .../frame/seeyon/dao/impl/CtpFileDaoImpl.java | 10 +- .../frame/seeyon/entity/CtpFileEntity.xml | 14 +- .../seeyon/invoice/entity/InvoiceEntity.xml | 4 +- .../service/impl/InvoiceServiceImpl.java | 320 +++++++++++------- 7 files changed, 314 insertions(+), 163 deletions(-) diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java index 14fc3fe7..af9593bc 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/ht/plugin/InvoiceDistributePluginInitializer.java @@ -1092,26 +1092,6 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity { headers.putAll(header); } if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { - /* logger.info("=========正常开票申请单申请数据新增开始执行登录接口=============="); - //找到登陆接口 - SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); - if (null == loginApi) { - saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口不存在",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); - continue; - } - String rzquerys = getQuery(loginApi,null,null); - Map headersa = new HashMap<>(); - headersa.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj"); - headersa.put("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA="); - headersa.put("appId", sysApplicationEntity.getAppId().toString()); - headersa.put("apiCode", loginApi.getApiCode().toString()); - Map rzheaders = getHeaders(loginApi,headersa,null); - String rzbodys = getBodys(loginApi,null,null); - JsonResultEntity rzjsonResultEntity = sendData(loginApi,rzheaders,rzbodys,rzquerys); - if (!rzjsonResultEntity.isFlag()) { - saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","发送错误,认证接口错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); - continue; - }*/ JSONObject jsonObject=new JSONObject(); jsonObject.put("accessKey","6X3B526P5HqE6ums"); jsonObject.put("accessSecret","34e5fc32ac894a2ba2ade8c3852c7a0a"); @@ -1168,11 +1148,27 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity { mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); + //修改下发状态 + logger.info("===开票申请单申请正常下发时候完毕更新新增状态为1======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); } } } catch (Exception e) { logger.error("开票申请单申请下发新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute()); saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增返回脚本解析保存三方id错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + //修改下发状态 + logger.info("===开票申请单申请正常下发时候完毕更新新增状态为2======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "2"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); continue; } } @@ -1186,12 +1182,20 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity { saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); objects.get(i).put("sendsanfzt123",false); logger.info("========开票申请单申请数据新增下发完成,日志保存为失败============"); + //修改下发状态 + logger.info("===开票申请单申请正常下发时候完毕更新新增状态为2======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "2"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); continue; } } } - //所有下发发送完成,修改数据状态 + /* //所有下发发送完成,修改数据状态 for (int i = 0; i < objects.size(); i++) { if(objects.get(i).getBoolean("sendsanfzt123")){ Map updateMap = new HashMap<>(); @@ -1201,7 +1205,7 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity { updateMap.put("id", objects.get(i).getString("id")); mdmModuleDao.updateMdmSTs(updateMap); } - } + }*/ } private void saveMdmModuleSendLogEntity(Long mdmCode,String distributeId,String dataType,String remark,String dbname,String formmain_id, String target_app, String appId, String target_api,String apiID, String source_data, String option_type) throws Exception { diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZxBankDistributePluginInitializer.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZxBankDistributePluginInitializer.java index 32edad78..3bad135e 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZxBankDistributePluginInitializer.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/zxBank/plugin/ZxBankDistributePluginInitializer.java @@ -826,7 +826,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { /** body */ String bodys = doObjects.get(i).toJSONString(); if(scriptEntity != null && scriptEntity.getId() != null ){ - logger.info("=========开始执行正常主数据修改下发脚本,第一次=============="); + logger.info("=========开始执行正常中信司库付款单修改下发脚本,第一次=============="); groovy.put("code",scriptEntity.getScriptCode()); groovy.put("className",scriptEntity.getClassName()); groovy.put("name",scriptEntity.getScriptName()); @@ -854,7 +854,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { headers.putAll(header); } if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { - logger.info("=========正常主数据修改开始执行登录接口=============="); + logger.info("=========正常中信司库付款单修改开始执行登录接口=============="); //找到登陆接口 SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); if (null == loginApi) { @@ -875,28 +875,42 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { continue; } JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); - logger.info("=======主数据正常修改下发登录返回数据:{}========",attritube.toJSONString()); + logger.info("=======中信司库付款单正常修改下发登录返回数据:{}========",attritube.toJSONString()); querys = getQuery(apiEntity,querys,attritube); headers = getHeaders(apiEntity,headers,attritube); bodys = getBodys(apiEntity,bodys,attritube); } //组装数据发送 - logger.info("=========开始执行主业务修改数据下发脚本,第二次=============="); + logger.info("=========开始执行中信司库付款单修改数据下发脚本,第二次=============="); JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); - logger.info("=====主数据修改下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); + logger.info("=====中信司库付款单修改下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); if(jsonResultEntity.isFlag()){ //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + //修改下发状态 + logger.info("===中信司库付款单正常下发时候完毕更新新增状态为1======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "F"); + updateMap.put("updateStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); continue; }else { //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"2"); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "F"); + updateMap.put("updateStatus", "2"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); continue; } } } - //所有下发发送完成,修改数据状态 + /*//所有下发发送完成,修改数据状态 for (int i = 0; i < objects.size(); i++) { Map updateMap = new HashMap<>(); updateMap.put("tableName",mainDb); @@ -904,7 +918,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { updateMap.put("updateStatus", "1"); updateMap.put("id", objects.get(i).getString("id")); mdmModuleDao.updateMdmSTs(updateMap); - } + }*/ } /** @@ -1083,19 +1097,19 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { continue; } JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); - logger.info("=======主数据正常新增下发登录返回数据:{}========",attritube.toJSONString()); + logger.info("=======中信司库付款单数据正常新增下发登录返回数据:{}========",attritube.toJSONString()); querys = getQuery(apiEntity,querys,attritube); headers = getHeaders(apiEntity,headers,attritube); bodys = getBodys(apiEntity,bodys,attritube); } //组装数据发送 - logger.info("=========开始执行主业务新增数据下发脚本,第二次=============="); + logger.info("=========开始执行中信司库付款单新增数据下发脚本,第二次=============="); JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); - logger.info("=====主数据新增下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); + logger.info("=====中信司库付款单新增下发返回结果为:{}",JSONObject.parseObject(jsonResultEntity.getAttribute().toString()).toJSONString()); if(jsonResultEntity.isFlag()){ if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) { - logger.info("=========开始执行主数据新增返回脚本=============="); + logger.info("=========开始执行中信司库付款单新增返回脚本=============="); JSONObject backScriptJson = new JSONObject(); backScriptJson.put("data", jsonResultEntity.getAttribute()); groovy.put("code", scriptEntity.getScriptCode()+"back"); @@ -1124,30 +1138,54 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); + //修改下发状态 + logger.info("===中信司库付款单正常下发时候完毕更新新增状态为1======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "1"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); } } } catch (Exception e) { - logger.error("新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute()); + logger.error("中信司库付款单新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute()); saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","新增返回脚本解析保存三方id错误",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); + //修改下发状态 + logger.info("===中信司库付款单正常下发时候完毕更新新增状态为2======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "2"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); continue; } } //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); objects.get(i).put("sendsanfzt123",true); - logger.info("========主数据新增下发完成,日志保存为成功============"); + logger.info("========中信司库付款单新增下发完成,日志保存为成功============"); continue; }else { //保存日志 saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1"); objects.get(i).put("sendsanfzt123",false); - logger.info("========主数据新增下发完成,日志保存为失败============"); + logger.info("========中信司库付款单新增下发完成,日志保存为失败============"); + //修改下发状态 + logger.info("===中信司库付款单正常下发时候完毕更新新增状态为2======="); + Map updateMap = new HashMap<>(); + updateMap.put("tableName",mainDb); + //updateMap.put("dataStatus", "Y"); + updateMap.put("addStatus", "2"); + updateMap.put("id", objects.get(i).getString("id")); + mdmModuleDao.updateMdmSTs(updateMap); continue; } } } - //所有下发发送完成,修改数据状态 + /* //所有下发发送完成,修改数据状态 for (int i = 0; i < objects.size(); i++) { if(objects.get(i).getBoolean("sendsanfzt123")){ Map updateMap = new HashMap<>(); @@ -1157,7 +1195,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity { updateMap.put("id", objects.get(i).getString("id")); mdmModuleDao.updateMdmSTs(updateMap); } - } + }*/ } private void saveMdmModuleSendLogEntity(Long mdmCode,String distributeId,String dataType,String remark,String dbname,String formmain_id, String target_app, String appId, String target_api,String apiID, String source_data, String option_type) throws Exception { diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/ICtpFileDao.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/ICtpFileDao.java index 87961648..47fe57ae 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/ICtpFileDao.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/ICtpFileDao.java @@ -3,10 +3,21 @@ package com.hzya.frame.seeyon.dao; import com.hzya.frame.basedao.dao.IBaseDao; import com.hzya.frame.seeyon.entity.CtpFileEntity; +import java.util.List; + /** * @Description seeyon 附件对象 * @Author xiangerlin * @Date 2024/6/17 15:21 **/ public interface ICtpFileDao extends IBaseDao { + /** + * + * @content 根据附件id查询附加信息 + * @Param + * @Return + * @Author hecan + * @Date 2025-04-27 18:03 + * **/ + List queryCtpFileById(CtpFileEntity ctpFileEntity); } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/impl/CtpFileDaoImpl.java b/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/impl/CtpFileDaoImpl.java index 8b80d3d7..7b02c5c6 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/impl/CtpFileDaoImpl.java +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/dao/impl/CtpFileDaoImpl.java @@ -1,12 +1,13 @@ package com.hzya.frame.seeyon.dao.impl; +import com.baomidou.dynamic.datasource.annotation.DS; import com.hzya.frame.basedao.dao.MybatisGenericDao; -import com.hzya.frame.seeyon.dao.ICtpAttachmentDao; import com.hzya.frame.seeyon.dao.ICtpFileDao; -import com.hzya.frame.seeyon.entity.CtpAttachmentEntity; import com.hzya.frame.seeyon.entity.CtpFileEntity; import org.springframework.stereotype.Repository; +import java.util.List; + /** * @Description * @Author xiangerlin @@ -14,4 +15,9 @@ import org.springframework.stereotype.Repository; **/ @Repository() public class CtpFileDaoImpl extends MybatisGenericDao implements ICtpFileDao { + @DS("#ctpFileEntity.dataSourceCode") + @Override + public List queryCtpFileById(CtpFileEntity ctpFileEntity) { + return (List) super.selectList("queryCtpFileById",ctpFileEntity); + } } diff --git a/fw-oa/src/main/java/com/hzya/frame/seeyon/entity/CtpFileEntity.xml b/fw-oa/src/main/java/com/hzya/frame/seeyon/entity/CtpFileEntity.xml index 3f3c8cad..366258d7 100644 --- a/fw-oa/src/main/java/com/hzya/frame/seeyon/entity/CtpFileEntity.xml +++ b/fw-oa/src/main/java/com/hzya/frame/seeyon/entity/CtpFileEntity.xml @@ -1,6 +1,6 @@ - + @@ -45,5 +45,17 @@ + + + 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 index 10213540..9d0bdd09 100644 --- 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 @@ -95,7 +95,7 @@ - update ${tabName} set ${url_field} =#{url} where id=#{id} + update formmain_0331 set ${url_field} =#{url} where id=#{id} @@ -105,7 +105,7 @@ - update ${tabName} set + update formmain_0331 set ${input_result_status_filed} = #{input_result_status}, ${invoice_code_field} = #{invoice_code}, 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 index dfbdd22f..da2a802c 100644 --- 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 @@ -1,6 +1,8 @@ package com.hzya.frame.seeyon.invoice.service.impl; +import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -8,7 +10,9 @@ 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.dao.ICtpFileDao; import com.hzya.frame.seeyon.entity.CtpAttachmentEntity; +import com.hzya.frame.seeyon.entity.CtpFileEntity; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao; import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; @@ -31,11 +35,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; +import java.security.cert.X509Certificate; import java.util.*; @Service(value = "InvoiceServiceImpl") @@ -54,6 +63,9 @@ public class InvoiceServiceImpl extends BaseService imple private ComparisonServiceImpl comparisonServiceimpl; @Autowired private ICtpAttachmentDao ctpAttachmentDao; + @Autowired + private ICtpFileDao ctpFileDao; + @Value("${zt.url}") private String url; @@ -152,84 +164,82 @@ public class InvoiceServiceImpl extends BaseService imple 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.getId()); - 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); - JSONObject resultJson = JSONObject.parseObject(result); - if (!resultJson.getBoolean("flag")) { - saveTaskLivingDetails(entity.getId(), entity.getBusiness_no(), jsonObject.toJSONString(), resultJson.toJSONString(), false,""); - } else { - JSONObject attribute = resultJson.getJSONObject("attribute"); - if("0".equals(attribute.getString("code"))){ - JSONObject jsonResult=JSONObject.parseObject(attribute.getString("result")); - if(null !=jsonResult){ - JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList"); - if(CollectionUtils.isNotEmpty(jsonArray)){ - for (int i = 0; i < jsonArray.size(); i++) { - //表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference - String sub_reference = String.valueOf(UUIDLong.longUUID()); - String att_reference = entity.getSummaryId();//Summary_id - JSONObject invoiceInfo = jsonArray.getJSONObject(i); - String invoiceCode = invoiceInfo.getString("invoiceCode");//发票代码 - String invoiceNumber = invoiceInfo.getString("invoiceNumber");//发票号码 - String resultStatus = InvoiceState.invoiceStateGetValue(jsonResult.getString("resultStatus"));//开票结果 - entity.setInvoice_code(invoiceCode); - entity.setInvoice_number(invoiceNumber); - entity.setResult_status(resultStatus); - //将开票结果,发票号码,发票代码,回写OA - invoiceDao.updateInvoiceResult(entity); - if (null != invoiceInfo.getString("url") || null != invoiceInfo.getString("ofdUrl")) { - String pdfUrl = invoiceInfo.getString("url");//pdf文件 - String ofdUrl = invoiceInfo.getString("ofdUrl");//ofd文件 - String xmlUrl = invoiceInfo.getString("xmlUrl");//xml文件 - //获取pdf文件到本地 并为pdf取名,否则会报无法访问错误 - logger.info("========开始将pdf文件保存到本地========"); - String pdfFileName = generateFileName(pdfUrl, "pdf"); - String pdfSavePath = invoicePdfUrl + pdfFileName; - downloadPdf(pdfUrl, pdfSavePath); - logger.info("========pdf文件保存到本地完成========"); - File filePdf = new File(pdfSavePath); - logger.info("========开始将pdf文件上传OA========"); - ManyfileUpload(filePdf, entity, sub_reference, att_reference, jsonObject); - logger.info("========pdf文件上传OA完成========"); - //获取ofd文件到本地 - logger.info("========开始将ofd文件保存到本地========"); - String ofdFileName = generateFileName(ofdUrl, "ofd"); - String ofdSavePath = ofdUrl + ofdFileName; - downloadPdf(ofdUrl, ofdSavePath); - logger.info("========ofd文件保存到本地完成========"); - File fileOfd = new File(ofdSavePath); - logger.info("========开始将ofd文件上传OA========"); - ManyfileUpload(fileOfd, entity, sub_reference, att_reference, jsonObject); - logger.info("========ofd文件上传OA完成========"); + entity.setDataSourceCode("HT-OA"); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("serialNumber", entity.getSerial_number()); + //发送数据 + 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); + JSONObject resultJson = JSONObject.parseObject(result); + if (!resultJson.getBoolean("flag")) { + saveTaskLivingDetails(entity.getId(), entity.getBusiness_no(), jsonObject.toJSONString(), resultJson.toJSONString(), false, ""); + } else { + JSONObject attribute = resultJson.getJSONObject("attribute"); + if ("0".equals(attribute.getString("code"))) { + JSONObject jsonResult = JSONObject.parseObject(attribute.getString("result")); + if (null != jsonResult && jsonResult.getString("serialNumber").equals(entity.getSerial_number())) { + JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList"); + if (CollectionUtils.isNotEmpty(jsonArray)) { + for (int i = 0; i < jsonArray.size(); i++) { + //表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference + String sub_reference = String.valueOf(UUIDLong.longUUID()); + String att_reference = entity.getSummaryId();//Summary_id + JSONObject invoiceInfo = jsonArray.getJSONObject(i); + String invoiceCode = invoiceInfo.getString("invoiceCode");//发票代码 + String invoiceNumber = invoiceInfo.getString("invoiceNumber");//发票号码 + String resultStatus = InvoiceState.invoiceStateGetValue(jsonResult.getString("resultStatus"));//开票结果 + entity.setInvoice_code(invoiceCode); + entity.setInvoice_number(invoiceNumber); + entity.setResult_status(resultStatus); + entity.setId(entity.getSerial_number()); + //将开票结果,发票号码,发票代码,回写OA + logger.info("=======开始将开票结果,发票号码,发票代码,回写OA======"); + invoiceDao.updateInvoiceResult(entity); + logger.info("=======将开票结果,发票号码,发票代码,回写OA完毕======"); + if (null != invoiceInfo.getString("url") || null != invoiceInfo.getString("ofdUrl")) { + String pdfUrl = invoiceInfo.getString("url");//pdf文件 + String ofdUrl = invoiceInfo.getString("ofdUrl");//ofd文件 + String xmlUrl = invoiceInfo.getString("xmlUrl");//xml文件 + //获取pdf文件到本地 并为pdf取名,否则会报无法访问错误 + logger.info("========开始将pdf文件保存到本地========"); + String pdfFileName = generateFileName(pdfUrl, "PDF"); + String pdfSavePath = invoicePdfUrl + pdfFileName; + downloadPdf(pdfUrl, pdfSavePath); + logger.info("========pdf文件保存到本地完成========"); + File filePdf = new File(pdfSavePath); + if(null !=filePdf){ + logger.info("========开始将pdf文件上传OA========"); + ManyfileUpload(filePdf, entity, sub_reference, att_reference, jsonObject); + logger.info("========pdf文件上传OA完成========"); + } + //获取ofd文件到本地 + logger.info("========开始将ofd文件保存到本地========"); + String ofdFileName = generateFileName(ofdUrl, "OFD"); + String ofdSavePath = invoiceOfdUrl + ofdFileName; + downloadPdf(ofdUrl, ofdSavePath); + logger.info("========ofd文件保存到本地完成========"); + File fileOfd = new File(ofdSavePath); + if(null !=fileOfd){ + logger.info("========开始将ofd文件上传OA========"); + ManyfileUpload(fileOfd, entity, sub_reference, att_reference, jsonObject); + logger.info("========ofd文件上传OA完成========"); + } + } } } } } } - } - } }catch (Exception e){ - logger.info("======查询杭泰税务申请单详情失败====",e.getMessage()); + logger.info("======查询杭泰税务申请单详情失败:{}====",e.getMessage()); e.printStackTrace(); } return null; @@ -248,17 +258,9 @@ public class InvoiceServiceImpl extends BaseService imple 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"); + entity.setDataSourceCode("HT-OA"); JSONObject jsonObject=new JSONObject(); jsonObject.put("serialNumber",entity.getId()); - jsonObject.put("accessKey","6X3B526P5HqE6ums"); - jsonObject.put("sign",sign); - jsonObject.put("timestamp",timestamp); - logger.info("=======调用杭泰税务查询发票批量录入结果的请求参数为:{}=======",jsonObject.toJSONString()); //发送数据 String result = HttpRequest.post(url). header("appId", "800060"). @@ -293,61 +295,125 @@ public class InvoiceServiceImpl extends BaseService imple } } }catch (Exception e){ - logger.info("======查询杭泰税务发票批量录入结果失败====",e.getMessage()); + logger.info("======查询杭泰税务发票批量录入结果失败:{}====",e.getMessage()); e.printStackTrace(); } return null; } private void ManyfileUpload(File file,InvoiceEntity entity,String sub_reference,String att_reference,JSONObject jsonObject){ - JSONObject jsonObjectOfd = OARestUtil.fileUpload(file,"8000590003","8000590001"); - if (jsonObjectOfd.getString("fileUrl") != null) { - entity.setUrl(sub_reference); - entity.setDataSourceCode("HT-OA"); - invoiceDao.updateInvoiceUrl(entity); - //根据附件id查询附件业务数据 - String file_url = jsonObjectOfd.getString("fileUrl"); - CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); - ctpAttachmentEntity.setFile_url(file_url); - 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附件业务表中查到多条记录"); + logger.info("=======文件名称为:{}=====",file.getName()); + if(null !=file) { + JSONObject jsonObjectOfd = fileUploadPdfAndOfd(file); + if (jsonObjectOfd.getString("fileUrl") != null) { + entity.setUrl(sub_reference); + entity.setDataSourceCode("HT-OA"); + logger.info("===========查询开票详情开始将附件id更新OA=========="); + invoiceDao.updateInvoiceUrl(entity); + logger.info("===========查询开票详情将附件id更新OA完毕=========="); + //根据附件id查询附件信息 + CtpFileEntity ctpFileEntity=new CtpFileEntity(); + ctpFileEntity.setId(jsonObjectOfd.getString("fileUrl")); + ctpFileEntity.setDataSourceCode("HT-OA"); + List query = ctpFileDao.queryCtpFileById(ctpFileEntity); + if(CollectionUtils.isNotEmpty(query)) { + CtpFileEntity ctpFile = query.get(0); + //根据附件id查询附件业务数据 + String file_url = jsonObjectOfd.getString("fileUrl"); + CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); + ctpAttachmentEntity.setFile_url(file_url); + 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 =ctpFile.getCategory(); + String type =ctpFile.getType(); + String filename =ctpFile.getFilename(); + String mime_type =ctpFile.getMime_type(); + String attachment_size =ctpFile.getFile_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("=====电子回单执行完毕======="); + }else{ + logger.info("========根据附件id:{}没有查询到附件信息======",jsonObjectOfd.getString("fileUrl")); } - //更新数据到OA附件业务表中 - ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity); } - logger.info("=====电子回单执行完毕======="); + file.delete(); + }else{ + logger.info("==========本地没有文件=============="); } - file.delete(); } + public JSONObject fileUploadPdfAndOfd(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 void downloadPdf(String pdfUrl, String savePath) { try { URL url = new URL(pdfUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("Post"); + // 处理 HTTPS 证书(测试环境忽略验证,生产环境需移除) + if (pdfUrl.startsWith("https")) { + trustAllCertificates((HttpsURLConnection) connection); + } + connection.setRequestMethod("GET"); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { InputStream inputStream = connection.getInputStream(); @@ -371,6 +437,20 @@ public class InvoiceServiceImpl extends BaseService imple } } + private static void trustAllCertificates(HttpsURLConnection conn) throws Exception { + TrustManager[] trustAllCerts = new TrustManager[]{ + new X509TrustManager() { + @Override public void checkClientTrusted(X509Certificate[] chain, String authType) {} + @Override public void checkServerTrusted(X509Certificate[] chain, String authType) {} + @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } + } + }; + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); + conn.setSSLSocketFactory(sslContext.getSocketFactory()); + conn.setHostnameVerifier((hostname, session) -> true); // 忽略主机名验证 + } + private String generateFileName(String url, String extension) { // 这里简单根据 URL 的参数生成文件名,你可以根据实际需求调整 String[] parts = url.split("&"); From aecdd8a4fbc66a4a90f3f25679a8786a96ef41bf Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 14:18:24 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/CInvoiceImportPluginServiceImpl.java | 79 +++++++++++++++---- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java index dcc9d89d..344cd049 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java @@ -14,6 +14,8 @@ import com.hzya.frame.plugin.cinvoice.lexmis.service.*; import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportHService; import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportPluginService; import com.hzya.frame.seeyon.util.YzfSignUtil; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService; import org.apache.commons.collections.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,7 +52,8 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer private ILexmiscivPlaneticketService lexmiscivPlaneticketService; @Autowired ILexmiscivPlaneticketsService lexmiscivPlaneticketsService; - + @Resource + private IIntegrationTaskLivingDetailsService taskLivingDetailsService; @Value("${zt.url:}") private String url; @Value("${yzf.accessSecret:}") @@ -67,8 +72,8 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer //1、 查OA主表 - requestJson.get(""); - String dataSourceCode = "HT-OA"; + String dataSourceCode = requestJson.getString("sourceCode"); + String id = requestJson.getString("id");//主表id CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity(); importHEntity.setDataSourceCode(dataSourceCode); importHEntity.setId("3922481031277596479"); @@ -88,15 +93,16 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer int no = 1;//序号 //4、 根据发票类型,组装不同参数 long timestamp = System.currentTimeMillis(); - Map parametersMap = new HashMap<>(); - parametersMap.put("accessKey",accesskey); - parametersMap.put("timestamp",timestamp); - String sign = YzfSignUtil.signRequest(parametersMap, accessSecret); + //Map parametersMap = new HashMap<>(); + //parametersMap.put("accessKey",accesskey); + //parametersMap.put("timestamp",timestamp); + //String sign = YzfSignUtil.signRequest(parametersMap, accessSecret); JSONObject head = new JSONObject(); - head.put("accessKey","6X3B526P5HqE6ums");//密钥 - head.put("sign",sign);//签名 - head.put("timestamp",timestamp);//时间戳 + //head.put("accessKey",accesskey);//密钥 + // head.put("sign",sign);//签名 + // head.put("timestamp",timestamp);//时间戳 head.put("taxNo","91330110MAC5FPUY2U");//当前企业税号 + //head.put("taxNo",lexmisPublicinfoEntityList.get(0).getPI_TAXNO()); JSONArray inputInfos = new JSONArray(); head.put("inputInfos",inputInfos);//发票录入信息,单次最大50张 @@ -108,7 +114,6 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer for (Map.Entry> entry : groupedByPiTablename.entrySet()){ String key = entry.getKey();//对应发票类型的表名 List publicinfoList = entry.getValue(); - ParamAssemblerContext context = null;//策略上下文类 for (LexmisPublicinfoEntity info : publicinfoList){ JSONObject inputInfo = new JSONObject(); @@ -153,6 +158,22 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer .build(); String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body(); logger.info("调用有度发票批量导入接口响应参数:{}",body); + //保存操作日志 + if (StrUtil.isNotEmpty(body)){ + JSONObject jsonObject = JSONObject.parseObject(body); + Boolean flag = jsonObject.getBoolean("flag"); + //保存日志 + IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity(); + taskLivingDetail.setCreate_time(new Date()); + taskLivingDetail.setModify_time(new Date()); + taskLivingDetail.setRootAppPk(cInvoiceH.getId()); + taskLivingDetail.setRootAppBill(cInvoiceH.getBill_code()); + taskLivingDetail.setPluginId("CInvoiceImportPluginInitializer"); + taskLivingDetail.setRootAppNewData(head.toString()); + taskLivingDetail.setNewTransmitInfo(body); + taskLivingDetail.setNewPushDate(new Date()); + this.saveLog(id,flag,taskLivingDetail); + } } } } @@ -161,6 +182,36 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer return null; } + /** + * 保存日志 + * @param integration_task_living_details_id + * @param flag + * @param taskLivingDetail + */ + public void saveLog(String integration_task_living_details_id, Boolean flag, IntegrationTaskLivingDetailsEntity taskLivingDetail){ + try { + //判断,成功调用这个方法 + if (StrUtil.isEmpty(integration_task_living_details_id)){ + if (flag){ + taskLivingDetailsService.saveLogToSuccess(taskLivingDetail); + }else { + //失败 调用这个方法 + taskLivingDetailsService.saveLogToFail(taskLivingDetail); + } + }else { + taskLivingDetail.setId(integration_task_living_details_id); + if (flag){ + //如果是重试 成功调这个方法 + taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail); + }else { + //如果是重试 失败调这个方法 + taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail); + } + } + }catch (Exception e){ + logger.error("保存日志出错:{}",e); + } + } /** * 机票 * @param dataSourceCode @@ -169,7 +220,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer * @param baseInfo */ private void planeInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) { - ParamAssemblerContext context; + ParamAssemblerContext context;//策略上下文类 JSONObject contentInfo; ParamAssembler assembler; LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode)); @@ -220,7 +271,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer private void trainInvoice(String dataSourceCode, JSONArray inputInfos, LexmisPublicinfoEntity info, JSONObject inputInfo, JSONObject invoiceInfo, JSONObject baseInfo) { JSONObject contentInfo; ParamAssembler assembler; - ParamAssemblerContext context; + ParamAssemblerContext context;//策略上下文类 LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode); trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开,3和4没遇到过,先查1 LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity); @@ -264,7 +315,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer * @param baseInfo 发票基本数据对象 */ private void zzsInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) { - ParamAssemblerContext context; + ParamAssemblerContext context;//策略上下文类 JSONObject contentInfo; ParamAssembler assembler; LexmiscivInvoicemainEntity zzsInvoiceH = lexmiscivInvoicemainService.queryOne(new LexmiscivInvoicemainEntity(info.getPI_DATAKEY(), dataSourceCode)); From cd82812db737d4e59756f03216dd872a9dee135c Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 14:19:01 +0800 Subject: [PATCH 3/9] =?UTF-8?q?port=E6=94=B9=E6=88=9010086?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base-buildpackage/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base-buildpackage/src/main/resources/application.yml b/base-buildpackage/src/main/resources/application.yml index a0bbeaae..b87e5bf7 100644 --- a/base-buildpackage/src/main/resources/application.yml +++ b/base-buildpackage/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 9999 + port: 10086 servlet: context-path: /kangarooDataCenterV3 localIP: 127.0.0.1 From 36eeec00aa72e169f665b70d119a2d54869d7240 Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 14:19:39 +0800 Subject: [PATCH 4/9] =?UTF-8?q?queryList=E5=A2=9E=E5=8A=A0=20@DS=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hzya/frame/basedao/dao/MybatisGenericDao.java | 1 + 1 file changed, 1 insertion(+) diff --git a/base-common/src/main/java/com/hzya/frame/basedao/dao/MybatisGenericDao.java b/base-common/src/main/java/com/hzya/frame/basedao/dao/MybatisGenericDao.java index 95e43393..04398663 100644 --- a/base-common/src/main/java/com/hzya/frame/basedao/dao/MybatisGenericDao.java +++ b/base-common/src/main/java/com/hzya/frame/basedao/dao/MybatisGenericDao.java @@ -97,6 +97,7 @@ public abstract class MybatisGenericDao queryList(E o, String stamentID) { List tempList = this.sqlSession.selectList(stamentID, o); From 63ed457e22532d81c1f9da5aa49093bac550507e Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 14:27:13 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base-buildpackage/src/main/resources/application-ht.yml | 7 +------ base-buildpackage/src/main/resources/application-xel.yml | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/base-buildpackage/src/main/resources/application-ht.yml b/base-buildpackage/src/main/resources/application-ht.yml index 3f014426..afbc5086 100644 --- a/base-buildpackage/src/main/resources/application-ht.yml +++ b/base-buildpackage/src/main/resources/application-ht.yml @@ -51,9 +51,4 @@ invoice_ofd: zx: # 生产用这个 这个是银行给的 privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgOHOzaKWBWOAbslvtYtS8tcQiJ9W9DT2cGQM3KSgXpfygCgYIKoEcz1UBgi2hRANCAAQNPct0MHOuDrVJBIy0RI7JKx9/PTlFHZlkIJr0EqpC+b/+N+z3JKbCMZ/wcP1V36Q+DlfDJCY9Ai/Uk2PZ9ZaF - publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEDT3LdDBzrg61SQSMtESOySsffz05RR2ZZCCa9BKqQvm//jfs9ySmwjGf8HD9Vd+kPg5XwyQmPQIv1JNj2fWWhQ== -# 云帐房配置 -yzf: - accessKey: 6X3B526P5HqE6ums - accessSecret: 34e5fc32ac894a2ba2ade8c3852c7a0a - baseUrl: http://oapi.nanofintax.com \ No newline at end of file + publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEDT3LdDBzrg61SQSMtESOySsffz05RR2ZZCCa9BKqQvm//jfs9ySmwjGf8HD9Vd+kPg5XwyQmPQIv1JNj2fWWhQ== \ No newline at end of file diff --git a/base-buildpackage/src/main/resources/application-xel.yml b/base-buildpackage/src/main/resources/application-xel.yml index 32f34dbb..35b8c248 100644 --- a/base-buildpackage/src/main/resources/application-xel.yml +++ b/base-buildpackage/src/main/resources/application-xel.yml @@ -37,7 +37,3 @@ OA: data_source_code: yc-test zt: url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface -yzf: - accessKey: 6X3B526P5HqE6ums - accessSecret: 34e5fc32ac894a2ba2ade8c3852c7a0a - baseUrl: http://oapi.nanofintax.com From e6613ecc935d8ceb2e08ba772e4355863751704a Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 14:27:26 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CInvoiceImportPluginServiceImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java index 344cd049..ced95d7f 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/service/impl/CInvoiceImportPluginServiceImpl.java @@ -56,10 +56,6 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer private IIntegrationTaskLivingDetailsService taskLivingDetailsService; @Value("${zt.url:}") private String url; - @Value("${yzf.accessSecret:}") - private String accessSecret; - @Value("${yzf.accesskey:}") - private String accesskey; /** * 发票导入 * From 4326329c6856348188ad0fb7a86f9be94422f66a Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 14:34:58 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hzya/frame/plugin/cinvoice/util/YzfUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/util/YzfUtils.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/util/YzfUtils.java index b1811548..84088463 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/util/YzfUtils.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/cinvoice/util/YzfUtils.java @@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Value; import java.time.Instant; /** - * @Description 云帐房accessToken + * @Description 云帐房accessToken 没用了 * @Author xiangerlin * @Date 2025/4/24 10:03 **/ @@ -28,15 +28,15 @@ public class YzfUtils { private static String accessSecret; //接口地址 private static String baseUrl; - @Value("${yzf.accessKey:}") + //@Value("${yzf.accessKey:}") public static void setaccessKey(String accessKey) { YzfUtils.accessKey = accessKey; } - @Value("${yzf.accessSecret:}") + //@Value("${yzf.accessSecret:}") public static void setaccessSecret(String accessSecret) { YzfUtils.accessSecret = accessSecret; } - @Value("${yzf.baseUrl:}") + //@Value("${yzf.baseUrl:}") public static void setBaseUrl(String baseUrl){ YzfUtils.baseUrl = baseUrl; } From 2e80feef58f8c202793e9e456baa9672be371ebe Mon Sep 17 00:00:00 2001 From: xiang2lin <251481237@qq.com> Date: Mon, 28 Apr 2025 16:19:58 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=8F=92=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/cfgHome/plugin/cinvoice/pluginCfg.xml | 6 ++++++ .../plugin/cinvoice/spring/spring-buildpackage-plugin.xml | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/pluginCfg.xml create mode 100644 base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/spring/spring-buildpackage-plugin.xml diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/pluginCfg.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/pluginCfg.xml new file mode 100644 index 00000000..9abdda66 --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/pluginCfg.xml @@ -0,0 +1,6 @@ + + +CInvoiceImportPluginInitializer +CInvoiceImportPluginInitializer插件 +25042301 + diff --git a/base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/spring/spring-buildpackage-plugin.xml b/base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/spring/spring-buildpackage-plugin.xml new file mode 100644 index 00000000..d691238c --- /dev/null +++ b/base-buildpackage/src/main/resources/cfgHome/plugin/cinvoice/spring/spring-buildpackage-plugin.xml @@ -0,0 +1,5 @@ + + + + + From d0e553c358f50041d7900723ddba2cd646b6c785 Mon Sep 17 00:00:00 2001 From: hecan <1718492867@qq.com> Date: Wed, 30 Apr 2025 22:11:57 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BC=80=E7=A5=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=9F=A5=E8=AF=A2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hzya/frame/seeyon/invoice/entity/InvoiceEntity.xml | 2 +- .../seeyon/invoice/service/impl/InvoiceServiceImpl.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 index 9d0bdd09..18fa2fc2 100644 --- 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 @@ -90,7 +90,7 @@ 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 index da2a802c..e9535a6d 100644 --- 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 @@ -233,6 +233,13 @@ public class InvoiceServiceImpl extends BaseService imple } } } + }else{ + logger.info("=======开始将开票结果回写OA======"); + String resultStatus = InvoiceState.invoiceStateGetValue(jsonResult.getString("resultStatus"));//开票结果 + entity.setResult_status(resultStatus); + entity.setId(entity.getSerial_number()); + invoiceDao.updateInvoiceResult(entity); + logger.info("=======将开票结果回写OA完毕======"); } } }