1. 定位日志
2. 低电量警报开关
This commit is contained in:
parent
8bc7c4c95d
commit
fb772973e0
|
@ -251,7 +251,7 @@ public class AppController extends BaseController
|
||||||
@GetMapping("/fee/list")
|
@GetMapping("/fee/list")
|
||||||
public AjaxResult feeList(EtFeeRule etFeeRule)
|
public AjaxResult feeList(EtFeeRule etFeeRule)
|
||||||
{
|
{
|
||||||
List<EtFeeRule> list = etFeeRuleService.selectRuleInfoListByModelId(etFeeRule.getModelId());
|
List<EtFeeRule> list = etFeeRuleService.selectEtFeeRuleListByAreaId(etFeeRule.getAreaId());
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
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.EtLocationLog;
|
||||||
|
import com.ruoyi.system.service.IEtLocationLogService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定位日志Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2024-09-12
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/locationLog")
|
||||||
|
public class EtLocationLogController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IEtLocationLogService etLocationLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询定位日志列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:locationLog:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(EtLocationLog etLocationLog)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<EtLocationLog> list = etLocationLogService.selectEtLocationLogList(etLocationLog);
|
||||||
|
etLocationLogService.analytic(list);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出定位日志列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:locationLog:export')")
|
||||||
|
@Log(title = "定位日志", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, EtLocationLog etLocationLog)
|
||||||
|
{
|
||||||
|
List<EtLocationLog> list = etLocationLogService.selectEtLocationLogList(etLocationLog);
|
||||||
|
ExcelUtil<EtLocationLog> util = new ExcelUtil<EtLocationLog>(EtLocationLog.class);
|
||||||
|
util.exportExcel(response, list, "定位日志数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取定位日志详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:locationLog:query')")
|
||||||
|
@GetMapping(value = "/{locationId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("locationId") Long locationId)
|
||||||
|
{
|
||||||
|
return success(etLocationLogService.selectEtLocationLogByLocationId(locationId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增定位日志
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:locationLog:add')")
|
||||||
|
@Log(title = "定位日志", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody EtLocationLog etLocationLog)
|
||||||
|
{
|
||||||
|
return toAjax(etLocationLogService.insertEtLocationLog(etLocationLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改定位日志
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:locationLog:edit')")
|
||||||
|
@Log(title = "定位日志", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody EtLocationLog etLocationLog)
|
||||||
|
{
|
||||||
|
return toAjax(etLocationLogService.updateEtLocationLog(etLocationLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除定位日志
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:locationLog:remove')")
|
||||||
|
@Log(title = "定位日志", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{locationIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] locationIds)
|
||||||
|
{
|
||||||
|
return toAjax(etLocationLogService.deleteEtLocationLogByLocationIds(locationIds));
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ public class LocationVo {
|
||||||
|
|
||||||
private String lat;//纬度
|
private String lat;//纬度
|
||||||
|
|
||||||
private Integer status;//电动车状态 0断电,1上电运行 2轮动抱死 3超出区域断电(远程下发了qlose)
|
private Integer status;//电动车状态 0断电,1上电运行 2轮动抱死 3超出区域断电(远程下发了qlose) 解析参数
|
||||||
|
|
||||||
private Integer bat;//电池电压 "bat":571 ==> 57.1V
|
private Integer bat;//电池电压 "bat":571 ==> 57.1V
|
||||||
|
|
||||||
|
|
|
@ -44,4 +44,25 @@ public class AccessTokenUtil {
|
||||||
Long expirationTime = tokenExpirationTimes.get(cacheKey);
|
Long expirationTime = tokenExpirationTimes.get(cacheKey);
|
||||||
return expirationTime == null || System.currentTimeMillis() > expirationTime;
|
return expirationTime == null || System.currentTimeMillis() > expirationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强制刷新token
|
||||||
|
* */
|
||||||
|
@SneakyThrows
|
||||||
|
public static String getForceRefreshToken(String appid, String appsecret) {
|
||||||
|
String cacheKey = appid + ":" + appsecret;
|
||||||
|
log.info("强制获取token");
|
||||||
|
WxMaService wxMaService = new WxMaServiceImpl();
|
||||||
|
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
|
||||||
|
config.setAppid(appid);
|
||||||
|
config.setSecret(appsecret);
|
||||||
|
wxMaService.setWxMaConfig(config);
|
||||||
|
String accessToken = wxMaService.getAccessToken(true);
|
||||||
|
|
||||||
|
// 更新缓存
|
||||||
|
cachedTokens.put(cacheKey, accessToken);
|
||||||
|
tokenExpirationTimes.put(cacheKey, System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(3600L));
|
||||||
|
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class LogAspect
|
||||||
@Before(value = "@annotation(controllerLog)")
|
@Before(value = "@annotation(controllerLog)")
|
||||||
public void boBefore(JoinPoint joinPoint, Log controllerLog)
|
public void boBefore(JoinPoint joinPoint, Log controllerLog)
|
||||||
{
|
{
|
||||||
|
log.info("设置TIME_THREADLOCAL时间");
|
||||||
TIME_THREADLOCAL.set(System.currentTimeMillis());
|
TIME_THREADLOCAL.set(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +118,13 @@ public class LogAspect
|
||||||
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
|
||||||
// 处理设置注解上的参数
|
// 处理设置注解上的参数
|
||||||
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
|
||||||
// 设置消耗时间
|
Long startTime = TIME_THREADLOCAL.get();
|
||||||
operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
|
if (startTime != null) {
|
||||||
|
operLog.setCostTime(System.currentTimeMillis() - startTime);
|
||||||
|
} else {
|
||||||
|
log.warn("TIME_THREADLOCAL为空,无法设置消耗时间。");
|
||||||
|
operLog.setCostTime(0L); // 你可以设置为0或其他合适的默认值
|
||||||
|
}
|
||||||
// 保存数据库
|
// 保存数据库
|
||||||
AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
|
AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,12 @@ public class SysLoginService
|
||||||
String post = HttpUtils.sendPost(url,jsonObject.toString());
|
String post = HttpUtils.sendPost(url,jsonObject.toString());
|
||||||
|
|
||||||
JSONObject jsonObject1 = JSONObject.parseObject(post);
|
JSONObject jsonObject1 = JSONObject.parseObject(post);
|
||||||
|
if(jsonObject1.getInteger("errcode")!=0){// 如果token无效则重新获取一次最新的token
|
||||||
|
token = AccessTokenUtil.getForceRefreshToken(dept.getAppid(), dept.getAppSecret());
|
||||||
|
url = url+token;
|
||||||
|
post = HttpUtils.sendPost(url,jsonObject.toString());
|
||||||
|
jsonObject1 = JSONObject.parseObject(post);
|
||||||
|
}
|
||||||
String phoneInfo = jsonObject1.getString("phone_info");
|
String phoneInfo = jsonObject1.getString("phone_info");
|
||||||
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = JSONObject.parseObject(phoneInfo, WxMaPhoneNumberInfo.class);
|
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = JSONObject.parseObject(phoneInfo, WxMaPhoneNumberInfo.class);
|
||||||
if(StringUtils.isEmpty(wxMaPhoneNumberInfo.getPhoneNumber())){
|
if(StringUtils.isEmpty(wxMaPhoneNumberInfo.getPhoneNumber())){
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package com.ruoyi.system.domain;
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
import com.ruoyi.common.constant.ServiceConstants;
|
|
||||||
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.annotation.Excel;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -50,4 +47,19 @@ public class EtLocationLog extends BaseEntity
|
||||||
@Excel(name = "锁状态")
|
@Excel(name = "锁状态")
|
||||||
private String lockStatus;
|
private String lockStatus;
|
||||||
|
|
||||||
|
@Excel(name = "电动车状态")
|
||||||
|
private Integer status2;//电动车状态 0断电,1上电运行 2轮动抱死 3超出区域断电(远程下发了qlose) 解析参数
|
||||||
|
|
||||||
|
@Excel(name = "电池电压")
|
||||||
|
private Integer bat;//电池电压 "bat":571 ==> 57.1V
|
||||||
|
|
||||||
|
@Excel(name = "信号强度")
|
||||||
|
private Integer csq;//信号强度
|
||||||
|
|
||||||
|
@Excel(name = "卫星数量")
|
||||||
|
private Integer s;//卫星数量
|
||||||
|
|
||||||
|
@Excel(name = "钥匙")
|
||||||
|
private Integer q;//钥匙
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,10 @@ public class EtModel extends BaseEntity
|
||||||
@Excel(name = "骑行低电量提醒")
|
@Excel(name = "骑行低电量提醒")
|
||||||
private Integer lowBatteryReminder;
|
private Integer lowBatteryReminder;
|
||||||
|
|
||||||
|
/** 骑行低电量提醒开关 */
|
||||||
|
@Excel(name = "骑行低电量提醒开关")
|
||||||
|
private Boolean lowBatteryReminderSwitch;
|
||||||
|
|
||||||
/** 已投放车辆数 */
|
/** 已投放车辆数 */
|
||||||
private Integer deviceNum;
|
private Integer deviceNum;
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,10 @@ public class EtOrder extends BaseEntity
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<EtRefund> etRefunds;
|
private List<EtRefund> etRefunds;
|
||||||
|
|
||||||
|
/** 总退款金额 */
|
||||||
|
@TableField(exist = false)
|
||||||
|
private BigDecimal totalRefundFee;
|
||||||
|
|
||||||
/** 设备sn编码 */
|
/** 设备sn编码 */
|
||||||
@Excel(name = "设备sn编码")
|
@Excel(name = "设备sn编码")
|
||||||
private String sn;
|
private String sn;
|
||||||
|
@ -348,4 +352,7 @@ public class EtOrder extends BaseEntity
|
||||||
@Excel(name = "可退停车点外调度费退款")
|
@Excel(name = "可退停车点外调度费退款")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private BigDecimal refundableManageFee;
|
private BigDecimal refundableManageFee;
|
||||||
|
|
||||||
|
@Excel(name = "描述")
|
||||||
|
private String description;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,4 +58,12 @@ public interface IEtLocationLogService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteEtLocationLogByLocationId(Long locationId);
|
public int deleteEtLocationLogByLocationId(Long locationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析参数
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public List<EtLocationLog> analytic(List<EtLocationLog> list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.system.mapper.EtLocationLogMapper;
|
import com.ruoyi.system.mapper.EtLocationLogMapper;
|
||||||
import com.ruoyi.system.domain.EtLocationLog;
|
import com.ruoyi.system.domain.EtLocationLog;
|
||||||
import com.ruoyi.system.service.IEtLocationLogService;
|
import com.ruoyi.system.service.IEtLocationLogService;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定位日志Service业务层处理
|
* 定位日志Service业务层处理
|
||||||
*
|
*
|
||||||
|
@ -17,7 +21,7 @@ import com.ruoyi.system.service.IEtLocationLogService;
|
||||||
@Service
|
@Service
|
||||||
public class EtLocationLogServiceImpl implements IEtLocationLogService
|
public class EtLocationLogServiceImpl implements IEtLocationLogService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Resource
|
||||||
private EtLocationLogMapper etLocationLogMapper;
|
private EtLocationLogMapper etLocationLogMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,4 +96,51 @@ public class EtLocationLogServiceImpl implements IEtLocationLogService
|
||||||
{
|
{
|
||||||
return etLocationLogMapper.deleteEtLocationLogByLocationId(locationId);
|
return etLocationLogMapper.deleteEtLocationLogByLocationId(locationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析参数
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EtLocationLog> analytic(List<EtLocationLog> list) {
|
||||||
|
// 创建 ObjectMapper 实例用于解析 JSON
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
for (EtLocationLog log : list) {
|
||||||
|
try {
|
||||||
|
// 解析 onenetMsg 字段中的 JSON 字符串
|
||||||
|
JsonNode rootNode = objectMapper.readTree(log.getOnenetMsg());
|
||||||
|
JsonNode valueNode = rootNode.path("value");
|
||||||
|
|
||||||
|
// 提取各个字段的值并填充到 EtLocationLog 对象中
|
||||||
|
if (valueNode.has("status")) {
|
||||||
|
log.setStatus2(valueNode.get("status").asInt());
|
||||||
|
}
|
||||||
|
if (valueNode.has("bat")) {
|
||||||
|
// 电池电压,例如 bat: 511 表示 51.1V
|
||||||
|
log.setBat(valueNode.get("bat").asInt());
|
||||||
|
}
|
||||||
|
if (valueNode.has("csq")) {
|
||||||
|
// 信号强度
|
||||||
|
log.setCsq(valueNode.get("csq").asInt());
|
||||||
|
}
|
||||||
|
if (valueNode.has("s")) {
|
||||||
|
// 卫星数量
|
||||||
|
log.setS(valueNode.get("s").asInt());
|
||||||
|
}
|
||||||
|
if (valueNode.has("q")) {
|
||||||
|
// 钥匙状态
|
||||||
|
log.setQ(valueNode.get("q").asInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 捕获并打印解析异常信息
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.IotConstants;
|
import com.ruoyi.common.constant.IotConstants;
|
||||||
|
import com.ruoyi.common.constant.ServiceConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.utils.CommonUtil;
|
import com.ruoyi.common.utils.CommonUtil;
|
||||||
|
@ -10,10 +12,7 @@ import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.onenet.ResponseVo;
|
import com.ruoyi.common.utils.onenet.ResponseVo;
|
||||||
import com.ruoyi.common.utils.onenet.Token;
|
import com.ruoyi.common.utils.onenet.Token;
|
||||||
import com.ruoyi.system.domain.AsDevice;
|
import com.ruoyi.system.domain.*;
|
||||||
import com.ruoyi.system.domain.EtModel;
|
|
||||||
import com.ruoyi.system.domain.EtModelRule;
|
|
||||||
import com.ruoyi.system.domain.EtOperatingArea;
|
|
||||||
import com.ruoyi.system.mapper.AsDeviceMapper;
|
import com.ruoyi.system.mapper.AsDeviceMapper;
|
||||||
import com.ruoyi.system.mapper.EtModelMapper;
|
import com.ruoyi.system.mapper.EtModelMapper;
|
||||||
import com.ruoyi.system.mapper.EtModelRuleMapper;
|
import com.ruoyi.system.mapper.EtModelRuleMapper;
|
||||||
|
@ -28,7 +27,12 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆型号Service业务层处理
|
* 车辆型号Service业务层处理
|
||||||
|
@ -55,6 +59,12 @@ public class EtModelServiceImpl implements IEtModelService
|
||||||
@Resource
|
@Resource
|
||||||
private EtModelRuleMapper etModelRuleMapper;
|
private EtModelRuleMapper etModelRuleMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AsDeviceMapper asDeviceMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆型号
|
* 查询车辆型号
|
||||||
|
@ -128,6 +138,10 @@ public class EtModelServiceImpl implements IEtModelService
|
||||||
etModelRuleMapper.insert(EtModelRule.builder().modelId(etModel.getModelId()).ruleId(ruleId).build());
|
etModelRuleMapper.insert(EtModelRule.builder().modelId(etModel.getModelId()).ruleId(ruleId).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Java报错:No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
|
||||||
|
if(!etModel.getLowBatteryReminderSwitch()){// 提醒关闭时,发送低电压命令 为0
|
||||||
|
asynchronousSendCommand(etModel.getModelId());
|
||||||
|
}
|
||||||
|
|
||||||
// // 发送设置低电压命令
|
// // 发送设置低电压命令
|
||||||
// Integer lowBatteryReminder = etModel.getLowBatteryReminder();
|
// Integer lowBatteryReminder = etModel.getLowBatteryReminder();
|
||||||
|
@ -174,6 +188,9 @@ public class EtModelServiceImpl implements IEtModelService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!etModel.getLowBatteryReminderSwitch()){// 提醒关闭时,发送低电压命令 为0
|
||||||
|
asynchronousSendCommand(etModel.getModelId());
|
||||||
|
}
|
||||||
// 发送设置低电压命令
|
// 发送设置低电压命令
|
||||||
// Integer lowBatteryReminder = etModel.getLowBatteryReminder();
|
// Integer lowBatteryReminder = etModel.getLowBatteryReminder();
|
||||||
// if(ObjectUtil.isNotNull(lowBatteryReminder) && lowBatteryReminder > 0){
|
// if(ObjectUtil.isNotNull(lowBatteryReminder) && lowBatteryReminder > 0){
|
||||||
|
@ -194,6 +211,36 @@ public class EtModelServiceImpl implements IEtModelService
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步发送低电压命令
|
||||||
|
*/
|
||||||
|
private void asynchronousSendCommand(Long modelId) {
|
||||||
|
//开异步线程:
|
||||||
|
scheduledExecutorService.schedule(() -> {
|
||||||
|
AsDevice device = new AsDevice();
|
||||||
|
device.setModelId(modelId);
|
||||||
|
List<AsDevice> asDevices = asDeviceMapper.selectAsDeviceList(device);
|
||||||
|
for(AsDevice asDevice: asDevices){
|
||||||
|
// 根据百分比计算提醒电压值
|
||||||
|
String lowVoltageCommand = IotConstants.COMMAND_BAT + 0 + "@";
|
||||||
|
log.info("发送低电压命令:" + lowVoltageCommand);
|
||||||
|
ResponseVo responseVo = null;
|
||||||
|
try {
|
||||||
|
responseVo = asDeviceService.sendCommandWithResp(asDevice.getMac(), Token.getToken(), lowVoltageCommand,"发送低电压播报",null);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvalidKeyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if(responseVo.getCode()!=0){
|
||||||
|
log.info("【还车关锁】设备【{}】远程关锁失败", asDevice.getMac());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除车辆型号
|
* 批量删除车辆型号
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.IotConstants;
|
import com.ruoyi.common.constant.IotConstants;
|
||||||
|
@ -141,6 +142,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
AsDevice device = asDeviceMapper.selectAsDeviceBySn(order.getSn());
|
||||||
order.setDevice(device);
|
order.setDevice(device);
|
||||||
EtFeeRule etFeeRule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
|
EtFeeRule etFeeRule = etFeeRuleService.selectEtFeeRuleByRuleIdIncludeDelete(order.getRuleId());
|
||||||
|
setDescription(order);
|
||||||
String endTime;
|
String endTime;
|
||||||
if(ObjectUtil.isNull(order.getReturnTime())){
|
if(ObjectUtil.isNull(order.getReturnTime())){
|
||||||
endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getNowDate());
|
endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getNowDate());
|
||||||
|
@ -166,6 +168,24 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDescription(EtOrder order) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String ridingRuleJson = order.getRidingRuleJson();
|
||||||
|
String unit = "";
|
||||||
|
if(order.getRidingRule() != null && order.getRidingRule().equals("1")){
|
||||||
|
StartingRuleVo startingRule = JSONObject.parseObject(ridingRuleJson, StartingRuleVo.class);
|
||||||
|
String rentalUnit = order.getRentalUnit();
|
||||||
|
if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_MINUTES)){
|
||||||
|
unit = "分钟";
|
||||||
|
}else if(rentalUnit.equals(ServiceConstants.RENTAL_UNIT_HOURS)){
|
||||||
|
unit = "小时";
|
||||||
|
}
|
||||||
|
sb.append("起步价:"+startingRule.getStartingPrice()+"元(含"+startingRule.getStartingTime()+unit+"),");
|
||||||
|
sb.append("超出价:"+startingRule.getTimeoutPrice()+"元/"+startingRule.getTimeoutTime()+unit);
|
||||||
|
}
|
||||||
|
order.setDescription(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据订单号查询订单
|
* 根据订单号查询订单
|
||||||
*
|
*
|
||||||
|
@ -310,14 +330,18 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
}
|
}
|
||||||
List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder);
|
List<EtOrder> etOrders = etOrderMapper.selectEtOrderList(etOrder);
|
||||||
//如果查询押金则增加退款记录
|
//如果查询押金则增加退款记录
|
||||||
if(ServiceConstants.ORDER_TYPE_DEPOSIT.equals(etOrder.getType())){
|
|
||||||
etOrders.forEach(etOrder1 -> {
|
etOrders.forEach(etOrder1 -> {
|
||||||
List<EtRefund> refund = etRefundService.selectEtRefundByOrderNo(etOrder1.getOrderNo());
|
List<EtRefund> refunds = etRefundService.selectEtRefundByOrderNo(etOrder1.getOrderNo());
|
||||||
if(ObjectUtil.isNotNull(refund) && refund.size() > 0){
|
if(ObjectUtil.isNotNull(refunds) && refunds.size() > 0){
|
||||||
etOrder1.setEtRefund(refund.get(0));
|
etOrder1.setEtRefund(refunds.get(0));
|
||||||
|
etOrder1.setEtRefunds(refunds);
|
||||||
|
// 计算总的退款金额
|
||||||
|
BigDecimal totalRefundFee = refunds.stream()
|
||||||
|
.map(EtRefund::getAmount)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
etOrder1.setTotalRefundFee(totalRefundFee);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return etOrders;
|
return etOrders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,6 +556,7 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
if(deposit.compareTo(ridingFee) <= 0){
|
if(deposit.compareTo(ridingFee) <= 0){
|
||||||
afterDeductionFee = BigDecimal.ZERO;
|
afterDeductionFee = BigDecimal.ZERO;
|
||||||
mark = "押金抵扣成功,骑行费【"+ridingFee+"】大于押金【"+deposit+"】";
|
mark = "押金抵扣成功,骑行费【"+ridingFee+"】大于押金【"+deposit+"】";
|
||||||
|
order.setPayFee(deposit);//实际支付金额等于押金
|
||||||
}else{
|
}else{
|
||||||
// 押金大于订单金额 扣除后
|
// 押金大于订单金额 扣除后
|
||||||
afterDeductionFee = deposit.subtract(ridingFee);
|
afterDeductionFee = deposit.subtract(ridingFee);
|
||||||
|
@ -1832,6 +1857,19 @@ public class EtOrderServiceImpl implements IEtOrderService
|
||||||
if(ObjectUtil.isNotNull(etCoupon)){
|
if(ObjectUtil.isNotNull(etCoupon)){
|
||||||
order.setCoupon(etCoupon);
|
order.setCoupon(etCoupon);
|
||||||
}
|
}
|
||||||
|
// 骑行结束并且订单金额等于0,并且未支付
|
||||||
|
if(ServiceConstants.ORDER_STATUS_RIDING_END.equals(order.getStatus()) && order.getTotalFee().compareTo(BigDecimal.ZERO) == 0 && order.getPaid().equals(ServiceConstants.ORDER_PAY_STATUS_NON_PAYMENT)){
|
||||||
|
order.setPaid(ServiceConstants.ORDER_PAY_STATUS_PAID);
|
||||||
|
order.setPayTime(new Date());
|
||||||
|
order.setPayType(ServiceConstants.PAY_TYPE_SYS);
|
||||||
|
order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
|
||||||
|
int updateEtOrder = etOrderMapper.updateEtOrder(order);
|
||||||
|
if(updateEtOrder == 0){
|
||||||
|
throw new ServiceException("更新订单outTradeNo失败");
|
||||||
|
}else {
|
||||||
|
log.info("【isInOrder接口】更新订单outTradeNo成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return inOrder;
|
return inOrder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="lowVoltage" column="low_voltage" />
|
<result property="lowVoltage" column="low_voltage" />
|
||||||
<result property="fullEndurance" column="full_endurance" />
|
<result property="fullEndurance" column="full_endurance" />
|
||||||
<result property="lowBatteryReminder" column="low_battery_reminder" />
|
<result property="lowBatteryReminder" column="low_battery_reminder" />
|
||||||
|
<result property="lowBatteryReminderSwitch" column="low_battery_reminder_switch" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
@ -22,12 +23,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectEtModelVo">
|
<sql id="selectEtModelVo">
|
||||||
select model_id, model, brand, operator, area_id, full_voltage, low_voltage, full_endurance, low_battery_reminder, create_by, create_time, update_by, update_time, remark from et_model
|
select model_id, model, brand, operator, area_id, full_voltage, low_voltage, full_endurance, low_battery_reminder, low_battery_reminder_switch, create_by, create_time, update_by, update_time, remark from et_model
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectEtModelList" parameterType="EtModel" resultMap="EtModelResult">
|
<select id="selectEtModelList" parameterType="EtModel" resultMap="EtModelResult">
|
||||||
select m.model_id, m.model, m.brand, m.operator, m.full_voltage, m.low_voltage,m.area_id,a.area_name areaName,
|
select m.model_id, m.model, m.brand, m.operator, m.full_voltage, m.low_voltage,m.area_id,a.area_name areaName,
|
||||||
m.full_endurance, m.low_battery_reminder, m.create_by, m.create_time,
|
m.full_endurance, m.low_battery_reminder, m.low_battery_reminder_switch, m.create_by, m.create_time,
|
||||||
m.update_by, m.update_time, m.remark from et_model m
|
m.update_by, m.update_time, m.remark from et_model m
|
||||||
left join sys_dept d on d.dept_id = m.operator
|
left join sys_dept d on d.dept_id = m.operator
|
||||||
left join et_operating_area a on a.area_id = m.area_id
|
left join et_operating_area a on a.area_id = m.area_id
|
||||||
|
@ -42,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="selectEtModelByModelId" parameterType="Long" resultMap="EtModelResult">
|
<select id="selectEtModelByModelId" parameterType="Long" resultMap="EtModelResult">
|
||||||
select m.model_id, m.model, m.brand, m.operator, d.dept_name, m.full_voltage, m.low_voltage,m.area_id,
|
select m.model_id, m.model, m.brand, m.operator, d.dept_name, m.full_voltage, m.low_voltage,m.area_id,
|
||||||
m.full_endurance, m.low_battery_reminder, m.create_by, m.create_time,
|
m.full_endurance, m.low_battery_reminder, m.low_battery_reminder_switch, m.create_by, m.create_time,
|
||||||
m.update_by, m.update_time, m.remark from et_model m
|
m.update_by, m.update_time, m.remark from et_model m
|
||||||
left join sys_dept d on d.dept_id = m.operator
|
left join sys_dept d on d.dept_id = m.operator
|
||||||
where m.model_id = #{modelId}
|
where m.model_id = #{modelId}
|
||||||
|
@ -64,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="lowVoltage != null">low_voltage,</if>
|
<if test="lowVoltage != null">low_voltage,</if>
|
||||||
<if test="fullEndurance != null">full_endurance,</if>
|
<if test="fullEndurance != null">full_endurance,</if>
|
||||||
<if test="lowBatteryReminder != null">low_battery_reminder,</if>
|
<if test="lowBatteryReminder != null">low_battery_reminder,</if>
|
||||||
|
<if test="lowBatteryReminderSwitch != null">low_battery_reminder_switch,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
@ -80,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="lowVoltage != null">#{lowVoltage},</if>
|
<if test="lowVoltage != null">#{lowVoltage},</if>
|
||||||
<if test="fullEndurance != null">#{fullEndurance},</if>
|
<if test="fullEndurance != null">#{fullEndurance},</if>
|
||||||
<if test="lowBatteryReminder != null">#{lowBatteryReminder},</if>
|
<if test="lowBatteryReminder != null">#{lowBatteryReminder},</if>
|
||||||
|
<if test="lowBatteryReminderSwitch != null">#{lowBatteryReminderSwitch},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
@ -99,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="lowVoltage != null">low_voltage = #{lowVoltage},</if>
|
<if test="lowVoltage != null">low_voltage = #{lowVoltage},</if>
|
||||||
<if test="fullEndurance != null">full_endurance = #{fullEndurance},</if>
|
<if test="fullEndurance != null">full_endurance = #{fullEndurance},</if>
|
||||||
<if test="lowBatteryReminder != null">low_battery_reminder = #{lowBatteryReminder},</if>
|
<if test="lowBatteryReminder != null">low_battery_reminder = #{lowBatteryReminder},</if>
|
||||||
|
<if test="lowBatteryReminderSwitch != null">low_battery_reminder_switch = #{lowBatteryReminderSwitch},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user