|
|
|
@ -8,6 +8,7 @@ import com.zdxt.enforcementcode.domain.vo.EnforcementRegistrationVo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.report.ChartDataVo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.report.RegistrationAnalysisVo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.report.RegistrationExportVo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.report.RegistrationExportV2Vo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.report.RegistrationStatisticsVo; |
|
|
|
import com.zdxt.enforcementcode.mapper.EnforcementRegistrationMapper; |
|
|
|
import com.zdxt.enforcementcode.report.IEnforcementRegistrationReport; |
|
|
|
@ -65,23 +66,142 @@ public class EnforcementRegistrationReportImpl implements IEnforcementRegistrati |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public TableDataInfo<EnforcementRegistrationVo> list(EnforcementRegistrationBo bo, PageQuery pageQuery) { |
|
|
|
// 数据权限由 @EfcodeDataFilter 拦截器自动处理
|
|
|
|
public TableDataInfo<EnforcementRegistrationVo> listForV1(EnforcementRegistrationBo bo, PageQuery pageQuery) { |
|
|
|
// 与旧系统一致:加载全量数据 → 填充区域/街道 → 按字典顺序排序 → 手动分页
|
|
|
|
List<EnforcementRegistrationVo> allRecords = loadAndSortAll(bo); |
|
|
|
|
|
|
|
// 手动分页
|
|
|
|
int pageNum = pageQuery.getPageNum(); |
|
|
|
int pageSize = pageQuery.getPageSize(); |
|
|
|
int total = allRecords.size(); |
|
|
|
int fromIndex = (pageNum - 1) * pageSize; |
|
|
|
int toIndex = Math.min(fromIndex + pageSize, total); |
|
|
|
List<EnforcementRegistrationVo> pageData = fromIndex < total ? allRecords.subList(fromIndex, toIndex) : Collections.emptyList(); |
|
|
|
|
|
|
|
return new TableDataInfo<>(pageData, (long) total); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public TableDataInfo<EnforcementRegistrationVo> listForV2(EnforcementRegistrationBo bo, PageQuery pageQuery) { |
|
|
|
// V2:SQL层JOIN字典表排序 + 服务端分页(依赖district/street已回填)
|
|
|
|
Page<EnforcementRegistrationVo> page = pageQuery.build(); |
|
|
|
IPage<EnforcementRegistrationVo> result = registrationMapper.selectReportPage(page, bo, null); |
|
|
|
IPage<EnforcementRegistrationVo> result = registrationMapper.selectReportPageV2(page, bo, null); |
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<EnforcementRegistrationVo> listAll(EnforcementRegistrationBo bo) { |
|
|
|
// 数据权限由 @EfcodeDataFilter 拦截器自动处理
|
|
|
|
return loadAndSortAll(bo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 加载全量数据并按字典顺序排序(与旧系统一致) |
|
|
|
* 旧系统:加载全部 → 按区域字典顺序遍历 → 按街道字典顺序收集 → 前端分页 |
|
|
|
*/ |
|
|
|
private List<EnforcementRegistrationVo> loadAndSortAll(EnforcementRegistrationBo bo) { |
|
|
|
Page<EnforcementRegistrationVo> page = new Page<>(1, Integer.MAX_VALUE, false); |
|
|
|
IPage<EnforcementRegistrationVo> result = registrationMapper.selectReportPage(page, bo, null); |
|
|
|
return result.getRecords(); |
|
|
|
List<EnforcementRegistrationVo> records = result.getRecords(); |
|
|
|
// 从企业地址中解析区域/街道并按字典顺序排序
|
|
|
|
return enrichAndSortByDictOrder(records); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 从 enterprise_address 中解析区域和街道,并按字典顺序排序(与旧系统逻辑完全一致) |
|
|
|
* 旧系统排序:按区域字典dict_sort顺序 → 每个区域内按街道dict_sort顺序 → 同街道内按enforcement_time倒序 |
|
|
|
*/ |
|
|
|
private List<EnforcementRegistrationVo> enrichAndSortByDictOrder(List<EnforcementRegistrationVo> list) { |
|
|
|
if (list == null || list.isEmpty()) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
// 加载区域字典(address_type)——按dict_sort顺序
|
|
|
|
List<SysDictDataVo> areaList = dictTypeService.selectDictDataByType("address_type"); |
|
|
|
if (areaList == null || areaList.isEmpty()) { |
|
|
|
return list; |
|
|
|
} |
|
|
|
// 加载每个区域下的街道字典(按dict_sort顺序)
|
|
|
|
Map<String, List<SysDictDataVo>> areaStreetMap = new LinkedHashMap<>(); |
|
|
|
for (SysDictDataVo area : areaList) { |
|
|
|
List<SysDictDataVo> streets = dictTypeService.selectDictDataByType(area.getDictValue()); |
|
|
|
areaStreetMap.put(area.getDictLabel(), streets != null ? streets : Collections.emptyList()); |
|
|
|
} |
|
|
|
|
|
|
|
// 构建区域排序索引(dictLabel → 顺序号)
|
|
|
|
Map<String, Integer> areaSortMap = new HashMap<>(); |
|
|
|
int areaIdx = 0; |
|
|
|
for (SysDictDataVo area : areaList) { |
|
|
|
areaSortMap.put(area.getDictLabel(), areaIdx++); |
|
|
|
} |
|
|
|
// 构建街道排序索引(dictLabel → 顺序号)
|
|
|
|
Map<String, Integer> streetSortMap = new HashMap<>(); |
|
|
|
for (List<SysDictDataVo> streets : areaStreetMap.values()) { |
|
|
|
int streetIdx = 0; |
|
|
|
for (SysDictDataVo street : streets) { |
|
|
|
streetSortMap.put(street.getDictLabel(), streetIdx++); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 填充区域/街道
|
|
|
|
list.forEach(vo -> { |
|
|
|
String address = vo.getEnterpriseAddress(); |
|
|
|
if (StringUtils.isBlank(address)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
String matchedArea = null; |
|
|
|
String matchedStreet = null; |
|
|
|
|
|
|
|
for (Map.Entry<String, List<SysDictDataVo>> entry : areaStreetMap.entrySet()) { |
|
|
|
String areaLabel = entry.getKey(); |
|
|
|
int quIdx = areaLabel.indexOf("区"); |
|
|
|
if (quIdx <= 0) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
String prefix = areaLabel.substring(0, quIdx); |
|
|
|
String prefixQu = "深圳市" + prefix + "区"; |
|
|
|
String prefixXinQu = "深圳市" + prefix + "新区"; |
|
|
|
if (address.startsWith(prefixQu) || address.startsWith(prefixXinQu)) { |
|
|
|
matchedArea = areaLabel; |
|
|
|
for (SysDictDataVo street : entry.getValue()) { |
|
|
|
String streetLabel = street.getDictLabel(); |
|
|
|
if (address.startsWith(prefixQu + streetLabel) || address.startsWith(prefixXinQu + streetLabel)) { |
|
|
|
matchedStreet = streetLabel; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
vo.setDistrict(matchedArea != null ? matchedArea : ""); |
|
|
|
vo.setStreet(matchedStreet != null ? matchedStreet : ""); |
|
|
|
}); |
|
|
|
|
|
|
|
// 按字典顺序排序:区域字典序 → 街道字典序 → 执法时间倒序
|
|
|
|
int maxAreaIdx = areaList.size(); |
|
|
|
int maxStreetIdx = streetSortMap.size() + 1; |
|
|
|
list.sort((a, b) -> { |
|
|
|
int aAreaSort = areaSortMap.getOrDefault(a.getDistrict(), maxAreaIdx); |
|
|
|
int bAreaSort = areaSortMap.getOrDefault(b.getDistrict(), maxAreaIdx); |
|
|
|
if (aAreaSort != bAreaSort) { |
|
|
|
return Integer.compare(aAreaSort, bAreaSort); |
|
|
|
} |
|
|
|
int aStreetSort = streetSortMap.getOrDefault(a.getStreet(), maxStreetIdx); |
|
|
|
int bStreetSort = streetSortMap.getOrDefault(b.getStreet(), maxStreetIdx); |
|
|
|
if (aStreetSort != bStreetSort) { |
|
|
|
return Integer.compare(aStreetSort, bStreetSort); |
|
|
|
} |
|
|
|
// 同区域同街道,按执法时间倒序
|
|
|
|
if (a.getEnforcementTime() == null && b.getEnforcementTime() == null) return 0; |
|
|
|
if (a.getEnforcementTime() == null) return 1; |
|
|
|
if (b.getEnforcementTime() == null) return -1; |
|
|
|
return b.getEnforcementTime().compareTo(a.getEnforcementTime()); |
|
|
|
}); |
|
|
|
|
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<RegistrationExportVo> exportList(EnforcementRegistrationBo bo) { |
|
|
|
public List<RegistrationExportVo> exportListV1(EnforcementRegistrationBo bo) { |
|
|
|
List<EnforcementRegistrationVo> dataList = listAll(bo); |
|
|
|
|
|
|
|
// 字典翻译:执法类别
|
|
|
|
@ -115,6 +235,60 @@ public class EnforcementRegistrationReportImpl implements IEnforcementRegistrati |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<RegistrationExportV2Vo> exportListV2(EnforcementRegistrationBo bo) { |
|
|
|
// 使用V2排序:Sql JOIN字典表排序,全量加载
|
|
|
|
Page<EnforcementRegistrationVo> page = new Page<>(1, Integer.MAX_VALUE, false); |
|
|
|
IPage<EnforcementRegistrationVo> result = registrationMapper.selectReportPageV2(page, bo, null); |
|
|
|
List<EnforcementRegistrationVo> dataList = result.getRecords(); |
|
|
|
|
|
|
|
// 字典翻译
|
|
|
|
Map<String, String> categoryDictMap2 = dictTypeService.selectDictDataByType("law_enforce_category").stream() |
|
|
|
.collect(Collectors.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel, (a, b) -> a)); |
|
|
|
Map<String, String> checkCategoryDictMap = dictTypeService.selectDictDataByType("check_category").stream() |
|
|
|
.collect(Collectors.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel, (a, b) -> a)); |
|
|
|
Map<String, String> noScanReasonDictMap = dictTypeService.selectDictDataByType("no-scan-reason").stream() |
|
|
|
.collect(Collectors.toMap(SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel, (a, b) -> a)); |
|
|
|
|
|
|
|
java.text.SimpleDateFormat sdf2 = new java.text.SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
|
|
return dataList.stream().map(vo -> { |
|
|
|
RegistrationExportV2Vo export = new RegistrationExportV2Vo(); |
|
|
|
export.setBureauDeptName(vo.getBureauDeptName()); |
|
|
|
export.setEnterpriseName(vo.getEnterpriseName()); |
|
|
|
export.setEnterpriseNumber(vo.getEnterpriseNumber()); |
|
|
|
export.setDistrict(vo.getDistrict()); |
|
|
|
export.setStreet(vo.getStreet()); |
|
|
|
// 执法人员
|
|
|
|
String enforcer = vo.getLawEnforcer() != null ? vo.getLawEnforcer() : ""; |
|
|
|
if (StringUtils.isNotBlank(vo.getLawEnforcerTwo())) { |
|
|
|
enforcer = enforcer + "," + vo.getLawEnforcerTwo(); |
|
|
|
} |
|
|
|
export.setLawEnforcer(enforcer); |
|
|
|
export.setLawEnforcementItemText(vo.getLawEnforcementItemText()); |
|
|
|
// 执法时间
|
|
|
|
export.setEnforcementTime(vo.getEnforcementTime() != null ? sdf2.format(vo.getEnforcementTime()) : ""); |
|
|
|
// 联合执法
|
|
|
|
export.setHasUnion(vo.getHasUnion() != null && vo.getHasUnion() == 1 && StringUtils.isNotBlank(vo.getUnionNo()) ? "是" : "否"); |
|
|
|
// 受委托
|
|
|
|
export.setHasAuto(vo.getHasAuto() != null && vo.getHasAuto() == 1 ? "是" : "否"); |
|
|
|
// 委托单位
|
|
|
|
export.setEntrustDeptName(vo.getEntrustDeptName()); |
|
|
|
// 行政执法类别
|
|
|
|
export.setLawEnforceCategory(categoryDictMap2.getOrDefault( |
|
|
|
vo.getLawEnforceCategory() != null ? vo.getLawEnforceCategory() : "", "")); |
|
|
|
// 任务来源
|
|
|
|
export.setCheckCategory(checkCategoryDictMap.getOrDefault( |
|
|
|
vo.getCheckCategory() != null ? vo.getCheckCategory() : "", "")); |
|
|
|
// 未扫码原因
|
|
|
|
export.setNoScanReason(noScanReasonDictMap.getOrDefault( |
|
|
|
vo.getCheckCss() != null ? vo.getCheckCss() : "", "")); |
|
|
|
// 是否投诉
|
|
|
|
export.setIsComplaint(vo.getIsComplaint() != null && vo.getIsComplaint() == 1 ? "是" : "否"); |
|
|
|
return export; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ChartDataVo> categoryChart(EnforcementRegistrationBo bo) { |
|
|
|
// 数据权限由 @EfcodeDataFilter 拦截器自动处理
|
|
|
|
|