浏览代码

修改报表接口,增加驱动报表

zhoupeng 2 年之前
父节点
当前提交
95bbc472c1

+ 3 - 2
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/controller/ReportTableController.java

@@ -148,8 +148,9 @@ public class ReportTableController {
     @PostMapping("/addReportTable")
     @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.REPORTTABLE, OperationEnum = OperationEnum.ADD)
     public Result addReportTable(@RequestBody ReportTable reportTable) {
-        if (Blank.isEmpty(reportTable, reportTable.getTableTemplateId(), reportTable.getReportTableName(), reportTable.getReportTableData(), reportTable.getReportValueFormat())) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表名称,报表内容,报表取值格式不能为空");
+        if (Blank.isEmpty(reportTable, reportTable.getTableTemplateId(), reportTable.getReportTableName(),
+                reportTable.getReportTableData(), reportTable.getReportValueFormat(), reportTable.getIsAutoReport())) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表名称,报表内容,报表类型,报表取值格式不能为空");
         }
         return reportTableService.addReportTable(reportTable);
     }

+ 11 - 5
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ReportTableServiceImpl.java

@@ -8,7 +8,6 @@ import com.example.opc_common.util.ConstantStr;
 import com.example.opc_common.util.Result;
 import com.example.opc_da.dao.DictDao;
 import com.example.opc_da.dao.ReportTableDao;
-import com.example.opc_da.dao.UserGroupDao;
 import com.example.opc_da.dynamicSchedule.CronTaskRegister;
 import com.example.opc_da.dynamicSchedule.SchedulingRunnable;
 import com.example.opc_da.service.ReportTableService;
@@ -92,7 +91,11 @@ public class ReportTableServiceImpl implements ReportTableService {
         String userId = userUtil.getCurrentUserId();
         ReportTable isExistReportTable = reportTableDao.getReportTableByName(userId, reportTable.getReportTableName());
         reportTable.setUserId(userId);
-        reportTable.setIsAutoReport(ConstantStr.MANUAL_REPORT);
+        if (!reportTable.getIsAutoReport().equals(ConstantStr.MANUAL_REPORT) &&
+                !reportTable.getIsAutoReport().equals(ConstantStr.AUTOMATIC_REPORT) &&
+                !reportTable.getIsAutoReport().equals(ConstantStr.EVENT_DRIVEN_REPORT)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表类型不正确,请选择其他报表类型");
+        }
         reportTable.setVersion(ConstantStr.DEFAULT_VERSION);
         if (Blank.isNotEmpty(isExistReportTable)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此名称的报表了,请更改名称");
@@ -196,9 +199,9 @@ public class ReportTableServiceImpl implements ReportTableService {
             }
             cronTaskRegister.addCronTask(task, cronId, cron);
             return Result.ok(reportTableDao.tableExchangeAutoById(id, isAutoReport, cronId, cron));
-        } else if (isAutoReport == ConstantStr.MANUAL_REPORT) {
-            if (Blank.isEmpty(reportTable, reportTable.getCronId())) {
-                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表不存在,或相应的定时器已被移除");
+        } else if (isAutoReport == ConstantStr.MANUAL_REPORT || isAutoReport == ConstantStr.EVENT_DRIVEN_REPORT) {
+            if (Blank.isEmpty(reportTable)) {
+                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表不存在");
             }
             if (Blank.isEmpty(reportTable.getIsAutoReport())) {
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "未知报表类型,请刷新重试");
@@ -206,6 +209,9 @@ public class ReportTableServiceImpl implements ReportTableService {
             if (reportTable.getIsAutoReport() == ConstantStr.MANUAL_REPORT) {
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此报表已经是手动报表了");
             }
+            if (reportTable.getIsAutoReport() == ConstantStr.EVENT_DRIVEN_REPORT) {
+                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此报表已经是事件驱动报表了");
+            }
             //移除相应的定时器
             cronTaskRegister.removeCronTask(reportTable.getCronId());
             return Result.ok(reportTableDao.tableExchangeTypeById(id, isAutoReport));