Commit 4e3a4886 authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://39.100.92.250:5000/moa/amos-boot-biz into develop_tzs_register
parents fd338117 045ef29c
......@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.common.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
......@@ -13,18 +12,15 @@ public enum StatisticalAnalysisEnum {
/**
* 综合统计分析列表查询设备、企业、人员ES索引
*/
company("企业", "company", "idx_biz_enterprise_info"),
inspectionCompany("检验检测机构", "inspectionCompany", "idx_biz_enterprise_info"),
person("人员", "person", "idx_biz_user_info"),
inspectionPerson("检验检测人员", "inspectionPerson", "idx_biz_user_info"),
equip("设备", "equip", "idx_biz_equipment_info");
private String name;
private String code;
private String key;
private final String name;
private final String code;
private final String key;
private static final Map<String, StatisticalAnalysisEnum> CODE_MAP = new HashMap<>();
......
......@@ -724,9 +724,9 @@
<if test="dto.fullAddress != null and dto.fullAddress != ''">
AND fullAddress LIKE CONCAT('%', #{dto.fullAddress}, '%')
</if>
<if test="dto.receiveCompanyCode != null and dto.receiveCompanyCode != ''">
AND receive_company_code = #{dto.receiveCompanyCode}
</if>
<!-- <if test="dto.receiveCompanyCode != null and dto.receiveCompanyCode != ''">-->
<!-- AND receive_company_code = #{dto.receiveCompanyCode}-->
<!-- </if>-->
<if test="dto.useUnitName != null and dto.useUnitName != ''">
and useUnitName like concat('%',#{dto.useUnitName},'%')
</if>
......@@ -742,6 +742,16 @@
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND auditPassDate BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgLook'">
and supervisionOrgCode like concat(#{dto.orgBranchCode},'%')
</when>
<otherwise>
and supervisionOrgCode = #{dto.orgBranchCode}
</otherwise>
</choose>
</if>
<if test="dto.dataType == 'supervision' ">
<choose>
<when test="client == 'jgAudit'">
......
......@@ -438,12 +438,29 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
}
List<RegistrationVo> exportData = registrationMapper.queryRegistrationInIds(dto, client);
for (RegistrationVo vo : exportData) {
vo.setEquCode(limitByComma(vo.getEquCode()));
vo.setSupervisoryCode(limitByComma(vo.getSupervisoryCode()));
vo.setRegType(RegTypeEnum.getNameByCode(vo.getRegType()).orElse(RegTypeEnum.REGISTRATION_NEW.getName()));
}
ExcelUtil.createTemplate(response, "使用登记列表数据", "使用登记列表", exportData, RegistrationVo.class, null, false);
}
/**
* 截取逗号分隔字符串,只保留前100项,多余用 "..." 代替
*/
private String limitByComma(String equCode) {
if (equCode == null || equCode.trim().isEmpty()) {
return "";
}
String[] parts = equCode.split(",");
if (parts.length <= 100) {
return equCode;
}
// 只保留前100项并添加省略号
return String.join(",", Arrays.copyOf(parts, 100)) + "...";
}
/**
* 单位变更列表数据导出
*
* @param response 响应
......
......@@ -41,6 +41,9 @@ public class EquipInfoVo {
@ExcelProperty("使用登记证编号")
private String USE_ORG_CODE;
@ExcelProperty("注册代码")
private String RECORD;
@ExcelProperty("96333电梯码")
private String CODE96333;
......
......@@ -20,13 +20,13 @@
<select id="getUseRegisterCount" resultType="java.util.Map">
SELECT
C.time, -- 月份
COUNT(1) AS num -- 每月的记录数
C.time,
COUNT(1) AS num
FROM
tzs_cylinder_business_statistics C
WHERE
C.supervision_org_code LIKE '50%' -- 仅过滤 '50%' 开头的监管机构代码
C.supervision_org_code LIKE '50%'
GROUP BY
C.time -- 按月份分组
C.time
</select>
</mapper>
......@@ -1487,7 +1487,6 @@
<if test="dto.superviseUnitName != null and dto.superviseUnitName != ''">
and tjcrn.receive_org_name like CONCAT('%', #{dto.superviseUnitName}, '%')
</if>
<!-- 因更名变更是将单位下所有设备都修改,未存设备id,故筛选设备种类和类别默认筛选不到数据-->
<if test="dto.equListCode != null and dto.equListCode != ''">
and 1 = 2
</if>
......@@ -2199,7 +2198,6 @@
<if test="dto.superviseUnitName != null and dto.superviseUnitName != ''">
and tjcrn.receive_org_name like CONCAT('%', #{dto.superviseUnitName}, '%')
</if>
<!-- 因更名变更是将单位下所有设备都修改,未存设备id,故筛选设备种类和类别默认筛选不到数据-->
<if test="dto.equListCode != null and dto.equListCode != ''">
and 1 = 2
</if>
......
......@@ -46,8 +46,6 @@
"ORG_BRANCH_CODE" IS NULL
AND ibjui."RECORD" is not null
AND ibjsi."RECORD" is null
--AND ibjri."EQU_CATEGORY" = '2300'
--AND "CLAIM_STATUS" = '已认领'
order by ibjui."RECORD" desc
</select>
<select id="selectRecords" resultType="java.lang.String">
......
......@@ -184,7 +184,7 @@
and
(
<choose>
<when test="regionCode != null and regionCode != ''">--按监管单位统计时,省局使用
<when test="regionCode != null and regionCode != ''">
(
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
......@@ -198,7 +198,7 @@
OR
(bi.supervise_org_code = '50' AND bi.office_region LIKE CONCAT('%', #{regionCode}, '%'))
</when>
<otherwise>--按监管单位统计时,除省局外使用
<otherwise>
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
bi.supervise_org_code != '50' AND bi.supervise_org_code = #{orgCode}
......
......@@ -521,7 +521,14 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
return ResponseHelper.buildResponse(statisticalAnalysisService.getDataDifference(code));
}
/**
* 获取es和数据库中设备数据差异V2
* @return Object
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/getDataDifferenceV2")
@ApiOperation(httpMethod = "GET", value = "获取es和数据库数据差异V2", notes = "获取es和数据库数据差异V2")
public ResponseModel<Object> getDataDifferenceV2() {
return ResponseHelper.buildResponse(statisticalAnalysisService.getDataDifferenceV2());
}
}
......@@ -18,10 +18,12 @@ import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RequestContextWrapper;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.dto.TechParamItem;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.common.api.enums.StatisticalAnalysisEnum;
import com.yeejoin.amos.boot.module.common.api.enums.UnitTypeNewEnum;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EsSearchServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.TZSCommonServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.utils.TechParamUtil;
import com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils;
......@@ -146,7 +148,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private final CommonBaseMapper commonMapper;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
private final EsSearchServiceImpl esSearchService;
@Autowired
EquipmentCategoryMapper equipmentCategoryMapper;
......@@ -2651,6 +2653,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject maintenances = equip.getJSONArray("maintenances").getJSONObject(0);
BeanUtil.copyProperties(maintenances, equipInfoVo, CopyOptions.create().setIgnoreNullValue(true));
}
Optional.of(equip)
.filter(e -> "3000".equals(String.valueOf(e.get("EQU_LIST_CODE"))))
.filter(e -> String.valueOf(e.get("DATA_SOURCE")).contains("jg_his_xa"))
.map(e -> String.valueOf(e.get("SEQUENCE_NBR")))
.ifPresent(equipInfoVo::setRECORD);
// 技术参数
if (!equip.getJSONArray("techParams").isEmpty()) {
JSONObject paramsJson = new JSONObject();
......@@ -4565,4 +4573,59 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.filter(element -> !bSet.contains(element))
.collect(Collectors.toList());
}
/**
* 获取数据库与ES数据差异:找出ES比数据库多的记录ID
*/
public Object getDataDifferenceV2() {
Map<String, Object> result = new HashMap<>();
List<String> extraInEs;
// 获取索引
String index = "idx_biz_view_jg_all";
// 1. 查询数据库中所有设备 record
List<String> dbRecords = idxBizJgUseInfoMapper.selectEquipsClaimStatus();
log.info("数据库设备记录数: {}", dbRecords.size());
// 2. 从ES中查询对应记录
List<String> esRecords = getEsDataV2(index);
log.info("ES设备记录数: {}", esRecords.size());
// 3. 对比差异(ES比DB多的记录)
extraInEs = findElementsInANotInB(esRecords, dbRecords);
log.info("ES比数据库多的记录数: {}", extraInEs.size());
result.put("extraInEs", extraInEs);
return result;
}
/**
* 从 ES 中拉取索引中所有的 SEQUENCE_NBR(match_all)
*/
private List<String> getEsDataV2(String index) {
// 使用 match_all 查询,拉取所有文档(通过 scroll 分批)
log.info("ES 全量查询开始, index={}, 时间={}", index, System.currentTimeMillis());
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
.must(QueryBuilders.termsQuery("STATUS", Collections.singletonList("已认领")));
// 线程安全的结果容器
List<String> esIds = Collections.synchronizedList(new ArrayList<>());
try {
esSearchService.searchResponseInBatch(index, boolQuery, 2000, searchHits -> {
// 每个批次只解析需要的字段
List<String> batchIds = searchHits.stream()
.map(hit -> {
ESEquipmentCategoryDto dto = JSONObject.parseObject(hit.getSourceAsString(), ESEquipmentCategoryDto.class);
return dto == null ? null : dto.getSEQUENCE_NBR();
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
esIds.addAll(batchIds);
});
} catch (Exception ex) {
log.error("ES 全量查询异常, index={}, 错误={}", index, ex.getMessage(), ex);
throw new RuntimeException("ES 查询失败: " + ex.getMessage(), ex);
}
// 去重并返回
return esIds.stream().distinct().collect(Collectors.toList());
}
}
\ No newline at end of file
......@@ -3899,8 +3899,9 @@ public class JGDPStatisticsServiceImpl {
countItemDto.setGl(String.valueOf(data.get(DPMapStatisticsItemEnum.BOILERS.getCode())));
countItemDto.setYlrq(String.valueOf(data.get(DPMapStatisticsItemEnum.PRESSURE_VESSELS.getCode())));
// 2. 压力管道长度统计
this.staticsCenterMapCountPipLine(data, orgCode, true,isOrgBranchCodeExactMatch);
// countItemDto.setYlgd(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true, isOrgBranchCodeExactMatch));
this.staticsCenterMapCountPipLine(data, orgCode, true, isOrgBranchCodeExactMatch);
countItemDto.setYlgd(String.valueOf(data.get(DPMapStatisticsItemEnum.PRESSURE_PIPELINES.getCode())));
//countItemDto.setYlgd(stCommonService.staticsCenterMapCountDataForPipeline(data, orgCode, true, isOrgBranchCodeExactMatch));
// 如果是地市数据则计算上线率,上线率=系统已有数据/最新期底数x100%
if ("610000".equals(r.getParentRegionCode())) {
Map<String, Object> baselineMap = baselineData.stream().filter(d -> d.get("city_code").equals(regionCode)).findFirst().orElse(null);
......@@ -4170,17 +4171,22 @@ public class JGDPStatisticsServiceImpl {
}
public String sumWithValidation(List<SkjsEquipCountItemDto> list) {
if (list == null || list.isEmpty()) return "0.000";
return list.stream()
.filter(Objects::nonNull)
.map(item -> {
try {
return new BigDecimal(item.getYlgd());
} catch (NumberFormatException e) {
log.warn("Invalid number in item {}", item);
return BigDecimal.ZERO;
}
})
.reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, RoundingMode.HALF_UP).toPlainString();
.map(item -> this.safeBigDecimal(item.getYlgd()))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.setScale(3, RoundingMode.HALF_UP)
.toPlainString();
}
private BigDecimal safeBigDecimal(String val) {
if (val == null || val.trim().isEmpty()) return BigDecimal.ZERO;
try {
return new BigDecimal(val.trim());
} catch (NumberFormatException e) {
return BigDecimal.ZERO;
}
}
public List<Map<String, Object>> getSuperviseTreeByLoginUnitCode(String orgCode) {
......
......@@ -104,8 +104,7 @@ public class TzsTwoStaffingController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/exportData")
@ApiOperation(httpMethod = "GET", value = "监管单位统计信息导出", notes = "监管单位统计信息导出")
public void exportData(HttpServletResponse response,
@RequestParam("sequenceNbr") String sequenceNbr,
public void exportData(HttpServletResponse response, @RequestParam(value = "sequenceNbr", required = false) String sequenceNbr,
@RequestParam("type") String type) {
List<LinkedHashMap> data = (List<LinkedHashMap>) redisUtils.get(REGULATOR_UNIT_TREE);
ArrayList<LinkedHashMap> result = new ArrayList<>();
......
......@@ -1025,7 +1025,8 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (!ObjectUtils.isEmpty(result)) {
return result;
}
List<LinkedHashMap> list = data.stream().filter(item -> item.get("sequenceNbr").toString().equals(id)).collect(Collectors.toList());
List<LinkedHashMap> list = data.stream().filter(item -> Objects.equals(item.get("sequenceNbr"), id))
.collect(Collectors.toList());
if (!ObjectUtils.isEmpty(list)) {
return list;
}
......
......@@ -50,4 +50,6 @@ public interface IdxBizJgUseInfoMapper extends CustomBaseMapper<IdxBizJgUseInfo>
List<Map<String, Object>> queryBaseInfoByIds(@Param("records") List<String> records);
List<IdxBizJgOtherInfo> selectOneMockRecord(@Param("equList") String equList, @Param("equCategory") String equCategory, @Param("equDefine") String equDefine, @Param("useUnitCode") String useUnitCode, @Param("size") Integer size);
List<String> selectEquipsClaimStatus();
}
......@@ -235,4 +235,10 @@
ORDER BY r."REC_DATE" limit ${size}
</select>
<select id="selectEquipsClaimStatus" resultType="java.lang.String">
SELECT ibjui."RECORD"
FROM idx_biz_jg_use_info ibjui
JOIN idx_biz_jg_other_info joi ON ibjui."RECORD" = joi."RECORD"
WHERE joi.claim_status = '已认领'
</select>
</mapper>
......@@ -326,7 +326,7 @@
<where>
(
<choose>
<when test="cityCode != null and cityCode != ''">--按监管单位统计时,省局使用
<when test="cityCode != null and cityCode != ''">
(
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
......@@ -340,7 +340,7 @@
OR
(a.supervise_org_code = '50' AND a.office_region LIKE CONCAT('%', #{cityCode}, '%'))
</when>
<otherwise>--按监管单位统计时,除省局使用
<otherwise>
<choose>
<when test="isOrgCodeExactMatch != null and isOrgCodeExactMatch != ''">
a.supervise_org_code != '50' AND a.supervise_org_code = #{orgCode}
......
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