|
@@ -3,6 +3,7 @@ package com.huaxu.utils;
|
|
|
import com.huaxu.evaluation.enums.EvaluationCycleEnums;
|
|
|
import com.huaxu.evaluation.vo.EvaluationItemVo;
|
|
|
import com.huaxu.evaluation.vo.EvaluationResultVo;
|
|
|
+import com.huaxu.order.dto.WorkOrderManageDto;
|
|
|
import com.huaxu.util.DatesUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
@@ -10,10 +11,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -30,6 +28,51 @@ public class EvaluationUtil {
|
|
|
*/
|
|
|
private static final String DATE_STRING = "%s年%s";
|
|
|
|
|
|
+ /**
|
|
|
+ * 3月
|
|
|
+ */
|
|
|
+ private static final int MARCH = 3;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 6月
|
|
|
+ */
|
|
|
+ private static final int JUNE = 6;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 9月
|
|
|
+ */
|
|
|
+ private static final int SEPTEMBER = 9;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 12月
|
|
|
+ */
|
|
|
+ private static final int DECEMBER = 12;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第一季度
|
|
|
+ */
|
|
|
+ private static final String Q1 = "1";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第二度
|
|
|
+ */
|
|
|
+ private static final String Q2 = "2";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第三季度
|
|
|
+ */
|
|
|
+ private static final String Q3 = "3";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 第四季度
|
|
|
+ */
|
|
|
+ private static final String Q4 = "4";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工单类型
|
|
|
+ */
|
|
|
+ static List<Integer> workList = Arrays.asList(1,2,3,4,5,6);
|
|
|
+
|
|
|
private static Calendar getCalendar(){
|
|
|
return Calendar.getInstance();
|
|
|
}
|
|
@@ -40,6 +83,15 @@ public class EvaluationUtil {
|
|
|
return calendar;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断是不是工单
|
|
|
+ * @param orderTypeId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static boolean isWork(Integer orderTypeId){
|
|
|
+ return workList.contains(orderTypeId);
|
|
|
+ }
|
|
|
+
|
|
|
/***
|
|
|
* 格式化考评周期时间
|
|
|
* @author lihui
|
|
@@ -50,20 +102,32 @@ public class EvaluationUtil {
|
|
|
* @return java.lang.String
|
|
|
**/
|
|
|
public static String formatCycle(int cycle, String year, String month){
|
|
|
- String monthString = "";
|
|
|
- if (cycle != EvaluationCycleEnums.YEAR.getType()) {
|
|
|
- monthString = cycle == 0 ? month + "月" : month + "季度";
|
|
|
+ // 格式化月度
|
|
|
+ if (cycle == EvaluationCycleEnums.MONTH.getType()) {
|
|
|
+ return String.format(DATE_STRING, year, month + "月");
|
|
|
}
|
|
|
- if ("3".equals(month)) {
|
|
|
- month = "1";
|
|
|
- } else if ("6".equals(month)){
|
|
|
- month = "2";
|
|
|
- } else if ("9".equals(month)){
|
|
|
- month = "3";
|
|
|
- } else if ("12".equals(month)){
|
|
|
- month = "4";
|
|
|
+ // 格式化年度
|
|
|
+ if (cycle == EvaluationCycleEnums.YEAR.getType()) {
|
|
|
+ return String.format(DATE_STRING, year, "");
|
|
|
}
|
|
|
- return String.format(DATE_STRING, year, monthString);
|
|
|
+ // 格式化季度
|
|
|
+ switch (Integer.parseInt(month)) {
|
|
|
+ case MARCH :
|
|
|
+ month = Q1;
|
|
|
+ break;
|
|
|
+ case JUNE :
|
|
|
+ month = Q2;
|
|
|
+ break;
|
|
|
+ case SEPTEMBER :
|
|
|
+ month = Q3;
|
|
|
+ break;
|
|
|
+ case DECEMBER :
|
|
|
+ month = Q4;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ month = "";
|
|
|
+ }
|
|
|
+ return String.format(DATE_STRING, year, month + "季度");
|
|
|
}
|
|
|
|
|
|
public static Integer toInteger(Long lon) {
|
|
@@ -242,6 +306,59 @@ public class EvaluationUtil {
|
|
|
return localDate.toString() + " 23:59:59";
|
|
|
}
|
|
|
|
|
|
+ public static String getStartTime(int cycle, int year, int newMonth, int day) {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ localDate = localDate.withYear(year);
|
|
|
+ localDate = localDate.withMonth(newMonth);
|
|
|
+ if (cycle == EvaluationCycleEnums.MONTH.getType()) {
|
|
|
+ localDate = localDate.plusMonths(-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cycle == EvaluationCycleEnums.QUARTER.getType()){
|
|
|
+ int month = newMonth == 1 ? 1 :
|
|
|
+ newMonth == 2 ? 4 :
|
|
|
+ newMonth == 3 ? 7 :
|
|
|
+ newMonth == 4 ? 10 : null;
|
|
|
+
|
|
|
+ localDate = localDate.withMonth(month);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cycle == EvaluationCycleEnums.YEAR.getType()){
|
|
|
+ localDate = localDate.plusYears(-1);
|
|
|
+ localDate = localDate.withMonth(1);
|
|
|
+ }
|
|
|
+ localDate = localDate.withDayOfMonth(day);
|
|
|
+ return localDate.toString() + " 00:00:00";
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getEndTime(int cycle, int year, int newMonth, int day) {
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ localDate = localDate.withYear(year);
|
|
|
+ localDate = localDate.withMonth(newMonth);
|
|
|
+ if (cycle == EvaluationCycleEnums.MONTH.getType()) {
|
|
|
+ localDate = day == 1 ? localDate.plusMonths(-1) : localDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cycle == EvaluationCycleEnums.QUARTER.getType()){
|
|
|
+ int month = newMonth == 1 ? 4 :
|
|
|
+ newMonth == 2 ? 7 :
|
|
|
+ newMonth == 3 ? 10 :
|
|
|
+ newMonth == 4 ? 1 : null;
|
|
|
+ localDate = localDate.withMonth(month);
|
|
|
+ // 设置月份
|
|
|
+ localDate = day == 1 ? localDate.plusMonths(-1) : localDate;
|
|
|
+ localDate = newMonth == 4 ? localDate.plusYears(1) : localDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cycle == EvaluationCycleEnums.YEAR.getType()){
|
|
|
+ localDate = localDate.withMonth(1);
|
|
|
+ localDate = day == 1 ? localDate.plusMonths(-1) : localDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ localDate = day != 1 ? localDate.withDayOfMonth(day - 1) : localDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ return localDate.toString() + " 23:59:59";
|
|
|
+ }
|
|
|
+
|
|
|
public static LocalDate getLocalDateByCycle(String startTime, String endTime, int cycle){
|
|
|
// 季度获取后面的时间
|
|
|
String quarterString = "4,7,10,1";
|
|
@@ -255,7 +372,7 @@ public class EvaluationUtil {
|
|
|
}
|
|
|
|
|
|
public static List<List<String>> getExcelTitle(){
|
|
|
- String string[] = {"No.","用户名","所属公司","所属部门","绩效等级","绩效得分","考评周期"};
|
|
|
+ String[] string = new String[]{"No.","用户名","所属公司","所属部门","绩效等级","绩效得分","考评周期"};
|
|
|
List<List<String>> list = new ArrayList<>();
|
|
|
for (String str : string) {
|
|
|
List<String> title = new ArrayList<>();
|
|
@@ -275,7 +392,7 @@ public class EvaluationUtil {
|
|
|
list.add(evaluationResultVo.getCompanyOrgName());
|
|
|
list.add(evaluationResultVo.getDeptOrgName());
|
|
|
list.add(evaluationResultVo.getEvaluationGrade());
|
|
|
- list.add(evaluationResultVo.getValue().toString());
|
|
|
+ list.add(evaluationResultVo.getValue()!= null ? evaluationResultVo.getValue().toString() : "");
|
|
|
list.add(evaluationResultVo.getCycle());
|
|
|
result.add(list);
|
|
|
total++;
|
|
@@ -285,8 +402,8 @@ public class EvaluationUtil {
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- LocalDate localDate = EvaluationUtil.getLocalDateByCycle("2020-12-01 00:00:00","2021-01-30 00:00:00",1);
|
|
|
- System.out.println(localDate.getYear() + "-" + localDate.getMonthValue());
|
|
|
+ System.out.println(EvaluationUtil.getStartTime(1, 15));
|
|
|
+ System.out.println(EvaluationUtil.getEndTime(1, 15));
|
|
|
}
|
|
|
|
|
|
}
|