Bläddra i källkod

Merge branch 'master' of http://116.63.33.55/git/read_opc

FinalYu 1 år sedan
förälder
incheckning
d73ae68283

+ 1 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/dynamicSchedule/DynamicScheduleConfig.java

@@ -69,7 +69,7 @@ public class DynamicScheduleConfig implements SchedulingConfigurer {
                 String clsId = dataSource.getClsId().toUpperCase();
                 DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
                 if (OpcUtil.isOpcDa(dataSourceType.getDataSourceTypeKey())) {
-                    if (itemGroup.getRunState() == ConstantStr.START_UP) {
+                    if (itemGroup.getRunState() == ConstantStr.START_UP || itemGroup.getRunState() == ConstantStr.EXCEPT_STOP_UP) {
                         if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpUserName(), dataSource.getIpPassword())) {
                             throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据组配置的数据源的ip地址,帐户,密码都不能为空");
                         }

+ 2 - 4
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/DataSourceServiceImpl.java

@@ -315,7 +315,6 @@ public class DataSourceServiceImpl implements DataSourceService {
             if (Blank.isNotEmpty(driverBasicItemList)) {
                 dataSourceDao.addDriverBasicItemList(id, driverBasicItemList);
             }
-            DataSourceDriver newDataSourceDriver = dataSourceDao.getDataSourceDriverByid(dataSourceDriver.getId());
             List<DataSource> dataSourceList = dataSourceDao.getDataSourceByclsId(clsId);
             if (Blank.isNotEmpty(dataSourceList)) {
                 List<ItemGroup> itemGroupList = itemGroupDao.getIgListByDsId(dataSourceList);
@@ -327,8 +326,7 @@ public class DataSourceServiceImpl implements DataSourceService {
                         }
                     }
                     List<Item> itemList = itemGroupDao.getItemListByGidList(itemGroupList);
-                    itemList = OpcDaUtil.genBasicDa(itemList,
-                            Blank.isEmpty(newDataSourceDriver) ? null : newDataSourceDriver);
+                    itemList = OpcDaUtil.genBasicDa(itemList, dataSourceDriver);
                     if (Blank.isNotEmpty(itemList)) {
                         String strArr = "";
                         int size = itemList.size();
@@ -367,7 +365,7 @@ public class DataSourceServiceImpl implements DataSourceService {
             List<ItemGroup> itemGroupList = itemGroupDao.getIgListByDsId(dataSourceList);
             if (Blank.isNotEmpty(itemGroupList)) {
                 for (ItemGroup itemGroup : itemGroupList) {
-                    itemGroupDao.updateItByItemGroupId(itemGroup.getId(),ConstantStr.BASIC_ATTRIBUTES);
+                    itemGroupDao.updateItByItemGroupId(itemGroup.getId(), ConstantStr.BASIC_ATTRIBUTES);
                 }
             }
         }

+ 0 - 30
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/util/OpcDaUtil.java

@@ -173,36 +173,6 @@ public class OpcDaUtil {
                 itemList.get(i).setItemType(ConstantStr.BASIC_ATTRIBUTES);
             }
         }
-//        if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.KEPSERVER.getValue()) ||
-//                dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.SCADA.getValue()) ||
-//                dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.PAS300.getValue())
-//        ) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                itemList.get(i).setItemReadName(itemList.get(i).getItemName());
-//            }
-//        } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.YOKOGAWA.getValue())) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                itemList.get(i).setItemReadName(itemList.get(i).getItemName().replaceFirst("\\.", "!"));
-//            }
-//        } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.OPCIFIX.getValue())) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                String itemName = itemList.get(i).getItemName();
-//                try {
-//                    int j = itemName.indexOf(".");
-//                    String s = itemName.substring(j + 1);
-//                    itemList.get(i).setItemReadName(itemName.substring(0, j) + s.substring(s.indexOf(".")));
-//                } catch (Exception e) {
-//                    itemList.remove(i);
-//                }
-//            }
-//        } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.WINCC.getValue())) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                String itemName = itemList.get(i).getItemName();
-//                itemList.get(i).setItemReadName(itemName.substring(itemName.lastIndexOf(".") + 1));
-//            }
-//        } else {
-//            throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前未适配此种驱动类型");
-//        }
         return itemList;
     }
 

+ 20 - 2
reado-app/components/ecahrts/bar-echarts.vue

@@ -6,6 +6,10 @@
 </template>
 
 <script>
+	import {
+		nowDate,
+		timeToDate
+	} from '../../utils/date.js'
 	export default {
 		props: {
 			echartsData: Object
@@ -94,12 +98,17 @@
 						}
 					],
 				},
-				timeNum: 10
+				timeNum: 10,
+				barTime: null
 			};
 		},
 		mounted() {
 			this.getEmit();
 		},
+		beforeDestroy(){
+			clearInterval(this.barTime)
+			this.barTime = null
+		},
 		methods: {
 			getServerData() {
 				const chartData = this.echartsData.chartItemList
@@ -144,7 +153,16 @@
 						break;
 				}
 				this.getServerData()
-				this.$emit('barPolling', time, this.echartsData.id)
+				this.barTime = setInterval(() => {
+					let chartParams = {
+						id: this.echartsData.id,
+						startTime: timeToDate(new Date().getTime() - 3600000),
+						endTime: nowDate()
+					}
+					uni.$http.get('/chart/getChartById', chartParams).then(res => {
+
+					})
+				}, time)
 			}
 		}
 	};

+ 20 - 2
reado-app/components/ecahrts/line-echarts.vue

@@ -6,6 +6,10 @@
 </template>
 
 <script>
+	import {
+		nowDate,
+		timeToDate
+	} from '../../utils/date.js'
 	export default {
 		props: {
 			echartsData: Object
@@ -91,12 +95,17 @@
 						}
 					],
 				},
-				timeNum: 10
+				timeNum: 10,
+				lineTime: null,
 			};
 		},
 		mounted() {
 			this.getEmit();
 		},
+		beforeDestroy(){
+			clearInterval(this.lineTime)
+			this.lineTime = null
+		},
 		methods: {
 			getServerData() {
 				const chartData = this.echartsData.chartItemList
@@ -142,7 +151,16 @@
 						break;
 				}
 				this.getServerData()
-				this.$emit('linePolling', time, this.echartsData.id)
+				this.lineTime = setInterval(() => {
+					let chartParams = {
+						id: this.echartsData.id,
+						startTime: timeToDate(new Date().getTime() - 3600000),
+						endTime: nowDate()
+					}
+					uni.$http.get('/chart/getChartById', chartParams).then(res => {
+
+					})
+				}, time)
 			}
 		}
 	};

+ 20 - 3
reado-app/components/ecahrts/pie-echarts.vue

@@ -5,6 +5,10 @@
 </template>
 
 <script>
+	import {
+		nowDate,
+		timeToDate
+	} from '../../utils/date.js'
 	export default {
 		props: {
 			echartsData: Object
@@ -23,13 +27,17 @@
 						left: 'left'
 					}
 				},
-				timeNum: 10
+				timeNum: 10,
+				pieTime: null
 			};
 		},
 		mounted() {
-
 			this.getEmit()
 		},
+		beforeDestroy() {
+			clearInterval(this.pieTime)
+			this.pieTime = null
+		},
 		methods: {
 			getServerData() {
 				const chartData = this.echartsData.chartItemList[0]
@@ -84,7 +92,16 @@
 						break;
 				}
 				this.getServerData();
-				this.$emit('piePolling', time, this.echartsData.id)
+				this.pieTime = setInterval(() => {
+					let chartParams = {
+						id: this.echartsData.id,
+						startTime: timeToDate(new Date().getTime() - 3600000),
+						endTime: nowDate()
+					}
+					uni.$http.get('/chart/getChartById', chartParams).then(res => {
+
+					})
+				}, time)
 			}
 		}
 	};

+ 21 - 59
reado-app/pages/homePage/index.vue

@@ -4,26 +4,28 @@
 			style="width:80%;display: flex;align-items: center;margin:40rpx 0 20rpx 0">
 			<uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select>
 		</uni-section>
-		<view v-for="item in echartsData" :key="item.id" style="padding-right:20rpx">
-			<view v-if="item.chartType==='pie'">
-				<view class="title" v-if="echartsData.length">
-					{{item.chartName}}
+		<template v-if="clear">
+			<view v-for="item in echartsData" :key="item.id" style="padding-right:20rpx">
+				<view v-if="item.chartType==='pie'">
+					<view class="title" v-if="echartsData.length">
+						{{item.chartName}}
+					</view>
+					<pieEcharts :echartsData="item" @piePolling="piePolling" />
 				</view>
-				<pieEcharts :echartsData="item" @piePolling="piePolling" />
-			</view>
-			<view v-if="item.chartType==='bar'">
-				<view class="title" v-if="echartsData.length">
-					{{item.chartName}}
+				<view v-if="item.chartType==='bar'">
+					<view class="title" v-if="echartsData.length">
+						{{item.chartName}}
+					</view>
+					<barEcharts :echartsData="item" @barPolling="barPolling" />
 				</view>
-				<barEcharts :echartsData="item" @barPolling="barPolling" />
-			</view>
-			<view v-if="item.chartType==='line'">
-				<view class="title" v-if="echartsData.length">
-					{{item.chartName}}
+				<view v-if="item.chartType==='line'">
+					<view class="title" v-if="echartsData.length">
+						{{item.chartName}}
+					</view>
+					<lineEcharts :echartsData="item" @linePolling="linePolling" />
 				</view>
-				<lineEcharts :echartsData="item" @linePolling="linePolling" />
 			</view>
-		</view>
+		</template>
 		<u-empty text="暂无数据" icon="../../static/data.png" v-if="!echartsData.length"></u-empty>
 	</view>
 </template>
@@ -65,20 +67,17 @@
 						text: "近一天"
 					},
 				],
-				barTime: null,
-				lineTime: null,
-				pieTime: null
+				clear: true
 			}
 		},
 		onShow() {
+			this.clear = true
 			this.value = null
 			this.startTime = timeToDate(new Date().getTime() - 3600000)
 			this.temperature()
 		},
 		onHide() {
-			clearInterval(this.barTime)
-			clearInterval(this.lineTime)
-			clearInterval(this.pieTime)
+			this.clear = false
 		},
 		methods: {
 			//用户图表数据
@@ -120,43 +119,6 @@
 					clearInterval(this.pieTime)
 				}
 				this.temperature()
-			},
-			//轮询
-			barPolling(time, id) {
-				this.barTime = setInterval(() => {
-					let chartParams = {
-						id: id,
-						startTime: this.startTime,
-						endTime: nowDate()
-					}
-					uni.$http.get('/chart/getChartById', chartParams).then(res => {
-
-					})
-				}, time)
-			},
-			linePolling(time, id) {
-				this.lineTime = setInterval(() => {
-					let chartParams = {
-						id: id,
-						startTime: this.startTime,
-						endTime: nowDate()
-					}
-					uni.$http.get('/chart/getChartById', chartParams).then(res => {
-
-					})
-				}, time)
-			},
-			piePolling(time, id) {
-				this.pieTime = setInterval(() => {
-					let chartParams = {
-						id: id,
-						startTime: this.startTime,
-						endTime: nowDate()
-					}
-					uni.$http.get('/chart/getChartById', chartParams).then(res => {
-
-					})
-				}, time)
 			}
 		}
 	};