Commit a61b03b2 authored by suhuiguang's avatar suhuiguang

refeat(jyjc): 报检规则4.0开发

1.报检规则联调自测,固定式压力容器,增加按照使用单位进行过滤,否则否则会有多个标签 2.设备选择增加按照使用单位进行过滤
parent 0bac4f33
......@@ -274,4 +274,10 @@ public class JyjcInspectionApplication extends BaseEntity {
*/
@TableField(value = "equip_tag1")
private String equipTag1;
/**
* 设备的使用单位报检监督检验规则使用
*/
@TableField(value = "use_unit_credit_code")
private String useUnitCreditCode;
}
......@@ -49,4 +49,7 @@ public class InspectionEquipInfoModel implements Serializable {
@ApiModelProperty(value = "设备分类,大型游乐设施使用")
private String equipTag1;
@ApiModelProperty(value = "设备的使用单位,报检监督检验规则使用")
private String useUnitCreditCode;
}
......@@ -208,6 +208,9 @@ public class JyjcInspectionApplicationModel extends BaseModel {
@ApiModelProperty(value = "设备分类,大型游乐设施使用")
private String equipTag1;
@ApiModelProperty(value = "设备的使用单位,报检监督检验规则使用")
private String useUnitCreditCode;
public String getProcessInstanceId() {
return this.instanceId != null ? this.instanceId : this.processInstanceId;
}
......
......@@ -55,7 +55,7 @@ public class TouchRuleEventListener implements ApplicationListener<TouchRuleEven
factBaseModel.setPackageId(ruleName + "/" + inspectionEquipInfo.getBizType());
factBaseModel.setProcessIds(null);
if (log.isInfoEnabled()) {
log.info("发送规则的消息对象:{},\n变量对象:{}", toJSONString(factBaseModel), toJSONString(factBaseModel));
log.info("发送规则的消息对象:{},\n变量对象:{}", toJSONString(inspectionEquipInfo), toJSONString(factBaseModel));
}
Rule.ruleClient.fireRule(factBaseModel);
} catch (Exception e) {
......
......@@ -20,9 +20,11 @@ import com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.RuleCommonServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -68,6 +70,7 @@ public class EnableRuleDataPreparationService {
private final TzBaseEnterpriseInfoMapper baseEnterpriseInfoMapper;
private final RedisUtils redisUtils;
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
@Value("${rule.data.preparation.thread.number:2}")
private int threadNumber;
......@@ -151,10 +154,16 @@ public class EnableRuleDataPreparationService {
// 标签
inspectionEquipInfo.setEquipTag1(equipInfoModel.getEquipTag1());
}
inspectionEquipInfo.setInspectionType(equipInfoModel.getInspectionType());
inspectionEquipInfo.setBizType(getCategoryByType(JYJCTypeEnum.of(inspectionEquipInfo.getInspectionType())));
if (PRESSURE_EQU_LIST.contains(equipInfoModel.getEquList())) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(equipInfoModel.getUserId(), equipInfoModel.getToken())).toString(), ReginParams.class);
setCompanyInfo(reginParams, inspectionEquipInfo);
TzBaseEnterpriseInfo enterpriseInfo = baseEnterpriseInfoMapper.selectOne(new LambdaQueryWrapper<TzBaseEnterpriseInfo>().eq(TzBaseEnterpriseInfo::getUseCode, reginParams.getCompany().getCompanyCode()).select(BaseEntity::getSequenceNbr, TzBaseEnterpriseInfo::getRegulatoryLabels));
// 取设备的useUnitCreditCode(前端已经限制按照使用单位筛选进行报检)
String useUnitCode = this.getUseInfo(equipInfoModel.getRecord());
TzBaseEnterpriseInfo enterpriseInfo = baseEnterpriseInfoMapper.selectOne(new LambdaQueryWrapper<TzBaseEnterpriseInfo>()
.eq(TzBaseEnterpriseInfo::getUseUnitCode, useUnitCode).
select(BaseEntity::getSequenceNbr, TzBaseEnterpriseInfo::getRegulatoryLabels));
inspectionEquipInfo.setManageLevel(StringUtils.isNotBlank(enterpriseInfo.getRegulatoryLabels()) ? enterpriseInfo.getRegulatoryLabels() : defaultRegulatoryLabels);
} else {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(equipInfoModel.getUserId(), equipInfoModel.getToken())).toString(), ReginParams.class);
......@@ -163,9 +172,7 @@ public class EnableRuleDataPreparationService {
inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(equipInfoModel.getCity(), equipInfoModel.getCounty()));
inspectionEquipInfo.setDistrictOrCountyCode(equipInfoModel.getCounty());
inspectionEquipInfo.setComponentKey(equipInfoModel.getComponentKey());
inspectionEquipInfo.setInspectionType(equipInfoModel.getInspectionType());
inspectionEquipInfo.setRecord(equipInfoModel.getRecord());
inspectionEquipInfo.setBizType(getCategoryByType(JYJCTypeEnum.of(inspectionEquipInfo.getInspectionType())));
inspectionEquipInfo.setUuid(sequence.nextId() + "");
JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog = getLastNoAcceptLog(equipInfoModel);
inspectionEquipInfo.setRequestType(this.buildRequestType(equipInfoModel, jyjcInspectionApplicationNoAcceptLog));
......@@ -175,6 +182,11 @@ public class EnableRuleDataPreparationService {
publisher.publish(new TouchRuleEvent(this, inspectionEquipInfo));
}
private String getUseInfo(String record) {
IdxBizJgUseInfo useInfo = idxBizJgUseInfoMapper.selectOne(new LambdaQueryWrapper<IdxBizJgUseInfo>().eq(IdxBizJgUseInfo::getRecord, record).select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getUseUnitCreditCode));
return useInfo.getUseUnitCreditCode();
}
private static void setCompanyInfo(ReginParams reginParams, InspectionEquipInfo inspectionEquipInfo) {
Map<String, Object> companyInfo = new HashMap<>();
companyInfo.put("companyType", reginParams.getCompany().getCompanyType());
......
......@@ -636,8 +636,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
BeanUtil.beanToMap(equip, objectHashMap, false, false);
objectHashMap.put("record", equip.getSEQUENCE_NBR());
objectHashMap.put("ADDRESS", concatDetailAddress(equip));
objectHashMap.forEach((k,v)->{
if(ObjectUtils.isEmpty(v) || "null".equals(v)){
objectHashMap.forEach((k, v) -> {
if (ObjectUtils.isEmpty(v) || "null".equals(v)) {
objectHashMap.put(k, "");
}
});
......@@ -835,7 +835,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
LambdaQueryWrapper<JyjcOpeningApplication> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JyjcOpeningApplication::getUnitCode, applicationModel.getInspectionUnitCode());
queryWrapper.eq(JyjcOpeningApplication::getStatus, FlowStatusEnum.TO_BE_FINISHED.getName());
queryWrapper.select(JyjcOpeningApplication::getResultType, BaseEntity::getSequenceNbr,JyjcOpeningApplication::getDockingUnitCode);
queryWrapper.select(JyjcOpeningApplication::getResultType, BaseEntity::getSequenceNbr, JyjcOpeningApplication::getDockingUnitCode);
queryWrapper.orderByDesc(JyjcOpeningApplication::getRecDate);
queryWrapper.last("limit 1");
List<JyjcOpeningApplication> applicationList = jyjcOpeningApplicationService.list(queryWrapper);
......@@ -1218,7 +1218,6 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 获取当前登录人单位类型
*
*/
public JSONObject getCompanyType() {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
......@@ -1364,9 +1363,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
private void replaceNull2EmptyString(JSONObject dto2) {
dto2.forEach((k,v)->{
if(v == null || "null".equals(v)){
dto2.put(k,"");
dto2.forEach((k, v) -> {
if (v == null || "null".equals(v)) {
dto2.put(k, "");
}
});
}
......@@ -1470,7 +1469,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
String companyCode = company.getString("companyCode").contains("_") ? company.getString("companyCode").split("_")[1] : company.getString("companyCode");
String type = company.getString("companyType");
// 按照身份过滤
setFilterByIndefinite(map, type, companyCode);
setFilterByIndefinite(map, type, companyCode, boolMust);
// 设备种类编码
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE", QueryParser.escape(map.getString("EQU_LIST_CODE"))));
......@@ -1497,17 +1496,18 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
String test = QueryParser.escape(map.getString(EQU_CODE));
boolMust.must(QueryBuilders.wildcardQuery(EQU_CODE, "*" + test.toLowerCase() + "*"));
}
// 单位内部编号模糊查询
if (!ObjectUtils.isEmpty(map.getString("USE_INNER_CODE"))) {
String test = QueryParser.escape(map.getString("USE_INNER_CODE"));
boolMust.must(QueryBuilders.matchPhraseQuery("USE_INNER_CODE", test));
}
// 大型游乐设施时按照设备分类过滤
if(!ObjectUtils.isEmpty(map.getString("equipTag1")) && EquipmentClassifityEnum.YLSS.getCode().equals(map.getString("EQU_LIST_CODE"))){
if (!ObjectUtils.isEmpty(map.getString("equipTag1")) && EquipmentClassifityEnum.YLSS.getCode().equals(map.getString("EQU_LIST_CODE"))) {
boolMust.must(QueryBuilders.termQuery("tag1.keyword", QueryParser.escape(map.getString("equipTag1"))));
}
// 固定式压力容器按照是否球罐过滤
if(!ObjectUtils.isEmpty(map.getString("equipTag1")) && BizCommonConstant.EQU_CATEGORY_CODE_GDYLRQ.equals(map.getString("EQU_CATEGORY_CODE"))){
if (!ObjectUtils.isEmpty(map.getString("equipTag1")) && BizCommonConstant.EQU_CATEGORY_CODE_GDYLRQ.equals(map.getString("EQU_CATEGORY_CODE"))) {
boolMust.must(QueryBuilders.termQuery("WHETHER_SPHERICAL_TANK.keyword", QueryParser.escape(map.getString("equipTag1"))));
}
this.setFilterOfInFlowing(boolMust, map.getString("EQU_LIST_CODE"), map.getString("inspectionType"), map.getString("EQU_CATEGORY_CODE"));
......@@ -1517,9 +1517,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
builder.size(size);
request.source(builder);
List<JSONObject> list = new LinkedList<>();
long totle = 0;
if (log.isDebugEnabled()) {
log.debug("查询es 的查询条件: {}", request);
long total = 0;
if (log.isInfoEnabled()) {
log.info("查询es 的查询条件: {}", request);
}
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
......@@ -1537,27 +1537,29 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
// 填充地址
fillAddress(list);
totle = response.getInternalResponse().hits().getTotalHits().value;
total = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
result.setTotal(total);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
private static void setFilterByIndefinite(JSONObject map, String type, String companyCode) {
private static void setFilterByIndefinite(JSONObject map, String type, String companyCode, BoolQueryBuilder boolMust) {
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(type) && type.contains("使用单位")) {
if (ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
boolMust.must(QueryBuilders.termQuery("USE_UNIT_CREDIT_CODE.keyword", QueryParser.escape(companyCode)));
}
if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
BoolQueryBuilder builder = QueryBuilders.boolQuery();
builder.should(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + QueryParser.escape(companyCode).toLowerCase() + "*"));
String useUnitCode = map.getString("useUnitCreditCode");
builder.should(QueryBuilders.termQuery("USE_UNIT_CREDIT_CODE.keyword", QueryParser.escape(useUnitCode)));
boolMust.must(builder);
}
if (!ValidationUtil.isEmpty(type) && type.contains("个人主体")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
boolMust.must(QueryBuilders.termQuery("USE_UNIT_CREDIT_CODE.keyword", QueryParser.escape(companyCode)));
}
}
......
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