Commit 36957ed5 authored by suhuiguang's avatar suhuiguang

1.统计服务合并api整理

parent 010add58
......@@ -13,6 +13,4 @@ public interface IAlertStatisticsService {
void statisticalGeneration(String type);
List<AlertStatistics> getList(String date) throws ParseException;
JSONArray statisticInfoByRegionAndDate(DPFilterParamDto queryParams);
}
......@@ -350,14 +350,4 @@ public class StatisticsController extends BaseController {
ExcelUtil.createTemplate(response, "困人救援超时情况统计", "困人救援超时情况统计", exportVos, AlertDispatchStatisticsExportVo.class, null, false);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/region/info")
@ApiOperation(httpMethod = "POST", value = "查询区域统计信息", notes = "查询区域统计信息")
public ResponseModel<JSONArray> statisticsRegionInfo(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
}
return ResponseHelper.buildResponse(alertStatisticsService.statisticInfoByRegionAndDate(dpFilterParamDto));
}
}
......@@ -73,7 +73,6 @@ public class TzsAuthController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "获取用户regionCode", notes = "获取用户regionCode")
public ResponseModel<List<String>> getUserRegincode() {
List<String> regionList = tzsAuthService.getUserRegionCode();
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
return ResponseHelper.buildResponse(regionList);
}
......
......@@ -168,100 +168,4 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
return alertStatistics;
}
@Override
public JSONArray statisticInfoByRegionAndDate(DPFilterParamDto params) {
LocalDate today = LocalDate.now();
LocalDate startDate;
LocalDate endDate;
String regionCode = params.getCityCode();
if (ObjectUtils.isEmpty(params.getBeginDate()) || ObjectUtils.isEmpty(params.getBeginDate())) {
startDate = today.minusDays(6);
endDate = today;
} else {
startDate = LocalDate.parse(params.getBeginDate());
endDate = LocalDate.parse(params.getEndDate());
}
params.setBeginDate(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
params.setEndDate(endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
AlertStatistics statistics = this.baseMapper.statisticsInfoByRegionAndDate(regionCode, startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
JSONArray jsonArray = new JSONArray();
if (!ObjectUtils.isEmpty(statistics)) {
JSONObject jsonObject0 = new JSONObject();
jsonObject0.put("key", "dtkr");
jsonObject0.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople());
jsonObject0.put("name", "电梯困人");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("key", "slts");
jsonObject1.put("value", ValidationUtil.isEmpty(statistics.getComplaint()) ? 0 : statistics.getComplaint());
jsonObject1.put("name", "受理投诉");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("key", "gzbx");
jsonObject2.put("value", ValidationUtil.isEmpty(statistics.getBreakdownRescue()) ? 0 : statistics.getBreakdownRescue());
jsonObject2.put("name", "故障维修");
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("key", "jjbkck");
jsonObject3.put("value", ValidationUtil.isEmpty(statistics.getRescuePersonnel()) ? 0 : statistics.getRescuePersonnel());
jsonObject3.put("name", "解救被困乘客");
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("key", "30fzdd");
jsonObject4.put("value", ValidationUtil.isEmpty(statistics.getWithinThirtyRescue()) ? 0 : statistics.getWithinThirtyRescue());
jsonObject4.put("name", "30分钟内到达");
JSONObject jsonObject5 = new JSONObject();
jsonObject5.put("key", "pjjysj");
jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime());
jsonObject5.put("name", "平均救援时间");
String orgCode = this.getAndSetOrgCode(regionCode);
JSONObject jsonObject6 = new JSONObject();
jsonObject6.put("key", "jycq");
jsonObject6.put("value", this.getQuestionNumber("检验超期",params, orgCode));
jsonObject6.put("name", "检验超期");
JSONObject jsonObject7 = new JSONObject();
jsonObject7.put("key", "jybhg");
jsonObject7.put("value", this.getQuestionNumber("检验不合格",params, orgCode));
jsonObject7.put("name", "检验不合格");
JSONObject jsonObject8 = new JSONObject();
jsonObject8.put("key", "wbcq");
jsonObject8.put("value", this.getQuestionNumber("维保超期",params, orgCode));
jsonObject8.put("name", "维保超期");
JSONObject jsonObject9 = new JSONObject();
jsonObject9.put("key", "csjsynx");
jsonObject9.put("value", this.getQuestionNumber("超设计使用年限",params, orgCode));
jsonObject9.put("name", "超设计使用年限");
jsonArray.add(jsonObject0);
jsonArray.add(jsonObject1);
jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4);
jsonArray.add(jsonObject5);
jsonArray.add(jsonObject6);
jsonArray.add(jsonObject7);
jsonArray.add(jsonObject8);
jsonArray.add(jsonObject9);
}
return jsonArray;
}
private Long getQuestionNumber(String problemType, DPFilterParamDto params, String orgCode) {
return this.getBaseMapper().countProblemByTypeDateAndOrgCode(problemType, params, orgCode);
}
private String getAndSetOrgCode(String region) {
String orgCode = regionCodeOrgCodeMap.get(region);
if (orgCode == null) {
orgCode = this.getBaseMapper().getOrgCodeByCompanyCode(region);
if (orgCode != null) {
regionCodeOrgCodeMap.put(region, orgCode);
}
}
return orgCode;
}
}
\ No newline at end of file
......@@ -228,7 +228,7 @@ public class JGDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏监管-中屏-各地市数据统计", notes = "大屏监管-中屏-各地市数据统计")
@PostMapping(value = "/jg/centre/dataStatistic")
@PostMapping(value = "/centre/dataStatistic")
public ResponseModel<List<Map<String, Object>>> dataStatisticByReginCode(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
......@@ -239,7 +239,7 @@ public class JGDPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏监管-中屏-当前区域数据统计", notes = "大屏监管-中屏-当前区域数据统计")
@PostMapping(value = "/jg/centre/dataStatisticCount")
@PostMapping(value = "/centre/dataStatisticCount")
public ResponseModel<Map<String, Object>> dataStatisticCountByReginCode(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
......
package com.yeejoin.amos.boot.module.statistcs.biz.controller;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.StCommonServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
@RestController
@Api(tags = "统计公共API")
@RequestMapping(value = "/st-common")
public class StCommonController {
StCommonServiceImpl commonService;
/**
* 获取用户regionCode
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getUserRegincode")
@ApiOperation(httpMethod = "GET", value = "获取用户regionCode", notes = "获取用户regionCode")
public ResponseModel<List<String>> getUserRegincode() {
List<String> regionList = commonService.getUserRegionCode();
return ResponseHelper.buildResponse(regionList);
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.controller;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.statistcs.biz.service.impl.ZLDPStatisticsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
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.ResponseModel;
......@@ -69,4 +74,15 @@ public class ZLDPStatisticsController {
public ResponseModel<List<Map<String, Object>>> equipmentInformCount(@RequestBody DPFilterParamDto screenDto) {
return ResponseHelper.buildResponse(statisticsService.equipmentInformCount(screenDto));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/region/info")
@ApiOperation(httpMethod = "POST", value = "查询区域统计信息", notes = "查询区域统计信息")
public ResponseModel<JSONArray> statisticsRegionInfo(@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.statisticInfoByRegionAndDate(dpFilterParamDto));
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author Administrator
*/
@Service
public class StCommonServiceImpl {
public List<String> getUserRegionCode() {
List<String> regionList = new ArrayList<>();
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
CompanyModel userCompany = me.getCompanys().get(0);
String regions = userCompany.getRegionSeq();
if(regions != null) {
String[] regionsId = regions.split(",");
for(String regionId:regionsId) {
RegionModel region = Systemctl.regionClient.getRegion(Long.valueOf(regionId)).getResult();
regionList.add(region.getRegionCode() + "");
}
}
return regionList;
}
}
package com.yeejoin.amos.boot.module.statistcs.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.common.api.entity.AlertStatistics;
import com.yeejoin.amos.boot.module.statistics.api.mapper.AlertStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
......@@ -15,11 +18,13 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
......@@ -27,16 +32,25 @@ import java.util.stream.Collectors;
@Service
public class ZLDPStatisticsServiceImpl {
@Resource
private ZLStatisticsMapper screenMapper;
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
@Autowired
RestHighLevelClient restHighLevelClient;
private DataDictionaryServiceImpl iDataDictionaryService;
private AlertStatisticsMapper alertStatisticsMapper;
private RestHighLevelClient restHighLevelClient;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
public ZLDPStatisticsServiceImpl(ZLStatisticsMapper screenMapper, DataDictionaryServiceImpl iDataDictionaryService, AlertStatisticsMapper alertStatisticsMapper, RestHighLevelClient restHighLevelClient) {
this.screenMapper = screenMapper;
this.iDataDictionaryService = iDataDictionaryService;
this.alertStatisticsMapper = alertStatisticsMapper;
this.restHighLevelClient = restHighLevelClient;
}
public List<Map<String, Object>> companyInfo(DPFilterParamDto screenDto) {
......@@ -450,4 +464,89 @@ public class ZLDPStatisticsServiceImpl {
}
return orgCode;
}
public JSONArray statisticInfoByRegionAndDate(DPFilterParamDto params) {
LocalDate today = LocalDate.now();
LocalDate startDate;
LocalDate endDate;
String regionCode = params.getCityCode();
if (ObjectUtils.isEmpty(params.getBeginDate()) || ObjectUtils.isEmpty(params.getBeginDate())) {
startDate = today.minusDays(6);
endDate = today;
} else {
startDate = LocalDate.parse(params.getBeginDate());
endDate = LocalDate.parse(params.getEndDate());
}
params.setBeginDate(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
params.setEndDate(endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
AlertStatistics statistics = alertStatisticsMapper.statisticsInfoByRegionAndDate(regionCode, startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
JSONArray jsonArray = new JSONArray();
if (!ObjectUtils.isEmpty(statistics)) {
JSONObject jsonObject0 = new JSONObject();
jsonObject0.put("key", "dtkr");
jsonObject0.put("value", ValidationUtil.isEmpty(statistics.getTrappedPeople()) ? 0 : statistics.getTrappedPeople());
jsonObject0.put("name", "电梯困人");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("key", "slts");
jsonObject1.put("value", ValidationUtil.isEmpty(statistics.getComplaint()) ? 0 : statistics.getComplaint());
jsonObject1.put("name", "受理投诉");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("key", "gzbx");
jsonObject2.put("value", ValidationUtil.isEmpty(statistics.getBreakdownRescue()) ? 0 : statistics.getBreakdownRescue());
jsonObject2.put("name", "故障维修");
JSONObject jsonObject3 = new JSONObject();
jsonObject3.put("key", "jjbkck");
jsonObject3.put("value", ValidationUtil.isEmpty(statistics.getRescuePersonnel()) ? 0 : statistics.getRescuePersonnel());
jsonObject3.put("name", "解救被困乘客");
JSONObject jsonObject4 = new JSONObject();
jsonObject4.put("key", "30fzdd");
jsonObject4.put("value", ValidationUtil.isEmpty(statistics.getWithinThirtyRescue()) ? 0 : statistics.getWithinThirtyRescue());
jsonObject4.put("name", "30分钟内到达");
JSONObject jsonObject5 = new JSONObject();
jsonObject5.put("key", "pjjysj");
jsonObject5.put("value", ValidationUtil.isEmpty(statistics.getAvgTime()) ? 0 : statistics.getAvgTime());
jsonObject5.put("name", "平均救援时间");
String orgCode = this.getAndSetOrgCode(regionCode);
JSONObject jsonObject6 = new JSONObject();
jsonObject6.put("key", "jycq");
jsonObject6.put("value", this.getQuestionNumber("检验超期",params, orgCode));
jsonObject6.put("name", "检验超期");
JSONObject jsonObject7 = new JSONObject();
jsonObject7.put("key", "jybhg");
jsonObject7.put("value", this.getQuestionNumber("检验不合格",params, orgCode));
jsonObject7.put("name", "检验不合格");
JSONObject jsonObject8 = new JSONObject();
jsonObject8.put("key", "wbcq");
jsonObject8.put("value", this.getQuestionNumber("维保超期",params, orgCode));
jsonObject8.put("name", "维保超期");
JSONObject jsonObject9 = new JSONObject();
jsonObject9.put("key", "csjsynx");
jsonObject9.put("value", this.getQuestionNumber("超设计使用年限",params, orgCode));
jsonObject9.put("name", "超设计使用年限");
jsonArray.add(jsonObject0);
jsonArray.add(jsonObject1);
jsonArray.add(jsonObject2);
jsonArray.add(jsonObject3);
jsonArray.add(jsonObject4);
jsonArray.add(jsonObject5);
jsonArray.add(jsonObject6);
jsonArray.add(jsonObject7);
jsonArray.add(jsonObject8);
jsonArray.add(jsonObject9);
}
return jsonArray;
}
private Long getQuestionNumber(String problemType, DPFilterParamDto params, String orgCode) {
return alertStatisticsMapper.countProblemByTypeDateAndOrgCode(problemType, params, 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