Commit 3b6b0562 authored by suhuiguang's avatar suhuiguang

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

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