|
@@ -956,6 +956,10 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static Long dateToLong(String startDate) {
|
|
|
+ return Long.valueOf(startDate.replace("-", ""));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
|
|
@@ -1262,7 +1266,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
Date parse = null;
|
|
|
try {
|
|
|
parse = df.parse(date);
|
|
|
- }catch (ParseException e) {
|
|
|
+ } catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return String.format("%tY", parse);
|
|
@@ -1295,12 +1299,12 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
* @return
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
- public static String getDay(String format, String date){
|
|
|
+ public static String getDay(String format, String date) {
|
|
|
SimpleDateFormat df = new SimpleDateFormat(format);
|
|
|
Date parse = null;
|
|
|
try {
|
|
|
parse = df.parse(date);
|
|
|
- }catch (ParseException e) {
|
|
|
+ } catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return String.format("%td", parse);
|
|
@@ -1863,7 +1867,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
+ /**
|
|
|
* int 日期转 string
|
|
|
* 20220118 ====>>>> 2022-01-18
|
|
|
*
|
|
@@ -1878,7 +1882,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
String dateTarget = "";
|
|
|
try {
|
|
|
dateTarget = sdfTarget.format(sdfSource.parse(dateSource));
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return dateTarget;
|
|
@@ -1886,8 +1890,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 获取当前月份第一天
|
|
|
*
|
|
@@ -2262,15 +2264,13 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
|
|
|
System.out.println(subMonthMiddleDay("2022-12-01"));
|
|
|
- if (subMonthMiddleDay("2022-12-01") == 20221215){
|
|
|
+ if (subMonthMiddleDay("2022-12-01") == 20221215) {
|
|
|
System.out.println("111");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
System.out.println("222");
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/****
|
|
@@ -2285,7 +2285,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
Date dt = null;
|
|
|
try {
|
|
|
dt = sdf.parse(date);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
@@ -2298,21 +2298,20 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 获取季度所在的3个月份的 开始和结束时间
|
|
|
+ *
|
|
|
* @param quarterTime
|
|
|
* @return
|
|
|
*/
|
|
|
- public static List<Map<String,Integer>> getQuarStartAndEndTime(int quarterTime){
|
|
|
- List<Map<String,Integer>> list = new ArrayList();
|
|
|
- Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(quarterTime);
|
|
|
- String[] quarterStr = (String[])timeMap.get("quarter");
|
|
|
- for (String month : quarterStr ){
|
|
|
- Map<String,Integer> map = new HashMap<>();
|
|
|
- map.put("startTime",getFirstDayOfMonth(Integer.valueOf(month)));
|
|
|
- map.put("endTime",getLastDayOfMonth(Integer.valueOf(month)));
|
|
|
+ public static List<Map<String, Integer>> getQuarStartAndEndTime(int quarterTime) {
|
|
|
+ List<Map<String, Integer>> list = new ArrayList();
|
|
|
+ Map<String, Object> timeMap = DateUtils.getCurrentQuarterMonths(quarterTime);
|
|
|
+ String[] quarterStr = (String[]) timeMap.get("quarter");
|
|
|
+ for (String month : quarterStr) {
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ map.put("startTime", getFirstDayOfMonth(Integer.valueOf(month)));
|
|
|
+ map.put("endTime", getLastDayOfMonth(Integer.valueOf(month)));
|
|
|
list.add(map);
|
|
|
}
|
|
|
return list;
|
|
@@ -2321,33 +2320,35 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
/**
|
|
|
* 获取当前时间的季度的月份
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Map<String,Object> getCurrentQuarterMonths(int quarterTime){
|
|
|
+ public static Map<String, Object> getCurrentQuarterMonths(int quarterTime) {
|
|
|
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
String quarter[] = new String[]{};
|
|
|
|
|
|
- if (quarterTime == 1){
|
|
|
- quarter = new String[]{"01","02","03"};
|
|
|
+ if (quarterTime == 1) {
|
|
|
+ quarter = new String[]{"01", "02", "03"};
|
|
|
}
|
|
|
- if (quarterTime == 2){
|
|
|
- quarter = new String[]{"04","05","06"};
|
|
|
+ if (quarterTime == 2) {
|
|
|
+ quarter = new String[]{"04", "05", "06"};
|
|
|
}
|
|
|
- if (quarterTime == 3){
|
|
|
- quarter = new String[]{"07","08","09"};
|
|
|
+ if (quarterTime == 3) {
|
|
|
+ quarter = new String[]{"07", "08", "09"};
|
|
|
}
|
|
|
- if (quarterTime == 4){
|
|
|
- quarter = new String[]{"10","11","12"};
|
|
|
+ if (quarterTime == 4) {
|
|
|
+ quarter = new String[]{"10", "11", "12"};
|
|
|
}
|
|
|
- map.put("quarterTime",quarterTime);
|
|
|
- map.put("quarter",quarter);
|
|
|
+ map.put("quarterTime", quarterTime);
|
|
|
+ map.put("quarter", quarter);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获得季度开始时间
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public static Date getCurrentQuarterStartTime() {
|
|
@@ -2375,6 +2376,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
/**
|
|
|
* 当前季度的结束时间
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public static Date getCurrentQuarterEndTime() {
|
|
@@ -2395,6 +2397,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
/**
|
|
|
* 离职时间所在季度的最后一天
|
|
|
+ *
|
|
|
* @param time
|
|
|
* @return
|
|
|
*/
|
|
@@ -2417,9 +2420,9 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取当前月第一天
|
|
|
+ *
|
|
|
* @param month
|
|
|
* @return
|
|
|
*/
|
|
@@ -2439,6 +2442,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
/**
|
|
|
* 获取当前月最后一天
|
|
|
+ *
|
|
|
* @param month
|
|
|
* @return
|
|
|
*/
|
|
@@ -2447,12 +2451,12 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
// 设置月份
|
|
|
calendar.set(Calendar.MONTH, month - 1);
|
|
|
// 获取某月最大天数
|
|
|
- int lastDay=0;
|
|
|
+ int lastDay = 0;
|
|
|
//2月的平年瑞年天数
|
|
|
- if(month==2) {
|
|
|
+ if (month == 2) {
|
|
|
// 这个api在计算2020年2月的过程中有问题
|
|
|
lastDay = calendar.getLeastMaximum(Calendar.DAY_OF_MONTH);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
}
|
|
|
// 设置日历中月份的最大天数
|
|
@@ -2464,12 +2468,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- public static Double getMaterialCost(String frozenTime, String createTime,int monthTime){
|
|
|
+ public static Double getMaterialCost(String frozenTime, String createTime, int monthTime) {
|
|
|
|
|
|
//String frozenTime = "";
|
|
|
//String createTime = "2022-11-02 12:23:23";
|
|
@@ -2481,72 +2480,72 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
/**
|
|
|
* 人员离职
|
|
|
*/
|
|
|
- if (frozenTime != null){
|
|
|
+ if (frozenTime != null) {
|
|
|
|
|
|
- Date date = DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
+ Date date = DateUtils.str2Date(frozenTime, new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
// 判断时间所在的季度
|
|
|
int quarterTime = DateUtils.getQuarter(date);
|
|
|
|
|
|
//季度查询时间 超过 离职时间 则比例为0 绩效 无
|
|
|
- if (quarterTime < monthTime){
|
|
|
+ if (quarterTime < monthTime) {
|
|
|
i = 0;
|
|
|
- log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},",frozenTime,monthTime,new Date());
|
|
|
+ log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},", frozenTime, monthTime, new Date());
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (quarterTime > monthTime){
|
|
|
- log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},",frozenTime,monthTime,new Date());
|
|
|
+ if (quarterTime > monthTime) {
|
|
|
+ log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},", frozenTime, monthTime, new Date());
|
|
|
|
|
|
}
|
|
|
|
|
|
//离职时间 是否是当前季度
|
|
|
- if (quarterTime == monthTime){
|
|
|
- Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
+ if (quarterTime == monthTime) {
|
|
|
+ Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
//离职时间所在 月份
|
|
|
- String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
|
|
|
+ String month = DateUtils.getMonth("yyyy-MM-dd", frozenTime);
|
|
|
//离职时间所在的季度 的全部 月份
|
|
|
- String[] quarter =(String[]) map.get("quarter");
|
|
|
+ String[] quarter = (String[]) map.get("quarter");
|
|
|
//判断当前离职所在的月份 与当前季度中的月份集合 并获取下标 下标+1 则是 在职月份i
|
|
|
- int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
|
|
|
+ int j = Collections.indexOfSubList(Arrays.asList(quarter), Arrays.asList(month));
|
|
|
i = j + 1;
|
|
|
- log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}",frozenTime,monthTime,i,i*cost);
|
|
|
+ log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}", frozenTime, monthTime, i, i * cost);
|
|
|
|
|
|
}
|
|
|
//return i * cost;
|
|
|
|
|
|
- }else {
|
|
|
- Date date = DateUtils.str2Date(createTime,new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
+ } else {
|
|
|
+ Date date = DateUtils.str2Date(createTime, new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
// 判断时间所在的季度
|
|
|
int quarterTime = DateUtils.getQuarter(date);
|
|
|
//查询入职前的 比例
|
|
|
//季度查询时间 超过 入职时间 绩效0
|
|
|
- if (quarterTime < monthTime){
|
|
|
- log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},",createTime,monthTime,new Date());
|
|
|
+ if (quarterTime < monthTime) {
|
|
|
+ log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},", createTime, monthTime, new Date());
|
|
|
}
|
|
|
//查询入职后的 比例
|
|
|
- if (quarterTime > monthTime){
|
|
|
+ if (quarterTime > monthTime) {
|
|
|
i = 0;
|
|
|
- log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},",createTime,monthTime,new Date());
|
|
|
+ log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},", createTime, monthTime, new Date());
|
|
|
}
|
|
|
|
|
|
//入职时间 在当前季度
|
|
|
- if (quarterTime == monthTime){
|
|
|
- Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
+ if (quarterTime == monthTime) {
|
|
|
+ Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
|
|
|
//月份
|
|
|
//入职时间所在 月份
|
|
|
- String month = DateUtils.getMonth("yyyy-MM-dd",createTime);
|
|
|
+ String month = DateUtils.getMonth("yyyy-MM-dd", createTime);
|
|
|
//季度
|
|
|
- String[] quarter =(String[]) map.get("quarter");
|
|
|
+ String[] quarter = (String[]) map.get("quarter");
|
|
|
//判断当前离职所在的月份 与当前季度中的月份集合 并获取下标 下标+1 则是 在职月份i
|
|
|
- int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
|
|
|
+ int j = Collections.indexOfSubList(Arrays.asList(quarter), Arrays.asList(month));
|
|
|
i = j + 1;
|
|
|
- log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}",createTime,monthTime,i,i*cost);
|
|
|
+ log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}", createTime, monthTime, i, i * cost);
|
|
|
return i * cost;
|
|
|
- };
|
|
|
+ }
|
|
|
+ ;
|
|
|
}
|
|
|
return i * cost;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|