浏览代码

更新版本,添加新的上报文件,更新超短期数据生成,预测数据查询界面添加选择超短期点位

wanghc 3 年之前
父节点
当前提交
f647ef4069

+ 763 - 0
ipfcst-common/ipfcst-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/TimeUtils.java

@@ -0,0 +1,763 @@
+package com.jiayue.ipfcst.common.core.util;
+
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by bqw on 14/11/19.
+ */
+public class TimeUtils {
+
+
+    /**
+     * 今日凌晨 毫秒
+     * @return
+     */
+    public static long getCurrentTime(){
+
+        Calendar c = Calendar.getInstance();
+
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 日期的增加月数
+     * add by xxl
+     * @param date     日期
+     * @param addMonth 增加的月数,正数表示增加,负数表示减少
+     * @return Date 日期的增加月数后的结果
+     */
+    public static Date addMonth(Date date, int addMonth) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.MONTH, addMonth);
+        return new Date(calendar.getTime().getTime());
+    }
+    public static Date addYear(Date date, int addYear) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.MONTH, addYear);
+        return new Date(calendar.getTime().getTime());
+    }
+
+
+    /**
+     * 日期的增加天数
+     * add by xxl
+     * @param date   日期
+     * @param addDay 增加的天数,正数表示增加,负数表示减少
+     * @return Date 日期的增加月数后的结果
+     */
+    public static Date addDay(Date date, int addDay) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH, addDay);
+        return new Date(calendar.getTime().getTime());
+    }
+
+    /**
+     * 获取输入日期所属月份第一天
+     * add by xxl
+     * @param date
+     * @return
+     */
+    public static Date getFirstDateMonth(Date date) {
+
+        if (date == null) {
+            return null;
+        }
+        Date newDate = null;
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int start = calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
+        calendar.set(Calendar.DAY_OF_MONTH, start);
+        newDate = new Date(calendar.getTime().getTime());
+        return newDate;
+    }
+    /**
+     * 获取输入日期所属月份最后一天
+     * add by xxl
+     * @param date
+     * @return
+     */
+    public static Date getLastDayOfMonth(Date date) {
+        if (date == null) {
+            return null;
+        }
+        Date newDate = null;
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int end = calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
+        calendar.set(Calendar.DAY_OF_MONTH, end);
+        newDate = new Date(calendar.getTime().getTime());
+        return newDate;
+    }
+
+    /**
+     * creat by linwb 20160908
+     * @param date
+     * @return
+     */
+
+    public static Date getFirstDateYear(Date date){
+        if (date == null) {
+            return null;
+        }
+        Date newDate = null;
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int start = calendar.getMinimum(Calendar.DAY_OF_YEAR);
+        calendar.set(Calendar.DAY_OF_YEAR,start);
+        newDate = new Date(calendar.getTime().getTime());
+        return newDate;
+    }
+    /**
+     *
+     */
+    public static Date getLastDayOfyear(Date date) {
+        if (date == null) {
+            return null;
+        }
+        Date newDate = null;
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int end = calendar.getActualMaximum(Calendar.DAY_OF_YEAR);
+        calendar.set(Calendar.DAY_OF_YEAR, end);
+        newDate = new Date(calendar.getTime().getTime());
+        return newDate;
+    }
+
+
+    /**
+     * 得到本季度第一天的日期
+     * @Methods Name getFirstDayOfQuarter
+     * @return Date
+     */
+    public static Date getFirstDayOfQuarter(Date date)   {
+        Calendar cDay = Calendar.getInstance();
+        cDay.setTime(date);
+        int curMonth = cDay.get(Calendar.MONTH);
+        if (curMonth >= Calendar.JANUARY && curMonth <= Calendar.MARCH){
+            cDay.set(Calendar.MONTH, Calendar.JANUARY);
+        }
+        if (curMonth >= Calendar.APRIL && curMonth <= Calendar.JUNE){
+            cDay.set(Calendar.MONTH, Calendar.APRIL);
+        }
+        if (curMonth >= Calendar.JULY && curMonth <= Calendar.AUGUST) {
+            cDay.set(Calendar.MONTH, Calendar.JULY);
+        }
+        if (curMonth >= Calendar.OCTOBER && curMonth <= Calendar.DECEMBER) {
+            cDay.set(Calendar.MONTH, Calendar.OCTOBER);
+        }
+        cDay.set(Calendar.DAY_OF_MONTH, cDay.getActualMinimum(Calendar.DAY_OF_MONTH));
+        System.out.println(cDay.getTime());
+        return cDay.getTime();
+    }
+
+    /**
+     * 得到本季度最后一天的日期
+     * @Methods Name getLastDayOfQuarter
+     * @return Date
+     */
+    public static Date getLastDayOfQuarter(Date date)   {
+        Calendar cDay = Calendar.getInstance();
+        cDay.setTime(date);
+        int curMonth = cDay.get(Calendar.MONTH);
+        if (curMonth >= Calendar.JANUARY && curMonth <= Calendar.MARCH){
+            cDay.set(Calendar.MONTH, Calendar.MARCH);
+        }
+        if (curMonth >= Calendar.APRIL && curMonth <= Calendar.JUNE){
+            cDay.set(Calendar.MONTH, Calendar.JUNE);
+        }
+        if (curMonth >= Calendar.JULY && curMonth <= Calendar.AUGUST) {
+            cDay.set(Calendar.MONTH, Calendar.AUGUST);
+        }
+        if (curMonth >= Calendar.OCTOBER && curMonth <= Calendar.DECEMBER) {
+            cDay.set(Calendar.MONTH, Calendar.DECEMBER);
+        }
+        cDay.set(Calendar.DAY_OF_MONTH, cDay.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return cDay.getTime();
+    }
+
+
+
+    public static void main(String[] args) throws Exception{
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
+
+//        Date date = addMonth(new Date(),1);
+//        System.out.println(DateFormatUtils.format(date.getTime(), "yyyyMM"));
+
+//        CronExpression cronExpression =new CronExpression("0 0 18 9 * ?");
+//        String str = cronExpression.getExpressionSummary();
+//        String crons = "{"+str.replaceAll("\n",",")+"}";
+//        JSONObject json = JSONUtil.parseObj(crons);
+//        String daysOfMonth = json.get("daysOfMonth").toString();
+//        System.out.println(daysOfMonth);
+//        System.out.println(cronExpression.getExpressionSummary());
+//        System.out.println(cronExpression.getFinalFireTime());
+
+
+//    	long ll=1467188298610l;
+//    	NumberFormat nf=NumberFormat.getInstance();
+//    	nf.setGroupingUsed(false);
+//    	System.out.println(""+nf.format(ll));
+//
+//    	String dd="1467188298610333";
+//    	BigDecimal bd=new BigDecimal(dd);
+//    	double dds=bd.doubleValue();
+//    	NumberFormat nf1 =NumberFormat.getInstance();
+//    	nf1.setGroupingUsed(false);
+//    	System.out.println(nf.format(dds));
+//
+//    	System.out.println(new Double("1467188298610333"));
+//    	String date = "2017-06-01";
+//    	getDateWithOutZero(date,"-");
+//    	String date = DateFormatUtils.format(Long.valueOf("1496214861000"), "yyyy/MM/dd");
+//    	String timed = date;
+//
+//        String date10 = date.substring(5, 7);
+//    	if(date10.compareTo("10") < 0)timed = date.substring(0,5) + date.substring(6, date.length());
+//    	else timed = date;
+//
+//    	if(timed.lastIndexOf("-") > 0){
+//    		int pos = timed.lastIndexOf("-");
+//    		String day = timed.substring(pos + 1,pos + 3);
+//    		if(day.compareTo("10") < 0)timed = timed.substring(0,pos + 1) + timed.substring(pos + 2, timed.length());
+//    	}
+//
+//
+//    	System.out.println(timed.toString());
+
+//    	String time10 = timel.substring(0, 2);
+//    	if(time10.compareTo("10") < 0)time10 = time10.substring(1,2);
+//
+//    	System.out.println(timel);
+//    	System.out.println(time10);
+//		Calendar cal = Calendar.getInstance();
+//		int current = 0;
+//		int suff = 0;
+//		long time = System.currentTimeMillis();
+//		cal.setTimeInMillis(Long.valueOf("1456120500000"));
+//		int currentMinute = cal.get(Calendar.MINUTE);
+//		current = currentMinute % 15;
+//		suff = currentMinute / 15;
+//		if (current < 4) {
+//			// 存储period的整数值
+//			cal.set(Calendar.MINUTE, suff * 15);
+//			// 赋值
+//		    time = cal.getTimeInMillis();
+//		}
+//		System.out.println(DateFormatUtils.format(time, "yyyy-MM-dd HH:mm:ss"));
+    }
+
+
+    /**
+     * 描述:获取int型的4位年和月
+     * 参数:
+     * 返回: Map<String,Integer>
+     * 创建时间:2016-11-07
+     * 作者: chendi
+     */
+    public static Map<String,Integer> getCurrenYearAndMonth(){
+        Map<String,Integer> result = new HashMap();
+        Date d = new Date();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
+        String year = simpleDateFormat.format(d);
+        simpleDateFormat.applyPattern("MM");
+        String month = simpleDateFormat.format(d);
+        result.put("year", Integer.parseInt(year));
+        result.put("month", Integer.parseInt(month));
+        return result;
+    }
+
+    /**
+     * 描述:获取一个月的开始时间和结束时间(1日零点、最后一天23点59分59秒)
+     * 参数:year month 传入年月则按照该年月计算起始,传入空则取当前时间接
+     * 返回: Map<String,Long> key:"startTime" "endTime"
+     * 创建时间:2016-11-07
+     * 作者: chendi
+     */
+    public static Map<String,Long> getCurrentMonthStartTimeAndEndTime(){
+        return getMonthStartTimeAndEndTime(null,null);
+    }
+    public static Map<String,Long> getMonthStartTimeAndEndTime(Integer year,Integer month){
+        Map<String,Long> result = new HashMap();
+        Calendar cal = Calendar.getInstance();
+        if(year!=null){
+            cal.set(Calendar.YEAR,year);
+        }
+        if(month!=null){
+            cal.set(Calendar.MONTH,month - 1);
+        }
+        cal.set(Calendar.HOUR_OF_DAY,0);
+        cal.set(Calendar.MINUTE,0);
+        cal.set(Calendar.SECOND,0);
+        Date firstDay = getFirstDateMonth(cal.getTime());
+        Date nextMonth = TimeUtils.addMonth(firstDay, 1);
+        nextMonth = getFirstDateMonth(nextMonth);
+        result.put("startTime",firstDay.getTime());
+        result.put("endTime",nextMonth.getTime()-1*1000);
+        return result;
+    }
+
+
+
+    /**
+     * 判断时间是否在时间段内
+     *
+     * @param date
+     *            当前时间 yyyy-MM-dd HH:mm:ss
+     * @param strDateBegin
+     *            开始时间 00:00:00
+     * @param strDateEnd
+     *            结束时间 00:05:00
+     * @return
+     */
+    public static boolean isInDate(Date date, String strDateBegin,
+                                   String strDateEnd) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String strDate = sdf.format(date);
+        //System.out.println(strDate);
+        // 截取当前时间时分秒
+        int strDateH = Integer.parseInt(strDate.substring(11, 13));
+        int strDateM = Integer.parseInt(strDate.substring(14, 16));
+        int strDateS = Integer.parseInt(strDate.substring(17, 19));
+        //System.out.println("strDateH:"+strDateH+"|strDateM:"+strDateM+"|strDateS:"+strDateS);
+        // 截取开始时间时分秒
+        int strDateBeginH = Integer.parseInt(strDateBegin.substring(11, 13));
+        int strDateBeginM = Integer.parseInt(strDateBegin.substring(14, 16));
+        int strDateBeginS = Integer.parseInt(strDateBegin.substring(17, 19));
+        //System.out.println("strDateBeginH:"+strDateBeginH+"|strDateBeginM:"+strDateBeginM+"|strDateBeginS:"+strDateBeginS);
+
+        // 截取结束时间时分秒
+        int strDateEndH = Integer.parseInt(strDateEnd.substring(11, 13));
+        int strDateEndM = Integer.parseInt(strDateEnd.substring(14, 16));
+        int strDateEndS = Integer.parseInt(strDateEnd.substring(17, 19));
+        //System.out.println("strDateEndH:"+strDateEndH+"|strDateEndM:"+strDateEndM+"|strDateEndS:"+strDateEndS);
+
+        if ((strDateH >= strDateBeginH && strDateH <= strDateEndH)) {
+            //System.out.println("strDateEndH1:");
+
+            // 当前时间小时数在开始时间和结束时间小时数之间
+            if (strDateH > strDateBeginH && strDateH < strDateEndH) {
+
+                return true;
+                // 当前时间小时数等于开始时间小时数,分钟数在开始和结束之间
+            } else if (strDateH == strDateBeginH && strDateM >= strDateBeginM
+                    && strDateM <= strDateEndM) {
+                //System.out.println("strDateEndH2:");
+
+                return true;
+                // 当前时间小时数等于开始时间小时数,分钟数等于开始时间分钟数,秒数在开始和结束之间
+            } else if (strDateH == strDateBeginH && strDateM == strDateBeginM
+                    && strDateS >= strDateBeginS && strDateS <= strDateEndS) {
+                return true;
+            }
+            // 当前时间小时数大等于开始时间小时数,等于结束时间小时数,分钟数小等于结束时间分钟数
+            else if (strDateH >= strDateBeginH && strDateH == strDateEndH
+                    && strDateM <= strDateEndM) {
+                return true;
+                // 当前时间小时数大等于开始时间小时数,等于结束时间小时数,分钟数等于结束时间分钟数,秒数小等于结束时间秒数
+            } else return strDateH >= strDateBeginH && strDateH == strDateEndH
+                    && strDateM == strDateEndM && strDateS <= strDateEndS;
+        } else {
+            return false;
+        }
+    }
+
+
+
+    /**
+     * 根据type获取两日期差
+     * @param start 开始时间
+     * @param end 结束时间
+     * @param type days表示相差天数 hours小时数 minutes分钟数
+     * @return 返回int,未设置type则返回0
+     */
+    public static int getDateDiffer(Date start,Date end,String type){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        String startDate = sdf.format(start);
+        String endDate = sdf.format(end);
+        try {
+            long from = sdf.parse(startDate).getTime();
+            long to = sdf.parse(endDate).getTime();
+
+            if (type.equals("days")){ // 返回相差天数
+                int days = (int) ((to - from)/(1000 * 60 * 60 * 24));
+                return days;
+            } else if (type.equals("hours")){ // 返回相差小时数
+                int hours = (int) ((to - from)/(1000 * 60 * 60));
+                return hours;
+            } else if (type.equals("minutes")){ // 返回相差分钟数
+                int minutes = (int) ((to - from)/(1000 * 60));
+                return minutes;
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
+	/**
+	 * 修改时间为不包含0的数据,格式必须报分隔符
+	 * @Title: getDateWithOutZero
+	 * @Description: TODO
+	 * @param date
+	 */
+	public static String getDateWithOutZero(String date,String split) {
+		String timed = date;
+		String date10 = date.substring(5, 7);
+		if(date10.compareTo("10") < 0)timed = date.substring(0,5) + date.substring(6, date.length());
+		else timed = date;
+
+		if(timed.lastIndexOf(split) > 0){
+			int pos = timed.lastIndexOf(split);
+			String day = timed.substring(pos + 1,pos + 3);
+			if(day.compareTo("10") < 0)timed = timed.substring(0,pos + 1) + timed.substring(pos + 2, timed.length());
+		}
+		System.out.println(timed);
+		return timed;
+	}
+
+   	/**
+   	 * 获取当前时间的后一天时间
+   	 *
+   	 * @param date
+   	 */
+	public static Date getAfterDay(Date date) {
+           Calendar calendar = Calendar.getInstance();
+           calendar.setTime(date);
+           calendar.add(Calendar.DAY_OF_MONTH, +1);
+           date = calendar.getTime();
+   		return date;
+   	}
+   	/**
+   	 * 获取时间的前一天时间
+   	 *
+   	 * @param date
+   	 */
+	public static Date getBeforeDay(Date date) {
+           Calendar calendar = Calendar.getInstance();
+           calendar.setTime(date);
+           calendar.add(Calendar.DAY_OF_MONTH, -1);
+           date = calendar.getTime();
+   		return date;
+   	}
+
+
+
+//   ----------------------------------------------------------------------------------------------------------------
+//    bizy添加时间工具
+    /**
+     * 时间戳转日期(传过来的参数没除1000)
+     * @param ms
+     * @return
+     */
+    public static String transForDateShort(Long ms){
+        String str = "";
+        if(ms!=null){
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+            if(ms!=null){
+                try {
+                    str=sdf.format(ms);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return str;
+    }
+
+    /**
+     * 时间戳转日期(传过来的参数没除1000)
+     * @param ms
+     * @return
+     */
+    public static String transForDate(Long ms){
+        String str = "";
+        if(ms!=null){
+            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            if(ms!=null){
+                try {
+                    str=sdf.format(ms);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return str;
+    }
+    /**
+     * 获取现在时间
+     *
+     * @return 返回时间类型 yyyy-MM-dd HH:mm:ss
+     */
+    public static Date getNowDate() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(currentTime);
+        ParsePosition pos = new ParsePosition(0);
+        Date currentTime_2 = formatter.parse(dateString, pos);
+        return currentTime_2;
+    }
+
+    /**
+     * 获取现在时间
+     *
+     * @return返回短时间格式 yyyy-MM-dd
+     */
+    public static Date getNowDateShort() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(currentTime);
+        ParsePosition pos = new ParsePosition(0);
+        Date currentTime_2 = formatter.parse(dateString, pos);
+        return currentTime_2;
+    }
+
+    /**
+     * 获取现在时间
+     *
+     * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
+     */
+    public static String getStringDate() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 获取现在时间
+     *
+     * @return 返回短时间字符串格式yyyy-MM-dd
+     */
+    public static String getStringDateShort() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 获取当日凌晨时间
+     *
+     * @return 返回短时间字符串格式yyyy-MM-dd
+     */
+    public static String getStringDateShortLc(Date currentTime) {
+//        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 获取现在时间
+     *
+     * @return 返回短时间字符串格式yyyy-MM-dd
+     */
+    public static String getStringDateShortYM() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 获取时间 小时:分;秒 HH:mm:ss
+     *
+     * @return
+     */
+    public static String getTimeShort() {
+        SimpleDateFormat formatter = new SimpleDateFormat("HHmmss");
+        Date currentTime = new Date();
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
+     *
+     * @param strDate
+     * @return
+     */
+    public static Date strToDateLong(String strDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        ParsePosition pos = new ParsePosition(0);
+        Date strtodate = formatter.parse(strDate, pos);
+        return strtodate;
+    }
+
+    /**
+     * 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
+     *
+     * @param strDate
+     * @return
+     */
+    public static Date strToDateLongHM(String strDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
+        ParsePosition pos = new ParsePosition(0);
+        Date strtodate = formatter.parse(strDate, pos);
+        return strtodate;
+    }
+
+    /**
+     * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
+     *
+     * @param dateDate
+     * @return
+     */
+    public static String dateToStrLong(Date dateDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(dateDate);
+        return dateString;
+    }
+
+    /**
+     * 将短时间格式时间转换为字符串 yyyy-MM-dd
+     *
+     * @param dateDate
+     * @param
+     * @return
+     */
+    public static String dateToStr(Date dateDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(dateDate);
+        return dateString;
+    }
+
+    /**
+     * 将短时间格式字符串转换为时间 yyyy-MM-dd
+     *
+     * @param strDate
+     * @return
+     */
+    public static Date strToDate(String strDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        ParsePosition pos = new ParsePosition(0);
+        Date strtodate = formatter.parse(strDate, pos);
+        return strtodate;
+    }
+
+    /**
+     * 得到现在时间
+     *
+     * @return
+     */
+    public static Date getNow() {
+        Date currentTime = new Date();
+        return currentTime;
+    }
+
+    /**
+     * 提取一个月中的最后一天
+     *
+     * @param day
+     * @return
+     */
+    public static Date getLastDate(long day) {
+        Date date = new Date();
+        long date_3_hm = date.getTime() - 3600000 * 34 * day;
+        Date date_3_hm_date = new Date(date_3_hm);
+        return date_3_hm_date;
+    }
+
+    /**
+     * 得到现在时间
+     *
+     * @return 字符串 yyyyMMdd HHmmss
+     */
+    public static String getStringToday() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+
+    /**
+     * 得到现在月份
+     *
+     * @return 字符串 yyyyMMdd HHmmss
+     */
+    public static String getStringTodayMonth() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
+        String dateString = formatter.format(currentTime);
+        String month;
+        month = dateString.substring(4, 6);
+        return month;
+    }
+
+
+    /**
+     * 得到现在小时
+     */
+    public static String getHour() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(currentTime);
+        String hour;
+        hour = dateString.substring(11, 13);
+        return hour;
+    }
+
+    /**
+     * 得到现在分钟
+     *
+     * @return
+     */
+    public static String getTime() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(currentTime);
+        String min;
+        min = dateString.substring(14, 16);
+        return min;
+    }
+
+    /**
+     * 根据用户传入的时间表示格式,返回当前时间的格式 如果是yyyyMMdd,注意字母y不能大写。
+     *
+     * @param sformat yyyyMMddhhmmss
+     * @return
+     */
+    public static String getUserDate(String sformat) {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat(sformat);
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 获得指定日期的前一天
+     * @param specifiedDay
+     * @return
+     * @throws Exception
+     */
+    public static String getSpecifiedDayBefore(String specifiedDay){
+//SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        Date date=null;
+        try {
+            date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        c.setTime(date);
+        int day=c.get(Calendar.DATE);
+        c.set(Calendar.DATE,day-1);
+
+        String dayBefore=new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+        return dayBefore;
+    }
+
+}

+ 2 - 1
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/constant/enums/FileTypeEnum.java

@@ -155,7 +155,8 @@ public enum FileTypeEnum {
 	E117(117,"贵州总调超短期"),
 
 	E118(118,"贵州总调气象站"),
-	E119(119,"贵州总调逆变器");
+	E119(119,"贵州总调逆变器"),
+	E158(158,"青海新电量预测");
 	private Integer code;
 	private String message;
 

+ 56 - 4
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/service/uploadfilerule/E63UploadFileRuleService.java

@@ -1,18 +1,21 @@
 package com.jiayue.ipfcst.common.data.service.uploadfilerule;
 
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
+import com.jiayue.ipfcst.common.core.util.TimeUtils;
 import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.SysParameter;
 import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
 import org.apache.commons.lang.time.DateFormatUtils;
 import org.apache.commons.lang.time.DateUtils;
+import org.quartz.CronExpression;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.text.ParseException;
+import java.util.*;
 
 /**
  * 青海文件规则
@@ -430,6 +433,51 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 fileName = getFileNameRule(electricFieldInfo, "E41", startTime);
                 shouldFileNameList.add(fileName);
                 break;
+            case "E158":
+                // 未来12个月预测发电量
+                CronExpression cronExpression = null;
+                try {
+                    cronExpression = new CronExpression(cronStr);
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                // cron表达式日期
+                String str = cronExpression.getExpressionSummary();
+                String tempCron = "{"+str.replaceAll("\n",",")+"}";
+                JSONObject json = JSONUtil.parseObj(tempCron);
+                String cronDaysOfMonth = json.get("daysOfMonth").toString();
+
+                // 参数日期
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(date);
+                int paramDayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
+                if (paramDayOfMonth==Integer.parseInt(cronDaysOfMonth)){
+                    Date culDate = DateTimeUtil.getDayStartTime(currentDate.getTime());
+                    Date tempDate = DateTimeUtil.getDayStartTime(date.getTime());
+                    if (culDate.getTime()==tempDate.getTime()){
+                        // 当天
+                        String cronHours = json.get("hours").toString();
+                        String cronMinutes = json.get("minutes").toString();
+                        String cronSeconds = json.get("seconds").toString();
+                        Calendar newDate = Calendar.getInstance();
+                        newDate.setTimeInMillis(new Date().getTime());
+                        newDate.set(Calendar.HOUR_OF_DAY, Integer.parseInt(cronHours));
+                        newDate.set(Calendar.MINUTE, Integer.parseInt(cronMinutes));
+                        newDate.set(Calendar.SECOND, Integer.parseInt(cronSeconds));
+                        if (currentDate.getTime()>newDate.getTimeInMillis()){
+                            Date fileTime = TimeUtils.addMonth(date,1);
+                            fileName = getFileNameRule(electricFieldInfo, "E158", fileTime.getTime());
+                            shouldFileNameList.add(fileName);
+                            break;
+                        }
+                    }
+                    else{
+                        Date fileTime = TimeUtils.addMonth(date,1);
+                        fileName = getFileNameRule(electricFieldInfo, "E158", fileTime.getTime());
+                        shouldFileNameList.add(fileName);
+                        break;
+                    }
+                }
             default:
                 break;
         }
@@ -548,6 +596,10 @@ public class E63UploadFileRuleService extends UploadFileRuleCommonService implem
                 // 理论功率
                 fileName = electricFieldInfo.getSign() + "_" + DateFormatUtils.format(fileNameTime, "yyyyMMdd_HHmm") + "_THEROY.PVD";
                 break;
+            case "E158":
+                // 青海新电量预测
+                fileName = electricFieldInfo.getSign() + "_" + DateFormatUtils.format(fileNameTime, "yyyyMM") + "_DL.PVD";
+                break;
             default:
                 break;
         }

+ 46 - 4
ipfcst-console/src/main/frontend/views/dataquery/forecastPowerUltraShortTerm16/index.vue

@@ -29,6 +29,15 @@
           value-format="timestamp"
           placeholder="选择日期">
         </el-date-picker>
+        <span style="font-weight: bold;font-size: 14px">超短期预测点位:</span>
+        <el-select style="width:250px" clearable v-model="cdqQueryPoint" size="small">
+          <el-option
+            v-for="item in cdqPoint"
+            :key="item.label"
+            :label="item.value"
+            :value="item.label">
+          </el-option>
+        </el-select>
         <el-button :loading=loading size="small" @click="dateQuery">查询</el-button>
       </div>
       <div class="toolbar" v-show="this.showToolBar"> <vxe-toolbar ref="fstToolBar" custom >
@@ -92,6 +101,40 @@ export default {
   mixins: [resize],
   data(){
     return{
+      cdqPoint: [{
+        value: 1,
+        label: '1'}, {
+        value: 2,
+        label: '2'}, {
+        value: 3,
+        label: '3'}, {
+        value: 4,
+        label: '4'}, {
+        value: 5,
+        label: '5'}, {
+        value: 6,
+        label: '6'}, {
+        value: 7,
+        label: '7'}, {
+        value: 8,
+        label: '8'}, {
+        value: 9,
+        label: '9'}, {
+        value: 10,
+        label: '10'}, {
+        value: 11,
+        label: '11'}, {
+        value: 12,
+        label: '12'}, {
+        value: 13,
+        label: '13'}, {
+        value: 14,
+        label: '14'}, {
+        value: 15,
+        label: '15'}, {
+        value: 16,
+        label: '16'}],
+      cdqQueryPoint:16,
       outer:'outer',
       chart: null,
       queryStartTime:'',
@@ -142,10 +185,10 @@ export default {
       // this.getTable()
 
     },*/
-    getDraw(startTime,endTime,stationCode){
+    getDraw(startTime,endTime,stationCode,cdqQueryPoint){
       this.drawLoading = true
 
-      this.$axios.get('/ForecastDataComparison/'+startTime+'/'+endTime+'/'+stationCode).then((res) => {
+      this.$axios.get('/ForecastDataComparison/'+startTime+'/'+endTime+'/'+stationCode+'/'+cdqQueryPoint).then((res) => {
         const value = res.data
         this.tableData = []
         console.log(res.data.time.length)
@@ -158,7 +201,6 @@ export default {
           temp.value3 = value.dq[i]
           this.tableData.push(temp)
         }
-        console.log(this.tableData)
         this.loading = false
         this.drawData = res.data
         this.drawLoading = false
@@ -231,7 +273,7 @@ export default {
       // }
       this.queryStartTime = this.startTime
       // this.queryEndTime = this.endTime
-      this.getDraw(this.queryStartTime,this.endTime,this.stationCode)
+      this.getDraw(this.queryStartTime,this.endTime,this.stationCode,this.cdqQueryPoint)
       // this.getTable()
     },
     Byresize(tab){

+ 5 - 3
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/PowerStationStatusDataController.java

@@ -121,14 +121,16 @@ return null;
    * @param startTime 开始时间
    * @param endTime 结束时间
    * @param stationCode 场站编号
+   * @param cdqQueryPoint 超短期查询点位
    * @return
    */
-  @GetMapping(value = "/ForecastDataComparison/{startTime}/{endTime}/{stationCode}")
+  @GetMapping(value = "/ForecastDataComparison/{startTime}/{endTime}/{stationCode}/{cdqQueryPoint}")
   public ResponseVO ForecastDataComparison(@PathVariable("startTime") Long startTime,
                                            @PathVariable("endTime") Long endTime,
-                                           @PathVariable("stationCode") String stationCode){
+                                           @PathVariable("stationCode") String stationCode,
+                                           @PathVariable("cdqQueryPoint") Integer cdqQueryPoint){
     try {
-      Map<String, Object> map=  powerStationStatusDataService.findForecastDataComparison(startTime,endTime,stationCode);
+      Map<String, Object> map=  powerStationStatusDataService.findForecastDataComparison(startTime,endTime,stationCode,cdqQueryPoint);
       return ResponseVO.success(map);
     }catch (Exception e){
       e.printStackTrace();

+ 7 - 11
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerUltraShortTermService.java

@@ -219,16 +219,14 @@ public class ForecastPowerUltraShortTermService extends BaseService {
         String stationCode = electricField.getStationCode();
         // 根据场站类型执行相应超短期预测
         try {
-          // 获取查询时间,从当前时间所处时间点标记时间开始查询,截至到96个时间点对应的标记时间
-          String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0", stationCode);
+          String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0",stationCode);
           Long calTime = DateMomentUtil.getMomentTime(System.currentTimeMillis() + Integer.parseInt(cdqUpMin) * 1000 * 60, 1, 15 * 60 * 1000L);
           Long startTime = calTime + 15 * 1000 * 60L;
-          String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16", stationCode);
+          String llcdq_point = super.getSysParameter("FILE_LLCDQ_POINT", "16",stationCode);
           Integer forecastPoints = Integer.parseInt(llcdq_point);
           Integer forecastMinutes = forecastPoints * 15;
           // 结束时间增加15分钟为了防止文件先生成,实时表中最后一个时间点没有点位的问题
-          Long endTime = DateUtils.addMinutes(new Date(startTime), forecastMinutes).getTime() + 1000 * 60 * 15L;
-
+          Long endTime = DateUtils.addMinutes(new Date(startTime), forecastMinutes).getTime();
           // 查询该时间段内的短期预测功率
           List<ForecastPowerShortTerm> forecastPowerShortTermList = this.forecastPowerShortTermRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
           Map<Long, List<ForecastPowerShortTerm>> forecastPowerShortTermsMap =
@@ -306,8 +304,6 @@ public class ForecastPowerUltraShortTermService extends BaseService {
     } catch (Exception e) {
       log.error("获取当前时刻错误", e);
     }
-    String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16", stationCode);
-    Integer forecastPoints = Integer.parseInt(llcdq_point);
     if (filterList.size() > 0) {
       // 获取当前时刻对应的短期
       List<ForecastPowerShortTerm> currentForecastPowerShortTermList;
@@ -315,7 +311,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       try {
         Long currentMoment = DateMomentUtil.getMomentTime(currentTime.getTime(), 1, 15 * 60 * 1000L);
         currentForecastPowerShortTermList = this.forecastPowerShortTermRepository.findByForecastTimeBetweenAndStationCode(currentMoment, currentMoment, stationCode);
-        if (currentForecastPowerShortTermList.size() <= 0) {
+        if (currentForecastPowerShortTermList.size() > 0) {
           currentForecastPowerValue = currentForecastPowerShortTermList.get(0).getFpValue();
         } else {
           // 当前时间没有对应的短期,用实际功率最近的一个替换
@@ -330,7 +326,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       BigDecimal averageAbleValue = sumAbleValue.divide(new BigDecimal(filterList.size()), 2, RoundingMode.HALF_UP);
       //可用-短期差值
       BigDecimal deviationValue = averageAbleValue.subtract(currentForecastPowerValue);
-      for (int i = 0; i < forecastPoints; i++) {
+      for (int i = 0; i < forecastPowerShortTermList.size(); i++) {
         forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
         forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTermList.get(i).getForecastTime());
         forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
@@ -376,7 +372,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       log.info(stationCode + "库中没有可用,本次可用计算数据采用短期*系数的方式生成数据");
 
       // 短期乘以系数
-      for (int i = 0; i < forecastPoints; i++) {
+      for (int i = 0; i < forecastPowerShortTermList.size(); i++) {
         stPower = forecastPowerShortTermList.get(i).getFpValue();
         ustPower = stPower.multiply(new BigDecimal(coe)).setScale(2, RoundingMode.HALF_UP);
         forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
@@ -391,7 +387,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       }
     }
     // 保存超短期预测结果
-    this.forecastPowerUltraShortTermRepository.deleteByForecastTimeBetweenAndStationCode(forecastPowerUltraShortTermList.get(0).getForecastTime(), forecastPowerUltraShortTermList.get(forecastPoints - 1).getForecastTime(), stationCode);
+    this.forecastPowerUltraShortTermRepository.deleteByForecastTimeBetweenAndStationCode(forecastPowerUltraShortTermList.get(0).getForecastTime(), forecastPowerUltraShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime(), stationCode);
     this.forecastPowerUltraShortTermRepository.saveAll(forecastPowerUltraShortTermList);
 
   }

+ 2 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationStatusDataService.java

@@ -396,10 +396,10 @@ public class PowerStationStatusDataService extends BaseService {
   }
 
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public Map<String, Object> findForecastDataComparison(Long startTime, Long endTime, String stationCode) {
+  public Map<String, Object> findForecastDataComparison(Long startTime, Long endTime, String stationCode,Integer cdqQueryPoint) {
     List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(startTime),new Date(endTime),stationCode);
     List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = forecastPowerShortTermHisRepository.findByForecastTimeBetweenAndStationCodeAndForecastHowLongAgo(startTime,endTime,stationCode, 1);
-    List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList =forecastPowerUltraShortTermHisRepository.findByForecastTimeBetweenAndStationCodeAndForecastHowLongAgo(startTime,endTime,stationCode,1);
+    List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList =forecastPowerUltraShortTermHisRepository.findByForecastTimeBetweenAndStationCodeAndForecastHowLongAgo(startTime,endTime,stationCode,cdqQueryPoint);
     Map<String, Object> map = new HashMap<>();
     Map<Long, BigDecimal> cdqMap = new HashMap<>();
     for (ForecastPowerUltraShortTermHis forecastPowerUltraShortTermHis : forecastPowerUltraShortTermList) {

+ 27 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/job/UploadFileE158Job.java

@@ -0,0 +1,27 @@
+package com.jiayue.ipfcst.fileupload.job;
+
+import com.jiayue.ipfcst.common.data.job.BaseJob;
+import com.jiayue.ipfcst.fileupload.service.E63UploadFileService;
+import org.quartz.JobDataMap;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 可用超短期生成任务
+ *
+ * @author whc
+ * @version 3.0
+ * @since 2020/4/15 9:16
+ */
+@Service
+public class UploadFileE158Job extends BaseJob {
+  @Autowired
+  E63UploadFileService e63UploadFileService;
+
+  @Override
+  public boolean execute(JobDataMap jobDataMap) {
+    e63UploadFileService.generateE158File(null);
+    return true;
+  }
+}
+

+ 82 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java

@@ -1,9 +1,11 @@
 package com.jiayue.ipfcst.fileupload.service;
 
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
+import com.jiayue.ipfcst.common.core.util.TimeUtils;
 import com.jiayue.ipfcst.common.data.abst.equipmentinfo.AbstractEquipmentInfo;
 import com.jiayue.ipfcst.common.data.constant.enums.AlarmTypeEnum;
 import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
@@ -94,7 +96,85 @@ public class E63UploadFileService extends BaseUploadFileService {
     this.redisUtils = redisUtils;
     this.sysAlarmService = sysAlarmService;
   }
-
+  /**
+   * 青海新电量预测
+   */
+  public void generateE158File(Date date) {
+    VelocityContext velocityContext;
+    StringWriter writer;
+    String fileName;
+    File file;
+    List<ElectricField> electricFieldList = new ArrayList<>();
+    try {
+      electricFieldList = super.getMultipleStation();
+    } catch (BusinessException e) {
+      log.error("场站获取失败", e);
+    }
+    // 获取当前系统时间
+    Date systemDate = new Date();
+    if (date != null) {
+      systemDate = date;
+    }
+    try {
+      // 生成上报文件名格式
+      Date fileTime = TimeUtils.addMonth(systemDate,0);
+      for (ElectricField electricFieldInfo : electricFieldList) {
+        String stationCode = electricFieldInfo.getStationCode();
+        // 业务计算
+        Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
+        Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, 10).getTime());
+        fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E158", startTime);
+        if (getFileName(fileName, "E158",stationCode)) {
+          // 获取短期模板
+          Template template = this.velocityEngine.getTemplate(this.vmsPath + "/N_POWER.vm");
+          List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime,stationCode);
+          //累计发电量公式  发电量= 预测值*0.25*0.1  累加96个点的发电量得出1天的累计发电量
+          BigDecimal sumValue = BigDecimal.ZERO;
+          BigDecimal radio = new BigDecimal(0.025);
+          List<Map> vList = new ArrayList<>();
+          DecimalFormat df = new DecimalFormat("0.00");
+          for (ForecastPowerShortTermHis forecastPowerShortTermHis : forecastPowerShortTermHisList) {
+            sumValue = sumValue.add(forecastPowerShortTermHis.getAbleValue().multiply(radio).setScale(3, BigDecimal.ROUND_HALF_UP));
+          }
+          // 用10天的电量*3,计算出1个月的
+          sumValue = sumValue.multiply(new BigDecimal(3)).setScale(3, BigDecimal.ROUND_HALF_UP);
+          for (int i = 0; i <= 12; i++) {
+            Map<String, String> monthMap = new HashMap<>();
+            if (i == 0) {
+              monthMap.put("name", "VAL" + DateFormatUtils.format(fileTime, "yyyyMM"));
+              monthMap.put("value", df.format(sumValue));
+            } else {
+              // 生成未来11个月的发电量,每个月用第1个月的数*正负20%
+              BigDecimal tempValue = sumValue.multiply(new BigDecimal(RandomUtil.randomInt(-20, 20)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
+              tempValue = sumValue.add(tempValue);
+              Date tempTime = TimeUtils.addMonth(systemDate, i);
+              monthMap.put("name", "VAL" + DateFormatUtils.format(tempTime, "yyyyMM"));
+              monthMap.put("value", df.format(tempValue));
+            }
+            vList.add(monthMap);
+          }
+          // 创建上报文件
+          file = super.createTempFile(fileName);
+          // 根据模板生成文件内容
+          velocityContext = new VelocityContext();
+          velocityContext.put("vList", vList);
+          //场站标识
+          velocityContext.put("sign", electricFieldInfo.getSign());
+          velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
+          //系统当前日期
+          velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
+          //上报数据开始日期
+          velocityContext.put("startMonth", DateFormatUtils.format(fileTime, "yyyy-MM"));
+          writer = new StringWriter();
+          template.merge(velocityContext, writer);
+          // 将文件复制到上报路径中
+          super.copyUploadFile(writer, file, FileTypeEnum.E158.name(), null, date, stationCode);
+        }
+      }
+    } catch (Exception e) {
+      log.error("青海新电量预测生成失败", e);
+    }
+  }
   /**
    * 生成短期预测上报文件。
    */
@@ -131,7 +211,7 @@ public class E63UploadFileService extends BaseUploadFileService {
           }
 
           // 短期默认天数
-          int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3", stationCode);
+          int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "10", stationCode);
           // 开始时间
           Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
           // 结束时间(开始加24小时再减去1秒)

+ 4 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadFileLogService.java

@@ -454,6 +454,10 @@ public class UploadFileLogService {
             // 理论功率风
             e63UploadFileService.generateTheroyFile(date);
             break;
+          case "E158":
+            // 青海新电量预测
+            e63UploadFileService.generateE158File(date);
+            break;
           default:
             break;
         }

+ 1 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/UploadObjectService.java

@@ -129,6 +129,7 @@ public class UploadObjectService extends BaseService {
     uploadFileTypeMap.put(FileTypeEnum.E26.toString(), FileTypeEnum.E26.getMessage());
     uploadFileTypeMap.put(FileTypeEnum.E27.toString(), FileTypeEnum.E27.getMessage());
     uploadFileTypeMap.put(FileTypeEnum.E85.toString(), FileTypeEnum.E85.getMessage());
+    uploadFileTypeMap.put(FileTypeEnum.E158.toString(), FileTypeEnum.E158.getMessage());
     return uploadFileTypeMap;
   }
 }

+ 4 - 0
ipfcst-console/src/main/resources/sql/jobload/E63_JOB.sql

@@ -15,6 +15,7 @@ INSERT INTO qrtz_cron_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, CRON_EX
 INSERT INTO qrtz_cron_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, CRON_EXPRESSION, TIME_ZONE_ID) VALUES ('DEFAULT', 'UploadFileE26Job', 'defaultScheduler', '0 16-50 6 * * ?', 'Asia/Shanghai');
 INSERT INTO qrtz_cron_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, CRON_EXPRESSION, TIME_ZONE_ID) VALUES ('DEFAULT', 'UploadFileE27Job', 'defaultScheduler', '15 0/1 * * * ?', 'Asia/Shanghai');
 INSERT INTO qrtz_cron_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, CRON_EXPRESSION, TIME_ZONE_ID) VALUES ('DEFAULT', 'UploadFileE3Job', 'defaultScheduler', '15 0/1 * * * ?', 'Asia/Shanghai');
+INSERT INTO qrtz_cron_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, CRON_EXPRESSION, TIME_ZONE_ID) VALUES ('DEFAULT', 'UploadFileE158Job', 'defaultScheduler', '0 0 0 1 1/1 ?', 'Asia/Shanghai');
 
 -- ----------------------------
 -- Records of qrtz_job_details
@@ -27,6 +28,7 @@ INSERT INTO qrtz_job_details (JOB_GROUP, SCHED_NAME, JOB_NAME, DESCRIPTION, JOB_
 INSERT INTO qrtz_job_details (JOB_GROUP, SCHED_NAME, JOB_NAME, DESCRIPTION, JOB_CLASS_NAME, IS_NONCONCURRENT, REQUESTS_RECOVERY, IS_DURABLE, IS_UPDATE_DATA, JOB_DATA) VALUES ('DEFAULT', 'defaultScheduler', 'UploadFileE26Job', NULL, 'com.jiayue.ipfcst.fileupload.job.UploadFileE26Job', '0', '0', '0', '0', NULL);
 INSERT INTO qrtz_job_details (JOB_GROUP, SCHED_NAME, JOB_NAME, DESCRIPTION, JOB_CLASS_NAME, IS_NONCONCURRENT, REQUESTS_RECOVERY, IS_DURABLE, IS_UPDATE_DATA, JOB_DATA) VALUES ('DEFAULT', 'defaultScheduler', 'UploadFileE27Job', NULL, 'com.jiayue.ipfcst.fileupload.job.UploadFileE27Job', '0', '0', '0', '0', NULL);
 INSERT INTO qrtz_job_details (JOB_GROUP, SCHED_NAME, JOB_NAME, DESCRIPTION, JOB_CLASS_NAME, IS_NONCONCURRENT, REQUESTS_RECOVERY, IS_DURABLE, IS_UPDATE_DATA, JOB_DATA) VALUES ('DEFAULT', 'defaultScheduler', 'UploadFileE3Job', NULL, 'com.jiayue.ipfcst.fileupload.job.UploadFileE3Job', '0', '0', '0', '0', NULL);
+INSERT INTO qrtz_job_details (JOB_GROUP, SCHED_NAME, JOB_NAME, DESCRIPTION, JOB_CLASS_NAME, IS_NONCONCURRENT, REQUESTS_RECOVERY, IS_DURABLE, IS_UPDATE_DATA, JOB_DATA) VALUES ('DEFAULT', 'defaultScheduler', 'UploadFileE158Job', NULL, 'com.jiayue.ipfcst.fileupload.job.UploadFileE158Job', '0', '0', '0', '0', NULL);
 
 -- ----------------------------
 -- ----------------------------
@@ -40,6 +42,7 @@ INSERT INTO qrtz_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, DESCRIPTION,
 INSERT INTO qrtz_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, DESCRIPTION, START_TIME, JOB_NAME, END_TIME, NEXT_FIRE_TIME, TRIGGER_STATE, CALENDAR_NAME, PREV_FIRE_TIME, JOB_GROUP, JOB_DATA, TRIGGER_TYPE, MISFIRE_INSTR, PRIORITY) VALUES ('DEFAULT', 'UploadFileE26Job', 'defaultScheduler', NULL, '1604305788000', 'UploadFileE26Job', '0', '1604559900000', 'WAITING', NULL, '-1', 'DEFAULT', '', 'CRON', '2', '0');
 INSERT INTO qrtz_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, DESCRIPTION, START_TIME, JOB_NAME, END_TIME, NEXT_FIRE_TIME, TRIGGER_STATE, CALENDAR_NAME, PREV_FIRE_TIME, JOB_GROUP, JOB_DATA, TRIGGER_TYPE, MISFIRE_INSTR, PRIORITY) VALUES ('DEFAULT', 'UploadFileE27Job', 'defaultScheduler', NULL, '1604305788000', 'UploadFileE27Job', '0', '1604559900000', 'WAITING', NULL, '-1', 'DEFAULT', '', 'CRON', '2', '0');
 INSERT INTO qrtz_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, DESCRIPTION, START_TIME, JOB_NAME, END_TIME, NEXT_FIRE_TIME, TRIGGER_STATE, CALENDAR_NAME, PREV_FIRE_TIME, JOB_GROUP, JOB_DATA, TRIGGER_TYPE, MISFIRE_INSTR, PRIORITY) VALUES ('DEFAULT', 'UploadFileE3Job', 'defaultScheduler', NULL, '1604305788000', 'UploadFileE3Job', '0', '1604559900000', 'WAITING', NULL, '-1', 'DEFAULT', '', 'CRON', '2', '0');
+INSERT INTO qrtz_triggers (TRIGGER_GROUP, TRIGGER_NAME, SCHED_NAME, DESCRIPTION, START_TIME, JOB_NAME, END_TIME, NEXT_FIRE_TIME, TRIGGER_STATE, CALENDAR_NAME, PREV_FIRE_TIME, JOB_GROUP, JOB_DATA, TRIGGER_TYPE, MISFIRE_INSTR, PRIORITY) VALUES ('DEFAULT', 'UploadFileE158Job', 'defaultScheduler', NULL, '1604305788000', 'UploadFileE158Job', '0', '1604559900000', 'WAITING', NULL, '-1', 'DEFAULT', '', 'CRON', '2', '0');
 
 -- ----------------------------
 -- Records of ipfcst_quartz
@@ -52,3 +55,4 @@ INSERT INTO t_quartz (C_ID, C_JOB_NAME, C_JOB_STATE, C_EXECUTE_CLASS, C_DESCRIPT
 INSERT INTO t_quartz (C_ID, C_JOB_NAME, C_JOB_STATE, C_EXECUTE_CLASS, C_DESCRIPTION, C_CRON_EXPRESSION, C_JOB_TYPE, C_START_TIME, C_STATION_CODE) VALUES ('7', 'UploadFileE26Job', '正常', 'com.jiayue.ipfcst.fileupload.job.UploadFileE26Job', '短期可用', '0 16-50 6 * * ?', 'fileCreate', '1604305788000', NULL);
 INSERT INTO t_quartz (C_ID, C_JOB_NAME, C_JOB_STATE, C_EXECUTE_CLASS, C_DESCRIPTION, C_CRON_EXPRESSION, C_JOB_TYPE, C_START_TIME, C_STATION_CODE) VALUES ('8', 'UploadFileE27Job', '正常', 'com.jiayue.ipfcst.fileupload.job.UploadFileE27Job', '超短期可用', '15 0/1 * * * ?', 'fileCreate', '1604305788000', NULL);
 INSERT INTO t_quartz (C_ID, C_JOB_NAME, C_JOB_STATE, C_EXECUTE_CLASS, C_DESCRIPTION, C_CRON_EXPRESSION, C_JOB_TYPE, C_START_TIME, C_STATION_CODE) VALUES ('20', 'UploadFileE3Job', '正常', 'com.jiayue.ipfcst.fileupload.job.UploadFileE3Job', '青海理论功率', '15 0/1 * * * ?', 'fileCreate', '1604305788000', NULL);
+INSERT INTO t_quartz (C_ID, C_JOB_NAME, C_JOB_STATE, C_EXECUTE_CLASS, C_DESCRIPTION, C_CRON_EXPRESSION, C_JOB_TYPE, C_START_TIME, C_STATION_CODE) VALUES ('9', 'UploadFileE158Job', '正常', 'com.jiayue.ipfcst.fileupload.job.UploadFileE158Job', '青海新电量预测', '0 0 0 1 1/1 ?', 'fileCreate', '1604305788000', NULL);

+ 1 - 0
ipfcst-console/src/main/resources/sql/t_init_job_class.sql

@@ -5,3 +5,4 @@ INSERT INTO t_init_job_class  (C_JOB_CLASS_NAME, C_JOB_CLASS_PATH, C_JOB_CLASS_T
 INSERT INTO t_init_job_class  (C_JOB_CLASS_NAME, C_JOB_CLASS_PATH, C_JOB_CLASS_TYPE, C_STATION_CODE) select '逆变器', 'com.jiayue.ipfcst.fileupload.job.UploadFileE8Job', 'fileCreate', '' from dual where not exists (select C_JOB_CLASS_NAME from t_init_job_class where C_JOB_CLASS_NAME = '逆变器') ;
 INSERT INTO t_init_job_class  (C_JOB_CLASS_NAME, C_JOB_CLASS_PATH, C_JOB_CLASS_TYPE, C_STATION_CODE) select '可用短期', 'com.jiayue.ipfcst.fileupload.job.UploadFileE26Job', 'fileCreate', '' from dual where not exists (select C_JOB_CLASS_NAME from t_init_job_class where C_JOB_CLASS_NAME = '可用短期') ;
 INSERT INTO t_init_job_class  (C_JOB_CLASS_NAME, C_JOB_CLASS_PATH, C_JOB_CLASS_TYPE, C_STATION_CODE) select '可用超短期', 'com.jiayue.ipfcst.fileupload.job.UploadFileE27Job', 'fileCreate', '' from dual where not exists (select C_JOB_CLASS_NAME from t_init_job_class where C_JOB_CLASS_NAME = '可用超短期') ;
+INSERT INTO t_init_job_class  (C_JOB_CLASS_NAME, C_JOB_CLASS_PATH, C_JOB_CLASS_TYPE, C_STATION_CODE) select '青海新电量预测', 'com.jiayue.ipfcst.fileupload.job.UploadFileE158Job', 'fileCreate', '' from dual where not exists (select C_JOB_CLASS_NAME from t_init_job_class where C_JOB_CLASS_NAME = '青海新电量预测') ;

+ 8 - 0
ipfcst-console/src/main/resources/vms/E63/N_POWER.vm

@@ -0,0 +1,8 @@
+// ${currentTime}
+<! Entity=${sign}  type=DL  month='${startMonth}' !>
+<DL::${sign}>
+@@NUM	NAME	VALUE
+#foreach( $dl in $vList )
+#${velocityCount}	${dl.name}	${dl.value}
+#end
+</DL::${sign}>