@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