feature: 增加业务字典,根据value反差label接口。

1.增加字典value反差label接口
2.修改任务包列表查询接口,替换提报人id为提报人名称
pull/16/head
shuliYao 1 year ago
parent 611f07687d
commit a151f9047a

@ -59,4 +59,26 @@ public class OcrDictionaryController {
}
return new ResultVo<>(ResultVo.ERROR,"根据field查询不到字典组!");
}
/**
*valuelable
*
*mail.zhangyong@gmail.com
*2024-01-14 10:27:02
**/
@GetMapping("/getLabelByValue")
@ResponseBody
public ResultVo<IPage<OcrDictionary>> getLabelByValue(HttpServletResponse response,
HttpServletRequest request,
@RequestParam(name="field", defaultValue="upName",required = true) String field,
@RequestParam(name="value", defaultValue="",required = true) String value) {
String tenantId = request.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
return ResultVoUtil.error("租户主键不能为空");
}
String result= ocrDictionaryService.queryLabelByValue(field,value,tenantId);
return new ResultVo<>(ResultVo.ERROR,result);
}
}

@ -110,7 +110,11 @@ public class OcrTaskPackageController extends BaseController {
@RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize,
HttpServletRequest req) {
Page<Map<String, Object>> result = ocrTaskPackageService.getPackageList(pageNo, pageSize, packageName);
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
return ResultVoUtil.error("租户主键不能为空");
}
Page<Map<String, Object>> result = ocrTaskPackageService.getPackageList(pageNo, pageSize, packageName,tenantId);
return ResultVoUtil.success(result);
}

@ -20,5 +20,6 @@ import java.util.Map;
@Mapper
public interface OcrTaskPackageMapper extends BaseMapper<OcrTaskPackage> {
Page<Map<String,Object>> getPackageList(Page<Map<String, Object>> page, @Param("packageName") String packageName);
Page<Map<String,Object>> getPackageList(Page<Map<String, Object>> page, @Param("packageName") String packageName,
@Param("tenantId") String tenantId);
}

@ -34,5 +34,5 @@ public interface IOcrTaskPackageService extends IService<OcrTaskPackage> {
* @param packageName
* @return
*/
Page<Map<String, Object>> getPackageList(Integer pageNo, Integer pageSize, String packageName);
Page<Map<String, Object>> getPackageList(Integer pageNo, Integer pageSize, String packageName,String tenantId);
}

@ -2,7 +2,6 @@ package cn.jyjz.xiaoyao.ocr.service;
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseService;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
import liquibase.pro.packaged.L;
/**
*
@ -27,4 +26,14 @@ public interface OcrDictionaryService extends BaseService<OcrDictionary> {
* @return
*/
OcrDictionaryGroup queryGroupByField(String field);
/**
* value lable
*
* @param field
* @param value 1.value(xxx) ,2.value(xxx,xxx)
* @param tenantId
* @return
*/
String queryLabelByValue(String field, String value, String tenantId);
}

@ -1,5 +1,7 @@
package cn.jyjz.xiaoyao.ocr.service.impl;
import cn.hutool.core.util.ArrayUtil;
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseServiceImpl;
import cn.jyjz.xiaoyao.ocr.dataDao.OcrDictionaryDao;
import cn.jyjz.xiaoyao.ocr.dataDao.OcrDictionaryGroupDao;
@ -8,9 +10,12 @@ import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
import cn.jyjz.xiaoyao.ocr.service.OcrDictionaryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
/**
@ -47,4 +52,33 @@ public class OcrDictionaryServiceImpl extends BaseServiceImpl<OcrDictionaryDao,
}
return null;
}
@Override
public String queryLabelByValue(String field, String value, String tenantId) {
if(!StringUtils.isNotBlank(value)){
return null;
}
OcrDictionaryGroup dictionaryGroup = this.queryGroupByField(field);
if(dictionaryGroup==null){
return null;
}
String[] values = value.split(",");
if(values!=null && values.length>0){
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("group_id",dictionaryGroup.getId());
queryWrapper.eq("tenant_id",tenantId);
queryWrapper.in("value",values);
List<OcrDictionary> dictionaries = baseMapper.selectList(queryWrapper);
List<String> result = new ArrayList<>();
if(dictionaries!=null && dictionaries.size()>0){
for (OcrDictionary dictionary: dictionaries) {
result.add(dictionary.getLable());
}
return String.join(",",result);
}
}
return null;
}
}

@ -19,6 +19,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -47,6 +48,8 @@ public class OcrTaskPackageServiceImpl extends ServiceImpl<OcrTaskPackageMapper,
private OcrFieldService fieldService;
@Resource
private UserService userService;
@Resource
private OcrDictionaryService ocrDictionaryService;
@Override
public ResultVo saveTaskPackage(OcrTaskPackageDto ocrTaskPackage) {
@ -65,9 +68,9 @@ public class OcrTaskPackageServiceImpl extends ServiceImpl<OcrTaskPackageMapper,
}
@Override
public Page<Map<String, Object>> getPackageList(Integer pageNo, Integer pageSize, String packageName) {
public Page<Map<String, Object>> getPackageList(Integer pageNo, Integer pageSize, String packageName,String tenantId) {
Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
Page<Map<String, Object>> result = taskPackageMapper.getPackageList(page, packageName);
Page<Map<String, Object>> result = taskPackageMapper.getPackageList(page, packageName,tenantId);
if (CollectionUtils.isNotEmpty(result.getRecords())) {
List<OcrField> list = fieldService.list(new LambdaQueryWrapper<OcrField>().eq(OcrField::getReviewType, 1));
List<Map<String, Object>> records = result.getRecords();
@ -83,7 +86,7 @@ public class OcrTaskPackageServiceImpl extends ServiceImpl<OcrTaskPackageMapper,
map.put(field, "");
}
}
disMapData(map);
disMapData(map,tenantId);
map.putAll(record);
record.putAll(map);
}
@ -92,12 +95,12 @@ public class OcrTaskPackageServiceImpl extends ServiceImpl<OcrTaskPackageMapper,
return result;
}
private void disMapData(Map map) {
Object field1 = map.get("field1");
private void disMapData(Map map,String tenantId) {
Object field1 = map.get("upuserid");
if (ObjectUtils.isNotEmpty(field1)) {
User user = userService.getById(field1.toString());
if (ObjectUtils.isNotEmpty(user)) {
map.put("field1", user.getUsername());
String result = ocrDictionaryService.queryLabelByValue("person",field1.toString(),tenantId);
if (!StringUtils.isEmpty(result)) {
map.put("upuserid", result);
}
}
}

@ -9,9 +9,10 @@
LEFT JOIN ocr_check_duplicate t2 ON t1.check_duplicate_id = t2.id
left join s_user_t t3 on t1.create_by = t3.ID
<where>
t1.tenant_id = #{tenantId}
<if test="packageName != null and packageName != ''">
t1.name like concat('%', #{packageName}, '%')
and t1.name like concat('%', #{packageName}, '%')
</if>
</where>
</select>
</mapper>
</mapper>

Loading…
Cancel
Save