合併
This commit is contained in:
		
						commit
						bca579903b
					
				@ -19,4 +19,8 @@ namespace Backend.Models
 | 
				
			|||||||
        public byte Is_complete { get; set; }
 | 
					        public byte Is_complete { get; set; }
 | 
				
			||||||
        public double Repeat_times { get; set; }
 | 
					        public double Repeat_times { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    public class archiveTable
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public string archive_yyyymm { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@
 | 
				
			|||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Security.Permissions;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Backend.Models
 | 
					namespace Backend.Models
 | 
				
			||||||
@ -80,6 +81,16 @@ namespace Backend.Models
 | 
				
			|||||||
        public string device_system_tag { get; set; } 
 | 
					        public string device_system_tag { get; set; } 
 | 
				
			||||||
        public List<DeviceDisaster> Device_disasters { get; set; } //防災類型
 | 
					        public List<DeviceDisaster> Device_disasters { get; set; } //防災類型
 | 
				
			||||||
        public List<DeviceNode> Device_nodes { get; set; } //設備子節點
 | 
					        public List<DeviceNode> Device_nodes { get; set; } //設備子節點
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 前次成功日期;下次重新歸檔日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public System.DateTime archive_lastDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 前次執行日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public System.DateTime archive_lastActionDate { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class DeviceDisaster
 | 
					    public class DeviceDisaster
 | 
				
			||||||
@ -264,6 +275,16 @@ namespace Backend.Models
 | 
				
			|||||||
        public string DeviceNumber { get; set; }
 | 
					        public string DeviceNumber { get; set; }
 | 
				
			||||||
        public string Point { get; set; }
 | 
					        public string Point { get; set; }
 | 
				
			||||||
        public string FullDeviceNumberPoint { get; set; }
 | 
					        public string FullDeviceNumberPoint { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 前次成功日期;下次重新歸檔日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public System.DateTime archive_lastDate { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 前次執行日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        //public System.DateTime archive_lastActionDate { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class ImportDevForCoo
 | 
					    public class ImportDevForCoo
 | 
				
			||||||
 | 
				
			|||||||
@ -45,6 +45,15 @@ namespace Backend.Models
 | 
				
			|||||||
        public byte is_bool { get; set; }
 | 
					        public byte is_bool { get; set; }
 | 
				
			||||||
        public byte is_link { get; set; }
 | 
					        public byte is_link { get; set; }
 | 
				
			||||||
        public int is_show_history { get; set; }
 | 
					        public int is_show_history { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 歸檔作業暫存用 - 啟動的開始日期, value = (table)device.archive_lastDate 前次成功日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string start_archive_day { get; set; }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 歸檔作業暫存用 - 啟動的結束日期, value = 執行的當下日期
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public string end_archive_day { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class Checksame
 | 
					    public class Checksame
 | 
				
			||||||
 | 
				
			|||||||
@ -69,7 +69,7 @@ namespace BackendWorkerService.Quartz
 | 
				
			|||||||
            string Times = null;
 | 
					            string Times = null;
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var sql = $@"select b.system_value from task_detail a
 | 
					                var sql = $@" select b.system_value from task_detail a
 | 
				
			||||||
                                join variable b on a.variable_id = b.id
 | 
					                                join variable b on a.variable_id = b.id
 | 
				
			||||||
                                where a.task = '{task}' and a.task_item = '{task_item}'";
 | 
					                                where a.task = '{task}' and a.task_item = '{task_item}'";
 | 
				
			||||||
                Times = await backendRepository.GetOneAsync<string>(sql);
 | 
					                Times = await backendRepository.GetOneAsync<string>(sql);
 | 
				
			||||||
@ -95,12 +95,16 @@ namespace BackendWorkerService.Quartz
 | 
				
			|||||||
                            where a.task = '{task}' and a.task_item = '{task_item}'";
 | 
					                            where a.task = '{task}' and a.task_item = '{task_item}'";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var lastworkTime = await backendRepository.GetOneAsync<string>(sql);
 | 
					                var lastworkTime = await backendRepository.GetOneAsync<string>(sql);
 | 
				
			||||||
 | 
					                if (task_item == "Compensate")
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    string ss = "";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                DateTime dateTime = lastworkTime != null ? Convert.ToDateTime(lastworkTime) : Convert.ToDateTime("1970-01-01 00:00:01");
 | 
					                DateTime dateTime = lastworkTime != null ? Convert.ToDateTime(lastworkTime) : Convert.ToDateTime("1970-01-01 00:00:01");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var nextTime = CrontabSchedule.Parse(await GetWorkRule(task, task_item), new ParseOptions { IncludingSeconds = true } ).GetNextOccurrence(dateTime);
 | 
					                //取得 variable 中的 crob 時間設定 ex: 0 0/1 * * * *
 | 
				
			||||||
 | 
					                var crobTime = await GetWorkRule(task, task_item);
 | 
				
			||||||
 | 
					                var nextTime = CrontabSchedule.Parse(crobTime, new ParseOptions { IncludingSeconds = true } ).GetNextOccurrence(dateTime);
 | 
				
			||||||
                if (DateTime.Now >= nextTime)
 | 
					                if (DateTime.Now >= nextTime)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    return true;
 | 
					                    return true;
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -82,7 +82,7 @@ namespace BackendWorkerService.Quartz.Jobs
 | 
				
			|||||||
                            var spaceResponseResult = JsonConvert.DeserializeObject<SpaceResponse>(spaceResponseContent);
 | 
					                            var spaceResponseResult = JsonConvert.DeserializeObject<SpaceResponse>(spaceResponseContent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            //取得停車場車位對應表
 | 
					                            //取得停車場車位對應表
 | 
				
			||||||
                            var sqlSapceMapping = $@"SELECT * FROM variable WHERE deleted = 0 AND system_type = 'parkingSapceMapping'";
 | 
					                            var sqlSapceMapping = $@" SELECT * FROM variable WHERE deleted = 0 AND system_type = 'parkingSapceMapping'";
 | 
				
			||||||
                            var parkingSapceMapping = await backgroundServiceRepository.GetAllAsync<VariableInfo>(sqlSapceMapping);
 | 
					                            var parkingSapceMapping = await backgroundServiceRepository.GetAllAsync<VariableInfo>(sqlSapceMapping);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if (spaceResponseResult != null && spaceResponseResult.Code == "20000")
 | 
					                            if (spaceResponseResult != null && spaceResponseResult.Code == "20000")
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -7,6 +7,8 @@
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "LoggerPath": "C:\\inetpub\\Taipei_dome_background_service\\Logs",
 | 
					  "LoggerPath": "C:\\inetpub\\Taipei_dome_background_service\\Logs",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //MIN HOUR DOM MON DOW CMD
 | 
				
			||||||
  "BackgroundServiceCron": {
 | 
					  "BackgroundServiceCron": {
 | 
				
			||||||
    "ExecutionBackgroundServicePlanJob": "0 0 2 * * ?",
 | 
					    "ExecutionBackgroundServicePlanJob": "0 0 2 * * ?",
 | 
				
			||||||
    "MessageNotificationJob": "0 0 2 * * ?",
 | 
					    "MessageNotificationJob": "0 0 2 * * ?",
 | 
				
			||||||
@ -14,7 +16,7 @@
 | 
				
			|||||||
    "RegularUpdateDBTableJob": "0 0 2 * * ?",
 | 
					    "RegularUpdateDBTableJob": "0 0 2 * * ?",
 | 
				
			||||||
    "ParkingJob": "0 0 2 * * ?",
 | 
					    "ParkingJob": "0 0 2 * * ?",
 | 
				
			||||||
    "ArchiveElectricMeterHourJob": "0 0 2 * * ?",
 | 
					    "ArchiveElectricMeterHourJob": "0 0 2 * * ?",
 | 
				
			||||||
    "ArchiveElectricMeterDayJob": "0/5 * * * * ?",
 | 
					    "ArchiveElectricMeterDayJob": "0/2 * * * * ?", //每 5分鐘
 | 
				
			||||||
    "WeatherAPIJob": "0 0 2 * * ?"
 | 
					    "WeatherAPIJob": "0 0 2 * * ?"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "DBConfig": {
 | 
					  "DBConfig": {
 | 
				
			||||||
@ -25,7 +27,8 @@
 | 
				
			|||||||
      //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
 | 
					      //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
 | 
				
			||||||
      //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
 | 
					      //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
 | 
				
			||||||
      //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
 | 
					      //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
 | 
				
			||||||
      "Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
 | 
					      //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
 | 
				
			||||||
 | 
					      "Database": "j9LOmjFh2/9PpuwnVB8ugqnKdBDJHx1AAT7aTWeh37E=", //ibms_mcut_online
 | 
				
			||||||
      "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
 | 
					      "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
 | 
				
			||||||
      "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
 | 
					      "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1144
									
								
								Frontend/_alert.html
									
									
									
									
									
								
							
							
						
						
									
										1144
									
								
								Frontend/_alert.html
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -199,7 +199,7 @@
 | 
				
			|||||||
                   class="panel"
 | 
					                   class="panel"
 | 
				
			||||||
                   style="height: calc(100% - 1.5rem)">
 | 
					                   style="height: calc(100% - 1.5rem)">
 | 
				
			||||||
                <div class="panel-hdr">
 | 
					                <div class="panel-hdr">
 | 
				
			||||||
                  <h2>即時契約容量占比 - 第一校區</h2>
 | 
					                  <h2>即時契約容量占比 - 第一校區 <span id="contractCapacityForArea1">--</span></h2>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div class="panel-container show h-100">
 | 
					                <div class="panel-container show h-100">
 | 
				
			||||||
                  <div id="contractValueChart" style="height: 240px"></div>
 | 
					                  <div id="contractValueChart" style="height: 240px"></div>
 | 
				
			||||||
@ -211,7 +211,7 @@
 | 
				
			|||||||
                   class="panel"
 | 
					                   class="panel"
 | 
				
			||||||
                   style="height: calc(100% - 1.5rem)">
 | 
					                   style="height: calc(100% - 1.5rem)">
 | 
				
			||||||
                <div class="panel-hdr">
 | 
					                <div class="panel-hdr">
 | 
				
			||||||
                  <h2>即時契約容量占比 - 第二校區</h2>
 | 
					                  <h2>即時契約容量占比 - 第二校區 <span id="contractCapacityForArea2">--</span></</h2>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div class="panel-container h-100 show">
 | 
					                <div class="panel-container h-100 show">
 | 
				
			||||||
                  <div id="contractValueChart2" style="height: 240px"></div>
 | 
					                  <div id="contractValueChart2" style="height: 240px"></div>
 | 
				
			||||||
@ -441,11 +441,11 @@
 | 
				
			|||||||
    let devPath = tarElePath.split("/")[1]?.split("_").slice(0, 8).join("/");
 | 
					    let devPath = tarElePath.split("/")[1]?.split("_").slice(0, 8).join("/");
 | 
				
			||||||
    let tempOrdPath = { devicePath: devPath };
 | 
					    let tempOrdPath = { devicePath: devPath };
 | 
				
			||||||
    let myBaja = new subscriptionElectricmeter();
 | 
					    let myBaja = new subscriptionElectricmeter();
 | 
				
			||||||
 | 
					    const deviceTag = devPath.split("/")[devPath.split("/").length - 1]
 | 
				
			||||||
    myBaja.setSubscribeElectricmeterByBql(tempOrdPath);
 | 
					    myBaja.setSubscribeElectricmeterByBql(tempOrdPath);
 | 
				
			||||||
      myBaja.setSubscribeElectricmeterCallBack(function (data) {
 | 
					      myBaja.setSubscribeElectricmeterCallBack(function (data) {
 | 
				
			||||||
      if (data.point_name == "P") {
 | 
					          if (data.point_name === "P" && data.device_number === deviceTag) {
 | 
				
			||||||
        let value = parseFloat(data.value).roundDecimal(2);
 | 
					          let value = parseFloat(data.value.replaceAll(",", "")).roundDecimal(2);
 | 
				
			||||||
        $("#insPower").text(value);
 | 
					        $("#insPower").text(value);
 | 
				
			||||||
        // $("#insPowerPer").text((value / 4).roundDecimal(2));
 | 
					        // $("#insPowerPer").text((value / 4).roundDecimal(2));
 | 
				
			||||||
        $("#insPowerPer").text((value / contractCapacity).roundDecimal(2));
 | 
					        $("#insPowerPer").text((value / contractCapacity).roundDecimal(2));
 | 
				
			||||||
@ -469,9 +469,11 @@
 | 
				
			|||||||
            ({ point_name }) => point_name === "Capacity"
 | 
					            ({ point_name }) => point_name === "Capacity"
 | 
				
			||||||
          )?.value;
 | 
					          )?.value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        $("#contractCapacityForArea1").text(` (${contractCapacityForchart1} kW)`);
 | 
				
			||||||
        chartContractValue(
 | 
					        chartContractValue(
 | 
				
			||||||
          "contractValueChart",
 | 
					          "contractValueChart",
 | 
				
			||||||
          ((value / contractCapacityForchart1) * 100).roundDecimal(2)
 | 
					          Math.round((value / contractCapacityForchart1) * 100),
 | 
				
			||||||
 | 
					          value
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      } else if (value && compus === "Area2") {
 | 
					      } else if (value && compus === "Area2") {
 | 
				
			||||||
        if (data.some(({ point_name }) => point_name === "Capacity")) {
 | 
					        if (data.some(({ point_name }) => point_name === "Capacity")) {
 | 
				
			||||||
@ -479,9 +481,11 @@
 | 
				
			|||||||
            ({ point_name }) => point_name === "Capacity"
 | 
					            ({ point_name }) => point_name === "Capacity"
 | 
				
			||||||
          )?.value;
 | 
					          )?.value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        $("#contractCapacityForArea2").text(` (${contractCapacityForchart2} kW)`);
 | 
				
			||||||
        chartContractValue(
 | 
					        chartContractValue(
 | 
				
			||||||
          "contractValueChart2",
 | 
					          "contractValueChart2",
 | 
				
			||||||
          ((value / contractCapacityForchart2) * 100).roundDecimal(2)
 | 
					          Math.round((value / contractCapacityForchart2) * 100),
 | 
				
			||||||
 | 
					          value
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -1121,7 +1125,7 @@
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 圖表 - 取得契約容量
 | 
					  // 圖表 - 取得契約容量
 | 
				
			||||||
  function chartContractValue(ele, value) {
 | 
					  function chartContractValue(ele, value, pValue) {
 | 
				
			||||||
    var chartDom = document.getElementById(ele);
 | 
					    var chartDom = document.getElementById(ele);
 | 
				
			||||||
    contractValueChart = echarts.init(chartDom, null, {
 | 
					    contractValueChart = echarts.init(chartDom, null, {
 | 
				
			||||||
      renderer: "canvas",
 | 
					      renderer: "canvas",
 | 
				
			||||||
@ -1132,6 +1136,9 @@
 | 
				
			|||||||
      series: [
 | 
					      series: [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          type: "gauge",
 | 
					          type: "gauge",
 | 
				
			||||||
 | 
					          //startAngle: 180,
 | 
				
			||||||
 | 
					          //endAngle: 0,
 | 
				
			||||||
 | 
					          //center: ['50%', '60%'],
 | 
				
			||||||
          axisLine: {
 | 
					          axisLine: {
 | 
				
			||||||
            lineStyle: {
 | 
					            lineStyle: {
 | 
				
			||||||
              width: 30,
 | 
					              width: 30,
 | 
				
			||||||
@ -1171,13 +1178,13 @@
 | 
				
			|||||||
          },
 | 
					          },
 | 
				
			||||||
          detail: {
 | 
					          detail: {
 | 
				
			||||||
            valueAnimation: true,
 | 
					            valueAnimation: true,
 | 
				
			||||||
            formatter: "{value} %",
 | 
					            formatter: (value) => { return `\t\n ${value} % \t\n ${Math.round(pValue)} kW` },
 | 
				
			||||||
            color: "inherit",
 | 
					            color: "inherit",
 | 
				
			||||||
            fontSize: 20,
 | 
					            fontSize: 20,
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          data: [
 | 
					          data: [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              value,
 | 
					              value
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
          ],
 | 
					          ],
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
				
			|||||||
@ -6,14 +6,17 @@
 | 
				
			|||||||
      <div class="rounded border border-white">
 | 
					      <div class="rounded border border-white">
 | 
				
			||||||
        <div class="d-flex position-relative py-3 px-4">
 | 
					        <div class="d-flex position-relative py-3 px-4">
 | 
				
			||||||
          <i class="fal fa-search color-success-700 position-absolute pos-left fs-lg px-3 py-2 mt-1 ml-4"></i>
 | 
					          <i class="fal fa-search color-success-700 position-absolute pos-left fs-lg px-3 py-2 mt-1 ml-4"></i>
 | 
				
			||||||
          <input type="text" id="js_nested_list_filter" class="form-control shadow-inset-1 pl-6 border-success" placeholder="輸入兩字以上">
 | 
					          <input type="text"
 | 
				
			||||||
 | 
					                 id="js_nested_list_filter"
 | 
				
			||||||
 | 
					                 class="form-control shadow-inset-1 pl-6 border-success"
 | 
				
			||||||
 | 
					                 placeholder="輸入兩字以上" />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <!-- nav-menu-reset will reset the font colors -->
 | 
					        <!-- nav-menu-reset will reset the font colors -->
 | 
				
			||||||
        <ul id="js_nested_list" class="nav-menu nav-menu-reset nav-menu-compact mb-sm-4 mb-md-0 rounded border border-white" data-nav-accordion="true">
 | 
					        <ul id="js_nested_list"
 | 
				
			||||||
        </ul>
 | 
					            class="nav-menu nav-menu-reset nav-menu-compact mb-sm-4 mb-md-0 rounded border border-white"
 | 
				
			||||||
 | 
					            data-nav-accordion="true"></ul>
 | 
				
			||||||
        <div class="filter-message js-filter-message m-0 text-left pl-4 py-3 fw-500"></div>
 | 
					        <div class="filter-message js-filter-message m-0 text-left pl-4 py-3 fw-500"></div>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div class="col-sm-12 col-xl-10">
 | 
					    <div class="col-sm-12 col-xl-10">
 | 
				
			||||||
      <div class="row bg-dark p-2">
 | 
					      <div class="row bg-dark p-2">
 | 
				
			||||||
@ -27,31 +30,65 @@
 | 
				
			|||||||
      <div class="row bg-dark p-2 mb-5 align-items-center">
 | 
					      <div class="row bg-dark p-2 mb-5 align-items-center">
 | 
				
			||||||
        <div class="col-auto">
 | 
					        <div class="col-auto">
 | 
				
			||||||
          <div class="btn-group">
 | 
					          <div class="btn-group">
 | 
				
			||||||
            <button type="button" onclick="setDateType('day', this)" class="btn btn-secondary waves-effect waves-themed">日期</button>
 | 
					            <button type="button"
 | 
				
			||||||
            <button type="button" onclick="setDateType('range', this)" class="btn btn-secondary waves-effect waves-themed">區間</button>
 | 
					                    onclick="setDateType('day', this)"
 | 
				
			||||||
            <button type="button" onclick="setDateType('month', this)" class="btn btn-secondary waves-effect waves-themed">月</button>
 | 
					                    class="btn btn-secondary waves-effect waves-themed">
 | 
				
			||||||
 | 
					              日期
 | 
				
			||||||
 | 
					            </button>
 | 
				
			||||||
 | 
					            <button type="button"
 | 
				
			||||||
 | 
					                    onclick="setDateType('range', this)"
 | 
				
			||||||
 | 
					                    class="btn btn-secondary waves-effect waves-themed">
 | 
				
			||||||
 | 
					              區間
 | 
				
			||||||
 | 
					            </button>
 | 
				
			||||||
 | 
					            <button type="button"
 | 
				
			||||||
 | 
					                    onclick="setDateType('month', this)"
 | 
				
			||||||
 | 
					                    class="btn btn-secondary waves-effect waves-themed">
 | 
				
			||||||
 | 
					              月
 | 
				
			||||||
 | 
					            </button>
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="col-auto">
 | 
					        <div class="col-auto">
 | 
				
			||||||
          <div class="btn-group">
 | 
					          <div class="btn-group">
 | 
				
			||||||
            <button type="button" onclick="setDateType('today', this)" class="btn btn-secondary waves-effect waves-themed">今天</button>
 | 
					            <button type="button"
 | 
				
			||||||
            <button type="button" onclick="setDateType('ytd', this)" class="btn btn-secondary waves-effect waves-themed">昨天</button>
 | 
					                    onclick="setDateType('today', this)"
 | 
				
			||||||
 | 
					                    class="btn btn-secondary waves-effect waves-themed">
 | 
				
			||||||
 | 
					              今天
 | 
				
			||||||
 | 
					            </button>
 | 
				
			||||||
 | 
					            <button type="button"
 | 
				
			||||||
 | 
					                    onclick="setDateType('ytd', this)"
 | 
				
			||||||
 | 
					                    class="btn btn-secondary waves-effect waves-themed">
 | 
				
			||||||
 | 
					              昨天
 | 
				
			||||||
 | 
					            </button>
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="col-auto">
 | 
					        <div class="col-auto">
 | 
				
			||||||
          <div class="form-group">
 | 
					          <div class="form-group">
 | 
				
			||||||
            <input class="form-control flatpickr flatpickr-input selectDate" id="his_startdate" data-val="" type="date" name="date" value="">
 | 
					            <input class="form-control flatpickr flatpickr-input selectDate"
 | 
				
			||||||
            <input class="form-control" id="getmonth" type="month" style="display: none" />
 | 
					                   id="his_startdate"
 | 
				
			||||||
 | 
					                   data-val=""
 | 
				
			||||||
 | 
					                   type="date"
 | 
				
			||||||
 | 
					                   name="date"
 | 
				
			||||||
 | 
					                   value="" />
 | 
				
			||||||
 | 
					            <input class="form-control flatpickr flatpickr-input selectMonth"
 | 
				
			||||||
 | 
					                   id="getmonth"
 | 
				
			||||||
 | 
					                   type="month"
 | 
				
			||||||
 | 
					                   style="display: none" />
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="col-auto" id="his_enddate" style="display: none">
 | 
					        <div class="col-auto" id="his_enddate" style="display: none">
 | 
				
			||||||
          <div class="form-group">
 | 
					          <div class="form-group">
 | 
				
			||||||
            <input class="form-control" type="date" data-val="" name="date" value="">
 | 
					            <input class="form-control flatpickr flatpickr-input selectDate"
 | 
				
			||||||
 | 
					                   type="date"
 | 
				
			||||||
 | 
					                   data-val=""
 | 
				
			||||||
 | 
					                   name="date"
 | 
				
			||||||
 | 
					                   value="" />
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="col-auto">
 | 
					        <div class="col-auto">
 | 
				
			||||||
          <a href="#" onclick="searchDate()" class="btn btn-info">查詢</a>
 | 
					          <a href="#" onclick="searchDate()" class="btn btn-info">查詢</a>
 | 
				
			||||||
          <a href="#" onclick="exportExcel()" class="btn btn-info waves-effect waves-themed">
 | 
					          <a href="#"
 | 
				
			||||||
 | 
					             onclick="exportExcel()"
 | 
				
			||||||
 | 
					             class="btn btn-info waves-effect waves-themed">
 | 
				
			||||||
            <span class="fal fa-file-excel mr-1"></span>
 | 
					            <span class="fal fa-file-excel mr-1"></span>
 | 
				
			||||||
            匯出
 | 
					            匯出
 | 
				
			||||||
          </a>
 | 
					          </a>
 | 
				
			||||||
@ -59,29 +96,48 @@
 | 
				
			|||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="row-cols-1 mb-2">
 | 
					      <div class="row-cols-1 mb-2">
 | 
				
			||||||
        <div id="devPointsList" class="btn-group">
 | 
					        <div id="devPointsList" class="btn-group"></div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div>
 | 
					      <div>
 | 
				
			||||||
        <div class="frame-wrap">
 | 
					        <div class="frame-wrap">
 | 
				
			||||||
          <table id="historyTable" class="table table-bordered table-striped text-center m-0 w-100">
 | 
					          <table id="historyTable"
 | 
				
			||||||
          </table>
 | 
					                 class="table table-bordered table-striped text-center m-0 w-100"></table>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</main>
 | 
					</main>
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					  .flatpickr-monthDropdown-month {
 | 
				
			||||||
 | 
					    color: black !important;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
  var historyTable = null;
 | 
					  var historyTable = null;
 | 
				
			||||||
  var buildingTag = null;
 | 
					  var buildingTag = null;
 | 
				
			||||||
  pageAct.hisBuiName = "";
 | 
					  pageAct.hisBuiName = "";
 | 
				
			||||||
  hisFirst = true;
 | 
					  hisFirst = true;
 | 
				
			||||||
  $(function () {
 | 
					  $(function () {
 | 
				
			||||||
    flatpickr(".selectDate", {});
 | 
					    flatpickr(".selectDate", {
 | 
				
			||||||
 | 
					      locale: "zh_tw",
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    flatpickr(".selectMonth", {
 | 
				
			||||||
 | 
					      dateFormat: "Y-m",
 | 
				
			||||||
 | 
					      locale: "zh_tw",
 | 
				
			||||||
 | 
					      onMonthChange: (selectedDates, dateStr, instance) => {
 | 
				
			||||||
 | 
					        const curMon = new Date(
 | 
				
			||||||
 | 
					          `${instance.currentYear}-${instance.currentMonth + 1}`
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        instance.setDate(curMon);
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      onYearChange: (selectedDates, dateStr, instance) => {
 | 
				
			||||||
 | 
					        const curMon = new Date(
 | 
				
			||||||
 | 
					          `${instance.currentYear}-${instance.currentMonth + 1}`
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        instance.setDate(curMon);
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
    let html = "";
 | 
					    let html = "";
 | 
				
			||||||
    for (let building of pageAct.buildList) {
 | 
					    for (let building of pageAct.buildList) {
 | 
				
			||||||
      html += `<label class="btn btn-secondary">
 | 
					      html += `<label class="btn btn-secondary">
 | 
				
			||||||
@ -91,138 +147,174 @@
 | 
				
			|||||||
    $("#his_building").find(".item").empty();
 | 
					    $("#his_building").find(".item").empty();
 | 
				
			||||||
    $("#his_building").find(".item").append(html);
 | 
					    $("#his_building").find(".item").append(html);
 | 
				
			||||||
    if ($("#his_building .item label").first())
 | 
					    if ($("#his_building .item label").first())
 | 
				
			||||||
      $("#his_building .item label").first().click()
 | 
					      $("#his_building .item label").first().click();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    initList();
 | 
					    initList();
 | 
				
			||||||
    // default list filter
 | 
					    // default list filter
 | 
				
			||||||
    initApp.listFilter($('#js_default_list'), $('#js_default_list_filter'));
 | 
					    initApp.listFilter($("#js_default_list"), $("#js_default_list_filter"));
 | 
				
			||||||
    // custom response message
 | 
					    // custom response message
 | 
				
			||||||
    initApp.listFilter($('#js-list-msg'), $('#js-list-msg-filter'));
 | 
					    initApp.listFilter($("#js-list-msg"), $("#js-list-msg-filter"));
 | 
				
			||||||
    //accordion filter
 | 
					    //accordion filter
 | 
				
			||||||
    initApp.listFilter($('#js_list_accordion'), $('#js_list_accordion_filter'));
 | 
					    initApp.listFilter($("#js_list_accordion"), $("#js_list_accordion_filter"));
 | 
				
			||||||
    // nested list filter
 | 
					    // nested list filter
 | 
				
			||||||
    initApp.listFilter($('#js_nested_list'), $('#js_nested_list_filter'));
 | 
					    initApp.listFilter($("#js_nested_list"), $("#js_nested_list_filter"));
 | 
				
			||||||
    //init navigation
 | 
					    //init navigation
 | 
				
			||||||
    initApp.buildNavigation($('#js_nested_list'));
 | 
					    initApp.buildNavigation($("#js_nested_list"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    loadTable(null);
 | 
					    loadTable(null);
 | 
				
			||||||
    $(`[onclick="setDateType('day', this)"]`).click();
 | 
					    $(`[onclick="setDateType('day', this)"]`).click();
 | 
				
			||||||
    $(`[onclick="setDateType('today', this)"]`).click();
 | 
					    $(`[onclick="setDateType('today', this)"]`).click();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    onEvent('change', '#his_startdate', function () {
 | 
					    onEvent("change", "#his_startdate", function () {
 | 
				
			||||||
      let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
 | 
					      let today = displayDate(new Date(Date.now()), "date").replaceAll(
 | 
				
			||||||
      let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
 | 
					        "/",
 | 
				
			||||||
 | 
					        "-"
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					      let ytd = displayDate(
 | 
				
			||||||
 | 
					        new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)),
 | 
				
			||||||
 | 
					        "date"
 | 
				
			||||||
 | 
					      ).replaceAll("/", "-");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (pageAct.dateType == 'range') {
 | 
					      if (pageAct.dateType == "range") {
 | 
				
			||||||
        if ($('#his_startdate').val() > $('#his_enddate input').val() && ($('#his_startdate').val() != "" && $('#his_enddate input').val() != "")) {
 | 
					        if (
 | 
				
			||||||
          $('#his_startdate').val($('#his_startdate').data('val'));
 | 
					          $("#his_startdate").val() > $("#his_enddate input").val() &&
 | 
				
			||||||
          toast_error('不可選擇大於結束時間');
 | 
					          $("#his_startdate").val() != "" &&
 | 
				
			||||||
        }
 | 
					          $("#his_enddate input").val() != ""
 | 
				
			||||||
        else {
 | 
					        ) {
 | 
				
			||||||
          $('#his_startdate').data('val', $('#his_startdate').val());
 | 
					          $("#his_startdate").val($("#his_startdate").data("val"));
 | 
				
			||||||
          $('#his_enddate input').data('val', $('#his_enddate input').val());
 | 
					          toast_error("不可選擇大於結束時間");
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          $("#his_startdate").data("val", $("#his_startdate").val());
 | 
				
			||||||
 | 
					          $("#his_enddate input").data("val", $("#his_enddate input").val());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          $(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
 | 
					          $(`[onclick="setDateType('today', this)"]`).addClass("btn-secondary");
 | 
				
			||||||
          $(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
 | 
					          $(`[onclick="setDateType('today', this)"]`).removeClass("btn-info");
 | 
				
			||||||
          $(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
 | 
					          $(`[onclick="setDateType('ytd', this)"]`).addClass("btn-secondary");
 | 
				
			||||||
          $(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
 | 
					          $(`[onclick="setDateType('ytd', this)"]`).removeClass("btn-info");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if ($('#his_startdate').val() == $('#his_enddate input').val()) {
 | 
					          if ($("#his_startdate").val() == $("#his_enddate input").val()) {
 | 
				
			||||||
            if ($('#his_startdate').val() == today) {
 | 
					            if ($("#his_startdate").val() == today) {
 | 
				
			||||||
              $(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
 | 
					              $(`[onclick="setDateType('today', this)"]`).removeClass(
 | 
				
			||||||
              $(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
 | 
					                "btn-secondary"
 | 
				
			||||||
            }
 | 
					              );
 | 
				
			||||||
            else if ($('#his_startdate').val() == ytd) {
 | 
					              $(`[onclick="setDateType('today', this)"]`).addClass("btn-info");
 | 
				
			||||||
              $(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
 | 
					            } else if ($("#his_startdate").val() == ytd) {
 | 
				
			||||||
              $(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
 | 
					              $(`[onclick="setDateType('ytd', this)"]`).removeClass(
 | 
				
			||||||
 | 
					                "btn-secondary"
 | 
				
			||||||
 | 
					              );
 | 
				
			||||||
 | 
					              $(`[onclick="setDateType('ytd', this)"]`).addClass("btn-info");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      } else if ($(this).val() == today) {
 | 
				
			||||||
      else if ($(this).val() == today) {
 | 
					        $(`[onclick="setDateType('today', this)"]`).removeClass(
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
 | 
					          "btn-secondary"
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
 | 
					        );
 | 
				
			||||||
        $(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
 | 
					        $(`[onclick="setDateType('today', this)"]`).addClass("btn-info");
 | 
				
			||||||
        $(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
 | 
					        $(`[onclick="setDateType('ytd', this)"]`).addClass("btn-secondary");
 | 
				
			||||||
      }
 | 
					        $(`[onclick="setDateType('ytd', this)"]`).removeClass("btn-info");
 | 
				
			||||||
      else if ($(this).val() == ytd) {
 | 
					      } else if ($(this).val() == ytd) {
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
 | 
					        $(`[onclick="setDateType('today', this)"]`).addClass("btn-secondary");
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
 | 
					        $(`[onclick="setDateType('today', this)"]`).removeClass("btn-info");
 | 
				
			||||||
        $(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
 | 
					        $(`[onclick="setDateType('ytd', this)"]`).removeClass("btn-secondary");
 | 
				
			||||||
        $(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
 | 
					        $(`[onclick="setDateType('ytd', this)"]`).addClass("btn-info");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    onEvent('change', '#his_enddate input', function () {
 | 
					    onEvent("change", "#his_enddate input", function () {
 | 
				
			||||||
      let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
 | 
					      let today = displayDate(new Date(Date.now()), "date").replaceAll(
 | 
				
			||||||
      let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
 | 
					        "/",
 | 
				
			||||||
 | 
					        "-"
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					      let ytd = displayDate(
 | 
				
			||||||
 | 
					        new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)),
 | 
				
			||||||
 | 
					        "date"
 | 
				
			||||||
 | 
					      ).replaceAll("/", "-");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if ($('#his_startdate').val() > $('#his_enddate input').val() && ($('#his_startdate').val() != "" && $('#his_enddate input').val() != "")) {
 | 
					      if (
 | 
				
			||||||
        $('#his_enddate input').val($('#his_enddate input').data('val'));
 | 
					        $("#his_startdate").val() > $("#his_enddate input").val() &&
 | 
				
			||||||
        toast_error('不可選擇大於結束時間');
 | 
					        $("#his_startdate").val() != "" &&
 | 
				
			||||||
      }
 | 
					        $("#his_enddate input").val() != ""
 | 
				
			||||||
      else {
 | 
					      ) {
 | 
				
			||||||
        $('#his_startdate').data('val', $('#his_startdate').val());
 | 
					        $("#his_enddate input").val($("#his_enddate input").data("val"));
 | 
				
			||||||
        $('#his_enddate input').data('val', $('#his_enddate input').val());
 | 
					        toast_error("不可選擇大於結束時間");
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        $("#his_startdate").data("val", $("#his_startdate").val());
 | 
				
			||||||
 | 
					        $("#his_enddate input").data("val", $("#his_enddate input").val());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
 | 
					        $(`[onclick="setDateType('today', this)"]`).addClass("btn-secondary");
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
 | 
					        $(`[onclick="setDateType('today', this)"]`).removeClass("btn-info");
 | 
				
			||||||
        $(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
 | 
					        $(`[onclick="setDateType('ytd', this)"]`).addClass("btn-secondary");
 | 
				
			||||||
        $(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
 | 
					        $(`[onclick="setDateType('ytd', this)"]`).removeClass("btn-info");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($('#his_startdate').val() == $('#his_enddate input').val()) {
 | 
					        if ($("#his_startdate").val() == $("#his_enddate input").val()) {
 | 
				
			||||||
          if ($('#his_startdate').val() == today) {
 | 
					          if ($("#his_startdate").val() == today) {
 | 
				
			||||||
            $(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
 | 
					            $(`[onclick="setDateType('today', this)"]`).removeClass(
 | 
				
			||||||
            $(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
 | 
					              "btn-secondary"
 | 
				
			||||||
          }
 | 
					            );
 | 
				
			||||||
          else if ($('#his_startdate').val() == ytd) {
 | 
					            $(`[onclick="setDateType('today', this)"]`).addClass("btn-info");
 | 
				
			||||||
            $(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
 | 
					          } else if ($("#his_startdate").val() == ytd) {
 | 
				
			||||||
            $(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
 | 
					            $(`[onclick="setDateType('ytd', this)"]`).removeClass(
 | 
				
			||||||
 | 
					              "btn-secondary"
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            $(`[onclick="setDateType('ytd', this)"]`).addClass("btn-info");
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function initList() {
 | 
					  function initList() {
 | 
				
			||||||
    let sendData = {
 | 
					    let sendData = {
 | 
				
			||||||
      building_tag: buildingTag
 | 
					      building_tag: buildingTag,
 | 
				
			||||||
    }
 | 
					    };
 | 
				
			||||||
    objSendData.Data = sendData;
 | 
					    objSendData.Data = sendData;
 | 
				
			||||||
    let url = baseApiUrl + "/api/History/GetMainSub";
 | 
					    let url = baseApiUrl + "/api/History/GetMainSub";
 | 
				
			||||||
    function success(res) {
 | 
					    function success(res) {
 | 
				
			||||||
      let strHtml = ``;
 | 
					      let strHtml = ``;
 | 
				
			||||||
      let i1 = null, i2 = null, first = true;
 | 
					      let i1 = null,
 | 
				
			||||||
 | 
					        i2 = null,
 | 
				
			||||||
 | 
					        first = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $.each(res.data.history_Main_Systems, function (index, val) {
 | 
					      $.each(res.data.history_Main_Systems, function (index, val) {
 | 
				
			||||||
        if (pageAct.mainStatus) {
 | 
					        if (pageAct.mainStatus) {
 | 
				
			||||||
          strHtml += `<li>
 | 
					          strHtml += `<li>
 | 
				
			||||||
                                    <a href="#" data-filter-tags="${val.full_name.toLowerCase()}" data-maintag="${val.main_system_tag}">
 | 
					                                      <a href="#" data-filter-tags="${val.full_name.toLowerCase()}" data-maintag="${val.main_system_tag
 | 
				
			||||||
                                        <span class="nav-link-text">${val.full_name}</span>
 | 
					            }">
 | 
				
			||||||
 | 
					                                          <span class="nav-link-text">${val.full_name
 | 
				
			||||||
 | 
					            }</span>
 | 
				
			||||||
                                          </a>
 | 
					                                          </a>
 | 
				
			||||||
                                        <ul style="${index == 0 ? `display:block;` : ``}">`;
 | 
					                                          <ul style="${index == 0 ? `display:block;` : ``
 | 
				
			||||||
 | 
					            }">`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          i1 = (val.history_Sub_systems != null && i1 == null) ? index : null;
 | 
					          i1 = val.history_Sub_systems != null && i1 == null ? index : null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $.each(val.history_Sub_systems, function (index2, val2) {
 | 
					        $.each(val.history_Sub_systems, function (index2, val2) {
 | 
				
			||||||
          i2 = (val2.device != null && i2 == null) ? index2 : null;
 | 
					          i2 = val2.device != null && i2 == null ? index2 : null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          strHtml += `<li>
 | 
					          strHtml += `<li>
 | 
				
			||||||
                                    <a href="#" data-filter-tags="${val2.full_name.toLowerCase()}"  data-subtag="${val2.sub_system_tag}">
 | 
					                                      <a href="#" data-filter-tags="${val2.full_name.toLowerCase()}"  data-subtag="${val2.sub_system_tag
 | 
				
			||||||
 | 
					            }">
 | 
				
			||||||
                                          <span class="nav-link-text">
 | 
					                                          <span class="nav-link-text">
 | 
				
			||||||
                                              ${val2.full_name}
 | 
					                                              ${val2.full_name}
 | 
				
			||||||
                                          </span>
 | 
					                                          </span>
 | 
				
			||||||
                                      </a>
 | 
					                                      </a>
 | 
				
			||||||
                                    <ul style="${(i1 != null ? index == i1 : first) && index2 == i2 ? `display:block;` : ``}">`;
 | 
					                                      <ul style="${(i1 != null ? index == i1 : first) &&
 | 
				
			||||||
 | 
					              index2 == i2
 | 
				
			||||||
 | 
					              ? `display:block;`
 | 
				
			||||||
 | 
					              : ``
 | 
				
			||||||
 | 
					            }">`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          $.each(val2.device, function (index3, val3) {
 | 
					          $.each(val2.device, function (index3, val3) {
 | 
				
			||||||
            if (val3.device_number.includes("$3"))
 | 
					            if (val3.device_number.includes("$3"))
 | 
				
			||||||
              val3.device_number = val3.device_number.replace("$3", "");
 | 
					              val3.device_number = val3.device_number.replace("$3", "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            strHtml += `<li data-tabname="hisListItem">
 | 
					            strHtml += `<li data-tabname="hisListItem">
 | 
				
			||||||
                                        <a href="#" onClick="setValue('${val3.device_number}', '${val3.full_name}', null)" data-filter-tags="${val3.full_name.toLowerCase()} ${val3.device_serial_tag.toLowerCase()}" data-devnum="${val3.device_number}">
 | 
					                                          <a href="#" onClick="setValue('${val3.device_number
 | 
				
			||||||
 | 
					              }', '${val3.full_name
 | 
				
			||||||
 | 
					              }', null)" data-filter-tags="${val3.full_name.toLowerCase()} ${val3.device_serial_tag.toLowerCase()}" data-devnum="${val3.device_number
 | 
				
			||||||
 | 
					              }">
 | 
				
			||||||
                                              <span class="nav-link-text">
 | 
					                                              <span class="nav-link-text">
 | 
				
			||||||
                                                  ${val3.full_name}
 | 
					                                                  ${val3.full_name}
 | 
				
			||||||
                                              </span>
 | 
					                                              </span>
 | 
				
			||||||
@ -236,8 +328,7 @@
 | 
				
			|||||||
                pageAct.deviceName = val3.full_name;
 | 
					                pageAct.deviceName = val3.full_name;
 | 
				
			||||||
                devPointsList();
 | 
					                devPointsList();
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            }
 | 
					            } else {
 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
              if (index2 == i2 && first) {
 | 
					              if (index2 == i2 && first) {
 | 
				
			||||||
                first = false;
 | 
					                first = false;
 | 
				
			||||||
                pageAct.deviceNumber = val3.device_number;
 | 
					                pageAct.deviceNumber = val3.device_number;
 | 
				
			||||||
@ -254,7 +345,7 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $('#js_nested_list').html(strHtml);
 | 
					      $("#js_nested_list").html(strHtml);
 | 
				
			||||||
      $(`[data-tabname="hisListItem"]`).YTTab();
 | 
					      $(`[data-tabname="hisListItem"]`).YTTab();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    $(loadEle).Loading("close");
 | 
					    $(loadEle).Loading("close");
 | 
				
			||||||
@ -263,8 +354,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  function devPointsList() {
 | 
					  function devPointsList() {
 | 
				
			||||||
    let sendData = {
 | 
					    let sendData = {
 | 
				
			||||||
      device_number: pageAct.deviceNumber
 | 
					      device_number: pageAct.deviceNumber,
 | 
				
			||||||
    }
 | 
					    };
 | 
				
			||||||
    objSendData.Data = sendData;
 | 
					    objSendData.Data = sendData;
 | 
				
			||||||
    let url = baseApiUrl + "/api/History/GetDevPoi";
 | 
					    let url = baseApiUrl + "/api/History/GetDevPoi";
 | 
				
			||||||
    function success(res) {
 | 
					    function success(res) {
 | 
				
			||||||
@ -272,15 +363,19 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      $.each(res.data, function (index, val) {
 | 
					      $.each(res.data, function (index, val) {
 | 
				
			||||||
        if (index == 0) {
 | 
					        if (index == 0) {
 | 
				
			||||||
          strHtml += `<button onClick="setValue(null, null, '${val.points}', this)" type="button" class="btn btn-info waves-effect waves-themed">${val.full_name || val.points}</button>`;
 | 
					          strHtml += `<button onClick="setValue(null, null, '${val.points
 | 
				
			||||||
 | 
					            }', this)" type="button" class="btn btn-info waves-effect waves-themed">${val.full_name || val.points
 | 
				
			||||||
 | 
					            }</button>`;
 | 
				
			||||||
          pageAct.deviceItem = val.points;
 | 
					          pageAct.deviceItem = val.points;
 | 
				
			||||||
          pageAct.devicePoiName = val.full_name + ' ' + val.points;
 | 
					          pageAct.devicePoiName = val.full_name + " " + val.points;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          strHtml += `<button onClick="setValue(null, null, '${val.points}', this)" type="button" class="btn btn-secondary waves-effect waves-themed">${val.full_name || val.points}</button>`;
 | 
					          strHtml += `<button onClick="setValue(null, null, '${val.points
 | 
				
			||||||
 | 
					            }', this)" type="button" class="btn btn-secondary waves-effect waves-themed">${val.full_name || val.points
 | 
				
			||||||
 | 
					            }</button>`;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $('#devPointsList').html(strHtml);
 | 
					      $("#devPointsList").html(strHtml);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!hisFirst) {
 | 
					      if (!hisFirst) {
 | 
				
			||||||
        searchDate();
 | 
					        searchDate();
 | 
				
			||||||
@ -298,48 +393,60 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    let sendData = {
 | 
					    let sendData = {
 | 
				
			||||||
      device_number: pageAct.deviceNumber,
 | 
					      device_number: pageAct.deviceNumber,
 | 
				
			||||||
      device_point: pageAct.deviceItem
 | 
					      device_point: pageAct.deviceItem,
 | 
				
			||||||
    }
 | 
					    };
 | 
				
			||||||
    objSendData.Data = sendData;
 | 
					    objSendData.Data = sendData;
 | 
				
			||||||
    let url = baseApiUrl + "/api/DevGetWay";
 | 
					    let url = baseApiUrl + "/api/DevGetWay";
 | 
				
			||||||
    ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
 | 
					    ytAjax = new YourTeam.Ajax(
 | 
				
			||||||
 | 
					      url,
 | 
				
			||||||
 | 
					      objSendData,
 | 
				
			||||||
 | 
					      function (res) {
 | 
				
			||||||
        if (res && res.code == "0000") {
 | 
					        if (res && res.code == "0000") {
 | 
				
			||||||
          pageAct.hisBuiName = res.data;
 | 
					          pageAct.hisBuiName = res.data;
 | 
				
			||||||
        getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
 | 
					          getHistoryDataByBaja(
 | 
				
			||||||
 | 
					            pageAct.deviceNumber + "_" + pageAct.deviceItem,
 | 
				
			||||||
            new Date(start).getTime(),
 | 
					            new Date(start).getTime(),
 | 
				
			||||||
            new Date(end).getTime(),
 | 
					            new Date(end).getTime(),
 | 
				
			||||||
            pageAct.deviceName,
 | 
					            pageAct.deviceName,
 | 
				
			||||||
            pageAct.hisBuiName,
 | 
					            pageAct.hisBuiName,
 | 
				
			||||||
          callBackFromHistory);
 | 
					            callBackFromHistory
 | 
				
			||||||
      }
 | 
					          );
 | 
				
			||||||
      else {
 | 
					        } else {
 | 
				
			||||||
          $(loadEle).Loading("close");
 | 
					          $(loadEle).Loading("close");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }, function (res) { $(loadEle).Loading("close"); }, "POST", true).send();
 | 
					      },
 | 
				
			||||||
 | 
					      function (res) {
 | 
				
			||||||
 | 
					        $(loadEle).Loading("close");
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      "POST",
 | 
				
			||||||
 | 
					      true
 | 
				
			||||||
 | 
					    ).send();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function callBackFromHistory(res = '{"count":0,"data":[]}') {
 | 
					  function callBackFromHistory(res = '{"count":0,"data":[]}') {
 | 
				
			||||||
    res = JSON.parse(res);
 | 
					    res = JSON.parse(res);
 | 
				
			||||||
    loadTable(res.data);
 | 
					    loadTable(res.data);
 | 
				
			||||||
    if (historyTable != null) {
 | 
					    if (historyTable != null) {
 | 
				
			||||||
      let t = $('#historyTable').dataTable();
 | 
					      let t = $("#historyTable").dataTable();
 | 
				
			||||||
      t.fnClearTable();
 | 
					      t.fnClearTable();
 | 
				
			||||||
      if (res.data.length > 0)
 | 
					      if (res.data.length > 0) t.fnAddData(res.data);
 | 
				
			||||||
        t.fnAddData(res.data);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function setValue(deviceNumber, deviceName, deviceItem, elem) {
 | 
					  function setValue(deviceNumber, deviceName, deviceItem, elem) {
 | 
				
			||||||
    hisFirst = false;
 | 
					    hisFirst = false;
 | 
				
			||||||
    btnSelCss(elem);
 | 
					    btnSelCss(elem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((deviceNumber != null && deviceNumber != undefined) && (deviceName != null && deviceName != undefined)) {
 | 
					    if (
 | 
				
			||||||
 | 
					      deviceNumber != null &&
 | 
				
			||||||
 | 
					      deviceNumber != undefined &&
 | 
				
			||||||
 | 
					      deviceName != null &&
 | 
				
			||||||
 | 
					      deviceName != undefined
 | 
				
			||||||
 | 
					    ) {
 | 
				
			||||||
      pageAct.deviceNumber = deviceNumber;
 | 
					      pageAct.deviceNumber = deviceNumber;
 | 
				
			||||||
      pageAct.deviceName = deviceName;
 | 
					      pageAct.deviceName = deviceName;
 | 
				
			||||||
      devPointsList();
 | 
					      devPointsList();
 | 
				
			||||||
    }
 | 
					    } else if (deviceItem != null && deviceItem != undefined) {
 | 
				
			||||||
    else if (deviceItem != null && deviceItem != undefined) {
 | 
					 | 
				
			||||||
      pageAct.devicePoiName = $(elem).text();
 | 
					      pageAct.devicePoiName = $(elem).text();
 | 
				
			||||||
      pageAct.deviceItem = deviceItem;
 | 
					      pageAct.deviceItem = deviceItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -352,67 +459,83 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    pageAct.dateType = type;
 | 
					    pageAct.dateType = type;
 | 
				
			||||||
    let now = formatDate(new Date(Date.now()), "date");
 | 
					    let now = formatDate(new Date(Date.now()), "date");
 | 
				
			||||||
    let ytd = formatDate(new Date(new Date().setDate(new Date().getDate() - 1)), "date");
 | 
					    let ytd = formatDate(
 | 
				
			||||||
    let tmr = formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), "date");
 | 
					      new Date(new Date().setDate(new Date().getDate() - 1)),
 | 
				
			||||||
 | 
					      "date"
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    let tmr = formatDate(
 | 
				
			||||||
 | 
					      new Date(new Date().setDate(new Date().getDate() + 1)),
 | 
				
			||||||
 | 
					      "date"
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    $(".flatpickr-innerContainer").show();
 | 
				
			||||||
    if (type == "day" || type == "today" || type == "ytd") {
 | 
					    if (type == "day" || type == "today" || type == "ytd") {
 | 
				
			||||||
      let date = type == "ytd" ? ytd : now;
 | 
					      let date = type == "ytd" ? ytd : now;
 | 
				
			||||||
      $('#his_startdate').css('display', 'block');
 | 
					      $("#his_startdate").css("display", "block");
 | 
				
			||||||
      $('#his_enddate').css('display', 'none');
 | 
					      $("#his_enddate").css("display", "none");
 | 
				
			||||||
      $('#getmonth').css('display', 'none');
 | 
					      $("#getmonth").css("display", "none");
 | 
				
			||||||
      $('#his_startdate').val(date);
 | 
					      $("#his_startdate").val(date);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (type == "today")
 | 
					      if (type == "today")
 | 
				
			||||||
        getData(formatDate(now, "date", true), formatDate(now, "date", true));
 | 
					        getData(formatDate(now, "date", true), formatDate(now, "date", true));
 | 
				
			||||||
      else if (type == "ytd")
 | 
					      else if (type == "ytd")
 | 
				
			||||||
        getData(formatDate(ytd, "date", true), formatDate(ytd, "date", true));
 | 
					        getData(formatDate(ytd, "date", true), formatDate(ytd, "date", true));
 | 
				
			||||||
      else {
 | 
					      else {
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
 | 
					        $(`[onclick="setDateType('today', this)"]`).removeClass(
 | 
				
			||||||
        $(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
 | 
					          "btn-secondary"
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        $(`[onclick="setDateType('today', this)"]`).addClass("btn-info");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    } else if (type == "range") {
 | 
				
			||||||
    else if (type == "range") {
 | 
					      $(
 | 
				
			||||||
      $(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
 | 
					        `[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`
 | 
				
			||||||
      $(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
 | 
					      ).removeClass("btn-info");
 | 
				
			||||||
 | 
					      $(
 | 
				
			||||||
 | 
					        `[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`
 | 
				
			||||||
 | 
					      ).addClass("btn-secondary");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $('#his_startdate').css('display', 'block');
 | 
					      $("#his_startdate").css("display", "block");
 | 
				
			||||||
      $('#his_enddate').css('display', 'block');
 | 
					      $("#his_enddate").css("display", "block");
 | 
				
			||||||
      $('#getmonth').css('display', 'none');
 | 
					      $("#getmonth").css("display", "none");
 | 
				
			||||||
      $('#his_startdate').val(now);
 | 
					      $("#his_startdate").val(now);
 | 
				
			||||||
      $('#his_startdate').data('val', now);
 | 
					      $("#his_startdate").data("val", now);
 | 
				
			||||||
      $('#his_enddate input').val(tmr);
 | 
					      $("#his_enddate input").val(tmr);
 | 
				
			||||||
      $('#his_enddate input').data('val', tmr);
 | 
					      $("#his_enddate input").data("val", tmr);
 | 
				
			||||||
    }
 | 
					    } else if (type == "month") {
 | 
				
			||||||
    else if (type == "month") {
 | 
					      $(
 | 
				
			||||||
      $(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
 | 
					        `[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`
 | 
				
			||||||
      $(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
 | 
					      ).removeClass("btn-info");
 | 
				
			||||||
 | 
					      $(
 | 
				
			||||||
 | 
					        `[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`
 | 
				
			||||||
 | 
					      ).addClass("btn-secondary");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $('#his_startdate').css('display', 'none');
 | 
					      $("#his_startdate").css("display", "none");
 | 
				
			||||||
      $('#his_enddate').css('display', 'none');
 | 
					      $("#his_enddate").css("display", "none");
 | 
				
			||||||
      $('#getmonth').css('display', 'block');
 | 
					      $("#getmonth").css("display", "block");
 | 
				
			||||||
      $('#getmonth').val(now.substr(0, 7));
 | 
					      $("#getmonth").val(now.substr(0, 7));
 | 
				
			||||||
    }
 | 
					      $(".flatpickr-innerContainer").hide();
 | 
				
			||||||
    else if (type == "ytd") {
 | 
					    } else if (type == "ytd") {
 | 
				
			||||||
      $('#his_startdate').css('display', 'block');
 | 
					      $("#his_startdate").css("display", "block");
 | 
				
			||||||
      $('#his_enddate').css('display', 'none');
 | 
					      $("#his_enddate").css("display", "none");
 | 
				
			||||||
      $('#getmonth').css('display', 'none');
 | 
					      $("#getmonth").css("display", "none");
 | 
				
			||||||
      $('#his_startdate').val(ytd);
 | 
					      $("#his_startdate").val(ytd);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function searchDate() {
 | 
					  function searchDate() {
 | 
				
			||||||
    let start = new Date($('#his_startdate').val());
 | 
					    let start = new Date($("#his_startdate").val());
 | 
				
			||||||
    let end = new Date($('#his_enddate input').val());
 | 
					    let end = new Date($("#his_enddate input").val());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd")
 | 
					    if (
 | 
				
			||||||
 | 
					      pageAct.dateType == "today" ||
 | 
				
			||||||
 | 
					      pageAct.dateType == "day" ||
 | 
				
			||||||
 | 
					      pageAct.dateType == "ytd"
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
      end = start;
 | 
					      end = start;
 | 
				
			||||||
    else if (pageAct.dateType == "month") {
 | 
					    else if (pageAct.dateType == "month") {
 | 
				
			||||||
      start = new Date($('#getmonth').val());
 | 
					      start = new Date($("#getmonth").val());
 | 
				
			||||||
      end = new Date(start.valueOf()).setMonth(start.getMonth() + 1);
 | 
					      end = new Date(start.valueOf()).setMonth(start.getMonth() + 1);
 | 
				
			||||||
      end = new Date(new Date(end).setDate(new Date(end).getDate() - 1));
 | 
					      end = new Date(new Date(end).setDate(new Date(end).getDate() - 1));
 | 
				
			||||||
    }
 | 
					    } else if (pageAct.dateType != "range") return;
 | 
				
			||||||
    else if (pageAct.dateType != "range")
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pageAct.hisStartDate = start;
 | 
					    pageAct.hisStartDate = start;
 | 
				
			||||||
    pageAct.hisEndDate = end;
 | 
					    pageAct.hisEndDate = end;
 | 
				
			||||||
@ -420,20 +543,18 @@
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function formatDate(date, type, send = false) {
 | 
					  function formatDate(date, type, send = false) {
 | 
				
			||||||
    if (!send)
 | 
					    if (!send) return displayDate(date, type).replaceAll("/", "-");
 | 
				
			||||||
      return displayDate(date, type).replaceAll("/", "-");
 | 
					 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
      date = displayDate(date, type);
 | 
					      date = displayDate(date, type);
 | 
				
			||||||
      let month = date.split('/')[1];
 | 
					      let month = date.split("/")[1];
 | 
				
			||||||
      let year = date.split('/')[0];
 | 
					      let year = date.split("/")[0];
 | 
				
			||||||
      let day = date.split('/')[2];
 | 
					      let day = date.split("/")[2];
 | 
				
			||||||
      return month + "/" + day + "/" + year;
 | 
					      return month + "/" + day + "/" + year;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function loadTable(data) {
 | 
					  function loadTable(data) {
 | 
				
			||||||
    if (data) {
 | 
					    if (data) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
      $.each(data, function (i, v) {
 | 
					      $.each(data, function (i, v) {
 | 
				
			||||||
        v.type = pageAct.devicePoiName.split(" ")[0];
 | 
					        v.type = pageAct.devicePoiName.split(" ")[0];
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@ -441,41 +562,51 @@
 | 
				
			|||||||
      let tag = "#historyTable";
 | 
					      let tag = "#historyTable";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let column_defs = [
 | 
					      let column_defs = [
 | 
				
			||||||
        { "targets": [0], "width": "20%", "sortable": true },
 | 
					        { targets: [0], width: "20%", sortable: true },
 | 
				
			||||||
        { "targets": [1], "width": "20%", "sortable": true },
 | 
					        { targets: [1], width: "20%", sortable: true },
 | 
				
			||||||
        { "targets": [2], "width": "20%", "sortable": true }
 | 
					        { targets: [2], width: "20%", sortable: true },
 | 
				
			||||||
      ];
 | 
					      ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let columns = [
 | 
					      let columns = [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "title": "類別",
 | 
					          title: "類別",
 | 
				
			||||||
          "data": "type"
 | 
					          data: "type",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "title": "設備名稱",
 | 
					          title: "設備名稱",
 | 
				
			||||||
          "data": "deviceName",
 | 
					          data: "deviceName",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "title": "數值",
 | 
					          title: "數值",
 | 
				
			||||||
          "data": "value",
 | 
					          data: "value",
 | 
				
			||||||
          "render": function (data) {
 | 
					          render: function (data) {
 | 
				
			||||||
            if (isNaN(data.toString())) {
 | 
					            if (isNaN(data.toString())) {
 | 
				
			||||||
              return data
 | 
					              return data;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return data.roundDecimal(2);
 | 
					            return data.roundDecimal(2);
 | 
				
			||||||
          }
 | 
					          },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "title": "紀錄時間",
 | 
					          title: "紀錄時間",
 | 
				
			||||||
          "data": "timestamp",
 | 
					          data: "timestamp",
 | 
				
			||||||
          "render": function (data) {
 | 
					          render: function (data) {
 | 
				
			||||||
            return displayDate(data, "datetime");
 | 
					            return displayDate(data, "datetime");
 | 
				
			||||||
          }
 | 
					          },
 | 
				
			||||||
        }
 | 
					        },
 | 
				
			||||||
      ];
 | 
					      ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
 | 
					      historyTable = new YourTeam.JqDataTables.getTableByStatic(
 | 
				
			||||||
      $(tag).DataTable().order([3, 'desc']);
 | 
					        tag,
 | 
				
			||||||
 | 
					        data,
 | 
				
			||||||
 | 
					        columns,
 | 
				
			||||||
 | 
					        column_defs,
 | 
				
			||||||
 | 
					        null,
 | 
				
			||||||
 | 
					        null,
 | 
				
			||||||
 | 
					        null,
 | 
				
			||||||
 | 
					        null,
 | 
				
			||||||
 | 
					        "tpi"
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					      $(tag).DataTable().order([3, "desc"]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -543,7 +674,7 @@
 | 
				
			|||||||
      $("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
 | 
					      $("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
 | 
				
			||||||
      $("[name=buildingRadio]:checked").parent().addClass("btn-info");
 | 
					      $("[name=buildingRadio]:checked").parent().addClass("btn-info");
 | 
				
			||||||
      buildingTag = buildingRadios.val(); //building tag
 | 
					      buildingTag = buildingRadios.val(); //building tag
 | 
				
			||||||
      pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1];
 | 
					      pageAct.hisBuiName = buildingRadios.prop("id").split("-")[1];
 | 
				
			||||||
      initList();
 | 
					      initList();
 | 
				
			||||||
      result = true;
 | 
					      result = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -806,12 +806,12 @@
 | 
				
			|||||||
    switch (tableType) {
 | 
					    switch (tableType) {
 | 
				
			||||||
      case "day":
 | 
					      case "day":
 | 
				
			||||||
        columns = getDayByMonth($("#elecMonthDate").val()).map((dc) => {
 | 
					        columns = getDayByMonth($("#elecMonthDate").val()).map((dc) => {
 | 
				
			||||||
          return { title: dc, data: dc, sWidth: columnWidth };
 | 
					          return { title: dc, data: dc, width: columnWidth };
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "month":
 | 
					      case "month":
 | 
				
			||||||
        columns = getMonthByYear($("#elecYearDate").val()).map((dc) => {
 | 
					        columns = getMonthByYear($("#elecYearDate").val()).map((dc) => {
 | 
				
			||||||
          return { title: dc, data: dc, sWidth: columnWidth };
 | 
					          return { title: dc, data: dc, width: columnWidth };
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "year":
 | 
					      case "year":
 | 
				
			||||||
@ -819,7 +819,7 @@
 | 
				
			|||||||
          $("#elecSYearDate").val(),
 | 
					          $("#elecSYearDate").val(),
 | 
				
			||||||
          $("#elecEYearDate").val()
 | 
					          $("#elecEYearDate").val()
 | 
				
			||||||
        ).map((dc) => {
 | 
					        ).map((dc) => {
 | 
				
			||||||
          return { title: dc, data: dc, sWidth: columnWidth };
 | 
					          return { title: dc, data: dc, width: columnWidth };
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case "compare":
 | 
					      case "compare":
 | 
				
			||||||
@ -859,10 +859,10 @@
 | 
				
			|||||||
              title: dc.value,
 | 
					              title: dc.value,
 | 
				
			||||||
              data: dc.value,
 | 
					              data: dc.value,
 | 
				
			||||||
              sClass: "compare",
 | 
					              sClass: "compare",
 | 
				
			||||||
              sWidth: columnWidth,
 | 
					              width: columnWidth,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          return { title: dc, data: dc, sWidth: columnWidth };
 | 
					          return { title: dc, data: dc, width: columnWidth };
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
@ -909,7 +909,7 @@
 | 
				
			|||||||
          value: "last year different",
 | 
					          value: "last year different",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
      ].map((dc) => {
 | 
					      ].map((dc) => {
 | 
				
			||||||
        return { title: dc.label, data: dc.value, sWidth: "120px" };
 | 
					        return { title: dc.label, data: dc.value, width: "120px" };
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      datesColumns = setTableColumns();
 | 
					      datesColumns = setTableColumns();
 | 
				
			||||||
@ -929,12 +929,14 @@
 | 
				
			|||||||
      {
 | 
					      {
 | 
				
			||||||
        title: "小計",
 | 
					        title: "小計",
 | 
				
			||||||
        data: "total",
 | 
					        data: "total",
 | 
				
			||||||
        sWidth: "70px",
 | 
					        width: "70px",
 | 
				
			||||||
 | 
					        className: "text-nowrap",
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        title: "單價",
 | 
					        title: "單價",
 | 
				
			||||||
        data: "price",
 | 
					        data: "price",
 | 
				
			||||||
        sWidth: "45px",
 | 
					        width: "45px",
 | 
				
			||||||
 | 
					        className: "text-nowrap",
 | 
				
			||||||
        render: function (data) {
 | 
					        render: function (data) {
 | 
				
			||||||
          return parseInt(data) === 0 ? "" : data;
 | 
					          return parseInt(data) === 0 ? "" : data;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@ -942,7 +944,8 @@
 | 
				
			|||||||
      {
 | 
					      {
 | 
				
			||||||
        title: "金額總計",
 | 
					        title: "金額總計",
 | 
				
			||||||
        data: "total_price",
 | 
					        data: "total_price",
 | 
				
			||||||
        sWidth: "70px",
 | 
					        width: "70px",
 | 
				
			||||||
 | 
					        className: "text-nowrap",
 | 
				
			||||||
        render: function (data) {
 | 
					        render: function (data) {
 | 
				
			||||||
          return parseInt(data) === 0 ? "" : data;
 | 
					          return parseInt(data) === 0 ? "" : data;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@ -966,11 +969,12 @@
 | 
				
			|||||||
          totalColumns.splice(i + 1, 0, {
 | 
					          totalColumns.splice(i + 1, 0, {
 | 
				
			||||||
            title: com2Time + c.title,
 | 
					            title: com2Time + c.title,
 | 
				
			||||||
            data: "_compare_" + c.data,
 | 
					            data: "_compare_" + c.data,
 | 
				
			||||||
            sWidth: "70px",
 | 
					            width: "70px",
 | 
				
			||||||
            sClass: "compare",
 | 
					            sClass: "compare text-nowrap",
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
          c.title = com1Time + c.title;
 | 
					          c.title = com1Time + c.title;
 | 
				
			||||||
          c.sWidth = "70px";
 | 
					          c.width = "70px";
 | 
				
			||||||
 | 
					          c.className = "text-nowrap";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -979,10 +983,13 @@
 | 
				
			|||||||
      data: datas,
 | 
					      data: datas,
 | 
				
			||||||
      destroy: true,
 | 
					      destroy: true,
 | 
				
			||||||
      sDom: '<"toolbar">tipl',
 | 
					      sDom: '<"toolbar">tipl',
 | 
				
			||||||
      fixedColumns: { left: 3, right: tableType == "compare" ? 2 : 3 },
 | 
					      fixedColumns: {
 | 
				
			||||||
 | 
					        leftColumns: 3,
 | 
				
			||||||
 | 
					        rightColumns: tableType == "compare" ? 2 : 3,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      scrollX: "auto",
 | 
					      scrollX: "auto",
 | 
				
			||||||
      scrollCollapse: true,
 | 
					      scrollCollapse: true,
 | 
				
			||||||
      autoWidth: true,
 | 
					      autoWidth: false,
 | 
				
			||||||
      language: { url: "/file/BajascriptTest/js/dataTables/zh-HANT.json" },
 | 
					      language: { url: "/file/BajascriptTest/js/dataTables/zh-HANT.json" },
 | 
				
			||||||
      aaSorting: [],
 | 
					      aaSorting: [],
 | 
				
			||||||
      columns: [
 | 
					      columns: [
 | 
				
			||||||
@ -990,18 +997,19 @@
 | 
				
			|||||||
          title: "棟別",
 | 
					          title: "棟別",
 | 
				
			||||||
          data: "building_name",
 | 
					          data: "building_name",
 | 
				
			||||||
          className: "text-nowrap",
 | 
					          className: "text-nowrap",
 | 
				
			||||||
          sWidth: "100px",
 | 
					          width: "100px",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          title: "樓層",
 | 
					          title: "樓層",
 | 
				
			||||||
          data: "floor_tag",
 | 
					          data: "floor_tag",
 | 
				
			||||||
          sWidth: "8%",
 | 
					          width: "8%",
 | 
				
			||||||
          className: "text-nowrap",
 | 
					          className: "text-nowrap",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          title: "設備",
 | 
					          title: "設備",
 | 
				
			||||||
          data: "device_full_name",
 | 
					          data: "device_full_name",
 | 
				
			||||||
          sWidth: "100px",
 | 
					          width: "300px",
 | 
				
			||||||
 | 
					          className: "text-nowrap",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        ...datesColumns,
 | 
					        ...datesColumns,
 | 
				
			||||||
        ...(ElecEachTotal ? [] : totalColumns),
 | 
					        ...(ElecEachTotal ? [] : totalColumns),
 | 
				
			||||||
 | 
				
			|||||||
@ -821,6 +821,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
				
			|||||||
                + src/../jquery-snippets.js (core) -->
 | 
					                + src/../jquery-snippets.js (core) -->
 | 
				
			||||||
  <!-- verdors.bundle.js 已含有 jquery Library v3.5.1-->
 | 
					  <!-- verdors.bundle.js 已含有 jquery Library v3.5.1-->
 | 
				
			||||||
  <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
 | 
					  <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
 | 
				
			||||||
 | 
					  <script src="https://npmcdn.com/flatpickr@4.6.13/dist/l10n/zh-tw.js"></script>
 | 
				
			||||||
  <script src="lib/vendors.bundle.js"></script>
 | 
					  <script src="lib/vendors.bundle.js"></script>
 | 
				
			||||||
  <!-- toast 第三方套件 若 require 此套件只能用 define 使用,先暫時 html 引用-->
 | 
					  <!-- toast 第三方套件 若 require 此套件只能用 define 使用,先暫時 html 引用-->
 | 
				
			||||||
  <script src="lib/notifications/toastr/toastr.min.js"></script>
 | 
					  <script src="lib/notifications/toastr/toastr.min.js"></script>
 | 
				
			||||||
@ -1032,7 +1033,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
				
			|||||||
        checkDevState();
 | 
					        checkDevState();
 | 
				
			||||||
        loadNoticeConSta();
 | 
					        loadNoticeConSta();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                refreshSubPage()
 | 
					        refreshSubPage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        allDevices = getAllDevice();
 | 
					        allDevices = getAllDevice();
 | 
				
			||||||
        if (pageAct.isShowBuildingInMenu) {
 | 
					        if (pageAct.isShowBuildingInMenu) {
 | 
				
			||||||
@ -1355,7 +1356,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              $(
 | 
					              $(
 | 
				
			||||||
                `#subSysBtn${lastPageAct.sysSubTag
 | 
					                `#subSysBtn${lastPageAct.sysSubTag
 | 
				
			||||||
                                }[data-building-tag=${buildingTagOnJquery(lastPageAct.buiTag)}]`
 | 
					                }[data-building-tag=${buildingTagOnJquery(
 | 
				
			||||||
 | 
					                  lastPageAct.buiTag
 | 
				
			||||||
 | 
					                )}]`
 | 
				
			||||||
              ).click();
 | 
					              ).click();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
@ -1910,7 +1913,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function setSysTagForPageAct(obj) {
 | 
					    function setSysTagForPageAct(obj) {
 | 
				
			||||||
            console.log($(obj).data("subsysobj"))
 | 
					      console.log($(obj).data("subsysobj"));
 | 
				
			||||||
      pageAct.sysMainTag =
 | 
					      pageAct.sysMainTag =
 | 
				
			||||||
        $(obj).data("subsysobj")?.main_system_tag ||
 | 
					        $(obj).data("subsysobj")?.main_system_tag ||
 | 
				
			||||||
        pageAct.sysSubObj.main_system_tag;
 | 
					        pageAct.sysSubObj.main_system_tag;
 | 
				
			||||||
@ -2237,9 +2240,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
				
			|||||||
                      {
 | 
					                      {
 | 
				
			||||||
                        page: page,
 | 
					                        page: page,
 | 
				
			||||||
                        tabname: "systemMonitor",
 | 
					                        tabname: "systemMonitor",
 | 
				
			||||||
                                                "building-tag": buildingTagOnJquery(
 | 
					                        "building-tag": buildingTagOnJquery(pageAct.buiTag),
 | 
				
			||||||
                                                    pageAct.buiTag
 | 
					 | 
				
			||||||
                                                ),
 | 
					 | 
				
			||||||
                      },
 | 
					                      },
 | 
				
			||||||
                      "topFunBtn"
 | 
					                      "topFunBtn"
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
@ -2329,16 +2330,25 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
				
			|||||||
      ];
 | 
					      ];
 | 
				
			||||||
      // 向 niagara 取得告警資料
 | 
					      // 向 niagara 取得告警資料
 | 
				
			||||||
      getDeviceAlarmCardByBaja(null, now, false, false, function (bajaDatas) {
 | 
					      getDeviceAlarmCardByBaja(null, now, false, false, function (bajaDatas) {
 | 
				
			||||||
                let datas = bajaDatas.data;
 | 
					        let datas = bajaDatas.data.filter(
 | 
				
			||||||
 | 
					          ({ alarmClass }) => alarmClass !== "defaultAlarmClass"
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
        let titleHtml = `異常通知`;
 | 
					        let titleHtml = `異常通知`;
 | 
				
			||||||
        let notices = [];
 | 
					        let notices = [];
 | 
				
			||||||
        // 遍歷每個告警資料
 | 
					        // 遍歷每個告警資料
 | 
				
			||||||
        $.each(datas ?? [], (idx, data) => {
 | 
					        $.each(datas ?? [], (idx, data) => {
 | 
				
			||||||
          if (noticeOptArr.findIndex((x) => x.id == data.uuid) == -1) {
 | 
					          if (noticeOptArr.findIndex((x) => x.id == data.uuid) == -1) {
 | 
				
			||||||
            // 針對該告警對象的設備,從 allDevices 找出設備名稱
 | 
					            // 針對該告警對象的設備,從 allDevices 找出設備名稱
 | 
				
			||||||
                        datas[idx].full_name = allDevices.filter(
 | 
					            const building_name = pageAct.buildList.find(
 | 
				
			||||||
                            (x) => x.device_number == data.devicePath
 | 
					              ({ building_tag }) =>
 | 
				
			||||||
                        )[0]?.full_name;
 | 
					                building_tag === data.devicePath.split("_")[1]
 | 
				
			||||||
 | 
					            )?.full_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            datas[idx].full_name =
 | 
				
			||||||
 | 
					              allDevices.filter((x) => x.device_number == data.devicePath)[0]
 | 
				
			||||||
 | 
					                ?.full_name || (data.alarmClass === "Sys_Con_AlarmClass"
 | 
				
			||||||
 | 
					                  ? `${building_name}_電錶邊緣控制器_${data.split("_")[7]}`
 | 
				
			||||||
 | 
					                  : "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let div1 = creDiv(["col-12"]);
 | 
					            let div1 = creDiv(["col-12"]);
 | 
				
			||||||
            let button = creBtn(
 | 
					            let button = creBtn(
 | 
				
			||||||
 | 
				
			|||||||
@ -99,7 +99,19 @@ function getAlarmByBaja(
 | 
				
			|||||||
  var _index = 0;
 | 
					  var _index = 0;
 | 
				
			||||||
  var _recoverState = isRecover ? "= 'normal'" : "= 'offnormal'";
 | 
					  var _recoverState = isRecover ? "= 'normal'" : "= 'offnormal'";
 | 
				
			||||||
  var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
 | 
					  var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
 | 
				
			||||||
  //console.log("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc")
 | 
					  // console.log('@@@@@@@@@',
 | 
				
			||||||
 | 
					  //   "local:|foxs:|alarm:|bql:select timestamp, ackTime, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime where alarmClass = '" +
 | 
				
			||||||
 | 
					  //     alarmClass +
 | 
				
			||||||
 | 
					  //     "' and timestamp.millis > " +
 | 
				
			||||||
 | 
					  //     startDate_millisecond +
 | 
				
			||||||
 | 
					  //     " and timestamp.millis < " +
 | 
				
			||||||
 | 
					  //     endDate_millisecond +
 | 
				
			||||||
 | 
					  //     " and sourceState " +
 | 
				
			||||||
 | 
					  //     _recoverState +
 | 
				
			||||||
 | 
					  //     " and ackState " +
 | 
				
			||||||
 | 
					  //     _ackState +
 | 
				
			||||||
 | 
					  //     " order by timestamp asc"
 | 
				
			||||||
 | 
					  // );
 | 
				
			||||||
  require(["baja!"], function (baja) {
 | 
					  require(["baja!"], function (baja) {
 | 
				
			||||||
    baja.Ord.make(
 | 
					    baja.Ord.make(
 | 
				
			||||||
      "local:|foxs:|alarm:|bql:select timestamp, ackTime, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime where alarmClass = '" +
 | 
					      "local:|foxs:|alarm:|bql:select timestamp, ackTime, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime where alarmClass = '" +
 | 
				
			||||||
@ -121,12 +133,11 @@ function getAlarmByBaja(
 | 
				
			|||||||
            const alarmDisplayName =
 | 
					            const alarmDisplayName =
 | 
				
			||||||
              record.get("alarmData").get("sourceName").split(":")[1] ??
 | 
					              record.get("alarmData").get("sourceName").split(":")[1] ??
 | 
				
			||||||
              record.get("alarmData").get("sourceName").split(":")[0];
 | 
					              record.get("alarmData").get("sourceName").split(":")[0];
 | 
				
			||||||
            //console.log(alarmDisplayName)
 | 
					 | 
				
			||||||
            _sourceTmp = alarmDisplayName.split("_");
 | 
					            _sourceTmp = alarmDisplayName.split("_");
 | 
				
			||||||
            _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
 | 
					            _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
 | 
				
			||||||
            _sourceName = _sourceTmp.slice(0, 8).join("_");
 | 
					            _sourceName = _sourceTmp.slice(0, 8).join("_");
 | 
				
			||||||
            _sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
 | 
					            _sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
 | 
				
			||||||
            if (!_sourceTmp.includes("undefined")) {
 | 
					            // if (!_sourceTmp.includes("undefined")) {
 | 
				
			||||||
            _ss.push({
 | 
					            _ss.push({
 | 
				
			||||||
              buildingFloorName_zh: _bfName,
 | 
					              buildingFloorName_zh: _bfName,
 | 
				
			||||||
              uuid: record.get("uuid"),
 | 
					              uuid: record.get("uuid"),
 | 
				
			||||||
@ -139,7 +150,7 @@ function getAlarmByBaja(
 | 
				
			|||||||
              normalTime: record.get("normalTime"),
 | 
					              normalTime: record.get("normalTime"),
 | 
				
			||||||
              ackedTime: record.get("ackTime").$cEncStr,
 | 
					              ackedTime: record.get("ackTime").$cEncStr,
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
            }
 | 
					            // }
 | 
				
			||||||
            _index++;
 | 
					            _index++;
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          after: function () {
 | 
					          after: function () {
 | 
				
			||||||
@ -262,7 +273,6 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
 | 
				
			|||||||
      })
 | 
					      })
 | 
				
			||||||
      .catch(() => {
 | 
					      .catch(() => {
 | 
				
			||||||
        $(loadEle).Loading("close");
 | 
					        $(loadEle).Loading("close");
 | 
				
			||||||
 | 
					 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -102,7 +102,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                #endregion
 | 
					                #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                #region get data from niagara
 | 
					                #region get data from niagara
 | 
				
			||||||
                lhe.endtime = lhe.dateType == "today" ? lhe.starttime : lhe.dateType == "month" ? lhe.starttime.AddMonths(1) : lhe.endtime;
 | 
					                lhe.endtime = lhe.dateType == "today" ? lhe.starttime : lhe.dateType == "month" ? lhe.starttime.AddMonths(1).AddDays(-1) : lhe.endtime;
 | 
				
			||||||
                var startTimestamp = string.Format("{0}T00:00:00.000+08:00", lhe.starttime.ToString("yyyy-MM-dd"));
 | 
					                var startTimestamp = string.Format("{0}T00:00:00.000+08:00", lhe.starttime.ToString("yyyy-MM-dd"));
 | 
				
			||||||
                var endTimestamp = string.Format("{0}T23:59:59.000+08:00", lhe.endtime?.ToString("yyyy-MM-dd"));
 | 
					                var endTimestamp = string.Format("{0}T23:59:59.000+08:00", lhe.endtime?.ToString("yyyy-MM-dd"));
 | 
				
			||||||
                var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
 | 
					                var historyQueryFilter = $@"<obj is='obix: HistoryFilter'>
 | 
				
			||||||
@ -175,7 +175,11 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                                HistoryExport hed = new HistoryExport();
 | 
					                                HistoryExport hed = new HistoryExport();
 | 
				
			||||||
                                hed.type = devicePoint.Where(x => x.device_building_tag == d.building_tag && x.points == ard["@point"].ToString()).Select(x => x.full_name).FirstOrDefault();
 | 
					                                hed.type = devicePoint.Where(x => x.device_building_tag == d.building_tag && x.points == ard["@point"].ToString()).Select(x => x.full_name).FirstOrDefault();
 | 
				
			||||||
                                hed.deviceName = device.Where(x => x.device_number == ard["@device_number"].ToString()).Select(x => x.full_name).FirstOrDefault();
 | 
					                                hed.deviceName = device.Where(x => x.device_number == ard["@device_number"].ToString()).Select(x => x.full_name).FirstOrDefault();
 | 
				
			||||||
                                hed.value = ard["@avg_rawdata"].ToString() == "-1" ? "NaN" : Math.Round((decimal.Parse(ard["@avg_rawdata"].ToString(), System.Globalization.NumberStyles.Float)), 2).ToString();
 | 
					                                // 四捨六入
 | 
				
			||||||
 | 
					                                //hed.value = ard["@avg_rawdata"].ToString() == "-1" ? "NaN" : Math.Round((decimal.Parse(ard["@avg_rawdata"].ToString(), System.Globalization.NumberStyles.Float)), 2).ToString();
 | 
				
			||||||
 | 
					                                // 四捨五入
 | 
				
			||||||
 | 
					                                //ref: Math.Round(Convert.ToDecimal(45.365), 2, MidpointRounding.AwayFromZero)
 | 
				
			||||||
 | 
					                                hed.value = ard["@avg_rawdata"].ToString() == "-1" ? "NaN" : Math.Round(Convert.ToDecimal(ard["@avg_rawdata"].ToString()), 2, MidpointRounding.AwayFromZero).ToString();                               
 | 
				
			||||||
                                hed.timestamp = Convert.ToDateTime(ard["@start_timestamp"].ToString());
 | 
					                                hed.timestamp = Convert.ToDateTime(ard["@start_timestamp"].ToString());
 | 
				
			||||||
                                hed.building_tag = d.building_tag;
 | 
					                                hed.building_tag = d.building_tag;
 | 
				
			||||||
                                he.Add(hed);
 | 
					                                he.Add(hed);
 | 
				
			||||||
@ -262,8 +266,10 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        if (d.type != lastDeviceItem)
 | 
					                        if (d.type != lastDeviceItem)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
 | 
					                            RowPosition = 0;
 | 
				
			||||||
                            lastDeviceItem = d.type;
 | 
					                            lastDeviceItem = d.type;
 | 
				
			||||||
                            sheet = workbook.CreateSheet($"{building.Where(x => x.building_tag == lhe.device_number.Split("_")[1]).Select(x => x.full_name).FirstOrDefault()}{"_" + d.type}");
 | 
					                            sheet = workbook.CreateSheet($"{building.Where(x => x.building_tag == lhe.device_number.Split("_")[1]).Select(x => x.full_name).FirstOrDefault()}{"_" + d.type}");
 | 
				
			||||||
 | 
					                            //sheet = workbook.CreateSheet($"{d.deviceName}{"_" + d.type}");
 | 
				
			||||||
                            #region set cell
 | 
					                            #region set cell
 | 
				
			||||||
                            row = sheet.CreateRow(RowPosition);
 | 
					                            row = sheet.CreateRow(RowPosition);
 | 
				
			||||||
                            sheet.SetColumnWidth(0, 4 * 160 * 12);
 | 
					                            sheet.SetColumnWidth(0, 4 * 160 * 12);
 | 
				
			||||||
@ -282,7 +288,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                            cell.SetCellValue("記錄時間");
 | 
					                            cell.SetCellValue("記錄時間");
 | 
				
			||||||
                            cell.CellStyle = styleLine12;
 | 
					                            cell.CellStyle = styleLine12;
 | 
				
			||||||
                            #endregion
 | 
					                            #endregion
 | 
				
			||||||
                            RowPosition = 0;
 | 
					                            RowPosition = 1;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else {
 | 
					                        else {
 | 
				
			||||||
                            RowPosition += 1;
 | 
					                            RowPosition += 1;
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,8 @@ using Google.Protobuf.Collections;
 | 
				
			|||||||
using Org.BouncyCastle.Asn1.Pkcs;
 | 
					using Org.BouncyCastle.Asn1.Pkcs;
 | 
				
			||||||
using NPOI.SS.Formula.Functions;
 | 
					using NPOI.SS.Formula.Functions;
 | 
				
			||||||
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
 | 
					using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
 | 
				
			||||||
 | 
					using static NPOI.HSSF.Record.PageBreakRecord;
 | 
				
			||||||
 | 
					using System.Linq.Expressions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FrontendWebApi.ApiControllers
 | 
					namespace FrontendWebApi.ApiControllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -114,7 +116,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                if (input.tableType == "year")
 | 
					                if (input.tableType == "year")
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    sqlGroup = $@" group by year(start_timestamp), year(end_timestamp), device_number ";
 | 
					                    sqlGroup = $@" group by year(start_timestamp), year(end_timestamp), device_number ";
 | 
				
			||||||
                    sqlAvgRawData = " round(avg(kwh_result), 2) as avg_rawdata, year(start_timestamp) as start_timestamp, year(end_timestamp) as end_timestamp ";
 | 
					                    sqlAvgRawData = " round(sum(kwh_result), 2) as avg_rawdata, year(start_timestamp) as start_timestamp, year(end_timestamp) as end_timestamp ";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                    sqlAvgRawData = " round(kwh_result, 2) as avg_rawdata, start_timestamp, end_timestamp ";
 | 
					                    sqlAvgRawData = " round(kwh_result, 2) as avg_rawdata, start_timestamp, end_timestamp ";
 | 
				
			||||||
@ -132,20 +134,28 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                var dateFormat = input.tableType == "day" || input.tableType == "week" ? "%Y-%m-%d" : input.tableType == "month" ? "%Y-%m" : input.tableType == "year" ? "%Y" : null;
 | 
					                var dateFormat = input.tableType == "day" || input.tableType == "week" ? "%Y-%m-%d" : input.tableType == "month" ? "%Y-%m" : input.tableType == "year" ? "%Y" : null;
 | 
				
			||||||
                var aemmEndDate = input.tableType == "year" ? $"year(DATE_ADD(fd.date, INTERVAL +1 {input.tableType}))" : $"DATE_ADD(fd.date, INTERVAL +1 {input.tableType})";
 | 
					                var aemmEndDate = input.tableType == "year" ? $"year(DATE_ADD(fd.date, INTERVAL +1 {input.tableType}))" : $"DATE_ADD(fd.date, INTERVAL +1 {input.tableType})";
 | 
				
			||||||
                var aemmStaDate = input.tableType == "year" ? "year(fd.date)" : "fd.date";
 | 
					                var aemmStaDate = input.tableType == "year" ? "year(fd.date)" : "fd.date";
 | 
				
			||||||
                var sql = $@"set @i = -1;
 | 
					                string date_yyyymmdd = "";
 | 
				
			||||||
 | 
					                    switch (input.tableType)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        case "day": date_yyyymmdd = @$" date(aemm.start_timestamp)  = {aemmStaDate}"; break;
 | 
				
			||||||
 | 
					                        // case "month": date_yyyymmdd = @$"  aemm.start_timestamp >= {aemmStaDate} and aemm.end_timestamp < {aemmEndDate}  "; break;
 | 
				
			||||||
 | 
					                        case "month": date_yyyymmdd = @$"  date(aemm.start_timestamp)  = {aemmStaDate}"; break;
 | 
				
			||||||
 | 
					                        case "year": date_yyyymmdd = @$" aemm.start_timestamp >= {aemmStaDate} and aemm.end_timestamp < {aemmEndDate}  "; break; 
 | 
				
			||||||
 | 
					                    }  
 | 
				
			||||||
 | 
					                var sql = $@" set @i = -1;
 | 
				
			||||||
                            select fd.device_number, case when aemm.avg_rawdata = -1.0 then 'NaN' when aemm.avg_rawdata is null then 0.00 else aemm.avg_rawdata end as avg_rawdata, DATE_FORMAT(fd.date, @dateFormat) as timestamp
 | 
					                            select fd.device_number, case when aemm.avg_rawdata = -1.0 then 'NaN' when aemm.avg_rawdata is null then 0.00 else aemm.avg_rawdata end as avg_rawdata, DATE_FORMAT(fd.date, @dateFormat) as timestamp
 | 
				
			||||||
                            from (
 | 
					                            from (
 | 
				
			||||||
	                            select *
 | 
						                            select *
 | 
				
			||||||
	                            from (
 | 
						                            from (
 | 
				
			||||||
		                            (
 | 
							                            (
 | 
				
			||||||
			                            SELECT DATE(ADDDATE(@startTime, INTERVAL @i:=@i+1 {input.tableType})) AS date
 | 
								                            SELECT DATE(ADDDATE('{startTime}', INTERVAL @i:=@i+1 {input.tableType})) AS date
 | 
				
			||||||
                                        FROM {table}
 | 
					                                        FROM {table}
 | 
				
			||||||
			                            HAVING @i < TIMESTAMPDIFF({input.tableType}, @startTime, ADDDATE(@endTime, INTERVAL -1 DAY))
 | 
								                            HAVING @i < TIMESTAMPDIFF({input.tableType}, '{startTime}', ADDDATE('{endTime}' , INTERVAL -1 DAY))
 | 
				
			||||||
		                            ) d,
 | 
							                            ) d,
 | 
				
			||||||
		                            (   
 | 
							                            (   
 | 
				
			||||||
                                        select device_number
 | 
					                                        select device_number
 | 
				
			||||||
                                        from {table}
 | 
					                                        from {table}
 | 
				
			||||||
                                        where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'KWH' {buildingSql}
 | 
					                                        where start_timestamp >= '{startTime}' and end_timestamp < '{endTime}'  and point = 'KWH' {buildingSql}
 | 
				
			||||||
                                        {sqlWhere} 
 | 
					                                        {sqlWhere} 
 | 
				
			||||||
                                        group by device_number
 | 
					                                        group by device_number
 | 
				
			||||||
                                    ) dn
 | 
					                                    ) dn
 | 
				
			||||||
@ -154,11 +164,13 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                            left join (
 | 
					                            left join (
 | 
				
			||||||
	                            select device_number, {sqlAvgRawData}
 | 
						                            select device_number, {sqlAvgRawData}
 | 
				
			||||||
		                            from {table}
 | 
							                            from {table}
 | 
				
			||||||
 		                            where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'KWH' {buildingSql}
 | 
					 		                            where start_timestamp >= '{startTime}' and end_timestamp < '{endTime}' and point = 'KWH' {buildingSql}
 | 
				
			||||||
                                    {sqlWhere} {sqlGroup}
 | 
					                                    {sqlWhere} {sqlGroup}
 | 
				
			||||||
                            ) aemm on aemm.start_timestamp >= {aemmStaDate} and aemm.end_timestamp < {aemmEndDate} and aemm.device_number = fd.device_number
 | 
					                            ) aemm on {date_yyyymmdd}  and aemm.device_number = fd.device_number
 | 
				
			||||||
 | 
					                            join device dc on fd.device_number = dc.device_number
 | 
				
			||||||
 | 
						                        where dc.deleted = 0
 | 
				
			||||||
                            order by fd.device_number, fd.date";
 | 
					                            order by fd.device_number, fd.date";
 | 
				
			||||||
                Logger.LogInformation("SQL = " + sql + " startTime=" + startTime + " endTime=" + endTime + " building=" + input.building_tag + " floor_tag = " + input.floor_tag);
 | 
					                Logger.LogInformation("0918 SQL = " + sql + Environment.NewLine + " startTime='" + startTime + "' endTime='" + endTime + "' building=" + input.building_tag );
 | 
				
			||||||
                var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
 | 
					                var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
 | 
				
			||||||
                                new { startTime = startTime, endtime = endTime, building_tag = input.building_tag, dateFormat = dateFormat });
 | 
					                                new { startTime = startTime, endtime = endTime, building_tag = input.building_tag, dateFormat = dateFormat });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -177,7 +189,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                            .Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag, device_master = x.Key.device_master, device_number = x.Key.device_number })
 | 
					                            .Select(x => new HydroMeterOutput { building_tag = x.Key.building_tag, floor_tag = x.Key.floor_tag, device_serial_tag = x.Key.device_serial_tag, device_master = x.Key.device_master, device_number = x.Key.device_number })
 | 
				
			||||||
                            .ToList();
 | 
					                            .ToList();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                int i = 0;
 | 
				
			||||||
                foreach (var l in list)
 | 
					                foreach (var l in list)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    l.rawData = new List<HydroMeterRawDataOutput>();
 | 
					                    l.rawData = new List<HydroMeterRawDataOutput>();
 | 
				
			||||||
@ -196,13 +208,21 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
 | 
					                    l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
 | 
				
			||||||
                                        new { building_tag = l.building_tag });
 | 
					                                        new { building_tag = l.building_tag });
 | 
				
			||||||
 | 
					                    //如果是 總計不含分盤 mode = custom; 就呈現 化工總計
 | 
				
			||||||
 | 
					                    //if (input.Mode == HydroMeterInputSearchMode.Custom && l.building_tag == "D8") 
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    l.building_name = "化工館總計";
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    l.total = l.rawData.Where(x => x.avg_rawdata != "NaN").Sum(x => decimal.Parse(x.avg_rawdata ?? "0", System.Globalization.NumberStyles.Float)).ToString();
 | 
					                    l.total = l.rawData.Where(x => x.avg_rawdata != "NaN").Sum(x => decimal.Parse(x.avg_rawdata ?? "0", System.Globalization.NumberStyles.Float)).ToString();
 | 
				
			||||||
                    l.price = input.price.HasValue 
 | 
					                    l.price = input.price.HasValue 
 | 
				
			||||||
                                ? (Math.Round(input.price.Value, 2)).ToString() 
 | 
					                                ? (Math.Round(input.price.Value, 2)).ToString() 
 | 
				
			||||||
                                : Math.Round((await backendRepository.GetOneAsync<decimal>("select system_value from variable where system_type = 'ElectricPrice' and deleted = 0")), 2).ToString();
 | 
					                                : Math.Round((await backendRepository.GetOneAsync<decimal>("select system_value from variable where system_type = 'ElectricPrice' and deleted = 0")), 2).ToString();
 | 
				
			||||||
                    l.total_price = Math.Round((Decimal.Parse(l.total) * Decimal.Parse(l.price)), 2).ToString();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
 | 
					                    l.total_price = Math.Round((Decimal.Parse(l.total) * Decimal.Parse(l.price)), 2).ToString();
 | 
				
			||||||
 | 
					                    i++;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                Logger.LogInformation(" 筆數:" + i.ToString());
 | 
				
			||||||
                apiResult.Code = "0000";
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
                apiResult.Data = list;
 | 
					                apiResult.Data = list;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -428,11 +448,12 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            List<List<HydroMeterOutput>> result = new List<List<HydroMeterOutput>>();
 | 
					            List<List<HydroMeterOutput>> result = new List<List<HydroMeterOutput>>();
 | 
				
			||||||
            var building = backendRepository.GetAllAsync<HydroBuildList>("select * from building where deleted = 0").Result;
 | 
					            var building = backendRepository.GetAllAsync<HydroBuildList>("select * from building where deleted = 0").Result;
 | 
				
			||||||
            foreach(var b in building)
 | 
					            //foreach(var b in building)
 | 
				
			||||||
            {
 | 
					            //{
 | 
				
			||||||
                input.building_tag = b.building_tag;
 | 
					            //    input.building_tag = b.building_tag;
 | 
				
			||||||
 | 
					            //   0 result.Add(this.ElectricList(input).Result.Value.Data.ToList());
 | 
				
			||||||
 | 
					            //}
 | 
				
			||||||
            result.Add(this.ElectricList(input).Result.Value.Data.ToList());
 | 
					            result.Add(this.ElectricList(input).Result.Value.Data.ToList());
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            List<Dictionary<string, byte[]>> docFile = new List<Dictionary<string, byte[]>>();
 | 
					            List<Dictionary<string, byte[]>> docFile = new List<Dictionary<string, byte[]>>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var workbook = new XSSFWorkbook();
 | 
					            var workbook = new XSSFWorkbook();
 | 
				
			||||||
@ -467,6 +488,20 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            styleLine12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
					            styleLine12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
            styleLine12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
					            styleLine12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
            styleLine12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
					            styleLine12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
 | 
					            #region setting for data
 | 
				
			||||||
 | 
					            //IFont fontNumeric = workbook.CreateFont();
 | 
				
			||||||
 | 
					            //fontNumeric.FontName = "新細明體";
 | 
				
			||||||
 | 
					            //fontNumeric.FontHeightInPoints = 12;
 | 
				
			||||||
 | 
					            //ICellStyle styleLineNumeric = workbook.CreateCellStyle();
 | 
				
			||||||
 | 
					            //styleLineNumeric.SetFont(fontNumeric);
 | 
				
			||||||
 | 
					            //styleLineNumeric.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
 | 
				
			||||||
 | 
					            //styleLineNumeric.VerticalAlignment = VerticalAlignment.Center;
 | 
				
			||||||
 | 
					            //styleLineNumeric.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
 | 
					            //styleLineNumeric.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
 | 
					            //styleLineNumeric.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
 | 
					            //styleLineNumeric.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
 | 
					            #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ICellStyle stylein12 = workbook.CreateCellStyle();
 | 
					            ICellStyle stylein12 = workbook.CreateCellStyle();
 | 
				
			||||||
            stylein12.SetFont(font12Times);
 | 
					            stylein12.SetFont(font12Times);
 | 
				
			||||||
            stylein12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
 | 
					            stylein12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
 | 
				
			||||||
@ -477,14 +512,25 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
					            stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
 | 
				
			||||||
            stylein12.WrapText = true;
 | 
					            stylein12.WrapText = true;
 | 
				
			||||||
            #endregion
 | 
					            #endregion
 | 
				
			||||||
 | 
					            string reportType = string.Empty;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            switch (input.tableType.ToLower()) //day, week, month, year
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                case "day": reportType = "日報表";  break;
 | 
				
			||||||
 | 
					                case "week": reportType = "周報表"; break;
 | 
				
			||||||
 | 
					                case "month": reportType = "月報表"; break;
 | 
				
			||||||
 | 
					                case "year": reportType = "年報表"; break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //var sheet = workbook.CreateSheet($"{buildingName}");
 | 
				
			||||||
 | 
					            var sheet = workbook.CreateSheet($"{reportType}");
 | 
				
			||||||
            foreach (var r in result)
 | 
					            foreach (var r in result)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (r.Count > 0)
 | 
					                if (r.Count > 0)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    string buildingName = r.Select(x => x.building_name).FirstOrDefault();
 | 
					                    string buildingName = r.Select(x => x.building_name).FirstOrDefault();
 | 
				
			||||||
                    var sheet = workbook.CreateSheet($"{buildingName} 電表報表");
 | 
					                    Logger.LogInformation(@$"buildingName = {buildingName}" + Environment.NewLine);
 | 
				
			||||||
                    int RowPosition = 0;
 | 
					                    int RowPosition = 0;
 | 
				
			||||||
                    #region set cell
 | 
					                    #region set cell for columns
 | 
				
			||||||
                    IRow row = sheet.CreateRow(RowPosition);
 | 
					                    IRow row = sheet.CreateRow(RowPosition);
 | 
				
			||||||
                    sheet.SetColumnWidth(0, 4 * 160 * 12);
 | 
					                    sheet.SetColumnWidth(0, 4 * 160 * 12);
 | 
				
			||||||
                    sheet.SetColumnWidth(1, 4 * 160 * 12);
 | 
					                    sheet.SetColumnWidth(1, 4 * 160 * 12);
 | 
				
			||||||
@ -585,7 +631,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            ms.Flush();
 | 
					            ms.Flush();
 | 
				
			||||||
            ms.Seek(0, SeekOrigin.Begin);
 | 
					            ms.Seek(0, SeekOrigin.Begin);
 | 
				
			||||||
            Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
 | 
					            Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
 | 
				
			||||||
            return File(ms, "application/vnd.ms", @$"電表報表{System.DateTime.Now.ToString("yyyyMMddHHmm")}.xlsx");
 | 
					            return File(ms, "application/vnd.ms", @$"電表報表_{reportType}_{System.DateTime.Now.ToString("yyyyMMddHHmm")}.xlsx");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [HttpPost]
 | 
					        [HttpPost]
 | 
				
			||||||
@ -829,26 +875,29 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            return File(ms, "application/vnd.ms-excel", @$"電表報表{System.DateTime.Now.ToString("yyyyMMddHHmm")}.xlsx");
 | 
					            return File(ms, "application/vnd.ms-excel", @$"電表報表{System.DateTime.Now.ToString("yyyyMMddHHmm")}.xlsx");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 客製化報表 excel 匯出 - 總計不含分盤 
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="input"></param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
        [HttpPost]
 | 
					        [HttpPost]
 | 
				
			||||||
        [Route("api/ExportElectricEachTotalCompareList")]
 | 
					        [Route("api/ExportElectricEachTotalCompareList")]
 | 
				
			||||||
        public FileResult OpeExportEachTotalCompareExcelElec([FromBody] HydroMeterInput input)
 | 
					        public FileResult OpeExportEachTotalCompareExcelElec([FromBody] HydroMeterInput input)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            List<HydroMeterOutput> result = new List<HydroMeterOutput>();
 | 
					 | 
				
			||||||
            List<HydroMeterOutput> result_for_sum = new List<HydroMeterOutput>();
 | 
					 | 
				
			||||||
            result = ElectricListEachTotal(input).Result.Value.Data.ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            bool flag = true;
 | 
					            bool flag = true;
 | 
				
			||||||
            bool total_flag = false;
 | 
					            bool total_flag = false;
 | 
				
			||||||
 | 
					            string outputFileName = input.Mode == HydroMeterInputSearchMode.All ? "用電月份比較_含分盤_" : "用電月份比較_";
 | 
				
			||||||
            if (input.Mode == HydroMeterInputSearchMode.Custom)
 | 
					            if (input.Mode == HydroMeterInputSearchMode.Custom)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                result_for_sum = ElectricListEachTotal(input).Result.Value.Data.ToList();
 | 
					                //flag = false;
 | 
				
			||||||
                flag = false;
 | 
					                
 | 
				
			||||||
                total_flag = true;
 | 
					                total_flag = true;
 | 
				
			||||||
 | 
					                input.Mode = HydroMeterInputSearchMode.All;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					
 | 
				
			||||||
            {
 | 
					            List<HydroMeterOutput> result = new List<HydroMeterOutput>();
 | 
				
			||||||
                result_for_sum = new List<HydroMeterOutput>(result);
 | 
					            result = ElectricListEachTotal(input).Result.Value.Data.ToList();
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<Dictionary<string, byte[]>> docFile = new List<Dictionary<string, byte[]>>();
 | 
					            List<Dictionary<string, byte[]>> docFile = new List<Dictionary<string, byte[]>>();
 | 
				
			||||||
            var workbook = new XSSFWorkbook();
 | 
					            var workbook = new XSSFWorkbook();
 | 
				
			||||||
@ -956,12 +1005,12 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                int columnIndex = 1; // 假設第一欄是要填入的位置
 | 
					                int columnIndex = 1; // 假設第一欄是要填入的位置
 | 
				
			||||||
                List<string> need_cal_total = new List<string>
 | 
					                List<string> need_cal_total = new List<string>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    "綜合大樓",
 | 
					                    "綜合大樓",  //G6
 | 
				
			||||||
                    "體育舘",
 | 
					                    "體育舘",    //F5
 | 
				
			||||||
                    "化工館",
 | 
					                    "化工電機",  //D8
 | 
				
			||||||
                    "創新大樓",
 | 
					                    "創新大樓",  //G9
 | 
				
			||||||
                    "學人會館",
 | 
					                    "學人會館", //B9
 | 
				
			||||||
                    "綠能中心"
 | 
					                    "綠能中心"  //$340B9
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                List<string> no_cal_sum_device = new List<string>
 | 
					                List<string> no_cal_sum_device = new List<string>
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@ -970,16 +1019,16 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                    "第二校區總盤",
 | 
					                    "第二校區總盤",
 | 
				
			||||||
                    "薄膜分盤"
 | 
					                    "薄膜分盤"
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                List<string> need_green_device = new List<string>
 | 
					                List<string> need_green_device = new List<string> //需要綠色底色
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    "第一校區總盤",
 | 
					                    "第一校區總盤",
 | 
				
			||||||
                    "圖資大樓總盤",
 | 
					                    "圖資大樓總盤",
 | 
				
			||||||
                    "教學大樓總盤",
 | 
					                    "教學大樓總盤",
 | 
				
			||||||
                    "教學大樓總盤",
 | 
					 | 
				
			||||||
                    "電子館分盤",
 | 
					                    "電子館分盤",
 | 
				
			||||||
                    "機械館分盤",
 | 
					                    "機械館分盤",
 | 
				
			||||||
                    "電機館分盤",
 | 
					                    "電機館分盤",
 | 
				
			||||||
                    "學5舍總盤",
 | 
					                    "學1-4舍餐廳總盤", //C7
 | 
				
			||||||
 | 
					                    "學5舍5眷總盤",   //B4
 | 
				
			||||||
                    "8眷舍分盤",
 | 
					                    "8眷舍分盤",
 | 
				
			||||||
                    "企教分盤",
 | 
					                    "企教分盤",
 | 
				
			||||||
                    "7眷舍分盤",
 | 
					                    "7眷舍分盤",
 | 
				
			||||||
@ -991,11 +1040,18 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                string last_build = "";
 | 
					                string last_build = "";
 | 
				
			||||||
                string last_device = "";
 | 
					                string last_device = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // ------------------
 | 
					 | 
				
			||||||
                Dictionary<string, Dictionary<string, double>> buildingSumData = new Dictionary<string, Dictionary<string, double>>();
 | 
					                Dictionary<string, Dictionary<string, double>> buildingSumData = new Dictionary<string, Dictionary<string, double>>();
 | 
				
			||||||
                #region 特定棟別總計處理
 | 
					                #region 特定棟別總計處理
 | 
				
			||||||
                foreach (var item in result_for_sum)
 | 
					                foreach (var item in result)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    if (item.device_full_name == "NTPC_D8_EE_E4_RF_H1_WHT_N1") //化工電機
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Console.WriteLine("here 化工電機 " + item.building_name);
 | 
				
			||||||
 | 
					                        if (item.building_name == "化工電機")
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            Console.WriteLine("here 化工電機 " + item.building_name);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    if (!need_cal_total.Contains(item.building_name))
 | 
					                    if (!need_cal_total.Contains(item.building_name))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
@ -1020,7 +1076,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        buildingSumData[item.building_name][dataItem.timeStamp] += Math.Round(double.Parse(dataItem.avg_rawdata));
 | 
					                        buildingSumData[item.building_name][dataItem.timeStamp] += Math.Round(double.Parse(dataItem.avg_rawdata));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                #endregion
 | 
					
 | 
				
			||||||
                // 測試
 | 
					                // 測試
 | 
				
			||||||
                //foreach (var building in buildingSumData)
 | 
					                //foreach (var building in buildingSumData)
 | 
				
			||||||
                //{
 | 
					                //{
 | 
				
			||||||
@ -1030,40 +1086,61 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                //        Console.WriteLine($"  TimeStamp: {timeStampData.Key}, Total Avg RawData: {timeStampData.Value}");
 | 
					                //        Console.WriteLine($"  TimeStamp: {timeStampData.Key}, Total Avg RawData: {timeStampData.Value}");
 | 
				
			||||||
                //    }
 | 
					                //    }
 | 
				
			||||||
                //}
 | 
					                //}
 | 
				
			||||||
                // ------------------
 | 
					                #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                foreach (var r in result)
 | 
					                foreach (var r in result)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (total_flag)
 | 
					                    //if (total_flag)
 | 
				
			||||||
                    {
 | 
					                    //{
 | 
				
			||||||
                        flag = false;
 | 
					                    //    flag = false;
 | 
				
			||||||
                    }
 | 
					                    //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    string buildingName = r.building_name;
 | 
					                    string buildingName = r.building_name;
 | 
				
			||||||
                    string floorTag = r.floor_tag;
 | 
					                    string floorTag = r.floor_tag;
 | 
				
			||||||
                    string deviceFullName = r.device_full_name;
 | 
					                    string deviceFullName = r.device_full_name;
 | 
				
			||||||
                    columnIndex = 0;
 | 
					                    columnIndex = 0;
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
 | 
					                    // 這兩個盤不納入該棟總計
 | 
				
			||||||
                    if (last_device == "電機館分盤" || last_device == "薄膜分盤")
 | 
					                    if (last_device == "電機館分盤" || last_device == "薄膜分盤")
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        flag = false;
 | 
					                        flag = false;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if ((flag && buildingName == "化工館" && deviceFullName == "電機館分盤") || (flag && buildingName == "綠能中心" && deviceFullName == "薄膜分盤"))
 | 
					                    if ((flag && buildingName == "化工電機" && deviceFullName == "電機館分盤") || (flag && buildingName == "綠能中心" && deviceFullName == "薄膜分盤"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
					                        row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
				
			||||||
                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
                        cell.SetCellValue(count_index.ToString());
 | 
					                        cell.SetCellValue(count_index.ToString());
 | 
				
			||||||
                        count_index++;
 | 
					                        count_index++;
 | 
				
			||||||
 | 
					                        if (total_flag)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            cell = row.GetCell(columnIndex) ?? row.CreateCell(columnIndex);
 | 
				
			||||||
 | 
					                            cell.SetCellValue(buildingName + floorTag);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        columnIndex++;
 | 
					                        columnIndex++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
 | 
					                        if (last_build == "化工電機")
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            cell.SetCellValue("化工館總計");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            cell.SetCellValue(last_build + "總計");
 | 
					                            cell.SetCellValue(last_build + "總計");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        cell.CellStyle = greenCellStyle;
 | 
					                        cell.CellStyle = greenCellStyle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        foreach (var timeStampData in buildingSumData[last_build])
 | 
					                        foreach (var timeStampData in buildingSumData[last_build])
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                            cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
                            cell.SetCellValue(timeStampData.Value.ToString());
 | 
					                            //if (last_build == "化工電機")
 | 
				
			||||||
 | 
					                            //{
 | 
				
			||||||
 | 
					                            //    cell.SetCellValue(10); //總計結果寫入 
 | 
				
			||||||
 | 
					                            //}
 | 
				
			||||||
 | 
					                            //else
 | 
				
			||||||
 | 
					                            //{
 | 
				
			||||||
 | 
					                                cell.SetCellValue(timeStampData.Value.ToString()); //總計結果寫入 by jiahao 09/28 
 | 
				
			||||||
 | 
					                            //}
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        rowIndex++;
 | 
					                        rowIndex++;
 | 
				
			||||||
@ -1072,7 +1149,8 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        columnIndex = 0;
 | 
					                        columnIndex = 0;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                    if ((total_flag && need_cal_total.Contains(last_build)) || (flag && buildingName != last_build && need_cal_total.Contains(last_build)))
 | 
					                    //增加總計欄位
 | 
				
			||||||
 | 
					                    if (flag && buildingName != last_build && need_cal_total.Contains(last_build))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
					                        row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
				
			||||||
                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
@ -1087,7 +1165,15 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        columnIndex++;
 | 
					                        columnIndex++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
 | 
					                        
 | 
				
			||||||
 | 
					                        if (last_build == "學人會館")
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            cell.SetCellValue("學人國際總計");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        else {
 | 
				
			||||||
                            cell.SetCellValue(last_build + "總計");
 | 
					                            cell.SetCellValue(last_build + "總計");
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                       
 | 
				
			||||||
                        cell.CellStyle = greenCellStyle;
 | 
					                        cell.CellStyle = greenCellStyle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        foreach (var timeStampData in buildingSumData[last_build])
 | 
					                        foreach (var timeStampData in buildingSumData[last_build])
 | 
				
			||||||
@ -1102,6 +1188,11 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        // continue;
 | 
					                        // continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
 | 
					                    //是否需要總計
 | 
				
			||||||
 | 
					                    if (total_flag)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        if (need_green_device.Contains(deviceFullName))
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
                            columnIndex = 0;
 | 
					                            columnIndex = 0;
 | 
				
			||||||
                            row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
					                            row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
				
			||||||
                            cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                            cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
@ -1113,7 +1204,35 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                            cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                            cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
                            cell.SetCellValue(deviceFullName);
 | 
					                            cell.SetCellValue(deviceFullName);
 | 
				
			||||||
                    if (total_flag || need_green_device.Contains(deviceFullName))
 | 
					                            cell.CellStyle = greenCellStyle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            foreach (var rawD in r.rawData)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
 | 
					                                cell.SetCellValue(rawD.avg_rawdata);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            rowIndex++;
 | 
				
			||||||
 | 
					                            last_build = buildingName;
 | 
				
			||||||
 | 
					                            last_device = deviceFullName;
 | 
				
			||||||
 | 
					                            flag = true;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        last_build = buildingName;
 | 
				
			||||||
 | 
					                        last_device = deviceFullName;
 | 
				
			||||||
 | 
					                        flag = true;
 | 
				
			||||||
 | 
					                        continue;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    columnIndex = 0;
 | 
				
			||||||
 | 
					                    row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex);
 | 
				
			||||||
 | 
					                    cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
 | 
					                    cell.SetCellValue(count_index.ToString());
 | 
				
			||||||
 | 
					                    count_index++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
 | 
					                    cell.SetCellValue(buildingName + floorTag);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
 | 
					                    cell.SetCellValue(deviceFullName);
 | 
				
			||||||
 | 
					                    if (need_green_device.Contains(deviceFullName))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        cell.CellStyle = greenCellStyle;
 | 
					                        cell.CellStyle = greenCellStyle;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
@ -1123,7 +1242,6 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
					                        cell = row.GetCell(columnIndex++) ?? row.CreateCell(columnIndex++);
 | 
				
			||||||
                        cell.SetCellValue(rawD.avg_rawdata);
 | 
					                        cell.SetCellValue(rawD.avg_rawdata);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    rowIndex++;
 | 
					                    rowIndex++;
 | 
				
			||||||
                    last_build = buildingName;
 | 
					                    last_build = buildingName;
 | 
				
			||||||
                    last_device = deviceFullName;
 | 
					                    last_device = deviceFullName;
 | 
				
			||||||
@ -1139,7 +1257,8 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            ms.Flush();
 | 
					            ms.Flush();
 | 
				
			||||||
            ms.Seek(0, SeekOrigin.Begin);
 | 
					            ms.Seek(0, SeekOrigin.Begin);
 | 
				
			||||||
            Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
 | 
					            Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
 | 
				
			||||||
            return File(ms, "application/vnd.ms", @$"用電差異比較表{System.DateTime.Now.ToString("yyyyMMddHHmm")}.xlsx");
 | 
					            
 | 
				
			||||||
 | 
					            return File(ms, "application/vnd.ms", @$"{outputFileName}{System.DateTime.Now.ToString("yyyyMMddHHmm")}.xlsx");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [HttpPost]
 | 
					        [HttpPost]
 | 
				
			||||||
@ -1178,19 +1297,20 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                string sqlWhere = "";
 | 
					                string sqlWhere = "";
 | 
				
			||||||
                string tag_quantity = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'obixConfig' and system_key = 'tag_quantity' and deleted = 0");
 | 
					                string tag_quantity = await backendRepository.GetOneAsync<string>("select system_value from variable where system_type = 'obixConfig' and system_key = 'tag_quantity' and deleted = 0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                switch (input.Mode)
 | 
					                //switch (input.Mode)
 | 
				
			||||||
                {
 | 
					                //{
 | 
				
			||||||
                    case HydroMeterInputSearchMode.All:
 | 
					                //    case HydroMeterInputSearchMode.All:
 | 
				
			||||||
 | 
					                //        sqlWhere = @$" a.priority <> 0 ";
 | 
				
			||||||
 | 
					                //        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //    case HydroMeterInputSearchMode.Custom:
 | 
				
			||||||
 | 
					                //        sqlWhere = @$" a.device_number in (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(system_value, '/', -1), '_', 8) COLLATE utf8mb4_0900_ai_ci as val FROM variable where system_type = 'dashboard_total_elec')";
 | 
				
			||||||
 | 
					                //        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //    default:
 | 
				
			||||||
 | 
					                //        break;
 | 
				
			||||||
 | 
					                //}
 | 
				
			||||||
                sqlWhere = @$" a.priority <> 0 ";
 | 
					                sqlWhere = @$" a.priority <> 0 ";
 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    case HydroMeterInputSearchMode.Custom:
 | 
					 | 
				
			||||||
                        sqlWhere = @$" a.device_number in (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(system_value, '/', -1), '_', 8) COLLATE utf8mb4_0900_ai_ci as val FROM variable where system_type = 'dashboard_total_elec')";
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    default:
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var table = "archive_electric_meter_month";
 | 
					                var table = "archive_electric_meter_month";
 | 
				
			||||||
                var schema = await backendRepository.GetOneAsync<string>($"select system_value from variable where system_type = 'project_name'");
 | 
					                var schema = await backendRepository.GetOneAsync<string>($"select system_value from variable where system_type = 'project_name'");
 | 
				
			||||||
@ -1218,6 +1338,25 @@ order by  e.report_priority, a.priority";
 | 
				
			|||||||
                Logger.LogInformation("SQL = " + sql + " building=" + input.building_tag + " floor_tag = " + input.floor_tag);
 | 
					                Logger.LogInformation("SQL = " + sql + " building=" + input.building_tag + " floor_tag = " + input.floor_tag);
 | 
				
			||||||
                var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataEachTotalOutput>(sql);
 | 
					                var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataEachTotalOutput>(sql);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                List<string> need_green_device = new List<string>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    "第一校區總盤",
 | 
				
			||||||
 | 
					                    "圖資大樓總盤",
 | 
				
			||||||
 | 
					                    "教學大樓總盤",
 | 
				
			||||||
 | 
					                    "電子館分盤",
 | 
				
			||||||
 | 
					                    "機械館分盤",
 | 
				
			||||||
 | 
					                    "化工電機總盤",
 | 
				
			||||||
 | 
					                    "電機館分盤",
 | 
				
			||||||
 | 
					                    "學1-4舍餐廳總盤",
 | 
				
			||||||
 | 
					                    "學5舍5眷總盤",
 | 
				
			||||||
 | 
					                    "8眷舍分盤",
 | 
				
			||||||
 | 
					                    "企教分盤",
 | 
				
			||||||
 | 
					                    "7眷舍分盤",
 | 
				
			||||||
 | 
					                    "第二校區總盤",
 | 
				
			||||||
 | 
					                    "薄膜一館分盤",
 | 
				
			||||||
 | 
					                    "薄膜二館分盤"
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                List<HydroMeterOutput> ResultData = new List<HydroMeterOutput>();
 | 
					                List<HydroMeterOutput> ResultData = new List<HydroMeterOutput>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                ResultData = rawData
 | 
					                ResultData = rawData
 | 
				
			||||||
@ -1227,6 +1366,20 @@ order by  e.report_priority, a.priority";
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                foreach (var l in ResultData)
 | 
					                foreach (var l in ResultData)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    var full_name = await backendRepository.GetOneAsync<string>($"select full_name from device where device_number = '{l.device_number}'");
 | 
				
			||||||
 | 
					                    //if (l.device_number == "NTPC_B4_EE_E4_B1F_VCB3B_WHT_N1")//"學5舍5眷總盤"
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    Console.WriteLine("here " + l.device_full_name);
 | 
				
			||||||
 | 
					                    //} 
 | 
				
			||||||
 | 
					                    if (l.device_number == "NTPC_D8_EE_E4_RF_HM_WHT_N1")// 化工電機總盤 
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Console.WriteLine("here " + l.device_full_name);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (input.Mode == HydroMeterInputSearchMode.Custom && !need_green_device.Contains(full_name))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        continue;
 | 
				
			||||||
 | 
					                    }                   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    l.rawData = new List<HydroMeterRawDataOutput>();
 | 
					                    l.rawData = new List<HydroMeterRawDataOutput>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1281,18 +1434,39 @@ order by  e.report_priority, a.priority";
 | 
				
			|||||||
                            })
 | 
					                            })
 | 
				
			||||||
                    );
 | 
					                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    l.device_full_name = await backendRepository.GetOneAsync<string>($"select full_name from device where device_number = '{l.device_number}'");
 | 
					                    l.device_full_name = full_name;
 | 
				
			||||||
                    l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
 | 
					                    l.building_name = await backendRepository.GetOneAsync<string>("select full_name from building where building_tag = @building_tag and deleted = 0",
 | 
				
			||||||
                                        new { building_tag = l.building_tag });
 | 
					                                        new { building_tag = l.building_tag });
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    //不含分盤 需要修改大樓名稱
 | 
				
			||||||
 | 
					                    //if(input.Mode == HydroMeterInputSearchMode.Custom && l.)
 | 
				
			||||||
 | 
					                    //{
 | 
				
			||||||
 | 
					                    //    l.building_name = "化工館總計";
 | 
				
			||||||
 | 
					                    //}
 | 
				
			||||||
                    l.total = l.rawData.Where(x => x.avg_rawdata != "NaN").Sum(x => decimal.Parse(x.avg_rawdata ?? "0", System.Globalization.NumberStyles.Float)).ToString();
 | 
					                    l.total = l.rawData.Where(x => x.avg_rawdata != "NaN").Sum(x => decimal.Parse(x.avg_rawdata ?? "0", System.Globalization.NumberStyles.Float)).ToString();
 | 
				
			||||||
                    l.price = input.price.HasValue
 | 
					                    l.price = input.price.HasValue
 | 
				
			||||||
                                ? (Math.Round(input.price.Value, 2)).ToString()
 | 
					                                ? (Math.Round(input.price.Value, 2)).ToString()
 | 
				
			||||||
                                : Math.Round((await backendRepository.GetOneAsync<decimal>("select system_value from variable where system_type = 'ElectricPrice' and deleted = 0")), 2).ToString();
 | 
					                                : Math.Round((await backendRepository.GetOneAsync<decimal>("select system_value from variable where system_type = 'ElectricPrice' and deleted = 0")), 2).ToString();
 | 
				
			||||||
                    l.total_price = Math.Round((Decimal.Parse(l.total) * Decimal.Parse(l.price))).ToString();
 | 
					                    l.total_price = Math.Round((Decimal.Parse(l.total) * Decimal.Parse(l.price))).ToString();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                List<HydroMeterOutput> ResultData_custom = new List<HydroMeterOutput>();
 | 
				
			||||||
 | 
					                foreach (var l in ResultData)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (l.device_full_name != null)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        ResultData_custom.Add(l);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                apiResult.Code = "0000";
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
                apiResult.Data = ResultData;
 | 
					                if (input.Mode == HydroMeterInputSearchMode.All)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    apiResult.Data = ResultData; //含分盤
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    apiResult.Data = ResultData_custom; //不含分盤
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception exception)
 | 
					            catch (Exception exception)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,7 @@ using System.Threading.Tasks;
 | 
				
			|||||||
using Image = System.Drawing.Image;
 | 
					using Image = System.Drawing.Image;
 | 
				
			||||||
using System.IdentityModel.Tokens.Jwt;
 | 
					using System.IdentityModel.Tokens.Jwt;
 | 
				
			||||||
using System.Net;
 | 
					using System.Net;
 | 
				
			||||||
 | 
					using System.Data.SqlTypes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace FrontendWebApi.ApiControllers
 | 
					namespace FrontendWebApi.ApiControllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -206,7 +207,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var sqlString = @$"select device_number, concat(device_floor_tag, ' ', full_name) as device_name, full_name, device_floor_tag, device_system_tag, device_name_tag
 | 
					                var sqlString = @$"select device_number, concat(device_floor_tag, ' ', full_name) as device_name, full_name, device_floor_tag, device_system_tag, device_name_tag
 | 
				
			||||||
                                   from device where deleted = 0 and device_area_tag = @device_area_tag and device_building_tag = @device_building_tag and device_name_tag in @list_sub_system_tag  ";
 | 
					                                   from device where deleted = 0 and device_area_tag = @device_area_tag and device_name_tag in @list_sub_system_tag  ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var param = new { @device_building_tag = bl.device_building_tag, @device_area_tag = bl.device_area_tag, @list_sub_system_tag = bl.list_sub_system_tag };
 | 
					                var param = new { @device_building_tag = bl.device_building_tag, @device_area_tag = bl.device_area_tag, @list_sub_system_tag = bl.list_sub_system_tag };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -769,7 +770,7 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
            List<Operation_Firm> opList = new List<Operation_Firm>();
 | 
					            List<Operation_Firm> opList = new List<Operation_Firm>();
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var sqlString = $@"select id, name from operation_firm where deleted = 0 and device_system_category_layer3 in @sub_system_tag";
 | 
					                var sqlString = $@"select id, name from operation_firm where deleted = 0";
 | 
				
			||||||
                opList = await backendRepository.GetAllAsync<Operation_Firm>(sqlString, new { @sub_system_tag = ofl.sub_system_tag });
 | 
					                opList = await backendRepository.GetAllAsync<Operation_Firm>(sqlString, new { @sub_system_tag = ofl.sub_system_tag });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                apiResult.Code = "0000";
 | 
					                apiResult.Code = "0000";
 | 
				
			||||||
@ -1226,8 +1227,8 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        { "@device_system_category_layer3", or.device_system_category_layer3},
 | 
					                        { "@device_system_category_layer3", or.device_system_category_layer3},
 | 
				
			||||||
                        { "@work_type", or.work_type},
 | 
					                        { "@work_type", or.work_type},
 | 
				
			||||||
                        { "@error_code", or.error_code},
 | 
					                        { "@error_code", or.error_code},
 | 
				
			||||||
                        { "@fix_do", or.fix_do},
 | 
					                        { "@fix_do", or.fix_do == "null" ? "" : or.fix_do },
 | 
				
			||||||
                        { "@fix_do_code", or.fix_do_code },
 | 
					                        { "@fix_do_code", or.fix_do_code == "null" ? "" : or.fix_do_code },
 | 
				
			||||||
                        { "@fix_firm", or.fix_firm},
 | 
					                        { "@fix_firm", or.fix_firm},
 | 
				
			||||||
                        { "@status", or.status},
 | 
					                        { "@status", or.status},
 | 
				
			||||||
                        { "@work_person_id", or.work_person_id},
 | 
					                        { "@work_person_id", or.work_person_id},
 | 
				
			||||||
@ -1291,8 +1292,8 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        { "@device_system_category_layer2", or.device_system_category_layer2},
 | 
					                        { "@device_system_category_layer2", or.device_system_category_layer2},
 | 
				
			||||||
                        { "@device_system_category_layer3", or.device_system_category_layer3},
 | 
					                        { "@device_system_category_layer3", or.device_system_category_layer3},
 | 
				
			||||||
                        { "@error_code", or.error_code},
 | 
					                        { "@error_code", or.error_code},
 | 
				
			||||||
                        { "@fix_do", or.fix_do},
 | 
					                        { "@fix_do", or.fix_do == "null" ? "" : or.fix_do },
 | 
				
			||||||
                        { "@fix_do_code", or.fix_do_code },
 | 
					                        { "@fix_do_code", or.fix_do_code == "null" ? "" : or.fix_do_code },
 | 
				
			||||||
                        { "@fix_firm", or.fix_firm},
 | 
					                        { "@fix_firm", or.fix_firm},
 | 
				
			||||||
                        { "@status", or.status},
 | 
					                        { "@status", or.status},
 | 
				
			||||||
                        { "@work_person_id", or.work_person_id},
 | 
					                        { "@work_person_id", or.work_person_id},
 | 
				
			||||||
@ -1300,8 +1301,8 @@ namespace FrontendWebApi.ApiControllers
 | 
				
			|||||||
                        { "@end_time", or.end_time},
 | 
					                        { "@end_time", or.end_time},
 | 
				
			||||||
                        { "@work_time", or.work_time},
 | 
					                        { "@work_time", or.work_time},
 | 
				
			||||||
                        { "@finish_time", or.finish_time},
 | 
					                        { "@finish_time", or.finish_time},
 | 
				
			||||||
                        { "@notice", or.notice},
 | 
					                        { "@notice", or.notice == "null" ? null : or.notice},
 | 
				
			||||||
                        { "@description", or.description},
 | 
					                        { "@description", or.description == "null" ? null : or.description},
 | 
				
			||||||
                        { "@updated_by", myUser.userinfo_guid},
 | 
					                        { "@updated_by", myUser.userinfo_guid},
 | 
				
			||||||
                        { "@updated_at", DateTime.Now}
 | 
					                        { "@updated_at", DateTime.Now}
 | 
				
			||||||
                    };
 | 
					                    };
 | 
				
			||||||
 | 
				
			|||||||
@ -21,7 +21,8 @@
 | 
				
			|||||||
      //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
 | 
					      //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
 | 
				
			||||||
      //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
 | 
					      //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
 | 
				
			||||||
      //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
 | 
					      //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
 | 
				
			||||||
      "Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT
 | 
					      //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT
 | 
				
			||||||
 | 
					      "Database": "j9LOmjFh2/9PpuwnVB8ugqnKdBDJHx1AAT7aTWeh37E=", // ibms_mcut_online
 | 
				
			||||||
      "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
 | 
					      "Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
 | 
				
			||||||
      "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
 | 
					      "Password": "FVAPxztxpY4gJJKQ/se4bQ=="
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							@ -19,8 +19,8 @@ namespace tpDomeWinAPP
 | 
				
			|||||||
            Application.EnableVisualStyles();
 | 
					            Application.EnableVisualStyles();
 | 
				
			||||||
            Application.SetCompatibleTextRenderingDefault(false);
 | 
					            Application.SetCompatibleTextRenderingDefault(false);
 | 
				
			||||||
            //Application.Run(new fmCheckTagName());
 | 
					            //Application.Run(new fmCheckTagName());
 | 
				
			||||||
            Application.Run(new fmKeke());
 | 
					            //Application.Run(new fmKeke());
 | 
				
			||||||
            //Application.Run(new fmDecrypt());
 | 
					            Application.Run(new fmDecrypt());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										13
									
								
								z01_WinAPP/fmKeke.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										13
									
								
								z01_WinAPP/fmKeke.Designer.cs
									
									
									
										generated
									
									
									
								
							@ -32,6 +32,7 @@
 | 
				
			|||||||
            lbMsg = new System.Windows.Forms.Label();
 | 
					            lbMsg = new System.Windows.Forms.Label();
 | 
				
			||||||
            loadData = new System.Windows.Forms.Button();
 | 
					            loadData = new System.Windows.Forms.Button();
 | 
				
			||||||
            dataGridView1 = new System.Windows.Forms.DataGridView();
 | 
					            dataGridView1 = new System.Windows.Forms.DataGridView();
 | 
				
			||||||
 | 
					            button1 = new System.Windows.Forms.Button();
 | 
				
			||||||
            ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
 | 
					            ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
 | 
				
			||||||
            splitContainer1.Panel1.SuspendLayout();
 | 
					            splitContainer1.Panel1.SuspendLayout();
 | 
				
			||||||
            splitContainer1.Panel2.SuspendLayout();
 | 
					            splitContainer1.Panel2.SuspendLayout();
 | 
				
			||||||
@ -48,6 +49,7 @@
 | 
				
			|||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // splitContainer1.Panel1
 | 
					            // splitContainer1.Panel1
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
 | 
					            splitContainer1.Panel1.Controls.Add(button1);
 | 
				
			||||||
            splitContainer1.Panel1.Controls.Add(lbMsg);
 | 
					            splitContainer1.Panel1.Controls.Add(lbMsg);
 | 
				
			||||||
            splitContainer1.Panel1.Controls.Add(loadData);
 | 
					            splitContainer1.Panel1.Controls.Add(loadData);
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
@ -89,6 +91,16 @@
 | 
				
			|||||||
            dataGridView1.TabIndex = 0;
 | 
					            dataGridView1.TabIndex = 0;
 | 
				
			||||||
            dataGridView1.CellContentClick += dataGridView1_CellContentClick;
 | 
					            dataGridView1.CellContentClick += dataGridView1_CellContentClick;
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
 | 
					            // button1
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
 | 
					            button1.Location = new System.Drawing.Point(238, 32);
 | 
				
			||||||
 | 
					            button1.Name = "button1";
 | 
				
			||||||
 | 
					            button1.Size = new System.Drawing.Size(94, 29);
 | 
				
			||||||
 | 
					            button1.TabIndex = 1;
 | 
				
			||||||
 | 
					            button1.Text = "button1";
 | 
				
			||||||
 | 
					            button1.UseVisualStyleBackColor = true;
 | 
				
			||||||
 | 
					            button1.Click += button1_Click_1;
 | 
				
			||||||
 | 
					            // 
 | 
				
			||||||
            // fmKeke
 | 
					            // fmKeke
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
 | 
					            AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
 | 
				
			||||||
@ -113,5 +125,6 @@
 | 
				
			|||||||
        private System.Windows.Forms.Button loadData;
 | 
					        private System.Windows.Forms.Button loadData;
 | 
				
			||||||
        private System.Windows.Forms.Label lbMsg;
 | 
					        private System.Windows.Forms.Label lbMsg;
 | 
				
			||||||
        private System.Windows.Forms.DataGridView dataGridView1;
 | 
					        private System.Windows.Forms.DataGridView dataGridView1;
 | 
				
			||||||
 | 
					        private System.Windows.Forms.Button button1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -73,5 +73,13 @@ namespace z01_WinAPP
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void button1_Click_1(object sender, EventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string targetTable = "archive_electric_meter_day_202308";
 | 
				
			||||||
 | 
					            string yyyymm = targetTable.Split('_')[targetTable.Split('_').Length - 1]; //取出 archive_electric_meter_day_202308 的最後一段 202308
 | 
				
			||||||
 | 
					            string yyyy = yyyymm.Substring(0, 4);
 | 
				
			||||||
 | 
					            string mm = yyyymm.Remove(0, 4);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@
 | 
				
			|||||||
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
 | 
					    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
 | 
				
			||||||
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
 | 
					    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
 | 
				
			||||||
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
 | 
					    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
 | 
				
			||||||
    <data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
 | 
					    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
 | 
				
			||||||
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
 | 
					    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
 | 
				
			||||||
        <value>[base64 mime encoded serialized .NET Framework object]</value>
 | 
					        <value>[base64 mime encoded serialized .NET Framework object]</value>
 | 
				
			||||||
    </data>
 | 
					    </data>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user