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.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.cbs8.dto.req.ElecRequestDTO;
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.util.CBSUtil;
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.seeyon.cbs8.entity.CbsLogEntity;
import com.hzya.frame.seeyon.cbs8.entity.PaymentEntity;
import com.hzya.frame.seeyon.cbs8.service.ICbsLogService;
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.CtpFileEntity;
import com.hzya.frame.seeyon.service.ICtpAttachmentService;
import com.hzya.frame.seeyon.util.RestUtil;
import com.hzya.frame.uuid.UUIDLong;
@ -53,6 +51,8 @@ public class CbsPluginServiceImpl implements ICbsPluginService {
@Value("${cbs8.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);
if (CollectionUtils.isNotEmpty(paymentList)) {
for (PaymentEntity pay : paymentList) {
String payDate = DateUtil.format(DateUtil.parse(pay.getPayDate()), "yyyy-MM-dd");
//查询cbs电子回单
List<ElecResponseDTO> elecResList = cbs8Service.queryElecBill(new ElecRequestDTO(payDate,DateUtil.today(),pay.getReferenceNum()));
if (CollectionUtils.isNotEmpty(elecResList)){
ElecResponseDTO elecResponseDTO = elecResList.get(0);
String bucketFileUrl = elecResponseDTO.getBucketFileUrl();
String bucketFileName = elecResponseDTO.getBucketFileName();
//上传电子回单到OA
HttpUtil.downloadFile(bucketFileUrl, FileUtil.file(elec_path));//附件下载
String pdfUrl = elec_path + bucketFileName;
File file = new File(pdfUrl);
if (file.exists()) {
JSONObject jsonObjectUpload = RestUtil.fileUpload(file);
String file_url = jsonObjectUpload.getString("fileUrl");
if (null != jsonObjectUpload && StrUtil.isNotEmpty(file_url)) {
String sub_reference = String.valueOf(UUIDLong.longUUID());
pay.setReceipt(sub_reference);
//更新表单的电子回单值
paymentService.updateElec(pay);
//保存附件关系
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity();
ctpAttachmentEntity.setFile_url(file_url);
ctpAttachmentService.saveAttachment(file_url, pay.getSummaryId(), sub_reference);
try {
String payDate = DateUtil.format(DateUtil.parse(pay.getPayDate()), "yyyy-MM-dd");
//查询cbs电子回单
List<ElecResponseDTO> elecResList = cbs8Service.queryElecBill(new ElecRequestDTO(payDate,DateUtil.today(),pay.getReferenceNum()));
if (CollectionUtils.isNotEmpty(elecResList)){
ElecResponseDTO elecResponseDTO = elecResList.get(0);
String bucketFileUrl = elecResponseDTO.getBucketFileUrl();
String bucketFileName = elecResponseDTO.getBucketFileName();
//上传电子回单到OA
HttpUtil.downloadFile(bucketFileUrl, FileUtil.file(elec_path));//附件下载
String pdfUrl = elec_path + bucketFileName;
File file = new File(pdfUrl);
if (file.exists()) {
CtpFileEntity cpFileEntity = new CtpFileEntity();
cpFileEntity.setFile(file);
cpFileEntity.setDataSourceCode(oa_data_source_code);
JSONObject jsonObjectUpload = RestUtil.fileUpload(file,"8000240005");
String file_url = jsonObjectUpload.getString("fileUrl");
if (null != jsonObjectUpload && StrUtil.isNotEmpty(file_url)) {
String sub_reference = String.valueOf(UUIDLong.longUUID());
pay.setReceipt(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);
}
}
}