Commit 2967f7bc authored by tianbo's avatar tianbo

feat(module-jg): 增加监管查看功能并优化查询逻辑

- 在 JgChangeRegistrationReform 和 JgEnableDisable 接口中添加 client 参数,用于区分监管审核和监管查看
parent f95ceb0f
......@@ -109,6 +109,9 @@ public class JgChangeRegistrationReformDto extends BaseDto {
@ApiModelProperty(value = "登记机构代码")
private String receiveOrgCode;
@ApiModelProperty(value = "监管单位机构代码")
private String orgBranchCode;
@ApiModelProperty(value = "登记机构公司代码")
private String receiveCompanyCode;
......
......@@ -43,6 +43,9 @@ public class JgEnableDisableDto extends BaseDto {
@ApiModelProperty(value = "接受机构公司代码")
private String receiveCompanyCode;
@ApiModelProperty(value = "监管单位机构代码")
private String orgBranchCode;
@ApiModelProperty(value = "终审通过时间")
private Date auditPassDate;
......
......@@ -27,7 +27,8 @@ public interface JgChangeRegistrationReformMapper extends BaseMapper<JgChangeReg
@Param("sort") SortVo sortMap,
@Param("dto") JgChangeRegistrationReformDto dto ,
@Param("roleIds") List<String> roleIds,
@Param("currentUserId")String currentUserId);
@Param("currentUserId")String currentUserId,
@Param("client") String client);
List<ChangeRegistrationReformVo> queryChangeRegistrationReformInIds(@Param("ids") List<String> ids);
......
......@@ -26,7 +26,8 @@ public interface JgEnableDisableMapper extends BaseMapper<JgEnableDisable> {
@Param("sort") SortVo sortMap,
@Param("dto") JgEnableDisableDto dto,
@Param("type") String type,
@Param("userId") String userId);
@Param("userId") String userId,
@Param("client") String client);
List<EnableDisableVo> queryEnableDisableInIds(@Param("ids") List<String> ids);
......
......@@ -26,7 +26,7 @@ public interface IJgChangeRegistrationReformService {
* @param roleIds
* @return
*/
Page<Map<String, Object>> getList(JgChangeRegistrationReformDto dto,String sort, Page<Map<String, Object>> page, List<String> roleIds);
Page<Map<String, Object>> getList(JgChangeRegistrationReformDto dto,String sort, Page<Map<String, Object>> page, List<String> roleIds, String client);
/**
* @deprecated 保存数据-根据入参判断是暂存还是执行流程
......
......@@ -30,21 +30,23 @@
ur.next_execute_user_ids as nextExecuteUserIds,
ur.next_task_id as nextTaskId,
ur.create_user_id as createUserId,
oi.CODE96333 as code96333,
oi."CODE96333" as code96333,
ur.cancel_reason as cancelReason,
(SELECT name from tz_equipment_category ec WHERE ec.code = jri.EQU_LIST) AS equList,
(select name from tz_equipment_category ec WHERE ec.code = jri.EQU_DEFINE) AS equDefine,
ur.receive_company_code,
jri.EQU_LIST,
jri.EQU_CATEGORY,
jri.EQU_DEFINE,
jri."EQU_LIST",
jri."EQU_CATEGORY",
jri."EQU_DEFINE",
ur.transfer_to_user_ids,
ur.use_unit_credit_code
ur.use_unit_credit_code,
si."ORG_BRANCH_CODE" as orgBranchCode
from tzs_jg_change_registration_reform ur
LEFT JOIN tzs_jg_change_registration_reform_eq re on ur.sequence_nbr = re.equip_transfer_id
LEFT JOIN idx_biz_jg_register_info jri on jri.RECORD = re.equ_id
LEFT JOIN idx_biz_jg_use_info use on use.RECORD = re.equ_id
LEFT JOIN idx_biz_jg_other_info oi ON oi.RECORD = re.equ_id
LEFT JOIN idx_biz_jg_register_info jri on jri."RECORD" = re.equ_id
LEFT JOIN idx_biz_jg_use_info use on use."RECORD" = re.equ_id
LEFT JOIN idx_biz_jg_other_info oi ON oi."RECORD" = re.equ_id
LEFT JOIN idx_biz_jg_supervision_info si ON si."RECORD" = re.equ_id
where
jri."EQU_LIST" != '8000'
and ur.is_delete = 0
......@@ -62,7 +64,7 @@
pc.project_contraption as productName,
pc.equ_code as equCode,
'' as innerCode,
concat_ws('',pc.PROVINCE_NAME,pc.CITY_NAME,pc.COUNTY_NAME,pc.STREET_NAME, pc."ADDRESS") as place,
concat_ws('',pc.PROVINCE_NAME,pc.CITY_NAME,pc.COUNTY_NAME,pc.STREET_NAME, pc.ADDRESS) as place,
ifnull(ur.instance_id, '') as instanceId,
'' as equipId,
ur.apply_no as applyNo,
......@@ -81,7 +83,8 @@
pc.EQU_CATEGORY,
pc.EQU_DEFINE,
ur.transfer_to_user_ids,
ur.use_unit_credit_code
ur.use_unit_credit_code,
pc.org_code orgBranchCode
from tzs_jg_change_registration_reform ur,
idx_biz_jg_project_contraption pc
where
......@@ -118,16 +121,16 @@
and ur.regDate like concat('%',DATE_FORMAT(#{dto.applicationDate},'%Y-%m-%d'),'%')
</if>
<if test="dto.equList != null and dto.equList != ''">
AND ur."EQU_LIST" = #{dto.equList}
AND ur.EQU_LIST = #{dto.equList}
</if>
<if test="dto.equCategory != null and dto.equCategory != ''">
AND ur."equ_category" = #{dto.equCategory}
AND ur.equ_category = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
AND jri."EQU_DEFINE" = #{dto.equDefine}
AND ur.EQU_DEFINE = #{dto.equDefine}
</if>
<if test="dto.equCode != null and dto.equCode != ''">
AND ur."EQU_CODE" like concat('%',#{dto.equCode},'%')
AND ur.equCode like concat('%',#{dto.equCode},'%')
</if>
<if test="dto.code96333 != null and dto.code96333 != ''">
AND ur.CODE96333 like concat('%',#{dto.code96333},'%')
......@@ -136,11 +139,19 @@
AND ur.createDate LIKE concat(DATE_FORMAT(#{dto.createDate},'%Y-%m-%d'),'%')
</if>
<if test="dto.equAddress != null and dto.equAddress != ''">
AND ur."place" LIKE CONCAT('%', #{dto.equAddress}, '%')
AND ur.place LIKE CONCAT('%', #{dto.equAddress}, '%')
</if>
<if test="dto.dataType != null and dto.dataType == 'supervision' ">
and (ur.receive_company_code = #{dto.receiveOrgCode} or (ur.transfer_to_user_ids like concat('%',#{currentUserId},'%')))
AND ur.instanceId <![CDATA[<>]]> ''
<choose>
<when test="client == 'jgAudit' and dto.receiveOrgCode != null and dto.receiveOrgCode != ''">
and (ur.receive_company_code = #{dto.receiveOrgCode} or (ur.transfer_to_user_ids like concat('%', #{currentUserId}, '%')))
AND ur.instanceId <![CDATA[<>]]> ''
</when>
<when test="client == 'jgLook' and dto.orgBranchCode != null and dto.orgBranchCode != ''">
and ur.orgBranchCode like concat(#{dto.orgBranchCode}, '%')
AND ur.instanceId <![CDATA[<>]]> ''
</when>
</choose>
</if>
<if test="dto.dataType != null and dto.dataType == 'company' ">
and (ur.use_unit_credit_code = #{dto.useUnitCreditCode} or (ur.transfer_to_user_ids like concat('%',#{currentUserId},'%')))
......
......@@ -3,6 +3,17 @@
<mapper namespace="com.yeejoin.amos.boot.module.jg.api.mapper.JgEnableDisableMapper">
<sql id="page_list">
<![CDATA[/*+ set(query_dop 16)*/ ]]>
WITH equip_data as (
SELECT
enable_disable_apply_id as applyId,
equ_id as equId,
group_concat(distinct si."ORG_BRANCH_CODE") as orgBranchCodes
FROM
tzs_jg_enable_disable_eq ede
LEFT JOIN idx_biz_jg_supervision_info si ON si.record = ede.equ_id
GROUP BY enable_disable_apply_id
)
SELECT
CASE
when jed.apply_type = 'SB_TY' then '设备停用'
......@@ -25,6 +36,7 @@
jed.create_user_id as createUserId,
jed.next_task_id as nextTaskId
FROM tzs_jg_enable_disable jed
left join equip_data jede on jede.applyId = jed.sequence_nbr
</sql>
<select id="pageList" resultType="java.util.Map">
<include refid="page_list"/>
......@@ -37,8 +49,20 @@
and jed.audit_status = #{dto.auditStatus}
</if>
<if test="type != 'company'">
AND jed.instance_id is not null
and (jed.receive_company_code = #{dto.receiveCompanyCode} or jed.transfer_to_user_ids like concat('%',#{userId},'%'))
<choose>
<when test="client == 'jgAudit' and dto.receiveCompanyCode != null and dto.receiveCompanyCode != ''">
AND jed.instance_id is not null
AND (jed.receive_company_code = #{dto.receiveCompanyCode} or jed.transfer_to_user_ids like concat('%',#{userId},'%'))
</when>
<when test="client == 'jgLook' and dto.orgBranchCode != null and dto.orgBranchCode != ''">
AND jed.instance_id is not null
AND EXISTS (
SELECT 1
FROM unnest(string_to_array(ed.orgBranchCodes, ',')) AS elem
WHERE elem LIKE concat(#{dto.orgBranchCode}, '%')
)
</when>
</choose>
</if>
<if test="type == 'company'">
and (jed.use_unit_credit_code = #{dto.useUnitCreditCode} or jed.transfer_to_user_ids like concat('%',#{userId},'%'))
......
......@@ -506,6 +506,15 @@
<if test="dto.equDefine != null and dto.equDefine != ''">
AND jri.EQU_DEFINE = #{dto.equDefine}
</if>
<if test="dto.equCode != null and dto.equCode != ''">
AND jri.EQU_CODE LIKE CONCAT('%', #{dto.equCode}, '%')
</if>
<if test="dto.code96333 != null and dto.code96333 != ''">
AND other.CODE96333 LIKE CONCAT('%', #{dto.code96333}, '%')
</if>
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
AND other.supervisory_code LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
</if>
</where>
GROUP BY re.equip_transfer_id
)
......@@ -558,20 +567,6 @@
FROM filtered_ur fu
LEFT JOIN equipment_data ed ON fu.sequence_nbr = ed.equip_transfer_id
WHERE 1=1
<!-- 设备代码过滤 -->
<if test="dto.equCode != null and dto.equCode != ''">
AND ed.equCode LIKE CONCAT('%', #{dto.equCode}, '%')
</if>
<!-- 96333码过滤 -->
<if test="dto.code96333 != null and dto.code96333 != ''">
AND ed.code96333 LIKE CONCAT('%', #{dto.code96333}, '%')
</if>
<!-- 监管码过滤 -->
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
AND ed.supervisoryCode LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
</if>
ORDER BY
<choose>
<when test="sort != null">
......@@ -583,86 +578,87 @@
</choose>
</select>
<select id="getListPageCount" resultType="java.lang.Long">
<select id="getListPageCount" resultType="long">
SELECT <![CDATA[/*+ set(query_dop 16)*/]]> COUNT(DISTINCT ur.sequence_nbr)
FROM tzs_jg_use_registration ur
LEFT JOIN tzs_jg_use_registration_eq re ON ur.sequence_nbr = re.equip_transfer_id
LEFT JOIN idx_biz_jg_register_info jri ON re.equ_id = jri.RECORD
LEFT JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD"
LEFT JOIN idx_biz_jg_other_info other ON re.equ_id = other."RECORD"
WHERE ur.is_delete = 0
AND ur.supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
AND ur.status <![CDATA[<>]]> '使用单位待提交'
<!-- 统一设备过滤条件 -->
<if test="dto.equList != null and dto.equList != ''">
AND jri.EQU_LIST = #{dto.equList}
AND jri."EQU_LIST" = #{dto.equList}
</if>
<if test="dto.equCategory != null and dto.equCategory != ''">
AND jri.EQU_CATEGORY = #{dto.equCategory}
AND jri."EQU_CATEGORY" = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
AND jri.EQU_DEFINE = #{dto.equDefine}
AND jri."EQU_DEFINE" = #{dto.equDefine}
</if>
<!-- 设备代码过滤 -->
<if test="dto.equCode != null and dto.equCode != ''">
AND equCode LIKE CONCAT('%', #{dto.equCode}, '%')
AND jri."EQU_CODE" LIKE CONCAT('%', #{dto.equCode}, '%')
</if>
<!-- 96333码过滤 -->
<if test="dto.code96333 != null and dto.code96333 != ''">
AND code96333 LIKE CONCAT('%', #{dto.code96333}, '%')
AND other."CODE96333" LIKE CONCAT('%', #{dto.code96333}, '%')
</if>
<!-- 监管码过滤 -->
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
AND supervisoryCode LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
AND other."SUPERVISORY_CODE" LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
</if>
<if test="dto.status != null and dto.status != ''">
AND status = #{dto.status}
AND ur.status = #{dto.status}
</if>
<if test="dto.applicationDate != null">
AND create_date LIKE CONCAT('%', DATE_FORMAT(#{dto.applicationDate}, '%Y-%m-%d'), '%')
AND ur.create_date LIKE CONCAT('%', DATE_FORMAT(#{dto.applicationDate}, '%Y-%m-%d'), '%')
</if>
<if test="dto.fullAddress != null and dto.fullAddress != ''">
AND use_address LIKE CONCAT('%', #{dto.fullAddress}, '%')
AND ur.use_address LIKE CONCAT('%', #{dto.fullAddress}, '%')
</if>
<if test="dto.useUnitName != null and dto.useUnitName != ''">
AND use_unit_name LIKE CONCAT('%', #{dto.useUnitName}, '%')
AND ur.use_unit_name LIKE CONCAT('%', #{dto.useUnitName}, '%')
</if>
<if test="dto.applyNo != null and dto.applyNo != ''">
AND apply_no LIKE CONCAT('%', #{dto.applyNo}, '%')
AND ur.apply_no LIKE CONCAT('%', #{dto.applyNo}, '%')
</if>
<if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
AND use_registration_code LIKE CONCAT('%', #{dto.useRegistrationCode}, '%')
AND ur.use_registration_code LIKE CONCAT('%', #{dto.useRegistrationCode}, '%')
</if>
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
AND use_unit_credit_code = #{dto.useUnitCode}
AND ur.use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgLook'">
AND supervision_org_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
AND ur.supervision_org_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
</when>
<otherwise>
AND supervision_org_code = #{dto.orgBranchCode}
AND ur.supervision_org_code = #{dto.orgBranchCode}
</otherwise>
</choose>
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND audit_pass_date BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
AND ur.audit_pass_date BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
<choose>
<when test="client == 'jgAudit'">
AND (receive_company_code = #{dto.receiveCompanyCode}
OR transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
AND (ur.receive_company_code = #{dto.receiveCompanyCode}
OR ur.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</when>
<otherwise>
AND supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
AND ur.supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
</otherwise>
</choose>
</if>
<if test="dto.dataType == 'company' ">
AND (use_unit_credit_code = #{dto.unitCode}
OR transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
AND (ur.use_unit_credit_code = #{dto.unitCode}
OR ur.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</if>
</select>
......
......@@ -11,10 +11,10 @@ import com.yeejoin.amos.boot.module.jg.api.entity.JgChangeRegistrationReform;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationReformServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.feign.privilege.model.AgencyModel;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
......@@ -99,7 +99,9 @@ public class JgChangeRegistrationReformController extends BaseController {
public ResponseModel<Page<Map<String, Object>>> getList(JgChangeRegistrationReformDto dto,
@RequestParam(value = "sort", required = false) String sort,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
@RequestParam(value = "size") int size,
@ApiParam(value = "客户端类型: jgAudit-监管审核;jgLook-监管查看")
@RequestParam(value = "client", required = false, defaultValue = "jgAudit") String client) {
Page<Map<String, Object>> page = new Page<>(current, size);
ReginParams reginParams = getSelectedOrgInfo();
if (reginParams.getCompany().getLevel().equals(COMPANY_TYPE_COMPANY)) {
......@@ -108,8 +110,9 @@ public class JgChangeRegistrationReformController extends BaseController {
} else {
dto.setDataType(COMPANY_TYPE_SUPERVISION);
dto.setReceiveOrgCode(reginParams.getCompany().getCompanyCode());
dto.setOrgBranchCode(reginParams.getCompany().getOrgCode());
}
Page<Map<String, Object>> list = jgChangeRegistrationReformServiceImpl.getList(dto, sort, page, dto.getRoleIds());
Page<Map<String, Object>> list = jgChangeRegistrationReformServiceImpl.getList(dto, sort, page, dto.getRoleIds(), client);
list.getRecords().forEach(x -> x.put("companyType", reginParams.getCompany().getCompanyType()));
return ResponseHelper.buildResponse(list);
}
......
......@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.module.jg.api.dto.JgEnableDisableDto;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgEnableDisableServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -54,11 +55,13 @@ public class JgEnableDisableController extends BaseController {
public ResponseModel<Page<Map<String, Object>>> page(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "sort",required = false) String sort,
@ApiParam(value = "客户端类型: jgAudit-监管审核;jgLook-监管查看")
@RequestParam(value = "client", required = false, defaultValue = "jgAudit") String client,
JgEnableDisableDto dto) {
Page<Map<String, Object>> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(jgEnableDisableServiceImpl.pageList(page,sort, dto));
return ResponseHelper.buildResponse(jgEnableDisableServiceImpl.pageList(page,sort, dto, client));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -203,9 +203,9 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
* @param roleIds 当前登陆人的角色id值
* @return
*/
public Page<Map<String, Object>> getList(JgChangeRegistrationReformDto dto, String sort, Page<Map<String, Object>> page, List<String> roleIds) {
public Page<Map<String, Object>> getList(JgChangeRegistrationReformDto dto, String sort, Page<Map<String, Object>> page, List<String> roleIds, String client) {
SortVo sortMap = commonServiceImpl.sortFieldConversion(sort);
return this.baseMapper.getListPage(page, sortMap, dto, roleIds, RequestContext.getExeUserId());
return this.baseMapper.getListPage(page, sortMap, dto, roleIds, RequestContext.getExeUserId(), client);
}
private void rollBackForDelRedisData() {
......
......@@ -476,7 +476,7 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
}
public Page<Map<String, Object>> pageList(Page<Map<String, Object>> page, String sort, JgEnableDisableDto dto) {
public Page<Map<String, Object>> pageList(Page<Map<String, Object>> page, String sort, JgEnableDisableDto dto, String client) {
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if ("company".equals(reginParams.getCompany().getLevel())) {
dto.setUseUnitCreditCode(CompanyTypeEnum.INDIVIDUAL.getName().equals(reginParams.getCompany().getCompanyType()) ?
......@@ -484,11 +484,12 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
reginParams.getCompany().getCompanyCode());
} else {
dto.setReceiveCompanyCode(reginParams.getCompany().getCompanyCode());
dto.setOrgBranchCode(reginParams.getCompany().getOrgCode());
}
String level = reginParams.getCompany().getLevel();
String userId = reginParams.getUserModel().getUserId();
SortVo sortMap = commonService.sortFieldConversion(sort);
return this.baseMapper.pageList(page, sortMap, dto, level, userId);
return this.baseMapper.pageList(page, sortMap, dto, level, userId, client);
}
......
......@@ -110,13 +110,14 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Date;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
......
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