Commit 8c934585 authored by tianbo's avatar tianbo

feat(module-jg): 维保备案单据增加监管单位查询功能并优化数据过滤

- 在 JgMaintenanceContractDto 中添加 orgBranchCode 字段,用于监管单位查询
parent 2967f7bc
...@@ -205,4 +205,7 @@ public class JgMaintenanceContractDto extends BaseDto { ...@@ -205,4 +205,7 @@ public class JgMaintenanceContractDto extends BaseDto {
@ApiModelProperty(value = "取消人") @ApiModelProperty(value = "取消人")
private String cancelUserId; private String cancelUserId;
@ApiModelProperty(value = "监管单位机构代码")
private String orgBranchCode;
} }
...@@ -24,7 +24,8 @@ public interface JgMaintenanceContractMapper extends BaseMapper<JgMaintenanceCon ...@@ -24,7 +24,8 @@ public interface JgMaintenanceContractMapper extends BaseMapper<JgMaintenanceCon
Page<JgMaintenanceContractDto> getContractList(@Param("page") Page<JgMaintenanceContract> page, Page<JgMaintenanceContractDto> getContractList(@Param("page") Page<JgMaintenanceContract> page,
@Param("sort") SortVo sortMap, @Param("sort") SortVo sortMap,
@Param("contractDto") JgMaintenanceContractDto contractDto, @Param("contractDto") JgMaintenanceContractDto contractDto,
@Param("currentUserId") String currentUserId); @Param("currentUserId") String currentUserId,
@Param("client") String client);
JgMaintenanceContractDto queryBySequenceNbr(@Param("sequenceNbr") Long sequenceNbr); JgMaintenanceContractDto queryBySequenceNbr(@Param("sequenceNbr") Long sequenceNbr);
......
...@@ -16,6 +16,6 @@ import com.yeejoin.amos.boot.module.jg.api.vo.JgMaintenanceContractVo; ...@@ -16,6 +16,6 @@ import com.yeejoin.amos.boot.module.jg.api.vo.JgMaintenanceContractVo;
*/ */
public interface IJgMaintenanceContractService extends IService<JgMaintenanceContract> { public interface IJgMaintenanceContractService extends IService<JgMaintenanceContract> {
Page<JgMaintenanceContractVo> queryForPage(Page<JgMaintenanceContract> page, String sort, JgMaintenanceContractDto dto, ReginParams reginParams); Page<JgMaintenanceContractVo> queryForPage(Page<JgMaintenanceContract> page, String sort, JgMaintenanceContractDto dto, ReginParams reginParams, String client);
} }
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
WITH equip_data as ( WITH equip_data as (
SELECT SELECT
enable_disable_apply_id as applyId, enable_disable_apply_id as applyId,
equ_id as equId,
group_concat(distinct si."ORG_BRANCH_CODE") as orgBranchCodes group_concat(distinct si."ORG_BRANCH_CODE") as orgBranchCodes
FROM FROM
tzs_jg_enable_disable_eq ede tzs_jg_enable_disable_eq ede
...@@ -36,7 +35,7 @@ ...@@ -36,7 +35,7 @@
jed.create_user_id as createUserId, jed.create_user_id as createUserId,
jed.next_task_id as nextTaskId jed.next_task_id as nextTaskId
FROM tzs_jg_enable_disable jed FROM tzs_jg_enable_disable jed
left join equip_data jede on jede.applyId = jed.sequence_nbr left join equip_data ed on ed.applyId = jed.sequence_nbr
</sql> </sql>
<select id="pageList" resultType="java.util.Map"> <select id="pageList" resultType="java.util.Map">
<include refid="page_list"/> <include refid="page_list"/>
......
...@@ -16,6 +16,16 @@ ...@@ -16,6 +16,16 @@
</delete> </delete>
<sql id="page_list"> <sql id="page_list">
<![CDATA[/*+ set(query_dop 16)*/ ]]>
WITH equip_data as (
SELECT
equip_transfer_id as applyId,
group_concat(distinct si."ORG_BRANCH_CODE") as orgBranchCodes
FROM
tzs_jg_maintenance_contract_eq ede
LEFT JOIN idx_biz_jg_supervision_info si ON si."RECORD" = ede.equ_id
GROUP BY equip_transfer_id
)
SELECT SELECT
tjmc.sequence_nbr, tjmc.sequence_nbr,
tjmc.apply_no, tjmc.apply_no,
...@@ -41,19 +51,13 @@ ...@@ -41,19 +51,13 @@
tjmc.cancel_reason, tjmc.cancel_reason,
date_format(tjmc.create_date,'%Y-%m-%d') AS createDate, date_format(tjmc.create_date,'%Y-%m-%d') AS createDate,
concat(date_format(IFNULL(inform_start, null),'%Y-%m-%d'),' ~ ',date_format(IFNULL(inform_end, null),'%Y-%m-%d')) as informStartAndEnd concat(date_format(IFNULL(inform_start, null),'%Y-%m-%d'),' ~ ',date_format(IFNULL(inform_end, null),'%Y-%m-%d')) as informStartAndEnd
FROM
<!-- ri."EQU_CODE" as equCode,--> tzs_jg_maintenance_contract tjmc
<!-- (SELECT name from tz_equipment_category ec WHERE ec.code = ri.EQU_LIST) AS equList,--> left join equip_data ed on ed.applyId = tjmc.sequence_nbr
<!-- (select name from tz_equipment_category ec WHERE ec.code = ri.EQU_CATEGORY) AS equCategory,-->
<!-- (select name from tz_equipment_category ec WHERE ec.code = ri.EQU_DEFINE) AS equDefine-->
</sql> </sql>
<select id="getContractList" resultType="com.yeejoin.amos.boot.module.jg.api.dto.JgMaintenanceContractDto"> <select id="getContractList" resultType="com.yeejoin.amos.boot.module.jg.api.dto.JgMaintenanceContractDto">
<include refid="page_list"/> <include refid="page_list"/>
FROM
amos_tzs_biz.tzs_jg_maintenance_contract tjmc
<!-- LEFT JOIN tzs_jg_maintenance_contract_eq tjmce ON tjmce.equip_transfer_id = tjmc.sequence_nbr-->
<!-- LEFT JOIN idx_biz_jg_register_info ri ON ri.record = tjmce.equ_id-->
<where> <where>
tjmc.is_delete = 0 tjmc.is_delete = 0
<if test="contractDto.applyNo != '' and contractDto.applyNo != null"> <if test="contractDto.applyNo != '' and contractDto.applyNo != null">
...@@ -88,47 +92,31 @@ ...@@ -88,47 +92,31 @@
<if test="contractDto.createDate != null"> <if test="contractDto.createDate != null">
AND tjmc.create_date LIKE concat(DATE_FORMAT(#{contractDto.createDate},'%Y-%m-%d'),'%') AND tjmc.create_date LIKE concat(DATE_FORMAT(#{contractDto.createDate},'%Y-%m-%d'),'%')
</if> </if>
<!-- <if test="contractDto.equList != null and contractDto.equList != ''">-->
<!-- AND ri."EQU_LIST" = #{contractDto.equList}-->
<!-- </if>-->
<!-- <if test="contractDto.equCategory != null and contractDto.equCategory != ''">-->
<!-- AND ri."equ_category" = #{contractDto.equCategory}-->
<!-- </if>-->
<!-- <if test="contractDto.equDefine != null and contractDto.equDefine != ''">-->
<!-- AND ri."EQU_DEFINE" = #{contractDto.equDefine}-->
<!-- </if>-->
<!-- <if test="contractDto.equCode != null and contractDto.equCode != ''">-->
<!-- AND ri."EQU_CODE" like concat('%',#{contractDto.equCode},'%')-->
<!-- </if>-->
-- 数据过滤开始 ---------------------------------------------------- -- 数据过滤开始 ----------------------------------------------------
<!-- <choose>--> -- 只有使用单位或者维保单位用,或者都没有
<!-- <when test="contractDto.useUnitCodeFilter != '' and contractDto.useUnitCodeFilter != null and--> <if test="contractDto.useUnitCodeFilter != '' and contractDto.useUnitCodeFilter != null">
<!-- contractDto.maintenanceUnitCodeFilter != '' and contractDto.maintenanceUnitCodeFilter != null">--> and (tjmc.use_unit_code = #{contractDto.useUnitCodeFilter}
<!-- &#45;&#45; 同时有使用单位和维保单位用--> or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' ))
<!-- and (--> </if>
<!-- tjmc.use_unit_code = #{contractDto.useUnitCodeFilter}--> <if test="contractDto.maintenanceUnitCodeFilter != '' and contractDto.maintenanceUnitCodeFilter != null">
<!-- or tjmc.maintenance_unit_code = #{contractDto.maintenanceUnitCodeFilter}--> and (tjmc.maintenance_unit_code = #{contractDto.maintenanceUnitCodeFilter}
<!-- or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' )--> or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' ))
<!-- )--> and (tjmc.instance_id <![CDATA[<>]]> '')
<!-- </when>--> </if>
<!-- <otherwise >--> -- 接受机构用
-- 只有使用单位或者维保单位用,或者都没有
<if test="contractDto.useUnitCodeFilter != '' and contractDto.useUnitCodeFilter != null">
and (tjmc.use_unit_code = #{contractDto.useUnitCodeFilter}
or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' ))
</if>
<if test="contractDto.maintenanceUnitCodeFilter != '' and contractDto.maintenanceUnitCodeFilter != null">
and (tjmc.maintenance_unit_code = #{contractDto.maintenanceUnitCodeFilter}
or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' ))
and (tjmc.instance_id <![CDATA[<>]]> '')
</if>
<!-- </otherwise>-->
<!-- </choose>-->
-- 监管单位用
<if test="contractDto.receiveOrgCodeFilter != '' and contractDto.receiveOrgCodeFilter != null"> <if test="contractDto.receiveOrgCodeFilter != '' and contractDto.receiveOrgCodeFilter != null">
and (tjmc.receive_org_code = #{contractDto.receiveOrgCodeFilter} and (tjmc.receive_org_code = #{contractDto.receiveOrgCodeFilter}
or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' )) or tjmc.transfer_to_user_ids LIKE concat ( '%', #{currentUserId}, '%' ))
and (tjmc.instance_id <![CDATA[<>]]> '') and (tjmc.instance_id <![CDATA[<>]]> '')
</if>
-- 监管单位用
<if test="contractDto.orgBranchCode != '' and contractDto.orgBranchCode != null">
and tjmc.instance_id <![CDATA[<>]]> ''
AND EXISTS (
SELECT 1
FROM unnest(string_to_array(ed.orgBranchCodes, ',')) AS elem
WHERE elem LIKE concat(#{contractDto.orgBranchCode}, '%')
)
</if> </if>
-- 数据过滤结束 ---------------------------------------------------- -- 数据过滤结束 ----------------------------------------------------
</where> </where>
...@@ -183,7 +171,6 @@ ...@@ -183,7 +171,6 @@
<select id="queryMaintenanceInIds" resultType="com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.MaintenanceVo"> <select id="queryMaintenanceInIds" resultType="com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.MaintenanceVo">
<include refid="page_list"/> <include refid="page_list"/>
from amos_tzs_biz.tzs_jg_maintenance_contract tjmc
<where> <where>
<if test='ids != null'> <if test='ids != null'>
and tjmc.sequence_nbr in and tjmc.sequence_nbr in
......
package com.yeejoin.amos.boot.module.jg.biz.controller; package com.yeejoin.amos.boot.module.jg.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.JgMaintenanceContractDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgMaintenanceContractDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract; import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract;
...@@ -13,11 +11,10 @@ import com.yeejoin.amos.boot.module.jg.api.vo.JgMaintenanceContractVo; ...@@ -13,11 +11,10 @@ import com.yeejoin.amos.boot.module.jg.api.vo.JgMaintenanceContractVo;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgMaintenanceContractServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgMaintenanceContractServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.component.event.RestEventTrigger; import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -139,12 +136,14 @@ public class JgMaintenanceContractController extends BaseController { ...@@ -139,12 +136,14 @@ public class JgMaintenanceContractController extends BaseController {
public ResponseModel<Page<JgMaintenanceContractVo>> queryForPage(@RequestParam(value = "current") int current, public ResponseModel<Page<JgMaintenanceContractVo>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, @RequestParam(value = "size") int size,
@RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "sort", required = false) String sort,
@ApiParam(value = "客户端类型: jgAudit-监管审核;jgLook-监管查看")
@RequestParam(value = "client", required = false, defaultValue = "jgAudit") String client,
@RequestBody(required = false) JgMaintenanceContractDto dto) { @RequestBody(required = false) JgMaintenanceContractDto dto) {
Page<JgMaintenanceContract> page = new Page<>(); Page<JgMaintenanceContract> page = new Page<>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
Page<JgMaintenanceContractVo> contractDtoPage = jgMaintenanceContractServiceImpl.queryForPage(page, sort, dto, reginParams); Page<JgMaintenanceContractVo> contractDtoPage = jgMaintenanceContractServiceImpl.queryForPage(page, sort, dto, reginParams, client);
return ResponseHelper.buildResponse(contractDtoPage); return ResponseHelper.buildResponse(contractDtoPage);
} }
......
...@@ -461,12 +461,12 @@ public class IdxBizJgProjectContraptionServiceImplService extends BaseEntityServ ...@@ -461,12 +461,12 @@ public class IdxBizJgProjectContraptionServiceImplService extends BaseEntityServ
} }
private Map<String, Boolean> checkContraptionIsCanEdit(List<Long> projectContraptionIdList) { private Map<String, Boolean> checkContraptionIsCanEdit(List<Long> projectContraptionIdList) {
Map<String, Boolean> resultMap = new HashMap<>(); Map<String, Boolean> resultMap = new HashMap<>();
if (ValidationUtil.isEmpty(projectContraptionIdList)) { if (ValidationUtil.isEmpty(projectContraptionIdList)) {
return resultMap; return resultMap;
} }
List<Map<String, Integer>> inUseTimeMap = this.baseMapper.countContraptionInUseTimesForEdit(projectContraptionIdList); List<Map<String, Integer>> inUseTimeMap = this.baseMapper.countContraptionInUseTimesForEdit(projectContraptionIdList);
return getCheckResultMap(projectContraptionIdList, resultMap, inUseTimeMap); return getCheckResultMap(projectContraptionIdList, resultMap, inUseTimeMap);
} }
......
...@@ -116,7 +116,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -116,7 +116,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
/** /**
* 分页查询 * 分页查询
*/ */
public Page<JgMaintenanceContractVo> queryForPage(Page<JgMaintenanceContract> page, String sort, JgMaintenanceContractDto dto, ReginParams reginParams) { public Page<JgMaintenanceContractVo> queryForPage(Page<JgMaintenanceContract> page, String sort, JgMaintenanceContractDto dto, ReginParams reginParams, String client) {
if (ObjectUtils.isEmpty(dto)) { if (ObjectUtils.isEmpty(dto)) {
dto = new JgMaintenanceContractDto(); dto = new JgMaintenanceContractDto();
} }
...@@ -136,6 +136,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -136,6 +136,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
if ("supervision".equals(companyLevel)) { if ("supervision".equals(companyLevel)) {
// 监管单位用"接收机构统一使用代码"匹配 // 监管单位用"接收机构统一使用代码"匹配
dto.setReceiveOrgCodeFilter(company.getCompanyCode()); dto.setReceiveOrgCodeFilter(company.getCompanyCode());
dto.setOrgBranchCode(company.getOrgCode());
} else if ("company".equals(companyLevel)) { } else if ("company".equals(companyLevel)) {
if (companyType.contains(CompanyTypeEnum.USE.getCode()) || companyType.contains(CompanyTypeEnum.INDIVIDUAL.getCode())) { if (companyType.contains(CompanyTypeEnum.USE.getCode()) || companyType.contains(CompanyTypeEnum.INDIVIDUAL.getCode())) {
// 使用单位用"使用单位统一信用代码"匹配数据 // 使用单位用"使用单位统一信用代码"匹配数据
...@@ -147,7 +148,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -147,7 +148,7 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
dto.setMaintenanceUnitCodeFilter(company.getCompanyCode()); dto.setMaintenanceUnitCodeFilter(company.getCompanyCode());
} }
} }
contractList = maintenanceContractMapper.getContractList(page, sortMap, dto, reginParams.getUserModel().getUserId()); contractList = maintenanceContractMapper.getContractList(page, sortMap, dto, reginParams.getUserModel().getUserId(), client);
List<JgMaintenanceContractDto> records = contractList.getRecords().stream().peek(x -> x.setUnitType(company.getCompanyType())).collect(Collectors.toList()); List<JgMaintenanceContractDto> records = contractList.getRecords().stream().peek(x -> x.setUnitType(company.getCompanyType())).collect(Collectors.toList());
contractList.setRecords(records); contractList.setRecords(records);
BeanUtils.copyProperties(contractList, result); BeanUtils.copyProperties(contractList, result);
......
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