|
|
|
@ -1,8 +1,6 @@
|
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.entity.MntnCmdHistory;
|
|
|
|
|
import com.shxy.xymanager_common.entity.MntnCmds;
|
|
|
|
|
import com.shxy.xymanager_common.entity.MntnCmdsExample;
|
|
|
|
|
import com.shxy.xymanager_common.entity.*;
|
|
|
|
|
import com.shxy.xymanager_common.exception.ApiException;
|
|
|
|
|
import com.shxy.xymanager_common.model.CmdModel;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.MntnCmdHistoryMapper;
|
|
|
|
@ -12,6 +10,7 @@ import com.shxy.xymanager_service.service.MntnCmdsService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -44,7 +43,24 @@ public class MntnCmdsServiceImpl implements MntnCmdsService {
|
|
|
|
|
case "cancel":
|
|
|
|
|
this.cancel(model);
|
|
|
|
|
break;
|
|
|
|
|
case "":
|
|
|
|
|
case "clear":
|
|
|
|
|
this.clear(model);
|
|
|
|
|
break;
|
|
|
|
|
case "clearHis":
|
|
|
|
|
this.clearHis(model);
|
|
|
|
|
break;
|
|
|
|
|
case "mntn":
|
|
|
|
|
this.mntn(model);
|
|
|
|
|
break;
|
|
|
|
|
case "quickhb":
|
|
|
|
|
this.quickhb(model);
|
|
|
|
|
break;
|
|
|
|
|
case "reset":
|
|
|
|
|
this.reset(model);
|
|
|
|
|
break;
|
|
|
|
|
case "reset-mcu":
|
|
|
|
|
this.resetmcu(model);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -68,4 +84,103 @@ public class MntnCmdsServiceImpl implements MntnCmdsService {
|
|
|
|
|
cmdsMapper.deleteByPrimaryKey(item.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void clear(CmdModel model) {
|
|
|
|
|
MntnCmdsExample example = new MntnCmdsExample();
|
|
|
|
|
MntnCmdsExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
List<MntnCmds> list = cmdsMapper.selectByExample(example);
|
|
|
|
|
for (MntnCmds item : list) {
|
|
|
|
|
MntnCmdHistory history = new MntnCmdHistory();
|
|
|
|
|
history.setId(item.getId());
|
|
|
|
|
history.setCmd(item.getCmd());
|
|
|
|
|
history.setDesc(item.getDesc());
|
|
|
|
|
history.setName(item.getName());
|
|
|
|
|
history.setTermId(item.getTermId());
|
|
|
|
|
history.setCreateTime(item.getCreateTime());
|
|
|
|
|
history.setStatus(Byte.valueOf("2"));
|
|
|
|
|
history.setPublishTime(new Date());
|
|
|
|
|
historyMapper.insert(history);
|
|
|
|
|
cmdsMapper.deleteByPrimaryKey(item.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void clearHis(CmdModel model) {
|
|
|
|
|
MntnCmdHistoryExample example = new MntnCmdHistoryExample();
|
|
|
|
|
MntnCmdHistoryExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
|
|
|
|
|
MntnCmdHistory row = new MntnCmdHistory();
|
|
|
|
|
row.setStatus(Byte.valueOf("0"));
|
|
|
|
|
historyMapper.updateByExampleSelective(row, example);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mntn(CmdModel model) {
|
|
|
|
|
if (CollectionUtils.isEmpty(model.getTermIds())) {
|
|
|
|
|
throw new ApiException("termIds不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Integer termId : model.getTermIds()) {
|
|
|
|
|
MntnStatusExample example = new MntnStatusExample();
|
|
|
|
|
MntnStatusExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andTermIdEqualTo(termId);
|
|
|
|
|
|
|
|
|
|
MntnStatus record = new MntnStatus();
|
|
|
|
|
record.setInMaintain(model.getMntnMode());
|
|
|
|
|
record.setModeTime(System.currentTimeMillis() / 1000);
|
|
|
|
|
statusMapper.updateByExampleSelective(record, example);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void quickhb(CmdModel model) {
|
|
|
|
|
if (CollectionUtils.isEmpty(model.getTermIds())) {
|
|
|
|
|
throw new ApiException("termIds不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Integer termId : model.getTermIds()) {
|
|
|
|
|
MntnStatusExample example = new MntnStatusExample();
|
|
|
|
|
MntnStatusExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andTermIdEqualTo(termId);
|
|
|
|
|
|
|
|
|
|
MntnStatus record = new MntnStatus();
|
|
|
|
|
record.setQuickHb(model.getQuickHeartbeat());
|
|
|
|
|
record.setModeTime(System.currentTimeMillis() / 1000);
|
|
|
|
|
statusMapper.updateByExampleSelective(record, example);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void reset(CmdModel model) {
|
|
|
|
|
if (model.getTermId() == null) {
|
|
|
|
|
throw new ApiException("termId不能为空");
|
|
|
|
|
}
|
|
|
|
|
String name = "yw_cmd_android_reboot";
|
|
|
|
|
MntnCmdsExample example = new MntnCmdsExample();
|
|
|
|
|
MntnCmdsExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andTermIdEqualTo(model.getTermId());
|
|
|
|
|
criteria.andNameEqualTo(name);
|
|
|
|
|
cmdsMapper.deleteByExample(example);
|
|
|
|
|
|
|
|
|
|
MntnCmds cmd = new MntnCmds();
|
|
|
|
|
cmd.setTermId(model.getTermId());
|
|
|
|
|
cmd.setName(name);
|
|
|
|
|
cmd.setCreateTime(new Date());
|
|
|
|
|
cmdsMapper.insert(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetmcu(CmdModel model) {
|
|
|
|
|
if (model.getTermId() == null) {
|
|
|
|
|
throw new ApiException("termId不能为空");
|
|
|
|
|
}
|
|
|
|
|
String name = "yw_cmd_mcu_reboot";
|
|
|
|
|
MntnCmdsExample example = new MntnCmdsExample();
|
|
|
|
|
MntnCmdsExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andTermIdEqualTo(model.getTermId());
|
|
|
|
|
criteria.andNameEqualTo(name);
|
|
|
|
|
cmdsMapper.deleteByExample(example);
|
|
|
|
|
|
|
|
|
|
MntnCmds cmd = new MntnCmds();
|
|
|
|
|
cmd.setTermId(model.getTermId());
|
|
|
|
|
cmd.setName(name);
|
|
|
|
|
cmd.setCreateTime(new Date());
|
|
|
|
|
cmdsMapper.insert(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|