Commit cc71a773 authored by suhuiguang's avatar suhuiguang

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

1.增加排序
parent 66308606
......@@ -27,6 +27,17 @@ public class RuleInspectUnitIndoDto {
*/
private String useUnit;
/**
* 机构分类
*/
private String agencyClassify;
/**
* 序号
*/
private Integer sort;
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
......@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
......@@ -53,6 +54,9 @@ public class RuleActionHandler {
private final BaseEnterpriseCertServiceImpl baseEnterpriseCertService;
private final JyjcOpeningApplicationMapper openingApplicationMapper;
@Value("${jyjc.sy.unit.code:126100004352004822}")
private String syCode;
/**
* 规则回调方法-用户自选首次提交的检验机构匹配,可替换firstInspectionOrgMatchAction,由于规则修改太多,故新增一个
......@@ -89,8 +93,9 @@ public class RuleActionHandler {
List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList = getInspectionUnitListForFirstCommit2(isMatchItem, unitLicenceList, isMatchArea, inspectionEquipInfo, orgType, defaultInspectionCode, legalInspectionCodes, isMustAccept, inspectionCompanyType);
// 3.数据去重按照use_code
Set<RuleInspectUnitIndoDto> units = this.distinctByUseCode(tzBaseEnterpriseInfoList);
// todo 4.tzBaseEnterpriseInfoList排序
ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), units);
// 4.tzBaseEnterpriseInfoList排序
List<RuleInspectUnitIndoDto> sortedUnits = this.sortedUnit(units);
ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), sortedUnits);
} catch (MqttException | InterruptedException e) {
log.error("用户自选首次提交的检验机构匹配动作执行失败: {}", e.getMessage());
} finally {
......@@ -100,10 +105,33 @@ public class RuleActionHandler {
}
}
/**
* 排序:先属地(SBGY)、再省院(syCode)、再省内(SBDSF)、再其他(nullsLast)
* @param units 要排序的单位
* @return 排序后
*/
private List<RuleInspectUnitIndoDto> sortedUnit(Set<RuleInspectUnitIndoDto> units) {
for (RuleInspectUnitIndoDto unitDto : units) {
if(syCode.equals(unitDto.getUseCode())){
unitDto.setSort(0);
continue;
}
if(unitDto.getAgencyClassify().contains(JyAgencyClassifyEnum.SBGY.getCode())){
unitDto.setSort(-1);
continue;
}
if(unitDto.getAgencyClassify().contains(JyAgencyClassifyEnum.SBDSF.getCode())){
unitDto.setSort(1);
}
}
return units.stream().sorted(Comparator.comparing(RuleInspectUnitIndoDto::getSort, Comparator.nullsLast(Integer::compareTo))).collect(Collectors.toList());
}
private Set<RuleInspectUnitIndoDto> distinctByUseCode(List<TzBaseEnterpriseInfoDto> tzBaseEnterpriseInfoList) {
return tzBaseEnterpriseInfoList.stream().map(u -> {
RuleInspectUnitIndoDto ruleInspectUnitIndoDto = new RuleInspectUnitIndoDto();
BeanUtil.copyProperties(u, ruleInspectUnitIndoDto);
ruleInspectUnitIndoDto.setAgencyClassify(u.getEquipType());
return ruleInspectUnitIndoDto;
}).collect(Collectors.toSet());
}
......@@ -150,8 +178,9 @@ public class RuleActionHandler {
this.removeNoAcceptUnit(tzBaseEnterpriseInfoList, inspectionEquipInfo);
// 4.数据去重按照use_code
Set<RuleInspectUnitIndoDto> units = this.distinctByUseCode(tzBaseEnterpriseInfoList);
// todo 5.tzBaseEnterpriseInfoList排序
ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), units);
// 5.tzBaseEnterpriseInfoList排序
List<RuleInspectUnitIndoDto> sortedUnits = this.sortedUnit(units);
ruleCommonService.publishMqttMessage(inspectionEquipInfo.getComponentKey(), sortedUnits);
} catch (MqttException e) {
log.error("Error publishing MQTT message: {}", e.getMessage());
}
......
......@@ -291,11 +291,18 @@
</if>
</select>
<select id="getInspectionUnitListByCodeNoZjjg" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto">
<include refid="unit-list-info" />
INNER JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
AND tjoa.status = '已完成'
and tjoa.open_biz_type = #{openBizType}
and tjoa.agency_classify != 'JYJGFL_ZJJG'
SELECT
info.sequence_nbr,
info.use_unit_code as use_code,
info.use_unit,
concat(info.use_unit_code,'_',info.use_unit) as useCodeAndName,
group_concat(joa.agency_classify) as equipType
FROM
tz_base_enterprise_info info
INNER JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
AND tjoa.status = '已完成'
and tjoa.open_biz_type = #{openBizType}
and tjoa.agency_classify != 'JYJGFL_ZJJG'
<if test="list !=null and list.size()>0">
AND info.use_code in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
......@@ -305,6 +312,7 @@
<if test="city != null and city != ''">
and tjoa.detection_region like concat('%',#{city},'%')
</if>
group by info.sequence_nbr
</select>
<select id="selectBySeq" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo">
select * from tz_base_enterprise_info where sequence_nbr = #{sequenceNbr}
......
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