Conflicts:
	fw-oa/src/main/java/com/hzya/frame/seeyon/dao/ICtpFileDao.java
	fw-oa/src/main/java/com/hzya/frame/seeyon/dao/impl/CtpFileDaoImpl.java
This commit is contained in:
lvleigang 2025-05-08 09:43:59 +08:00
commit 3f6cff85f0
15 changed files with 399 additions and 196 deletions

View File

@ -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.ICInvoiceImportHService;
import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportPluginService; import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportPluginService;
import com.hzya.frame.seeyon.util.YzfSignUtil; 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.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,13 +52,10 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
private ILexmiscivPlaneticketService lexmiscivPlaneticketService; private ILexmiscivPlaneticketService lexmiscivPlaneticketService;
@Autowired @Autowired
ILexmiscivPlaneticketsService lexmiscivPlaneticketsService; ILexmiscivPlaneticketsService lexmiscivPlaneticketsService;
@Resource
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Value("${zt.url:}") @Value("${zt.url:}")
private String url; private String url;
@Value("${yzf.accessSecret:}")
private String accessSecret;
@Value("${yzf.accesskey:}")
private String accesskey;
/** /**
* 发票导入 * 发票导入
* *
@ -67,8 +68,8 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
//1 查OA主表 //1 查OA主表
requestJson.get(""); String dataSourceCode = requestJson.getString("sourceCode");
String dataSourceCode = "HT-OA"; String id = requestJson.getString("id");//主表id
CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity(); CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity();
importHEntity.setDataSourceCode(dataSourceCode); importHEntity.setDataSourceCode(dataSourceCode);
importHEntity.setId("3922481031277596479"); importHEntity.setId("3922481031277596479");
@ -88,15 +89,16 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
int no = 1;//序号 int no = 1;//序号
//4 根据发票类型组装不同参数 //4 根据发票类型组装不同参数
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
Map<String, Object> parametersMap = new HashMap<>(); //Map<String, Object> parametersMap = new HashMap<>();
parametersMap.put("accessKey",accesskey); //parametersMap.put("accessKey",accesskey);
parametersMap.put("timestamp",timestamp); //parametersMap.put("timestamp",timestamp);
String sign = YzfSignUtil.signRequest(parametersMap, accessSecret); //String sign = YzfSignUtil.signRequest(parametersMap, accessSecret);
JSONObject head = new JSONObject(); JSONObject head = new JSONObject();
head.put("accessKey","6X3B526P5HqE6ums");//密钥 //head.put("accessKey",accesskey);//密钥
head.put("sign",sign);//签名 // head.put("sign",sign);//签名
head.put("timestamp",timestamp);//时间戳 // head.put("timestamp",timestamp);//时间戳
head.put("taxNo","91330110MAC5FPUY2U");//当前企业税号 head.put("taxNo","91330110MAC5FPUY2U");//当前企业税号
//head.put("taxNo",lexmisPublicinfoEntityList.get(0).getPI_TAXNO());
JSONArray inputInfos = new JSONArray(); JSONArray inputInfos = new JSONArray();
head.put("inputInfos",inputInfos);//发票录入信息单次最大50张 head.put("inputInfos",inputInfos);//发票录入信息单次最大50张
@ -108,7 +110,6 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
for (Map.Entry<String,List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()){ for (Map.Entry<String,List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()){
String key = entry.getKey();//对应发票类型的表名 String key = entry.getKey();//对应发票类型的表名
List<LexmisPublicinfoEntity> publicinfoList = entry.getValue(); List<LexmisPublicinfoEntity> publicinfoList = entry.getValue();
ParamAssemblerContext context = null;//策略上下文类
for (LexmisPublicinfoEntity info : publicinfoList){ for (LexmisPublicinfoEntity info : publicinfoList){
JSONObject inputInfo = new JSONObject(); JSONObject inputInfo = new JSONObject();
@ -153,6 +154,22 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
.build(); .build();
String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body(); String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body();
logger.info("调用有度发票批量导入接口响应参数:{}",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 +178,36 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
return null; 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 * @param dataSourceCode
@ -169,7 +216,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
* @param baseInfo * @param baseInfo
*/ */
private void planeInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) { private void planeInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) {
ParamAssemblerContext context; ParamAssemblerContext context;//策略上下文类
JSONObject contentInfo; JSONObject contentInfo;
ParamAssembler assembler; ParamAssembler assembler;
LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode)); LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode));
@ -220,7 +267,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
private void trainInvoice(String dataSourceCode, JSONArray inputInfos, LexmisPublicinfoEntity info, JSONObject inputInfo, JSONObject invoiceInfo, JSONObject baseInfo) { private void trainInvoice(String dataSourceCode, JSONArray inputInfos, LexmisPublicinfoEntity info, JSONObject inputInfo, JSONObject invoiceInfo, JSONObject baseInfo) {
JSONObject contentInfo; JSONObject contentInfo;
ParamAssembler assembler; ParamAssembler assembler;
ParamAssemblerContext context; ParamAssemblerContext context;//策略上下文类
LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode); LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode);
trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开3和4没遇到过先查1 trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开3和4没遇到过先查1
LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity); LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity);
@ -264,7 +311,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
* @param baseInfo 发票基本数据对象 * @param baseInfo 发票基本数据对象
*/ */
private void zzsInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) { private void zzsInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) {
ParamAssemblerContext context; ParamAssemblerContext context;//策略上下文类
JSONObject contentInfo; JSONObject contentInfo;
ParamAssembler assembler; ParamAssembler assembler;
LexmiscivInvoicemainEntity zzsInvoiceH = lexmiscivInvoicemainService.queryOne(new LexmiscivInvoicemainEntity(info.getPI_DATAKEY(), dataSourceCode)); LexmiscivInvoicemainEntity zzsInvoiceH = lexmiscivInvoicemainService.queryOne(new LexmiscivInvoicemainEntity(info.getPI_DATAKEY(), dataSourceCode));

View File

@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Value;
import java.time.Instant; import java.time.Instant;
/** /**
* @Description 云帐房accessToken * @Description 云帐房accessToken 没用了
* @Author xiangerlin * @Author xiangerlin
* @Date 2025/4/24 10:03 * @Date 2025/4/24 10:03
**/ **/
@ -28,15 +28,15 @@ public class YzfUtils {
private static String accessSecret; private static String accessSecret;
//接口地址 //接口地址
private static String baseUrl; private static String baseUrl;
@Value("${yzf.accessKey:}") //@Value("${yzf.accessKey:}")
public static void setaccessKey(String accessKey) { public static void setaccessKey(String accessKey) {
YzfUtils.accessKey = accessKey; YzfUtils.accessKey = accessKey;
} }
@Value("${yzf.accessSecret:}") //@Value("${yzf.accessSecret:}")
public static void setaccessSecret(String accessSecret) { public static void setaccessSecret(String accessSecret) {
YzfUtils.accessSecret = accessSecret; YzfUtils.accessSecret = accessSecret;
} }
@Value("${yzf.baseUrl:}") //@Value("${yzf.baseUrl:}")
public static void setBaseUrl(String baseUrl){ public static void setBaseUrl(String baseUrl){
YzfUtils.baseUrl = baseUrl; YzfUtils.baseUrl = baseUrl;
} }

View File

@ -1092,26 +1092,6 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity {
headers.putAll(header); headers.putAll(header);
} }
if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { 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<String, String> 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<String, String> 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 jsonObject=new JSONObject();
jsonObject.put("accessKey","6X3B526P5HqE6ums"); jsonObject.put("accessKey","6X3B526P5HqE6ums");
jsonObject.put("accessSecret","34e5fc32ac894a2ba2ade8c3852c7a0a"); jsonObject.put("accessSecret","34e5fc32ac894a2ba2ade8c3852c7a0a");
@ -1168,11 +1148,27 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity {
mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId());
mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId"));
mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity);
//修改下发状态
logger.info("===开票申请单申请正常下发时候完毕更新新增状态为1=======");
Map<String, Object> 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) { } 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"); 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<String, Object> 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; 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"); 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); objects.get(i).put("sendsanfzt123",false);
logger.info("========开票申请单申请数据新增下发完成,日志保存为失败============"); logger.info("========开票申请单申请数据新增下发完成,日志保存为失败============");
//修改下发状态
logger.info("===开票申请单申请正常下发时候完毕更新新增状态为2=======");
Map<String, Object> 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; continue;
} }
} }
} }
//所有下发发送完成修改数据状态 /* //所有下发发送完成修改数据状态
for (int i = 0; i < objects.size(); i++) { for (int i = 0; i < objects.size(); i++) {
if(objects.get(i).getBoolean("sendsanfzt123")){ if(objects.get(i).getBoolean("sendsanfzt123")){
Map<String, Object> updateMap = new HashMap<>(); Map<String, Object> updateMap = new HashMap<>();
@ -1201,7 +1205,7 @@ public class InvoiceDistributePluginInitializer extends PluginBaseEntity {
updateMap.put("id", objects.get(i).getString("id")); updateMap.put("id", objects.get(i).getString("id"));
mdmModuleDao.updateMdmSTs(updateMap); 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 { 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 {

View File

@ -826,7 +826,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
/** body */ /** body */
String bodys = doObjects.get(i).toJSONString(); String bodys = doObjects.get(i).toJSONString();
if(scriptEntity != null && scriptEntity.getId() != null ){ if(scriptEntity != null && scriptEntity.getId() != null ){
logger.info("=========开始执行正常主数据修改下发脚本,第一次=============="); logger.info("=========开始执行正常中信司库付款单修改下发脚本,第一次==============");
groovy.put("code",scriptEntity.getScriptCode()); groovy.put("code",scriptEntity.getScriptCode());
groovy.put("className",scriptEntity.getClassName()); groovy.put("className",scriptEntity.getClassName());
groovy.put("name",scriptEntity.getScriptName()); groovy.put("name",scriptEntity.getScriptName());
@ -854,7 +854,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
headers.putAll(header); headers.putAll(header);
} }
if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) { if (SysEnum.NEED_LOGIN.getValue().equals(apiEntity.getNeedLogin())) {
logger.info("=========正常主数据修改开始执行登录接口=============="); logger.info("=========正常中信司库付款单修改开始执行登录接口==============");
//找到登陆接口 //找到登陆接口
SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort()); SysApplicationApiEntity loginApi = sysApplicationApiDao.get(apiEntity.getAuthenticationPort());
if (null == loginApi) { if (null == loginApi) {
@ -875,28 +875,42 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
continue; continue;
} }
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
logger.info("=======主数据正常修改下发登录返回数据:{}========",attritube.toJSONString()); logger.info("=======中信司库付款单正常修改下发登录返回数据:{}========",attritube.toJSONString());
querys = getQuery(apiEntity,querys,attritube); querys = getQuery(apiEntity,querys,attritube);
headers = getHeaders(apiEntity,headers,attritube); headers = getHeaders(apiEntity,headers,attritube);
bodys = getBodys(apiEntity,bodys,attritube); bodys = getBodys(apiEntity,bodys,attritube);
} }
//组装数据发送 //组装数据发送
logger.info("=========开始执行主业务修改数据下发脚本,第二次=============="); logger.info("=========开始执行中信司库付款单修改数据下发脚本,第二次==============");
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); 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(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"); 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<String, Object> 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; continue;
}else { }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"); 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<String, Object> 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; continue;
} }
} }
} }
//所有下发发送完成修改数据状态 /*//所有下发发送完成修改数据状态
for (int i = 0; i < objects.size(); i++) { for (int i = 0; i < objects.size(); i++) {
Map<String, Object> updateMap = new HashMap<>(); Map<String, Object> updateMap = new HashMap<>();
updateMap.put("tableName",mainDb); updateMap.put("tableName",mainDb);
@ -904,7 +918,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
updateMap.put("updateStatus", "1"); updateMap.put("updateStatus", "1");
updateMap.put("id", objects.get(i).getString("id")); updateMap.put("id", objects.get(i).getString("id"));
mdmModuleDao.updateMdmSTs(updateMap); mdmModuleDao.updateMdmSTs(updateMap);
} }*/
} }
/** /**
@ -1083,19 +1097,19 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
continue; continue;
} }
JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString()); JSONObject attritube = JSONObject.parseObject(rzjsonResultEntity.getAttribute().toString());
logger.info("=======数据正常新增下发登录返回数据:{}========",attritube.toJSONString()); logger.info("=======中信司库付款单数据正常新增下发登录返回数据:{}========",attritube.toJSONString());
querys = getQuery(apiEntity,querys,attritube); querys = getQuery(apiEntity,querys,attritube);
headers = getHeaders(apiEntity,headers,attritube); headers = getHeaders(apiEntity,headers,attritube);
bodys = getBodys(apiEntity,bodys,attritube); bodys = getBodys(apiEntity,bodys,attritube);
} }
//组装数据发送 //组装数据发送
logger.info("=========开始执行主业务新增数据下发脚本,第二次=============="); logger.info("=========开始执行中信司库付款单新增数据下发脚本,第二次==============");
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys); 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(jsonResultEntity.isFlag()){
if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) { if (scriptEntity != null && scriptEntity.getId() != null && scriptEntity.getBackScriptData() != null ) {
logger.info("=========开始执行主数据新增返回脚本=============="); logger.info("=========开始执行中信司库付款单新增返回脚本==============");
JSONObject backScriptJson = new JSONObject(); JSONObject backScriptJson = new JSONObject();
backScriptJson.put("data", jsonResultEntity.getAttribute()); backScriptJson.put("data", jsonResultEntity.getAttribute());
groovy.put("code", scriptEntity.getScriptCode()+"back"); groovy.put("code", scriptEntity.getScriptCode()+"back");
@ -1124,30 +1138,54 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId()); mdmModuleDistributeTripartiteEntity.setAppId(sysApplicationEntity.getId());
mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId")); mdmModuleDistributeTripartiteEntity.setTripartiteId(backJsonResultEntity.getString("tripartiteId"));
mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity); mdmModuleDistributeTripartiteDao.save(mdmModuleDistributeTripartiteEntity);
//修改下发状态
logger.info("===中信司库付款单正常下发时候完毕更新新增状态为1=======");
Map<String, Object> 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) { } 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"); 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<String, Object> 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; 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"); 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); objects.get(i).put("sendsanfzt123",true);
logger.info("========主数据新增下发完成,日志保存为成功============"); logger.info("========中信司库付款单新增下发完成,日志保存为成功============");
continue; continue;
}else { }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"); 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); objects.get(i).put("sendsanfzt123",false);
logger.info("========主数据新增下发完成,日志保存为失败============"); logger.info("========中信司库付款单新增下发完成,日志保存为失败============");
//修改下发状态
logger.info("===中信司库付款单正常下发时候完毕更新新增状态为2=======");
Map<String, Object> 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; continue;
} }
} }
} }
//所有下发发送完成修改数据状态 /* //所有下发发送完成修改数据状态
for (int i = 0; i < objects.size(); i++) { for (int i = 0; i < objects.size(); i++) {
if(objects.get(i).getBoolean("sendsanfzt123")){ if(objects.get(i).getBoolean("sendsanfzt123")){
Map<String, Object> updateMap = new HashMap<>(); Map<String, Object> updateMap = new HashMap<>();
@ -1157,7 +1195,7 @@ public class ZxBankDistributePluginInitializer extends PluginBaseEntity {
updateMap.put("id", objects.get(i).getString("id")); updateMap.put("id", objects.get(i).getString("id"));
mdmModuleDao.updateMdmSTs(updateMap); 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 { 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 {

View File

@ -52,8 +52,3 @@ zx:
# 生产用这个 这个是银行给的 # 生产用这个 这个是银行给的
privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgOHOzaKWBWOAbslvtYtS8tcQiJ9W9DT2cGQM3KSgXpfygCgYIKoEcz1UBgi2hRANCAAQNPct0MHOuDrVJBIy0RI7JKx9/PTlFHZlkIJr0EqpC+b/+N+z3JKbCMZ/wcP1V36Q+DlfDJCY9Ai/Uk2PZ9ZaF privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgOHOzaKWBWOAbslvtYtS8tcQiJ9W9DT2cGQM3KSgXpfygCgYIKoEcz1UBgi2hRANCAAQNPct0MHOuDrVJBIy0RI7JKx9/PTlFHZlkIJr0EqpC+b/+N+z3JKbCMZ/wcP1V36Q+DlfDJCY9Ai/Uk2PZ9ZaF
publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEDT3LdDBzrg61SQSMtESOySsffz05RR2ZZCCa9BKqQvm//jfs9ySmwjGf8HD9Vd+kPg5XwyQmPQIv1JNj2fWWhQ== publicKey: MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEDT3LdDBzrg61SQSMtESOySsffz05RR2ZZCCa9BKqQvm//jfs9ySmwjGf8HD9Vd+kPg5XwyQmPQIv1JNj2fWWhQ==
# 云帐房配置
yzf:
accessKey: 6X3B526P5HqE6ums
accessSecret: 34e5fc32ac894a2ba2ade8c3852c7a0a
baseUrl: http://oapi.nanofintax.com

View File

@ -37,7 +37,3 @@ OA:
data_source_code: yc-test data_source_code: yc-test
zt: zt:
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
yzf:
accessKey: 6X3B526P5HqE6ums
accessSecret: 34e5fc32ac894a2ba2ade8c3852c7a0a
baseUrl: http://oapi.nanofintax.com

View File

@ -1,5 +1,5 @@
server: server:
port: 9999 port: 10086
servlet: servlet:
context-path: /kangarooDataCenterV3 context-path: /kangarooDataCenterV3
localIP: 127.0.0.1 localIP: 127.0.0.1

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>CInvoiceImportPluginInitializer</id>
<name>CInvoiceImportPluginInitializer插件</name>
<category>25042301</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="cInvoiceImportPluginInitializer" class="com.hzya.frame.plugin.cinvoice.plugin.CInvoiceImportPluginInitializer" />
</beans>

View File

@ -97,6 +97,7 @@ public abstract class MybatisGenericDao<E extends Serializable, PK extends Seria
return (E) this.sqlSession.selectOne(stamentID, o); return (E) this.sqlSession.selectOne(stamentID, o);
} }
@DS("#o.dataSourceCode")
@Override @Override
public List<E> queryList(E o, String stamentID) { public List<E> queryList(E o, String stamentID) {
List<E> tempList = this.sqlSession.selectList(stamentID, o); List<E> tempList = this.sqlSession.selectList(stamentID, o);

View File

@ -14,4 +14,13 @@ public interface ICtpFileDao extends IBaseDao<CtpFileEntity,String> {
List<CtpFileEntity> queryFile(CtpFileEntity ctpFileEntity); List<CtpFileEntity> queryFile(CtpFileEntity ctpFileEntity);
/**
*
* @content 根据附件id查询附加信息
* @Param
* @Return
* @Author hecan
* @Date 2025-04-27 18:03
* **/
List<CtpFileEntity> queryCtpFileById(CtpFileEntity ctpFileEntity);
} }

View File

@ -2,9 +2,7 @@ package com.hzya.frame.seeyon.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao; 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.dao.ICtpFileDao;
import com.hzya.frame.seeyon.entity.CtpAttachmentEntity;
import com.hzya.frame.seeyon.entity.CtpFileEntity; import com.hzya.frame.seeyon.entity.CtpFileEntity;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -17,6 +15,11 @@ import java.util.List;
**/ **/
@Repository() @Repository()
public class CtpFileDaoImpl extends MybatisGenericDao<CtpFileEntity,String> implements ICtpFileDao { public class CtpFileDaoImpl extends MybatisGenericDao<CtpFileEntity,String> implements ICtpFileDao {
@DS("#ctpFileEntity.dataSourceCode")
@Override
public List<CtpFileEntity> queryCtpFileById(CtpFileEntity ctpFileEntity) {
return (List<CtpFileEntity>) super.selectList("queryCtpFileById",ctpFileEntity);
}

View File

@ -57,5 +57,17 @@
</trim> </trim>
</select> </select>
<!-- 查询 采用==查询 -->
<select id="queryCtpFileById" resultMap="get-CtpFileEntity-result" parameterType="com.hzya.frame.seeyon.entity.CtpFileEntity">
select
<include refid="CtpFileEntity_sql"/>
from
ctp_file
<trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">id = #{id}</if>
<if test="filename != null and filename != ''">and filename = #{filename}</if>
</trim>
</select>
</mapper> </mapper>

View File

@ -90,12 +90,12 @@
<select id="queryInputInvoiceResult" resultMap="get-InvoiceEntity-result" parameterType="com.hzya.frame.seeyon.invoice.entity.InvoiceEntity"> <select id="queryInputInvoiceResult" resultMap="get-InvoiceEntity-result" parameterType="com.hzya.frame.seeyon.invoice.entity.InvoiceEntity">
select select
* *
from where from formmain_0533
</select> </select>
<!--通过主键修改方法--> <!--通过主键修改方法-->
<update id="updateInvoiceUrl" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" > <update id="updateInvoiceUrl" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" >
update ${tabName} set ${url_field} =#{url} where id=#{id} update formmain_0331 set ${url_field} =#{url} where id=#{id}
</update> </update>
<!--通过主键修改方法--> <!--通过主键修改方法-->
@ -105,7 +105,7 @@
<!--通过主键修改方法--> <!--通过主键修改方法-->
<update id="updateInvoiceResult" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" > <update id="updateInvoiceResult" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" >
update ${tabName} set update formmain_0331 set
<trim suffix="" suffixOverrides=","> <trim suffix="" suffixOverrides=",">
<if test="input_result_status != null and input_result_status != ''"> ${input_result_status_filed} = #{input_result_status},</if> <if test="input_result_status != null and input_result_status != ''"> ${input_result_status_filed} = #{input_result_status},</if>
<if test="invoice_code != null and invoice_code != ''"> ${invoice_code_field} = #{invoice_code},</if> <if test="invoice_code != null and invoice_code != ''"> ${invoice_code_field} = #{invoice_code},</if>

View File

@ -1,6 +1,8 @@
package com.hzya.frame.seeyon.invoice.service.impl; package com.hzya.frame.seeyon.invoice.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
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;
@ -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.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.dao.ICtpAttachmentDao;
import com.hzya.frame.seeyon.dao.ICtpFileDao;
import com.hzya.frame.seeyon.entity.CtpAttachmentEntity; 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.IInvoiceDao;
import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao;
import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; 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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; 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.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.*; import java.util.*;
@Service(value = "InvoiceServiceImpl") @Service(value = "InvoiceServiceImpl")
@ -54,6 +63,9 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
private ComparisonServiceImpl comparisonServiceimpl; private ComparisonServiceImpl comparisonServiceimpl;
@Autowired @Autowired
private ICtpAttachmentDao ctpAttachmentDao; private ICtpAttachmentDao ctpAttachmentDao;
@Autowired
private ICtpFileDao ctpFileDao;
@Value("${zt.url}") @Value("${zt.url}")
private String url; private String url;
@ -152,17 +164,9 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
return BaseResult.getSuccessMessageEntity("查询成功"); return BaseResult.getSuccessMessageEntity("查询成功");
} }
for (InvoiceEntity entity : invoiceEntities) { for (InvoiceEntity entity : invoiceEntities) {
long timestamp = System.currentTimeMillis(); entity.setDataSourceCode("HT-OA");
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 jsonObject = new JSONObject();
jsonObject.put("serialNumber",entity.getId()); jsonObject.put("serialNumber", entity.getSerial_number());
jsonObject.put("accessKey","6X3B526P5HqE6ums");
jsonObject.put("sign",sign);
jsonObject.put("timestamp",timestamp);
logger.info("=======调用杭泰税务查询申请单详情的请求参数为:{}=======",jsonObject.toJSONString());
//发送数据 //发送数据
String result = HttpRequest.post(url). String result = HttpRequest.post(url).
header("appId", "800060"). header("appId", "800060").
@ -180,7 +184,7 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
JSONObject attribute = resultJson.getJSONObject("attribute"); JSONObject attribute = resultJson.getJSONObject("attribute");
if ("0".equals(attribute.getString("code"))) { if ("0".equals(attribute.getString("code"))) {
JSONObject jsonResult = JSONObject.parseObject(attribute.getString("result")); JSONObject jsonResult = JSONObject.parseObject(attribute.getString("result"));
if(null !=jsonResult){ if (null != jsonResult && jsonResult.getString("serialNumber").equals(entity.getSerial_number())) {
JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList"); JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList");
if (CollectionUtils.isNotEmpty(jsonArray)) { if (CollectionUtils.isNotEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
@ -194,42 +198,55 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
entity.setInvoice_code(invoiceCode); entity.setInvoice_code(invoiceCode);
entity.setInvoice_number(invoiceNumber); entity.setInvoice_number(invoiceNumber);
entity.setResult_status(resultStatus); entity.setResult_status(resultStatus);
entity.setId(entity.getSerial_number());
//将开票结果发票号码发票代码回写OA //将开票结果发票号码发票代码回写OA
logger.info("=======开始将开票结果发票号码发票代码回写OA======");
invoiceDao.updateInvoiceResult(entity); invoiceDao.updateInvoiceResult(entity);
logger.info("=======将开票结果发票号码发票代码回写OA完毕======");
if (null != invoiceInfo.getString("url") || null != invoiceInfo.getString("ofdUrl")) { if (null != invoiceInfo.getString("url") || null != invoiceInfo.getString("ofdUrl")) {
String pdfUrl = invoiceInfo.getString("url");//pdf文件 String pdfUrl = invoiceInfo.getString("url");//pdf文件
String ofdUrl = invoiceInfo.getString("ofdUrl");//ofd文件 String ofdUrl = invoiceInfo.getString("ofdUrl");//ofd文件
String xmlUrl = invoiceInfo.getString("xmlUrl");//xml文件 String xmlUrl = invoiceInfo.getString("xmlUrl");//xml文件
//获取pdf文件到本地 并为pdf取名否则会报无法访问错误 //获取pdf文件到本地 并为pdf取名否则会报无法访问错误
logger.info("========开始将pdf文件保存到本地========"); logger.info("========开始将pdf文件保存到本地========");
String pdfFileName = generateFileName(pdfUrl, "pdf"); String pdfFileName = generateFileName(pdfUrl, "PDF");
String pdfSavePath = invoicePdfUrl + pdfFileName; String pdfSavePath = invoicePdfUrl + pdfFileName;
downloadPdf(pdfUrl, pdfSavePath); downloadPdf(pdfUrl, pdfSavePath);
logger.info("========pdf文件保存到本地完成========"); logger.info("========pdf文件保存到本地完成========");
File filePdf = new File(pdfSavePath); File filePdf = new File(pdfSavePath);
if(null !=filePdf){
logger.info("========开始将pdf文件上传OA========"); logger.info("========开始将pdf文件上传OA========");
ManyfileUpload(filePdf, entity, sub_reference, att_reference, jsonObject); ManyfileUpload(filePdf, entity, sub_reference, att_reference, jsonObject);
logger.info("========pdf文件上传OA完成========"); logger.info("========pdf文件上传OA完成========");
}
//获取ofd文件到本地 //获取ofd文件到本地
logger.info("========开始将ofd文件保存到本地========"); logger.info("========开始将ofd文件保存到本地========");
String ofdFileName = generateFileName(ofdUrl, "ofd"); String ofdFileName = generateFileName(ofdUrl, "OFD");
String ofdSavePath = ofdUrl + ofdFileName; String ofdSavePath = invoiceOfdUrl + ofdFileName;
downloadPdf(ofdUrl, ofdSavePath); downloadPdf(ofdUrl, ofdSavePath);
logger.info("========ofd文件保存到本地完成========"); logger.info("========ofd文件保存到本地完成========");
File fileOfd = new File(ofdSavePath); File fileOfd = new File(ofdSavePath);
if(null !=fileOfd){
logger.info("========开始将ofd文件上传OA========"); logger.info("========开始将ofd文件上传OA========");
ManyfileUpload(fileOfd, entity, sub_reference, att_reference, jsonObject); ManyfileUpload(fileOfd, entity, sub_reference, att_reference, jsonObject);
logger.info("========ofd文件上传OA完成========"); logger.info("========ofd文件上传OA完成========");
} }
} }
} }
}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完毕======");
}
} }
} }
} }
} }
}catch (Exception e){ }catch (Exception e){
logger.info("======查询杭泰税务申请单详情失败====",e.getMessage()); logger.info("======查询杭泰税务申请单详情失败:{}====",e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
@ -248,17 +265,9 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
return BaseResult.getSuccessMessageEntity("查询成功"); return BaseResult.getSuccessMessageEntity("查询成功");
} }
for (InvoiceEntity entity : invoiceEntities) { for (InvoiceEntity entity : invoiceEntities) {
long timestamp = System.currentTimeMillis(); entity.setDataSourceCode("HT-OA");
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 jsonObject=new JSONObject();
jsonObject.put("serialNumber",entity.getId()); 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). String result = HttpRequest.post(url).
header("appId", "800060"). header("appId", "800060").
@ -293,18 +302,29 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
} }
} }
}catch (Exception e){ }catch (Exception e){
logger.info("======查询杭泰税务发票批量录入结果失败====",e.getMessage()); logger.info("======查询杭泰税务发票批量录入结果失败:{}====",e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
private void ManyfileUpload(File file,InvoiceEntity entity,String sub_reference,String att_reference,JSONObject jsonObject){ private void ManyfileUpload(File file,InvoiceEntity entity,String sub_reference,String att_reference,JSONObject jsonObject){
JSONObject jsonObjectOfd = OARestUtil.fileUpload(file,"8000590003","8000590001"); logger.info("=======文件名称为:{}=====",file.getName());
if(null !=file) {
JSONObject jsonObjectOfd = fileUploadPdfAndOfd(file);
if (jsonObjectOfd.getString("fileUrl") != null) { if (jsonObjectOfd.getString("fileUrl") != null) {
entity.setUrl(sub_reference); entity.setUrl(sub_reference);
entity.setDataSourceCode("HT-OA"); entity.setDataSourceCode("HT-OA");
logger.info("===========查询开票详情开始将附件id更新OA==========");
invoiceDao.updateInvoiceUrl(entity); invoiceDao.updateInvoiceUrl(entity);
logger.info("===========查询开票详情将附件id更新OA完毕==========");
//根据附件id查询附件信息
CtpFileEntity ctpFileEntity=new CtpFileEntity();
ctpFileEntity.setId(jsonObjectOfd.getString("fileUrl"));
ctpFileEntity.setDataSourceCode("HT-OA");
List<CtpFileEntity> query = ctpFileDao.queryCtpFileById(ctpFileEntity);
if(CollectionUtils.isNotEmpty(query)) {
CtpFileEntity ctpFile = query.get(0);
//根据附件id查询附件业务数据 //根据附件id查询附件业务数据
String file_url = jsonObjectOfd.getString("fileUrl"); String file_url = jsonObjectOfd.getString("fileUrl");
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity();
@ -315,11 +335,11 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
List<CtpAttachmentEntity> ctpAttachmentEntities = ctpAttachmentDao.queryCtpAttachment(ctpAttachmentEntity); List<CtpAttachmentEntity> ctpAttachmentEntities = ctpAttachmentDao.queryCtpAttachment(ctpAttachmentEntity);
//如果没有查询到数据就新增附件业务否则更新 //如果没有查询到数据就新增附件业务否则更新
if (ctpAttachmentEntities.size() == 0) { if (ctpAttachmentEntities.size() == 0) {
String category = jsonObject.getString("category"); String category =ctpFile.getCategory();
String type = jsonObject.getString("type"); String type =ctpFile.getType();
String filename = jsonObject.getString("filename"); String filename =ctpFile.getFilename();
String mime_type = jsonObject.getString("mimeType"); String mime_type =ctpFile.getMime_type();
String attachment_size = jsonObject.getString("size"); String attachment_size =ctpFile.getFile_size();
String id = String.valueOf(UUIDLong.longUUID()); String id = String.valueOf(UUIDLong.longUUID());
ctpAttachmentEntity.setCategory(category); ctpAttachmentEntity.setCategory(category);
ctpAttachmentEntity.setFilename(filename); ctpAttachmentEntity.setFilename(filename);
@ -339,15 +359,68 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity); ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity);
} }
logger.info("=====电子回单执行完毕======="); logger.info("=====电子回单执行完毕=======");
}else{
logger.info("========根据附件id:{}没有查询到附件信息======",jsonObjectOfd.getString("fileUrl"));
}
} }
file.delete(); file.delete();
}else{
logger.info("==========本地没有文件==============");
}
}
public JSONObject fileUploadPdfAndOfd(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 void downloadPdf(String pdfUrl, String savePath) { private void downloadPdf(String pdfUrl, String savePath) {
try { try {
URL url = new URL(pdfUrl); URL url = new URL(pdfUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("Post"); // 处理 HTTPS 证书测试环境忽略验证生产环境需移除
if (pdfUrl.startsWith("https")) {
trustAllCertificates((HttpsURLConnection) connection);
}
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode(); int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) { if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream(); InputStream inputStream = connection.getInputStream();
@ -371,6 +444,20 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> 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) { private String generateFileName(String url, String extension) {
// 这里简单根据 URL 的参数生成文件名你可以根据实际需求调整 // 这里简单根据 URL 的参数生成文件名你可以根据实际需求调整
String[] parts = url.split("&"); String[] parts = url.split("&");