提交内容:BIP收款处理代码修改

备注:BIP收款处理代码修改
提交人:邹江涛
This commit is contained in:
zoujiangtao 2025-01-06 14:54:34 +08:00
parent 16f50e4613
commit 575ccf54c7
5 changed files with 66 additions and 19 deletions

View File

@ -14,6 +14,9 @@ import kd.bos.dataentity.resource.ResManager;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.MainEntityType;
import kd.bos.exception.KDBizException;
import kd.bos.fileservice.FileItem;
import kd.bos.fileservice.FileService;
import kd.bos.fileservice.FileServiceFactory;
import kd.bos.form.IFormView;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
@ -25,11 +28,11 @@ import kd.bos.orm.query.QFilter;
import kd.bos.print.core.service.PrtAttach;
import kd.bos.print.matchtpl.MatcherTpl;
import kd.bos.print.matchtpl.ViewType;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.MetadataServiceHelper;
import kd.bos.servicehelper.PrintServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.print.service.BosPrintServiceHelper;
import kd.bos.servicehelper.*;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.servicehelper.print.NotePrintService;
import kd.bos.util.FileNameUtils;
import kd.tmc.bei.business.ocr.impl.ScanServiceImpl;
import kd.tmc.bei.business.ocr.invoke.ScanSystemFactory;
import kd.tmc.bei.common.helper.BeiHelper;
@ -43,6 +46,9 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@ -294,15 +300,15 @@ public class ApiService {
// 电子回单关联标记
String receiptno = dynamic.getString("receiptno");
DynamicObject[] loaded = BusinessDataServiceHelper.load("bei_elecreceipt",
"id,billno,shkd_pushstatus,fileserverurl,bizdate,oppbankname,description,company,oppbanknumber," +
"detaildatetime,accountbank,amount,use,debitamount,creditamount,detailid,uploadfilename," +
"shkd_businessnumber,shkd_businessid,shkd_businessname,receiptno"
"id,billno,shkd_pushstatus,fileserverurl,bizdate,oppbankname,description,company," +
"oppbanknumber,detaildatetime,accountbank,amount,use,debitamount,creditamount,detailid," +
"uploadfilename,shkd_businessnumber,shkd_businessid,shkd_businessname,filepath"
, new QFilter("receiptno", QCP.equals, receiptno).toArray());
String slipsJson = paymentSlipsJson(loaded[0], "BIP", dynamicObjects, null);
if (slipsJson.contains("成功")) {
result = "推送 → 银行收付处理 → 成功\n推送 → 电子回单 → 成功";
result = "推送 → 银行收付处理 → 成功\n推送 → 电子回单 → 成功\n推送 → 电子回单附件 → 成功)";
} else {
result = "推送 → 银行收付处理 → 成功\n推送 → 电子回单 → 失败";
result = "推送 → 银行收付处理 → 成功\n推送 → 电子回单 → 失败\n推送 → 电子回单附件 → 失败)";
}
} else {
@ -355,14 +361,18 @@ public class ApiService {
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, dynamic.getPkValue())});
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
Path path = Paths.get(dynamic.getString("filepath"));
String upfileName = path.getFileName().toString();
logger.info("电子回单查询 → BIP推送接口 → 获取pdf地址{}", pdfUrl);
Map<String, Object> hashMap = new HashMap<>();
hashMap.put("bankpdf", attachmentBase64(pdfUrl));
hashMap.put("fileName", dynamic.getString("uploadfilename"));
hashMap.put("fileName", upfileName);
hashMap.put("id", jsonObject.getJSONArray("data").get(0).toString());
hashMap.put("receiptno", dynamic.getString("billno"));
String attachmentRequestBody = getAttachmentRequestBody(hashMap);
String pushResult = pushBill(token, "https://biptestctny.invest.com.cn:8002/iuap-api-auth//yonbip/ctm/bank/tran/update", attachmentRequestBody);
logger.info("电子回单查询 → BIP推送附件接口 → \n推送数据{}\n请求返回结果{}", attachmentRequestBody, pushResult);
logger.info("电子回单查询 → BIP推送附件接口 → 请求返回结果:\n{}", pushResult);
result = "推送 → 电子回单查询 → 成功";
} else {
logger.info("电子回单查询 → BIP推送接口 → 失败\n失败单据编号{}\n失败请求体{}\n推送失败接口返回数据{}",
@ -988,4 +998,34 @@ public class ApiService {
}
return base64;
}
/**
* 确保目录存在如果不存在则创建
*
* @param directoryPath 目录路径
* @throws IOException 如果发生 I/O 错误
*/
public static void ensureDirectoryExists(String directoryPath) throws IOException {
Path directory = Paths.get(directoryPath);
if (!Files.exists(directory)) {
Files.createDirectories(directory);
}
}
/**
* InputStream 下载为文件
*
* @param inputStream 输入流
* @param filePath 文件保存路径
* @throws IOException 如果发生 I/O 错误
*/
public static void downloadFile(InputStream inputStream, String filePath) throws IOException {
try (FileOutputStream outputStream = new FileOutputStream(filePath)) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
}
}
}

View File

@ -75,9 +75,6 @@ public class InfoSecService extends AbstractCAService {
result.setSuccess(false);
result.setMessage("验签失败:" + e.getMessage());
}
return result;
}
}

View File

@ -109,7 +109,7 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
DynamicObject[] objects4 = BusinessDataServiceHelper.load("bei_elecreceipt",
"id,billno,shkd_pushstatus,fileserverurl,bizdate,oppbankname,description,company,oppbanknumber," +
"detaildatetime,accountbank,amount,use,debitamount,creditamount,detailid,uploadfilename," +
"shkd_businessnumber,shkd_businessid,shkd_businessname"
"shkd_businessnumber,shkd_businessid,shkd_businessname,filepath"
, new QFilter("billno", QCP.equals, billNumber).toArray());
billObject = objects4[0];
logger.info("获取银企交易明细查询推送对象 → billObject{}", billObject);

View File

@ -26,6 +26,10 @@ public class HitBackOperationServicePlugin extends AbstractOperationServicePlugI
private static final Log logger = LogFactory.getLog(HitBackOperationServicePlugin.class);
/**
* 单据操作前 打回操作
* @param args
*/
@Override
public void beforeExecuteOperationTransaction(BeforeOperationArgs args) {
super.beforeExecuteOperationTransaction(args);

View File

@ -23,6 +23,7 @@ import java.util.List;
*/
public class PushTransdetailOperationServicePlugin extends AbstractOperationServicePlugIn implements Plugin {
private static final Log logger = LogFactory.getLog(PushTransdetailOperationServicePlugin.class);
@Override
public void beforeExecuteOperationTransaction(BeforeOperationArgs args) {
super.beforeExecuteOperationTransaction(args);
@ -32,10 +33,10 @@ public class PushTransdetailOperationServicePlugin extends AbstractOperationServ
Arrays.stream(entities).forEach(dynamicObject -> {
pkValue.add(dynamicObject.getPkValue());
});
DynamicObject[] objects = BusinessDataServiceHelper.load("bei_transdetail_cas", "id," +
"billno,bizdate,oppbank,oppunit,accountbank,description,company,oppbanknumber," +
DynamicObject[] objects = BusinessDataServiceHelper.load("bei_transdetail_cas",
"id,billno,bizdate,oppbank,oppunit,accountbank,description,company,oppbanknumber," +
"bankdetailno,transbalance,description,debitamount,creditamount,shkd_pushstatus," +
"shkd_businessnumber,shkd_businessid,shkd_businessname,receiptno"
"shkd_businessnumber,shkd_businessid,shkd_businessname"
, new QFilter("id", QCP.in, pkValue)
.and("shkd_pushstatus", QCP.not_equals, "已推送").toArray());
if (pkValue.size() != objects.length) {
@ -44,10 +45,15 @@ public class PushTransdetailOperationServicePlugin extends AbstractOperationServ
return;
}
StringBuilder builder = new StringBuilder();
List<DynamicObject> dynamicObjects = new ArrayList<>();
Arrays.stream(objects).forEach(dynamicObject -> {
String result = ApiService.paymentSlipsJson(dynamicObject, "BIP", dynamicObjects, null);
builder.append("推送银行收付处理单据:【").append(dynamicObject.getString("billno")).append("】结果 → ")
.append(ApiService.paymentSlipsJson(dynamicObject, "BIP", dynamicObjects, null))
.append("\n");
});
logger.info("推送银行收付处理单据结果:{}", builder.toString());
SaveServiceHelper.save(dynamicObjects.toArray(new DynamicObject[0]));
}
}