增加 解锁

master
wanghao 4 weeks ago
parent db2f62ba57
commit fd34ece36f

@ -13,9 +13,9 @@ spring:
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: true enabled: true
url: jdbc:mysql://1.13.177.47:3306/bg_wheel_chocks?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://119.45.202.115:3306/bg_wheel_chocks?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: Haiwei123456 password: haiwei@123
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5
# 最小连接池数量 # 最小连接池数量

@ -7,9 +7,9 @@ ruoyi:
# 版权年份 # 版权年份
copyrightYear: 2025 copyrightYear: 2025
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: false
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath profile: F:/nopower/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: true addressEnabled: true

@ -1,8 +1,9 @@
package com.ruoyi.device.service; package com.ruoyi.device.service;
import java.util.List;
import com.ruoyi.device.domain.BaseInfo; import com.ruoyi.device.domain.BaseInfo;
import java.util.List;
/** /**
* Service * Service
* *
@ -42,6 +43,7 @@ public interface IBaseInfoService
* @return * @return
*/ */
public int updateBaseInfo(BaseInfo baseInfo); public int updateBaseInfo(BaseInfo baseInfo);
public int updateBaseInfoForApi(BaseInfo baseInfo);
/** /**
* *

@ -1,15 +1,15 @@
package com.ruoyi.device.service.impl; package com.ruoyi.device.service.impl;
import java.util.List; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.device.domain.BaseType; import com.ruoyi.device.domain.BaseInfo;
import com.ruoyi.device.mapper.BaseInfoMapper;
import com.ruoyi.device.service.IBaseInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.BaseInfoMapper;
import com.ruoyi.device.domain.BaseInfo; import java.util.List;
import com.ruoyi.device.service.IBaseInfoService;
import com.ruoyi.common.core.text.Convert;
/** /**
* Service * Service
@ -18,8 +18,7 @@ import com.ruoyi.common.core.text.Convert;
* @date 2025-05-19 * @date 2025-05-19
*/ */
@Service @Service
public class BaseInfoServiceImpl implements IBaseInfoService public class BaseInfoServiceImpl implements IBaseInfoService {
{
@Autowired @Autowired
private BaseInfoMapper baseInfoMapper; private BaseInfoMapper baseInfoMapper;
@ -30,8 +29,7 @@ public class BaseInfoServiceImpl implements IBaseInfoService
* @return * @return
*/ */
@Override @Override
public BaseInfo selectBaseInfoByObjId(Long objId) public BaseInfo selectBaseInfoByObjId(Long objId) {
{
return baseInfoMapper.selectBaseInfoByObjId(objId); return baseInfoMapper.selectBaseInfoByObjId(objId);
} }
@ -42,8 +40,7 @@ public class BaseInfoServiceImpl implements IBaseInfoService
* @return * @return
*/ */
@Override @Override
public List<BaseInfo> selectBaseInfoList(BaseInfo baseInfo) public List<BaseInfo> selectBaseInfoList(BaseInfo baseInfo) {
{
return baseInfoMapper.selectBaseInfoList(baseInfo); return baseInfoMapper.selectBaseInfoList(baseInfo);
} }
@ -54,8 +51,7 @@ public class BaseInfoServiceImpl implements IBaseInfoService
* @return * @return
*/ */
@Override @Override
public int insertBaseInfo(BaseInfo baseInfo) public int insertBaseInfo(BaseInfo baseInfo) {
{
baseInfo.setCreateTime(DateUtils.getNowDate()); baseInfo.setCreateTime(DateUtils.getNowDate());
baseInfo.setCreateBy(ShiroUtils.getLoginName()); baseInfo.setCreateBy(ShiroUtils.getLoginName());
return baseInfoMapper.insertBaseInfo(baseInfo); return baseInfoMapper.insertBaseInfo(baseInfo);
@ -68,13 +64,18 @@ public class BaseInfoServiceImpl implements IBaseInfoService
* @return * @return
*/ */
@Override @Override
public int updateBaseInfo(BaseInfo baseInfo) public int updateBaseInfo(BaseInfo baseInfo) {
{
baseInfo.setUpdateTime(DateUtils.getNowDate()); baseInfo.setUpdateTime(DateUtils.getNowDate());
baseInfo.setUpdateBy(ShiroUtils.getLoginName()); baseInfo.setUpdateBy(ShiroUtils.getLoginName());
return baseInfoMapper.updateBaseInfo(baseInfo); return baseInfoMapper.updateBaseInfo(baseInfo);
} }
@Override
public int updateBaseInfoForApi(BaseInfo baseInfo) {
return baseInfoMapper.updateBaseInfo(baseInfo);
}
/** /**
* *
* *
@ -82,8 +83,7 @@ public class BaseInfoServiceImpl implements IBaseInfoService
* @return * @return
*/ */
@Override @Override
public int deleteBaseInfoByObjIds(String objIds) public int deleteBaseInfoByObjIds(String objIds) {
{
return baseInfoMapper.deleteBaseInfoByObjIds(Convert.toStrArray(objIds)); return baseInfoMapper.deleteBaseInfoByObjIds(Convert.toStrArray(objIds));
} }
@ -94,15 +94,14 @@ public class BaseInfoServiceImpl implements IBaseInfoService
* @return * @return
*/ */
@Override @Override
public int deleteBaseInfoByObjId(Long objId) public int deleteBaseInfoByObjId(Long objId) {
{
return baseInfoMapper.deleteBaseInfoByObjId(objId); return baseInfoMapper.deleteBaseInfoByObjId(objId);
} }
@Override @Override
public boolean checkDeviceCode(BaseInfo baseInfo) { public boolean checkDeviceCode(BaseInfo baseInfo) {
BaseInfo result = baseInfoMapper.checkDeviceCode(baseInfo); BaseInfo result = baseInfoMapper.checkDeviceCode(baseInfo);
if (result==null) { if (result == null) {
return true; return true;
} }
if (result.getObjId().equals(baseInfo.getObjId())) { if (result.getObjId().equals(baseInfo.getObjId())) {

@ -1,14 +1,13 @@
package com.ruoyi.device.service.impl; package com.ruoyi.device.service.impl;
import java.util.List; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.device.domain.RecordUse;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.device.mapper.RecordUseMapper;
import com.ruoyi.device.service.IRecordUseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.device.mapper.RecordUseMapper;
import com.ruoyi.device.domain.RecordUse; import java.util.List;
import com.ruoyi.device.service.IRecordUseService;
import com.ruoyi.common.core.text.Convert;
/** /**
* 使Service * 使Service
@ -55,8 +54,8 @@ public class RecordUseServiceImpl implements IRecordUseService
@Override @Override
public int insertRecordUse(RecordUse recordUse) public int insertRecordUse(RecordUse recordUse)
{ {
recordUse.setCreateTime(DateUtils.getNowDate()); // recordUse.setCreateTime(DateUtils.getNowDate());
recordUse.setCreateBy(ShiroUtils.getLoginName()); // recordUse.setCreateBy(ShiroUtils.getLoginName());
return recordUseMapper.insertRecordUse(recordUse); return recordUseMapper.insertRecordUse(recordUse);
} }

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="typeName" column="device_type_name" /> <result property="typeName" column="device_type_name" />
<result property="defaultPrice" column="default_price" /> <result property="defaultPrice" column="default_price" />
<result property="defaultTime" column="default_time" /> <result property="defaultTime" column="default_time" />
<result property="remark" column="remark" />
</resultMap> </resultMap>
<sql id="selectBaseInfoVo"> <sql id="selectBaseInfoVo">
@ -40,7 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
open_password, open_password,
dbt.device_type_name, dbt.device_type_name,
dbt.default_price, dbt.default_price,
dbt.default_time dbt.default_time,
dbt.remark
from device_base_info info from device_base_info info
left join device_base_type dbt on info.device_type = dbt.obj_id left join device_base_type dbt on info.device_type = dbt.obj_id
</sql> </sql>

@ -36,10 +36,10 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">摆放桩位:</label> <label class="col-sm-4 control-label">摆放桩位:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<!-- <input name="locationName" class="form-control" type="text">--> <input class="form-control" name="locationName" type="text">
<select class="form-control" name="locationName" th:with="type=${@lundang.selectLundangBaseStoreList()}"> <!-- <select class="form-control" name="locationName" th:with="type=${@lundang.selectLundangBaseStoreList()}">-->
<option th:each="dict : ${type}" th:text="${dict.storeName}" th:value="${dict.storeName}"></option> <!-- <option th:each="dict : ${type}" th:text="${dict.storeName}" th:value="${dict.storeName}"></option>-->
</select> <!-- </select>-->
</div> </div>

@ -58,10 +58,10 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">摆放桩位:</label> <label class="col-sm-4 control-label">摆放桩位:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input class="form-control" name="locationName" th:field="*{locationName}" type="text">
<select class="form-control" name="locationName" th:field="*{locationName}" th:with="type=${@lundang.selectLundangBaseStoreList()}"> <!-- <select class="form-control" name="locationName" th:field="*{locationName}" th:with="type=${@lundang.selectLundangBaseStoreList()}">-->
<option th:each="dict : ${type}" th:text="${dict.storeName}" th:value="${dict.storeName}"></option> <!-- <option th:each="dict : ${type}" th:text="${dict.storeName}" th:value="${dict.storeName}"></option>-->
</select> <!-- </select>-->
</div> </div>
</div> </div>
</div> </div>

@ -100,6 +100,8 @@
removeUrl: prefix + "/remove", removeUrl: prefix + "/remove",
exportUrl: prefix + "/export", exportUrl: prefix + "/export",
modalName: "使用记录", modalName: "使用记录",
sortName: "openTime",
sortOrder: "desc",
columns: [{ columns: [{
checkbox: true checkbox: true
}, },

@ -1,17 +1,26 @@
package com.ruoyi.pda.controller; package com.ruoyi.pda.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.device.domain.BaseInfo; import com.ruoyi.device.domain.BaseInfo;
import com.ruoyi.device.domain.RecordUse;
import com.ruoyi.device.service.IBaseInfoService; import com.ruoyi.device.service.IBaseInfoService;
import com.ruoyi.device.service.IRecordUseService;
import com.ruoyi.pda.domain.MyResult;
import com.ruoyi.pda.service.IPdaApiService; import com.ruoyi.pda.service.IPdaApiService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import java.io.IOException; import java.time.LocalDate;
import java.net.HttpURLConnection; import java.time.YearMonth;
import java.net.URL; import java.util.List;
import static com.ruoyi.common.core.domain.AjaxResult.error; import static com.ruoyi.common.core.domain.AjaxResult.error;
import static com.ruoyi.common.core.domain.AjaxResult.success; import static com.ruoyi.common.core.domain.AjaxResult.success;
@ -24,6 +33,9 @@ public class PdaApiController {
@Autowired @Autowired
private IBaseInfoService baseInfoService; private IBaseInfoService baseInfoService;
@Autowired
private IRecordUseService recordUseService;
@PostMapping("/home/selectDeviceInfo") @PostMapping("/home/selectDeviceInfo")
public AjaxResult selectDeviceInfo(String code) { public AjaxResult selectDeviceInfo(String code) {
BaseInfo baseInfo = baseInfoService.selectDeviceInfo(code); BaseInfo baseInfo = baseInfoService.selectDeviceInfo(code);
@ -37,22 +49,64 @@ public class PdaApiController {
} }
public AjaxResult open() throws IOException { @PostMapping("/home/openDeviceLock")
URL url = new URL("https://api.example.com/data"); public AjaxResult openDeviceLock(@RequestBody BaseInfo baseInfo) {
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); String deviceCode = baseInfo.getDeviceCode();
conn.setRequestMethod("GET"); String openPassword = baseInfo.getOpenPassword();
int responseCode = conn.getResponseCode(); ResponseEntity<String> response = null;
if (responseCode == 200) { try {
// BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); RestTemplate restTemplate = new RestTemplate();
// String inputLine; // String url = "http://127.0.0.1:7789/devcontrolbusiness/unlock?idStr=" + deviceCode + "&password=" + openPassword;
// StringBuilder response = new StringBuilder(); String url = "http://119.45.202.115:7789/devcontrolbusiness/unlock?idStr=" + deviceCode + "&password=" + openPassword;
// while ((inputLine = in.readLine()) != null) { // 根据实际情况调整参数值
// response.append(inputLine); response = restTemplate.getForEntity(url, String.class);
// }
// in.close(); if (response.getStatusCode().is2xxSuccessful()) {
// System.out.println(response); // {"code":200/500,"isSuc":true,"msg":"开锁指令下发成功,已收到设备回复","buffer":null,"data":null}
MyResult myResult = JSONObject.parseObject(response.getBody(), MyResult.class);
if (myResult.getCode() == 200) {
/**
*
*/
RecordUse recordUse = new RecordUse();
BeanUtils.copyProperties(baseInfo, recordUse);
recordUse.setDeviceId(String.valueOf(baseInfo.getObjId()));//设备ID
recordUse.setDeviceType(baseInfo.getTypeName());//设备类型
recordUse.setChargePrice(baseInfo.getDefaultPrice());//计费价格
recordUse.setUseState("1");
// 获取当前日期和时间
LocalDate now = LocalDate.now();
// 从LocalDate获取YearMonth
YearMonth currentYearMonth = YearMonth.from(now);
// 获取年份和月份
recordUse.setQueryYear(String.valueOf(currentYearMonth.getYear()));
recordUse.setQueryMonth(String.valueOf(currentYearMonth.getMonthValue()));
recordUseService.insertRecordUse(recordUse);
/**
*
*/
BaseInfo updateBaseInfo = new BaseInfo();
updateBaseInfo.setObjId(baseInfo.getObjId());
updateBaseInfo.setUseState("1");
baseInfoService.updateBaseInfoForApi(updateBaseInfo);
return success("开锁成功");
} else {
return error(myResult.getMsg());
} }
return success(conn.getInputStream());
} }
} catch (RestClientException e) {
return error("通讯失败");
}
return success("开锁成功");
}
@PostMapping("/record/selectUseList")
public AjaxResult selectUseList() {
List<RecordUse> list=service.selectUseList();
return success(list);
}
} }

@ -0,0 +1,32 @@
package com.ruoyi.pda.domain;
public class MyResult {
private int code;
private String msg;
private Object data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}

@ -1,8 +1,11 @@
package com.ruoyi.pda.mapper; package com.ruoyi.pda.mapper;
import com.ruoyi.device.domain.RecordUse;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Repository @Repository
public interface PdaApiMapper { public interface PdaApiMapper {
List<RecordUse> selectUseList();
} }

@ -1,4 +1,9 @@
package com.ruoyi.pda.service; package com.ruoyi.pda.service;
import com.ruoyi.device.domain.RecordUse;
import java.util.List;
public interface IPdaApiService { public interface IPdaApiService {
List<RecordUse> selectUseList();
} }

@ -1,12 +1,20 @@
package com.ruoyi.pda.service.impl; package com.ruoyi.pda.service.impl;
import com.ruoyi.device.domain.RecordUse;
import com.ruoyi.pda.mapper.PdaApiMapper; import com.ruoyi.pda.mapper.PdaApiMapper;
import com.ruoyi.pda.service.IPdaApiService; import com.ruoyi.pda.service.IPdaApiService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public class PdaServiceImpl implements IPdaApiService { public class PdaServiceImpl implements IPdaApiService {
@Autowired @Autowired
private PdaApiMapper mapper; private PdaApiMapper mapper;
@Override
public List<RecordUse> selectUseList() {
return mapper.selectUseList();
}
} }

@ -1,5 +1,18 @@
<?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="com.ruoyi.pda.mapper.PdaApiMapper"> <mapper namespace="com.ruoyi.pda.mapper.PdaApiMapper">
<select id="selectUseList" resultMap="com.ruoyi.device.mapper.RecordUseMapper.RecordUseResult">
SELECT
device_code,
device_name,
device_type,
open_time,
close_time,
use_state,
CASE
WHEN use_time = 0 or use_time is null THEN ROUND(TIMESTAMPDIFF(SECOND, open_time, NOW()) / 3600, 2)
ELSE use_time
END as use_time
FROM device_record_use order by open_time desc
</select>
</mapper> </mapper>

Loading…
Cancel
Save