Commit 976ffb7d authored by tianbo's avatar tianbo

refactor(common): 重构过滤参数DTO继承结构并优化字段映射逻辑

- 将DPFilterParamDto和DPFilterParamForDetailDto改为继承DPFilterParamBaseDto - 移除重复的cityCode字段定义,统一由基类管理 - 优化FieldMappingAspect中的字段查找逻辑,支持从父类中查找字段 - 在JGDPStatisticsServiceImpl中增加companyCodes字段映射配置 - 更新XML mapper文件,根据cityCode动态构建companyCodes查询条件 - StCommonServiceImpl中新增getCompanyCodesByRegionCode方法用于获取区域下公司编码列表
parent edc1a018
...@@ -179,14 +179,19 @@ public class FieldMappingAspect { ...@@ -179,14 +179,19 @@ public class FieldMappingAspect {
try { try {
return FIELD_CACHE.get(clazz) return FIELD_CACHE.get(clazz)
.computeIfAbsent(fieldName, name -> { .computeIfAbsent(fieldName, name -> {
Class<?> currentClass = clazz;
while (currentClass != null) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = currentClass.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field; return field;
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
log.debug("Field not found: {} in {}", name, clazz.getName()); // 继续在父类中查找
return null; currentClass = currentClass.getSuperclass();
}
} }
log.debug("Field not found: {} in {} or its superclasses", name, clazz.getName());
return null;
}); });
} catch (ExecutionException e) { } catch (ExecutionException e) {
log.error("Cache operation failed", e); log.error("Cache operation failed", e);
......
package com.yeejoin.amos.boot.module.common.api.dto; package com.yeejoin.amos.boot.module.common.api.dto;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.util.List; import java.util.List;
/** /**
...@@ -10,14 +10,9 @@ import java.util.List; ...@@ -10,14 +10,9 @@ import java.util.List;
* *
* @author Administrator * @author Administrator
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
public class DPFilterParamDto { public class DPFilterParamDto extends DPFilterParamBaseDto {
/**
* 区域
*/
@NotBlank(message = "区域编码不能为空!")
private String cityCode;
/** /**
* 数据统计的开始日期 * 数据统计的开始日期
*/ */
...@@ -103,9 +98,4 @@ public class DPFilterParamDto { ...@@ -103,9 +98,4 @@ public class DPFilterParamDto {
* 监管机构组织机构代码 * 监管机构组织机构代码
*/ */
private String superviseOrgCode; private String superviseOrgCode;
/**
* 区域下的所有单位监管、行政审批(地市、区县级)
*/
private List<String> companyCodes;
} }
...@@ -3,10 +3,10 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -3,10 +3,10 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import javax.validation.constraints.NotBlank;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -15,14 +15,9 @@ import java.util.List; ...@@ -15,14 +15,9 @@ import java.util.List;
* *
* @author Administrator * @author Administrator
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
public class DPFilterParamForDetailDto { public class DPFilterParamForDetailDto extends DPFilterParamBaseDto {
/**
* 区域
*/
@NotBlank(message = "区域编码不能为空!")
private String cityCode;
/** /**
* 机构 * 机构
*/ */
......
...@@ -1682,11 +1682,24 @@ ...@@ -1682,11 +1682,24 @@
tzs_jg_enable_disable tjed tzs_jg_enable_disable tjed
LEFT JOIN tzs_jg_enable_disable_eq tjede ON tjed.sequence_nbr = tjede.enable_disable_apply_id LEFT JOIN tzs_jg_enable_disable_eq tjede ON tjed.sequence_nbr = tjede.enable_disable_apply_id
LEFT JOIN idx_biz_jg_register_info ri ON tjede.equ_id = ri.RECORD LEFT JOIN idx_biz_jg_register_info ri ON tjede.equ_id = ri.RECORD
LEFT JOIN privilege_company pc ON pc.company_code = tjed.receive_company_code
WHERE WHERE
pc.org_code LIKE CONCAT ( #{orgCode}, '%' ) tjed.audit_status != '已作废'
AND tjed.audit_status != '已作废'
AND tjed.apply_type = 'SB_TY' AND tjed.apply_type = 'SB_TY'
<choose>
<when test='dto.cityCode != null and dto.cityCode == "610000"'>
and 1=1
</when>
<otherwise>
<if test="dto.companyCodes != null and dto.companyCodes.size > 0">
and tjed.receive_company_code =
ANY(ARRAY[
<foreach collection="dto.companyCodes" item="companyCode" separator=",">
#{companyCode}
</foreach>
])
</if>
</otherwise>
</choose>
<if test="dto.beginDate != null and dto.beginDate != ''"> <if test="dto.beginDate != null and dto.beginDate != ''">
and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_ge(CAST(audit_pass_date as date),#{dto.beginDate})
</if> </if>
...@@ -1735,11 +1748,24 @@ ...@@ -1735,11 +1748,24 @@
tzs_jg_enable_disable tjed tzs_jg_enable_disable tjed
LEFT JOIN tzs_jg_enable_disable_eq tjede ON tjed.sequence_nbr = tjede.enable_disable_apply_id LEFT JOIN tzs_jg_enable_disable_eq tjede ON tjed.sequence_nbr = tjede.enable_disable_apply_id
LEFT JOIN idx_biz_jg_register_info ri ON tjede.equ_id = ri.RECORD LEFT JOIN idx_biz_jg_register_info ri ON tjede.equ_id = ri.RECORD
LEFT JOIN privilege_company pc ON pc.company_code = tjed.receive_company_code
WHERE WHERE
pc.org_code LIKE CONCAT ( #{orgCode}, '%' ) tjed.audit_status != '已作废'
AND tjed.audit_status != '已作废'
AND tjed.apply_type = 'SB_QY' AND tjed.apply_type = 'SB_QY'
<choose>
<when test='dto.cityCode != null and dto.cityCode == "610000"'>
and 1=1
</when>
<otherwise>
<if test="dto.companyCodes != null and dto.companyCodes.size > 0">
and tjed.receive_company_code =
ANY(ARRAY[
<foreach collection="dto.companyCodes" item="companyCode" separator=",">
#{companyCode}
</foreach>
])
</if>
</otherwise>
</choose>
<if test="dto.beginDate != null and dto.beginDate != ''"> <if test="dto.beginDate != null and dto.beginDate != ''">
and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_ge(CAST(audit_pass_date as date),#{dto.beginDate})
</if> </if>
...@@ -1788,11 +1814,24 @@ ...@@ -1788,11 +1814,24 @@
tzs_jg_scrap_cancel tjsc tzs_jg_scrap_cancel tjsc
LEFT JOIN tzs_jg_scrap_cancel_eq tjsce ON tjsc.sequence_nbr = tjsce.equip_transfer_id LEFT JOIN tzs_jg_scrap_cancel_eq tjsce ON tjsc.sequence_nbr = tjsce.equip_transfer_id
LEFT JOIN idx_biz_jg_register_info ri ON tjsce.equ_id = ri.RECORD LEFT JOIN idx_biz_jg_register_info ri ON tjsce.equ_id = ri.RECORD
LEFT JOIN privilege_company pc ON pc.company_code = tjsc.receive_org_code
WHERE WHERE
pc.org_code LIKE CONCAT ( #{orgCode}, '%' ) tjsc.audit_status != '已作废'
AND tjsc.audit_status != '已作废'
AND tjsc.cancel_type = '2' AND tjsc.cancel_type = '2'
<choose>
<when test='dto.cityCode != null and dto.cityCode == "610000"'>
and 1=1
</when>
<otherwise>
<if test="dto.companyCodes != null and dto.companyCodes.size > 0">
and tjsc.receive_company_code =
ANY(ARRAY[
<foreach collection="dto.companyCodes" item="companyCode" separator=",">
#{companyCode}
</foreach>
])
</if>
</otherwise>
</choose>
<if test="dto.beginDate != null and dto.beginDate != ''"> <if test="dto.beginDate != null and dto.beginDate != ''">
and date_ge(CAST(audit_pass_date as date),#{dto.beginDate}) and date_ge(CAST(audit_pass_date as date),#{dto.beginDate})
</if> </if>
......
...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.annotation.FieldMapping;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
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.dto.CountDto; import com.yeejoin.amos.boot.biz.common.dto.CountDto;
...@@ -3715,6 +3716,9 @@ public class JGDPStatisticsServiceImpl { ...@@ -3715,6 +3716,9 @@ public class JGDPStatisticsServiceImpl {
return result; return result;
} }
@FieldMapping({
@FieldMapping.FieldMap(sourceField = "cityCode", targetField = "companyCodes", serviceClass = StCommonServiceImpl.class, queryMethod = "getCompanyCodesByRegionCode"),
})
public Page<Map<String, Object>> getJgBusinessList(DPFilterParamForDetailDto dpFilterParamForDetailDto, Page<Map<String, Object>> page) { public Page<Map<String, Object>> getJgBusinessList(DPFilterParamForDetailDto dpFilterParamForDetailDto, Page<Map<String, Object>> page) {
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamForDetailDto.getCityCode()); String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamForDetailDto.getCityCode());
Page<Map<String, Object>> maps = null; Page<Map<String, Object>> maps = null;
...@@ -3726,6 +3730,7 @@ public class JGDPStatisticsServiceImpl { ...@@ -3726,6 +3730,7 @@ public class JGDPStatisticsServiceImpl {
filterParamDto.setEquCategoryCode(dpFilterParamForDetailDto.getEquCategoryCode()); filterParamDto.setEquCategoryCode(dpFilterParamForDetailDto.getEquCategoryCode());
filterParamDto.setEquListCode(dpFilterParamForDetailDto.getEquListCode()); filterParamDto.setEquListCode(dpFilterParamForDetailDto.getEquListCode());
filterParamDto.setStatus(dpFilterParamForDetailDto.getStatus()); filterParamDto.setStatus(dpFilterParamForDetailDto.getStatus());
filterParamDto.setCompanyCodes(dpFilterParamForDetailDto.getCompanyCodes());
if (null != dpFilterParamForDetailDto.getTimeSearchOne()) { if (null != dpFilterParamForDetailDto.getTimeSearchOne()) {
filterParamDto.setBeginDate(dpFilterParamForDetailDto.getTimeSearchOne().getBeginDate()); filterParamDto.setBeginDate(dpFilterParamForDetailDto.getTimeSearchOne().getBeginDate());
filterParamDto.setEndDate(dpFilterParamForDetailDto.getTimeSearchOne().getEndDate()); filterParamDto.setEndDate(dpFilterParamForDetailDto.getTimeSearchOne().getEndDate());
......
...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
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.dto.CountDto; import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant; import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamBaseDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto; import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto; import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum; import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum;
...@@ -165,11 +166,16 @@ public class StCommonServiceImpl { ...@@ -165,11 +166,16 @@ public class StCommonServiceImpl {
/** /**
* 按照regionCode查询区域下的公司 * 按照regionCode查询区域下的公司
* @param cityCode 区域 * @param cityCode 区域
* @param dpFilterParamDto 过滤条件 * @param dpFilterParamBaseDto 过滤条件
*/ */
private void setChildCompanyCodeByRegion(String cityCode, DPFilterParamDto dpFilterParamDto) { private void setChildCompanyCodeByRegion(String cityCode, DPFilterParamBaseDto dpFilterParamBaseDto) {
RegionModel region = regionCodeRegionMap.get(Integer.valueOf(cityCode)); RegionModel region = regionCodeRegionMap.get(Integer.valueOf(cityCode));
dpFilterParamDto.setCompanyCodes(regionCodeCompanyCodeMap.computeIfAbsent(Integer.valueOf(cityCode), k -> commonMapper.selectCompanyCodeByRegionCode(region.getSequenceNbr()))); dpFilterParamBaseDto.setCompanyCodes(regionCodeCompanyCodeMap.computeIfAbsent(Integer.valueOf(cityCode), k -> commonMapper.selectCompanyCodeByRegionCode(region.getSequenceNbr())));
}
public List<String> getCompanyCodesByRegionCode(String cityCode) {
RegionModel region = regionCodeRegionMap.get(Integer.valueOf(cityCode));
return regionCodeCompanyCodeMap.computeIfAbsent(Integer.valueOf(cityCode), k -> commonMapper.selectCompanyCodeByRegionCode(region.getSequenceNbr()));
} }
public String getAndSetOrgCode(String cityCode) { public String getAndSetOrgCode(String cityCode) {
......
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