|
@@ -24,6 +24,7 @@ import java.math.BigDecimal;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
+import java.time.LocalDate;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -49,6 +50,7 @@ public class WorkOrderStatisticsController {
|
|
@ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
|
|
@ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
//同比日期
|
|
//同比日期
|
|
String sameStartDate = null, sameEndDate = null;
|
|
String sameStartDate = null, sameEndDate = null;
|
|
//环比日期
|
|
//环比日期
|
|
@@ -74,7 +76,12 @@ public class WorkOrderStatisticsController {
|
|
} else if (statsType == 2) {
|
|
} else if (statsType == 2) {
|
|
startDate = String.format("%s-01", startDate);
|
|
startDate = String.format("%s-01", startDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
- endDate = subMonth(endDate,1);
|
|
|
|
|
|
+ if(isCurrentMonth(endDate)==true){
|
|
|
|
+ endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ endDate = subMonth(endDate, 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//根据用户编号,获取用户的权限
|
|
//根据用户编号,获取用户的权限
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -168,6 +175,7 @@ public class WorkOrderStatisticsController {
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
int maintainerCount = 0;
|
|
int maintainerCount = 0;
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
Map<String,Object> result = new HashMap<>();
|
|
Map<String,Object> result = new HashMap<>();
|
|
List<Map<String, Object>> statistics = new ArrayList<>(), average =new ArrayList<>();
|
|
List<Map<String, Object>> statistics = new ArrayList<>(), average =new ArrayList<>();
|
|
//根据用户编号,获取用户的权限
|
|
//根据用户编号,获取用户的权限
|
|
@@ -193,7 +201,12 @@ public class WorkOrderStatisticsController {
|
|
maintainerCount = userCenterClient.findMaintainerCount(endDate);
|
|
maintainerCount = userCenterClient.findMaintainerCount(endDate);
|
|
startDate = String.format("%s-01", startDate);
|
|
startDate = String.format("%s-01", startDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
- endDate = subMonth(endDate,1);
|
|
|
|
|
|
+ if(isCurrentMonth(endDate)==true){
|
|
|
|
+ endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ endDate = subMonth(endDate, 1);
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
workOrderManageDto.setStartDate(startDate);
|
|
workOrderManageDto.setStartDate(startDate);
|
|
@@ -230,6 +243,7 @@ public class WorkOrderStatisticsController {
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
//根据用户编号,获取用户的权限
|
|
//根据用户编号,获取用户的权限
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
workOrderManageDto.setTenantId(loginUser.getTenantId());
|
|
workOrderManageDto.setTenantId(loginUser.getTenantId());
|
|
@@ -249,7 +263,12 @@ public class WorkOrderStatisticsController {
|
|
case 2:
|
|
case 2:
|
|
startDate = String.format("%s-01", startDate);
|
|
startDate = String.format("%s-01", startDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
- endDate = subMonth(endDate,1);
|
|
|
|
|
|
+ if(isCurrentMonth(endDate)==true){
|
|
|
|
+ endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ endDate = subMonth(endDate, 1);
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
workOrderManageDto.setStartDate(startDate);
|
|
workOrderManageDto.setStartDate(startDate);
|
|
@@ -267,10 +286,8 @@ public class WorkOrderStatisticsController {
|
|
@ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
|
|
@ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
-
|
|
|
|
- List<Integer> idList = new ArrayList<>();
|
|
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
List<Map<String,Object>> statistics = new ArrayList<Map<String, Object>>();
|
|
List<Map<String,Object>> statistics = new ArrayList<Map<String, Object>>();
|
|
-
|
|
|
|
WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
switch (statsType) {
|
|
switch (statsType) {
|
|
case 0:
|
|
case 0:
|
|
@@ -284,7 +301,12 @@ public class WorkOrderStatisticsController {
|
|
case 2:
|
|
case 2:
|
|
startDate = String.format("%s-01", startDate);
|
|
startDate = String.format("%s-01", startDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
- endDate = subMonth(endDate,1);
|
|
|
|
|
|
+ if(isCurrentMonth(endDate)==true){
|
|
|
|
+ endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ endDate = subMonth(endDate, 1);
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
workOrderManageDto.setScenesId(scenesId);
|
|
workOrderManageDto.setScenesId(scenesId);
|
|
@@ -308,6 +330,7 @@ public class WorkOrderStatisticsController {
|
|
@ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
|
|
@ApiParam(value = "统计类型:0-按月统计,1-按年统计,2-自定义统计", required = true) @RequestParam(required = true) int statsType,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
//根据用户编号,获取用户的权限
|
|
//根据用户编号,获取用户的权限
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -327,7 +350,12 @@ public class WorkOrderStatisticsController {
|
|
} else if (statsType == 2) {
|
|
} else if (statsType == 2) {
|
|
startDate = String.format("%s-01", startDate);
|
|
startDate = String.format("%s-01", startDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
endDate = String.format("%s-01", endDate);
|
|
- endDate = subMonth(endDate,1);
|
|
|
|
|
|
+ if(isCurrentMonth(endDate)==true){
|
|
|
|
+ endDate = String.format("%s-%s", endDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ endDate = subMonth(endDate, 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
workOrderManageDto.setStartDate(startDate);
|
|
workOrderManageDto.setStartDate(startDate);
|
|
workOrderManageDto.setEndDate(endDate);
|
|
workOrderManageDto.setEndDate(endDate);
|
|
@@ -421,4 +449,21 @@ public class WorkOrderStatisticsController {
|
|
String reStr = sdf.format(dt1);
|
|
String reStr = sdf.format(dt1);
|
|
return reStr;
|
|
return reStr;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 日期是否当前月份
|
|
|
|
+ */
|
|
|
|
+ public boolean isCurrentMonth(String date) throws ParseException {
|
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date dt = sdf.parse(date);
|
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
|
+ rightNow.setTime(dt);
|
|
|
|
+ int y = rightNow.get(Calendar.YEAR);
|
|
|
|
+ int m =rightNow.get(Calendar.MONTH)+1;
|
|
|
|
+ if( y== localDate.getYear() && m == localDate.getMonthValue()){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|