|
@@ -47,22 +47,30 @@ public class AnnualInspectionDataService {
|
|
|
* @date 2020/2/5 4:05 下午
|
|
|
*/
|
|
|
public RestResponse annualOverView(AnnualInspectionDataRequest annualInspectionDataRequest) {
|
|
|
+ Map<Integer, Map<Integer, Long>> monthTomAnnual = DataStatisticsUtil.initNum();
|
|
|
+ DataStatisticsUtil.initCommonRequest(annualInspectionDataRequest);
|
|
|
List<AnnualInspectionDataModel> annualInspectionDataModelList = getAnnualInspectionDataListFromRedis(
|
|
|
annualInspectionDataRequest);
|
|
|
- Map<Integer, Long> annualStatusToNum = DataStatisticsConstants.ANNUAL_STATUS_TO_NUM;
|
|
|
if (annualInspectionDataModelList != null && annualInspectionDataModelList.size() > 0) {
|
|
|
- //设置计划年检条数
|
|
|
- annualStatusToNum.put(1, (long) annualInspectionDataModelList.size());
|
|
|
- //设置完成年检条数
|
|
|
- long finishAnnualCount = annualInspectionDataModelList.stream()
|
|
|
- .filter(a -> a.getStatus() == 1).count();
|
|
|
- annualStatusToNum.put(2, finishAnnualCount);
|
|
|
- //设置超期未检条数
|
|
|
- long beyondAnnualCount = annualInspectionDataModelList.stream()
|
|
|
- .filter(a -> a.getStatus() == 2).count();
|
|
|
- annualStatusToNum.put(3, beyondAnnualCount);
|
|
|
+ monthTomAnnual.keySet().forEach(month -> {
|
|
|
+ Map<Integer, Long> annualStatusToNum = monthTomAnnual.get(month);
|
|
|
+ //计划年检设置
|
|
|
+ annualStatusToNum.put(0, (long) annualInspectionDataModelList.size());
|
|
|
+ //完成年检设置
|
|
|
+ List<AnnualInspectionDataModel> finishAnnualNum = annualInspectionDataModelList.stream()
|
|
|
+ .filter(annualInspectionDataModel -> {
|
|
|
+ if (annualInspectionDataModel.getStatus() != null) {
|
|
|
+ return annualInspectionDataModel.getStatus() == 1;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if (finishAnnualNum.size() > 0) {
|
|
|
+ annualStatusToNum.put(1, (long) finishAnnualNum.size());
|
|
|
+ }
|
|
|
+ monthTomAnnual.put(month, annualStatusToNum);
|
|
|
+ });
|
|
|
}
|
|
|
- return RestResponse.success(ProjectUtils.transReturnMapToStatisticsKVModel(annualStatusToNum),
|
|
|
+ return RestResponse.success(ProjectUtils.transReturnMapToStatisticsKVModel(monthTomAnnual),
|
|
|
ApiConstants.RESULT_SUCCESS, "获取统计数据成功");
|
|
|
}
|
|
|
|
|
@@ -73,56 +81,31 @@ public class AnnualInspectionDataService {
|
|
|
* @date 2020/2/5 4:11 下午
|
|
|
*/
|
|
|
public RestResponse annualProgress(AnnualInspectionDataRequest annualInspectionDataRequest) {
|
|
|
- List<AnnualInspectionDataModel> annualInspectionDataModelList = getProjectAnnualProgress(
|
|
|
- annualInspectionDataRequest, "top5");
|
|
|
- return RestResponse.success(annualInspectionDataModelList, ApiConstants.RESULT_SUCCESS, "获取统计数据成功");
|
|
|
+ DataStatisticsUtil.initCommonRequest(annualInspectionDataRequest);
|
|
|
+ List<AnnualInspectionDataModel> projectAnnualList = annualInspectionDataMapper.getProjectAnnual(annualInspectionDataRequest);
|
|
|
+ List<AnnualInspectionDataModel> projectLiftNum = annualInspectionDataMapper.projectLiftNum(annualInspectionDataRequest);
|
|
|
+ Map<Long, Long> projectIdToLiftNum = projectLiftNum.stream().collect(Collectors.groupingBy(
|
|
|
+ AnnualInspectionDataModel::getProjectId, Collectors.counting()));
|
|
|
+ //封装台量
|
|
|
+ projectAnnualList.forEach(annualInspectionDataModel -> {
|
|
|
+ if (projectIdToLiftNum != null && projectIdToLiftNum.size() > 0) {
|
|
|
+ annualInspectionDataModel.setUnitNum(DataStatisticsUtil.getLongValue(
|
|
|
+ projectIdToLiftNum.get(annualInspectionDataModel.getProjectId())));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return RestResponse.success(projectAnnualList, ApiConstants.RESULT_SUCCESS, "获取统计数据成功");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param
|
|
|
+ * @param annualInspectionDataRequest 年检数据
|
|
|
* @return
|
|
|
- * @description 获取所有项目的年检进度
|
|
|
- * @date 2020/2/5 4:14 下午
|
|
|
+ * @description
|
|
|
+ * @date 2020/5/23 10:02 上午
|
|
|
*/
|
|
|
- public RestResponse allProjectAnnualProgress(AnnualInspectionDataRequest annualInspectionDataRequest) {
|
|
|
- List<AnnualInspectionDataModel> annualInspectionDataModelList = getProjectAnnualProgress(
|
|
|
- annualInspectionDataRequest, "all");
|
|
|
- return RestResponse.success(annualInspectionDataModelList, ApiConstants.RESULT_SUCCESS, "获取统计数据成功");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param
|
|
|
- * @return
|
|
|
- * @description 获取项目的年检进度
|
|
|
- * @date 2020/2/5 4:16 下午
|
|
|
- */
|
|
|
- private List<AnnualInspectionDataModel> getProjectAnnualProgress(
|
|
|
- AnnualInspectionDataRequest annualInspectionDataRequest, String countFlag) {
|
|
|
- //从redis中获取当前公司年检数据
|
|
|
- List<AnnualInspectionDataModel> annualInspectionDataModelList = getAnnualInspectionDataListFromRedis(
|
|
|
- annualInspectionDataRequest);
|
|
|
- if (annualInspectionDataModelList != null && annualInspectionDataModelList.size() > 0) {
|
|
|
- //获取全部项目的年检进度
|
|
|
- if ("all".equals(countFlag)) {
|
|
|
- if (StringUtils.isNotBlank(annualInspectionDataRequest.getProjectName())) {
|
|
|
- //通过项目名称模糊查询
|
|
|
- annualInspectionDataModelList = annualInspectionDataModelList.stream()
|
|
|
- //通过名称模糊匹配
|
|
|
- .filter(a -> DataStatisticsUtil.strMatch(
|
|
|
- annualInspectionDataRequest.getProjectName(), a.getProjectName()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
- //获取所有项目的年检进度,按照计划年检时间顺序排列
|
|
|
- annualInspectionDataModelList = annualInspectionDataModelList.stream()
|
|
|
- .sorted(Comparator.comparing(AnnualInspectionDataModel::getPlanDate))
|
|
|
- .collect(Collectors.toList());
|
|
|
- } else {
|
|
|
- //获取计划年检时间前五的项目的年检进度,按照计划年检时间顺序排列
|
|
|
- annualInspectionDataModelList = annualInspectionDataModelList.stream()
|
|
|
- .sorted(Comparator.comparing(AnnualInspectionDataModel::getPlanDate)).limit(5)
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
- }
|
|
|
- return annualInspectionDataModelList;
|
|
|
+ public RestResponse liftAnnualInfo(AnnualInspectionDataRequest annualInspectionDataRequest) {
|
|
|
+ DataStatisticsUtil.initCommonRequest(annualInspectionDataRequest);
|
|
|
+ List<AnnualInspectionDataModel> liftAnnualList = annualInspectionDataMapper
|
|
|
+ .getProjectLiftAnnualInfo(annualInspectionDataRequest);
|
|
|
+ return RestResponse.success(liftAnnualList);
|
|
|
}
|
|
|
}
|