Commit 1b23f90a by 吕明尚

设备信息增加所属门店与房间字段,设备网关信息页面,增加所属门店

parent a6b30a3d
...@@ -53,9 +53,7 @@ public class DeviceController extends BaseController ...@@ -53,9 +53,7 @@ public class DeviceController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(DeviceDto device) public TableDataInfo list(DeviceDto device)
{ {
startPage(); return deviceService.devicePage(device);
List<Device> list = deviceService.selectDeviceList(device);
return getDataTable(list);
} }
/** /**
......
...@@ -46,9 +46,7 @@ public class DeviceGatewayController extends BaseController ...@@ -46,9 +46,7 @@ public class DeviceGatewayController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(DeviceGatewayDto deviceGatewayDto) public TableDataInfo list(DeviceGatewayDto deviceGatewayDto)
{ {
startPage(); return deviceGatewayService.deviceGatewayPage(deviceGatewayDto);
List<DeviceGateway> list = deviceGatewayService.selectDeviceGatewayList(deviceGatewayDto);
return getDataTable(list);
} }
/** /**
......
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.DeviceGateway;
@Data
public class DeviceGatewayVo extends DeviceGateway {
//门店名称
private String storeName;
}
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.Device;
@Data
public class DeviceVo extends Device {
//门店名称
private String storeName;
//房间名称
private String roomName;
}
...@@ -2,6 +2,7 @@ package share.system.service; ...@@ -2,6 +2,7 @@ package share.system.service;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.DeviceGateway; import share.system.domain.DeviceGateway;
import share.system.domain.DeviceGatewayDto; import share.system.domain.DeviceGatewayDto;
...@@ -67,4 +68,5 @@ public interface DeviceGatewayService extends IService<DeviceGateway> ...@@ -67,4 +68,5 @@ public interface DeviceGatewayService extends IService<DeviceGateway>
*/ */
boolean deviceGatewayStatusMonitor(); boolean deviceGatewayStatusMonitor();
TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto);
} }
...@@ -2,6 +2,7 @@ package share.system.service; ...@@ -2,6 +2,7 @@ package share.system.service;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.Device; import share.system.domain.Device;
import share.system.domain.DeviceDto; import share.system.domain.DeviceDto;
...@@ -81,4 +82,6 @@ public interface DeviceService extends IService<Device> ...@@ -81,4 +82,6 @@ public interface DeviceService extends IService<Device>
* @return 设备信息 * @return 设备信息
*/ */
Device selectDeviceByDevId(String devId); Device selectDeviceByDevId(String devId);
TableDataInfo devicePage(DeviceDto device);
} }
package share.system.service.impl; package share.system.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport;
import share.common.enums.DeviceStatusEnum; import share.common.enums.DeviceStatusEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
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 share.system.domain.Device;
import share.system.domain.DeviceGatewayDto; import share.system.domain.DeviceGatewayDto;
import share.system.domain.SStore;
import share.system.domain.vo.DeviceGatewayVo;
import share.system.domain.vo.DeviceVo;
import share.system.mapper.DeviceGatewayMapper; import share.system.mapper.DeviceGatewayMapper;
import share.system.domain.DeviceGateway; import share.system.domain.DeviceGateway;
import share.system.mapper.SStoreMapper;
import share.system.service.DeviceGatewayService; import share.system.service.DeviceGatewayService;
/** /**
...@@ -30,6 +44,8 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -30,6 +44,8 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
@Value("${mqtt.device-gateway-last-report-time}") @Value("${mqtt.device-gateway-last-report-time}")
private Integer deviceGatewayLastReportTime; private Integer deviceGatewayLastReportTime;
@Autowired
private SStoreMapper storeMapper;
/** /**
* 查询设备网关信息 * 查询设备网关信息
...@@ -124,4 +140,44 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -124,4 +140,44 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
}); });
return this.updateBatchById(list); return this.updateBatchById(list);
} }
@Override
public TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto) {
List<DeviceGateway> deviceGateways = deviceGatewayMapper.selectDeviceGatewayList(deviceGatewayDto);
List<DeviceGatewayVo> deviceGatewayVoList = convertDosToVos(deviceGateways);
if (CollectionUtils.isNotEmpty(deviceGatewayVoList)) {
List<SStore> sStoreList = storeMapper.selectList(new LambdaQueryWrapper<>());
deviceGatewayVoList.stream().forEach(item -> {
if (StringUtils.isNoneEmpty(item.getGroup())) {
SStore sStore = sStoreList.stream().filter(store -> store.getDeviceGroup().equals(item.getGroup())).findFirst().orElse(null);
if (ObjectUtil.isNotEmpty(sStore)) {
item.setStoreName(sStore.getName());
}
}
});
}
deviceGatewayVoList.sort(Comparator.comparing(DeviceGatewayVo::getCreateTime).reversed());
PageDomain pageDomain = TableSupport.buildPageRequest();
int start = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
int end = Math.min(start + pageDomain.getPageSize(), deviceGatewayVoList.size());
List<DeviceGatewayVo> deviceGatewayVos = deviceGatewayVoList.subList(start, end);
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setRows(deviceGatewayVos);
tableDataInfo.setTotal(deviceGatewayVoList.size());
tableDataInfo.setCode(200);
tableDataInfo.setMsg("查询成功");
return tableDataInfo;
}
private List<DeviceGatewayVo> convertDosToVos(List<DeviceGateway> deviceGateways) {
List<DeviceGatewayVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(deviceGateways)) {
deviceGateways.stream().forEach(o -> {
DeviceGatewayVo vo = new DeviceGatewayVo();
org.springframework.beans.BeanUtils.copyProperties(o, vo);
voList.add(vo);
});
}
return voList;
}
} }
package share.system.service.impl; package share.system.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
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 share.common.utils.SecurityUtils; import share.common.utils.SecurityUtils;
import share.common.utils.bean.BeanUtils;
import share.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.DeviceVo;
import share.system.domain.vo.SStoreVo;
import share.system.mapper.DeviceMapper; import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper; import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreMapper; import share.system.mapper.SStoreMapper;
...@@ -132,6 +143,39 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -132,6 +143,39 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
} }
@Override @Override
public TableDataInfo devicePage(DeviceDto device) {
List<Device> devices = deviceMapper.selectDeviceList(device);
List<DeviceVo> deviceVoList = convertDosToVos(devices);
if (CollectionUtils.isNotEmpty(deviceVoList)) {
List<SStore> sStoreList = storeMapper.selectList(new LambdaQueryWrapper<>());
List<SRoom> sRoomList = roomMapper.selectList(new LambdaQueryWrapper<>());
deviceVoList.stream().forEach(item -> {
if (ObjectUtil.isNotEmpty(item.getRoomId())) {
SRoom sRoom = sRoomList.stream().filter(room -> room.getId().equals(item.getRoomId())).findFirst().orElse(null);
if (ObjectUtil.isNotEmpty(sRoom)) {
SStore sStore = sStoreList.stream().filter(store -> store.getId().equals(sRoom.getStoreId())).findFirst().orElse(null);
if (ObjectUtil.isNotEmpty(sStore)) {
item.setStoreName(sStore.getName());
}
item.setRoomName(sRoom.getName());
}
}
});
}
deviceVoList.sort(Comparator.comparing(DeviceVo::getCreateTime).reversed());
PageDomain pageDomain = TableSupport.buildPageRequest();
int start = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
int end = Math.min(start + pageDomain.getPageSize(), deviceVoList.size());
List<DeviceVo> deviceVos = deviceVoList.subList(start, end);
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setRows(deviceVos);
tableDataInfo.setTotal(deviceVoList.size());
tableDataInfo.setCode(200);
tableDataInfo.setMsg("查询成功");
return tableDataInfo;
}
@Override
public List<Device> notRoomIdList(Device device) { public List<Device> notRoomIdList(Device device) {
SRoom room = roomMapper.selectSRoomById(device.getRoomId()); SRoom room = roomMapper.selectSRoomById(device.getRoomId());
if (room != null) { if (room != null) {
...@@ -147,4 +191,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -147,4 +191,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
return deviceMapper.notRoomIdList(device); return deviceMapper.notRoomIdList(device);
} }
private List<DeviceVo> convertDosToVos(List<Device> devices) {
List<DeviceVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(devices)) {
devices.stream().forEach(o -> {
DeviceVo vo = new DeviceVo();
org.springframework.beans.BeanUtils.copyProperties(o, vo);
voList.add(vo);
});
}
return voList;
}
} }
...@@ -255,8 +255,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -255,8 +255,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE); deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE);
} }
} }
//当前时间加90分钟 //当前时间加1年
Date date = DateUtils.addMinutes(new Date(), 90); Date date = DateUtils.addYears(new Date(), 1);
sOrder.setPreStartDate(date); sOrder.setPreStartDate(date);
sOrder.setPreEndDate(date); sOrder.setPreEndDate(date);
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode()); sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
......
...@@ -244,6 +244,7 @@ ...@@ -244,6 +244,7 @@
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = NOW(),</if> <if test="updateTime != null">update_time = NOW(),</if>
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if> <if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment