|
@@ -30,7 +30,15 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -47,6 +55,9 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
@Autowired
|
|
|
private YDClient ydClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private YDConf ydConf;
|
|
|
+
|
|
|
@Autowired
|
|
|
private DDConf ddConf;
|
|
|
|
|
@@ -62,6 +73,9 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
@Value("${aliwork.accessKeySecret}")
|
|
|
private String accessKeySecret;
|
|
|
|
|
|
+ @Value("${ocr.filePath}")
|
|
|
+ private String filePath;
|
|
|
+
|
|
|
//审批实例url前缀(卡倍亿)
|
|
|
private static final String PROC_INST_PREFIX_URL = "https://aflow.dingtalk.com/dingtalk/web/query/pchomepage.htm?from=oflow&op=true&corpid=dingc3a744cb591a7346f2c783f7214b6d69#/plainapproval?procInstId=";
|
|
|
//宜搭-关联数据(卡倍亿)
|
|
@@ -318,8 +332,9 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
.formInstId(formInstId)
|
|
|
.build(), YDConf.FORM_QUERY.retrieve_id);
|
|
|
Map formData = ddrNew.getFormData();
|
|
|
- //审核人
|
|
|
- List<String> reviewerUserIds = (List<String>) formData.get("employeeField_m061zye5_id");
|
|
|
+
|
|
|
+ List<String> reviewerUserIds = (List<String>) formData.get("employeeField_m061zye5_id");//审核人
|
|
|
+ String area = formData.get("selectField_m0w4kilf").toString();//审核区域
|
|
|
|
|
|
List<Map> details = (List<Map>) formData.get("tableField_m0kqtqoy");
|
|
|
String[] yida = McProject.getYida("1009");
|
|
@@ -337,6 +352,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
//根据userId获取部门id
|
|
|
List<String> rectificationUserIds = (List<String>) detail.get("employeeField_m061zyeq_id");
|
|
|
question.put("employeeField_m061zyeq",rectificationUserIds);//责任整改人
|
|
|
+ question.put("selectField_m0w4kilf",area);//审核区域
|
|
|
|
|
|
Map body2 = new HashMap<>();
|
|
|
body2.put("userid", rectificationUserIds.get(0));
|
|
@@ -364,17 +380,70 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public McR ocr() {
|
|
|
+ public McR ocr(String downloadUrl,String name,String type) {
|
|
|
+ MDC.put("MDC_KEY_PID","1009");
|
|
|
+
|
|
|
try {
|
|
|
- String content = RecognizeAllText.recognizeText("C:\\Users\\EDY\\Desktop\\3.jpg","Table",accessKeyId,accessKeySecret);
|
|
|
+ String content = RecognizeAllText.recognizeText("C:\\Users\\EDY\\Desktop\\4.png", type, accessKeyId, accessKeySecret);
|
|
|
return McR.success(content);
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println(e.getMessage());
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("识别失败:{}" + e.getMessage());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //下载宜搭附件
|
|
|
+ /*try {
|
|
|
+ String[] yida = McProject.getYida("1009");
|
|
|
+ downloadFile(downloadUrl,filePath + name,yida[0],yida[1]);
|
|
|
+ log.info("文件下载成功!");
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("文件下载失败:{}" + e.getMessage());
|
|
|
+ }
|
|
|
+ //ocr识别
|
|
|
+ try {
|
|
|
+ String content = RecognizeAllText.recognizeText(filePath + name, type, accessKeyId, accessKeySecret);
|
|
|
+ return McR.success(content);
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("识别失败:{}" + e.getMessage());
|
|
|
+ }*/
|
|
|
return McR.errorUnknown("识别失败!");
|
|
|
}
|
|
|
|
|
|
+ public void downloadFile(String fileURL, String savePath,String appType,String systemToken) throws IOException {
|
|
|
+ //若是宜搭附件url 则需获得附件临时免登地址
|
|
|
+ Map<String,Object> param = new HashMap<>();
|
|
|
+ param.put("systemToken",systemToken);
|
|
|
+ param.put("userId",ddConf.getOperator());
|
|
|
+ param.put("fileUrl",fileURL);
|
|
|
+ fileURL = ((DDR_New) UtilHttp.doGet("https://api.dingtalk.com/v1.0/yida/apps/temporaryUrls/" + appType, ddClient.initTokenHeader(), param, DDR_New.class)).getResult().toString();
|
|
|
+
|
|
|
+ URL url = new URL(fileURL);
|
|
|
+ HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
|
|
|
+ int responseCode = httpConn.getResponseCode();
|
|
|
+
|
|
|
+ // 检查HTTP响应代码是否为200
|
|
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
+ InputStream inputStream = httpConn.getInputStream();
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(savePath);
|
|
|
+
|
|
|
+ byte[] buffer = new byte[4096];
|
|
|
+ int bytesRead = -1;
|
|
|
+
|
|
|
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+
|
|
|
+ outputStream.close();
|
|
|
+ inputStream.close();
|
|
|
+ } else {
|
|
|
+ System.out.println("无法下载文件。HTTP响应代码: " + responseCode);
|
|
|
+ }
|
|
|
+ httpConn.disconnect();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public McR addPlanApproval(Map map) {
|
|
|
MDC.put("MDC_KEY_PID","1009");
|
|
@@ -459,6 +528,7 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
|
//更新审核计划下次发起审批时间及上次发起审批时间
|
|
|
formData.put("dateField_m0nbpasw", lastTime);
|
|
|
formData.put("dateField_m0nbpasq", nextDate);
|
|
|
+ formData.put("employeeField_m061zye5",reviewerUserIds);
|
|
|
ydClient.operateData(YDParam.builder()
|
|
|
.formInstId(formInstId)
|
|
|
.updateFormDataJson(JSON.toJSONString(formData))
|