Commit 1d096ab5 authored by 刘林's avatar 刘林

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into…

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into develop_tzs_register_to_0715
parents 1a863b7b eaeed283
...@@ -147,16 +147,13 @@ ...@@ -147,16 +147,13 @@
LEFT JOIN idx_biz_jg_use_info ibjuj ON tac.equipment_id = ibjuj.RECORD LEFT JOIN idx_biz_jg_use_info ibjuj ON tac.equipment_id = ibjuj.RECORD
LEFT JOIN cb_data_dictionary cdd ON ibjuj.USE_PLACE = cdd.sequence_nbr LEFT JOIN cb_data_dictionary cdd ON ibjuj.USE_PLACE = cdd.sequence_nbr
WHERE WHERE
biz_org_code LIKE concat(#{regionCode}, '%') tac.biz_org_code LIKE concat(#{regionCode}, '%')
AND (tac.alarm_type_code = '960' or tac.alarm_type_code = '961') AND (tac.alarm_type_code = '960' or tac.alarm_type_code = '961')
AND AND
ibjuj.USE_PLACE is NOT NULL ibjuj.USE_PLACE is NOT NULL
AND cdd.NAME is NOT NULL AND cdd.NAME is NOT NULL
<if test="dto.beginDate !=null and dto.beginDate !=''"> <if test="dto.beginDate !=null and dto.beginDate !='' and dto.endDate !=null and dto.endDate !=''">
and date_ge(CAST(tac.call_time as date),#{dto.beginDate}) AND tac.call_time BETWEEN #{dto.beginDate} AND #{dto.endDate}
</if>
<if test="dto.endDate !=null and dto.endDate !=''">
and date_le(CAST(tac.call_time as date),#{dto.endDate})
</if> </if>
GROUP BY GROUP BY
cdd.NAME cdd.NAME
......
...@@ -133,6 +133,9 @@ public class DPStatisticsServiceImpl { ...@@ -133,6 +133,9 @@ public class DPStatisticsServiceImpl {
public JSONObject eventStatByLocation(DPFilterParamDto dpFilterParamDto) throws Exception { public JSONObject eventStatByLocation(DPFilterParamDto dpFilterParamDto) throws Exception {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto); String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
dpFilterParamDto.setBeginDate(DateUtil.formatDate(DateTimeUtil.getMinValueOfOneDay(DateTimeUtil.addMonths(new Date(), -1)), DateUtil.Y_M_D_HMS));
dpFilterParamDto.setEndDate(DateUtil.formatDate(DateTimeUtil.getMaxValueOfOneDay(new Date()), DateUtil.Y_M_D_HMS));
List<Map<String, Object>> maps = alertCalledMapper.queryListByLocation(orgCode, dpFilterParamDto); List<Map<String, Object>> maps = alertCalledMapper.queryListByLocation(orgCode, dpFilterParamDto);
List<Object> xdata = maps.stream().map(item -> item.get("name")).collect(Collectors.toList()); List<Object> xdata = maps.stream().map(item -> item.get("name")).collect(Collectors.toList());
List<Object> ydata = maps.stream().map(item -> item.get("majorAlertCount")).collect(Collectors.toList()); List<Object> ydata = maps.stream().map(item -> item.get("majorAlertCount")).collect(Collectors.toList());
......
...@@ -15,8 +15,6 @@ public enum IssueMainBodyEnum { ...@@ -15,8 +15,6 @@ public enum IssueMainBodyEnum {
COMPANY("企业","2"), COMPANY("企业","2"),
//设备 //设备
EQUIPMENT("设备","3"), EQUIPMENT("设备","3"),
//气瓶
CYLINDER("气瓶","4"),
; ;
......
...@@ -10,13 +10,13 @@ import java.util.List; ...@@ -10,13 +10,13 @@ import java.util.List;
@Getter @Getter
public enum IssueTypeEnum { public enum IssueTypeEnum {
//检验超期(设备) //检验超期(设备)
CHECK_OVERDUE_EQUMENT("检验超期","2","3"), CHECK_OVERDUE_EQUMENT("检验超期","2","3,4"),
//维保超期(设备) //维保超期(设备)
MAINTENANCE_OVERDUE_EQUMENT("维保超期","1","3"), MAINTENANCE_OVERDUE_EQUMENT("维保超期","1","3"),
//资质超期(设备) //资质超期(设备)
QUALIFICATION_OVERDUE_EQUMENT("资质超期","3","3"), QUALIFICATION_OVERDUE_EQUMENT("资质超期","3","3"),
//检验不合格(设备) //检验不合格(设备)
CHECK_UNQUALIFIED_EQUMENT("检验不合格","4","3"), CHECK_UNQUALIFIED_EQUMENT("检验不合格","4","3,4"),
//超设计使用年限(设备) //超设计使用年限(设备)
DESIGN_OVERDUE_EQUMENT("超设计使用年限","5","3"), DESIGN_OVERDUE_EQUMENT("超设计使用年限","5","3"),
//电梯困人(设备) //电梯困人(设备)
...@@ -33,16 +33,12 @@ public enum IssueTypeEnum { ...@@ -33,16 +33,12 @@ public enum IssueTypeEnum {
LICENSE_EXPIRY_PERSON("许可临期","11","1"), LICENSE_EXPIRY_PERSON("许可临期","11","1"),
//许可超期(个人) //许可超期(个人)
LICENSE_OVERDUE_PERSON("许可超期","12","1"), LICENSE_OVERDUE_PERSON("许可超期","12","1"),
//许可超期(气瓶)
LICENSE_OVERDUE_CYLINDER("许可超期","13","4"),
//检验超期(气瓶)
CHECK_OVERDUE_CYLINDER("检验超期","14","4"),
//检验不合格(气瓶)
CHECK_UNQUALIFIED_CYLINDER("检验不合格","15","4"),
//操作人员资质超期(气瓶) //操作人员资质超期(气瓶)
OPERATOR_QUALIFICATION_OVERDUE_CYLINDER("操作人员资质超期","16","1"), OPERATOR_QUALIFICATION_OVERDUE_CYLINDER("操作人员资质超期","13","4"),
//充装异常(气瓶) //充装异常(气瓶)
CHARGE_EXCEPTION_CYLINDER("充装异常","17","4"), CHARGE_EXCEPTION_CYLINDER("充装异常","14","4"),
//许可超期(设备,气瓶)
LICENSE_OVERDUE("许可超期","14","3,4"),
...@@ -68,10 +64,19 @@ public enum IssueTypeEnum { ...@@ -68,10 +64,19 @@ public enum IssueTypeEnum {
return list; return list;
} }
public static String getNameByCode(String code) {
for (IssueTypeEnum testEnum : EnumSet.allOf(IssueTypeEnum.class)) {
if(testEnum.getCode().equals(code)){
return testEnum.getName();
}
}
return null;
}
public static List<String> getEnumNameListByMainBody(String mainBody) { public static List<String> getEnumNameListByMainBody(String mainBody) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (IssueTypeEnum testEnum : EnumSet.allOf(IssueTypeEnum.class)) { for (IssueTypeEnum testEnum : EnumSet.allOf(IssueTypeEnum.class)) {
if(mainBody.equals(testEnum.getMainBody())){ if(testEnum.getMainBody().contains(mainBody)){
list.add(testEnum.getName()); list.add(testEnum.getName());
} }
} }
......
package com.yeejoin.amos.boot.module.cylinder.api.dto;
import lombok.Data;
/**
* @author Administrator
*/
@Data
public class EquipQuestionNumCountDto {
/**
* 设备id
*/
private String sourceId;
private String useOrgCode;
private String supervisoryCode;
private String useUnitName;
private String cityName;
private String equList;
private Long total;
private Long finished;
}
...@@ -38,4 +38,13 @@ public enum EquipmentClassifityEnum { ...@@ -38,4 +38,13 @@ public enum EquipmentClassifityEnum {
} }
} }
public static String getNameByCode(String code){
for (EquipmentClassifityEnum value : EquipmentClassifityEnum.values()) {
if (value.getCode().equals(code)){
return value.getName();
}
}
return "";
}
} }
package com.yeejoin.amos.boot.module.cylinder.api.mapper; package com.yeejoin.amos.boot.module.cylinder.api.mapper;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.EquipQuestionNumCountDto;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -15,7 +17,7 @@ public interface DPStatisticsMapper { ...@@ -15,7 +17,7 @@ public interface DPStatisticsMapper {
@Param("startDate") String startDate, @Param("status") String status); @Param("startDate") String startDate, @Param("status") String status);
List<Map<String, Object>> selectByOrgAndProblemType(@Param("orgCode") String orgCode, @Param("enumNameList") List<String> enumNameList, List<Map<String, Object>> selectByOrgAndProblemType(@Param("orgCode") String orgCode, @Param("enumNameList") List<String> enumNameList,
@Param("startDate") String startDate, @Param("sourceType") String sourceType); @Param("startDate") String startDate, @Param("sourceType") String sourceType, @Param("equipType") String equipType);
List<Map<String, Object>> getIssueCountByMonth(@Param("orgCode") String orgCode, @Param("year") String year, @Param("status") String status); List<Map<String, Object>> getIssueCountByMonth(@Param("orgCode") String orgCode, @Param("year") String year, @Param("status") String status);
List<Map<String, Object>> getIssueCountByDate(@Param("orgCode") String orgCode, @Param("year") String year, @Param("status") String status); List<Map<String, Object>> getIssueCountByDate(@Param("orgCode") String orgCode, @Param("year") String year, @Param("status") String status);
...@@ -31,4 +33,10 @@ public interface DPStatisticsMapper { ...@@ -31,4 +33,10 @@ public interface DPStatisticsMapper {
List<Map<String, Object>> issueProblemLevelCount(@Param("orgCode") String orgCode, @Param("time") String time); List<Map<String, Object>> issueProblemLevelCount(@Param("orgCode") String orgCode, @Param("time") String time);
List<Map<String, Object>> issueCompanyTop(@Param("orgCode") String orgCode, @Param("time") String time); List<Map<String, Object>> issueCompanyTop(@Param("orgCode") String orgCode, @Param("time") String time);
List<Map<String, Object>> issueChildrenCityCountTop(@Param("orgCodes") List<String> orgCodes, @Param("now") String now, @Param("status") String status);
List<Map<String, Object>> issueCountTopByProblemType(@Param("orgCode") String orgCode, @Param("status") String status);
List<EquipQuestionNumCountDto> queryEquipQuestionList(@Param("orgCode")String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
} }
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
governing_body_org_code LIKE concat ( #{orgCode}, '%' ) governing_body_org_code LIKE concat ( #{orgCode}, '%' )
AND problem_time &gt;= #{startDate} AND problem_time &gt;= #{startDate}
AND source_type = #{sourceType} AND source_type = #{sourceType}
<if test="null != equipType">
AND equip_list_code = #{equipType}
</if>
AND problem_type IN AND problem_type IN
<foreach collection="enumNameList" item="item" separator="," open="(" close=")"> <foreach collection="enumNameList" item="item" separator="," open="(" close=")">
#{item} #{item}
...@@ -149,6 +152,91 @@ ...@@ -149,6 +152,91 @@
COUNT DESC COUNT DESC
LIMIT 10 LIMIT 10
</select> </select>
<select id="issueChildrenCityCountTop" resultType="java.util.Map">
SELECT COUNT
( 1 ),
governing_body_org_code AS orgCode
FROM
tzs_safety_problem_tracing
WHERE
DATE_FORMAT(problem_time,'%Y') &gt;= #{now}
AND
<foreach collection="orgCodes" item="orgCode" separator="OR" open="(" close=")">
governing_body_org_code LIKE concat ( #{orgCode}, '%' )
</foreach>
<if test="null != status">
AND problem_status_code = #{status}
</if>
GROUP BY
governing_body_org_code
</select>
<select id="issueCountTopByProblemType" resultType="java.util.Map">
SELECT COUNT
( 1 ),
problem_type_code AS problemTypeCode
FROM
tzs_safety_problem_tracing
WHERE
governing_body_org_code LIKE concat ( #{orgCode}, '%' )
<if test="null != status">
AND problem_status_code = #{status}
</if>
GROUP BY
problem_type_code
ORDER BY
COUNT DESC
LIMIT 10
</select>
<select id="queryEquipQuestionList" resultType="com.yeejoin.amos.boot.module.cylinder.api.dto.EquipQuestionNumCountDto">
select
bb."USE_ORG_CODE",
cc."SUPERVISORY_CODE",
dd."USE_UNIT_NAME",
aa.finished,
aa.source_id,
aa.total,
dd."CITY_NAME",
bb."EQU_LIST"
from
(
select
a.total,
a.source_id,
ifnull(b.total,0) as finished
from
(
SELECT
count(1) as total,
source_id
FROM
"tzs_safety_problem_tracing"
WHERE
source_type_code = '3'
and governing_body_org_code like concat(#{orgCode}, '%')
and cast(problem_time AS DATE) between #{dto.beginDate} and #{dto.endDate}
GROUP BY source_id ORDER BY total desc) a
left join (
SELECT
count(1) as total,
source_id
FROM
"tzs_safety_problem_tracing"
WHERE
source_type_code = '3'
and problem_status_code ='1'
and governing_body_org_code like concat(#{orgCode}, '%')
and cast(problem_time AS DATE) between #{dto.beginDate} and #{dto.endDate}
GROUP BY source_id ORDER BY total desc) b on a.source_id = b.source_id
) aa,
idx_biz_jg_register_info bb,
idx_biz_jg_other_info cc,
idx_biz_jg_use_info dd
where
aa.source_id=bb."RECORD"
and aa.source_id=cc."RECORD"
and aa.source_id=dd."RECORD"
order by aa.total desc
</select>
</mapper> </mapper>
...@@ -4,15 +4,21 @@ package com.yeejoin.amos.boot.module.cylinder.flc.biz.controller; ...@@ -4,15 +4,21 @@ package com.yeejoin.amos.boot.module.cylinder.flc.biz.controller;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel; import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingMessageModel;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDataServiceImpl; import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderAreaDataServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.DPStatisticsServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -26,6 +32,8 @@ public class CylinderStatisticsController { ...@@ -26,6 +32,8 @@ public class CylinderStatisticsController {
@Autowired @Autowired
private CylinderAreaDataServiceImpl service; private CylinderAreaDataServiceImpl service;
@Autowired
private DPStatisticsServiceImpl statisticsService;
/** /**
* 预警预报统计 * 预警预报统计
...@@ -217,5 +225,40 @@ public class CylinderStatisticsController { ...@@ -217,5 +225,40 @@ public class CylinderStatisticsController {
} }
List<Map<String, Object>> result = service.issueCompanyTop(regionCode.toString()); List<Map<String, Object>> result = service.issueCompanyTop(regionCode.toString());
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-安全追溯-同设备近30天按问题次数滚动", notes = "大屏-安全追溯-同设备近30天按问题次数滚动")
@PostMapping(value = "/aqzs/equip-question/list")
public ResponseModel<List<Map<String, Object>>> getEquipQuestionList(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(statisticsService.getEquipQuestionList(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "当年下级区域问题闭环率排名")
@PostMapping(value = "/issueChildrenCityCountTop")
public ResponseModel<List<Map<String, Object>>> issueChildrenCityCountTop(@RequestBody Map<String, Object> map ) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
List<Map<String, Object>> result = service.issueChildrenCityCountTop(regionCode.toString());
return ResponseHelper.buildResponse(result);
};
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "按问题类型排名top 10")
@PostMapping(value = "/issueCountTopByProblemType")
public ResponseModel<List<Map<String, Object>>> issueCountTopByProblemType(@RequestBody Map<String, Object> map ) throws Exception {
Object regionCode = map.get("cityCode");
if (ObjectUtils.isEmpty(regionCode)) {
regionCode = "610000";
}
List<Map<String, Object>> result = service.issueCountTopByProblemType(regionCode.toString());
return ResponseHelper.buildResponse(result);
}; };
} }
...@@ -872,7 +872,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -872,7 +872,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
String orgCode = getAndSetOrgCode(cityCode); String orgCode = getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("3"); List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("3");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate,IssueMainBodyEnum.EQUIPMENT.getName()); List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate,IssueMainBodyEnum.EQUIPMENT.getName(),null);
list.stream().forEach(t->{ list.stream().forEach(t->{
dataMap.put(t.get("problemType").toString(),t.get("count").toString()); dataMap.put(t.get("problemType").toString(),t.get("count").toString());
}); });
...@@ -891,7 +891,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -891,7 +891,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
String orgCode = getAndSetOrgCode(cityCode); String orgCode = getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("2"); List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("2");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate,IssueMainBodyEnum.COMPANY.getName()); List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate,IssueMainBodyEnum.COMPANY.getName(),null);
list.stream().forEach(t->{ list.stream().forEach(t->{
dataMap.put(t.get("problemType").toString(),t.get("count").toString()); dataMap.put(t.get("problemType").toString(),t.get("count").toString());
}); });
...@@ -923,7 +923,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -923,7 +923,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
String orgCode = getAndSetOrgCode(cityCode); String orgCode = getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("1"); List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("1");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.PERSON.getName()); List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.PERSON.getName(),null);
list.stream().forEach(t->{ list.stream().forEach(t->{
dataMap.put(t.get("problemType").toString(),t.get("count").toString()); dataMap.put(t.get("problemType").toString(),t.get("count").toString());
}); });
...@@ -944,7 +944,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -944,7 +944,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
String orgCode = getAndSetOrgCode(cityCode); String orgCode = getAndSetOrgCode(cityCode);
List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("4"); List<String> enumNameList = IssueTypeEnum.getEnumNameListByMainBody("4");
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.CYLINDER.getName()); List<Map<String,Object>> list = statisticsMapper.selectByOrgAndProblemType(orgCode, enumNameList, startDate, IssueMainBodyEnum.EQUIPMENT.getName(),"2300");
list.stream().forEach(t->{ list.stream().forEach(t->{
dataMap.put(t.get("problemType").toString(),t.get("count").toString()); dataMap.put(t.get("problemType").toString(),t.get("count").toString());
}); });
...@@ -1151,4 +1151,87 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -1151,4 +1151,87 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
} }
return resultList; return resultList;
} }
public List<Map<String, Object>> issueChildrenCityCountTop(String cityCode) throws Exception {
List<RegionModel> regionModels = setRegionIfRootParent(cityCode);
List<Integer> regionCodeList = regionModels.stream().map(m -> m.getRegionCode()).collect(Collectors.toList());
List<Map<String, String>> orgCodeAndCompanyCodesByCompanyCodes = statisticsMapper.getOrgCodeAndCompanyCodesByCompanyCodes(regionCodeList);
List<String> orgCodes = orgCodeAndCompanyCodesByCompanyCodes.stream().map(m -> m.get("orgCode")).collect(Collectors.toList());
String now = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy"));
Map<String,String> orgCodeAndCompanyCodesMap = new HashMap<>();
orgCodeAndCompanyCodesByCompanyCodes.stream().forEach(t->{
orgCodeAndCompanyCodesMap.put(t.get("companyCode"),t.get("orgCode"));
});
List<Map<String, Object>> allIssueCount = statisticsMapper.issueChildrenCityCountTop(orgCodes,now,null);
List<Map<String, Object>> endIssueCount = statisticsMapper.issueChildrenCityCountTop(orgCodes,now,"1");
Map<String,Object> allIssuedataMap = new HashMap<>();
Map<String,Object> endIssuedataMap = new HashMap<>();
allIssueCount.stream().forEach(t->{
allIssuedataMap.put(t.get("orgCode").toString(),t.get("count"));
});
endIssueCount.stream().forEach(t->{
endIssuedataMap.put(t.get("orgCode").toString(),t.get("count"));
});
List<Map<String,Object>> resultList = new ArrayList<>();
for(RegionModel regionModel : regionModels){
Map<String,Object> map = new HashMap<>();
AtomicInteger allCount = new AtomicInteger();
AtomicInteger endCount = new AtomicInteger();
map.put("region",regionModel.getRegionName());
if(StringUtils.isNotBlank(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode()+""))){
allIssuedataMap.forEach((k, v)->{
if(k.startsWith(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode()+""))){
if(null != v){
allCount.addAndGet(Integer.valueOf(v+""));
}
}
});
}
if(StringUtils.isNotBlank(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode()+""))){
endIssuedataMap.forEach((k, v)->{
if(k.startsWith(orgCodeAndCompanyCodesMap.get(regionModel.getRegionCode()+""))){
if(null != v){
endCount.addAndGet(Integer.valueOf(v+""));
}
}
});
}
if(allCount.get() != 0) {
map.put("rate", new DecimalFormat("0.00").format(Double.parseDouble(endCount+"") / (Double.parseDouble(allCount.get()+""))));
}else{
map.put("rate", "0.00");
}
resultList.add(map);
}
resultList.sort(Comparator.comparing(m -> Double.valueOf( m.get("rate")+""), Comparator.reverseOrder()));
for(int i = 0; i < resultList.size(); i++){
resultList.get(i).put("sequenceNbr",(i+1)+"");
}
return resultList;
}
public List<Map<String, Object>> issueCountTopByProblemType(String cityCode) {
String orgCode = getAndSetOrgCode(cityCode);
List<Map<String,Object>> allList = statisticsMapper.issueCountTopByProblemType(orgCode,null);
List<Map<String,Object>> endList = statisticsMapper.issueCountTopByProblemType(orgCode,"1");
Map<String,Object> endIssuedataMap = new HashMap<>();
endList.stream().forEach(t->{
endIssuedataMap.put(t.get("problemTypeCode").toString(),t.get("count"));
});
List<Map<String,Object>> resultList = new ArrayList<>();
for(int i = 0; i < allList.size(); i++){
Map<String,Object> map = new HashMap<>();
map.put("name",IssueTypeEnum.getNameByCode(allList.get(i).get("problemTypeCode").toString()));
map.put("count",allList.get(i).get("count"));
if(null != endIssuedataMap.get(allList.get(i).get("problemTypeCode").toString())){
map.put("rate",new DecimalFormat("0.00").format(Double.parseDouble(endIssuedataMap.get(allList.get(i).get("problemTypeCode").toString())+"") / (Double.parseDouble(allList.get(i).get("count")+""))));
}
resultList.add(map);
}
return resultList;
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.EquipQuestionNumCountDto;
import com.yeejoin.amos.boot.module.cylinder.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.cylinder.api.mapper.DPStatisticsMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service
public class DPStatisticsServiceImpl {
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
private DPStatisticsMapper statisticsMapper;
public DPStatisticsServiceImpl(DPStatisticsMapper statisticsMapper) {
this.statisticsMapper = statisticsMapper;
}
public List<Map<String, Object>> getEquipQuestionList(DPFilterParamDto dpFilterParamDto) {
this.setDefaultFilter(dpFilterParamDto);
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if(StringUtils.isEmpty(orgCode)){
return new ArrayList<>();
}
List<EquipQuestionNumCountDto> equipQuestionNumCountDtos = statisticsMapper.queryEquipQuestionList(orgCode, dpFilterParamDto);
return this.calPercentFinishedAndCast2Map(equipQuestionNumCountDtos);
}
private List<Map<String, Object>> calPercentFinishedAndCast2Map(List<EquipQuestionNumCountDto> equipQuestionNumCountDtos) {
return equipQuestionNumCountDtos.stream().map(e -> {
Map<String, Object> item = new HashMap<>();
// 设备id
item.put("key", e.getSourceId());
// 区域名称
item.put("regionName", e.getCityName());
// 设备种类
item.put("deviceCategoryName", EquipmentClassifityEnum.getNameByCode(e.getEquList()));
// 监管码/使用登记证编号
item.put("code", this.buildCodeWithSplit(e.getSupervisoryCode(), e.getUseOrgCode()));
// 使用单位
item.put("useUnitName", e.getUseUnitName());
// 问题次数
item.put("issuesNumber", e.getTotal());
// 闭环率
item.put("closedLoopRate", this.calClosedLoopRate(e.getTotal(), e.getFinished()));
return item;
}).collect(Collectors.toList());
}
private String calClosedLoopRate(Long total, Long finished) {
if (total == 0) {
return "0";
}
BigDecimal totalBig = new BigDecimal(total.toString());
BigDecimal finishedBig = new BigDecimal(finished.toString());
BigDecimal result = finishedBig.divide(totalBig, 2, RoundingMode.HALF_UP);
NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(0);
return nt.format(result);
}
private String buildCodeWithSplit(String supervisoryCode, String useOrgCode) {
if (StringUtils.isNotEmpty(supervisoryCode) && StringUtils.isNotEmpty(useOrgCode)) {
return String.format("%s/%s", supervisoryCode, useOrgCode);
}
if (StringUtils.isNotEmpty(supervisoryCode)) {
return supervisoryCode;
}
if (StringUtils.isNotEmpty(useOrgCode)) {
return useOrgCode;
}
return "";
}
private void setDefaultFilter(DPFilterParamDto dpFilterParamDto) {
if (StringUtils.isEmpty(dpFilterParamDto.getBeginDate())) {
dpFilterParamDto.setBeginDate(DateUtil.lastMonth().toDateStr());
}
if (StringUtils.isEmpty(dpFilterParamDto.getEndDate())) {
dpFilterParamDto.setEndDate(DateUtil.today());
}
}
private String getAndSetOrgCode(String region) {
String orgCode = regionCodeOrgCodeMap.get(region);
if (orgCode == null) {
orgCode = statisticsMapper.getOrgCodeByCompanyCode(region);
if (orgCode != null) {
regionCodeOrgCodeMap.put(region, orgCode);
}
}
return 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