sinake
4 天以前 ee089a8ac4a9d99ef0a0491bbf1d80a2d4fbc393
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceInvoiceController.java
@@ -168,6 +168,7 @@
            String url = url1 + fileName;
            String base64= Base64.getEncoder().encodeToString(file.getBytes());
            List<Map<String,Object>> lists=aliOCR(base64,userId,caseId);
            logger.info(JSON.toJSONString(lists));
            List<ServiceInvoice> invoiceList=new ArrayList<>();
            for(Map<String,Object> row : lists){
                ServiceInvoice invoice=new ServiceInvoice();
@@ -177,14 +178,14 @@
                if(ObjectUtils.isNotEmpty(caseId)) {
                    invoice.setCaseId(Long.parseLong(caseId));
                }
                invoice.setInvoiceType(row.get("发票分类")+"");
                invoice.setInvoiceType(row.get("type")+"");
                invoice.setInvoiceNo(row.get("发票号码")+"");
                invoice.setOccurDate(row.get("开票日期")+"");
                invoice.setInvoiceAmount(row.get("金额")+"");
                invoice.setInvoiceAmount(row.get("发票金额")+"");
                invoice.setSellerName(row.get("受票方名称")+"");
                invoice.setInvoiceUrl(url);
                String invoiceName=newFilename.isEmpty() ? filename : newFilename;
                invoice.setInvoiceName(invoiceName.split(".")[0]);
                invoice.setInvoiceName(invoiceName.substring(0, invoiceName.lastIndexOf(".")));
                invoice.setExtContent(JSON.toJSONString(row));
                invoice.setCreateBy(userId);
                invoice.setCreateTime(DateUtils.getNowDate());
@@ -221,6 +222,7 @@
            HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
            //获取response的body
            String content= EntityUtils.toString(response.getEntity());
            logger.info(content);
            JSONObject jsonContent=JSONObject.parseObject(content);
            JSONArray subMsgs=jsonContent.getJSONArray("subMsgs");
@@ -234,19 +236,20 @@
                for(Map.Entry<String, Object> entry : result.entrySet()){
                    tempList.put(entry.getKey(),entry.getValue());
                }
                if(rowObject.getString("发票分类").equals("银行承兑汇票")){
                if(rowObject.getString("type").equals("银行承兑汇票")){
                    BigDecimal totalAmount= ChineseUtils.chineseToNumber(result.getString("票据金额大写"));
                    tempList.put("金额",totalAmount);
                    tempList.put("发票金额",totalAmount);
                }
                if(rowObject.getString("发票分类").equals("火车票")){
                    tempList.put("金额",result.getString("票价"));
                if(rowObject.getString("type").equals("火车票")){
                    tempList.put("发票金额",result.getString("票价"));
                }
                tempList.put("type",rowObject.getString("type"));
                lists.add(tempList);
            }
            return lists;
        } catch (Exception e) {
            logger.error(e.getMessage());
            return lists;
        }
    }