Blame view

parking-module-system/src/main/java/com/zteits/sys/dao/impl/SysOpAdviceDaoImpl.java 4.04 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
109
110
111
112
113
114
115
116
117
118
119
120
  package com.zteits.sys.dao.impl;
  
  import java.util.Date;
  import java.util.List;
  
  import org.apache.commons.collections4.CollectionUtils;
  import com.github.pagehelper.PageHelper;
  import com.github.pagehelper.PageInfo;
  import com.zteits.clouds.api.dto.sys.param.OpAdviceNumOfReadStateQueryReq;
  import com.zteits.clouds.api.dto.sys.param.OpAdviceReadStateUpdateReq;
  import com.zteits.clouds.api.dto.sys.param.SysOpAdviceForPageQueryReq;
  import com.zteits.sys.dao.SysOpAdviceDao;
  import com.zteits.sys.domain.SysOpAdvice;
  import com.zteits.sys.domain.SysOpAdviceExample;
  import com.zteits.sys.domain.SysOpAdviceExample.Criteria;
  import com.zteits.sys.mapper.SysOpAdviceMapper;
  import com.zteits.sys.mapper.smapper.SysOpAdviceSMapper;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  /**
   * Copyright: Copyright (c) 2018  zteits
   *
   * @ClassName: com.zteits.sys.dao.impl
   * @Description:职工系统通知接口
   * @version: v1.0.0
   * @author: atao
   * @date: 2018/8/7   下午3:07
   * Modification History:
   * Date         Author          Version      Description
   * ---------------------------------------------------------*
   * 2018/8/7      atao          v1.0.0          创建
   */
  @Component
  public class SysOpAdviceDaoImpl implements SysOpAdviceDao {
  
      @Autowired
      private SysOpAdviceMapper sysOpAdviceMapper;
  
      @Autowired
      private SysOpAdviceSMapper sysOpAdviceSMapper;
  
      @Override
      public PageInfo<SysOpAdvice> querySysOpAdviceForPage(SysOpAdviceForPageQueryReq req) {
  
          SysOpAdviceExample example = new SysOpAdviceExample();
          example.setOrderByClause("create_date desc ");
          Criteria criteria = example.createCriteria();
  //        criteria.andOpIdEqualTo(req.getOpId());
          if (null != req.getStartCreateDate()) {
              criteria.andCreateDateGreaterThanOrEqualTo(req.getStartCreateDate());
          }
  
          if (null != req.getEndCreateDate()) {
              criteria.andCreateDateLessThanOrEqualTo(req.getEndCreateDate());
          }
  
          /**消息类型 1 待办消息 2 异常消息*/
          if (null != req.getAdviceType() && req.getAdviceType() == 1) {
              criteria.andAdviceTypeGreaterThan(0);
          }
  
          if (null != req.getAdviceType() && req.getAdviceType() == 2) {
              criteria.andAdviceTypeLessThan(0);
          }
  
          if (null != req.getReadState()) {
              criteria.andReadStateEqualTo(req.getReadState());
          }
  
          PageHelper.startPage(req.getBaseRequest().getPageNum(), req.getBaseRequest().getPageSize());
          List<SysOpAdvice> list = sysOpAdviceMapper.selectByExample(example);
  
          return new PageInfo<>(list);
      }
  
      @Override
      public Integer batchSaveSysOpAdvice(List<SysOpAdvice> sysOpAdviceList) {
  
          return sysOpAdviceSMapper.batchSaveSysOpAdvice(sysOpAdviceList);
      }
  
      @Override
      public Integer updateOpAdviceReadState(OpAdviceReadStateUpdateReq req) {
          SysOpAdviceExample example = new SysOpAdviceExample();
          Criteria criteria = example.createCriteria();
  
          criteria.andOpIdEqualTo(req.getOpId());
          if (CollectionUtils.isNotEmpty(req.getIds())) {
              criteria.andIdIn(req.getIds());
          }
  
          SysOpAdvice opAdvice = new SysOpAdvice();
          opAdvice.setReadState(req.getReadState());
          opAdvice.setModfiyDate(new Date());
          opAdvice.setModfiyEmpid(req.getsOpId() + "");
          Integer num = sysOpAdviceMapper.updateByExampleSelective(opAdvice, example);
  
          return num;
      }
  
      @Override
      public Integer queryOpAdviceNumOfReadState(OpAdviceNumOfReadStateQueryReq req) {
  
          SysOpAdviceExample example = new SysOpAdviceExample();
          Criteria criteria = example.createCriteria();
  
          criteria.andOpIdEqualTo(req.getOpId());
          criteria.andReadStateEqualTo(req.getReadState());
  
          Long num = sysOpAdviceMapper.countByExample(example);
  
          return num.intValue();
      }
  
      @Override
      public Boolean saveSysOpAdvice(SysOpAdvice sysOpAdvice) {
          return sysOpAdviceMapper.insertSelective(sysOpAdvice) > 0;
      }
  }