Commit ece62426 authored by suhuiguang's avatar suhuiguang

1.检验检测大屏接口接口开发

parent e7299805
......@@ -65,4 +65,12 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti
* @return 统计信息
*/
List<CountDto> queryAllPendingResultInspectApp(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
/**
* 按照8大类,查询指定区域下的报检数量、待检数量
* @param orgCode 指定区域对应的公司
* @param dpFilterParamDto 时间过滤条件
* @return List<CountDto>
*/
List<CountDto> queryAppByEquListForDP(@Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamDto);
}
......@@ -242,6 +242,37 @@
a.inspection_unit_code= b.use_unit_code
and b.supervise_org_code like CONCAT(#{orgCode}, '%') and a.status = '6616'
and EXISTS (select 1 from tz_jyjc_inspection_result r where r.result_status='1' and a.application_no = r.application_no)
and date_ge(CAST(a.application_date as date),#{dto.beginDate}) and date_le(CAST(a.application_date as date),#{dto.endDate})
and date_ge(CAST(a.accept_date as date),#{dto.beginDate}) and date_le(CAST(a.accept_date as date),#{dto.endDate})
group by a.inspection_type
</select>
<select id="queryAppByEquListForDP" resultType="com.yeejoin.amos.boot.biz.common.dto.CountDto">
-- 8大类 待检数量
SELECT
count(1) as longValue,
a.equip_classify as keyStr,
'pending' as label
FROM
tz_jyjc_inspection_application a,
tz_base_enterprise_info b
where
a.inspection_unit_code= b.use_unit_code
and b.supervise_org_code like CONCAT(#{orgCode}, '%') and a.status = '6616'
and EXISTS (select 1 from tz_jyjc_inspection_result r where r.result_status='1' and a.application_no = r.application_no)
and date_ge(CAST(a.accept_date as date),#{dto.beginDate}) and date_le(CAST(a.accept_date as date),#{dto.endDate})
GROUP BY a.equip_classify
-- 8大类 报检数量统计
union all
SELECT
count(1) as longValue,
a.equip_classify as keyStr,
'reporting' as label
FROM
tz_jyjc_inspection_application a,
tz_base_enterprise_info b
where
a.inspection_unit_code= b.use_unit_code
and b.supervise_org_code like CONCAT(#{orgCode}, '%') and a.status != '6610' and a.status != '6615'
and date_ge(CAST(a.application_date as date),#{dto.beginDate}) and date_le(CAST(a.application_date as date),#{dto.endDate})
GROUP BY a.equip_classify
</select>
</mapper>
......@@ -114,4 +114,14 @@ public class DPStatisticsController {
return ResponseHelper.buildResponse(statisticsService.queryInspectionOrgListForPublicity(dpFilterParamDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-检验检测-八大类设备报检/待检数量统计", notes = "大屏-检验检测-八大类设备报检/待检数量统计")
@PostMapping(value = "/jy/inspectionEquip/countByEquList")
public ResponseModel<Map<String, Object>> inspectionEquipCountByEquList(@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.queryInspectionEquipByEquList(dpFilterParamDto));
}
}
......@@ -283,4 +283,46 @@ public class DPStatisticsServiceImpl {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
return openingApplicationMapper.queryInspectionOrgListForPublicity(orgCode);
}
public Map<String, Object> queryInspectionEquipByEquList(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
// 1.查询条件构造未上送时间时,默认查询数据为近一个月数据
this.setDefaultFilter(dpFilterParamDto);
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 2.x轴数据构建
List<EquipmentCategoryDto> equipmentCategoryDtos = equipmentCategoryMapper.selectClassify();
this.setXDataForInspectionEquipByEquList(result, equipmentCategoryDtos);
// 3.y轴数据设置
// 目前都单设备报检故统计主表即可
List<CountDto> countDtos = inspectionApplicationMapper.queryAppByEquListForDP(orgCode, dpFilterParamDto);
Map<String, List<CountDto>> groupByMap = countDtos.stream().collect(Collectors.groupingBy(CountDto::getLabel));
this.setYDataForInspectionEquipByEquList(result, groupByMap, equipmentCategoryDtos);
// 4.图列数据设置
this.setLegendDataForInspectionEquipByEquList(result);
return result;
}
private void setYDataForInspectionEquipByEquList(Map<String, Object> result, Map<String, List<CountDto>> groupByMap, List<EquipmentCategoryDto> equipmentCategoryDtos) {
groupByMap.forEach((key, value) -> result.put(key, this.setInspectionEquipData(value, equipmentCategoryDtos)));
}
private List<Long> setInspectionEquipData(List<CountDto> countDtos, List<EquipmentCategoryDto> equipmentCategoryDtos) {
return equipmentCategoryDtos.stream().map(e -> countDtos.stream().filter(c -> c.getKeyStr().equals(e.getCode())).mapToLong(CountDto::getLongValue).sum()).collect(Collectors.toList());
}
private void setLegendDataForInspectionEquipByEquList(Map<String, Object> result) {
Map<String, Object> item1 = new LinkedHashMap<>();
item1.put("dataKey", "pending");
item1.put("value", "待检数量");
Map<String, Object> item2 = new LinkedHashMap<>();
item2.put("dataKey", "reporting");
item2.put("value", "报检数量");
result.put("legendData", Arrays.asList(item1, item2));
}
private void setXDataForInspectionEquipByEquList(Map<String, Object> result, List<EquipmentCategoryDto> equipmentCategoryDtos) {
// 8大类
List<String> names = equipmentCategoryDtos.stream().map(EquipmentCategoryDto::getName).collect(Collectors.toList());
result.put("xdata", names);
}
}
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