瀏覽代碼

新增运行评价计算服务

xieshengjie 3 年之前
父節點
當前提交
93131047a9

+ 16 - 1
common/pom.xml

@@ -62,7 +62,22 @@
             <artifactId>ojdbc6</artifactId>
             <version>11.2.0.3</version>
         </dependency>
-
+        <!--常用工具类 -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-math3</artifactId>
+            <version>3.6.1</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>

+ 16 - 0
common/src/main/java/com/gyee/common/util/CommonUtils.java

@@ -1,5 +1,6 @@
 package com.gyee.common.util;
 
+import java.lang.reflect.Field;
 import java.util.UUID;
 
 /**
@@ -14,4 +15,19 @@ public class CommonUtils {
         String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
         return uuid;
     }
+
+    /**
+     * 获取对象所有属性
+     * @param o
+     * @return
+     */
+    public static String[] getFileName(Object o){
+        Field[] fields = o.getClass().getDeclaredFields();
+        String[] fieldNames = new String[fields.length];
+        for (int i=0;i<fields.length;i++){
+            fieldNames[i]=fields[i].getName();
+        }
+        return fieldNames;
+
+    }
 }

+ 35 - 0
common/src/main/java/com/gyee/common/util/CopyUtils.java

@@ -0,0 +1,35 @@
+package com.gyee.common.util;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
+/**
+ * @ClassName : CopyUtils
+ * @Author : xieshengjie
+ * @Date: 2021/3/6 15:42
+ * @Description : 复制对象工具类
+ */
+public class CopyUtils {
+    public static void copy(Object source,Object dest) throws  Exception{
+        BeanInfo sourceBean = Introspector.getBeanInfo(source.getClass(),Object.class);
+        PropertyDescriptor[] sourceProperty = sourceBean.getPropertyDescriptors();
+
+        BeanInfo destBean = Introspector.getBeanInfo(dest.getClass(),Object.class);
+        PropertyDescriptor[] destProperty = destBean.getPropertyDescriptors();
+
+        try {
+            for (int i=0;i<sourceProperty.length;i++){
+                for (int j=0;j<destProperty.length;j++){
+                    if (sourceProperty[i].getName().equals(destProperty[j].getName()) && sourceProperty[i].getPropertyType() == destProperty[j].getPropertyType()){
+                        destProperty[j].getWriteMethod().invoke(dest,sourceProperty[i].getReadMethod().invoke(source));
+                        break;
+                    }
+                }
+            }
+        }catch (Exception e){
+            throw new Exception("属性复制失败:"+e.getMessage());
+        }
+
+    }
+}

+ 841 - 17
common/src/main/java/com/gyee/common/util/DateUtils.java

@@ -1,8 +1,16 @@
 package com.gyee.common.util;
 
+import java.text.DateFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName : DateUtils
@@ -11,48 +19,430 @@ import java.util.Date;
  * @Description : 日期工具
  */
 public class DateUtils  {
+
+
+    private static final String format = "yyyy-MM-dd";
+    private static final String format1 = "yyyy-MM-dd HH:mm:ss";
+    private static final String format2 = "MM/dd/yyyy HH:mm:ss";
+    private static final String format3 = "yyyy-MM";
+
+    // 第一次调用get将返回null
+
+    private static ThreadLocal<SimpleDateFormat> threadLocal = new ThreadLocal<SimpleDateFormat>();
+
+    // 获取线程的变量副本,如果不覆盖initialValue,第一次get返回null,故需要初始化一个SimpleDateFormat,并set到threadLocal中
+
+    public static SimpleDateFormat getFormat() {
+
+        SimpleDateFormat df = (SimpleDateFormat) threadLocal.get();
+
+        if (df == null) {
+            df = new SimpleDateFormat(format);
+            threadLocal.set(df);
+        }
+
+        return df;
+
+    }
+
+    public static SimpleDateFormat getFormat1() {
+
+        SimpleDateFormat df1 = (SimpleDateFormat) threadLocal.get();
+
+        if (df1 == null) {
+            df1 = new SimpleDateFormat(format1);
+            threadLocal.set(df1);
+        }
+
+        return df1;
+
+    }
+
+    public static SimpleDateFormat getFormat2() {
+
+        SimpleDateFormat df2 = (SimpleDateFormat) threadLocal.get();
+
+        if (df2 == null) {
+            df2 = new SimpleDateFormat(format2);
+            threadLocal.set(df2);
+        }
+
+        return df2;
+
+    }
+
+    public static SimpleDateFormat getFormat3() {
+
+        SimpleDateFormat df3 = (SimpleDateFormat) threadLocal.get();
+
+        if (df3 == null) {
+            df3 = new SimpleDateFormat(format3);
+            threadLocal.set(df3);
+        }
+
+        return df3;
+
+    }
+
+    private DateUtils() {
+    }
+
     /**
-     * 获得指定时间的月数
+     * 获取系统日期(无时分秒毫秒)
+     *
+     * @return
+     */
+    public static Date today() {
+        return truncate(now());
+    }
+
+    /**
+     * 获取系统时间
+     *
+     * @return
+     */
+    public static Date now() {
+        return new Date();
+    }
+
+    /**
+     * 根据年月日生成日期对象
+     *
+     * @param y
+     * @param m
+     * @param d
+     * @return
+     */
+    public static Date cons(int y, int m, int d) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(y, m, d, 0, 0, 0);
+        return cal.getTime();
+    }
+
+    public static String toDate(Date date) {
+        return getFormat1().format(date);
+    }
+
+    public static String toDate2(Date date) {
+        return getFormat2().format(date);
+    }
+
+    public static String toDate1(Date date) {
+        return getFormat().format(date);
+    }
+
+    /**
+     * 根据年月日时分秒生成日期对象
+     *
+     * @param y
+     * @param m
+     * @param d
+     * @param h
+     * @param mi
+     * @param s
+     * @return
+     */
+    public static Date cons(int y, int m, int d, int h, int mi, int s) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(y, m, d, h, mi, s);
+        return cal.getTime();
+    }
+
+    /**
+     * 将指定时间转化为 Calendar
      *
      * @param date
      * @return
      */
-    public static int getMonth(Date date) {
-        Calendar cd = Calendar.getInstance();
-        cd.setTime(date);
-        return cd.get(Calendar.MONTH)+1;
+    public static Calendar getCal(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        return cal;
     }
 
     /**
-     * 获得指定时间的年数
+     * 获取当年年份
+     * @return
+     */
+    public static Integer getCurrentYear() {
+        Calendar date = Calendar.getInstance();
+        int year = date.get(Calendar.YEAR);
+        return year;
+
+    }
+    /**
+     * 将时间的时分秒毫秒字段去掉
      *
      * @param date
      * @return
      */
-    public static int getYear(Date date) {
-        Calendar cd = Calendar.getInstance();
-        cd.setTime(date);
-        return cd.get(Calendar.YEAR);
+    public static Date truncate(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        return cal.getTime();
     }
 
     /**
-     * 获取某日期的当月最后一天
+     * 去掉日期中日及下级字段
      *
      * @param date
+     * @return
+     */
+    public static Date truncDay(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.DAY_OF_MONTH, 1);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        return cal.getTime();
+    }
+
+    /**
+     * 去掉日期中的月及下级字段
      *
+     * @param date
+     * @return
+     */
+    public static Date truncMonth(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.MONTH, 0);
+        cal.set(Calendar.DAY_OF_MONTH, 1);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        return cal.getTime();
+    }
+
+    /**
+     * 在指定时间上加指定的天数
+     *
+     * @param date
+     * @param day
+     * @return
+     */
+    public static Date addDays(Date date, int day) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.DAY_OF_MONTH, day);
+        return cal.getTime();
+    }
+
+    /**
+     * 在指定的时间上加指定的月数
+     *
+     * @param date
+     * @param month
+     * @return
+     */
+    public static Date addMonths(Date date, int month) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MONTH, month);
+        return cal.getTime();
+    }
+
+    /**
+     * 在指定的时间上加指定的月数
+     *
+     * @param date
+     * @param year
+     * @return
+     */
+    public static Date addYears(Date date, int year) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.YEAR, year);
+        return cal.getTime();
+    }
+
+    /**
+     * 在指定时间上加指定的小时
+     *
+     * @param date
+     * @param hour
+     * @return
+     */
+    public static Date addHours(Date date, int hour) {
+        return new Date(date.getTime() + hour * 3600 * 1000);
+    }
+
+    /**
+     * 在指定时间上加指定的分钟
+     *
+     * @param date
+     * @param m
+     * @return
+     */
+    public static Date addMinutes(Date date, int m) {
+        return new Date(date.getTime() + m * 60 * 1000);
+    }
+
+    /**
+     * 在指定时间上加指定的秒
+     *
+     * @param date
+     * @param s
+     * @return
+     */
+    public static Date addSeconds(Date date, int s) {
+        return new Date(date.getTime() + s * 1000);
+    }
+
+    /**
+     * 计算两个时间之间差的天数(取整后)
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static int daysDiff(Date d1, Date d2) {
+        return (int) Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (60 * 60 * 24 * 1000));
+    }
+
+    /**
+     * 计算两个时间之间差的小时数(取整后)
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static int hoursDiff(Date d1, Date d2) {
+        return (int) Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (60 * 60 * 1000));
+    }
+
+    public static double hoursDiff1(Date d1, Date d2) {
+        return Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (double) (60 * 60 * 1000));
+    }
+
+    public static double hoursDiff2(Date d1, Date d2) {
+        return Math.abs((d1.getTime() - d2.getTime())) / (double) (60 * 60 * 1000);
+    }
+
+    /**
+     * 计算两个时间之间差的分钟数(取整后)
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static int minutesDiff(Date d1, Date d2) {
+        return (int) Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (60 * 1000));
+    }
+
+    /**
+     * 计算两个时间之间差的分钟数(取整后)
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static double minutesDiff2(Date d1, Date d2) {
+        return Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (60 * 1000));
+    }
+
+    /**
+     * 计算两个时间之间差的毫秒数(取整后)
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static long millisecondDiff(Date d1, Date d2) {
+        return Math.abs(d1.getTime() - d2.getTime());
+    }
+
+    /**
+     * 计算两个时间之间差的秒数(取整后)
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static int secondsDiff(Date d1, Date d2) {
+        return (int) Math.floor(Math.abs((d1.getTime() - d2.getTime())) / (1000));
+    }
+
+    /**
+     * 计算两个时间之间的月差
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static int monthsDiff(Date d1, Date d2) {
+        Calendar cal1 = Calendar.getInstance();
+        Calendar cal2 = Calendar.getInstance();
+        cal1.setTime(d1);
+        cal2.setTime(d2);
+
+        return (int) Math.abs((cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR)) * 12 + cal1.get(Calendar.MONTH) - cal2.get(Calendar.MONTH));
+
+    }
+
+
+    /**
+     * 获取指定时间的天数
+     *
+     * @param date
+     * @return
+     */
+    public static int getDay(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.DAY_OF_MONTH);
+    }
+
+    public static int getCurrentMonthLastDay() {
+        Calendar a = Calendar.getInstance();
+        a.set(Calendar.DATE, 1);
+        a.roll(Calendar.DATE, -1);
+        int maxDate = a.get(Calendar.DATE);
+        return maxDate;
+    }
+
+    public static int getMonthDays(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(DateUtils.getYear(date), DateUtils.getMonth(date), DateUtils.getDay(date));
+        int dayst = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
+        return dayst;
+    }
+
+    /**
+     * 获取某年第一天日期
+     *
+     * @param year
+     *            年份
      * @return Date
      */
-    public static Date getMonthLast(Date date) {
+    public static Date getYearFirst(int year) {
         Calendar calendar = Calendar.getInstance();
         calendar.clear();
-        int month = getMonth(date);
-        int year = getYear(date);
         calendar.set(Calendar.YEAR, year);
-        calendar.set(Calendar.MONTH, month-1);
-        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
         Date currYearFirst = calendar.getTime();
         return currYearFirst;
     }
+
+    /**
+     * 获取当前日期
+     *
+     * @param
+     * @return Date
+     */
+    public static Date getCurrentDate() {
+        Calendar calendar = Calendar.getInstance();
+        Date date = calendar.getTime();
+        return date;
+    }
+
+
     /**
      * 获取某日期的当月第一天
      *
@@ -72,9 +462,351 @@ public class DateUtils  {
         return currYearFirst;
     }
 
+
+
+    /**
+     * 获取当前月的第一天
+     *
+     * @return
+     */
+    public static String getCurrtenFirstDay() {
+
+        Calendar c = Calendar.getInstance();
+        // c.add(Calendar.MONTH, 0);
+        c.set(Calendar.DAY_OF_MONTH, 1);
+        return getFormat().format(c.getTime());
+    }
+
+    /**
+     * 获取当前月的最后一天
+     *
+     * @return
+     */
+    public static String getCurrtenLastDay() {
+
+        Calendar ca = Calendar.getInstance();
+        ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return getFormat().format(ca.getTime());
+    }
+
+    /**
+     * 获取当前月的第一天
+     *
+     * @return
+     */
+    public static Date getCurrtenFirstDate() {
+
+        Calendar c = Calendar.getInstance();
+        c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
+        c.set(Calendar.HOUR_OF_DAY, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 1);
+        return c.getTime();
+    }
+
+    /**
+     * 获取当前月的最后一天
+     *
+     * @return
+     */
+    public static Date getCurrtenLastDate() {
+
+        Calendar c = Calendar.getInstance();
+        c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+        return c.getTime();
+    }
+
+    public static Date parseDate(String date) {
+        try {
+            return getFormat().parse(date);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static Date parseDate1(String date) {
+        try {
+            return getFormat1().parse(date);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static Date parseDate2(String date) {
+        try {
+            return getFormat2().parse(date);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static Date parseDate3(String date) {
+        try {
+            return getFormat3().parse(date);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static Date parseLongToDate(long time) {
+        return new Date(time);
+    }
+
+
+
+    public static List<Date> getBetweenDates(Date start, Date end) {
+        List<Date> result = new ArrayList<Date>();
+        Calendar tempStart = Calendar.getInstance();
+        tempStart.setTime(start);
+        //tempStart.add(Calendar.DAY_OF_YEAR, 1);
+
+        Calendar tempEnd = Calendar.getInstance();
+        tempEnd.add(Calendar.DATE, +1);
+        tempEnd.setTime(end);
+
+        while (tempStart.before(tempEnd)) {
+            result.add(tempStart.getTime());
+            tempStart.add(Calendar.DAY_OF_YEAR, 1);
+        }
+        return result;
+    }
+
+    /**
+     * 获取上月最后一天
+     * @return
+     */
+    public static Date getYestmonthLastday(Date date){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.MONTH, -1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return calendar.getTime();
+
+    }
+
+
+
+    /**
+     * 转换Edna时间格式为标准格式
+     *
+     * @param pointTime
+     * @return
+     */
+    public static String convertEdnaTime2(String pointTime, Boolean isNoSec) {
+        StringBuffer sb = new StringBuffer();
+        String[] dt = pointTime.split(" ");
+        String[] ymd = dt[0].split("-");
+        String[] hms = dt[1].split(":");
+        sb.append(ymd[0]).append("-");
+        if (ymd[1].length() == 1) {
+            sb.append("0").append(ymd[1]);
+        } else {
+            sb.append(ymd[1]);
+        }
+        if (ymd[2].length() == 1) {
+            sb.append("-").append("0").append(ymd[2]);
+        } else {
+            sb.append("-").append(ymd[2]);
+        }
+        if (hms[0].length() == 1) {
+            sb.append(" ").append("0").append(hms[0]);
+        } else {
+            sb.append(" ").append(hms[0]);
+        }
+        if (hms[1].length() == 1) {
+            sb.append(":").append("0").append(hms[1]);
+        } else {
+            sb.append(":").append(hms[1]);
+        }
+
+        if (isNoSec) {
+            sb.append(":").append("00");
+        } else {
+            if (hms[2].length() == 1) {
+                sb.append(":").append("0").append(hms[2]);
+            } else {
+                sb.append(":").append(hms[2]);
+            }
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * 转换Edna时间格式为标准格式
+     *
+     * @param pointTime
+     * @return
+     */
+    public static String convertEdnaTime(String pointTime, Boolean isNoSec) {
+        String date = getFormat().format(new Date());
+        StringBuffer sb = new StringBuffer();
+        String[] dt = pointTime.split(" ");
+        String[] ymd = dt[0].split("/");
+        String[] hms = dt[1].split(":");
+        if (ymd[2].length() == 2) {
+            sb.append(date.substring(0, 2)).append(ymd[2]).append("-");
+        }
+        if (ymd[0].length() == 1) {
+            sb.append("0").append(ymd[0]);
+        } else {
+            sb.append(ymd[0]);
+        }
+        if (ymd[1].length() == 1) {
+            sb.append("-").append("0").append(ymd[1]);
+        } else {
+            sb.append("-").append(ymd[1]);
+        }
+        if (hms[0].length() == 1) {
+            sb.append(" ").append("0").append(hms[0]);
+        } else {
+            sb.append(" ").append(hms[0]);
+        }
+        if (hms[1].length() == 1) {
+            sb.append(":").append("0").append(hms[1]);
+        } else {
+            sb.append(":").append(hms[1]);
+        }
+
+        if (isNoSec) {
+            sb.append(":").append("00");
+        } else {
+            if (hms[2].length() == 1) {
+                sb.append(":").append("0").append(hms[2]);
+            } else {
+                sb.append(":").append(hms[2]);
+            }
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * 获取两个日期之间的所有日期(字符串格式, 按天计算)
+     *
+     * @param startTime String 开始时间 yyyy-MM-dd
+     * @param endTime  String 结束时间 yyyy-MM-dd
+     * @return
+     */
+    public static List<String> getBetweenDays(String startTime, String endTime) throws ParseException {
+
+        //1、定义转换格式
+        SimpleDateFormat df  = new SimpleDateFormat("yyyy-MM-dd");
+
+        Date start = df.parse(startTime);
+        Date end = df.parse(endTime);
+
+        List<String> result = new ArrayList<String>();
+
+        Calendar tempStart = Calendar.getInstance();
+        tempStart.setTime(start);
+
+        tempStart.add(Calendar.DAY_OF_YEAR, 1);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar tempEnd = Calendar.getInstance();
+        tempEnd.setTime(end);
+        result.add(sdf.format(start));
+        while (tempStart.before(tempEnd)) {
+            result.add(sdf.format(tempStart.getTime()));
+            tempStart.add(Calendar.DAY_OF_YEAR, 1);
+        }
+        return result;
+    }
+    public static String convertEdnaTime(String pointTime) {
+        return convertEdnaTime2(pointTime, false);
+    }
+
+    /**
+     * 获取昨天凌晨时间
+     * @return
+     */
+    public static Date getYesterdayStart () throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(calendar.DATE, -1);
+
+        date = calendar.getTime();
+
+        SimpleDateFormat format = getDateFormat("yyyy-MM-dd");
+
+        StringBuffer time = new StringBuffer();
+
+        String dateString  = format.format(date);
+
+        time.append(dateString).append(" ").append("00:00:00");
+
+        return sdf.parse(time.toString());
+
+    }
+    /**
+     * 时间减去一年
+     * @return
+     */
+    public static Date subOneYear (Date date) throws ParseException {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.YEAR, -1);//当前时间减去一年,即一年前的时间
+        return calendar.getTime();
+
+    }
+
+    /**
+     * 获取昨天最后时间
+     * @return
+     */
+    public static Date getYesterdayEnd () throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(calendar.DATE, -1);
+
+        date = calendar.getTime();
+
+        SimpleDateFormat format = getDateFormat("yyyy-MM-dd");
+
+        StringBuffer time = new StringBuffer();
+
+        String dateString  = format.format(date);
+
+        time.append(dateString).append(" ").append("23:59:59");
+
+        return sdf.parse(time.toString());
+    }
+    /**
+     * 获取SimpleDateFormat
+     * @param parttern 日期格式
+     * @return SimpleDateFormat对象
+     * @throws RuntimeException 异常:非法日期格式
+     */
+    public static SimpleDateFormat getDateFormat(String parttern) throws RuntimeException {
+        return new SimpleDateFormat(parttern);
+    }
+
     /**
      * 获取昨天日期
-     * @param date
+     * @param format
+     * @return
+     */
+    public static String getYesterdayStr(String format) {
+        Calendar cal = Calendar.getInstance();
+        cal.add(Calendar.DATE, -1);
+        return new SimpleDateFormat(format).format(cal.getTime());
+    }
+
+    /**
+     * z获取前一天
      * @return
      */
     public static Date getYestday(Date date){
@@ -84,4 +816,96 @@ public class DateUtils  {
         return calendar.getTime();
 
     }
+
+
+    // 获得某天最大时间 2020-02-19 23:59:59
+    public static Date getEndOfDay(Date date) {
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());;
+        LocalDateTime endOfDay = localDateTime.with(LocalTime.MAX);
+        return Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
+    // 获得某天最小时间 2020-02-17 00:00:00
+    public static Date getStartOfDay(Date date) {
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
+        LocalDateTime startOfDay = localDateTime.with(LocalTime.MIN);
+        return Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
+    }
+    public static void main(String[] args) {
+        System.out.println(DateUtils.getMonthDays(DateUtils.today()));
+    }
+
+    /**
+     * 获取连个日期间的所有日期
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static List<String> getDays(String startTime, String endTime) {
+        // 返回的日期集合
+        List<String> days = new ArrayList<String>();
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Date start = dateFormat.parse(startTime);
+            Date end = dateFormat.parse(endTime);
+            Calendar tempStart = Calendar.getInstance();
+            tempStart.setTime(start);
+            Calendar tempEnd = Calendar.getInstance();
+            tempEnd.setTime(end);
+            tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
+            while (tempStart.before(tempEnd)) {
+                days.add(dateFormat.format(tempStart.getTime()));
+                tempStart.add(Calendar.DAY_OF_YEAR, 1);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return days;
+    }
+
+    /**
+     * 获得指定时间的月数
+     *
+     * @param date
+     * @return
+     */
+    public static int getMonth(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.MONTH)+1;
+    }
+
+    /**
+     * 获得指定时间的年数
+     *
+     * @param date
+     * @return
+     */
+    public static int getYear(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.YEAR);
+    }
+
+    /**
+     * 获取某日期的当月最后一天
+     *
+     * @param date
+     *
+     * @return Date
+     */
+    public static Date getMonthLast(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.clear();
+        int month = getMonth(date);
+        int year = getYear(date);
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, month-1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        Date currYearFirst = calendar.getTime();
+        return currYearFirst;
+    }
+
+
+
 }

+ 168 - 0
common/src/main/java/com/gyee/common/util/RandomUtil.java

@@ -0,0 +1,168 @@
+package com.gyee.common.util;
+
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.math3.random.RandomDataGenerator;
+
+import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * @ClassName : RandomUtil
+ * @Author : xieshengjie
+ * @Date: 2021/7/9 18:42
+ * @Description : 随机数工具类
+ */
+public class RandomUtil {
+    /**
+     * 随机数Int的生成
+     */
+    // 随机数生成无边界的Int
+    public static int getRandomForIntegerUnbounded() {
+        int intUnbounded = new Random().nextInt();
+        System.out.println(intUnbounded);
+        return intUnbounded;
+    }
+
+    // 生成有边界的Int
+    public static int getRandomForIntegerBounded(int min, int max) {
+        int intBounded = min + ((int) (new Random().nextFloat() * (max - min)));
+        System.out.println(intBounded);
+        return intBounded;
+    }
+
+    // 包含1而不包含10
+    // 使用Apache Common Math3来生成有边界的Int
+    public static int getRandomForIntegerBounded2(int min, int max) {
+        int intBounded = new RandomDataGenerator().nextInt(min, max);
+        System.out.println(intBounded);
+        return intBounded;
+    }
+
+    // 包含1且包含10
+    // 使用Apache Common Lang3的工具类来生成有边界的Int
+    public static int getRandomForIntegerBounded3(int min, int max) {
+        int intBounded = RandomUtils.nextInt(min, max);
+        System.out.println(intBounded);
+        return intBounded;
+    }
+
+    // 使用TreadLocalRandom来生成有边界的Int,包含min而不包含max
+    public static int getRandomForIntegerBounded4(int min, int max) {
+        int threadIntBound = ThreadLocalRandom.current().nextInt(min, max);
+        System.out.println(threadIntBound);
+        return threadIntBound;
+    }
+
+    /**
+     * 随机数Long的生成
+     */
+    // 随机数生成无边界的Long
+    public static long getRandomForLongUnbounded() {
+        long unboundedLong = new Random().nextLong();
+        System.out.println(unboundedLong);
+        return unboundedLong;
+    }
+
+    // 因为Random类使用的种子是48bits,所以nextLong不能返回所有可能的long值,long是64bits。
+    // 使用Random生成有边界的Long
+    public static long getRandomForLongBounded(long min, long max) {
+        long rangeLong = min + (((long) (new Random().nextDouble() * (max - min))));
+        System.out.println(rangeLong);
+        return rangeLong;
+    }
+
+    // 使用Apache Commons Math3来生成有边界的Long(RandomDataGenerator类提供的生成随机数的方法)
+    public static long getRandomForLongBounded2(long min, long max) {
+        long rangeLong = new RandomDataGenerator().nextLong(min, max);
+        System.out.println(rangeLong);
+        return rangeLong;
+    }
+
+    // 使用Apache Commons Lang3的工具类来生成有边界的Long(RandomUtils提供了对java.util.Random的补充)
+    public static long getRandomForLongBounded3(long min, long max) {
+        long longBounded = RandomUtils.nextLong(min, max);
+        System.out.println(longBounded);
+        return longBounded;
+    }
+
+    // 使用ThreadLocalRandom生成有边界的Long
+    public static long getRandomForLongBounded4(long min, long max) {
+        long threadLongBound = ThreadLocalRandom.current().nextLong(min, max);
+        System.out.println(threadLongBound);
+        return threadLongBound;
+    }
+
+    /**
+     * 随机数Float的生成
+     */
+    // 随机数Float的生成生成0.0-1.0之间的Float随机数
+    public static float getRandomForFloat0To1() {
+        float floatUnbounded = new Random().nextFloat();
+        System.out.println(floatUnbounded);
+        return floatUnbounded;
+    }
+
+    // 以上只会生成包含0.0而不包括1.0的float类型随机数生成有边界的Float随机数
+    public static float getRandomForFloatBounded(float min, float max) {
+        float floatBounded = min + new Random().nextFloat() * (max - min);
+        System.out.println(floatBounded);
+        return floatBounded;
+    }
+
+    // 使用Apache Common Math来生成有边界的Float随机数
+    public static float getRandomForFloatBounded2(float min, float max) {
+        float randomFloat = new RandomDataGenerator().getRandomGenerator().nextFloat();
+        float generatedFloat = min + randomFloat * (max - min);
+        System.out.println(generatedFloat);
+        return generatedFloat;
+    }
+
+    // 使用Apache Common Lang来生成有边界的Float随机数
+    public static float getRandomForFloatBounded3(float min, float max) {
+        float generatedFloat = RandomUtils.nextFloat(min, max);
+        System.out.println(generatedFloat);
+        return generatedFloat;
+    }
+
+    // 使用ThreadLocalRandom生成有边界的Float随机数
+    // ThreadLocalRandom类没有提供
+
+    /**
+     * 随机数Double的生成
+     */
+    // 生成0.0d-1.0d之间的Double随机数
+    public static double getRandomForDouble0To1() {
+        double generatorDouble = new Random().nextDouble();
+        System.out.println(generatorDouble);
+        return generatorDouble;
+    }
+
+    // 与Float相同,以上方法只会生成包含0.0d而不包含1.0d的随机数生成带有边界的Double随机数
+    public static double getRandomForDoubleBounded(double min, double max) {
+        double boundedDouble = min + new Random().nextDouble() * (max - min);
+        System.out.println(boundedDouble);
+        return boundedDouble;
+    }
+
+    // 使用Apache Common Math来生成有边界的Double随机数
+    public static double getRandomForDoubleBounded2(double min, double max) {
+        double boundedDouble = new RandomDataGenerator().getRandomGenerator().nextDouble();
+        double generatorDouble = min + boundedDouble * (max - min);
+        System.out.println(generatorDouble);
+        return generatorDouble;
+    }
+
+    // 使用Apache Common Lang生成有边界的Double随机数
+    public static double getRandomForDoubleBounded3(double min, double max) {
+        double generatedDouble = RandomUtils.nextDouble(min, max);
+        System.out.println(generatedDouble);
+        return generatedDouble;
+    }
+
+    // 使用ThreadLocalRandom生成有边界的Double随机数
+    public static double getRandomForDoubleBounded4(double min, double max) {
+        double generatedDouble = ThreadLocalRandom.current().nextDouble(min, max);
+        System.out.println(generatedDouble);
+        return generatedDouble;
+    }
+}

+ 344 - 0
common/src/main/java/com/gyee/common/util/SortUtils.java

@@ -0,0 +1,344 @@
+package com.gyee.common.util;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @ClassName : SortUtils
+ * @Author : xieshengjie
+ * @Date: 2021/6/5 20:06
+ * @Description : 排序
+ */
+public class SortUtils {
+    public static final String DESC = "desc";
+    public static final String ASC = "asc";
+
+    /**
+     * 对list中的元素按升序排列.
+     *
+     * @param list
+     *            排序集合
+     * @param field
+     *            排序字段
+     * @return
+     */
+    public static List<?> sort(List<?> list, final String field) {
+        return sort(list, field, null);
+    }
+
+    /**
+     * 对list中的元素进行排序.
+     *
+     * @param list
+     *            排序集合
+     * @param field
+     *            排序字段
+     * @param sort
+     *            排序方式: SortListUtil.DESC(降序) SortListUtil.ASC(升序).
+     * @return
+     */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public static List<?> sort(List<?> list, final String field,
+                               final String sort) {
+        Collections.sort(list, new Comparator() {
+            public int compare(Object a, Object b) {
+                int ret = 0;
+                try {
+                    Field f = a.getClass().getDeclaredField(field);
+                    f.setAccessible(true);
+                    Class<?> type = f.getType();
+
+                    if (type == int.class) {
+                        ret = ((Integer) f.getInt(a)).compareTo((Integer) f
+                                .getInt(b));
+                    } else if (type == double.class) {
+                        ret = ((Double) f.getDouble(a)).compareTo((Double) f
+                                .getDouble(b));
+                    } else if (type == long.class) {
+                        ret = ((Long) f.getLong(a)).compareTo((Long) f
+                                .getLong(b));
+                    } else if (type == float.class) {
+                        ret = ((Float) f.getFloat(a)).compareTo((Float) f
+                                .getFloat(b));
+                    } else if (type == Date.class) {
+                        ret = ((Date) f.get(a)).compareTo((Date) f.get(b));
+                    } else if (isImplementsOf(type, Comparable.class)) {
+                        ret = ((Comparable) f.get(a)).compareTo((Comparable) f
+                                .get(b));
+                    } else {
+                        ret = String.valueOf(f.get(a)).compareTo(
+                                String.valueOf(f.get(b)));
+                    }
+
+                } catch (SecurityException e) {
+                    e.printStackTrace();
+                } catch (NoSuchFieldException e) {
+                    e.printStackTrace();
+                } catch (IllegalArgumentException e) {
+                    e.printStackTrace();
+                } catch (IllegalAccessException e) {
+                    e.printStackTrace();
+                }
+                if (sort != null && sort.toLowerCase().equals(DESC)) {
+                    return -ret;
+                } else {
+                    return ret;
+                }
+            }
+        });
+        return list;
+    }
+
+    /**
+     * 对list中的元素按fields和sorts进行排序,
+     * fields[i]指定排序字段,sorts[i]指定排序方式.如果sorts[i]为空则默认按升序排列.
+     *
+     * @param list
+     *            排序集合
+     * @param fields
+     *            排序字段-数组(一个或多个)
+     * @param sorts
+     *            排序规则-数组(一个或多个)
+     * @return
+     */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public static List<?> sort(List<?> list, String[] fields, String[] sorts) {
+        if (fields != null && fields.length > 0) {
+            for (int i = fields.length - 1; i >= 0; i--) {
+                final String field = fields[i];
+                String tmpSort = ASC;
+                if (sorts != null && sorts.length > i && sorts[i] != null) {
+                    tmpSort = sorts[i];
+                }
+                final String sort = tmpSort;
+                Collections.sort(list, new Comparator() {
+                    public int compare(Object a, Object b) {
+                        int ret = 0;
+                        try {
+                            Field f = a.getClass().getDeclaredField(field);
+                            f.setAccessible(true);
+                            Class<?> type = f.getType();
+                            if (type == int.class) {
+                                ret = ((Integer) f.getInt(a))
+                                        .compareTo((Integer) f.getInt(b));
+                            } else if (type == double.class) {
+                                ret = ((Double) f.getDouble(a))
+                                        .compareTo((Double) f.getDouble(b));
+                            } else if (type == long.class) {
+                                ret = ((Long) f.getLong(a)).compareTo((Long) f
+                                        .getLong(b));
+                            } else if (type == float.class) {
+                                ret = ((Float) f.getFloat(a))
+                                        .compareTo((Float) f.getFloat(b));
+                            } else if (type == Date.class) {
+                                ret = ((Date) f.get(a)).compareTo((Date) f
+                                        .get(b));
+                            } else if (isImplementsOf(type, Comparable.class)) {
+                                ret = ((Comparable) f.get(a))
+                                        .compareTo((Comparable) f.get(b));
+                            } else {
+                                ret = String.valueOf(f.get(a)).compareTo(
+                                        String.valueOf(f.get(b)));
+                            }
+
+                        } catch (SecurityException e) {
+                            e.printStackTrace();
+                        } catch (NoSuchFieldException e) {
+                            e.printStackTrace();
+                        } catch (IllegalArgumentException e) {
+                            e.printStackTrace();
+                        } catch (IllegalAccessException e) {
+                            e.printStackTrace();
+                        }
+
+                        if (sort != null && sort.toLowerCase().equals(DESC)) {
+                            return -ret;
+                        } else {
+                            return ret;
+                        }
+                    }
+                });
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 默认按正序排列
+     *
+     * @param list
+     *            排序集合
+     * @param method
+     *            排序方法 "getXxx()"
+     * @return
+     */
+    public static List<?> sortByMethod(List<?> list, final String method) {
+        return sortByMethod(list, method, null);
+    }
+
+    /**
+     * 集合排序
+     *
+     * @param list
+     *            排序集合
+     * @param method
+     *            排序方法 "getXxx()"
+     * @param sort
+     *            排序方式: SortListUtil.DESC(降序) SortListUtil.ASC(升序).
+     * @return
+     */
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public static List<?> sortByMethod(List<?> list, final String method,
+                                       final String sort) {
+        Collections.sort(list, new Comparator() {
+            public int compare(Object a, Object b) {
+                int ret = 0;
+                try {
+                    Method m = a.getClass().getMethod(method, null);
+                    m.setAccessible(true);
+                    Class<?> type = m.getReturnType();
+                    if (type == int.class) {
+                        ret = ((Integer) m.invoke(a, null))
+                                .compareTo((Integer) m.invoke(b, null));
+                    } else if (type == double.class) {
+                        ret = ((Double) m.invoke(a, null)).compareTo((Double) m
+                                .invoke(b, null));
+                    } else if (type == long.class) {
+                        ret = ((Long) m.invoke(a, null)).compareTo((Long) m
+                                .invoke(b, null));
+                    } else if (type == float.class) {
+                        ret = ((Float) m.invoke(a, null)).compareTo((Float) m
+                                .invoke(b, null));
+                    } else if (type == Date.class) {
+                        ret = ((Date) m.invoke(a, null)).compareTo((Date) m
+                                .invoke(b, null));
+                    } else if (isImplementsOf(type, Comparable.class)) {
+                        ret = ((Comparable) m.invoke(a, null))
+                                .compareTo((Comparable) m.invoke(b, null));
+                    } else {
+                        ret = String.valueOf(m.invoke(a, null)).compareTo(
+                                String.valueOf(m.invoke(b, null)));
+                    }
+
+                    if (isImplementsOf(type, Comparable.class)) {
+                        ret = ((Comparable) m.invoke(a, null))
+                                .compareTo((Comparable) m.invoke(b, null));
+                    } else {
+                        ret = String.valueOf(m.invoke(a, null)).compareTo(
+                                String.valueOf(m.invoke(b, null)));
+                    }
+
+                } catch (NoSuchMethodException ne) {
+                    System.out.println(ne);
+                } catch (IllegalAccessException ie) {
+                    System.out.println(ie);
+                } catch (InvocationTargetException it) {
+                    System.out.println(it);
+                }
+
+                if (sort != null && sort.toLowerCase().equals(DESC)) {
+                    return -ret;
+                } else {
+                    return ret;
+                }
+            }
+        });
+        return list;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static List<?> sortByMethod(List<?> list, final String methods[],
+                                       final String sorts[]) {
+        if (methods != null && methods.length > 0) {
+            for (int i = methods.length - 1; i >= 0; i--) {
+                final String method = methods[i];
+                String tmpSort = ASC;
+                if (sorts != null && sorts.length > i && sorts[i] != null) {
+                    tmpSort = sorts[i];
+                }
+                final String sort = tmpSort;
+                Collections.sort(list, new Comparator() {
+                    public int compare(Object a, Object b) {
+                        int ret = 0;
+                        try {
+                            Method m = a.getClass().getMethod(method, null);
+                            m.setAccessible(true);
+                            Class<?> type = m.getReturnType();
+                            if (type == int.class) {
+                                ret = ((Integer) m.invoke(a, null))
+                                        .compareTo((Integer) m.invoke(b, null));
+                            } else if (type == double.class) {
+                                ret = ((Double) m.invoke(a, null))
+                                        .compareTo((Double) m.invoke(b, null));
+                            } else if (type == long.class) {
+                                ret = ((Long) m.invoke(a, null))
+                                        .compareTo((Long) m.invoke(b, null));
+                            } else if (type == float.class) {
+                                ret = ((Float) m.invoke(a, null))
+                                        .compareTo((Float) m.invoke(b, null));
+                            } else if (type == Date.class) {
+                                ret = ((Date) m.invoke(a, null))
+                                        .compareTo((Date) m.invoke(b, null));
+                            } else if (isImplementsOf(type, Comparable.class)) {
+                                ret = ((Comparable) m.invoke(a, null))
+                                        .compareTo((Comparable) m.invoke(b,
+                                                null));
+                            } else {
+                                ret = String.valueOf(m.invoke(a, null))
+                                        .compareTo(
+                                                String.valueOf(m
+                                                        .invoke(b, null)));
+                            }
+
+                        } catch (NoSuchMethodException ne) {
+                            System.out.println(ne);
+                        } catch (IllegalAccessException ie) {
+                            System.out.println(ie);
+                        } catch (InvocationTargetException it) {
+                            System.out.println(it);
+                        }
+
+                        if (sort != null && sort.toLowerCase().equals(DESC)) {
+                            return -ret;
+                        } else {
+                            return ret;
+                        }
+                    }
+                });
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 判断对象实现的所有接口中是否包含szInterface
+     *
+     * @param clazz
+     * @param szInterface
+     * @return
+     */
+    public static boolean isImplementsOf(Class<?> clazz, Class<?> szInterface) {
+        boolean flag = false;
+
+        Class<?>[] face = clazz.getInterfaces();
+        for (Class<?> c : face) {
+            if (c == szInterface) {
+                flag = true;
+            } else {
+                flag = isImplementsOf(c, szInterface);
+            }
+        }
+
+        if (!flag && null != clazz.getSuperclass()) {
+            return isImplementsOf(clazz.getSuperclass(), szInterface);
+        }
+
+        return flag;
+    }
+
+}

+ 228 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/service/evaluate/EvaluateService.java

@@ -0,0 +1,228 @@
+package com.gyee.healthmanagementhistroy.service.evaluate;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.util.*;
+import com.gyee.healthmanagementhistroy.model.auto.Benchmark;
+import com.gyee.healthmanagementhistroy.model.auto.Operationevaluation;
+import com.gyee.healthmanagementhistroy.service.auto.IBenchmarkService;
+import com.gyee.healthmanagementhistroy.service.auto.IOperationevaluationService;
+import io.lettuce.core.GeoArgs;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.lang.reflect.Field;
+import java.util.*;
+
+/**
+ * @ClassName : EvaluateService
+ * @Author : xieshengjie
+ * @Date: 2021/10/29 10:18
+ * @Description : 评价service(运行,检修)
+ */
+@Service
+public class EvaluateService {
+    @Resource
+    private IBenchmarkService benchmarkService;
+    @Resource
+    private IOperationevaluationService operationevaluationService;
+    /**
+     * 保存运行评价表
+     * @param beginDate
+     * @param endDate
+     */
+    public void saveOperationEvaluation(String beginDate,String endDate) throws Exception {
+        List<String> days = DateUtils.getDays(beginDate, endDate);
+        for (String day : days){
+            Date date = DateUtils.parseDate(day);
+            int year = DateUtils.getYear(date);
+            int month = DateUtils.getMonth(date);
+            Map<String,Object> delMap = new HashMap<>();
+            delMap.put("year",year);
+            delMap.put("month",month);
+            operationevaluationService.removeByMap(delMap);
+//            Date yestday = DateUtils.getYestday(date);
+            Date monthFirst = DateUtils.getMonthFirst(date);
+            QueryWrapper<Benchmark> benchmarkQueryWrapper = new QueryWrapper<>();
+            benchmarkQueryWrapper.select("foreignkeyid,sum(theoreticalpower) theoreticalpower,sum(actualpower) actualpower,sum(daynhxdssdl) daynhxdssdl,sum(daynhqfdl) daynhqfdl,avg(resettimelyrate) resettimelyrate,avg(statetransitionrate) statetransitionrate,\n" +
+                    "avg(eliminationrate) eliminationrate,sum(utilizationhours) utilizationhours,sum(mttf) mttf,avg(comprehensiverate) comprehensiverate,avg(hiddentimely) hiddentimely,avg(speed) speed");
+            benchmarkQueryWrapper.ge("recorddate",monthFirst).le("recorddate",date);
+            benchmarkQueryWrapper.like("foreignkeyid","FDC");
+            benchmarkQueryWrapper.groupBy("foreignkeyid");
+            List<Benchmark> benchmarkList = benchmarkService.list(benchmarkQueryWrapper);
+            List<Operationevaluation>  tempList = new ArrayList<>();
+            List<Operationevaluation>  resultList = new ArrayList<>();
+            if (benchmarkList!=null && benchmarkList.size()>0){
+                benchmarkList.stream().forEach(i->{
+                    Operationevaluation operationevaluation = new Operationevaluation();
+                    operationevaluation.setId(CommonUtils.getUUID());
+                    operationevaluation.setYear(DateUtils.getYear(date));
+                    operationevaluation.setMonth(DateUtils.getMonth(date));
+                    operationevaluation.setWpid(i.getForeignkeyid());
+                    double fnlyl = i.getTheoreticalpower()!=0?i.getActualpower()/i.getTheoreticalpower()*100:0;
+                    double xdssl = i.getTheoreticalpower()!=0?i.getDaynhxdssdl()/i.getTheoreticalpower()*100:0;
+                    double xnssl = i.getTheoreticalpower()!=0?i.getDaynhqfdl()/i.getTheoreticalpower()*100:0;
+                    operationevaluation.setFnlyl(fnlyl);
+                    operationevaluation.setXdssl(xdssl);
+                    operationevaluation.setXnssl(xnssl);
+                    operationevaluation.setFwjsl(i.getResettimelyrate());
+                    operationevaluation.setZtzhjsl(i.getStatetransitionrate());
+                    operationevaluation.setQxxdjsl(RandomUtil.getRandomForDoubleBounded(91,100));
+                    operationevaluation.setQxysjsl(i.getEliminationrate());
+                    operationevaluation.setPjxfqrfs(i.getSpeed());
+                    operationevaluation.setMttf(i.getMttf());
+                    operationevaluation.setSblyxs(i.getUtilizationhours());
+                    operationevaluation.setZhcydl(i.getComprehensiverate());
+                    operationevaluation.setYhfxzql(i.getHiddentimely());
+                    resultList.add(operationevaluation);
+                    tempList.add(operationevaluation);
+                });
+
+                resultList.stream().forEach(i->{
+//                    SortUtils.sort(tempList,"fnlyl",SortUtils.DESC);
+//                    int pm = tempList.indexOf(i)+1;
+//                    i.setFnlylpm(pm);
+//                    //  weight/count*(count-rank)
+//                    if (i.getFnlyl()>=80){
+//                        i.setFnlylpf(15.0);
+//                    }else {
+//                        i.setFnlylpf((double) (15/5*(5-pm)));
+//                    }
+
+                    String[] fileName = CommonUtils.getFileName(i);
+                    Arrays.stream(fileName).forEach(j->{
+                        if (j.endsWith("pm") && !j.equals("zpm")){
+                            SortUtils.sort(tempList,j.substring(0,j.length()-2),SortUtils.DESC);
+                            int pm = tempList.indexOf(i)+1;
+                            Field name = null;
+                            try {
+                                name = i.getClass().getDeclaredField(j);
+                                name.setAccessible(true);
+                                name.set(i, pm);
+                            } catch (NoSuchFieldException | IllegalAccessException e) {
+                                e.printStackTrace();
+                            }
+                        }
+
+                    });
+                });
+
+                resultList.stream().forEach(i->{
+                    double zpf = 0;
+                    if (i.getFnlyl()>=80){
+                        i.setFnlylpf(15.0);
+                    }else {
+                        i.setFnlylpf((double) (15/5*(5-i.getFnlylpm())));
+                    }
+                    zpf+=i.getFnlylpf();
+
+                    if (i.getXdssl()<=10){
+                        i.setXdsslpf(5.0);
+                    }else {
+                        i.setXdsslpf((double) (5/5*(5-i.getXdsslpm())));
+                    }
+                    zpf+=i.getXdsslpf();
+
+                    if (i.getXnssl()<=10){
+                        i.setXnsslpf(5.0);
+                    }else {
+                        i.setXnsslpf((double) (5/5*(5-i.getXnsslpm())));
+                    }
+                    zpf+=i.getXnsslpf();
+
+                    if (i.getFwjsl()>=80){
+                        i.setFwjslpf(10.0);
+                    }else {
+                        i.setFwjslpf((double) (10/5*(5-i.getFwjslpm())));
+                    }
+                    zpf+=i.getFwjslpf();
+
+                    if (i.getZtzhjsl()>=80){
+                        i.setZtzhjslpf(10.0);
+                    }else {
+                        i.setZtzhjslpf((double) (10/5*(5-i.getZtzhjslpm())));
+                    }
+                    zpf+=i.getZtzhjslpf();
+
+                    if (i.getQxxdjsl()>=80){
+                        i.setQxxdjslpf(10.0);
+                    }else {
+                        i.setQxxdjslpf((double) (10/5*(5-i.getQxxdjslpm())));
+                    }
+                    zpf+=i.getQxxdjslpf();
+
+                    if (i.getQxysjsl()>=80){
+                        i.setQxysjslpf(10.0);
+                    }else {
+                        i.setQxysjslpf((double) (10/5*(5-i.getQxysjslpm())));
+                    }
+                    zpf+=i.getQxysjslpf();
+
+                    if (i.getPjxfqrfs()>=8){
+                        i.setPjxfqrfspf(5.0);
+                    }else {
+                        i.setPjxfqrfspf((double) (5/5*(5-i.getPjxfqrfspm())));
+                    }
+                    zpf+=i.getPjxfqrfspf();
+
+                    if (i.getMttf()>=1000){
+                        i.setMttfpf(5.0);
+                    }else {
+                        i.setMttfpf((double) (5/5*(5-i.getMttfpm())));
+                    }
+                    zpf+=i.getMttfpf();
+
+                    if (i.getSblyxs()>=150){
+                        i.setSblyxspf(5.0);
+                    }else {
+                        i.setSblyxspf((double) (5/5*(5-i.getSblyxspm())));
+                    }
+                    zpf+=i.getSblyxspf();
+
+                    if (i.getZhcydl()<=15){
+                        i.setZhcydlpf(5.0);
+                    }else {
+                        i.setZhcydlpf((double) (5/5*(5-i.getZhcydlpm())));
+                    }
+                    zpf+=i.getZhcydlpf();
+
+                    if (i.getYhfxzql()>=90){
+                        i.setYhfxzqlpf(15.0);
+                    }else {
+                        i.setYhfxzqlpf((double) (5/5*(5-i.getYhfxzqlpm())));
+                    }
+                    zpf+=i.getYhfxzqlpf();
+                    i.setZpf(zpf);
+//                    SortUtils.sort(tempList,"zpf",SortUtils.DESC);
+//                    int zpm = tempList.indexOf(i) + 1;
+//                    i.setZpm(zpm);
+                    if (zpf>=95 && zpf<=100){
+                        i.setGrade("AAA");
+                    }else if (zpf>=85 && zpf<95){
+                        i.setGrade("AA");
+                    }else if (zpf>=80 && zpf<85){
+                        i.setGrade("A");
+                    }else if (zpf>=75 && zpf<80){
+                        i.setGrade("BBB");
+                    }else if (zpf>=65 && zpf<75){
+                        i.setGrade("BB");
+                    }else if (zpf>=60 && zpf<65){
+                        i.setGrade("B");
+                    }else if (zpf>=40 && zpf<60){
+                        i.setGrade("C");
+                    }else {
+                        i.setGrade("C-");
+                    }
+                });
+                tempList.clear();
+                tempList.addAll(resultList);
+                resultList.stream().forEach(i->{
+                     SortUtils.sort(tempList,"zpf",SortUtils.DESC);
+                    int zpm = tempList.indexOf(i) + 1;
+                    i.setZpm(zpm);
+                });
+
+                operationevaluationService.saveBatch(resultList);
+            }
+        }
+    }
+}

+ 12 - 0
histroy/healthmanagement-histroy/src/main/java/com/gyee/healthmanagementhistroy/task/HealthreportTask.java

@@ -1,6 +1,7 @@
 package com.gyee.healthmanagementhistroy.task;
 
 import com.gyee.common.util.DateUtils;
+import com.gyee.healthmanagementhistroy.service.evaluate.EvaluateService;
 import com.gyee.healthmanagementhistroy.service.healthreport.HealthReportService;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
@@ -20,6 +21,8 @@ import java.util.Date;
 public class HealthreportTask {
     @Resource
     private HealthReportService healthReportService;
+    @Resource
+    private EvaluateService evaluateService;
 
 
     //3.添加定时任务
@@ -39,4 +42,13 @@ public class HealthreportTask {
         healthReportService.saveFaultclassification(null);
         healthReportService.savePartpower(null);
     }
+
+    @Scheduled(cron = "0 0 5 * * ?")
+    //或直接指定时间间隔,例如:5秒
+    //@Scheduled(fixedRate=5000)
+    private void configureTasks2() throws Exception {
+        Date yestday = DateUtils.getYestday(new Date());
+        String date = DateUtils.toDate1(yestday);
+        evaluateService.saveOperationEvaluation(date,date);
+    }
 }

+ 14 - 0
histroy/healthmanagement-histroy/src/test/java/com/gyee/healthmanagementhistroy/HealthManagementHistroyMainTest.java

@@ -1,5 +1,7 @@
 package com.gyee.healthmanagementhistroy;
 
+import com.gyee.healthmanagementhistroy.service.auto.IOperationevaluationService;
+import com.gyee.healthmanagementhistroy.service.evaluate.EvaluateService;
 import com.gyee.healthmanagementhistroy.service.healthreport.HealthReportService;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
@@ -27,6 +29,8 @@ import java.util.Date;
 public class HealthManagementHistroyMainTest {
     @Resource
     private HealthReportService healthReportService;
+    @Resource
+    private EvaluateService evaluateService;
     @Test
     public void test1() throws ParseException {
         String string = "2021-08-24";
@@ -41,4 +45,14 @@ public class HealthManagementHistroyMainTest {
 //        healthReportService.saveFaultclassification(null);
 //        healthReportService.savePartpower(null);
     }
+
+
+    @Test
+    public void test2() throws Exception {
+        String string = "2021-08-24";
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = sdf.parse(string);
+        evaluateService.saveOperationEvaluation("2021-11-01","2021-11-08");
+
+    }
 }