This commit is contained in:
xiang2lin 2024-06-18 10:35:30 +08:00
parent e0efefc522
commit f0b53a019f
1 changed files with 35 additions and 28 deletions

View File

@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.cbs8.dto.req.ElecRequestDTO; import com.hzya.frame.cbs8.dto.req.ElecRequestDTO;
import com.hzya.frame.cbs8.dto.req.PayResultRequestDTO; import com.hzya.frame.cbs8.dto.req.PayResultRequestDTO;
@ -13,14 +12,13 @@ import com.hzya.frame.cbs8.dto.res.*;
import com.hzya.frame.cbs8.service.ICbs8Service; import com.hzya.frame.cbs8.service.ICbs8Service;
import com.hzya.frame.cbs8.util.CBSUtil; import com.hzya.frame.cbs8.util.CBSUtil;
import com.hzya.frame.cbs8.util.PayState; import com.hzya.frame.cbs8.util.PayState;
import com.hzya.frame.plugin.cbs8.plugin.PayApplyPluginInitializer;
import com.hzya.frame.plugin.cbs8.service.ICbsPluginService; import com.hzya.frame.plugin.cbs8.service.ICbsPluginService;
import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity; import com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity;
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity; import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
import com.hzya.frame.seeyon.cbs8.service.ICbsLogService; import com.hzya.frame.seeyon.cbs8.service.ICbsLogService;
import com.hzya.frame.seeyon.cbs8.service.IPaymentService; import com.hzya.frame.seeyon.cbs8.service.IPaymentService;
import com.hzya.frame.seeyon.dao.ICtpAttachmentDao;
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.service.ICtpAttachmentService; import com.hzya.frame.seeyon.service.ICtpAttachmentService;
import com.hzya.frame.seeyon.util.RestUtil; import com.hzya.frame.seeyon.util.RestUtil;
import com.hzya.frame.uuid.UUIDLong; import com.hzya.frame.uuid.UUIDLong;
@ -53,6 +51,8 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
@Value("${cbs8.elec_path}") @Value("${cbs8.elec_path}")
private String elec_path; private String elec_path;
@Value("${OA.data_source_code}")
private String oa_data_source_code;
/** /**
* 支付申请 * 支付申请
* *
@ -161,33 +161,40 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
List<PaymentEntity> paymentList = paymentService.queryElecIsNull(paymentEntity); List<PaymentEntity> paymentList = paymentService.queryElecIsNull(paymentEntity);
if (CollectionUtils.isNotEmpty(paymentList)) { if (CollectionUtils.isNotEmpty(paymentList)) {
for (PaymentEntity pay : paymentList) { for (PaymentEntity pay : paymentList) {
String payDate = DateUtil.format(DateUtil.parse(pay.getPayDate()), "yyyy-MM-dd"); try {
//查询cbs电子回单 String payDate = DateUtil.format(DateUtil.parse(pay.getPayDate()), "yyyy-MM-dd");
List<ElecResponseDTO> elecResList = cbs8Service.queryElecBill(new ElecRequestDTO(payDate,DateUtil.today(),pay.getReferenceNum())); //查询cbs电子回单
if (CollectionUtils.isNotEmpty(elecResList)){ List<ElecResponseDTO> elecResList = cbs8Service.queryElecBill(new ElecRequestDTO(payDate,DateUtil.today(),pay.getReferenceNum()));
ElecResponseDTO elecResponseDTO = elecResList.get(0); if (CollectionUtils.isNotEmpty(elecResList)){
String bucketFileUrl = elecResponseDTO.getBucketFileUrl(); ElecResponseDTO elecResponseDTO = elecResList.get(0);
String bucketFileName = elecResponseDTO.getBucketFileName(); String bucketFileUrl = elecResponseDTO.getBucketFileUrl();
//上传电子回单到OA String bucketFileName = elecResponseDTO.getBucketFileName();
HttpUtil.downloadFile(bucketFileUrl, FileUtil.file(elec_path));//附件下载 //上传电子回单到OA
String pdfUrl = elec_path + bucketFileName; HttpUtil.downloadFile(bucketFileUrl, FileUtil.file(elec_path));//附件下载
File file = new File(pdfUrl); String pdfUrl = elec_path + bucketFileName;
if (file.exists()) { File file = new File(pdfUrl);
JSONObject jsonObjectUpload = RestUtil.fileUpload(file); if (file.exists()) {
String file_url = jsonObjectUpload.getString("fileUrl"); CtpFileEntity cpFileEntity = new CtpFileEntity();
if (null != jsonObjectUpload && StrUtil.isNotEmpty(file_url)) { cpFileEntity.setFile(file);
String sub_reference = String.valueOf(UUIDLong.longUUID()); cpFileEntity.setDataSourceCode(oa_data_source_code);
pay.setReceipt(sub_reference); JSONObject jsonObjectUpload = RestUtil.fileUpload(file,"8000240005");
//更新表单的电子回单值 String file_url = jsonObjectUpload.getString("fileUrl");
paymentService.updateElec(pay); if (null != jsonObjectUpload && StrUtil.isNotEmpty(file_url)) {
//保存附件关系 String sub_reference = String.valueOf(UUIDLong.longUUID());
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity(); pay.setReceipt(sub_reference);
ctpAttachmentEntity.setFile_url(file_url); //更新表单的电子回单值
ctpAttachmentService.saveAttachment(file_url, pay.getSummaryId(), sub_reference); paymentService.updateElec(pay);
//保存附件关系
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity();
ctpAttachmentEntity.setFile_url(file_url);
ctpAttachmentService.saveAttachment(file_url, pay.getSummaryId(), sub_reference);
}
//删除本地临时文件
file.delete();
} }
//删除本地临时文件
file.delete();
} }
}catch (Exception e){
logger.error("电子回单查询出错",e);
} }
} }
} }