diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java new file mode 100644 index 00000000..a190cf68 --- /dev/null +++ b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteBuildingService.java @@ -0,0 +1,13 @@ +package org.dromara.property.api; + +import org.dromara.property.api.domain.vo.RemoteBuildingVo; + +/** + * 物业楼层远程服务 + * @author lxj + */ +public interface RemoteBuildingService { + + RemoteBuildingVo queryBuildingById(Long id); + +} diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java deleted file mode 100644 index 175b9b0e..00000000 --- a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteUnitService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.dromara.property.api; - -import org.dromara.property.api.domain.vo.RemoteUnitVo; - -/** - * 物业楼层远程服务 - * @author lxj - */ -public interface RemoteUnitService { - - RemoteUnitVo queryUnitById(Long id); - -} diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteUnitVo.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteBuildingVo.java similarity index 54% rename from ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteUnitVo.java rename to ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteBuildingVo.java index 97b6e0b7..3e4e5137 100644 --- a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteUnitVo.java +++ b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/domain/vo/RemoteBuildingVo.java @@ -11,7 +11,7 @@ import java.io.Serializable; * @author lxj */ @Data -public class RemoteUnitVo implements Serializable { +public class RemoteBuildingVo implements Serializable { @Serial private static final long serialVersionUID = -11L; @@ -21,31 +21,19 @@ public class RemoteUnitVo implements Serializable { */ private Long id; + /** + * 园区id + */ private Long communityId; /** * 建筑名称 */ - private Long buildingId; + private String buildingName; /** - * 单元名称 + * 总层数 */ - private String unitName; - - /** - * 单元层数 - */ - private Integer floorCount; - - /** - * 单元户数 - */ - private Integer householdCount; - - /** - * 楼梯数量 - */ - private Integer stairCount; + private Long floorCount; } diff --git a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java index 429d3dbf..9a39759f 100644 --- a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java +++ b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileService.java @@ -27,7 +27,7 @@ public interface RemoteFileService { * @return 结果 * @throws ServiceException */ - RemoteFile upload(byte[] file) throws ServiceException; + RemoteFile uploadImg(byte[] file) throws ServiceException; /** * 通过ossId查询对应的url diff --git a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java index fb6452fc..5a478bb7 100644 --- a/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java +++ b/ruoyi-api/ruoyi-api-resource/src/main/java/org/dromara/resource/api/RemoteFileServiceMock.java @@ -2,6 +2,7 @@ package org.dromara.resource.api; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; +import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StringUtils; import org.dromara.resource.api.domain.RemoteFile; @@ -28,6 +29,18 @@ public class RemoteFileServiceMock implements RemoteFileService { return null; } + /** + * 文件上传 + * + * @param file 文件信息 + * @return 结果 + */ + @Override + public RemoteFile uploadImg(byte[] file) { + log.warn("服务调用异常 -> 降级处理"); + return null; + } + /** * 通过ossId查询对应的url * @@ -55,7 +68,7 @@ public class RemoteFileServiceMock implements RemoteFileService { /** * 文件下载方法,支持一次性下载完整文件 * - * @param ossId OSS对象ID + * @param ossId OSS对象ID * @return byte[] 返回下载的字节数组 */ public byte[] downloadToByteArray(Long ossId) throws IOException { diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/ContentTypeEnum.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/ContentTypeEnum.java index 78530307..1c67a916 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/ContentTypeEnum.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/ContentTypeEnum.java @@ -30,7 +30,13 @@ public enum ContentTypeEnum { /** * GIF图片类型 */ - GIF("gif", "image/gif"); + GIF("gif", "image/gif"), + + WEBP("webp", "image/webp"), + + SVG("svg", "image/svg+xml"), + + ; private final String extension; private final String contentType; @@ -41,13 +47,13 @@ public enum ContentTypeEnum { * @param extension 文件扩展名 * @return 对应的内容类型,如果未找到则返回null */ - public static String getContentType(String extension) { + public static ContentTypeEnum ContentTypeEnum(String extension) { for (ContentTypeEnum type : values()) { if (type.extension.equalsIgnoreCase(extension)) { - return type.contentType; + return type; } } - return null; + return JPG; } /** diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AttendanceArrangementVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AttendanceArrangementVo.java index 6c36bfad..77cb3442 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AttendanceArrangementVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AttendanceArrangementVo.java @@ -75,16 +75,20 @@ public class AttendanceArrangementVo implements Serializable { @ExcelProperty(value = "状态:0-未生效,1-已生效") private Long status; + //考勤组 private AttendanceGroup attendanceGroup; + //用户组 private List userGroupList; + //固定排班 private AttendanceWeekSet weekSet; + //班次 private AttendanceShift shift; - private AttendanceScheduleCycle cycle; + //排班制 + private AttendanceScheduleCycle scheduleCycle; - private AttendanceUserGroup userGroup; } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java new file mode 100644 index 00000000..391fbe35 --- /dev/null +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteBuildingServiceImpl.java @@ -0,0 +1,37 @@ +package org.dromara.property.dubbo; + +import lombok.RequiredArgsConstructor; +import org.apache.dubbo.config.annotation.DubboService; +import org.dromara.property.api.RemoteBuildingService; +import org.dromara.property.api.domain.vo.RemoteBuildingVo; +import org.dromara.property.domain.vo.TbBuildingVo; +import org.dromara.property.domain.vo.TbUnitVo; +import org.dromara.property.service.ITbBuildingService; +import org.dromara.property.service.ITbUnitService; + +/** + * 对外提供的远程服务调用 + * + * @author lxj + */ +@DubboService +@RequiredArgsConstructor +public class RemoteBuildingServiceImpl implements RemoteBuildingService { + + private final ITbBuildingService iTbBuildingService; + + + @Override + public RemoteBuildingVo queryBuildingById(Long id) { + TbBuildingVo tbBuildingVo = iTbBuildingService.queryById(id); + if(tbBuildingVo == null) { + return null; + } + RemoteBuildingVo remoteBuildingVo = new RemoteBuildingVo(); + remoteBuildingVo.setId(tbBuildingVo.getId()); + remoteBuildingVo.setCommunityId(tbBuildingVo.getCommunityId()); + remoteBuildingVo.setBuildingName(tbBuildingVo.getBuildingName()); + remoteBuildingVo.setFloorCount(tbBuildingVo.getFloorCount()); + return remoteBuildingVo; + } +} diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java deleted file mode 100644 index 7016393e..00000000 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteUnitServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.dromara.property.dubbo; - -import lombok.RequiredArgsConstructor; -import org.apache.dubbo.config.annotation.DubboService; -import org.dromara.common.core.utils.MapstructUtils; -import org.dromara.property.api.RemoteUnitService; -import org.dromara.property.api.domain.vo.RemoteUnitVo; -import org.dromara.property.domain.vo.TbUnitVo; -import org.dromara.property.service.ITbUnitService; - -/** - * 对外提供的远程服务调用 - * - * @author lxj - */ -@DubboService -@RequiredArgsConstructor -public class RemoteUnitServiceImpl implements RemoteUnitService { - - private final ITbUnitService tbUnitService; - - - @Override - public RemoteUnitVo queryUnitById(Long id) { - TbUnitVo tbUnitVo = tbUnitService.queryById(id); - if(tbUnitVo == null) { - return null; - } - RemoteUnitVo remoteUnitVo = new RemoteUnitVo(); - remoteUnitVo.setId(tbUnitVo.getId()); - remoteUnitVo.setCommunityId(tbUnitVo.getCommunityId()); - remoteUnitVo.setBuildingId(tbUnitVo.getBuildingId()); - remoteUnitVo.setUnitName(tbUnitVo.getUnitName()); - remoteUnitVo.setFloorCount(tbUnitVo.getFloorCount()); - remoteUnitVo.setHouseholdCount(tbUnitVo.getHouseholdCount()); - remoteUnitVo.setStairCount(tbUnitVo.getStairCount()); - return remoteUnitVo; - } -} diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AttendanceArrangementServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AttendanceArrangementServiceImpl.java index b12dd475..afada305 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AttendanceArrangementServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AttendanceArrangementServiceImpl.java @@ -20,8 +20,10 @@ import org.dromara.property.service.IAttendanceArrangementService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.DayOfWeek; import java.time.LocalDate; import java.time.ZoneId; +import java.time.temporal.WeekFields; import java.util.*; import java.util.stream.Collectors; @@ -78,90 +80,170 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS @Override public TableDataInfo queryPageList(AttendanceArrangementBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); - Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + + //查询当前日期在哪些排班中,当前日期大于等于排班开始日期,小于等于排班结束日期 + LambdaQueryWrapper ge = lqw + .le(AttendanceArrangement::getStartDate, bo.getCurrentDate()) + .ge(AttendanceArrangement::getEndDate, bo.getCurrentDate()); + + Page result = baseMapper.selectVoPage(pageQuery.build(), ge); + + Page attendanceArrangementVoPage = result.setRecords(result.getRecords().stream().map(vo -> { + //根据当前日期查询在开始时间和结束时间之间的排班信息 + //从前端查询出来的当前日期,判断是否在排班时间内 + if (bo.getCurrentDate().isAfter(vo.getStartDate()) && bo.getCurrentDate().isBefore(vo.getEndDate())) { + //1.查询人员表信息 + //根据查询出来的result取出shceduleId + Long scheduleId = vo.getId(); + //根据排班的id查询出排班的人员详细信息 + List userGroupList = userGroupMapper.selectList(Wrappers.lambdaQuery().in(AttendanceUserGroup::getScheduleId, scheduleId)); + vo.setUserGroupList(userGroupList); + + //2.查询考勤组信息 + //根据查询出来的信息取出考勤组的id + Long groupId = vo.getGroupId(); + //根据考勤组的id查询出考勤组的详细信息 + AttendanceGroup attendanceGroup = attendanceGroupMapper.selectById(groupId); + //将考勤组的信息存到vo中 + vo.setAttendanceGroup(attendanceGroup); + + //3.查询班制信息 + //判断当前考勤组的班制是固定班制还是排班制 + if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.FIXEDSCHEDULE)) { + //3.1固定班制 + //根据考勤组id查询出班制信息的dayOfWeek + List weekSetList = weekSetMapper.selectList(Wrappers.lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId)); + //将当前日期转换为周几 + int weekNumber = bo.getCurrentDate().getDayOfWeek().getValue(); + //匹配weekNumber和weekSetList中的dayOfWeek,匹配成功则将weekSet存到vo中 + AttendanceWeekSet attendanceWeekSet = weekSetList.stream().filter(weekSet -> weekSet.getDayOfWeek() == weekNumber).findFirst().orElse(null); + //根据过滤出来的attendanceWeekSet的weekSetId查询出shiftId + Long shiftId = attendanceWeekSet.getShiftId(); + //根据shiftId查询出班次的详细信息 + AttendanceShift attendanceShift = attendanceShiftMapper.selectById(shiftId); + //将attendanceShift存到vo中 + vo.setShift(attendanceShift); - Page attendanceArrangementVoPage = result.setRecords(result.getRecords().stream().peek(vo -> { - //1.根据当前日期查询在开始时间和结束时间之间的排班信息 - //查询指定日期查询在哪些排班中,并返回arrangementList - List arrangementList = baseMapper.selectList( - Wrappers.lambdaQuery() - .ge(AttendanceArrangement::getStartDate, bo.getCurrentDate()) - .le(AttendanceArrangement::getEndDate, bo.getCurrentDate()) - ); - //根据排班查询出考勤组id - List groupIds = arrangementList.stream().map(AttendanceArrangement::getGroupId).distinct().toList(); + }else if (Objects.equals(attendanceGroup.getAttendanceType(), StatusConstant.SHIFTSCHEDULE)) { + //3.2排班制 - // 2.循环将所有的考勤组id设置到考勤组中 - //循环groupIds,循环和AttendanceGroup中的id做对比,如果有相同的,则取出attendanceGroup中的所有数据 - groupIds.forEach( - groupId -> { - //从数据库查询出当前考勤组的所有数据 - AttendanceGroup group = attendanceGroupMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceGroup::getId, groupId)); + //将startDate作为第一天,endDate作为最后一天,循环判断当前日期是第几天,取出当前天数的班次信息。 + LocalDate startDate = vo.getStartDate(); + LocalDate endDate = vo.getEndDate(); + LocalDate currentDate = bo.getCurrentDate(); +// //统计当前考勤组有多少条数据 +// int count = Math.toIntExact(scheduleCycleMapper.selectCount(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId))); - // 3.查询出当前考勤组的所有数据,从考勤组判断当前id是固定班制还是排班制 - if (group.getAttendanceType().equals(StatusConstant.FIXEDSCHEDULE)) { - // 3.1固定班制:将当前的日期转为周几,然后与数据库中的班次周数作对比,取出当前日期的班次信息 - //将传来的日期参数转为周几 -// int week = DateUtil.dayOfWeek(bo.getCurrentDate()); - int week = 1; - //取出当前日期的周数,与数据库中的班次周数作对比,取出当前日期的班次信息 - AttendanceWeekSet weekSet = weekSetMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId).eq(AttendanceWeekSet::getDayOfWeek, week)); - //将weekSet存到结果中 - vo.setWeekSet(weekSet); - //根据weekSet取出id,根据id查询出attendanceWeekSetShift表中的shiftId - Long shiftId = weekSet.getId(); - //根据shiftId查询attendanceShift表中对应的id的数据 - AttendanceShift shift = attendanceShiftMapper.selectById(shiftId); - //将shift存到结果中 - vo.setShift(shift); - } else if (group.getAttendanceType().equals(StatusConstant.SHIFTSCHEDULE)) { - // 3.2排班制:判断第一天是从几号开始,循环判断,判断当前是循环中的第几天,取出当前天数的班次信息。 - //取出排班中的开始时间和结束时间 - LocalDate startDate = bo.getStartDate(); - LocalDate endDate = bo.getEndDate(); - LocalDate currentDate = bo.getCurrentDate(); - //统计当前考勤组有多少条数据 - int count = Math.toIntExact(scheduleCycleMapper.selectCount(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId))); - - - //todo: 匹配天数 - - - //取出attendanceScheduleCycle表中的天数 - Integer cycleDays = scheduleCycleMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).getDayNumber(); - //在startDate和endDate之间循环,判端当前日期是cycleDays中的第几天 - int cycleDay = 0; - while (startDate.isBefore(currentDate) || endDate.isAfter(currentDate)) { - cycleDay++; -// startDate = DateUtil.offsetDay(startDate, 1); - //判断当前日期是clcleDays中的第几天 - if (cycleDay > cycleDays) { - cycleDay = 1; + //取出attendanceScheduleCycle表中的天数 + List cycleDaysList = scheduleCycleMapper.selectList(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).stream().map(AttendanceScheduleCycle::getDayNumber).collect(Collectors.toList()); + // 在startDate和endDate之间循环,判端当前日期是cycleDays中的第几天 + int cycleDay = 1; // 初始化 cycleDay 为 1 + for (LocalDate date = startDate; date.isBefore(endDate) || date.isEqual(endDate); date = date.plusDays(1)) { + if (date.isEqual(currentDate)) { + // 判断当前日期是cycleDays中的第几天 + int dayNumber = date.getDayOfYear() - startDate.getDayOfYear() + 1; + cycleDay = dayNumber % cycleDaysList.size(); + if (cycleDay == 0) { + cycleDay = cycleDaysList.size(); } + // 根据cycleDay查询出当前日期的班次信息 + AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.lambdaQuery() + .eq(AttendanceScheduleCycle::getGroupId, groupId) + .eq(AttendanceScheduleCycle::getDayNumber, cycleDay)); + //将cycle存到vo中 + vo.setScheduleCycle(cycle); + //根据cycleId查询出shiftId + Long cycleId = cycle.getId(); + AttendanceShift shift = attendanceShiftMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceShift::getId, cycle.getShiftId())); + //将shift存到vo中 + vo.setShift(shift); + break; // 找到当前日期后跳出循环 } - //根据cycleDay查询出当前日期的班次信息 - AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId).eq(AttendanceScheduleCycle::getDayNumber, cycleDay)); - //将cycle存到结果中 - vo.setCycle(cycle); - } + + + + //根据cycleDay查询出当前日期的班次信息 + AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId).eq(AttendanceScheduleCycle::getDayNumber, cycleDay)); + //将cycle存到vo中 + vo.setScheduleCycle(cycle); + } - ); -// AttendanceArrangementVo arrangementvo = baseMapper.selectVoByTime(bo.getCurrentDate()); -// //2.查询人员组的信息 -// //根据开始时间查询出所有的排班id -// List scheduleIdList = baseMapper.selectList(Wrappers.lambdaQuery().ge(AttendanceArrangement::getStartDate, bo.getCurrentDate())).stream().map(AttendanceArrangement::getId).collect(Collectors.toList()); -// //根据排班的id查询出排班的人员详细信息 -// List userGroupList = userGroupMapper.selectList(Wrappers.lambdaQuery().in(AttendanceUserGroup::getScheduleId, scheduleIdList)); -// //将排班人员信息添加到排班信息中 -// arrangementvo.setUserGroupList(userGroupList); + } else { + TableDataInfo.build(); + } + +// //1.根据当前日期查询在开始时间和结束时间之间的排班信息 +// //查询指定日期查询在哪些排班中,并返回arrangementList +// List arrangementList = baseMapper.selectList( +// Wrappers.lambdaQuery() +// .ge(AttendanceArrangement::getStartDate, bo.getCurrentDate()) +// .le(AttendanceArrangement::getEndDate, bo.getCurrentDate()) +// ); +// //根据排班查询出考勤组id +// List groupIds = arrangementList.stream().map(AttendanceArrangement::getGroupId).distinct().toList(); // -// //3.根据排班的id查询出排班的考勤组id -// List groupIds = baseMapper.selectList(Wrappers.lambdaQuery().ge(AttendanceArrangement::getStartDate, bo.getCurrentDate())).stream().map(AttendanceArrangement::getGroupId).distinct().collect(Collectors.toList()); -// //判断考勤组是排班制还是固定班制 +// // 2.循环将所有的考勤组id设置到考勤组中 +// //循环groupIds,循环和AttendanceGroup中的id做对比,如果有相同的,则取出attendanceGroup中的所有数据 +// groupIds.forEach( +// groupId -> { +// //从数据库查询出当前考勤组的所有数据 +// AttendanceGroup group = attendanceGroupMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceGroup::getId, groupId)); +// +// // 3.查询出当前考勤组的所有数据,从考勤组判断当前id是固定班制还是排班制 +// if (group.getAttendanceType().equals(StatusConstant.FIXEDSCHEDULE)) { +// // 3.1固定班制:将当前的日期转为周几,然后与数据库中的班次周数作对比,取出当前日期的班次信息 +// //将传来的日期参数转为周几 +//// int week = DateUtil.dayOfWeek(bo.getCurrentDate()); +// int week = 1; +// //取出当前日期的周数,与数据库中的班次周数作对比,取出当前日期的班次信息 +// AttendanceWeekSet weekSet = weekSetMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId).eq(AttendanceWeekSet::getDayOfWeek, week)); +// //将weekSet存到结果中 +// vo.setWeekSet(weekSet); +// //根据weekSet取出id,根据id查询出attendanceWeekSetShift表中的shiftId +// Long shiftId = weekSet.getId(); +// //根据shiftId查询attendanceShift表中对应的id的数据 +// AttendanceShift shift = attendanceShiftMapper.selectById(shiftId); +// //将shift存到结果中 +// vo.setShift(shift); +// } else if (group.getAttendanceType().equals(StatusConstant.SHIFTSCHEDULE)) { +// // 3.2排班制:判断第一天是从几号开始,循环判断,判断当前是循环中的第几天,取出当前天数的班次信息。 +// //取出排班中的开始时间和结束时间 +// LocalDate startDate = bo.getStartDate(); +// LocalDate endDate = bo.getEndDate(); +// LocalDate currentDate = bo.getCurrentDate(); +// //统计当前考勤组有多少条数据 +// int count = Math.toIntExact(scheduleCycleMapper.selectCount(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId))); +// +// +// //todo: 匹配天数 +// +// +// //取出attendanceScheduleCycle表中的天数 +// Integer cycleDays = scheduleCycleMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).getDayNumber(); +// //在startDate和endDate之间循环,判端当前日期是cycleDays中的第几天 +// int cycleDay = 0; +// while (startDate.isBefore(currentDate) || endDate.isAfter(currentDate)) { +// cycleDay++; +//// startDate = DateUtil.offsetDay(startDate, 1); +// //判断当前日期是clcleDays中的第几天 +// if (cycleDay > cycleDays) { +// cycleDay = 1; +// } +// } +// //根据cycleDay查询出当前日期的班次信息 +// AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId).eq(AttendanceScheduleCycle::getDayNumber, cycleDay)); +// //将cycle存到结果中 +// vo.setCycle(cycle); +// +// } +// } +// ); + + return vo; }).collect(Collectors.toList())); @@ -202,7 +284,6 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS // List userGroupList = userGroupMapper.selectList(Wrappers.lambdaQuery().in(AttendanceUserGroup::getScheduleId, scheduleIdList)); - // 根据排班查询出考勤组id List groupIds = arrangementList.stream() .map(AttendanceArrangement::getGroupId) diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisAlarmEventAttachments.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisAlarmEventAttachments.java index 7e34cfbd..808aacc7 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisAlarmEventAttachments.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisAlarmEventAttachments.java @@ -36,7 +36,7 @@ public class SisAlarmEventAttachments extends TenantEntity { /** * 时间图片id */ - private String ossId; + private Long ossId; /** * 1:图片,2:文件;3视频 diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisDeviceManage.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisDeviceManage.java index 10ef03ea..e18bbf54 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisDeviceManage.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisDeviceManage.java @@ -77,4 +77,7 @@ public class SisDeviceManage extends BaseEntity { * 设备组id */ private Long groupId; + + private String tenantId; + } diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisElevatorFloorChannelRef.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisElevatorFloorChannelRef.java new file mode 100644 index 00000000..925f4bf9 --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/SisElevatorFloorChannelRef.java @@ -0,0 +1,51 @@ +package org.dromara.sis.domain; + +import org.dromara.common.tenant.core.TenantEntity; +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 电梯⇄楼层⇄通道关联对象 sis_elevator_floor_channel_ref + * + * @author lsm + * @date 2025-08-04 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("sis_elevator_floor_channel_ref") +public class SisElevatorFloorChannelRef extends TenantEntity { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @TableId(value = "id") + private Long id; + + /** + * 楼层id + */ + private Long floorId; + + /** + * 电梯id + */ + private Long elevatorId; + + /** + * 内部通道号 + */ + private Long inChannel; + + /** + * 外部通道号 + */ + private Long outChannel; + + +} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventAttachmentsBo.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventAttachmentsBo.java index 5fdc96fe..a66bb97c 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventAttachmentsBo.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventAttachmentsBo.java @@ -35,7 +35,7 @@ public class SisAlarmEventAttachmentsBo extends BaseEntity { /** * 时间图片id */ - private String ossId; + private Long ossId; /** * 1:图片,2:文件;3视频 diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorFloorChannelRefBo.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorFloorChannelRefBo.java new file mode 100644 index 00000000..4ce2864d --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorFloorChannelRefBo.java @@ -0,0 +1,52 @@ +package org.dromara.sis.domain.bo; + +import org.dromara.sis.domain.SisElevatorFloorChannelRef; +import org.dromara.common.mybatis.core.domain.BaseEntity; +import org.dromara.common.core.validate.AddGroup; +import org.dromara.common.core.validate.EditGroup; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; +import jakarta.validation.constraints.*; + +/** + * 电梯⇄楼层⇄通道关联业务对象 sis_elevator_floor_channel_ref + * + * @author lsm + * @date 2025-08-04 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = SisElevatorFloorChannelRef.class, reverseConvertGenerate = false) +public class SisElevatorFloorChannelRefBo extends BaseEntity { + + /** + * 主键id + */ + @NotNull(message = "主键id不能为空", groups = { EditGroup.class }) + private Long id; + + /** + * 楼层id + */ + @NotNull(message = "楼层id不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long floorId; + + /** + * 电梯id + */ + @NotNull(message = "电梯id不能为空", groups = { AddGroup.class, EditGroup.class }) + private Long elevatorId; + + /** + * 内部通道号 + */ + private Long inChannel; + + /** + * 外部通道号 + */ + private Long outChannel; + + +} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorInfoBo.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorInfoBo.java index e5a725c0..a81c6f0a 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorInfoBo.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisElevatorInfoBo.java @@ -135,12 +135,12 @@ public class SisElevatorInfoBo extends BaseEntity { /** * 建筑id */ + @NotNull(message = "建筑不能为空", groups = {AddGroup.class, EditGroup.class}) private Long buildingId; /** * 单元编码 */ - @NotNull(message = "不能为空", groups = {AddGroup.class, EditGroup.class}) private Long unitId; /** @@ -153,6 +153,19 @@ public class SisElevatorInfoBo extends BaseEntity { */ private DeviceInfo elevatorControlDeviceId; + /** + * 通道信息 + */ + private List channels; + + + @Data + public static class ChannelInfo { + private Long floorId; + private Long inChannel; + private Long outChannel; + } + @Data public static class DeviceInfo { diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisAlarmEventAttachmentsVo.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisAlarmEventAttachmentsVo.java index ca0c1380..0cf84127 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisAlarmEventAttachmentsVo.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisAlarmEventAttachmentsVo.java @@ -40,7 +40,7 @@ public class SisAlarmEventAttachmentsVo implements Serializable { * 时间图片id */ @ExcelProperty(value = "时间图片id") - private String ossId; + private Long ossId; /** * 1:图片,2:文件;3视频 diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisElevatorFloorChannelRefVo.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisElevatorFloorChannelRefVo.java new file mode 100644 index 00000000..3aedcabf --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/vo/SisElevatorFloorChannelRefVo.java @@ -0,0 +1,62 @@ +package org.dromara.sis.domain.vo; + +import org.dromara.sis.domain.SisElevatorFloorChannelRef; +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import org.dromara.common.excel.annotation.ExcelDictFormat; +import org.dromara.common.excel.convert.ExcelDictConvert; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.Date; + + + +/** + * 电梯⇄楼层⇄通道关联视图对象 sis_elevator_floor_channel_ref + * + * @author lsm + * @date 2025-08-04 + */ +@Data +@ExcelIgnoreUnannotated +@AutoMapper(target = SisElevatorFloorChannelRef.class) +public class SisElevatorFloorChannelRefVo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + @ExcelProperty(value = "主键id") + private Long id; + + /** + * 楼层id + */ + @ExcelProperty(value = "楼层id") + private Long floorId; + + /** + * 电梯id + */ + @ExcelProperty(value = "电梯id") + private Long elevatorId; + + /** + * 内部通道号 + */ + @ExcelProperty(value = "内部通道号") + private Long inChannel; + + /** + * 外部通道号 + */ + @ExcelProperty(value = "外部通道号") + private Long outChannel; + + +} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/mapper/SisElevatorFloorChannelRefMapper.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/mapper/SisElevatorFloorChannelRefMapper.java new file mode 100644 index 00000000..27ce7a9b --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/mapper/SisElevatorFloorChannelRefMapper.java @@ -0,0 +1,17 @@ +package org.dromara.sis.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.dromara.sis.domain.SisElevatorFloorChannelRef; +import org.dromara.sis.domain.vo.SisElevatorFloorChannelRefVo; +import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; + +/** + * 电梯⇄楼层⇄通道关联Mapper接口 + * + * @author lsm + * @since 2025-08-04 + */ +@Mapper +public interface SisElevatorFloorChannelRefMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisAlarmEventAttachmentsService.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisAlarmEventAttachmentsService.java index 89feccd8..ec99b37d 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisAlarmEventAttachmentsService.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisAlarmEventAttachmentsService.java @@ -2,6 +2,7 @@ package org.dromara.sis.service; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.sis.domain.SisAlarmEventAttachments; import org.dromara.sis.domain.bo.SisAlarmEventAttachmentsBo; import org.dromara.sis.domain.vo.SisAlarmEventAttachmentsVo; @@ -65,4 +66,13 @@ public interface ISisAlarmEventAttachmentsService { * @return 是否删除成功 */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 批量写入事件附件表 + * + * @param ls 附件数据 + * @return 返回写入数量 + */ + Boolean batchInsert(List ls); + } diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisDeviceManageService.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisDeviceManageService.java index 68b45bca..4cdb47a7 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisDeviceManageService.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisDeviceManageService.java @@ -76,6 +76,7 @@ public interface ISisDeviceManageService { */ SisDeviceManageVo queryVoByDeviceIp(String deviceIp); + SisDeviceManage queryByDeviceIp(String deviceId); /** * 查询设备数 * diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisElevatorFloorChannelRefService.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisElevatorFloorChannelRefService.java new file mode 100644 index 00000000..4037e412 --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/ISisElevatorFloorChannelRefService.java @@ -0,0 +1,78 @@ +package org.dromara.sis.service; + +import org.dromara.sis.domain.SisElevatorFloorChannelRef; +import org.dromara.sis.domain.vo.SisElevatorFloorChannelRefVo; +import org.dromara.sis.domain.bo.SisElevatorFloorChannelRefBo; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; + +import java.util.Collection; +import java.util.List; + +/** + * 电梯⇄楼层⇄通道关联Service接口 + * + * @author lsm + * @since 2025-08-04 + */ +public interface ISisElevatorFloorChannelRefService { + + /** + * 查询电梯⇄楼层⇄通道关联 + * + * @param id 主键 + * @return 电梯⇄楼层⇄通道关联 + */ + SisElevatorFloorChannelRefVo queryById(Long id); + + /** + * 分页查询电梯⇄楼层⇄通道关联列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 电梯⇄楼层⇄通道关联分页列表 + */ + TableDataInfo queryPageList(SisElevatorFloorChannelRefBo bo, PageQuery pageQuery); + + /** + * 查询符合条件的电梯⇄楼层⇄通道关联列表 + * + * @param bo 查询条件 + * @return 电梯⇄楼层⇄通道关联列表 + */ + List queryList(SisElevatorFloorChannelRefBo bo); + + /** + * 新增电梯⇄楼层⇄通道关联 + * + * @param bo 电梯⇄楼层⇄通道关联 + * @return 是否新增成功 + */ + Boolean insertByBo(SisElevatorFloorChannelRefBo bo); + + /** + * 修改电梯⇄楼层⇄通道关联 + * + * @param bo 电梯⇄楼层⇄通道关联 + * @return 是否修改成功 + */ + Boolean updateByBo(SisElevatorFloorChannelRefBo bo); + + /** + * 校验并批量删除电梯⇄楼层⇄通道关联信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 批量增加电梯⇄楼层⇄通道关联信息 + * + * @param elevatorId 电梯id + * @param bo 电梯⇄楼层⇄通道关联 + * @return 是否添加成功 + */ + Boolean batchInsert(Long elevatorId, Collection bo); +} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventAttachmentsServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventAttachmentsServiceImpl.java index b3da1c3f..1440804d 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventAttachmentsServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventAttachmentsServiceImpl.java @@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.utils.MapstructUtils; -import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.sis.domain.SisAlarmEventAttachments; @@ -40,7 +39,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach * @return 【请填写功能名称】 */ @Override - public SisAlarmEventAttachmentsVo queryById(Long id){ + public SisAlarmEventAttachmentsVo queryById(Long id) { return baseMapper.selectVoById(id); } @@ -75,7 +74,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.orderByAsc(SisAlarmEventAttachments::getId); lqw.eq(bo.getEventId() != null, SisAlarmEventAttachments::getEventId, bo.getEventId()); - lqw.eq(StringUtils.isNotBlank(bo.getOssId()), SisAlarmEventAttachments::getOssId, bo.getOssId()); + lqw.eq(bo.getOssId() != null, SisAlarmEventAttachments::getOssId, bo.getOssId()); lqw.eq(bo.getType() != null, SisAlarmEventAttachments::getType, bo.getType()); return lqw; } @@ -113,7 +112,7 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach /** * 保存前的数据校验 */ - private void validEntityBeforeSave(SisAlarmEventAttachments entity){ + private void validEntityBeforeSave(SisAlarmEventAttachments entity) { //TODO 做一些数据校验,如唯一约束 } @@ -126,9 +125,14 @@ public class SisAlarmEventAttachmentsServiceImpl implements ISisAlarmEventAttach */ @Override public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { - if(isValid){ + if (isValid) { //TODO 做一些业务上的校验,判断是否需要校验 } return baseMapper.deleteByIds(ids) > 0; } + + @Override + public Boolean batchInsert(List ls) { + return baseMapper.insertBatch(ls); + } } diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java index 28680f85..f0ed7bbc 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java @@ -11,19 +11,21 @@ import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.resource.api.RemoteFileService; +import org.dromara.resource.api.domain.RemoteFile; +import org.dromara.sis.domain.SisAlarmEventAttachments; import org.dromara.sis.domain.SisAlarmEvents; +import org.dromara.sis.domain.SisDeviceManage; import org.dromara.sis.domain.bo.SisAlarmEventsBo; import org.dromara.sis.domain.vo.SisAlarmEventsVo; -import org.dromara.sis.domain.vo.SisDeviceManageVo; import org.dromara.sis.mapper.SisAlarmEventsMapper; +import org.dromara.sis.service.ISisAlarmEventAttachmentsService; import org.dromara.sis.service.ISisAlarmEventsService; import org.dromara.sis.service.ISisDeviceManageService; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 告警Service业务层处理 @@ -38,9 +40,11 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { private final SisAlarmEventsMapper baseMapper; private final ISisDeviceManageService deviceManageService; + private final ISisAlarmEventAttachmentsService alarmEventAttachmentsService; @DubboReference private RemoteFileService remoteFileService; + /** * 查询告警 * @@ -48,7 +52,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { * @return 告警 */ @Override - public SisAlarmEventsVo queryById(Long id){ + public SisAlarmEventsVo queryById(Long id) { return baseMapper.selectVoById(id); } @@ -125,7 +129,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { /** * 保存前的数据校验 */ - private void validEntityBeforeSave(SisAlarmEvents entity){ + private void validEntityBeforeSave(SisAlarmEvents entity) { //TODO 做一些数据校验,如唯一约束 } @@ -138,7 +142,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { */ @Override public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { - if(isValid){ + if (isValid) { //TODO 做一些业务上的校验,判断是否需要校验 } return baseMapper.deleteByIds(ids) > 0; @@ -146,19 +150,49 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { @Async @Override + @Transactional(rollbackFor = Exception.class) public void createAlarmRecord(String deviceIp, Integer level, Integer type, byte[] smallImg, byte[] bigImg) { // 校验设备信息 - SisDeviceManageVo sisDeviceManageVo = deviceManageService.queryVoByDeviceIp(deviceIp); - if(sisDeviceManageVo == null){ + SisDeviceManage sisDeviceManage = deviceManageService.queryByDeviceIp(deviceIp); + if (sisDeviceManage == null) { log.error("设备信息不存在,放弃此条告警记录。"); return; } + // 生成时间信息 + SisAlarmEvents alarmEvents = new SisAlarmEvents(); + alarmEvents.setType(1L); + alarmEvents.setLevel(Long.valueOf(level)); + alarmEvents.setDeviceIp(deviceIp); + alarmEvents.setDeviceName(sisDeviceManage.getDeviceName()); + alarmEvents.setDeviceGroupId(sisDeviceManage.getId()); + alarmEvents.setReportTime(new Date()); + alarmEvents.setState(1); + alarmEvents.setTenantId(sisDeviceManage.getTenantId()); + alarmEvents.setCreateDept(sisDeviceManage.getCreateDept()); + int insert = this.baseMapper.insert(alarmEvents); + log.info("写入报警事件表完成,num={}", insert); + // 写入附件表 // 上传图片 - remoteFileService.upload(smallImg); - - - - + List ls = new ArrayList<>(); + if (smallImg != null && smallImg.length > 0) { + ls.add(createEventAttachments(smallImg, alarmEvents, sisDeviceManage)); + } + if (bigImg != null && bigImg.length > 0) { + ls.add(createEventAttachments(bigImg, alarmEvents, sisDeviceManage)); + } + Boolean flag = alarmEventAttachmentsService.batchInsert(ls); + log.info("写入告警事件附件表完成, reslut={}, size={}", flag, ls.size()); } + + public SisAlarmEventAttachments createEventAttachments(byte[] img, SisAlarmEvents alarmEvents, SisDeviceManage sisDeviceManage) { + RemoteFile result = remoteFileService.uploadImg(img); + SisAlarmEventAttachments attachments = new SisAlarmEventAttachments(); + attachments.setEventId(alarmEvents.getId()); + attachments.setOssId(result.getOssId()); + attachments.setType(1L); + attachments.setTenantId(sisDeviceManage.getTenantId()); + attachments.setCreateDept(sisDeviceManage.getCreateDept()); + return attachments; + } } diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDeviceManageServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDeviceManageServiceImpl.java index 6cf7f4ec..86973097 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDeviceManageServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisDeviceManageServiceImpl.java @@ -178,7 +178,14 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService { public SisDeviceManageVo queryVoByDeviceIp(String deviceIp) { LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.eq(SisDeviceManage::getDeviceIp, deviceIp); - return baseMapper.selectVoById(lqw); + return baseMapper.selectVoOne(lqw); + } + + @Override + public SisDeviceManage queryByDeviceIp(String deviceId) { + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.eq(SisDeviceManage::getDeviceIp, deviceId); + return baseMapper.selectOne(lqw); } @Override diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorFloorChannelRefServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorFloorChannelRefServiceImpl.java new file mode 100644 index 00000000..74c036eb --- /dev/null +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorFloorChannelRefServiceImpl.java @@ -0,0 +1,157 @@ +package org.dromara.sis.service.impl; + +import cn.hutool.core.lang.Assert; +import org.dromara.common.core.utils.MapstructUtils; +import org.dromara.common.core.utils.StringUtils; +import org.dromara.common.mybatis.core.page.TableDataInfo; +import org.dromara.common.mybatis.core.page.PageQuery; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.dromara.sis.domain.bo.SisElevatorFloorChannelRefBo; +import org.dromara.sis.domain.vo.SisElevatorFloorChannelRefVo; +import org.dromara.sis.domain.SisElevatorFloorChannelRef; +import org.dromara.sis.mapper.SisElevatorFloorChannelRefMapper; +import org.dromara.sis.service.ISisElevatorFloorChannelRefService; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; +import java.util.Collection; + +/** + * 电梯⇄楼层⇄通道关联Service业务层处理 + * + * @author lsm + * @date 2025-08-04 + */ +@Slf4j +@RequiredArgsConstructor +@Service +public class SisElevatorFloorChannelRefServiceImpl implements ISisElevatorFloorChannelRefService { + + private final SisElevatorFloorChannelRefMapper baseMapper; + + /** + * 查询电梯⇄楼层⇄通道关联 + * + * @param id 主键 + * @return 电梯⇄楼层⇄通道关联 + */ + @Override + public SisElevatorFloorChannelRefVo queryById(Long id) { + return baseMapper.selectVoById(id); + } + + /** + * 分页查询电梯⇄楼层⇄通道关联列表 + * + * @param bo 查询条件 + * @param pageQuery 分页参数 + * @return 电梯⇄楼层⇄通道关联分页列表 + */ + @Override + public TableDataInfo queryPageList(SisElevatorFloorChannelRefBo bo, PageQuery pageQuery) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + return TableDataInfo.build(result); + } + + /** + * 查询符合条件的电梯⇄楼层⇄通道关联列表 + * + * @param bo 查询条件 + * @return 电梯⇄楼层⇄通道关联列表 + */ + @Override + public List queryList(SisElevatorFloorChannelRefBo bo) { + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + return baseMapper.selectVoList(lqw); + } + + private LambdaQueryWrapper buildQueryWrapper(SisElevatorFloorChannelRefBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.orderByAsc(SisElevatorFloorChannelRef::getId); + lqw.eq(bo.getFloorId() != null, SisElevatorFloorChannelRef::getFloorId, bo.getFloorId()); + lqw.eq(bo.getElevatorId() != null, SisElevatorFloorChannelRef::getElevatorId, bo.getElevatorId()); + lqw.eq(bo.getInChannel() != null, SisElevatorFloorChannelRef::getInChannel, bo.getInChannel()); + lqw.eq(bo.getOutChannel() != null, SisElevatorFloorChannelRef::getOutChannel, bo.getOutChannel()); + return lqw; + } + + /** + * 新增电梯⇄楼层⇄通道关联 + * + * @param bo 电梯⇄楼层⇄通道关联 + * @return 是否新增成功 + */ + @Override + public Boolean insertByBo(SisElevatorFloorChannelRefBo bo) { + SisElevatorFloorChannelRef add = MapstructUtils.convert(bo, SisElevatorFloorChannelRef.class); + validEntityBeforeSave(add); + boolean flag = baseMapper.insert(add) > 0; + if (flag) { + bo.setId(add.getId()); + } + return flag; + } + + /** + * 修改电梯⇄楼层⇄通道关联 + * + * @param bo 电梯⇄楼层⇄通道关联 + * @return 是否修改成功 + */ + @Override + public Boolean updateByBo(SisElevatorFloorChannelRefBo bo) { + SisElevatorFloorChannelRef update = MapstructUtils.convert(bo, SisElevatorFloorChannelRef.class); + validEntityBeforeSave(update); + return baseMapper.updateById(update) > 0; + } + + /** + * 保存前的数据校验 + */ + private void validEntityBeforeSave(SisElevatorFloorChannelRef entity) { + //TODO 做一些数据校验,如唯一约束 + } + + /** + * 校验并批量删除电梯⇄楼层⇄通道关联信息 + * + * @param ids 待删除的主键集合 + * @param isValid 是否进行有效性校验 + * @return 是否删除成功 + */ + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if (isValid) { + //TODO 做一些业务上的校验,判断是否需要校验 + } + return baseMapper.deleteByIds(ids) > 0; + } + + /** + * 批量增加电梯⇄楼层⇄通道关联信息 + * + * @param elevatorId 电梯id + * @param bo 电梯⇄楼层⇄通道关联 + * @return 是否添加成功 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean batchInsert(Long elevatorId, Collection bo) { + // 先删除通道关系 + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.eq(SisElevatorFloorChannelRef::getElevatorId, elevatorId); + baseMapper.delete(lqw); + + boolean flag = baseMapper.insertBatch(bo); + Assert.isTrue(flag, "批量增加电梯⇄楼层⇄通道关联信息失败"); + return flag; + } +} diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java index 2b1bc9b7..bb48eae2 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisElevatorInfoServiceImpl.java @@ -13,15 +13,17 @@ import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.TableDataInfo; -import org.dromara.property.api.RemoteUnitService; -import org.dromara.property.api.domain.vo.RemoteUnitVo; +import org.dromara.property.api.RemoteBuildingService; +import org.dromara.property.api.domain.vo.RemoteBuildingVo; import org.dromara.sis.domain.SisDeviceBindRef; +import org.dromara.sis.domain.SisElevatorFloorChannelRef; import org.dromara.sis.domain.SisElevatorInfo; import org.dromara.sis.domain.bo.SisElevatorInfoBo; import org.dromara.sis.domain.enums.ControlTypeEnum; import org.dromara.sis.domain.vo.SisElevatorInfoVo; import org.dromara.sis.mapper.SisElevatorInfoMapper; import org.dromara.sis.service.ISisDeviceBindRefService; +import org.dromara.sis.service.ISisElevatorFloorChannelRefService; import org.dromara.sis.service.ISisElevatorInfoService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -43,9 +45,10 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService { private final SisElevatorInfoMapper baseMapper; private final ISisDeviceBindRefService deviceBindRefService; + private final ISisElevatorFloorChannelRefService elevatorFloorChannelRefService; @DubboReference - private RemoteUnitService remoteUnitService; + private RemoteBuildingService remoteBuildingService; /** * 查询电梯基本信息 @@ -137,17 +140,23 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService { @Override @Transactional(rollbackFor = Exception.class) public Boolean insertByBo(SisElevatorInfoBo bo) { - // 验证单元是否存在 - RemoteUnitVo remoteUnitVo = remoteUnitService.queryUnitById(bo.getUnitId()); - Assert.notNull(remoteUnitVo, "社区单元信息不存在。"); + // 验证建筑是否存在 + RemoteBuildingVo remoteBuildingVo = remoteBuildingService.queryBuildingById(bo.getBuildingId()); + Assert.notNull(remoteBuildingVo, "建筑信息不存在。"); + + // 数据转换 SisElevatorInfo add = MapstructUtils.convert(bo, SisElevatorInfo.class); Assert.notNull(add, "电梯信息处理失败。"); - add.setCommunityId(remoteUnitVo.getCommunityId()); - add.setBuildingId(remoteUnitVo.getBuildingId()); + + assert add != null; + add.setCommunityId(remoteBuildingVo.getCommunityId()); + add.setBuildingId(remoteBuildingVo.getId()); // 生成电梯编码 String code = ELEVATOR_CONTROL_CODE_PREFIX + IdUtil.getSnowflakeNextIdStr(); add.setElevatorCode(code); boolean flag = baseMapper.insert(add) > 0; + Assert.isTrue(flag, "新增电梯信息失败。"); + if (flag) { bo.setElevatorId(add.getElevatorId()); List ls = new ArrayList<>(); @@ -176,6 +185,22 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService { Boolean b = deviceBindRefService.batchInsert(ls); Assert.isTrue(b, "设备绑定关联关系写入失败!"); } + + // 写入电梯⇄楼层⇄通道关联表 + if(!bo.getChannels().isEmpty()){ + Collection channelRefs = new ArrayList<>(); + for (SisElevatorInfoBo.ChannelInfo channelInfo : bo.getChannels()) { + SisElevatorFloorChannelRef ref = new SisElevatorFloorChannelRef(); + ref.setElevatorId(add.getElevatorId()); + ref.setFloorId(channelInfo.getFloorId()); + ref.setInChannel(channelInfo.getInChannel()); + ref.setOutChannel(channelInfo.getOutChannel()); + channelRefs.add(ref); + } + Boolean b = elevatorFloorChannelRefService.batchInsert(add.getElevatorId(), channelRefs); + Assert.isTrue(b, "电梯楼层通道关联关系写入失败!"); + } + // hik sdk 登录 // short port = bo.getControlPort().shortValue(); // Boolean isLogin = HikApiService.getInstance().login(bo.getControlIp(), port, bo.getControlAccount(), bo.getControlPwd()); @@ -224,6 +249,21 @@ public class SisElevatorInfoServiceImpl implements ISisElevatorInfoService { Boolean b = deviceBindRefService.batchInsert(ls); Assert.isTrue(b, "设备绑定关联关系写入失败!"); } + + // 写入电梯⇄楼层⇄通道关联表 + if(!bo.getChannels().isEmpty()){ + Collection channelRefs = new ArrayList<>(); + for (SisElevatorInfoBo.ChannelInfo channelInfo : bo.getChannels()) { + SisElevatorFloorChannelRef ref = new SisElevatorFloorChannelRef(); + ref.setElevatorId(update.getElevatorId()); + ref.setFloorId(channelInfo.getFloorId()); + ref.setInChannel(channelInfo.getInChannel()); + ref.setOutChannel(channelInfo.getOutChannel()); + channelRefs.add(ref); + } + Boolean b = elevatorFloorChannelRefService.batchInsert(update.getElevatorId(), channelRefs); + Assert.isTrue(b, "电梯楼层通道关联关系写入失败!"); + } return baseMapper.updateById(update) > 0; } diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java index 306e57b9..ff8551cd 100644 --- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java +++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/dubbo/RemoteFileServiceImpl.java @@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboService; +import org.dromara.common.core.enums.ContentTypeEnum; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.Base64Utils; import org.dromara.common.core.utils.MapstructUtils; @@ -68,16 +69,33 @@ public class RemoteFileServiceImpl implements RemoteFileService { } @Override - public RemoteFile upload(byte[] file) throws ServiceException { - // 计算文件类型 - String type = Base64Utils.getType(file); - // 获contentType - - - - - - return null; + public RemoteFile uploadImg(byte[] file) throws ServiceException { + try { + // 计算文件类型 + String type = Base64Utils.getType(file); + // 获contentType + ContentTypeEnum contentTypeEnum = ContentTypeEnum.ContentTypeEnum(type); + OssClient storage = OssFactory.instance(); + UploadResult uploadResult = storage.uploadSuffix(file, type, contentTypeEnum.getContentType()); + // 保存文件信息 + SysOssBo oss = new SysOssBo(); + oss.setUrl(uploadResult.getUrl()); + oss.setFileSuffix(type); + oss.setFileName(uploadResult.getFilename()); + oss.setOriginalName(uploadResult.getFilename()); + oss.setService(storage.getConfigKey()); + sysOssService.insertByBo(oss); + RemoteFile sysFile = new RemoteFile(); + sysFile.setOssId(oss.getOssId()); + sysFile.setName(uploadResult.getFilename()); + sysFile.setUrl(uploadResult.getUrl()); + sysFile.setOriginalName(uploadResult.getFilename()); + sysFile.setFileSuffix(type); + return sysFile; + } catch (Exception e) { + log.error("上传文件失败", e); + throw new ServiceException("上传文件失败"); + } } /**