parent
c41c2a08ee
commit
fa6fd0f2a6
|
@ -216,6 +216,10 @@ public enum ErrorCode {
|
|||
* The Err decrypt aes 256.
|
||||
*/
|
||||
ERR_DECRYPT_AES256(111, "AES256解密失败"),
|
||||
/**
|
||||
* The Err no device by areaCode.
|
||||
*/
|
||||
ERR_NODEVICE_AREACODE(111, "区域无该设备"),
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,4 +55,12 @@ public interface DisposeDeviceManager {
|
|||
* @return the all dispose devices
|
||||
*/
|
||||
List<DisposeDevice> getAllNormalDisposeDevices();
|
||||
|
||||
/**
|
||||
* Gets all dispose devices.
|
||||
*
|
||||
* @param areaCode the areaCode
|
||||
* @return the dispose devices
|
||||
*/
|
||||
List<DisposeDevice> getDisposeDevices(Integer areaCode);
|
||||
}
|
||||
|
|
|
@ -274,4 +274,16 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
|
|||
.filter(v -> v.getStatus() == ObjectStatus.NORMAL)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,4 +94,13 @@ public interface DisposeDeviceMapper {
|
|||
*/
|
||||
DisposeDevice getDeviceById(@Param("id") Long id);
|
||||
|
||||
|
||||
/**
|
||||
* Gets deviceId by areaCode.
|
||||
*
|
||||
* @param areaCode the areaCode
|
||||
* @return the list
|
||||
*/
|
||||
List<DisposeDevice> getDeviceByAreaCode(@Param("areaCode") Integer areaCode);
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,12 @@ public interface DisposeDeviceManagerService {
|
|||
* @return the all dispose device
|
||||
*/
|
||||
List<DisposeDevice> getAllDisposeDevice();
|
||||
|
||||
/**
|
||||
* Gets dispose device by areaCode.
|
||||
*
|
||||
* @param areaCode the areaCode
|
||||
* @return the all dispose device
|
||||
*/
|
||||
List<DisposeDevice> getDisposeDeviceByAreaCode(Integer areaCode);
|
||||
}
|
||||
|
|
|
@ -128,4 +128,21 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,18 @@ package com.dispose.service.impl;
|
|||
import com.dispose.common.DisposeTaskStatus;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.manager.DisposeTaskManager;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeAbilityRouterService;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
import com.dispose.service.DisposeTaskService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Dispose task service.
|
||||
|
@ -32,6 +35,12 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
|||
@Resource
|
||||
DisposeAbilityRouterService disposeAbilityRouterService;
|
||||
|
||||
/**
|
||||
* The Dispose device manager service.
|
||||
*/
|
||||
@Resource
|
||||
DisposeDeviceManagerService disposeDeviceManagerService;
|
||||
|
||||
/**
|
||||
* Create task mul return type.
|
||||
*
|
||||
|
@ -55,9 +64,19 @@ public class DisposeTaskServiceImpl implements DisposeTaskService {
|
|||
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),
|
||||
disposeTaskManager.getDisposeTaskById(task.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop task mul return type.
|
||||
|
|
|
@ -129,4 +129,18 @@
|
|||
SET status = ${@com.dispose.common.ObjectStatus@NORMAL.getValue()}
|
||||
WHERE id = #{id}
|
||||
</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>
|
Loading…
Reference in New Issue