Blame view

parking-module-park/src/main/java/com/zteits/park/dao/impl/DutyRosterPlanDaoImpl.java 4.57 KB
9af4a544   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  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<DutyRosterPlan> 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<DutyRosterPlan> queryDutyRosterPlanForPage(List<Long> orgIds, List<Long> 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<DutyRosterPlan> planList = dutyRosterPlanMapper.selectByExample(example);
  
  
  
          return new PageInfo<>(planList);
      }
  
      @Override
      public Integer deleteDutyRosterPlanByPlanIds(Long orgId, List<Long> 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<Long> queryPlanIdOfEffectDutyRosterPlan(Integer dutyType) {
  
          return dutyRosterPlanSmapper.queryPlanIdOfEffectDutyRosterPlan(dutyType);
      }
  
      /**
       * 通过dutyDay查询查询小于dutyDay日期的最大排班记录.<br/>
       *
       * @param dutyDay
       * @return
       */
      @Override
      public List<DutyRosterPlanDO> queryDutyPlanMaxDutyDay(String dutyDay,Integer dutyType) {
          return dutyRosterPlanSmapper.queryDutyPlanMaxDutyDay(dutyDay,dutyType);
      }
  
      /**
       * 根据删除停车场数量,将duty_roster_plan表中停车场数量相应减少.<br/>
       *
       * @param
       * @return
       */
      @Override
      public Integer decreasePlNumFromRosterPlan(Long planId , Integer plNum,Integer chargerNum) {
          return dutyRosterPlanSmapper.decreasePlNumFromRosterPlan(planId,plNum, chargerNum);
      }
  
      /**
       * 根据删除停车场数量,将duty_roster_plan表中停车场数量相应减少.<br/>
       *
       * @param
       * @return
       */
      @Override
      public Integer updatePlNumAndEmployeeNumForRosterPlan(DutyRosterForAddRosterInfoReq req) {
          return dutyRosterPlanSmapper.updatePlNumAndEmployeeNumForRosterPlan(req);
      }
  }