Commit 3b6b0562 authored by suhuiguang's avatar suhuiguang

feat(jyjc):安改维设备过滤

1.设备查询慢
parent b3d69015
......@@ -55,7 +55,7 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti
*
* @return Set<String>
*/
Set<String> queryRecordInFlowing();
Set<String> queryRecordInFlowing(@Param("applicationUnitCode") String applicationUnitCode);
/**
......@@ -146,7 +146,7 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti
*/
List<Map<String, Object>> selectPieLineListOfNoInspectInfo(@Param("records") List<String> records);
Page<JSONObject> selectEquipList(Page<JSONObject> page,@Param("queryParams") Map<String, Object> map, @Param("records") Set<String> records);
Page<JSONObject> selectEquipList(Page<JSONObject> page,@Param("queryParams") Map<String, Object> map);
}
......@@ -260,6 +260,7 @@
where
a.sequence_nbr = ae.application_seq
and a.status='6611'
and a.application_unit_code = #{applicationUnitCode}
</select>
<select id="queryRecordListInFlowing" resultType="java.lang.String">
SELECT
......@@ -815,9 +816,26 @@
ORDER BY ui.REC_DATE DESC
</select>
<select id="selectEquipList" resultType="com.alibaba.fastjson.JSONObject">
select
a.* from
(SELECT
WITH maintenance_records AS (
SELECT
DISTINCT ON ("RECORD") "RECORD"
FROM
idx_biz_jg_maintenance_record_info
where
ME_UNIT_CREDIT_CODE = #{queryParams.ME_UNIT_CREDIT_CODE}
and INFORM_END >= CURRENT_DATE
ORDER BY "RECORD", "REC_DATE" DESC
),
equipment_flow AS (
SELECT
count(1) as cnt,
ae.equip_unicode
FROM tz_jyjc_inspection_application a
JOIN tz_jyjc_inspection_application_equip ae ON a.sequence_nbr = ae.application_seq
WHERE a.status = '6611'
GROUP BY ae.equip_unicode
)
SELECT
ibjui."RECORD" AS "SEQUENCE_NBR",
ibjui."REC_DATE",
ibjui."USE_UNIT_NAME",
......@@ -836,63 +854,48 @@
ibjoi."CODE96333",
ibjri."EQU_CODE",
ibjoi."SUPERVISORY_CODE",
concat_ws ( '/', ibjui."PROVINCE_NAME", ibjui."CITY_NAME", ibjui."COUNTY_NAME", ibjui."STREET_NAME" ) AS "USE_PLACE",
concat_ws('/', ibjui."PROVINCE_NAME", ibjui."CITY_NAME", ibjui."COUNTY_NAME", ibjui."STREET_NAME") AS "USE_PLACE",
ibjui."ADDRESS",
ibjui."EQU_STATE",
ibjui."IS_INTO_MANAGEMENT",
ibjoi."CLAIM_STATUS" AS "STATUS",
ibjfi."FACTORY_NUM",
ibjui."CREATE_DATE" ,
ibjui."SAFETY_MANAGER" ,
ibjui."CREATE_DATE",
ibjui."SAFETY_MANAGER",
ibjui."PHONE",
ibjui."USE_DATE",
ibjui."USE_PLACE" as USE_SITE_CODE,
ibjui."DATA_QUALITY_SCORE",
ibjui.CITY,
ibjui.COUNTY
FROM
idx_biz_jg_use_info ibjui
LEFT JOIN amos_tzs_biz.idx_biz_jg_register_info ibjri ON ibjui."RECORD" = ibjri."RECORD"
LEFT JOIN amos_tzs_biz.idx_biz_jg_other_info ibjoi ON ibjui."RECORD" = ibjoi."RECORD"
LEFT JOIN amos_tzs_biz.idx_biz_jg_factory_info ibjfi ON ibjui."RECORD" = ibjfi."RECORD"
where
ibjui.COUNTY,
COALESCE(ef.cnt, 0) as flowingNum
FROM idx_biz_jg_use_info ibjui
JOIN maintenance_records mr ON ibjui."RECORD" = mr."RECORD"
JOIN amos_tzs_biz.idx_biz_jg_register_info ibjri ON ibjui."RECORD" = ibjri."RECORD"
JOIN amos_tzs_biz.idx_biz_jg_other_info ibjoi ON ibjui."RECORD" = ibjoi."RECORD"
JOIN amos_tzs_biz.idx_biz_jg_factory_info ibjfi ON ibjui."RECORD" = ibjfi."RECORD"
LEFT JOIN equipment_flow ef ON ibjui."RECORD" = ef.equip_unicode
WHERE
ibjri."EQU_LIST" = '3000'
<if test="records != null and records.size() > 0">
and ibjui.record != ALL(
ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>
])
</if>
) a,
(SELECT
DISTINCT ON ("RECORD") *
FROM
idx_biz_jg_maintenance_record_info
where ME_UNIT_CREDIT_CODE = #{queryParams.ME_UNIT_CREDIT_CODE}
and INFORM_END >= CURRENT_DATE
ORDER BY "RECORD", "REC_DATE" DESC) b
where
a.SEQUENCE_NBR = b.record
and (ef.cnt = 0 OR ef.cnt IS NULL)
<if test="queryParams.EQU_CATEGORY_CODE != null">
and a.EQU_CATEGORY_CODE = #{queryParams.EQU_CATEGORY_CODE}
and ibjri.EQU_CATEGORY = #{queryParams.EQU_CATEGORY_CODE}
</if>
<if test="queryParams.EQU_DEFINE_CODE != null">
and a.EQU_DEFINE_CODE = #{queryParams.EQU_DEFINE_CODE}
and ibjri.EQU_DEFINE = #{queryParams.EQU_DEFINE_CODE}
</if>
<if test="queryParams.CITY != null">
and a.CITY = #{queryParams.CITY}
and ibjui.CITY = #{queryParams.CITY}
</if>
<if test="queryParams.COUNTY != null">
and a.COUNTY = #{queryParams.COUNTY}
and ibjui.COUNTY = #{queryParams.COUNTY}
</if>
<if test="queryParams.EQU_CODE != null">
and a.EQU_CODE like concat('%',#{queryParams.EQU_CODE},'%')
and ibjri.EQU_CODE like concat('%',#{queryParams.EQU_CODE},'%')
</if>
<if test="queryParams.USE_INNER_CODE != null">
and a.USE_INNER_CODE like concat('%',#{queryParams.USE_INNER_CODE},'%')
and ibjui.USE_INNER_CODE like concat('%',#{queryParams.USE_INNER_CODE},'%')
</if>
order by a.REC_DATE DESC
order by ibjui.REC_DATE DESC
</select>
</mapper>
......@@ -1516,7 +1516,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
int size = ObjectUtils.isEmpty(queryParams.getInteger("size")) ? 20 : queryParams.getInteger("size");
Page<JSONObject> page = new Page<>(pageNumber, size);
Map<String, Object> params = setFilterParamMap(queryParams);
Page<JSONObject> equips = this.getBaseMapper().selectEquipList(page, params, getEquipInFlowing());
Page<JSONObject> equips = this.getBaseMapper().selectEquipList(page, params);
equips.getRecords().forEach(item -> {
if (!ValidationUtil.isEmpty(item.get(EQU_STATE))) {
Integer integer = Integer.valueOf(item.get(EQU_STATE).toString());
......@@ -1648,7 +1648,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
if (!ObjectUtils.isEmpty(map.getString("equipTag1")) && BizCommonConstant.EQU_CATEGORY_CODE_GDYLRQ.equals(map.getString("EQU_CATEGORY_CODE"))) {
boolMust.must(QueryBuilders.termQuery("whetherSphericalTank.keyword", QueryParser.escape(map.getString("equipTag1"))));
}
this.setFilterOfInFlowing(boolMust, map.getString("EQU_LIST_CODE"), map.getString("inspectionType"), map.getString("EQU_CATEGORY_CODE"));
this.setFilterOfInFlowing(boolMust, map.getString("EQU_LIST_CODE"), map.getString("inspectionType"), map.getString("EQU_CATEGORY_CODE"), companyCode);
builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
builder.from((pageNumber - 1) * size);
......@@ -1772,9 +1772,10 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
* 过滤条件去掉流程中的设备,
*
* @param boolMust 条件
* @param companyCode
*/
private void setFilterOfInFlowing(BoolQueryBuilder boolMust, String equListCode, String inspectionType, String equCategoryCode) {
Set<String> records = this.getEquipInFlowing();
private void setFilterOfInFlowing(BoolQueryBuilder boolMust, String equListCode, String inspectionType, String equCategoryCode, String companyCode) {
Set<String> records = this.getEquipInFlowing(companyCode);
if (records != null && !records.isEmpty()) {
boolMust.mustNot(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records));
}
......@@ -1792,8 +1793,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
boolMust.must(QueryBuilders.existsQuery("IS_INTO_MANAGEMENT"));
}
private Set<String> getEquipInFlowing() {
return this.getBaseMapper().queryRecordInFlowing();
private Set<String> getEquipInFlowing(String companyCode) {
return this.getBaseMapper().queryRecordInFlowing(companyCode);
}
private void fillAddress(List<JSONObject> list) {
......
......@@ -402,6 +402,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
}
if (!(jyjcOpeningApplication.getOpenBizType().equals(OpenBizTypeEnumV2.SYDW.getCode()) || jyjcOpeningApplication.getOpenBizType().equals(OpenBizTypeEnumV2.AGW.getCode()))) {
JyjcInspectionHistory history = inspectionHistoryService.getBySSeq(jyjcOpeningApplication.getSequenceNbr());
if(history != null){
JSONObject hisData = history.getHistoryData();
List<BaseEnterpriseCertDto> certDtos = hisData.getJSONArray(BizCommonConstant.UNIT_LICENCE_KEY).toJavaList(BaseEnterpriseCertDto.class);
// 修改资质及证为超期状态
......@@ -413,6 +414,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
.set("remark", remark)
.eq("SEQUENCE_NBR", sequenceNbr);
this.update(updateWrapper);
}
} else {
LambdaUpdateWrapper<JyjcOpeningApplication> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(JyjcOpeningApplication::getStatus, FlowStatusEnum.TO_BE_DISCARD.getName())
......
......@@ -205,7 +205,7 @@ public class EnterpriseManageServiceImpl {
List<AgencyUserModel> userModels = FeignUtil.remoteCall(() -> Privilege.agencyUserClient.queryByCompanyId(companyModel.getSequenceNbr(), null, null, false));
if (!userModels.isEmpty()) {
List<String> userIds = userModels.stream().map(AgencyUserModel::getUserId).collect(Collectors.toList());
Privilege.agencyUserClient.multDeleteUser(String.join(",", userIds), true);
Privilege.agencyUserClient.multDeleteUser(String.join(",", userIds), false);
}
}
......
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