Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java
zhangcl 4 months ago
parent
commit
d60ffda305
12 changed files with 76 additions and 21 deletions
  1. 1 0
      yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java
  2. 15 4
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotInfoClassifyController.java
  3. 8 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotInfoController.java
  4. 3 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoPageReqVO.java
  5. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoRespVO.java
  6. 4 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoSaveReqVO.java
  7. 1 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/IotInfoDO.java
  8. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java
  9. 14 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoClassifyServiceImpl.java
  10. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoService.java
  11. 25 6
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoServiceImpl.java
  12. 0 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java

+ 1 - 0
yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java

@@ -21,4 +21,5 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_COMMON_BOM_MATERIAL_NOT_EXISTS = new ErrorCode(123, "设备分类公共BOM挂载物料关联不存在");
     ErrorCode IOT_DEVICE_CATEGORY_TEMPLATE_NOT_EXISTS = new ErrorCode(124, "设备分类属性公用模板不存在");
     ErrorCode IOT_DEVICE_CATEGORY_TEMPLATE_ATTRS_NOT_EXISTS = new ErrorCode(125, "设备分类公共模板属性不存在");
+    ErrorCode IOT_INFO_EXISTS = new ErrorCode(125, "存在子分类");
 }

+ 15 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotInfoClassifyController.java

@@ -3,15 +3,13 @@ package cn.iocoder.yudao.module.pms.controller.admin;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifyListReqVO;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifyRespVO;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifySaveReqVO;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifySimpleRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.vo.*;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
 import cn.iocoder.yudao.module.pms.service.IotInfoClassifyService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -30,6 +28,8 @@ public class IotInfoClassifyController {
 
     @Resource
     private IotInfoClassifyService IotInfoClassifyService;
+    @Autowired
+    private IotInfoClassifyService iotInfoClassifyService;
 
     @PostMapping("create")
     @Operation(summary = "创建资料分类")
@@ -47,6 +47,17 @@ public class IotInfoClassifyController {
         return success(true);
     }
 
+    @PutMapping("/update/remove")
+    @Operation(summary = "更新资料分类")
+    @PreAuthorize("@ss.hasPermission('rq:iot-classify:update')")
+    public CommonResult<Boolean> removeIotInfo(@Valid @RequestBody IotInfoClassifySaveReqVO updateReqVO) {
+        IotInfoClassifyDO classify = iotInfoClassifyService.getIotInfoClassify(updateReqVO.getId());
+        classify.setParentId(updateReqVO.getParentId());
+        BeanUtils.copyProperties(classify, updateReqVO);
+        iotInfoClassifyService.updateIotInfoClassify(updateReqVO);
+        return success(true);
+    }
+
     @DeleteMapping("delete")
     @Operation(summary = "删除资料分类")
     @Parameter(name = "id", description = "编号", required = true, example = "1024")

+ 8 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotInfoController.java

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoSaveReqVO;
@@ -40,8 +41,9 @@ public class IotInfoController {
     @PostMapping("/create")
     @Operation(summary = "创建资料")
     @PreAuthorize("@ss.hasPermission('rq:iot-info:create')")
-    public CommonResult<Long> createIotInfo(@Valid @RequestBody IotInfoSaveReqVO createReqVO) {
-        return success(iotInfoService.createIotInfo(createReqVO));
+    public CommonResult<Boolean> createIotInfo(@Valid @RequestBody IotInfoSaveReqVO createReqVO) {
+        iotInfoService.createIotInfo(createReqVO);
+        return success(true);
     }
 
     @PutMapping("/update")
@@ -74,6 +76,8 @@ public class IotInfoController {
     @Operation(summary = "获得资料分页")
     @PreAuthorize("@ss.hasPermission('rq:iot-info:query')")
     public CommonResult<PageResult<IotInfoRespVO>> getIotInfoPage(@Valid IotInfoPageReqVO pageReqVO) {
+        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
+        pageReqVO.setCreator(String.valueOf(loginUserId));
         PageResult<IotInfoDO> pageResult = iotInfoService.getIotInfoPage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, IotInfoRespVO.class));
     }
@@ -82,6 +86,8 @@ public class IotInfoController {
     @Operation(summary = "获得资料分页")
     @PreAuthorize("@ss.hasPermission('rq:iot-info:query')")
     public CommonResult<PageResult<IotInfoRespVO>> getIotInfoFilePage(@Valid IotInfoPageReqVO pageReqVO) {
+        Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
+        pageReqVO.setCreator(String.valueOf(loginUserId));
         PageResult<IotInfoDO> pageResult = iotInfoService.getIotInfoFilePage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, IotInfoRespVO.class));
     }

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoPageReqVO.java

@@ -40,4 +40,7 @@ public class IotInfoPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    @Schema(description = "创建id")
+    private String creator;
+
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoRespVO.java

@@ -48,4 +48,6 @@ public class IotInfoRespVO {
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;
 
+    @Schema(description = "文件大小")
+    private String fileSize;
 }

+ 4 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoSaveReqVO.java

@@ -25,7 +25,7 @@ public class IotInfoSaveReqVO {
     private Long orgId;
 
     @Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
-    @NotEmpty(message = "文件名称不能为空")
+    //@NotEmpty(message = "文件名称不能为空")
     private String filename;
 
     @Schema(description = "文件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -36,6 +36,9 @@ public class IotInfoSaveReqVO {
     @NotEmpty(message = "文件路径不能为空")
     private String filePath;
 
+    @Schema(description = "文件大小")
+    private String fileSize;
+
     @Schema(description = "备注", example = "随便")
     private String remark;
 

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/IotInfoDO.java

@@ -51,6 +51,7 @@ public class IotInfoDO extends BaseDO {
      * 文件路径
      */
     private String filePath;
+    private String fileSize;
     /**
      * 备注
      */

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -79,7 +79,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         iotDeviceMapper.updateById(updateObj);
         //更新pms树
         List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getId(), "device");
-        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(iotTreeDOS)) {
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(iotTreeDOS)) {
             throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该部门");
         }
         IotTreeDO iotTreeDO = iotTreeDOS.get(0);

+ 14 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoClassifyServiceImpl.java

@@ -10,12 +10,14 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifySaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoClassifyMapper;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotTreeMapper;
 import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
 import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableMap;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
@@ -27,6 +29,7 @@ import java.util.*;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_INFO_EXISTS;
 import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
 
 /**
@@ -43,6 +46,8 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
     private IotInfoClassifyMapper iotInfoClassifyMapper;
     @Resource
     private IotTreeMapper iotTreeMapper;
+    @Autowired
+    private IotInfoMapper iotInfoMapper;
 
     @Override
     @CacheEvict(cacheNames = RedisKeyConstants.IOT_INFO_CHILDREN_ID_LIST,
@@ -93,11 +98,16 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
         iotInfoClassifyMapper.updateById(updateObj);
         //更新pms树
         List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getId(), "file");
-        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(iotTreeDOS)) {
+        List<IotTreeDO> parentIotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getParentId(), "file");
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(iotTreeDOS)) {
             throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该部门");
         }
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(parentIotTreeDOS)) {
+            throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该节点");
+        }
         IotTreeDO iotTreeDO = iotTreeDOS.get(0);
         iotTreeDO.setName(updateObj.getName());
+        iotTreeDO.setParentId(parentIotTreeDOS.get(0).getId());
         iotTreeMapper.updateById(iotTreeDO);
     }
 
@@ -110,12 +120,14 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
         validateIotInfoClassifyExists(id);
         // 校验是否有子产品分类
         if (iotInfoClassifyMapper.selectCountByParentId(id) > 0) {
-            throw exception(DEPT_EXITS_CHILDREN);
+            throw exception(IOT_INFO_EXISTS);
         }
         // 删除产品分类
         iotInfoClassifyMapper.deleteById(id);
         //删除pms树
         iotTreeMapper.deleteByMap(ImmutableMap.of("origin_id", id));
+        //删除文件
+        iotInfoMapper.deleteByMap(ImmutableMap.of("class_id", id));
     }
 
     @VisibleForTesting

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoService.java

@@ -19,9 +19,8 @@ public interface IotInfoService {
      * 创建资料
      *
      * @param createReqVO 创建信息
-     * @return 编号
      */
-    Long createIotInfo(@Valid IotInfoSaveReqVO createReqVO);
+    void createIotInfo(@Valid IotInfoSaveReqVO createReqVO);
 
     /**
      * 更新资料
@@ -29,6 +28,7 @@ public interface IotInfoService {
      * @param updateReqVO 更新信息
      */
     void updateIotInfo(@Valid IotInfoSaveReqVO updateReqVO);
+    void removeIotInfo(@Valid IotInfoSaveReqVO updateReqVO);
 
     /**
      * 删除资料

+ 25 - 6
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.pms.service;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
@@ -7,13 +8,17 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoMapper;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.File;
 import java.util.*;
+import java.util.stream.Collectors;
+
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -40,24 +45,38 @@ public class IotInfoServiceImpl implements IotInfoService {
     private IotTreeService iotTreeService;
 
     @Override
-    public Long createIotInfo(IotInfoSaveReqVO createReqVO) {
+    public void createIotInfo(IotInfoSaveReqVO createReqVO) {
         // 插入
-        IotInfoDO iotInfo = BeanUtils.toBean(createReqVO, IotInfoDO.class);
-        iotInfo.setDeleted(false);
-        iotInfoMapper.insert(iotInfo);
+        if (StringUtils.isBlank(createReqVO.getFilePath())) {
+            throw exception(IOT_INFO_NOT_EXISTS);
+        }
+        List<IotInfoDO> collect = Arrays.stream(createReqVO.getFilePath().split(",")).map(path -> {
+            IotInfoDO iotInfo = BeanUtils.toBean(createReqVO, IotInfoDO.class);
+            // todo iotInfo.setFilename(StringUtils.substringAfterLast(path, File.separator));
+            iotInfo.setFilename(StringUtils.substringAfterLast(path, "/"));
+            iotInfo.setFilePath(path);
+            iotInfo.setDeleted(false);
+            return iotInfo;
+        }).collect(Collectors.toList());
+
+        iotInfoMapper.insert(collect);
         // 返回
-        return iotInfo.getId();
     }
-
     @Override
     public void updateIotInfo(IotInfoSaveReqVO updateReqVO) {
         // 校验存在
         validateIotInfoExists(updateReqVO.getId());
         // 更新
         IotInfoDO updateObj = BeanUtils.toBean(updateReqVO, IotInfoDO.class);
+        updateObj.setFilename(StringUtils.substringAfterLast(updateObj.getFilePath(), "/"));
         iotInfoMapper.updateById(updateObj);
     }
 
+    @Override
+    public void removeIotInfo(IotInfoSaveReqVO updateReqVO) {
+
+    }
+
     @Override
     public void deleteIotInfo(Long id) {
         // 校验存在

+ 0 - 3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java

@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.service.dept;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
-import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
@@ -11,9 +10,7 @@ import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqV
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
 import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
-import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;