修改分页获取预约记录的返回数据结构

master
liuqingkun 3 years ago
parent 2404ae533d
commit 2dd831d8f8
  1. 53
      src/main/java/org/springblade/common/cache/DeptCache.java
  2. 11
      src/main/java/org/springblade/modules/business/controller/ApmRecordController.java
  3. 8
      src/main/java/org/springblade/modules/business/mapper/ApmRecordMapper.java
  4. 25
      src/main/java/org/springblade/modules/business/mapper/ApmRecordMapper.xml
  5. 3
      src/main/java/org/springblade/modules/business/service/IApmRecordService.java
  6. 51
      src/main/java/org/springblade/modules/business/service/impl/ApmRecordServiceImpl.java
  7. 44
      src/main/java/org/springblade/modules/business/vo/ApmRecordDetailVO.java
  8. 62
      src/main/java/org/springblade/modules/business/vo/ApmRecordListVO.java
  9. 31
      src/main/java/org/springblade/modules/business/wrapper/ApmRecordListWrapper.java

@ -0,0 +1,53 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.cache;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IUserService;
import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
/**
* 部门缓存
*
* @author Chill
*/
public class DeptCache {
private static final String DEPT_CACHE = "blade:dept";
private static final String DEPT_CACHE_ID = "dept:id:";
private static final IDeptService deptService;
static {
deptService = SpringUtil.getBean(IDeptService.class);
}
/**
* 获取部门
*
* @param id 部门id
* @return
*/
public static Dept getDept(Long id) {
return CacheUtil.get(DEPT_CACHE, DEPT_CACHE_ID, id, () -> deptService.getById(id), Boolean.FALSE);
}
}

@ -19,6 +19,7 @@ import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.business.entity.ApmRecord;
import org.springblade.modules.business.service.IApmRecordService;
import org.springblade.modules.business.vo.ApmRecordListVO;
import org.springblade.modules.business.vo.ApmRecordVO;
import org.springblade.modules.business.wrapper.ApmRecordWrapper;
import org.springframework.web.bind.annotation.*;
@ -70,7 +71,7 @@ public class ApmRecordController extends BladeController {
ApmRecord record = recordService.getById(id);
if (Func.isNotEmpty(record)) {
record.setApmStatus(BusinessConstant.RECORD_STATUS_REGISTER);
recordService.save(record);
recordService.updateById(record);
} else {
return R.fail("报到失败, 未找到对应预约记录");
}
@ -109,12 +110,12 @@ public class ApmRecordController extends BladeController {
@ApiImplicitParam(name = "startTime", value = "查询开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "查询结束时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "cupCardNo", value = "体检人证件号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "project", value = "体检项目", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "project", value = "项目名称", paramType = "query", dataType = "String")
})
@ApiOperationSupport(order = 4)
@ApiOperation(value = "分页", notes = "传入notice")
public R<IPage<ApmRecordVO>> selectPage(Query query, Long createDept, String startTime, String endTime, String cupCardNo, String project) {
IPage<ApmRecordVO> page = recordService.selectPage(Condition.getPage(query), createDept, startTime, endTime, cupCardNo, project);
@ApiOperation(value = "分页", notes = "分页")
public R<IPage<ApmRecordListVO>> selectPage(Query query, Long createDept, String startTime, String endTime, String cupCardNo, String project) {
IPage<ApmRecordListVO> page = recordService.selectRecordPage(Condition.getPage(query), createDept, startTime, endTime, cupCardNo, project);
return R.data(page);
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.business.dto.ApmRecordCountDTO;
import org.springblade.modules.business.entity.ApmConfig;
import org.springblade.modules.business.entity.ApmRecord;
import java.util.List;
@ -26,10 +27,13 @@ public interface ApmRecordMapper extends BaseMapper<ApmRecord> {
* @param cupCardNo
* @return
*/
List<ApmRecord> selectPage(IPage page, @Param("createDept") Long createDept, @Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("cupCardNo") String cupCardNo, @Param("project") String project);
IPage<ApmRecord> selectRecordPage(IPage page, @Param("createDept") Long createDept, @Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("cupCardNo") String cupCardNo, @Param("project") String project);
List<ApmRecord> selectRecordList(@Param("createDept") Long createDept, @Param("startTime") String startTime, @Param("endTime") String endTime,
@Param("cupCardNo") String cupCardNo, @Param("project") String project);
List<ApmRecordCountDTO> countAmpNum(@Param("createDept") Long createDept, @Param("apmDay") String apmDay);
List<ApmRecordCountDTO> countAmpNumWithDays(@Param("createDept") Long createDept, @Param("apmDayList") List<String> apmDayList);

@ -32,8 +32,29 @@
<result column="apmNum" property="apmNum"/>
</resultMap>
<select id="selectPage" resultMap="apmRecordResultMap">
SELECT ar.*
<select id="selectRecordPage" resultMap="apmRecordResultMap">
SELECT distinct ar.create_dept, ar.cup_card_no, ar.apm_day
FROM ca_apm_record ar
WHERE ar.is_deleted = 0
<if test="createDept != '' and createDept != null">
and ar.create_dept = #{createDept}
</if>
<if test="startTime != '' and startTime != null">
and ar.apm_day &gt;= #{startTime}
</if>
<if test="endTime != '' and endTime != null">
and ar.apm_day &lt;= #{endTime}
</if>
<if test="cupCardNo != '' and cupCardNo != null">
and ar.cup_card_no like concat(concat('%', #{cupCardNo}), '%')
</if>
<if test="project != '' and project != null">
and ar.project like concat(concat('%', #{project}), '%')
</if>
</select>
<select id="selectRecordList" resultMap="apmRecordResultMap">
SELECT *
FROM ca_apm_record ar
WHERE ar.is_deleted = 0
<if test="createDept != '' and createDept != null">

@ -6,6 +6,7 @@ import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import org.springblade.modules.business.dto.ApmRecordCountDTO;
import org.springblade.modules.business.entity.ApmRecord;
import org.springblade.modules.business.vo.ApmRecordListVO;
import org.springblade.modules.business.vo.ApmRecordVO;
import org.springblade.modules.business.vo.NoticeVO;
import org.springframework.web.bind.annotation.RequestParam;
@ -30,7 +31,7 @@ public interface IApmRecordService extends BaseService<ApmRecord> {
* @param cupCardNo
* @return
*/
IPage<ApmRecordVO> selectPage(IPage<ApmRecordVO> page, Long createDept, String startTime, String endTime, String cupCardNo, String project);
IPage<ApmRecordListVO> selectRecordPage(IPage<ApmRecordVO> page, Long createDept, String startTime, String endTime, String cupCardNo, String project);
String checkApmRecordSave(List<ApmRecord> apmRecordList);

@ -3,32 +3,33 @@ package org.springblade.modules.business.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springblade.common.cache.DeptCache;
import org.springblade.common.cache.DictBizCache;
import org.springblade.common.constant.BusinessConstant;
import org.springblade.common.enums.ErrorMsgEnum;
import org.springblade.common.utils.CommonDateUtil;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.business.dto.ApmRecordCountDTO;
import org.springblade.modules.business.entity.ApmConfig;
import org.springblade.modules.business.entity.ApmRecord;
import org.springblade.modules.business.entity.Blacklist;
import org.springblade.modules.business.mapper.ApmRecordMapper;
import org.springblade.modules.business.service.IApmRecordService;
import org.springblade.modules.business.service.IBlacklistService;
import org.springblade.modules.business.vo.ApmConfigListVO;
import org.springblade.modules.business.vo.ApmRecordDetailVO;
import org.springblade.modules.business.vo.ApmRecordListVO;
import org.springblade.modules.business.vo.ApmRecordVO;
import org.springblade.modules.business.wrapper.ApmConfigListWrapper;
import org.springblade.modules.business.wrapper.ApmRecordListWrapper;
import org.springblade.modules.business.wrapper.ApmRecordWrapper;
import org.springblade.modules.system.service.IDictService;
import org.springblade.modules.system.entity.Dept;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 服务实现类
@ -41,9 +42,35 @@ public class ApmRecordServiceImpl extends BaseServiceImpl<ApmRecordMapper, ApmRe
private final IBlacklistService blacklistService;
@Override
public IPage<ApmRecordVO> selectPage(IPage<ApmRecordVO> page, Long createDept, String startTime, String endTime, String cupCardNo, String project) {
List<ApmRecord> recordList = baseMapper.selectPage(page, createDept, startTime, endTime, cupCardNo, project);
return page.setRecords(ApmRecordWrapper.build().listVO(recordList));
public IPage<ApmRecordListVO> selectRecordPage(IPage<ApmRecordVO> page, Long createDept, String startTime, String endTime, String cupCardNo, String project) {
// 由于每个项目的预约保存了一条记录, 故分页时, 先使用distinct查询(医院, 预约人 配置天)进行分页
IPage<ApmRecord> pageRecord = baseMapper.selectRecordPage(page, createDept, startTime, endTime, cupCardNo, project);
List<ApmRecord> allRecord = baseMapper.selectRecordList(createDept, startTime, endTime, cupCardNo, project);
Map<String, List<ApmRecord>> recordMap = new HashMap<>();
allRecord.forEach(record -> {
String key = record.getCreateDept() + DateUtil.format(record.getApmDay(), DateUtil.PATTERN_DATE) + record.getCupCardNo();
List<ApmRecord> records = recordMap.containsKey(key) ? recordMap.get(key) : new ArrayList<>();
records.add(record);
recordMap.put(key, records);
});
IPage<ApmRecordListVO> recordList = ApmRecordListWrapper.build().pageVO(pageRecord);
recordList.getRecords().forEach(vo -> {
Dept hospital = DeptCache.getDept(vo.getCreateDept());
vo.setCreateDeptName(Func.isNotEmpty(hospital) ? hospital.getDeptName() : "");
String key = vo.getCreateDept() + DateUtil.format(vo.getApmDay(), DateUtil.PATTERN_DATE) + vo.getCupCardNo();
List<ApmRecord> records = recordMap.containsKey(key) ? recordMap.get(key) : new ArrayList<>();
List<ApmRecordDetailVO> details = new ArrayList<>();
for (ApmRecord record : records) {
details.add(BeanUtil.copy(record, ApmRecordDetailVO.class));
}
vo.setDetails(details);
});
return recordList;
}
@Override

@ -0,0 +1,44 @@
package org.springblade.modules.business.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 预约记录视图类
*
* @author Chill
*/
@Data
public class ApmRecordDetailVO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long id;
/**
* 体检项目
*/
@ApiModelProperty(value = "体检项目")
private String project;
/**
* 体检地址
*/
@ApiModelProperty(value = "体检地址")
private String cuAddr;
/**
* 时段(上午,下午)
*/
@ApiModelProperty(value = "时段(上午,下午)")
private String period;
/**
* 时段范围, 格式(HH:mm-HH:mm)
*/
@ApiModelProperty(value = "时段范围, 格式(HH:mm-HH:mm)")
private String timeFrame;
}

@ -0,0 +1,62 @@
package org.springblade.modules.business.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 预约记录视图类
*
* @author Chill
*/
@Data
public class ApmRecordListVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 创建部门
*/
@ApiModelProperty(value = "创建部门")
private Long createDept;
/**
* 创建部门名称
*/
@ApiModelProperty(value = "创建部门名称")
private String createDeptName;
/**
* 放号天
*/
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@ApiModelProperty(value = "放号天")
private Date apmDay;
/**
* 体检人用户名
*/
@ApiModelProperty(value = "体检人用户名")
private String cupName;
/**
* 体检人证件号
*/
@ApiModelProperty(value = "体检人证件号")
private String cupCardNo;
/**
* 体检人联系方式
*/
@ApiModelProperty(value = "体检人联系方式")
private String cupPhone;
private List<ApmRecordDetailVO> details;
}

@ -0,0 +1,31 @@
package org.springblade.modules.business.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.business.entity.ApmRecord;
import org.springblade.modules.business.vo.ApmRecordListVO;
import java.util.Objects;
/**
* ApmConfigListVO包装类,返回视图层所需的字段
*
* @author Chill
*/
public class ApmRecordListWrapper extends BaseEntityWrapper<ApmRecord, ApmRecordListVO> {
public static ApmRecordListWrapper build() {
return new ApmRecordListWrapper();
}
@Override
public ApmRecordListVO entityVO(ApmRecord entity) {
if (Func.isEmpty(entity)) {
return null;
}
ApmRecordListVO vo = Objects.requireNonNull(BeanUtil.copy(entity, ApmRecordListVO.class));
return vo;
}
}
Loading…
Cancel
Save