| | |
| | | package cn.lihu.jh.module.ecg.dal.mysql.jobrecord; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | import cn.lihu.jh.framework.common.pojo.PageResult; |
| | | import cn.lihu.jh.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.lihu.jh.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.jobrecord.JobRecordDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.jobrecord.JobRecordStatisticDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import cn.lihu.jh.module.ecg.controller.admin.jobrecord.vo.*; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | |
| | | /** |
| | | * 工作记录 Mapper |
| | |
| | | |
| | | default PageResult<JobRecordDO> selectPage(JobRecordPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<JobRecordDO>() |
| | | .eqIfPresent(JobRecordDO::getJobType, reqVO.getJobType()) |
| | | //.eqIfPresent(JobRecordDO::getJobType, reqVO.getJobType()) |
| | | .inIfPresent(JobRecordDO::getJobType, reqVO.getJobType()) |
| | | .eqIfPresent(JobRecordDO::getDocId, reqVO.getDocId()) |
| | | .likeIfPresent(JobRecordDO::getDocName, reqVO.getDocName()) |
| | | .eqIfPresent(JobRecordDO::getDevId, reqVO.getDevId()) |
| | |
| | | .eqIfPresent(JobRecordDO::getRemark, reqVO.getRemark()) |
| | | .betweenIfPresent(JobRecordDO::getCreateTime, reqVO.getCreateTime()) |
| | | .eqIfPresent(JobRecordDO::getRentId, reqVO.getRentId()) |
| | | // 按诊室的检查项目隔离已完成记录(详见 JobRecordPageReqVO#checkTypes 注释) |
| | | .inIfPresent(JobRecordDO::getCheckType, reqVO.getCheckTypes()) |
| | | .orderByDesc(JobRecordDO::getId)); |
| | | } |
| | | |
| | | @Select("SELECT * FROM lihu.job_record where rent_id=#{rentId} and job_type=#{jobType} and doc_id=#{docId} limit 1") |
| | | JobRecordDO selectByRentIdJobTypeDocId(@Param("rentId") Long rentId, @Param("jobType") Integer jobType, @Param("docId") Long docId ); |
| | | } |
| | | @Select("<script> " + |
| | | "SELECT * FROM lihu.job_record " + |
| | | " where rent_id=#{rentId} and doc_id=#{docId} and job_type in (" + |
| | | " <foreach collection='jobTypeList' separator=',' item='jobType'>" + |
| | | " #{jobType} " + |
| | | " </foreach> )" + |
| | | " limit 1;" + |
| | | " </script>") |
| | | JobRecordDO selectByRentIdDocId(@Param("rentId") Long rentId, @Param("docId") Long docId, @Param("jobTypeList") List<Integer> jobTypeList ); |
| | | |
| | | @Select("SELECT count(1) FROM lihu.job_record where pat_id=#{patId} and TO_DAYS(job_time)=TO_DAYS(#{jobTime}) and job_type=#{jobType} ") |
| | | Integer getPatientJobNum(@Param("patId") String patId, @Param("jobTime") LocalDateTime jobTime, @Param("jobType") Integer jobType ); |
| | | |
| | | /** |
| | | * 工作量统计(按 年/月/医生/作业类型 汇总)。 |
| | | * |
| | | * <p>【ONLY_FULL_GROUP_BY】doc_name 是 job_record 上的冗余列,不参与分组, |
| | | * 直接 select 会在 MySQL 8 默认 sql_mode(含 ONLY_FULL_GROUP_BY)下报 |
| | | * “Expression #4 of SELECT list is not in GROUP BY clause ...”,页面表现为“系统异常”。 |
| | | * 本机库的 sql_mode 恰好没开 ONLY_FULL_GROUP_BY,所以本地一直正常、测试库才炸。 |
| | | * 这里用 ANY_VALUE(doc_name) 取同组任意一条名称:既满足 ONLY_FULL_GROUP_BY, |
| | | * 又保持“一个医生一个月一行”(把 doc_name 加进 group by 会因改名拆成两行)。 |
| | | */ |
| | | @Select("select year(job_time) as year, month(job_time) as month, doc_id, ANY_VALUE(doc_name) as doc_name, job_type, count(1) as job_count from lihu.job_record " + |
| | | "where job_time >= #{jobTimeFrom} and job_time < #{jobTimeTo} \n" + |
| | | "group by year(job_time), month(job_time), doc_id, job_type;") |
| | | List<JobRecordStatisticDO> getJobStatistic(@Param("jobTimeFrom") LocalDateTime jobTimeFrom, @Param("jobTimeTo") LocalDateTime jobTimeTo); |
| | | } |