|
@@ -24,6 +24,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@@ -49,6 +50,7 @@ public class WorkOrderStatisticsController {
|
|
|
@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 = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
//同比日期
|
|
|
String sameStartDate = null, sameEndDate = null;
|
|
|
//环比日期
|
|
@@ -74,7 +76,12 @@ public class WorkOrderStatisticsController {
|
|
|
} else if (statsType == 2) {
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
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();
|
|
@@ -117,34 +124,34 @@ public class WorkOrderStatisticsController {
|
|
|
DecimalFormat df = new DecimalFormat("#0.00");
|
|
|
|
|
|
if (sameStatistic.get("工单完成率") == null || sameStatistic.get("工单完成率").toString().equals("0")) {
|
|
|
- statistics.put("工单完成率同比", "-");
|
|
|
+ statistics.put("工单完成率同比", null);
|
|
|
} else {
|
|
|
Double finishedSameRate = (Double.parseDouble(statistics.get("工单完成率").toString()) - Double.parseDouble(sameStatistic.get("工单完成率").toString())) * 100 / Double.parseDouble(sameStatistic.get("工单完成率").toString());
|
|
|
statistics.put("工单完成率同比", df.format(finishedSameRate));
|
|
|
}
|
|
|
|
|
|
if (chainStatistic.get("工单完成率") == null || chainStatistic.get("工单完成率").toString().equals("0")) {
|
|
|
- statistics.put("工单完成率环比", "-");
|
|
|
+ statistics.put("工单完成率环比", null);
|
|
|
} else {
|
|
|
Double finishedChainRate = (Double.parseDouble(statistics.get("工单完成率").toString()) - Double.parseDouble(chainStatistic.get("工单完成率").toString())) * 100 / Double.parseDouble(chainStatistic.get("工单完成率").toString());
|
|
|
statistics.put("工单完成率环比", df.format(finishedChainRate));
|
|
|
}
|
|
|
|
|
|
if (sameStatistic.get("工单总数") == null || sameStatistic.get("工单总数").toString().equals("0")) {
|
|
|
- statistics.put("工单总数同比", "-");
|
|
|
+ statistics.put("工单总数同比", null);
|
|
|
} else {
|
|
|
Double orderSameTotalNumberRate = (Double.parseDouble(statistics.get("工单总数").toString()) - Double.parseDouble(sameStatistic.get("工单总数").toString())) * 100 / Double.parseDouble(sameStatistic.get("工单总数").toString());
|
|
|
statistics.put("工单总数同比", df.format(orderSameTotalNumberRate));
|
|
|
}
|
|
|
if (chainStatistic.get("工单总数") == null || chainStatistic.get("工单总数").toString().equals("0")) {
|
|
|
- statistics.put("工单总数环比", "-");
|
|
|
+ statistics.put("工单总数环比", null);
|
|
|
} else {
|
|
|
Double orderChainTotalNumberRate = (Double.parseDouble(statistics.get("工单总数").toString()) - Double.parseDouble(chainStatistic.get("工单总数").toString())) * 100 / Double.parseDouble(chainStatistic.get("工单总数").toString());
|
|
|
statistics.put("工单总数环比", df.format(orderChainTotalNumberRate));
|
|
|
}
|
|
|
|
|
|
if (sameStatistic.get("工单完成数") == null || sameStatistic.get("工单完成数").toString().equals("0")) {
|
|
|
- statistics.put("工单完成数同比", "-");
|
|
|
+ statistics.put("工单完成数同比", null);
|
|
|
|
|
|
} else {
|
|
|
Double finishedSameNumber = (Double.parseDouble(statistics.get("工单完成数").toString()) - Double.parseDouble(sameStatistic.get("工单完成数").toString())) * 100 / Double.parseDouble(sameStatistic.get("工单完成数").toString());
|
|
@@ -152,7 +159,7 @@ public class WorkOrderStatisticsController {
|
|
|
}
|
|
|
|
|
|
if (chainStatistic.get("工单完成数") == null || chainStatistic.get("工单完成数").toString().equals("0")) {
|
|
|
- statistics.put("工单完成数环比", "-");
|
|
|
+ statistics.put("工单完成数环比", null);
|
|
|
} else {
|
|
|
Double finishedChainNumber = (Double.parseDouble(statistics.get("工单完成数").toString()) - Double.parseDouble(chainStatistic.get("工单完成数").toString())) * 100 / Double.parseDouble(chainStatistic.get("工单完成数").toString());
|
|
|
statistics.put("工单完成数环比", df.format(finishedChainNumber));
|
|
@@ -168,6 +175,7 @@ public class WorkOrderStatisticsController {
|
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
int maintainerCount = 0;
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
|
List<Map<String, Object>> statistics = new ArrayList<>(), average =new ArrayList<>();
|
|
|
//根据用户编号,获取用户的权限
|
|
@@ -182,7 +190,12 @@ public class WorkOrderStatisticsController {
|
|
|
case 0:
|
|
|
maintainerCount = userCenterClient.findMaintainerCount(startDate);
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
- endDate = subMonth(startDate, 1);
|
|
|
+ if(isCurrentMonth(startDate)==true){
|
|
|
+ endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ endDate = subMonth(startDate, 1);
|
|
|
+ }
|
|
|
break;
|
|
|
case 1:
|
|
|
maintainerCount = userCenterClient.findMaintainerCount(String.format("%s-12",startDate));
|
|
@@ -193,7 +206,12 @@ public class WorkOrderStatisticsController {
|
|
|
maintainerCount = userCenterClient.findMaintainerCount(endDate);
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
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;
|
|
|
}
|
|
|
workOrderManageDto.setStartDate(startDate);
|
|
@@ -230,6 +248,7 @@ public class WorkOrderStatisticsController {
|
|
|
@ApiParam(value = "统计时间:月格式(yyyy-MM),年格式(yyyy),自定义统计时间开始日期", required = true) @RequestParam(required = true) String startDate,
|
|
|
@ApiParam(value = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
//根据用户编号,获取用户的权限
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
|
workOrderManageDto.setTenantId(loginUser.getTenantId());
|
|
@@ -240,7 +259,12 @@ public class WorkOrderStatisticsController {
|
|
|
switch (statsType) {
|
|
|
case 0:
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
- endDate = subMonth(startDate, 1);
|
|
|
+ if(isCurrentMonth(startDate)==true){
|
|
|
+ endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ endDate = subMonth(startDate, 1);
|
|
|
+ }
|
|
|
break;
|
|
|
case 1:
|
|
|
startDate = String.format("%s-01-01", startDate);
|
|
@@ -249,7 +273,12 @@ public class WorkOrderStatisticsController {
|
|
|
case 2:
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
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;
|
|
|
}
|
|
|
workOrderManageDto.setStartDate(startDate);
|
|
@@ -267,15 +296,18 @@ public class WorkOrderStatisticsController {
|
|
|
@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 = "统计时间:年月统计不用传入此参数,自定义统计截至日期", 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>>();
|
|
|
-
|
|
|
WorkOrderManageDto workOrderManageDto = new WorkOrderManageDto();
|
|
|
switch (statsType) {
|
|
|
case 0:
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
- endDate = subMonth(startDate, 1);
|
|
|
+ if(isCurrentMonth(startDate)==true){
|
|
|
+ endDate = String.format("%s-%s", startDate.substring(0,7),localDate.getDayOfMonth()+1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ endDate = subMonth(startDate, 1);
|
|
|
+ }
|
|
|
break;
|
|
|
case 1:
|
|
|
startDate = String.format("%s-01-01", startDate);
|
|
@@ -284,7 +316,12 @@ public class WorkOrderStatisticsController {
|
|
|
case 2:
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
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;
|
|
|
}
|
|
|
workOrderManageDto.setScenesId(scenesId);
|
|
@@ -308,6 +345,7 @@ public class WorkOrderStatisticsController {
|
|
|
@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 = "统计时间:年月统计不用传入此参数,自定义统计截至日期", required = false) @RequestParam(required = false) String endDate) throws ParseException {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//根据用户编号,获取用户的权限
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -327,7 +365,12 @@ public class WorkOrderStatisticsController {
|
|
|
} else if (statsType == 2) {
|
|
|
startDate = String.format("%s-01", startDate);
|
|
|
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.setEndDate(endDate);
|
|
@@ -421,4 +464,21 @@ public class WorkOrderStatisticsController {
|
|
|
String reStr = sdf.format(dt1);
|
|
|
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;
|
|
|
+ }
|
|
|
}
|