| | |
| | | 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(); |
| | |
| | | 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()); |
| | |
| | | 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"); |
| | | |
| | |
| | | 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; |
| | | } |
| | | } |