|
|
|
@ -3,6 +3,7 @@ package com.shxy.xymanager_service.impl;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalInfoDto;
|
|
|
|
@ -14,6 +15,8 @@ import com.shxy.xymanager_common.exception.Asserts;
|
|
|
|
|
import com.shxy.xymanager_common.model.TerminalListModel;
|
|
|
|
|
import com.shxy.xymanager_common.model.TerminalModel;
|
|
|
|
|
import com.shxy.xymanager_common.page.PageUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.MyDateUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.ProcessExecUtils;
|
|
|
|
|
import com.shxy.xymanager_common.vo.*;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalChannelMapperDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
|
|
|
|
@ -27,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -166,31 +170,53 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
/**
|
|
|
|
|
* 装置复位
|
|
|
|
|
*
|
|
|
|
|
* @param vo
|
|
|
|
|
* @param cmId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<String> resetTerminal(TerminalIdVo vo) {
|
|
|
|
|
public ServiceBody<String> resetTerminal(String cmId) {
|
|
|
|
|
// Cma cma = new Cma("47.96.238.157", 6891);
|
|
|
|
|
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=47.96.238.157 --port=6891 --act=reset --cmdid=" +cmId +"\t"+"--mode=0";
|
|
|
|
|
Integer retCode = ProcessExecUtils.exec(cmd);
|
|
|
|
|
// boolean reset = cma.reset(vo.getTermid().toString(), (short) 0x01);
|
|
|
|
|
// if (reset) {
|
|
|
|
|
return Asserts.success("删除成功");
|
|
|
|
|
// } else {
|
|
|
|
|
// return Asserts.error("装置复位成功");
|
|
|
|
|
// }
|
|
|
|
|
if (retCode ==0) {
|
|
|
|
|
return Asserts.success("装置复位成功");
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("装置复位失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<TerminalModel> getTerminalInfo(Integer termId) {
|
|
|
|
|
public ServiceBody<TerminalModel> getTerminalStatus(Integer termId) {
|
|
|
|
|
String cmdId = terminalsDao.getCmdIdByTermId(termId);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --act=runningstatus --cmdid="+cmdId;
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
TerminalModel model = new TerminalModel();
|
|
|
|
|
TerminalInfoDto dto = terminalsDao.getTerminalInfo(termId);
|
|
|
|
|
if(null!=dto) {
|
|
|
|
|
BeanUtils.copyProperties(dto, model);
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
|
model.setQueryTime(now);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<TerminalModel> getLastedTerminalStatus(TerminalStatusVo vo) {
|
|
|
|
|
BigInteger wsUpdateTime = terminalsDao.getUpdateTime(vo.getTermId());
|
|
|
|
|
BigInteger queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime());
|
|
|
|
|
Boolean hasNew =wsUpdateTime.compareTo(queryTime)<0?false:true;
|
|
|
|
|
TerminalModel model = new TerminalModel();
|
|
|
|
|
if(hasNew) {
|
|
|
|
|
TerminalInfoDto dto = terminalsDao.getTerminalInfo(vo.getTermId());
|
|
|
|
|
BeanUtils.copyProperties(dto,model);
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
return Asserts.success(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|