Browse Source

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

lhy 1 year ago
parent
commit
e175d8a46b

+ 43 - 39
chuanyi_client2/src/components/CustomDialog/DataSourceItem.vue

@@ -515,9 +515,9 @@ export default {
     loadGroupDataItemNode(node, resolve) {
       if (node.level === 0) {
           // setTimeout(() => {
-          //     this.getDataItemByDataSource()
+              this.getDataItemByDataSource()
           // }, 200)
-
+		// console.log(this.itemDataListByTree)
           // return resolve(this.itemDataListByTree)
       }
       let itemNames = []
@@ -623,44 +623,48 @@ export default {
       if (this.tempItemList && this.tempItemList.length > 0) {
         this.chooseItemDataListByTree = this.tempItemList
       }
-      const loading = showLoading(this, '加载中,请稍候···')
-      getNextAllItem(id, null).then(res => {
-        loading.close()
-        let data = res.data
+	  this.$nextTick(() => {
+	    // 区分驱动返回数据类型
+	    this.hasLeavesFlag = 1
+	  })
+      // const loading = showLoading(this, '加载中,请稍候···')
+      // getNextAllItem(id, null).then(res => {
+      //   loading.close()
+      //   let data = res.data
 
-        let leaves = []
-        if (data.leaves && data.leaves.length > 0) {
-          data.leaves.forEach((t) => {
-            t.label = t.itemName
-            t.value = t.itemReadName
-            t.checked = false
-            leaves.push(t)
-          })
-        }
-        this.leavesList = leaves
-        console.log(33, this.leavesList)
-        this.leavesListF = JSON.parse(JSON.stringify(this.leavesList))
-        let items = []
-        if (data.label && data.label.length > 0) {
-          data.label.forEach((t) => {
-            items.push({
-              'dataSourceId': id,
-              'label': t.itemName,
-              'leaf': false,
-              'children': []
-            })
-          })
-        }
-        this.$nextTick(() => {
-          // 区分驱动返回数据类型
-          this.hasLeavesFlag = 1
-          this.itemDataListByTree = items
-          this.itemDataListByTreeF = JSON.parse(JSON.stringify(this.itemDataListByTree))
-        })
-      }).catch((e) => {
-        loading.close()
-        showAlertWin(this, null, e)
-      })
+      //   let leaves = []
+      //   if (data.leaves && data.leaves.length > 0) {
+      //     data.leaves.forEach((t) => {
+      //       t.label = t.itemName
+      //       t.value = t.itemReadName
+      //       t.checked = false
+      //       leaves.push(t)
+      //     })
+      //   }
+      //   this.leavesList = leaves
+      //   console.log(33, this.leavesList)
+      //   this.leavesListF = JSON.parse(JSON.stringify(this.leavesList))
+      //   let items = []
+      //   if (data.label && data.label.length > 0) {
+      //     data.label.forEach((t) => {
+      //       items.push({
+      //         'dataSourceId': id,
+      //         'label': t.itemName,
+      //         'leaf': false,
+      //         'children': []
+      //       })
+      //     })
+      //   }
+      //   this.$nextTick(() => {
+      //     // 区分驱动返回数据类型
+      //     this.hasLeavesFlag = 1
+      //     this.itemDataListByTree = items
+      //     this.itemDataListByTreeF = JSON.parse(JSON.stringify(this.itemDataListByTree))
+      //   })
+      // }).catch((e) => {
+      //   loading.close()
+      //   showAlertWin(this, null, e)
+      // })
     },
     /** 获取右侧数据源类型列表 */
     getDataSourceList() {

+ 7 - 5
chuanyi_client2/src/utils/luckysheettool.js

@@ -76,17 +76,19 @@ export function insertLuckysheetEChart({
     let S = r.init(document.getElementsByClassName(u)[0]);
     f.animation = false;
 	// 图例为空时,从数据组series中获取名称
-	if (!f.legend.data || f.legend.data.length == 0 || !f.legend.data[0]) {
+	if (f.legend && (!f.legend.data || f.legend.data.length == 0 || !f.legend.data[0])) {
 		let arr = []
 		 for (let nn = 0; nn < f.series.length; nn++) {
 		 	arr.push(f.series[nn].name)
 		 }
 		 f.legend.data = arr
 	}
-	// 动态获取图例所占高度
-	const height = getLegendHeight(j, f.legend.data)
-	console.log(height)
-	f.grid.bottom = height + 80
+	if (f.legend) {
+		// 动态获取图例所占高度
+		const height = getLegendHeight(j, f.legend.data)
+		console.log(height)
+		f.grid.bottom = height + 80
+	}
     S.on('finished', function() {
         // const imgBase = n(`.${u} canvas`)[0].toDataURL('image/png');
         // console.log(imgBase);

+ 4 - 2
chuanyi_client2/src/views/report_template/index.vue

@@ -2561,12 +2561,14 @@ export default {
           chartInfo = this.toolItemChart[i]
         }
       }
-      let temp = JSON.parse(chartInfo.standby).option
+	  const chartData = JSON.parse(chartInfo.standby)
+      let temp = chartData.option
+	  luckysheet.setRangeShow((toExcelColumn(chartData.pos[1] + 1) + (chartData.pos[0] + 1)) + ":" + (toExcelColumn(chartData.pos[1] + 1) + (chartData.pos[0] + 1)))
       this.barChartForm.uid = new Date().getTime()
       this.barChartForm.title = temp.title.text
       this.barChartForm.subtitle = temp.title.subtext
       this.barChartForm.showTitle = temp.title.show ? '1' : '0'
-      this.barChartForm.showLegend = temp.legend.show ? '1' : '0'
+      this.barChartForm.showLegend = temp.legend?.show ? '1' : '0'
       this.barChartForm.type = temp.series[0].type
       this.barChartForm.legendType = '1'
       this.barChartForm.bucketType = chartInfo.bucketType

+ 8 - 5
cqcy-ei/cqcy-ei-common/src/main/java/com/example/opc_common/util/ConstantStr.java

@@ -65,11 +65,11 @@ public class ConstantStr {
     public static final String INDEX = "index";
     public static final String VALUE = "value";
     public static final String VALUE_BELONG_TIME = "valueBelongTime";
-    public static final String START_NUM="startNum";
-    public static final String END_NUM="endNum";
-    public static final String CURRENT_NUM="currentNum";
-    public static final String TABLE_ID="tableId";
-    public static final String REPORT_TABLE_ITEM="reportTableItem";
+    public static final String START_NUM = "startNum";
+    public static final String END_NUM = "endNum";
+    public static final String CURRENT_NUM = "currentNum";
+    public static final String TABLE_ID = "tableId";
+    public static final String REPORT_TABLE_ITEM = "reportTableItem";
 
     public static final String DATA_SOURCE_TREE = "dataSourceTree";
 
@@ -82,6 +82,9 @@ public class ConstantStr {
     public static final String BAR_CHART = "bar";
     public static final String PIE_CHART = "pie";
 
+    //同一数据源中数据组最大运行个数,字典值
+    public static final String DATA_SOURCE_CON = "data_source_con";
+
     //数据项类型,0附属属性,1基础属性
     public static final Integer ATTACH_ATTRIBUTES = 0;
     public static final Integer BASIC_ATTRIBUTES = 1;

+ 1 - 5
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/controller/ReportTableController.java

@@ -2,13 +2,9 @@ package com.example.opc_da.controller;
 
 import com.example.opc_common.entity.ReportTable;
 import com.example.opc_common.entity.TableTemplate;
-import com.example.opc_common.enums.ModelEnum;
-import com.example.opc_common.enums.OperationEnum;
 import com.example.opc_common.enums.ResultEnum;
-import com.example.opc_common.enums.ServerEnum;
 import com.example.opc_common.util.Blank;
 import com.example.opc_common.util.Result;
-import com.example.opc_da.annotation.WebLog;
 import com.example.opc_da.service.ReportTableService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
@@ -289,7 +285,7 @@ public class ReportTableController {
      * 查询报表数量
      */
     @GetMapping("/queryTableNum")
-    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.REPORTTABLE, OperationEnum = OperationEnum.SELECT)
+//    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.REPORTTABLE, OperationEnum = OperationEnum.SELECT)
     public Result queryTableNum() {
         return reportTableService.queryTableNum();
     }

+ 2 - 0
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/dao/ItemGroupDao.java

@@ -81,4 +81,6 @@ public interface ItemGroupDao {
      * @return
      */
     Integer updateItemGroupState(@Param("dataSourceList") List<DataSource> dataSourceList, @Param("modifyState") Integer modifyState, @Param("changeState") Integer changeState);
+
+    Integer getRunItemGroupNum(String ipAddress, String clsId, Integer runState);
 }

+ 1 - 1
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/dao/ReportTableDao.java

@@ -44,7 +44,7 @@ public interface ReportTableDao {
     Integer updateReportTable(ReportTable reportTable);
 
     //通过报表id修改报表的data数据
-    Integer updateReportTableDataById(String tableId, String reportTableData);
+    Integer updateReportTableDataById(String id, String reportTableData);
 
     //获取所有报表
     List<ReportTable> getAllReportTable(Long startNum, Long limitNum, String userId, Integer isAutoReport);

+ 48 - 33
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/service/impl/ItemGroupServiceImpl.java

@@ -64,6 +64,9 @@ public class ItemGroupServiceImpl implements ItemGroupService {
     @Autowired
     private ReportTableDao reportTableDao;
 
+    @Autowired
+    private DictDao dictDao;
+
     @Value("${opc_ua_server.address}")
     private String opcUaUrl;
 
@@ -335,44 +338,56 @@ public class ItemGroupServiceImpl implements ItemGroupService {
                 if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpUserName(), dataSource.getIpPassword())) {
                     throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据组配置的数据源的ip地址,帐户,密码都不能为空");
                 }
-                Server server = null;
-                try {
-                    server = OpcDaUtil.createServer(dataSource);
-                    if (Blank.isEmpty(server)) {
-                        return Result.no(ResultEnum.REQUEST_TIME_OUT.getRespCode(), "创建服务失败");
+                synchronized (this) {
+                    DictType dictType = dictDao.queryDictTypeByKeyType(ConstantStr.DATA_SOURCE_CON, null);
+                    String dictKeyValue = dictType.getDictKeyValue();
+                    if (Blank.isEmpty(dictType, dictKeyValue)) {
+                        return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "字典中(data_source_con)未未配置同一数据源数据组个数限制");
                     }
-                    server.connect();
-                } catch (Exception e) {
-                    throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), OpcDaUtil.genException(e.getMessage()));
-                } finally {
-                    if (Blank.isNotEmpty(server)) {
-                        server.dispose();
+                    Integer num = Integer.valueOf(dictKeyValue);
+                    Integer runNum = itemGroupDao.getRunItemGroupNum(dataSource.getIpAddress(), dataSource.getClsId(), ConstantStr.START_UP);
+                    if (runNum >= num) {
+                        return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "同一数据源,数据组只能运行" + num + "个,请先关闭一些不必要的数据组,再启动");
                     }
-                }
-                redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
-                //新增定时器任务
-                String cronId = Blank.isEmpty(itemGroup.getCronId()) ?
-                        UUID.randomUUID().toString().replace("-", "") :
-                        itemGroup.getCronId();
-                String cron = "0 0 0 ? * ";
-                if (Blank.isEmpty(readWeek)) {
-                    cron = cron + "MON,TUE,WED,THU,FRI,SAT,SUN";
-                    //立即执行一次Timer
-                    opcDaTask.opcDaTask(itemGroup, dataSource, cronId);
-                } else {
-                    cron = cron + readWeek;
-                    for (String str : readWeek.split(",")) {
-                        if (str.equals(DateUtil.getCurrentWeekEn())) {
-                            //立即执行一次Timer
-                            opcDaTask.opcDaTask(itemGroup, dataSource, cronId);
-                            break;
+                    Server server = null;
+                    try {
+                        server = OpcDaUtil.createServer(dataSource);
+                        if (Blank.isEmpty(server)) {
+                            return Result.no(ResultEnum.REQUEST_TIME_OUT.getRespCode(), "创建服务失败");
+                        }
+                        server.connect();
+                    } catch (Exception e) {
+                        throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), OpcDaUtil.genException(e.getMessage()));
+                    } finally {
+                        if (Blank.isNotEmpty(server)) {
+                            server.dispose();
+                        }
+                    }
+                    redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
+                    //新增定时器任务
+                    String cronId = Blank.isEmpty(itemGroup.getCronId()) ?
+                            UUID.randomUUID().toString().replace("-", "") :
+                            itemGroup.getCronId();
+                    String cron = "0 0 0 ? * ";
+                    if (Blank.isEmpty(readWeek)) {
+                        cron = cron + "MON,TUE,WED,THU,FRI,SAT,SUN";
+                        //立即执行一次Timer
+                        opcDaTask.opcDaTask(itemGroup, dataSource, cronId);
+                    } else {
+                        cron = cron + readWeek;
+                        for (String str : readWeek.split(",")) {
+                            if (str.equals(DateUtil.getCurrentWeekEn())) {
+                                //立即执行一次Timer
+                                opcDaTask.opcDaTask(itemGroup, dataSource, cronId);
+                                break;
+                            }
                         }
                     }
+                    SchedulingRunnable task = new SchedulingRunnable(OpcDaTask.class, "opcDaTask", new Object[]{itemGroup, dataSource, cronId});
+                    cronTaskRegister.addCronTask(task, cronId, cron);
+                    itemGroupDao.runItemGroupById(id, runState, cronId);
+                    return Result.ok("启动成功");
                 }
-                SchedulingRunnable task = new SchedulingRunnable(OpcDaTask.class, "opcDaTask", new Object[]{itemGroup, dataSource, cronId});
-                cronTaskRegister.addCronTask(task, cronId, cron);
-                itemGroupDao.runItemGroupById(id, runState, cronId);
-                return Result.ok("启动成功");
             } else if (runState.equals(ConstantStr.STOP_IT)) {
                 redisUtil.set(ConstantStr.ITEM_GROUP + id, false);
                 itemGroupDao.stopItemGroupById(id, runState);

+ 6 - 4
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/service/impl/ReportTableServiceImpl.java

@@ -149,10 +149,11 @@ public class ReportTableServiceImpl implements ReportTableService {
             }
             reportTableTask.updateEventReport(tableTemplate, reportTable);
         } else if (templateType.equals(ConstantStr.DEVICE_REPORT)) {
-            if (Blank.isNotEmpty(tableTemplate.getTableTemplateChartList())) {
-                throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "设备报表不能存在统计图");
-            }
-            reportTableTask.updateDeviceReport(tableTemplate, reportTable);
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "设备报表目前不支持修改");
+//            if (Blank.isNotEmpty(tableTemplate.getTableTemplateChartList())) {
+//                throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "设备报表不能存在统计图");
+//            }
+//            reportTableTask.updateDeviceReport(tableTemplate, reportTable);
         } else {
             throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前只支持手动,自动,事件驱动类型的报表");
         }
@@ -440,6 +441,7 @@ public class ReportTableServiceImpl implements ReportTableService {
                 ReportTable chReportTable = reportTableDao.getReportTableById(chTableId);
                 chReportTable.setReportTableData(reportTable.getReportTableData());
                 chReportTable.setReportTableItemList(reportTableDao.getTableItemListById(chTableId));
+                chReportTable.setReportChartList(reportTableDao.getReportChartList(chTableId));
                 chReportTable.setUserGroupList(reportTableDao.getTableUserGroup(chTableId));
                 return Result.ok(chReportTable);
             }

+ 30 - 10
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/OpcAsyncTask.java

@@ -191,7 +191,10 @@ public class OpcAsyncTask {
                 } else {
                     //如果两者相等,将上一次的数据异步存入到数据库,并生成新的子报表
                     if (eventNum == (int) currentNum) {
-                        asyncAsyncTask.updateReportNum(redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString(), eventNum);
+                        Object o = redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId);
+                        if (Blank.isNotEmpty(o)) {
+                            asyncAsyncTask.updateReportNum(o.toString(), eventNum);
+                        }
                         //从redis中取出数据
                         List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
                         if (Blank.isNotEmpty(tttItemList)) {
@@ -207,6 +210,7 @@ public class OpcAsyncTask {
                         //生成新的子报表
                         String id = IdUtil.createSnowflake(1, 1).nextId() + "";
                         asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, 1);
+                        redisUtil.set(ConstantStr.TABLE_ID + tableTemplateId, id);
                         redisUtil.set(ConstantStr.CURRENT_NUM + tableTemplateId, 1);
                         //获取事件驱动报表中所有的数据项信息
                         if (Blank.isNotEmpty(tttItemList)) {
@@ -330,9 +334,16 @@ public class OpcAsyncTask {
                     continue;
                 }
                 //获取开始数据项的数据
+                Map<String, TableTemplateTableItem> tttItemMap = ttIdMap.get(tableTemplateId);
+                TableTemplateTableItem startTttItem = tttItemMap.get(startItemName + ConstantStr.START_TIME_ITEM);
+                Integer startValueType = startTttItem.getValueType();
+                Boolean valueFlag = false;
+                if (startValueType.equals(ConstantStr.CALCULATED_VALUE)) {
+                    valueFlag = true;
+                }
                 CursorRawData startCrData = dataMap.get(startItemName);
                 //如果开始数据项的数据等于,设定的开始值
-                if (startCrData.getDataValue().equals(startValue)) {
+                if ((valueFlag ? startCrData.getDataValue() : startCrData.getOrgDataValue()).equals(startValue)) {
                     //从redis中获取开始、结束时间存入redis中的长度
                     int startNum = 0;
                     int endNum = 0;
@@ -364,13 +375,10 @@ public class OpcAsyncTask {
                             asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.DEVICE_GENERATE_REPORT, 0);
                             redisUtil.set(ConstantStr.START_NUM + tableTemplateId, startNum + 1);
                             redisUtil.set(ConstantStr.TABLE_ID + tableTemplateId, id);
-                            //获取模板中开始时间对应的数据项信息
-                            Map<String, TableTemplateTableItem> tttItemMap = ttIdMap.get(tableTemplateId);
-                            TableTemplateTableItem tttItem = tttItemMap.get(startItemName + ConstantStr.START_TIME_ITEM);
                             //生成新的开始时间数据项的数据项信息,并存入到redis中
                             ReportTableItem reportTableItem = new ReportTableItem(
-                                    id, startItemId, tttItem.getItemName(), tttItem.getDescribe(), ConstantStr.START_TIME_ITEM, tttItem.getValueType(), tttItem.getXaxis(), tttItem.getYaxis(),
-                                    tttItem.getStandby(), startValue, startCrData.getDataValueTime(), index.toString()
+                                    id, startItemId, startTttItem.getItemName(), startTttItem.getDescribe(), ConstantStr.START_TIME_ITEM, startTttItem.getValueType(), startTttItem.getXaxis(), startTttItem.getYaxis(),
+                                    startTttItem.getStandby(), startValue, startCrData.getDataValueTime(), index.toString()
                             );
                             asyncAsyncTask.addReportTableItem(reportTableItem);
                             redisUtil.set(tableTemplateId + ConstantStr.REPORT_TABLE_ITEM + startItemName + ConstantStr.REPORT_TABLE_ITEM + ConstantStr.START_TIME_ITEM, reportTableItem);
@@ -384,8 +392,14 @@ public class OpcAsyncTask {
                     }
                 }
                 //获取结束数据项的数据
+                TableTemplateTableItem endTttItem = tttItemMap.get(endItemName + ConstantStr.END_TIME_ITEM);
+                Integer endValueType = endTttItem.getValueType();
+                valueFlag = false;
+                if (endValueType.equals(ConstantStr.CALCULATED_VALUE)) {
+                    valueFlag = true;
+                }
                 CursorRawData endCrData = dataMap.get(endItemName);
-                if (endCrData.getDataValue().equals(endValue)) {
+                if ((valueFlag ? endCrData.getDataValue() : endCrData.getOrgDataValue()).equals(endValue)) {
                     //从redis中获取开始、结束时间存入redis中的长度
                     int startNum = 0;
                     int endNum = 0;
@@ -416,7 +430,9 @@ public class OpcAsyncTask {
                             String id = redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString();
                             redisUtil.set(ConstantStr.END_NUM + tableTemplateId, endNum + 1);
                             //修改报表当前数量
-                            asyncAsyncTask.updateReportNum(redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString(), endNum + 1);
+                            if (Blank.isNotEmpty(id)) {
+                                asyncAsyncTask.updateReportNum(id, eventNum + 1);
+                            }
                             List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
                             for (TableTemplateTableItem tttItem : tttItemList) {
                                 Integer timeItemType = tttItem.getTimeItemType();
@@ -444,8 +460,12 @@ public class OpcAsyncTask {
                             }
                         } else {
                             redisUtil.set(ConstantStr.END_NUM + tableTemplateId, endNum + 1);
+                            //获取子报表中的报表主键
+                            String id = redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString();
                             //修改报表当前数量
-                            asyncAsyncTask.updateReportNum(redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString(), endNum + 1);
+                            if (Blank.isNotEmpty(id)) {
+                                asyncAsyncTask.updateReportNum(id, eventNum + 1);
+                            }
                             //如果此时插入的结束时间为最后一个数据
                             if ((endNum + 1) == eventNum) {
                                 List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();

+ 0 - 3
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/OpcDaFrequencyTask.java

@@ -266,9 +266,6 @@ public class OpcDaFrequencyTask extends TimerTask {
                         break;
                     }
                     try {
-                        System.out.println("--------------server" + server);
-                        System.out.println("--------------serverState" + server.getServerState());
-                        System.out.println("--------------group" + group);
                         Map<org.openscada.opc.lib.da.Item, ItemState> resultMap = group.read(true, itemArr);
                         index++;
                         List<CursorRawData> cursorRawDataList = new ArrayList<>();

+ 1 - 4
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/PrintTask.java

@@ -1,6 +1,5 @@
 package com.example.opc_da.task;
 
-import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.example.opc_common.entity.Print;
@@ -18,9 +17,7 @@ import org.springframework.stereotype.Component;
 
 import java.net.InetAddress;
 import java.net.URLEncoder;
-import java.nio.charset.Charset;
 import java.util.HashMap;
-import java.util.Map;
 
 @Slf4j
 @Component
@@ -56,7 +53,7 @@ public class PrintTask {
                 }
             }
 //            String url = "http://192.168.0.15:8081/app" + pageUrl + "?id=" + reportTableId;
-            String url = "http://localhost:8084/cy-sheet/index.html?id=" + reportTableId;
+            String url = "http://localhost:8084/cy-sheet-ss/index.html?id=" + reportTableId;
 //            String url = "http://" + hostAddress + ":8081/app" + pageUrl + "?id=" + reportTableId;
             log.info("报表请求地址{}", url);
             String post = HttpUtil.post("http://" + printIp + ":8084" + printUrl + "?excelUrl=" + URLEncoder.encode(url, "UTF-8") + "&printConfig=" + JSONObject.toJSONString(printConfig), new HashMap<>());

+ 2 - 2
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/ReportTableTask.java

@@ -820,7 +820,7 @@ public class ReportTableTask {
             return reportTable;
         }
         //#查询报表模板
-        TableTemplate tableTemplate = reportTableDao.getTableTemplateById(tableTemplateId);
+        TableTemplate tableTemplate = reportTableDao.getTableTemplateNoDataById(tableTemplateId);
         if (Blank.isEmpty(tableTemplate)) {
             return reportTable;
         }
@@ -1138,7 +1138,7 @@ public class ReportTableTask {
     public void genAutoTableData(ReportTable reportTable) {
         log.info("自动报表,{},执行开始,时间为{}", reportTable, DateUtil.dateChangeStrYmdhmss(new Date()));
         Integer tableTemplateId = reportTable.getTableTemplateId();
-        TableTemplate tableTemplate = reportTableDao.getTableTemplateById(tableTemplateId);
+        TableTemplate tableTemplate = reportTableDao.getTableTemplateNoDataById(tableTemplateId);
         if (Blank.isEmpty(tableTemplate)) {
             log.info("报表模板不存在");
         }

+ 1 - 1
cqcy-ei/cqcy-ei-da/src/main/resources/application.yml

@@ -16,7 +16,7 @@ opc_ua_server:
 
 reportTable:
   pageUrl: /static/webview/report-wv.html
-  printUrl: /api/printUrl
+  printUrl: /api/printUrlreal
 
 opc_storage:
   time_format: "yyyy-MM-dd HH"

+ 11 - 0
cqcy-ei/cqcy-ei-da/src/main/resources/mapper/ItemGroupDao.xml

@@ -324,4 +324,15 @@
         </foreach>
     </select>
 
+    <select id="getRunItemGroupNum" resultType="java.lang.Integer">
+        SELECT count(*)
+        FROM t_item_group
+        WHERE run_state = #{runState}
+          AND data_source_id IN
+              (SELECT id
+               FROM t_data_source
+               WHERE ip_address = #{ipAddress}
+                 AND cls_id = #{clsId})
+    </select>
+
 </mapper>