Commit af39bcc7 authored by suhuiguang's avatar suhuiguang

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

1.报检规则推送规则
parent 05372613
package com.yeejoin.amos.boot.module.jyjc.api.mapper; package com.yeejoin.amos.boot.module.jyjc.api.mapper;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.dto.CountDto; import com.yeejoin.amos.boot.biz.common.dto.CountDto;
...@@ -136,6 +137,8 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti ...@@ -136,6 +137,8 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti
* @return List<Map<String, Object>> * @return List<Map<String, Object>>
*/ */
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);
} }
...@@ -728,4 +728,83 @@ ...@@ -728,4 +728,83 @@
</foreach> </foreach>
ORDER BY ui.REC_DATE DESC ORDER BY ui.REC_DATE DESC
</select> </select>
<select id="selectEquipList" resultType="com.alibaba.fastjson.JSONObject">
select
a.* from
(SELECT
ibjui."RECORD" AS "SEQUENCE_NBR",
ibjui."REC_DATE",
ibjui."USE_UNIT_NAME",
ibjui."USE_UNIT_CREDIT_CODE",
ibjui."USC_UNIT_NAME",
ibjui."USC_UNIT_CREDIT_CODE",
ibjri."EQU_LIST" AS "EQU_LIST_CODE",
ibjri."EQU_DEFINE" AS "EQU_DEFINE_CODE",
ibjri."PRODUCT_NAME",
ibjri."BRAND_NAME",
ibjri."EQU_TYPE",
ibjri."EQU_CATEGORY" AS "EQU_CATEGORY_CODE",
ibjri."USE_ORG_CODE",
ibjui."USE_INNER_CODE",
ibjui."DATA_SOURCE",
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",
ibjui."ADDRESS",
ibjui."EQU_STATE",
ibjui."IS_INTO_MANAGEMENT",
ibjoi."CLAIM_STATUS" AS "STATUS",
ibjfi."FACTORY_NUM",
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
ibjri."EQU_LIST" = '3000'
<if test="records != null and records.size() > 0">
and ibjui.record not in
<foreach collection="records" item="record" open="(" close=")">
#{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
<if test="queryParams.EQU_CATEGORY_CODE != null">
and a.EQU_CATEGORY_CODE = #{queryParams.EQU_CATEGORY_CODE}
</if>
<if test="queryParams.EQU_DEFINE_CODE != null">
and a.EQU_DEFINE_CODE = #{queryParams.EQU_DEFINE_CODE}
</if>
<if test="queryParams.CITY != null">
and a.CITY = #{queryParams.CITY}
</if>
<if test="queryParams.COUNTY != null">
and a.COUNTY = #{queryParams.COUNTY}
</if>
<if test="queryParams.EQU_CODE != null">
and a.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},'%')
</if>
order by a.REC_DATE DESC
</select>
</mapper> </mapper>
...@@ -264,9 +264,9 @@ public class JyjcInspectionApplicationController extends BaseController { ...@@ -264,9 +264,9 @@ public class JyjcInspectionApplicationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "设备注册信息分页查询", notes = "设备注册信息分页查询") @ApiOperation(httpMethod = "GET", value = "设备注册信息分页查询", notes = "设备注册信息分页查询")
@GetMapping(value = "/equip/list") @GetMapping(value = "/equip/list")
public ResponseModel<Page<JSONObject>> getEquipListWithOutFlowing(@RequestParam Map<String, Object> map) { public ResponseModel<Page<?>> getEquipListWithOutFlowing(@RequestParam Map<String, Object> map) {
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.queryForEquipmentRegisterPage(jsonObject)); return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.queryForEquipmentRegisterPageDispatch(jsonObject));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
...@@ -47,7 +47,6 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum; ...@@ -47,7 +47,6 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.model.DictionarieModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieModel;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
...@@ -90,6 +89,7 @@ import java.math.BigDecimal; ...@@ -90,6 +89,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -171,6 +171,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -171,6 +171,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
@Resource @Resource
private EquipCategoryTypeHandler typeHandler; private EquipCategoryTypeHandler typeHandler;
@Resource
private EquipCategoryTypeHandler equipCategoryTypeHandler;
@NotNull @NotNull
public static List<DictionarieModel> getDictionarieModels(String bizType) { public static List<DictionarieModel> getDictionarieModels(String bizType) {
...@@ -1210,24 +1213,16 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1210,24 +1213,16 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/** /**
* 获取当前登录人单位类型 * 获取当前登录人单位类型
* *
* @return
*/ */
public JSONObject getCompanyType() { public JSONObject getCompanyType() {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
if (!ValidationUtil.isEmpty(company)) { object.put("level", company.getLevel());
object.put("level", company.getLevel()); object.put("orgCode", company.getOrgCode());
object.put("orgCode", company.getOrgCode()); object.put("companyName", company.getCompanyName());
object.put("companyName", company.getCompanyName()); object.put("companyCode", company.getCompanyCode());
object.put("companyCode", company.getCompanyCode()); object.put("companyType", company.getCompanyType());
CompanyModel result = Privilege.companyClient.queryByCompanyCode(company.getCompanyCode()).getResult();
if (!ValidationUtil.isEmpty(result)) {
object.put("companyType", result.getCompanyType());
}
}
return object; return object;
} }
...@@ -1354,6 +1349,78 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1354,6 +1349,78 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
return result; return result;
} }
private Function<JSONObject, Page<?>> handleByInspectType(String inspectType) {
return queryParams -> {
if (shouldUseNewMethod(inspectType)) {
// 调用新方法处理特定inspectType的逻辑
return handleSpecialInspectType(queryParams, inspectType);
} else {
// 默认使用原有查询方法
return queryForEquipmentRegisterPage(queryParams);
}
};
}
private Page<?> handleSpecialInspectType(JSONObject queryParams, String inspectType) {
int pageNumber = ObjectUtils.isEmpty(queryParams.getInteger("number")) ? 1 : queryParams.getInteger("number");
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());
equips.getRecords().forEach(item -> {
if (!ValidationUtil.isEmpty(item.get(EQU_STATE))) {
Integer integer = Integer.valueOf(item.get(EQU_STATE).toString());
String status = EquimentEnum.getName.get(integer);
item.put(EQU_STATE, status);
}
item.put("EQU_LIST", equipCategoryTypeHandler.handle(item.getString("EQU_LIST_CODE")));
item.put("EQU_CATEGORY", equipCategoryTypeHandler.handle(item.getString("EQU_CATEGORY_CODE")));
item.put("EQU_DEFINE", equipCategoryTypeHandler.handle(item.getString("EQU_DEFINE_CODE")));
item.put("record", item.get(SEQUENCE_NBR));
item.put("ADDRESS", this.removeSplitLine(item));
});
return equips;
}
private Map<String, Object> setFilterParamMap(JSONObject queryParams) {
// 获取当前登录人单位类型
JSONObject company = getCompanyType();
Map<String, Object> params = new HashMap<>();
String companyCode = company.getString("companyCode").contains("_") ? company.getString("companyCode").split("_")[1] : company.getString("companyCode");
params.put("ME_UNIT_CREDIT_CODE", companyCode);
// 设备类别
if (!ObjectUtils.isEmpty(queryParams.getString("EQU_CATEGORY_CODE"))) {
params.put("EQU_CATEGORY_CODE", queryParams.getString("EQU_CATEGORY_CODE"));
}
// 设备类别编码
if (!ObjectUtils.isEmpty(queryParams.getString("EQU_DEFINE_CODE"))) {
params.put("EQU_DEFINE_CODE", queryParams.getString("EQU_DEFINE_CODE"));
}
// 地市
if (!ObjectUtils.isEmpty(queryParams.getString("CITY"))) {
params.put("CITY", queryParams.getString("CITY"));
}
// 区县
if (!ObjectUtils.isEmpty(queryParams.getString("COUNTY"))) {
params.put("COUNTY", queryParams.getString("COUNTY"));
}
// 设备代码模糊查询
if (!ObjectUtils.isEmpty(queryParams.getString(EQU_CODE))) {
params.put(EQU_CODE, queryParams.getString(EQU_CODE));
}
// 单位内部编号模糊查询
if (!ObjectUtils.isEmpty(queryParams.getString("USE_INNER_CODE"))) {
params.put("USE_INNER_CODE", queryParams.getString("USE_INNER_CODE"));
}
return params;
}
private boolean shouldUseNewMethod(String inspectType) {
JSONObject company = getCompanyType();
String type = company.getString("companyType");
return JYJCTypeEnum.DTJC.getCode().equals(inspectType) && "安装改造维修单位".equals(type);
}
/** /**
* 设备过滤查询-显示未提交的设备、未使用的设备,流程中的设备不显示 * 设备过滤查询-显示未提交的设备、未使用的设备,流程中的设备不显示
* *
...@@ -1381,11 +1448,6 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1381,11 +1448,6 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
String type = company.getString("companyType"); String type = company.getString("companyType");
// 按照身份过滤 // 按照身份过滤
setFilterByIndefinite(map, type, companyCode); setFilterByIndefinite(map, type, companyCode);
// 监管码
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
String supervisoryCode = map.getString("SUPERVISORY_CODE");
boolMust.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*" + supervisoryCode + "*"));
}
// 设备种类编码 // 设备种类编码
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE", QueryParser.escape(map.getString("EQU_LIST_CODE")))); boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE", QueryParser.escape(map.getString("EQU_LIST_CODE"))));
...@@ -1460,18 +1522,14 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1460,18 +1522,14 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
} }
} }
if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) { if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) {
String inspectionType = map.getString("inspectionType"); map.put("USC_UNIT_CREDIT_CODE", companyCode);
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("个人主体")) { if (!ValidationUtil.isEmpty(type) && type.contains("个人主体")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode); map.put("USE_UNIT_CREDIT_CODE", companyCode);
} }
} }
/** /**
* 过滤条件去掉流程中的设备, * 过滤条件去掉流程中的设备,
* *
...@@ -1673,4 +1731,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1673,4 +1731,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
projectContraptionPage.getRecords().forEach(pro -> pro.setDataQualityScore(commonService.castDataQualityScore2Name(pro.getDataQualityScore(), pro.getIsIntoManagement()))); projectContraptionPage.getRecords().forEach(pro -> pro.setDataQualityScore(commonService.castDataQualityScore2Name(pro.getDataQualityScore(), pro.getIsIntoManagement())));
return projectContraptionPage; return projectContraptionPage;
} }
public Page<?> queryForEquipmentRegisterPageDispatch(JSONObject jsonObject) {
return handleByInspectType(jsonObject.getString("inspectionType")).apply(jsonObject);
}
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.yeejoin.amos.boot.biz.common.typeHandler.TypeHandler; ...@@ -5,6 +5,7 @@ import com.yeejoin.amos.boot.biz.common.typeHandler.TypeHandler;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map; import java.util.Map;
...@@ -22,7 +23,7 @@ public class EquipCategoryTypeHandler implements TypeHandler<String> { ...@@ -22,7 +23,7 @@ public class EquipCategoryTypeHandler implements TypeHandler<String> {
@Override @Override
public String handle(String code) { public String handle(String code) {
return code != null ? CODE_NAME_MAP.computeIfAbsent(code, (k) -> { return StringUtils.isNotEmpty(code) ? CODE_NAME_MAP.computeIfAbsent(code, (k) -> {
EquipmentCategory equipmentCategory = equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, code).select(EquipmentCategory::getName, EquipmentCategory::getId)); EquipmentCategory equipmentCategory = equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, code).select(EquipmentCategory::getName, EquipmentCategory::getId));
return equipmentCategory == null ? "" : equipmentCategory.getName(); return equipmentCategory == null ? "" : equipmentCategory.getName();
}) : null; }) : null;
......
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