refactor(property): 优化能源趋势查询接口返回值类型

This commit is contained in:
2025-08-28 15:05:01 +08:00
parent 76c0aa74f1
commit cfff5df7d0
7 changed files with 89 additions and 50 deletions

View File

@@ -4,6 +4,8 @@ package org.dromara.sis.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -17,6 +19,7 @@ import org.dromara.sis.service.ISisPersonLibImgService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
@@ -40,46 +43,38 @@ public class SisVisitorController {
* 查询人员通行记录
*/
@GetMapping("/list")
public TableDataInfo<AccessRecordFindRes> list(QueryDto dto) {
public TableDataInfo<AccessRecordFindRes> list(@RequestParam(required = false) String beginTime,
@RequestParam(required = false) String endTime,
@NotNull(message = "页码不能为空") @RequestParam Integer pageNum,
@NotNull(message = "页数不能为空") @RequestParam Integer pageSize,
@RequestParam(required = false) String personName,
@RequestParam(required = false) Integer recordType) {
AccessRecordFindReq req = new AccessRecordFindReq();
if (beginTime != null && !beginTime.isEmpty()) {
req.setStartTime(DateUtil.format(DateUtil.parse(beginTime), "yyyy-MM-dd 00:00:00"));
} else {
// 默认设置为7天前
req.setStartTime(DateUtil.format(DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -7), "yyyy-MM-dd 00:00:00"));
}
if (endTime != null && !endTime.isEmpty()) {
req.setEndTime(DateUtil.format(DateUtil.parse(endTime), "yyyy-MM-dd 23:59:59"));
} else {
// 默认设置为今天
req.setEndTime(DateUtil.format(new Date(), "yyyy-MM-dd 23:59:59"));
}
TableDataInfo tableDataInfo = new TableDataInfo();
List<AccessRecordFindRes> accessRecordFindResList = new ArrayList<>();
AccessRecordFindRes accessRecordFindRes = new AccessRecordFindRes();
accessRecordFindRes.setDeviceName("4#岗亭09");
accessRecordFindRes.setDoorName("4#岗亭09");
accessRecordFindRes.setDeviceType(1102);
accessRecordFindRes.setReaderName("");
accessRecordFindRes.setGatewayType(1);
accessRecordFindRes.setCustomerName("德隆吴鹏");
accessRecordFindRes.setOrganFullPath("主楼11楼");
accessRecordFindRes.setPictureUrl("https://bpic.588ku.com/back_list_pic/23/04/21/ef5e2a3dd5cfc336fdcf2fd000474f0f.jpg");
accessRecordFindRes.setCardType(34);
accessRecordFindRes.setRecordType(2);
accessRecordFindRes.setActionTime(new Date());
accessRecordFindResList.add(accessRecordFindRes);
tableDataInfo.setRows(accessRecordFindResList);
tableDataInfo.setTotal(1);
tableDataInfo.setCode(200);
return tableDataInfo;
//
// dto.setPageIndex(1);
// dto.setMaxResultCount(20);
//
// // 10秒内
// String starTime = DateUtil.format(DateUtil.offset(new Date(), DateField.SECOND, -10), "yyyy-MM-dd HH:mm:ss");
// String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
//
// AccessRecordFindReq lift = new AccessRecordFindReq();
// lift.setStartTime(starTime);
// lift.setEndTime(endTime);
// lift.setRecordType(2);
// // 9号电梯
// lift.setDeviceId(550757939925061L);
// dto.setQueryDto(lift);
//// TableDataInfo<AccessRecordFindRes> nineLiftList = e8PlatformApi.getPageAccessRecordList(dto);
// TableDataInfo<AccessRecordFindRes> pageAccessRecordList = new TableDataInfo();
//
// return e8PlatformApi.getPageAccessRecordList(dto);
//如果pageAccessRecordList报错就捕获并封装
if (personName != null && !personName.isEmpty()) {
req.setCustomerName(personName);
}
if (recordType != null) {
req.setRecordType(recordType);
}
QueryDto dto = new QueryDto();
dto.setQueryDto(req);
dto.setPageIndex(pageNum);
dto.setMaxResultCount(pageSize);
return e8PlatformApi.getPageAccessRecordList(dto);
}
}

View File

@@ -422,6 +422,8 @@ public class E8PlatformApiService implements E8PlatformApi {
tableData.setTotal(Long.parseLong(result.get("total").toString()));
// 从结果映射中获取项目列表,转换为访问记录信息列表后设置到分页对象中
tableData.setRows(JSONUtil.toList(JSONUtil.toJsonStr(result.get("item")), AccessRecordFindRes.class));
tableData.setCode(200);
tableData.setMsg("查询成功");
// 返回填充了数据的分页对象
return tableData;
}