Commit 05372613 authored by suhuiguang's avatar suhuiguang

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

1.报检规则推送规则
parent f3923df0
package com.yeejoin.amos.boot.module.jyjc.api.dto;
import lombok.Data;
import java.util.Objects;
@Data
public class RuleInspectUnitIndoDto {
/**
* id
*/
private Long sequenceNbr;
/**
* 单位唯一标识-来源use_unit_code,不带证件类型
*/
private String useCode;
/**
* use_code下滑线use_unit
*/
private String useCodeAndName;
/**
* 单位名称
*/
private String useUnit;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RuleInspectUnitIndoDto that = (RuleInspectUnitIndoDto) o;
return Objects.equals(useCode, that.useCode);
}
@Override
public int hashCode() {
return Objects.hashCode(useCode);
}
}
...@@ -270,12 +270,6 @@ public class JyjcInspectionApplication extends BaseEntity { ...@@ -270,12 +270,6 @@ public class JyjcInspectionApplication extends BaseEntity {
private LocalDate planInspectionDate; private LocalDate planInspectionDate;
/** /**
* 电梯检测的维保单位(电梯检测批量报检使用)
*/
@TableField(value = "maintenance_unit_code")
private String maintenanceUnitCode;
/**
* 设备分类,大型游乐设施使用 * 设备分类,大型游乐设施使用
*/ */
@TableField(value = "equip_tag1") @TableField(value = "equip_tag1")
......
...@@ -13,11 +13,21 @@ public enum InspectionCompanyType { ...@@ -13,11 +13,21 @@ public enum InspectionCompanyType {
/** /**
* 检验单位分类 * 检验单位分类
*/ */
LEGAL("legal","法定"), LEGAL("legal", "法定"),
THIRD("third","第3方"), THIRD("third", "第3方"),
DESIGNATED("designated", "定向单位"), DESIGNATED("designated", "定向单位"),
ALL("all","全部机构"); ALL("all", "全部机构"),
ALL_OR_APP("allOrApp", "所有机构和发起者");
private final String code; private final String code;
private final String name; private final String name;
public static InspectionCompanyType getByCode(String code) {
for (InspectionCompanyType e : InspectionCompanyType.values()) {
if (e.getCode().equals(code)) {
return e;
}
}
throw new RuntimeException("未知的单位类型" + code);
}
} }
...@@ -51,10 +51,4 @@ public interface JyjcOpeningApplicationMapper extends BaseMapper<JyjcOpeningAppl ...@@ -51,10 +51,4 @@ public interface JyjcOpeningApplicationMapper extends BaseMapper<JyjcOpeningAppl
*/ */
List<String> selectUnitCodeListByAgencyClassify(@Param("agencyClassifies") List<String> agencyClassifies); List<String> selectUnitCodeListByAgencyClassify(@Param("agencyClassifies") List<String> agencyClassifies);
/**
* 查询电梯检测的自检机构
* @param appSeq 申请表主键
* @return 发起单位自检机构 + 维保单位
*/
List<String> selectSelfDetectionUnitList(@Param("appSeq") Long appSeq);
} }
...@@ -205,10 +205,6 @@ public class JyjcInspectionApplicationModel extends BaseModel { ...@@ -205,10 +205,6 @@ public class JyjcInspectionApplicationModel extends BaseModel {
@ApiModelProperty(value = "装置id") @ApiModelProperty(value = "装置id")
private String projectContraptionId; private String projectContraptionId;
@ApiModelProperty(value = "电梯检测的维保单位(电梯检测批量报检使用)")
private String maintenanceUnitCode;
@ApiModelProperty(value = "设备分类,大型游乐设施使用") @ApiModelProperty(value = "设备分类,大型游乐设施使用")
private String equipTag1; private String equipTag1;
......
...@@ -142,23 +142,4 @@ ...@@ -142,23 +142,4 @@
#{agencyClassify} #{agencyClassify}
</foreach> </foreach>
</select> </select>
<select id="selectSelfDetectionUnitList" resultType="java.lang.String">
SELECT
unit_code
from
tz_jyjc_opening_application
where
unit_code = (SELECT application_unit_code FROM "tz_jyjc_inspection_application" where sequence_nbr = #{appSeq})
and status = '已完成'
and open_biz_type = 'jc-sydw'
union all
SELECT
unit_code
from
tz_jyjc_opening_application
where
unit_code = (SELECT maintenance_unit_code FROM "tz_jyjc_inspection_application" where sequence_nbr = #{appSeq})
and status = '已完成'
and open_biz_type = 'jc-agw'
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.jyjc.biz.action; package com.yeejoin.amos.boot.module.jyjc.biz.action;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.enums.LicenceStateEnum; import com.yeejoin.amos.boot.biz.common.enums.LicenceStateEnum;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.entity.BaseEnterpriseCert; import com.yeejoin.amos.boot.module.common.api.entity.BaseEnterpriseCert;
import com.yeejoin.amos.boot.module.common.api.enums.JyAgencyClassifyEnum; import com.yeejoin.amos.boot.module.common.api.enums.JyAgencyClassifyEnum;
import com.yeejoin.amos.boot.module.common.biz.service.impl.BaseEnterpriseCertServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.BaseEnterpriseCertServiceImpl;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.dto.RuleInspectUnitIndoDto;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationNoAcceptLog; import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationNoAcceptLog;
import com.yeejoin.amos.boot.module.jyjc.api.enums.InspectionCompanyType; import com.yeejoin.amos.boot.module.jyjc.api.enums.InspectionCompanyType;
import com.yeejoin.amos.boot.module.jyjc.api.enums.LicenceTypeEnum; import com.yeejoin.amos.boot.module.jyjc.api.enums.LicenceTypeEnum;
...@@ -84,10 +87,10 @@ public class RuleActionHandler { ...@@ -84,10 +87,10 @@ public class RuleActionHandler {
List<TzBaseUnitLicence> unitLicenceList = getBaseUnitLicenceList(itemCode, isMatchItem, orgType); List<TzBaseUnitLicence> unitLicenceList = getBaseUnitLicenceList(itemCode, isMatchItem, orgType);
// 2.匹配过滤机构信息,区分检验还是检测 // 2.匹配过滤机构信息,区分检验还是检测
List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList = getInspectionUnitListForFirstCommit2(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, orgType, defaultInspectionCode, legalInspectionCodes, isMustAccept, inspectionCompanyType); List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList = getInspectionUnitListForFirstCommit2(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, orgType, defaultInspectionCode, legalInspectionCodes, isMustAccept, inspectionCompanyType);
// 3.如果当前机构为符合条件的自检机构则增加上(电梯检测才需要) // 3.数据去重按照use_code
this.setSelfUnitIfDetection(orgType, inspectionEquipInfo, tzBaseEnterpriseInfoList, isMustAccept); Set<RuleInspectUnitIndoDto> units = this.distinctByUseCode(tzBaseEnterpriseInfoList);
// todo 4.tzBaseEnterpriseInfoList排序 // todo 4.tzBaseEnterpriseInfoList排序
ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), tzBaseEnterpriseInfoList); ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), units);
} catch (MqttException | InterruptedException e) { } catch (MqttException | InterruptedException e) {
log.error("用户自选首次提交的检验机构匹配动作执行失败: {}", e.getMessage()); log.error("用户自选首次提交的检验机构匹配动作执行失败: {}", e.getMessage());
} finally { } finally {
...@@ -97,12 +100,29 @@ public class RuleActionHandler { ...@@ -97,12 +100,29 @@ public class RuleActionHandler {
} }
} }
private void setSelfUnitIfDetection(String orgType, InspectionEquipInfo inspectionEquipInfo, List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList, Boolean isMustAccept) { private Set<RuleInspectUnitIndoDto> distinctByUseCode(List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList) {
if (OpenBizTypeEnumV2.JC.getUnitType().equals(orgType)) { return tzBaseEnterpriseInfoList.stream().map(u -> {
List<String> selfDetectionCodes = openingApplicationMapper.selectSelfDetectionUnitList(Long.parseLong(inspectionEquipInfo.getAppSeq())); RuleInspectUnitIndoDto ruleInspectUnitIndoDto = new RuleInspectUnitIndoDto();
List<TzBaseEnterpriseInfoDto> selfDetectionUnits = !selfDetectionCodes.isEmpty() ? tzBaseEnterpriseInfoMapper.queryInspectionUnitListByUseUnitCode(selfDetectionCodes) : new ArrayList<>(); BeanUtil.copyProperties(u, ruleInspectUnitIndoDto);
setIsCanNoAccept(selfDetectionUnits, isMustAccept); return ruleInspectUnitIndoDto;
tzBaseEnterpriseInfoList.addAll(selfDetectionUnits); }).collect(Collectors.toSet());
}
private void setSelfUnitIfDetection(InspectionEquipInfo inspectionEquipInfo, List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList, Boolean isMustAccept) {
Map<String, Object> companyInfoMap = inspectionEquipInfo.getCompanyInfo();
String companyCode = companyInfoMap.get("companyCode").toString();
// 自检时按照登录人类型进行约束,进行对应的报检业务开通后才能接受
OpenBizTypeEnumV2 bizTypeEnumV2 = this.getOpenBizTypeByCompanyType(companyInfoMap.get("companyType").toString());
List<TzBaseEnterpriseInfoDto> selfDetectionUnits = tzBaseEnterpriseInfoMapper.queryInspectionUnitListByUseUnitCode(companyCode, bizTypeEnumV2.getCode());
setIsCanNoAccept(selfDetectionUnits, isMustAccept);
tzBaseEnterpriseInfoList.addAll(selfDetectionUnits);
}
private OpenBizTypeEnumV2 getOpenBizTypeByCompanyType(String companyType) {
if (CompanyTypeEnum.CONSTRUCTION.getName().equals(companyType)) {
return OpenBizTypeEnumV2.AGW;
} else {
return OpenBizTypeEnumV2.SYDW;
} }
} }
...@@ -126,12 +146,12 @@ public class RuleActionHandler { ...@@ -126,12 +146,12 @@ public class RuleActionHandler {
List<TzBaseUnitLicence> unitLicenceList = getBaseUnitLicenceList(itemCode, isMatchItem, orgType); List<TzBaseUnitLicence> unitLicenceList = getBaseUnitLicenceList(itemCode, isMatchItem, orgType);
// 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测) // 2.匹配过滤机构信息,默认检验机构(目前检测没配置规则,后续检测也需要配置规则时,需要规则那回调方法新增参数,区分检验还是检测)
List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList = getInspectionUnitListForNoAccept2(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, orgType, defaultInspectionCode, legalInspectionCodes, inspectionCompanyType, isMustAccept); List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList = getInspectionUnitListForNoAccept2(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, orgType, defaultInspectionCode, legalInspectionCodes, inspectionCompanyType, isMustAccept);
// 3.如果当前机构为符合条件的自检机构则增加上(电梯检测才需要) // 3.去掉已经不予受理的单位,报检时该单位不能再进行接收报检信息(列表不显示)
this.setSelfUnitIfDetection(orgType, inspectionEquipInfo, tzBaseEnterpriseInfoList, isMustAccept);
// 4.去掉已经不予受理的单位,报检时该单位不能再进行接收报检信息(列表不显示)
this.removeNoAcceptUnit(tzBaseEnterpriseInfoList, inspectionEquipInfo); this.removeNoAcceptUnit(tzBaseEnterpriseInfoList, inspectionEquipInfo);
// 4.数据去重按照use_code
Set<RuleInspectUnitIndoDto> units = this.distinctByUseCode(tzBaseEnterpriseInfoList);
// todo 5.tzBaseEnterpriseInfoList排序 // todo 5.tzBaseEnterpriseInfoList排序
ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), tzBaseEnterpriseInfoList); ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), units);
} catch (MqttException e) { } catch (MqttException e) {
log.error("Error publishing MQTT message: {}", e.getMessage()); log.error("Error publishing MQTT message: {}", e.getMessage());
} }
...@@ -194,19 +214,30 @@ public class RuleActionHandler { ...@@ -194,19 +214,30 @@ public class RuleActionHandler {
} }
private List<TzBaseEnterpriseInfoDto> getInspectionUnitListForFirstCommit2(Boolean isMatchItem, List<TzBaseUnitLicence> unitLicenceList, Boolean isMatchArea, InspectionEquipInfo inspectionEquipInfo, String openBizType, String defaultInspectionCode, String legalInspectionCodes, Boolean isMustAccept, String inspectionCompanyType) { private List<TzBaseEnterpriseInfoDto> getInspectionUnitListForFirstCommit2(Boolean isMatchItem, List<TzBaseUnitLicence> unitLicenceList, Boolean isMatchArea, InspectionEquipInfo inspectionEquipInfo, String openBizType, String defaultInspectionCode, String legalInspectionCodes, Boolean isMustAccept, String inspectionCompanyTypeCode) {
List<TzBaseEnterpriseInfoDto> matchEnterpriseInfos = new ArrayList<>(); List<TzBaseEnterpriseInfoDto> matchEnterpriseInfos = new ArrayList<>();
if (inspectionCompanyType.equals(InspectionCompanyType.ALL.getCode())) { InspectionCompanyType inspectionCompanyType = InspectionCompanyType.getByCode(inspectionCompanyTypeCode);
// 所有开通的检验检测机构 switch (inspectionCompanyType) {
matchEnterpriseInfos = getInspectionUnitListForAll(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, openBizType, isMustAccept); case ALL:
} else if (inspectionCompanyType.equals(InspectionCompanyType.LEGAL.getCode())) { // 所有开通的检验检测机构
// 查询省内公益机构(省内法定机构) matchEnterpriseInfos = getInspectionUnitListForAll(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, openBizType, isMustAccept);
matchEnterpriseInfos = getInspectionUnitListForLegal(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, openBizType, defaultInspectionCode, legalInspectionCodes, isMustAccept); break;
} else if (inspectionCompanyType.equals(InspectionCompanyType.DESIGNATED.getCode())) { case LEGAL:
// 查询指定机构 // 查询省内公益机构(省内法定机构)
matchEnterpriseInfos = getDesignatedUnitList(isMatchItem, defaultInspectionCode, isMatchArea, inspectionEquipInfo, openBizType, isMustAccept, unitLicenceList); matchEnterpriseInfos = getInspectionUnitListForLegal(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, openBizType, defaultInspectionCode, legalInspectionCodes, isMustAccept);
} else { break;
log.warn("未实现的检验机构名单类型:{}", inspectionCompanyType); case DESIGNATED:
// 查询指定机构
matchEnterpriseInfos = getDesignatedUnitList(isMatchItem, defaultInspectionCode, isMatchArea, inspectionEquipInfo, openBizType, isMustAccept, unitLicenceList);
break;
case ALL_OR_APP:
// 所有开通的检验检测机构 + 发起单位
matchEnterpriseInfos = getInspectionUnitListForAll(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, openBizType, isMustAccept);
setSelfUnitIfDetection(inspectionEquipInfo, matchEnterpriseInfos, isMustAccept);
break;
default:
log.warn("未实现的检验机构名单类型:{}", inspectionCompanyType);
return matchEnterpriseInfos;
} }
return matchEnterpriseInfos; return matchEnterpriseInfos;
} }
......
...@@ -9,7 +9,7 @@ import org.springframework.context.ApplicationEvent; ...@@ -9,7 +9,7 @@ import org.springframework.context.ApplicationEvent;
*/ */
@Getter @Getter
public class TouchRuleEvent extends ApplicationEvent { public class TouchRuleEvent extends ApplicationEvent {
private InspectionEquipInfo inspectionEquipInfo; private final InspectionEquipInfo inspectionEquipInfo;
/** /**
* Create a new {@code ApplicationEvent}. * Create a new {@code ApplicationEvent}.
......
...@@ -24,7 +24,7 @@ import static com.alibaba.fastjson.JSON.toJSONString; ...@@ -24,7 +24,7 @@ import static com.alibaba.fastjson.JSON.toJSONString;
@Slf4j @Slf4j
public class TouchRuleEventListener implements ApplicationListener<TouchRuleEvent> { public class TouchRuleEventListener implements ApplicationListener<TouchRuleEvent> {
private AmosRequestContext amosRequestContext; private final AmosRequestContext amosRequestContext;
@Value("${inspection.rule.project-name:报检规则}") @Value("${inspection.rule.project-name:报检规则}")
private String ruleName; private String ruleName;
......
...@@ -152,9 +152,12 @@ public class EnableRuleDataPreparationService { ...@@ -152,9 +152,12 @@ public class EnableRuleDataPreparationService {
} }
if (PRESSURE_EQU_LIST.contains(equipInfoModel.getEquList())) { if (PRESSURE_EQU_LIST.contains(equipInfoModel.getEquList())) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(equipInfoModel.getUserId(), equipInfoModel.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(equipInfoModel.getUserId(), equipInfoModel.getToken())).toString(), ReginParams.class);
String useCode = reginParams.getCompany().getCompanyCode(); setCompanyInfo(reginParams, inspectionEquipInfo);
TzBaseEnterpriseInfo enterpriseInfo = baseEnterpriseInfoMapper.selectOne(new LambdaQueryWrapper<TzBaseEnterpriseInfo>().eq(TzBaseEnterpriseInfo::getUseCode, useCode).select(BaseEntity::getSequenceNbr, TzBaseEnterpriseInfo::getRegulatoryLabels)); TzBaseEnterpriseInfo enterpriseInfo = baseEnterpriseInfoMapper.selectOne(new LambdaQueryWrapper<TzBaseEnterpriseInfo>().eq(TzBaseEnterpriseInfo::getUseCode, reginParams.getCompany().getCompanyCode()).select(BaseEntity::getSequenceNbr, TzBaseEnterpriseInfo::getRegulatoryLabels));
inspectionEquipInfo.setManageLevel(StringUtils.isNotBlank(enterpriseInfo.getRegulatoryLabels()) ? enterpriseInfo.getRegulatoryLabels() : defaultRegulatoryLabels); 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);
setCompanyInfo(reginParams, inspectionEquipInfo);
} }
inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(equipInfoModel.getCity(), equipInfoModel.getCounty())); inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(equipInfoModel.getCity(), equipInfoModel.getCounty()));
inspectionEquipInfo.setDistrictOrCountyCode(equipInfoModel.getCounty()); inspectionEquipInfo.setDistrictOrCountyCode(equipInfoModel.getCounty());
...@@ -171,6 +174,13 @@ public class EnableRuleDataPreparationService { ...@@ -171,6 +174,13 @@ public class EnableRuleDataPreparationService {
publisher.publish(new TouchRuleEvent(this, inspectionEquipInfo)); publisher.publish(new TouchRuleEvent(this, inspectionEquipInfo));
} }
private static void setCompanyInfo(ReginParams reginParams, InspectionEquipInfo inspectionEquipInfo) {
Map<String, Object> companyInfo = new HashMap<>();
companyInfo.put("companyType", reginParams.getCompany().getCompanyType());
companyInfo.put("companyCode", reginParams.getCompany().getCompanyCode());
inspectionEquipInfo.setCompanyInfo(companyInfo);
}
private String buildLastNoAcceptInspectionCode(JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog) { private String buildLastNoAcceptInspectionCode(JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog) {
if (jyjcInspectionApplicationNoAcceptLog != null) { if (jyjcInspectionApplicationNoAcceptLog != null) {
return jyjcInspectionApplicationNoAcceptLog.getInspectionUnitCode(); return jyjcInspectionApplicationNoAcceptLog.getInspectionUnitCode();
......
...@@ -69,4 +69,7 @@ public class InspectionEquipInfo implements Serializable { ...@@ -69,4 +69,7 @@ public class InspectionEquipInfo implements Serializable {
@ApiModelProperty(value = "设备分类,大型游乐设施使用") @ApiModelProperty(value = "设备分类,大型游乐设施使用")
private String equipTag1; private String equipTag1;
@ApiModelProperty(value = "公司信息")
private Map<String, Object> companyInfo;
} }
...@@ -814,7 +814,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -814,7 +814,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
// 更新流程中的流程数据 // 更新流程中的流程数据
commonService.saveExecuteFlowData2Redis(model.getProcessInstanceId(), this.buildInstanceRuntimeData(jyjcInspectionApplication)); commonService.saveExecuteFlowData2Redis(model.getProcessInstanceId(), this.buildInstanceRuntimeData(jyjcInspectionApplication));
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally { } finally {
if (lock.isHeldByCurrentThread()) { if (lock.isHeldByCurrentThread()) {
lock.unlock(); lock.unlock();
...@@ -1379,49 +1379,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1379,49 +1379,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
} }
String companyCode = company.getString("companyCode").contains("_") ? company.getString("companyCode").split("_")[1] : company.getString("companyCode"); String companyCode = company.getString("companyCode").contains("_") ? company.getString("companyCode").split("_")[1] : company.getString("companyCode");
String type = company.getString("companyType"); String type = company.getString("companyType");
// 按照身份过滤
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数 setFilterByIndefinite(map, type, companyCode);
if (!ValidationUtil.isEmpty(type) && type.contains("使用单位")) {
if (ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
}
if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
if (!ValidationUtil.isEmpty(type) && type.contains("个人主体")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
//默认条件 限制西安电梯隶属导入数据不可做业务
BoolQueryBuilder tBuilder = QueryBuilders.boolQuery();
tBuilder.should(QueryBuilders.matchQuery("IS_DO_BUSINESS", true));
tBuilder.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("IS_DO_BUSINESS")));
tBuilder.minimumShouldMatch(1);
boolMust.must(tBuilder);
// 使用单位 //安装改造维修单位
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) && !ObjectUtils.isEmpty(map.getString("USC_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder ubuilder = QueryBuilders.boolQuery();
String useCode = QueryParser.escape(map.getString("USE_UNIT_CREDIT_CODE"));
useCode = useCode.contains("_") ? useCode.split("_")[0] : useCode;
ubuilder.should(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", useCode));
String uscCode = QueryParser.escape(map.getString("USC_UNIT_CREDIT_CODE")).toLowerCase();
ubuilder.should(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + uscCode + "*"));
ubuilder.minimumShouldMatch(1);
boolMust.must(ubuilder);
} else {
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) || !ObjectUtils.isEmpty(map.getString("useUnitCreditCode"))) {
String uucc = !ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) ? map.getString("USE_UNIT_CREDIT_CODE") : map.getString("useUnitCreditCode");
String param = QueryParser.escape(uucc);
param = param.contains("_") ? param.split("_")[0] : param;
boolMust.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", param));
}
if (!ObjectUtils.isEmpty(map.getString("USC_UNIT_CREDIT_CODE"))) {
String uscCode = QueryParser.escape(map.getString("USC_UNIT_CREDIT_CODE")).toLowerCase();
boolMust.must(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + uscCode + "*"));
}
}
// 监管码 // 监管码
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
String supervisoryCode = map.getString("SUPERVISORY_CODE"); String supervisoryCode = map.getString("SUPERVISORY_CODE");
...@@ -1493,11 +1452,30 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1493,11 +1452,30 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
return result; return result;
} }
private static void setFilterByIndefinite(JSONObject map, String type, String companyCode) {
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(type) && type.contains("使用单位")) {
if (ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
}
if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) {
String inspectionType = map.getString("inspectionType");
if (JYJCTypeEnum.SCJY.getCode().equals(inspectionType)) { // 电梯检测时 按照电梯维保单位进行过滤
map.put("MAINTAIN_UNIT_CREDIT_CODE", companyCode);
} else { // 其他按照安改维单位进行过滤
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
}
if (!ValidationUtil.isEmpty(type) && type.contains("个人主体")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
}
/** /**
* 过滤条件去掉流程中的设备, * 过滤条件去掉流程中的设备,
* *
* @param boolMust 条件 * @param boolMust 条件
* @param equCategoryCode
*/ */
private void setFilterOfInFlowing(BoolQueryBuilder boolMust, String equListCode, String inspectionType, String equCategoryCode) { private void setFilterOfInFlowing(BoolQueryBuilder boolMust, String equListCode, String inspectionType, String equCategoryCode) {
Set<String> records = this.getEquipInFlowing(); Set<String> records = this.getEquipInFlowing();
......
...@@ -110,9 +110,9 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -110,9 +110,9 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
/** /**
* 按照不带证件类型的的单位code,重新单位-检验检测业务专用 * 按照不带证件类型的的单位code,重新单位-检验检测业务专用
* @param list 单位code * @param unitCode 单位code
* @return 单位列表 * @return 单位列表
*/ */
List<TzBaseEnterpriseInfoDto> queryInspectionUnitListByUseUnitCode(List<String> list); List<TzBaseEnterpriseInfoDto> queryInspectionUnitListByUseUnitCode(@Param("unitCode") String unitCode, @Param("openBizType") String openBizType);
} }
...@@ -393,9 +393,7 @@ ...@@ -393,9 +393,7 @@
<select id="queryInspectionUnitListByUseUnitCode" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto"> <select id="queryInspectionUnitListByUseUnitCode" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto">
<include refid="unit-list-info" /> <include refid="unit-list-info" />
where where
info.use_code in info.use_code = #{unitCode}
<foreach collection="list" item="item" index="index" open="(" close=")" separator=","> and exists (SELECT 1 from tz_jyjc_opening_application where unit_code = #{unitCode} and status = '已完成' and open_biz_type = #{openBizType})
#{item}
</foreach>
</select> </select>
</mapper> </mapper>
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