Commit b87711ce by libin

Merge remote-tracking branch 'origin/master'

parents 2c01377b 7cf273dc
......@@ -11,6 +11,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import sun.misc.BASE64Encoder;
@RestController
@RequestMapping(value="/ocr",produces = "application/json; charset=utf-8")
......@@ -20,6 +23,9 @@ public class OcrController {
@ResponseBody
@PostMapping("/InvoiceOcr")
public JSONObject query(HttpServletRequest request, MultipartFile file) {
DateFormat df2 = DateFormat.getDateTimeInstance();//可以精确到时分秒
Date date = new Date();
System.out.println(df2.format(date)+"开始时间");
byte[] fileByte = null;
try {
fileByte = file.getBytes();
......@@ -31,6 +37,9 @@ public class OcrController {
String voiceBase64= encoder.encode(fileByte);
JSONObject j = new JSONObject();
j.put("msg",ocrjService.getOcr(voiceBase64));
Date date1 = new Date();
DateFormat df3 = DateFormat.getDateTimeInstance();//可以精确到时分秒
System.out.println(df3.format(date1)+"结束时间");
return j;
}
......
......@@ -35,8 +35,8 @@ public class TbStAsjView implements Serializable {
//案事件发生时间_案事件发生结束时间
private java.util.Date asjfssjAsjfsjssj;
//涉案金额
private Double saje;
//损失价值
private Double ssjzrmby;
//案事件发生地点_行政区划代码
private String asjfsddXzqhdm;
......@@ -158,12 +158,12 @@ public class TbStAsjView implements Serializable {
this.asjfssjAsjfsjssj = asjfssjAsjfsjssj;
}
public Double getSaje() {
return saje;
public Double getSsjzrmby() {
return ssjzrmby;
}
public void setSaje(Double saje) {
this.saje = saje;
public void setSsjzrmby(Double ssjzrmby) {
this.ssjzrmby = ssjzrmby;
}
public String getAsjfsddXzqhdm() {
......
......@@ -8,7 +8,17 @@ import com.founder.util.InvoiceOcr;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.text.DateFormat;
import java.util.Date;
import java.util.Map;
/**
* Created by wangxing on 2019/8/14.
......@@ -20,16 +30,31 @@ public class OcrServiceImpl implements OcrService {
@Override
public String getOcr(String encoder) {
InvoiceOcr ac = new InvoiceOcr(orc);
/* InvoiceOcr ac = new InvoiceOcr(orc);
JSONArray arry = new JSONArray();
JSONObject j = new JSONObject();
arry.add(encoder);
j.put("images",arry);
String result = ac.post(j.toJSONString());
String result = ac.post(j.toJSONString());*/
String result= getRestTemplate( encoder);
System.out.println(result);
return result;
}
public String getRestTemplate(String encoder){
HttpHeaders headers = new HttpHeaders();
//设置请求头格式
//Set the request header format
headers.setContentType(MediaType.APPLICATION_JSON);
//构建请求参数
//Build request parameters
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("images", encoder);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);
RestTemplate restTemplate = new RestTemplate();
Map json = restTemplate.postForEntity(orc, request, Map.class).getBody();
String sss= JSONObject.toJSONString(json.get("results"));
return sss;
}
//接口地址
......
......@@ -51,7 +51,8 @@ public class XxcxServiceImpl implements XxcxService {
tbStAsjView.setXxlyms(tbStAsj.getXxlyms());
tbStAsjView.setZczjZxsj(tbStAsj.getZczjZxsj01());
tbStAsjView.setAsjlydm(tbStAsj.getAsjlydm());
tbStAsjView.setSaje(tbStAsj.getSsjzrmby());
tbStAsjView.setSsjzrmby(tbStAsj.getSsjzrmby());
tbStAsjView.setJqbh(tbStAsj.getJjbh());
}
return tbStAsjView;
}
......@@ -81,7 +82,8 @@ public class XxcxServiceImpl implements XxcxService {
tbStAsjView.setXxlyms(tbStAsj.getXxlyms());
tbStAsjView.setZczjZxsj(tbStAsj.getZczjZxsj01());
tbStAsjView.setAsjlydm(tbStAsj.getAsjlydm());
tbStAsjView.setSaje(tbStAsj.getSsjzrmby());
tbStAsjView.setSsjzrmby(tbStAsj.getSsjzrmby());
tbStAsjView.setJqbh(tbStAsj.getJjbh());
}
return tbStAsjView;
}
......
......@@ -24,7 +24,9 @@ jslocation: E:/sysDictJs/common/dict/
ssdw: 140000000000
server:
port: 9061
port: 8762
xxcx:
author: Basic 9b6c45cfcf3a4a629e3ed90fa3e5d058
orc: http://39.99.224.27:8866/predict/chinese_ocr_db_crnn_mobile
orc: http://47.92.223.200:8866/predict/ocr_system
ce: http://39.99.224.27:8866/predict/chinese_ocr_db_crnn_mobile
ce1: http://39.99.224.27:8866/predict/ocr_system
......@@ -47,6 +47,7 @@
var uploadInst = upload.render({
elem: '#test1'
,url: '/ocr/InvoiceOcr' //改成您自己的上传接口
,size: 1024
,before: function(obj){
//预读本地文件示例,不支持ie8
......@@ -63,7 +64,7 @@
//上传成功
$('#demoText2').html(res.msg);
alert(res.msg);
}
,error: function(){
//演示失败状态,并实现重传
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment