hxd 3 сар өмнө
parent
commit
d82ef51c4a
16 өөрчлөгдсөн 356 нэмэгдсэн , 26 устгасан
  1. 3 3
      portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/ShareController.java
  2. 63 3
      portal-service-application/src/main/java/com/hfln/portal/application/controller/web/DictController.java
  3. 3 1
      portal-service-application/src/main/java/com/hfln/portal/application/controller/web/WebSystemController.java
  4. 24 0
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/dic/DicDTO.java
  5. 2 2
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/pub/DicItemDto.java
  6. 5 5
      portal-service-common/src/main/java/com/hfln/portal/common/dto/data/room/RegionInfo.java
  7. 2 1
      portal-service-common/src/main/java/com/hfln/portal/common/request/web/AddAccountParam.java
  8. 25 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/web/DicAddParam.java
  9. 29 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/web/DicItemAddParam.java
  10. 32 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/web/UpdateDicItemParam.java
  11. 28 0
      portal-service-common/src/main/java/com/hfln/portal/common/request/web/UpdateDicParam.java
  12. 18 5
      portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/WebGateway.java
  13. 13 3
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java
  14. 95 1
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/WebGatewayImpl.java
  15. 4 0
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/TblDicService.java
  16. 10 2
      portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/TblDicServiceImpl.java

+ 3 - 3
portal-service-application/src/main/java/com/hfln/portal/application/controller/wap/ShareController.java

@@ -41,7 +41,7 @@ public class ShareController {
 
     @GetMapping("/queryDevShare")
     @Operation(summary = "查看设备分享记录")
-    public ApiResult<List<ShareDto>> queryDevShare(@Valid @RequestParam Long userId) {
+    public ApiResult<List<ShareDto>> queryDevShare(@RequestParam Long userId) {
         return ApiResult.success(deviceGateway.queryDevShare(userId));
     }
 
@@ -53,14 +53,14 @@ public class ShareController {
     }
 
     @PostMapping("/cancelShare")
-    @Operation(summary = "取消设备分享")
+    @Operation(summary = "取消分享账户")
     public ApiResult<Void> cancelShare(@RequestParam("shareId") Long shareId){
         deviceGateway.cancelShare(shareId);
         return ApiResult.success();
     }
 
     @PostMapping("/updateDeviceShare")
-    @Operation(summary = "更新设备分享")
+    @Operation(summary = "修改当前分享账户权限")
     public ApiResult<Void> updateDeviceShare(@RequestBody @Valid updateShareParam param) {
         deviceGateway.updateDeviceShare(param);
         return ApiResult.success();

+ 63 - 3
portal-service-application/src/main/java/com/hfln/portal/application/controller/web/DictController.java

@@ -3,23 +3,83 @@ package com.hfln.portal.application.controller.web;
 
 
 import cn.hfln.framework.catchlog.CatchAndLog;
+import cn.hfln.framework.dto.ApiResult;
+import com.hfln.portal.common.dto.data.dic.DicDTO;
+import com.hfln.portal.common.request.web.DicAddParam;
+import com.hfln.portal.common.request.web.DicItemAddParam;
+import com.hfln.portal.common.request.web.UpdateDicItemParam;
+import com.hfln.portal.common.request.web.UpdateDicParam;
 import com.hfln.portal.domain.gateway.PubGateway;
+import com.hfln.portal.domain.gateway.WebGateway;
+import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
 
 @RestController
 @CatchAndLog
-@Tag(name = "字典")
+@Tag(name = "web端字典相关")
 @Slf4j
 @RequestMapping("/web/dic")
 public class DictController {
 
     @Autowired
     private PubGateway pubGateway;
+    @Autowired
+    private WebGateway webGateway;
 
     // todo 增删改 dic
 
+    @PostMapping("/addDic")
+    @Operation(summary = "添加字典类值")
+    public ApiResult<Void> addDic(@RequestBody @Valid DicAddParam param){
+        webGateway.addDic(param);
+        return ApiResult.success();
+    }
+
+    @PostMapping("/updateDic")
+    @Operation(summary = "修改字典类值")
+    public ApiResult<Void> updateDic(@RequestBody @Valid UpdateDicParam param){
+        webGateway.updateDic(param);
+        return ApiResult.success();
+    }
+
+    @PostMapping("/deleteDic")
+    @Operation(summary = "删除字典类值")
+    public ApiResult<Void> deleteDic(@RequestParam Long dicId){
+        webGateway.deleteDic(dicId);
+        return ApiResult.success();
+    }
+
+    @GetMapping("/queryDic")
+    @Operation(summary = "查询字典类值")
+    public ApiResult<List<DicDTO>> queryDic(){
+        List<DicDTO> dicList = webGateway.queryDic();
+        return ApiResult.success(dicList);
+    }
+
+    @PostMapping("/addDicItem")
+    @Operation(summary = "添加字典项值")
+    public ApiResult<Void> addDicItem(@RequestBody @Valid DicItemAddParam param){
+        webGateway.addDicItem(param);
+        return ApiResult.success();
+    }
+
+    @PostMapping("/updateDicItem")
+    @Operation(summary = "修改字典项值")
+    public ApiResult<Void> updateDicItem(@RequestBody @Valid UpdateDicItemParam param){
+        webGateway.updateDicItem(param);
+        return ApiResult.success();
+    }
+
+    @PostMapping("/deleteDicItem")
+    @Operation(summary = "删除字典项值")
+    public ApiResult<Void> deleteDicItem(@RequestParam Long ItemId){
+        webGateway.deleteDicItem(ItemId);
+        return ApiResult.success();
+    }
 }

+ 3 - 1
portal-service-application/src/main/java/com/hfln/portal/application/controller/web/WebSystemController.java

@@ -82,7 +82,9 @@ public class WebSystemController {
 
     @GetMapping("/queryMenuList")
     @Operation(summary = "查询菜单列表")
-    public ApiResult<List<MenuListDTO>> queryMenuList(@RequestParam(required = false) Integer disabledFlag) {
+    public ApiResult<List<MenuListDTO>> queryMenuList(
+            @Parameter(description = "默认什么都不传-查全部,0-查启用, 1-查禁用")
+            @RequestParam(required = false) Integer disabledFlag) {
         return ApiResult.success(webGateway.queryMenuList(disabledFlag));
     }
 

+ 24 - 0
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/dic/DicDTO.java

@@ -0,0 +1,24 @@
+package com.hfln.portal.common.dto.data.dic;
+
+import com.hfln.portal.common.vo.BaseDto;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DicDTO extends BaseDto {
+
+    @Schema(description = "主键ID")
+    private Long dicId;
+
+    @Schema(description = "字典类型")
+    private String dicType;
+
+    @Schema(description = "字典类编码")
+    private String dicName;
+
+    @Schema(description = "字典类排序")
+    private Integer sort;
+}

+ 2 - 2
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/pub/DicItemDto.java

@@ -18,7 +18,7 @@ public class DicItemDto extends BaseDto {
     @Schema(description = "字典类型")
     private String dicType;
 
-    @Schema(description = "字典编码")
+    @Schema(description = "字典编码")
     private String itemCode;
 
     @Schema(description = "字典项名称")
@@ -27,6 +27,6 @@ public class DicItemDto extends BaseDto {
     @Schema(description = "字典项值")
     private String itemValue;
 
-    @Schema(description = "排序号")
+    @Schema(description = "字典项排序号")
     private Integer sort;
 } 

+ 5 - 5
portal-service-common/src/main/java/com/hfln/portal/common/dto/data/room/RegionInfo.java

@@ -15,20 +15,20 @@ public class RegionInfo {
     @Schema(description = "类型")
     private String type;
 
-    @Schema(description = "宽度")
+    @Schema(description = "家具宽度 cm")
     private BigDecimal width;
 
-    @Schema(description = "长度")
+    @Schema(description = "家具长度 cm")
     private BigDecimal length;
 
-    @Schema(description = "距离顶点相对距离")
+    @Schema(description = "距离检测范围上方位置  cm")
     private BigDecimal top;
 
-    @Schema(description = "距离左侧边相对距离")
+    @Schema(description = "距离检测范围左边位置  cm")
     private BigDecimal left;
 
     @Schema(description = "旋转角度: 0°,90°,180°,270°")
-    private Boolean rotate;
+    private BigDecimal rotate;
 
     @Schema(description = "距离雷达的X距离")
     private BigDecimal x;

+ 2 - 1
portal-service-common/src/main/java/com/hfln/portal/common/request/web/AddAccountParam.java

@@ -1,5 +1,6 @@
 package com.hfln.portal.common.request.web;
 
+import com.hfln.portal.common.vo.BaseVO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -8,7 +9,7 @@ import javax.validation.constraints.NotNull;
 
 
 @Data
-public class AddAccountParam {
+public class AddAccountParam extends BaseVO {
 
     @Schema(description = "账号")
     @NotBlank(message = "账号不能为空")

+ 25 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/web/DicAddParam.java

@@ -0,0 +1,25 @@
+package com.hfln.portal.common.request.web;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+
+@Data
+public class DicAddParam extends BaseVO {
+
+    @Schema(description = "字典类型")
+    @NotBlank(message = "字典类型不能为空")
+    private String dicType;
+
+    @Schema(description = "字典名称")
+    @NotBlank(message = "字典名称不能为空")
+    private String dicName;
+
+    @Schema(description = "排序")
+    @NotNull(message = "排序不能为空")
+    private Integer sort;
+}

+ 29 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/web/DicItemAddParam.java

@@ -0,0 +1,29 @@
+package com.hfln.portal.common.request.web;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class DicItemAddParam extends BaseVO {
+
+    @Schema(description = "字典项类型")
+    @NotBlank(message = "字典项名称不能为空")
+    private String dicType;
+
+    @Schema(description = "字典项编码")
+    @NotBlank(message = "字典项编码不能为空")
+    private String itemCode;
+
+    @Schema(description = "字典项名称")
+    @NotBlank(message = "字典项名称不能为空")
+    private String itemName;
+
+    @Schema(description = "排序")
+    @NotNull(message = "排序不能为空")
+    private Integer sort;
+
+}

+ 32 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/web/UpdateDicItemParam.java

@@ -0,0 +1,32 @@
+package com.hfln.portal.common.request.web;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class UpdateDicItemParam extends BaseVO {
+
+    @Schema(description = "字典项ID")
+    @NotNull(message = "字典项ID不能为空")
+    private Long ItemId;
+
+    @Schema(description = "字典项类型")
+    @NotBlank(message = "字典项名称不能为空")
+    private String dicType;
+
+    @Schema(description = "字典项编码")
+    @NotBlank(message = "字典项编码不能为空")
+    private String itemCode;
+
+    @Schema(description = "字典项名称")
+    @NotBlank(message = "字典项名称不能为空")
+    private String itemName;
+
+    @Schema(description = "排序")
+    @NotNull(message = "排序不能为空")
+    private Integer sort;
+}

+ 28 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/web/UpdateDicParam.java

@@ -0,0 +1,28 @@
+package com.hfln.portal.common.request.web;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class UpdateDicParam extends BaseVO {
+
+    @Schema(description = "字典ID")
+    @NotNull(message = "字典ID不能为空")
+    private Long dicId;
+
+    @Schema(description = "字典类型")
+    @NotBlank(message = "字典类型不能为空")
+    private String dicType;
+
+    @Schema(description = "字典名称")
+    @NotBlank(message = "字典名称不能为空")
+    private String dicName;
+
+    @Schema(description = "排序")
+    @NotNull(message = "排序不能为空")
+    private Integer sort;
+}

+ 18 - 5
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/WebGateway.java

@@ -1,6 +1,7 @@
 package com.hfln.portal.domain.gateway;
 
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
+import com.hfln.portal.common.dto.data.dic.DicDTO;
 import com.hfln.portal.common.dto.data.menu.MenuListDTO;
 import com.hfln.portal.common.dto.data.menu.MenuTreeDTO;
 import com.hfln.portal.common.dto.data.role.RoleListDTO;
@@ -65,14 +66,26 @@ public interface WebGateway {
 
     List<MenuTreeDTO> queryMenuTree();
 
-    /**
-     * 查询菜单列表
-     * @param disabledFlag 是否禁用:null-全部,0-启用,1-禁用
-     * @return 菜单列表
-     */
+
     List<MenuListDTO> queryMenuList(Integer disabledFlag);
 
     RoleMenuTreeDTO getRoleSelectedMenu(Long roleId);
 
+    /**
+     * web字典相关
+     */
+    void addDic(DicAddParam param);
+
+    void updateDic(UpdateDicParam param);
+
+    void deleteDic(Long dicId);
+
+    List<DicDTO> queryDic();
+
+    void addDicItem(DicItemAddParam param);
+
+    void updateDicItem(UpdateDicItemParam param);
+
+    void deleteDicItem(Long ItemId);
 }
 

+ 13 - 3
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/DeviceGatewayImpl.java

@@ -429,14 +429,24 @@ public class DeviceGatewayImpl implements DeviceGateway {
         }
 
         //3.更新设备指示灯状态
-        boolean update = devInfoService.update(
+        boolean updateResult = devInfoService.update(
                 Wrappers.<DevInfo>lambdaUpdate()
                         .set(DevInfo::getStatusLight, statusLight)
                         .eq(DevInfo::getDevId, devId)
         );
-        return update;
 
-        //TODO 通过mqtt往设备发送消息
+        //4.通过MQTT把信息参数发送到设备
+        String topic = TopicConstants.TOPIC_SET_DEVICE_PARAM;
+        JSONObject msg = new JSONObject();
+        msg.put("dev_id", devId);
+        msg.put("status_light", statusLight);
+        try {
+            mqttClient.sendMessage(topic, msg.toJSONString());
+        } catch (Exception e) {
+            log.error("发送设备参数到MQTT失败", e);
+        }
+
+        return updateResult;
     }
 
     @Override

+ 95 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/WebGatewayImpl.java

@@ -13,6 +13,7 @@ import com.hfln.portal.common.constant.UserConstants;
 import com.hfln.portal.common.constant.redis.RedisCacheConstant;
 import com.hfln.portal.common.dto.DevInfoImportDto;
 import com.hfln.portal.common.dto.data.device.DeviceDTO;
+import com.hfln.portal.common.dto.data.dic.DicDTO;
 import com.hfln.portal.common.dto.data.menu.MenuListDTO;
 import com.hfln.portal.common.dto.data.menu.MenuTreeDTO;
 import com.hfln.portal.common.dto.data.role.RoleListDTO;
@@ -89,6 +90,10 @@ public class WebGatewayImpl implements WebGateway {
 
     @Value("${sa-token.admin.active-timeout}")
     private long adminActiveTimeout;
+    @Autowired
+    private TblDicService tblDicService;
+    @Autowired
+    private TblDicItemService tblDicItemService;
 
     @Override
     public UploadRes uploadDev(MultipartFile file) throws IOException {
@@ -456,7 +461,9 @@ public class WebGatewayImpl implements WebGateway {
         
         // 转换为DTO
         List<MenuListDTO> menuList = CopyUtils.copyList(allMenus, MenuListDTO.class);
-        
+        if(menuList == null ){
+            menuList = Collections.emptyList();
+        }
         // 根据ParentId进行分组
         Map<Long, List<MenuListDTO>> parentMap = menuList.stream()
                 .collect(Collectors.groupingBy(MenuListDTO::getParentId, Collectors.toList()));
@@ -520,4 +527,91 @@ public class WebGatewayImpl implements WebGateway {
         res.forEach(e -> e.setChildren(buildMenuTree(parentMap, e.getMenuId())));
         return res;
     }
+
+    @Override
+    public  void addDic(DicAddParam param) {
+        TblDic tblDic = new TblDic();
+        tblDic.setDicType(param.getDicType());
+        tblDic.setDicName(param.getDicName());
+        tblDic.setSort(param.getSort());
+        tblDic.setIsDeleted(BasePO.DeleteFlag.NOT_DELETED);
+        tblDicService.save(tblDic);
+    }
+
+    @Override
+    public void updateDic(UpdateDicParam param){
+        TblDic tblDic = tblDicService.getById(param.getDicId());
+        if (tblDic == null) {
+            throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
+        }
+        tblDic.setDicType(param.getDicType());
+        tblDic.setDicName(param.getDicName());
+        tblDic.setSort(param.getSort());
+        tblDicService.updateById(tblDic);
+    }
+
+    @Override
+    @Transactional
+    public void deleteDic(Long dicId) {
+        TblDic tblDic = tblDicService.getById(dicId);
+        if (tblDic == null) {
+            throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
+        }
+
+        //1.删除字典类
+        tblDic.setIsDeleted(BasePO.DeleteFlag.DELETED);
+        tblDicService.removeById(tblDic);
+
+        //2.同步删除字典类下面的字典值
+        tblDicItemService.lambdaUpdate()
+                .set(TblDicItem::getIsDeleted, BasePO.DeleteFlag.DELETED)
+                .eq(TblDicItem::getDicType, tblDic.getDicType())
+                .update();
+    }
+
+    @Override
+    public List<DicDTO> queryDic() {
+        // 调用底层服务查询所有未删除的字典项
+        List<TblDic> dicList = tblDicService.queryDic();
+        // 转换为DTO并返回
+        return CopyUtils.copyList(dicList, DicDTO.class);
+    }
+
+    @Override
+    public void addDicItem(DicItemAddParam param) {
+        TblDicItem tblDicItem = new TblDicItem();
+        tblDicItem.setDicType(param.getDicType());
+        tblDicItem.setItemCode(param.getItemCode());
+        tblDicItem.setItemName(param.getItemName());
+        tblDicItem.setSort(param.getSort());
+        tblDicItemService.save(tblDicItem);
+    }
+
+    @Override
+    public void updateDicItem(UpdateDicItemParam param) {
+        TblDicItem tblDicItem = tblDicItemService.getById(param.getItemId());
+
+        if (tblDicItem == null) {
+            throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
+        }
+
+        tblDicItem.setDicType(param.getDicType());
+        tblDicItem.setItemName(param.getItemName());
+        tblDicItem.setItemCode(param.getItemCode());
+        tblDicItem.setSort(param.getSort());
+        tblDicItemService.updateById(tblDicItem);
+    }
+
+    @Override
+    public void deleteDicItem(Long ItemId) {
+        TblDicItem tblDicItem = tblDicItemService.getById(ItemId);
+
+        if (tblDicItem == null) {
+            throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
+        }
+
+        tblDicItem.setIsDeleted(BasePO.DeleteFlag.DELETED);
+        tblDicItemService.removeById(tblDicItem);
+    }
+
 }

+ 4 - 0
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/TblDicService.java

@@ -3,6 +3,10 @@ package com.hfln.portal.infrastructure.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.hfln.portal.infrastructure.po.TblDic;
 
+import java.util.List;
+
 public interface TblDicService extends IService<TblDic> {
 
+    List<TblDic> queryDic();
+
 }

+ 10 - 2
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/service/impl/TblDicServiceImpl.java

@@ -1,16 +1,24 @@
 package com.hfln.portal.infrastructure.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hfln.portal.infrastructure.mapper.TblDicMapper;
+import com.hfln.portal.infrastructure.po.BasePO;
 import com.hfln.portal.infrastructure.po.TblDic;
 import com.hfln.portal.infrastructure.service.TblDicService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 
 @Service
 @Slf4j
 public class TblDicServiceImpl extends ServiceImpl<TblDicMapper, TblDic> implements TblDicService {
-
-
+    @Override
+    public List<TblDic> queryDic() {
+        // 查询所有未删除的字典项,按排序号升序排列
+        return this.list(new LambdaQueryWrapper<TblDic>()
+                .eq(TblDic::getIsDeleted, BasePO.DeleteFlag.NOT_DELETED)
+                .orderByAsc(TblDic::getSort));
+    }
 }