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("&");