|
|
|
@ -9,7 +9,6 @@ import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalInfoDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalChannelMapper;
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalStatus;
|
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
|
import com.shxy.xymanager_common.enums.CommonStatus;
|
|
|
|
|
import com.shxy.xymanager_common.exception.Asserts;
|
|
|
|
@ -23,17 +22,13 @@ import com.shxy.xymanager_dao.dao.TerminalChannelMapperDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalStatusDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalsDao;
|
|
|
|
|
import com.shxy.xymanager_service.interaction.Cma;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import net.sf.jsqlparser.expression.StringValue;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -60,9 +55,6 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private TerminalStatusDao terminalStatusDao;
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private Cma cma;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有设备列表
|
|
|
|
|
*
|
|
|
|
@ -135,9 +127,24 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<String> updateTerminal(UpdateTerminalVo vo) {
|
|
|
|
|
Integer termid = vo.getId();
|
|
|
|
|
List<Integer> channelid = vo.getChannelid();
|
|
|
|
|
Terminals terminals = new Terminals();
|
|
|
|
|
BeanUtil.copyProperties(vo, terminals, true);
|
|
|
|
|
int i = terminalsDao.updateByPrimaryKeySelective(terminals, new Date());
|
|
|
|
|
|
|
|
|
|
terminalChannelMapperDao.deleteByTermId(termid);
|
|
|
|
|
if (!CollectionUtil.isEmpty(channelid)) {
|
|
|
|
|
List<TerminalChannelMapper> list = new ArrayList<>();
|
|
|
|
|
for (Integer id : channelid) {
|
|
|
|
|
TerminalChannelMapper record = new TerminalChannelMapper();
|
|
|
|
|
record.setChannelId(id);
|
|
|
|
|
record.setTermId(termid);
|
|
|
|
|
list.add(record);
|
|
|
|
|
}
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
terminalChannelMapperDao.insertList(list, date, date);
|
|
|
|
|
}
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
return Asserts.success("修改成功");
|
|
|
|
|
} else {
|
|
|
|
@ -160,7 +167,6 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
terminals.setId(item.getTermid());
|
|
|
|
|
list.add(terminals);
|
|
|
|
|
}
|
|
|
|
|
// List<Terminals> list = BeanUtil.copyToList(vo.getList(), Terminals.class);
|
|
|
|
|
int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
|
|
|
|
|
if (i != 0) {
|
|
|
|
|
return Asserts.success("删除成功");
|
|
|
|
@ -179,13 +185,13 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<String> resetTerminal(String cmId) {
|
|
|
|
|
// Cma cma = new Cma("47.96.238.157", 6891);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=reset --cmdid=" +cmId +"\t"+"--mode=0";
|
|
|
|
|
Integer retCode = ProcessExecUtils.exec(cmd);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=reset --cmdid=" + cmId + "\t" + "--mode=0";
|
|
|
|
|
Integer retCode = ProcessExecUtils.exec(cmd);
|
|
|
|
|
// boolean reset = cma.reset(vo.getTermid().toString(), (short) 0x01);
|
|
|
|
|
if (retCode ==0) {
|
|
|
|
|
if (retCode == 0) {
|
|
|
|
|
return Asserts.success("装置复位成功");
|
|
|
|
|
} else {
|
|
|
|
|
return Asserts.error("装置复位失败");
|
|
|
|
|
return Asserts.error("装置复位失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -193,11 +199,11 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
@Override
|
|
|
|
|
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;
|
|
|
|
|
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) {
|
|
|
|
|
if (null != dto) {
|
|
|
|
|
BigInteger updatetime = MyDateUtils.TimeSecond2MillSecond(dto.getWsUpdateTime().longValue());
|
|
|
|
|
BeanUtils.copyProperties(dto, model);
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
@ -212,11 +218,11 @@ public class TerminalServiceImpl implements TerminalService {
|
|
|
|
|
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;
|
|
|
|
|
Boolean hasNew = wsUpdateTime.compareTo(queryTime) < 0 ? false : true;
|
|
|
|
|
TerminalModel model = new TerminalModel();
|
|
|
|
|
if(hasNew) {
|
|
|
|
|
if (hasNew) {
|
|
|
|
|
TerminalInfoDto dto = terminalsDao.getTerminalInfo(vo.getTermId());
|
|
|
|
|
BeanUtils.copyProperties(dto,model);
|
|
|
|
|
BeanUtils.copyProperties(dto, model);
|
|
|
|
|
String updateTime = MyDateUtils.TimeSecondToDate(dto.getWsUpdateTime());
|
|
|
|
|
model.setWsUpdateTime(updateTime);
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|