排班计划需求-查询list思路实现-计划-值班-人员-成员-分页

本文详细介绍了一种基于实体类DutyPlanVo的排班系统设计思路,该实体类包含了两个列表结构,分别用于存储排班计划中的值班组和成员信息。通过使用MyBatis Plus的selectList方法查询数据库,并利用foreach循环将数据映射到DutyPlanVo实体类中,实现了根据日期和值班组查询特定日期排班情况的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

@Data
public class DutyPlanVo {
    @ApiModelProperty(value = "排班计划表的id")
    private String id;

    @ApiModelProperty(value = "排班年计划")
    private Integer year;

    @ApiModelProperty(value = "排班计划值班组")
    private List<DutyPlanGroup> dutyPlanGroupList;

    @ApiModelProperty(value = "排班计划成员组")
    private List<DutyPlanMenber> dutyPlanMenberList;

    @ApiModelProperty(value = "绑定排班人员组id-关联成员")
    private String dutyPersonId;

    @ApiModelProperty(value = "排班计划开始时间(yyyy-MM-dd)")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date startDate;

    @ApiModelProperty(value = "排班计划结束时间(yyyy-MM-dd)")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date endDate;

    @ApiModelProperty(value = "值班组的名称")
    private String  planDutyName;

    @ApiModelProperty(value = "值班时间")
    private String  planTime;

    @ApiModelProperty(value = "排班计划的值班方式")
    private String  planDutyType;

    @ApiModelProperty(value = "排班计划周末")
    private String  planWeek;

}

前端数据结构
包含2个list《``》

{
  "code": 200,
  "msg": null,
  "data": {
    "total": 2,
    "content": [
      {
        "id": "490c04d43cfd4c7687be0c7c40253d1d",
        "year": 2020,
        "dutyPlanGroupList": [
          {
            "planStartTime": null,
            "planEndTime": null,
            "planNameCode": null,
            "planId": "0c66b6b30d064e4bb8f8d686776643bb",
            "planGroup": "监狱A组",
            "id": "d1ffaa3edd7e4581bd8c5086f957654e"
          }
        ],
        "dutyPlanMenberList": [
          {
            "id": "4501f8ce6c404e0eba448bd696746773",
            "planDutyPersonId": "e2d3035acc72403cb56b5ad35c4afbce",
            "planDutyPersonName": "监区A组有0001",
            "planNameCode": null
          },
          {
            "id": "a97e60d53e3243528f8e7d9a50ee51da",
            "planDutyPersonId": "e2d3035acc72403cb56b5ad35c4afbce",
            "planDutyPersonName": "监区A组有0001",
            "planNameCode": null
          }
        ],
        "dutyPersonId": "0c66b6b30d064e4bb8f8d686776643bb",
        "startDate": "2020-01-01",
        "endDate": "2020-01-01",
        "planDutyName": "监狱A组",
        "planTime": null,
        "planDutyType": null,
        "planWeek": "星期三"
      },
      {
        "id": "cdfdec7a25ca4780a88527f01a170434",
        "year": 2020,
        "dutyPlanGroupList": [
          {
            "planStartTime": null,
            "planEndTime": null,
            "planNameCode": null,
            "planId": "0c66b6b30d064e4bb8f8d686776643bb",
            "planGroup": "监狱A组",
            "id": "d1ffaa3edd7e4581bd8c5086f957654e"
          }
        ],
        "dutyPlanMenberList": [
          {
            "id": "4501f8ce6c404e0eba448bd696746773",
            "planDutyPersonId": "e2d3035acc72403cb56b5ad35c4afbce",
            "planDutyPersonName": "监区A组有0001",
            "planNameCode": null
          },
          {
            "id": "a97e60d53e3243528f8e7d9a50ee51da",
            "planDutyPersonId": "e2d3035acc72403cb56b5ad35c4afbce",
            "planDutyPersonName": "监区A组有0001",
            "planNameCode": null
          }
        ],
        "dutyPersonId": "0c66b6b30d064e4bb8f8d686776643bb",
        "startDate": "2020-01-02",
        "endDate": "2020-01-02",
        "planDutyName": "监狱A组",
        "planTime": null,
        "planDutyType": null,
        "planWeek": "星期四"
      }
    ]
  }
}

实现代码-用mp实现查询。思路foreach循环。然后再set进去
@Serivce

 @Override
    public PageResponse<DutyPlanVo> queryPlan(Integer current,
                                  Integer size,
                                  String planDutyName,
                                  Date startYearMonthDate,
                                  Date endYearMonthDate) {
        PageResponse<DutyPlanVo> response = new PageResponse<DutyPlanVo>();
        QueryWrapper<DutyPlan> wrapper = new QueryWrapper<>();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        String startYearMonthDate1 = sdf.format(startYearMonthDate);
        String endYearMonthDate1 = sdf.format(endYearMonthDate);
        if (ObjectUtils.isNotEmpty(startYearMonthDate1)) {
            wrapper.lambda().ge(DutyPlan::getStartDate, startYearMonthDate1);
        }
        if (ObjectUtils.isNotEmpty(endYearMonthDate1)) {
            wrapper.lambda().le(DutyPlan::getEndDate, endYearMonthDate1);
        }
        wrapper.lambda().eq(DutyPlan::getPlanDutyName,planDutyName);
        List<DutyPlan> dutyPlans = dutyPlayMapper.selectList(wrapper);

        List<DutyPlanVo> dutyPlanVos = mapperFacade.mapAsList(dutyPlans, DutyPlanVo.class);
        dutyPlanVos.forEach(dutyPlanVo -> {
            QueryWrapper<DutyPlanGroup> wrapperDutyPlanGroup= new QueryWrapper<>();
            List<DutyPlanGroup> dutyPlanGroups = dutyPlanGroupMapper.selectList(wrapperDutyPlanGroup.lambda().eq(DutyPlanGroup::getPlanId, dutyPlanVo.getDutyPersonId()));
            if (ObjectUtils.isNotEmpty(dutyPlanGroups)) {
                dutyPlanVo.setDutyPlanGroupList(dutyPlanGroups);
            }

            QueryWrapper<DutyPlanPerson> wrapperDutyPlanPerson = new QueryWrapper<>();
            DutyPlanPerson one = dutyPlanPersonMapper.selectOne(wrapperDutyPlanPerson.lambda().eq(DutyPlanPerson::getPlanDutyGroupId, dutyPlanVo.getDutyPersonId()));
            QueryWrapper<DutyPlanMenber> wrapperDutyPlanMenber = new QueryWrapper<>();
            List<DutyPlanMenber> dutyPlanMenbers = dutyPlanMenberMapper.selectList(wrapperDutyPlanMenber.lambda().eq(DutyPlanMenber::getPlanDutyPersonId, one.getPlanDutyPersonId()));
            if (ObjectUtils.isNotEmpty(dutyPlanMenbers)) {
                dutyPlanVo.setDutyPlanMenberList(dutyPlanMenbers);
            }});
        IPage<DutyPlanVo> dutyPlanVoIPage = PageUtil.pageInfo(dutyPlanVos, Long.valueOf(size), Long.valueOf(current));
        response.setTotal(dutyPlanVoIPage.getTotal());
        response.setContent(dutyPlanVoIPage.getRecords());
        return response;

在这里插入图片描述
代码思路:
根据日期和值班组查询某一天排班情况
使用实体类DutyPLanVo 里面包含2个list结构
调用 selectList查询出来。然后再set实体类DutyPlanVo就可以。新思路。
对比Xml
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
PageResponse类型的分页
PageRespons在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值