CertCompanyMappingServiceImpl.java
4.72 KB
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
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.dto.cert.ChangeCompanyCertsDTO;
import com.subsidy.dto.cert.GetCompanyCertsDTO;
import com.subsidy.dto.cert.GetCompanyCertsWithStatusDTO;
import com.subsidy.mapper.CertMemberMappingMapper;
import com.subsidy.mapper.CertTypeDictMapper;
import com.subsidy.model.CertCompanyMappingDO;
import com.subsidy.mapper.CertCompanyMappingMapper;
import com.subsidy.model.CertDictDO;
import com.subsidy.model.CertMemberMappingDO;
import com.subsidy.model.CertTypeDictDO;
import com.subsidy.service.CertCompanyMappingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.cert.GetCompanyCertsVO;
import com.subsidy.vo.cert.GetCompanyCertsWithStatusVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 证书-公司映射表 服务实现类
* </p>
*
* @author DengMin
* @since 2022-05-11
*/
@Service
public class CertCompanyMappingServiceImpl extends ServiceImpl<CertCompanyMappingMapper, CertCompanyMappingDO> implements CertCompanyMappingService {
@Autowired
private CertMemberMappingMapper certMemberMappingMapper;
@Autowired
private CertTypeDictMapper certTypeDictMapper;
@Autowired
private CertCompanyMappingMapper certCompanyMappingMapper;
public List<GetCompanyCertsWithStatusVO> getCompanyCertsWithStatus(GetCompanyCertsWithStatusDTO getCompanyCertsDTO){
List<GetCompanyCertsWithStatusVO> getCompanyCertsWithStatusVOS = new ArrayList<>();
//查看某个公司所有的证书
List<CertDictDO> certDictDOS = this.baseMapper.getCompanyCerts(getCompanyCertsDTO.getCompanyId(),getCompanyCertsDTO.getTypeId());
for (CertDictDO certDictDO : certDictDOS){
GetCompanyCertsWithStatusVO getCompanyCertsWithStatusVO = new GetCompanyCertsWithStatusVO();
BeanUtils.copyProperties(certDictDO,getCompanyCertsWithStatusVO);
int count = certMemberMappingMapper.selectCount(new QueryWrapper<CertMemberMappingDO>()
.lambda()
.eq(CertMemberMappingDO::getCertId,certDictDO.getId())
.eq(CertMemberMappingDO::getMemberId,getCompanyCertsDTO.getMemberId()));
if (count>0){
getCompanyCertsWithStatusVO.setStatus(true);
}else {
getCompanyCertsWithStatusVO.setStatus(false);
}
getCompanyCertsWithStatusVOS.add(getCompanyCertsWithStatusVO);
}
return getCompanyCertsWithStatusVOS;
}
public IPage<GetCompanyCertsVO> getCompanyCerts(GetCompanyCertsDTO getCompanyCertsDTO){
Page pager = new Page(getCompanyCertsDTO.getPageNum(), getCompanyCertsDTO.getPageSize());
IPage<GetCompanyCertsVO> getCompanyCertsVOIPage = this.baseMapper.getCompanyCertStatus(pager);
List<GetCompanyCertsVO> getCompanyCertsVOS = getCompanyCertsVOIPage.getRecords();
for (GetCompanyCertsVO getCompanyCertsVO : getCompanyCertsVOS){
List<CertTypeDictDO> certTypeDictDOS = certTypeDictMapper.getCertTypes(getCompanyCertsVO.getId());
getCompanyCertsVO.setCertTypeDictDOS(certTypeDictDOS);
int count = certCompanyMappingMapper.selectCount(new QueryWrapper<CertCompanyMappingDO>()
.lambda()
.eq(CertCompanyMappingDO::getCertId,getCompanyCertsVO.getId())
.eq(CertCompanyMappingDO::getCompanyId,getCompanyCertsDTO.getCompanyId()));
if (count>0){
getCompanyCertsVO.setSignStatus(true);
}else {
getCompanyCertsVO.setSignStatus(false);
}
}
return getCompanyCertsVOIPage;
}
public String changeCompanyCerts(ChangeCompanyCertsDTO changeCompanyCertsDTO){
if (changeCompanyCertsDTO.getSignStatus()){
CertCompanyMappingDO certCompanyMappingDO = new CertCompanyMappingDO();
certCompanyMappingDO.setCertId(changeCompanyCertsDTO.getCertId());
certCompanyMappingDO.setCompanyId(changeCompanyCertsDTO.getCompanyId());
this.baseMapper.insert(certCompanyMappingDO);
}else {
this.baseMapper.delete(new QueryWrapper<CertCompanyMappingDO>()
.lambda()
.eq(CertCompanyMappingDO::getCertId,changeCompanyCertsDTO.getCertId())
.eq(CertCompanyMappingDO::getCompanyId,changeCompanyCertsDTO.getCompanyId()));
}
return ConstantUtils.SET_SUCCESS;
}
}