1.在线/离线日志

2.还车审核
This commit is contained in:
邱贞招 2024-07-15 10:02:56 +08:00
parent 3ddba90fc2
commit 91433732dc
18 changed files with 586 additions and 48 deletions

View File

@ -737,6 +737,7 @@ public class AppVerifyController extends BaseController
/** /**
* 实名认证 * 实名认证
*/ */
@Log(title = "实名认证", businessType = BusinessType.AUTHENTICATION)
@GetMapping("/user/authentication") @GetMapping("/user/authentication")
public AjaxResult partnerBillList(AuthenticationVo authenticationVo) public AjaxResult partnerBillList(AuthenticationVo authenticationVo)
{ {
@ -781,6 +782,7 @@ public class AppVerifyController extends BaseController
/** /**
* sn和mac号绑定 * sn和mac号绑定
*/ */
@Log(title = "设备绑定", businessType = BusinessType.BAND)
@PostMapping("/band") @PostMapping("/band")
public AjaxResult bandSn(String sn,String mac) public AjaxResult bandSn(String sn,String mac)
{ {
@ -846,11 +848,12 @@ public class AppVerifyController extends BaseController
public AjaxResult getAreaList() public AjaxResult getAreaList()
{ {
AsUser asUser = getLoginUser().getAsUser(); AsUser asUser = getLoginUser().getAsUser();
logger.info("获取到当前app登录用户【{}】", JSON.toJSON(asUser)); AsUser asUser1 = asUserMapper.selectUserById(asUser.getUserId());
if(ObjectUtil.isNull(asUser.getSysUserId())){ logger.info("获取到当前app登录用户【{}】", JSON.toJSON(asUser1));
throw new RuntimeException("用户【"+asUser.getUserName()+"】未绑定系统用户"); if(ObjectUtil.isNull(asUser1.getSysUserId())){
throw new RuntimeException("用户【"+asUser1.getUserName()+"】未绑定系统用户");
} }
SysUser sysUser = userService.selectUserById(asUser.getSysUserId()); SysUser sysUser = userService.selectUserById(asUser1.getSysUserId());
Long deptId; Long deptId;
if(sysUser.isAdmin()){ if(sysUser.isAdmin()){
deptId = null; deptId = null;
@ -899,6 +902,7 @@ public class AppVerifyController extends BaseController
/** /**
* 重启设备 * 重启设备
*/ */
@Log(title = "重启设备", businessType = BusinessType.REBOOT)
@PostMapping("/device/reboot") @PostMapping("/device/reboot")
public AjaxResult reboot(String sn) public AjaxResult reboot(String sn)
{ {

View File

@ -74,6 +74,9 @@ public class ReceiveController {
@Autowired @Autowired
private ScheduledExecutorService scheduledExecutorService; private ScheduledExecutorService scheduledExecutorService;
@Autowired
private IEtOnlineLogService etOnlineLogService;
private final Object lock = new Object(); private final Object lock = new Object();
@ -216,7 +219,7 @@ public class ReceiveController {
String noRidingOutage = area.getNoRidingOutage(); String noRidingOutage = area.getNoRidingOutage();
if (noRidingOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 禁行区内断电 if (noRidingOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 禁行区内断电
log.info("禁行区内断电命令--SN" + device.getSn()); log.info("禁行区内断电命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "禁行区内断电"); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "禁行区内断电",null);
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
int updateAsDevice = asDeviceService.updateAsDevice(device); int updateAsDevice = asDeviceService.updateAsDevice(device);
if (updateAsDevice > 0) { if (updateAsDevice > 0) {
@ -228,7 +231,7 @@ public class ReceiveController {
boolean inPolygon = asDeviceService.isNoRidingAreaWithTolerance(device.getSn(), device.getAreaId(),20); boolean inPolygon = asDeviceService.isNoRidingAreaWithTolerance(device.getSn(), device.getAreaId(),20);
if (inPolygon) { if (inPolygon) {
log.info("距离禁行区20米内发送警告命令--SN" + device.getSn()); log.info("距离禁行区20米内发送警告命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "距离禁行区20米内"); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "距离禁行区20米内",null);
} }
} }
/** 3.超出运营区外断电*/ /** 3.超出运营区外断电*/
@ -239,14 +242,14 @@ public class ReceiveController {
if(inPolygon){ if(inPolygon){
//在20米范围内发报警 //在20米范围内发报警
log.info("超出运营区30米内发送警告命令--SN" + device.getSn()); log.info("超出运营区30米内发送警告命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区30米内"); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区30米内",null);
}else{ }else{
//超出运营区外断电 //超出运营区外断电
String isAdminUnlocking = device.getIsAdminUnlocking();// 是否管理员开锁 String isAdminUnlocking = device.getIsAdminUnlocking();// 是否管理员开锁
String areaOutOutage = area.getAreaOutOutage(); String areaOutOutage = area.getAreaOutOutage();
if (areaOutOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 超出营运区断电 if (areaOutOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 超出营运区断电
log.info("超出营运区断电命令--SN" + device.getSn()); log.info("超出营运区断电命令--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电"); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null);
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
int updateAsDevice = asDeviceService.updateAsDevice(device); int updateAsDevice = asDeviceService.updateAsDevice(device);
if (updateAsDevice > 0) { if (updateAsDevice > 0) {
@ -259,7 +262,7 @@ public class ReceiveController {
Boolean inOrderBySn = etOrderService.isInOrderBySn(device.getSn()); Boolean inOrderBySn = etOrderService.isInOrderBySn(device.getSn());
if (inOrderBySn && ServiceConstants.VEHICLE_STATUS_IN_USING.equals(device.getStatus()) && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) { // 有正在骑行的订单给车辆上电 if (inOrderBySn && ServiceConstants.VEHICLE_STATUS_IN_USING.equals(device.getStatus()) && ServiceConstants.LOCK_STATUS_CLOSE.equals(device.getLockStatus())) { // 有正在骑行的订单给车辆上电
log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN" + device.getSn()); log.info("返回营运区上电,有正在骑行的订单,给车辆上电--SN" + device.getSn());
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "返回营运区上电"); asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "返回营运区上电",null);
// 更新车辆状态和锁状态 // 更新车辆状态和锁状态
/** 3.更新车辆状态*/ /** 3.更新车辆状态*/
device.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); device.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
@ -383,7 +386,7 @@ public class ReceiveController {
if(StrUtil.isNotBlank(verStr)){ if(StrUtil.isNotBlank(verStr)){
device.setVersion(verStr); device.setVersion(verStr);
} }
//开异步线程保存回调参数 //开异步线程1.更新在线状态 2.记录在线离线日志
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
if(device.getOnlineStatus().equals(ServiceConstants.VEHICLE_STATUS_OFFLINE)){ if(device.getOnlineStatus().equals(ServiceConstants.VEHICLE_STATUS_OFFLINE)){
log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device)); log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device));
@ -392,6 +395,17 @@ public class ReceiveController {
if(i>0){ if(i>0){
log.info("【接收onenet推送】异步保存在线状态成功"); log.info("【接收onenet推送】异步保存在线状态成功");
} }
EtOnlineLog etOnlineLog = new EtOnlineLog();
etOnlineLog.setMac(device.getMac());
etOnlineLog.setSn(device.getSn());
etOnlineLog.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE);
etOnlineLog.setLongitude(device.getLongitude());
etOnlineLog.setLatitude(device.getLatitude());
etOnlineLog.setCreateTime(DateUtils.getNowDate());
int i1 = etOnlineLogService.insertEtOnlineLog(etOnlineLog);
if(i1>0){
log.info("【接收onenet推送】异步保存在线日志成功");
}
} }
}, 0, TimeUnit.SECONDS); }, 0, TimeUnit.SECONDS);
} }

View File

@ -0,0 +1,104 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EtOnlineLog;
import com.ruoyi.system.service.IEtOnlineLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 在线/离线日志Controller
*
* @author 邱贞招
* @date 2024-07-13
*/
@RestController
@RequestMapping("/system/onlineLog")
public class EtOnlineLogController extends BaseController
{
@Autowired
private IEtOnlineLogService etOnlineLogService;
/**
* 查询在线/离线日志列表
*/
@PreAuthorize("@ss.hasPermi('system:onlineLog:list')")
@GetMapping("/list")
public TableDataInfo list(EtOnlineLog etOnlineLog)
{
startPage();
List<EtOnlineLog> list = etOnlineLogService.selectEtOnlineLogList(etOnlineLog);
return getDataTable(list);
}
/**
* 导出在线/离线日志列表
*/
@PreAuthorize("@ss.hasPermi('system:onlineLog:export')")
@Log(title = "在线/离线日志", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EtOnlineLog etOnlineLog)
{
List<EtOnlineLog> list = etOnlineLogService.selectEtOnlineLogList(etOnlineLog);
ExcelUtil<EtOnlineLog> util = new ExcelUtil<EtOnlineLog>(EtOnlineLog.class);
util.exportExcel(response, list, "在线/离线日志数据");
}
/**
* 获取在线/离线日志详细信息
*/
@PreAuthorize("@ss.hasPermi('system:onlineLog:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(etOnlineLogService.selectEtOnlineLogById(id));
}
/**
* 新增在线/离线日志
*/
@PreAuthorize("@ss.hasPermi('system:onlineLog:add')")
@Log(title = "在线/离线日志", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EtOnlineLog etOnlineLog)
{
return toAjax(etOnlineLogService.insertEtOnlineLog(etOnlineLog));
}
/**
* 修改在线/离线日志
*/
@PreAuthorize("@ss.hasPermi('system:onlineLog:edit')")
@Log(title = "在线/离线日志", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EtOnlineLog etOnlineLog)
{
return toAjax(etOnlineLogService.updateEtOnlineLog(etOnlineLog));
}
/**
* 删除在线/离线日志
*/
@PreAuthorize("@ss.hasPermi('system:onlineLog:remove')")
@Log(title = "在线/离线日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(etOnlineLogService.deleteEtOnlineLogByIds(ids));
}
}

View File

@ -153,6 +153,10 @@ public class HttpStatus
*/ */
public static final String ERROR_CODE_DEVICE_NOT_ONLINE = "10421"; public static final String ERROR_CODE_DEVICE_NOT_ONLINE = "10421";
/**
* 错误码 请求超时
*/
public static final String ERROR_CODE_TIMEOUT = "10500";
/** /**
* 错误码 新增设备失败设备已存在 * 错误码 新增设备失败设备已存在
*/ */
@ -206,6 +210,10 @@ public class HttpStatus
* 错误码 设备不在线 * 错误码 设备不在线
*/ */
public static final String ERROR_CODE_DEVICE_NOT_ONLINE_MSG = "设备不在线"; public static final String ERROR_CODE_DEVICE_NOT_ONLINE_MSG = "设备不在线";
/**
* 错误码 请求超时
*/
public static final String ERROR_CODE_TIMEOUT_MSG = "请求超时";
/**----------------------------IOT错误码end----------------------------*/ /**----------------------------IOT错误码end----------------------------*/
} }

View File

@ -60,7 +60,7 @@ public class ServiceConstants {
/**----------------------------支付场景end----------------------------*/ /**----------------------------支付场景end----------------------------*/
/**----------------------------订单状态start----------------------------*/ /**----------------------------订单状态start----------------------------*/
/** 订单状态:0-预约中1-取消预约2-开始骑行3-结束 4-订单结束*/ /** 订单状态:0-预约中1-取消预约2-开始骑行3-结束 4-订单结束 5-待审核 6-车辆有损坏 */
/** /**
* 订单状态:0-预约中 * 订单状态:0-预约中
*/ */

View File

@ -150,5 +150,18 @@ public enum BusinessType
* 保存视频 * 保存视频
*/ */
VIDEO, VIDEO,
/**
* 重启设备
*/
REBOOT,
/**
* 绑定
*/
BAND,
/**
* 实名认证
*/
AUTHENTICATION,
} }

View File

@ -37,6 +37,8 @@ public class IotUtil {
return HttpStatus.ERROR_CODE_DEVICE_EVENT_HISTORY_DATA_QUERY_FAIL_MSG; return HttpStatus.ERROR_CODE_DEVICE_EVENT_HISTORY_DATA_QUERY_FAIL_MSG;
}else if(HttpStatus.ERROR_CODE_DEVICE_OPERATE_RECORD_QUERY_FAIL.equals(code)){ }else if(HttpStatus.ERROR_CODE_DEVICE_OPERATE_RECORD_QUERY_FAIL.equals(code)){
return HttpStatus.ERROR_CODE_DEVICE_OPERATE_RECORD_QUERY_FAIL_MSG; return HttpStatus.ERROR_CODE_DEVICE_OPERATE_RECORD_QUERY_FAIL_MSG;
}else if(HttpStatus.ERROR_CODE_TIMEOUT.equals(code)){
return HttpStatus.ERROR_CODE_TIMEOUT_MSG;
} }
return ""; return "";
} }

View File

@ -44,5 +44,20 @@ public class EtCommandLog extends BaseEntity
@Excel(name = "响应") @Excel(name = "响应")
private String result; private String result;
/** 经度 */
@Excel(name = "经度")
private String longitude;
/** 纬度 */
@Excel(name = "纬度")
private String latitude;
/** 回调状态 */
@Excel(name = "回调状态")
private String callStatus;
/** 订单号 */
@Excel(name = "订单号")
private String orderNo;
} }

View File

@ -0,0 +1,44 @@
package com.ruoyi.system.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 在线/离线日志对象 et_online_log
*
* @author 邱贞招
* @date 2024-07-13
*/
@Data
public class EtOnlineLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@Excel(name = "主键")
private Long id;
/** MAC */
@Excel(name = "MAC")
private String mac;
/** SN */
@Excel(name = "SN")
private String sn;
/** 在线状态 */
@Excel(name = "在线状态")
private String onlineStatus;
/** 经度 */
@Excel(name = "经度")
private String longitude;
/** 纬度 */
@Excel(name = "纬度")
private String latitude;
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.EtOnlineLog;
/**
* 在线/离线日志Mapper接口
*
* @author 邱贞招
* @date 2024-07-13
*/
public interface EtOnlineLogMapper
{
/**
* 查询在线/离线日志
*
* @param id 在线/离线日志主键
* @return 在线/离线日志
*/
public EtOnlineLog selectEtOnlineLogById(Long id);
/**
* 查询在线/离线日志列表
*
* @param etOnlineLog 在线/离线日志
* @return 在线/离线日志集合
*/
public List<EtOnlineLog> selectEtOnlineLogList(EtOnlineLog etOnlineLog);
/**
* 新增在线/离线日志
*
* @param etOnlineLog 在线/离线日志
* @return 结果
*/
public int insertEtOnlineLog(EtOnlineLog etOnlineLog);
/**
* 修改在线/离线日志
*
* @param etOnlineLog 在线/离线日志
* @return 结果
*/
public int updateEtOnlineLog(EtOnlineLog etOnlineLog);
/**
* 删除在线/离线日志
*
* @param id 在线/离线日志主键
* @return 结果
*/
public int deleteEtOnlineLogById(Long id);
/**
* 批量删除在线/离线日志
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEtOnlineLogByIds(Long[] ids);
}

View File

@ -151,12 +151,12 @@ public interface IAsDeviceService extends IService<AsDevice>
/** /**
* 发送命令 * 发送命令
*/ */
public void sendCommand(String mac, String token,String command,String type); public void sendCommand(String mac, String token,String command,String type,String orderNo);
/** /**
* 发送命令(带响应) * 发送命令(带响应)
*/ */
public ResponseVo sendCommandWithResp(String mac, String token, String command, String type); public ResponseVo sendCommandWithResp(String mac, String token, String command, String type,String orderNo);
/** /**
* 查询数据点 * 查询数据点

View File

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.EtOnlineLog;
/**
* 在线/离线日志Service接口
*
* @author 邱贞招
* @date 2024-07-13
*/
public interface IEtOnlineLogService
{
/**
* 查询在线/离线日志
*
* @param id 在线/离线日志主键
* @return 在线/离线日志
*/
public EtOnlineLog selectEtOnlineLogById(Long id);
/**
* 查询在线/离线日志列表
*
* @param etOnlineLog 在线/离线日志
* @return 在线/离线日志集合
*/
public List<EtOnlineLog> selectEtOnlineLogList(EtOnlineLog etOnlineLog);
/**
* 新增在线/离线日志
*
* @param etOnlineLog 在线/离线日志
* @return 结果
*/
public int insertEtOnlineLog(EtOnlineLog etOnlineLog);
/**
* 修改在线/离线日志
*
* @param etOnlineLog 在线/离线日志
* @return 结果
*/
public int updateEtOnlineLog(EtOnlineLog etOnlineLog);
/**
* 批量删除在线/离线日志
*
* @param ids 需要删除的在线/离线日志主键集合
* @return 结果
*/
public int deleteEtOnlineLogByIds(Long[] ids);
/**
* 删除在线/离线日志信息
*
* @param id 在线/离线日志主键
* @return 结果
*/
public int deleteEtOnlineLogById(Long id);
}

View File

@ -100,6 +100,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Resource @Resource
private EtCommandLogMapper etCommandLogMapper; private EtCommandLogMapper etCommandLogMapper;
@Autowired
private IEtOnlineLogService etOnlineLogService;
@Value(value = "${iot.iotUrl}") @Value(value = "${iot.iotUrl}")
private String iotUrl; private String iotUrl;
@ -610,9 +613,8 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String finalOrderNo = orderNo; String finalOrderNo = orderNo;
if(!"true".equals(orderVo.getIsBluetooth())){ if(!"true".equals(orderVo.getIsBluetooth())){
/** 2.发送命令*/ /** 2.发送命令*/
ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁"); ResponseVo responseVo = sendCommandWithResp(asDevice.getMac(), token, IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5, "编号开锁", finalOrderNo);
if(responseVo.getCode() != 0){ if(responseVo.getCode() != 0){
// asynchronousUpdateOnlineStatus(asDevice.getMac());
throw new ServiceException("【扫码/编号开锁骑行】发送开锁命令失败"); throw new ServiceException("【扫码/编号开锁骑行】发送开锁命令失败");
} }
}else{ }else{
@ -681,7 +683,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
Boolean execute = transactionTemplate.execute(e -> { Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_20,"管理员开锁"); sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_20,"管理员开锁",null);
asDevice.setIsAdminUnlocking("1"); asDevice.setIsAdminUnlocking("1");
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_SCHEDULING); asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_SCHEDULING);
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
@ -706,7 +708,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
Boolean execute = transactionTemplate.execute(e -> { Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(mac, token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_20,"管理员开锁"); sendCommand(mac, token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_20,"管理员开锁",null);
asDevice.setIsAdminUnlocking("1"); asDevice.setIsAdminUnlocking("1");
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_SCHEDULING); asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_SCHEDULING);
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN); asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_OPEN);
@ -846,14 +848,14 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Transactional @Transactional
@Override @Override
/** 发送命令*/ /** 发送命令*/
public void sendCommand(String mac, String token,String command,String type) { public void sendCommand(String mac, String token,String command,String type,String orderNo) {
String param = "device_name=" + mac + "&product_id=" + productId +"&timeout=" + timeout; String param = "device_name=" + mac + "&product_id=" + productId +"&timeout=" + timeout;
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param; String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param;
String result = HttpUtils.sendPostWithToken(sendUrl, command, token); String result = HttpUtils.sendPostWithToken(sendUrl, command, token);
log.info(""+type+"】===>IOT请求调用结果:【{}】",result); log.info(""+type+"】===>IOT请求调用结果:【{}】",result);
JSONObject paramsObj = JSON.parseObject(result); JSONObject paramsObj = JSON.parseObject(result);
String code = paramsObj.getString("code"); String code = paramsObj.getString("code");
asynchronousSaveLog(sendUrl,command,mac,result,type); asynchronousSaveLog(sendUrl,command,mac,result,type,orderNo);
//记录命令 //记录命令
if (!HttpStatus.IOT_SUCCESS.equals(code)) if (!HttpStatus.IOT_SUCCESS.equals(code))
{ {
@ -875,12 +877,22 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
log.info("【接收onenet推送】异步保存在线状态成功"); log.info("【接收onenet推送】异步保存在线状态成功");
} }
} }
EtOnlineLog etOnlineLog = new EtOnlineLog();
etOnlineLog.setMac(device.getMac());
etOnlineLog.setSn(device.getSn());
etOnlineLog.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_OFFLINE);
etOnlineLog.setLongitude(device.getLongitude());
etOnlineLog.setLatitude(device.getLatitude());
etOnlineLog.setCreateTime(DateUtils.getNowDate());
int i1 = etOnlineLogService.insertEtOnlineLog(etOnlineLog);
if(i1>0){
log.info("【接收onenet推送】异步保存在线日志成功");
}
}, 0, TimeUnit.SECONDS); }, 0, TimeUnit.SECONDS);
} }
/* 异步保存发送命令日志*/ /* 异步保存发送命令日志*/
private void asynchronousSaveLog(String url,String command,String mac,String result,String type) { private void asynchronousSaveLog(String url,String command,String mac,String result,String type,String orderNo) {
//异步保存发送命令日志 //异步保存发送命令日志
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
EtCommandLog etCommandLog = new EtCommandLog(); EtCommandLog etCommandLog = new EtCommandLog();
@ -888,9 +900,16 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
etCommandLog.setCommand(command); etCommandLog.setCommand(command);
etCommandLog.setType(type); etCommandLog.setType(type);
etCommandLog.setMac(mac); etCommandLog.setMac(mac);
etCommandLog.setSn(asDeviceMapper.selectAsDeviceByMac(mac).getSn()); AsDevice device = asDeviceMapper.selectAsDeviceByMac(mac);
etCommandLog.setSn(device.getSn());
etCommandLog.setResult(result); etCommandLog.setResult(result);
etCommandLog.setLongitude(device.getLongitude());
etCommandLog.setLatitude(device.getLatitude());
etCommandLog.setCreateTime(DateUtils.getNowDate()); etCommandLog.setCreateTime(DateUtils.getNowDate());
JSONObject paramsObj = JSON.parseObject(result);
String code = paramsObj.getString("code");
etCommandLog.setCallStatus(code);
etCommandLog.setOrderNo(orderNo);
int i = etCommandLogMapper.insertEtCommandLog(etCommandLog); int i = etCommandLogMapper.insertEtCommandLog(etCommandLog);
if(i>0){ if(i>0){
log.info("【发送命令】异步保存发送命令日志"); log.info("【发送命令】异步保存发送命令日志");
@ -900,7 +919,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override @Override
/** 发送命令*/ /** 发送命令*/
public ResponseVo sendCommandWithResp(String mac, String token,String command,String type) { public ResponseVo sendCommandWithResp(String mac, String token,String command,String type,String orderNo) {
String param = "device_name=" + mac + "&product_id=" + productId +"&timeout=" + timeout; String param = "device_name=" + mac + "&product_id=" + productId +"&timeout=" + timeout;
String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param; String sendUrl = iotUrl+ IotConstants.ADDS_COMMAND + "?"+param;
String result = HttpUtils.sendPostWithToken(sendUrl, command, token); String result = HttpUtils.sendPostWithToken(sendUrl, command, token);
@ -909,7 +928,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(responseVo.getCode() != 0){ if(responseVo.getCode() != 0){
asynchronousUpdateOnlineStatus(mac); asynchronousUpdateOnlineStatus(mac);
} }
asynchronousSaveLog(sendUrl,command,mac,result,type); asynchronousSaveLog(sendUrl,command,mac,result,type,orderNo);
return JSON.parseObject(result,ResponseVo.class); return JSON.parseObject(result,ResponseVo.class);
} }
@ -936,7 +955,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
Boolean execute = transactionTemplate.execute(e -> { Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY1,"响铃寻车"); sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY1,"响铃寻车",null);
return Boolean.TRUE; return Boolean.TRUE;
}); });
if(!execute)throw new ServiceException("响铃寻车失败"); if(!execute)throw new ServiceException("响铃寻车失败");
@ -956,7 +975,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
Boolean execute = transactionTemplate.execute(e -> { Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY1,"重启设备"); sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_PLAY1,"重启设备",null);
return Boolean.TRUE; return Boolean.TRUE;
}); });
if(!execute)throw new ServiceException("重启设备失败"); if(!execute)throw new ServiceException("重启设备失败");
@ -975,7 +994,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
Boolean execute = transactionTemplate.execute(e -> { Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(mac, token,IotConstants.COMMAND_REBOOT,"重启设备"); sendCommand(mac, token,IotConstants.COMMAND_REBOOT,"重启设备",null);
return Boolean.TRUE; return Boolean.TRUE;
}); });
if(!execute)throw new ServiceException("重启设备失败"); if(!execute)throw new ServiceException("重启设备失败");
@ -994,7 +1013,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
Boolean execute = transactionTemplate.execute(e -> { Boolean execute = transactionTemplate.execute(e -> {
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(mac, token,IotConstants.COMMAND_PLAY1,"响铃寻车"); sendCommand(mac, token,IotConstants.COMMAND_PLAY1,"响铃寻车",null);
return Boolean.TRUE; return Boolean.TRUE;
}); });
if(!execute)throw new ServiceException("响铃寻车失败"); if(!execute)throw new ServiceException("响铃寻车失败");
@ -1019,7 +1038,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String token = Token.getToken(); String token = Token.getToken();
if(!"true".equals(isBluetooth)){ if(!"true".equals(isBluetooth)){
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_LLOSE+IotConstants.COMMAND_FREQUENCY_3600,"临时锁车"); sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_LLOSE+IotConstants.COMMAND_FREQUENCY_3600,"临时锁车",orderNo);
}else{ }else{
asDevice.setLongitude(lon); asDevice.setLongitude(lon);
asDevice.setLatitude(lat); asDevice.setLatitude(lat);
@ -1056,8 +1075,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空"); if(StrUtil.isBlank(sn))throw new ServiceException("sn不能为空");
AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn); AsDevice asDevice = asDeviceMapper.selectAsDeviceBySn(sn);
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车"); sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车",null);
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
asDevice.setIsAdminUnlocking("0"); asDevice.setIsAdminUnlocking("0");
int device = asDeviceMapper.updateAsDevice(asDevice); int device = asDeviceMapper.updateAsDevice(asDevice);
if(device==0){ if(device==0){
@ -1079,8 +1099,9 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(StrUtil.isBlank(mac))throw new ServiceException("mac不能为空"); if(StrUtil.isBlank(mac))throw new ServiceException("mac不能为空");
AsDevice asDevice = asDeviceMapper.selectAsDeviceByMac(mac); AsDevice asDevice = asDeviceMapper.selectAsDeviceByMac(mac);
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车"); sendCommand(asDevice.getMac(), Token.getToken(),IotConstants.COMMAND_CLOSE+IotConstants.COMMAND_FREQUENCY_3600,"管理员锁车",null);
asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);
asDevice.setIsAdminUnlocking("0"); asDevice.setIsAdminUnlocking("0");
int device = asDeviceMapper.updateAsDevice(asDevice); int device = asDeviceMapper.updateAsDevice(asDevice);
if(device==0){ if(device==0){
@ -1108,7 +1129,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
String finalSn = sn; String finalSn = sn;
if(!"true".equals(isBluetooth)){ if(!"true".equals(isBluetooth)){
/** 2.发送命令*/ /** 2.发送命令*/
sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5,"临时解锁"); sendCommand(asDevice.getMac(), token,IotConstants.COMMAND_OPEN+IotConstants.COMMAND_FREQUENCY_5,"临时解锁",orderNo);
}else{ }else{
asDevice.setLongitude(lon); asDevice.setLongitude(lon);
asDevice.setLatitude(lat); asDevice.setLatitude(lat);
@ -1320,7 +1341,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
if(ServiceConstants.RETURN_TYPE_NORMAL.equals(returnType)){ if(ServiceConstants.RETURN_TYPE_NORMAL.equals(returnType)){
if(!"true".equals(isBluetooth)){ if(!"true".equals(isBluetooth)){
/** 2. 车辆远程关锁*/ /** 2. 车辆远程关锁*/
ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "还车关锁"); ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "还车关锁",orderNo);
if(responseVo.getCode()!=0){ if(responseVo.getCode()!=0){
log.info("【还车关锁】远程关锁失败"); log.info("【还车关锁】远程关锁失败");
throw new ServiceException("远程关锁失败"); throw new ServiceException("远程关锁失败");
@ -1344,7 +1365,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
device.setLastTime(DateUtils.getNowDate()); device.setLastTime(DateUtils.getNowDate());
} }
}else{ }else{
ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "还车关锁"); ResponseVo responseVo = sendCommandWithResp(device.getMac(), token, IotConstants.COMMAND_CLOSE + IotConstants.COMMAND_FREQUENCY_3600, "辅助还车关锁",orderNo);
if(responseVo.getCode()!=0){ if(responseVo.getCode()!=0){
log.info("【还车关锁】远程关锁失败"); log.info("【还车关锁】远程关锁失败");
} }
@ -1876,7 +1897,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
@Override @Override
public boolean isOnline(String sn) { public boolean isOnline(String sn) {
AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn);
ResponseVo responseVo = sendCommandWithResp(device.getMac(), Token.getToken(), "111", "是否在线"); ResponseVo responseVo = sendCommandWithResp(device.getMac(), Token.getToken(), "111", "是否在线",null);
if(responseVo.getCode() == 0){ if(responseVo.getCode() == 0){
return true; return true;
} }

View File

@ -137,7 +137,7 @@ public class EtModelServiceImpl implements IEtModelService
Integer quantityByPercentage = CommonUtil.getElectricQuantityByPercentage(lowBatteryReminder, etModel.getFullVoltage(), etModel.getLowVoltage()); Integer quantityByPercentage = CommonUtil.getElectricQuantityByPercentage(lowBatteryReminder, etModel.getFullVoltage(), etModel.getLowVoltage());
String lowVoltageCommand = IotConstants.COMMAND_BAT + quantityByPercentage * 10 + "@"; String lowVoltageCommand = IotConstants.COMMAND_BAT + quantityByPercentage * 10 + "@";
log.info("发送低电压命令:" + lowVoltageCommand); log.info("发送低电压命令:" + lowVoltageCommand);
asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报"); asDeviceService.sendCommand(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报",null);
} }
} }
return i; return i;
@ -173,7 +173,7 @@ public class EtModelServiceImpl implements IEtModelService
Integer quantityByPercentage = CommonUtil.getElectricQuantityByPercentage(lowBatteryReminder, etModel.getFullVoltage(), etModel.getLowVoltage()); Integer quantityByPercentage = CommonUtil.getElectricQuantityByPercentage(lowBatteryReminder, etModel.getFullVoltage(), etModel.getLowVoltage());
String lowVoltageCommand = IotConstants.COMMAND_BAT + quantityByPercentage * 10 + "@"; String lowVoltageCommand = IotConstants.COMMAND_BAT + quantityByPercentage * 10 + "@";
log.info("发送低电压命令:" + lowVoltageCommand); log.info("发送低电压命令:" + lowVoltageCommand);
ResponseVo responseVo = asDeviceService.sendCommandWithResp(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报"); ResponseVo responseVo = asDeviceService.sendCommandWithResp(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报",null);
if(responseVo.getCode()!=0){ if(responseVo.getCode()!=0){
log.info("【还车关锁】设备【{}】远程关锁失败", asDevice.getMac()); log.info("【还车关锁】设备【{}】远程关锁失败", asDevice.getMac());
} }

View File

@ -0,0 +1,95 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EtOnlineLogMapper;
import com.ruoyi.system.domain.EtOnlineLog;
import com.ruoyi.system.service.IEtOnlineLogService;
/**
* 在线/离线日志Service业务层处理
*
* @author 邱贞招
* @date 2024-07-13
*/
@Service
public class EtOnlineLogServiceImpl implements IEtOnlineLogService
{
@Autowired
private EtOnlineLogMapper etOnlineLogMapper;
/**
* 查询在线/离线日志
*
* @param id 在线/离线日志主键
* @return 在线/离线日志
*/
@Override
public EtOnlineLog selectEtOnlineLogById(Long id)
{
return etOnlineLogMapper.selectEtOnlineLogById(id);
}
/**
* 查询在线/离线日志列表
*
* @param etOnlineLog 在线/离线日志
* @return 在线/离线日志
*/
@Override
public List<EtOnlineLog> selectEtOnlineLogList(EtOnlineLog etOnlineLog)
{
return etOnlineLogMapper.selectEtOnlineLogList(etOnlineLog);
}
/**
* 新增在线/离线日志
*
* @param etOnlineLog 在线/离线日志
* @return 结果
*/
@Override
public int insertEtOnlineLog(EtOnlineLog etOnlineLog)
{
etOnlineLog.setCreateTime(DateUtils.getNowDate());
return etOnlineLogMapper.insertEtOnlineLog(etOnlineLog);
}
/**
* 修改在线/离线日志
*
* @param etOnlineLog 在线/离线日志
* @return 结果
*/
@Override
public int updateEtOnlineLog(EtOnlineLog etOnlineLog)
{
return etOnlineLogMapper.updateEtOnlineLog(etOnlineLog);
}
/**
* 批量删除在线/离线日志
*
* @param ids 需要删除的在线/离线日志主键
* @return 结果
*/
@Override
public int deleteEtOnlineLogByIds(Long[] ids)
{
return etOnlineLogMapper.deleteEtOnlineLogByIds(ids);
}
/**
* 删除在线/离线日志信息
*
* @param id 在线/离线日志主键
* @return 结果
*/
@Override
public int deleteEtOnlineLogById(Long id)
{
return etOnlineLogMapper.deleteEtOnlineLogById(id);
}
}

View File

@ -12,11 +12,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="mac" column="mac" /> <result property="mac" column="mac" />
<result property="sn" column="sn" /> <result property="sn" column="sn" />
<result property="result" column="result" /> <result property="result" column="result" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="callStatus" column="call_status" />
<result property="orderNo" column="order_no" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectEtCommandLogVo"> <sql id="selectEtCommandLogVo">
select id, url, command, type, mac, sn, result, create_time from et_command_log select id, url, command, type, mac, sn, result, longitude, latitude, call_status, create_time, order_no from et_command_log
</sql> </sql>
<select id="selectEtCommandLogList" parameterType="EtCommandLog" resultMap="EtCommandLogResult"> <select id="selectEtCommandLogList" parameterType="EtCommandLog" resultMap="EtCommandLogResult">
@ -28,6 +32,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="sn != null and sn != ''"> and sn like concat('%', #{sn}, '%')</if> <if test="sn != null and sn != ''"> and sn like concat('%', #{sn}, '%')</if>
<if test="type != null and type != ''"> and type like concat('%', #{type}, '%')</if> <if test="type != null and type != ''"> and type like concat('%', #{type}, '%')</if>
<if test="result != null and result != ''"> and result like concat('%', #{result}, '%')</if> <if test="result != null and result != ''"> and result like concat('%', #{result}, '%')</if>
<if test="orderNo != null and orderNo != ''"> and order_no like concat('%', #{orderNo}, '%')</if>
<if test="callStatus != null and callStatus != ''"> and call_status = #{callStatus}</if>
</where> </where>
order by create_time desc order by create_time desc
</select> </select>
@ -46,6 +52,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mac != null">mac,</if> <if test="mac != null">mac,</if>
<if test="sn != null">sn,</if> <if test="sn != null">sn,</if>
<if test="result != null">result,</if> <if test="result != null">result,</if>
<if test="latitude != null">latitude,</if>
<if test="longitude != null">longitude,</if>
<if test="callStatus != null">call_status,</if>
<if test="orderNo != null">order_no,</if>
create_time create_time
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -55,6 +65,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mac != null">#{mac},</if> <if test="mac != null">#{mac},</if>
<if test="sn != null">#{sn},</if> <if test="sn != null">#{sn},</if>
<if test="result != null">#{result},</if> <if test="result != null">#{result},</if>
<if test="latitude != null">#{latitude},</if>
<if test="longitude != null">#{longitude},</if>
<if test="callStatus != null">#{callStatus},</if>
<if test="orderNo != null">#{orderNo},</if>
sysdate() sysdate()
</trim> </trim>
</insert> </insert>
@ -68,6 +82,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mac != null">mac = #{mac},</if> <if test="mac != null">mac = #{mac},</if>
<if test="sn != null">sn = #{sn},</if> <if test="sn != null">sn = #{sn},</if>
<if test="result != null">result = #{result},</if> <if test="result != null">result = #{result},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="callStatus != null">call_status = #{callStatus},</if>
<if test="orderNo != null">order_no = #{orderNo},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@ -0,0 +1,78 @@
<?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">
<mapper namespace="com.ruoyi.system.mapper.EtOnlineLogMapper">
<resultMap type="EtOnlineLog" id="EtOnlineLogResult">
<result property="id" column="id" />
<result property="mac" column="mac" />
<result property="sn" column="sn" />
<result property="onlineStatus" column="online_status" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectEtOnlineLogVo">
select id, mac, sn, online_status, longitude, latitude, create_time from et_online_log
</sql>
<select id="selectEtOnlineLogList" parameterType="EtOnlineLog" resultMap="EtOnlineLogResult">
<include refid="selectEtOnlineLogVo"/>
<where>
<if test="mac != null and mac != ''"> and mac like concat('%', #{mac}, '%')</if>
<if test="sn != null and sn != ''"> and sn like concat('%', #{sn}, '%')</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
</where>
</select>
<select id="selectEtOnlineLogById" parameterType="Long" resultMap="EtOnlineLogResult">
<include refid="selectEtOnlineLogVo"/>
where id = #{id}
</select>
<insert id="insertEtOnlineLog" parameterType="EtOnlineLog" useGeneratedKeys="true" keyProperty="id">
insert into et_online_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="mac != null">mac,</if>
<if test="sn != null">sn,</if>
<if test="onlineStatus != null">online_status,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mac != null">#{mac},</if>
<if test="sn != null">#{sn},</if>
<if test="onlineStatus != null">#{onlineStatus},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateEtOnlineLog" parameterType="EtOnlineLog">
update et_online_log
<trim prefix="SET" suffixOverrides=",">
<if test="mac != null">mac = #{mac},</if>
<if test="sn != null">sn = #{sn},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEtOnlineLogById" parameterType="Long">
delete from et_online_log where id = #{id}
</delete>
<delete id="deleteEtOnlineLogByIds" parameterType="String">
delete from et_online_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -37,8 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult"> <select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/> <include refid="selectOperLogVo"/>
<where> <where>
<if test="operIp != null and operIp != ''"> <if test="operParam != null and operParam != ''">
AND oper_ip like concat('%', #{operIp}, '%') AND oper_param like concat('%', #{operParam}, '%')
</if> </if>
<if test="title != null and title != ''"> <if test="title != null and title != ''">
AND title like concat('%', #{title}, '%') AND title like concat('%', #{title}, '%')