Browse Source

信控实体类修正提交

shilin 2 years ago
parent
commit
730206116d

+ 14 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/model/vo/PointVo.java

@@ -0,0 +1,14 @@
+package com.gyee.generation.model.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PointVo {
+
+    private Double x;
+    private Double y;
+}

File diff suppressed because it is too large
+ 1100 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/FiveLossesService.java


+ 599 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/util/DateUtils.java

@@ -0,0 +1,599 @@
+package com.gyee.generation.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * 
+ * 
+ * 项目名称:nxfd 类名称:DateUtils 类描述: 创建人:石林 创建时间:2015-3-30 上午11:42:54 修改人:shilinno1
+ * 修改时间:2015-3-30 上午11:42:54 修改备注:
+ * 
+ * @version
+ * 
+ */
+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";
+
+    // 第一次调用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;
+
+    }
+
+    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 Calendar getCal(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        return cal;
+    }
+
+    /**
+     * 将时间的时分秒毫秒字段去掉
+     * 
+     * @param date
+     * @return
+     */
+    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
+
+     * @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
+
+     * @return
+     */
+    public static Date addHours(Date date, int hour) {
+        return new Date(date.getTime() + hour * 3600 * 1000);
+    }
+
+    /**
+     * 在指定时间上加指定的分钟
+     * 
+     * @param date
+     * @return
+     */
+    public static Date addMinutes(Date date, int m) {
+        return new Date(date.getTime() + m * 60 * 1000);
+    }
+
+    /**
+     * 在指定时间上加指定的秒
+     * 
+     * @param date
+     * @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 getMonth(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.MONTH);
+    }
+
+    /**
+     * 获得指定时间的年数
+     * 
+     * @param date
+     * @return
+     */
+    public static int getYear(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        return cd.get(Calendar.YEAR);
+    }
+
+    /**
+     * 获取指定时间的天数
+     * 
+     * @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;
+    }
+
+    /**
+     * 获取当前月的第一天
+     * 
+     * @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 parseLongToDate(long time) {
+        return new Date(time);
+    }
+
+    /**
+     * 转换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();
+    }
+
+    public static String convertEdnaTime(String pointTime) {
+        return convertEdnaTime2(pointTime, false);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(DateUtils.getMonthDays(DateUtils.today()));
+    }
+
+}

+ 219 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/util/LineUtil.java

@@ -0,0 +1,219 @@
+package com.gyee.generation.util;
+
+import com.gyee.generation.model.vo.PointVo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LineUtil {
+
+    public static List<PointVo> BuildLine(double[] arrX, double[] arrY, int length, int dimension, double scale)
+    {
+
+        List<PointVo> points =new ArrayList<PointVo>();
+
+        if (arrX.length != arrY.length || arrX.length<3)
+        {
+            return points;
+        }
+
+        double minValue=arrY[0];
+        double maxValue=arrY[arrY.length-1];
+
+
+        double min = 0;
+        double max= 0;
+
+        double[] coefficient = MultiLine(arrX, arrY, length, dimension);
+
+        for (double i = arrX[0]; i <= arrX[arrX.length - 1]; i += scale)
+        {
+            PointVo point = new PointVo();
+            point.setX(i);
+
+
+            for (int j = 0; j < coefficient.length; j++)
+            {
+                if(j==0)
+                {
+                    point.setY(coefficient[j] * Math.pow(point.getX(), (double)j));
+                }else
+                {
+                    double temp=coefficient[j] * Math.pow(point.getX(), (double)j);
+                    point.setY(point.getY()+temp);
+                }
+
+            }
+            if (point.getY() < minValue)
+            {
+                point.setY(minValue);
+   
+            }
+            if (point.getY() > maxValue)
+            {
+                point.setY(maxValue);
+            }
+
+            if (point.getY() < min)
+            {
+                min = point.getY();
+            }
+            if (point.getY() > max)
+            {
+                max = point.getY();
+            }
+
+            points.add(point);
+        }
+        Builder(points, min, max);
+        return points;
+    }
+
+    private static void Builder(List<PointVo> points, double min, double max)
+    {
+        boolean b = false;
+        for (int i = 0; i < points.size(); i++)
+        {
+            if (b)
+            {
+                points.get(i).setY(max);
+            }
+            else
+            {
+                if (max == points.get(i).getY())
+                {
+                    b = true;
+                }
+            }
+
+        }
+
+        for (int i = points.size()-1; i > -1; i--)
+        {
+            if (!b)
+            {
+                points.get(i).setY(min);
+            }
+            else
+            {
+                if (min == points.get(i).getY())
+                {
+                    b = false;
+                }
+            }
+
+        }
+    }
+
+
+
+    ///<summary>
+    ///用最小二乘法拟合二元多次曲线
+    ///</summary>
+    ///<param name="arrX">已知点的x坐标集合</param>
+    ///<param name="arrY">已知点的y坐标集合</param>
+    ///<param name="length">已知点的个数</param>
+    ///<param name="dimension">方程的最高次数</param>
+    public static double[] MultiLine(double[] arrX, double[] arrY, int length, int dimension)//二元多次线性方程拟合曲线
+    {
+        int n = dimension + 1;                  //dimension次方程需要求 dimension+1个 系数
+        double[][] Guass = new double[n][n+1];      //高斯矩阵 例如:y=a0+a1*x+a2*x*x
+        for (int i = 0; i < n; i++)
+        {
+            int j;
+            for (j = 0; j < n; j++)
+            {
+                Guass[i][j] = SumArr(arrX, j + i, length);
+            }
+            Guass[i][j]= SumArr(arrX, i, arrY, 1, length);
+        }
+        return ComputGauss(Guass, n);
+    }
+    public static double SumArr(double[] arr, int n, int length) //求数组的元素的n次方的和
+    {
+        double s = 0;
+        for (int i = 0; i < length; i++)
+        {
+            if (arr[i] != 0 || n != 0)
+                s = s + Math.pow(arr[i], n);
+            else
+                s = s + 1;
+        }
+        return s;
+    }
+    public static double SumArr(double[] arr1, int n1, double[] arr2, int n2, int length)
+    {
+        double s = 0;
+        for (int i = 0; i < length; i++)
+        {
+            if ((arr1[i] != 0 || n1 != 0) && (arr2[i] != 0 || n2 != 0))
+                s = s + Math.pow(arr1[i], n1) * Math.pow(arr2[i], n2);
+            else
+                s = s + 1;
+        }
+        return s;
+
+    }
+    public static double[] ComputGauss(double[][] Guass, int n)
+    {
+        int i, j;
+        int k, m;
+        double temp;
+        double max;
+        double s;
+        double[] x = new double[n];
+        for (i = 0; i < n; i++) x[i] = 0.0;//初始化
+
+        for (j = 0; j < n; j++)
+        {
+            max = 0;
+            k = j;
+            for (i = j; i < n; i++)
+            {
+                if (Math.abs(Guass[i][j]) > max)
+                {
+                    max = Guass[i][j];
+                    k = i;
+                }
+            }
+
+
+            if (k != j)
+            {
+                for (m = j; m < n + 1; m++)
+                {
+                    temp = Guass[j][m];
+                    Guass[j][m]= Guass[k][m];
+                    Guass[k][m] = temp;
+                }
+            }
+            if (0 == max)
+            {
+                // "此线性方程为奇异线性方程" 
+                return x;
+            }
+
+            for (i = j + 1; i < n; i++)
+            {
+                s = Guass[i][j];
+                for (m = j; m < n + 1; m++)
+                {
+                    Guass[i][m] = Guass[i][m] - Guass[j][m] * s / (Guass[j][j]);
+                }
+            }
+
+        }//结束for (j=0;j<n;j++)
+
+        for (i = n - 1; i >= 0; i--)
+        {
+            s = 0;
+            for (j = i + 1; j < n; j++)
+            {
+                s = s + Guass[i][j] * x[j];
+            }
+            x[i] = (Guass[i][n]- s) / Guass[i][i];
+        }
+        return x;
+    }//返回值是函数的系数
+}
+

+ 559 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/util/StringUtils.java

@@ -0,0 +1,559 @@
+package com.gyee.generation.util;
+
+import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang.text.StrBuilder;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * 字符串工具类
+ * 
+ * @author fc
+ */
+public class StringUtils extends org.apache.commons.lang3.StringUtils
+{
+    /** 空字符串 */
+    private static final String NULLSTR = "";
+
+    /** 下划线 */
+    private static final char SEPARATOR = '_';
+
+    /**
+     * 获取参数不为空值
+     * 
+     * @param value defaultValue 要判断的value
+     * @return value 返回值
+     */
+    public static <T> T nvl(T value, T defaultValue)
+    {
+        return value != null ? value : defaultValue;
+    }
+
+    /**
+     * * 判断一个Collection是否为空, 包含List,Set,Queue
+     * 
+     * @param coll 要判断的Collection
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(Collection<?> coll)
+    {
+        return isNull(coll) || coll.isEmpty();
+    }
+
+    /**
+     * * 判断一个Collection是否非空,包含List,Set,Queue
+     * 
+     * @param coll 要判断的Collection
+     * @return true:非空 false:空
+     */
+    public static boolean isNotEmpty(Collection<?> coll)
+    {
+        return !isEmpty(coll);
+    }
+    public static int roundToInt(double num) {
+
+        return new BigDecimal(num).setScale(0, RoundingMode.HALF_UP).intValue();
+    }
+    /**
+     * * 判断一个对象数组是否为空
+     * 
+     * @param objects 要判断的对象数组
+     ** @return true:为空 false:非空
+     */
+    public static boolean isEmpty(Object[] objects)
+    {
+        return isNull(objects) || (objects.length == 0);
+    }
+
+    /**
+     * * 判断一个对象数组是否非空
+     * 
+     * @param objects 要判断的对象数组
+     * @return true:非空 false:空
+     */
+    public static boolean isNotEmpty(Object[] objects)
+    {
+        return !isEmpty(objects);
+    }
+
+    /**
+     * * 判断一个Map是否为空
+     * 
+     * @param map 要判断的Map
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(Map<?, ?> map)
+    {
+        return isNull(map) || map.isEmpty();
+    }
+
+    /**
+     * * 判断一个Map是否为空
+     * 
+     * @param map 要判断的Map
+     * @return true:非空 false:空
+     */
+    public static boolean isNotEmpty(Map<?, ?> map)
+    {
+        return !isEmpty(map);
+    }
+
+    /**
+     * * 判断一个字符串是否为空串
+     * 
+     * @param str String
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(String str)
+    {
+        return isNull(str) || NULLSTR.equals(str.trim());
+    }
+
+    /**
+     * * 判断一个字符串是否为非空串
+     * 
+     * @param str String
+     * @return true:非空串 false:空串
+     */
+    public static boolean isNotEmpty(String str)
+    {
+        return !isEmpty(str);
+    }
+
+    /**
+     * * 判断一个对象是否为空
+     * 
+     * @param object Object
+     * @return true:为空 false:非空
+     */
+    public static boolean isNull(Object object)
+    {
+        return object == null;
+    }
+
+    /**
+     * * 判断一个对象是否非空
+     * 
+     * @param object Object
+     * @return true:非空 false:空
+     */
+    public static boolean isNotNull(Object object)
+    {
+        return !isNull(object);
+    }
+
+    /**
+     * * 判断一个对象是否是数组类型(Java基本型别的数组)
+     * 
+     * @param object 对象
+     * @return true:是数组 false:不是数组
+     */
+    public static boolean isArray(Object object)
+    {
+        return isNotNull(object) && object.getClass().isArray();
+    }
+
+    /**
+     * 去空格
+     */
+    public static String trim(String str)
+    {
+        return (str == null ? "" : str.trim());
+    }
+
+    /**
+     * 截取字符串
+     * 
+     * @param str 字符串
+     * @param start 开始
+     * @return 结果
+     */
+    public static String substring(final String str, int start)
+    {
+        if (str == null)
+        {
+            return NULLSTR;
+        }
+
+        if (start < 0)
+        {
+            start = str.length() + start;
+        }
+
+        if (start < 0)
+        {
+            start = 0;
+        }
+        if (start > str.length())
+        {
+            return NULLSTR;
+        }
+
+        return str.substring(start);
+    }
+
+    /**
+     * 截取字符串
+     * 
+     * @param str 字符串
+     * @param start 开始
+     * @param end 结束
+     * @return 结果
+     */
+    public static String substring(final String str, int start, int end)
+    {
+        if (str == null)
+        {
+            return NULLSTR;
+        }
+
+        if (end < 0)
+        {
+            end = str.length() + end;
+        }
+        if (start < 0)
+        {
+            start = str.length() + start;
+        }
+
+        if (end > str.length())
+        {
+            end = str.length();
+        }
+
+        if (start > end)
+        {
+            return NULLSTR;
+        }
+
+        if (start < 0)
+        {
+            start = 0;
+        }
+        if (end < 0)
+        {
+            end = 0;
+        }
+
+        return str.substring(start, end);
+    }
+
+
+    /**
+     * 驼峰首字符小写 NameVc>>nameVc
+     */
+    public static String uncapitalize(String str)
+    {
+        int strLen;
+        if (str == null || (strLen = str.length()) == 0)
+        {
+            return str;
+        }
+        return new StrBuilder(strLen).append(Character.toLowerCase(str.charAt(0))).append(str.substring(1)).toString();
+    }
+
+    /**
+     * 驼峰命名转下划线 nameVc>>name_vc
+     */
+    public static String toUnderScoreCase(String s)
+    {
+        if (s == null)
+        {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        boolean upperCase = false;
+        for (int i = 0; i < s.length(); i++)
+        {
+            char c = s.charAt(i);
+
+            boolean nextUpperCase = true;
+
+            if (i < (s.length() - 1))
+            {
+                nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
+            }
+
+            if ((i > 0) && Character.isUpperCase(c))
+            {
+                if (!upperCase || !nextUpperCase)
+                {
+                    sb.append(SEPARATOR);
+                }
+                upperCase = true;
+            }
+            else
+            {
+                upperCase = false;
+            }
+
+            sb.append(Character.toLowerCase(c));
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * 是否包含字符串
+     * 
+     * @param str 验证字符串
+     * @param strs 字符串组
+     * @return 包含返回true
+     */
+    public static boolean inStringIgnoreCase(String str, String... strs)
+    {
+        if (str != null && strs != null)
+        {
+            for (String s : strs)
+            {
+                if (str.equalsIgnoreCase(trim(s)))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+   
+    
+    /**
+     * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
+     * 
+     * @param name 转换前的下划线大写方式命名的字符串
+     * @return 转换后的驼峰式命名的字符串
+     */
+    public static String convertToCamelCase(String name)
+    {
+        StringBuilder result = new StringBuilder();
+        // 快速检查
+        if (name == null || name.isEmpty())
+        {
+            // 没必要转换
+            return "";
+        }
+        else if (!name.contains("_"))
+        {
+            // 不含下划线,仅将首字母大写
+            return name.substring(0, 1).toUpperCase() + name.substring(1);
+        }
+        // 用下划线将原始字符串分割
+        String[] camels = name.split("_");
+        for (String camel : camels)
+        {
+            // 跳过原始字符串中开头、结尾的下换线或双重下划线
+            if (camel.isEmpty())
+            {
+                continue;
+            }
+            // 首字母大写
+            result.append(camel.substring(0, 1).toUpperCase());
+            result.append(camel.substring(1).toLowerCase());
+        }
+        return result.toString();
+    }
+    /**
+     * 首字母大写
+     *
+     * @param name
+     * @return
+     */
+    public static String firstUpperCase(String name) {
+        name = name.substring(0, 1).toUpperCase() + name.substring(1);
+        return name;
+    }
+    /**
+     * 首字母小写
+     *
+     * @param name
+     * @return
+     */
+    public static String firstLowerCase(String name) {
+        name = name.substring(0, 1).toLowerCase() + name.substring(1);
+        return name;
+
+    }
+    
+    /**
+     * 将下划线转化为大写
+     *
+     * @param name
+     * @param firstCase 首字母是否大写 true:大写 false;小写
+     * @return
+     */
+    public static String upperCase_(String name, boolean firstCase) {
+        if(isEmpty(name)){
+            return "";
+        }
+        String[] s = name.split("_");
+        StringBuffer stringBuffer = new StringBuffer();
+        for (String s1 : s) {
+            stringBuffer.append(s1.substring(0, 1).toUpperCase() + s1.substring(1));
+        }
+        if(!firstCase){
+            return firstLowerCase(stringBuffer.toString());
+        }
+        return stringBuffer.toString();
+    }
+    
+    /**
+     * get方法名字转成 t_b_abc>>tBAbc
+     * @param str
+     * @return
+     * @author gyee
+     * @Date 2020年1月30日 下午11:55:54
+     */
+    public static String toFUNName(String str) {
+    	StringBuffer buffer=new StringBuffer();
+    	String name=str;
+    	if(name.contains("_")) {
+    		// 用下划线将原始字符串分割
+            String[] camels = name.split("_");
+            boolean b=true;
+            
+            for (String str1 : camels) {
+            	if(str1.length()==1&&b) {
+            		b=false;
+            		buffer.append(str1);
+            	}else {
+            		buffer.append(StringUtils.firstUpperCase(str1));
+            	}
+				
+			}
+    	}else {
+    		buffer.append(StringUtils.firstUpperCase(name));
+    	}
+		return buffer.toString();
+    }
+
+    /**
+     * 列名转换成Java属性名
+     */
+    public static String columnToJava(String columnName) {
+        return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", "" );
+    }
+    
+    
+    /**
+     * 表名转换成Java类名
+     */
+    public static String tableToJava(String tableName, String tablePrefix) {
+        if (StringUtils.isNotBlank(tablePrefix)) {
+            tableName = tableName.replaceFirst(tablePrefix, "" );
+        }
+        return columnToJava(tableName);
+    }
+
+    /**
+     * 是否不为空串
+     *
+     * @param obj
+     * @return
+     */
+    public static boolean notEmp(Object obj) {
+        return !empty(obj);
+    }
+
+    /**
+     * 是否为空串
+     *
+     * @param obj
+     * @return
+     */
+    public static boolean empty(Object obj) {
+        if (obj == null)
+            return true;
+        String str;
+        if (obj instanceof String) {
+            str = (String) obj;
+        } else {
+            str = obj.toString();
+        }
+        return str.length() == 0;
+    }
+
+    public static double round(double num, int digit) {
+
+        return new BigDecimal(num).setScale(digit, RoundingMode.HALF_UP).doubleValue();
+    }
+    /**
+     * 将字符串解析为Date类型
+     *
+     * @param date
+     * @param pattern
+     * @return
+     */
+    public static Date toDate(String date, String pattern) {
+        SimpleDateFormat format = new SimpleDateFormat(pattern);
+        try {
+            return format.parse(date);
+        } catch (ParseException e) {
+            throw new RuntimeException(String.format("Failed to parse the String [%s] to Date.", date), e);
+        }
+    }
+    /**
+     *
+     * @方法名称: getUUID
+     * @描述: 获得UUID
+     * @参数 @return
+     * @返回值 String
+     * @抛出异常
+     */
+    public static String getUUID() {
+        String s = UUID.randomUUID().toString();
+        // 去掉“-”符号
+        return s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24);
+    }
+
+    /**
+     * 判断是否为数字字符串
+     * @param str
+     * @return
+     */
+    public static boolean isNumeric(String str){
+        Pattern pattern = Pattern.compile("^(-?\\d+)(\\.\\d+)?$");
+        if(notEmp(str))
+        {
+            Matcher isNum = pattern.matcher(str);
+            if( !isNum.matches() ){
+                return false;
+            }
+
+        }else
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+
+    /**
+     * 正则表达式
+     * @param input     需要匹配的字符串
+     * @param expression 正则表达公式
+     * @return
+     */
+    public static List<String> pattern(String input, String expression){
+        // 创建 Pattern 对象
+        Pattern p = Pattern.compile(expression);
+        Matcher m = p.matcher(input);
+
+        ArrayList list = new ArrayList();
+        while (m.find()) {
+            list.add(m.group(0));
+        }
+        //去除重复值
+        HashSet hs=new HashSet(list);
+        list.clear();
+        list.addAll(hs);
+
+        return list;
+    }
+}

+ 6 - 5
realtime/generationXK-service/src/main/resources/application-xk.yml

@@ -97,11 +97,12 @@ AI134: 17.4    #叶轮转速给定
 AI178: 17.4    #转矩给定
 #AI443:容量
 
-#计算电量直接取,如果不是1就是相减算
-typeOfElectric:
-  #直接取
-  direct: GJY02_GC,YF01_GC,YF02_GC,HSM01_GC,PTZ01_GC,ZK01_GC
-
+#功率曲线拟合
+curvefitting:
+  #维度
+  dimension: 20
+  #尺度
+  scale: 0.01
 
 
 

+ 964 - 0
realtime/generationXK-service/src/test/java/com/gyee/generation/PowerCurveFittingService.java

@@ -0,0 +1,964 @@
+//package com.gyee.generation;
+//
+//import com.gyee.generation.util.realtimesource.IEdosUtil;
+//import org.springframework.beans.factory.annotation.Value;
+//
+//import javax.annotation.Resource;
+//import java.io.Console;
+//import java.util.Date;
+//
+//public class PowerCurveFittingService {
+//
+//    @Resource
+//    private IEdosUtil edosUtil;
+//
+//    @Value("${curvefitting.dimension}")
+//    private Integer dimension;
+//    @Value("${curvefitting.scale}")
+//    private Double scale;
+//
+//
+//    public void CureFitting(Date nowDate, Date begion, int insertType, String fdcId, params String[] fdjIds)
+//    {
+//
+//
+//        Date current = nowDate.Date.AddDays(-1);
+//        int year = current.Year;
+//        int month = current.Month;
+//        Date begin1 = new Date(year, month, 1);
+//        Date begin2 = current.AddDays(-6);
+//        //Date begin2 = current;
+//        Date end = nowDate.Date;
+//        if (begion != Date.MaxValue && begion != Date.MinValue)
+//        {
+//            begin1 = begion;
+//        }
+//
+//
+//        int dimension = ConfigurationFramework.ConfigManager.MySection.CurveFitting.dimension;
+//        double scale = ConfigurationFramework.ConfigManager.MySection.CurveFitting.scale;
+//
+//        //上个月
+//        int year2 = begin1.AddMonths(-1).Year;
+//        int month2 = begin1.AddMonths(-1).Month;
+//
+//        //去年同期
+//        int year3 = begin1.AddYears(-1).Year;
+//        int month3 = begin1.AddYears(-1).Month;
+//
+//
+//        Dictionary<String, CureFitting> windDictionary = new Dictionary<String, CureFitting>();
+//        using (GdsjEntities entities = new GdsjEntities())
+//        {
+//
+//
+//            var WindturbineIds = entities.WINDTURBINE.Where(GetConditionExpression<WINDTURBINE>(WindList.ToArray<String>(), "WINDPOWERSTATIONID")).ToList();
+//
+//            if (windturbineCapacity == null)
+//            {
+//                windturbineCapacity = new Dictionary<String, decimal>();
+//                Dictionary<String, EQUIPMENTMODEL> modelDictionary = entities.EQUIPMENTMODEL.ToDictionary(it => it.ID);
+//                foreach (var windturbine in WindturbineIds)
+//                {
+//                    if (modelDictionary.ContainsKey(windturbine.MODELID))
+//                    {
+//                        windturbineCapacity.Add(windturbine.ID, modelDictionary[windturbine.MODELID].POWERPRODUCTION.Value);
+//                    }
+//                }
+//            }
+//            foreach (var windturbine in WindturbineIds)
+//            {
+//                String windturbineId = windturbine.ID;
+//                String windpowerId = windturbine.WINDPOWERSTATIONID;
+//
+//                if (fdcId != null && fdcId != String.Empty)
+//                {
+//                    if (fdcId != windpowerId)
+//                    {
+//                        continue;
+//                    }
+//                }
+//                if (fdjIds != null)
+//                {
+//                    if (!fdjIds.Contains(windturbineId))
+//                    {
+//                        continue;
+//                    }
+//                }
+//
+//                String pointIdGL = entities.WINDTURBINETESTINGPOINTAI.Where(it => it.UNIFORMCODE == BusinessHandle.GdnxfdTarget.FJYG && it.WINDTURBINEID == windturbineId).Select(it => it.ID).FirstOrDefault();
+//
+//                String pointIdZT = entities.WINDTURBINETESTINGPOINTAI.Where(it => it.UNIFORMCODE == BusinessHandle.GdnxfdTarget.ZTMX && it.WINDTURBINEID == windturbineId).Select(it => it.ID).FirstOrDefault();
+//
+//                String pointIdFS = "";
+//                if (type == "GDC")
+//                    pointIdFS = entities.WINDPOWERSTATIONTESTINGPOINT.Where(it => it.UNIFORMCODE == BusinessHandle.GdnxfdTarget.IRRAD && it.WINDPOWERSTATIONID == windpowerId).Select(it => it.CODE).FirstOrDefault();
+//                    else
+//                pointIdFS = entities.WINDTURBINETESTINGPOINTAI.Where(it => it.UNIFORMCODE == BusinessHandle.GdnxfdTarget.FJFS && it.WINDTURBINEID == windturbineId).Select(it => it.ID).FirstOrDefault();
+//
+//                //String pointIdZT2 = entities.WINDTURBINETESTINGPOINTDI2.Where(it => it.UNIFORMCODE == "DI064" && it.WINDTURBINEID == windturbineId).Select(it => it.ID).FirstOrDefault();
+//
+//                //if (pointIdZT2 == null)
+//                //{
+//                //    pointIdZT2 = entities.WINDTURBINETESTINGPOINTDIS2.Where(it => it.NAME.IndexOf("发电状态")>-1 && it.WINDTURBINEID == windturbineId).Select(it => it.ID).FirstOrDefault();
+//                //}
+//
+//
+//                CureFitting item = new Tools.CureFitting();
+//
+//                item.pointIdFS = pointIdFS;
+//                item.pointIdGL = pointIdGL;
+//                item.pointIdZT = pointIdZT;
+//                //item.pointIdZT2 = pointIdZT2;
+//                item.StandardId = windturbine.STANDARDID;
+//                windDictionary.Add(windturbineId, item);
+//            }
+//        }
+//
+//
+//        foreach (String key in windDictionary.Keys)
+//        {
+//            windDictionary[key].myPoints1 = new List<MyMath.Point>();
+//            windDictionary[key].myPointsFF1 = new List<MyMath.Point>();
+//
+//            windDictionary[key].myPoints2 = new List<MyMath.Point>();
+//            windDictionary[key].myPointsFF2 = new List<MyMath.Point>();
+//
+//            if (windDictionary[key].pointIdGL == null || windDictionary[key].pointIdFS == null || windDictionary[key].pointIdZT == null)
+//            {
+//                Console.WriteLine(key);
+//                continue;
+//            }
+//
+//
+//            CurveFittingBuilder(begin1, end, dimension, scale, windDictionary[key].pointIdGL, windDictionary[key].pointIdFS, windDictionary[key].pointIdZT, windDictionary[key].myPoints1, windDictionary[key].myPointsFF1, key);
+//            CurveFittingBuilder(begin2, end, dimension, scale, windDictionary[key].pointIdGL, windDictionary[key].pointIdFS, windDictionary[key].pointIdZT, windDictionary[key].myPoints2, windDictionary[key].myPointsFF2, key);
+//        }
+//
+//        foreach (String key in windDictionary.Keys)
+//        {
+//
+//            decimal modelpower = 1500;
+//            if (windturbineCapacity.ContainsKey(key))
+//            {
+//                modelpower = windturbineCapacity[key];
+//            }
+//
+//            using (GdsjEntities entities = new GdsjEntities())
+//            {
+//
+//
+//                //月的上月
+//                List<MyMath.Point> monthPoints = new List<MyMath.Point>();
+//                //月的去年同期
+//                List<MyMath.Point> yearPoints = new List<MyMath.Point>();
+//                //月标准功率
+//                List<MyMath.Point> standardPoints = new List<MyMath.Point>();
+//
+//
+//                //日的昨天
+//                List<MyMath.Point> monthdayPoints = new List<MyMath.Point>();
+//                //日的去年同期
+//                List<MyMath.Point> yeardayPoints = new List<MyMath.Point>();
+//                //日标准功率
+//                List<MyMath.Point> standarddayPoints = new List<MyMath.Point>();
+//
+//                //保证功率
+//                List<MyMath.Point> powerPoints = new List<MyMath.Point>();
+//
+//
+//
+//
+//                if (windTurbineDictionary.ContainsKey(key))
+//                {
+//                    String standardId = windTurbineDictionary[key].STANDARDID;
+//                    if (!String.IsNullOrEmpty(standardId))
+//                    {
+//                        if (windDictionary.ContainsKey(key))
+//                        {
+//                            standardPoints = windDictionary[standardId].myPoints1;
+//                            standarddayPoints = windDictionary[standardId].myPoints2;
+//                        }
+//                    }
+//                }
+//
+//                String stringyear = year.ToString();
+//                String stringmonth = month.ToString();
+//
+//                String stringyear2 = year2.ToString();
+//                String stringmonth2 = month2.ToString();
+//
+//                String stringyear3 = year3.ToString();
+//                String stringmonth3 = month3.ToString();
+//
+//                var data = (from c in entities.WINDTURBINECURVEFITTINGMONTH
+//                where (c.WINDTURBINEID == key && c.YEAR == stringyear2 && c.MONTH == stringmonth2)
+//                select c).OrderBy(it => it.SPEED).ToList();
+//
+//                BuildPoints(data, monthPoints);
+//                data = null;
+//                data = (from c in entities.WINDTURBINECURVEFITTINGMONTH
+//                where (c.WINDTURBINEID == key && c.YEAR == stringyear3 && c.MONTH == stringmonth3)
+//                select c).OrderBy(it => it.SPEED).ToList();
+//
+//                BuildPoints(data, yearPoints);
+//
+//                Date d1 = current.AddDays(-1);
+//                Date d2 = current.AddYears(-1);
+//
+//                var data2 = (from c in entities.WINDTURBINECURVEFITTING
+//                where (c.WINDTURBINEID == key && c.RECORDDATE.Value.CompareTo(d1) == 0)
+//                select c).ToList();
+//
+//                BuildPoints(data2, monthdayPoints);
+//
+//                data2 = null;
+//                data2 = (from c in entities.WINDTURBINECURVEFITTING
+//                where (c.WINDTURBINEID == key && c.RECORDDATE.Value.CompareTo(d2) == 0)
+//                select c).ToList();
+//
+//                BuildPoints(data2, monthPoints);
+//
+//                if (windTurbineDictionary.ContainsKey(key))
+//                {
+//                    String modelid = windTurbineDictionary[key].MODELID;
+//                    if (!String.IsNullOrEmpty(modelid))
+//                    {
+//                        if (modelPowerDictionary.ContainsKey(modelid))
+//                        {
+//                            foreach (var speed in modelPowerDictionary[modelid].Keys)
+//                            {
+//                                MyMath.Point point = new MyMath.Point();
+//                                point.X = (double)speed;
+//                                point.Y = (double)modelPowerDictionary[modelid][speed].ENSUREPOWER.Value;
+//                                powerPoints.Add(point);
+//                            }
+//                        }
+//                    }
+//                }
+//
+//
+//
+//
+//                CURVEFITTINGMONTHMAIN main1 = (from c in entities.CURVEFITTINGMONTHMAIN
+//                where (c.WINDTURBINEID == key && c.YEAR == stringyear && c.MONTH == stringmonth)
+//                select c).FirstOrDefault();
+//                if (main1 == null)
+//                {
+//                    main1 = new CURVEFITTINGMONTHMAIN();
+//                    main1.ID = Guid.NewGuid().ToString();
+//                    main1.WINDTURBINEID = key;
+//                    main1.YEAR = year.ToString();
+//                    main1.MONTH = month.ToString();
+//                    entities.AddToCURVEFITTINGMONTHMAIN(main1);
+//                }
+//                //月---实际/最优
+//                main1.DEVIATIONRATE1 = (decimal)pcl(windDictionary[key].myPoints1, windDictionary[key].myPointsFF1, modelpower);
+//                //月---实际/保证
+//                main1.DEVIATIONRATE2 = (decimal)pcl(windDictionary[key].myPoints1, powerPoints, modelpower);
+//                //月---最优/保证
+//                main1.DEVIATIONRATE3 = (decimal)pcl(windDictionary[key].myPointsFF1, powerPoints, modelpower);
+//                //月---实际/上月实际
+//                main1.MONTHDEVIATIONRATE = (decimal)pcl(windDictionary[key].myPoints1, monthPoints, modelpower);
+//                //月---实际/同期实际
+//                main1.YEARDEVIATIONRATE = (decimal)pcl(windDictionary[key].myPoints1, yearPoints, modelpower);
+//                //月---实际/标杆实际
+//                main1.STANDARDDEVIATIONRATE = (decimal)pcl(windDictionary[key].myPoints1, standardPoints, modelpower);
+//
+//
+//
+//                CURVEFITTINGMAIN main2 = (from c in entities.CURVEFITTINGMAIN
+//                where (c.WINDTURBINEID == key && c.RECORDDATE.Value.CompareTo(current) == 0)
+//                select c).FirstOrDefault();
+//                if (main2 == null)
+//                {
+//                    main2 = new CURVEFITTINGMAIN();
+//                    main2.ID = Guid.NewGuid().ToString();
+//                    main2.WINDTURBINEID = key;
+//                    main2.RECORDDATE = current;
+//
+//                    entities.AddToCURVEFITTINGMAIN(main2);
+//
+//                }
+//                //日---实际/最优
+//                main2.DEVIATIONRATE1 = (decimal)pcl(windDictionary[key].myPoints2, windDictionary[key].myPointsFF2, modelpower);
+//                //日---实际/保证
+//                main2.DEVIATIONRATE2 = (decimal)pcl(windDictionary[key].myPoints2, powerPoints, modelpower);
+//                //日---最优/保证
+//                main2.DEVIATIONRATE3 = (decimal)pcl(windDictionary[key].myPointsFF2, powerPoints, modelpower);
+//                //日---实际/上日实际
+//                main2.MONTHDEVIATIONRATE = (decimal)pcl(windDictionary[key].myPoints2, monthdayPoints, modelpower);
+//                //日---实际/同期实际
+//                main2.YEARDEVIATIONRATE = (decimal)pcl(windDictionary[key].myPoints2, yeardayPoints, modelpower);
+//                //日---实际/标杆实际
+//                main2.STANDARDDEVIATIONRATE = (decimal)pcl(windDictionary[key].myPoints2, standarddayPoints, modelpower);
+//
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 3, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 4, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 5, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 6, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 7, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 8, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 9, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 10, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 11, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 12, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//                PLCBuild(entities, key, stringyear, stringmonth, current, windDictionary, modelpower, 13, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
+//
+//
+//                if (insertType == 0)
+//                {
+//                    InsertPoints(current, stringyear, stringmonth, entities, windDictionary[key].myPoints1, windDictionary[key].myPointsFF1, windDictionary[key].myPoints2, windDictionary[key].myPointsFF2, key);
+//                }
+//                else
+//                {
+//                    InsertPoints2(current, stringyear, stringmonth, entities, windDictionary[key].myPoints1, windDictionary[key].myPointsFF1, windDictionary[key].myPoints2, windDictionary[key].myPointsFF2, key);
+//                }
+//                Console.WriteLine(key);
+//                int z = entities.SaveChanges(false);
+//                logger.Info(String.Format("{1}:更新sqlserver数据库记录数:{0}", z, Date.Now));
+//            }
+//
+//        }
+//
+//
+//
+//    }
+//
+//    public void PLCBuild(GdsjEntities entities, String key, String stringyear, String stringmonth, Date current, Dictionary<String, CureFitting> windDictionary, decimal modelpower, double speed,
+//                         List<MyMath.Point> powerPoints, List<MyMath.Point> monthPoints, List<MyMath.Point> yearPoints, List<MyMath.Point> standardPoints, List<MyMath.Point> monthdayPoints, List<MyMath.Point> yeardayPoints, List<MyMath.Point> standarddayPoints)
+//    {
+//
+//        String speedStr = speed.ToString();
+//
+//        CURVEFITTINGMONTHSUB main1 = (from c in entities.CURVEFITTINGMONTHSUB
+//        where (c.WINDTURBINEID == key && c.YEAR == stringyear && c.MONTH == stringmonth && c.SPEED == speedStr)
+//        select c).FirstOrDefault();
+//        if (main1 == null)
+//        {
+//            main1 = new CURVEFITTINGMONTHSUB();
+//            main1.ID = Guid.NewGuid().ToString();
+//            main1.WINDTURBINEID = key;
+//            main1.YEAR = stringyear;
+//            main1.MONTH = stringmonth;
+//            main1.SPEED = speed.ToString();
+//            entities.AddToCURVEFITTINGMONTHSUB(main1);
+//        }
+//        //月---实际/最优
+//        main1.DEVIATIONRATE1 = (decimal)pcl2(windDictionary[key].myPoints1, windDictionary[key].myPointsFF1, modelpower, speed);
+//        //月---实际/保证
+//        main1.DEVIATIONRATE2 = (decimal)pcl2(windDictionary[key].myPoints1, powerPoints, modelpower, speed);
+//        //月---最优/保证
+//        main1.DEVIATIONRATE3 = (decimal)pcl2(windDictionary[key].myPointsFF1, powerPoints, modelpower, speed);
+//        //月---实际/上月实际
+//        main1.MONTHDEVIATIONRATE = (decimal)pcl2(windDictionary[key].myPoints1, monthPoints, modelpower, speed);
+//        //月---实际/同期实际
+//        main1.YEARDEVIATIONRATE = (decimal)pcl2(windDictionary[key].myPoints1, yearPoints, modelpower, speed);
+//        //月---实际/标杆实际
+//        main1.STANDARDDEVIATIONRATE = (decimal)pcl2(windDictionary[key].myPoints1, standardPoints, modelpower, speed);
+//
+//
+//
+//        CURVEFITTINGSUB main2 = (from c in entities.CURVEFITTINGSUB
+//        where (c.WINDTURBINEID == key && c.RECORDDATE.Value.CompareTo(current) == 0 && c.SPEED == speedStr)
+//        select c).FirstOrDefault();
+//        if (main2 == null)
+//        {
+//            main2 = new CURVEFITTINGSUB();
+//            main2.ID = Guid.NewGuid().ToString();
+//            main2.WINDTURBINEID = key;
+//            main2.RECORDDATE = current;
+//            main2.SPEED = speed.ToString();
+//            entities.AddToCURVEFITTINGSUB(main2);
+//
+//        }
+//        //日---实际/最优
+//        main2.DEVIATIONRATE1 = (decimal)pcl2(windDictionary[key].myPoints2, windDictionary[key].myPointsFF2, modelpower, speed);
+//        //日---实际/保证
+//        main2.DEVIATIONRATE2 = (decimal)pcl2(windDictionary[key].myPoints2, powerPoints, modelpower, speed);
+//        //日---最优/保证
+//        main2.DEVIATIONRATE3 = (decimal)pcl2(windDictionary[key].myPointsFF2, powerPoints, modelpower, speed);
+//        //日---实际/上日实际
+//        main2.MONTHDEVIATIONRATE = (decimal)pcl2(windDictionary[key].myPoints2, monthdayPoints, modelpower, speed);
+//        //日---实际/同期实际
+//        main2.YEARDEVIATIONRATE = (decimal)pcl2(windDictionary[key].myPoints2, yeardayPoints, modelpower, speed);
+//        //日---实际/标杆实际
+//        main2.STANDARDDEVIATIONRATE = (decimal)pcl2(windDictionary[key].myPoints2, standarddayPoints, modelpower, speed);
+//    }
+//
+//
+//    private void InsertPoints(Date current, String year, String month, GdsjEntities entities, List<MyMath.Point> pointsF1, List<MyMath.Point> pointsFF1, List<MyMath.Point> pointsF2, List<MyMath.Point> pointsFF2, String windturbineId)
+//    {
+//        var data = (from c in entities.WINDTURBINECURVEFITTINGMONTH
+//        where (c.WINDTURBINEID == windturbineId && c.YEAR == year && c.MONTH == month)
+//        select c).ToList();
+//
+//        for (int i = 0; i < data.Count; i++)
+//        {
+//            entities.DeleteObject(data[i]);
+//        }
+//
+//        if (pointsF1.Count == pointsFF1.Count)
+//        {
+//            for (int i = 0; i < pointsF1.Count; i++)
+//            {
+//                WINDTURBINECURVEFITTINGMONTH item = new WINDTURBINECURVEFITTINGMONTH();
+//                item.WINDTURBINEID = windturbineId;
+//
+//                if (type == "GDC")
+//                {
+//                    continue;
+//                    item.SPEED = decimal.Truncate((decimal)pointsF1[i].X);
+//                }
+//                else
+//                {
+//
+//                    item.SPEED = (decimal)pointsF1[i].X;
+//                }
+//                item.ACTUALPOWER = (decimal)pointsF1[i].Y;
+//                item.OPTIMALPOWER = (decimal)pointsFF1[i].Y;
+//                item.YEAR = year.ToString();
+//                item.MONTH = month.ToString();
+//                entities.AddToWINDTURBINECURVEFITTINGMONTH(item);
+//            }
+//        }
+//        else
+//        {
+//
+//            logger.WarnFormat(String.Format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF1.Count, pointsFF1.Count));
+//
+//            for (int i = 0; i < pointsF1.Count; i++)
+//            {
+//                WINDTURBINECURVEFITTINGMONTH item = new WINDTURBINECURVEFITTINGMONTH();
+//                item.WINDTURBINEID = windturbineId;
+//                if (type == "GDC")
+//                {
+//                    continue;
+//                    item.SPEED = decimal.Truncate((decimal)pointsF1[i].X);
+//                }
+//                else
+//                {
+//
+//                    item.SPEED = (decimal)pointsF1[i].X;
+//                }
+//                item.ACTUALPOWER = (decimal)pointsF1[i].Y;
+//                item.OPTIMALPOWER = (decimal)pointsFF1.Where(it => it.X == pointsF1[i].X).Select(it => it.Y).FirstOrDefault();
+//                item.YEAR = year.ToString();
+//                item.MONTH = month.ToString();
+//                entities.AddToWINDTURBINECURVEFITTINGMONTH(item);
+//            }
+//        }
+//
+//
+//        var data2 = (from c in entities.WINDTURBINECURVEFITTING
+//        where (c.WINDTURBINEID == windturbineId && c.RECORDDATE.Value.CompareTo(current) == 0)
+//        select c).ToList();
+//
+//
+//        for (int i = 0; i < data2.Count; i++)
+//        {
+//            entities.DeleteObject(data2[i]);
+//        }
+//
+//        if (pointsF2.Count == pointsFF2.Count)
+//        {
+//            for (int i = 0; i < pointsF2.Count; i++)
+//            {
+//                WINDTURBINECURVEFITTING item = new WINDTURBINECURVEFITTING();
+//                item.WINDTURBINEID = windturbineId;
+//                if (type == "GDC")
+//                {
+//                    continue;
+//                    item.SPEED = decimal.Truncate((decimal)pointsF2[i].X);
+//                }
+//                else
+//                {
+//                    bool l = pointsF2[i].X.ToString().Contains(".");
+//                    if (l)
+//                    {
+//                        continue;
+//                    }
+//                    item.SPEED = (decimal)pointsF2[i].X;
+//                }
+//                item.ACTUALPOWER = (int)pointsF2[i].Y;
+//                item.OPTIMALPOWER = (int)pointsFF2[i].Y;
+//                item.RECORDDATE = current;
+//
+//                entities.AddToWINDTURBINECURVEFITTING(item);
+//            }
+//        }
+//        else
+//        {
+//            logger.WarnFormat(String.Format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF2.Count, pointsFF2.Count));
+//
+//            for (int i = 0; i < pointsF2.Count; i++)
+//            {
+//                WINDTURBINECURVEFITTING item = new WINDTURBINECURVEFITTING();
+//                item.WINDTURBINEID = windturbineId;
+//                if (type == "GDC")
+//                {
+//                    continue;
+//                    item.SPEED = decimal.Truncate((decimal)pointsF2[i].X);
+//                }
+//                else
+//                {
+//                    bool l = pointsF2[i].X.ToString().Contains(".");
+//                    if (l)
+//                    {
+//                        continue;
+//                    }
+//                    item.SPEED = (decimal)pointsF2[i].X;
+//                }
+//                item.ACTUALPOWER = (int)pointsF2[i].Y;
+//                item.OPTIMALPOWER = (int)pointsFF2.Where(it => it.X == pointsF2[i].X).Select(it => it.Y).FirstOrDefault();
+//                item.RECORDDATE = current;
+//
+//                entities.AddToWINDTURBINECURVEFITTING(item);
+//            }
+//        }
+//    }
+//
+//
+//
+//    private void InsertPoints2(Date current, String year, String month, GdsjEntities entities, List<MyMath.Point> pointsF1, List<MyMath.Point> pointsFF1, List<MyMath.Point> pointsF2, List<MyMath.Point> pointsFF2, String windturbineId)
+//    {
+//        var data = (from c in entities.WINDTURBINEPOWERCURVEFITTING
+//        where (c.WINDTURBINEID == windturbineId)
+//        select c).ToList();
+//
+//        for (int i = 0; i < data.Count; i++)
+//        {
+//            entities.DeleteObject(data[i]);
+//        }
+//
+//        if (pointsF1.Count == pointsFF1.Count)
+//        {
+//            for (int i = 0; i < pointsF1.Count; i++)
+//            {
+//                WINDTURBINEPOWERCURVEFITTING item = new WINDTURBINEPOWERCURVEFITTING();
+//                item.ID = Guid.NewGuid().ToString();
+//                item.WINDTURBINEID = windturbineId;
+//
+//                if (type == "GDC")
+//                {
+//                    continue;
+//                    item.SPEED = decimal.Truncate((decimal)pointsF1[i].X);
+//                }
+//                else
+//                {
+//                    bool l = pointsF1[i].X.ToString().Contains(".");
+//                    if (l)
+//                    {
+//                        continue;
+//                    }
+//                    item.SPEED = (decimal)pointsF1[i].X;
+//                }
+//                item.ACTUALPOWER = (decimal)pointsF1[i].Y;
+//                item.OPTIMALPOWER = (decimal)pointsFF1[i].Y;
+//
+//                entities.AddToWINDTURBINEPOWERCURVEFITTING(item);
+//            }
+//        }
+//        else
+//        {
+//
+//            logger.WarnFormat(String.Format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF1.Count, pointsFF1.Count));
+//
+//            for (int i = 0; i < pointsF1.Count; i++)
+//            {
+//                WINDTURBINEPOWERCURVEFITTING item = new WINDTURBINEPOWERCURVEFITTING();
+//                item.ID = Guid.NewGuid().ToString();
+//                item.WINDTURBINEID = windturbineId;
+//                if (type == "GDC")
+//                {
+//                    continue;
+//                    item.SPEED = decimal.Truncate((decimal)pointsF1[i].X);
+//                }
+//                else
+//                {
+//                    bool l = pointsF1[i].X.ToString().Contains(".");
+//                    if (l)
+//                    {
+//                        continue;
+//                    }
+//                    item.SPEED = (decimal)pointsF1[i].X;
+//                }
+//                item.ACTUALPOWER = (decimal)pointsF1[i].Y;
+//                item.OPTIMALPOWER = (decimal)pointsFF1.Where(it => it.X == pointsF1[i].X).Select(it => it.Y).FirstOrDefault();
+//
+//                entities.AddToWINDTURBINEPOWERCURVEFITTING(item);
+//            }
+//        }
+//    }
+//
+//
+//    private void BuildPoints(List<WINDTURBINECURVEFITTINGMONTH> data, List<MyMath.Point> points)
+//    {
+//        if (data != null)
+//        {
+//            for (int i = 0; i < data.Count; i++)
+//            {
+//                MyMath.Point point = new MyMath.Point();
+//                point.X = (double)data[i].SPEED.Value;
+//                point.Y = (double)data[i].ACTUALPOWER.Value;
+//                points.Add(point);
+//            }
+//        }
+//    }
+//    private void BuildPoints(List<WINDTURBINECURVEFITTING> data, List<MyMath.Point> points)
+//    {
+//        if (data != null)
+//        {
+//            for (int i = 0; i < data.Count; i++)
+//            {
+//                MyMath.Point point = new MyMath.Point();
+//                point.X = (double)data[i].SPEED.Value;
+//                point.Y = (double)data[i].ACTUALPOWER.Value;
+//                points.Add(point);
+//            }
+//        }
+//    }
+//    //曲线偏差率
+//    private double pcl(List<MyMath.Point> Points1, List<MyMath.Point> Points2, decimal modelpower)
+//    {
+//        double result = -0;
+//        double pc = 0;
+//        if (Points1 != null && Points1.Count != 0 && Points2 != null && Points2.Count != 0)
+//        {
+//            double count = 0;
+//            double sum = 0;
+//            double max = (double)modelpower;
+//            foreach (MyMath.Point point in Points1)
+//            {
+//                var item = Points2.Where(it => it.X == point.X).ToList();
+//                if (item != null && item.Count > 0)
+//                {
+//                    sum += Math.Pow((point.Y - item[0].Y), 2);
+//                    count++;
+//                    pc += point.Y - item[0].Y;
+//                }
+//            }
+//            sum = Math.Sqrt(sum);
+//            count = Math.Sqrt(count);
+//            max = max * count;
+//            if (max != 0)
+//            {
+//                result = sum / max * 100;
+//            }
+//
+//            if (pc < 0)
+//            {
+//                result = 0 - result;
+//            }
+//        }
+//        return result;
+//    }
+//    //曲线偏差率2
+//    private double pcl2(List<MyMath.Point> Points1, List<MyMath.Point> Points2, decimal modelpower, double speed)
+//    {
+//        double minSpeed = speed;
+//        double maxSpeed = minSpeed + 1;
+//        double result = -0;
+//        double pc = 0;
+//        if (Points1 != null && Points1.Count != 0 && Points2 != null && Points2.Count != 0)
+//        {
+//            double count = 0;
+//            double sum = 0;
+//            double max = (double)modelpower;
+//            foreach (MyMath.Point point in Points1)
+//            {
+//                var item = Points2.Where(it => it.X == point.X).ToList();
+//                if (item != null && item.Count > 0 && item[0].X >= minSpeed && item[0].X < maxSpeed)
+//                {
+//                    sum += Math.Pow((point.Y - item[0].Y), 2);
+//                    count++;
+//                    pc += point.Y - item[0].Y;
+//                }
+//            }
+//            sum = Math.Sqrt(sum);
+//            count = Math.Sqrt(count);
+//            max = max * count;
+//            if (max != 0)
+//            {
+//                result = sum / max * 100;
+//            }
+//
+//            if (pc < 0)
+//            {
+//                result = 0 - result;
+//            }
+//        }
+//        return result;
+//    }
+//
+//
+//    //功率曲线拟合
+//    public void CurveFittingBuilder(Date begin, Date end, int dimension, double scale, String pointIdGL, String pointIdFS, String pointIdZT, List<MyMath.Point> myPoints, List<MyMath.Point> myPointsFF, String windturbineId)
+//    {
+//        double maxPower = (double)windturbineCapacity[windturbineId] * 1.3;
+//        List<PointF> pointsF = new List<PointF>();
+//        Dictionary<float, PointF> pointsFF = new Dictionary<float, PointF>();
+//
+//        if (end > begin)
+//        {
+//            if (String.Empty != pointIdGL && String.Empty != pointIdFS)
+//            {
+//                var glpoints = ednaHelper.GetHisData(pointIdGL, begin, end);
+//                var fspoints = ednaHelper.GetHisData(pointIdFS, begin, end);
+//                var ztpoints = ednaHelper.GetHisData(pointIdZT, begin, end);
+//
+//                //var ztpoints2 = GoldenHelper.GetHisData(pointIdZT2, begin, end);
+//
+//                //Console.WriteLine(ztpoints2);
+//
+//
+//                if (glpoints.Count != fspoints.Count || glpoints.Count != ztpoints.Count)
+//                {
+//                    for (int i = 0; i < fspoints.Count; i++)
+//                    {
+//                        double x = double.Parse(fspoints[i].value.ToString());
+//                        double y = -1;
+//                        double z = -1;
+//                        double z1 = -1;
+//                        var yArray = glpoints.Where(it => it.time == fspoints[i].time).ToList();
+//                        if (yArray != null && yArray.Count > 0)
+//                        {
+//
+//                            y = double.Parse(yArray[0].value.ToString());
+//                        }
+//
+//                        yArray = ztpoints.Where(it => it.time == fspoints[i].time).ToList();
+//                        if (yArray != null && yArray.Count > 0)
+//                        {
+//
+//                            z = double.Parse(yArray[0].value.ToString());
+//                        }
+//
+//                        //yArray = ztpoints2.Where(it => it.time == fspoints[i].time).ToList();
+//                        //if (yArray != null && yArray.Count > 0)
+//                        //{
+//                        //    z1 = double.Parse(yArray[0].value.ToString());
+//                        //}
+//
+//                        float x1 = (float)Math.Round(x, 2);
+//                        float y1 = (float)y;
+//
+//
+//                        bool b = true;
+//                        if (type == "GDC")
+//                            b = (x >= 0 && y > 0);
+//                        else
+//                        if (z == 2)
+//                        {
+//
+//                            b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
+//
+//                            if (b)
+//                            {
+//                                if (x > 3 && y <= 0)
+//                                {
+//                                    b = false;
+//                                }
+//                                if (x <= 3 && y > 0)
+//                                {
+//                                    b = false;
+//                                }
+//                            }
+//
+//                        }
+//                        else
+//                        {
+//                            b = false;
+//                        }
+//                        if (b)
+//                        {
+//                            pointsF.Add(new PointF(x1, y1));
+//
+//                            if (pointsFF.ContainsKey(x1))
+//                            {
+//                                if (pointsFF[x1].Y < y1)
+//                                {
+//                                    pointsFF[x1] = new PointF(x1, y1);
+//                                }
+//                            }
+//                            else
+//                            {
+//                                pointsFF.Add(x1, new PointF(x1, y1));
+//                            }
+//
+//
+//                        }
+//
+//
+//
+//                    }
+//                }
+//                else
+//                {
+//
+//                    for (int i = 0; i < fspoints.Count; i++)
+//                    {
+//                        double x = double.Parse(fspoints[i].value.ToString());
+//                        double y = double.Parse(glpoints[i].value.ToString());
+//                        double z = double.Parse(ztpoints[i].value.ToString());
+//                        //double z1 = double.Parse(ztpoints2[i].value.ToString());
+//
+//                        float x1 = (float)Math.Round(x, 2);
+//                        float y1 = (float)y;
+//
+//
+//                        bool b = true;
+//                        if (type == "GDC")
+//                            b = (x >= 0 && y > 0);
+//                        else
+//                        {
+//                            if (z == 2)
+//                            {
+//
+//                                b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
+//
+//                                if (b)
+//                                {
+//                                    if (x > 3 && y <= 0)
+//                                    {
+//                                        b = false;
+//                                    }
+//                                    if (x <= 3 && y > 0)
+//                                    {
+//                                        b = false;
+//                                    }
+//                                }
+//
+//                            }
+//                            else
+//                            {
+//                                b = false;
+//                            }
+//                        }
+//                        if (b)
+//                        {
+//                            pointsF.Add(new PointF(x1, y1));
+//
+//                            if (pointsFF.ContainsKey(x1))
+//                            {
+//                                if (pointsFF[x1].Y < y1)
+//                                {
+//                                    pointsFF[x1] = new PointF(x1, y1);
+//                                }
+//                            }
+//                            else
+//                            {
+//                                pointsFF.Add(x1, new PointF(x1, y1));
+//                            }
+//
+//                        }
+//                    }
+//                }
+//                pointsF.Add(new PointF(0, 0));
+//
+//                pointsF = pointsF.Where(it => it.X >= 3).OrderBy(it => it.X).ToList();
+//
+//                var temp = MyMath.Line.BuildLine(pointsF.Select(it => (double)it.X).ToArray(), pointsF.Select(it => (double)it.Y).ToArray(), pointsF.Count, dimension, scale);
+//
+//                myPoints.AddRange(temp);
+//                if (myPoints != null && myPoints.Count != 0)
+//                {
+//                    BuildMyPoints(myPoints, scale);
+//                }
+//
+//
+//
+//                if (!pointsFF.ContainsKey(0))
+//                    pointsFF.Add(0, new PointF(0, 0));
+//
+//                List<PointF> FF = pointsFF.Values.Where(it => it.X >= 3).OrderBy(it => it.X).ToList();
+//                if (FF != null && FF.Count != 0)
+//                {
+//                    temp = MyMath.Line.BuildLine(FF.Select(it => (double)it.X).ToArray(), FF.Select(it => (double)it.Y).ToArray(), FF.Count, dimension, scale);
+//                }
+//                myPointsFF.AddRange(temp);
+//                if (myPointsFF != null && myPointsFF.Count != 0)
+//                {
+//                    BuildMyPoints(myPointsFF, scale);
+//                }
+//
+//                myPoints = myPoints.Where(it => it.X >= 0 && it.X <= 25).OrderBy(it => it.X).ToList();
+//
+//                myPointsFF = myPointsFF.Where(it => it.X >= 0 && it.X <= 25).OrderBy(it => it.X).ToList();
+//            }
+//        }
+//    }
+//
+//    private static void BuildMyPoints(List<MyMath.Point> myPoints, double scale)
+//    {
+//        int coefficient = 1;
+//        int dec = 0;
+//        int smax = 25;
+//        if (scale == 0.01)
+//        {
+//            coefficient = 100;
+//            dec = 2;
+//        }
+//        if (scale == 0.1)
+//        {
+//            coefficient = 10;
+//            dec = 1;
+//        }
+//
+//        smax *= coefficient;
+//
+//
+//
+//        double min = myPoints.Min(it => it.X) * coefficient;
+//        double max = myPoints.Max(it => it.X) * coefficient;
+//
+//        double maxval = myPoints.Max(it => it.Y);
+//
+//        for (double i = 0; i < min; i += 1)
+//        {
+//            MyMath.Point point = new MyMath.Point();
+//            point.X = Math.Round(i / coefficient, dec);
+//            point.Y = 0;
+//            myPoints.Add(point);
+//        }
+//        //var tt = myPoints.Where(it => it.X == 3).ToList();
+//
+//        //Console.WriteLine(tt);
+//
+//        for (double i = smax; i > max; i -= 1)
+//        {
+//            MyMath.Point point = new MyMath.Point();
+//            point.X = Math.Round(i / coefficient, dec);
+//            point.Y = maxval;
+//            myPoints.Add(point);
+//        }
+//    }
+//
+//    private static void BuildMyPoints2(List<MyMath.Point> myPoints)
+//    {
+//        double min = myPoints.Min(it => it.X);
+//        double max = myPoints.Max(it => it.X);
+//
+//        double maxval = myPoints.Max(it => it.Y);
+//
+//        for (int i = 0; i < min; i += 1)
+//        {
+//            MyMath.Point point = new MyMath.Point();
+//            point.X = i;
+//            point.Y = 0;
+//            myPoints.Add(point);
+//        }
+//        //var tt = myPoints.Where(it => it.X == 3).ToList();
+//
+//        //Console.WriteLine(tt);
+//
+//        for (int i = 25; i > max; i -= 1)
+//        {
+//            MyMath.Point point = new MyMath.Point();
+//            point.X = i;
+//            point.Y = maxval;
+//            myPoints.Add(point);
+//        }
+//    }
+//}
+//}