|
|
|
@ -1,8 +1,13 @@
|
|
|
|
|
package cn.jyjz.xiaoyao.ocr.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.jyjz.flowable.service.IFlowTaskService;
|
|
|
|
|
import cn.jyjz.flowable.utils.PageUtils;
|
|
|
|
|
import cn.jyjz.xiaoyao.admin.dataobject.User;
|
|
|
|
|
import cn.jyjz.xiaoyao.admin.service.UserService;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.service.UserTokenService;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.requestFormat.SearchQuery;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.util.requestFormat.SearchQueryUtil;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.vo.ResultVo;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.base.vo.UserToken;
|
|
|
|
@ -10,8 +15,11 @@ import cn.jyjz.xiaoyao.common.redis.cache.ICacheManager;
|
|
|
|
|
import cn.jyjz.xiaoyao.common.redis.cache.constants.CacheConstants;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataobject.OcrTaskchildPictureAppro;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.IOcrSearchHistoryService;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -20,6 +28,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import cn.jyjz.xiaoyao.ocr.dataDao.OcrSearchHistoryMapper;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.ServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -43,6 +53,13 @@ public class OcrSearchHistoryServiceImpl extends ServiceImpl<OcrSearchHistoryMap
|
|
|
|
|
@Resource
|
|
|
|
|
private OcrPictureService ocrPictureService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IFlowTaskService flowTaskService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<Object, List<Map<String,String>>> selectsearch(String search, String assignee, String userId, String tenantId) {
|
|
|
|
|
|
|
|
|
@ -65,50 +82,67 @@ public class OcrSearchHistoryServiceImpl extends ServiceImpl<OcrSearchHistoryMap
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResultVo toolscount(String tenantid,String userId) {
|
|
|
|
|
public ResultVo toolscount(String tenantid, String userId, HttpServletRequest request) {
|
|
|
|
|
ResultVo<Map<String, Integer>> resultVo = null;
|
|
|
|
|
|
|
|
|
|
//系统中记录的ai统计租户id
|
|
|
|
|
String counttenantid = iCacheManager.get(CacheConstants.TOOLSCOUNT_TENANTID_MODEL_NAME,tenantid+"_"+userId);
|
|
|
|
|
try {
|
|
|
|
|
//系统中记录的ai统计租户id
|
|
|
|
|
String counttenantid = iCacheManager.get(CacheConstants.TOOLSCOUNT_TENANTID_MODEL_NAME,tenantid+"_"+userId);
|
|
|
|
|
// if(!StringUtils.isBlank(counttenantid)){
|
|
|
|
|
// return ResultVoUtil.error("true");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//用户登录信息写入缓存
|
|
|
|
|
iCacheManager.put(CacheConstants.TOOLSCOUNT_TENANTID_MODEL_NAME,tenantid+"_"+userId,"true",CacheConstants.TOOLSCOUNT_TENANTID_CACHE_TIME);
|
|
|
|
|
//用户登录信息写入缓存
|
|
|
|
|
iCacheManager.put(CacheConstants.TOOLSCOUNT_TENANTID_MODEL_NAME,tenantid+"_"+userId,"true",CacheConstants.TOOLSCOUNT_TENANTID_CACHE_TIME);
|
|
|
|
|
|
|
|
|
|
SearchQuery searchQuery = this.getParametersStartingWithToSearchJson(request, "search_");
|
|
|
|
|
String taskName = request.getParameter("keyword");
|
|
|
|
|
if (StringUtils.isNotBlank(taskName)) {
|
|
|
|
|
searchQuery.addLike("fromtaskname", taskName);
|
|
|
|
|
}
|
|
|
|
|
User user = this.userService.getSessionUser(request);
|
|
|
|
|
PageUtils pageUtils = new PageUtils();
|
|
|
|
|
pageUtils.setPageSize(9999);
|
|
|
|
|
pageUtils.setCurrPage(1);
|
|
|
|
|
List<OcrTaskchildPictureAppro> ocrTaskchildPictureApproList = flowTaskService.getMyProcessInstancesNew(user, tenantid, searchQuery.getQuery(), pageUtils);
|
|
|
|
|
resultVo = new ResultVo<>();
|
|
|
|
|
int pendingApprovalCount = 0; // 待审批的数量
|
|
|
|
|
int approvedCount = 0; // 通过的数量
|
|
|
|
|
int notGoCount = 0; // 不通过的数量
|
|
|
|
|
for (OcrTaskchildPictureAppro ocrTaskchildPictureAppro : ocrTaskchildPictureApproList) {
|
|
|
|
|
if (ocrTaskchildPictureAppro.getStatshis() != null) {
|
|
|
|
|
switch (ocrTaskchildPictureAppro.getStatshis()) {
|
|
|
|
|
case 1:
|
|
|
|
|
pendingApprovalCount++;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
approvedCount++;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
notGoCount++;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//暂定,后期修改
|
|
|
|
|
pendingApprovalCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<Object, Object> toolscount = ocrsearchhistorymapper.toolscount(userId);
|
|
|
|
|
return ResultVoUtil.success(toolscount);
|
|
|
|
|
Map<String, Integer> counts = new HashMap<>();
|
|
|
|
|
counts.put("total", approvedCount + pendingApprovalCount + notGoCount);
|
|
|
|
|
counts.put("treat", pendingApprovalCount);
|
|
|
|
|
counts.put("approvedCount", approvedCount);
|
|
|
|
|
resultVo.setCode("OK");
|
|
|
|
|
resultVo.setMessage("成功");
|
|
|
|
|
resultVo.setData(counts);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return resultVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public Map<Object, Object> selectaisp(String userid,String id) {
|
|
|
|
|
// Map<Object, Object> selectaisp = ocrsearchhistorymapper.selectaisp(id);
|
|
|
|
|
// if(null==selectaisp){
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// String selectaiuser = ocrsearchhistorymapper.selectaiuser(userid);
|
|
|
|
|
//
|
|
|
|
|
// String[] cps = selectaisp.get("pictureresult").toString().split(",");
|
|
|
|
|
//
|
|
|
|
|
// List<OcrPicture> saveList = new ArrayList<>();
|
|
|
|
|
// int i=0;
|
|
|
|
|
// for (String childpictureid : cps) {
|
|
|
|
|
// if (childpictureid.equals("100")){
|
|
|
|
|
// i++;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Map<Object,Object> map=new HashMap<>();
|
|
|
|
|
// map.put("taskid",id);
|
|
|
|
|
// map.put("tenantusername",selectaiuser);
|
|
|
|
|
// map.put("packagename",selectaisp.get("packagename"));
|
|
|
|
|
// map.put("tasks","基线任务");
|
|
|
|
|
//// map.put("similarcount",selectaisp.get("similarcount"));
|
|
|
|
|
// map.put("createtime",selectaisp.get("createtime"));
|
|
|
|
|
// map.put("similarComplete",i);
|
|
|
|
|
//
|
|
|
|
|
// return map;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<Object, Object> selectaisp(String userid, String id,Integer nodeType) {
|
|
|
|
@ -185,14 +219,31 @@ public class OcrSearchHistoryServiceImpl extends ServiceImpl<OcrSearchHistoryMap
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List<OcrPicture> collect = Arrays.stream(cps)
|
|
|
|
|
// .map(Long::parseLong)
|
|
|
|
|
// .map(childpictureid -> this.ocrPictureService.selectDtoById(childpictureid))
|
|
|
|
|
// .filter(ocrPicture->ocrPicture.getSimilarityscore() >= 90)
|
|
|
|
|
//
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
return this.ocrPictureService.updateBatchById(saveList) ? ResultVoUtil.success() : ResultVoUtil.error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*取得带相同前缀的Request Parameters, copy from spring WebUtils.
|
|
|
|
|
* @param request 请求对象
|
|
|
|
|
* @param prefix 分割符
|
|
|
|
|
* @return 返回的结果的Parameter名已去除前缀.并且拼装成ligerui形式使用的搜索条件
|
|
|
|
|
*/
|
|
|
|
|
public SearchQuery getParametersStartingWithToSearchJson(ServletRequest request, String prefix) {
|
|
|
|
|
Map<String, Object> params = SearchQueryUtil.getParametersStartingWith(request,prefix);
|
|
|
|
|
|
|
|
|
|
SearchQuery searchQuery = new SearchQuery();
|
|
|
|
|
if(null != params && params.size() > 0){
|
|
|
|
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
|
|
|
|
|
|
|
|
|
JSONObject obj = JSON.parseObject(entry.getValue().toString());
|
|
|
|
|
String value = obj.getString("value");
|
|
|
|
|
if(StringUtils.isNotBlank(value) && !"null".equals(value) && !"undefined".equals(value)){
|
|
|
|
|
obj.put("field",entry.getKey());
|
|
|
|
|
searchQuery.addJsonQuery(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.ocrPictureService.updateBatchById(saveList) ? ResultVoUtil.success() : ResultVoUtil.error();
|
|
|
|
|
return searchQuery;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|