|
@@ -3,6 +3,7 @@ package com.huaxu.order.controller;
|
|
|
import com.huaxu.model.AjaxMessage;
|
|
|
import com.huaxu.model.LoginUser;
|
|
|
import com.huaxu.model.ResultStatus;
|
|
|
+import com.huaxu.order.dto.StatisticsDto;
|
|
|
import com.huaxu.order.dto.WorkOrderManageDto;
|
|
|
import com.huaxu.order.service.WorkOrderManageService;
|
|
|
import com.huaxu.util.UserUtil;
|
|
@@ -15,13 +16,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/order/workOrderStatistics/")
|
|
@@ -35,7 +34,8 @@ public class WorkOrderStatisticsController {
|
|
|
@ApiOperation(value = "工单完成情况统计")
|
|
|
public AjaxMessage<Map<String,Object>> completionStatistics(
|
|
|
@ApiParam(value="统计类型:0-按月统计,1-按年统计",required =true) @RequestParam(required = true) int type,
|
|
|
- @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy)", required = true) @RequestParam(required = true) String startDate) throws ParseException {
|
|
|
+ @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
|
+ @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
//同比日期
|
|
|
String sameStartDate = null;
|
|
|
//环比日期
|
|
@@ -102,11 +102,12 @@ public class WorkOrderStatisticsController {
|
|
|
|
|
|
return new AjaxMessage<>(ResultStatus.OK, statistics);
|
|
|
}
|
|
|
- @RequestMapping(value = "eventMonthStatistics", method = RequestMethod.GET)
|
|
|
- @ApiOperation(value = "工单完成情况统计")
|
|
|
- public AjaxMessage<List<Map<String,Object>>> eventMonthStatistics(
|
|
|
- @ApiParam(value="统计类型:0-按月统计,1-按年统计",required =true) @RequestParam(required = true) int type,
|
|
|
- @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy)", required = true) @RequestParam(required = true) String startDate) {
|
|
|
+ @RequestMapping(value = "eventStatistics", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "事件曲线数据统计展示")
|
|
|
+ public AjaxMessage<List<Map<String,Object>>> eventStatistics(
|
|
|
+ @ApiParam(value="统计类型:0-按月统计,1-按年统计,2-自定义统计",required =true) @RequestParam(required = true) int type,
|
|
|
+ @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
|
+ @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) {
|
|
|
List<Map<String,Object>> statistics = null;
|
|
|
//根据用户编号,获取用户的权限
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -117,14 +118,69 @@ public class WorkOrderStatisticsController {
|
|
|
workOrderManageDto.setUserType(loginUser.getType());
|
|
|
//1是公司,2是公司及以下,3部门,4部门及以下,5自定义
|
|
|
workOrderManageDto.setPermissonType(loginUser.getPermissonType());
|
|
|
- if(type==0){
|
|
|
- statistics =workOrderManageService.eventMonthStatistics(workOrderManageDto);
|
|
|
+ if(type == 0){
|
|
|
+ statistics = workOrderManageService.eventMonthStatistics(workOrderManageDto);
|
|
|
}
|
|
|
- else if(type ==1){
|
|
|
+ else if(type == 1){
|
|
|
statistics =workOrderManageService.eventYearStatistics(workOrderManageDto);
|
|
|
}
|
|
|
+ else if(type == 2){
|
|
|
+ workOrderManageDto.setEndDate(endDate);
|
|
|
+ statistics = workOrderManageService.eventMonthStatistics(workOrderManageDto);
|
|
|
+ }
|
|
|
return new AjaxMessage<>(ResultStatus.OK, statistics);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "distributionStatistics", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "分布统计")
|
|
|
+ public AjaxMessage<Map<String,Object>> distributionStatistics(
|
|
|
+ @ApiParam(value="统计类型:0-按月统计,1-按年统计,2-自定义统计",required =true) @RequestParam(required = true) int type,
|
|
|
+ @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy)", required = true) @RequestParam(required = true) String startDate,
|
|
|
+ @ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) {
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
+ //根据用户编号,获取用户的权限
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
|
+ workOrderManageDto.setOrderStatus(type);
|
|
|
+ workOrderManageDto.setProgramItems(loginUser.getProgramItemList());
|
|
|
+ workOrderManageDto.setUserType(loginUser.getType());
|
|
|
+ //1是公司,2是公司及以下,3部门,4部门及以下,5自定义
|
|
|
+ workOrderManageDto.setPermissonType(loginUser.getPermissonType());
|
|
|
+ if(type == 0){
|
|
|
+
|
|
|
+ workOrderManageDto.setStartDate(startDate);
|
|
|
+ }
|
|
|
+ else if(type == 1){
|
|
|
+
|
|
|
+ workOrderManageDto.setStartDate(startDate);
|
|
|
+ }
|
|
|
+ else if(type == 2){
|
|
|
+ workOrderManageDto.setStartDate(startDate);
|
|
|
+ workOrderManageDto.setEndDate(endDate);
|
|
|
+ }
|
|
|
+ result.put("上报类型",CalculatePercentage(workOrderManageService.reportStatistics(workOrderManageDto)));
|
|
|
+ result.put("工单状态",CalculatePercentage(workOrderManageService.orderStatusStatistics(workOrderManageDto)));
|
|
|
+ result.put("工单类型",CalculatePercentage(workOrderManageService.orderTypeStatistics(workOrderManageDto)));
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<StatisticsDto> CalculatePercentage(List<StatisticsDto> list){
|
|
|
+ double total= 0;
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+ for(StatisticsDto statisticsDto: list){
|
|
|
+ if(statisticsDto.getStatisticsValue()!= null) {
|
|
|
+ total += statisticsDto.getStatisticsValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(StatisticsDto statisticsDto: list){
|
|
|
+ double d = statisticsDto.getStatisticsValue()*100/total;
|
|
|
+ BigDecimal b = new BigDecimal(d);
|
|
|
+ statisticsDto.setStatisticsValue(b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 日期增加一年
|
|
|
*/
|