Commit 0a0f933f by 黄小葱

新增接口(1)

1 parent c0ed0ba9
...@@ -11,14 +11,11 @@ import com.glsx.plat.core.web.R; ...@@ -11,14 +11,11 @@ import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank; import java.util.Collection;
import java.util.List;
@Slf4j @Slf4j
@Validated @Validated
...@@ -61,6 +58,16 @@ public class DeviceApiController implements DeviceFeignService { ...@@ -61,6 +58,16 @@ public class DeviceApiController implements DeviceFeignService {
return R.ok().data(statusModel); 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; ...@@ -4,9 +4,14 @@ import cn.com.glsx.devicemonitor.modules.entity.Device;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
@Mapper @Mapper
public interface DeviceMapper extends CommonBaseMapper<Device> { public interface DeviceMapper extends CommonBaseMapper<Device> {
Device selectBySn(String sn); Device selectBySn(String sn);
List<Device> selectBySns(Collection<String> sns);
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,9 @@ import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel; ...@@ -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.entity.Device;
import cn.com.glsx.devicemonitor.modules.model.TrackInfoBo; import cn.com.glsx.devicemonitor.modules.model.TrackInfoBo;
import java.util.Collection;
import java.util.List;
/** /**
* @desc 提供设备相关的服务 * @desc 提供设备相关的服务
* @author huangxc * @author huangxc
...@@ -54,4 +57,12 @@ public interface DeviceService { ...@@ -54,4 +57,12 @@ public interface DeviceService {
* @return 设备上点总次数 * @return 设备上点总次数
*/ */
Integer getDevicesTotalCount(String sn); 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; ...@@ -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.model.TrackInfoBo;
import cn.com.glsx.devicemonitor.modules.service.DeviceService; import cn.com.glsx.devicemonitor.modules.service.DeviceService;
import cn.com.glsx.devicemonitor.modules.utils.DeviceUtils; import cn.com.glsx.devicemonitor.modules.utils.DeviceUtils;
import com.alibaba.excel.util.CollectionUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collection; import java.util.*;
import java.util.Date;
@Slf4j @Slf4j
@Service @Service
...@@ -64,6 +64,16 @@ public class DeviceServiceImpl implements DeviceService { ...@@ -64,6 +64,16 @@ public class DeviceServiceImpl implements DeviceService {
DeviceStatusModel statusModel = DeviceUtils.parseDeviceStatus(deviceLogin, device.getSource(), offlineTime); DeviceStatusModel statusModel = DeviceUtils.parseDeviceStatus(deviceLogin, device.getSource(), offlineTime);
return statusModel; 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 @Override
public TrackInfoBo getTrackInfoBo(String sn) { public TrackInfoBo getTrackInfoBo(String sn) {
......
...@@ -44,4 +44,15 @@ ...@@ -44,4 +44,15 @@
and sn = #{sn} and sn = #{sn}
</select> </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> </mapper>
\ No newline at end of file \ 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!