From d3b5c1badd7f652c4d629a97b0c95b06607bb849 Mon Sep 17 00:00:00 2001
From: sinake <sinake1@qq.com>
Date: 星期五, 30 十月 2026 15:52:57 +0800
Subject: [PATCH] 器管回款显示列表内容调整
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceInvoiceController.java | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceInvoiceController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceInvoiceController.java
index f90d12f..f656021 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceInvoiceController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceInvoiceController.java
@@ -20,6 +20,8 @@
import com.ruoyi.web.controller.tool.HttpUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -126,7 +128,7 @@
String base64= Base64.getEncoder().encodeToString( Files.readAllBytes(filePath));
AjaxResult ajax = AjaxResult.success();
- ajax.put("OCRList", aliOCR(base64,0,0));
+ ajax.put("OCRList", aliOCR(base64,"0","0"));
return ajax;
}
@@ -134,7 +136,7 @@
* 閫氱敤涓婁紶璇锋眰
*/
@PostMapping("/uploadOCR")
- public AjaxResult uploadOCR(@RequestParam("file") MultipartFile file, @RequestParam("userId") long userId, @RequestParam("caseId") long caseId) throws Exception {
+ public AjaxResult uploadOCR(@RequestParam("file") MultipartFile file, @RequestParam("userId") String userId, @RequestParam("caseId") String caseId) throws Exception {
try {
// 涓婁紶鏂囦欢璺緞
@@ -166,32 +168,44 @@
String url = url1 + fileName;
String base64= Base64.getEncoder().encodeToString(file.getBytes());
List<Map<String,Object>> lists=aliOCR(base64,userId,caseId);
+ List<ServiceInvoice> invoiceList=new ArrayList<>();
for(Map<String,Object> row : lists){
ServiceInvoice invoice=new ServiceInvoice();
- invoice.setUserId(userId);
- invoice.setCaseId(caseId);
- invoice.setInvoiceType(row.get("type")+"");
+ if(ObjectUtils.isNotEmpty(userId)) {
+ invoice.setUserId(Long.parseLong(userId));
+ }
+ if(ObjectUtils.isNotEmpty(caseId)) {
+ invoice.setCaseId(Long.parseLong(caseId));
+ }
+ invoice.setInvoiceType(row.get("鍙戠エ鍒嗙被")+"");
invoice.setInvoiceNo(row.get("鍙戠エ鍙风爜")+"");
invoice.setOccurDate(row.get("寮�绁ㄦ棩鏈�")+"");
- invoice.setInvoiceAmount(row.get("鍙戠エ閲戦")+"");
+ invoice.setInvoiceAmount(row.get("閲戦")+"");
invoice.setSellerName(row.get("鍙楃エ鏂瑰悕绉�")+"");
invoice.setInvoiceUrl(url);
- invoice.setInvoiceName(newFilename);
+ String invoiceName=newFilename.isEmpty() ? filename : newFilename;
+ invoice.setInvoiceName(invoiceName.split(".")[0]);
invoice.setExtContent(JSON.toJSONString(row));
+ invoice.setCreateBy(userId);
+ invoice.setCreateTime(DateUtils.getNowDate());
+ invoice.setUpdateBy(userId);
+ invoice.setUpdateTime(DateUtils.getNowDate());
serviceInvoiceService.save(invoice);
+ invoiceList.add(invoice);
}
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);
ajax.put("OCRList", lists);
+ ajax.put("invoiceList", invoiceList);
return ajax;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
- public List<Map<String,Object>> aliOCR(String base64,long userId,long caseId) {
+ public List<Map<String,Object>> aliOCR(String base64,String userId,String caseId) {
String host = "https://mixedmulti.market.alicloudapi.com";
String path = "/ocrservice/mixedMultiInvoice";
String method = "POST";
@@ -214,18 +228,18 @@
Map<String,Object> tempList=new HashMap<>();
JSONObject rowObject=(JSONObject)row;
- tempList.put("鍙戠エ鍒嗙被",rowObject.getString("type"));
+
JSONObject result=((JSONObject)rowObject.get("result")).getJSONObject("data");
for(Map.Entry<String, Object> entry : result.entrySet()){
tempList.put(entry.getKey(),entry.getValue());
}
- if(rowObject.getString("type").equals("閾惰鎵垮厬姹囩エ")){
+ if(rowObject.getString("鍙戠エ鍒嗙被").equals("閾惰鎵垮厬姹囩エ")){
BigDecimal totalAmount= ChineseUtils.chineseToNumber(result.getString("绁ㄦ嵁閲戦澶у啓"));
- tempList.put("鍙戠エ閲戦",totalAmount);
+ tempList.put("閲戦",totalAmount);
}
- if(rowObject.getString("type").equals("鐏溅绁�")){
- tempList.put("鍙戠エ閲戦",result.getString("绁ㄤ环"));
+ if(rowObject.getString("鍙戠エ鍒嗙被").equals("鐏溅绁�")){
+ tempList.put("閲戦",result.getString("绁ㄤ环"));
}
lists.add(tempList);
--
Gitblit v1.9.3