Blame view

parking-module-charge/src/main/java/com/zteits/charge/dao/impl/EquipmentInfoDaoImpl.java 4.25 KB
55f68655   王彪总   新项目
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
  package com.zteits.charge.dao.impl;
  import org.apache.commons.collections4.CollectionUtils;
  import com.github.pagehelper.PageHelper;
  import com.github.pagehelper.PageInfo;
  import com.zteits.charge.domain.EquipmentInfo;
  import com.zteits.charge.domain.EquipmentInfoExample;
  import com.zteits.charge.mapper.smapper.EquipmentInfoSMapper;
  import com.zteits.clouds.api.dto.charge.dto.EquipmentInfoDTO;
  import com.zteits.clouds.api.dto.charge.param.EquipmentInfoRequest;
  import com.zteits.charge.dao.EquipmentInfoDao;
  import com.zteits.charge.mapper.EquipmentInfoMapper;
  
  import com.zteits.clouds.api.dto.charge.param.QueryEquipmentInfoRequest;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  
  @Component
  public class EquipmentInfoDaoImpl implements  EquipmentInfoDao {
      @Autowired
      private EquipmentInfoMapper equipmentInfoMapper;
      @Autowired
      private EquipmentInfoSMapper equipmentInfoSMapper;
  
      @Override
      public int saveEquipmentInfo(EquipmentInfo paramInfo) {
          EquipmentInfo info = this.selectByEquipmentId(paramInfo.getOperatorId(), paramInfo.getEquipmentId());
          if (info == null) {
              // 插入
              paramInfo.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
              paramInfo.setCreateTime(new Date());
              paramInfo.setModifyTime(new Date());
              return equipmentInfoMapper.insertSelective(paramInfo);
          } else {
              // 更新
              paramInfo.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
              paramInfo.setModifyTime(new Date());
              paramInfo.setId(info.getId());
              return equipmentInfoMapper.updateByPrimaryKeySelective(paramInfo);
          }
      }
  
      @Override
      public int updateByExampleSelective(EquipmentInfo record, EquipmentInfoExample example) {
          return equipmentInfoMapper.updateByExampleSelective(record,example);
      }
  
      @Override
      public int updateByPrimaryKeySelective(EquipmentInfo record) {
          return equipmentInfoMapper.updateByPrimaryKeySelective(record);
      }
  
      @Override
      public List<EquipmentInfo> selectByExample(EquipmentInfoExample example) {
          return equipmentInfoMapper.selectByExample(example);
      }
  
      @Override
      public EquipmentInfo queryByPrimaryKey(Long id) {
          return equipmentInfoMapper.selectByPrimaryKey(id);
      }
  
      @Override
      public List<EquipmentInfo> queryEquipmentInfo(EquipmentInfoRequest request) {
          //return equipmentInfoSMapper.queryEquipmentInfo(request);
          return null;
      }
  
      @Override
      public int batchDeleteEquipmentInfoByPrimaryKey(List<Long> ids, String opId, String opName) {
          EquipmentInfo record = new EquipmentInfo();
          record.setModifyEmpId(opId);
          record.setModifyEmpName(opName);
          record.setModifyTime(new Date());
          record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
          EquipmentInfoExample example = new EquipmentInfoExample();
          example.createCriteria().andIdIn(ids);
          return equipmentInfoMapper.updateByExampleSelective(record,example);
      }
  
      @Override
      public EquipmentInfo selectByEquipmentId(String operatorId, String equipmentId) {
          EquipmentInfoExample example = new EquipmentInfoExample();
          example.createCriteria().andOperatorIdEqualTo(operatorId)
                  .andEquipmentIdEqualTo(equipmentId)
                  .andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
          List<EquipmentInfo> infos = this.selectByExample(example);
          if (CollectionUtils.isNotEmpty(infos)) {
              return infos.get(0);
          }
          return null;
      }
  
      @Override
      public PageInfo<EquipmentInfoDTO> queryEquipmentInfoForPage(QueryEquipmentInfoRequest request) {
          PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
          List<EquipmentInfoDTO> list = equipmentInfoSMapper.queryEquipmentInfo(request);
          if (CollectionUtils.isNotEmpty(list)) {
              return new PageInfo<EquipmentInfoDTO>(list);
          }
          return new PageInfo<EquipmentInfoDTO>(new ArrayList<EquipmentInfoDTO>());
      }
  }