|
@@ -1,10 +1,7 @@
|
|
|
package com.example.opc_da.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.example.opc_common.entity.Dict;
|
|
|
-import com.example.opc_common.entity.ReportTable;
|
|
|
-import com.example.opc_common.entity.TableTemplate;
|
|
|
-import com.example.opc_common.entity.UserGroupUser;
|
|
|
+import com.example.opc_common.entity.*;
|
|
|
import com.example.opc_common.enums.ResultEnum;
|
|
|
import com.example.opc_common.util.Blank;
|
|
|
import com.example.opc_common.util.ConstantStr;
|
|
@@ -84,8 +81,9 @@ public class ReportTableServiceImpl implements ReportTableService {
|
|
|
if (Blank.isNotEmpty(isExistReportTable)) {
|
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此名称的报表了,请更改名称");
|
|
|
}
|
|
|
- if (reportTableDao.addReportTable(reportTable) <= 0) {
|
|
|
- return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "添加报表失败");
|
|
|
+ reportTableDao.addReportTable(reportTable);
|
|
|
+ if (Blank.isNotEmpty(reportTable.getUserGroupList())) {
|
|
|
+ reportTableDao.addTableUserGroup(reportTable.getId(), reportTable.getUserGroupList());
|
|
|
}
|
|
|
return Result.ok("添加报表成功");
|
|
|
}
|
|
@@ -100,6 +98,11 @@ public class ReportTableServiceImpl implements ReportTableService {
|
|
|
if (reportTableDao.updateReportTable(reportTable) <= 0) {
|
|
|
return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "修改报表失败");
|
|
|
}
|
|
|
+ reportTableDao.delTableUserGroup(reportTable.getId());
|
|
|
+ if (Blank.isNotEmpty(reportTable.getUserGroupList())) {
|
|
|
+ reportTableDao.addTableUserGroup(reportTable.getId(), reportTable.getUserGroupList());
|
|
|
+
|
|
|
+ }
|
|
|
return Result.ok("修改报表成功");
|
|
|
}
|
|
|
|
|
@@ -135,6 +138,10 @@ public class ReportTableServiceImpl implements ReportTableService {
|
|
|
@Override
|
|
|
public synchronized Result tableExchangeTypeById(Integer id, Integer isAutoReport, String cron) {
|
|
|
ReportTable reportTable = reportTableDao.getReportTableById(id);
|
|
|
+ List<UserGroup> userGroupList = reportTableDao.getTableUserGroup(reportTable.getId());
|
|
|
+ if (Blank.isNotEmpty(userGroupList)) {
|
|
|
+ reportTable.setUserGroupList(userGroupList);
|
|
|
+ }
|
|
|
if (isAutoReport == ConstantStr.AUTOMATIC_REPORT) {
|
|
|
if (Blank.isEmpty(cron)) {
|
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "cron表达式不能为空");
|
|
@@ -246,6 +253,23 @@ public class ReportTableServiceImpl implements ReportTableService {
|
|
|
return Result.ok(reportTableDao.getSysTableTemplateById(id));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public synchronized Result updateTableTemplateNameById(Integer id, String templateName) {
|
|
|
+ String userId = userUtil.getCurrentUserId();
|
|
|
+ TableTemplate tableTemplate = reportTableDao.getTableTemplateById(id);
|
|
|
+ if (!tableTemplate.getUserId().equals(userId)) {
|
|
|
+ return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此报表模板不是你创建的,不能修改其名称");
|
|
|
+ }
|
|
|
+ TableTemplate isExistTableTemplate = reportTableDao.getTableTemplateByNameNoId(id, userId, templateName);
|
|
|
+ if (Blank.isNotEmpty(isExistTableTemplate)) {
|
|
|
+ return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此报表模板名称了,请修改");
|
|
|
+ }
|
|
|
+ if (reportTableDao.updateTableTemplateNameById(id, templateName) <= 0) {
|
|
|
+ return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "修改报表模板名称失败");
|
|
|
+ }
|
|
|
+ return Result.ok("修改报表模板名称成功");
|
|
|
+ }
|
|
|
+
|
|
|
public List<Integer> gen(List<Integer> dictIdList, List<Dict> dictList, Integer dictId) {
|
|
|
dictIdList.add(dictId);
|
|
|
Iterator<Dict> iterator = dictList.iterator();
|