Blame view

parking-module-system/src/main/java/com/zteits/sys/biz/SysLicenseServiceImpl.java 3.93 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
  package com.zteits.sys.biz;
  
  import com.alibaba.fastjson.JSONObject;
  import com.clouds.common.log.LogSelf;
  import com.clouds.common.utils.LogSelfFactory;
  import com.zteits.clouds.api.apibase.bean.BizResult;
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  import com.zteits.clouds.api.dto.sys.SysLicenseDTO;
  import com.zteits.clouds.api.dto.sys.param.QuerySysLicenseByOrgIdReq;
  import com.zteits.clouds.api.dto.sys.param.SaveSysLicenseReq;
  import com.zteits.clouds.api.service.sys.SysLicenseService;
  import com.zteits.sys.domain.SysLicense;
  import com.zteits.sys.domain.SysLicenseExample;
  import com.zteits.sys.mapper.SysLicenseMapper;
  import com.zteits.sys.mapper.smapper.SysLicenseSmapper;
  import org.apache.ibatis.annotations.Param;
  import org.springframework.beans.BeanUtils;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  import org.springframework.util.CollectionUtils;
  
  import java.util.Collections;
  import java.util.Date;
  import java.util.List;
  
  /**
   * Copyright: Copyright (c) 2017  zteits
   *
   * @ClassName: SysLicenseServiceImpl.java
   * @Description:
   * @version: v1.0.0
   * @author: wangfs
   * @date: 2019-06-11 16:15
   * Modification History:
   * Date             Author          Version            Description
   * ---------------------------------------------------------*
   * 2019-06-11     wangfs              v1.0.0               创建
   */
  @Service("com.zteits.sys.biz.SysLicenseServiceImpl")
  public class SysLicenseServiceImpl implements SysLicenseService {
  
      private static final LogSelf logger = LogSelfFactory.getLogSelf(SysLicenseServiceImpl.class);
      @Autowired
      private SysLicenseMapper sysLicenseMapper;
  
      @Autowired
      private SysLicenseSmapper sysLicenseSmapper;
  
  
  
      @Override
      public BizResult<SysLicenseDTO> querySysLicenseByOrgId(QuerySysLicenseByOrgIdReq req) {
          logger.info("begin通过组织ID获取License,入参={}", JSONObject.toJSON(req));
          SysLicenseDTO sysLicenseDTO = new SysLicenseDTO();
          SysLicenseExample example = new SysLicenseExample();
          example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                  .andOrgIdEqualTo(req.getOrgId());
          List<SysLicense> list = sysLicenseMapper.selectByExampleWithBLOBs(example);
          logger.info("通过组织ID获取License对象为={}", JSONObject.toJSON(list));
          if(!CollectionUtils.isEmpty(list)){
              BeanUtils.copyProperties(list.get(0),sysLicenseDTO);
          }
          logger.info("end通过组织ID获取LicenseDTO对象={}", JSONObject.toJSON(sysLicenseDTO));
          return new BizResult<SysLicenseDTO>(sysLicenseDTO);
      }
  
      @Override
      public BizResult<Boolean> updateSysLicenseByOrgId(SaveSysLicenseReq req) {
          logger.info("begin通过组织ID更新License,入参={}", JSONObject.toJSON(req));
          int i =0;
          SysLicenseExample example = new SysLicenseExample();
          example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
                  .andOrgIdEqualTo(req.getOrgId());
          List<SysLicense> list = sysLicenseMapper.selectByExampleWithBLOBs(example);
  
          SysLicense record = new SysLicense();
          record.setLicense(req.getLicense());
          record.setOrgId(req.getOrgId());
          record.setModfiyDate(new Date());
          record.setModfiyEmpid(req.getModfiyEmpid());
  
          if(CollectionUtils.isEmpty(list) && list.size()==0){
              record.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
              record.setCreateDate(new Date());
              record.setCreateEmpid(req.getModfiyEmpid());
              i = sysLicenseMapper.insert(record);
              logger.info("end通过组织没有查询到执行,插入条数={}条.", i);
          }else{
              i = sysLicenseSmapper.updateLicenseByOrgId(record);
              logger.info("end通过组织ID更新License,更新条数={}条.", i);
          }
  
          return new BizResult<Boolean>(i >0);
      }
  }