浏览代码

后端调整

lipenghui 4 月之前
父节点
当前提交
5181cab12e

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

@@ -104,8 +104,8 @@ public class IotDeviceController {
         iotDeviceRespVO.setDeptName(Objects.nonNull(dept)?dept.getName():"");
         IotProductClassifyDO iotProductClassify = iotProductClassifyService.getIotProductClassify(iotDevice.getAssetClass());
         iotDeviceRespVO.setAssetClassName(Objects.nonNull(iotProductClassify)?iotProductClassify.getName():"");
-        IotModelDO iotModel = iotModelService.getIotModel(iotDevice.getModel());
-        iotDeviceRespVO.setModelName(Objects.nonNull(iotModel)?iotModel.getName():"");
+//        IotModelDO iotModel = iotModelService.getIotModel(iotDevice.getModel());
+//        iotDeviceRespVO.setModelName(Objects.nonNull(iotModel)?iotModel.getName():"");
         return success(iotDeviceRespVO);
     }
 

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

@@ -21,7 +21,7 @@ public class IotModelPageReqVO extends PageParam {
     private String name;
 
     @Schema(description = "品牌")
-    private String brand;
+    private Long brand;
 
     @Schema(description = "符合标准 如 API 6D、ASME B16.5、ISO 3183")
     private String standard;

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

@@ -22,7 +22,7 @@ public class IotModelRespVO {
 
     @Schema(description = "品牌")
     @ExcelProperty("品牌")
-    private String brand;
+    private Long brand;
     @Schema(description = "品牌")
     @ExcelProperty("品牌名称")
     private String brandName;

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

@@ -14,7 +14,7 @@ public class IotModelSaveReqVO {
     private String name;
 
     @Schema(description = "品牌")
-    private String brand;
+    private Long brand;
     @Schema(description = "品牌名称")
     private String brandName;
 

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

@@ -28,7 +28,7 @@ public class IotDevicePageReqVO extends PageParam {
     private Long brand;
 
     @Schema(description = "规格型号")
-    private Long model;
+    private String model;
 
     @Schema(description = "所在部门", example = "8581")
     private Long deptId;

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

@@ -31,7 +31,7 @@ public class IotDeviceRespVO {
 
     @Schema(description = "规格型号")
     @ExcelProperty("规格型号")
-    private Long model;
+    private String model;
 
     @Schema(description = "所在部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "8581")
     @ExcelProperty("所在部门")

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

@@ -28,7 +28,7 @@ public class IotDeviceSaveReqVO {
     private Long brand;
 
     @Schema(description = "规格型号")
-    private Long model;
+    private String model;
 
     @Schema(description = "所在部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "8581")
     @NotNull(message = "所在部门不能为空")

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

@@ -44,7 +44,7 @@ public class IotDeviceDO extends BaseDO {
     /**
      * 规格型号
      */
-    private Long model;
+    private String model;
     /**
      * 所在部门
      */

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

@@ -33,7 +33,7 @@ public class IotModelDO extends BaseDO {
     /**
      * 品牌
      */
-    private String brand;
+    private Long brand;
 
     private String brandName;
     /**

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

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.pms.service;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -8,12 +9,17 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSaveReqVO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodel.IotModelDO;
 import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
 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.IotTreeMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotmodel.IotModelMapper;
+import cn.iocoder.yudao.module.pms.service.iotmodel.IotModelService;
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
 import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
 import com.google.common.collect.ImmutableMap;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
@@ -47,6 +53,10 @@ public class IotDeviceServiceImpl implements IotDeviceService {
     private IotTreeMapper iotTreeMapper;
     @Resource
     private DeptService deptService;
+    @Resource
+    private IotModelMapper iotModelMapper;
+    @Resource
+    private DictDataService dictDataService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -73,6 +83,17 @@ public class IotDeviceServiceImpl implements IotDeviceService {
             iotTreeDO.setParentId(Objects.nonNull(iotTreeDOS.get(0)) ? iotTreeDOS.get(0).getId() : 0);
             iotTreeMapper.insert(iotTreeDO);
         }
+        //维护品牌
+        List<IotModelDO> iotModelDOS = iotModelMapper.selectByMap(ImmutableMap.of("brand", createReqVO.getBrand(), "name", createReqVO.getModel()));
+        if (CollUtil.isEmpty(iotModelDOS)) {
+            IotModelDO iotModelDO = new IotModelDO();
+            iotModelDO.setBrand(createReqVO.getBrand());
+            DictDataDO dictData = dictDataService.getDictData(createReqVO.getBrand());
+            iotModelDO.setBrandName(Objects.nonNull(dictData)?dictData.getLabel():"");
+            iotModelDO.setName(createReqVO.getModel());
+            iotModelDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
+            iotModelMapper.insert(iotModelDO);
+        }
         // 返回
         return iotDevice.getId();
     }