|
@@ -15,9 +15,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
|
|
+import java.util.Date;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -29,15 +31,23 @@ public class WorkOrderStatisticsController {
|
|
WorkOrderManageService workOrderManageService;
|
|
WorkOrderManageService workOrderManageService;
|
|
|
|
|
|
@RequestMapping(value = "completionStatistics", method = RequestMethod.GET)
|
|
@RequestMapping(value = "completionStatistics", method = RequestMethod.GET)
|
|
- @ApiOperation(value = "工单完成情况统计()")
|
|
|
|
|
|
+ @ApiOperation(value = "工单完成情况统计")
|
|
public AjaxMessage<Map<String,Object>> completionStatistics(
|
|
public AjaxMessage<Map<String,Object>> completionStatistics(
|
|
@ApiParam(value="统计类型:0-按月统计,1-按年统计",required =true) @RequestParam(required = true) int type,
|
|
@ApiParam(value="统计类型:0-按月统计,1-按年统计",required =true) @RequestParam(required = true) int type,
|
|
- @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy)", required = true) @RequestParam(required = true) String startDate) {
|
|
|
|
|
|
+ @ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy)", required = true) @RequestParam(required = true) String startDate) throws ParseException {
|
|
|
|
+ //同比日期
|
|
|
|
+ String sameStartDate = null;
|
|
|
|
+ //环比日期
|
|
|
|
+ String chainStartDate =null;
|
|
if(type==0){
|
|
if(type==0){
|
|
startDate = String.format("%s-01",startDate);
|
|
startDate = String.format("%s-01",startDate);
|
|
|
|
+ sameStartDate = subYear(startDate,-1);
|
|
|
|
+ chainStartDate = subMonth(startDate,-1);
|
|
}
|
|
}
|
|
else if(type==1){
|
|
else if(type==1){
|
|
startDate = String.format("%s-01-01",startDate);
|
|
startDate = String.format("%s-01-01",startDate);
|
|
|
|
+ sameStartDate = subYear(startDate, -1);
|
|
|
|
+ chainStartDate = subYear(startDate,-1);
|
|
}
|
|
}
|
|
//根据用户编号,获取用户的权限
|
|
//根据用户编号,获取用户的权限
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -48,8 +58,77 @@ public class WorkOrderStatisticsController {
|
|
workOrderManageDto.setUserType(loginUser.getType());
|
|
workOrderManageDto.setUserType(loginUser.getType());
|
|
//1是公司,2是公司及以下,3部门,4部门及以下,5自定义
|
|
//1是公司,2是公司及以下,3部门,4部门及以下,5自定义
|
|
workOrderManageDto.setPermissonType(loginUser.getPermissonType());
|
|
workOrderManageDto.setPermissonType(loginUser.getPermissonType());
|
|
- Map<String,Object> result=workOrderManageService.workOrderStatistics(workOrderManageDto);
|
|
|
|
- return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
|
|
|
+ Map<String,Object> statistics=workOrderManageService.workOrderStatistics(workOrderManageDto);
|
|
|
|
+ workOrderManageDto.setStartDate(sameStartDate);
|
|
|
|
+ //同比
|
|
|
|
+ Map<String,Object> sameStatistic = workOrderManageService.workOrderStatistics(workOrderManageDto);
|
|
|
|
+ //环比
|
|
|
|
+ workOrderManageDto.setStartDate(chainStartDate);
|
|
|
|
+ Map<String,Object> chainStatistic = workOrderManageService.workOrderStatistics(workOrderManageDto);
|
|
|
|
+
|
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
|
+
|
|
|
|
+ if(statistics.get("工单完成率") == null || statistics.get("工单完成率").toString().equals("0")){
|
|
|
|
+ statistics.put("工单完成率同比",0);
|
|
|
|
+ statistics.put("工单完成率环比",0);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Double finishedSameRate = (Double.parseDouble(statistics.get("工单完成率").toString())-Double.parseDouble(sameStatistic.get("工单完成率").toString()))*100/Double.parseDouble(statistics.get("工单完成率").toString());
|
|
|
|
+ statistics.put("工单完成率同比",df.format(finishedSameRate));
|
|
|
|
+ Double finishedChainRate = (Double.parseDouble(statistics.get("工单完成率").toString())-Double.parseDouble(chainStatistic.get("工单完成率").toString()))*100/Double.parseDouble(statistics.get("工单完成率").toString());
|
|
|
|
+ statistics.put("工单完成率环比",df.format(finishedChainRate));
|
|
|
|
+ }
|
|
|
|
+ if(statistics.get("工单总数") == null || statistics.get("工单总数").toString().equals("0")){
|
|
|
|
+ statistics.put("工单总数同比",0);
|
|
|
|
+ statistics.put("工单总数环比",0);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Double orderSameTotalNumberRate = (Double.parseDouble(statistics.get("工单总数").toString())-Double.parseDouble(sameStatistic.get("工单总数").toString()))*100/Double.parseDouble(statistics.get("工单总数").toString());
|
|
|
|
+ statistics.put("工单总数同比",df.format(orderSameTotalNumberRate));
|
|
|
|
+ Double orderChainTotalNumberRate = (Double.parseDouble(statistics.get("工单总数").toString())-Double.parseDouble(chainStatistic.get("工单总数").toString()))*100/Double.parseDouble(statistics.get("工单总数").toString());
|
|
|
|
+ statistics.put("工单总数环比",df.format(orderChainTotalNumberRate));
|
|
|
|
+ }
|
|
|
|
+ if(statistics.get("工单完成数") == null || statistics.get("工单完成数").toString().equals("0")){
|
|
|
|
+ statistics.put("工单完成数同比",0);
|
|
|
|
+ statistics.put("工单完成数环比",0);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ Double finishedSameNumber = (Double.parseDouble(statistics.get("工单完成数").toString())-Double.parseDouble(sameStatistic.get("工单完成数").toString()))*100/Double.parseDouble(statistics.get("工单完成数").toString());
|
|
|
|
+ statistics.put("工单完成数同比",df.format(finishedSameNumber));
|
|
|
|
+ Double finishedChainNumber = (Double.parseDouble(statistics.get("工单完成数").toString())-Double.parseDouble(chainStatistic.get("工单完成数").toString()))*100/Double.parseDouble(statistics.get("工单完成数").toString());
|
|
|
|
+ statistics.put("工单完成数环比",df.format(finishedChainNumber));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, statistics);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 日期增加一年
|
|
|
|
+ */
|
|
|
|
+ private String subYear(String date,int n) throws ParseException {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date dt = sdf.parse(date);
|
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
|
+ rightNow.setTime(dt);
|
|
|
|
+ rightNow.add(Calendar.YEAR, n);
|
|
|
|
+ Date dt1 = rightNow.getTime();
|
|
|
|
+ String reStr = sdf.format(dt1);
|
|
|
|
+ return reStr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *日期增加一月
|
|
|
|
+ */
|
|
|
|
+ private String subMonth(String date,int n) throws ParseException {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date dt = sdf.parse(date);
|
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
|
+ rightNow.setTime(dt);
|
|
|
|
+ rightNow.add(Calendar.MONTH, n);
|
|
|
|
+ Date dt1 = rightNow.getTime();
|
|
|
|
+ String reStr = sdf.format(dt1);
|
|
|
|
+ return reStr;
|
|
|
|
+ }
|
|
}
|
|
}
|