package com.zteits.park.dao.impl; import java.util.List; import org.apache.commons.collections4.CollectionUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.xiaoleilu.hutool.date.DateUtil; import com.zteits.clouds.api.apibase.constants.DataStatusEnum; import com.zteits.clouds.api.dto.park.param.dutyroster.DutyRosterForAddRosterInfoReq; import com.zteits.park.dao.DutyRosterPlanDao; import com.zteits.park.domain.DutyRosterPlan; import com.zteits.park.domain.DutyRosterPlanExample; import com.zteits.park.domain.DutyRosterPlanExample.Criteria; import com.zteits.park.domain.bean.DutyRosterPlanDO; import com.zteits.park.mapper.DutyRosterPlanMapper; import com.zteits.park.mapper.smapper.DutyRosterPlanSMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * Copyright: Copyright (c) 2018 zteits * * @ClassName: com.zteits.park.dao.impl * @Description: * @version: v1.0.0 * @author: atao * @date: 2018/8/15 下午3:35 * Modification History: * Date Author Version Description * ---------------------------------------------------------* * 2018/8/15 atao v1.0.0 创建 */ @Component public class DutyRosterPlanDaoImpl implements DutyRosterPlanDao { @Autowired private DutyRosterPlanMapper dutyRosterPlanMapper; @Autowired private DutyRosterPlanSMapper dutyRosterPlanSmapper; @Override public Integer saveDutyRosterPlan(List dutyRosterPlans) { int num = 0; if (CollectionUtils.isNotEmpty(dutyRosterPlans)) { for (DutyRosterPlan base : dutyRosterPlans) { int i = dutyRosterPlanMapper.insertSelective(base); if (i > 0) { num++; } } } return num; } @Override public PageInfo queryDutyRosterPlanForPage(List orgIds, List planIds,Integer dutyType, Integer pageNum, Integer pagesize) { DutyRosterPlanExample example = new DutyRosterPlanExample(); Criteria sql = example.createCriteria(); sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); sql.andOrgIdIn(orgIds); if (CollectionUtils.isNotEmpty(planIds)) { sql.andPlanIdIn(planIds); } if(null != dutyType){ sql.andDutyTypeEqualTo(dutyType); } //只查询未失效的排班计划 失效时间 大于 当前时间 sql.andExpireTimeGreaterThan(DateUtil.date()); PageHelper.startPage(pageNum, pagesize); example.setOrderByClause("create_time desc"); List planList = dutyRosterPlanMapper.selectByExample(example); return new PageInfo<>(planList); } @Override public Integer deleteDutyRosterPlanByPlanIds(Long orgId, List planIds,Integer dutyType) { DutyRosterPlanExample example = new DutyRosterPlanExample(); example.createCriteria().andOrgIdEqualTo(orgId).andPlanIdIn(planIds); DutyRosterPlan plan = new DutyRosterPlan(); plan.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value()); //设置失效时间为昨天结束时间 plan.setExpireTime(DateUtil.endOfDay(DateUtil.yesterday())); return dutyRosterPlanMapper.updateByExampleSelective(plan, example); } @Override public List queryPlanIdOfEffectDutyRosterPlan(Integer dutyType) { return dutyRosterPlanSmapper.queryPlanIdOfEffectDutyRosterPlan(dutyType); } /** * 通过dutyDay查询查询小于dutyDay日期的最大排班记录.
* * @param dutyDay * @return */ @Override public List queryDutyPlanMaxDutyDay(String dutyDay,Integer dutyType) { return dutyRosterPlanSmapper.queryDutyPlanMaxDutyDay(dutyDay,dutyType); } /** * 根据删除停车场数量,将duty_roster_plan表中停车场数量相应减少.
* * @param * @return */ @Override public Integer decreasePlNumFromRosterPlan(Long planId , Integer plNum,Integer chargerNum) { return dutyRosterPlanSmapper.decreasePlNumFromRosterPlan(planId,plNum, chargerNum); } /** * 根据删除停车场数量,将duty_roster_plan表中停车场数量相应减少.
* * @param * @return */ @Override public Integer updatePlNumAndEmployeeNumForRosterPlan(DutyRosterForAddRosterInfoReq req) { return dutyRosterPlanSmapper.updatePlNumAndEmployeeNumForRosterPlan(req); } }