mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
refactor: 优化发布功能
This commit is contained in:
@@ -44,4 +44,6 @@ public interface ExtChartViewMapper {
|
||||
ChartBasePO queryChart(@Param("id") Long id);
|
||||
|
||||
List<CoreChartView> selectListCustom(@Param("sceneId") Long sceneId, @Param("resourceTable") String resourceTable);
|
||||
|
||||
void deleteViewsBySceneId(@Param("sceneId") Long sceneId, @Param("resourceTable") String resourceTable);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SnapshotDataVisualizationInfo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
@@ -29,12 +29,12 @@ public class SnapshotDataVisualizationInfo implements Serializable {
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String pid;
|
||||
private Long pid;
|
||||
|
||||
/**
|
||||
* 所属组织id
|
||||
*/
|
||||
private String orgId;
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
@@ -141,11 +141,11 @@ public class SnapshotDataVisualizationInfo implements Serializable {
|
||||
*/
|
||||
private String checkVersion;
|
||||
|
||||
public String getId() {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -157,19 +157,19 @@ public class SnapshotDataVisualizationInfo implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
public Long getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
public void setPid(Long pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getOrgId() {
|
||||
public Long getOrgId() {
|
||||
return orgId;
|
||||
}
|
||||
|
||||
public void setOrgId(String orgId) {
|
||||
public void setOrgId(Long orgId) {
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ public interface ExtDataVisualizationMapper {
|
||||
|
||||
List<VisualizationReportFilterVO> queryReportFilter(@Param("dvId") Long dvId,@Param("taskId") Long taskId);
|
||||
|
||||
void deleteDataVBatch(@Param("ids") Set<Long> ids);
|
||||
void deleteDataVBatch(@Param("ids") Set<Long> ids,@Param("resourceTable") String resourceTable);
|
||||
|
||||
void deleteViewsBatch(@Param("ids") Set<Long> ids);
|
||||
void deleteViewsBatch(@Param("ids") Set<Long> ids,@Param("resourceTable") String resourceTable);
|
||||
|
||||
UserFormVO queryInnerUserInfo(@Param("id") Long id);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.dataease.api.visualization.request.DataVisualizationBaseRequest;
|
||||
import io.dataease.api.visualization.request.VisualizationWorkbranchQueryRequest;
|
||||
import io.dataease.api.visualization.vo.VisualizationResourceVO;
|
||||
import io.dataease.chart.dao.ext.mapper.ExtChartViewMapper;
|
||||
import io.dataease.commons.constants.DataVisualizationConstants;
|
||||
import io.dataease.commons.constants.OptConstants;
|
||||
import io.dataease.constant.BusiResourceEnum;
|
||||
@@ -62,6 +63,9 @@ public class CoreVisualizationManage {
|
||||
@Resource
|
||||
private CoreOptRecentManage coreOptRecentManage;
|
||||
|
||||
@Resource
|
||||
private ExtChartViewMapper extCoreChartMapper;
|
||||
|
||||
@XpackInteract(value = "visualizationResourceTree", replace = true, invalid = true)
|
||||
public List<BusiNodeVO> tree(BusiNodeRequest request) {
|
||||
List<VisualizationNodeBO> nodes = new ArrayList<>();
|
||||
@@ -108,9 +112,11 @@ public class CoreVisualizationManage {
|
||||
}
|
||||
}
|
||||
// 删除可视化资源
|
||||
extDataVisualizationMapper.deleteDataVBatch(delIds);
|
||||
extDataVisualizationMapper.deleteDataVBatch(delIds,CommonConstants.RESOURCE_TABLE.CORE);
|
||||
extDataVisualizationMapper.deleteDataVBatch(delIds,CommonConstants.RESOURCE_TABLE.SNAPSHOT);
|
||||
// 删除图表信息
|
||||
extDataVisualizationMapper.deleteViewsBatch(delIds);
|
||||
extDataVisualizationMapper.deleteViewsBatch(delIds,CommonConstants.RESOURCE_TABLE.CORE);
|
||||
extDataVisualizationMapper.deleteViewsBatch(delIds,CommonConstants.RESOURCE_TABLE.SNAPSHOT);
|
||||
|
||||
coreOptRecentManage.saveOpt(id, OptConstants.OPT_RESOURCE_TYPE.VISUALIZATION, OptConstants.OPT_TYPE.DELETE);
|
||||
}
|
||||
@@ -168,7 +174,13 @@ public class CoreVisualizationManage {
|
||||
// 更新主表名称
|
||||
DataVisualizationInfo coreVisualizationInfo = new DataVisualizationInfo();
|
||||
coreVisualizationInfo.setId(visualizationInfo.getId());
|
||||
coreVisualizationInfo.setStatus(visualizationInfo.getStatus());
|
||||
coreVisualizationInfo.setPid(visualizationInfo.getPid());
|
||||
coreVisualizationInfo.setContentId(visualizationInfo.getContentId());
|
||||
coreVisualizationInfo.setName(visualizationInfo.getName());
|
||||
visualizationInfo.setUpdateTime(System.currentTimeMillis());
|
||||
visualizationInfo.setUpdateBy(AuthUtils.getUser().getUserId().toString());
|
||||
visualizationInfo.setVersion(3);
|
||||
mapper.updateById(coreVisualizationInfo);
|
||||
coreOptRecentManage.saveOpt(visualizationInfo.getId(), OptConstants.OPT_RESOURCE_TYPE.VISUALIZATION, OptConstants.OPT_TYPE.UPDATE);
|
||||
}
|
||||
@@ -235,9 +247,14 @@ public class CoreVisualizationManage {
|
||||
return extDataVisualizationMapper.findRecent(page, uid, request.getKeyword(), params);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void removeSnapshot(Long dvId){
|
||||
if(dvId != null){
|
||||
// 清理历史数据
|
||||
Set<Long> dvIds = new HashSet<>();
|
||||
dvIds.add(dvId);
|
||||
extDataVisualizationMapper.deleteDataVBatch(dvIds,CommonConstants.RESOURCE_TABLE.SNAPSHOT);
|
||||
extCoreChartMapper.deleteViewsBySceneId(dvId,CommonConstants.RESOURCE_TABLE.SNAPSHOT);
|
||||
linkageMapper.deleteViewLinkageFieldSnapshot(dvId,null);
|
||||
linkageMapper.deleteViewLinkageSnapshot(dvId,null);
|
||||
linkJumpMapper.deleteJumpTargetViewInfoWithVisualizationSnapshot(dvId);
|
||||
@@ -248,7 +265,25 @@ public class CoreVisualizationManage {
|
||||
outerParamsMapper.deleteOuterParamsWithVisualizationIdSnapshot(dvId);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void removeDvCore(Long dvId){
|
||||
if(dvId != null){
|
||||
// 清理历史数据
|
||||
Set<Long> dvIds = new HashSet<>();
|
||||
dvIds.add(dvId);
|
||||
extDataVisualizationMapper.deleteDataVBatch(dvIds,CommonConstants.RESOURCE_TABLE.CORE);
|
||||
extCoreChartMapper.deleteViewsBySceneId(dvId,CommonConstants.RESOURCE_TABLE.CORE);
|
||||
linkageMapper.deleteViewLinkageField(dvId,null);
|
||||
linkageMapper.deleteViewLinkage(dvId,null);
|
||||
linkJumpMapper.deleteJumpTargetViewInfoWithVisualization(dvId);
|
||||
linkJumpMapper.deleteJumpInfoWithVisualization(dvId);
|
||||
linkJumpMapper.deleteJumpWithVisualization(dvId);
|
||||
outerParamsMapper.deleteOuterParamsTargetWithVisualizationId(dvId.toString());
|
||||
outerParamsMapper.deleteOuterParamsInfoWithVisualizationId(dvId.toString());
|
||||
outerParamsMapper.deleteOuterParamsWithVisualizationId(dvId.toString());
|
||||
}
|
||||
}
|
||||
@Transactional
|
||||
public void dvSnapshotCheck(Long dvId){
|
||||
/**
|
||||
* 1.检查当前仪表板(大屏)是否存在镜像
|
||||
@@ -273,8 +308,8 @@ public class CoreVisualizationManage {
|
||||
extDataVisualizationMapper.snapshotOuterParams(dvId);
|
||||
}
|
||||
}
|
||||
|
||||
public void dvRemove(Long dvId){
|
||||
@Transactional
|
||||
public void dvRestore(Long dvId){
|
||||
extDataVisualizationMapper.restoreDataV(dvId);
|
||||
extDataVisualizationMapper.restoreViews(dvId);
|
||||
extDataVisualizationMapper.restoreLinkJumpTargetViewInfo(dvId);
|
||||
|
||||
@@ -511,12 +511,24 @@ public class DataVisualizationServer implements DataVisualizationApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updatePublishStatus(DataVisualizationBaseRequest request) {
|
||||
/**
|
||||
* 如果当前传入状态是1(已发布),则原始状态0(未发布)-》1(已发布);2(已保存未发布)-》1(已发布)
|
||||
* 统一处理为1.删除主表数据,2.将镜像表数据统一copy到主表 3.删除镜像表数据
|
||||
* 其他状态仅更新主表和镜像表状态
|
||||
* */
|
||||
Long dvId = request.getId();
|
||||
DataVisualizationInfo visualizationInfo = new DataVisualizationInfo();
|
||||
visualizationInfo.setStatus(request.getStatus());
|
||||
visualizationInfo.setId(request.getId());
|
||||
visualizationInfo.setStatus(CommonConstants.DV_STATUS.SAVED_UNPUBLISHED);
|
||||
visualizationInfo.setId(dvId);
|
||||
visualizationInfo.setStatus(request.getStatus());
|
||||
coreVisualizationManage.innerEdit(visualizationInfo);
|
||||
if(CommonConstants.DV_STATUS.PUBLISHED == request.getStatus()){
|
||||
coreVisualizationManage.removeDvCore(dvId);
|
||||
coreVisualizationManage.dvRestore(dvId);
|
||||
coreVisualizationManage.removeSnapshot(dvId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,12 +4,26 @@
|
||||
|
||||
<select id="selectListCustom" resultType="io.dataease.chart.dao.auto.entity.CoreChartView">
|
||||
select * from
|
||||
<if test="resourceTable = 'snapshot'">
|
||||
snapshot_core_chart_view
|
||||
</if>
|
||||
<if test="resourceTable = 'snapshot'">
|
||||
core_chart_view
|
||||
</if>
|
||||
<choose>
|
||||
<when test="resourceTable == 'snapshot'">
|
||||
snapshot_core_chart_view
|
||||
</when>
|
||||
<otherwise>
|
||||
core_chart_view
|
||||
</otherwise>
|
||||
</choose>
|
||||
where scene_id = #{sceneId}
|
||||
</select>
|
||||
<delete id="deleteViewsBySceneId">
|
||||
delete from
|
||||
<choose>
|
||||
<when test="resourceTable == 'snapshot'">
|
||||
snapshot_core_chart_view
|
||||
</when>
|
||||
<otherwise>
|
||||
core_chart_view
|
||||
</otherwise>
|
||||
</choose>
|
||||
where scene_id = #{sceneId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -170,12 +170,14 @@
|
||||
`content_id`,
|
||||
`check_version`
|
||||
FROM
|
||||
<if test="resourceTable == 'snapshot'">
|
||||
snapshot_data_visualization_info dvi
|
||||
</if>
|
||||
<if test="resourceTable == 'core'">
|
||||
data_visualization_info dvi
|
||||
</if>
|
||||
<choose>
|
||||
<when test="resourceTable == 'snapshot'">
|
||||
snapshot_data_visualization_info dvi
|
||||
</when>
|
||||
<otherwise>
|
||||
data_visualization_info dvi
|
||||
</otherwise>
|
||||
</choose>
|
||||
where dvi.delete_flag = 0
|
||||
and dvi.id = #{dvId}
|
||||
<if test="dvType">
|
||||
@@ -447,7 +449,12 @@
|
||||
<delete id="deleteDataVBatch">
|
||||
DELETE
|
||||
FROM
|
||||
<if test="resourceTable = 'snapshot'">
|
||||
snapshot_data_visualization_info dvi
|
||||
</if>
|
||||
<if test="resourceTable != 'snapshot'">
|
||||
data_visualization_info dvi
|
||||
</if>
|
||||
WHERE
|
||||
dvi.id IN
|
||||
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
|
||||
@@ -457,7 +464,12 @@
|
||||
<delete id="deleteViewsBatch">
|
||||
DELETE
|
||||
FROM
|
||||
<if test="resourceTable = 'snapshot'">
|
||||
snapshot_core_chart_view ccv
|
||||
</if>
|
||||
<if test="resourceTable != 'snapshot'">
|
||||
core_chart_view ccv
|
||||
</if>
|
||||
WHERE
|
||||
ccv.scene_id IN
|
||||
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
|
||||
|
||||
@@ -182,6 +182,10 @@ const resourceOptFinish = param => {
|
||||
|
||||
const publishStatusChange = status => {
|
||||
// do update
|
||||
updatePublishStatus({ id: dvInfo.value.id, pid: dvInfo.value.id, status }).then(() => {
|
||||
dvMainStore.updateDvInfoCall(status)
|
||||
ElMessage.success(t('visualization.published_success'))
|
||||
})
|
||||
}
|
||||
|
||||
const saveCanvasWithCheck = () => {
|
||||
@@ -706,7 +710,7 @@ const initOpenHandler = newWindow => {
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="dvInfo.status === 2"
|
||||
@click="saveCanvasWithCheck()"
|
||||
@click="publishStatusChange(1)"
|
||||
style="float: right; margin-right: 12px"
|
||||
type="primary"
|
||||
>
|
||||
|
||||
@@ -2802,6 +2802,8 @@ export default {
|
||||
},
|
||||
visualization: {
|
||||
re_publish: '重新发布',
|
||||
published_success: '发布成功',
|
||||
cancel_publish: '取消发布',
|
||||
publish: '发布',
|
||||
freeze_top: '位置冻结在顶部',
|
||||
indicator_linkage: '指标卡联动仅携带图表过滤参数',
|
||||
|
||||
@@ -1553,7 +1553,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
getViewDetails(viewId) {
|
||||
return this.canvasViewInfo[viewId]
|
||||
},
|
||||
updateDvInfoId(newId, contentId?) {
|
||||
updateDvInfoCall(status = 1, newId?, contentId?) {
|
||||
if (this.dvInfo) {
|
||||
this.dvInfo.dataState = 'ready'
|
||||
this.dvInfo.optType = null
|
||||
@@ -1563,6 +1563,7 @@ export const dvMainStore = defineStore('dataVisualization', {
|
||||
if (contentId) {
|
||||
this.dvInfo.contentId = contentId
|
||||
}
|
||||
this.dvInfo.status = status
|
||||
}
|
||||
},
|
||||
popAreaActiveSwitch() {
|
||||
|
||||
@@ -610,7 +610,7 @@ export async function canvasSave(callBack) {
|
||||
})
|
||||
}
|
||||
method(canvasInfo).then(res => {
|
||||
dvMainStore.updateDvInfoId(res.data, newContentId)
|
||||
dvMainStore.updateDvInfoCall(method === updateCanvas ? 2 : 1, res.data, newContentId)
|
||||
snapshotStore.resetStyleChangeTimes()
|
||||
callBack(res)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user