Commit 1b23f90a by 吕明尚

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

parent a6b30a3d
......@@ -53,9 +53,7 @@ public class DeviceController extends BaseController
@GetMapping("/list")
public TableDataInfo list(DeviceDto device)
{
startPage();
List<Device> list = deviceService.selectDeviceList(device);
return getDataTable(list);
return deviceService.devicePage(device);
}
/**
......
......@@ -46,9 +46,7 @@ public class DeviceGatewayController extends BaseController
@GetMapping("/list")
public TableDataInfo list(DeviceGatewayDto deviceGatewayDto)
{
startPage();
List<DeviceGateway> list = deviceGatewayService.selectDeviceGatewayList(deviceGatewayDto);
return getDataTable(list);
return deviceGatewayService.deviceGatewayPage(deviceGatewayDto);
}
/**
......
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;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.DeviceGateway;
import share.system.domain.DeviceGatewayDto;
......@@ -67,4 +68,5 @@ public interface DeviceGatewayService extends IService<DeviceGateway>
*/
boolean deviceGatewayStatusMonitor();
TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto);
}
......@@ -2,6 +2,7 @@ package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.Device;
import share.system.domain.DeviceDto;
......@@ -81,4 +82,6 @@ public interface DeviceService extends IService<Device>
* @return 设备信息
*/
Device selectDeviceByDevId(String devId);
TableDataInfo devicePage(DeviceDto device);
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
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.query.LambdaQueryWrapper;
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 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.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.Device;
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.domain.DeviceGateway;
import share.system.mapper.SStoreMapper;
import share.system.service.DeviceGatewayService;
/**
......@@ -30,6 +44,8 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
@Value("${mqtt.device-gateway-last-report-time}")
private Integer deviceGatewayLastReportTime;
@Autowired
private SStoreMapper storeMapper;
/**
* 查询设备网关信息
......@@ -124,4 +140,44 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
});
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;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.SecurityUtils;
import share.common.utils.bean.BeanUtils;
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.SRoomMapper;
import share.system.mapper.SStoreMapper;
......@@ -132,6 +143,39 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
@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) {
SRoom room = roomMapper.selectSRoomById(device.getRoomId());
if (room != null) {
......@@ -147,4 +191,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
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
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE);
}
}
//当前时间加90分钟
Date date = DateUtils.addMinutes(new Date(), 90);
//当前时间加1年
Date date = DateUtils.addYears(new Date(), 1);
sOrder.setPreStartDate(date);
sOrder.setPreEndDate(date);
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
......
......@@ -244,6 +244,7 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = NOW(),</if>
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</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