浏览代码

解决班级考勤统计不正确的问题

dzx 5 月之前
父节点
当前提交
ad9d6a073f

+ 14 - 5
src/main/java/com/xjrsoft/module/attendance/controller/StatisticsController.java

@@ -5,12 +5,14 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.OutInStatusEnum;
 import com.xjrsoft.common.enums.StudyStatusEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.attendance.vo.TeacherStatisticsVo;
 import com.xjrsoft.module.attendance.vo.VisitorInfoVo;
+import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.concat.service.IXjrUserService;
 import com.xjrsoft.module.organization.entity.UserDeptRelation;
 import com.xjrsoft.module.outint.entity.CarOutInRecord;
@@ -115,7 +117,7 @@ public class StatisticsController {
                             .le(CarOutInRecord::getRecordTime, endTime)
                             .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
                             .ge(dto.getTimePeriod() == 2 && amEndTime != null, CarOutInRecord::getRecordTime, amEndTime)
-                            .eq(CarOutInRecord::getStatus, 0)
+                            .eq(CarOutInRecord::getStatus, OutInStatusEnum.enter.getCode())
                             .orderByAsc(CarOutInRecord::getRecordTime)
             );
 
@@ -165,10 +167,11 @@ public class StatisticsController {
         MPJLambdaWrapper<XjrUser> queryWrapper = MPJWrappers.<XjrUser>lambdaJoin()
                 .disableSubLogicDel()
                 .distinct()
-                .eq(ObjectUtil.isNotNull(dto.getGradeId()), BaseStudentSchoolRoll::getGradeId, dto.getGradeId())
+                .eq(ObjectUtil.isNotNull(dto.getGradeId()), BaseClass::getGradeId, dto.getGradeId())
                 .eq(BaseStudentSchoolRoll::getArchivesStatus, "FB2901")
                 .eq(ObjectUtil.isNotNull(dto.getClassId()), BaseStudentSchoolRoll::getClassId, dto.getClassId())
                 .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, XjrUser::getId)
+                .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
                 .innerJoin(BaseStudent.class, BaseStudent::getUserId, XjrUser::getId);
         long allCount = xjrUserService.count(queryWrapper);
 
@@ -191,9 +194,15 @@ public class StatisticsController {
             }
 
             List<StudentOutInRecord> outInRecords = studentOutInRecordService.list(
-                    new QueryWrapper<StudentOutInRecord>().lambda()
-                            .between(StudentOutInRecord::getRecordTime, startTime, endTime)
-                            .eq(StudentOutInRecord::getStatus, 1)
+                    new MPJLambdaWrapper<StudentOutInRecord>()
+                            .select(StudentOutInRecord.class, x -> VoToColumnUtil.fieldsToColumns(StudentOutInRecord.class).contains(x.getProperty()))
+                            .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, StudentOutInRecord::getUserId)
+                            .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
+                            .le(StudentOutInRecord::getRecordTime, endTime)
+                            .eq("DATE_FORMAT(record_time, '%Y-%m-%d')", endTime.toLocalDate())
+                            .eq(StudentOutInRecord::getStatus, OutInStatusEnum.enter.getCode())
+                            .eq(ObjectUtil.isNotNull(dto.getClassId()), BaseStudentSchoolRoll::getClassId, dto.getClassId())
+                            .eq(ObjectUtil.isNotNull(dto.getGradeId()), BaseClass::getGradeId, dto.getGradeId())
             );
             //实到人数
             Set<Long> collect = outInRecords.stream().map(StudentOutInRecord::getUserId).collect(Collectors.toSet());

+ 1 - 4
src/main/java/com/xjrsoft/module/attendance/controller/StudentStatisticsController.java

@@ -284,10 +284,7 @@ public class StudentStatisticsController {
     @SaCheckPermission("statistics:detail")
     public RT<PageOutput<ClassStatisticsVo>> classHistory(@Valid AttendanceStatisticDto dto){
         Page<ClassStatisticsVo> attendancePage = classService.getAttendancePage(new Page<>(dto.getLimit(), dto.getSize()), dto);
-        List<Long> classIds = new ArrayList<>();
-        for (ClassStatisticsVo record : attendancePage.getRecords()) {
-            classIds.add(record.getId());
-        }
+        List<Long> classIds = attendancePage.getRecords().stream().map(ClassStatisticsVo::getId).collect(Collectors.toList());
         if(dto.getStartTime() != null && !"".equals(dto.getStartTime()) && dto.getEndTime() != null && !"".equals(dto.getEndTime())){
             DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
             LocalDateTime startTime = LocalDate.parse(dto.getStartTime(), formatter).atTime(0, 0, 0);

+ 1 - 1
src/main/java/com/xjrsoft/module/attendance/controller/TeacherStatisticsController.java

@@ -175,7 +175,7 @@ public class TeacherStatisticsController {
                 }
                 TeacherOutInRecordDto outInDto = new TeacherOutInRecordDto();
                 outInDto.setQueryDate(startTime.toLocalDate());
-                outInDto.setRecordTime(startTime);
+                outInDto.setRecordTime(endTime);
                 outInDto.setStatus(OutInStatusEnum.enter.getCode());
                 outInDto.setUserId(record.getUserId());
                 List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.getListByParam(outInDto);

+ 1 - 0
src/main/java/com/xjrsoft/module/outint/controller/TeacherOutInRecordController.java

@@ -71,6 +71,7 @@ public class TeacherOutInRecordController {
                         ext->ext.selectAs(XjrUser::getCredentialNumber, TeacherOutInRecordPageVo::getIdentityCard)
                         .selectAs(XjrUser::getMobile,TeacherOutInRecordPageVo::getPhone)
                         .select(XjrUser::getName))
+                .leftJoin("xjr_dictionary_detail t2 ON (t2.code = t1.gender) and t2.item_id = ")
                 .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode, XjrUser::getGender, ext->ext.selectAs(DictionaryDetail::getName, TeacherOutInRecordPageVo::getGender));
 
         if(ObjectUtil.isNotNull(dto.getDeptId()) && dto.getDeptId() != 0){