Commit 1023f6af authored by linruibiao's avatar linruibiao

接口编写

parent 95fd45c3
...@@ -35,10 +35,10 @@ public class SysMetaObjectHandler implements MetaObjectHandler { ...@@ -35,10 +35,10 @@ public class SysMetaObjectHandler implements MetaObjectHandler {
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
fillValue(metaObject, fillValue(metaObject,
APP_ID, APP_ID,
() -> (metaObject.getValue(APP_ID) == null ? IdWorker.get32UUID() : metaObject.getValue(APP_ID))); () -> (metaObject.getValue(APP_ID) == null ? "68d61d7f990e11eb847e88d7f63cc98f" : metaObject.getValue(APP_ID)));
fillValue(metaObject, fillValue(metaObject,
CREATOR, CREATOR,
() -> (metaObject.getValue(CREATOR) == null ? IdWorker.get32UUID() : metaObject.getValue(CREATOR))); () -> (metaObject.getValue(CREATOR) == null ? "68d61d7f990e11eb847e88d7f63cc98f" : metaObject.getValue(CREATOR)));
fillValue(metaObject, fillValue(metaObject,
CREATOR_NAME, CREATOR_NAME,
() -> (metaObject.getValue(CREATOR_NAME) == null ? "小明" : metaObject.getValue(CREATOR_NAME))); () -> (metaObject.getValue(CREATOR_NAME) == null ? "小明" : metaObject.getValue(CREATOR_NAME)));
...@@ -52,7 +52,7 @@ public class SysMetaObjectHandler implements MetaObjectHandler { ...@@ -52,7 +52,7 @@ public class SysMetaObjectHandler implements MetaObjectHandler {
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
setFieldValByName(UPDATER, IdWorker.get32UUID(), metaObject); setFieldValByName(UPDATER, "68d61d7f990e11eb847e88d7f63cc98f", metaObject);
setFieldValByName(UPDATER_NAME, "小明",metaObject); setFieldValByName(UPDATER_NAME, "小明",metaObject);
setFieldValByName(UPDATE_TIME, new Date(), metaObject); setFieldValByName(UPDATE_TIME, new Date(), metaObject);
} }
......
...@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
...@@ -57,9 +58,9 @@ public class InstrumentPanelController extends BaseRestController { ...@@ -57,9 +58,9 @@ public class InstrumentPanelController extends BaseRestController {
@ApiImplicitParams({@ApiImplicitParam(name = "ids", @ApiImplicitParams({@ApiImplicitParam(name = "ids",
value = "仪表板id集合", value = "仪表板id集合",
required = true, required = true,
dataTypeClass = String.class), dataTypeClass = Arrays.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)}) @ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)})
public R<Object> batchPublish(@PathVariable String appId, @RequestBody List<String> ids) { public R<Object> batchPublish(@PathVariable String appId, @RequestParam List<String> ids) {
return call(() -> instrumentPanelService.batchPublish(ids)); return call(() -> instrumentPanelService.batchPublish(ids));
} }
......
...@@ -34,7 +34,7 @@ public class InstrumentPanelGroupController extends BaseRestController{ ...@@ -34,7 +34,7 @@ public class InstrumentPanelGroupController extends BaseRestController{
@ApiOperation("仪表板列表查询,仪表板分组增删改页面的分组树") @ApiOperation("仪表板列表查询,仪表板分组增删改页面的分组树")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class), @ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称", required = true,dataTypeClass = String.class) @ApiImplicitParam(name = "name", value = "分组名称",dataTypeClass = String.class)
}) })
public R<List<InstrumentPanelGroupVo>> selectGroupList(@PathVariable String appId, @RequestParam(required = false,value = "name") String name) { public R<List<InstrumentPanelGroupVo>> selectGroupList(@PathVariable String appId, @RequestParam(required = false,value = "name") String name) {
return call(()->instrumentPanelGroupService.selectGroupList(appId,name)); return call(()->instrumentPanelGroupService.selectGroupList(appId,name));
...@@ -44,14 +44,14 @@ public class InstrumentPanelGroupController extends BaseRestController{ ...@@ -44,14 +44,14 @@ public class InstrumentPanelGroupController extends BaseRestController{
@ApiOperation("保存仪表板分组") @ApiOperation("保存仪表板分组")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class) @ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<String> saveGroup(@PathVariable String appId, @RequestBody CreateInstrumentPanelGroupDTO group) { public R<String> saveGroup(@PathVariable String appId, @RequestBody CreateInstrumentPanelGroupDTO group) {
return call(()->instrumentPanelGroupService.saveGroup(group)); return call(()->instrumentPanelGroupService.saveGroup(group,appId));
} }
@PutMapping @PutMapping
@ApiOperation("更新仪表板分组") @ApiOperation("更新仪表板分组")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class) @ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class)
public R<String> updateGroup(@PathVariable String appId, @RequestBody InstrumentPanelGroupDTO group) { public R<String> updateGroup(@PathVariable String appId, @RequestBody InstrumentPanelGroupDTO group) {
return call(()->instrumentPanelGroupService.updateGroup(group)); return call(()->instrumentPanelGroupService.updateGroup(group,appId));
} }
@DeleteMapping("/{groupId}") @DeleteMapping("/{groupId}")
......
...@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
...@@ -23,43 +24,52 @@ import java.util.List; ...@@ -23,43 +24,52 @@ import java.util.List;
@Api(value = "仪表板权限控制", tags = "仪表板权限控制") @Api(value = "仪表板权限控制", tags = "仪表板权限控制")
@RestController @RestController
@RequestMapping("/{appId}/panel-permissions") @RequestMapping("/{appId}/panel-permissions")
public class InstrumentPanelPermissionController { public class InstrumentPanelPermissionController extends BaseRestController {
@Autowired @Autowired
private InstrumentPanelPermissionService instrumentPanelPermissionService; private InstrumentPanelPermissionService instrumentPanelPermissionService;
@PostMapping @PostMapping
@ApiOperation("保存仪表板权限(列表的属性保存)") @ApiOperation("保存仪表板权限(列表的属性保存)")
@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class) @ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)
public R<String> savePermission(@PathVariable String appId, @RequestBody InstrumentPanelPermissionDTO permission) { public R<String> savePermission(@PathVariable String appId, @RequestBody InstrumentPanelPermissionDTO permission) {
return R.ok(instrumentPanelPermissionService.savePermission(permission)); return call(() -> instrumentPanelPermissionService.savePermission(permission));
} }
@PostMapping("/{panelId}/to-copy") @PutMapping("/{panelId}/to-copy")
@ApiOperation("从其他仪表板复制配置") @ApiOperation("从其他仪表板复制配置")
@ApiImplicitParams({@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class), @ApiImplicitParams({@ApiImplicitParam(name = "appId",
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true,dataTypeClass = String.class)}) value = "租户id",
public R<List<InstrumentPanelPermissionVo>> saveCopyOtherPermission(@PathVariable String appId, required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true, dataTypeClass = String.class)})
public R<InstrumentPanelPermissionVo> saveCopyOtherPermission(@PathVariable String appId,
@PathVariable String panelId) { @PathVariable String panelId) {
return R.ok(instrumentPanelPermissionService.saveCopyOtherPermission(panelId)); return call(() -> (instrumentPanelPermissionService.saveCopyOtherPermission(panelId)));
} }
@PostMapping("/{panelId}/copy-to") @PostMapping("/copy-to")
@ApiOperation("将仪表板权限复制给其他仪表板") @ApiOperation("将仪表板权限复制给其他仪表板")
@ApiImplicitParams({@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class), @ApiImplicitParams({@ApiImplicitParam(name = "appId",
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true,dataTypeClass = String.class)}) value = "租户id",
public R<String> saveCopyToOtherPermission(@PathVariable String appId, required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true, dataTypeClass = Arrays.class)})
public R<Object> saveCopyToOtherPermission(@PathVariable String appId,
@RequestBody InstrumentPanelPermissionDTO permission, @RequestBody InstrumentPanelPermissionDTO permission,
@PathVariable String panelId) { @RequestParam List<String> panelIds) {
return R.ok(instrumentPanelPermissionService.saveCopyToOtherPermission(permission, panelId)); return call(() -> instrumentPanelPermissionService.saveCopyToOtherPermission(permission, panelIds));
} }
@GetMapping("/{panelId}") @GetMapping("/{panelId}")
@ApiOperation("根据仪表板id获取仪表板权限") @ApiOperation("根据仪表板id获取仪表板权限")
@ApiImplicitParams({@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class), @ApiImplicitParams({@ApiImplicitParam(name = "appId",
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true,dataTypeClass = String.class)}) value = "租户id",
public R<List<InstrumentPanelPermissionVo>> selectPermissionByPanelId(@PathVariable String appId, required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true, dataTypeClass = String.class)})
public R<InstrumentPanelPermissionVo> selectPermissionByPanelId(@PathVariable String appId,
@PathVariable String panelId) { @PathVariable String panelId) {
return R.ok(instrumentPanelPermissionService.selectPermissionByPanelId(panelId)); return call(() -> (instrumentPanelPermissionService.selectPermissionByPanelId(panelId)));
} }
} }
package com.syc.slm.slmbi.controller; package com.syc.slm.slmbi.controller;
import com.syc.slm.common.core.util.R; import com.syc.slm.common.core.util.R;
import com.syc.slm.slmbi.service.InstrumentPanelGroupService; import com.syc.slm.slmbi.service.InstrumentPanelConfigService;
import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo; import com.syc.slm.slmbi.service.InstrumentPanelTreeService;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo; import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -20,36 +21,80 @@ import java.util.List; ...@@ -20,36 +21,80 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/{appId}/panel-tree") @RequestMapping("/{appId}/panel-tree")
@Api(value = "仪表板树接口", tags = "仪表板树接口") @Api(value = "仪表板树接口", tags = "仪表板树接口")
public class InstrumentPanelTreeController { public class InstrumentPanelTreeController extends BaseRestController {
@Autowired
private InstrumentPanelTreeService treeService;
@Autowired @Autowired
private InstrumentPanelGroupService instrumentPanelGroupService; private InstrumentPanelConfigService configService;
@GetMapping @GetMapping
@ApiOperation("第一次进入页面,或者点击查询,获取全部分组下的仪表板数据,以及分组数据") @ApiOperation("显示已发布仪表板树==》(刚进入页面)")
@ApiImplicitParams({@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class), @ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class)
@ApiImplicitParam(name = "name", value = "分组名称或者仪表板名称",dataTypeClass = String.class)}) public R<List<PanelTreeNodeVo>> loadTrees(@PathVariable String appId) {
return call(() -> (treeService.loadTrees(appId)));
}
@GetMapping("/search")
@ApiOperation("显示已发布仪表板树==》(点击查询)")
@ApiImplicitParams({@ApiImplicitParam(name = "appId",
value = "租户id",
required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称或者仪表板名称", dataTypeClass = String.class)})
public R<List<PanelTreeNodeVo>> loadTrees(@PathVariable String appId, public R<List<PanelTreeNodeVo>> loadTrees(@PathVariable String appId,
@RequestParam(value = "name", required = false) String name) { @RequestParam(value = "name", required = false) String name) {
return R.ok(instrumentPanelGroupService.loadTrees(name)); return call(() -> (treeService.loadTrees(appId, name)));
} }
@GetMapping("/children") @GetMapping("/children")
@ApiOperation("点击节点获取,该分组下的仪表板信息,以及分组数据") @ApiOperation("点击节点,显示已发布仪表板树")
@ApiImplicitParams({@ApiImplicitParam(name = "appId", value = "租户id", required = true,dataTypeClass = String.class), @ApiImplicitParams({@ApiImplicitParam(name = "appId",
@ApiImplicitParam(name = "groupId", value = "分组id", required = true,dataTypeClass = String.class), value = "租户id",
@ApiImplicitParam(name = "name", value = "分组名称或者仪表板名称",dataTypeClass = String.class)}) required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "nodeId", value = "分组id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称或者仪表板名称", dataTypeClass = String.class)})
public R<List<PanelTreeNodeVo>> children(@PathVariable String appId, public R<List<PanelTreeNodeVo>> children(@PathVariable String appId,
@RequestParam("groupId") String groupId, @RequestParam("nodeId") String groupId,
@RequestParam(value = "name", required = false) String name) { @RequestParam(value = "name", required = false) String name) {
return R.ok(instrumentPanelGroupService.children(groupId, name)); return call(() -> (treeService.children(groupId, name)));
} }
// FIXME 使用场景? @GetMapping("/children-panel")
@GetMapping("/selectInstrumentPanelGroups") @ApiOperation("点击节点,显示已发布仪表板配置")
//@ApiOperation("获取所有的仪表板分组以及分组下的仪表板以及仪表板下的组件") @ApiImplicitParams({@ApiImplicitParam(name = "appId",
public R<List<InstrumentPanelGroupVo>> selectInstrumentPanelGroups() { value = "租户id",
return R.ok(); required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "panelId", value = "仪表板id", required = true, dataTypeClass = String.class)})
public R<InstrumentPanelConfigVo> childrenPanel(@PathVariable String appId, @RequestParam("nodeId") String nodeId) {
return call(() -> (configService.getPublishConfigByPanelId(nodeId)));
} }
// TODO 树搜索
@GetMapping("/copy")
@ApiOperation("复制仪表板配置树")
@ApiImplicitParams({@ApiImplicitParam(name = "appId",
value = "租户id",
required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称或者仪表板名称", dataTypeClass = String.class)})
public R<List<PanelTreeNodeVo>> copyTreeList(@PathVariable String appId,@RequestParam(value = "name", required = false) String name) {
return call(() -> (treeService.copyTreeList(appId,name)));
}
@GetMapping("/cite")
@ApiOperation("复用仪表板树")
@ApiImplicitParams({@ApiImplicitParam(name = "appId",
value = "租户id",
required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称,仪表板名称,组件名称", dataTypeClass = String.class)})
public R<List<PanelTreeNodeVo>> cite(@PathVariable String appId,@RequestParam(value = "name", required = false) String name) {
return call(() -> (treeService.citeTreeList(appId,name)));
}
} }
package com.syc.slm.slmbi.dao; package com.syc.slm.slmbi.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syc.slm.slmbi.entity.InstrumentPanelDraft; import com.syc.slm.slmbi.entity.InstrumentPanelDraft;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
/** /**
* 仪表板草稿 * 仪表板草稿
* *
...@@ -12,4 +16,6 @@ import org.springframework.stereotype.Component; ...@@ -12,4 +16,6 @@ import org.springframework.stereotype.Component;
@Component @Component
public interface InstrumentPanelDraftMapper extends BaseMapper<InstrumentPanelDraft> { public interface InstrumentPanelDraftMapper extends BaseMapper<InstrumentPanelDraft> {
List<InstrumentPanelDraft> selectDraftList(@Param("appId") String appId,@Param("panelIds") Set<String> panelIds, @Param("officeIds") String officeIds, @Param(
"userId") String userId, @Param("roleId") String roleId);
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syc.slm.slmbi.entity.InstrumentPanelGroup; import com.syc.slm.slmbi.entity.InstrumentPanelGroup;
import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo; import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -32,4 +33,6 @@ public interface InstrumentPanelGroupMapper extends BaseMapper<InstrumentPanelGr ...@@ -32,4 +33,6 @@ public interface InstrumentPanelGroupMapper extends BaseMapper<InstrumentPanelGr
* @return * @return
*/ */
List<InstrumentPanelGroupVo> selectGroupList(@Param("ew") LambdaQueryWrapper<InstrumentPanelGroup> where); List<InstrumentPanelGroupVo> selectGroupList(@Param("ew") LambdaQueryWrapper<InstrumentPanelGroup> where);
List<PanelTreeNodeVo> selectGroupByIds(@Param("finalPanelIds") Set<String> finalPanelIds, @Param("name") String name);
} }
...@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.syc.slm.slmbi.entity.InstrumentPanel; import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.vo.InstrumentPanelVo; import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
...@@ -25,4 +27,5 @@ public interface InstrumentPanelMapper extends BaseMapper<InstrumentPanel> { ...@@ -25,4 +27,5 @@ public interface InstrumentPanelMapper extends BaseMapper<InstrumentPanel> {
IPage<InstrumentPanelVo> selectInstrumentPanelList(@Param("page") IPage<InstrumentPanelVo> page, IPage<InstrumentPanelVo> selectInstrumentPanelList(@Param("page") IPage<InstrumentPanelVo> page,
@Param("ew") Wrapper<InstrumentPanel> wrapper); @Param("ew") Wrapper<InstrumentPanel> wrapper);
List<PanelTreeNodeVo> selectPanelByIds(@Param("finalPanelIds") Set<String> finalPanelIds, @Param("name") String name);
} }
...@@ -2,9 +2,11 @@ package com.syc.slm.slmbi.dao; ...@@ -2,9 +2,11 @@ package com.syc.slm.slmbi.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.syc.slm.slmbi.entity.InstrumentPanelTree; import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
......
...@@ -19,8 +19,8 @@ import java.util.List; ...@@ -19,8 +19,8 @@ import java.util.List;
@ApiModel(value = "仪表板权限DTO", description = "仪表板权限DTO") @ApiModel(value = "仪表板权限DTO", description = "仪表板权限DTO")
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class InstrumentPanelPermissionDTO { public class InstrumentPanelPermissionDTO {
@ApiModelProperty(value = "主键id") @ApiModelProperty(value = "仪表板主键id")
private String id; private String panelId;
@ApiModelProperty(value = "仪表板名称", required = true) @ApiModelProperty(value = "仪表板名称", required = true)
private String panelName; private String panelName;
......
...@@ -13,8 +13,8 @@ import lombok.Data; ...@@ -13,8 +13,8 @@ import lombok.Data;
public class QueryPageDTO { public class QueryPageDTO {
@ApiModelProperty("页码") @ApiModelProperty("页码")
private Integer pageNum = 1; private Integer current = 1;
@ApiModelProperty("每页大小") @ApiModelProperty("每页大小")
private Integer pageSize = 10; private Integer size = 10;
} }
...@@ -40,4 +40,7 @@ public class InstrumentPanelDraft extends BaseEntity<InstrumentPanelDraft> { ...@@ -40,4 +40,7 @@ public class InstrumentPanelDraft extends BaseEntity<InstrumentPanelDraft> {
@ApiModelProperty(value = "状态(发布,下线)") @ApiModelProperty(value = "状态(发布,下线)")
private String published; private String published;
@ApiModelProperty(value = "仪表板id")
private String panelId;
} }
package com.syc.slm.slmbi.entity; package com.syc.slm.slmbi.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -24,6 +25,9 @@ public class InstrumentPanelTree extends BaseEntity<InstrumentPanelTree> { ...@@ -24,6 +25,9 @@ public class InstrumentPanelTree extends BaseEntity<InstrumentPanelTree> {
*/ */
@ApiModelProperty(value = "节点全路径id") @ApiModelProperty(value = "节点全路径id")
private String fullId; private String fullId;
@ApiModelProperty(value = "节点名字")
private String name;
/** /**
* 节点全路径 * 节点全路径
*/ */
...@@ -37,8 +41,11 @@ public class InstrumentPanelTree extends BaseEntity<InstrumentPanelTree> { ...@@ -37,8 +41,11 @@ public class InstrumentPanelTree extends BaseEntity<InstrumentPanelTree> {
@ApiModelProperty(value = "组件key") @ApiModelProperty(value = "组件key")
private String assemblyKey; private String assemblyKey;
/* @ApiModelProperty(value = "业务id") @ApiModelProperty(value = "父级id")
private String bizId;*/ @TableField(exist = false)
private String parentId;
} }
package com.syc.slm.slmbi.function;
import java.io.Serializable;
/**
* Created by Yeshirow on 2018-01-16.
*/
public interface Action1<T> extends Serializable {
void call(T t);
@SafeVarargs
static <T1>Action1<T1>[] of(Action1<T1>... funcs){
return funcs;
}
}
package com.syc.slm.slmbi.function;
import java.io.Serializable;
/**
* Created by Yeshirow on 2018-01-16.
*/
public interface Action2<T1,T2> extends Serializable {
void call(T1 t1, T2 t2);
@SafeVarargs
static <T1,T2>Action2<T1,T2>[] of(Action2<T1, T2>... funcs){
return funcs;
}
}
...@@ -31,8 +31,10 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo ...@@ -31,8 +31,10 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo
* @return * @return
*/ */
InstrumentPanelConfigVo getConfigByPanelId(@NotNull String instrumentPanelId); InstrumentPanelConfigVo getConfigByPanelId(@NotNull String instrumentPanelId);
/** /**
* 保存发布仪表板配置 * 保存发布仪表板配置
* @param appId
* @param config * @param config
* @return * @return
*/ */
...@@ -49,6 +51,7 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo ...@@ -49,6 +51,7 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo
/** /**
* 根据仪表板id删除仪表板配置 * 根据仪表板id删除仪表板配置
* @param panelId * @param panelId
* @param publishedStatus
*/ */
void delConfig(@NotNull String panelId,Integer publishedStatus); void delConfig(@NotNull String panelId,Integer publishedStatus);
...@@ -65,4 +68,19 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo ...@@ -65,4 +68,19 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo
* @param ids * @param ids
*/ */
void publishConfigByPanelIds(List<String> ids); void publishConfigByPanelIds(List<String> ids);
/**
* 根据仪表板id以及状态获取仪表板配置
* @param panelId
* @param publishStatus
* @return
*/
List<InstrumentPanelConfig> getConfigByPanelIdAndPublishStatus(String panelId,Integer publishStatus);
/**
* 下线仪表盘配置
* @param panelId
* @param publishStatus
*/
void offlineConfig(String panelId, Integer publishStatus);
} }
...@@ -5,6 +5,7 @@ import com.syc.slm.slmbi.entity.InstrumentPanel; ...@@ -5,6 +5,7 @@ import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.entity.InstrumentPanelDraft; import com.syc.slm.slmbi.entity.InstrumentPanelDraft;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 仪表板草稿 * 仪表板草稿
...@@ -19,4 +20,29 @@ public interface InstrumentPanelDraftService extends IService<InstrumentPanelDra ...@@ -19,4 +20,29 @@ public interface InstrumentPanelDraftService extends IService<InstrumentPanelDra
* @param panels * @param panels
*/ */
void saveDrafts(List<InstrumentPanel> panels); void saveDrafts(List<InstrumentPanel> panels);
/**
* 根据仪表板id获取 仪表板草稿
* @param panelIds
* @return
*/
List<InstrumentPanelDraft> getByIds(Set<String> panelIds);
/**
* 获取仪表板信息
* @param appId
* @param panelIds
* @param officeIds
* @param userId
* @param roleId
* @return
*/
List<InstrumentPanelDraft> selectDraftList(String appId,Set<String> panelIds, String officeIds, String userId, String roleId);
/**
* 根据仪表板id获取 仪表板草稿
* @param panelId
* @return
*/
InstrumentPanelDraft getByPanelId(String panelId);
} }
...@@ -8,6 +8,7 @@ import com.syc.slm.slmbi.vo.PanelTreeNodeVo; ...@@ -8,6 +8,7 @@ import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import lombok.NonNull; import lombok.NonNull;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* slm-bi * slm-bi
...@@ -20,12 +21,15 @@ public interface InstrumentPanelGroupService extends IService<InstrumentPanelGro ...@@ -20,12 +21,15 @@ public interface InstrumentPanelGroupService extends IService<InstrumentPanelGro
/** /**
* 查询仪表板分组 * 查询仪表板分组
* @param appId
* @param name
* @return * @return
*/ */
List<InstrumentPanelGroupVo> selectGroupList(String appId,String name); List<InstrumentPanelGroupVo> selectGroupList(String appId, String name);
/** /**
* 删除仪表板分组 * 删除仪表板分组
*
* @param groupId * @param groupId
* @return * @return
*/ */
...@@ -34,29 +38,24 @@ public interface InstrumentPanelGroupService extends IService<InstrumentPanelGro ...@@ -34,29 +38,24 @@ public interface InstrumentPanelGroupService extends IService<InstrumentPanelGro
/** /**
* 修改仪表板分组 * 修改仪表板分组
* @param group * @param group
* @param appId
* @return * @return
*/ */
String updateGroup(@NonNull InstrumentPanelGroupDTO group); String updateGroup(@NonNull InstrumentPanelGroupDTO group,String appId);
/** /**
* 保存仪表板分组 * 保存仪表板分组
* @param group * @param group
* @param appId
* @return * @return
*/ */
String saveGroup(@NonNull InstrumentPanelGroupDTO group); String saveGroup(@NonNull InstrumentPanelGroupDTO group,String appId);
/**
* 加载仪表板树
* @param name
* @return
*/
List<PanelTreeNodeVo> loadTrees(String name);
/** /**
* 查询下一节点分组 * 根据分组id集合 已经名称批量查询仪表板分组
* @param groupId * @param finalPanelIds
* @param name * @param name
* @return * @return
*/ */
List<PanelTreeNodeVo> children(String groupId, String name); List<PanelTreeNodeVo> selectGroupByIds(Set<String> finalPanelIds,String name);
} }
...@@ -31,16 +31,16 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan ...@@ -31,16 +31,16 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan
* @param instrumentPanelId * @param instrumentPanelId
* @return * @return
*/ */
List<InstrumentPanelPermissionVo> saveCopyOtherPermission(@NonNull String instrumentPanelId); InstrumentPanelPermissionVo saveCopyOtherPermission(@NonNull String instrumentPanelId);
/** /**
* 将仪表板权限复制给其他仪表板 * 将仪表板权限复制给其他仪表板
* *
* @param permissions * @param permissions
* @param otherInstrumentPanelId * @param otherInstrumentPanelIds
* @return * @return
*/ */
String saveCopyToOtherPermission(InstrumentPanelPermissionDTO permissions, String otherInstrumentPanelId); void saveCopyToOtherPermission(InstrumentPanelPermissionDTO permissions, List<String> otherInstrumentPanelIds);
/** /**
* 根据仪表板id获取仪表板权限 * 根据仪表板id获取仪表板权限
...@@ -48,7 +48,7 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan ...@@ -48,7 +48,7 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan
* @param instrumentPanelId * @param instrumentPanelId
* @return * @return
*/ */
List<InstrumentPanelPermissionVo> selectPermissionByPanelId(@NonNull String instrumentPanelId); InstrumentPanelPermissionVo selectPermissionByPanelId(@NonNull String instrumentPanelId);
/** /**
* 根据仪表板id删除仪表板权限 * 根据仪表板id删除仪表板权限
...@@ -77,4 +77,18 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan ...@@ -77,4 +77,18 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan
* @param ids * @param ids
*/ */
void publishPermissionByPanelIds(List<String> ids); void publishPermissionByPanelIds(List<String> ids);
/**
* 根据仪表板id 以及 状态获取仪表板对应权限
* @param panelId
* @param publishStatus
* @return
*/
List<InstrumentPanelPermission> getPermissionByPanelIdAndPublishStatus(String panelId, Integer publishStatus);
/**
* 下线仪表板对应权限
* @param panelId
*/
void offlinePermission(String panelId);
} }
...@@ -7,6 +7,7 @@ import com.syc.slm.slmbi.dto.QueryInstrumentPanelDTO; ...@@ -7,6 +7,7 @@ import com.syc.slm.slmbi.dto.QueryInstrumentPanelDTO;
import com.syc.slm.slmbi.entity.InstrumentPanel; import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo; import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.InstrumentPanelVo; import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import lombok.NonNull; import lombok.NonNull;
import java.util.List; import java.util.List;
...@@ -98,4 +99,8 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> { ...@@ -98,4 +99,8 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param panelName * @param panelName
*/ */
void checkName(@NonNull String appId,String panelId,@NonNull String panelName); void checkName(@NonNull String appId,String panelId,@NonNull String panelName);
List<InstrumentPanel> getByIds(Set<String> panelIds);
List<PanelTreeNodeVo> selectPanelByIds(Set<String> finalPanelIds,String name);
} }
...@@ -2,9 +2,8 @@ package com.syc.slm.slmbi.service; ...@@ -2,9 +2,8 @@ package com.syc.slm.slmbi.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.syc.slm.slmbi.dto.InstrumentPanelAssemblyDTO; import com.syc.slm.slmbi.dto.InstrumentPanelAssemblyDTO;
import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.entity.InstrumentPanelTree; import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import lombok.NonNull; import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -58,4 +57,51 @@ public interface InstrumentPanelTreeService extends IService<InstrumentPanelTree ...@@ -58,4 +57,51 @@ public interface InstrumentPanelTreeService extends IService<InstrumentPanelTree
* @param groupId * @param groupId
*/ */
void updatePanelTreeFullName(String panelId,String panelName,String groupId) ; void updatePanelTreeFullName(String panelId,String panelName,String groupId) ;
/**
* 加载树
* @param appId
* @param name
* @return
*/
List<PanelTreeNodeVo> loadTrees(String appId, String name);
/**
* 加载树
* @param appId
* @return
*/
List<PanelTreeNodeVo> loadTrees(String appId);
/**
* 加载树节点下一节点
* @param groupId
* @param name
* @return
*/
List<PanelTreeNodeVo> children(String groupId, String name);
/**
* 根据仪表板分组id更新 fullId fullName
* @param groupId
* @param panelId
* @param panelName
*/
void updateFullNameByGroupId(String groupId, String panelId, String panelName);
/**
* 复制仪表板配置显示的仪表板树
* @param appId
* @param name
* @return
*/
List<PanelTreeNodeVo> copyTreeList(String appId,String name);
/**
* 复用仪表板树
* @param appId
* @param name
* @return
*/
List<PanelTreeNodeVo> citeTreeList(String appId, String name);
} }
...@@ -21,12 +21,15 @@ import org.springframework.beans.BeanUtils; ...@@ -21,12 +21,15 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.events.Event;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -63,7 +66,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -63,7 +66,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public InstrumentPanelConfigVo getConfigByPanelId(String instrumentPanelId) { public InstrumentPanelConfigVo getConfigByPanelId(String instrumentPanelId) {
InstrumentPanelDraft draft = draftService.getById(instrumentPanelId); InstrumentPanelDraft draft = draftService.getByPanelId(instrumentPanelId);
return getInstrumentPanelConfigVo(instrumentPanelId, return getInstrumentPanelConfigVo(instrumentPanelId,
ObjectUtils.isNotEmpty(draft) ? PublishedStatus.PUBLISHED : ObjectUtils.isNotEmpty(draft) ? PublishedStatus.PUBLISHED :
PublishedStatus.WAIT_PUBLISHED); PublishedStatus.WAIT_PUBLISHED);
...@@ -92,7 +95,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -92,7 +95,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
log.info("更新仪表板树"); log.info("更新仪表板树");
updateTree(config, panel); updateTree(config, panel);
InstrumentPanelDraft draft = draftService.getById(panel.getId()); InstrumentPanelDraft draft = draftService.getByPanelId(panel.getId());
if (ObjectUtils.isNotEmpty(draft)) { if (ObjectUtils.isNotEmpty(draft)) {
BeanUtils.copyProperties(panel, draft); BeanUtils.copyProperties(panel, draft);
draftService.updateById(draft); draftService.updateById(draft);
...@@ -115,7 +118,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -115,7 +118,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
fillPanelProp(permission, panel); fillPanelProp(permission, panel);
//判断是否有发布版本 //判断是否有发布版本
InstrumentPanelDraft draft = draftService.getById(panel.getId()); InstrumentPanelDraft draft = draftService.getByPanelId(panel.getId());
if (ObjectUtils.isNotEmpty(draft)) { if (ObjectUtils.isNotEmpty(draft)) {
log.info("保存配置详情"); log.info("保存配置详情");
savePanelConfig(panel.getId(), config.getConfigDetails(), PublishedStatus.WAIT_PUBLISHED.value); savePanelConfig(panel.getId(), config.getConfigDetails(), PublishedStatus.WAIT_PUBLISHED.value);
...@@ -164,13 +167,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -164,13 +167,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
@Override @Override
public void delConfig(@NotNull String panelId, Integer publishedStatus) { public void delConfig(@NotNull String panelId, Integer publishedStatus) {
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>(); List<InstrumentPanelConfig> configs = getConfigByPanelIdAndPublishStatus(panelId,publishedStatus);
where.eq(InstrumentPanelConfig::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, panelId);
if (publishedStatus != null) {
where.eq(InstrumentPanelConfig::getPublished, publishedStatus);
}
List<InstrumentPanelConfig> configs = baseMapper.selectList(where);
if (CollectionUtils.isNotEmpty(configs)) { if (CollectionUtils.isNotEmpty(configs)) {
configs.forEach(x -> { configs.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED); x.setRecordStatus(SlmConstants.DATA_DELETED);
...@@ -201,20 +198,17 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -201,20 +198,17 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
where.in(InstrumentPanelConfig::getPanelId, ids); where.in(InstrumentPanelConfig::getPanelId, ids);
List<InstrumentPanelConfig> configs = baseMapper.selectList(where); List<InstrumentPanelConfig> configs = baseMapper.selectList(where);
if (CollectionUtils.isNotEmpty(configs)) { if (CollectionUtils.isNotEmpty(configs)) {
List<InstrumentPanelConfig> waitPublishConfigs = Map<String, List<InstrumentPanelConfig>> configMaps = configs.stream().collect(Collectors.groupingBy(InstrumentPanelConfig::getPanelId));
configs.stream().filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished())).collect( if(CollectionUtils.isNotEmpty(configMaps)){
Collectors.toList()); configMaps.forEach((k,v)->{
if (CollectionUtils.isNotEmpty(waitPublishConfigs)) { List<InstrumentPanelConfig> waitPublishConfigs = configs.stream().filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList());
List<InstrumentPanelConfig> publishConfigs = configs.stream().filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(waitPublishConfigs)){
waitPublishConfigs.forEach(x -> { waitPublishConfigs.forEach(x -> {
x.setPublished(PublishedStatus.PUBLISHED.value); x.setPublished(PublishedStatus.PUBLISHED.value);
baseMapper.updateById(x); baseMapper.updateById(x);
}); });
} if(CollectionUtils.isNotEmpty(publishConfigs)){
List<InstrumentPanelConfig> publishConfigs =
configs.stream().filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished())).collect(
Collectors.toList());
if (CollectionUtils.isNotEmpty(publishConfigs)) {
publishConfigs.forEach(x -> { publishConfigs.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED); x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x); baseMapper.updateById(x);
...@@ -222,6 +216,56 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -222,6 +216,56 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
} }
} }
});
}
}
}
@Override
@Transactional(readOnly = true)
public List<InstrumentPanelConfig> getConfigByPanelIdAndPublishStatus(String panelId, Integer publishStatus) {
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, panelId);
if(publishStatus!=null) {
where.eq(InstrumentPanelConfig::getPublished, publishStatus);
}
return baseMapper.selectList(where);
}
@Override
public void offlineConfig(String panelId, Integer publishStatus) {
List<InstrumentPanelConfig> configs = getConfigByPanelIdAndPublishStatus(panelId, publishStatus);
InstrumentPanelConfig waitConfig = configs.stream()
.filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished()))
.findFirst()
.orElse(null);
if(ObjectUtils.isNotEmpty(waitConfig)){
InstrumentPanelConfig publishConfig =
configs.stream().filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished())).findFirst().orElse(null);
if(ObjectUtils.isNotEmpty(publishConfig)){
publishConfig.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(publishConfig);
}
}else{
InstrumentPanelConfig pushConfig = configs.stream()
.filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished()))
.findFirst()
.orElse(null);
if(ObjectUtils.isNotEmpty(pushConfig)){
InstrumentPanelConfig config = new InstrumentPanelConfig();
BeanUtils.copyProperties(pushConfig,config);
config.setPublished(PublishedStatus.WAIT_PUBLISHED.value);
config.setId(IdWorker.get32UUID());
baseMapper.insert(config);
pushConfig.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(pushConfig);
}
}
} }
private InstrumentPanelConfigVo getInstrumentPanelConfigVo(String instrumentPanelId, PublishedStatus published) { private InstrumentPanelConfigVo getInstrumentPanelConfigVo(String instrumentPanelId, PublishedStatus published) {
......
package com.syc.slm.slmbi.service.impl; package com.syc.slm.slmbi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.syc.slm.common.core.constant.SlmConstants; import com.syc.slm.common.core.constant.SlmConstants;
...@@ -13,6 +16,7 @@ import com.syc.slm.slmbi.service.InstrumentPanelDraftService; ...@@ -13,6 +16,7 @@ import com.syc.slm.slmbi.service.InstrumentPanelDraftService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -28,21 +32,47 @@ public class InstrumentPanelDraftServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -28,21 +32,47 @@ public class InstrumentPanelDraftServiceImpl extends ServiceImpl<InstrumentPanel
@Override @Override
public void saveDrafts(List<InstrumentPanel> panels) { public void saveDrafts(List<InstrumentPanel> panels) {
if(CollectionUtils.isNotEmpty(panels)){ if (CollectionUtils.isNotEmpty(panels)) {
List<InstrumentPanelDraft> drafts= SlmConstants.gson.fromJson(SlmConstants.gson.toJson(panels), List<InstrumentPanelDraft> drafts = SlmConstants.gson.fromJson(SlmConstants.gson.toJson(panels), new TypeToken<List<InstrumentPanelDraft>>() {
new TypeToken<List<InstrumentPanelDraft>>() {
}.getType()); }.getType());
List<InstrumentPanelDraft> panelDrafts = baseMapper.selectBatchIds(panels.stream() if (CollectionUtils.isNotEmpty(drafts)) {
.map(InstrumentPanel::getId) List<InstrumentPanelDraft> panelDrafts = getByIds(panels.stream().map(InstrumentPanel::getId).collect(Collectors.toSet()));
.collect(Collectors.toList())); Map<String, String> maps = CollectionUtils.isNotEmpty(panelDrafts) ? panelDrafts.stream().collect(
Set<String> idSets= CollectionUtils.isNotEmpty(panelDrafts)?panelDrafts.stream().map(BaseEntity::getId).collect(Collectors.toSet()): Sets.newHashSet(); Collectors.toMap(InstrumentPanelDraft::getPanelId, BaseEntity::getId)) : Maps.newHashMap();
drafts.forEach(x->{ drafts.forEach(x -> {
if(idSets.contains(x.getId())){ x.setPanelId(x.getId());
if (maps.containsKey(x.getId())) {
x.setId(maps.get(x.getId()));
baseMapper.updateById(x); baseMapper.updateById(x);
}else{ } else {
x.setId(IdWorker.get32UUID());
baseMapper.insert(x); baseMapper.insert(x);
} }
}); });
} }
} }
}
@Override
public List<InstrumentPanelDraft> getByIds(Set<String> panelIds) {
LambdaQueryWrapper<InstrumentPanelDraft> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.in(InstrumentPanelDraft::getPanelId, panelIds);
return baseMapper.selectList(where);
}
@Override
public List<InstrumentPanelDraft> selectDraftList(String appId,
Set<String> panelIds,
String officeIds,
String userId,
String roleId) {
return baseMapper.selectDraftList(appId, panelIds, officeIds, userId, roleId);
}
@Override
public InstrumentPanelDraft getByPanelId(String panelId) {
List<InstrumentPanelDraft> drafts = getByIds(Sets.newHashSet(panelId));
return CollectionUtils.isNotEmpty(drafts)?drafts.get(0):null;
}
} }
...@@ -13,6 +13,7 @@ import com.syc.slm.slmbi.entity.InstrumentPanelGroup; ...@@ -13,6 +13,7 @@ import com.syc.slm.slmbi.entity.InstrumentPanelGroup;
import com.syc.slm.slmbi.entity.InstrumentPanelTree; import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import com.syc.slm.slmbi.enums.NodeType; import com.syc.slm.slmbi.enums.NodeType;
import com.syc.slm.slmbi.exception.SysException; import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.function.Action2;
import com.syc.slm.slmbi.service.InstrumentPanelGroupService; import com.syc.slm.slmbi.service.InstrumentPanelGroupService;
import com.syc.slm.slmbi.service.InstrumentPanelService; import com.syc.slm.slmbi.service.InstrumentPanelService;
import com.syc.slm.slmbi.service.InstrumentPanelTreeService; import com.syc.slm.slmbi.service.InstrumentPanelTreeService;
...@@ -93,49 +94,50 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -93,49 +94,50 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel
tree.setRecordStatus(SlmConstants.DATA_DELETED); tree.setRecordStatus(SlmConstants.DATA_DELETED);
treeService.updateById(tree); treeService.updateById(tree);
log.info("查询该仪表板树下的子节点"); log.info("查询该仪表板树下的子节点");
List<InstrumentPanelTree> instrumentPanelTrees = getInstrumentPanelTrees.apply(tree.getFullId()); List<InstrumentPanelTree> children = getInstrumentPanelTrees.apply(tree.getFullId());
if (CollectionUtils.isNotEmpty(instrumentPanelTrees)) { if (CollectionUtils.isNotEmpty(children)) {
Set<String> treeIds = instrumentPanelTrees.stream().map(BaseEntity::getId).collect(Collectors.toSet()); Set<String> childrenIds = children.stream().map(BaseEntity::getId).collect(Collectors.toSet());
log.info("删除该仪表板树下的子节点"); log.info("删除该仪表板树下的子节点");
treeService.batchUpdateTreeByIds(treeIds, SlmConstants.DATA_DELETED); treeService.batchUpdateTreeByIds(childrenIds, SlmConstants.DATA_DELETED);
log.info("删除子分组"); log.info("删除子分组");
delChildrenGroups.accept(instrumentPanelTrees); delChildrenGroups.accept(children);
log.info("删除各个分组下的仪表板"); log.info("删除各个分组下的仪表板");
delPanelByIds.accept(instrumentPanelTrees); delPanelByIds.accept(children);
} }
return groupId; return groupId;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String updateGroup(@NonNull InstrumentPanelGroupDTO group) { public String updateGroup(@NonNull InstrumentPanelGroupDTO group,String appId) {
if(StringUtils.isEmpty(group.getName())){ if(StringUtils.isEmpty(group.getName())){
throw new SysException("仪表板分组名称必填"); throw new SysException("仪表板分组名称必填");
} }
log.info("检查分组名字是否重复"); log.info("检查分组名字是否重复");
checkedRepeatName.accept(group); checkedRepeatName.call(group,appId);
InstrumentPanelGroup instrumentPanelGroup = new InstrumentPanelGroup(); InstrumentPanelGroup entity = new InstrumentPanelGroup();
BeanUtils.copyProperties(group, instrumentPanelGroup); BeanUtils.copyProperties(group, entity);
baseMapper.updateById(instrumentPanelGroup); baseMapper.updateById(entity);
log.info("更新分组在仪表盘树中的全路径"); log.info("更新分组在仪表盘树中的全路径");
InstrumentPanelTree tree = treeService.getById(instrumentPanelGroup.getId()); InstrumentPanelTree tree = treeService.getById(entity.getId());
String beforeFullName = tree.getFullName(); String beforeFullName = tree.getFullName();
String beforeFullId = tree.getFullId(); String beforeFullId = tree.getFullId();
InstrumentPanelTree panelTree = treeService.getById(group.getParentId()); InstrumentPanelTree panelTree = treeService.getById(group.getParentId());
tree.setFullName(panelTree.getFullName() + "." + instrumentPanelGroup.getName()); tree.setFullName(panelTree.getFullName() + "." + entity.getName());
tree.setFullId(panelTree.getFullId() + "." + instrumentPanelGroup.getId()); tree.setFullId(panelTree.getFullId() + "." + entity.getId());
tree.setName(entity.getName());
treeService.updateById(tree); treeService.updateById(tree);
log.info("重新构建该分组下的仪表板树全路径"); log.info("重新构建该分组下的仪表板树全路径");
List<InstrumentPanelTree> instrumentPanelTrees = getInstrumentPanelTrees.apply(beforeFullId); List<InstrumentPanelTree> children = getInstrumentPanelTrees.apply(beforeFullId);
instrumentPanelTrees.forEach(x -> { children.forEach(x -> {
x.setFullId(x.getFullId().replace(beforeFullId, tree.getFullId())); x.setFullId(x.getFullId().replace(beforeFullId, tree.getFullId()));
x.setFullName(tree.getFullName()+"." + x.getFullName() x.setFullName(tree.getFullName()+"." + x.getFullName()
.substring(x.getFullName().lastIndexOf(beforeFullName))); .substring(beforeFullName.length()+1));
treeService.updateById(x); treeService.updateById(x);
}); });
...@@ -144,52 +146,49 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -144,52 +146,49 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String saveGroup(@NonNull InstrumentPanelGroupDTO group) { public String saveGroup(@NonNull InstrumentPanelGroupDTO group,String appId) {
if(StringUtils.isEmpty(group.getName())){ if(StringUtils.isEmpty(group.getName())){
throw new SysException("仪表板分组名称必填"); throw new SysException("仪表板分组名称必填");
} }
log.info("校验名字是否重复"); log.info("校验名字是否重复");
checkedRepeatName.accept(group); checkedRepeatName.call(group,appId);
log.info("新增仪表板分组"); log.info("新增仪表板分组");
InstrumentPanelGroup instrumentPanelGroup = new InstrumentPanelGroup(); InstrumentPanelGroup entity = new InstrumentPanelGroup();
BeanUtils.copyProperties(group, instrumentPanelGroup); BeanUtils.copyProperties(group, entity);
instrumentPanelGroup.setId(IdWorker.get32UUID()); entity.setId(IdWorker.get32UUID());
baseMapper.insert(instrumentPanelGroup); baseMapper.insert(entity);
log.info("构建仪表板树 聚合表"); log.info("构建仪表板树 聚合表");
InstrumentPanelTree tree = new InstrumentPanelTree(); InstrumentPanelTree tree = new InstrumentPanelTree();
tree.setId(instrumentPanelGroup.getId()); tree.setId(entity.getId());
if (StringUtils.isNotEmpty(group.getParentId())) { if (StringUtils.isNotEmpty(group.getParentId())) {
InstrumentPanelTree panelTree = treeService.getById(group.getParentId()); InstrumentPanelTree panelTree = treeService.getById(group.getParentId());
if (SlmConstants.DATA_DELETED.equals(panelTree.getRecordStatus())) { if (SlmConstants.DATA_DELETED.equals(panelTree.getRecordStatus())) {
throw new SysException(panelTree.getFullName().substring(group.getParentId().lastIndexOf(".") + 1) throw new SysException(panelTree.getName() + ",已不存在,请刷新页面");
+ ",已不存在,请刷新页面");
} }
tree.setFullId(panelTree.getFullId() + "." + instrumentPanelGroup.getId()); tree.setFullId(panelTree.getFullId() + "." + entity.getId());
tree.setFullName(panelTree.getFullName() + "." + instrumentPanelGroup.getName()); tree.setFullName(panelTree.getFullName() + "." + entity.getName());
} else { } else {
//顶级分组 //顶级分组
log.info("重新构建该分组下的仪表板树全路径"); log.info("重新构建该分组下的仪表板树全路径");
tree.setFullId(instrumentPanelGroup.getId()); tree.setFullId(entity.getId());
tree.setFullName(instrumentPanelGroup.getName()); tree.setFullName(entity.getName());
} }
tree.setNodeType(NodeType.GROUP.value); tree.setNodeType(NodeType.GROUP.value);
tree.setName(entity.getName());
treeService.save(tree); treeService.save(tree);
return instrumentPanelGroup.getId(); return entity.getId();
} }
@Override @Override
public List<PanelTreeNodeVo> loadTrees(String name) { public List<PanelTreeNodeVo> selectGroupByIds(Set<String> finalPanelIds,String name) {
return null; return baseMapper.selectGroupByIds(finalPanelIds,name);
} }
@Override private Action2<InstrumentPanelGroupDTO,String> checkedRepeatName=(group,appId)-> {
public List<PanelTreeNodeVo> children(String groupId, String name) {
return null;
}
private Consumer<InstrumentPanelGroupDTO> checkedRepeatName = (group) -> {
LambdaQueryWrapper<InstrumentPanelGroup> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstrumentPanelGroup> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(InstrumentPanelGroup::getName, group.getName()); wrapper.eq(InstrumentPanelGroup::getName, group.getName());
wrapper.eq(BaseEntity::getAppId, appId);
wrapper.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
if (StringUtils.isNotEmpty(group.getId())) { if (StringUtils.isNotEmpty(group.getId())) {
wrapper.ne(InstrumentPanelGroup::getId, group.getId()); wrapper.ne(InstrumentPanelGroup::getId, group.getId());
} }
...@@ -198,8 +197,9 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -198,8 +197,9 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel
} }
}; };
private Consumer<List<InstrumentPanelTree>> delChildrenGroups = (instrumentPanelTrees) -> {
Set<String> groupIds = instrumentPanelTrees.stream() private Consumer<List<InstrumentPanelTree>> delChildrenGroups = (trees) -> {
Set<String> groupIds = trees.stream()
.filter(x -> NodeType.GROUP.value.equals(x.getNodeType())) .filter(x -> NodeType.GROUP.value.equals(x.getNodeType()))
.map(BaseEntity::getId) .map(BaseEntity::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
...@@ -210,12 +210,14 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -210,12 +210,14 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel
} }
}; };
private Consumer<List<InstrumentPanelTree>> delPanelByIds = (instrumentPanelTrees) -> { private Consumer<List<InstrumentPanelTree>> delPanelByIds = (trees) -> {
Set<String> panelIds = instrumentPanelTrees.stream() Set<String> panelIds = trees.stream()
.filter(x -> NodeType.PANEL.value.equals(x.getNodeType())) .filter(x -> NodeType.PANEL.value.equals(x.getNodeType()))
.map(BaseEntity::getId) .map(BaseEntity::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if(CollectionUtils.isNotEmpty(panelIds)) {
panelService.batchUpdatePanelByIds(panelIds, SlmConstants.DATA_DELETED); panelService.batchUpdatePanelByIds(panelIds, SlmConstants.DATA_DELETED);
}
}; };
private Function<String, List<InstrumentPanelTree>> getInstrumentPanelTrees = (fullId) -> { private Function<String, List<InstrumentPanelTree>> getInstrumentPanelTrees = (fullId) -> {
......
...@@ -3,23 +3,35 @@ package com.syc.slm.slmbi.service.impl; ...@@ -3,23 +3,35 @@ package com.syc.slm.slmbi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Sets;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.syc.slm.common.core.constant.SlmConstants; import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelPermissionMapper; import com.syc.slm.slmbi.dao.InstrumentPanelPermissionMapper;
import com.syc.slm.slmbi.dto.CustomPermissionDTO; import com.syc.slm.slmbi.dto.CustomPermissionDTO;
import com.syc.slm.slmbi.dto.InstrumentPanelPermissionDTO; import com.syc.slm.slmbi.dto.InstrumentPanelPermissionDTO;
import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.entity.InstrumentPanelConfig;
import com.syc.slm.slmbi.entity.InstrumentPanelPermission; import com.syc.slm.slmbi.entity.InstrumentPanelPermission;
import com.syc.slm.slmbi.enums.AccessType; import com.syc.slm.slmbi.enums.AccessType;
import com.syc.slm.slmbi.enums.PublishedStatus; import com.syc.slm.slmbi.enums.PublishedStatus;
import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.InstrumentPanelPermissionService; import com.syc.slm.slmbi.service.InstrumentPanelPermissionService;
import com.syc.slm.slmbi.service.InstrumentPanelService;
import com.syc.slm.slmbi.service.InstrumentPanelTreeService;
import com.syc.slm.slmbi.vo.CustomPermissionVo; import com.syc.slm.slmbi.vo.CustomPermissionVo;
import com.syc.slm.slmbi.vo.InstrumentPanelPermissionVo; import com.syc.slm.slmbi.vo.InstrumentPanelPermissionVo;
import lombok.NonNull; import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -30,42 +42,91 @@ import java.util.stream.Collectors; ...@@ -30,42 +42,91 @@ import java.util.stream.Collectors;
* @date : 2021-03-25 19:04 * @date : 2021-03-25 19:04
**/ **/
@Service @Service
@Slf4j
public class InstrumentPanelPermissionImpl public class InstrumentPanelPermissionImpl
extends ServiceImpl<InstrumentPanelPermissionMapper, InstrumentPanelPermission> extends ServiceImpl<InstrumentPanelPermissionMapper, InstrumentPanelPermission>
implements InstrumentPanelPermissionService { implements InstrumentPanelPermissionService {
@Autowired
private InstrumentPanelService panelService;
@Autowired
private InstrumentPanelTreeService treeService;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public String savePermission(InstrumentPanelPermissionDTO permissions) { public String savePermission(InstrumentPanelPermissionDTO permissions) {
//判断仪表板的名称是否重复 log.info("判断仪表板的名称是否重复");
//删除原本的权限 if (StringUtils.isBlank(permissions.getPanelName())) {
//插入现有的权限 throw new SysException("仪表板名称必填");
//更新仪表板的名称跟分组
return null;
} }
if (StringUtils.isBlank(permissions.getPanelId())) {
throw new SysException("仪表板id必填,请联系管理员");
}
if (StringUtils.isBlank(permissions.getGroupId())) {
throw new SysException("仪表板groupId必填,请联系管理员");
}
InstrumentPanel panel = panelService.getById(permissions.getPanelId());
panel.setName(permissions.getPanelName());
panel.setGroupId(permissions.getGroupId());
permissions.setAccessType(permissions.getAccessType());
@Override log.info("删除原本的权限");
public List<InstrumentPanelPermissionVo> saveCopyOtherPermission(@NonNull String instrumentPanelId) { delPermissionByPanelId(permissions.getPanelId(), PublishedStatus.WAIT_PUBLISHED.value);
return null; savePanelPermission(permissions.getCustomPermissions(),permissions.getPanelId(),permissions.getAccessType(),PublishedStatus.WAIT_PUBLISHED.value);
log.info("更新仪表板的名称跟分组");
treeService.updateFullNameByGroupId(permissions.getGroupId(),permissions.getPanelId(),permissions.getPanelName());
panelService.updateById(panel);
return permissions.getPanelId();
} }
@Override @Override
public String saveCopyToOtherPermission(InstrumentPanelPermissionDTO permissions, String otherInstrumentPanelId) { public InstrumentPanelPermissionVo saveCopyOtherPermission(@NonNull String instrumentPanelId) {
return null; return selectPermissionByPanelId(instrumentPanelId);
} }
@Override @Override
public List<InstrumentPanelPermissionVo> selectPermissionByPanelId(@NonNull String instrumentPanelId) { @Transactional(rollbackFor = Exception.class)
return null; public void saveCopyToOtherPermission(InstrumentPanelPermissionDTO permissions, List<String> otherInstrumentPanelIds) {
if(CollectionUtils.isEmpty(otherInstrumentPanelIds)){
throw new SysException("其他仪表板id必填,请联系管理员");
}
if(StringUtils.isBlank(permissions.getAccessType())){
throw new SysException("访问权限类型必填");
}
List<InstrumentPanel> panels = panelService.getByIds(Sets.newHashSet(otherInstrumentPanelIds));
panels.forEach(panel->{
panel.setAccessPermission(permissions.getAccessType());
log.info("删除原本的权限");
delPermissionByPanelId(permissions.getPanelId(), PublishedStatus.WAIT_PUBLISHED.value);
log.info("插入现有的权限");
savePanelPermission(permissions.getCustomPermissions(), panel.getId(), panel.getAccessPermission(), PublishedStatus.WAIT_PUBLISHED.value);
log.info("更新访问权限");
panelService.updateById(panel);
});
} }
@Override @Override
public void delPermissionByPanelId(@NonNull String panelId,Integer publishStatus) { @Transactional(readOnly = true)
LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>(); public InstrumentPanelPermissionVo selectPermissionByPanelId(@NonNull String instrumentPanelId) {
where.eq(InstrumentPanelPermission::getPanelId, panelId); InstrumentPanelPermissionVo vo = new InstrumentPanelPermissionVo();
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID); InstrumentPanel panel = panelService.getById(instrumentPanelId);
if(publishStatus!=null){ vo.setAccessType(panel.getAccessPermission());
where.eq(InstrumentPanelPermission::getPublished, publishStatus); List<CustomPermissionVo> vos = getPublishPermissionByPanelId(instrumentPanelId, PublishedStatus.WAIT_PUBLISHED.value);
if(CollectionUtils.isEmpty(vos)){
vos = getPublishPermissionByPanelId(instrumentPanelId, PublishedStatus.PUBLISHED.value);
} }
List<InstrumentPanelPermission> permissions = baseMapper.selectList(where); vo.setCustomPermissions(vos);
return vo;
}
@Override
public void delPermissionByPanelId(@NonNull String panelId, Integer publishStatus) {
List<InstrumentPanelPermission> permissions =getPermissionByPanelIdAndPublishStatus(panelId,publishStatus);
if (CollectionUtils.isNotEmpty(permissions)) { if (CollectionUtils.isNotEmpty(permissions)) {
permissions.forEach(x -> { permissions.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED); x.setRecordStatus(SlmConstants.DATA_DELETED);
...@@ -76,21 +137,18 @@ public class InstrumentPanelPermissionImpl ...@@ -76,21 +137,18 @@ public class InstrumentPanelPermissionImpl
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId,@NonNull Integer publishStatus) { public List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId,
LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>(); @NonNull Integer publishStatus) {
where.eq(InstrumentPanelPermission::getPanelId, panelId); List<InstrumentPanelPermission> permissions = getPermissionByPanelIdAndPublishStatus(panelId,publishStatus);
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID); return CollectionUtils.isNotEmpty(permissions) ? SlmConstants.gson.fromJson(SlmConstants.gson.toJson(permissions), new TypeToken<List<CustomPermissionVo>>() {}.getType()) : null;
where.eq(InstrumentPanelPermission::getPublished, publishStatus);
List<InstrumentPanelPermission> permissions = baseMapper.selectList(where);
return CollectionUtils.isNotEmpty(permissions) ?
SlmConstants.gson.fromJson(SlmConstants.gson.toJson(permissions),
new TypeToken<List<CustomPermissionVo>>() {
}.getType()) : null;
} }
@Override @Override
public void savePanelPermission(List<CustomPermissionDTO> customPermissions,String panelId,String accessType,Integer publishStatus) { public void savePanelPermission(List<CustomPermissionDTO> customPermissions,
if(CollectionUtils.isNotEmpty(customPermissions)){ String panelId,
String accessType,
Integer publishStatus) {
if (CollectionUtils.isNotEmpty(customPermissions)) {
if (AccessType.CUSTOM.value.equals(accessType)) { if (AccessType.CUSTOM.value.equals(accessType)) {
if (CollectionUtils.isNotEmpty(customPermissions)) { if (CollectionUtils.isNotEmpty(customPermissions)) {
customPermissions.forEach(x -> { customPermissions.forEach(x -> {
...@@ -114,22 +172,64 @@ public class InstrumentPanelPermissionImpl ...@@ -114,22 +172,64 @@ public class InstrumentPanelPermissionImpl
where.in(InstrumentPanelPermission::getPanelId, ids); where.in(InstrumentPanelPermission::getPanelId, ids);
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID); where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID);
List<InstrumentPanelPermission> permissions = baseMapper.selectList(where); List<InstrumentPanelPermission> permissions = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(permissions)){ Map<String, List<InstrumentPanelPermission>> permissionMaps = permissions.stream().collect(Collectors.groupingBy(InstrumentPanelPermission::getPanelId));
List<InstrumentPanelPermission> waitPublishPermission = if(CollectionUtils.isNotEmpty(permissionMaps)){
permissions.stream().filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList()); permissionMaps.forEach((k,v)->{
if(CollectionUtils.isNotEmpty(waitPublishPermission)){ List<InstrumentPanelPermission> waitings = permissions.stream().filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList());
waitPublishPermission.forEach(x->{ List<InstrumentPanelPermission> publishs = permissions.stream().filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(waitings)) {
waitings.forEach(x -> {
x.setPublished(PublishedStatus.PUBLISHED.value); x.setPublished(PublishedStatus.PUBLISHED.value);
baseMapper.updateById(x); baseMapper.updateById(x);
}); });
if (CollectionUtils.isNotEmpty(publishs)) {
publishs.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x);
});
}
} }
List<InstrumentPanelPermission> publishPermission = });
permissions.stream().filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList()); }
if(CollectionUtils.isNotEmpty(publishPermission)){
publishPermission.forEach(x->{ }
@Override
public List<InstrumentPanelPermission> getPermissionByPanelIdAndPublishStatus(String panelId, Integer publishStatus) {
LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>();
where.eq(InstrumentPanelPermission::getPanelId, panelId);
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID);
if(publishStatus!=null) {
where.eq(InstrumentPanelPermission::getPublished, publishStatus);
}
return baseMapper.selectList(where);
}
@Override
public void offlinePermission(String panelId) {
List<InstrumentPanelPermission> permissions = getPermissionByPanelIdAndPublishStatus(panelId,null);
long waitP = permissions.stream().filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished())).count();
List<InstrumentPanelPermission> publish = permissions.stream().filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished())).collect(Collectors.toList());
if(waitP>0){
if(CollectionUtils.isNotEmpty(publish)){
publish.forEach(x->{
x.setRecordStatus(SlmConstants.DATA_DELETED); x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x); baseMapper.updateById(x);
}); });
}
}else{
if(CollectionUtils.isNotEmpty(publish)){
publish.forEach(push->{
InstrumentPanelPermission p = new InstrumentPanelPermission();
BeanUtils.copyProperties(push, p);
p.setPublished(PublishedStatus.WAIT_PUBLISHED.value);
p.setId(IdWorker.get32UUID());
baseMapper.insert(p);
push.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(push);
});
} }
} }
} }
......
...@@ -22,6 +22,7 @@ import com.syc.slm.slmbi.exception.SysException; ...@@ -22,6 +22,7 @@ import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.*; import com.syc.slm.slmbi.service.*;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo; import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.InstrumentPanelVo; import com.syc.slm.slmbi.vo.InstrumentPanelVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import lombok.NonNull; import lombok.NonNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -57,31 +58,31 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -57,31 +58,31 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public IPage<InstrumentPanelVo> selectInstrumentPanelList(String appId, QueryInstrumentPanelDTO where) { public IPage<InstrumentPanelVo> selectInstrumentPanelList(String appId, QueryInstrumentPanelDTO query) {
IPage<InstrumentPanelVo> page = new Page<>(where.getPageNum(), where.getPageSize()); IPage<InstrumentPanelVo> page = new Page<>(query.getCurrent(), query.getSize());
QueryWrapper<InstrumentPanel> wrapper = new QueryWrapper<>(); QueryWrapper<InstrumentPanel> where = new QueryWrapper<>();
wrapper.eq("p.app_id", appId); where.eq("p.app_id", appId);
wrapper.eq("p.group_id", where.getGroupId()); where.eq("p.group_id", query.getGroupId());
wrapper.eq("p.record_status", SlmConstants.DATA_VALID); where.eq("p.record_status", SlmConstants.DATA_VALID);
if (StringUtils.isNotEmpty(where.getName())) { if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like("p.name", where.getName()); where.like("p.name", query.getName());
} }
if (StringUtils.isNotEmpty(where.getCreatorName())) { if (StringUtils.isNotEmpty(query.getCreatorName())) {
wrapper.like("p.creator_name", where.getCreatorName()); where.like("p.creator_name", query.getCreatorName());
} }
if (StringUtils.isNotEmpty(where.getUpdaterName())) { if (StringUtils.isNotEmpty(query.getUpdaterName())) {
wrapper.like("p.updater_name", where.getUpdaterName()); where.like("p.updater_name", query.getUpdaterName());
} }
if (where.getPublished() != null) { if (query.getPublished() != null) {
wrapper.eq("p.published", where.getPublished()); where.eq("p.published", query.getPublished());
} }
if (where.getUpdateTimeBegin() != null) { if (query.getUpdateTimeBegin() != null) {
wrapper.gt("p.update_time", where.getUpdateTimeBegin()); where.ge("p.update_time", query.getUpdateTimeBegin());
} }
if (where.getUpdateTimeEnd() != null) { if (query.getUpdateTimeEnd() != null) {
wrapper.lt("p.update_time", where.getUpdateTimeEnd()); where.le("p.update_time", query.getUpdateTimeEnd());
} }
return baseMapper.selectInstrumentPanelList(page, wrapper); return baseMapper.selectInstrumentPanelList(page, where);
} }
@Override @Override
...@@ -129,9 +130,8 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -129,9 +130,8 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
log.info("删除该仪表板下的配置"); log.info("删除该仪表板下的配置");
delAllSetting(id); delAllSetting(id);
log.info("删除仪表板草稿表"); log.info("删除仪表板草稿表");
InstrumentPanelDraft draft = new InstrumentPanelDraft(); InstrumentPanelDraft draft =draftService.getByPanelId(id);
draft.setRecordStatus(SlmConstants.DATA_DELETED); draft.setRecordStatus(SlmConstants.DATA_DELETED);
draft.setId(id);
draftService.updateById(draft); draftService.updateById(draft);
return id; return id;
} }
...@@ -146,7 +146,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -146,7 +146,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Boolean showRecoveryBtn(String id) { public Boolean showRecoveryBtn(String id) {
return draftService.getById(id) != null; return draftService.getByPanelId(id) != null;
} }
@Override @Override
...@@ -168,14 +168,22 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -168,14 +168,22 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
if (SlmConstants.DATA_DELETED.equals(panel.getRecordStatus())) { if (SlmConstants.DATA_DELETED.equals(panel.getRecordStatus())) {
throw new SysException("该数据已被删除,请刷新页面"); throw new SysException("该数据已被删除,请刷新页面");
} }
panel.setPublished(PublishedStatus.OFFLINE.value); if(PublishedStatus.WAIT_PUBLISHED.value.equals(panel.getPublished())){
// panel.setRecordStatus(SlmConstants.DATA_DELETED); throw new SysException("该仪表板已被下线,请刷新页面");
}
panel.setPublished(PublishedStatus.WAIT_PUBLISHED.value);
baseMapper.updateById(panel); baseMapper.updateById(panel);
// log.info("删除配置"); log.info("删除草稿");
// log.info("删除权限"); InstrumentPanelDraft draft = draftService.getByPanelId(panel.getId());
// log.info("删除草稿"); if(ObjectUtils.isNotEmpty(draft)){
// log.info("删除仪表板树"); draft.setRecordStatus(SlmConstants.DATA_DELETED);
// delAllSetting(id); draftService.updateById(draft);
}
log.info("更新仪表板配置为待发布状态");
configService.offlineConfig(panel.getId(), null);
log.info("更新仪表板权限为待发布状态");
permissionService.offlinePermission(panel.getId());
return id; return id;
} }
...@@ -200,6 +208,16 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -200,6 +208,16 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
} }
} }
@Override
public List<InstrumentPanel> getByIds(Set<String> panelIds) {
return baseMapper.selectBatchIds(panelIds);
}
@Override
public List<PanelTreeNodeVo> selectPanelByIds(Set<String> finalPanelIds,String name) {
return baseMapper.selectPanelByIds(finalPanelIds,name);
}
private String savePanelData(String appId, SaveInstrumentPanelDTO panel) { private String savePanelData(String appId, SaveInstrumentPanelDTO panel) {
if (StringUtils.isEmpty(panel.getName())) { if (StringUtils.isEmpty(panel.getName())) {
throw new SysException("仪表板名字必填"); throw new SysException("仪表板名字必填");
...@@ -213,21 +231,11 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -213,21 +231,11 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
log.info("保存仪表板访问权限"); log.info("保存仪表板访问权限");
String panelId = IdWorker.get32UUID(); String panelId = IdWorker.get32UUID();
String accessType = AccessType.PUBLIC.value; String accessType = AccessType.PUBLIC.value;
if (ObjectUtils.isNotEmpty(panel.getPermission()) && StringUtils.isNotEmpty(panel.getPermission() if (ObjectUtils.isNotEmpty(panel.getPermission()) && StringUtils.isNotEmpty(panel.getPermission().getAccessType())) {
.getAccessType())) {
accessType = panel.getPermission().getAccessType(); accessType = panel.getPermission().getAccessType();
permissionService.savePanelPermission(panel.getPermission().getCustomPermissions(), permissionService.savePanelPermission(panel.getPermission().getCustomPermissions(),panelId,panel.getPermission().getAccessType(),PublishedStatus.WAIT_PUBLISHED.value);
panelId,
panel.getPermission().getAccessType(),
PublishedStatus.WAIT_PUBLISHED.value);
} }
InstrumentPanel entity = new InstrumentPanel(panelId,panel.getName(),panel.getGroupId(),accessType,PublishedStatus.WAIT_PUBLISHED.value);
InstrumentPanel instrumentPanel = new InstrumentPanel(panelId,
panel.getName(),
panel.getGroupId(),
accessType,
PublishedStatus.WAIT_PUBLISHED.value);
log.info("保存仪表板配置"); log.info("保存仪表板配置");
if (StringUtils.isNotEmpty(panel.getConfigDetails())) { if (StringUtils.isNotEmpty(panel.getConfigDetails())) {
...@@ -235,20 +243,17 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -235,20 +243,17 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
} }
log.info("初始化仪表板树"); log.info("初始化仪表板树");
treeService.initTree(instrumentPanel.getGroupId(), treeService.initTree(entity.getGroupId(),NodeType.PANEL.value,entity.getId(),entity.getName());
NodeType.PANEL.value,
instrumentPanel.getId(),
instrumentPanel.getName());
if (CollectionUtils.isNotEmpty(panel.getAssemblys())) { if (CollectionUtils.isNotEmpty(panel.getAssemblys())) {
InstrumentPanelTree tree = treeService.getById(instrumentPanel.getId()); InstrumentPanelTree tree = treeService.getById(entity.getId());
log.info("保存仪表板组件树"); log.info("保存仪表板组件树");
treeService.savePanelAssemblyTree(tree, panel.getAssemblys(), instrumentPanel.getId()); treeService.savePanelAssemblyTree(tree, panel.getAssemblys(), entity.getId());
} else { } else {
log.info("前端没有构建组件树"); log.info("前端没有构建组件树");
} }
log.info("保存仪表板数据"); log.info("保存仪表板数据");
baseMapper.insert(instrumentPanel); baseMapper.insert(entity);
return panelId; return panelId;
} }
......
...@@ -2,20 +2,33 @@ package com.syc.slm.slmbi.service.impl; ...@@ -2,20 +2,33 @@ package com.syc.slm.slmbi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gson.reflect.TypeToken;
import com.syc.slm.common.core.constant.SlmConstants; import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelTreeMapper; import com.syc.slm.slmbi.dao.InstrumentPanelTreeMapper;
import com.syc.slm.slmbi.dto.InstrumentPanelAssemblyDTO; import com.syc.slm.slmbi.dto.InstrumentPanelAssemblyDTO;
import com.syc.slm.slmbi.entity.BaseEntity; import com.syc.slm.slmbi.entity.*;
import com.syc.slm.slmbi.entity.InstrumentPanel;
import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import com.syc.slm.slmbi.enums.NodeType; import com.syc.slm.slmbi.enums.NodeType;
import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.InstrumentPanelDraftService;
import com.syc.slm.slmbi.service.InstrumentPanelGroupService;
import com.syc.slm.slmbi.service.InstrumentPanelService;
import com.syc.slm.slmbi.service.InstrumentPanelTreeService; import com.syc.slm.slmbi.service.InstrumentPanelTreeService;
import com.syc.slm.slmbi.vo.CustomPermissionVo;
import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import lombok.NonNull; import lombok.NonNull;
import org.apache.commons.io.filefilter.FalseFileFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.*;
import java.util.Set; import java.util.stream.Collectors;
/** /**
* 仪表板树聚合表 * 仪表板树聚合表
...@@ -27,10 +40,18 @@ import java.util.Set; ...@@ -27,10 +40,18 @@ import java.util.Set;
public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelTreeMapper, InstrumentPanelTree> public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelTreeMapper, InstrumentPanelTree>
implements InstrumentPanelTreeService { implements InstrumentPanelTreeService {
@Autowired
private InstrumentPanelDraftService draftService;
@Autowired
private InstrumentPanelGroupService groupService;
@Autowired
private InstrumentPanelService panelService;
@Override @Override
public void batchUpdateTreeByIds(Set<String> treeIds, Integer recordStatus) { public void batchUpdateTreeByIds(Set<String> treeIds, Integer recordStatus) {
if(CollectionUtils.isNotEmpty(treeIds)){ if (CollectionUtils.isNotEmpty(treeIds)) {
baseMapper.batchUpdateTreeByIds(treeIds,recordStatus); baseMapper.batchUpdateTreeByIds(treeIds, recordStatus);
} }
} }
...@@ -42,6 +63,7 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -42,6 +63,7 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
tree.setNodeType(nodeType); tree.setNodeType(nodeType);
tree.setFullName(panelTree.getFullName() + "." + bizName); tree.setFullName(panelTree.getFullName() + "." + bizName);
tree.setFullId(panelTree.getFullId() + "." + bizId); tree.setFullId(panelTree.getFullId() + "." + bizId);
tree.setName(bizName);
baseMapper.insert(tree); baseMapper.insert(tree);
} }
...@@ -50,13 +72,12 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -50,13 +72,12 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
InstrumentPanelTree tree = baseMapper.selectById(panelId); InstrumentPanelTree tree = baseMapper.selectById(panelId);
tree.setRecordStatus(SlmConstants.DATA_DELETED); tree.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(tree); baseMapper.updateById(tree);
//#todo 仪表板组件树
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID); where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId,tree.getFullId()+"."); where.likeRight(InstrumentPanelTree::getFullId, tree.getFullId() + ".");
List<InstrumentPanelTree> list = baseMapper.selectList(where); List<InstrumentPanelTree> list = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(list)){ if (CollectionUtils.isNotEmpty(list)) {
list.forEach(x->{ list.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED); x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x); baseMapper.updateById(x);
}); });
...@@ -65,14 +86,18 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -65,14 +86,18 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
@Override @Override
public void savePanelAssemblyTree(InstrumentPanelTree tree,List<InstrumentPanelAssemblyDTO> assembly,String panelId) { public void savePanelAssemblyTree(InstrumentPanelTree tree,List<InstrumentPanelAssemblyDTO> assembly,String panelId) {
if(CollectionUtils.isNotEmpty(assembly)){ if (CollectionUtils.isNotEmpty(assembly)) {
for (int i = 0; i < assembly.size(); i++) { for (int i = 0; i < assembly.size(); i++) {
if(StringUtils.isBlank(assembly.get(i).getName()) || StringUtils.isBlank(assembly.get(i).getKey())){
throw new SysException("主键名称或者key不能为空,请联系管理员");
}
InstrumentPanelTree t = new InstrumentPanelTree(); InstrumentPanelTree t = new InstrumentPanelTree();
t.setId(tree.getId() + "_" + i); t.setId(tree.getId() + "_" + i);
t.setNodeType(NodeType.ASSEMBLY.value); t.setNodeType(NodeType.ASSEMBLY.value);
t.setFullId(tree.getFullId() + "." + t.getId()); t.setFullId(tree.getFullId() + "." + t.getId());
t.setFullName(tree.getFullName() + "." + assembly.get(i).getName()); t.setFullName(tree.getFullName() + "." + assembly.get(i).getName());
t.setAssemblyKey(assembly.get(i).getKey()); t.setAssemblyKey(assembly.get(i).getKey());
t.setName(assembly.get(i).getName());
baseMapper.insert(t); baseMapper.insert(t);
} }
} }
...@@ -85,19 +110,279 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -85,19 +110,279 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID); where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId, fullId + "."); where.likeRight(InstrumentPanelTree::getFullId, fullId + ".");
List<InstrumentPanelTree> trees = baseMapper.selectList(where); List<InstrumentPanelTree> trees = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(trees)){ if (CollectionUtils.isNotEmpty(trees)) {
trees.forEach(x->{ trees.forEach(x -> {
x.setRecordStatus(SlmConstants.DATA_DELETED); x.setRecordStatus(SlmConstants.DATA_DELETED);
baseMapper.updateById(x); baseMapper.updateById(x);
}); });
} }
} }
@Override @Override
public void updatePanelTreeFullName(String panelId,String panelName,String groupId) { public void updatePanelTreeFullName(String panelId, String panelName, String groupId) {
InstrumentPanelTree groupTree = baseMapper.selectById(groupId); InstrumentPanelTree groupTree = baseMapper.selectById(groupId);
InstrumentPanelTree tree = baseMapper.selectById(panelId); InstrumentPanelTree tree = baseMapper.selectById(panelId);
tree.setFullName(groupTree.getFullName() + "." + panelName); tree.setFullName(groupTree.getFullName() + "." + panelName);
tree.setFullId(groupTree.getFullId() + "." + panelId); tree.setFullId(groupTree.getFullId() + "." + panelId);
tree.setName(panelName);
baseMapper.updateById(tree); baseMapper.updateById(tree);
} }
@Override
public List<PanelTreeNodeVo> loadTrees(String appId, String name) {
if(StringUtils.isBlank(name)){
return loadTrees(appId);
}
List<PanelTreeNodeVo> lists = Lists.newArrayList();
String officeIds = null;
String userId = null;
String roleId = null;
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getAppId, appId);
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelTree::getNodeType, NodeType.PANEL.value);
if (StringUtils.isNotBlank(name)) {
where.like(InstrumentPanelTree::getFullName, name);
}
List<InstrumentPanelTree> trees = baseMapper.selectList(where);
if (CollectionUtils.isNotEmpty(trees)) {
Set<String> panelIds = trees.stream().map(BaseEntity::getId).collect(Collectors.toSet());
List<InstrumentPanelDraft> panels = draftService.selectDraftList(appId, panelIds, officeIds, userId, roleId);
if (CollectionUtils.isNotEmpty(panels)) {
Set<String> publishIds = panels.stream().map(InstrumentPanelDraft::getPanelId).collect(Collectors.toSet());
Set<String[]> finalPanelArrays = trees.stream()
.filter(x -> publishIds.contains(x.getId()))
.map(x -> x.getFullId().split("[.]"))
.collect(Collectors.toSet());
Set<String> finalPanelIds = Sets.newHashSet();
finalPanelArrays.forEach(x-> finalPanelIds.addAll(Arrays.asList(x)));
List<PanelTreeNodeVo> panelTreeNodeVos = panelService.selectPanelByIds(finalPanelIds,name);
if (CollectionUtils.isNotEmpty(panelTreeNodeVos)) {
lists.addAll(panelTreeNodeVos);
}
List<PanelTreeNodeVo> groupTreeNodeVos = groupService.selectGroupByIds(finalPanelIds,null);
if (CollectionUtils.isNotEmpty(groupTreeNodeVos)) {
if(CollectionUtils.isEmpty(panelTreeNodeVos) && StringUtils.isNotBlank(name)){
Set<String> groupIds = groupTreeNodeVos.stream().filter(x -> x.getName().contains(name)).map(PanelTreeNodeVo::getId).collect(Collectors.toSet());
List<InstrumentPanelTree> groupTrees = baseMapper.selectBatchIds(groupIds);
groupIds.clear();
groupTrees.forEach(x->{
if(x.getFullId().contains(".")){
groupIds.addAll(Arrays.asList(x.getFullId().split("[.]")));
}else{
groupIds.add(x.getFullId());
}
});
groupTreeNodeVos= groupService.selectGroupByIds(groupIds,null);
}
lists.addAll(groupTreeNodeVos);
}
}
}
return lists;
}
@Override
public List<PanelTreeNodeVo> loadTrees(String appId) {
List<PanelTreeNodeVo> lists = Lists.newArrayList();
String officeIds=null;
String userId=null;
String roleId=null;
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getAppId, appId);
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelTree::getNodeType, NodeType.PANEL.value);
List<InstrumentPanelTree> trees = baseMapper.selectList(where);
if (CollectionUtils.isNotEmpty(trees)) {
Set<String> panelIds = trees.stream().map(BaseEntity::getId).collect(Collectors.toSet());
List<InstrumentPanelDraft> panels = draftService.selectDraftList(appId,panelIds,officeIds,userId,roleId);
if(CollectionUtils.isNotEmpty(panels)) {
Set<String> publishIds = panels.stream().map(InstrumentPanelDraft::getPanelId).collect(Collectors.toSet());
Set<String[]> finalPanelArrays = trees.stream()
.filter(x -> publishIds.contains(x.getId()))
.map(x -> x.getFullId().split("[.]"))
.collect(Collectors.toSet());
Set<String> finalPanelIds = Sets.newHashSet();
finalPanelArrays.forEach(x -> {
if (x.length > 3) {
for (int i = 0; i < x.length; i++) {
if (i == 2) {
break;
}
finalPanelIds.add(x[i]);
}
}
});
List<PanelTreeNodeVo> groupTreeNodeVos = groupService.selectGroupByIds(finalPanelIds,null);
if (CollectionUtils.isNotEmpty(groupTreeNodeVos)) {
lists.addAll(groupTreeNodeVos);
}
List<PanelTreeNodeVo> panelTreeNodeVos = panelService.selectPanelByIds(finalPanelIds,null);
if (CollectionUtils.isNotEmpty(panelTreeNodeVos)) {
lists.addAll(panelTreeNodeVos);
} else {
if (CollectionUtils.isNotEmpty(groupTreeNodeVos)) {
String groupId = groupTreeNodeVos.stream().filter(x->StringUtils.isNotBlank(x.getParentId())).findFirst().get().getId();
boolean flag = true;
int num =0;
while (flag) {
if(num>10){
break;
}
num++;
List<PanelTreeNodeVo> childrenNodes = this.children(groupId, null);
if(CollectionUtils.isEmpty(childrenNodes)){
flag=false;
}
long count = childrenNodes.stream()
.filter(x -> NodeType.PANEL.value.equals(x.getNodeType()))
.count();
if (count == 0) {
lists.addAll(childrenNodes);
groupId = childrenNodes.stream()
.filter(x -> NodeType.GROUP.value.equals(x.getNodeType()))
.findFirst()
.get()
.getId();
} else {
flag = false;
lists.addAll(childrenNodes);
}
}
}
}
}
}
return lists;
}
@Override
@Transactional(readOnly = true)
public List<PanelTreeNodeVo> children(String groupId, String name) {
List<PanelTreeNodeVo> lists = Lists.newArrayList();
String officeIds = null;
String userId = null;
String roleId = null;
InstrumentPanelTree tree = baseMapper.selectById(groupId);
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.likeRight(InstrumentPanelTree::getFullId, tree.getFullId() + ".");
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
if (StringUtils.isNotBlank(name)) {
where.like(InstrumentPanelTree::getFullName, name);
}
where.eq(InstrumentPanelTree::getNodeType, NodeType.PANEL.value);
List<InstrumentPanelTree> trees = baseMapper.selectList(where);
if (CollectionUtils.isNotEmpty(trees)) {
Set<String> panelIds = trees.stream().map(BaseEntity::getId).collect(Collectors.toSet());
List<InstrumentPanelDraft> panels = draftService.selectDraftList(tree.getAppId(),
panelIds,
officeIds,
userId,
roleId);
if (CollectionUtils.isNotEmpty(panels)) {
Set<String> publishIds = panels.stream().map(InstrumentPanelDraft::getPanelId).collect(Collectors.toSet());
Set<String> finalPanelIds = trees.stream().filter(x -> publishIds.contains(x.getId())).map(x -> {
String fullId = x.getFullId();
fullId = fullId.replace(tree.getFullId() + ".", "");
if (fullId.contains(".")) {
return fullId.substring(0, fullId.indexOf("."));
} else {
return fullId;
}
}).collect(Collectors.toSet());
if (CollectionUtils.isNotEmpty(finalPanelIds)) {
List<PanelTreeNodeVo> panelTreeNodeVos = panelService.selectPanelByIds(finalPanelIds, name);
if (CollectionUtils.isNotEmpty(panelTreeNodeVos)) {
lists.addAll(panelTreeNodeVos);
finalPanelIds.addAll(panelTreeNodeVos.stream()
.filter(x -> !groupId.equals(x.getParentId()))
.map(PanelTreeNodeVo::getParentId)
.collect(Collectors.toSet()));
}
List<PanelTreeNodeVo> groupTreeNodeVos = groupService.selectGroupByIds(finalPanelIds, name);
if (CollectionUtils.isNotEmpty(groupTreeNodeVos)) {
lists.addAll(groupTreeNodeVos);
}
}
}
}
return lists;
}
@Override
public void updateFullNameByGroupId(String groupId, String panelId, String panelName) {
InstrumentPanelTree group = baseMapper.selectById(groupId);
InstrumentPanelTree panelTree = baseMapper.selectById(panelId);
String beforeFullName = panelTree.getFullName();
String beforeFullId = panelTree.getFullId();
if(ObjectUtils.isNotEmpty(group)){
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.likeRight(InstrumentPanelTree::getFullId, group.getFullId() + ".");
List<InstrumentPanelTree> trees = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(trees)){
trees.forEach(x->{
x.setFullId(x.getFullId().replace(beforeFullId, group.getFullId()));
String name = x.getFullName().substring(x.getFullName().lastIndexOf(beforeFullName));
x.setFullName(group.getFullName()+"." + name);
x.setName(name);
baseMapper.updateById(x);
});
}
}
}
@Override
@Transactional(readOnly = true)
public List<PanelTreeNodeVo> copyTreeList(String appId,String name) {
return getCopyAndCiteTrees(appId, name, false);
}
@Override
@Transactional(readOnly = true)
public List<PanelTreeNodeVo> citeTreeList(String appId, String name) {
return getCopyAndCiteTrees(appId, name, true);
}
private List<PanelTreeNodeVo> getCopyAndCiteTrees(String appId, String name,boolean showAssembly) {
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getAppId, appId);
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
if(!showAssembly){
where.eq(InstrumentPanelTree::getNodeType, NodeType.ASSEMBLY.value);
}
List<InstrumentPanelTree> allGroups=baseMapper.selectList(where);
List<InstrumentPanelTree> filteredTrees=allGroups;
Map<String, InstrumentPanelTree> allMaps=allGroups.stream().collect(Collectors.toMap(InstrumentPanelTree::getFullId, x->x));
Map<String, InstrumentPanelTree> filteredMaps=allMaps;
where.like(InstrumentPanelTree::getName, name);
if(StringUtils.isNotBlank(name)){
filteredTrees=baseMapper.selectList(where);
filteredMaps=filteredTrees.stream().collect(Collectors.toMap(InstrumentPanelTree::getFullId, x->x));
}
Stack<InstrumentPanelTree> stack=new Stack<>();
stack.addAll(filteredTrees);
while(!stack.isEmpty()){
InstrumentPanelTree tree = stack.pop();
String fullId=tree.getFullId();
int lastDot=fullId.lastIndexOf(".");
String pid=fullId;
while(lastDot>0){
pid=pid.substring(0, lastDot);
InstrumentPanelTree pTree= Optional.ofNullable(filteredMaps.get(pid)).orElse(allMaps.get(pid));
if(pTree!=null){
tree.setParentId(pid.substring(pid.lastIndexOf(".")+1));
filteredMaps.putIfAbsent(pid, pTree);
stack.add(pTree);
break;
}
lastDot=pid.lastIndexOf(".");
}
}
return CollectionUtils.isNotEmpty(filteredMaps.values())?SlmConstants.gson.fromJson(SlmConstants.gson.toJson(filteredMaps.values()), new TypeToken<List<PanelTreeNodeVo>>() {}.getType()):
Lists.newArrayList();
}
} }
package com.syc.slm.slmbi.vo; package com.syc.slm.slmbi.vo;
import com.syc.slm.slmbi.dto.CustomPermissionDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.List;
/** /**
* slm-bi * slm-bi
* 仪表板权限vo * 仪表板权限vo
...@@ -16,10 +19,10 @@ import lombok.EqualsAndHashCode; ...@@ -16,10 +19,10 @@ import lombok.EqualsAndHashCode;
@ApiModel(value = "仪表板权限Vo",description = "仪表板权限Vo") @ApiModel(value = "仪表板权限Vo",description = "仪表板权限Vo")
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
public class InstrumentPanelPermissionVo { public class InstrumentPanelPermissionVo {
@ApiModelProperty(value = "存储类型,1代表岗位,2代表部门,3 代表个体用户") @ApiModelProperty(value = "访问权限类型", required = true)
private Integer permissionType; private String accessType;
@ApiModelProperty(value = "代表岗位,部门,个体用户id")
private String bizId;
@ApiModelProperty(value = "代表岗位,部门,个体用户名称") @ApiModelProperty(value = "自定义权限配置,当访问类型为CUSTOM时必填")
private String bizName; private List<CustomPermissionVo> customPermissions;
} }
...@@ -24,5 +24,7 @@ public class PanelTreeNodeVo { ...@@ -24,5 +24,7 @@ public class PanelTreeNodeVo {
@ApiModelProperty(value = "节点名称") @ApiModelProperty(value = "节点名称")
private String name; private String name;
@ApiModelProperty(value = "节点类型") @ApiModelProperty(value = "节点类型")
private PanelTreeNodeType type; private String nodeType;
@ApiModelProperty(value = "组件对应key,分组跟仪表板该字段为空")
private String assemblyKey;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment