master
周文涛 2 years ago
parent f15fa61da5
commit bbf8824bf5

@ -327,8 +327,8 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
return super.importExcel(request, response, OcrIdentify.class);
}
@RequestMapping(value = "/pushNotice")
@ApiOperation(value = "上报通知给无量云")
@PostMapping(value = "/pushNotice")
public Result<?> pushNotice(@RequestParam(name = "ids", required = true) String ids){
List<OcrIdentify> ocrIdentifyList = ocrIdentifyService.listByIds(Arrays.asList(ids.split(",")));
if (ocrIdentifyList==null|| ocrIdentifyList.size()==0) {
@ -340,7 +340,9 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
for (OcrIdentify ocrIdentify : ocrIdentifyList) {
ocrIdentify.setNoticeStatus("1");
}
ocrIdentifyService.updateBatchById(ocrIdentifyList);
for (String identifyId : Arrays.asList(ids.split(","))) {
ocrIdentifyService.callbackWly(identifyId);
}
return Result.OK("操作成功");
}
}

@ -129,8 +129,11 @@ public class OcrIdentify implements Serializable {
@TableField(exist = false)
private String taskType_dictText;
@ApiModelProperty(value = "任务失败描述信息")
private String errorMsg;
/**任务匹配结果*/
@ApiModelProperty(value = "任务匹配结果 0匹配失败,1匹配成功 -1匹配中")
@TableField(exist = false)
private String taskResult="-1";
/*匹配结果信息*/
private String taskResultInfo;
}

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
@ -93,4 +94,9 @@ public class OcrIdentifyDetail implements Serializable {
@TableField(exist = false)
@ApiModelProperty(value = "图片预览地址")
private String imagePreviewUrl;
///===========================================
/*字段校验成功对象.*//*
@TableField(exist = false)
private Map<String, Boolean> fieldRightMap;*/
}

@ -3,6 +3,8 @@ package org.jeecg.modules.ocr.service;
import org.jeecg.modules.ocr.entity.OcrIdentifyDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: ocr
* @Author: jeecg-boot
@ -10,5 +12,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @Version: V1.0
*/
public interface IOcrIdentifyDetailService extends IService<OcrIdentifyDetail> {
/**
* id,identifyId
* @param identifyId
* @return
*/
List<OcrIdentifyDetail> listByIdentifyId(String identifyId);
}

@ -23,6 +23,7 @@ public interface IOcrIdentifyService extends IService<OcrIdentify> {
*
* @param ocrIdentifyId
*/
@Async
public void callbackWly(String ocrIdentifyId);

@ -1,5 +1,9 @@
package org.jeecg.modules.ocr.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.ocr.entity.OcrIdentifyDetail;
import org.jeecg.modules.ocr.mapper.OcrIdentifyDetailMapper;
import org.jeecg.modules.ocr.service.IOcrIdentifyDetailService;
@ -7,6 +11,9 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Description: ocr
* @Author: jeecg-boot
@ -16,4 +23,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class OcrIdentifyDetailServiceImpl extends ServiceImpl<OcrIdentifyDetailMapper, OcrIdentifyDetail> implements IOcrIdentifyDetailService {
@Override
public List<OcrIdentifyDetail> listByIdentifyId(String identifyId) {
List<OcrIdentifyDetail> list = super.list(new LambdaQueryWrapper<OcrIdentifyDetail>().eq(OcrIdentifyDetail::getIdentifyId, identifyId));
return list;
}
}

@ -243,9 +243,51 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
updateWrapper.eq(OcrIdentify::getId, id);
updateWrapper.set(OcrIdentify::getEndTime, new Date());
updateWrapper.set(OcrIdentify::getStatus, "1");
/*获取 明细 的成功或失败.*/
List<OcrIdentifyDetail> identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(id);
if(true) {
if (identifyDetailList != null && identifyDetailList.size() > 0) {
Map<String, OcrResult> fieldRightMap = new LinkedHashMap<>();
String tag = null;
boolean ruleValidation = false;
/////明细中,如果有字段成功的,则会覆盖其他明细的匹配失败的情况,如果全都是失败的,会获取第一次失败的.
for (OcrIdentifyDetail ocrIdentifyDetail : identifyDetailList) {
String dataStructured = ocrIdentifyDetail.getDataStructured();
if (org.apache.commons.lang.StringUtils.isNotBlank(dataStructured)) {
JSONArray jsonArray = JSONObject.parseArray(dataStructured);
List<OcrResult> resultList = jsonArray.toJavaList(OcrResult.class);
for (OcrResult result : resultList) {
tag = result.getTag();
ruleValidation = result.getRuleValidation();
OcrResult lastResult = fieldRightMap.get(tag);
if (ruleValidation) {
fieldRightMap.put(tag, result);
} else if (lastResult == null && !lastResult.getRuleValidation()) {
fieldRightMap.put(tag, result);
}
}
}
}
//如果明细合并一起,都是成功,则主任务 匹配成功, 否则匹配失败
List<OcrResult> errorResults = fieldRightMap.values().stream().filter(f -> !f.getRuleValidation()).collect(Collectors.toList());
List<OcrResult> ocrResults = fieldRightMap.values().stream().collect(Collectors.toList());
String taskResultInfo = JSONArray.toJSONString(ocrResults);
updateWrapper.set(OcrIdentify::getTaskResultInfo,taskResultInfo);
if (errorResults.size() > 0) {
//匹配失败.
String errorMsg = errorResults.stream().map(e -> e.getFailureReason()).collect(Collectors.joining(";"));
updateWrapper.set(OcrIdentify::getErrorMsg, errorMsg);
updateWrapper.set(OcrIdentify::getTaskResult, 0);
} else {
//匹配成功.
updateWrapper.set(OcrIdentify::getTaskResult, 1);
}
}
}
super.update(updateWrapper);
this.callbackWly(id);
System.out.println("已通过一条!");
/*System.out.println("已通过一条!");*/
}
@Override

Loading…
Cancel
Save