Commit fbc03d60 authored by tianyiming's avatar tianyiming

refactor(biz): 修改人员类型查询接口参数和逻辑

parent bf2cdc70
......@@ -116,10 +116,10 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryRYLX")
@ApiOperation(httpMethod = "GET", value = "查询人员类型", notes = "查询人员类型")
public ResponseModel<JSONArray> queryRYLX(@RequestParam(required = false) String type) {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryRYLX(type));
@PostMapping(value = "/select/queryRYLX")
@ApiOperation(httpMethod = "POST", value = "查询人员类型", notes = "查询人员类型")
public ResponseModel<JSONArray> queryRYLX(@RequestBody JSONObject params) {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryRYLX(params));
}
/**
......
......@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.biz.common.annotation.TechnicalParameter;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
......@@ -85,6 +87,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
@Value("classpath:/json/equipCategory.json")
private Resource equipCategory;
@Value("classpath:/json/unitTypeLimitUserType.json")
private Resource unitTypeLimitUserType;
private final TzsCustomFilterMapper tzsCustomFilterMapper;
private final DataDictionaryServiceImpl dataDictionaryService;
private final EmqKeeper emqKeeper;
......@@ -496,7 +502,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
if (filterType.equals("advanced")) {
filterParams.forEach((k, v) -> {
if (v instanceof JSONArray) {
if (!((JSONArray) v).contains("all")) {
if (!((JSONArray) v).contains("all") && ((JSONArray) v).size() > 0) {
String field = k;
if (k.equals("unitCategory")) {
if (!ObjectUtils.isEmpty(v) && ((JSONArray) v).size() == 1) {
......@@ -660,7 +666,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String orgCode = filter.getString("orgCode");
boolMust.must(QueryBuilders.prefixQuery("ORG_BRANCH_CODE", orgCode));
JSONObject filterParams = null;
JSONObject filterParams = new JSONObject();
// 筛选
if (!ObjectUtils.isEmpty(filter.get("filterParams"))) {
filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
......@@ -886,6 +892,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private BigDecimal getPipeLength(BoolQueryBuilder boolMust, SearchSourceBuilder builder) {
SearchRequest request = new SearchRequest();
BigDecimal pipeLong = BigDecimal.ZERO;
// boolMust.must(QueryBuilders.termQuery("EQU_LIST_CODE", "8000"));
builder.query(boolMust);
builder.from(0);
builder.size(10000000);
......@@ -1771,31 +1778,62 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
public JSONArray queryRYLX(String type) {
public JSONArray queryRYLX(JSONObject params) {
JSONArray result = new JSONArray();
if (ValidationUtil.isEmpty(type)) {
List<String> typeList = new ArrayList<>(Arrays.asList(
"QYRYGW",
"QYRYGW-SYDW",
"QYRYGW-SCDW",
"QYRYGW-INSTALL",
"QYRYGW-INSPECTION"
));
result = deployDictionary(dataDictionaryService.lambdaQuery()
.select(DataDictionary::getName, DataDictionary::getCode)
.eq(DataDictionary::getIsDelete, false)
.isNull(DataDictionary::getParent)
.in(DataDictionary::getType, typeList)
.list());
} else {
JSONArray type = params.containsKey("type") ? JSONObject.parseArray(JSONObject.toJSONString(params.get("type"))) : null;
String subType = params.containsKey("subType") ? params.get("subType").toString() : null;
List<String> typeList = new ArrayList<>(Arrays.asList(
"QYRYGW",
"QYRYGW-SYDW",
"QYRYGW-SCDW",
"QYRYGW-INSTALL",
"QYRYGW-INSPECTION"
));
List<DataDictionary> allPost = dataDictionaryService.lambdaQuery()
.select(DataDictionary::getName, DataDictionary::getCode)
.eq(DataDictionary::getIsDelete, false)
.isNull(DataDictionary::getParent)
.in(DataDictionary::getType, typeList)
.list();
if (subType != null) {
List<DataDictionary> childrenrylx = dataDictionaryService.lambdaQuery()
.in(DataDictionary::getParent, type)
.in(DataDictionary::getParent, subType)
.like(DataDictionary::getType, "QYRYGW")
.orderByAsc(DataDictionary::getSortNum)
.list();
;
result = deployDictionary(childrenrylx);
}
if (type != null) {
try {
ArrayList<String> postDictCodeList = new ArrayList<>();
JsonNode jsonNode = new ObjectMapper().readTree(unitTypeLimitUserType.getInputStream());
type.forEach(unitType -> {
JsonNode companyTypeNode = jsonNode.get(unitType.toString());
if (companyTypeNode != null && companyTypeNode.isObject()) {
Iterator<Map.Entry<String, JsonNode>> fields = companyTypeNode.fields();
while (fields.hasNext()) {
Map.Entry<String, JsonNode> entry = fields.next();
String postCode = entry.getKey();
postDictCodeList.add(postCode); // 主岗位
}
}
});
result = deployDictionary(allPost.stream()
.filter(item -> postDictCodeList.contains(item.getCode()))
.collect(Collectors.toList()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if (subType == null && type == null) {
result = deployDictionary(allPost);
}
return result;
}
......
......@@ -71,7 +71,6 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -82,10 +81,12 @@ import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.io.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......
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