Commit c714594f authored by Lambertliu's avatar Lambertliu

fix(jg):大屏气瓶查询修改

parent 9ac3dac1
...@@ -92,6 +92,8 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> { ...@@ -92,6 +92,8 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
List<Map<String,Object>> getUseRegisterCount(@Param("orgCode")String orgCode); List<Map<String,Object>> getUseRegisterCount(@Param("orgCode")String orgCode);
List<Map<String,Object>> getUseRegisterCountTotal();
List<Map<String, Object>> getElevatorModeList(@Param("equIds") List<String> equIds); List<Map<String, Object>> getElevatorModeList(@Param("equIds") List<String> equIds);
List<Map<String, Object>> getCylinderInfoList(@Param("records") List<String> records); List<Map<String, Object>> getCylinderInfoList(@Param("records") List<String> records);
......
...@@ -1279,4 +1279,20 @@ ...@@ -1279,4 +1279,20 @@
) )
</update> </update>
<select id="getUseRegisterCountTotal" resultType="java.util.Map">
SELECT
date_format(A.audit_pass_date, '%Y-%m') AS time,
A.supervision_org_code AS supervisionOrgCode
FROM
"tzs_jg_use_registration_eq" ae
JOIN tzs_jg_use_registration A ON A.sequence_nbr = ae.equip_transfer_id
JOIN "idx_biz_jg_use_info" u ON ae.equ_id = u."RECORD"
JOIN idx_biz_jg_register_info ri ON u."RECORD" = ri."RECORD"
WHERE
ae.equ_id = u."RECORD"
AND ri.EQU_CATEGORY = '2300'
AND A.status = '已完成'
AND A.is_delete = 0
AND A.supervision_org_code is not null
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.statistics.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @author system_generator
* @date 2025-02-21
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="CylinderBusinessStatisticsDto", description="")
public class CylinderBusinessStatisticsDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "年月")
private String time;
@ApiModelProperty(value = "总数")
private Long num;
@ApiModelProperty(value = "机构代码")
private String supervisionOrgCode;
}
package com.yeejoin.amos.boot.module.statistics.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
*
*
* @author system_generator
* @date 2025-02-21
*/
@Data
@Accessors(chain = true)
@TableName("tzs_cylinder_business_statistics")
public class CylinderBusinessStatistics implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(
value = "SEQUENCE_NBR",
type = IdType.ID_WORKER
)
protected Long sequenceNbr;
/**
* 年月
*/
@TableField("time")
private String time;
/**
* 总数
*/
@TableField("num")
private Long num;
/**
* 机构代码
*/
@TableField("supervision_org_code")
private String supervisionOrgCode;
public CylinderBusinessStatistics(String time, String supervisionOrgCode) {
this.time = time;
this.supervisionOrgCode = supervisionOrgCode;
}
}
package com.yeejoin.amos.boot.module.statistics.api.mapper;
import com.yeejoin.amos.boot.module.statistics.api.entity.CylinderBusinessStatistics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
*
* @author system_generator
* @date 2025-02-21
*/
public interface CylinderBusinessStatisticsMapper extends BaseMapper<CylinderBusinessStatistics> {
void deleteAll();
void insertBatch(@Param("list") List<CylinderBusinessStatistics> cylinderBusinessStatisticsList);
List<Map<String,Object>> getUseRegisterCount(@Param("orgCode")String orgCode);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper">
<insert id="insertBatch" parameterType="com.yeejoin.amos.boot.module.statistics.api.entity.CylinderBusinessStatistics">
insert into tzs_cylinder_business_statistics
(sequence_nbr, time, supervision_org_code, update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.sequenceNbr},
#{item.time},
#{item.supervisionOrgCode},
CURRENT_TIMESTAMP
)
</foreach>
</insert>
<delete id="deleteAll">
delete from tzs_cylinder_business_statistics
</delete>
<select id="getUseRegisterCount" resultType="java.util.Map">
SELECT
C.time, -- 月份
COUNT(1) AS num -- 每月的记录数
FROM
tzs_cylinder_business_statistics C
WHERE
C.supervision_org_code LIKE '50%' -- 仅过滤 '50%' 开头的监管机构代码
GROUP BY
C.time -- 按月份分组
</select>
</mapper>
package com.yeejoin.amos.boot.module.statistcs.biz.job;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.statistics.api.entity.CylinderBusinessStatistics;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 定时任务统计
*
* @author LiuLin
*/
@EnableScheduling
@Component
@Slf4j
public class MonthCylinderBusinessStatisticsJob {
private final JgUseRegistrationMapper useRegistrationMapper;
private final CylinderBusinessStatisticsMapper businessStatisticsMapper;
public MonthCylinderBusinessStatisticsJob(JgUseRegistrationMapper useRegistrationMapper,
CylinderBusinessStatisticsMapper businessStatisticsMapper) {
this.useRegistrationMapper = useRegistrationMapper;
this.businessStatisticsMapper = businessStatisticsMapper;
}
@Scheduled(cron = "0 */5 * * * ?")
@SchedulerLock(name = "cylinderBusinessStatisticsJob", lockAtMostFor = "PT1H")
public void cylinderBusinessStatisticsJob() {
List<Map<String, Object>> useRegisterCountList = useRegistrationMapper.getUseRegisterCountTotal();
if (!CollectionUtils.isEmpty(useRegisterCountList)) {
businessStatisticsMapper.deleteAll();
List<CylinderBusinessStatistics> statisticsList = useRegisterCountList.stream()
.map(item -> new CylinderBusinessStatistics(
(String) item.get("time"),
(String) item.get("supervisionOrgCode")
))
.collect(Collectors.toList());
businessStatisticsMapper.insertBatch(statisticsList);
}
}
}
...@@ -306,11 +306,11 @@ public class CylinderDPStatisticsServiceImpl { ...@@ -306,11 +306,11 @@ public class CylinderDPStatisticsServiceImpl {
public Map<String, Object> getCylinderStatisticsDataByCityForTotal(DPFilterParamDto dpFilterParamDto) { public Map<String, Object> getCylinderStatisticsDataByCityForTotal(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode()); String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
getCylinderMapCount(orgCode, result); getCylinderMapCount(orgCode, result, dpFilterParamDto.getCityCode());
return result; return result;
} }
private Map<String, Object> getCylinderMapCount(String orgCode, Map<String, Object> result) { private void getCylinderMapCount(String orgCode, Map<String, Object> result, String cityCode) {
if (StringUtils.isNotEmpty(orgCode)) { if (StringUtils.isNotEmpty(orgCode)) {
Long cylindersCount = this.countForCylinderNum(orgCode); Long cylindersCount = this.countForCylinderNum(orgCode);
Long automotiveGasCount = this.countForCylinderNumForVehicleUsed(orgCode); Long automotiveGasCount = this.countForCylinderNumForVehicleUsed(orgCode);
...@@ -330,15 +330,38 @@ public class CylinderDPStatisticsServiceImpl { ...@@ -330,15 +330,38 @@ public class CylinderDPStatisticsServiceImpl {
// 检验超期气瓶数 // 检验超期气瓶数
result.put("jycqsbCount", this.countForCylinderOverdueInspect(orgCode)); result.put("jycqsbCount", this.countForCylinderOverdueInspect(orgCode));
// 充气量 // 充气量
Long fillingVolumeCount = cylinderStatisticsMapper.countFillingVolumeCount(orgCode); // Long fillingVolumeCount = cylinderStatisticsMapper.countFillingVolumeCount(orgCode);
result.put("fillingVolumeCount", fillingVolumeCount == null ? 0L : new BigDecimal(fillingVolumeCount).divide(new BigDecimal("10000000")).setScale(3,RoundingMode.HALF_UP).toString()); Double fillingVolumeCount = this.countFillingVolumeCount(cityCode);
BigDecimal value = new BigDecimal(fillingVolumeCount);
value = value.divide(new BigDecimal("1000"), 3, RoundingMode.HALF_UP);
String unit = (fillingVolumeCount == 0) ? "吨" : (fillingVolumeCount > 10000 ? "万吨" : "吨");
BigDecimal resultValue = (fillingVolumeCount > 10000000) ? value.divide(new BigDecimal("10000000"), 3, RoundingMode.HALF_UP) : value;
result.put("fillingVolumeCount", resultValue );
// 卸液量 // 卸液量
Long dischargeVolumeCount = cylinderStatisticsMapper.countDischargeVolumeCount(orgCode); Long dischargeVolumeCount = cylinderStatisticsMapper.countDischargeVolumeCount(orgCode);
result.put("dischargeVolumeCount", dischargeVolumeCount == null ? 0L : new BigDecimal(dischargeVolumeCount).divide(new BigDecimal("10000000")).setScale(3,RoundingMode.HALF_UP).toString()); result.put("dischargeVolumeCount", dischargeVolumeCount == null ? 0L : new BigDecimal(dischargeVolumeCount).divide(new BigDecimal("10000000")).setScale(3,RoundingMode.HALF_UP).toString());
} else { } else {
this.setDefaultValueIfNoData(result, "cylindersCount", "stationCount", "operatorCount", "liquefiedGasCount", "automotiveGasCount", "industrialGasCount", "useRegistrationQuantityCount", "jylqsbCount", "jycqsbCount","fillingVolumeCount","dischargeVolumeCount"); this.setDefaultValueIfNoData(result, "cylindersCount", "stationCount", "operatorCount", "liquefiedGasCount", "automotiveGasCount", "industrialGasCount", "useRegistrationQuantityCount", "jylqsbCount", "jycqsbCount","fillingVolumeCount","dischargeVolumeCount");
} }
return result; }
/**
* 从ES查询总量
* @param cityCode
* @return
*/
private Double countFillingVolumeCount(String cityCode) {
DPFilterParamForDetailDto dpFilterParamForDetailDto = new DPFilterParamForDetailDto();
dpFilterParamForDetailDto.setCityCode(cityCode);
List<Map<String, Object>> list = this.getFillingQuantity(dpFilterParamForDetailDto, null, null);
return list.isEmpty()
? 0L
: list.stream()
.mapToDouble(e -> Optional.ofNullable(e.get("fillingQuantity"))
.map(f -> Double.parseDouble(f.toString()))
.orElse(0.0))
.sum();
} }
/** /**
...@@ -422,7 +445,7 @@ public class CylinderDPStatisticsServiceImpl { ...@@ -422,7 +445,7 @@ public class CylinderDPStatisticsServiceImpl {
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
item.put("regionCode", r.getRegionCode()); item.put("regionCode", r.getRegionCode());
item.put("regionName", r.getRegionName()); item.put("regionName", r.getRegionName());
getCylinderMapCount(orgCode, item); getCylinderMapCount(orgCode, item, dpFilterParamDto.getCityCode());
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
......
...@@ -35,6 +35,7 @@ import com.yeejoin.amos.boot.module.jg.api.entity.SafetyProblemTracing; ...@@ -35,6 +35,7 @@ import com.yeejoin.amos.boot.module.jg.api.entity.SafetyProblemTracing;
import com.yeejoin.amos.boot.module.jg.api.enums.*; import com.yeejoin.amos.boot.module.jg.api.enums.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.*; import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils; import com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.JGStatisticsMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.JGStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto; import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
...@@ -180,6 +181,8 @@ public class JGDPStatisticsServiceImpl { ...@@ -180,6 +181,8 @@ public class JGDPStatisticsServiceImpl {
private JgUseRegistrationMapper useRegistrationMapper; private JgUseRegistrationMapper useRegistrationMapper;
private CylinderBusinessStatisticsMapper businessStatisticsMapper;
private JgEnableDisableMapper enableDisableMapper; private JgEnableDisableMapper enableDisableMapper;
private JgScrapCancelMapper scrapCancelMapper; private JgScrapCancelMapper scrapCancelMapper;
...@@ -277,8 +280,10 @@ public class JGDPStatisticsServiceImpl { ...@@ -277,8 +280,10 @@ public class JGDPStatisticsServiceImpl {
IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper, IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper,
IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper, IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper,
DataDictionaryServiceImpl iDataDictionaryService, DataDictionaryServiceImpl iDataDictionaryService,
SafetyProblemTracingMapper safetyProblemTracingMapper) { SafetyProblemTracingMapper safetyProblemTracingMapper,
CylinderBusinessStatisticsMapper businessStatisticsMapper) {
this.useRegistrationMapper = useRegistrationMapper; this.useRegistrationMapper = useRegistrationMapper;
this.businessStatisticsMapper = businessStatisticsMapper;
this.enableDisableMapper = enableDisableMapper; this.enableDisableMapper = enableDisableMapper;
this.scrapCancelMapper = scrapCancelMapper; this.scrapCancelMapper = scrapCancelMapper;
this.restHighLevelClient = restHighLevelClient; this.restHighLevelClient = restHighLevelClient;
...@@ -512,7 +517,7 @@ public class JGDPStatisticsServiceImpl { ...@@ -512,7 +517,7 @@ public class JGDPStatisticsServiceImpl {
List<Object> scrappedDeviceList = new ArrayList(); List<Object> scrappedDeviceList = new ArrayList();
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM"); DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM");
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode()); String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
List<Map<String,Object>> useRegisterCountList = useRegistrationMapper.getUseRegisterCount(orgCode); List<Map<String,Object>> useRegisterCountList = businessStatisticsMapper.getUseRegisterCount(orgCode);
List<Map<String,Object>> scrappedDeviceCountList = scrapCancelMapper.getScrappedDeviceCount(dpFilterParamDto); List<Map<String,Object>> scrappedDeviceCountList = scrapCancelMapper.getScrappedDeviceCount(dpFilterParamDto);
Map<String,Object> useRegisterCount = new HashMap<>(); Map<String,Object> useRegisterCount = new HashMap<>();
Map<String,Object> scrappedDeviceCount = new HashMap<>(); Map<String,Object> scrappedDeviceCount = new HashMap<>();
......
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