|
|
@ -24,16 +24,16 @@ import com.shxy.xymanager_common.util.StringUtils;
|
|
|
|
import com.shxy.xymanager_common.util.TerminalUtils;
|
|
|
|
import com.shxy.xymanager_common.util.TerminalUtils;
|
|
|
|
import com.shxy.xymanager_common.vo.*;
|
|
|
|
import com.shxy.xymanager_common.vo.*;
|
|
|
|
import com.shxy.xymanager_dao.dao.*;
|
|
|
|
import com.shxy.xymanager_dao.dao.*;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_service.cache.XyCache;
|
|
|
|
import com.shxy.xymanager_service.service.CacheService;
|
|
|
|
import com.shxy.xymanager_service.service.CacheService;
|
|
|
|
import com.shxy.xymanager_service.service.TerminalService;
|
|
|
|
import com.shxy.xymanager_service.service.TerminalService;
|
|
|
|
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.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
import java.math.BigInteger;
|
|
|
|
import java.math.BigInteger;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
@ -146,7 +146,7 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
for (TermChannelAndMapperDto dto : channellist) {
|
|
|
|
for (TermChannelAndMapperDto dto : channellist) {
|
|
|
|
TerminalListModel.ChannelBeans e = new TerminalListModel.ChannelBeans();
|
|
|
|
TerminalListModel.ChannelBeans e = new TerminalListModel.ChannelBeans();
|
|
|
|
e.setAlias(dto.getAlias());
|
|
|
|
e.setAlias(dto.getAlias());
|
|
|
|
e.setId(dto.getId());
|
|
|
|
e.setId(dto.getChannelid());
|
|
|
|
e.setName(dto.getChannelname());
|
|
|
|
e.setName(dto.getChannelname());
|
|
|
|
list.add(e);
|
|
|
|
list.add(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -201,7 +201,11 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Date date = new Date();
|
|
|
|
Date date = new Date();
|
|
|
|
int i1 = terminalChannelMapperDao.insertList(list, date, date);
|
|
|
|
int i1 = terminalChannelMapperDao.insertList(list, date, date);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cacheService.updateTerminalMap();
|
|
|
|
|
|
|
|
cacheService.updateTermAndChannelMap();
|
|
|
|
|
|
|
|
cacheService.updateTermChannelMapMap();
|
|
|
|
if (i != 0) {
|
|
|
|
if (i != 0) {
|
|
|
|
return Asserts.success("录入成功");
|
|
|
|
return Asserts.success("录入成功");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -235,6 +239,9 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
Date date = new Date();
|
|
|
|
Date date = new Date();
|
|
|
|
terminalChannelMapperDao.insertList(list, date, date);
|
|
|
|
terminalChannelMapperDao.insertList(list, date, date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cacheService.updateTerminalMap();
|
|
|
|
|
|
|
|
cacheService.updateTermAndChannelMap();
|
|
|
|
|
|
|
|
cacheService.updateTermChannelMapMap();
|
|
|
|
if (i != 0) {
|
|
|
|
if (i != 0) {
|
|
|
|
return Asserts.success("修改成功");
|
|
|
|
return Asserts.success("修改成功");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -258,6 +265,7 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
list.add(terminals);
|
|
|
|
list.add(terminals);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
|
|
|
|
int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
|
|
|
|
|
|
|
|
cacheService.updateTerminalMap();
|
|
|
|
if (i != 0) {
|
|
|
|
if (i != 0) {
|
|
|
|
return Asserts.success("删除成功");
|
|
|
|
return Asserts.success("删除成功");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -307,29 +315,31 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public ServiceBody<TerminalModel> getLastedTerminalStatus(TerminalStatusVo vo) {
|
|
|
|
public ServiceBody<TerminalStatusInfoModel> getLastedTerminalStatus(TerminalStatusVo vo) {
|
|
|
|
/* String result = terminalPhotoDao.getRequestResult(5);//待修改
|
|
|
|
TerminalStatusInfoModel model = new TerminalStatusInfoModel();
|
|
|
|
TerminalModel model = new TerminalModel();
|
|
|
|
Integer termId = vo.getTermId();
|
|
|
|
if (StringUtils.isNotBlank(result)) {
|
|
|
|
TerminalStatus bean = terminalStatusDao.selectByPrimaryKey(termId);
|
|
|
|
model = JSONObject.parseObject(result, TerminalModel.class);
|
|
|
|
|
|
|
|
model.setIsNew(true);
|
|
|
|
|
|
|
|
} else {*/
|
|
|
|
|
|
|
|
TerminalModel model = new TerminalModel();
|
|
|
|
|
|
|
|
TerminalInfoDto dto = terminalsDao.getTerminalInfo(vo.getTermId());
|
|
|
|
|
|
|
|
Boolean hasNew = false;
|
|
|
|
Boolean hasNew = false;
|
|
|
|
if (null != dto) {
|
|
|
|
if (BeanUtil.isNotEmpty(bean)) {
|
|
|
|
BeanUtils.copyProperties(dto, model);
|
|
|
|
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
|
|
|
|
BigInteger wsUpdateTime = dto.getWsUpdateTime();
|
|
|
|
Terminals terminals = terminalMap.get(termId);
|
|
|
|
|
|
|
|
if (BeanUtil.isNotEmpty(terminals)) {
|
|
|
|
|
|
|
|
model.setCmId(terminals.getCmdid());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
model.setBatteryCapacity(bean.getBatteryCapacity());
|
|
|
|
|
|
|
|
model.setBatteryVoltage(bean.getBatteryVoltage());
|
|
|
|
|
|
|
|
model.setConnectionState(bean.getConnectionState());
|
|
|
|
|
|
|
|
model.setFloatingCharge(bean.getFloatingCharge());
|
|
|
|
|
|
|
|
model.setTermId(termId);
|
|
|
|
|
|
|
|
model.setTotalWorkingTime(bean.getTotalWorkingTime());
|
|
|
|
|
|
|
|
model.setWorkingTime(bean.getWorkingTime());
|
|
|
|
|
|
|
|
model.setWsUpdateTime(bean.getWsUpdateTime());
|
|
|
|
|
|
|
|
BigInteger wsUpdateTime = bean.getWsUpdateTime();
|
|
|
|
long queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime());
|
|
|
|
long queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime());
|
|
|
|
hasNew = wsUpdateTime.longValue() < queryTime ? false : true;
|
|
|
|
hasNew = wsUpdateTime.longValue() < queryTime ? false : true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
model.setIsNew(hasNew);
|
|
|
|
model.setIsNew(hasNew);
|
|
|
|
/* if (dto != null) {
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(dto, model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
model.setWsUpdateTime(MyDateUtils.TimeSecond2MillSecond(dto.getWsUpdateTime().longValue()));
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
return Asserts.success(model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -342,9 +352,9 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
|
|
|
|
|
|
|
int result = terminalsDao.updateCmd(vo);
|
|
|
|
int result = terminalsDao.updateCmd(vo);
|
|
|
|
if (result > 0) {
|
|
|
|
if (result > 0) {
|
|
|
|
|
|
|
|
cacheService.updateTerminalMap();
|
|
|
|
return Asserts.success(model);
|
|
|
|
return Asserts.success(model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Asserts.error("装置ID修改失败");
|
|
|
|
return Asserts.error("装置ID修改失败");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -471,5 +481,33 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
return Asserts.success(model);
|
|
|
|
return Asserts.success(model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取数据库最新装置信息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param termId
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public ServiceBody<TerminalStatusInfoModel> getLastTermInfo(Integer termId) {
|
|
|
|
|
|
|
|
TerminalStatusInfoModel model = new TerminalStatusInfoModel();
|
|
|
|
|
|
|
|
TerminalStatus bean = terminalStatusDao.selectByPrimaryKey(termId);
|
|
|
|
|
|
|
|
if (!BeanUtil.isEmpty(bean)) {
|
|
|
|
|
|
|
|
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
|
|
|
|
|
|
|
|
Terminals terminals = terminalMap.get(termId);
|
|
|
|
|
|
|
|
if (BeanUtil.isNotEmpty(terminals)) {
|
|
|
|
|
|
|
|
model.setCmId(terminals.getCmdid());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
model.setBatteryCapacity(bean.getBatteryCapacity());
|
|
|
|
|
|
|
|
model.setBatteryVoltage(bean.getBatteryVoltage());
|
|
|
|
|
|
|
|
model.setConnectionState(bean.getConnectionState());
|
|
|
|
|
|
|
|
model.setFloatingCharge(bean.getFloatingCharge());
|
|
|
|
|
|
|
|
model.setTermId(termId);
|
|
|
|
|
|
|
|
model.setTotalWorkingTime(bean.getTotalWorkingTime());
|
|
|
|
|
|
|
|
model.setWorkingTime(bean.getWorkingTime());
|
|
|
|
|
|
|
|
model.setWsUpdateTime(bean.getWsUpdateTime());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|