REM:
1. 修改启动处置任务接口,当区域编码下无该设备时返回对应错误信息
This commit is contained in:
chenlinghy 2020-10-30 17:59:57 +08:00
parent c41c2a08ee
commit fa6fd0f2a6
9 changed files with 126 additions and 35 deletions

View File

@ -216,6 +216,10 @@ public enum ErrorCode {
* The Err decrypt aes 256. * The Err decrypt aes 256.
*/ */
ERR_DECRYPT_AES256(111, "AES256解密失败"), ERR_DECRYPT_AES256(111, "AES256解密失败"),
/**
* The Err no device by areaCode.
*/
ERR_NODEVICE_AREACODE(111, "区域无该设备"),
; ;
/** /**

View File

@ -55,4 +55,12 @@ public interface DisposeDeviceManager {
* @return the all dispose devices * @return the all dispose devices
*/ */
List<DisposeDevice> getAllNormalDisposeDevices(); List<DisposeDevice> getAllNormalDisposeDevices();
/**
* Gets all dispose devices.
*
* @param areaCode the areaCode
* @return the dispose devices
*/
List<DisposeDevice> getDisposeDevices(Integer areaCode);
} }

View File

@ -274,4 +274,16 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
.filter(v -> v.getStatus() == ObjectStatus.NORMAL) .filter(v -> v.getStatus() == ObjectStatus.NORMAL)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* Gets dispose devices by areaCode.
*
* @param areaCode the areaCode
* @return the dispose devices by areaCode.
*/
@Override
public List<DisposeDevice> getDisposeDevices(Integer areaCode) {
return disposeDeviceMapper.getDeviceByAreaCode(areaCode);
}
} }

View File

@ -94,4 +94,13 @@ public interface DisposeDeviceMapper {
*/ */
DisposeDevice getDeviceById(@Param("id") Long id); DisposeDevice getDeviceById(@Param("id") Long id);
/**
* Gets deviceId by areaCode.
*
* @param areaCode the areaCode
* @return the list
*/
List<DisposeDevice> getDeviceByAreaCode(@Param("areaCode") Integer areaCode);
} }

View File

@ -55,4 +55,12 @@ public interface DisposeDeviceManagerService {
* @return the all dispose device * @return the all dispose device
*/ */
List<DisposeDevice> getAllDisposeDevice(); List<DisposeDevice> getAllDisposeDevice();
/**
* Gets dispose device by areaCode.
*
* @param areaCode the areaCode
* @return the all dispose device
*/
List<DisposeDevice> getDisposeDeviceByAreaCode(Integer areaCode);
} }

View File

@ -128,4 +128,21 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
return disposeDevices; return disposeDevices;
} }
} }
/**
* Gets dispose device by areaCode.
*
* @param areaCode the areaCode
* @return the all dispose device by areaCode
*/
@Override
public List<DisposeDevice> getDisposeDeviceByAreaCode(Integer areaCode) {
List<DisposeDevice> disposeDevices = disposeDeviceManager.getDisposeDevices(areaCode);
if (disposeDevices == null) {
return new ArrayList<>();
} else {
return disposeDevices;
}
}
} }

View File

@ -3,15 +3,18 @@ package com.dispose.service.impl;
import com.dispose.common.DisposeTaskStatus; import com.dispose.common.DisposeTaskStatus;
import com.dispose.common.ErrorCode; import com.dispose.common.ErrorCode;
import com.dispose.manager.DisposeTaskManager; import com.dispose.manager.DisposeTaskManager;
import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.entity.DisposeTask; import com.dispose.pojo.entity.DisposeTask;
import com.dispose.pojo.po.MulReturnType; import com.dispose.pojo.po.MulReturnType;
import com.dispose.service.DisposeAbilityRouterService; import com.dispose.service.DisposeAbilityRouterService;
import com.dispose.service.DisposeDeviceManagerService;
import com.dispose.service.DisposeTaskService; import com.dispose.service.DisposeTaskService;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* The type Dispose task service. * The type Dispose task service.
@ -32,6 +35,12 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
@Resource @Resource
DisposeAbilityRouterService disposeAbilityRouterService; DisposeAbilityRouterService disposeAbilityRouterService;
/**
* The Dispose device manager service.
*/
@Resource
DisposeDeviceManagerService disposeDeviceManagerService;
/** /**
* Create task mul return type. * Create task mul return type.
* *
@ -55,9 +64,19 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
return new MulReturnType<>(err, task); return new MulReturnType<>(err, task);
} }
//areaCode获取对应的deviceId
List<DisposeDevice> devices = disposeDeviceManagerService.getDisposeDeviceByAreaCode(task.getAreaCode());
// 获取请求id列表
List<Long> deviceIds = devices.stream().map(DisposeDevice::getId).distinct().collect(Collectors.toList());
if (deviceIds.size() == 0 || !deviceIds.contains(task.getDeviceId())) {
return new MulReturnType<>(ErrorCode.ERR_NODEVICE_AREACODE, task);
} else {
return new MulReturnType<>(disposeTaskManager.addDisposeTask(task), return new MulReturnType<>(disposeTaskManager.addDisposeTask(task),
disposeTaskManager.getDisposeTaskById(task.getId())); disposeTaskManager.getDisposeTaskById(task.getId()));
} }
}
/** /**
* Stop task mul return type. * Stop task mul return type.

View File

@ -129,4 +129,18 @@
SET status = ${@com.dispose.common.ObjectStatus@NORMAL.getValue()} SET status = ${@com.dispose.common.ObjectStatus@NORMAL.getValue()}
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<select id="getDeviceByAreaCode" resultMap="dispose_device">
SELECT d.*,
c.id c_id,
c.deviceId deviceId,
c.capacityType capacityType,
c.objectType objectType,
c.ipType ipType,
c.protectIp protectIp,
c.reserveNetflow reserveNetflow
FROM dispose_device d
LEFT JOIN dispose_capacity c ON d.id = c.deviceId
WHERE d.areaCode = #{areaCode}
</select>
</mapper> </mapper>