|
|
@@ -1,28 +1,29 @@
|
|
|
package com.usoftchina.bi.server.service.dashboard;
|
|
|
|
|
|
import com.usoftchina.bi.core.exception.MyException;
|
|
|
-import com.usoftchina.bi.core.utils.EncryUtil;
|
|
|
-import com.usoftchina.bi.core.utils.JsonUtils;
|
|
|
+import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
|
|
|
import com.usoftchina.bi.server.dao.dashboard.DashboardsMapper;
|
|
|
import com.usoftchina.bi.server.dao.user.UserMapper;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.bi.server.model.bo.DashOrder;
|
|
|
import com.usoftchina.bi.server.model.bo.ShareReqBO;
|
|
|
+import com.usoftchina.bi.server.model.po.ChartConfig;
|
|
|
import com.usoftchina.bi.server.model.po.Dashboards;
|
|
|
import com.usoftchina.bi.core.base.RepCode;
|
|
|
import com.usoftchina.bi.core.base.RepEntity;
|
|
|
import com.usoftchina.bi.core.base.TestPage;
|
|
|
import com.usoftchina.bi.server.model.vo.configVo.ChangeOrderInfo;
|
|
|
import com.usoftchina.bi.server.model.vo.configVo.DashboardsInfo;
|
|
|
+import com.usoftchina.bi.server.model.vo.dataVo.DashboardCopyInfo;
|
|
|
import com.usoftchina.bi.server.model.vo.dataVo.DashboardOrderInfo;
|
|
|
import com.usoftchina.bi.server.service.chart.ChartsUtilService;
|
|
|
import com.usoftchina.bi.core.utils.GetTokenDataUtil;
|
|
|
import org.bouncycastle.util.encoders.UrlBase64;
|
|
|
-import org.bouncycastle.util.encoders.UrlBase64Encoder;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -38,6 +39,8 @@ public class DashboardsService {
|
|
|
UserMapper userMapper;
|
|
|
@Autowired
|
|
|
ChartsUtilService chartsUtilService;
|
|
|
+ @Autowired
|
|
|
+ private ChartsConfigMapper chartsConfigMapper;
|
|
|
|
|
|
/*
|
|
|
保存看板
|
|
|
@@ -270,4 +273,44 @@ public class DashboardsService {
|
|
|
dashboardOrderInfo.setGroupNames(groupNames);
|
|
|
return new RepEntity(RepCode.success, dashboardOrderInfo);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制看板
|
|
|
+ * @param dashboardCopyInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public RepEntity copy(String token, DashboardCopyInfo dashboardCopyInfo) {
|
|
|
+ Map<String, String> resultMap = GetTokenDataUtil.getTokenData(token);
|
|
|
+ int userId = Integer.parseInt(resultMap.get("id"));
|
|
|
+ String userName = resultMap.get("name");
|
|
|
+ int dashboardId = dashboardCopyInfo.getDashboardId(),
|
|
|
+ dataSourceId = dashboardCopyInfo.getDataSourceId();
|
|
|
+ List<String> idList = new ArrayList<>();
|
|
|
+ //复制图表
|
|
|
+ String chartIds = dashboardsMapper.getChartIdsById(dashboardId);
|
|
|
+ if (!StringUtils.isEmpty(chartIds)) {
|
|
|
+ String[] idArray = chartIds.split(",");
|
|
|
+ for (int i = 0, len = idArray.length; i < len; i++) {
|
|
|
+ ChartConfig chartConfig = chartsConfigMapper.getOneChart(Integer.valueOf(idArray[i]));
|
|
|
+ chartConfig.setCreateBy(userName);
|
|
|
+ chartConfig.setCreateId(userId);
|
|
|
+ chartConfig.setDataId(dataSourceId);
|
|
|
+ chartsConfigMapper.insertCharts(chartConfig);
|
|
|
+ idList.add(String.valueOf(chartConfig.getChartId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //复制报表
|
|
|
+ int dashboardCreatorId = dashboardsMapper.getCreateIdById(dashboardId);
|
|
|
+ Dashboards dashboards = dashboardsMapper.getDashboards(dashboardCreatorId, dashboardId);
|
|
|
+ dashboards.setCreateBy(userName);
|
|
|
+ dashboards.setCreateId(userId);
|
|
|
+ dashboards.setDemo(false);
|
|
|
+ dashboards.setBdCode("");
|
|
|
+ dashboardsMapper.setDashboards(dashboards);
|
|
|
+ String[] ids = String.join(",", idList).split(",");
|
|
|
+ dashboardsMapper.saveDashboardChartRelation(dashboards.getId(), ids);
|
|
|
+ return new RepEntity(RepCode.success, dashboards.getId());
|
|
|
+ }
|
|
|
+
|
|
|
}
|