缓存优化和查询优化

master
liuguijing 2 years ago
parent fb21540494
commit e1add5849e

@ -123,7 +123,7 @@ public class TerminalController extends BaseController {
@ApiOperation(value = "获取装置触发", notes = "获取装置信息接口", httpMethod = "POST") @ApiOperation(value = "获取装置触发", notes = "获取装置信息接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTerminalStatus") @RequestMapping("/getTerminalStatus")
@Log(title = "获取装置触发", type = "修改") @Log(title = "获取装置触发", type = "查询")
public ResponseReult<TerminalStatusModel> getTerminalStatus(@RequestParam("termId") Integer termId) { public ResponseReult<TerminalStatusModel> getTerminalStatus(@RequestParam("termId") Integer termId) {
ServiceBody<TerminalStatusModel> serviceBody = terminalService.getTerminalStatus(termId); ServiceBody<TerminalStatusModel> serviceBody = terminalService.getTerminalStatus(termId);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) { if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
@ -137,8 +137,8 @@ public class TerminalController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getLastedTerminalStatus") @RequestMapping("/getLastedTerminalStatus")
@Log(title = "获取最新装置运行状态", type = "修改") @Log(title = "获取最新装置运行状态", type = "修改")
public ResponseReult<TerminalModel> getLastedTerminalStatus(@RequestBody @Validated TerminalStatusVo vo) { public ResponseReult<TerminalStatusInfoModel> getLastedTerminalStatus(@RequestBody @Validated TerminalStatusVo vo) {
ServiceBody<TerminalModel> serviceBody = terminalService.getLastedTerminalStatus(vo); ServiceBody<TerminalStatusInfoModel> serviceBody = terminalService.getLastedTerminalStatus(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) { if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData()); return ResponseReult.success(serviceBody.getData());
} else { } else {
@ -211,5 +211,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("/getLastTermInfo")
@Log(title = "获取装置数据库信息", type = "查询")
public ResponseReult<TerminalStatusInfoModel> getLastTermInfo(@RequestParam("termId") @Validated Integer termId) {
ServiceBody<TerminalStatusInfoModel> serviceBody = terminalService.getLastTermInfo(termId);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
} }

@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -70,4 +71,17 @@ public class TerminalGPSController extends BaseController {
} }
} }
@ApiOperation(value = "获取数据库GPS位置数据", notes = "获取数据库GPS位置数据", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTermLastGPSPosition")
@Log(title = "获取数据库GPS位置数据", type = "查询")
public ResponseReult<TerminalGpsModel> getTermLastGPSPosition(@RequestParam("termId") @Validated Integer termId) {
ServiceBody<TerminalGpsModel> serviceBody = terminalGpsService.getTermLastGPSPosition(termId);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
} }

@ -12,7 +12,11 @@ public class TerminalStatus implements Serializable {
private BigInteger lastHeartbeat; private BigInteger lastHeartbeat;
private Short lastFrameNo; private String lastHeartbeatIp;
private Integer lastHeartbeatPort;
private Integer lastFrameNo;
private Float batteryVoltage; private Float batteryVoltage;
@ -30,6 +34,10 @@ public class TerminalStatus implements Serializable {
private Integer connectionState; private Integer connectionState;
private BigInteger sendFlow;
private BigInteger recvFlow;
private Integer signalStrength4g; private Integer signalStrength4g;
private Integer signalStrength2g; private Integer signalStrength2g;
@ -38,6 +46,8 @@ public class TerminalStatus implements Serializable {
private Integer remainingRom; private Integer remainingRom;
private BigInteger wsUpdateTime;
private BigInteger bootTime; private BigInteger bootTime;
private BigInteger updateTime; private BigInteger updateTime;

@ -1,36 +1,33 @@
package com.shxy.xymanager_common.model; package com.shxy.xymanager_common.model;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Date;
import java.util.List;
/** /**
* *
*/ */
@Data @Data
@ApiModel(value = "获取设备状态信息", description = "获取设备状态信息") @ApiModel(value = "设备状态信息", description = "设备状态信息")
public class TerminalModel implements Serializable { public class TerminalStatusInfoModel implements Serializable {
@ApiModelProperty(value = "装置编号", example = "123456") @ApiModelProperty(value = "装置编号", example = "123456")
private Integer termId; private Integer termId;
@ApiModelProperty(value = "电池电量", example = "123456") @ApiModelProperty(value = "电池电量", example = "123456")
private Integer batteryCapacity; private Float batteryCapacity;
@ApiModelProperty(value = "电池电压", example = "123456") @ApiModelProperty(value = "电池电压", example = "123456")
private Integer batteryVoltage; private Float batteryVoltage;
@ApiModelProperty(value = "本次连续工作时间(小时)", example = "12345678") @ApiModelProperty(value = "本次连续工作时间(小时)", example = "12345678")
private Integer workingTime; private Integer workingTime;
@ApiModelProperty(value = "浮充状态:充电 放电", example = "12345678") @ApiModelProperty(value = "浮充状态:充电 放电", example = "12345678")
private Integer floatingCharge; private Byte floatingCharge;
@ApiModelProperty(value = "工作总时间(小时)", example = "名称名称") @ApiModelProperty(value = "工作总时间(小时)", example = "名称名称")
private Integer totalWorkingTime; private Integer totalWorkingTime;

@ -1,6 +1,5 @@
package com.shxy.xymanager_common.vo; package com.shxy.xymanager_common.vo;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -12,7 +11,7 @@ import javax.validation.constraints.NotNull;
public class ReturnedPhotoParamsGetVo { public class ReturnedPhotoParamsGetVo {
@NotNull(message = "不能传入空值") @NotNull(message = "不能传入空值")
@ApiModelProperty(value = "监测装置id", required = true, example = "A0001") @ApiModelProperty(value = "监测装置id", required = true, example = "A0001")
private String cmdId; private Integer termId;
@ApiModelProperty(value = "通道ID", required = true, example = "A0001") @ApiModelProperty(value = "通道ID", required = true, example = "A0001")

@ -18,11 +18,11 @@ public class TerminalChannelVo {
@Data @Data
public static class ChannelItem { public static class ChannelItem {
@NotNull(message = "通道编号") @NotNull(message = "通道编号")
@ApiModelProperty(value = "装置编号", example = "123455") @ApiModelProperty(value = "通道编号", example = "123455")
private Integer id; private Integer id;
@NotNull(message = "通道编号不能缺少") @NotNull(message = "通道名称不能缺少")
@ApiModelProperty(value = "通道编号", example = "123455") @ApiModelProperty(value = "通道名称", example = "123455")
private String channelname; private String channelname;
@ApiModelProperty(value = "分辨率W", example = "123456") @ApiModelProperty(value = "分辨率W", example = "123456")

@ -1,6 +1,5 @@
package com.shxy.xymanager_common.vo; package com.shxy.xymanager_common.vo;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;

@ -6,6 +6,4 @@ import java.math.BigInteger;
public interface TerminalPositionsDao { public interface TerminalPositionsDao {
TerminalPositions selectByPrimaryKey(Integer termId); TerminalPositions selectByPrimaryKey(Integer termId);
BigInteger getUpdateTime(Integer termId);
} }

@ -1,5 +1,6 @@
package com.shxy.xymanager_dao.dao; package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.dto.TerminalInfoDto;
import com.shxy.xymanager_common.dto.TerminalsWithHeart; 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;

@ -42,8 +42,6 @@ public interface TerminalsDao {
String getCmdIdByTermId(Integer termId); String getCmdIdByTermId(Integer termId);
TerminalInfoDto getTerminalInfo(@Param("termId") Integer termId);
BigInteger getUpdateTime(@Param("termId") Integer termId); BigInteger getUpdateTime(@Param("termId") Integer termId);
int updateCmd(TerminalIdUpdateVo vo); int updateCmd(TerminalIdUpdateVo vo);

@ -19,10 +19,4 @@
where term_id = #{termId,jdbcType=INTEGER} where term_id = #{termId,jdbcType=INTEGER}
</select> </select>
<select id="getUpdateTime" resultType="java.math.BigInteger">
select
update_time updateTime
from terminal_positions
where term_id = #{termId,jdbcType=INTEGER}
</select>
</mapper> </mapper>

@ -4,6 +4,8 @@
<resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalStatus"> <resultMap id="BaseResultMap" type="com.shxy.xymanager_common.entity.TerminalStatus">
<id column="term_id" jdbcType="INTEGER" property="termId"/> <id column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="last_heartbeat" jdbcType="BIGINT" property="lastHeartbeat"/> <result column="last_heartbeat" jdbcType="BIGINT" property="lastHeartbeat"/>
<result column="last_heartbeat_ip" jdbcType="VARCHAR" property="lastHeartbeatIp"/>
<result column="last_heartbeat_port" jdbcType="SMALLINT" property="lastHeartbeatPort"/>
<result column="last_frame_no" jdbcType="SMALLINT" property="lastFrameNo"/> <result column="last_frame_no" jdbcType="SMALLINT" property="lastFrameNo"/>
<result column="battery_voltage" jdbcType="REAL" property="batteryVoltage"/> <result column="battery_voltage" jdbcType="REAL" property="batteryVoltage"/>
<result column="op_temperature" jdbcType="REAL" property="opTemperature"/> <result column="op_temperature" jdbcType="REAL" property="opTemperature"/>
@ -11,14 +13,17 @@
<result column="floating_charge" jdbcType="TINYINT" property="floatingCharge"/> <result column="floating_charge" jdbcType="TINYINT" property="floatingCharge"/>
<result column="total_working_time" jdbcType="INTEGER" property="totalWorkingTime"/> <result column="total_working_time" jdbcType="INTEGER" property="totalWorkingTime"/>
<result column="working_time" jdbcType="INTEGER" property="workingTime"/> <result column="working_time" jdbcType="INTEGER" property="workingTime"/>
<result column="gps_status" jdbcType="INTEGER" property="gpsStatus"/>
<result column="connection_state" jdbcType="TINYINT" property="connectionState"/> <result column="connection_state" jdbcType="TINYINT" property="connectionState"/>
<result column="signal_strength_4g" jdbcType="TINYINT" property="signalStrength4g"/> <result column="signal_strength_4g" jdbcType="TINYINT" property="signalStrength4g"/>
<result column="signal_strength_2g" jdbcType="TINYINT" property="signalStrength2g"/> <result column="signal_strength_2g" jdbcType="TINYINT" property="signalStrength2g"/>
<result column="send_flow" jdbcType="BIGINT" property="sendFlow"/>
<result column="recv_flow" jdbcType="BIGINT" property="recvFlow"/>
<result column="ws_update_time" jdbcType="BIGINT" property="wsUpdateTime"/>
<result column="remaining_ram" jdbcType="TINYINT" property="remainingRam"/> <result column="remaining_ram" jdbcType="TINYINT" property="remainingRam"/>
<result column="remaining_rom" jdbcType="TINYINT" property="remainingRom"/> <result column="remaining_rom" jdbcType="TINYINT" property="remainingRom"/>
<result column="boot_time" jdbcType="BIGINT" property="bootTime"/> <result column="boot_time" jdbcType="BIGINT" property="bootTime"/>
<result column="rs_update_time" jdbcType="BIGINT" property="updateTime"/> <result column="rs_update_time" jdbcType="BIGINT" property="updateTime"/>
<result column="gps_status" jdbcType="INTEGER" property="gpsStatus"/>
</resultMap> </resultMap>
<resultMap id="heartResultMap" type="com.shxy.xymanager_common.dto.TerminalsWithHeart"> <resultMap id="heartResultMap" type="com.shxy.xymanager_common.dto.TerminalsWithHeart">
@ -31,9 +36,9 @@
<result column="last_heartbeat" jdbcType="BIGINT" property="lastheartbeat"/> <result column="last_heartbeat" jdbcType="BIGINT" property="lastheartbeat"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
term_id, last_heartbeat, last_frame_no, battery_voltage, op_temperature, battery_capacity, term_id, last_heartbeat,last_heartbeat_ip,last_heartbeat_port, last_frame_no, battery_voltage, op_temperature, battery_capacity,
floating_charge, total_working_time, working_time, gps_status,connection_state, signal_strength_4g, floating_charge, total_working_time, working_time,connection_state, signal_strength_4g,
signal_strength_2g, remaining_ram, remaining_rom, boot_time, rs_update_time signal_strength_2g,send_flow, recv_flow,ws_update_time,remaining_ram, remaining_rom, boot_time, rs_update_time, gps_status
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
@ -62,6 +67,14 @@
from terminal_status from terminal_status
</select> </select>
<select id="selectTerminalInfo" resultType="com.shxy.xymanager_common.dto.TerminalInfoDto">
select
ts.term_id termId, ts.battery_voltage batteryVoltage, ts.battery_capacity batteryCapacity, ts.floating_charge floatingCharge, ts.total_working_time totalWorkingTime,
ts.working_time workingTime, ts.connection_state connectionState, ts.ws_update_time wsUpdateTime,t.cmdid cmId
from terminal_status ts left join terminals t on ts.term_id = t.id
where ts.term_id = #{termId,jdbcType=INTEGER}
</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}

@ -165,7 +165,7 @@
</if> </if>
</where> </where>
order by a.create_time desc order by d.create_time desc
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@ -489,14 +489,6 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="getTerminalInfo" resultType="com.shxy.xymanager_common.dto.TerminalInfoDto">
select
ts.term_id termId, ts.battery_voltage batteryVoltage, ts.battery_capacity batteryCapacity, ts.floating_charge floatingCharge, ts.total_working_time totalWorkingTime,
ts.working_time workingTime, ts.connection_state connectionState, ts.ws_update_time wsUpdateTime,t.cmdid cmId
from terminal_status ts left join terminals t on ts.term_id = t.id
where ts.term_id = #{termId,jdbcType=INTEGER}
</select>
<select id="getCmdIdByTermId" resultType="java.lang.String"> <select id="getCmdIdByTermId" resultType="java.lang.String">
select select
cmdid cmdid

@ -18,6 +18,7 @@ import com.shxy.xymanager_common.model.LineListModel;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
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.service.CacheService;
import com.shxy.xymanager_service.service.LineService; import com.shxy.xymanager_service.service.LineService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -42,13 +43,18 @@ public class LineServiceImpl implements LineService {
@Autowired @Autowired
private DyLevelDao dyLevelDao; private DyLevelDao dyLevelDao;
@Autowired @Autowired
private TowerDao towerDao; private TowerDao towerDao;
@Autowired @Autowired
private TerminalsDao terminalsDao; private TerminalsDao terminalsDao;
@Autowired @Autowired
private TerminalChannelsDao terminalChannelsDao; private TerminalChannelsDao terminalChannelsDao;
@Autowired
private CacheService cacheService;
/** /**
* 线 * 线
@ -96,6 +102,7 @@ public class LineServiceImpl implements LineService {
Date date = new Date(); Date date = new Date();
int i = linesDao.insertList(lines, CommonStatus.EFFECTIVE.value(), date, date); int i = linesDao.insertList(lines, CommonStatus.EFFECTIVE.value(), date, date);
if (i != 0) { if (i != 0) {
cacheService.updateLineMap();
return Asserts.success("录入成功"); return Asserts.success("录入成功");
} else { } else {
return Asserts.error("录入失败"); return Asserts.error("录入失败");
@ -114,6 +121,7 @@ public class LineServiceImpl implements LineService {
Date date = new Date(); Date date = new Date();
int i = linesDao.deleteById(lines, CommonStatus.DELETE.value(), date); int i = linesDao.deleteById(lines, CommonStatus.DELETE.value(), date);
if (i != 0) { if (i != 0) {
cacheService.updateLineMap();
return Asserts.success("删除成功"); return Asserts.success("删除成功");
} else { } else {
return Asserts.error("删除失败"); return Asserts.error("删除失败");
@ -133,6 +141,7 @@ public class LineServiceImpl implements LineService {
BeanUtil.copyProperties(vo, lines, true); BeanUtil.copyProperties(vo, lines, true);
int i = linesDao.updateByPrimaryKeySelective(lines, new Date()); int i = linesDao.updateByPrimaryKeySelective(lines, new Date());
if (i != 0) { if (i != 0) {
cacheService.updateLineMap();
return Asserts.success("修改成功"); return Asserts.success("修改成功");
} else { } else {
return Asserts.error("修改失败"); return Asserts.error("修改失败");

@ -66,8 +66,6 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
return Asserts.error("通道重复"); return Asserts.error("通道重复");
} }
int i = terminalChannelsDao.insertList(list, CommonStatus.EFFECTIVE.value(), date, date); int i = terminalChannelsDao.insertList(list, CommonStatus.EFFECTIVE.value(), date, date);
if (i != 0) { if (i != 0) {
return Asserts.success("录入成功"); return Asserts.success("录入成功");
} else { } else {
@ -83,10 +81,10 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
*/ */
@Override @Override
public ServiceBody<String> updateChannelList(UpdateTerminalChannelVo vo) { public ServiceBody<String> updateChannelList(UpdateTerminalChannelVo vo) {
int count = terminalChannelsDao.selectChannelCountById(vo); // int count = terminalChannelsDao.selectChannelCountById(vo);
if(count>0){ // if(count>0){
return Asserts.success("通道重复"); // return Asserts.success("通道重复");
} // }
TerminalChannels bean = new TerminalChannels(); TerminalChannels bean = new TerminalChannels();
BeanUtil.copyProperties(vo, bean, CopyOptions.create().ignoreCase()); BeanUtil.copyProperties(vo, bean, CopyOptions.create().ignoreCase());
int i = terminalChannelsDao.updateByPrimaryKeySelective(bean, new Date()); int i = terminalChannelsDao.updateByPrimaryKeySelective(bean, new Date());

@ -47,16 +47,12 @@ import java.util.List;
@Service @Service
public class TerminalGpsServiceImpl implements TerminalGpsService { public class TerminalGpsServiceImpl implements TerminalGpsService {
@Autowired
private TerminalStatusDao terminalStatusDao;
@Autowired @Autowired
private TerminalPositionsDao terminalPositionsDao; private TerminalPositionsDao terminalPositionsDao;
@Autowired @Autowired
TerminalPhotoDao terminalPhotoDao; TerminalPhotoDao terminalPhotoDao;
// @Autowired
// private Cma cma;
/** /**
@ -123,5 +119,28 @@ public class TerminalGpsServiceImpl implements TerminalGpsService {
return Asserts.success(now); return Asserts.success(now);
} }
@Override
public ServiceBody<TerminalGpsModel> getTermLastGPSPosition(Integer termid) {
TerminalGpsModel model = new TerminalGpsModel();
TerminalPositions bean = terminalPositionsDao.selectByPrimaryKey(termid);
if (BeanUtil.isEmpty(bean)) {
model.setTermid(termid);
model.setLatitude(0);
model.setLongitude(0);
model.setRadius(0);
model.setUpdatetime(new Date());
} else {
model.setTermid(termid);
model.setLatitude(bean.getLatitude());
model.setLongitude(bean.getLongitude());
model.setRadius(bean.getRadius());
Long updateTime = bean.getUpdateTime();
long l = MyDateUtils.TimeSecond2MillSecond(updateTime);
model.setUpdatetime(MyDateUtils.date(l));
}
return Asserts.success(model);
}
} }

@ -578,9 +578,12 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Override @Override
public ServiceBody<GetModel> getPhotoQueryParam(ReturnedPhotoParamsGetVo vo) { public ServiceBody<GetModel> getPhotoQueryParam(ReturnedPhotoParamsGetVo vo) {
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
Terminals terminals = terminalMap.get(vo.getTermId());
String cmdid = terminals.getCmdid();
GetModel model = new GetModel(); GetModel model = new GetModel();
int requestId = Constants.REQUEST_ID.addAndGet(1); int requestId = Constants.REQUEST_ID.addAndGet(1);
String cmd = Constants.CMD + "imgparams --cmdid=" + vo.getCmdId() + " --clientid=10 --reqid=" + requestId + " --flag=0 --rf=7 --channel=" + vo.getChannelId(); String cmd = Constants.CMD + "imgparams --cmdid=" + cmdid + " --clientid=10 --reqid=" + requestId + " --flag=0 --rf=7 --channel=" + vo.getChannelId();
ProcessExecUtils.exec(cmd); ProcessExecUtils.exec(cmd);
model.setRequestId(requestId); model.setRequestId(requestId);
/* /*

@ -24,16 +24,16 @@ import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.util.TerminalUtils; 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.service.CacheService; import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TerminalService; import com.shxy.xymanager_service.service.TerminalService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.date.DateUnit;
import javax.validation.constraints.NotNull;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -146,7 +146,7 @@ public class TerminalServiceImpl implements TerminalService {
for (TermChannelAndMapperDto dto : channellist) { for (TermChannelAndMapperDto dto : channellist) {
TerminalListModel.ChannelBeans e = new TerminalListModel.ChannelBeans(); TerminalListModel.ChannelBeans e = new TerminalListModel.ChannelBeans();
e.setAlias(dto.getAlias()); e.setAlias(dto.getAlias());
e.setId(dto.getId()); e.setId(dto.getChannelid());
e.setName(dto.getChannelname()); e.setName(dto.getChannelname());
list.add(e); list.add(e);
} }
@ -201,7 +201,11 @@ public class TerminalServiceImpl implements TerminalService {
} }
Date date = new Date(); Date date = new Date();
int i1 = terminalChannelMapperDao.insertList(list, date, date); int i1 = terminalChannelMapperDao.insertList(list, date, date);
} }
cacheService.updateTerminalMap();
cacheService.updateTermAndChannelMap();
cacheService.updateTermChannelMapMap();
if (i != 0) { if (i != 0) {
return Asserts.success("录入成功"); return Asserts.success("录入成功");
} else { } else {
@ -235,6 +239,9 @@ public class TerminalServiceImpl implements TerminalService {
Date date = new Date(); Date date = new Date();
terminalChannelMapperDao.insertList(list, date, date); terminalChannelMapperDao.insertList(list, date, date);
} }
cacheService.updateTerminalMap();
cacheService.updateTermAndChannelMap();
cacheService.updateTermChannelMapMap();
if (i != 0) { if (i != 0) {
return Asserts.success("修改成功"); return Asserts.success("修改成功");
} else { } else {
@ -258,6 +265,7 @@ public class TerminalServiceImpl implements TerminalService {
list.add(terminals); list.add(terminals);
} }
int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date()); int i = terminalsDao.deleteById(list, CommonStatus.DELETE.value(), new Date());
cacheService.updateTerminalMap();
if (i != 0) { if (i != 0) {
return Asserts.success("删除成功"); return Asserts.success("删除成功");
} else { } else {
@ -307,29 +315,31 @@ public class TerminalServiceImpl implements TerminalService {
} }
@Override @Override
public ServiceBody<TerminalModel> getLastedTerminalStatus(TerminalStatusVo vo) { public ServiceBody<TerminalStatusInfoModel> getLastedTerminalStatus(TerminalStatusVo vo) {
/* String result = terminalPhotoDao.getRequestResult(5);//待修改 TerminalStatusInfoModel model = new TerminalStatusInfoModel();
TerminalModel model = new TerminalModel(); Integer termId = vo.getTermId();
if (StringUtils.isNotBlank(result)) { TerminalStatus bean = terminalStatusDao.selectByPrimaryKey(termId);
model = JSONObject.parseObject(result, TerminalModel.class);
model.setIsNew(true);
} else {*/
TerminalModel model = new TerminalModel();
TerminalInfoDto dto = terminalsDao.getTerminalInfo(vo.getTermId());
Boolean hasNew = false; Boolean hasNew = false;
if (null != dto) { if (BeanUtil.isNotEmpty(bean)) {
BeanUtils.copyProperties(dto, model); Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
BigInteger wsUpdateTime = dto.getWsUpdateTime(); Terminals terminals = terminalMap.get(termId);
if (BeanUtil.isNotEmpty(terminals)) {
model.setCmId(terminals.getCmdid());
}
model.setBatteryCapacity(bean.getBatteryCapacity());
model.setBatteryVoltage(bean.getBatteryVoltage());
model.setConnectionState(bean.getConnectionState());
model.setFloatingCharge(bean.getFloatingCharge());
model.setTermId(termId);
model.setTotalWorkingTime(bean.getTotalWorkingTime());
model.setWorkingTime(bean.getWorkingTime());
model.setWsUpdateTime(bean.getWsUpdateTime());
BigInteger wsUpdateTime = bean.getWsUpdateTime();
long queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime()); long queryTime = MyDateUtils.TimeMillSecond2Second(vo.getQueryTime());
hasNew = wsUpdateTime.longValue() < queryTime ? false : true; hasNew = wsUpdateTime.longValue() < queryTime ? false : true;
} }
model.setIsNew(hasNew); model.setIsNew(hasNew);
/* if (dto != null) {
BeanUtils.copyProperties(dto, model);
}
model.setWsUpdateTime(MyDateUtils.TimeSecond2MillSecond(dto.getWsUpdateTime().longValue()));
}*/
return Asserts.success(model); return Asserts.success(model);
} }
@ -342,9 +352,9 @@ public class TerminalServiceImpl implements TerminalService {
int result = terminalsDao.updateCmd(vo); int result = terminalsDao.updateCmd(vo);
if (result > 0) { if (result > 0) {
cacheService.updateTerminalMap();
return Asserts.success(model); return Asserts.success(model);
} }
return Asserts.error("装置ID修改失败"); return Asserts.error("装置ID修改失败");
} }
@ -471,5 +481,33 @@ public class TerminalServiceImpl implements TerminalService {
return Asserts.success(model); return Asserts.success(model);
} }
/**
*
*
* @param termId
* @return
*/
@Override
public ServiceBody<TerminalStatusInfoModel> getLastTermInfo(Integer termId) {
TerminalStatusInfoModel model = new TerminalStatusInfoModel();
TerminalStatus bean = terminalStatusDao.selectByPrimaryKey(termId);
if (!BeanUtil.isEmpty(bean)) {
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
Terminals terminals = terminalMap.get(termId);
if (BeanUtil.isNotEmpty(terminals)) {
model.setCmId(terminals.getCmdid());
}
model.setBatteryCapacity(bean.getBatteryCapacity());
model.setBatteryVoltage(bean.getBatteryVoltage());
model.setConnectionState(bean.getConnectionState());
model.setFloatingCharge(bean.getFloatingCharge());
model.setTermId(termId);
model.setTotalWorkingTime(bean.getTotalWorkingTime());
model.setWorkingTime(bean.getWorkingTime());
model.setWsUpdateTime(bean.getWsUpdateTime());
}
return Asserts.success(model);
}
} }

@ -15,6 +15,7 @@ import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.vo.*; import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.TowerDao; import com.shxy.xymanager_dao.dao.TowerDao;
import com.shxy.xymanager_service.cache.XyCache; import com.shxy.xymanager_service.cache.XyCache;
import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TowerService; import com.shxy.xymanager_service.service.TowerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -37,12 +38,16 @@ public class TowerServiceImpl implements TowerService {
@Autowired @Autowired
private TowerDao towerDao; private TowerDao towerDao;
@Autowired
private CacheService cacheService;
@Override @Override
public ServiceBody addTower(TowersVo vo) { public ServiceBody addTower(TowersVo vo) {
List<Towers> towersLst = BeanUtil.copyToList(vo.getList(), Towers.class, CopyOptions.create().ignoreCase()); List<Towers> towersLst = BeanUtil.copyToList(vo.getList(), Towers.class, CopyOptions.create().ignoreCase());
Date date = new Date(); Date date = new Date();
int i = towerDao.addTower(towersLst,CommonStatus.EFFECTIVE.value(), date); int i = towerDao.addTower(towersLst,CommonStatus.EFFECTIVE.value(), date);
if (i != 0) { if (i != 0) {
cacheService.updateTowerMap();
return Asserts.success("录入成功"); return Asserts.success("录入成功");
} else { } else {
return Asserts.error("录入失败"); return Asserts.error("录入失败");
@ -84,6 +89,7 @@ public class TowerServiceImpl implements TowerService {
Date date = new Date(); Date date = new Date();
int i = towerDao.deleteById(lines, CommonStatus.DELETE.value(), date); int i = towerDao.deleteById(lines, CommonStatus.DELETE.value(), date);
if (i != 0) { if (i != 0) {
cacheService.updateTowerMap();
return Asserts.success("删除成功"); return Asserts.success("删除成功");
} else { } else {
return Asserts.error("删除失败"); return Asserts.error("删除失败");
@ -96,6 +102,7 @@ public class TowerServiceImpl implements TowerService {
BeanUtil.copyProperties(vo, towers, true); BeanUtil.copyProperties(vo, towers, true);
int i = towerDao.updateByPrimaryKeySelective(towers, new Date()); int i = towerDao.updateByPrimaryKeySelective(towers, new Date());
if (i != 0) { if (i != 0) {
cacheService.updateTowerMap();
return Asserts.success("修改成功"); return Asserts.success("修改成功");
} else { } else {
return Asserts.error("修改失败"); return Asserts.error("修改失败");

@ -31,4 +31,10 @@ public interface TerminalGpsService {
ServiceBody<DateTime> getReturnedGPS(TerminalGpsVo vo); ServiceBody<DateTime> getReturnedGPS(TerminalGpsVo vo);
/**
* gps
* @param termId
* @return
*/
ServiceBody<TerminalGpsModel> getTermLastGPSPosition( Integer termId);
} }

@ -51,7 +51,7 @@ public interface TerminalService {
ServiceBody<TerminalStatusModel> getTerminalStatus(Integer termId); ServiceBody<TerminalStatusModel> getTerminalStatus(Integer termId);
ServiceBody<TerminalModel> getLastedTerminalStatus(TerminalStatusVo vo); ServiceBody<TerminalStatusInfoModel> getLastedTerminalStatus(TerminalStatusVo vo);
/** /**
* ID * ID
@ -92,9 +92,17 @@ public interface TerminalService {
/** /**
* 线 * 线
*
* @param termId * @param termId
* @return * @return
*/ */
ServiceBody<TermStatusModel> getTermStatus(Integer termId); ServiceBody<TermStatusModel> getTermStatus(Integer termId);
/**
*
*
* @param termId
* @return
*/
ServiceBody<TerminalStatusInfoModel> getLastTermInfo(Integer termId);
} }

Loading…
Cancel
Save