Commit f206fb0c authored by hcing's avatar hcing

fix(tzs): 风险报送人员调整

parent ac0a35f2
......@@ -28,7 +28,5 @@ public interface IDataDictionaryService {
List<DataDictionary> getByParent(String parent);
List<DataDictionary> getByTypeAndDesc(String type, String group);
DataDictionary getByExtend(String groupId, String type);
}
......@@ -180,14 +180,6 @@ public class DataDictionaryServiceImpl extends BaseService<DataDictionaryDto, Da
}
@Override
public List<DataDictionary> getByTypeAndDesc(String type, String typeDesc) {
LambdaQueryWrapper<DataDictionary> wrapper = new LambdaQueryWrapper<>();
wrapper.likeRight(DataDictionary::getType,type);
wrapper.likeRight(DataDictionary::getTypeDesc,typeDesc);
return this.list(wrapper);
}
@Override
public DataDictionary getByExtend(String groupId, String type) {
LambdaQueryWrapper<DataDictionary> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DataDictionary::getExtend, groupId);
......
{
"检验检测机构": {
"检验机构": {
"6660": [],
"6667": [],
"66151": [],
......@@ -7,21 +7,34 @@
"6546": [],
"6616": [],
"6761": [],
"6762": []
"6762": [],
"6766": []
},
"检测机构": {
"6660": [],
"6667": [],
"66151": [],
"66152": [],
"6546": [],
"6616": [],
"6761": [],
"6762": [],
"6766": []
},
"设计单位": {
"6660": [],
"6661": [],
"6662": [],
"6619": [],
"6552": [],
"66151": [],
"66152": [],
"6546": [],
"6548": [],
"6550": [],
"6551": [],
"6616": []
"6660": [],
"6661": [],
"6662": [],
"6619": [],
"6552": [],
"66151": [],
"66152": [],
"6546": [],
"6548": [],
"6550": [],
"6551": [],
"6616": [],
"6766": []
},
"制造单位": {
"6660": [],
......@@ -35,7 +48,8 @@
"6548": [],
"6550": [],
"6551": [],
"6616": []
"6616": [],
"6766": []
},
"充装单位": {
"6660": [],
......@@ -46,7 +60,8 @@
"6548": [],
"6616": [],
"6763": [],
"6549": []
"6549": [],
"6766": []
},
"安装改造维修单位": {
"6660": [],
......@@ -58,12 +73,14 @@
"6552": [],
"66151": [],
"66152": [],
"6667": [],
"6546": [],
"6548": [],
"6550": [],
"6551": [],
"6616": [],
"6553": []
"6553": [],
"6766": []
},
"使用单位": {
"6552": ["6713"],
......@@ -72,7 +89,11 @@
"6548": [],
"6616": [],
"6617": [],
"6549": []
"6549": [],
"66151": [],
"66152": [],
"6667": [],
"6766": []
},
"个人主体": {
"6552": ["6713"],
......@@ -81,6 +102,13 @@
"6548": [],
"6616": [],
"6617": [],
"6549": []
"6549": [],
"66151": [],
"66152": [],
"6667": [],
"6766": []
},
"监管机构": {
"6766": []
}
}
......@@ -3,6 +3,10 @@ package com.yeejoin.amos.boot.module.common.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.NestedQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -15,6 +19,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
@Slf4j
@Service
public class TZSCommonServiceImpl {
......@@ -62,11 +68,11 @@ public class TZSCommonServiceImpl {
String licensesStatus = null;
if (esUserInfoJson.containsKey("licenses")) {
// 以下人员类型有资质要求
// 人员类型(newPost):检验人员:66151、检测人员:66152
// 人员类型(newPost):检验人员:66151、检测人员:66152 ,检验检测区域负责人 :6667
// 人员子类型(subPost): 持证人员:6713、持证人员(P):6764、持证人员(R2):6765
String newPost = ObjectUtils.isEmpty(esUserInfoJson.getString("newPost")) ? "" : esUserInfoJson.getString("newPost");
String subPost = ObjectUtils.isEmpty(esUserInfoJson.getString("subPost")) ? "" : esUserInfoJson.getString("subPost");
if (newPost.contains("66151") || newPost.contains("66152") || subPost.contains("6713") || subPost.contains("6764") || subPost.contains("6765")) {
if (newPost.contains("66151") || newPost.contains("66152") || newPost.contains("6667") || subPost.contains("6713") || subPost.contains("6764") || subPost.contains("6765")) {
JSONArray licenses = esUserInfoJson.getJSONArray("licenses");
String overdueStr = licensesStatusMap.get(overdue);
String nearStr = licensesStatusMap.get(near);
......@@ -119,4 +125,119 @@ public class TZSCommonServiceImpl {
}
return licensesStatus;
}
/**
* 需要资质的人员查询构造条件
* 无资质:需要资质但是没有填写
*
* @return
*/
public BoolQueryBuilder getNotLicencesBuilderWithPerson() {
return QueryBuilders.boolQuery()
.should(QueryBuilders.wildcardQuery("newPost", "*66151*"))
.should(QueryBuilders.wildcardQuery("newPost", "*66152*"))
.should(QueryBuilders.wildcardQuery("newPost", "*6667*"))
.should(QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery("newPost", "*6552*"))
.must(QueryBuilders.wildcardQuery("subPost", "*6713*")))
.should(QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery("newPost", "*6763*"))
.should(QueryBuilders.wildcardQuery("subPost", "*6764*"))
.should(QueryBuilders.wildcardQuery("subPost", "*6765*"))
.minimumShouldMatch(1)
)
.minimumShouldMatch(1);
}
/**
* 无资质要求的人员查询构造条件
* 无资质要求:不需要资质
*
* @return
*/
public BoolQueryBuilder getNotNeedLicencesBuilderWithPerson() {
return QueryBuilders.boolQuery()
.mustNot(QueryBuilders.wildcardQuery("newPost", "*66151*"))
.mustNot(QueryBuilders.wildcardQuery("newPost", "*66152*"))
.mustNot(QueryBuilders.wildcardQuery("newPost", "*6667*"))
.mustNot(QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery("newPost", "*6552*"))
.must(QueryBuilders.wildcardQuery("subPost", "*6713*")))
.mustNot(QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery("newPost", "*6763*"))
.should(QueryBuilders.wildcardQuery("subPost", "*6764*"))
.should(QueryBuilders.wildcardQuery("subPost", "*6765*"))
.minimumShouldMatch(1)
);
}
/**
* 人员资质状态查询构造条件
*
* @param boolMust
* @param licensesStatus
* @param path
* @param nestedField
*/
public void buildExpiryDateQueryBuilder(BoolQueryBuilder boolMust, String licensesStatus, String path, String nestedField) {
if (licensesStatus.equals(overdue)) {
// 不需要资质的人员查询构造条件
BoolQueryBuilder notNeedLicensesQueryBuilder = this.getNotLicencesBuilderWithPerson();
boolMust.must(notNeedLicensesQueryBuilder);
// 超期:小于当前日期
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.rangeQuery(nestedField).lt(LocalDate.now().format(formatter)),
ScoreMode.None
);
boolMust.must(nestedQuery);
} else if (licensesStatus.equals(near)) {
// 不需要资质的人员查询构造条件
BoolQueryBuilder notNeedLicensesQueryBuilder = this.getNotLicencesBuilderWithPerson();
boolMust.must(notNeedLicensesQueryBuilder);
// 临期:小于等于当前日期加上30天
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.rangeQuery(nestedField).lte(LocalDate.now().plusDays(30).format(formatter)).gte(LocalDate.now().format(formatter)),
ScoreMode.None
);
boolMust.must(nestedQuery);
} else if (licensesStatus.equals(normal)) {
// 不需要资质的人员查询构造条件
BoolQueryBuilder notNeedLicensesQueryBuilder = this.getNotLicencesBuilderWithPerson();
boolMust.must(notNeedLicensesQueryBuilder);
// 正常:大于当前日期加上30天
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.rangeQuery(nestedField).gt(LocalDate.now().plusDays(30).format(formatter)),
ScoreMode.None
);
boolMust.must(nestedQuery);
} else if (licensesStatus.equals(none)) {
// 不需要资质的人员查询构造条件
BoolQueryBuilder notNeedLicensesQueryBuilder = this.getNotLicencesBuilderWithPerson();
boolMust.must(notNeedLicensesQueryBuilder);
// 无有效期
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().mustNot(existsQuery(nestedField)),
ScoreMode.None
);
boolMust.must(nestedQuery);
}
// 只在人员列表处用到
// 综合统计处未用到下面的条件,理论上走不到下面俩条件
else if (licensesStatus.equals(noLicense)) {
// 无资质
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
existsQuery(path + "." + "certNo"),
ScoreMode.None
);
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(this.getNotLicencesBuilderWithPerson());
meBuilder.must(QueryBuilders.boolQuery().mustNot(nestedQuery));
boolMust.must(meBuilder);
} else if (licensesStatus.equals(noLicenseReq)) {
// 无资质要求
boolMust.must(this.getNotNeedLicencesBuilderWithPerson());
}
}
}
\ No newline at end of file
......@@ -145,4 +145,7 @@ public class TzsUserInfoDto extends BaseDto {
@ApiModelProperty(value = "创建时间")
protected Date createDate;
@ApiModelProperty(value = "人员所在企业类型:监管/行政审批局supervision;企业:company")
protected String companyType;
}
......@@ -242,4 +242,10 @@ public class TzsUserInfo extends BaseEntity {
*/
@TableField(value = "create_date")
protected Date createDate;
/**
* 人员所在企业类型:监管/行政审批局supervision;企业:company
*/
@TableField(value = "company_type")
protected String companyType;
}
......@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.tcm.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.tcm.api.vo.SortVo;
import com.yeejoin.amos.boot.module.tcm.api.vo.UserInfoVo;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
......@@ -44,6 +45,8 @@ public interface TzsUserInfoMapper extends BaseMapper<TzsUserInfo> {
String selectCompanyTypeById(Long companySeq);
CompanyModel selectPrivilegeCompanyByCompanyCode(@Param("companyCode") String companyCode);
/**
* 已资质为维度查询人
* @param page 分页对象
......
......@@ -96,7 +96,7 @@ public interface ITzsUserInfoService extends IService<TzsUserInfo> {
String deletePersonSubtypeHistoricalData();
List<DataDictionary> postByUnitType(CompanyBo company);
List<DataDictionary> postByUnitType(CompanyBo company,String formType);
List<DataDictionary> subPostByUnitType(CompanyBo company, String parentCode);
......
......@@ -261,6 +261,14 @@
<select id="selectCompanyTypeById" resultType="java.lang.String">
select company_type from privilege_company where sequence_nbr = #{companySeq}
</select>
<select id="selectPrivilegeCompanyByCompanyCode" resultType="com.yeejoin.amos.feign.privilege.model.CompanyModel">
select *
from privilege_company
where company_code = #{companyCode}
</select>
<select id="queryUserByPermissionOfOneCompany" resultType="com.yeejoin.amos.boot.module.common.api.dto.UserPermissionDto">
SELECT
COALESCE (p.sequence_nbr, u.sequence_nbr) as sequence_nbr,
......
......@@ -29,6 +29,7 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
......@@ -464,9 +465,10 @@ public class TzsUserInfoController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/postByUnitType")
@ApiOperation(httpMethod = "GET", value = "根据单位类型查询对应的人员类型", notes = "根据单位类型查询对应的人员类型")
public ResponseModel<List<DataDictionary>> postByUnitType() {
public ResponseModel<List<DataDictionary>> postByUnitType(@ApiParam(value = "表单类型:add/edit/detail,用于过滤监管单位查询人员类型,详情页面查询所有(可能是查看其他单位的人员详情),新增编辑页面只过滤自己类型下的,限制添加的人员类型", required = true, defaultValue = "detail")
@RequestParam(value = "formType", defaultValue = "") String formType) {
CompanyBo company = getSelectedOrgInfo().getCompany();
return ResponseHelper.buildResponse(tzsUserInfoService.postByUnitType(company));
return ResponseHelper.buildResponse(tzsUserInfoService.postByUnitType(company, formType));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.tcm.biz.refresh.handler;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.api.dao.EsBaseEnterpriseInfoDao;
import com.yeejoin.amos.boot.module.common.api.dao.EsUserInfoDao;
......@@ -17,6 +18,7 @@ import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.boot.module.tcm.biz.refresh.CommonRefreshService;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
......@@ -71,12 +73,21 @@ public class UserRefreshHandler implements IDataRefreshHandler {
esUserInfo.setEquipTypeName(RefreshDataUtils.castEquCategory2Name(esUserInfo.getEquipType()));
// 绑定设备状态
esUserInfo.setBindEquStatus(commonRefreshService.queryUserBindEquStatus(userInfo.getSequenceNbr()));
Optional<EsBaseEnterpriseInfo> esBaseEnterpriseInfo = esBaseEnterpriseInfoDao.findById(unit.getSequenceNbr() + "");
// 人员类型暂时取esBaseEnterpriseInfo按照资质分开后的,等检验和检测分开后,按照实际情况取就即可:unit.getUnitType()
String unitType = esBaseEnterpriseInfo.map(EsBaseEnterpriseInfo::getUnitType).orElse(unit.getUnitType());
esUserInfo.setUnitType(unitType);
esUserInfo.setSuperviseOrgName(unit.getSuperviseOrgName());
esUserInfo.setSuperviseOrgCode(unit.getSuperviseOrgCode());
// 监管机构
if (userInfo.getCompanyType().equals(BaseController.COMPANY_TYPE_SUPERVISION)) {
CompanyModel result = userInfoMapper.selectPrivilegeCompanyByCompanyCode(userInfo.getUnitCode());
esUserInfo.setUnitType(result.getCompanyType());
esUserInfo.setSuperviseOrgName(result.getCompanyName());
esUserInfo.setSuperviseOrgCode(result.getOrgCode());
} else {
// 企业
Optional<EsBaseEnterpriseInfo> esBaseEnterpriseInfo = esBaseEnterpriseInfoDao.findById(unit.getSequenceNbr() + "");
// 人员类型暂时取esBaseEnterpriseInfo按照资质分开后的,等检验和检测分开后,按照实际情况取就即可:unit.getUnitType()
String unitType = esBaseEnterpriseInfo.map(EsBaseEnterpriseInfo::getUnitType).orElse(unit.getUnitType());
esUserInfo.setUnitType(unitType);
esUserInfo.setSuperviseOrgName(unit.getSuperviseOrgName());
esUserInfo.setSuperviseOrgCode(unit.getSuperviseOrgCode());
}
esUserInfo.setLicenses(commonRefreshService.buildUserLicenses(userInfo.getSequenceNbr()));
esUserInfo.setLicenseMinExpiryDate(RefreshCmService.getMinDateFromLicensesUser(esUserInfo.getLicenses()));
esUserInfoDao.save(esUserInfo);
......
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