Commit b1aa0fa1 authored by suhuiguang's avatar suhuiguang

1.气瓶问题主题类型统计接口

parent 83d7e740
...@@ -80,7 +80,6 @@ ...@@ -80,7 +80,6 @@
a.unit_code= b.use_unit_code a.unit_code= b.use_unit_code
and a.unit_code=l.unit_code and a.unit_code=l.unit_code
and l.cert_type_code = a.open_biz_type and l.cert_type_code = a.open_biz_type
and b.supervise_org_code like CONCAT(#{orgCode}, '%')
and ((b.supervise_org_code != '50' and b.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (b.supervise_org_code = '50' and b.office_region LIKE CONCAT ('%', #{dto.cityCode}, '%'))) and ((b.supervise_org_code != '50' and b.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (b.supervise_org_code = '50' and b.office_region LIKE CONCAT ('%', #{dto.cityCode}, '%')))
ORDER BY unitName ORDER BY unitName
</select> </select>
......
...@@ -15,8 +15,7 @@ public interface AQZSDPStatisticsMapper { ...@@ -15,8 +15,7 @@ public interface AQZSDPStatisticsMapper {
String getOrgCodeByCompanyCode(@Param("cityCode") String cityCode); String getOrgCodeByCompanyCode(@Param("cityCode") String cityCode);
List<Map<String, Object>> selectByOrgAndMainBody(@Param("orgCode") String orgCode, @Param("mainBodyNameList") List<String> mainBodyNameList, List<CountDto> selectByOrgAndMainBody(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto filterParamDto);
@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("equipType") String equipType); @Param("startDate") String startDate, @Param("sourceType") String sourceType, @Param("equipType") String equipType);
......
...@@ -6,24 +6,22 @@ ...@@ -6,24 +6,22 @@
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String"> <select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{cityCode} limit 1 select org_code from privilege_company where company_code = #{cityCode} limit 1
</select> </select>
<select id="selectByOrgAndMainBody" resultType="java.util.Map"> <select id="selectByOrgAndMainBody" resultType="com.yeejoin.amos.boot.biz.common.dto.CountDto">
SELECT COUNT SELECT
( 1 ), COUNT(1) as longValue,
source_type AS sourceType source_type AS keyStr,
problem_status_code as label
FROM FROM
tzs_safety_problem_tracing tzs_safety_problem_tracing
WHERE WHERE
governing_body_org_code LIKE concat ( #{orgCode}, '%' ) governing_body_org_code LIKE concat (#{orgCode}, '%')
AND problem_time &gt;= #{startDate} <if test="dto.beginDate !=null and dto.beginDate !=''">
AND source_type IN and date_ge(CAST(problem_time as date),#{dto.beginDate})
<foreach collection="mainBodyNameList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
<if test="null != status">
AND problem_status_code = #{status}
</if> </if>
GROUP BY <if test="dto.endDate !=null and dto.endDate !=''">
source_type and date_le(CAST(problem_time as date),#{dto.endDate})
</if>
GROUP BY source_type,problem_status_code
</select> </select>
<select id="selectByOrgAndProblemType" resultType="java.util.Map"> <select id="selectByOrgAndProblemType" resultType="java.util.Map">
SELECT COUNT SELECT COUNT
......
...@@ -57,12 +57,12 @@ public class AQZSDPStatisticsController { ...@@ -57,12 +57,12 @@ public class AQZSDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "大屏-安全追溯-左屏-问题类型主体统计") @ApiOperation(value = "大屏-安全追溯-左屏-问题类型主体统计")
@PostMapping(value = "/mainBodyCount") @PostMapping(value = "/mainBodyCount")
public ResponseModel<Map<String, Object>> mainBodyCount(@RequestBody Map<String, Object> map) { public ResponseModel<Map<String, Object>> mainBodyCount(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult bindingResult) throws Exception {
Object regionCode = map.get("cityCode"); List<FieldError> fieldErrors = bindingResult.getFieldErrors();
if (ObjectUtils.isEmpty(regionCode)) { if (!fieldErrors.isEmpty()) {
regionCode = "610000"; throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
} }
Map<String, Object> result = statisticsService.mainBodyCount(regionCode.toString()); Map<String, Object> result = statisticsService.mainBodyCount(dpFilterParamDto);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
......
...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.api.enums.IssueMainBodyEnum; ...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.api.enums.IssueMainBodyEnum;
import com.yeejoin.amos.boot.module.common.api.enums.IssueProblemLevelEnum; import com.yeejoin.amos.boot.module.common.api.enums.IssueProblemLevelEnum;
import com.yeejoin.amos.boot.module.common.api.enums.IssueTypeEnum; import com.yeejoin.amos.boot.module.common.api.enums.IssueTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum; import com.yeejoin.amos.boot.module.jg.api.enums.DPMapStatisticsItemEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemStatusEnum;
import com.yeejoin.amos.boot.module.statistics.api.dto.EquipQuestionNumCountDto; import com.yeejoin.amos.boot.module.statistics.api.dto.EquipQuestionNumCountDto;
import com.yeejoin.amos.boot.module.statistics.api.dto.SecurityIndexCountItemDto; import com.yeejoin.amos.boot.module.statistics.api.dto.SecurityIndexCountItemDto;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AQZSDPStatisticsMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.AQZSDPStatisticsMapper;
...@@ -316,11 +317,40 @@ public class AQZSDPStatisticsServiceImpl { ...@@ -316,11 +317,40 @@ public class AQZSDPStatisticsServiceImpl {
countItemDto.setJianyanchaoqi("0"); countItemDto.setJianyanchaoqi("0");
} }
public Map<String, Object> mainBodyCount(String cityCode) { public Map<String, Object> mainBodyCount(DPFilterParamDto dpFilterParamDto) {
this.setDefaultFilter(dpFilterParamDto);
List<Object> problemCount = new ArrayList<>();
List<Object> problemRate = new ArrayList<>();
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> dataMap = new HashMap<>(); // 1.图列设置
String startDate = LocalDate.now().minusDays(29).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); List<IssueMainBodyEnum> mainBodyEnums = Arrays.asList(IssueMainBodyEnum.values());
List<String> mainBodyNameList = IssueMainBodyEnum.getEnumNameList(); resultMap.put("legendData", buildMainBodyLegendData());
// 2.x轴设置
resultMap.put("xdata", mainBodyEnums.stream().map(IssueMainBodyEnum::getName).collect(Collectors.toList()));
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
if(orgCode == null){
return resultMap;
}
// 3.y轴数据设置
List<CountDto> countDtos = statisticsMapper.selectByOrgAndMainBody(orgCode, dpFilterParamDto);
mainBodyEnums.forEach(e->{
Long allProblemNum = countDtos.stream().filter(c->c.getLabel().equals(e.getCode())).mapToLong(CountDto::getLongValue).sum();
long handledProblemNum = countDtos.stream().filter(c->c.getLabel().equals(e.getCode()) && c.getKeyStr().equals(SafetyProblemStatusEnum.HANDLED.getCode())).mapToLong(CountDto::getLongValue).sum();
BigDecimal all = new BigDecimal(allProblemNum.toString());
BigDecimal handled = new BigDecimal(Long.toString(handledProblemNum));
String percent = "0";
if(all.compareTo(BigDecimal.ZERO) > 0){
percent = handled.divide(all,2,RoundingMode.HALF_UP).toPlainString();
}
problemCount.add(allProblemNum);
problemRate.add(percent);
});
resultMap.put("problemCount", problemCount);
resultMap.put("problemRate", problemRate);
return resultMap;
}
private List<Object> buildMainBodyLegendData() {
List<Object> legendDataList = new ArrayList<>(); List<Object> legendDataList = new ArrayList<>();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -333,39 +363,7 @@ public class AQZSDPStatisticsServiceImpl { ...@@ -333,39 +363,7 @@ public class AQZSDPStatisticsServiceImpl {
} }
legendDataList.add(map); legendDataList.add(map);
} }
resultMap.put("legendData", legendDataList); return legendDataList;
List<String> xdata = new ArrayList<>();
List<Object> problemCount = new ArrayList<>();
List<Object> problemRate = new ArrayList<>();
String orgCode = stCommonService.getAndSetOrgCode(cityCode);
if(orgCode != null){
List<Map<String, Object>> list = statisticsMapper.selectByOrgAndMainBody(orgCode, mainBodyNameList, startDate, null);
list.forEach(t -> {
dataMap.put(t.get("sourceType").toString(), t.get("count").toString());
});
}
for (int i = 0; i < mainBodyNameList.size(); i++) {
if (null != dataMap.get(mainBodyNameList.get(i))) {
problemCount.add(dataMap.get(mainBodyNameList.get(i)));
List<String> list1 = new ArrayList<>();
list1.add(mainBodyNameList.get(i));
List<Map<String, Object>> maps = statisticsMapper.selectByOrgAndMainBody(orgCode, list1, startDate, "1");
if (maps.size() > 0) {
problemRate.add(new DecimalFormat("0.00").format(Double.parseDouble(maps.get(0).get("count").toString()) / Double.parseDouble(dataMap.get(mainBodyNameList.get(i)).toString())));
} else {
problemRate.add("0");
}
} else {
problemCount.add("0");
problemRate.add("0");
}
xdata.add(mainBodyNameList.get(i));
}
resultMap.put("xdata", xdata);
resultMap.put("problemCount", problemCount);
resultMap.put("problemRate", problemRate);
return resultMap;
} }
......
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