|
|
|
@ -1,14 +1,22 @@
|
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.constant.Constants;
|
|
|
|
|
import com.shxy.xymanager_common.dto.PhotoParamsDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalParams;
|
|
|
|
|
import com.shxy.xymanager_common.exception.Asserts;
|
|
|
|
|
import com.shxy.xymanager_common.model.SystemConfigModel;
|
|
|
|
|
import com.shxy.xymanager_common.model.TerminalPhotosParamsModel;
|
|
|
|
|
import com.shxy.xymanager_common.util.ProcessExecUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.StringUtils;
|
|
|
|
|
import com.shxy.xymanager_common.vo.SystemConfigReqVo;
|
|
|
|
|
import com.shxy.xymanager_common.vo.SystemConfigVo;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.SystemConfigDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalPhotoDao;
|
|
|
|
|
import com.shxy.xymanager_service.service.SystemConfigService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
@ -23,15 +31,21 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
|
|
|
|
@Autowired
|
|
|
|
|
SystemConfigDao systemConfigDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TerminalPhotoDao terminalPhotoDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<SystemConfigModel> getSystemConfig(String id) {
|
|
|
|
|
SystemConfigModel model = new SystemConfigModel();
|
|
|
|
|
public ServiceBody<Integer> getSystemConfig(String cmdId) {
|
|
|
|
|
/* SystemConfigModel model = new SystemConfigModel();
|
|
|
|
|
Integer beatHeartTime = systemConfigDao.getTerminalParams(id);
|
|
|
|
|
model.setHeartBeatTime(beatHeartTime);
|
|
|
|
|
String globalTime = systemConfigDao.getGlobalTime(Constants.GLOBAL_TIME);
|
|
|
|
|
model.setGlobalTime(Integer.parseInt(globalTime));
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=termid --cmdid=DSH10H00000000001 --flag=0";
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
model.setGlobalTime(Integer.parseInt(globalTime));*/
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=sampling --flag=0 --cmdid="+cmdId+ "\t"+"--reqid="+Constants.REQUEST_ID;
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
Constants.REQUEST_ID.addAndGet(1);
|
|
|
|
|
return Asserts.success(Integer.parseInt(Constants.REQUEST_ID.toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -40,7 +54,28 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
|
|
|
|
param.setTermId(vo.getTermId());
|
|
|
|
|
param.setHeartbeatTime(vo.getHeartBeatTime());
|
|
|
|
|
systemConfigDao.updateSystemConfig(param);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=termid --cmdid=DSH10H00000000001 --newcmdid=DSH10H00000000002";
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=sampling --cmdid="+vo.getCmdId()+ "\t"+ "--heartbeat=" + vo.getHeartBeatTime();
|
|
|
|
|
Integer retCode = ProcessExecUtils.exec(cmd);
|
|
|
|
|
if(retCode==0){
|
|
|
|
|
return Asserts.success("修改成功");
|
|
|
|
|
}
|
|
|
|
|
return Asserts.error("修改失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<SystemConfigModel> getSystemConfigDetail(SystemConfigReqVo vo) {
|
|
|
|
|
String result = terminalPhotoDao.getRequestResult(vo.getRequestId());
|
|
|
|
|
SystemConfigModel model = new SystemConfigModel();
|
|
|
|
|
if(StringUtils.isNotBlank(result)) {
|
|
|
|
|
JSONObject resultObj = JSONObject.parseObject(result);
|
|
|
|
|
model = JSONObject.parseObject(resultObj.get("groupData").toString(), SystemConfigModel.class);
|
|
|
|
|
}else{
|
|
|
|
|
Integer beatHeartTime = systemConfigDao.getTerminalParams(Constants.GLOBAL_TIME);
|
|
|
|
|
model.setHeartBeatTime(beatHeartTime);
|
|
|
|
|
String globalTime = systemConfigDao.getGlobalTime(vo.getTermId());
|
|
|
|
|
model.setGlobalTime(Integer.parseInt(globalTime));
|
|
|
|
|
}
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|