浏览代码

后端调整

lipenghui 5 月之前
父节点
当前提交
ba5d1aa8ce

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

@@ -19,4 +19,5 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_INFO_NOT_EXISTS = new ErrorCode( 122, "资料数据不存在");
     ErrorCode IOT_TREE_NOT_EXISTS = new ErrorCode(122, "pms树不存在");
     ErrorCode IOT_COMMON_BOM_MATERIAL_NOT_EXISTS = new ErrorCode(123, "设备分类公共BOM挂载物料关联不存在");
+    ErrorCode IOT_INFO_EXISTS = new ErrorCode(125, "存在子分类");
 }

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

@@ -40,8 +40,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")
@@ -52,6 +53,14 @@ public class IotInfoController {
         return success(true);
     }
 
+    @PutMapping("/update/remove")
+    @Operation(summary = "更新资料")
+    @PreAuthorize("@ss.hasPermission('rq:iot-info:remove')")
+    public CommonResult<Boolean> removeIotInfo(@Valid @RequestBody IotInfoSaveReqVO updateReqVO) {
+        iotInfoService.updateIotInfo(updateReqVO);
+        return success(true);
+    }
+
     @DeleteMapping("/delete")
     @Operation(summary = "删除资料")
     @Parameter(name = "id", description = "编号", required = true)

+ 2 - 2
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")
@@ -34,7 +34,7 @@ public class IotInfoSaveReqVO {
 
     @Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED)
     @NotEmpty(message = "文件路径不能为空")
-    private String filePath;
+    private String[] filePath;
 
     @Schema(description = "备注", example = "随便")
     private String remark;

+ 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);

+ 9 - 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,7 +98,7 @@ 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)) {
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(iotTreeDOS)) {
             throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该部门");
         }
         IotTreeDO iotTreeDO = iotTreeDOS.get(0);
@@ -110,12 +115,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);
 
     /**
      * 删除资料

+ 24 - 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,15 +45,23 @@ 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 (CollUtil.isEmpty(Arrays.asList(createReqVO.getFilePath()))) {
+            throw exception(IOT_INFO_NOT_EXISTS);
+        }
+        List<IotInfoDO> collect = Arrays.stream(createReqVO.getFilePath()).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) {
         // 校验存在
@@ -58,6 +71,11 @@ public class IotInfoServiceImpl implements IotInfoService {
         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;