Commit 9e06bb70 by 杨林龙

开发 1.9.0 首页看板功能

1 parent 2951d00e
...@@ -2,12 +2,8 @@ package cn.com.glsx.app.modules.controller; ...@@ -2,12 +2,8 @@ package cn.com.glsx.app.modules.controller;
import cn.com.glsx.app.modules.model.param.BasicSearch; import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.app.modules.model.param.DeviceActiveSearch; import cn.com.glsx.app.modules.model.param.DeviceActiveSearch;
import cn.com.glsx.app.modules.model.view.LowPowerVO; import cn.com.glsx.app.modules.model.param.DeviceOfflineSearch;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO; import cn.com.glsx.app.modules.model.view.*;
import cn.com.glsx.app.modules.model.view.DeviceActiveVO;
import cn.com.glsx.app.modules.model.view.FenceAlarmVO;
import cn.com.glsx.app.modules.model.view.OfflineAlarmVO;
import cn.com.glsx.app.modules.model.view.TrackAlarmVO;
import cn.com.glsx.app.modules.service.DashboardService; import cn.com.glsx.app.modules.service.DashboardService;
import cn.hutool.db.Page; import cn.hutool.db.Page;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -61,11 +57,11 @@ public class DashboardController { ...@@ -61,11 +57,11 @@ public class DashboardController {
} }
@GetMapping("/getActiveDeviceInfo") @GetMapping("/getActiveDeviceWeekReport")
@ApiOperation(value = "一周激活设备报表统计") @ApiOperation(value = "一周激活设备报表统计")
@SysLog(module = "一周激活设备报表统计", value = "一周激活设备报表统计", action = OperateType.QUERY, saveLog = false) @SysLog(module = "一周激活设备报表统计", value = "一周激活设备报表统计", action = OperateType.QUERY, saveLog = false)
public R<DeviceActiveVO> getActiveDeviceInfo(DeviceActiveSearch search) { public R<DeviceActiveVO> getActiveDeviceWeekReport(DeviceActiveSearch search) {
List<DeviceActiveVO> deviceActiveList = dashboardService.getActiveDeviceInfo(search); List<DeviceActiveVO> deviceActiveList = dashboardService.getActiveDeviceWeekReport(search);
return R.ok().data(deviceActiveList); return R.ok().data(deviceActiveList);
} }
......
...@@ -43,10 +43,17 @@ public class DeviceFreqController { ...@@ -43,10 +43,17 @@ public class DeviceFreqController {
if (StringUtils.isNullOrEmpty(model.getSn())) { if (StringUtils.isNullOrEmpty(model.getSn())) {
return R.error("sn号为空"); return R.error("sn号为空");
} }
// deviceFreqService.adjFreq(model); deviceFreqService.adjFreq(model);
return R.ok(); return R.ok();
} }
@ApiOperation(value = "关闭调频")
@SysLog(module = "关闭调频", value = "关闭调频", action = OperateType.EDIT)
@GetMapping(value = "/resetAdjFreq")
public R resetAdjFreq(@RequestParam String sn) {
deviceFreqService.resetAdjFreq(sn);
return R.ok();
}
@ApiOperation(value = "获取设备调频车辆设备列表") @ApiOperation(value = "获取设备调频车辆设备列表")
@SysLog(module = "获取设备调频车辆设备列表", value = "获取设备调频车辆设备列表", action = OperateType.QUERY, saveLog = false) @SysLog(module = "获取设备调频车辆设备列表", value = "获取设备调频车辆设备列表", action = OperateType.QUERY, saveLog = false)
......
...@@ -8,42 +8,76 @@ import javax.persistence.Table; ...@@ -8,42 +8,76 @@ import javax.persistence.Table;
/** /**
* 调频记录 * 调频记录
*
* @author yangll
*/ */
@Table(name = "t_device_freq") @Table(name = "t_device_freq")
@Data @Data
public class DeviceFreq extends BaseEntity { public class DeviceFreq extends BaseEntity {
//车辆id
/**
* 车辆id
*/
@Column(name = "vehicle_id") @Column(name = "vehicle_id")
private Long vehicleId; private Long vehicleId;
//设备号 /**
* 设备号
*/
private String sn; private String sn;
//调频模式0 追车模式;1 闹钟模式;2 星期模式;3 初始化模式 /**
* 调频模式0 追车模式;1 闹钟模式;2 星期模式;3 初始化模式
*/
@Column(name = "freq_type") @Column(name = "freq_type")
private Integer freqType; private Integer freqType;
//调频状态1 生效 ; 2 关闭 /**
* 调频状态1 生效 ; 2 关闭
*/
private Integer status; private Integer status;
//设备剩余电量 /**
* 设备剩余电量
*/
@Column(name = "battery_level") @Column(name = "battery_level")
private String batteryLevel; private String batteryLevel;
//操作渠道1 APP端 ; 2 虎哥E盾系统;3 FRMS系统 /**
* 操作渠道1 APP端 ; 2 虎哥E盾系统;3 FRMS系统
*/
private Integer channel; private Integer channel;
//追车模式下,如55 /**
* 追车模式下,如55
*/
@Column(name = "catching_timer") @Column(name = "catching_timer")
private Integer catchingTimer; private Integer catchingTimer;
//闹钟模式下,如0355,0422 /**
* 闹钟模式下,如0355,0422
*/
private String timer; private String timer;
//星期模式下。如:12 /**
* 星期模式下。如:12
*/
private String week; private String week;
//星期模式下上点时间.如1000 /**
* 星期模式下上点时间.如1000
*/
@Column(name = "week_timer") @Column(name = "week_timer")
private String weekTimer; private String weekTimer;
/**
* 是否还支持调频 默认为空,汇通设备专用字段
*/
private String supportFreq;
/**
* 用户类型 兼容小程序分享用户添加字段 1:有账户的用户 2:分享的用户
*/
@Column(name = "user_type")
private Integer userType;
} }
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.DeviceLocation; import cn.com.glsx.app.modules.entity.DeviceLocation;
import cn.com.glsx.app.modules.model.view.OfflineAlarmVO;
import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface DeviceLocationMapper extends CommonBaseMapper<DeviceLocation> { public interface DeviceLocationMapper extends CommonBaseMapper<DeviceLocation> {
/**
* 获取设备离线数据
*
* @param activeStartTime 激活开始时间
* @param offlineStartTime 离线开始时间
* @return
*/
@DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true)
List<OfflineAlarmVO> getOfflineAlarmInfo(@Param("activeStartTime") String activeStartTime, @Param("offlineStartTime") String offlineStartTime);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.Vehicle; import cn.com.glsx.app.modules.entity.Vehicle;
import cn.com.glsx.app.modules.model.view.AdjFredDetailVO;
import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO; import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO;
import com.glsx.plat.common.annotation.DataPerm; import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare; import com.glsx.plat.common.annotation.DataPermShare;
...@@ -26,5 +27,4 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> { ...@@ -26,5 +27,4 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
@DataPerm(permTable = "tv", showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countDeviceWithAuth(); Integer countDeviceWithAuth();
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.VehiclePermit; import cn.com.glsx.app.modules.entity.VehiclePermit;
import cn.com.glsx.app.modules.model.view.AdjFredDetailVO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface VehiclePermitMapper extends CommonBaseMapper<VehiclePermit> { public interface VehiclePermitMapper extends CommonBaseMapper<VehiclePermit> {
......
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.VehicleShared; import cn.com.glsx.app.modules.entity.VehicleShared;
import cn.com.glsx.app.modules.model.view.AdjFredDetailVO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface VehicleSharedMapper extends CommonBaseMapper<VehicleShared> { public interface VehicleSharedMapper extends CommonBaseMapper<VehicleShared> {
VehicleShared selectBySharedIdAndReceiverId(@Param("shareId") Long shareId, @Param("receiverId") Long receiverId); VehicleShared selectBySharedIdAndReceiverId(@Param("shareId") Long shareId, @Param("receiverId") Long receiverId);
/**
* 通过微信用户ID获取分享的车辆数据
*
* @param wxUserId 微信用户ID
* @return
*/
List<AdjFredDetailVO> getSharedVehicleByWxUserId(@Param("wxUserId") Integer wxUserId);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.model.param; package cn.com.glsx.app.modules.model.param;
import cn.hutool.db.Page;
import lombok.Data; import lombok.Data;
/** /**
...@@ -10,7 +9,7 @@ import lombok.Data; ...@@ -10,7 +9,7 @@ import lombok.Data;
* @date 2022/7/4 10:20 * @date 2022/7/4 10:20
*/ */
@Data @Data
public class AdjFreqSharedSearch extends Page { public class AdjFreqSharedSearch {
/** /**
* 搜索的关键字 工单号|车架号|设备号 * 搜索的关键字 工单号|车架号|设备号
......
package cn.com.glsx.app.modules.model.param;
import lombok.Data;
/**
* 设备离线
*
* @author Yanglinlong
* @date 2022/7/4 17:12
*/
@Data
public class DeviceOfflineSearch extends BasicSearch {
/**
* 查询开始时间
*/
String startTime;
/**
* 查询结束时间
*/
String endTime;
}
...@@ -36,5 +36,5 @@ public class AdjFredDetailVO { ...@@ -36,5 +36,5 @@ public class AdjFredDetailVO {
/** /**
* 设备调频记录信息 * 设备调频记录信息
*/ */
private List<DeviceFreqVO> deviceInfo; private List<DeviceFreqVO> deviceFreqList;
} }
package cn.com.glsx.app.modules.model.view;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 设备离线周报表 vo
*
* @author Yanglinlong
* @date 2022/7/4 15:01
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DeviceOfflineVO {
/**
* 激活设备的时间
*/
private String offlineDate;
/**
* 已激活设备的数量
*/
private Integer offlineNumber;
}
...@@ -30,10 +30,16 @@ public class OfflineAlarmVO { ...@@ -30,10 +30,16 @@ public class OfflineAlarmVO {
private String sn; private String sn;
/** /**
* 时间 * 最后GPS时间
**/ **/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date alarmTime; private Date lastGpsTime;
/**
* 最后基站时间
**/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date lastBsTime;
/** /**
* 激活时间 * 激活时间
......
...@@ -9,17 +9,13 @@ import cn.com.glsx.app.modules.model.RangeTimeDTO; ...@@ -9,17 +9,13 @@ import cn.com.glsx.app.modules.model.RangeTimeDTO;
import cn.com.glsx.app.modules.model.param.BasicSearch; import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.app.modules.model.param.DeviceActiveSearch; import cn.com.glsx.app.modules.model.param.DeviceActiveSearch;
import cn.com.glsx.app.modules.model.stat.StatActivatedVehicleDevice; import cn.com.glsx.app.modules.model.stat.StatActivatedVehicleDevice;
import cn.com.glsx.app.modules.model.view.LowPowerVO; import cn.com.glsx.app.modules.model.view.*;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import cn.com.glsx.app.modules.model.view.DeviceActiveVO;
import cn.com.glsx.app.modules.model.view.FenceAlarmVO;
import cn.com.glsx.app.modules.model.view.OfflineAlarmVO;
import cn.com.glsx.app.modules.model.view.TrackAlarmVO;
import cn.hutool.db.Page; import cn.hutool.db.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -54,7 +50,7 @@ public class DashboardService { ...@@ -54,7 +50,7 @@ public class DashboardService {
@Autowired @Autowired
private VehicleMapper vehicleMapper; private VehicleMapper vehicleMapper;
public List<DeviceActiveVO> getActiveDeviceInfo(DeviceActiveSearch search) { public List<DeviceActiveVO> getActiveDeviceWeekReport(DeviceActiveSearch search) {
List<StatActivatedVehicleDevice> activeDeviceList = vehicleDeviceMapper.getActiveDeviceInfo(search); List<StatActivatedVehicleDevice> activeDeviceList = vehicleDeviceMapper.getActiveDeviceInfo(search);
Map<String, List<StatActivatedVehicleDevice>> groupByActiveTimeMap = activeDeviceList.stream().collect(Collectors.groupingBy(StatActivatedVehicleDevice::getActiveTime)); Map<String, List<StatActivatedVehicleDevice>> groupByActiveTimeMap = activeDeviceList.stream().collect(Collectors.groupingBy(StatActivatedVehicleDevice::getActiveTime));
List<DeviceActiveVO> list = convertActiveDeviceVoList(groupByActiveTimeMap); List<DeviceActiveVO> list = convertActiveDeviceVoList(groupByActiveTimeMap);
...@@ -131,7 +127,11 @@ public class DashboardService { ...@@ -131,7 +127,11 @@ public class DashboardService {
} }
public PageInfo<OfflineAlarmVO> getOfflineAlarmInfo(Page page) { public PageInfo<OfflineAlarmVO> getOfflineAlarmInfo(Page page) {
return null; PageHelper.startPage(page.getPageNumber(), page.getPageSize());
String activeStartTime = DateUtil.formatDate(DateUtil.getDayBefore(180, new Date()));
String offlineStartTime = DateUtil.formatDate(DateUtils.addHours(new Date(), -72));
List<OfflineAlarmVO> offlineAlarmList = deviceLocationMapper.getOfflineAlarmInfo(activeStartTime, offlineStartTime);
return new PageInfo<>(offlineAlarmList);
} }
public StatisticalInfoVO getStatisticalInfo() { public StatisticalInfoVO getStatisticalInfo() {
...@@ -168,5 +168,4 @@ public class DashboardService { ...@@ -168,5 +168,4 @@ public class DashboardService {
public List<LowPowerVO> listTodayLowPower(BasicSearch search) { public List<LowPowerVO> listTodayLowPower(BasicSearch search) {
return null; return null;
} }
} }
package cn.com.glsx.app.modules.service; package cn.com.glsx.app.modules.service;
import cn.com.glsx.admin.common.constant.UserConstants;
import cn.com.glsx.app.common.constants.Constants; import cn.com.glsx.app.common.constants.Constants;
import cn.com.glsx.app.common.exception.AppServerException; import cn.com.glsx.app.common.exception.AppServerException;
import cn.com.glsx.app.modules.entity.DeviceFreq; import cn.com.glsx.app.modules.entity.DeviceFreq;
...@@ -8,6 +9,7 @@ import cn.com.glsx.app.modules.entity.VehicleDevice; ...@@ -8,6 +9,7 @@ import cn.com.glsx.app.modules.entity.VehicleDevice;
import cn.com.glsx.app.modules.mapper.DeviceFreqMapper; import cn.com.glsx.app.modules.mapper.DeviceFreqMapper;
import cn.com.glsx.app.modules.mapper.DevicePowerMapper; import cn.com.glsx.app.modules.mapper.DevicePowerMapper;
import cn.com.glsx.app.modules.mapper.VehicleDeviceMapper; import cn.com.glsx.app.modules.mapper.VehicleDeviceMapper;
import cn.com.glsx.app.modules.mapper.VehicleSharedMapper;
import cn.com.glsx.app.modules.model.DeviceWorkBO; import cn.com.glsx.app.modules.model.DeviceWorkBO;
import cn.com.glsx.app.modules.model.param.AdjFreqDetailsSearch; import cn.com.glsx.app.modules.model.param.AdjFreqDetailsSearch;
import cn.com.glsx.app.modules.model.param.AdjFreqSearch; import cn.com.glsx.app.modules.model.param.AdjFreqSearch;
...@@ -24,7 +26,6 @@ import com.github.pagehelper.PageInfo; ...@@ -24,7 +26,6 @@ import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.HttpUtils; import com.glsx.plat.common.utils.HttpUtils;
import com.glsx.plat.context.utils.PropertiesUtils; import com.glsx.plat.context.utils.PropertiesUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -52,53 +53,13 @@ public class DeviceFreqService { ...@@ -52,53 +53,13 @@ public class DeviceFreqService {
@Autowired @Autowired
private RemoteDeviceFeignService remoteDeviceFeignService; private RemoteDeviceFeignService remoteDeviceFeignService;
private static String transWeekFrequency(String week, String weekTimer) { @Autowired
StringBuilder sb = new StringBuilder(weekTimer + "/星期"); private VehicleSharedMapper vehicleSharedMapper;
for (int i = 0; i < week.length(); i++) {
char c = week.charAt(i);
switch (c) {
case '1':
sb.append("一、");
break;
case '2':
sb.append("二、");
break;
case '3':
sb.append("三、");
break;
case '4':
sb.append("四、");
break;
case '5':
sb.append("五、");
break;
case '6':
sb.append("六、");
break;
case '7':
sb.append("七、");
break;
default:
break;
}
}
String str = sb.toString();
return str.substring(0, str.length() - 1);
}
public void adjFreq(DeviceWorkBO model) { public void adjFreq(DeviceWorkBO model) {
log.info("调频sn:" + model.getSn() + "; 操作用户id:" + ShieldContextHolder.getUserId()); // 更新上个设备调频记录
List<DeviceFreq> df1 = deviceFreqMapper.selectBySn(model.getSn()); updateDeviceFreqRecord(model.getSn());
if (df1 != null) {
//存在
df1.forEach(deviceFreq -> {
log.info("存在则修改调频状态===" + deviceFreq.getId());
deviceFreq.setUpdatedDate(new Date());
deviceFreq.setUpdatedBy(ShieldContextHolder.getUserId());
deviceFreq.setStatus(2);
deviceFreqMapper.updateByPrimaryKey(deviceFreq);
});
}
DeviceFreq df = new DeviceFreq(); DeviceFreq df = new DeviceFreq();
String value = ""; String value = "";
if (model.getType() == 0) { if (model.getType() == 0) {
...@@ -132,18 +93,92 @@ public class DeviceFreqService { ...@@ -132,18 +93,92 @@ public class DeviceFreqService {
df.setBatteryLevel(devicePower.getSoc() + ""); df.setBatteryLevel(devicePower.getSoc() + "");
} }
df.setStatus(1); df.setStatus(1);
// todo 插入用户类型 // 插入用户类型
if (UserConstants.RolePermitCastType.wxShared.getCode().equals(ShieldContextHolder.getRolePermissionType())) {
df.setUserType(2);
} else {
df.setUserType(1);
}
df.setCreatedBy(ShieldContextHolder.getUserId());
df.setCreatedDate(new Date());
df.setUpdatedDate(new Date());
//设置操作渠道 4 新E盾系统 5 小程序
df.setChannel(5);
deviceFreqMapper.insert(df);
// 向大数据侧发送调频请求
sendRequest(model.getSn(), value);
}
public void resetAdjFreq(String sn) {
// 更新上个设备调频记录
updateDeviceFreqRecord(sn);
DeviceFreq df = new DeviceFreq();
//闹钟模式 (默认模式 一天一个点)
df.setFreqType(1);
df.setTimer("15:30");
String transTimer = "15:30".replace(":", "");
String value = "R:" + transTimer;
//调频记录
VehicleDevice vehicleDevice = vehicleDeviceMapper.selectBindDeviceBySn(sn);
df.setVehicleId(vehicleDevice.getVehicleId());
df.setSn(sn);
// 设置设备电量
Long vdId = Optional.of(vehicleDevice).map(VehicleDevice::getId).orElse(null);
DevicePower devicePower = devicePowerMapper.selectBySn(sn, vdId);
if (Objects.nonNull(devicePower)) {
df.setBatteryLevel(devicePower.getSoc() + "");
}
df.setStatus(1);
// 插入用户类型
if (UserConstants.RolePermitCastType.wxShared.getCode().equals(ShieldContextHolder.getRolePermissionType())) {
df.setUserType(2);
} else {
df.setUserType(1);
}
df.setCreatedBy(ShieldContextHolder.getUserId()); df.setCreatedBy(ShieldContextHolder.getUserId());
df.setCreatedDate(new Date()); df.setCreatedDate(new Date());
df.setUpdatedDate(new Date()); df.setUpdatedDate(new Date());
//设置操作渠道 4 新E盾系统 //设置操作渠道 4 新E盾系统 5 小程序
df.setChannel(4); df.setChannel(5);
deviceFreqMapper.insert(df); deviceFreqMapper.insert(df);
// 向大数据侧发送调频请求
sendRequest(sn, value);
}
/**
* 更新设备调频记录
*
* @param sn 设备号
*/
public void updateDeviceFreqRecord(String sn) {
log.info("调频sn:" + sn + "; 操作用户id:" + ShieldContextHolder.getUserId());
List<DeviceFreq> df1 = deviceFreqMapper.selectBySn(sn);
if (df1 != null) {
//存在
df1.forEach(deviceFreq -> {
log.info("存在则修改调频状态===" + deviceFreq.getId());
deviceFreq.setUpdatedDate(new Date());
deviceFreq.setUpdatedBy(ShieldContextHolder.getUserId());
deviceFreq.setStatus(2);
deviceFreqMapper.updateByPrimaryKey(deviceFreq);
});
}
}
/**
* 发送调频请求
*
* @param sn 设备号
* @param value 调频指令
*/
private void sendRequest(String sn, String value) {
String url = PropertiesUtils.getProperty("bsj.adjFreq.location"); String url = PropertiesUtils.getProperty("bsj.adjFreq.location");
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
List<DeviceFreq> freqs = deviceFreqMapper.selectBySn(model.getSn()); List<DeviceFreq> freqs = deviceFreqMapper.selectBySn(sn);
DeviceFreq freq = freqs.get(0); DeviceFreq freq = freqs.get(0);
params.put("DeviceNO", model.getSn()); params.put("DeviceNO", sn);
params.put("FacID", Constants.BSJ_FACTORY_ID); params.put("FacID", Constants.BSJ_FACTORY_ID);
params.put("Seq", String.valueOf(freq.getId())); params.put("Seq", String.valueOf(freq.getId()));
params.put("PosRepInfo", value); params.put("PosRepInfo", value);
...@@ -154,7 +189,7 @@ public class DeviceFreqService { ...@@ -154,7 +189,7 @@ public class DeviceFreqService {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
log.info("调频结果:" + result + ";SN" + model.getSn()); log.info("调频结果:" + result + ";SN" + sn);
int returnCode = (int) JsonUtils.getProperty(result, "result"); int returnCode = (int) JsonUtils.getProperty(result, "result");
if (returnCode != 0) { if (returnCode != 0) {
throw new AppServerException("调频失败"); throw new AppServerException("调频失败");
...@@ -173,12 +208,62 @@ public class DeviceFreqService { ...@@ -173,12 +208,62 @@ public class DeviceFreqService {
public PageInfo<DeviceFreqVO> getAdjFreqDetails(AdjFreqDetailsSearch adjFreqDetailsSearch) { public PageInfo<DeviceFreqVO> getAdjFreqDetails(AdjFreqDetailsSearch adjFreqDetailsSearch) {
PageHelper.startPage(adjFreqDetailsSearch.getPageNumber(), adjFreqDetailsSearch.getPageSize()); PageHelper.startPage(adjFreqDetailsSearch.getPageNumber(), adjFreqDetailsSearch.getPageSize());
List<DeviceFreqVO> freqModelList = deviceFreqMapper.getAdjFreqInfo(adjFreqDetailsSearch.getVehicleId()); List<DeviceFreqVO> deviceFreqList = getDeviceFreqList(adjFreqDetailsSearch.getVehicleId());
if (CollectionUtils.isEmpty(freqModelList)) { return new PageInfo<>(deviceFreqList);
return new PageInfo<>(); }
private static String transWeekFrequency(String week, String weekTimer) {
StringBuilder sb = new StringBuilder(weekTimer + "/星期");
for (int i = 0; i < week.length(); i++) {
char c = week.charAt(i);
switch (c) {
case '1':
sb.append("一、");
break;
case '2':
sb.append("二、");
break;
case '3':
sb.append("三、");
break;
case '4':
sb.append("四、");
break;
case '5':
sb.append("五、");
break;
case '6':
sb.append("六、");
break;
case '7':
sb.append("七、");
break;
default:
break;
}
}
String str = sb.toString();
return str.substring(0, str.length() - 1);
}
public List<AdjFredDetailVO> adjFreqDetailsForShared(AdjFreqSharedSearch adjFreqSharedSearch) {
List<AdjFredDetailVO> sharedVehicleFredList = vehicleSharedMapper.getSharedVehicleByWxUserId(adjFreqSharedSearch.getWxUserId());
for (AdjFredDetailVO adjFredDetail : sharedVehicleFredList) {
List<DeviceFreqVO> deviceFreqList = getDeviceFreqList(adjFredDetail.getVehicleId());
adjFredDetail.setDeviceFreqList(deviceFreqList);
}
return sharedVehicleFredList;
} }
for (DeviceFreqVO model : freqModelList) { /**
* 通过车辆ID获取设备调频记录
*
* @param vehicleId 车辆ID
* @return
*/
private List<DeviceFreqVO> getDeviceFreqList(Long vehicleId) {
List<DeviceFreqVO> deviceFreqList = deviceFreqMapper.getAdjFreqInfo(vehicleId);
for (DeviceFreqVO model : deviceFreqList) {
Integer freqType = model.getFreqType(); Integer freqType = model.getFreqType();
if (Constants.ADJ_FREQ_CATCHING == freqType) { if (Constants.ADJ_FREQ_CATCHING == freqType) {
//追车模式 //追车模式
...@@ -215,10 +300,6 @@ public class DeviceFreqService { ...@@ -215,10 +300,6 @@ public class DeviceFreqService {
Integer totalCount = remoteDeviceFeignService.getDevicesTotalCount(model.getSn()); Integer totalCount = remoteDeviceFeignService.getDevicesTotalCount(model.getSn());
model.setDevicePointTotal(totalCount); model.setDevicePointTotal(totalCount);
} }
return new PageInfo<>(freqModelList); return deviceFreqList;
}
public List<AdjFredDetailVO> adjFreqDetailsForShared(AdjFreqSharedSearch adjFreqSharedSearch) {
return null;
} }
} }
...@@ -68,8 +68,9 @@ ...@@ -68,8 +68,9 @@
</javaClientGenerator> </javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 --> <!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table tableName="t_alarm_track_rec" domainObjectName="AlarmTrackRec" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> <!-- <table tableName="t_alarm_track_rec" domainObjectName="AlarmTrackRec" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<table tableName="t_alarm_electric_fence" domainObjectName="AlarmElectricFence" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> <!-- <table tableName="t_alarm_electric_fence" domainObjectName="AlarmElectricFence" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<table tableName="t_device_location" domainObjectName="DeviceLocation" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> <!-- <table tableName="t_device_location" domainObjectName="DeviceLocation" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<table tableName="t_device_freq" domainObjectName="DeviceFreq" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
</context> </context>
</generatorConfiguration> </generatorConfiguration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.app.modules.mapper.DeviceFreqMapper"> <mapper namespace="cn.com.glsx.app.modules.mapper.DeviceFreqMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.app.modules.entity.DeviceFreq">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="vehicle_id" jdbcType="INTEGER" property="vehicleId"/>
<result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="freq_type" jdbcType="INTEGER" property="freqType"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="battery_level" jdbcType="VARCHAR" property="batteryLevel"/>
<result column="channel" jdbcType="INTEGER" property="channel"/>
<result column="catching_timer" jdbcType="VARCHAR" property="catchingTimer"/>
<result column="timer" jdbcType="VARCHAR" property="timer"/>
<result column="week" jdbcType="VARCHAR" property="week"/>
<result column="week_timer" jdbcType="VARCHAR" property="weekTimer"/>
<result column="support_freq" jdbcType="VARCHAR" property="supportFreq"/>
<result column="user_type" jdbcType="INTEGER" property="userType"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, vehicle_id, sn, freq_type, `status`, battery_level, channel, catching_timer,
timer, week, week_timer, support_freq, user_type, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
<select id="selectBySn" resultType="cn.com.glsx.app.modules.entity.DeviceFreq"> <select id="selectBySn" resultType="cn.com.glsx.app.modules.entity.DeviceFreq">
select select
...@@ -28,7 +59,7 @@ ...@@ -28,7 +59,7 @@
LEFT(tdf.created_date, 19) AS createTime, LEFT(tdf.created_date, 19) AS createTime,
tdf.freq_type AS freqType, tdf.freq_type AS freqType,
tdf.channel , tdf.channel ,
tu.username AS operation, IF(tdf.user_type = 1, tu.username, tcula.username) AS operation,
tdf.catching_timer AS catchingTimer, tdf.catching_timer AS catchingTimer,
tdf.timer , tdf.timer ,
tdf.week , tdf.week ,
...@@ -41,6 +72,8 @@ ...@@ -41,6 +72,8 @@
FROM t_device_freq tdf FROM t_device_freq tdf
LEFT JOIN t_vehicle tv ON tv.id = tdf.vehicle_id LEFT JOIN t_vehicle tv ON tv.id = tdf.vehicle_id
LEFT JOIN t_user tu ON tu.id = tdf.created_by LEFT JOIN t_user tu ON tu.id = tdf.created_by
LEFT JOIN t_cust_user_auth_rel tcuar ON tcuar.user_id = tdf.created_by and tcuar.auth_type = 'local'
LEFT JOIN t_cust_user_local_account tcula ON tcula.auth_id = tcuar.auth_id
WHERE tdf.vehicle_id = #{vehicleId} WHERE tdf.vehicle_id = #{vehicleId}
AND tdf.status = 2 AND tdf.status = 2
AND tdf.del_flag = 0 AND tdf.del_flag = 0
......
...@@ -23,4 +23,33 @@ ...@@ -23,4 +23,33 @@
created_time, updated_time created_time, updated_time
</sql> </sql>
<select id="getOfflineAlarmInfo" resultType="cn.com.glsx.app.modules.model.view.OfflineAlarmVO">
select tv.id as vehicleId,
tv.owner_name as ownerName,
tvd.sn as sn,
tv.vin as vin,
tvd.created_date as activeDate,
tdl.last_gps_time as lastGpsTime,
tdl.last_bs_time as lastBsTime
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device td on td.sn = tvd.sn
left join t_workorder tw on tw.id = tv.workorder_id and tw.del_flag = 0
left join t_user tu on tu.id = tv.created_by and tu.del_flag = 0
left join t_device_location tdl on tdl.sn = td.sn
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
<if test="offlineStartTime != null and offlineStartTime != ''">
and ((tdl.last_gps_time &lt; #{offlineStartTime} and tdl.last_bs_time &lt; #{offlineStartTime})
or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and tdl.last_bs_time &lt; #{offlineStartTime})
or (tdl.last_gps_time &lt; #{offlineStartTime} and tdl.last_bs_time is null)
)
</if>
<if test="activeStartTime != null and activeStartTime != ''">
and tvd.created_date &gt;= #{activeStartTime}
</if>
order by tdl.last_gps_time desc
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
where tvd.vehicle_id = #{vehicleId} where tvd.vehicle_id = #{vehicleId}
and tvd.bind_status = 1 and tvd.bind_status = 1
and tvd.del_flag = 0 and tvd.del_flag = 0
and td.del_flag = 0; and td.del_flag = 0
</select> </select>
<select id="getActiveDeviceInfo" <select id="getActiveDeviceInfo"
......
...@@ -37,4 +37,20 @@ ...@@ -37,4 +37,20 @@
and tvs.shared_id = #{shareId} and tvs.shared_id = #{shareId}
and tvs.receiver_id = #{receiverId} and tvs.receiver_id = #{receiverId}
</select> </select>
<select id="getSharedVehicleByWxUserId" resultType="cn.com.glsx.app.modules.model.view.AdjFredDetailVO">
select tv.id as vehicleId,
tv.owner_name as ownerName,
tv.vin as vin,
tw.partner_order_no as workOrderNo
from t_vehicle_shared tvs
left join t_vehicle tv on tv.id = tvs.content_id
left join t_workorder tw on tw.id = tv.workorder_id
left join (select vehicle_id, max(tdf.created_date) createdDate from t_device_freq tdf
group by tdf.vehicle_id) tdf on tdf.vehicle_id = tv.id
where tv.del_flag = 0
and tdf.vehicle_id is not null
and tvs.receiver_id = #{wxUserId}
and tvs.content_type = 0
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!