|
@@ -1,21 +1,30 @@
|
|
|
package com.bizmatics.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.bizmatics.common.core.bean.CommonPage;
|
|
|
import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
import com.bizmatics.model.Device;
|
|
|
+import com.bizmatics.model.DeviceAnalogVariableList;
|
|
|
import com.bizmatics.model.DeviceList;
|
|
|
-import com.bizmatics.model.PowerQualityConfig;
|
|
|
-import com.bizmatics.model.TemplateData;
|
|
|
+import com.bizmatics.model.system.SysUser;
|
|
|
+import com.bizmatics.model.vo.CorrespondDeviceListVO;
|
|
|
+import com.bizmatics.model.vo.CorrespondDeviceVO;
|
|
|
import com.bizmatics.persistence.mapper.DeviceMapper;
|
|
|
+import com.bizmatics.service.DeviceAnalogVariableListService;
|
|
|
import com.bizmatics.service.DeviceService;
|
|
|
import com.bizmatics.service.enums.DeviceStatusCode;
|
|
|
import com.bizmatics.service.enums.DeviceType;
|
|
|
import com.bizmatics.service.util.SecurityUtils;
|
|
|
+import com.bizmatics.service.vo.CommonIcoVO;
|
|
|
+import com.bizmatics.service.vo.CorrespondDeviceVOT;
|
|
|
import com.bizmatics.service.vo.DeviceCountVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.sql.Wrapper;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
@@ -32,6 +41,9 @@ import java.util.Optional;
|
|
|
public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device> implements DeviceService {
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceAnalogVariableListService deviceAnalogVariableListService;
|
|
|
+
|
|
|
@Override
|
|
|
public DeviceCountVO selectDeviceCount(Date startTime, Date endTime) {
|
|
|
Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
|
|
@@ -78,18 +90,96 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DeviceList> deviceList(String siteId){
|
|
|
+ public List<DeviceList> deviceList(String siteId) {
|
|
|
List<DeviceList> DeviceList = null;
|
|
|
DeviceList = baseMapper.DeviceList(Integer.parseInt(siteId));
|
|
|
return DeviceList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Device> dataManagementDeviceList(int siteId,int deviceType){
|
|
|
+ public List<Device> dataManagementDeviceList(int siteId, int deviceType) {
|
|
|
LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(Device::getEnable, 1).eq(Device::getSiteId, siteId);
|
|
|
List<Device> deviceList = this.list(queryWrapper);
|
|
|
return deviceList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void correspondDeviceAdd(CorrespondDeviceVOT correspondDeviceVOT) {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ Device device = correspondDeviceVOT.getDevice();
|
|
|
+ device.setEnable(1);
|
|
|
+ device.setInstallTime(new Date());
|
|
|
+ device.setCreator(user.getUserName());
|
|
|
+ List<DeviceAnalogVariableList> DeviceAnalogVariableList = correspondDeviceVOT.getDeviceAnalogVariableList();
|
|
|
+ this.save(device);
|
|
|
+ int ID = device.getId();
|
|
|
+ if (DeviceAnalogVariableList.size() > 0) {
|
|
|
+ for (int i = 0; i < DeviceAnalogVariableList.size(); i++) {
|
|
|
+ DeviceAnalogVariableList.get(i).setCommunicationEquipment(ID);
|
|
|
+ DeviceAnalogVariableList.get(i).setCreateTime(LocalDateTime.now());
|
|
|
+ DeviceAnalogVariableList.get(i).setCreator(user.getUserName());
|
|
|
+ DeviceAnalogVariableList.get(i).setStatus(1);
|
|
|
+ deviceAnalogVariableListService.save(DeviceAnalogVariableList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void correspondDeviceUpdate(CorrespondDeviceVOT correspondDeviceVOT) {
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ List<DeviceAnalogVariableList> DeviceAnalogVariableList = correspondDeviceVOT.getDeviceAnalogVariableList();
|
|
|
+ this.updateById(correspondDeviceVOT.getDevice());
|
|
|
+ int ID = correspondDeviceVOT.getDevice().getId();
|
|
|
+ if (DeviceAnalogVariableList.size() > 0) {
|
|
|
+ for (int i = 0; i < DeviceAnalogVariableList.size(); i++) {
|
|
|
+ DeviceAnalogVariableList.get(i).setCommunicationEquipment(ID);
|
|
|
+ DeviceAnalogVariableList.get(i).setCreateTime(LocalDateTime.now());
|
|
|
+ DeviceAnalogVariableList.get(i).setCreator(user.getUserName());
|
|
|
+ DeviceAnalogVariableList.get(i).setStatus(1);
|
|
|
+ deviceAnalogVariableListService.save(DeviceAnalogVariableList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void correspondDeviceDel(int id) {
|
|
|
+ Device device = new Device();
|
|
|
+ device.setId(id);
|
|
|
+ device.setEnable(0);
|
|
|
+ this.updateById(device);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<CorrespondDeviceVO> correspondDeviceList(String deviceName, int size, int current) {
|
|
|
+ List<CorrespondDeviceVO> correspondDeviceListOne = baseMapper.CorrespondDeviceList(deviceName, null, null);
|
|
|
+ int total=0;
|
|
|
+ if (correspondDeviceListOne.size()>0){
|
|
|
+ total= correspondDeviceListOne.size();
|
|
|
+ }
|
|
|
+ int startCurrent = (size - 1) * current;
|
|
|
+ List<CorrespondDeviceVO> correspondDeviceList = baseMapper.CorrespondDeviceList(deviceName, startCurrent, current);
|
|
|
+ return new CommonPage<>(correspondDeviceList, total, current, size);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CorrespondDeviceListVO> correspondDeviceListEcho(int id){
|
|
|
+ LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(Device::getEnable, 1).eq(Device::getId, id);
|
|
|
+ List<Device> deviceList = this.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<DeviceAnalogVariableList> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
+ queryWrapperOne.eq(DeviceAnalogVariableList::getStatus, 1).eq(DeviceAnalogVariableList::getCommunicationEquipment, deviceList.get(0).getId());
|
|
|
+ List<DeviceAnalogVariableList> deviceAnalogVariableList = deviceAnalogVariableListService.list(queryWrapperOne);
|
|
|
+
|
|
|
+ List<CorrespondDeviceListVO> list = new ArrayList<>();
|
|
|
+ list.add(CorrespondDeviceListVO.builder().deviceCode(deviceList.get(0).getDeviceCode()).deviceName(deviceList.get(0).getDeviceName())
|
|
|
+ .deviceType(deviceList.get(0).getDeviceType()).deviceAddress(deviceList.get(0).getDeviceAddress())
|
|
|
+ .creator(deviceList.get(0).getCreator()).enable(deviceList.get(0).getEnable()).floor(deviceList.get(0).getFloor())
|
|
|
+ .id(deviceList.get(0).getId()).sim(deviceList.get(0).getSim()).siteId(deviceList.get(0).getSiteId())
|
|
|
+ .installTime(deviceList.get(0).getInstallTime()).deviceAnalogVariableList(deviceAnalogVariableList).build());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|