4 Commits 5e4cebaeb5 ... 083d2bb1f3

Author SHA1 Message Date
  莫海杰 083d2bb1f3 合并后测试iOK 8 hours ago
  莫海杰 33d12fa793 合并 8 hours ago
  莫海杰 cbe24dbd95 1 8 hours ago
  莫海杰 89970b5d7e 1 8 hours ago
19 changed files with 1238 additions and 661 deletions
  1. 1 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/LcoalDB.tt
  2. 265 267
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SQLiteSchema.cs
  3. 1 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SQLiteSchema.tt
  4. 2 2
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/AlarmBoard.vue
  5. 2 2
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/DayOutput.vue
  6. 108 27
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/DeviceOeeTime.vue
  7. 174 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/ElectricityAir.vue
  8. 6 6
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/GunAirPressure.vue
  9. 5 5
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/GunCurrent.vue
  10. 2 2
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/HourOutput.vue
  11. 17 5
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/index.vue
  12. 52 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.Environment.cs
  13. 151 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.MachineTime.cs
  14. 171 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.Output.cs
  15. 159 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.Production.cs
  16. 31 341
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.cs
  17. 32 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/AppBYEnvironmentValuesModel.cs
  18. 59 4
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/CustomerService.cs
  19. 0 0
      skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj

+ 1 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/LcoalDB.tt

@@ -30,6 +30,7 @@
 #>
 using System;
 using System.Collections.Generic;
+using System.Linq.Expressions;
 using SCADA.CommonLib;
 using SCADA.CommonLib.Data;
 using SCADA.CommonLib.Data.DIL;

File diff suppressed because it is too large
+ 265 - 267
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SQLiteSchema.cs


+ 1 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.DAL/SQLiteSchema.tt

@@ -30,6 +30,7 @@
 #>
 using System;
 using System.Collections.Generic;
+using System.Linq.Expressions;
 using SCADA.CommonLib;
 using SCADA.CommonLib.Data;
 using SCADA.CommonLib.Data.DIL;

+ 2 - 2
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/AlarmBoard.vue

@@ -1,13 +1,13 @@
 <template>
   <div>
-    <dv-border-box-8 style="padding: 5px; ">
+    <dv-border-box-12 style="padding: 5px; ">
       <div style="width:1300px;height:409px;padding: 20px;">
         <dv-scroll-board
             style="width:880px;height:380px;overflow: hidden; "
             :config="config"
         />
       </div>
-    </dv-border-box-8>
+    </dv-border-box-12>
   </div>
 </template>
 

+ 2 - 2
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/DayOutput.vue

@@ -1,10 +1,10 @@
 <template>
   <div>
-    <dv-border-box-8 style="padding: 5px;">
+    <dv-border-box-12 style="padding: 5px;">
       <div style="height: 100%; width: 100%">
         <div ref="chartRef" style="width:900px; height:250px;"></div>
       </div>
-    </dv-border-box-8>
+    </dv-border-box-12>
   </div>
 </template>
 

+ 108 - 27
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/DeviceOeeTime.vue

@@ -1,48 +1,118 @@
 <template>
   <div style="width: 100%;">
-    <dv-border-box-8 style="padding: 20px; width: 100%;height: 300px;">
-      <div style="height: 200px; width: 25%">
-        <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />本月稼动率</div>
-        <dv-percent-pond :config="configMonthOee" style="width:200px;height:78px;margin-bottom: 20px"/>
-        <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />今日稼动率</div>
-        <dv-percent-pond :config="configDayOee" style="width:200px;height:78px;"/>
-      </div>
-      <div style="width: 73%; display: flex; justify-content: space-between; flex-wrap: wrap">
+    <dv-border-box-12 style="padding: 20px; width: 100%;height: 310px">
+<!--      <div style="height: 200px; width: 25%">-->
+<!--        <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />本月稼动率</div>-->
+<!--        <dv-percent-pond :config="configMonthOee" style="width:200px;height:78px;margin-bottom: 20px"/>-->
+<!--        <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />今日稼动率</div>-->
+<!--        <dv-percent-pond :config="configDayOee" style="width:200px;height:78px;"/>-->
+<!--      </div>-->
+      <div style="width: 100%;">
+        <div style="width: 100%; display: flex; justify-content: space-between">
 
-          <div>
-            <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />总时长</div>
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />总时长</div>
             <div style="position: relative;">
               <img class="item-bg" src="../../../../static/img/total.png">
-              <span style="position: absolute; left: 135px;top: 34px; font-size: 30px"> {{totalTime}} </span>
+              <span style="position: absolute; left: 85px;top: 17px; font-size: 28px"> {{totalTime}} </span>
             </div>
           </div>
 
-          <div>
-            <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />今日运行</div>
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />运行时间</div>
             <div style="position: relative;">
               <img class="item-bg" src="../../../../static/img/run.png">
-              <span style="position: absolute; left: 135px;top: 34px; font-size: 30px"> {{runTime}} </span>
+              <span style="position: absolute; left: 85px;top: 17px; font-size: 28px"> {{runTime}} </span>
+            </div>
+          </div>
+
+          <div style="width: 25%">
+          <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />待机时间</div>
+            <div style="position: relative;">
+              <img class="item-bg" src="../../../../static/img/standby.png">
+              <span style="position: absolute; left: 85px;top: 17px; font-size: 28px"> {{standbyTime}} </span>
             </div>
           </div>
 
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />报警时间</div>
+            <div style="position: relative;">
+              <img class="item-bg" src="../../../../static/img/alarm.png">
+              <span style="position: absolute; left: 85px;top: 17px; font-size: 28px"> {{alarmTime}} </span>
+            </div>
+          </div>
+        </div>
 
-        <div>
-          <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />今日待机</div>
-          <div style="position: relative;">
-            <img class="item-bg" src="../../../../static/img/standby.png">
-            <span style="position: absolute; left: 135px;top: 34px; font-size: 30px"> {{standbyTime}} </span>
+        <div style="width: 100%; display: flex; justify-content: space-between; margin-bottom: 35px">
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />温度</div>
+            <dv-border-box-9 style="position: relative;">
+              <i style="color: red; font-size: 40px; position: absolute; left: 13px; top: 10px" class="el-icon-sunny"  />
+              <div style="display: flex; justify-content: center; align-items: center; margin-left: 60px">
+                <span style="font-size: 28px"> {{temp}}°C</span>
+              </div>
+            </dv-border-box-9>
+          </div>
+          <div style="width: 25%">
+             <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />湿度</div>
+            <dv-border-box-9 style="position: relative;">
+              <i style="color: red; font-size: 40px; position: absolute; left: 13px; top: 10px" class="el-icon-heavy-rain"  />
+              <div style="display: flex; justify-content: center; align-items: center; margin-left: 60px">
+                <span style="font-size: 28px"> {{humidity}}%rh </span>
+              </div>
+            </dv-border-box-9>
+          </div>
+          <div style="width: 25%">
+             <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />压缩气空气流量</div>
+            <dv-border-box-9 style="position: relative;">
+              <i style="color: red; font-size: 40px; position: absolute; left: 13px; top: 10px" class="el-icon-finished"  />
+              <div style="display: flex; justify-content: center; align-items: center; margin-left: 60px">
+                <span style="font-size: 28px"> {{compressedAirFlowRate}}m³/min</span>
+              </div>
+            </dv-border-box-9>
+          </div>
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />露点值</div>
+            <dv-border-box-9 style="position: relative;">
+              <i style="color: red; font-size: 40px; position: absolute; left: 13px; top: 10px" class="el-icon-sunset"  />
+              <div style="display: flex; justify-content: center; align-items: center; margin-left: 60px">
+                <span style="font-size: 28px"> {{dewPoint}}Td </span>
+              </div>
+            </dv-border-box-9>
           </div>
         </div>
 
-        <div>
-          <div style="margin-bottom: 5px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />今日报警</div>
-          <div style="position: relative;">
-            <img class="item-bg" src="../../../../static/img/alarm.png">
-            <span style="position: absolute; left: 135px;top: 34px; font-size: 30px"> {{alarmTime}} </span>
+        <div style="width: 100%; display: flex; justify-content: space-between;">
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />压缩空气累计量</div>
+            <dv-border-box-13 style="position: relative; height: 60px; border-color: #5cd9e8">
+              <i style="color: red; font-size: 40px; position: absolute; left: 13px; top: 10px" class="el-icon-heavy-rain"  />
+              <div style="display: flex; justify-content: center; align-items: center; margin-left: 60px">
+                <span style="font-size: 28px"> {{compressedAirTotal}}m³ </span>
+              </div>
+            </dv-border-box-13>
+          </div>
+          <div style="width: 25%">
+            <div style="margin-bottom: 1px"><img src="../../../../static/img/Title_Icon.png" style="width: 15px; margin-right: 8px; height: 15px;" />累计用电量</div>
+            <dv-border-box-13 style="position: relative; height: 60px;">
+              <i style="color: red; font-size: 40px; position: absolute; left: 13px; top: 10px" class="el-icon-heavy-rain"  />
+              <div style="display: flex; justify-content: center; align-items: center; margin-left: 60px">
+                <span style="font-size: 28px"> {{electricityConsumption}}KW </span>
+              </div>
+            </dv-border-box-13>
+          </div>
+          <div style="width: 25%">
+            <div><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />本月稼动率</div>
+            <dv-percent-pond :config="configMonthOee" style="width:98%;height:58px"/>
+          </div>
+          <div style="width: 25%">
+            <div><img src="../../../../static/img/Title_Icon.png" style="width: 15px; height: 15px;" />今日稼动率</div>
+            <dv-percent-pond :config="configDayOee" style="width:98%;height:58px"/>
           </div>
         </div>
       </div>
-    </dv-border-box-8>
+
+    </dv-border-box-12>
   </div>
 </template>
 
@@ -62,6 +132,12 @@ export default {
       runTime: '00:00:00',
       standbyTime: '00:00:00',
       alarmTime: '00:00:00',
+      temp: 1, // 温度
+      humidity: 2, // 湿度
+      dewPoint: 1, // 露点值
+      compressedAirFlowRate: 1, // 压缩空气流量
+      compressedAirTotal: 1, // 压缩空气累积量
+      electricityConsumption: 1
     }
   },
   methods: {
@@ -76,6 +152,12 @@ export default {
       this.alarmTime = res.StateTime.AlarmTime
       this.runTime = res.StateTime.RunTime
       this.standbyTime = res.StateTime.StandbyTime
+      this.temp=res.Temp// 温度
+      this.humidity=res.Humidity // 湿度
+      this.dewPoint=res.DewPoint// 露点值
+      this.compressedAirFlowRate=res.CompressedAirFlowRate // 压缩空气流量
+      this.compressedAirTotal=res.CompressedAirTotal // 压缩空气累积量
+      this.electricityConsumption=res.ElectricityConsumption
     }
   },
   async created() {
@@ -95,7 +177,6 @@ export default {
   justify-content: space-between;
 }
 .item-bg{
-  height: 80px;
-  margin-top: 4px;
+  height: 54px;
 }
 </style>

+ 174 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/ElectricityAir.vue

@@ -0,0 +1,174 @@
+<template>
+  <div>
+    <dv-border-box-12 style="padding: 5px;">
+      <div ref="chartRef" style="width:950px;height:410px;"></div>
+    </dv-border-box-12>
+  </div>
+</template>
+
+<script>
+import * as echarts from "echarts";
+export default {
+  data() {
+    return {
+
+    }
+  },
+  props:{
+    compressedAir:{
+      type: Array,
+      default: ()=>[]
+    },
+    electricityConsumption:{
+      type: Array,
+      default: ()=>[]
+    },
+    dateTime:{
+      type:Array,
+      default:()=>[]
+    }
+  },
+  watch: {
+    // 侦听数值变化刷新echart
+    compressedAir: {
+      deep:true,
+      handler(newVal, oldVal){
+        this.myEcharts();
+      }
+    },
+    electricityConsumption: {
+      deep:true,
+      handler(newVal, oldVal){
+        this.myEcharts();
+      }
+    },
+    dateTime: {
+      deep:true,
+      handler(newVal, oldVal){
+        this.myEcharts();
+      }
+    },
+  },
+  methods: {
+    myEcharts() {
+      const chartDom = this.$refs.chartRef
+      const myChart = this.$echarts.init(chartDom);
+      let option;
+      option = {
+        // title: {
+        //   text: '增量设备贯通情况-单位',
+        //   x: 'center',
+        //   y: 0,
+        //   textStyle:{
+        //     color:'#fff',
+        //     fontSize:16,
+        //     fontWeight:'normal',
+        //   },
+        //
+        // },
+        // backgroundColor: '#191E40',
+        tooltip: {
+          trigger: 'axis',
+        },
+        legend: {
+          data: ['压缩空气', '用电量'],
+          textStyle: {
+            fontSize: 14,
+            color: "#fff",
+          },
+          left: "1%",
+          top: "3%",
+        },
+        grid: [{
+          top:65,
+          bottom: 30,
+          right: 75,
+          left: 45,
+        }],
+        xAxis: {
+          data: this.dateTime,
+          axisLine: {
+            lineStyle: {
+              color: '#fff'
+            }
+          },
+          axisTick:{
+            show:false,
+          },
+        },
+        yAxis: [{
+
+          splitLine: {show: false},
+          axisLine: {
+            lineStyle: {
+              color: '#fff',
+            }
+          },
+          name:' m³',
+          axisLabel:{
+            formatter:'{value}',
+          }
+        },
+          {
+
+            splitLine: {show: false},
+            axisLine: {
+              lineStyle: {
+                color: '#fff',
+              }
+            },
+            name: ' KW',
+            axisLabel:{
+              formatter:'{value}',
+            }
+          }],
+
+        series: [{
+          name: '压缩空气',
+          type: 'line',
+          smooth: true,
+          showAllSymbol: true,
+          symbol: 'emptyCircle',
+          symbolSize: 8,
+          yAxisIndex: 1,
+          itemStyle: {
+            normal: {
+              color:'#F02FC2'},
+          },
+          data: this.compressedAir
+        },
+
+          {
+            name: '用电量',
+            type: 'bar',
+            barWidth: 10,
+            itemStyle: {
+              normal: {
+                barBorderRadius: 5,
+                color: new echarts.graphic.LinearGradient(
+                    0, 0, 0, 1,
+                    [
+                      {offset: 0, color: 'rgba(149,111,212,0.68)'},
+                      {offset: 1, color: 'rgba(62,172,229,0.7)'}
+                    ]
+                )
+              }
+            },
+            // itemStyle: {
+            //   normal: {
+            //     color:'rgba(56,106,211,0.85)'},
+            // },
+            data: this.electricityConsumption
+          },
+        ]
+      };
+      //使用刚指定的配置项和数据显示图表。
+      myChart.setOption(option,true);
+    }
+  },
+  mounted() {
+    this.myEcharts();
+  }
+}
+</script>
+

+ 6 - 6
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/GunAirPressure.vue

@@ -1,8 +1,8 @@
 <template>
   <div>
-    <dv-border-box-8 style="padding: 5px;">
-      <div ref="chartRef" style="width:950px;height:310px;"></div>
-    </dv-border-box-8>
+    <dv-border-box-12 style="padding: 5px;">
+      <div ref="chartRef" style="width:950px;height:305px;"></div>
+    </dv-border-box-12>
   </div>
 </template>
 
@@ -35,7 +35,7 @@ export default {
       type: Array,
       default: ()=>[]
     },
-    dataTime:{
+    dateTime:{
       type:Array,
       default:()=>[]
     }
@@ -132,7 +132,7 @@ export default {
         },
         xAxis: {
           type: "category",
-          data: this.dataTime,
+          data: this.dateTime,
           axisLabel: {
             color: "#ffffff",
             // interval: 0,
@@ -154,7 +154,7 @@ export default {
         },
         yAxis: {
           type: "value",
-          name: "Kpa",
+          name: "MPA",
           nameTextStyle: {
             color: "#ffffff",
             fontSize: 12,

+ 5 - 5
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/GunCurrent.vue

@@ -1,8 +1,8 @@
 <template>
   <div>
-    <dv-border-box-8 style="padding: 5px;">
-      <div ref="chartRef" style="width:950px;height:310px;"></div>
-    </dv-border-box-8>
+    <dv-border-box-12 style="padding: 5px;">
+      <div ref="chartRef" style="width:950px;height:305px;"></div>
+    </dv-border-box-12>
   </div>
 </template>
 
@@ -35,7 +35,7 @@ export default {
       type: Array,
       default: ()=>[]
     },
-    dataTime:{
+    dateTime:{
       type:Array,
       default:()=>[]
     }
@@ -212,7 +212,7 @@ export default {
         },
         xAxis: {
           type: "category",
-          data: this.dataTime,
+          data: this.dateTime,
           axisLabel: {
             color: "#ffffff",
             // interval: 0,

+ 2 - 2
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/components/HourOutput.vue

@@ -1,10 +1,10 @@
 <template>
   <div>
-    <dv-border-box-8 style="padding: 5px;">
+    <dv-border-box-12 style="padding: 5px;">
       <div style="height: 100%; width: 100%">
         <div ref="chartRef" style="width:900px; height:250px;"></div>
       </div>
-    </dv-border-box-8>
+    </dv-border-box-12>
   </div>
 </template>
 

+ 17 - 5
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ.EicpApp/src/views/data-chart/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div id="data-chart" ref="appRef">
     <div class="background">
-      <title-head lineName="信息化看板" />
+      <title-head lineName="百亚智能信息化看板" />
       <dv-loading v-if="loading">Loading...</dv-loading>
       <div v-else>
         <div class="chart-main-container">
@@ -18,7 +18,13 @@
                 style="margin-bottom: 21px;"
                 v-if="dayOutput.values.length !== 0 && dayOutput.dateTime.length !== 0"
             />
-            <alarm-board />
+            <electricity-air
+                :electricity-consumption="environment.electricityConsumption"
+                :compressed-air="environment.compressedAir"
+                :date-time="environment.dateTime"
+                v-if="environment.electricityConsumption.length !== 0 && environment.dateTime.length !== 0"
+            />
+<!--            <alarm-board />-->
           </div>
 
           <div style="width: 49.5%; margin-left: 1%;">
@@ -33,7 +39,7 @@
                 :left-data="environment.leftCurrent"
                 :center-data="environment.centerCurrent"
                 :right-data="environment.rightCurrent"
-                :data-time="environment.dateTime"
+                :date-time="environment.dateTime"
                 style="margin-bottom: 20px;"
                 v-if="hourOutput.values.length !== 0 && hourOutput.dateTime.length !== 0"
             />
@@ -41,7 +47,7 @@
               :left-data="environment.leftAirPressure"
               :center-data="environment.centerAirPressure"
               :right-data="environment.rightAirPressure"
-              :data-time="environment.dateTime"
+              :date-time="environment.dateTime"
               v-if="environment.dateTime.length !== 0 && environment.dateTime.length !== 0"
             />
           </div>
@@ -60,6 +66,7 @@ import GunCurrent from "@/views/data-chart/components/GunCurrent.vue";
 import DeviceOeeTime from "@/views/data-chart/components/DeviceOeeTime.vue";
 import AlarmBoard from "@/views/data-chart/components/AlarmBoard.vue";
 import DayOutput from "@/views/data-chart/components/DayOutput.vue";
+import ElectricityAir from "@/views/data-chart/components/ElectricityAir.vue";
 import {getEnvironmentValuesAPI, getOutputAPI} from '@/api/chart.js'
 // import dayjs from "dayjs";
 export default {
@@ -70,7 +77,7 @@ export default {
     GunAirPressure,
     GunCurrent,
     DeviceOeeTime,
-    AlarmBoard,
+    ElectricityAir,
     DayOutput
   },
   data() {
@@ -91,6 +98,8 @@ export default {
         leftCurrent: [],
         centerCurrent: [],
         rightCurrent: [],
+        electricityConsumption: [],
+        compressedAir: [],
         dateTime: []
       },
       dayOee: 0,
@@ -124,6 +133,9 @@ export default {
       this.environment.centerCurrent = res.Center.Current
       this.environment.rightCurrent = res.Right.Current
       this.environment.dateTime = res.Time
+      this.environment.electricityConsumption = res.ElectricityConsumption
+      this.environment.compressedAir = res.CompressedAir
+
       // for (let i = 0; i < 89; i++) {
       //   this.environment.leftAirPressure[i] = Math.random()*(100-10)+10
       //   this.environment.centerAirPressure[i] = Math.random()*(100-10)+10

+ 52 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.Environment.cs

@@ -0,0 +1,52 @@
+using SCADA.CommonLib.Data.DIL;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DBNames;
+using SCADA;
+
+namespace SCADA_DAQ.Customer.Machines
+{
+    public partial class SampleMachine
+    {
+
+        public void InsertEnvironmentValues(SCADA.CommonLib.DateTimeChangedArgs e)
+        {
+            if (GetListenReg("左枪电流") != null)
+            {
+                
+                var leftCurrent = GetListenReg("左枪电流").Float;
+                var centerCurrent = GetListenReg("中枪电流").Float;
+                var rightCurrent = GetListenReg("右枪电流").Float;
+                var leftAirPressure = GetListenReg("左枪气压").Float;
+                var centerAirPressure = GetListenReg("中枪气压").Float;
+                var rightAirPressure = GetListenReg("右枪气压").Float;
+                //如果秒数发生变化
+                if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged)
+                {
+                    var nextRegElectricityConsumptionTotal = GetListenReg("累计用电量").Value;
+                    var electricityConsumption = nextRegElectricityConsumptionTotal - PreRegElectricityConsumptionTotalChart;
+                    PreRegElectricityConsumptionTotalChart = nextRegElectricityConsumptionTotal;
+
+                    var nextRegCompressedAirTotal = GetListenReg("压缩空气累计量").Value;
+                    var compressedAir = nextRegCompressedAirTotal - PreRegCompressedAirTotalChart;
+                    PreRegCompressedAirTotalChart = nextRegCompressedAirTotal;
+                    // 各字段插入数据 初始化
+                    Env.DAL.App_BY_EnvironmentValues.Insert(
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.DeviceID_Str, taiDaAS300),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CenterCurrent_Dec, centerCurrent),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.LeftCurrent_Dec, leftCurrent),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.RightCurrent_Dec, rightCurrent),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CenterAirPressure_Dec, centerAirPressure),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.LeftAirPressure_Dec, leftAirPressure),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.RightAirPressure_Dec, rightAirPressure),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.ElectricityConsumption_Int, electricityConsumption),
+                        new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CompressedAir_Int, compressedAir)
+                    );
+                }
+            }
+        }
+    }
+}

+ 151 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.MachineTime.cs

@@ -0,0 +1,151 @@
+using SCADA.CommonLib.Data.DIL;
+using SCADA_DAQ.Customer.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DBNames;
+
+namespace SCADA_DAQ.Customer.Machines
+{
+    public partial class SampleMachine
+    {
+        public void InsertMachineTime(SCADA.CommonLib.DateTimeChangedArgs e)
+        {
+            if (GetListenReg("总通电时间时")?.ScaleValue != null)
+            {
+                // 做判空
+                // 时间格式化
+                string ToHMS(double H, double M, double S)
+                {
+                    string h, m, s;
+                    h = H < 10 ? $"0{H}" : $"{H}";
+                    m = M < 10 ? $"0{M}" : $"{M}";
+                    s = S < 10 ? $"0{S}" : $"{S}";
+                    return $"{h}:{m}:{s}";
+                }
+                var totalTimeH = GetListenReg("总运行时间时").ScaleValue.Value;
+                var totalTimeM = GetListenReg("总运行时间分").ScaleValue.Value;
+                var totalTimeS = GetListenReg("总运行时间秒").ScaleValue.Value;
+                var totalTimeHMS = ToHMS(totalTimeH, totalTimeM, totalTimeS);
+                var runTimeH = GetListenReg("生产运行时间时").ScaleValue.Value;
+                var runTimeM = GetListenReg("生产运行时间分").ScaleValue.Value;
+                var runTimeS = 0;
+                var runTimeHMS = ToHMS(runTimeH, runTimeM, runTimeS);
+                var standbyTimeH = GetListenReg("待机时间时").ScaleValue.Value;
+                var standbyTimeM = GetListenReg("待机时间分").ScaleValue.Value;
+                var standbyTimeS = 0;
+                var standbyTimeHMS = ToHMS(standbyTimeH, standbyTimeM, standbyTimeS);
+                var alarmTimeH = GetListenReg("报警停机时间时").ScaleValue.Value;
+                var alarmTimeM = GetListenReg("报警停机时间分").ScaleValue.Value;
+                var alarmTimeS = 0;
+                var alarmTimeHMS = ToHMS(alarmTimeH, alarmTimeM, alarmTimeS);
+
+                //如果表一行数据也没有
+                if (Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>().Count == 0)
+                {
+                    // 各字段插入数据 初始化
+                    Env.DAL.App_BY_Machine_Time.Insert(
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.DeviceID_Str, taiDaAS300),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
+                    );
+
+                }
+
+                //如果表只有一行数据 对该数据更新
+                if (Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>().Count == 1)
+                {
+                    //每10秒更新一次
+                    if (e.TimeFlag.Second % 10 == 0)
+                    {
+                        // 获取表里的最新一行数据而且是台达AS300型号(此处未写)对其更新
+                        Env.DAL.App_BY_Machine_Time.Update("ID=(select max(id) from App_BY_Machine_Time)",
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
+                        );
+                    }
+                }
+
+                var appBYMachineTimeModelSql = Env.DAL.GetData<AppBYMachineTimeModel>();
+                var lastCreateTime = appBYMachineTimeModelSql.Last().CreateTime;
+                var nowTime = DateTime.Now;
+                // 如果现在(今天)日期不等于最新一行CreateTime日期则说明今天没有插入新数据
+                if (lastCreateTime.Date != nowTime.Date)
+                {
+                    // 插入今天新数据 
+                    Env.DAL.App_BY_Machine_Time.Insert(
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.DeviceID_Str, taiDaAS300),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
+                        new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
+                    );
+                }
+
+                // 每10秒且表行数大于1 对最后一行更新
+                if (appBYMachineTimeModelSql.Count >= 2)
+                {
+                    // 获取表里倒序第二行寄存器数据
+                    var oldTotalTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegTotalTimeHMS;
+                    var oldRunTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegRunTimeHMS;
+                    var oldStandbyTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegStandbyTimeHMS;
+                    var oldAlarmTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegAlarmTimeHMS;
+
+                    /// <summary>
+                    /// <param name="timeH">累计寄存器时</param>
+                    /// <param name="timeM">累计寄存器分</param>
+                    /// <param name="timeS">累计寄存器秒</param>
+                    /// <param name="oldTimeHMS">上一次累计寄存器时分秒字符串</param>
+                    /// <returns>返回当天的寄存器时分秒</returns>
+                    /// </summary>
+                    string GetNewTimeHMS(double timeH, double timeM, double timeS, string oldTimeHMS)
+                    {
+                        // 新数据 = 新寄存器数 - 旧寄存器数
+                        var oldTimeHMSArray = oldTimeHMS.Split(new char[] { ':', ':' });
+                        double oldTimeSumS = Convert.ToDouble(oldTimeHMSArray[0]) * 3600 + Convert.ToDouble(oldTimeHMSArray[1]) * 60 + Convert.ToDouble(oldTimeHMSArray[2]);
+                        double timeSumS = timeH * 3600 + timeM * 60 + timeS;
+                        var newTimeSumS = timeSumS - oldTimeSumS;
+                        var newTimeHMS = new TimeSpan(0, 0, Convert.ToInt32(newTimeSumS)).ToString(@"hh\:mm\:ss");
+                        return newTimeHMS;
+                    }
+                    var newTotalTimeHMS = GetNewTimeHMS(totalTimeH, totalTimeM, totalTimeS, oldTotalTimeHMS);
+                    var newRunTimeHMS = GetNewTimeHMS(runTimeH, runTimeM, runTimeS, oldRunTimeHMS);
+                    var newStandbyTimeHMS = GetNewTimeHMS(standbyTimeH, standbyTimeM, standbyTimeS, oldStandbyTimeHMS);
+                    var newAlarmTimeHMS = GetNewTimeHMS(alarmTimeH, alarmTimeM, alarmTimeS, oldAlarmTimeHMS);
+                    if (e.TimeFlag.Second % 10 == 0)
+                    {
+                        // 获取表里的最新一行数据对其更新
+                        Env.DAL.App_BY_Machine_Time.Update("ID=(select max(id) from App_BY_Machine_Time)",
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, newTotalTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, newRunTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, newStandbyTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, newAlarmTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
+                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
+                        );
+                    }
+                }
+            }
+        }
+    }
+}

+ 171 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.Output.cs

@@ -0,0 +1,171 @@
+using SCADA.CommonLib.Data.DIL;
+using SCADA_DAQ.Customer.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using DBNames;
+
+namespace SCADA_DAQ.Customer.Machines
+{
+    public partial class SampleMachine
+    {
+        public void InsertOutPut(SCADA.CommonLib.DateTimeChangedArgs e)
+        {
+            if (GetListenReg("产量统计") != null)
+            {
+                var output = GetListenReg("产量统计").Value;
+                var nowTime = DateTime.Now;
+
+                // 小时产量
+                var hourOutputRows = Env.DAL.App_BY_HourOutput.GetData<AppBYHourOutputModel>();
+                if (hourOutputRows.Count == 0)
+                {
+                    Env.DAL.App_BY_HourOutput.Insert(
+                      new UpdateItem(T_Col_Name.App_BY_HourOutput.DeviceID_Str, taiDaAS300),
+                      new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
+                      new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
+                    );
+                }
+                if (hourOutputRows.Count == 1)
+                {
+                    //每10秒更新一次
+                    if (e.TimeFlag.Second % 10 == 0)
+                    {
+                        // 获取表里的最新一行数据而且是台达AS300型号(此处未写)对其更新
+                        Env.DAL.App_BY_HourOutput.Update("ID=(select max(id) from App_BY_HourOutput)",
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+
+                if (hourOutputRows.Count >= 1)
+                {
+                    // 如果现在(这个小时)不等于最新一行CreateTime小时则说明这个小时没有插入新数据
+                    if (hourOutputRows.Last().CreateTime.ToString("yyyy-MM-dd HH") != nowTime.ToString("yyyy-MM-dd HH"))
+                    {
+                        // 插入这个小时新数据 
+                        Env.DAL.App_BY_HourOutput.Insert(
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.DeviceID_Str, taiDaAS300),
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+                if (hourOutputRows.Count >= 2)
+                {
+                    var oldHourOutput = hourOutputRows[hourOutputRows.Count - 2].RegOutput;
+                    var newHourOutput = output - oldHourOutput;
+                    if (e.TimeFlag.Second % 10 == 0)
+                    {
+                        // 获取表里的最新一行数据对其更新
+                        Env.DAL.App_BY_HourOutput.Update("ID=(select max(id) from App_BY_HourOutput)",
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, newHourOutput),
+                            new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+
+                // 每天产量
+                var dayOutputRows = Env.DAL.App_BY_DayOutput.GetData<AppBYDayOutputModel>();
+                if (dayOutputRows.Count == 0)
+                {
+                    Env.DAL.App_BY_DayOutput.Insert(
+                        new UpdateItem(T_Col_Name.App_BY_DayOutput.DeviceID_Str, taiDaAS300),
+                        new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
+                        new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
+                    );
+                }
+                if (dayOutputRows.Count == 1)
+                {
+                    // 每分钟更新一次
+                    if (e.TimeFlag.Minute % 1 == 0)
+                    {
+                        Env.DAL.App_BY_DayOutput.Update("ID=(select max(id) from App_BY_DayOutput)",
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+                // 如果现在(今天)日期不等于最新一行CreateTime日期则说明今天没有插入新数据
+                if (dayOutputRows.Count >= 1)
+                {
+                    if (dayOutputRows.Last().CreateTime.Date != nowTime.Date)
+                    {
+                        // 插入今天新数据 
+                        Env.DAL.App_BY_DayOutput.Insert(
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.DeviceID_Str, taiDaAS300),
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+                if (dayOutputRows.Count >= 2)
+                {
+                    var oldDayOutput = dayOutputRows[dayOutputRows.Count - 2].RegOutput;
+                    var newDayOutput = output - oldDayOutput;
+                    if (e.TimeFlag.Second % 10 == 0)
+                    {
+                        // 获取表里的最新一行数据对其更新
+                        Env.DAL.App_BY_DayOutput.Update("ID=(select max(id) from App_BY_DayOutput)",
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, newDayOutput),
+                            new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+
+                // 每月产量
+                var monthOutputRows = Env.DAL.App_BY_MonthOutput.GetData<AppBYMonthOutputModel>();
+                if (monthOutputRows.Count == 0)
+                {
+                    Env.DAL.App_BY_MonthOutput.Insert(
+                        new UpdateItem(T_Col_Name.App_BY_MonthOutput.DeviceID_Str, taiDaAS300),
+                        new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
+                        new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
+                    );
+                }
+                if (monthOutputRows.Count == 1)
+                {
+                    // 每2分钟更新一次
+                    if (e.TimeFlag.Minute % 2 == 0)
+                    {
+                        Env.DAL.App_BY_MonthOutput.Update("ID=(select max(id) from App_BY_MonthOutput)",
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+
+                // 如果今月没插入新数据 则插入新数据
+                if (monthOutputRows.Count >= 1)
+                {
+                    if (monthOutputRows.Last().CreateTime.ToString("yyyy-MM") != nowTime.ToString("yyyy-MM"))
+                    {
+                        // 插入今月新数据 
+                        Env.DAL.App_BY_MonthOutput.Insert(
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.DeviceID_Str, taiDaAS300),
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+                if (monthOutputRows.Count >= 2)
+                {
+                    var oldMonthOutput = monthOutputRows[monthOutputRows.Count - 2].RegOutput;
+                    var newMonthOutput = output - oldMonthOutput;
+                    if (e.TimeFlag.Second % 10 == 0)
+                    {
+                        // 获取表里的最新一行数据对其更新
+                        Env.DAL.App_BY_MonthOutput.Update("ID=(select max(id) from App_BY_MonthOutput)",
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, newMonthOutput),
+                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
+                        );
+                    }
+                }
+
+            }
+        }
+    }
+}

+ 159 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.Production.cs

@@ -0,0 +1,159 @@
+using SCADA.Drive;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static NPOI.HSSF.Util.HSSFColor;
+using DBNames;
+using DBModel;
+
+namespace SCADA_DAQ.Customer.Machines
+{
+    public partial class SampleMachine
+    {
+        public void InsertProduction(RegInfo reg, RegValueChangedEventArgs e)
+        {
+            if (reg.Comment.Variable == "生产完成")
+            {
+                if (e.NewValue == 1)
+                {
+                    var nextRegElectricityConsumptionTotal = GetListenReg("累计用电量").Value;
+                    var electricityConsumption = nextRegElectricityConsumptionTotal - PreRegElectricityConsumptionTotalProduction;
+                    PreRegElectricityConsumptionTotalProduction = nextRegElectricityConsumptionTotal;
+
+                    var nextRegCompressedAirTotal = GetListenReg("压缩空气累计量").Value;
+                    var compressedAir = nextRegCompressedAirTotal - PreRegCompressedAirTotalProduction;
+                    PreRegCompressedAirTotalProduction = nextRegCompressedAirTotal;
+
+                    var nextRegOutputTotal = GetListenReg("压缩空气累计量").Value;
+                    var output = nextRegOutputTotal - PreRegOutputTotalProduction;
+                    PreRegOutputTotalProduction = nextRegOutputTotal;
+
+                    var appByProduction = new App_BY_Production()
+                    {
+                        LeftWireFeedRate_Int = GetListenReg("左枪丝速").Value ?? 0,
+                        CenterWireFeedRate_Int = GetListenReg("中枪丝速").Value ?? 0,
+                        RightWireFeedRate_Int = GetListenReg("右枪丝速").Value ?? 0,
+                        LeftDistance_Int = GetListenReg("左枪枪距").Value ?? 0,
+                        CenterDistance_Int = GetListenReg("中枪枪距").Value ?? 0,
+                        RightDistance_Int = GetListenReg("右枪枪距").Value ?? 0,
+                        LeftShotNum_Int = GetListenReg("左枪次数").Value ?? 0,
+                        CenterShotNum_Int = GetListenReg("中枪次数").Value ?? 0,
+                        RightShotNum_Int = GetListenReg("右枪次数").Value ?? 0,
+                        LeftHighLimitCurrent_Dec = (decimal)GetListenReg("左枪电流高报警值").Float,
+                        CenterHighLimitCurrent_Dec = (decimal)GetListenReg("中枪电流高报警值").Float,
+                        RightHighLimitCurrent_Dec = (decimal)GetListenReg("右枪电流高报警值").Float,
+                        LeftLowLimitCurrent_Dec = (decimal)GetListenReg("左枪电流低报警值").Float,
+                        CenterLowLimitCurrent_Dec = (decimal)GetListenReg("中枪电流低报警值").Float,
+                        RightLowLimitCurrent_Dec = (decimal)GetListenReg("右枪电流低报警值").Float,
+                        MetalSprayingInitialVelocity_Dec = (decimal)GetListenReg("喷金起始速度").Float,
+                        Temp_Int = GetListenReg("温度").Value ?? 0,
+                        Humidity_Int = GetListenReg("湿度").Value ?? 0,
+                        DewPoint_Int = GetListenReg("露点值").Value ?? 0,
+                        CompressedAirFlowRate_Dec = (decimal)GetListenReg("压缩气空气流量").Float,
+                        ElectricityConsumption_Int = electricityConsumption ?? 0,
+                        CompressedAir_Int = compressedAir ?? 0,
+                        Output_Dec = output ?? 0,
+                    };
+                    Env.DAL.Insert(appByProduction, nameof(App_BY_Production), t => new
+                    {
+                        t.LeftWireFeedRate_Int,
+                        t.CenterWireFeedRate_Int,
+                        t.RightWireFeedRate_Int,
+                        t.LeftDistance_Int,
+                        t.CenterDistance_Int,
+                        t.RightDistance_Int,
+                        t.LeftShotNum_Int,
+                        t.CenterShotNum_Int,
+                        t.RightShotNum_Int,
+                        t.LeftHighLimitCurrent_Dec,
+                        t.CenterHighLimitCurrent_Dec,
+                        t.RightHighLimitCurrent_Dec,
+                        t.LeftLowLimitCurrent_Dec,
+                        t.CenterLowLimitCurrent_Dec,
+                        t.RightLowLimitCurrent_Dec,
+                        t.MetalSprayingInitialVelocity_Dec,
+                        t.Temp_Int,
+                        t.Humidity_Int,
+                        t.DewPoint_Int,
+                        t.CompressedAirFlowRate_Dec,
+                        t.ElectricityConsumption_Int,
+                        t.CompressedAir_Int,
+                        t.Output_Dec,
+                    });
+                }
+
+            }
+        }
+
+        public void TestInsertProduction()
+        {
+                var nextRegElectricityConsumptionTotal = GetListenReg("累计用电量").Value;
+                var electricityConsumption = nextRegElectricityConsumptionTotal - PreRegElectricityConsumptionTotalProduction;
+                PreRegElectricityConsumptionTotalProduction = nextRegElectricityConsumptionTotal;
+
+                var nextRegCompressedAirTotal = GetListenReg("压缩空气累计量").Value;
+                var compressedAir = nextRegCompressedAirTotal - PreRegCompressedAirTotalProduction;
+                PreRegCompressedAirTotalProduction = nextRegCompressedAirTotal;
+
+                var nextRegOutputTotal = GetListenReg("压缩空气累计量").Value;
+                var output = nextRegOutputTotal - PreRegOutputTotalProduction;
+                PreRegOutputTotalProduction = nextRegOutputTotal;
+
+                var appByProduction = new App_BY_Production()
+                {
+                    LeftWireFeedRate_Int = GetListenReg("左枪丝速").Value ?? 0,
+                    CenterWireFeedRate_Int = GetListenReg("中枪丝速").Value ?? 0,
+                    RightWireFeedRate_Int = GetListenReg("右枪丝速").Value ?? 0,
+                    LeftDistance_Int = GetListenReg("左枪枪距").Value ?? 0,
+                    CenterDistance_Int = GetListenReg("中枪枪距").Value ?? 0,
+                    RightDistance_Int = GetListenReg("右枪枪距").Value ?? 0,
+                    LeftShotNum_Int = GetListenReg("左枪次数").Value ?? 0,
+                    CenterShotNum_Int = GetListenReg("中枪次数").Value ?? 0,
+                    RightShotNum_Int = GetListenReg("右枪次数").Value ?? 0,
+                    LeftHighLimitCurrent_Dec = (decimal)GetListenReg("左枪电流高报警值").Float,
+                    CenterHighLimitCurrent_Dec = (decimal)GetListenReg("中枪电流高报警值").Float,
+                    RightHighLimitCurrent_Dec = (decimal)GetListenReg("右枪电流高报警值").Float,
+                    LeftLowLimitCurrent_Dec = (decimal)GetListenReg("左枪电流低报警值").Float,
+                    CenterLowLimitCurrent_Dec = (decimal)GetListenReg("中枪电流低报警值").Float,
+                    RightLowLimitCurrent_Dec = (decimal)GetListenReg("右枪电流低报警值").Float,
+                    MetalSprayingInitialVelocity_Dec = (decimal)GetListenReg("喷金起始速度").Float,
+                    Temp_Int = GetListenReg("温度").Value ?? 0,
+                    Humidity_Int = GetListenReg("湿度").Value ?? 0,
+                    DewPoint_Int = GetListenReg("露点值").Value ?? 0,
+                    CompressedAirFlowRate_Dec = (decimal)GetListenReg("压缩气空气流量").Float,
+                    ElectricityConsumption_Int = electricityConsumption ?? 0,
+                    CompressedAir_Int = compressedAir ?? 0,
+                    Output_Dec = output ?? 0,
+                };
+                Env.DAL.Insert(appByProduction, nameof(App_BY_Production), t => new
+                {
+                    t.LeftWireFeedRate_Int,
+                    t.CenterWireFeedRate_Int,
+                    t.RightWireFeedRate_Int,
+                    t.LeftDistance_Int,
+                    t.CenterDistance_Int,
+                    t.RightDistance_Int,
+                    t.LeftShotNum_Int,
+                    t.CenterShotNum_Int,
+                    t.RightShotNum_Int,
+                    t.LeftHighLimitCurrent_Dec,
+                    t.CenterHighLimitCurrent_Dec,
+                    t.RightHighLimitCurrent_Dec,
+                    t.LeftLowLimitCurrent_Dec,
+                    t.CenterLowLimitCurrent_Dec,
+                    t.RightLowLimitCurrent_Dec,
+                    t.MetalSprayingInitialVelocity_Dec,
+                    t.Temp_Int,
+                    t.Humidity_Int,
+                    t.DewPoint_Int,
+                    t.CompressedAirFlowRate_Dec,
+                    t.ElectricityConsumption_Int,
+                    t.CompressedAir_Int,
+                    t.Output_Dec,
+                });
+           
+        }
+    }
+}

+ 31 - 341
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/SampleMachine.cs

@@ -14,6 +14,7 @@ using System.ComponentModel;
 using System.IO;
 using System.Linq;
 using System.Windows;
+using static log4net.Appender.RollingFileAppender;
 
 namespace SCADA_DAQ.Customer.Machines
 {
@@ -31,10 +32,22 @@ namespace SCADA_DAQ.Customer.Machines
 
         //public Dictionary<int, string> EnvironmentValues { get; set; } = new Dictionary<int, string>();
 
-        public List<string> EnvironmentValues { get; set; } = new List<string>();
-        /// <summary>
-        /// 
-        /// </summary>
+        //public List<string> EnvironmentValues { get; set; } = new List<string>();
+
+        #region 曲线图累计 上一时间段值
+        public int? PreRegElectricityConsumptionTotalChart { get; set; }
+
+        public int? PreRegCompressedAirTotalChart { get; set; }
+        #endregion
+
+        #region 生产记录累计 上一时间段值
+        public int? PreRegElectricityConsumptionTotalProduction { get; set; }
+
+        public int? PreRegCompressedAirTotalProduction { get; set; }
+
+        public int? PreRegOutputTotalProduction { get; set; }
+        #endregion
+
         /// <param name="machieID"></param>
         public SampleMachine(string machieID) : base(machieID)
         {
@@ -56,333 +69,28 @@ namespace SCADA_DAQ.Customer.Machines
              .ToLookup(t => t.AlarmCode).
              ToDictionary(t => t.Key, t => t.First());
 
-            var c = 4;
+            Env.DAL.App_BY_EnvironmentValues.DeleteOldData(DateTime.Now);
 
+            PreRegElectricityConsumptionTotalChart = GetListenReg("累计用电量")?.Value;
+            PreRegCompressedAirTotalChart = GetListenReg("压缩空气累计量")?.Value;
 
+            PreRegElectricityConsumptionTotalProduction = GetListenReg("累计用电量")?.Value;
+            PreRegCompressedAirTotalProduction = GetListenReg("压缩空气累计量")?.Value;
+            PreRegOutputTotalProduction = GetListenReg("产量统计")?.Value;
 
         }
 
+        private readonly string taiDaAS300 = "台达AS300";
+
         //使用事件
         private void Schedual_DateTimeChanged1(object sender, SCADA.CommonLib.DateTimeChangedArgs e)
         {
             // 此在本类内 故是对设备筛选 若在其他类 则需实例化类设备对象如CustoneService文件内
-            var DeviceIDTaiDaAS300 = "台达AS300";
-            if (BaseDevice.DeviceID == DeviceIDTaiDaAS300)
+            if (BaseDevice.DeviceID == taiDaAS300)
             {
-                if (GetListenReg("左枪电流") != null)
-                {
-                    var LeftCurrent = GetListenReg("左枪电流").Float;
-                    var CenterCurrent = GetListenReg("中枪电流").Float;
-                    var RightCurrent = GetListenReg("右枪电流").Float;
-                    var LeftAirPressure = GetListenReg("左枪气压").Float;
-                    var CenterAirPressure = GetListenReg("中枪气压").Float;
-                    var RightAirPressure = GetListenReg("右枪气压").Float;
-
-                    //如果秒数发生变化
-                    if (e.ChangeType == SCADA.CommonLib.DateTimeChangeType.SecondChanged)
-                    {
-                        // 各字段插入数据 初始化
-                        Env.DAL.App_BY_EnvironmentValues.Insert(
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.DeviceID_Str, DeviceIDTaiDaAS300),
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CenterCurrent_Dec, CenterCurrent),
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.LeftCurrent_Dec, LeftCurrent),
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.RightCurrent_Dec, RightCurrent),
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.CenterAirPressure_Dec, CenterAirPressure),
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.LeftAirPressure_Dec, LeftAirPressure),
-                            new UpdateItem(T_Col_Name.App_BY_EnvironmentValues.RightAirPressure_Dec, RightAirPressure)
-                        );
-                    }
-                }
-
-
-                if (GetListenReg("总通电时间时")?.ScaleValue != null)
-                {
-                    // 做判空
-                    // 时间格式化
-                    string ToHMS(double H, double M, double S)
-                    {
-                        string h, m, s;
-                        h = H < 10 ? $"0{H}" : $"{H}";
-                        m = M < 10 ? $"0{M}" : $"{M}";
-                        s = S < 10 ? $"0{S}" : $"{S}";
-                        return $"{h}:{m}:{s}";
-                    }
-                    var totalTimeH = GetListenReg("总运行时间时").ScaleValue.Value;
-                    var totalTimeM = GetListenReg("总运行时间分").ScaleValue.Value;
-                    var totalTimeS = GetListenReg("总运行时间秒").ScaleValue.Value;
-                    var totalTimeHMS = ToHMS(totalTimeH, totalTimeM, totalTimeS);
-                    var runTimeH = GetListenReg("生产运行时间时").ScaleValue.Value;
-                    var runTimeM = GetListenReg("生产运行时间分").ScaleValue.Value;
-                    var runTimeS = GetListenReg("生产运行时间秒").ScaleValue.Value;
-                    var runTimeHMS = ToHMS(runTimeH, runTimeM, runTimeS);
-                    var standbyTimeH = GetListenReg("待机时间时").ScaleValue.Value;
-                    var standbyTimeM = GetListenReg("待机时间分").ScaleValue.Value;
-                    var standbyTimeS = GetListenReg("待机时间秒").ScaleValue.Value;
-                    var standbyTimeHMS = ToHMS(standbyTimeH, standbyTimeM, standbyTimeS);
-                    var alarmTimeH = GetListenReg("报警停机时间时").ScaleValue.Value;
-                    var alarmTimeM = GetListenReg("报警停机时间分").ScaleValue.Value;
-                    var alarmTimeS = GetListenReg("报警停机时间秒").ScaleValue.Value;
-                    var alarmTimeHMS = ToHMS(alarmTimeH, alarmTimeM, alarmTimeS);
-
-                    //如果表一行数据也没有
-                    if (Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>().Count == 0)
-                    {
-                        // 各字段插入数据 初始化
-                        Env.DAL.App_BY_Machine_Time.Insert(
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.DeviceID_Str, DeviceIDTaiDaAS300),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
-                        );
-
-                    }
-
-                    //如果表只有一行数据 对该数据更新
-                    if (Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>().Count == 1)
-                    {
-                        //每10秒更新一次
-                        if (e.TimeFlag.Second % 10 == 0)
-                        {
-                            // 获取表里的最新一行数据而且是台达AS300型号(此处未写)对其更新
-                            Env.DAL.App_BY_Machine_Time.Update("ID=(select max(id) from App_BY_Machine_Time)",
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
-                            );
-                        }
-                    }
-
-                    var appBYMachineTimeModelSql = Env.DAL.GetData<AppBYMachineTimeModel>();
-                    var lastCreateTime = appBYMachineTimeModelSql.Last().CreateTime;
-                    var nowTime = DateTime.Now;
-                    // 如果现在(今天)日期不等于最新一行CreateTime日期则说明今天没有插入新数据
-                    if (lastCreateTime.Date != nowTime.Date)
-                    {
-                        // 插入今天新数据 
-                        Env.DAL.App_BY_Machine_Time.Insert(
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.DeviceID_Str, DeviceIDTaiDaAS300),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, totalTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, runTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, standbyTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, alarmTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
-                            new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
-                        );
-                    }
-
-                    // 每10秒且表行数大于1 对最后一行更新
-                    if (appBYMachineTimeModelSql.Count >= 2)
-                    {
-                        // 获取表里倒序第二行寄存器数据
-                        var oldTotalTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegTotalTimeHMS;
-                        var oldRunTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegRunTimeHMS;
-                        var oldStandbyTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegStandbyTimeHMS;
-                        var oldAlarmTimeHMS = appBYMachineTimeModelSql[appBYMachineTimeModelSql.Count - 2].RegAlarmTimeHMS;
-
-                        /// <summary>
-                        /// <param name="timeH">累计寄存器时</param>
-                        /// <param name="timeM">累计寄存器分</param>
-                        /// <param name="timeS">累计寄存器秒</param>
-                        /// <param name="oldTimeHMS">上一次累计寄存器时分秒字符串</param>
-                        /// <returns>返回当天的寄存器时分秒</returns>
-                        /// </summary>
-                        string GetNewTimeHMS(double timeH, double timeM, double timeS, string oldTimeHMS)
-                        {
-                            // 新数据 = 新寄存器数 - 旧寄存器数
-                            var oldTimeHMSArray = oldTimeHMS.Split(new char[] { ':', ':' });
-                            double oldTimeSumS = Convert.ToDouble(oldTimeHMSArray[0]) * 3600 + Convert.ToDouble(oldTimeHMSArray[1]) * 60 + Convert.ToDouble(oldTimeHMSArray[2]);
-                            double timeSumS = timeH * 3600 + timeM * 60 + timeS;
-                            var newTimeSumS = timeSumS - oldTimeSumS;
-                            var newTimeHMS = new TimeSpan(0, 0, Convert.ToInt32(newTimeSumS)).ToString(@"hh\:mm\:ss");
-                            return newTimeHMS;
-                        }
-                        var newTotalTimeHMS = GetNewTimeHMS(totalTimeH, totalTimeM, totalTimeS, oldTotalTimeHMS);
-                        var newRunTimeHMS = GetNewTimeHMS(runTimeH, runTimeM, runTimeS, oldRunTimeHMS);
-                        var newStandbyTimeHMS = GetNewTimeHMS(standbyTimeH, standbyTimeM, standbyTimeS, oldStandbyTimeHMS);
-                        var newAlarmTimeHMS = GetNewTimeHMS(alarmTimeH, alarmTimeM, alarmTimeS, oldAlarmTimeHMS);
-                        if (e.TimeFlag.Second % 10 == 0)
-                        {
-                            // 获取表里的最新一行数据对其更新
-                            Env.DAL.App_BY_Machine_Time.Update("ID=(select max(id) from App_BY_Machine_Time)",
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.TotalTimeHMS_Str, newTotalTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RunTimeHMS_Str, newRunTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.StandbyTimeHMS_Str, newStandbyTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.AlarmTimeHMS_Str, newAlarmTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegTotalTimeHMS_Str, totalTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegRunTimeHMS_Str, runTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegStandbyTimeHMS_Str, standbyTimeHMS),
-                                new UpdateItem(T_Col_Name.App_BY_Machine_Time.RegAlarmTimeHMS_Str, alarmTimeHMS)
-                            );
-                        }
-                    }
-                }
-
-
-                if (GetListenReg("产量统计") != null)
-                {
-                    var output = GetListenReg("产量统计").Value;
-                    var nowTime = DateTime.Now;
-
-                    // 小时产量
-                    var hourOutputRows = Env.DAL.App_BY_HourOutput.GetData<AppBYHourOutputModel>();
-                    if (hourOutputRows.Count == 0)
-                    {
-                        Env.DAL.App_BY_HourOutput.Insert(
-                          new UpdateItem(T_Col_Name.App_BY_HourOutput.DeviceID_Str, DeviceIDTaiDaAS300),
-                          new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
-                          new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
-                        );
-                    }
-                    if (hourOutputRows.Count == 1)
-                    {
-                        //每10秒更新一次
-                        if (e.TimeFlag.Second % 10 == 0)
-                        {
-                            // 获取表里的最新一行数据而且是台达AS300型号(此处未写)对其更新
-                            Env.DAL.App_BY_HourOutput.Update("ID=(select max(id) from App_BY_HourOutput)",
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-
-                    if (hourOutputRows.Count >= 1)
-                    {
-                        // 如果现在(这个小时)不等于最新一行CreateTime小时则说明这个小时没有插入新数据
-                        if (hourOutputRows.Last().CreateTime.ToString("yyyy-MM-dd HH") != nowTime.ToString("yyyy-MM-dd HH"))
-                        {
-                            // 插入这个小时新数据 
-                            Env.DAL.App_BY_HourOutput.Insert(
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.DeviceID_Str, DeviceIDTaiDaAS300),
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, output),
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-                    if (hourOutputRows.Count >= 2)
-                    {
-                        var oldHourOutput = hourOutputRows[hourOutputRows.Count - 2].RegOutput;
-                        var newHourOutput = output - oldHourOutput;
-                        if (e.TimeFlag.Second % 10 == 0)
-                        {
-                            // 获取表里的最新一行数据对其更新
-                            Env.DAL.App_BY_HourOutput.Update("ID=(select max(id) from App_BY_HourOutput)",
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.Output_Dec, newHourOutput),
-                                new UpdateItem(T_Col_Name.App_BY_HourOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-
-                    // 每天产量
-                    var dayOutputRows = Env.DAL.App_BY_DayOutput.GetData<AppBYDayOutputModel>();
-                    if (dayOutputRows.Count == 0)
-                    {
-                        Env.DAL.App_BY_DayOutput.Insert(
-                            new UpdateItem(T_Col_Name.App_BY_DayOutput.DeviceID_Str, DeviceIDTaiDaAS300),
-                            new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
-                            new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
-                        );
-                    }
-                    if (dayOutputRows.Count == 1)
-                    {
-                        // 每分钟更新一次
-                        if (e.TimeFlag.Minute % 1 == 0)
-                        {
-                            Env.DAL.App_BY_DayOutput.Update("ID=(select max(id) from App_BY_DayOutput)",
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-                    // 如果现在(今天)日期不等于最新一行CreateTime日期则说明今天没有插入新数据
-                    if (dayOutputRows.Count >= 1)
-                    {
-                        if (dayOutputRows.Last().CreateTime.Date != nowTime.Date)
-                        {
-                            // 插入今天新数据 
-                            Env.DAL.App_BY_DayOutput.Insert(
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.DeviceID_Str, DeviceIDTaiDaAS300),
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, output),
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-                    if (dayOutputRows.Count >= 2)
-                    {
-                        var oldDayOutput = dayOutputRows[dayOutputRows.Count - 2].RegOutput;
-                        var newDayOutput = output - oldDayOutput;
-                        if (e.TimeFlag.Second % 10 == 0)
-                        {
-                            // 获取表里的最新一行数据对其更新
-                            Env.DAL.App_BY_DayOutput.Update("ID=(select max(id) from App_BY_DayOutput)",
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.Output_Dec, newDayOutput),
-                                new UpdateItem(T_Col_Name.App_BY_DayOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-
-                    // 每月产量
-                    var monthOutputRows = Env.DAL.App_BY_MonthOutput.GetData<AppBYMonthOutputModel>();
-                    if (monthOutputRows.Count == 0)
-                    {
-                        Env.DAL.App_BY_MonthOutput.Insert(
-                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.DeviceID_Str, DeviceIDTaiDaAS300),
-                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
-                            new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
-                        );
-                    }
-                    if (monthOutputRows.Count == 1)
-                    {
-                        // 每2分钟更新一次
-                        if (e.TimeFlag.Minute % 2 == 0)
-                        {
-                            Env.DAL.App_BY_MonthOutput.Update("ID=(select max(id) from App_BY_MonthOutput)",
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-
-                    // 如果今月没插入新数据 则插入新数据
-                    if (monthOutputRows.Count >= 1)
-                    {
-                        if (monthOutputRows.Last().CreateTime.ToString("yyyy-MM") != nowTime.ToString("yyyy-MM"))
-                        {
-                            // 插入今月新数据 
-                            Env.DAL.App_BY_MonthOutput.Insert(
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.DeviceID_Str, DeviceIDTaiDaAS300),
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, output),
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-                    if (monthOutputRows.Count >= 2)
-                    {
-                        var oldMonthOutput = monthOutputRows[monthOutputRows.Count - 2].RegOutput;
-                        var newMonthOutput = output - oldMonthOutput;
-                        if (e.TimeFlag.Second % 10 == 0)
-                        {
-                            // 获取表里的最新一行数据对其更新
-                            Env.DAL.App_BY_MonthOutput.Update("ID=(select max(id) from App_BY_MonthOutput)",
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.Output_Dec, newMonthOutput),
-                                new UpdateItem(T_Col_Name.App_BY_MonthOutput.RegOutput_Dec, output)
-                            );
-                        }
-                    }
-
-                }
+                InsertEnvironmentValues(e);
+                InsertMachineTime(e);
+                InsertOutPut(e);
             }
         }
         public string AlarmMsg { get => AlarmCollection.Count() > 0 ? string.Join(":", AlarmCollection.Select(t => t.AlarmCode)) : null; }
@@ -394,28 +102,10 @@ namespace SCADA_DAQ.Customer.Machines
         /// <param name="e"></param>
         protected override void RegValueChanged(object sender, RegValueChangedEventArgs e)
         {
-            //var DeviceIDTaiDaAS300 = "台达AS300";
-            ////此处是创建一个转型对象
-            //var reg = (RegInfo)sender;
-            //if (BaseDevice.DeviceID == DeviceIDTaiDaAS300)
-            //{
-            //    if (GetListenReg("手自动").Value == 0) { }
-            //}
-            //if (reg.)
-            //{
-            //    reg.
-            //}
-            ////此处筛选对象的属性
-            //// 也可以使用getListenReg("左枪电流") 此为baseMachine类的方法 获取寄存器的值 参数是注释表的变量名称
-            //if (reg.Comment.Variable == "左枪电流")
-            //{
-
-
-            //}
+            var reg = (RegInfo)sender;
+            InsertProduction(reg, e);
             //base.RegValueChanged(sender, e);
             //log.Debug($"{reg.RegName} Value Changed:{reg.OldValue}->{reg.Value}");
-
-
         }
 
 

+ 32 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/AppBYEnvironmentValuesModel.cs

@@ -140,5 +140,37 @@ namespace SCADA_DAQ.Customer.Models
         }
         private string _DeviceID;
 
+        [Column(T_Col_Name.App_BY_EnvironmentValues.CompressedAir_Int)]
+        public int CompressedAir
+        {
+
+            get { return _CompressedAir; }
+            set
+            {
+                if (value != _CompressedAir)
+                {
+                    _CompressedAir = value;
+                    OnPropertyChanged(nameof(CompressedAir));
+                }
+            }
+        }
+        private int _CompressedAir;
+
+        [Column(T_Col_Name.App_BY_EnvironmentValues.ElectricityConsumption_Int)]
+        public int ElectricityConsumption
+        {
+
+            get { return _ElectricityConsumption; }
+            set
+            {
+                if (value != _ElectricityConsumption)
+                {
+                    _ElectricityConsumption = value;
+                    OnPropertyChanged(nameof(ElectricityConsumption));
+                }
+            }
+        }
+        private int _ElectricityConsumption;
+
     }
 }

+ 59 - 4
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/CustomerService.cs

@@ -2,6 +2,7 @@
 using NPOI.SS.Formula.Functions;
 using SCADA;
 using SCADA.CommonLib;
+using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
 using SCADA.CommonLib.Service;
 using SCADA.Drive;
@@ -98,6 +99,8 @@ namespace SCADA_DAQ.Customer.Service
             var LeftAirPressure = new List<double>();
             var RightAirPressure = new List<double>();
             var CenterAirPressure = new List<double>();
+            var electricityConsumption = new List<int>();
+            var compressedAir = new List<int>();
             var Time = new List<TimeSpan>();
             if (lastRows.Count > 0)
             {
@@ -109,6 +112,8 @@ namespace SCADA_DAQ.Customer.Service
                     LeftAirPressure.Add(lastRows[i].LeftAirPressure >= 0 ? lastRows[i].LeftAirPressure : 0);
                     RightAirPressure.Add(lastRows[i].RightAirPressure >= 0 ? lastRows[i].RightAirPressure : 0);
                     CenterAirPressure.Add(lastRows[i].CenterAirPressure >= 0 ? lastRows[i].CenterAirPressure : 0);
+                    electricityConsumption.Add(lastRows[i].ElectricityConsumption);
+                    compressedAir.Add(lastRows[i].CompressedAir);
                     Time.Add(lastRows[i].CreateTime.TimeOfDay);
                 }
             }
@@ -124,6 +129,8 @@ namespace SCADA_DAQ.Customer.Service
                     LeftAirPressure.Add(init);
                     RightAirPressure.Add(init);
                     CenterAirPressure.Add(init);
+                    electricityConsumption.Add(0);
+                    compressedAir.Add(0);
                     Time.Add(new TimeSpan(0, 0, 0));
                 }
             }
@@ -145,12 +152,21 @@ namespace SCADA_DAQ.Customer.Service
                     Current = CenterCurrent,
                     AirPressure = CenterAirPressure
                 },
+                ElectricityConsumption = electricityConsumption,
+                CompressedAir = compressedAir,
                 Time = Time
             });
         }
 
         public RpcResponse<object> GetOEE()
         {
+            var device = MachineServer.GetInstance().GetMachine<SampleMachine>("台达AS300");
+            int? temp = 0;// 温度
+            int? humidity = 0; // 湿度
+            int? dewPoint = 0; // 露点值
+            double compressedAirFlowRate = 0; // 压缩空气流量
+            int? compressedAirTotal = 0; // 压缩空气累积量
+            int? electricityConsumptionTotal = 0;
             double GetDayMonthOee(string runTimeHMS, string totalTimeHMS)
             {
                 var totalTimeHMSArray = totalTimeHMS.Split(new char[] { ':', ':' });
@@ -162,12 +178,44 @@ namespace SCADA_DAQ.Customer.Service
             }
             // 获取最后一条数据 即今天的数据
             var thisDayData = Env.DAL.App_BY_Machine_Time.GetTopN<AppBYMachineTimeModel>(1, "1==1", "CreateTime_Dt Desc");
-            // 今天稼动率
             var thisDayTotalTime = thisDayData.Count == 1 ? thisDayData[0].TotalTimeHMS : "00:00:00";
             var thisDayRunTime = thisDayData.Count == 1 ? thisDayData[0].RunTimeHMS : "00:00:00";
             var thisDayStandbyTime = thisDayData.Count == 1 ? thisDayData[0].StandbyTimeHMS : "00:00:00";
             var thisDayAlarmTime = thisDayData.Count == 1 ? thisDayData[0].AlarmTimeHMS : "00:00:00";
             var thisDayOee = thisDayData.Count == 1 ? GetDayMonthOee(thisDayData[0].RunTimeHMS, thisDayData[0].TotalTimeHMS) : 0;
+            if (device != null)
+            {
+                string ToHMS(double H, double M, double S)
+                {
+                    string h, m, s;
+                    h = H < 10 ? $"0{H}" : $"{H}";
+                    m = M < 10 ? $"0{M}" : $"{M}";
+                    s = S < 10 ? $"0{S}" : $"{S}";
+                    return $"{h}:{m}:{s}";
+                }
+                var totalTimeH = device.GetListenReg("总运行时间时").ScaleValue.Value;
+                var totalTimeM = device.GetListenReg("总运行时间分").ScaleValue.Value;
+                var totalTimeS = device.GetListenReg("总运行时间秒").ScaleValue.Value;
+                thisDayTotalTime = ToHMS(totalTimeH, totalTimeM, totalTimeS);
+                var runTimeH = device.GetListenReg("生产运行时间时").ScaleValue.Value;
+                var runTimeM = device.GetListenReg("生产运行时间分").ScaleValue.Value;
+                var runTimeS = 0;
+                thisDayRunTime = ToHMS(runTimeH, runTimeM, runTimeS);
+                var standbyTimeH = device.GetListenReg("待机时间时").ScaleValue.Value;
+                var standbyTimeM = device.GetListenReg("待机时间分").ScaleValue.Value;
+                var standbyTimeS = 0;
+                thisDayStandbyTime = ToHMS(standbyTimeH, standbyTimeM, standbyTimeS);
+                var alarmTimeH = device.GetListenReg("报警停机时间时").ScaleValue.Value;
+                var alarmTimeM = device.GetListenReg("报警停机时间分").ScaleValue.Value;
+                var alarmTimeS = 0;
+                thisDayAlarmTime = ToHMS(alarmTimeH, alarmTimeM, alarmTimeS);
+                temp = device.GetListenReg("温度").Value;
+                humidity = device.GetListenReg("湿度").Value;
+                dewPoint = device.GetListenReg("露点值").Value;
+                compressedAirFlowRate = device.GetListenReg("压缩气空气流量").Float;
+                compressedAirTotal = device.GetListenReg("压缩空气累计量").Value;
+                electricityConsumptionTotal = device.GetListenReg("累计用电量").Value;
+            }
             // 获取本月所有数据行
             var thisMonthRows = Env.DAL.App_BY_Machine_Time.GetData<AppBYMachineTimeModel>("CreateTime_Dt between datetime('now','start of month','+1 seconds') and  datetime('now','start of month','+1 months','-1 seconds')");
             // thisMonthRows.Last().RegRunTimeHMS是本月最新的寄存器累计数据即总数据
@@ -183,13 +231,20 @@ namespace SCADA_DAQ.Customer.Service
                     RunTime = thisDayRunTime,
                     StandbyTime = thisDayStandbyTime,
                     AlarmTime = thisDayAlarmTime
-                }
+                },
+                Temp = temp, // 温度
+                Humidity = humidity, // 湿度
+                DewPoint = dewPoint, // 露点值
+                CompressedAirFlowRate = Math.Round(compressedAirFlowRate,2), // 压缩空气流量
+                CompressedAirTotal = compressedAirTotal, // 压缩空气累积量
+                ElectricityConsumption = electricityConsumptionTotal
             });
         }
         public RpcResponse<object> GetAlarms()
         {
-            var recoverRows = Env.DAL.Base_AlarmLog.GetData<BaseAlarmLogModel>("Duration_Str IS NOT NULL order by RecoverTime_Dt Desc", null);
-            var notRecoverRows = Env.DAL.Base_AlarmLog.GetData<BaseAlarmLogModel>("Duration_Str IS NULL", null);
+            var todaySql = "CreateTime_Dt >= datetime('now','start of day','+0 day') and CreateTime_Dt < datetime('now','start of day','+1 day')";
+            var recoverRows = Env.DAL.Base_AlarmLog.GetData<BaseAlarmLogModel>($"({todaySql}) and Duration_Str IS NOT NULL order by RecoverTime_Dt Desc", null);
+            var notRecoverRows = Env.DAL.Base_AlarmLog.GetData<BaseAlarmLogModel>($"({todaySql}) and Duration_Str IS NULL", null);
             var dataList = new List<object>();
             if (notRecoverRows.Count != 0)
             {

File diff suppressed because it is too large
+ 0 - 0
skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/SCADA_DAQ.csproj


Some files were not shown because too many files changed in this diff