新增装置状态判断 修改log日志路径 装置在线判断

master
liuguijing 2 years ago
parent 5e3982efd6
commit e34e1f1474

@ -47,7 +47,7 @@ public class TerminalController extends BaseController {
@Log(title = "获取绘制图标", type = "查询") @Log(title = "获取绘制图标", type = "查询")
public ResponseReult<PhotoMarkModel> getCoordinate(@RequestHeader HttpHeaders headers, @RequestBody @Validated MarkReqVo vo) { public ResponseReult<PhotoMarkModel> getCoordinate(@RequestHeader HttpHeaders headers, @RequestBody @Validated MarkReqVo vo) {
String requestIp = HeaderUtil.getRequestIp(headers); String requestIp = HeaderUtil.getRequestIp(headers);
ServiceBody<PhotoMarkModel> serviceBody = terminalService.getCoordinate(requestIp,vo); ServiceBody<PhotoMarkModel> serviceBody = terminalService.getCoordinate(requestIp, vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) { if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData()); return ResponseReult.success(serviceBody.getData());
} else { } else {
@ -198,4 +198,17 @@ public class TerminalController extends BaseController {
} }
} }
@ApiOperation(value = "获取装置在线状态", notes = "获取装置在线状态", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTermStatus")
@Log(title = "获取装置在线状态", type = "查询")
public ResponseReult<TermStatusModel> getTermStatus(@RequestParam("termId") @Validated Integer termId) {
ServiceBody<TermStatusModel> serviceBody = terminalService.getTermStatus(termId);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
} }

@ -185,7 +185,7 @@ system:
address: http://23.56.100.12 address: http://23.56.100.12
session: session:
expire_time: 3600 expire_time: 3600
open_expire_time: 1800 open_expire_time: 30
heart: heart:
time: 30 time: 30
rsa: rsa:

@ -21,7 +21,7 @@
value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%-5level}[%thread] %style{%logger{36}}{cyan} : %msg%n"/> value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%-5level}[%thread] %style{%logger{36}}{cyan} : %msg%n"/>
<!-- 定义日志存储的路径,不要配置相对路径 --> <!-- 定义日志存储的路径,不要配置相对路径 -->
<property name="FILE_PATH" value="/var/xymp/xymanagerLogs/"/> <property name="FILE_PATH" value="/var/log/xymp/xymanagerLogs/"/>
<property name="FILE_NAME" value="xymanagerlog"/> <property name="FILE_NAME" value="xymanagerlog"/>
</Properties> </Properties>

@ -0,0 +1,19 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 线
*/
@Data
@ApiModel(value = "装置在线状态对象", description = "装置在线状态对象")
public class TermStatusModel implements Serializable {
@ApiModelProperty(value = "是否在线", example = "123456")
private Boolean isonline;
}

@ -95,6 +95,9 @@ public class TerminalListModel implements Serializable {
@ApiModelProperty(value = "最后一次心跳时间", example = "213") @ApiModelProperty(value = "最后一次心跳时间", example = "213")
private BigInteger lastHeartbeat; private BigInteger lastHeartbeat;
@ApiModelProperty(value = "是否在线", example = "213")
private boolean isonline;
@ApiModelProperty(value = "通道编号和名称", example = "213") @ApiModelProperty(value = "通道编号和名称", example = "213")
private List<ChannelBeans> list; private List<ChannelBeans> list;

@ -32,6 +32,9 @@ public class TerminalPhotosModel implements Serializable {
@ApiModelProperty(value = "装置编号", example = "123456") @ApiModelProperty(value = "装置编号", example = "123456")
private Integer termid; private Integer termid;
@ApiModelProperty(value = "cmdid", example = "123456")
private String cmdid;
@ApiModelProperty(value = "装置显示名称", example = "123456") @ApiModelProperty(value = "装置显示名称", example = "123456")
private String displayname; private String displayname;

@ -19,7 +19,7 @@ public class HeaderUtil {
private static String address; private static String address;
@Value("${system.address}") @Value("${system.address}")
public void setHost(String address) { public void setAddress(String address) {
HeaderUtil.address = address; HeaderUtil.address = address;
} }
/** /**

@ -0,0 +1,51 @@
package com.shxy.xymanager_common.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import com.shxy.xymanager_common.entity.TerminalStatus;
import com.shxy.xymanager_common.entity.Terminals;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Map;
/**
*
*
* @author cy
*/
@Slf4j
@Component
public class TerminalUtils {
private static Integer hearttime;
@Value("${heart.time}")
public void setHearttime(Integer time) {
TerminalUtils.hearttime = time;
}
/**
* 线
*
* @param lastHeartbeat
*/
public static boolean judgeTerminalStatus(BigInteger lastHeartbeat) {
long time = MyDateUtils.TimeSecond2MillSecond(lastHeartbeat.longValue());
DateTime date = MyDateUtils.date(time);
long between = MyDateUtils.between(MyDateUtils.getNowDate(), date, DateUnit.MINUTE);
if (between > hearttime) {
return false;
} else {
return true;
}
}
}

@ -14,6 +14,10 @@ public class VoiceCtrlVo {
@ApiModelProperty(value = "监测装置ID", example = "123455") @ApiModelProperty(value = "监测装置ID", example = "123455")
private String cmdId; private String cmdId;
@NotNull(message = "装置编号不能缺少")
@ApiModelProperty(value = "装置id", example = "123455")
private Integer termId;
@NotNull(message = "声光报警开关 0:关闭 1:开启") @NotNull(message = "声光报警开关 0:关闭 1:开启")
@ApiModelProperty(value = "声光报警开关", example = "0:关闭 1:开启") @ApiModelProperty(value = "声光报警开关", example = "0:关闭 1:开启")
private short ctrl; private short ctrl;

@ -4,6 +4,8 @@ import com.shxy.xymanager_common.dto.TerminalsWithHeart;
import com.shxy.xymanager_common.entity.TerminalStatus; import com.shxy.xymanager_common.entity.TerminalStatus;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TerminalStatusDao { public interface TerminalStatusDao {
int deleteByPrimaryKey(Integer termId); int deleteByPrimaryKey(Integer termId);
@ -11,6 +13,8 @@ public interface TerminalStatusDao {
int insertSelective(TerminalStatus record); int insertSelective(TerminalStatus record);
List<TerminalStatus> selectAll();
TerminalStatus selectByPrimaryKey(Integer termId); TerminalStatus selectByPrimaryKey(Integer termId);
TerminalsWithHeart selectByCmdId(@Param("cmdid") String cmdid); TerminalsWithHeart selectByCmdId(@Param("cmdid") String cmdid);

@ -21,7 +21,7 @@
<sql id="selectUserVo"> <sql id="selectUserVo">
SELECT SELECT
user_id, uid,
user_name, user_name,
`status` `status`
FROM FROM
@ -54,8 +54,15 @@
where u.user_id = #{userId} where u.user_id = #{userId}
</select> </select>
<select id="selectBySessionId" resultMap="BaseResultMap"> <select id="selectBySessionId" resultMap="BaseResultMap">
<include refid="selectUserVo"/> select
id ,
session_id,
user_name,
role,
expire_time
FROM
sys_user_session u
where session_id = #{sessionid} where session_id = #{sessionid}
</select> </select>
@ -130,7 +137,7 @@
create_time as createTime, create_time as createTime,
role role
from sys_users from sys_users
WHERE status = #{status} and role != 0 WHERE status = #{status} and role != 0 and role != 3
order by create_time desc order by create_time desc
</select> </select>

@ -44,17 +44,24 @@
<select id="selectByCmdId" resultMap="heartResultMap"> <select id="selectByCmdId" resultMap="heartResultMap">
select select
b.term_id as term_id, b.id as term_id,
b.tower_id as tower_id, b.tower_id as tower_id,
b.cmdid as cmdid, b.cmdid as cmdid,
b.equip_name as equip_name, b.equip_name as equip_name,
b.display_name as display_name, b.display_name as display_name,
b.model as model, b.model as model,
b.last_heartbeat as last_heartbeat a.last_heartbeat as last_heartbeat
from terminal_status a, from terminal_status a,
terminals b terminals b
where a.term_id = b.id and b.cmdid = #{cmdid} where a.term_id = b.id and b.cmdid = #{cmdid}
</select> </select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_status
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from terminal_status delete from terminal_status
where term_id = #{termId,jdbcType=INTEGER} where term_id = #{termId,jdbcType=INTEGER}

@ -27,6 +27,8 @@ public class XyCache {
public static Map<String, String> globalParams = new HashMap<String, String>(); public static Map<String, String> globalParams = new HashMap<String, String>();
public static Map<Integer, TerminalStatus> terminalStatusMap = new HashMap<Integer, TerminalStatus>();
@Autowired @Autowired
private LinesDao linesDao; private LinesDao linesDao;
@Autowired @Autowired
@ -41,6 +43,8 @@ public class XyCache {
private TerminalImgAlarmParamsDao terminalImgAlarmParamsDao; private TerminalImgAlarmParamsDao terminalImgAlarmParamsDao;
@Autowired @Autowired
private GlobalParamsDao globalParamsDao; private GlobalParamsDao globalParamsDao;
@Autowired
private TerminalStatusDao terminalStatusDao;
@PostConstruct @PostConstruct
public void init() { public void init() {
@ -53,6 +57,7 @@ public class XyCache {
termchannelMapMap.clear(); termchannelMapMap.clear();
alarmParamMap.clear(); alarmParamMap.clear();
globalParams.clear(); globalParams.clear();
terminalStatusMap.clear();
List<LineAndDyNameDto> lineAndDyNameDtos = linesDao.selectAll(CommonStatus.EFFECTIVE.value()); List<LineAndDyNameDto> lineAndDyNameDtos = linesDao.selectAll(CommonStatus.EFFECTIVE.value());
for (LineAndDyNameDto lineitem : lineAndDyNameDtos) { for (LineAndDyNameDto lineitem : lineAndDyNameDtos) {
@ -90,6 +95,11 @@ public class XyCache {
globalParams.put(item.getParamName(), item.getParamValue()); globalParams.put(item.getParamName(), item.getParamValue());
} }
List<TerminalStatus> terminalStatuses = terminalStatusDao.selectAll();
for (TerminalStatus item : terminalStatuses) {
terminalStatusMap.put(item.getTermId(), item);
}
} }
@PreDestroy @PreDestroy

@ -53,7 +53,7 @@ public class OpenServiceImpl implements OpenService {
@Value("${session.open_expire_time}") @Value("${session.open_expire_time}")
public BigInteger time; public Integer time;
@Value("${heart.time}") @Value("${heart.time}")
public Integer hearttime; public Integer hearttime;
@ -68,6 +68,7 @@ public class OpenServiceImpl implements OpenService {
public JSONObject cmaUserLogin(UserLoginVo vo) { public JSONObject cmaUserLogin(UserLoginVo vo) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
String username = vo.getUserName(); String username = vo.getUserName();
String userPassword = vo.getPassWord();
SysUser sysUser = sysUserDao.selectByUserName(username); SysUser sysUser = sysUserDao.selectByUserName(username);
// 判断用户是否存在 // 判断用户是否存在
if (BeanUtil.isEmpty(sysUser)) { if (BeanUtil.isEmpty(sysUser)) {
@ -80,7 +81,6 @@ public class OpenServiceImpl implements OpenService {
jsonObject.putOpt("errcode", 2); jsonObject.putOpt("errcode", 2);
jsonObject.putOpt("errmsg", "密码错误"); jsonObject.putOpt("errmsg", "密码错误");
} }
String userPassword = SecureUtil.md5(password);
// 密码对比 // 密码对比
if (!sysUser.getPassword().equals(userPassword)) { if (!sysUser.getPassword().equals(userPassword)) {
jsonObject.putOpt("errcode", 2); jsonObject.putOpt("errcode", 2);
@ -93,13 +93,13 @@ public class OpenServiceImpl implements OpenService {
sysUserSession.setUserName(username); sysUserSession.setUserName(username);
sysUserSession.setRole(sysUser.getRole()); sysUserSession.setRole(sysUser.getRole());
sysUserSession.setSessionId(sessionId); sysUserSession.setSessionId(sessionId);
long expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, 30)); long expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, time));
sysUserSession.setExpireTime(BigInteger.valueOf(expiretime)); sysUserSession.setExpireTime(BigInteger.valueOf(expiretime));
sysUserMapperDao.insertOrUpdate(sysUserSession, date, date); sysUserMapperDao.insertOrUpdate(sysUserSession, date, date);
jsonObject.set("errcode", 0); jsonObject.set("errcode", 0);
jsonObject.set("errmsg", "OK"); jsonObject.set("errmsg", "OK");
jsonObject.set("sessionid", sessionId); jsonObject.set("sessionid", sessionId);
jsonObject.set("keepingtime", 30); jsonObject.set("keepingtime", time);
return jsonObject; return jsonObject;
} }

@ -7,9 +7,11 @@ import com.shxy.xymanager_common.entity.Resolution;
import com.shxy.xymanager_common.exception.Asserts; import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.ResolutionModel; import com.shxy.xymanager_common.model.ResolutionModel;
import com.shxy.xymanager_common.util.ProcessExecUtils; import com.shxy.xymanager_common.util.ProcessExecUtils;
import com.shxy.xymanager_common.util.TerminalUtils;
import com.shxy.xymanager_common.vo.TerminalIdVo; import com.shxy.xymanager_common.vo.TerminalIdVo;
import com.shxy.xymanager_common.vo.VoiceCtrlVo; import com.shxy.xymanager_common.vo.VoiceCtrlVo;
import com.shxy.xymanager_dao.dao.TerminalResolutionDao; import com.shxy.xymanager_dao.dao.TerminalResolutionDao;
import com.shxy.xymanager_service.cache.XyCache;
import com.shxy.xymanager_service.service.TermSetService; import com.shxy.xymanager_service.service.TermSetService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -32,7 +34,6 @@ public class TermSetServiceImpl implements TermSetService {
@Override @Override
public ServiceBody<String> alarmMark(VoiceCtrlVo vo) { public ServiceBody<String> alarmMark(VoiceCtrlVo vo) {
String cmd =Constants.CMD+"voice --cmdid="+vo.getCmdId()+ " --ctrl="+ vo.getCtrl(); String cmd =Constants.CMD+"voice --cmdid="+vo.getCmdId()+ " --ctrl="+ vo.getCtrl();
ProcessExecUtils.exec(cmd); ProcessExecUtils.exec(cmd);
return Asserts.success("设置成功"); return Asserts.success("设置成功");

@ -17,9 +17,11 @@ import com.shxy.xymanager_common.model.TerminalAllChannelListModel;
import com.shxy.xymanager_common.model.TerminalChannelListModel; import com.shxy.xymanager_common.model.TerminalChannelListModel;
import com.shxy.xymanager_common.model.TerminalChannelMapperListModel; import com.shxy.xymanager_common.model.TerminalChannelMapperListModel;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
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.TerminalChannelsDao; import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
import com.shxy.xymanager_dao.dao.TerminalStatusDao; import com.shxy.xymanager_dao.dao.TerminalStatusDao;
import com.shxy.xymanager_service.cache.XyCache;
import com.shxy.xymanager_service.service.TerminalChannelService; import com.shxy.xymanager_service.service.TerminalChannelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -166,8 +168,13 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
*/ */
@Override @Override
public ServiceBody<TerminalChannelMapperListModel> getChannelByTermid(TerminalIdVo vo) { public ServiceBody<TerminalChannelMapperListModel> getChannelByTermid(TerminalIdVo vo) {
Integer termId = vo.getTermid();
// boolean b = TerminalUtils.judgeTerminalStatus(XyCache.terminalStatusMap, termId);
// if (!b) {
// Asserts.fail(100, "装置下线");
// }
TerminalChannelMapperListModel model = new TerminalChannelMapperListModel(); TerminalChannelMapperListModel model = new TerminalChannelMapperListModel();
List<TermChannelAndMapperDto> list = terminalChannelsDao.selectByTermid(vo.getTermid(), CommonStatus.EFFECTIVE.value()); List<TermChannelAndMapperDto> list = terminalChannelsDao.selectByTermid(termId, CommonStatus.EFFECTIVE.value());
log.info("通道查出数据:{}", JSON.toJSONString(list)); log.info("通道查出数据:{}", JSON.toJSONString(list));
boolean empty = CollectionUtil.isEmpty(list); boolean empty = CollectionUtil.isEmpty(list);
if (empty) { if (empty) {
@ -176,7 +183,7 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
List<TerminalChannelMapperListModel.ChannelBean> channelBeans = BeanUtil.copyToList(list, TerminalChannelMapperListModel.ChannelBean.class, CopyOptions.create().ignoreCase()); List<TerminalChannelMapperListModel.ChannelBean> channelBeans = BeanUtil.copyToList(list, TerminalChannelMapperListModel.ChannelBean.class, CopyOptions.create().ignoreCase());
model.setList(channelBeans); model.setList(channelBeans);
} }
TerminalStatus terminalStatus = terminalStatusDao.selectByPrimaryKey(vo.getTermid()); TerminalStatus terminalStatus = terminalStatusDao.selectByPrimaryKey(termId);
if (!BeanUtil.isEmpty(terminalStatus)) { if (!BeanUtil.isEmpty(terminalStatus)) {
model.setGpsstatus(terminalStatus.getGpsStatus()); model.setGpsstatus(terminalStatus.getGpsStatus());
} }

@ -96,8 +96,6 @@ public class TerminalGpsServiceImpl implements TerminalGpsService {
TerminalPositions bean = terminalPositionsDao.selectByPrimaryKey(vo.getTermid()); TerminalPositions bean = terminalPositionsDao.selectByPrimaryKey(vo.getTermid());
Boolean hasNew = false; Boolean hasNew = false;
if (!BeanUtil.isEmpty(bean)) { if (!BeanUtil.isEmpty(bean)) {
model.setRadius(bean.getRadius()); model.setRadius(bean.getRadius());
model.setLongitude(bean.getLongitude()); model.setLongitude(bean.getLongitude());
model.setLatitude(bean.getLatitude()); model.setLatitude(bean.getLatitude());

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -18,10 +19,7 @@ import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts; import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.*; import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.CmaUtil; import com.shxy.xymanager_common.util.*;
import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.ProcessExecUtils;
import com.shxy.xymanager_common.util.StringUtils;
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.cache.XyCache;
@ -73,6 +71,8 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Value("${video.address}") @Value("${video.address}")
private String videoaddress; private String videoaddress;
@Value("${heart.time}")
public Integer hearttime;
/** /**
* idid * idid
@ -354,8 +354,8 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Override @Override
public ServiceBody<Date> getLatestPhoto(TerminalPhotoVo vo) { public ServiceBody<Date> getLatestPhoto(TerminalPhotoVo vo) {
DateTime now = DateTime.now();
Integer termId = vo.getTermId(); Integer termId = vo.getTermId();
DateTime now = DateTime.now();
Map<Integer, Terminals> terminalMap = XyCache.terminalMap; Map<Integer, Terminals> terminalMap = XyCache.terminalMap;
Terminals terminals = terminalMap.get(termId); Terminals terminals = terminalMap.get(termId);
String cmdid = null; String cmdid = null;
@ -367,8 +367,10 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
ProcessExecUtils.exec(cmd); ProcessExecUtils.exec(cmd);
} }
return Asserts.success(now); return Asserts.success(now);
} }
@Override @Override
public ServiceBody<Boolean> getReturnedPhoto(ReturnedPhotoVo vo) { public ServiceBody<Boolean> getReturnedPhoto(ReturnedPhotoVo vo) {
Boolean hasNew = false; Boolean hasNew = false;
@ -518,8 +520,8 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
lineid = terminals.getLineid(); lineid = terminals.getLineid();
photosBean.setLineid(lineid); photosBean.setLineid(lineid);
photosBean.setDisplayname(terminals.getDisplayName()); photosBean.setDisplayname(terminals.getDisplayName());
photosBean.setCmdid(terminals.getCmdid());
} }
photosBean.setChannelid(channelid); photosBean.setChannelid(channelid);
photosBean.setChannnelname(termchannelMap.get(channelid).getChannelName()); photosBean.setChannnelname(termchannelMap.get(channelid).getChannelName());

@ -14,6 +14,7 @@ import com.shxy.xymanager_common.dto.PhotoMarkDto;
import com.shxy.xymanager_common.dto.TerminalInfoDto; import com.shxy.xymanager_common.dto.TerminalInfoDto;
import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto; import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto;
import com.shxy.xymanager_common.entity.TerminalChannelMapper; 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.entity.Terminals;
import com.shxy.xymanager_common.enums.CommonStatus; import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.enums.GloableParamsType; import com.shxy.xymanager_common.enums.GloableParamsType;
@ -23,6 +24,7 @@ import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.MyDateUtils; import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.ProcessExecUtils; import com.shxy.xymanager_common.util.ProcessExecUtils;
import com.shxy.xymanager_common.util.StringUtils; import com.shxy.xymanager_common.util.StringUtils;
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.cache.XyCache;
@ -63,9 +65,15 @@ public class TerminalServiceImpl implements TerminalService {
@Autowired @Autowired
DyLevelDao dyLevelDao; DyLevelDao dyLevelDao;
@Autowired
TerminalStatusDao terminalStatusDao;
@Value("${photo.address}") @Value("${photo.address}")
private String photoaddress; private String photoaddress;
@Value("${heart.time}")
public Integer hearttime;
/** /**
* *
@ -90,6 +98,10 @@ public class TerminalServiceImpl implements TerminalService {
model.setList(new ArrayList<>()); model.setList(new ArrayList<>());
} else { } else {
List<TerminalListModel.TerminalsBean> beans = BeanUtil.copyToList(list2, TerminalListModel.TerminalsBean.class, CopyOptions.create().ignoreCase()); List<TerminalListModel.TerminalsBean> beans = BeanUtil.copyToList(list2, TerminalListModel.TerminalsBean.class, CopyOptions.create().ignoreCase());
for (TerminalListModel.TerminalsBean item : beans) {
boolean b = TerminalUtils.judgeTerminalStatus(item.getLastHeartbeat());
item.setIsonline(b);
}
model.setList(beans); model.setList(beans);
} }
} else { } else {
@ -305,7 +317,7 @@ public class TerminalServiceImpl implements TerminalService {
long time = MyDateUtils.TimeSecond2MillSecond(lastheartbeat); long time = MyDateUtils.TimeSecond2MillSecond(lastheartbeat);
DateTime date = MyDateUtils.date(time); DateTime date = MyDateUtils.date(time);
long between = MyDateUtils.between(MyDateUtils.getNowDate(), date, DateUnit.MINUTE); long between = MyDateUtils.between(MyDateUtils.getNowDate(), date, DateUnit.MINUTE);
if (between > 30) { if (between > hearttime) {
terminalsWithHeart.setOnlinestatus(CommonStatus.DELETE.value()); terminalsWithHeart.setOnlinestatus(CommonStatus.DELETE.value());
} else { } else {
terminalsWithHeart.setOnlinestatus(CommonStatus.EFFECTIVE.value()); terminalsWithHeart.setOnlinestatus(CommonStatus.EFFECTIVE.value());
@ -358,12 +370,10 @@ public class TerminalServiceImpl implements TerminalService {
terminalPhotoDao.updatePhotoMark(vo); terminalPhotoDao.updatePhotoMark(vo);
} else { } else {
terminalPhotoDao.addPhotoMark(vo); terminalPhotoDao.addPhotoMark(vo);
} }
if (CollectionUtil.isNotEmpty(vo.getList())) { if (CollectionUtil.isNotEmpty(vo.getList())) {
terminalPhotoDao.addPhotoMarkPath(vo.getList(), vo.getId()); terminalPhotoDao.addPhotoMarkPath(vo.getList(), vo.getId());
} }
return Asserts.success("保存成功"); return Asserts.success("保存成功");
} }
@ -394,5 +404,25 @@ public class TerminalServiceImpl implements TerminalService {
} }
return Asserts.success(model); return Asserts.success(model);
} }
/**
* 线
*
* @param termId
* @return
*/
@Override
public ServiceBody<TermStatusModel> getTermStatus(Integer termId) {
TermStatusModel model = new TermStatusModel();
TerminalStatus terminalStatus = terminalStatusDao.selectByPrimaryKey(termId);
if (terminalStatus != null) {
BigInteger lastHeartbeat = terminalStatus.getLastHeartbeat();
boolean b = TerminalUtils.judgeTerminalStatus(lastHeartbeat);
model.setIsonline(b);
} else {
model.setIsonline(false);
}
return Asserts.success(model);
}
} }

@ -90,4 +90,10 @@ public interface TerminalService {
ServiceBody<PhotoMarkModel> getCoordinate(String requestIp, MarkReqVo vo); ServiceBody<PhotoMarkModel> getCoordinate(String requestIp, MarkReqVo vo);
/**
* 线
* @param termId
* @return
*/
ServiceBody<TermStatusModel> getTermStatus(Integer termId);
} }

Loading…
Cancel
Save