Commit ddd09f71 authored by linruibiao's avatar linruibiao

接口编写

parent d1be6cdc
package com.syc.slm.common.core.util; package com.syc.slm.common.core.util;
import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.exception.SysException; import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.function.Action0; import com.syc.slm.slmbi.function.Action0;
...@@ -18,11 +19,11 @@ public final class NetResponseUtils { ...@@ -18,11 +19,11 @@ public final class NetResponseUtils {
return R.ok(x.get()); return R.ok(x.get());
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
if ((ex.getCause() instanceof SysException)) { if (ex instanceof SysException) {
SysException e = (SysException)ex.getCause(); SysException e = (SysException) ex;
return R.failed(e.getMsg()); return R.failed(e.getMsg());
} }
return R.failed(ex.getMessage()); return R.failed("出错啦请联系管理员",ex.toString());
} }
} }
...@@ -32,7 +33,11 @@ public final class NetResponseUtils { ...@@ -32,7 +33,11 @@ public final class NetResponseUtils {
return R.ok(); return R.ok();
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
return R.failed(ex.getMessage()); if (ex instanceof SysException) {
SysException e = (SysException) ex;
return R.failed(e.getMsg());
}
return R.bad("出错啦请联系管理员",ex.toString());
} }
} }
} }
...@@ -53,6 +53,11 @@ public class R<T> implements Serializable { ...@@ -53,6 +53,11 @@ public class R<T> implements Serializable {
@ApiModelProperty(value = "返回信息") @ApiModelProperty(value = "返回信息")
private String msg; private String msg;
@Getter
@Setter
@ApiModelProperty(value = "调式异常")
private String debugMsg;
@Getter @Getter
@Setter @Setter
@ApiModelProperty(value = "数据") @ApiModelProperty(value = "数据")
...@@ -77,7 +82,9 @@ public class R<T> implements Serializable { ...@@ -77,7 +82,9 @@ public class R<T> implements Serializable {
public static <T> R<T> failed(String msg) { public static <T> R<T> failed(String msg) {
return restResult(null, CommonConstants.FAIL, msg); return restResult(null, CommonConstants.FAIL, msg);
} }
public static <T> R<T> failed(String msg,String debugMsg) {
return restResult(null, CommonConstants.FAIL, msg,debugMsg);
}
public static <T> R<T> failed(T data) { public static <T> R<T> failed(T data) {
return restResult(data, CommonConstants.FAIL, null); return restResult(data, CommonConstants.FAIL, null);
} }
...@@ -86,6 +93,10 @@ public class R<T> implements Serializable { ...@@ -86,6 +93,10 @@ public class R<T> implements Serializable {
return restResult(data, CommonConstants.FAIL, msg); return restResult(data, CommonConstants.FAIL, msg);
} }
public static <T> R<T> bad(String msg,String debugMsg) {
return failed(msg,debugMsg);
}
private static <T> R<T> restResult(T data, int code, String msg) { private static <T> R<T> restResult(T data, int code, String msg) {
R<T> apiResult = new R<>(); R<T> apiResult = new R<>();
apiResult.setCode(code); apiResult.setCode(code);
...@@ -93,5 +104,13 @@ public class R<T> implements Serializable { ...@@ -93,5 +104,13 @@ public class R<T> implements Serializable {
apiResult.setMsg(msg); apiResult.setMsg(msg);
return apiResult; return apiResult;
} }
private static <T> R<T> restResult(T data, int code, String msg,String debugMsg) {
R<T> apiResult = new R<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
apiResult.setDebugMsg(debugMsg);
return apiResult;
}
} }
...@@ -18,7 +18,7 @@ import java.util.function.Supplier; ...@@ -18,7 +18,7 @@ import java.util.function.Supplier;
@Component @Component
@Slf4j @Slf4j
public class SysMetaObjectHandler implements MetaObjectHandler { public class SysMetaObjectHandler implements MetaObjectHandler {
private static final String ID = "id";
private static final String APP_ID = "appId"; private static final String APP_ID = "appId";
private static final String CREATOR = "creator"; private static final String CREATOR = "creator";
private static final String CREATOR_NAME = "creatorName"; private static final String CREATOR_NAME = "creatorName";
...@@ -33,6 +33,9 @@ public class SysMetaObjectHandler implements MetaObjectHandler { ...@@ -33,6 +33,9 @@ public class SysMetaObjectHandler implements MetaObjectHandler {
*/ */
@Override @Override
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
fillValue(metaObject,
ID,
() -> (metaObject.getValue(ID) == null ? IdWorker.get32UUID() : metaObject.getValue(ID)));
fillValue(metaObject, fillValue(metaObject,
APP_ID, APP_ID,
() -> (metaObject.getValue(APP_ID) == null ? "68d61d7f990e11eb847e88d7f63cc98f" : metaObject.getValue(APP_ID))); () -> (metaObject.getValue(APP_ID) == null ? "68d61d7f990e11eb847e88d7f63cc98f" : metaObject.getValue(APP_ID)));
......
package com.syc.slm.slmbi.controller; package com.syc.slm.slmbi.controller;
import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.common.core.util.NetResponseUtils; import com.syc.slm.common.core.util.NetResponseUtils;
import com.syc.slm.common.core.util.R; import com.syc.slm.common.core.util.R;
import com.syc.slm.slmbi.function.Action0; import com.syc.slm.slmbi.function.Action0;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ModelAttribute;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
/** /**
...@@ -13,7 +19,15 @@ import java.util.function.Supplier; ...@@ -13,7 +19,15 @@ import java.util.function.Supplier;
* @author : lin * @author : lin
* @date : 2021-04-06 09:09 * @date : 2021-04-06 09:09
**/ **/
@Slf4j
public class BaseRestController { public class BaseRestController {
@ModelAttribute
public void onInit(HttpServletRequest request) {
String uri = request.getRequestURI();
log.info("请求url--->>>>" + uri);
Map<String, String[]> parameterMap = request.getParameterMap();
log.info("请求参数--->>>>"+SlmConstants.gson.toJson(parameterMap));
}
R<Object> call(Action0 action) { R<Object> call(Action0 action) {
return NetResponseUtils.call(action); return NetResponseUtils.call(action);
} }
......
...@@ -30,7 +30,7 @@ public class InstrumentPanelConfigController { ...@@ -30,7 +30,7 @@ public class InstrumentPanelConfigController {
@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> saveInstrumentPanelConfig(@PathVariable String appId, InstrumentPanelConfigDTO config) { public R<String> saveInstrumentPanelConfig(@PathVariable String appId, @RequestBody InstrumentPanelConfigDTO config) {
return R.ok(instrumentPanelConfigService.saveConfig(appId,config)); return R.ok(instrumentPanelConfigService.saveConfig(appId,config));
} }
......
...@@ -60,7 +60,7 @@ public class InstrumentPanelController extends BaseRestController { ...@@ -60,7 +60,7 @@ public class InstrumentPanelController extends BaseRestController {
required = true, required = true,
dataTypeClass = Arrays.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, @RequestParam List<String> ids) { public R<List<String>> batchPublish(@PathVariable String appId, @RequestParam List<String> ids) {
return call(() -> instrumentPanelService.batchPublish(ids)); return call(() -> instrumentPanelService.batchPublish(ids));
} }
......
...@@ -48,7 +48,7 @@ public class InstrumentPanelGroupController extends BaseRestController{ ...@@ -48,7 +48,7 @@ public class InstrumentPanelGroupController extends BaseRestController{
} }
@PutMapping @PutMapping
@ApiOperation("更新仪表板分组") @ApiOperation("更新仪表板分组(一级分组是初始化得,不允许修改,其他分组修改必须传parentId)")
@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,appId)); return call(()->instrumentPanelGroupService.updateGroup(group,appId));
......
...@@ -36,7 +36,7 @@ public class InstrumentPanelPermissionController extends BaseRestController { ...@@ -36,7 +36,7 @@ public class InstrumentPanelPermissionController extends BaseRestController {
return call(() -> instrumentPanelPermissionService.savePermission(permission)); return call(() -> instrumentPanelPermissionService.savePermission(permission));
} }
@PutMapping("/{panelId}/to-copy") @GetMapping("/{panelId}/to-copy")
@ApiOperation("从其他仪表板复制配置") @ApiOperation("从其他仪表板复制配置")
@ApiImplicitParams({@ApiImplicitParam(name = "appId", @ApiImplicitParams({@ApiImplicitParam(name = "appId",
value = "租户id", value = "租户id",
...@@ -54,7 +54,7 @@ public class InstrumentPanelPermissionController extends BaseRestController { ...@@ -54,7 +54,7 @@ public class InstrumentPanelPermissionController extends BaseRestController {
value = "租户id", value = "租户id",
required = true, required = true,
dataTypeClass = String.class), dataTypeClass = String.class),
@ApiImplicitParam(name = "panelId", value = "其他仪表板id", required = true, dataTypeClass = Arrays.class)}) @ApiImplicitParam(name = "panelIds", value = "其他仪表板id", required = true, dataTypeClass = Arrays.class)})
public R<Object> saveCopyToOtherPermission(@PathVariable String appId, public R<Object> saveCopyToOtherPermission(@PathVariable String appId,
@RequestBody InstrumentPanelPermissionDTO permission, @RequestBody InstrumentPanelPermissionDTO permission,
@RequestParam List<String> panelIds) { @RequestParam List<String> panelIds) {
......
...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author liangbin * @author liangbin
...@@ -57,9 +58,9 @@ public class InstrumentPanelTreeController extends BaseRestController { ...@@ -57,9 +58,9 @@ public class InstrumentPanelTreeController extends BaseRestController {
@ApiImplicitParam(name = "nodeId", value = "分组id", required = true, dataTypeClass = String.class), @ApiImplicitParam(name = "nodeId", value = "分组id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "name", value = "分组名称或者仪表板名称", 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("nodeId") String groupId, @RequestParam("nodeId") String nodeId,
@RequestParam(value = "name", required = false) String name) { @RequestParam(value = "name", required = false) String name) {
return call(() -> (treeService.children(groupId, name))); return call(() -> (treeService.children(nodeId, name)));
} }
@GetMapping("/children-panel") @GetMapping("/children-panel")
...@@ -97,4 +98,15 @@ public class InstrumentPanelTreeController extends BaseRestController { ...@@ -97,4 +98,15 @@ public class InstrumentPanelTreeController extends BaseRestController {
public R<List<PanelTreeNodeVo>> cite(@PathVariable String appId,@RequestParam(value = "name", required = false) String name) { public R<List<PanelTreeNodeVo>> cite(@PathVariable String appId,@RequestParam(value = "name", required = false) String name) {
return call(() -> (treeService.citeTreeList(appId,name))); return call(() -> (treeService.citeTreeList(appId,name)));
} }
@GetMapping("/cite-assembly")
@ApiOperation("复用仪表板树点击组件获取配置(会返回一个map 优先从key为 wait_published 中匹配,如果找不到再从key 为published 中匹配 )")
@ApiImplicitParams({@ApiImplicitParam(name = "appId",
value = "租户id",
required = true,
dataTypeClass = String.class),
@ApiImplicitParam(name = "appId", value = "租户id", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "panelId", value = "仪表板id", required = true, dataTypeClass = String.class)})
public R<Map<String,String>> assembly(@PathVariable String appId,@RequestParam(value = "panelId", required = false) String panelId) {
return call(() -> (treeService.assembly(appId,panelId)));
}
} }
...@@ -28,37 +28,37 @@ public class BaseEntity<T extends Model<?>> extends Model<T> { ...@@ -28,37 +28,37 @@ public class BaseEntity<T extends Model<?>> extends Model<T> {
*/ */
@TableId @TableId
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "主键")
private String id; protected String id;
/** /**
* 租户id * 租户id
*/ */
@ApiModelProperty(value = "租户id") @ApiModelProperty(value = "租户id")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private String appId; protected String appId;
@ApiModelProperty(value = "创建人主键") @ApiModelProperty(value = "创建人主键")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private String creator; protected String creator;
@ApiModelProperty(value = "创建人名称") @ApiModelProperty(value = "创建人名称")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private String creatorName; protected String creatorName;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Date createTime; protected Date createTime;
@ApiModelProperty(value = "修改人主键") @ApiModelProperty(value = "修改人主键")
@TableField(fill = FieldFill.UPDATE) @TableField(fill = FieldFill.UPDATE)
private String updater; protected String updater;
@ApiModelProperty(value = "修改人名称") @ApiModelProperty(value = "修改人名称")
@TableField(fill = FieldFill.UPDATE) @TableField(fill = FieldFill.UPDATE)
private String updaterName; protected String updaterName;
@ApiModelProperty(value = "修改时间") @ApiModelProperty(value = "修改时间")
@TableField(fill = FieldFill.UPDATE) @TableField(fill = FieldFill.UPDATE)
private Date updateTime; protected Date updateTime;
@ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态")
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Integer recordStatus; protected Integer recordStatus;
@ApiModelProperty(value = "描述") @ApiModelProperty(value = "描述")
private String description; protected String description;
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
......
...@@ -18,8 +18,6 @@ import lombok.EqualsAndHashCode; ...@@ -18,8 +18,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper=true) @EqualsAndHashCode(callSuper=true)
@TableName("instrument_panel") @TableName("instrument_panel")
public class InstrumentPanel extends BaseEntity<InstrumentPanel>{ public class InstrumentPanel extends BaseEntity<InstrumentPanel>{
@ApiModelProperty(value = "仪表板主键")
private String id ;
@ApiModelProperty(value = "仪表板名称") @ApiModelProperty(value = "仪表板名称")
private String name; private String name;
@ApiModelProperty(value = "仪表板归属分组") @ApiModelProperty(value = "仪表板归属分组")
...@@ -27,13 +25,13 @@ public class InstrumentPanel extends BaseEntity<InstrumentPanel>{ ...@@ -27,13 +25,13 @@ public class InstrumentPanel extends BaseEntity<InstrumentPanel>{
@ApiModelProperty(value = "访问权限") @ApiModelProperty(value = "访问权限")
private String accessPermission; private String accessPermission;
@ApiModelProperty(value = "发布状态") @ApiModelProperty(value = "发布状态")
private Integer published; private String published;
public InstrumentPanel() { public InstrumentPanel() {
} }
public InstrumentPanel(String id, String name, String groupId, String accessPermission, Integer published) { public InstrumentPanel(String id, String name, String groupId, String accessPermission, String published) {
this.id = id; super.id=id;
this.name = name; this.name = name;
this.groupId = groupId; this.groupId = groupId;
this.accessPermission = accessPermission; this.accessPermission = accessPermission;
......
...@@ -24,5 +24,5 @@ public class InstrumentPanelConfig extends BaseEntity<InstrumentPanelConfig>{ ...@@ -24,5 +24,5 @@ public class InstrumentPanelConfig extends BaseEntity<InstrumentPanelConfig>{
@ApiModelProperty(value = "仪表板配置详情,包含了样式,数据配置") @ApiModelProperty(value = "仪表板配置详情,包含了样式,数据配置")
private String configDetails; private String configDetails;
@ApiModelProperty(value = "发布状态") @ApiModelProperty(value = "发布状态")
private Integer published; private String published;
} }
...@@ -17,7 +17,6 @@ import lombok.EqualsAndHashCode; ...@@ -17,7 +17,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value = "仪表板草稿") @ApiModel(value = "仪表板草稿")
public class InstrumentPanelDraft extends BaseEntity<InstrumentPanelDraft> { public class InstrumentPanelDraft extends BaseEntity<InstrumentPanelDraft> {
private static final long serialVersionUID = 1L;
/** /**
* 仪表板名字 * 仪表板名字
......
...@@ -17,7 +17,6 @@ import lombok.EqualsAndHashCode; ...@@ -17,7 +17,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value = "仪表板权限") @ApiModel(value = "仪表板权限")
public class InstrumentPanelPermission extends BaseEntity<InstrumentPanelPermission> { public class InstrumentPanelPermission extends BaseEntity<InstrumentPanelPermission> {
private static final long serialVersionUID = 1L;
/** /**
* 仪表板id * 仪表板id
*/ */
...@@ -42,5 +41,5 @@ public class InstrumentPanelPermission extends BaseEntity<InstrumentPanelPermiss ...@@ -42,5 +41,5 @@ public class InstrumentPanelPermission extends BaseEntity<InstrumentPanelPermiss
* 1代表第一版数据,2代表保存发布再次保存得数据 * 1代表第一版数据,2代表保存发布再次保存得数据
*/ */
@ApiModelProperty(value = "1代表第一版数据,2代表保存发布再次保存得数据") @ApiModelProperty(value = "1代表第一版数据,2代表保存发布再次保存得数据")
private Integer published; private String published;
} }
...@@ -8,18 +8,18 @@ public enum PublishedStatus { ...@@ -8,18 +8,18 @@ public enum PublishedStatus {
/** /**
* 发布 * 发布
*/ */
PUBLISHED(1), PUBLISHED("published"),
/** /**
* 待发布 * 待发布
*/ */
WAIT_PUBLISHED(2), WAIT_PUBLISHED("wait_published"),
/** /**
* 下线 * 下线
*/ */
OFFLINE(3), OFFLINE("offline"),
DRAFT(4); DRAFT("draft");
public Integer value; public String value;
PublishedStatus(Integer v) { PublishedStatus(String v) {
value = v; value = v;
}} }}
...@@ -7,6 +7,7 @@ import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo; ...@@ -7,6 +7,7 @@ import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* slm-bi * slm-bi
...@@ -53,7 +54,7 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo ...@@ -53,7 +54,7 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo
* @param panelId * @param panelId
* @param publishedStatus * @param publishedStatus
*/ */
void delConfig(@NotNull String panelId,Integer publishedStatus); void delConfig(@NotNull String panelId,String publishedStatus);
/** /**
* 根据仪表板详情保存仪表盘配置 * 根据仪表板详情保存仪表盘配置
...@@ -61,7 +62,7 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo ...@@ -61,7 +62,7 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo
* @param configDetails * @param configDetails
* @param publishStatus * @param publishStatus
*/ */
void savePanelConfig(String panelId,String configDetails,Integer publishStatus); void savePanelConfig(String panelId,String configDetails,String publishStatus);
/** /**
* 发布仪表板把对应配置状态修改为发布 * 发布仪表板把对应配置状态修改为发布
...@@ -75,12 +76,18 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo ...@@ -75,12 +76,18 @@ public interface InstrumentPanelConfigService extends IService<InstrumentPanelCo
* @param publishStatus * @param publishStatus
* @return * @return
*/ */
List<InstrumentPanelConfig> getConfigByPanelIdAndPublishStatus(String panelId,Integer publishStatus); List<InstrumentPanelConfig> getConfigByPanelIdAndPublishStatus(String panelId,String publishStatus);
/** /**
* 下线仪表盘配置 * 下线仪表盘配置
* @param panelId * @param panelId
* @param publishStatus * @param publishStatus
*/ */
void offlineConfig(String panelId, Integer publishStatus); void offlineConfig(String panelId, String publishStatus);
/**
* 根据仪表id获取仪表板配置
* @param panelId
*/
Map<String,String> getAssemblyConfig(@NotNull String panelId);
} }
...@@ -53,15 +53,17 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan ...@@ -53,15 +53,17 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan
/** /**
* 根据仪表板id删除仪表板权限 * 根据仪表板id删除仪表板权限
* @param panelId * @param panelId
* @param publishStatus
*/ */
void delPermissionByPanelId(@NonNull String panelId,Integer publishStatus); void delPermissionByPanelId(@NonNull String panelId,String publishStatus);
/** /**
* 根据仪表板id获取已经发布的配置 * 根据仪表板id获取已经发布的配置
* @param panelId * @param panelId
* @param publishStatus
* @return * @return
*/ */
List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId,@NonNull Integer publishStatus); List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId,@NonNull String publishStatus);
/** /**
* 根据仪表板详情保存仪表板配置 * 根据仪表板详情保存仪表板配置
...@@ -70,7 +72,7 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan ...@@ -70,7 +72,7 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan
* @param accessType * @param accessType
* @param publishStatus * @param publishStatus
*/ */
void savePanelPermission(List<CustomPermissionDTO> customPermissions,String panelId,String accessType,Integer publishStatus); void savePanelPermission(List<CustomPermissionDTO> customPermissions,String panelId,String accessType,String publishStatus);
/** /**
* 批量发布把对应配置状态更改为发布状态 * 批量发布把对应配置状态更改为发布状态
...@@ -84,7 +86,7 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan ...@@ -84,7 +86,7 @@ public interface InstrumentPanelPermissionService extends IService<InstrumentPan
* @param publishStatus * @param publishStatus
* @return * @return
*/ */
List<InstrumentPanelPermission> getPermissionByPanelIdAndPublishStatus(String panelId, Integer publishStatus); List<InstrumentPanelPermission> getPermissionByPanelIdAndPublishStatus(String panelId, String publishStatus);
/** /**
* 下线仪表板对应权限 * 下线仪表板对应权限
......
...@@ -43,7 +43,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> { ...@@ -43,7 +43,7 @@ public interface InstrumentPanelService extends IService<InstrumentPanel> {
* @param ids * @param ids
* @return * @return
*/ */
void batchPublish(List<String> ids); List<String> batchPublish(List<String> ids);
/** /**
* 删除仪表板 * 删除仪表板
......
...@@ -3,9 +3,11 @@ package com.syc.slm.slmbi.service; ...@@ -3,9 +3,11 @@ 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.InstrumentPanelTree; import com.syc.slm.slmbi.entity.InstrumentPanelTree;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo; import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
...@@ -104,4 +106,12 @@ public interface InstrumentPanelTreeService extends IService<InstrumentPanelTree ...@@ -104,4 +106,12 @@ public interface InstrumentPanelTreeService extends IService<InstrumentPanelTree
* @return * @return
*/ */
List<PanelTreeNodeVo> citeTreeList(String appId, String name); List<PanelTreeNodeVo> citeTreeList(String appId, String name);
/**
* 点击仪表板组件获取对应配置
* @param appId
* @param panelId
* @return
*/
Map<String, String> assembly(String appId, String panelId);
} }
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; ...@@ -5,6 +5,7 @@ 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.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.syc.slm.common.core.constant.SlmConstants; import com.syc.slm.common.core.constant.SlmConstants;
import com.syc.slm.slmbi.dao.InstrumentPanelConfigMapper; import com.syc.slm.slmbi.dao.InstrumentPanelConfigMapper;
import com.syc.slm.slmbi.dto.InstrumentPanelConfigDTO; import com.syc.slm.slmbi.dto.InstrumentPanelConfigDTO;
...@@ -62,7 +63,6 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -62,7 +63,6 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
return getInstrumentPanelConfigVo(instrumentPanelId, PublishedStatus.PUBLISHED); return getInstrumentPanelConfigVo(instrumentPanelId, PublishedStatus.PUBLISHED);
} }
//#todo 未确定
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public InstrumentPanelConfigVo getConfigByPanelId(String instrumentPanelId) { public InstrumentPanelConfigVo getConfigByPanelId(String instrumentPanelId) {
...@@ -78,7 +78,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -78,7 +78,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
InstrumentPanelPermissionDTO permission = config.getPermission(); InstrumentPanelPermissionDTO permission = config.getPermission();
checkAll(appId, config, permission); checkAll(appId, config, permission);
InstrumentPanel panel = panelService.getById(config.getPanelId()); InstrumentPanel panel = panelService.getById(config.getPanelId());
fillPanelProp(permission, panel); fillPanelProp(permission, panel, PublishedStatus.PUBLISHED.value);
log.info("删除仪表板配置详情"); log.info("删除仪表板配置详情");
delConfig(config.getPanelId(), null); delConfig(config.getPanelId(), null);
log.info("保存配置详情"); log.info("保存配置详情");
...@@ -87,23 +87,27 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -87,23 +87,27 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
log.info("删除仪表板权限信息"); log.info("删除仪表板权限信息");
permissionService.delPermissionByPanelId(config.getPanelId(), null); permissionService.delPermissionByPanelId(config.getPanelId(), null);
log.info("保存权限信息"); log.info("保存权限信息");
permissionService.savePanelPermission(permission.getCustomPermissions(), permissionService.savePanelPermission(permission.getCustomPermissions(),panel.getId(), permission.getAccessType(),PublishedStatus.PUBLISHED.value);
panel.getId(),
permission.getAccessType(),
PublishedStatus.PUBLISHED.value);
log.info("更新仪表板树"); log.info("更新仪表板树");
updateTree(config, panel); updateTree(config, panel);
InstrumentPanelDraft draft = draftService.getByPanelId(panel.getId()); InstrumentPanelDraft draft = draftService.getByPanelId(panel.getId());
if (ObjectUtils.isNotEmpty(draft)) { if (ObjectUtils.isNotEmpty(draft)) {
String beforeId =draft.getId();
BeanUtils.copyProperties(panel, draft); BeanUtils.copyProperties(panel, draft);
draft.setId(beforeId);
draft.setPanelId(panel.getId());
draftService.updateById(draft); draftService.updateById(draft);
} else { } else {
InstrumentPanelDraft df = new InstrumentPanelDraft(); InstrumentPanelDraft df = new InstrumentPanelDraft();
BeanUtils.copyProperties(panel, draft); BeanUtils.copyProperties(panel, df);
df.setId(IdWorker.get32UUID());
df.setPanelId(panel.getId());
df.setPublished(PublishedStatus.PUBLISHED.value);
draftService.save(df); draftService.save(df);
} }
panelService.updateById(panel); panelService.updateById(panel);
return panel.getId(); return panel.getId();
} }
...@@ -115,20 +119,16 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -115,20 +119,16 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
checkAll(appId, config, permission); checkAll(appId, config, permission);
InstrumentPanel panel = panelService.getById(config.getPanelId()); InstrumentPanel panel = panelService.getById(config.getPanelId());
fillPanelProp(permission, panel); fillPanelProp(permission, panel,PublishedStatus.WAIT_PUBLISHED.value);
//判断是否有发布版本 //判断是否有发布版本
InstrumentPanelDraft draft = draftService.getByPanelId(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); delConfig(panel.getId(),PublishedStatus.WAIT_PUBLISHED.value);
log.info("保存权限信息"); log.info("删除仪表板权限信息");
permissionService.savePanelPermission(permission.getCustomPermissions(), permissionService.delPermissionByPanelId(config.getPanelId(), PublishedStatus.WAIT_PUBLISHED.value);
panel.getId(),
permission.getAccessType(),
PublishedStatus.WAIT_PUBLISHED.value);
log.info("更新仪表盘树");
treeService.updatePanelTreeFullName(panel.getId(), panel.getName(), panel.getGroupId());
log.info("更新发布版本的groupId"); log.info("更新发布版本的groupId");
draft.setGroupId(permission.getGroupId()); draft.setGroupId(permission.getGroupId());
draftService.updateById(draft); draftService.updateById(draft);
...@@ -137,19 +137,18 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -137,19 +137,18 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
//修改 //修改
log.info("删除仪表板配置详情"); log.info("删除仪表板配置详情");
delConfig(config.getPanelId(), null); delConfig(config.getPanelId(), null);
log.info("保存配置详情");
savePanelConfig(panel.getId(), config.getConfigDetails(), PublishedStatus.WAIT_PUBLISHED.value);
log.info("删除仪表板权限信息"); log.info("删除仪表板权限信息");
permissionService.delPermissionByPanelId(config.getPanelId(), null); permissionService.delPermissionByPanelId(config.getPanelId(), null);
log.info("保存权限信息");
permissionService.savePanelPermission(permission.getCustomPermissions(),
panel.getId(),
permission.getAccessType(),
PublishedStatus.WAIT_PUBLISHED.value);
log.info("更新仪表板树");
updateTree(config, panel);
} }
log.info("保存配置详情");
savePanelConfig(panel.getId(), config.getConfigDetails(), PublishedStatus.WAIT_PUBLISHED.value);
log.info("保存权限信息");
permissionService.savePanelPermission(permission.getCustomPermissions(),panel.getId(),permission.getAccessType(),PublishedStatus.WAIT_PUBLISHED.value);
log.info("更新仪表板树");
updateTree(config, panel);
panelService.updateById(panel); panelService.updateById(panel);
return config.getPanelId(); return config.getPanelId();
} }
...@@ -161,12 +160,15 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -161,12 +160,15 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
if (StringUtils.isEmpty(permission.getPanelName())) { if (StringUtils.isEmpty(permission.getPanelName())) {
throw new SysException("仪表板名字必填"); throw new SysException("仪表板名字必填");
} }
if (StringUtils.isEmpty(permission.getGroupId())) {
throw new SysException("仪表板分组必填");
}
log.info("校验仪表板名称是否重复"); log.info("校验仪表板名称是否重复");
panelService.checkName(appId, config.getPanelId(), permission.getPanelName()); panelService.checkName(appId, config.getPanelId(), permission.getPanelName());
} }
@Override @Override
public void delConfig(@NotNull String panelId, Integer publishedStatus) { public void delConfig(@NotNull String panelId, String publishedStatus) {
List<InstrumentPanelConfig> configs = getConfigByPanelIdAndPublishStatus(panelId,publishedStatus); List<InstrumentPanelConfig> configs = getConfigByPanelIdAndPublishStatus(panelId,publishedStatus);
if (CollectionUtils.isNotEmpty(configs)) { if (CollectionUtils.isNotEmpty(configs)) {
configs.forEach(x -> { configs.forEach(x -> {
...@@ -177,7 +179,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -177,7 +179,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
} }
@Override @Override
public void savePanelConfig(String panelId, String configDetails, Integer publishStatus) { public void savePanelConfig(String panelId, String configDetails, String publishStatus) {
InstrumentPanelConfig panelConfig = new InstrumentPanelConfig(); InstrumentPanelConfig panelConfig = new InstrumentPanelConfig();
panelConfig.setId(IdWorker.get32UUID()); panelConfig.setId(IdWorker.get32UUID());
panelConfig.setPanelId(panelId); panelConfig.setPanelId(panelId);
...@@ -225,7 +227,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -225,7 +227,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<InstrumentPanelConfig> getConfigByPanelIdAndPublishStatus(String panelId, Integer publishStatus) { public List<InstrumentPanelConfig> getConfigByPanelIdAndPublishStatus(String panelId, String publishStatus) {
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID); where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, panelId); where.eq(InstrumentPanelConfig::getPanelId, panelId);
...@@ -236,7 +238,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -236,7 +238,7 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
} }
@Override @Override
public void offlineConfig(String panelId, Integer publishStatus) { public void offlineConfig(String panelId, String publishStatus) {
List<InstrumentPanelConfig> configs = getConfigByPanelIdAndPublishStatus(panelId, publishStatus); List<InstrumentPanelConfig> configs = getConfigByPanelIdAndPublishStatus(panelId, publishStatus);
InstrumentPanelConfig waitConfig = configs.stream() InstrumentPanelConfig waitConfig = configs.stream()
...@@ -268,41 +270,81 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane ...@@ -268,41 +270,81 @@ public class InstrumentPanelConfigServiceImpl extends ServiceImpl<InstrumentPane
} }
} }
@Override
@Transactional
public Map<String, String> getAssemblyConfig(@NotNull String panelId) {
Map<String,String> maps = Maps.newHashMap();
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, panelId);
List<InstrumentPanelConfig> configs = baseMapper.selectList(where);
if(CollectionUtils.isNotEmpty(configs)){
InstrumentPanelConfig waitConfig = configs.stream()
.filter(x -> PublishedStatus.WAIT_PUBLISHED.value.equals(x.getPublished()))
.findFirst()
.orElse(null);
if(ObjectUtils.isNotEmpty(waitConfig)){
try {
maps.put(PublishedStatus.WAIT_PUBLISHED.value,URLDecoder.decode(waitConfig.getConfigDetails(),StandardCharsets.UTF_8.name()));
}catch (Exception e){
e.printStackTrace();
}
}
InstrumentPanelConfig publishConfig = configs.stream()
.filter(x -> PublishedStatus.PUBLISHED.value.equals(x.getPublished()))
.findFirst()
.orElse(null);
if(ObjectUtils.isNotEmpty(publishConfig)){
try {
maps.put(PublishedStatus.PUBLISHED.value,URLDecoder.decode(publishConfig.getConfigDetails(),StandardCharsets.UTF_8.name()));
}catch (Exception e){
e.printStackTrace();
}
}
}
return maps;
}
private InstrumentPanelConfigVo getInstrumentPanelConfigVo(String instrumentPanelId, PublishedStatus published) { private InstrumentPanelConfigVo getInstrumentPanelConfigVo(String instrumentPanelId, PublishedStatus published) {
LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstrumentPanelConfig> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID); where.eq(BaseEntity::getRecordStatus, SlmConstants.DATA_VALID);
where.eq(InstrumentPanelConfig::getPanelId, instrumentPanelId); where.eq(InstrumentPanelConfig::getPanelId, instrumentPanelId);
where.eq(InstrumentPanelConfig::getPublished, published.value); where.eq(InstrumentPanelConfig::getPublished, published.value);
InstrumentPanelConfig config = baseMapper.selectOne(where); InstrumentPanelConfig config = baseMapper.selectOne(where);
InstrumentPanelConfigVo vo = new InstrumentPanelConfigVo(); if(ObjectUtils.isNotEmpty(config)) {
BeanUtils.copyProperties(config, vo); InstrumentPanelConfigVo vo = new InstrumentPanelConfigVo();
if (ObjectUtils.isNotEmpty(vo)) { BeanUtils.copyProperties(config, vo);
try { if (ObjectUtils.isNotEmpty(vo)) {
vo.setConfigDetails(URLDecoder.decode(vo.getConfigDetails(), StandardCharsets.UTF_8.name())); try {
} catch (Exception e) { vo.setConfigDetails(URLDecoder.decode(vo.getConfigDetails(), StandardCharsets.UTF_8.name()));
e.printStackTrace(); } catch (Exception e) {
throw new SysException("仪表板配置详情解密异常"); e.printStackTrace();
} throw new SysException("仪表板配置详情解密异常");
vo.setPermissions(permissionService.getPublishPermissionByPanelId(instrumentPanelId, published.value)); }
InstrumentPanelVo panelVo = new InstrumentPanelVo(); vo.setPermissions(permissionService.getPublishPermissionByPanelId(instrumentPanelId, published.value));
if (PublishedStatus.PUBLISHED.value.equals(published.value)) { InstrumentPanelVo panelVo = new InstrumentPanelVo();
InstrumentPanelDraft panel = draftService.getById(instrumentPanelId); if (PublishedStatus.PUBLISHED.value.equals(published.value)) {
BeanUtils.copyProperties(panel, panelVo); InstrumentPanelDraft panel = draftService.getById(instrumentPanelId);
BeanUtils.copyProperties(panel, panelVo);
} else {
InstrumentPanel panel = panelService.getById(instrumentPanelId); } else {
BeanUtils.copyProperties(panel, panelVo); InstrumentPanel panel = panelService.getById(instrumentPanelId);
BeanUtils.copyProperties(panel, panelVo);
}
vo.setPanel(panelVo);
return vo;
} }
vo.setPanel(panelVo);
} }
return vo; return null;
} }
private void fillPanelProp(InstrumentPanelPermissionDTO permission, InstrumentPanel panel) { private void fillPanelProp(InstrumentPanelPermissionDTO permission, InstrumentPanel panel,String publishStatus) {
panel.setGroupId(permission.getGroupId()); panel.setGroupId(permission.getGroupId());
panel.setName(permission.getPanelName()); panel.setName(permission.getPanelName());
panel.setAccessPermission(permission.getAccessType()); panel.setAccessPermission(permission.getAccessType());
panel.setDescription(permission.getDescription()); panel.setDescription(permission.getDescription());
panel.setPublished(publishStatus);
} }
private void updateTree(InstrumentPanelConfigDTO config, InstrumentPanel panel) { private void updateTree(InstrumentPanelConfigDTO config, InstrumentPanel panel) {
......
...@@ -62,11 +62,7 @@ public class InstrumentPanelDraftServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -62,11 +62,7 @@ public class InstrumentPanelDraftServiceImpl extends ServiceImpl<InstrumentPanel
} }
@Override @Override
public List<InstrumentPanelDraft> selectDraftList(String appId, public List<InstrumentPanelDraft> selectDraftList(String appId, Set<String> panelIds, String officeIds, String userId, String roleId) {
Set<String> panelIds,
String officeIds,
String userId,
String roleId) {
return baseMapper.selectDraftList(appId, panelIds, officeIds, userId, roleId); return baseMapper.selectDraftList(appId, panelIds, officeIds, userId, roleId);
} }
......
...@@ -117,6 +117,9 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel ...@@ -117,6 +117,9 @@ public class InstrumentPanelGroupServiceImpl extends ServiceImpl<InstrumentPanel
if(StringUtils.isEmpty(group.getName())){ if(StringUtils.isEmpty(group.getName())){
throw new SysException("仪表板分组名称必填"); throw new SysException("仪表板分组名称必填");
} }
if(StringUtils.isEmpty(group.getParentId())){
throw new SysException("父级分组必填");
}
log.info("检查分组名字是否重复"); log.info("检查分组名字是否重复");
checkedRepeatName.call(group,appId); checkedRepeatName.call(group,appId);
InstrumentPanelGroup entity = new InstrumentPanelGroup(); InstrumentPanelGroup entity = new InstrumentPanelGroup();
......
...@@ -70,7 +70,8 @@ public class InstrumentPanelPermissionImpl ...@@ -70,7 +70,8 @@ public class InstrumentPanelPermissionImpl
InstrumentPanel panel = panelService.getById(permissions.getPanelId()); InstrumentPanel panel = panelService.getById(permissions.getPanelId());
panel.setName(permissions.getPanelName()); panel.setName(permissions.getPanelName());
panel.setGroupId(permissions.getGroupId()); panel.setGroupId(permissions.getGroupId());
permissions.setAccessType(permissions.getAccessType()); panel.setAccessPermission(permissions.getAccessType());
panel.setDescription(permissions.getDescription());
log.info("删除原本的权限"); log.info("删除原本的权限");
delPermissionByPanelId(permissions.getPanelId(), PublishedStatus.WAIT_PUBLISHED.value); delPermissionByPanelId(permissions.getPanelId(), PublishedStatus.WAIT_PUBLISHED.value);
...@@ -97,10 +98,14 @@ public class InstrumentPanelPermissionImpl ...@@ -97,10 +98,14 @@ public class InstrumentPanelPermissionImpl
throw new SysException("访问权限类型必填"); throw new SysException("访问权限类型必填");
} }
List<InstrumentPanel> panels = panelService.getByIds(Sets.newHashSet(otherInstrumentPanelIds)); List<InstrumentPanel> panels = panelService.getByIds(Sets.newHashSet(otherInstrumentPanelIds));
if(CollectionUtils.isEmpty(panels)){
throw new SysException("查找不到对应的仪表板,请联系管理员");
}
panels.forEach(panel->{ panels.forEach(panel->{
panel.setAccessPermission(permissions.getAccessType()); panel.setAccessPermission(permissions.getAccessType());
panel.setDescription(permissions.getDescription());
log.info("删除原本的权限"); log.info("删除原本的权限");
delPermissionByPanelId(permissions.getPanelId(), PublishedStatus.WAIT_PUBLISHED.value); delPermissionByPanelId(panel.getId(), PublishedStatus.WAIT_PUBLISHED.value);
log.info("插入现有的权限"); log.info("插入现有的权限");
savePanelPermission(permissions.getCustomPermissions(), panel.getId(), panel.getAccessPermission(), PublishedStatus.WAIT_PUBLISHED.value); savePanelPermission(permissions.getCustomPermissions(), panel.getId(), panel.getAccessPermission(), PublishedStatus.WAIT_PUBLISHED.value);
...@@ -116,6 +121,7 @@ public class InstrumentPanelPermissionImpl ...@@ -116,6 +121,7 @@ public class InstrumentPanelPermissionImpl
InstrumentPanelPermissionVo vo = new InstrumentPanelPermissionVo(); InstrumentPanelPermissionVo vo = new InstrumentPanelPermissionVo();
InstrumentPanel panel = panelService.getById(instrumentPanelId); InstrumentPanel panel = panelService.getById(instrumentPanelId);
vo.setAccessType(panel.getAccessPermission()); vo.setAccessType(panel.getAccessPermission());
vo.setDescription(panel.getDescription());
List<CustomPermissionVo> vos = getPublishPermissionByPanelId(instrumentPanelId, PublishedStatus.WAIT_PUBLISHED.value); List<CustomPermissionVo> vos = getPublishPermissionByPanelId(instrumentPanelId, PublishedStatus.WAIT_PUBLISHED.value);
if(CollectionUtils.isEmpty(vos)){ if(CollectionUtils.isEmpty(vos)){
vos = getPublishPermissionByPanelId(instrumentPanelId, PublishedStatus.PUBLISHED.value); vos = getPublishPermissionByPanelId(instrumentPanelId, PublishedStatus.PUBLISHED.value);
...@@ -125,7 +131,7 @@ public class InstrumentPanelPermissionImpl ...@@ -125,7 +131,7 @@ public class InstrumentPanelPermissionImpl
} }
@Override @Override
public void delPermissionByPanelId(@NonNull String panelId, Integer publishStatus) { public void delPermissionByPanelId(@NonNull String panelId, String publishStatus) {
List<InstrumentPanelPermission> permissions =getPermissionByPanelIdAndPublishStatus(panelId,publishStatus); List<InstrumentPanelPermission> permissions =getPermissionByPanelIdAndPublishStatus(panelId,publishStatus);
if (CollectionUtils.isNotEmpty(permissions)) { if (CollectionUtils.isNotEmpty(permissions)) {
permissions.forEach(x -> { permissions.forEach(x -> {
...@@ -138,7 +144,7 @@ public class InstrumentPanelPermissionImpl ...@@ -138,7 +144,7 @@ public class InstrumentPanelPermissionImpl
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId, public List<CustomPermissionVo> getPublishPermissionByPanelId(@NonNull String panelId,
@NonNull Integer publishStatus) { @NonNull String publishStatus) {
List<InstrumentPanelPermission> permissions = getPermissionByPanelIdAndPublishStatus(panelId,publishStatus); List<InstrumentPanelPermission> permissions = getPermissionByPanelIdAndPublishStatus(panelId,publishStatus);
return CollectionUtils.isNotEmpty(permissions) ? SlmConstants.gson.fromJson(SlmConstants.gson.toJson(permissions), new TypeToken<List<CustomPermissionVo>>() {}.getType()) : null; return CollectionUtils.isNotEmpty(permissions) ? SlmConstants.gson.fromJson(SlmConstants.gson.toJson(permissions), new TypeToken<List<CustomPermissionVo>>() {}.getType()) : null;
} }
...@@ -147,7 +153,7 @@ public class InstrumentPanelPermissionImpl ...@@ -147,7 +153,7 @@ public class InstrumentPanelPermissionImpl
public void savePanelPermission(List<CustomPermissionDTO> customPermissions, public void savePanelPermission(List<CustomPermissionDTO> customPermissions,
String panelId, String panelId,
String accessType, String accessType,
Integer publishStatus) { String publishStatus) {
if (CollectionUtils.isNotEmpty(customPermissions)) { if (CollectionUtils.isNotEmpty(customPermissions)) {
if (AccessType.CUSTOM.value.equals(accessType)) { if (AccessType.CUSTOM.value.equals(accessType)) {
if (CollectionUtils.isNotEmpty(customPermissions)) { if (CollectionUtils.isNotEmpty(customPermissions)) {
...@@ -195,7 +201,7 @@ public class InstrumentPanelPermissionImpl ...@@ -195,7 +201,7 @@ public class InstrumentPanelPermissionImpl
} }
@Override @Override
public List<InstrumentPanelPermission> getPermissionByPanelIdAndPublishStatus(String panelId, Integer publishStatus) { public List<InstrumentPanelPermission> getPermissionByPanelIdAndPublishStatus(String panelId, String publishStatus) {
LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstrumentPanelPermission> where = new LambdaQueryWrapper<>();
where.eq(InstrumentPanelPermission::getPanelId, panelId); where.eq(InstrumentPanelPermission::getPanelId, panelId);
where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID); where.eq(InstrumentPanelPermission::getRecordStatus, SlmConstants.DATA_VALID);
......
...@@ -61,7 +61,13 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -61,7 +61,13 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
public IPage<InstrumentPanelVo> selectInstrumentPanelList(String appId, QueryInstrumentPanelDTO query) { public IPage<InstrumentPanelVo> selectInstrumentPanelList(String appId, QueryInstrumentPanelDTO query) {
IPage<InstrumentPanelVo> page = new Page<>(query.getCurrent(), query.getSize()); IPage<InstrumentPanelVo> page = new Page<>(query.getCurrent(), query.getSize());
QueryWrapper<InstrumentPanel> where = new QueryWrapper<>(); QueryWrapper<InstrumentPanel> where = new QueryWrapper<>();
if(StringUtils.isEmpty(appId)){
throw new SysException("appId必须传入");
}
where.eq("p.app_id", appId); where.eq("p.app_id", appId);
if(StringUtils.isEmpty(query.getGroupId())){
throw new SysException("必须选择需要查询的仪表板分组");
}
where.eq("p.group_id", query.getGroupId()); where.eq("p.group_id", query.getGroupId());
where.eq("p.record_status", SlmConstants.DATA_VALID); where.eq("p.record_status", SlmConstants.DATA_VALID);
if (StringUtils.isNotEmpty(query.getName())) { if (StringUtils.isNotEmpty(query.getName())) {
...@@ -94,7 +100,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -94,7 +100,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void batchPublish(List<String> ids) { public List<String> batchPublish(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
throw new SysException("请选择你要操作的数据"); throw new SysException("请选择你要操作的数据");
} }
...@@ -111,7 +117,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -111,7 +117,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
log.info("复制一份草稿"); log.info("复制一份草稿");
draftService.saveDrafts(panels); draftService.saveDrafts(panels);
} }
return ids;
} }
@Override @Override
...@@ -201,7 +207,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe ...@@ -201,7 +207,7 @@ public class InstrumentPanelServiceImpl extends ServiceImpl<InstrumentPanelMappe
wrapper.eq(InstrumentPanel::getAppId, appId); wrapper.eq(InstrumentPanel::getAppId, appId);
wrapper.eq(InstrumentPanel::getRecordStatus, SlmConstants.DATA_VALID); wrapper.eq(InstrumentPanel::getRecordStatus, SlmConstants.DATA_VALID);
if (StringUtils.isNotEmpty(panelId)) { if (StringUtils.isNotEmpty(panelId)) {
wrapper.eq(InstrumentPanel::getId, panelId); wrapper.ne(InstrumentPanel::getId, panelId);
} }
if (baseMapper.selectCount(wrapper) > 0) { if (baseMapper.selectCount(wrapper) > 0) {
throw new SysException("仪表板名字:" + panelName + "已存在!"); throw new SysException("仪表板名字:" + panelName + "已存在!");
......
...@@ -2,10 +2,12 @@ package com.syc.slm.slmbi.service.impl; ...@@ -2,10 +2,12 @@ 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.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; 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.Lists;
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,15 +15,15 @@ import com.syc.slm.slmbi.dao.InstrumentPanelTreeMapper; ...@@ -13,15 +15,15 @@ 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.*; import com.syc.slm.slmbi.entity.*;
import com.syc.slm.slmbi.enums.NodeType; import com.syc.slm.slmbi.enums.NodeType;
import com.syc.slm.slmbi.enums.PublishedStatus;
import com.syc.slm.slmbi.exception.SysException; import com.syc.slm.slmbi.exception.SysException;
import com.syc.slm.slmbi.service.InstrumentPanelDraftService; import com.syc.slm.slmbi.service.*;
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.vo.CustomPermissionVo; import com.syc.slm.slmbi.vo.CustomPermissionVo;
import com.syc.slm.slmbi.vo.InstrumentPanelConfigVo;
import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo; import com.syc.slm.slmbi.vo.InstrumentPanelGroupVo;
import com.syc.slm.slmbi.vo.PanelTreeNodeVo; import com.syc.slm.slmbi.vo.PanelTreeNodeVo;
import lombok.NonNull; import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.filefilter.FalseFileFilter; import org.apache.commons.io.filefilter.FalseFileFilter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -37,6 +39,7 @@ import java.util.stream.Collectors; ...@@ -37,6 +39,7 @@ import java.util.stream.Collectors;
* @date 2021-04-01 10:52:44 * @date 2021-04-01 10:52:44
*/ */
@Service @Service
@Slf4j
public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelTreeMapper, InstrumentPanelTree> public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelTreeMapper, InstrumentPanelTree>
implements InstrumentPanelTreeService { implements InstrumentPanelTreeService {
...@@ -45,6 +48,8 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -45,6 +48,8 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
@Autowired @Autowired
private InstrumentPanelGroupService groupService; private InstrumentPanelGroupService groupService;
@Autowired
private InstrumentPanelConfigService configService;
@Autowired @Autowired
private InstrumentPanelService panelService; private InstrumentPanelService panelService;
...@@ -87,19 +92,20 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -87,19 +92,20 @@ 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++) { assembly.forEach(x->{
if(StringUtils.isBlank(assembly.get(i).getName()) || StringUtils.isBlank(assembly.get(i).getKey())){ if(StringUtils.isBlank(x.getName()) || StringUtils.isBlank(x.getKey())){
throw new SysException("主键名称或者key不能为空,请联系管理员"); log.info("不要传入空得组件树");
} }else {
InstrumentPanelTree t = new InstrumentPanelTree(); InstrumentPanelTree t = new InstrumentPanelTree();
t.setId(tree.getId() + "_" + i); t.setId(IdWorker.get32UUID());
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() + "." + x.getName());
t.setAssemblyKey(assembly.get(i).getKey()); t.setAssemblyKey(x.getKey());
t.setName(assembly.get(i).getName()); t.setName(x.getName());
baseMapper.insert(t); baseMapper.insert(t);
} }
});
} }
} }
...@@ -318,16 +324,24 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -318,16 +324,24 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
InstrumentPanelTree panelTree = baseMapper.selectById(panelId); InstrumentPanelTree panelTree = baseMapper.selectById(panelId);
String beforeFullName = panelTree.getFullName(); String beforeFullName = panelTree.getFullName();
String beforeFullId = panelTree.getFullId(); String beforeFullId = panelTree.getFullId();
log.info("更新自身的树状结构");
panelTree.setFullName(group.getFullName()+"."+panelName);
panelTree.setFullId(group.getFullId()+"."+panelId);
panelTree.setName(panelName);
baseMapper.updateById(panelTree);
if(ObjectUtils.isNotEmpty(group)){ if(ObjectUtils.isNotEmpty(group)){
log.info("更新组件的树状结构");
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, group.getFullId() + "."); where.likeRight(InstrumentPanelTree::getFullId, beforeFullId+".");
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.setFullId(x.getFullId().replace(beforeFullId, group.getFullId())); x.setFullId(x.getFullId().replace(beforeFullId, panelTree.getFullId()));
String name = x.getFullName().substring(x.getFullName().lastIndexOf(beforeFullName)); String name = x.getFullName().substring(beforeFullName.length()+1);
x.setFullName(group.getFullName()+"." + name); x.setFullName(panelTree.getFullName()+"." + name);
x.setName(name); x.setName(name);
baseMapper.updateById(x); baseMapper.updateById(x);
}); });
...@@ -347,6 +361,11 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT ...@@ -347,6 +361,11 @@ public class InstrumentPanelTreeServiceImpl extends ServiceImpl<InstrumentPanelT
return getCopyAndCiteTrees(appId, name, true); return getCopyAndCiteTrees(appId, name, true);
} }
@Override
public Map<String, String> assembly(String appId, String panelId) {
return configService.getAssemblyConfig(panelId);
}
private List<PanelTreeNodeVo> getCopyAndCiteTrees(String appId, String name,boolean showAssembly) { private List<PanelTreeNodeVo> getCopyAndCiteTrees(String appId, String name,boolean showAssembly) {
LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstrumentPanelTree> where = new LambdaQueryWrapper<>();
where.eq(BaseEntity::getAppId, appId); where.eq(BaseEntity::getAppId, appId);
......
...@@ -22,6 +22,8 @@ public class InstrumentPanelPermissionVo { ...@@ -22,6 +22,8 @@ public class InstrumentPanelPermissionVo {
@ApiModelProperty(value = "访问权限类型", required = true) @ApiModelProperty(value = "访问权限类型", required = true)
private String accessType; private String accessType;
@ApiModelProperty(value = "描述", required = true)
private String description;
@ApiModelProperty(value = "自定义权限配置,当访问类型为CUSTOM时必填") @ApiModelProperty(value = "自定义权限配置,当访问类型为CUSTOM时必填")
private List<CustomPermissionVo> customPermissions; private List<CustomPermissionVo> customPermissions;
......
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