Commit f220d165 authored by liufan's avatar liufan

优化:设备列表查询,根据机构筛选

parent deb25b37
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
...@@ -12,17 +13,13 @@ import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum; ...@@ -12,17 +13,13 @@ import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.jg.biz.service.*; import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgConstructionInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgInspectionDetectionInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgMainPartsDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgMaintenanceRecordInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgProtectionDevicesDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgRegisterInfoDto; import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgRegisterInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.lucene.queryparser.classic.QueryParser; import org.apache.lucene.queryparser.classic.QueryParser;
...@@ -30,7 +27,6 @@ import org.elasticsearch.action.search.SearchRequest; ...@@ -30,7 +27,6 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.recycler.Recycler;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
...@@ -69,13 +65,6 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -69,13 +65,6 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private static final String EQUDEFINE = "EQU_DEFINE"; private static final String EQUDEFINE = "EQU_DEFINE";
private static final String EQUDEFINECODE = "EQU_DEFINE_CODE"; private static final String EQUDEFINECODE = "EQU_DEFINE_CODE";
/**
* levlel=company,是企业,如果不是都是监管单位,
* * 在接口中查询当前登录人所属单位是监管单位还是企业。
* * 如果为监管单位添加监管机构查询参数(ORG_BRANCH_CODE);
* * 如果为企业添加使用单位查询参数(USE_UNIT_CREDIT_CODE)
*/
private static final String LEVEL = "company";
// 新增修改标识 // 新增修改标识
private static final String OPERATESAVE = "save"; private static final String OPERATESAVE = "save";
private static final String OPERATEEDIT = "edit"; private static final String OPERATEEDIT = "edit";
...@@ -123,6 +112,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -123,6 +112,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired @Autowired
private SuperviseInfoMapper superviseInfoMapper; private SuperviseInfoMapper superviseInfoMapper;
/** /**
* 设备注册信息 * 设备注册信息
* *
...@@ -541,53 +531,32 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -541,53 +531,32 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
builder.trackTotalHits(true); builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//获取当前登录人单位类型
JSONObject company = getCompanyType();
if (ValidationUtil.isEmpty(company)) {
result.setRecords(new ArrayList<>());
result.setTotal(0);
return result;
}
String companyCode = company.getString("companyCode").contains("_") ?
company.getString("companyCode").split("_")[1] : company.getString("companyCode");
String type = company.getString("companyType");
if (ValidationUtil.isEmpty(type) || ValidationUtil.isEmpty(companyCode)) {
result.setRecords(new ArrayList<>());
result.setTotal(0);
return result;
}
//根据当前登录人查询 //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) { if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString()); map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
} }
//获取当前登录人单位类型
List<JSONObject> companyType = getCompanyType();
if (!ValidationUtil.isEmpty(companyType)) {
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
String companyCode = object.getString("companyCode").contains("_") ?
object.getString("companyCode").split("_")[1] : object.getString("companyCode");
String type = object.getString("companyType");
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "使用单位")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) { // 根据当前登录用户类型及管辖机构筛选条件添加对应参数
BoolQueryBuilder query = QueryBuilders.boolQuery(); if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "使用单位")) {
String test = QueryParser.escape(map.getString("ORG_BRANCH_CODE")); map.put("USE_UNIT_CREDIT_CODE", companyCode);
query.must(QueryBuilders.matchPhrasePrefixQuery("ORG_BRANCH_CODE", test)); } else if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "安装改造维修单位")) {
boolMust.must(query); map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
} else {
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
String paramCode = map.getString("ORG_BRANCH_CODE");
if (paramCode.contains(code)) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("ORG_BRANCH_CODE"));
query.must(QueryBuilders.matchPhrasePrefixQuery("ORG_BRANCH_CODE", test));
boolMust.must(query);
} else {
return result;
}
} else {
//监管单位
map.put("ORG_BRANCH_CODE", code);
}
}
}
} }
// 默认条件【STATUS==="" || null】 // 默认条件【STATUS==="" || null】
...@@ -732,23 +701,22 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -732,23 +701,22 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
* *
* @return * @return
*/ */
public List<JSONObject> getCompanyType() { public JSONObject getCompanyType() {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
List<CompanyModel> companys = reginParams.getUserModel().getCompanys(); CompanyBo company = reginParams.getCompany();
List<JSONObject> objectList = new ArrayList<>(); JSONObject object = new JSONObject();
if (!ValidationUtil.isEmpty(companys)) { if (!ValidationUtil.isEmpty(company)) {
for (CompanyModel company : companys) { object.put("level", company.getLevel());
JSONObject object = new JSONObject(); object.put("orgCode", company.getOrgCode());
object.put("level", company.getLevel()); object.put("companyCode", company.getCompanyCode());
object.put("orgCode", company.getOrgCode()); CompanyModel result = Privilege.companyClient.queryByCompanyCode(company.getCompanyCode()).getResult();
object.put("companyCode", company.getCompanyCode()); if(!ValidationUtil.isEmpty(result)){
object.put("companyType", company.getCompanyType()); object.put("companyType", result.getCompanyType());
objectList.add(object);
} }
} }
return objectList; return object;
} }
private String batchSubmitOrUpdate(Map<String, Object> map) { private String batchSubmitOrUpdate(Map<String, Object> map) {
......
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