Merge pull request 'master' (#3) from master into prod
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 18m49s
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 18m49s
Reviewed-on: #3
This commit is contained in:
@@ -239,13 +239,15 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
|||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
// 1. 获取今日排班人员(优先查缓存,未命中则查询数据库并缓存)
|
// 1. 获取今日排班人员(优先查缓存,未命中则查询数据库并缓存)
|
||||||
List<AttendanceUserGroup> attendanceUserGroups = RedisUtils.getCacheList(DateUtil.today());
|
List<AttendanceUserGroup> attendanceUserGroups = RedisUtils.getCacheList(DateUtil.today());
|
||||||
if (CollUtil.isEmpty(attendanceUserGroups)) {
|
List<AttendanceUserGroup> attendanceUserGroupList = attendanceUserGroupMapper.selectList(
|
||||||
attendanceUserGroups = attendanceUserGroupMapper.selectList(
|
|
||||||
new LambdaQueryWrapper<AttendanceUserGroup>()
|
new LambdaQueryWrapper<AttendanceUserGroup>()
|
||||||
.le(AttendanceUserGroup::getStartDate, today)
|
.le(AttendanceUserGroup::getStartDate, today)
|
||||||
.ge(AttendanceUserGroup::getEndDate, today)
|
.ge(AttendanceUserGroup::getEndDate, today)
|
||||||
.orderByAsc(AttendanceUserGroup::getCreateTime)
|
.eq(AttendanceUserGroup::getDeptId, serviceWorkOrders.getCreateDept())
|
||||||
|
.orderByAsc(AttendanceUserGroup::getStartDate)
|
||||||
);
|
);
|
||||||
|
if (CollUtil.isEmpty(attendanceUserGroups)|| attendanceUserGroups.size() != attendanceUserGroupList.size()) {
|
||||||
|
attendanceUserGroups=attendanceUserGroupList;
|
||||||
Assert.isTrue(CollUtil.isNotEmpty(attendanceUserGroups), "暂无排班人员");
|
Assert.isTrue(CollUtil.isNotEmpty(attendanceUserGroups), "暂无排班人员");
|
||||||
// 缓存当天排班数据(假设当天不会变)
|
// 缓存当天排班数据(假设当天不会变)
|
||||||
RedisUtils.setCacheList(DateUtil.today(), attendanceUserGroups);
|
RedisUtils.setCacheList(DateUtil.today(), attendanceUserGroups);
|
||||||
|
@@ -121,7 +121,8 @@ public class CleanOrderServiceImpl implements ICleanOrderService {
|
|||||||
private LambdaQueryWrapper<CleanOrder>buildQueryWrapper(CleanOrderBo bo) {
|
private LambdaQueryWrapper<CleanOrder>buildQueryWrapper(CleanOrderBo bo) {
|
||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<CleanOrder> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<CleanOrder> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.orderByAsc(CleanOrder::getId);
|
lqw.orderByDesc(CleanOrder::getCreateTime)
|
||||||
|
.orderByDesc(CleanOrder::getUpdateTime);
|
||||||
// lqw.eq(StringUtils.isNotBlank(bo.getLocation()), CleanOrder::getLocation, bo.getLocation());
|
// lqw.eq(StringUtils.isNotBlank(bo.getLocation()), CleanOrder::getLocation, bo.getLocation());
|
||||||
// lqw.eq(StringUtils.isNotBlank(bo.getArea()), CleanOrder::getArea, bo.getArea());
|
// lqw.eq(StringUtils.isNotBlank(bo.getArea()), CleanOrder::getArea, bo.getArea());
|
||||||
|
|
||||||
|
@@ -238,50 +238,80 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
|||||||
public Map<String, Object> getEnergyTrend(String floorId, String meterId, Long meterType, String day, String month, String year) {
|
public Map<String, Object> getEnergyTrend(String floorId, String meterId, Long meterType, String day, String month, String year) {
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
|
||||||
// hour
|
String yesterday = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(day), -1), "yyyy-MM-dd");
|
||||||
List<Map<String, Object>> hourList = baseMapper.getHourTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, day);
|
// todayHour
|
||||||
|
Map<String, Object> todayMap = trendHourData(floorId, meterId, meterType, day);
|
||||||
|
// yesterdayHour
|
||||||
|
Map<String, Object> yesterdayMap = trendHourData(floorId, meterId, meterType, yesterday);
|
||||||
|
|
||||||
Map<String, Object> hourMap = new HashMap<>();
|
Map<String, Object> hourMap = new HashMap<>();
|
||||||
String[] hourCategories = hourList.stream()
|
hourMap.put("today", todayMap);
|
||||||
.map(map -> map.get("hour").toString())
|
hourMap.put("yesterday", yesterdayMap);
|
||||||
.toArray(String[]::new);
|
|
||||||
BigDecimal[] hourData = hourList.stream()
|
|
||||||
.map(map -> new BigDecimal(map.get("total_consumption").toString()))
|
|
||||||
.toArray(BigDecimal[]::new);
|
|
||||||
hourMap.put("categories", hourCategories);
|
|
||||||
hourMap.put("data", hourData);
|
|
||||||
hourMap.put("total" , hourList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue());
|
|
||||||
|
|
||||||
// day
|
|
||||||
String[] monthArr = month.split("-");
|
String[] monthArr = month.split("-");
|
||||||
List<Map<String, Object>> dayList = baseMapper.getDayTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, monthArr[0], monthArr[1]);
|
String lastMonth = Integer.parseInt(monthArr[1]) - 1 + "";
|
||||||
|
// nowMonth
|
||||||
|
Map<String, Object> nowMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], monthArr[1]);
|
||||||
|
// lastMonth
|
||||||
|
Map<String, Object> lastMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], lastMonth);
|
||||||
|
|
||||||
Map<String, Object> dayMap = new HashMap<>();
|
Map<String, Object> dayMap = new HashMap<>();
|
||||||
String[] dayCategories = dayList.stream()
|
dayMap.put("nowMonth", nowMonthMap);
|
||||||
.map(map -> map.get("day").toString())
|
dayMap.put("lastMonth", lastMonthMap);
|
||||||
.toArray(String[]::new);
|
|
||||||
BigDecimal[] dayData = dayList.stream()
|
String lastYear = Integer.parseInt(year) - 1 + "";
|
||||||
.map(map -> new BigDecimal(map.get("total_consumption").toString()))
|
// nowYear
|
||||||
.toArray(BigDecimal[]::new);
|
Map<String, Object> nowYearMap = trendMonthData(floorId, meterId, meterType, year);
|
||||||
dayMap.put("categories", dayCategories);
|
// lastYear
|
||||||
dayMap.put("data", dayData);
|
Map<String, Object> lastYearMap = trendMonthData(floorId, meterId, meterType, lastYear);
|
||||||
dayMap.put("total", dayList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue());
|
|
||||||
|
|
||||||
// month
|
|
||||||
List<Map<String, Object>> monthList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year);
|
|
||||||
Map<String, Object> monthMap = new HashMap<>();
|
Map<String, Object> monthMap = new HashMap<>();
|
||||||
String[] monthCategories = monthList.stream()
|
monthMap.put("nowYear", nowYearMap);
|
||||||
.map(map -> map.get("month").toString())
|
monthMap.put("lastYear", lastYearMap);
|
||||||
.toArray(String[]::new);
|
|
||||||
BigDecimal[] monthData = monthList.stream()
|
|
||||||
.map(map -> new BigDecimal(map.get("total_consumption").toString()))
|
|
||||||
.toArray(BigDecimal[]::new);
|
|
||||||
monthMap.put("categories", monthCategories);
|
|
||||||
monthMap.put("data", monthData);
|
|
||||||
monthMap.put("total", monthList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue());
|
|
||||||
|
|
||||||
|
|
||||||
resultMap.put("hour", hourMap);
|
resultMap.put("hour", hourMap);
|
||||||
resultMap.put("day", dayMap);
|
resultMap.put("day", dayMap);
|
||||||
resultMap.put("month", monthMap);
|
resultMap.put("month", monthMap);
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> trendHourData(String floorId, String meterId, Long meterType, String day) {
|
||||||
|
Map<String, Object> hourMap = new HashMap<>();
|
||||||
|
List<Map<String, Object>> hourList = baseMapper.getHourTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, day);
|
||||||
|
List<String[]> hourData = new ArrayList<>();
|
||||||
|
hourList.forEach(item -> {
|
||||||
|
hourData.add(new String[]{item.get("hour").toString(), item.get("total_consumption").toString()});
|
||||||
|
});
|
||||||
|
Float total = hourList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue();
|
||||||
|
hourMap.put("total", total);
|
||||||
|
hourMap.put("data", hourData);
|
||||||
|
return hourMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> trendDayData(String floorId, String meterId, Long meterType, String year, String month) {
|
||||||
|
Map<String, Object> dayMap = new HashMap<>();
|
||||||
|
List<Map<String, Object>> dayList = baseMapper.getDayTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year, month);
|
||||||
|
List<String[]> dayData = new ArrayList<>();
|
||||||
|
dayList.forEach(item -> {
|
||||||
|
dayData.add(new String[]{item.get("day").toString(), item.get("total_consumption").toString()});
|
||||||
|
});
|
||||||
|
Float total = dayList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue();
|
||||||
|
dayMap.put("total", total);
|
||||||
|
dayMap.put("data", dayData);
|
||||||
|
return dayMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> trendMonthData(String floorId, String meterId, Long meterType, String year) {
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
List<Map<String, Object>> monthList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year);
|
||||||
|
List<String[]> monthData = new ArrayList<>();
|
||||||
|
monthList.forEach(item -> {
|
||||||
|
monthData.add(new String[]{item.get("month").toString(), item.get("total_consumption").toString()});
|
||||||
|
});
|
||||||
|
Float total = monthList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue();
|
||||||
|
resultMap.put("total", total);
|
||||||
|
resultMap.put("data", monthData);
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user