19 changed files with 1102 additions and 11 deletions
-
2modules/carbon-track/src/main/java/com/thing/carbontrack/event/standardcal/listener/ProductionResultListener.java
-
2modules/carbon-track/src/main/java/com/thing/carbontrack/productionResult/service/impl/IotCarbonProductionResultServiceImpl.java
-
2modules/configuration/src/main/java/com/thing/configuration/newmaterial/service/impl/IotNewSourceMaterialServiceImpl.java
-
155modules/visual-design/src/main/java/com/thing/visual/board/controller/IotVisualManageController.java
-
66modules/visual-design/src/main/java/com/thing/visual/board/dto/IotVisualManageDTO.java
-
56modules/visual-design/src/main/java/com/thing/visual/board/entity/IotVisualManageEntity.java
-
28modules/visual-design/src/main/java/com/thing/visual/board/excel/IotVisualManageExcel.java
-
17modules/visual-design/src/main/java/com/thing/visual/board/mapper/IotVisualManageMapper.java
-
42modules/visual-design/src/main/java/com/thing/visual/board/service/IotVisualManageService.java
-
367modules/visual-design/src/main/java/com/thing/visual/board/service/impl/IotVisualManageServiceImpl.java
-
2modules/visual-design/src/main/java/com/thing/visual/component/service/impl/IotVisualComponentServiceImpl.java
-
74modules/visual-design/src/main/java/com/thing/visual/configuration/controller/IotVisualDesignController.java
-
43modules/visual-design/src/main/java/com/thing/visual/configuration/dto/IotVisualDesignDTO.java
-
51modules/visual-design/src/main/java/com/thing/visual/configuration/entity/IotVisualDesignEntity.java
-
16modules/visual-design/src/main/java/com/thing/visual/configuration/mapper/IotVisualDesignMapper.java
-
28modules/visual-design/src/main/java/com/thing/visual/configuration/service/IotVisualDesignService.java
-
140modules/visual-design/src/main/java/com/thing/visual/configuration/service/impl/IotVisualDesignServiceImpl.java
-
16modules/visual-design/src/main/java/com/thing/visual/group/controller/IotVisualGroupController.java
-
6modules/visual-design/src/main/java/com/thing/visual/group/service/impl/IotVisualGroupServiceImpl.java
@ -0,0 +1,155 @@ |
|||||
|
package com.thing.visual.board.controller; |
||||
|
|
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.thing.common.core.annotation.LogOperation; |
||||
|
import com.thing.common.core.constants.Constant; |
||||
|
import com.thing.common.core.enumeration.IsDefaultEnum; |
||||
|
import com.thing.common.core.utils.JsonProcessingUtils; |
||||
|
import com.thing.common.core.validator.AssertUtils; |
||||
|
import com.thing.common.core.validator.ValidatorUtils; |
||||
|
import com.thing.common.core.validator.group.AddGroup; |
||||
|
import com.thing.common.core.validator.group.DefaultGroup; |
||||
|
import com.thing.common.core.validator.group.UpdateGroup; |
||||
|
import com.thing.common.core.web.response.PageData; |
||||
|
import com.thing.common.core.web.response.Result; |
||||
|
import com.thing.sys.security.context.UserContext; |
||||
|
import com.thing.visual.board.dto.IotVisualManageDTO; |
||||
|
import com.thing.visual.board.service.IotVisualManageService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.Parameters; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("v2/visual/manage") |
||||
|
@Tag(name="新组态大屏管理") |
||||
|
public class IotVisualManageController { |
||||
|
@Autowired |
||||
|
private IotVisualManageService iotVisualManageService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
@Operation(summary="分页") |
||||
|
@Parameters({ |
||||
|
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始") , |
||||
|
@Parameter(name = Constant.LIMIT,description ="每页显示记录数") , |
||||
|
@Parameter(name = Constant.ORDER_FIELD,description ="排序字段") , |
||||
|
@Parameter(name = Constant.ORDER,description ="排序方式,可选值(asc、desc)"), |
||||
|
@Parameter(name ="name",description ="看板名称"), |
||||
|
@Parameter(name ="type",description ="看板类型") |
||||
|
}) |
||||
|
public Result<PageData<IotVisualManageDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<IotVisualManageDTO> page = iotVisualManageService.pageIotBoardManageDTO(params); |
||||
|
|
||||
|
return new Result<PageData<IotVisualManageDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
@Operation(summary="信息") |
||||
|
public Result<IotVisualManageDTO> get(@PathVariable("id") Long id){ |
||||
|
IotVisualManageDTO data = iotVisualManageService.getIotBoardManageDTO(id); |
||||
|
checkParam(data); |
||||
|
return new Result<IotVisualManageDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
public static void checkParam(IotVisualManageDTO data) { |
||||
|
if(ObjectUtil.equals(data.getIsTemplate(), IsDefaultEnum.Y.getValue())) { |
||||
|
if(!"1001".equals(String.valueOf(UserContext.getTenantCode()))){ |
||||
|
data.setIsOperate("1"); |
||||
|
} |
||||
|
} |
||||
|
if (!String.valueOf(data.getTenantCode()).equals(String.valueOf(UserContext.getTenantCode()))){ |
||||
|
if(!UserContext.isAdmin()){ |
||||
|
data.setIsOperate("1"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
@Operation(summary="保存") |
||||
|
@LogOperation("保存") |
||||
|
public Result save(@RequestBody IotVisualManageDTO dto){ |
||||
|
//效验数据 |
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
|
||||
|
return iotVisualManageService.saveIotBoardManageDTO(dto); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
@Operation(summary="修改") |
||||
|
@LogOperation("修改") |
||||
|
public Result update(@RequestBody IotVisualManageDTO dto){ |
||||
|
//效验数据 |
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
|
||||
|
iotVisualManageService.updateIotBoardManageDTO(dto); |
||||
|
|
||||
|
return new Result().ok("修改成功!"); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
@Operation(summary="删除") |
||||
|
@LogOperation("删除") |
||||
|
public Result delete(@RequestBody Long[] ids){ |
||||
|
//效验数据 |
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
|
||||
|
return iotVisualManageService.deleteIotBoardManageDTO(ids); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
@Operation(summary="导出") |
||||
|
@Parameters({ |
||||
|
@Parameter(name ="name",description ="看板名称"), |
||||
|
@Parameter(name ="type",description ="看板类型") |
||||
|
}) |
||||
|
public void export( @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<IotVisualManageDTO> list = iotVisualManageService.listIotBoardManageDTO(params); |
||||
|
JsonProcessingUtils.exportJson(response, list, "group.json"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("importJson") |
||||
|
@Operation(summary="json导入,返回失败的数据信息") |
||||
|
public Result<List<IotVisualManageDTO>> importJson(MultipartFile file, HttpServletRequest request) { |
||||
|
return new Result<List<IotVisualManageDTO>>().ok(iotVisualManageService.importJson(file, request)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping("getAllTemplate") |
||||
|
@Operation(summary="获取所有为模板的大屏数据") |
||||
|
public Result<List<IotVisualManageDTO>> getAllTemplate(){ |
||||
|
return new Result<List<IotVisualManageDTO>>().ok(iotVisualManageService.getAllTemplate()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("getAllType") |
||||
|
@Operation(summary="获取所有看板类型") |
||||
|
public Result<Set<String>> getAllType(){ |
||||
|
return new Result<Set<String>>().ok(iotVisualManageService.getAllType()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/copy/{id}") |
||||
|
@Operation(summary="复制") |
||||
|
public Result copy(@PathVariable("id") Long id){ |
||||
|
return iotVisualManageService.copy(id); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
package com.thing.visual.board.dto; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.thing.common.core.utils.DateTimeUtils; |
||||
|
import com.thing.sys.biz.dto.SysMenuDTO; |
||||
|
import com.thing.visual.configuration.dto.IotVisualDesignDTO; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Schema( name= "组态大屏管理") |
||||
|
public class IotVisualManageDTO implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@Schema(description = "看板id主键") |
||||
|
private Long id; |
||||
|
@Schema(description = "看板名称") |
||||
|
private String name; |
||||
|
@Schema(description = "看板类型") |
||||
|
private String type; |
||||
|
@Schema(description = "缩略图url") |
||||
|
private String thumbnailUrl; |
||||
|
@Schema(description = "看板详情的背景图片") |
||||
|
private String backgroundImage; |
||||
|
@Schema(description = "看板详情的颜色") |
||||
|
private String backgroundColor; |
||||
|
@Schema(description = "看板详情的对比度") |
||||
|
private String backgroundRepeat; |
||||
|
@Schema(description = "看板详情的尺寸") |
||||
|
private String backgroundSize; |
||||
|
@Schema(description = "是否默认背景") |
||||
|
private Boolean isDefaultBackImg; |
||||
|
@Schema(description = "是否为模板") |
||||
|
private Object isTemplate; |
||||
|
@Schema(description = "备注") |
||||
|
private String remarks; |
||||
|
@Schema(description = "配置菜单信息") |
||||
|
private SysMenuDTO sysMenuDTO; |
||||
|
@Schema(description = "看板预览url") |
||||
|
private String previewUrl; |
||||
|
@Schema(description = "模板id") |
||||
|
private String templateId; |
||||
|
private IotVisualDesignDTO iotConfigurationDesigDTO; |
||||
|
@Schema(description = "是否可操作编辑,0可编辑,1不可编辑") |
||||
|
private String isOperate; |
||||
|
@Schema(description = "创建时间") |
||||
|
@JsonFormat(pattern = DateTimeUtils.DATE_TIME_PATTERN_STR) |
||||
|
private Long createDate; |
||||
|
|
||||
|
@Schema(description = "所属企业(租户code)") |
||||
|
private Long tenantCode; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
package com.thing.visual.board.entity; |
||||
|
|
||||
|
import com.mybatisflex.annotation.Table; |
||||
|
import com.thing.common.orm.entity.BaseInfoEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import lombok.experimental.Accessors; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Accessors(chain = true) |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@Table("iot_visual_manage") |
||||
|
public class IotVisualManageEntity extends BaseInfoEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 看板名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
/** |
||||
|
* 看板类型 |
||||
|
*/ |
||||
|
private String type; |
||||
|
/** |
||||
|
* 缩略图url |
||||
|
*/ |
||||
|
private String thumbnailUrl; |
||||
|
/** |
||||
|
* 看板详情的背景图片 |
||||
|
*/ |
||||
|
private String backgroundImage; |
||||
|
/** |
||||
|
* 是否为模板 |
||||
|
*/ |
||||
|
private Object isTemplate; |
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remarks; |
||||
|
|
||||
|
/** |
||||
|
* 看板预览url |
||||
|
*/ |
||||
|
private String previewUrl; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
package com.thing.visual.board.excel; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class IotVisualManageExcel { |
||||
|
private Long id; |
||||
|
private String name; |
||||
|
private String type; |
||||
|
private String thumbnailUrl; |
||||
|
private Object isTemplate; |
||||
|
private String remarks; |
||||
|
private Long tenantCode; |
||||
|
private Long companyId; |
||||
|
private Long deptId; |
||||
|
private Long creator; |
||||
|
private Date createDate; |
||||
|
private Long updater; |
||||
|
private Date updateDate; |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.thing.visual.board.mapper; |
||||
|
|
||||
|
|
||||
|
import com.thing.common.orm.mapper.PowerBaseMapper; |
||||
|
import com.thing.visual.board.entity.IotVisualManageEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface IotVisualManageMapper extends PowerBaseMapper<IotVisualManageEntity> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
package com.thing.visual.board.service; |
||||
|
|
||||
|
import com.thing.common.core.web.response.PageData; |
||||
|
import com.thing.common.core.web.response.Result; |
||||
|
import com.thing.common.orm.service.IBaseService; |
||||
|
import com.thing.visual.board.dto.IotVisualManageDTO; |
||||
|
import com.thing.visual.board.entity.IotVisualManageEntity; |
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
public interface IotVisualManageService extends IBaseService<IotVisualManageEntity> { |
||||
|
|
||||
|
Result saveIotBoardManageDTO(IotVisualManageDTO dto); |
||||
|
|
||||
|
PageData<IotVisualManageDTO> pageIotBoardManageDTO(Map<String, Object> params); |
||||
|
|
||||
|
void updateIotBoardManageDTO(IotVisualManageDTO dto); |
||||
|
|
||||
|
Result deleteIotBoardManageDTO(Long[] ids); |
||||
|
|
||||
|
IotVisualManageDTO getIotBoardManageDTO(Long id); |
||||
|
|
||||
|
List<IotVisualManageDTO> importJson(MultipartFile file, HttpServletRequest request); |
||||
|
|
||||
|
List<IotVisualManageDTO> getAllTemplate(); |
||||
|
|
||||
|
Set<String> getAllType(); |
||||
|
|
||||
|
Result copy(Long id); |
||||
|
|
||||
|
List<IotVisualManageDTO> listIotBoardManageDTO(Map<String, Object> params); |
||||
|
} |
||||
@ -0,0 +1,367 @@ |
|||||
|
package com.thing.visual.board.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.alibaba.fastjson.TypeReference; |
||||
|
import com.mybatisflex.core.query.QueryColumn; |
||||
|
import com.mybatisflex.core.query.QueryWrapper; |
||||
|
import com.thing.common.core.enumeration.SuperAdminEnum; |
||||
|
import com.thing.common.core.exception.ErrorCode; |
||||
|
import com.thing.common.core.exception.SysException; |
||||
|
import com.thing.common.core.utils.ConvertUtils; |
||||
|
import com.thing.common.core.utils.HttpContextUtils; |
||||
|
import com.thing.common.core.utils.JsonProcessingUtils; |
||||
|
import com.thing.common.core.web.response.PageData; |
||||
|
import com.thing.common.core.web.response.Result; |
||||
|
import com.thing.common.orm.service.impl.BaseServiceImpl; |
||||
|
import com.thing.sys.biz.dto.SysMenuDTO; |
||||
|
import com.thing.sys.biz.dto.SysRoleDTO; |
||||
|
import com.thing.sys.biz.entity.SysLanguageEntity; |
||||
|
import com.thing.sys.biz.entity.SysMenuEntity; |
||||
|
import com.thing.sys.biz.entity.SysRoleMenuEntity; |
||||
|
import com.thing.sys.biz.mapper.SysLanguageMapper; |
||||
|
import com.thing.sys.biz.mapper.SysRoleMenuMapper; |
||||
|
import com.thing.sys.biz.service.SysLanguageService; |
||||
|
import com.thing.sys.biz.service.SysMenuService; |
||||
|
import com.thing.sys.biz.service.SysRoleMenuService; |
||||
|
import com.thing.sys.biz.service.SysRoleService; |
||||
|
import com.thing.sys.security.context.TenantContext; |
||||
|
import com.thing.sys.security.domain.SecurityUser; |
||||
|
import com.thing.sys.security.domain.UserDetail; |
||||
|
import com.thing.util.TenantSubsetUtil; |
||||
|
import com.thing.visual.board.controller.IotVisualManageController; |
||||
|
import com.thing.visual.board.dto.IotVisualManageDTO; |
||||
|
import com.thing.visual.board.entity.IotVisualManageEntity; |
||||
|
import com.thing.visual.board.mapper.IotVisualManageMapper; |
||||
|
import com.thing.visual.board.service.IotVisualManageService; |
||||
|
import com.thing.visual.configuration.dto.IotVisualDesignDTO; |
||||
|
import com.thing.visual.configuration.entity.IotVisualDesignEntity; |
||||
|
import com.thing.visual.configuration.mapper.IotVisualDesignMapper; |
||||
|
import com.thing.visual.configuration.service.IotVisualDesignService; |
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.apache.commons.compress.utils.Lists; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.context.annotation.Lazy; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.*; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
import static com.mybatisflex.core.query.QueryMethods.column; |
||||
|
|
||||
|
/** |
||||
|
* 组态大屏管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-10 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class IotVisualManageServiceImpl extends BaseServiceImpl<IotVisualManageMapper, IotVisualManageEntity> implements IotVisualManageService { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysMenuService sysMenuService; |
||||
|
@Autowired |
||||
|
private SysLanguageService sysLanguageService; |
||||
|
@Autowired |
||||
|
private SysRoleService sysRoleService; |
||||
|
@Autowired |
||||
|
private SysRoleMenuService sysRoleMenuService; |
||||
|
@Autowired |
||||
|
private SysLanguageMapper sysLanguageDao; |
||||
|
@Autowired |
||||
|
private SysRoleMenuMapper sysRoleMenuDao; |
||||
|
@Autowired |
||||
|
private TenantSubsetUtil tenantSubsetUtil; |
||||
|
@Autowired |
||||
|
private IotVisualDesignMapper iotConfigurationDesignDao; |
||||
|
@Autowired |
||||
|
private IotVisualDesignService iotVisualDesignService; |
||||
|
|
||||
|
@Override |
||||
|
public QueryWrapper getWrapper(Map<String, Object> params){ |
||||
|
QueryColumn nameColumn = column("name"); |
||||
|
QueryColumn idColumn = column("id::varchar"); |
||||
|
|
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
String type = (String) params.get("type"); |
||||
|
wrapper.like( "type", type,StringUtils.isNotBlank(type)); |
||||
|
String name = (String) params.get("name"); |
||||
|
if(StringUtils.isNotEmpty(name)){ |
||||
|
try { |
||||
|
Long key = Long.parseLong(name); |
||||
|
wrapper.and(nameColumn.like(name).or(idColumn.like(key))); |
||||
|
} catch (NumberFormatException e) { |
||||
|
wrapper.and(nameColumn.like(name)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
String ids = (String) params.get("ids"); |
||||
|
if(StringUtils.isNotBlank(ids)&&!"null".equals(params.get("ids"))){ |
||||
|
List<String> idList = Arrays.asList(ids.split(",")); |
||||
|
wrapper.in( "id", idList,CollectionUtils.isNotEmpty(idList)); |
||||
|
} |
||||
|
wrapper.in("tenant_code",tenantSubsetUtil.paramsAddTenantCodeList(true)); |
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public Result saveIotBoardManageDTO(IotVisualManageDTO dto) { |
||||
|
QueryColumn is_template = column("is_template"); |
||||
|
QueryColumn tenant_code = column("tenant_code"); |
||||
|
|
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.eq( "type", dto.getType(),ObjectUtil.isNotEmpty(dto.getType())); |
||||
|
wrapper.eq( "name", dto.getName(),ObjectUtil.isNotEmpty(dto.getName())); |
||||
|
wrapper.and(is_template.eq(true).or(tenant_code.in(tenantSubsetUtil.paramsAddTenantCodeList(true)))); |
||||
|
|
||||
|
if(this.mapper.selectCountByQuery(wrapper)>0){ |
||||
|
return new Result().error("大屏看板已存在,请勿重复添加!"); |
||||
|
} |
||||
|
IotVisualManageEntity entity =ConvertUtils.convertWithTypeAdapt(dto, IotVisualManageEntity.class); |
||||
|
entity.setId(null); |
||||
|
this.mapper.insert(entity); |
||||
|
IotVisualDesignEntity designEntity = new IotVisualDesignEntity(); |
||||
|
designEntity.setBoardManageId(entity.getId()); |
||||
|
iotConfigurationDesignDao.insert(designEntity); |
||||
|
if(ObjectUtil.isNotNull(dto.getSysMenuDTO())&&ObjectUtil.isNotEmpty(dto.getSysMenuDTO().getName())){ |
||||
|
//新增菜单信息 |
||||
|
SysMenuDTO menuDTO = dto.getSysMenuDTO(); |
||||
|
menuDTO.setType(0); |
||||
|
menuDTO.setOpenStyle(0); |
||||
|
menuDTO.setSaView(1); |
||||
|
menuDTO.setUrl("scada/preview?id=" + entity.getId()); |
||||
|
SysMenuEntity sysMenuEntity = ConvertUtils.sourceToTarget(menuDTO, SysMenuEntity.class); |
||||
|
sysMenuService.save(sysMenuEntity); |
||||
|
sysLanguageService.saveOrUpdate("sys_menu", sysMenuEntity.getId(), "name", sysMenuEntity.getName(), HttpContextUtils.getLanguage()); |
||||
|
//将菜单分配给对应的租户/企业下的默认角色 |
||||
|
SysRoleDTO sysRoleDTO = sysRoleService.getDefaultRole(new HashMap<>(1)); |
||||
|
if (ObjectUtil.isNotNull(sysRoleDTO)){ |
||||
|
SysRoleMenuEntity sysRoleMenuEntity = new SysRoleMenuEntity(); |
||||
|
sysRoleMenuEntity.setRoleId(sysRoleDTO.getId()); |
||||
|
sysRoleMenuEntity.setMenuId(sysMenuEntity.getId()); |
||||
|
sysRoleMenuService.save(sysRoleMenuEntity); |
||||
|
} |
||||
|
} |
||||
|
if(StringUtils.isNotEmpty(dto.getTemplateId())){ |
||||
|
IotVisualDesignDTO configurationDesigDTO=null; |
||||
|
if(ObjectUtil.isNotNull(dto.getIotConfigurationDesigDTO())){ |
||||
|
configurationDesigDTO=dto.getIotConfigurationDesigDTO(); |
||||
|
}else { |
||||
|
configurationDesigDTO = iotVisualDesignService.getDetailByBoardManageId(String.valueOf(dto.getTemplateId())); |
||||
|
} |
||||
|
if(ObjectUtil.isNotNull(configurationDesigDTO)){ |
||||
|
configurationDesigDTO.setId(null); |
||||
|
configurationDesigDTO.setBoardManageId(entity.getId()); |
||||
|
configurationDesigDTO.setPageName(dto.getName()); |
||||
|
configurationDesigDTO.setApiSetIds(null); |
||||
|
iotVisualDesignService.saveDto(configurationDesigDTO); |
||||
|
} |
||||
|
} |
||||
|
return new Result().ok("添加成功!"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PageData<IotVisualManageDTO> pageIotBoardManageDTO(Map<String, Object> params) { |
||||
|
PageData<IotVisualManageDTO> pageData = this.getPageData(params, IotVisualManageDTO.class); |
||||
|
pageData.getList().forEach(temp->{ |
||||
|
SysMenuDTO sysMenuDTO = sysMenuService.getByUrl("scada/preview?id=" + temp.getId()); |
||||
|
if (ObjectUtil.isNotNull(sysMenuDTO)) { |
||||
|
temp.setSysMenuDTO(sysMenuDTO); |
||||
|
} |
||||
|
IotVisualManageController.checkParam(temp); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
return pageData; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void updateIotBoardManageDTO(IotVisualManageDTO dto) { |
||||
|
//更新看板管理信息 |
||||
|
IotVisualManageEntity entity = ConvertUtils.sourceToTarget(dto, IotVisualManageEntity.class); |
||||
|
updateById(entity); |
||||
|
// QueryWrapper wrapper = new QueryWrapper(); |
||||
|
// wrapper.eq("board_manage_id",entity.getId()); |
||||
|
// IotVisualDesignEntity desigEntity = iotConfigurationDesigDao.selectOneByQuery(wrapper); |
||||
|
// desigEntity.setPageName(entity.getName()); |
||||
|
|
||||
|
if(ObjectUtil.isNotNull(dto.getSysMenuDTO())&&StringUtils.isNotEmpty(dto.getSysMenuDTO().getName())){ |
||||
|
//更新菜单信息 |
||||
|
SysMenuDTO menuDTO = dto.getSysMenuDTO(); |
||||
|
if (ObjectUtil.isNotNull(menuDTO.getId())) { |
||||
|
sysMenuService.update(menuDTO); |
||||
|
} else { |
||||
|
//新增菜单信息 |
||||
|
menuDTO.setType(0); |
||||
|
menuDTO.setOpenStyle(0); |
||||
|
menuDTO.setSaView(1); |
||||
|
menuDTO.setUrl("scada/preview?id=" + entity.getId()); |
||||
|
SysMenuEntity sysMenuEntity = ConvertUtils.sourceToTarget(menuDTO, SysMenuEntity.class); |
||||
|
sysMenuService.save(sysMenuEntity); |
||||
|
sysLanguageService.saveOrUpdate("sys_menu", sysMenuEntity.getId(), "name", sysMenuEntity.getName(), HttpContextUtils.getLanguage()); |
||||
|
|
||||
|
//将菜单分配给对应的租户/企业下的默认角色 |
||||
|
SysRoleDTO sysRoleDTO = sysRoleService.getDefaultRole(new HashMap<>(1)); |
||||
|
if (ObjectUtil.isNull(sysRoleDTO)) return; |
||||
|
SysRoleMenuEntity sysRoleMenuEntity = new SysRoleMenuEntity(); |
||||
|
sysRoleMenuEntity.setRoleId(sysRoleDTO.getId()); |
||||
|
sysRoleMenuEntity.setMenuId(sysMenuEntity.getId()); |
||||
|
sysRoleMenuService.save(sysRoleMenuEntity); |
||||
|
} |
||||
|
} else { |
||||
|
List<IotVisualManageEntity> entityList = mapper.selectListByQuery(QueryWrapper.create().in(IotVisualManageEntity::getId, entity.getId())); |
||||
|
List<String> urlList = entityList.stream().map(item -> "scada/preview?id=" + item.getId()).collect(Collectors.toList()); |
||||
|
if(CollectionUtil.isNotEmpty(urlList)){ |
||||
|
List<SysMenuDTO> sysMenuDTOList = sysMenuService.getByUrlList(urlList); |
||||
|
if (CollectionUtil.isNotEmpty(sysMenuDTOList)) { |
||||
|
List<Long> menuIdList = sysMenuDTOList.stream().map(SysMenuDTO::getId).collect(Collectors.toList()); |
||||
|
sysRoleMenuDao.deleteByMenuIds(menuIdList); |
||||
|
//删除菜单表 |
||||
|
sysMenuService.batchDelete((Long[]) menuIdList.toArray()); |
||||
|
sysLanguageDao.deleteByQuery(QueryWrapper.create().in(SysLanguageEntity::getTableId, menuIdList)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public Result deleteIotBoardManageDTO(Long[] ids) { |
||||
|
List<IotVisualManageEntity> entityList = mapper.selectListByQuery(QueryWrapper.create().in(IotVisualManageEntity::getId, ids)); |
||||
|
//删除角色与菜单的关联表 |
||||
|
List<String> urlList = entityList.stream().map(item -> "scada/preview?id=" + item.getId()).collect(Collectors.toList()); |
||||
|
List<SysMenuDTO> sysMenuDTOList = sysMenuService.getByUrlList(urlList); |
||||
|
if (CollectionUtil.isNotEmpty(sysMenuDTOList)) { |
||||
|
// List<Long> menuIdList = sysMenuDTOList.stream().map(SysMenuDTO::getId).collect(Collectors.toList()); |
||||
|
// sysRoleMenuDao.deleteByMenuIds(menuIdList); |
||||
|
// //删除菜单表 |
||||
|
// sysMenuService.removeByIds(menuIdList); |
||||
|
// sysLanguageDao.deleteByQuery(QueryWrapper.create().in(SysLanguageEntity::getTableId, menuIdList)); |
||||
|
} |
||||
|
//删除大屏管理表 |
||||
|
batchDelete(ids); |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.in("board_manage_id",ids); |
||||
|
iotConfigurationDesignDao.deleteByQuery(wrapper); |
||||
|
return new Result().ok("删除成功"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public IotVisualManageDTO getIotBoardManageDTO(Long id) { |
||||
|
IotVisualManageDTO data =this.getByIdAs(id, IotVisualManageDTO.class); |
||||
|
//id 页面id为。组态设计详情id |
||||
|
SysMenuDTO sysMenuDTO = sysMenuService.getByUrl("scada/preview?id=" + data.getId()); |
||||
|
|
||||
|
if (ObjectUtil.isNotNull(sysMenuDTO)) { |
||||
|
data.setSysMenuDTO(sysMenuDTO); |
||||
|
} |
||||
|
return data; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public List<IotVisualManageDTO> importJson(MultipartFile file, HttpServletRequest request) { |
||||
|
List<IotVisualManageDTO> resultErrorList = new ArrayList<>(); |
||||
|
|
||||
|
String jsonString = JsonProcessingUtils.readJson(file); |
||||
|
List<IotVisualManageDTO> iotGroupList = JSON.parseObject(jsonString, new TypeReference<>() { |
||||
|
}); |
||||
|
if (CollectionUtil.isEmpty(iotGroupList)) { |
||||
|
throw new SysException("导入json为空,请检查json后再进行导入"); |
||||
|
} |
||||
|
for (IotVisualManageDTO temp : iotGroupList) { |
||||
|
temp.setTemplateId(Long.toString(temp.getId())); |
||||
|
if(ErrorCode.INTERNAL_SERVER_ERROR==this.saveIotBoardManageDTO(temp).getCode()){ |
||||
|
resultErrorList.add(temp); |
||||
|
}; |
||||
|
} |
||||
|
return resultErrorList; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<IotVisualManageDTO> getAllTemplate() { |
||||
|
QueryColumn is_default = column("is_default"); |
||||
|
QueryColumn tenant_code = column("tenant_code"); |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.eq("is_template", true); |
||||
|
UserDetail userDetail = SecurityUser.getUser(); |
||||
|
Long currentTenantCode = TenantContext.getTenantCode(userDetail); |
||||
|
if(!Objects.equals(userDetail.getSuperAdmin(), SuperAdminEnum.YES.value()) |
||||
|
|| !Objects.equals(currentTenantCode, userDetail.getTenantCode())) { |
||||
|
wrapper.and(is_default.eq(0).or(tenant_code.in(tenantSubsetUtil.paramsAddTenantCodeList(true)))); |
||||
|
} |
||||
|
List<IotVisualManageDTO> iotVisualManageDTOS = ConvertUtils.sourceToTarget(mapper.selectListByQuery(wrapper), IotVisualManageDTO.class); |
||||
|
return iotVisualManageDTOS.stream().sorted(Comparator.comparing(IotVisualManageDTO::getCreateDate).reversed()).collect(Collectors.toList()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Set<String> getAllType() { |
||||
|
Set<String> result = new HashSet<>(); |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
UserDetail userDetail = SecurityUser.getUser(); |
||||
|
Long currentTenantCode = TenantContext.getTenantCode(userDetail); |
||||
|
wrapper.eq("tenant_code",currentTenantCode); |
||||
|
wrapper.select("type"); |
||||
|
this.mapper.selectListByQuery(wrapper).forEach(temp->{ |
||||
|
result.add(temp.getType()); |
||||
|
}); |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public Result copy(Long id) { |
||||
|
IotVisualManageDTO data =this.getByIdAs(id, IotVisualManageDTO.class); |
||||
|
String name = data.getName()+"_COPY"+UUID.randomUUID().toString().substring(1,5); |
||||
|
data.setId(null); |
||||
|
data.setName(name); |
||||
|
this.saveDto(data); |
||||
|
IotVisualDesignDTO desigDTO = iotVisualDesignService.getDetailByBoardManageId(String.valueOf(id)); |
||||
|
if(ObjectUtil.isNotNull(desigDTO)){ |
||||
|
desigDTO.setBoardManageId(data.getId()); |
||||
|
desigDTO.setId(null); |
||||
|
desigDTO.setPageName(desigDTO.getPageName()+"_COPY"+UUID.randomUUID().toString().substring(1,5)); |
||||
|
iotVisualDesignService.saveDto(desigDTO); |
||||
|
} |
||||
|
return new Result().ok("复制成功"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<IotVisualManageDTO> listIotBoardManageDTO(Map<String, Object> params) { |
||||
|
String val =""; |
||||
|
List<IotVisualManageDTO> list = this.listAs(params, IotVisualManageDTO.class); |
||||
|
list.forEach(temp->{ |
||||
|
IotVisualDesignDTO desigDTO = iotVisualDesignService.getDetailByBoardManageId(temp.getId().toString()); |
||||
|
if(ObjectUtil.isNotNull(desigDTO)){ |
||||
|
JSONObject object = JSONObject.parseObject(desigDTO.getPictureData()); |
||||
|
JSONArray object1 = JSONArray.parseArray(JSONObject.toJSONString(object.get("nodes"))); |
||||
|
JSONArray object2 = new JSONArray(); |
||||
|
object1.parallelStream().forEach(info->{ |
||||
|
JSONObject o1 = JSON.parseObject(info.toString()); |
||||
|
JSONObject o2 = JSONObject.parseObject(o1.getString("properties")); |
||||
|
o2.put("dynamic",JSONObject.parseObject(val)); |
||||
|
o1.put("properties",o2); |
||||
|
object2.add(o1); |
||||
|
}); |
||||
|
object.put("nodes",object2); |
||||
|
desigDTO.setPictureData(JSONObject.toJSONString(object)); |
||||
|
desigDTO.setApiSetIds(""); |
||||
|
desigDTO.setIotThingApiDTOList(Lists.newArrayList()); |
||||
|
temp.setIotConfigurationDesigDTO(desigDTO); |
||||
|
} |
||||
|
}); |
||||
|
return list; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
package com.thing.visual.configuration.controller; |
||||
|
|
||||
|
import com.thing.common.core.annotation.LogOperation; |
||||
|
import com.thing.common.core.validator.ValidatorUtils; |
||||
|
import com.thing.common.core.validator.group.AddGroup; |
||||
|
import com.thing.common.core.validator.group.DefaultGroup; |
||||
|
import com.thing.common.core.validator.group.UpdateGroup; |
||||
|
import com.thing.common.core.web.response.Result; |
||||
|
import com.thing.visual.configuration.dto.IotVisualDesignDTO; |
||||
|
import com.thing.visual.configuration.service.IotVisualDesignService; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||
|
import io.swagger.v3.oas.annotations.Parameters; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 组态设计管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-29 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("v2/visual/design") |
||||
|
@Tag(name="新组态设计管理") |
||||
|
public class IotVisualDesignController { |
||||
|
@Autowired |
||||
|
private IotVisualDesignService iotVisualDesignService; |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
@Operation(summary="信息") |
||||
|
public Result<IotVisualDesignDTO> get(@PathVariable("id") Long id){ |
||||
|
IotVisualDesignDTO data = iotVisualDesignService.getIotConfigurationDesigDTOById(id); |
||||
|
|
||||
|
return new Result<IotVisualDesignDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
@Operation(summary="保存") |
||||
|
@LogOperation("保存 boardManageId必传") |
||||
|
public Result save(@RequestBody IotVisualDesignDTO dto){ |
||||
|
//效验数据 |
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
|
||||
|
iotVisualDesignService.saveIotConfigurationDesigDTO(dto); |
||||
|
|
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
@Operation(summary="修改") |
||||
|
@LogOperation("修改") |
||||
|
public Result update(@RequestBody IotVisualDesignDTO dto){ |
||||
|
//效验数据 |
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
|
||||
|
iotVisualDesignService.updateIotConfigurationDesigDTO(dto); |
||||
|
|
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("getDetailByBoardManageId") |
||||
|
@Operation(summary="获取组态设计信息,根据组态看板id") |
||||
|
@Parameters({ |
||||
|
@Parameter(name ="boardManageId", description = "组态看板id"), |
||||
|
}) |
||||
|
public Result<IotVisualDesignDTO> getDetailByBoardManageId(String boardManageId){ |
||||
|
IotVisualDesignDTO data = iotVisualDesignService.getDetailByBoardManageId(boardManageId); |
||||
|
|
||||
|
return new Result<IotVisualDesignDTO>().ok(data); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
package com.thing.visual.configuration.dto; |
||||
|
|
||||
|
import com.thing.thing.api.dto.IotThingApiDTO; |
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 组态设计管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-29 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Schema( name= "组态设计管理") |
||||
|
public class IotVisualDesignDTO implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
@Schema(description = "主键id") |
||||
|
private Long id; |
||||
|
@Schema(description = "组态看板id") |
||||
|
private Long boardManageId; |
||||
|
|
||||
|
@Schema(description = "页面名称") |
||||
|
private String pageName; |
||||
|
|
||||
|
@Schema(description = "图数据") |
||||
|
private String pictureData; |
||||
|
@Schema(description = "缩略图") |
||||
|
private String thumbnailUrl; |
||||
|
@Schema(description = "超级apiIds,多个id以英文逗号,分割") |
||||
|
private String apiSetIds; |
||||
|
@Schema(description = "超级api详细信息集合,用于组态设计编辑/查看,回显使用") |
||||
|
private List<IotThingApiDTO> iotThingApiDTOList; |
||||
|
public String previewUrl; |
||||
|
|
||||
|
@Schema(description = "boardType") |
||||
|
private String boardType; |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
package com.thing.visual.configuration.entity; |
||||
|
|
||||
|
import com.mybatisflex.annotation.Id; |
||||
|
import com.mybatisflex.annotation.Table; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import lombok.experimental.Accessors; |
||||
|
|
||||
|
/** |
||||
|
* 组态设计管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-29 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Accessors(chain = true) |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@Table("iot_visual_design") |
||||
|
public class IotVisualDesignEntity { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键id |
||||
|
*/ |
||||
|
@Id |
||||
|
private Long id; |
||||
|
/** |
||||
|
* 组态看板id |
||||
|
*/ |
||||
|
private Long boardManageId; |
||||
|
|
||||
|
/** |
||||
|
* 页面名称 |
||||
|
*/ |
||||
|
private String pageName; |
||||
|
|
||||
|
/** |
||||
|
* 图数据 |
||||
|
*/ |
||||
|
private String pictureData; |
||||
|
|
||||
|
/** |
||||
|
*超级apiid,多个id以英文逗号,分割 |
||||
|
*/ |
||||
|
private String apiSetIds; |
||||
|
|
||||
|
/** |
||||
|
* boardType |
||||
|
*/ |
||||
|
private String boardType; |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.thing.visual.configuration.mapper; |
||||
|
|
||||
|
import com.thing.common.orm.mapper.PowerBaseMapper; |
||||
|
import com.thing.visual.configuration.entity.IotVisualDesignEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 组态设计管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-29 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface IotVisualDesignMapper extends PowerBaseMapper<IotVisualDesignEntity> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
package com.thing.visual.configuration.service; |
||||
|
|
||||
|
import com.thing.common.orm.service.IBaseService; |
||||
|
import com.thing.visual.configuration.dto.IotVisualDesignDTO; |
||||
|
import com.thing.visual.configuration.entity.IotVisualDesignEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 组态设计管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-29 |
||||
|
*/ |
||||
|
public interface IotVisualDesignService extends IBaseService<IotVisualDesignEntity> { |
||||
|
|
||||
|
IotVisualDesignDTO getDetailByBoardManageId(String boardManageId); |
||||
|
|
||||
|
|
||||
|
List<IotVisualDesignDTO> getDetailsByBoardManageIds(List<Long> ids); |
||||
|
|
||||
|
|
||||
|
void saveIotConfigurationDesigDTO(IotVisualDesignDTO dto); |
||||
|
|
||||
|
void updateIotConfigurationDesigDTO(IotVisualDesignDTO dto); |
||||
|
|
||||
|
IotVisualDesignDTO getIotConfigurationDesigDTOById(Long id); |
||||
|
} |
||||
@ -0,0 +1,140 @@ |
|||||
|
package com.thing.visual.configuration.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.mybatisflex.core.query.QueryWrapper; |
||||
|
import com.thing.common.core.utils.ConvertUtils; |
||||
|
import com.thing.common.orm.service.impl.BaseServiceImpl; |
||||
|
import com.thing.thing.api.dto.IotThingApiDTO; |
||||
|
import com.thing.thing.api.mapper.IotThingApiMapper; |
||||
|
import com.thing.visual.board.dto.IotVisualManageDTO; |
||||
|
import com.thing.visual.board.entity.IotVisualManageEntity; |
||||
|
import com.thing.visual.board.service.IotVisualManageService; |
||||
|
import com.thing.visual.configuration.dto.IotVisualDesignDTO; |
||||
|
import com.thing.visual.configuration.entity.IotVisualDesignEntity; |
||||
|
import com.thing.visual.configuration.mapper.IotVisualDesignMapper; |
||||
|
import com.thing.visual.configuration.service.IotVisualDesignService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 组态设计管理 |
||||
|
* |
||||
|
* @author xc |
||||
|
* @since 3.0 2023-05-29 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class IotVisualDesignServiceImpl extends BaseServiceImpl<IotVisualDesignMapper, IotVisualDesignEntity> implements IotVisualDesignService { |
||||
|
|
||||
|
@Autowired |
||||
|
private IotVisualManageService iotVisualManageService; |
||||
|
@Autowired |
||||
|
IotThingApiMapper iotThingApiDao; |
||||
|
@Override |
||||
|
public QueryWrapper getWrapper(Map<String, Object> params){ |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
return wrapper; |
||||
|
} |
||||
|
@Override |
||||
|
public IotVisualDesignDTO getDetailByBoardManageId(String boardManageId) { |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.eq("board_manage_id",Long.parseLong(boardManageId)); |
||||
|
IotVisualDesignEntity entity = this.mapper.selectOneByQuery(wrapper); |
||||
|
if(ObjectUtil.isNotNull(entity)){ |
||||
|
IotVisualDesignDTO dto = ConvertUtils.convertWithTypeAdapt(entity, IotVisualDesignDTO.class); |
||||
|
if(StringUtils.isNotBlank(entity.getApiSetIds())){ |
||||
|
List<Long> apiIdList = Arrays.stream(entity.getApiSetIds().split(",")) |
||||
|
.map(Long::valueOf) |
||||
|
.collect(Collectors.toList()); |
||||
|
if(!apiIdList.isEmpty()){ |
||||
|
dto.setIotThingApiDTOList( ConvertUtils.sourceToTarget(iotThingApiDao.selectListByIds(apiIdList), IotThingApiDTO.class)); |
||||
|
} |
||||
|
} |
||||
|
IotVisualManageEntity manageDTO = iotVisualManageService.getById(Long.parseLong(boardManageId)); |
||||
|
dto.setThumbnailUrl(manageDTO.getThumbnailUrl()); |
||||
|
dto.setPreviewUrl(manageDTO.getPreviewUrl()); |
||||
|
return dto; |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<IotVisualDesignDTO> getDetailsByBoardManageIds(List<Long> ids) { |
||||
|
|
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.in("board_manage_id",ids); |
||||
|
List<IotVisualDesignEntity> entitys = mapper.selectListByQuery(wrapper); |
||||
|
if(ObjectUtil.isNotNull(entitys)){ |
||||
|
return ConvertUtils.sourceToTarget(entitys, IotVisualDesignDTO.class); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void saveIotConfigurationDesigDTO(IotVisualDesignDTO dto) { |
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.eq("board_manage_id",dto.getBoardManageId()); |
||||
|
IotVisualDesignEntity entity = mapper.selectOneByQuery(wrapper); |
||||
|
if(ObjectUtil.isNotNull(entity)){ |
||||
|
dto.setId(entity.getId()); |
||||
|
this.updateDto(dto); |
||||
|
}else { |
||||
|
this.saveDto(dto); |
||||
|
} |
||||
|
this.updateIotBoardManageDTO(dto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void updateIotConfigurationDesigDTO(IotVisualDesignDTO dto) { |
||||
|
|
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.eq("board_manage_id",dto.getBoardManageId()); |
||||
|
IotVisualDesignEntity entity = this.mapper.selectOneByQuery(wrapper); |
||||
|
if(ObjectUtil.isNotNull(entity)){ |
||||
|
dto.setId(entity.getId()); |
||||
|
this.updateDto(dto); |
||||
|
}else { |
||||
|
this.saveDto(dto); |
||||
|
} |
||||
|
this.updateIotBoardManageDTO(dto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public IotVisualDesignDTO getIotConfigurationDesigDTOById(Long id) { |
||||
|
|
||||
|
QueryWrapper wrapper = new QueryWrapper(); |
||||
|
wrapper.eq("board_manage_id",id); |
||||
|
IotVisualDesignDTO data = this.getOneAs(wrapper, IotVisualDesignDTO.class); |
||||
|
if(ObjectUtil.isNotEmpty(data)){ |
||||
|
if(StringUtils.isNotBlank(data.getApiSetIds())){ |
||||
|
List<String> apiIds = Arrays.asList(data.getApiSetIds().split(",")); |
||||
|
if(!apiIds.isEmpty()){ |
||||
|
data.setIotThingApiDTOList( ConvertUtils.sourceToTarget(iotThingApiDao.selectListByIds(apiIds), IotThingApiDTO.class)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
return data; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 修改组态看板缩略图字段 |
||||
|
* @param dto |
||||
|
*/ |
||||
|
public void updateIotBoardManageDTO(IotVisualDesignDTO dto){ |
||||
|
IotVisualManageDTO iotVisualManageDTO = new IotVisualManageDTO(); |
||||
|
iotVisualManageDTO.setId(dto.getBoardManageId()); |
||||
|
iotVisualManageDTO.setThumbnailUrl(dto.getThumbnailUrl()); |
||||
|
iotVisualManageDTO.setPreviewUrl(dto.getPreviewUrl()); |
||||
|
iotVisualManageService.updateDto(iotVisualManageDTO); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue