Commit 12431837 authored by 麻笑宇's avatar 麻笑宇

气瓶 / 区域气站对接率排名下钻

代码提交
parent 628216c8
...@@ -168,6 +168,12 @@ public class DPFilterParamForDetailDto { ...@@ -168,6 +168,12 @@ public class DPFilterParamForDetailDto {
* 接受单位 * 接受单位
*/ */
private String inspectionUnitName; private String inspectionUnitName;
/**
* 充装介质
*/
private String fillingMedium;
/**
* 是否对接 0:未对接,1:已对接
*/
private String isDock;
} }
package com.yeejoin.amos.boot.module.jg.api.enums;
import com.yeejoin.amos.boot.module.common.api.enums.JgBusinessTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.*;
@Getter
@AllArgsConstructor
public enum CylinderFillingMediumEnum {
COMPRESSED_NATURAL_GAS("压缩天然气", "COMPRESSED_NATURAL_GAS"),
LIQUEFIED_NATURAL_GAS("液化天然气", "LIQUEFIED_NATURAL_GAS"),
LIQUEFIED_PETROLEUM_GAS("液化石油气", "LIQUEFIED_PETROLEUM_GAS"),
HYDROGEN("氢气", "HYDROGEN");
private final String name;
private final String code;
public static String of(String code) {
for (CylinderFillingMediumEnum constants : values()) {
if (constants.getCode().equals(code)) {
return constants.getName();
}
}
return null;
}
public static List<Map<String,Object>> getEnumList() {
List<Map<String, Object>> list = new ArrayList<>();
for (CylinderFillingMediumEnum testEnum : EnumSet.allOf(CylinderFillingMediumEnum.class)) {
HashMap<String, Object> map = new HashMap<>();
map.put("title",testEnum.getName());
map.put("value",testEnum.getCode());
list.add(map);
}
return list;
}
}
package com.yeejoin.amos.boot.module.statistics.api.mapper; package com.yeejoin.amos.boot.module.statistics.api.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamForDetailDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.CylinderFillingMessageModel; import com.yeejoin.amos.boot.module.statistics.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto; import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Map;
/** /**
* Mapper 接口 * Mapper 接口
* *
...@@ -42,4 +46,10 @@ public interface CylinderStatisticsMapper { ...@@ -42,4 +46,10 @@ public interface CylinderStatisticsMapper {
@Param("orgCode") String orgCode); @Param("orgCode") String orgCode);
IPage<CylinderFillingMessageModel> getUploadCylinderLogsPage(IPage<CylinderFillingMessageModel> page, IPage<CylinderFillingMessageModel> getUploadCylinderLogsPage(IPage<CylinderFillingMessageModel> page,
@Param("orgCode") String orgCode); @Param("orgCode") String orgCode);
Long countFilling(@Param("orgCode") String orgCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
Long countOffloading(@Param("orgCode") String orgCode, @Param("startTime") String startTime, @Param("endTime") String endTime);
Page<Map<String, Object>> getNormalPage(@Param("page") Page<Map<String, Object>> page, @Param("dpFilterParamForDetailDto") DPFilterParamForDetailDto dpFilterParamForDetailDto);
} }
...@@ -100,4 +100,129 @@ ...@@ -100,4 +100,129 @@
</if> </if>
</where> </where>
</select> </select>
<select id="countFilling" resultType="java.lang.Long">
SELECT
IFNULL(SUM(cfr.filling_quantity),0)
FROM
tz_base_enterprise_info tbei
INNER JOIN tz_cylinder_filling_record cfr ON tbei.app_id = cfr.app_id
where
tbei.unit_type LIKE '%充装单位%'
and tbei.supervise_org_code like concat(#{orgCode},'%')
AND cfr.filling_endtime <![CDATA[>=]]> concat(#{startTime}, ' 00:00:00')
<if test="endTime != null and endTime != '' ">
AND cfr.filling_endtime <![CDATA[<=]]> concat(#{endTime}, ' 23:59:59')
</if>
</select>
<select id="countOffloading" resultType="java.lang.Long">
SELECT
IFNULL(SUM(co.offloading_volume),0)
FROM
tz_base_enterprise_info tbei
INNER JOIN tz_cylinder_offloading co ON tbei.app_id = co.app_id
where
tbei.unit_type LIKE '%充装单位%'
and tbei.supervise_org_code like concat(#{orgCode},'%')
AND co.statistics_sync_date <![CDATA[>=]]> concat(#{startTime})
<if test="endTime != null and endTime != '' ">
AND co.statistics_sync_date <![CDATA[<=]]> concat(#{endTime})
</if>
</select>
<select id="getNormalPage" resultType="java.util.Map">
SELECT
tbei.use_unit_code AS useUnitCode,
l.expiry_date AS expiryDate,
IFNULL ( u."userCount", '0' ) AS userCount,
IFNULL ( e."equipCount", '0' ) AS equipCount,
IFNULL ( f."fillingCount", '0' ) AS fillingCount,
IFNULL ( co."offloadingVolume", '0' ) AS offloadingVolume
FROM
tz_base_enterprise_info tbei
LEFT JOIN ( SELECT * FROM tz_base_unit_licence GROUP BY unit_code ORDER BY expiry_date DESC ) AS l ON
l.unit_code = tbei.use_unit_code
LEFT JOIN (
SELECT
tbei.use_unit_code AS useNnitCode,
COUNT ( 1 ) AS userCount
FROM
tz_base_enterprise_info tbei
INNER JOIN tzs_user_info ui ON tbei.use_unit_code = ui.unit_code
where
tbei.unit_type LIKE'%充装单位%'
GROUP BY
tbei.use_unit_code
) u ON u."useNnitCode" = tbei.use_unit_code
LEFT JOIN (
SELECT
tbei.use_unit_code AS useNnitCode,
COUNT ( 1 ) AS equipCount
FROM
tz_base_enterprise_info tbei
INNER JOIN idx_biz_jg_use_info jui ON tbei.use_unit_code = jui.USE_UNIT_CREDIT_CODE
LEFT JOIN idx_biz_jg_other_info joi ON joi.RECORD = jui.RECORD
AND joi.SUPERVISORY_CODE IS NOT NULL
AND joi.SUPERVISORY_CODE != ''
AND joi.SUPERVISORY_CODE != 'null'
where
tbei.unit_type LIKE'%充装单位%'
GROUP BY
tbei.use_unit_code
) e ON e."useNnitCode" = tbei.use_unit_code
LEFT JOIN (
SELECT
IFNULL ( SUM ( cfr.filling_quantity ), 0 ) AS fillingCount,
tbei.use_unit_code AS useNnitCode
FROM
tz_base_enterprise_info tbei
INNER JOIN tz_cylinder_filling_record cfr ON tbei.app_id = cfr.app_id
left join idx_biz_jg_factory_info jfi ON cfr.sequence_code = CONCAT(jfi.PRODUCE_UNIT_CREDIT_CODE,'-',jfi.FACTORY_NUM)
left join idx_biz_jg_tech_params_vessel jtpv ON jtpv.RECORD = jfi.RECORD
WHERE
tbei.unit_type LIKE'%充装单位%'
<if test="dpFilterParamForDetailDto.fillingMedium != null and dpFilterParamForDetailDto.fillingMedium != ''">
AND jtpv.CHARGING_MEDIUM = #{dpFilterParamForDetailDto.fillingMedium}
</if>
<if test="dpFilterParamForDetailDto.timeSearchOne != null and dpFilterParamForDetailDto.timeSearchOne != ''">
<if test="dpFilterParamForDetailDto.timeSearchOne.beginDate != null and dpFilterParamForDetailDto.timeSearchOne.beginDate != ''">
and date_ge(CAST(cfr.filling_endtime as date),#{dpFilterParamForDetailDto.timeSearchOne.beginDate})
</if>
<if test="dpFilterParamForDetailDto.timeSearchOne.endDate != null and dpFilterParamForDetailDto.timeSearchOne.endDate != ''">
and date_le(CAST(cfr.filling_endtime as date),#{dpFilterParamForDetailDto.timeSearchOne.endDate})
</if>
</if>
GROUP BY
tbei.use_unit_code
) f ON f."useNnitCode" = tbei.use_unit_code
LEFT JOIN (
SELECT
IFNULL ( SUM ( co.offloading_volume ), 0 ) AS offloadingVolume,
tbei.use_unit_code AS useNnitCode
FROM
tz_base_enterprise_info tbei
INNER JOIN tz_cylinder_offloading co ON tbei.app_id = co.app_id
WHERE
tbei.unit_type LIKE'%充装单位%'
<if test="dpFilterParamForDetailDto.timeSearchOne != null and dpFilterParamForDetailDto.timeSearchOne != ''">
<if test="dpFilterParamForDetailDto.timeSearchOne.beginDate != null and dpFilterParamForDetailDto.timeSearchOne.beginDate != ''">
and date_ge(CAST(co.statistics_sync_date as date),#{dpFilterParamForDetailDto.timeSearchOne.beginDate})
</if>
<if test="dpFilterParamForDetailDto.timeSearchOne.endDate != null and dpFilterParamForDetailDto.timeSearchOne.endDate != ''">
and date_le(CAST(co.statistics_sync_date as date),#{dpFilterParamForDetailDto.timeSearchOne.endDate})
</if>
</if>
GROUP BY
tbei.use_unit_code
) co ON co."useNnitCode" = tbei.use_unit_code
WHERE
tbei.unit_type LIKE'%充装单位%'
<if test="dpFilterParamForDetailDto.orgCode != null and dpFilterParamForDetailDto.orgCode != '' ">
AND tbei.supervise_org_code like concat(#{dpFilterParamForDetailDto.orgCode},'%')
</if>
<if test="dpFilterParamForDetailDto.isDock == 0">
AND ( fillingCount is null and offloadingVolume is null )
</if>
<if test="dpFilterParamForDetailDto.isDock == 1">
AND ( fillingCount is not null OR offloadingVolume is not null )
</if>
</select>
</mapper> </mapper>
...@@ -187,4 +187,43 @@ public class CylinderDPStatisticsController extends BaseController { ...@@ -187,4 +187,43 @@ public class CylinderDPStatisticsController extends BaseController {
IPage<CylinderFillingMessageModel> result = dpStatisticsService.getUploadCylinderLogs(pageParam, regionCode); IPage<CylinderFillingMessageModel> result = dpStatisticsService.getUploadCylinderLogs(pageParam, regionCode);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/normalChart")
@ApiOperation(httpMethod = "POST", value = "气瓶通用下钻图表", notes = "气瓶通用下钻图表")
public ResponseModel<Map<String, Object>> normalChart(@RequestBody DPFilterParamForDetailDto dpFilterParamForDetailDto) {
return ResponseHelper.buildResponse(dpStatisticsService.normalChart(dpFilterParamForDetailDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/normalPage")
@ApiOperation(httpMethod = "POST", value = "气瓶通用下钻列表", notes = "气瓶通用下列表")
public ResponseModel<Page<Map<String, Object>>> normalPage(@RequestBody DPFilterParamForDetailDto dpFilterParamForDetailDto,
@RequestParam(value = "current", defaultValue = "1") Integer current,
@RequestParam(value = "size", defaultValue = "20") Integer size) {
Page<Map<String, Object>> page = new Page<>(current,size);
return ResponseHelper.buildResponse(dpStatisticsService.normalPage(page,dpFilterParamForDetailDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "气瓶通用下钻筛选", notes = "气瓶通用下钻筛选")
@PostMapping(value = "/normalSearch")
public ResponseModel<Map<String,List<Map<String,Object>>>> normalSearch(@Validated @RequestBody DPFilterParamForDetailDto dpFilterParamForDetailDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(dpStatisticsService.normalSearch(dpFilterParamForDetailDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "气瓶通用下钻类型", notes = "气瓶通用下钻类型")
@PostMapping(value = "/normalType")
public ResponseModel<List<Map<String, Object>>> normalType(@Validated @RequestBody DPFilterParamForDetailDto dpFilterParamForDetailDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(dpStatisticsService.normalType(dpFilterParamForDetailDto));
}
} }
...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils; ...@@ -10,6 +10,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.dto.CylinderFillingRecordStatisticsDto; import com.yeejoin.amos.boot.module.common.api.dto.CylinderFillingRecordStatisticsDto;
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.jg.api.enums.CylinderFillingMediumEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum; import com.yeejoin.amos.boot.module.jg.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.statistics.api.dto.CylinderFillingMessageModel; import com.yeejoin.amos.boot.module.statistics.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.statistics.api.dto.SecurityIndexCountItemDto; import com.yeejoin.amos.boot.module.statistics.api.dto.SecurityIndexCountItemDto;
...@@ -874,4 +875,118 @@ public class CylinderDPStatisticsServiceImpl { ...@@ -874,4 +875,118 @@ public class CylinderDPStatisticsServiceImpl {
return page; return page;
} }
public Map<String, Object> normalChart(DPFilterParamForDetailDto dpFilterParamForDetailDto) {
List<RegionModel> regionList = stCommonService.setRegionIfRootParent(dpFilterParamForDetailDto.getCityCode());
List<Map<String,Object>> list = regionList.parallelStream().map(r -> {
String orgCode = stCommonService.getAndSetOrgCode(r.getRegionCode().toString());
Map<String, Object> item = new HashMap<>();
item.put("regionCode", r.getRegionCode());
item.put("regionName", r.getRegionName());
getNormalChart(orgCode, item, dpFilterParamForDetailDto);
return item;
}).collect(Collectors.toList());
List<String> counts = new ArrayList<>();
List<String> stationRates = new ArrayList<>();
List<String> fillCount = new ArrayList<>();
List<String> offloadingCount = new ArrayList<>();
List<String> xdata = new ArrayList<>();
for(int i = 0; i < list.size(); i++){
counts.add(list.get(i).get("totalNum") != null ? list.get(i).get("totalNum").toString() : "");
stationRates.add(list.get(i).get("stationRate") != null ? list.get(i).get("stationRate").toString() : "");
fillCount.add(list.get(i).get("fillCount") != null ? list.get(i).get("fillCount").toString() : "0");
offloadingCount.add(list.get(i).get("offloadingCount") != null ? list.get(i).get("offloadingCount").toString() : "0");
xdata.add(list.get(i).get("regionName")+"");
}
Map<String,Object> result = new HashMap<>();
Set<Map<String,String>> legendData = new HashSet<>();
for (int i = 0; i < 4; i++) {
Map<String, String> map = new HashMap<>();
if (i == 0) {
map.put("dataKey", "count");
map.put("value", "对接数量");
map.put("chartType", "bar");
} else if(i == 1){
map.put("dataKey", "stationRate");
map.put("value", "对接率");
map.put("chartType", "line");
} else if(i == 2){
map.put("dataKey", "fillCount");
map.put("value", "充装量");
map.put("chartType", "bar");
}else{
map.put("dataKey", "offloadingCount");
map.put("value", "卸液量");
map.put("chartType", "bar");
}
legendData.add(map);
}
result.put("legendData", legendData);
result.put("xdata", xdata);
result.put("count", counts);
result.put("stationRate", stationRates);
result.put("fillCount", fillCount);
result.put("offloadingCount",offloadingCount);
return result;
}
private Map<String,Object> getNormalChart(String orgCode, Map<String, Object> result, DPFilterParamForDetailDto dpFilterParamForDetailDto) {
// 气站总数
Long totalNum = null == orgCode ? null : cylinderStatisticsMapper.countEnterpriseNumForCylinder(orgCode);
// 已对接总数(存在充装业务数据的企业则认为已对接)
Long count = null == orgCode ? null : cylinderStatisticsMapper.countEnterpriseUsed(orgCode);
if (totalNum != null && count != null && totalNum > 0 ) {
BigDecimal percent = (new BigDecimal(count.doubleValue()).divide(new BigDecimal(totalNum.doubleValue()), 2, RoundingMode.HALF_UP));
result.put("stationRate", Double.valueOf(percent.toString()));
} else {
result.put("stationRate", 0.0);
}
//充装量
Long fillCount = cylinderStatisticsMapper.countFilling(orgCode,LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),null);
//卸液量
Long offloadingCount = cylinderStatisticsMapper.countOffloading(orgCode,LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")),null);
result.put("totalNum", totalNum);
result.put("count", count);
result.put("fillCount", fillCount);
result.put("offloadingCount", offloadingCount);
return result;
}
public Page<Map<String, Object>> normalPage(Page<Map<String, Object>> page, DPFilterParamForDetailDto dpFilterParamForDetailDto) {
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamForDetailDto.getCityCode());
dpFilterParamForDetailDto.setOrgCode(orgCode);
Page<Map<String, Object>> list = cylinderStatisticsMapper.getNormalPage(page, dpFilterParamForDetailDto);
for(int i = 0; i < list.getRecords().size(); i++){
if("0.0".equals(list.getRecords().get(i).get("fillingCount")+"") && "0.0".equals(list.getRecords().get(i).get("offloadingVolume")+"")){
list.getRecords().get(i).put("isDock","对接");
}else{
list.getRecords().get(i).put("isDock","已对接");
}
}
return list;
}
public Map<String,List<Map<String,Object>>> normalSearch(DPFilterParamForDetailDto dpFilterParamForDetailDto) {
Map<String,List<Map<String,Object>>> returnMap = new HashMap<>();
List<Map<String, Object>> enumList = CylinderFillingMediumEnum.getEnumList();
returnMap.put("fillingMedium",enumList);
return returnMap;
}
public List<Map<String, Object>> normalType(DPFilterParamForDetailDto dpFilterParamForDetailDto) {
List<Map<String, Object>> childrenList = new ArrayList<>();
Map<String,Object> childrenMap = new HashMap<>();
childrenMap.put("title","充装单位");
childrenMap.put("value","充装单位");
childrenList.add(childrenMap);
List<Map<String,Object>> result = new ArrayList<>();
Map<String,Object> map = new HashMap<>();
map.put("title","企业类型");
map.put("value","0");
map.put("children",childrenList);
result.add(map);
return result;
}
} }
\ No newline at end of file
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