Просмотр исходного кода

1.增加null判断
2.增加填写校验

lengfaqiang 2 лет назад
Родитель
Сommit
44687e6dd3

+ 14 - 7
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -336,9 +336,9 @@ public class ProjectService {
 
     @Transactional
     public HttpResult deviceBind(BindDevice bindDevice, HttpServletRequest request) {
-//        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
-//            return HttpResult.error("安装设备时间不能为空");
-//        }
+        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
+            return HttpResult.error("安装设备时间不能为空");
+        }
         HeaderData headerData = commonService.getHeaderData(request);
         Long projectId = Long.parseLong(bindDevice.getProjectId());
         KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
@@ -428,7 +428,7 @@ public class ProjectService {
                 deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
                         .eq(KwsDevice::getId, id)
                         .set(KwsDevice::getRelevanceLevel, level)
-                        .set(KwsDevice::getInstallTime,localDateTime)
+                        .set(KwsDevice::getInstallTime, localDateTime)
                         .set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
                         .set(KwsDevice::getOnline, 1)
                         .set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
@@ -1581,9 +1581,9 @@ public class ProjectService {
 
     @Transactional
     public HttpResult updateDeviceBind(BindDevice bindDevice, HttpServletRequest request) {
-//        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
-//            return HttpResult.error("安装设备时间不能为空");
-//        }
+        if (org.apache.commons.lang3.StringUtils.isBlank(bindDevice.getInstallTime())) {
+            return HttpResult.error("安装设备时间不能为空");
+        }
         String deviceRelationId = bindDevice.getDeviceRelationId();
         if (StringUtils.isBlank(deviceRelationId)) {
             return HttpResult.error("关联主键id不能为空");
@@ -1591,6 +1591,13 @@ public class ProjectService {
         String bindDeviceId = bindDevice.getBindDeviceId();
         String deviceIds = bindDevice.getDeviceIds();
         String alias = bindDevice.getAlias();
+        KwsDeviceRelation kwsDeviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
+                .eq(KwsDeviceRelation::getId, Long.parseLong(bindDeviceId))
+                .eq(KwsDeviceRelation::getDelFlag, NumberConstant.ZERO)
+        );
+        if (kwsDeviceRelation == null) {
+            return HttpResult.error("修改id传递错误");
+        }
         HeaderData headerData = commonService.getHeaderData(request);
         /**验证主设备是否存在子设备*/
 //        List<KwsDeviceRelation> deviceRelations = deviceRelationMapper.selectList(