style(watch): 清理代码格式,移除多余空行

统一 health-watch-api 模块中多个文件的代码风格,
删除冗余空行,保持代码整洁一致。

涉及文件:
- DepartStatTransfer.java
- DeptData.java
- DeptStatData.java
- WearingDetailTransfer.java
This commit is contained in:
2026-05-14 10:00:25 +08:00
parent 61f26973ae
commit 74310b095c
54 changed files with 315 additions and 29639 deletions
@@ -33,6 +33,12 @@ public class DepartStatTransfer {
private Map<String, AbnormalCount> secondDepartAbnormalCount;
/** 各部门非关爱人员数量 Map(orgCode → 数量) */
private Map<String, Integer> nonCareNumMap;
/** 二级部门汇总的非关爱人员数量(仅在指定二级部门时有值) */
private Integer secondDepartNonCareNum;
private IPage<DeptStatData> pagedData;
private List<DeptStatData> data;
@@ -39,6 +39,9 @@ public class WearingDetailTransfer {
private Map<String, LoginUserNew> userMap;
/** 用户非关爱人员标记 MapuserId → nonCareFlag),0-否,1-是 */
private Map<String, Integer> nonCareFlagMap;
private Map<String, SysDepart> departMap = new ConcurrentHashMap<>(8);
private List<String> dateList;
@@ -0,0 +1,39 @@
package com.renkang.watch.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 手表数据条目 VO
* <p>
* 用于分页查询手表设备列表的轻量返回对象,仅含工号、手表编号、姓名三个字段
* </p>
*
* @author lianlonggang
*/
@Data
@Schema(title = "手表数据条目")
public class WatchDataItemVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 工号
*/
@Schema(title = "工号")
private String workNo;
/**
* 手表编号
*/
@Schema(title = "手表编号")
private String watchNo;
/**
* 姓名
*/
@Schema(title = "姓名")
private String realName;
}
@@ -28,4 +28,9 @@ public class DeptData {
private Integer days1;
private Integer days2;
private Integer days3;
/**
* 非关爱人员标记:0-否,1-是
*/
private Integer nonCareFlag;
}
@@ -50,5 +50,11 @@ public class DeptStatData {
@Excel(name = "体温异常人数", width = 15,orderNum = "11")
private Integer tempNums;
/**
* 非关爱人员数量
*/
@Excel(name = "非关爱人员数量", width = 15, orderNum = "12")
private Integer nonCareNums;
}
@@ -1,8 +1,10 @@
package com.renkang.watch.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.renkang.watch.service.IWatchDeviceService;
import com.renkang.watch.service.IWatchMonitorDataService;
import com.renkang.watch.vo.WatchDataItemVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@@ -65,4 +67,48 @@ public class WatchApiController {
map.put("idcard",idcard);
return Result.ok(map);
}
/**
* 查询手表数据总页数
*
* @param workNo 工号(可空,模糊匹配)
* @param pageSize 每页大小(可空,默认 10)
* @return 包含 pageCount 字段的 Map
*/
@GetMapping(value = "getWatchDataPageCount")
@Operation(summary = "查询手表数据总页数")
@ResponseBody
public Result<Map<String, Integer>> getWatchDataPageCount(@RequestParam(value = "workNo", required = false) String workNo,
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
if (pageSize != null && pageSize > 200) {
return Result.error("pageSize 不能超过 200");
}
int actualPageSize = (pageSize == null || pageSize <= 0) ? 10 : pageSize;
Integer pageCount = watchDeviceService.getWatchDataPageCount(workNo, actualPageSize);
Map<String, Integer> map = new HashMap<>();
map.put("pageCount", pageCount);
map.put("pageSize", actualPageSize);
return Result.ok(map);
}
/**
* 分页查询手表数据列表
*
* @param workNo 工号(可空,模糊匹配)
* @param pageNo 页码(默认 1
* @param pageSize 每页大小(默认 10
* @return 手表数据条目分页
*/
@GetMapping(value = "getWatchDataByPage")
@Operation(summary = "分页查询手表数据列表")
@ResponseBody
public Result<IPage<WatchDataItemVO>> getWatchDataByPage(@RequestParam(value = "workNo", required = false) String workNo,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
if (pageSize != null && pageSize > 200) {
return Result.error("pageSize 不能超过 200");
}
IPage<WatchDataItemVO> page = watchDeviceService.getWatchDataByPage(workNo, pageNo, pageSize);
return Result.ok(page);
}
}
@@ -41,6 +41,13 @@ public interface WatchStatisticsMapper {
})
List<AbnormalCount> abnormalWarningCount(DepartStatsFilter filter);
@SelectProvider(type = WatchStatisticsProvider.class, method = "nonCareNumsSql")
@Results({
@Result(column = "org_code", property = "orgCode"),
@Result(column = "non_care_count", property = "deviceCount")
})
List<DepartDeviceNum> nonCareNums(DepartStatsFilter filter);
@SelectProvider(type = WatchStatisticsProvider.class, method = "wearingDetail")
@Results({
@Result(column = "bind_user_id", property = "bindUserId"),
@@ -62,6 +62,28 @@ public class WatchStatisticsProvider {
return sb.toString();
}
public String nonCareNumsSql(DepartStatsFilter filter) {
String orgCodeStr;
if (StrUtil.isEmpty(filter.getOrgCodeLeaf()) && StrUtil.isEmpty(filter.getOrgCode())) {
orgCodeStr = "left(b.org_code, 6)";
} else {
orgCodeStr = "left(b.org_code, 9)";
}
StringBuilder sb = new StringBuilder("select ");
sb.append(orgCodeStr)
.append(" as org_code, count(distinct a.id) as non_care_count ")
.append("from QH_HLT_USER_EMPLOYEE_EX a ")
.append("join QH_SYS_USER b on a.id = b.id ")
.append("where a.non_care_flag = 1 ");
if (StrUtil.isNotEmpty(filter.getOrgCodeLeaf())) {
sb.append("and b.org_code like CONCAT(#{orgCodeLeaf},'%')");
} else if (StrUtil.isNotEmpty(filter.getOrgCode())) {
sb.append("and b.org_code like CONCAT(#{orgCode},'%')");
}
sb.append(" group by ").append(orgCodeStr).append(";");
return sb.toString();
}
public String wearingDetail() {
return "SELECT " +
" max(wd.bind_user_id) as bind_user_id," +
@@ -235,4 +235,23 @@ public interface IWatchDeviceService extends IService<WatchDevice> {
void settingKeyUser(List<WatchKeyUser> watchKeyUserList);
void deleteKeyUser(String userId,String errorType);
/**
* 查询手表数据总页数
*
* @param workNo 工号(可空,模糊匹配)
* @param pageSize 每页大小(可空,默认 10)
* @return 总页数
*/
Integer getWatchDataPageCount(String workNo, Integer pageSize);
/**
* 分页查询手表数据列表
*
* @param workNo 工号(可空,模糊匹配)
* @param pageNo 页码
* @param pageSize 每页大小
* @return 手表数据条目分页
*/
IPage<com.renkang.watch.vo.WatchDataItemVO> getWatchDataByPage(String workNo, Integer pageNo, Integer pageSize);
}
@@ -38,6 +38,8 @@ import org.jeecg.global.GlobalUtils;
import org.jeecg.modules.exports.entity.CommonExportsInfo;
import org.jeecg.modules.manager.ISysCache;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.HealthUserEmployeeEx;
import org.jeecg.bean.request.ListUser;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -422,6 +424,7 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
headers.add(Arrays.asList(titleStr, "员工姓名"));
headers.add(Arrays.asList(titleStr, "手表编号"));
headers.add(Arrays.asList(titleStr, "手表所属单位"));
headers.add(Arrays.asList(titleStr, "非关爱人员"));
transfer.dateList()
.forEach(
dateStr -> headers.add(Arrays.asList(titleStr, dateStr))
@@ -450,6 +453,7 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
row.add(deptData.getRealName());
row.add(deptData.getWatchNo());
row.add(deptData.getWatchOrgName());
row.add(formatNonCareFlag(deptData.getNonCareFlag()));
row.addAll(deptData.getDateList().values());
row.add(deptData.getDays1().toString());
row.add(deptData.getDays2().toString());
@@ -457,6 +461,19 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
return row;
}
private String formatNonCareFlag(Integer flag) {
if (flag == null) {
return "";
}
if (flag == 1) {
return "";
}
if (flag == 0) {
return "";
}
return "";
}
@Override
public List<List<String>> getData(DepartStatsFilter params) {
WearingDetailTransfer transfer = getDeptDetail(params, false);
@@ -640,11 +657,15 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
DepartDeviceNum secondDepartBindAndWearNum = getSecondDepartBindAndWearNum(filter, departBindAndWearNumMap);
Map<String, Map<String, AbnormalCount>> departAbnormalCountMap = getDepartAbnormalCountMap(filter);
Map<String, AbnormalCount> secondDepartAbnormalCount = getSecondDepartAbnormalCount(filter, departAbnormalCountMap);
Map<String, Integer> nonCareNumMap = getNonCareNumMap(filter);
Integer secondDepartNonCareNum = getSecondDepartNonCareNum(filter, nonCareNumMap);
transfer.departDeviceNumMap(departDeviceNumMap)
.departBindAndWearNumMap(departBindAndWearNumMap)
.secondDepartBindAndWearNum(secondDepartBindAndWearNum)
.departAbnormalCountMap(departAbnormalCountMap)
.secondDepartAbnormalCount(secondDepartAbnormalCount);
.secondDepartAbnormalCount(secondDepartAbnormalCount)
.nonCareNumMap(nonCareNumMap)
.secondDepartNonCareNum(secondDepartNonCareNum);
if (paged) {
transfer.pagedData().setTotal(finalDeparts.size());
finalDeparts = getPagedDeparts(finalDeparts, filter);
@@ -721,6 +742,11 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
:
transfer.departAbnormalCountMap().getOrDefault(orgCode, Collections.emptyMap())
);
deptStatData.setNonCareNums(
(!allSecond && (isFirst || isSecond))
? Optional.ofNullable(transfer.secondDepartNonCareNum()).orElse(0)
: transfer.nonCareNumMap().getOrDefault(orgCode, 0)
);
return deptStatData;
}
@@ -820,6 +846,27 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
.collect(Collectors.groupingBy(AbnormalCount::getOrgCode, Collectors.toMap(AbnormalCount::getEventType, Function.identity())));
}
/**
* 查询各部门非关爱人员数量 Map(orgCode → 数量)
*/
private Map<String, Integer> getNonCareNumMap(DepartStatsFilter filter) {
return watchStatisticsMapper.nonCareNums(filter)
.stream()
.filter(o -> StrUtil.isNotBlank(o.getOrgCode()))
.collect(Collectors.toMap(DepartDeviceNum::getOrgCode, d -> Optional.ofNullable(d.getDeviceCount()).orElse(0)));
}
/**
* 汇总二级部门下所有三级部门的非关爱人员数量,用于二级部门行的数据展示
* 仅在"指定了二级部门但未指定三级部门"时有效,其他情况返回 null
*/
private Integer getSecondDepartNonCareNum(DepartStatsFilter filter, Map<String, Integer> nonCareNumMap) {
if (StrUtil.isNotEmpty(filter.getOrgCodeLeaf()) || StrUtil.isEmpty(filter.getOrgCode())) {
return null;
}
return nonCareNumMap.values().stream().mapToInt(Integer::intValue).sum();
}
/**
* 汇总二级部门下所有三级部门的绑定/佩戴数,用于二级部门行的数据展示
* <p>
@@ -1537,8 +1584,17 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
return transfer;
}
List<String> userIds = records.stream().map(WearingDetail::getBindUserId).collect(Collectors.toList());
Map<String, Integer> nonCareFlagMap = sysBaseAPI.listEmployeeUserByIds(new ListUser(userIds))
.stream()
.filter(e -> e.getId() != null)
.collect(Collectors.toMap(
HealthUserEmployeeEx::getId,
e -> Optional.ofNullable(e.getNonCareFlag()).orElse(0),
(a, b) -> a
));
transfer.rawData(records)
.userMap(getLoginUser(userIds));
.userMap(getLoginUser(userIds))
.nonCareFlagMap(nonCareFlagMap);
BeanUtil.copyProperties(detailPaged, transfer.pagedData(), "records");
List<DeptData> deptData = records.stream()
.map(detail -> transferData(detail, transfer))
@@ -1560,6 +1616,7 @@ public class DeptStatisticDataServiceImpl extends ServiceImpl<DeptStatisticDataM
deptData.setOrgCode(Optional.ofNullable(user).map(LoginUserNew::getOrgCode).orElse(null));
deptData.setOrgName(getDepartNameOrEmptyStr(getSecondDepart(user)));
deptData.setOrgLeafName(getDepartNameOrEmptyStr(getThirdDepart(user)));
deptData.setNonCareFlag(transfer.nonCareFlagMap().get(detail.getBindUserId()));
handleDetailDateInfo(detail, transfer, deptData);
return deptData;
}
@@ -2341,4 +2341,88 @@ public class WatchDeviceServiceImpl extends ServiceImpl<WatchDeviceMapper, Watch
keyUserMapper.update(wrapper);
}
/**
* 查询手表数据总页数
* <p>
* 仅统计已绑定用户的设备(bind_user_id 非空),按工号过滤时通过 Feign 调用
* health-system 服务获取用户 ID 列表后再过滤 QH_WAT_DEVICE 表,根据 pageSize 计算总页数
* </p>
*/
@Override
public Integer getWatchDataPageCount(String workNo, Integer pageSize) {
int size = (pageSize == null || pageSize <= 0) ? 10 : pageSize;
LambdaQueryWrapper<WatchDevice> wrapper = new LambdaQueryWrapper<>();
wrapper.isNotNull(WatchDevice::getBindUserId);
wrapper.ne(WatchDevice::getBindUserId, "");
if (StrUtil.isNotBlank(workNo)) {
List<String> userIds = sysBaseAPI.getUserIdsByDepartAndUsername(null, null, null, workNo);
if (CollectionUtil.isEmpty(userIds)) {
return 0;
}
wrapper.in(WatchDevice::getBindUserId, userIds);
}
long total = watchDeviceMapper.selectCount(wrapper);
if (total <= 0) {
return 0;
}
return (int) ((total + size - 1) / size);
}
/**
* 分页查询手表数据列表
* <p>
* 仅查询已绑定用户的设备(bind_user_id 非空),按工号模糊匹配 QH_WAT_DEVICE 表,
* 通过 Feign 调用 health-system 服务获取用户工号和姓名后回填,
* 返回仅含工号、手表编号、姓名的轻量对象
* </p>
*/
@Override
public IPage<WatchDataItemVO> getWatchDataByPage(String workNo, Integer pageNo, Integer pageSize) {
int pn = (pageNo == null || pageNo <= 0) ? 1 : pageNo;
int ps = (pageSize == null || pageSize <= 0) ? 10 : pageSize;
Page<WatchDataItemVO> voPage = new Page<>(pn, ps);
LambdaQueryWrapper<WatchDevice> wrapper = new LambdaQueryWrapper<>();
wrapper.isNotNull(WatchDevice::getBindUserId);
wrapper.ne(WatchDevice::getBindUserId, "");
// 通过工号过滤:先查 health-system 拿到 userIds,再用 userId 过滤 QH_WAT_DEVICE
if (StrUtil.isNotBlank(workNo)) {
List<String> userIds = sysBaseAPI.getUserIdsByDepartAndUsername(null, null, null, workNo);
if (CollectionUtil.isEmpty(userIds)) {
return voPage;
}
wrapper.in(WatchDevice::getBindUserId, userIds);
}
wrapper.orderByDesc(WatchDevice::getCreateDate);
Page<WatchDevice> page = watchDeviceMapper.selectPage(new Page<>(pn, ps), wrapper);
BeanUtil.copyProperties(page, voPage, "records");
if (CollectionUtil.isEmpty(page.getRecords())) {
return voPage;
}
// 跨服务批量查询用户基本信息(工号、姓名)
List<String> userIdList = page.getRecords().stream()
.map(WatchDevice::getBindUserId)
.filter(StrUtil::isNotBlank)
.distinct()
.collect(Collectors.toList());
List<LoginUserNew> loginUserNews = sysBaseAPI.listUserByIds(new ListUser(userIdList));
Map<String, LoginUserNew> userMap = CollectionUtil.isEmpty(loginUserNews)
? Collections.emptyMap()
: loginUserNews.stream().collect(Collectors.toMap(LoginUserNew::getId, u -> u, (a, b) -> a));
List<WatchDataItemVO> records = page.getRecords().stream().map(device -> {
WatchDataItemVO vo = new WatchDataItemVO();
vo.setWatchNo(device.getWatchNo());
LoginUserNew user = userMap.get(device.getBindUserId());
if (user != null) {
vo.setWorkNo(user.getWorkNo());
vo.setRealName(user.getRealname());
}
return vo;
}).collect(Collectors.toList());
voPage.setRecords(records);
return voPage;
}
}