Commit 0a0f933f by 黄小葱

新增接口(1)

1 parent c0ed0ba9
......@@ -11,14 +11,11 @@ import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.Collection;
import java.util.List;
@Slf4j
@Validated
......@@ -61,6 +58,16 @@ public class DeviceApiController implements DeviceFeignService {
return R.ok().data(statusModel);
}
@Override
@PostMapping(value = "/listDeviceStatusBySns")
public R<List<DeviceStatusModel>> listDeviceStatusBySns(Collection<String> sns, Long offlineTime) {
if (offlineTime == null || offlineTime == 0) {
offlineTime = ConstantsDevice.OFFLINE_TIME_OTHER;
}
List<DeviceStatusModel> deviceStatusList = deviceService.listDeviceStatusBySns(sns, offlineTime);
return R.ok().data(deviceStatusList);
}
/**
* 获取设备上点总个数
......
......@@ -4,9 +4,14 @@ import cn.com.glsx.devicemonitor.modules.entity.Device;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
@Mapper
public interface DeviceMapper extends CommonBaseMapper<Device> {
Device selectBySn(String sn);
List<Device> selectBySns(Collection<String> sns);
}
\ No newline at end of file
......@@ -5,6 +5,9 @@ import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel;
import cn.com.glsx.devicemonitor.modules.entity.Device;
import cn.com.glsx.devicemonitor.modules.model.TrackInfoBo;
import java.util.Collection;
import java.util.List;
/**
* @desc 提供设备相关的服务
* @author huangxc
......@@ -54,4 +57,12 @@ public interface DeviceService {
* @return 设备上点总次数
*/
Integer getDevicesTotalCount(String sn);
/**
* 批量获取设备状态
* @param sns
* @param offlineTime
* @return
*/
List<DeviceStatusModel> listDeviceStatusBySns(Collection<String> sns, Long offlineTime);
}
......@@ -11,13 +11,13 @@ import cn.com.glsx.devicemonitor.modules.mapper.DeviceMapper;
import cn.com.glsx.devicemonitor.modules.model.TrackInfoBo;
import cn.com.glsx.devicemonitor.modules.service.DeviceService;
import cn.com.glsx.devicemonitor.modules.utils.DeviceUtils;
import com.alibaba.excel.util.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Date;
import java.util.*;
@Slf4j
@Service
......@@ -64,6 +64,16 @@ public class DeviceServiceImpl implements DeviceService {
DeviceStatusModel statusModel = DeviceUtils.parseDeviceStatus(deviceLogin, device.getSource(), offlineTime);
return statusModel;
}
@Override
public List<DeviceStatusModel> listDeviceStatusBySns(Collection<String> sns, Long offlineTime) {
List<DeviceStatusModel> statusModels = new LinkedList<>();
if (CollectionUtils.isEmpty(sns)) {
return statusModels;
}
//TODO 正在实现...
return statusModels;
}
@Override
public TrackInfoBo getTrackInfoBo(String sn) {
......
......@@ -44,4 +44,15 @@
and sn = #{sn}
</select>
<select id="selectBySns" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_device
where del_flag = 0 and sn in
<foreach collection="sns" item="item" separator="," open="(" close=")" >
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!