MemberDictServiceImpl.java
15.9 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
package com.laowu.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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.laowu.common.exception.HttpException;
import com.laowu.dto.member.AddMemberDTO;
import com.laowu.dto.member.AllMembersDTO;
import com.laowu.dto.member.UpdateMemberDTO;
import com.laowu.mapper.*;
import com.laowu.model.*;
import com.laowu.service.MemberDictService;
import com.laowu.util.ConstantUtils;
import com.laowu.vo.member.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 自然人表 服务实现类
* </p>
*
* @author Tuyp
* @since 2023-03-23
*/
@Service
public class MemberDictServiceImpl extends ServiceImpl<MemberDictMapper, MemberDictDO> implements MemberDictService {
@Autowired
private MemberJobInfoMapper memberJobInfoMapper;
@Autowired
private LibCollegeMapper libCollegeMapper;
@Autowired
private LibMajorMapper libMajorMapper;
@Autowired
private CompanyDictMapper companyDictMapper;
@Autowired
private MemberCollegeMappingMapper memberCollegeMappingMapper;
@Autowired
private WorkstationDictMapper workstationDictMapper;
@Autowired
private MemberUpdateHistoryMapper memberUpdateHistoryMapper;
@Autowired
private WorkstationMemberMappingMapper workstationMemberMappingMapper;
@Autowired
private MemberTeamMappingMapper memberTeamMappingMapper;
@Autowired
private TeamDictMapper teamDictMapper;
@Autowired
private MemberPositionsMapper memberPositionsMapper;
@Autowired
private MemberCertsMapper memberCertsMapper;
@Autowired
private MemberTrainInfoMapper memberTrainInfoMapper;
@Autowired
private MemberTrainPositionsMapper memberTrainPositionsMapper;
public IPage<AllMembersVO> allMembers(AllMembersDTO allMembersDTO) {
Page pager = new Page(allMembersDTO.getPageNum(), allMembersDTO.getPageSize());
IPage<AllMembersVO> allMembersVOIPage = this.baseMapper.allMembers(pager, allMembersDTO.getProvince(), allMembersDTO.getCity(), allMembersDTO.getCounty(), allMembersDTO.getStatus(), allMembersDTO.getUserName());
List<AllMembersVO> allMembersVOS = allMembersVOIPage.getRecords();
for (AllMembersVO allMembersVO : allMembersVOS) {
//专业技能信息
List<PositionDictDO> memberPositions = memberPositionsMapper.memberPositions(allMembersVO.getId());
allMembersVO.setPositionDictDOS(memberPositions);
}
return allMembersVOIPage;
}
@Transactional(rollbackFor = Exception.class)
public String deleteMember(AddMemberDTO addMemberDTO) {
this.baseMapper.deleteById(addMemberDTO.getId());
memberTeamMappingMapper.delete(new QueryWrapper<MemberTeamMappingDO>()
.lambda()
.eq(MemberTeamMappingDO::getMemberId, addMemberDTO.getId()));
workstationMemberMappingMapper.delete(new QueryWrapper<WorkstationMemberMappingDO>()
.lambda()
.eq(WorkstationMemberMappingDO::getMemberId, addMemberDTO.getId()));
memberJobInfoMapper.delete(new QueryWrapper<MemberJobInfoDO>()
.lambda()
.eq(MemberJobInfoDO::getMemberId, addMemberDTO.getId()));
//团队领导人为id的团队组长职位空
List<TeamDictDO> teamDictDOS = teamDictMapper.selectList(new QueryWrapper<TeamDictDO>()
.lambda()
.eq(TeamDictDO::getMemberId, addMemberDTO.getId()));
for (TeamDictDO teamDictDO : teamDictDOS) {
teamDictMapper.noLeader(teamDictDO.getId());
}
//历史
MemberUpdateHistoryDO memberUpdateHistoryDO = new MemberUpdateHistoryDO();
memberUpdateHistoryDO.setAdministerId(addMemberDTO.getUserId());
memberUpdateHistoryDO.setModule(addMemberDTO.getModule());
memberUpdateHistoryDO.setMemberId(addMemberDTO.getId());
memberUpdateHistoryDO.setOpr("删除了该成员");
memberUpdateHistoryMapper.insert(memberUpdateHistoryDO);
return ConstantUtils.DELETE_SUCCESS;
}
public String addMember(AddMemberDTO addMemberDTO) {
int count = this.baseMapper.selectCount(new QueryWrapper<MemberDictDO>()
.lambda()
.isNotNull(MemberDictDO::getIdCard)
.eq(MemberDictDO::getIdCard, addMemberDTO.getIdCard()));
if (count > 0) {
throw new HttpException(70001);
}
MemberDictDO memberDictDO = new MemberDictDO();
BeanUtils.copyProperties(addMemberDTO, memberDictDO);
//信息来源
if (null != addMemberDTO.getStationId()) {
WorkstationDictDO workstationDictDO = workstationDictMapper.selectById(addMemberDTO.getStationId());
if (null != workstationDictDO) {
memberDictDO.setInfoOrigin(workstationDictDO.getWorkstationName());
}
} else {
memberDictDO.setInfoOrigin("自然人数据库");
}
List<Long> positionIds = addMemberDTO.getPositionIds();
for (Long positionId : positionIds) {
MemberPositionsDO memberPositionsDO = new MemberPositionsDO();
memberPositionsDO.setMemberId(memberDictDO.getId());
memberPositionsDO.setPositionId(positionId);
memberPositionsMapper.insert(memberPositionsDO);
}
this.baseMapper.insert(memberDictDO);
if (null != addMemberDTO.getStationId()) {
WorkstationMemberMappingDO workstationMemberMappingDO = new WorkstationMemberMappingDO();
workstationMemberMappingDO.setMemberId(memberDictDO.getId());
workstationMemberMappingDO.setStationId(addMemberDTO.getStationId());
workstationMemberMappingMapper.insert(workstationMemberMappingDO);
}
if (null != addMemberDTO.getTeamId()) {
MemberTeamMappingDO memberTeamMappingDO = new MemberTeamMappingDO();
memberTeamMappingDO.setMemberId(memberDictDO.getId());
memberTeamMappingDO.setTeamId(addMemberDTO.getTeamId());
memberTeamMappingMapper.insert(memberTeamMappingDO);
}
//历史
MemberUpdateHistoryDO memberUpdateHistoryDO = new MemberUpdateHistoryDO();
memberUpdateHistoryDO.setAdministerId(addMemberDTO.getUserId());
memberUpdateHistoryDO.setModule(addMemberDTO.getModule());
memberUpdateHistoryDO.setMemberId(memberDictDO.getId());
memberUpdateHistoryDO.setOpr("创建了该成员");
memberUpdateHistoryMapper.insert(memberUpdateHistoryDO);
return ConstantUtils.ADD_SUCCESS;
}
public OneMemberVO oneMember(MemberDictDO memberDictDO) {
OneMemberVO oneMemberVO = new OneMemberVO();
MemberDictDO memberDictDO1 = this.baseMapper.selectById(memberDictDO.getId());
BeanUtils.copyProperties(memberDictDO1, oneMemberVO);
if (null != memberDictDO1.getCollegeId()) {
LibCollegeDO libCollegeDO = libCollegeMapper.selectById(memberDictDO1.getCollegeId());
oneMemberVO.setCollege(libCollegeDO.getCollege());
}
if (null != memberDictDO1.getMajorId()) {
LibMajorDO libMajorDO = libMajorMapper.selectById(memberDictDO1.getMajorId());
oneMemberVO.setMajor(libMajorDO.getMajor());
}
//院校信息
List<MemberCollegeVO> memberCollegeVOS = new ArrayList<>();
List<MemberCollegeMappingDO> memberCollegeMappingDOS = memberCollegeMappingMapper.selectList(new QueryWrapper<MemberCollegeMappingDO>()
.lambda()
.eq(MemberCollegeMappingDO::getMemberId, memberDictDO1.getId()));
for (MemberCollegeMappingDO mcmd : memberCollegeMappingDOS) {
MemberCollegeVO memberCollegeVO = new MemberCollegeVO();
BeanUtils.copyProperties(mcmd, memberCollegeVO);
LibCollegeDO libCollegeDO = libCollegeMapper.selectById(mcmd.getCollegeId());
memberCollegeVO.setCollege(libCollegeDO.getCollege());
LibMajorDO libMajorDO = libMajorMapper.selectById(mcmd.getMajorId());
memberCollegeVO.setMajor(libMajorDO.getMajor());
memberCollegeVOS.add(memberCollegeVO);
}
oneMemberVO.setMemberCollegeVOS(memberCollegeVOS);
//就业信息
List<MemberJobInfoVO> memberJobInfoVOS = new ArrayList<MemberJobInfoVO>();
List<MemberJobInfoDO> memberJobInfoDOS = memberJobInfoMapper.selectList(new QueryWrapper<MemberJobInfoDO>()
.lambda()
.eq(MemberJobInfoDO::getMemberId, memberDictDO1.getId())
.orderByDesc(MemberJobInfoDO::getStartDate));
for (MemberJobInfoDO memberJobInfoDO : memberJobInfoDOS) {
MemberJobInfoVO memberJobInfoVO = new MemberJobInfoVO();
BeanUtils.copyProperties(memberJobInfoDO, memberJobInfoVO);
CompanyDictDO companyDictDO = companyDictMapper.selectById(memberJobInfoDO.getCompanyId());
memberJobInfoVO.setCompanyName(companyDictDO.getCompanyName());
memberJobInfoVOS.add(memberJobInfoVO);
}
oneMemberVO.setMemberJobInfoVOS(memberJobInfoVOS);
//专业技能信息
List<PositionDictDO> memberPositions = memberPositionsMapper.memberPositions(memberDictDO.getId());
oneMemberVO.setPositionDictDOS(memberPositions);
//专业证书信息
List<MemberCertsDO> memberCertsDOS = memberCertsMapper.selectList(new QueryWrapper<MemberCertsDO>()
.lambda()
.eq(MemberCertsDO::getMemberId, memberDictDO1.getId()));
oneMemberVO.setMemberCertsDOS(memberCertsDOS);
//培训信息
List<MemberTrainInfoVO> memberTrainInfoVOS = new ArrayList<>();
List<MemberTrainInfoDO> memberTrainInfoDOS = memberTrainInfoMapper.selectList(new QueryWrapper<MemberTrainInfoDO>()
.lambda()
.eq(MemberTrainInfoDO::getMemberId, memberDictDO1.getId()));
for (MemberTrainInfoDO mtid : memberTrainInfoDOS) {
MemberTrainInfoVO memberTrainInfoVO = new MemberTrainInfoVO();
BeanUtils.copyProperties(mtid, memberTrainInfoVO);
//技能
List<PositionDictDO> positionDictDOS = memberTrainPositionsMapper.positions(mtid.getId());
memberTrainInfoVO.setPositionDictDOS(positionDictDOS);
memberTrainInfoVOS.add(memberTrainInfoVO);
}
oneMemberVO.setMemberTrainInfoVOS(memberTrainInfoVOS);
return oneMemberVO;
}
public String updateMember(UpdateMemberDTO updateMemberDTO) {
MemberDictDO memberDictDO1 = this.baseMapper.selectById(updateMemberDTO.getId());
MemberDictDO memberDictDO = new MemberDictDO();
BeanUtils.copyProperties(updateMemberDTO, memberDictDO);
this.baseMapper.updateById(memberDictDO);
List<MemberJobInfoVO> memberJobInfoVOS = updateMemberDTO.getMemberJobInfoVOS();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("变更了“");
if (null != memberJobInfoVOS) {
memberJobInfoMapper.delete(new QueryWrapper<MemberJobInfoDO>()
.lambda()
.eq(MemberJobInfoDO::getMemberId, updateMemberDTO.getId()));
for (MemberJobInfoVO memberJobInfoVO : memberJobInfoVOS) {
MemberJobInfoDO memberJobInfoDO = new MemberJobInfoDO();
BeanUtils.copyProperties(memberJobInfoVO, memberJobInfoDO);
memberJobInfoMapper.insert(memberJobInfoDO);
}
stringBuffer.append("就业信息、");
}
if (null != updateMemberDTO.getPositionIds()) {
List<Long> newIds = updateMemberDTO.getPositionIds();
List<Long> oldIds = memberPositionsMapper.memberPositionIds(memberDictDO.getId());
List<Long> newIds2 = new ArrayList<Long>();
for (Long id : newIds) {
newIds2.add(id);
}
newIds.removeAll(oldIds); //新增的人在newIds里面
if (newIds.size() > 0) {
for (Long id : newIds) {
MemberPositionsDO memberPositionsDO = new MemberPositionsDO();
memberPositionsDO.setMemberId(memberDictDO.getId());
memberPositionsDO.setPositionId(id);
memberPositionsMapper.insert(memberPositionsDO);
}
}
oldIds.removeAll(newIds2);//删掉以前的
if (oldIds.size() > 0) {
for (Long id : oldIds) {
memberPositionsMapper.delete(new QueryWrapper<MemberPositionsDO>()
.lambda()
.eq(MemberPositionsDO::getMemberId, memberDictDO.getId())
.eq(MemberPositionsDO::getPositionId, id));
}
}
}
//历史
MemberUpdateHistoryDO memberUpdateHistoryDO = new MemberUpdateHistoryDO();
memberUpdateHistoryDO.setAdministerId(updateMemberDTO.getUserId());
memberUpdateHistoryDO.setModule(updateMemberDTO.getModule());
memberUpdateHistoryDO.setMemberId(memberDictDO.getId());
if (null != updateMemberDTO.getUserName() && !updateMemberDTO.getUserName().equals(memberDictDO1.getUserName())) {
stringBuffer.append("姓名、");
}
if (null != updateMemberDTO.getTelephone() && !updateMemberDTO.getTelephone().equals(memberDictDO1.getProvince())) {
stringBuffer.append("手机号码、");
}
if (null != updateMemberDTO.getProvince() && !updateMemberDTO.getProvince().equals(memberDictDO1.getProvince())) {
stringBuffer.append("省、");
}
if (null != updateMemberDTO.getCity() && !updateMemberDTO.getCity().equals(memberDictDO1.getCity())) {
stringBuffer.append("市、");
}
if (null != updateMemberDTO.getCounty() && !updateMemberDTO.getCounty().equals(memberDictDO1.getCounty())) {
stringBuffer.append("县、");
}
if (null != updateMemberDTO.getAddress() && !updateMemberDTO.getAddress().equals(memberDictDO1.getAddress())) {
stringBuffer.append("具体地址、");
}
if (null != updateMemberDTO.getEducation() && !updateMemberDTO.getEducation().equals(memberDictDO1.getEducation())) {
stringBuffer.append("学历、");
}
if (null != updateMemberDTO.getEducationType() && !updateMemberDTO.getEducationType().equals(memberDictDO1.getEducationType())) {
stringBuffer.append("学历类型、");
}
if (null != updateMemberDTO.getCollegeId() && !updateMemberDTO.getCollegeId().equals(memberDictDO1.getCollegeId())) {
stringBuffer.append("院校、");
}
if (null != updateMemberDTO.getIsPoor() && !updateMemberDTO.getIsPoor().equals(memberDictDO1.getIsPoor())) {
stringBuffer.append("是否为脱贫劳动力、");
}
if (null != updateMemberDTO.getIsMigration() && !updateMemberDTO.getIsMigration().equals(memberDictDO1.getIsMigration())) {
stringBuffer.append("是否易迁户、");
}
if (null != updateMemberDTO.getIsParty() && !updateMemberDTO.getIsParty().equals(memberDictDO1.getIsParty())) {
stringBuffer.append("是否党员、");
}
if (null != updateMemberDTO.getJobStatus() && !updateMemberDTO.getJobStatus().equals(memberDictDO1.getJobStatus())) {
stringBuffer.append("就业状态、");
}
String opr = stringBuffer.substring(0, stringBuffer.length() - 1) + "”";
memberUpdateHistoryDO.setOpr(opr);
memberUpdateHistoryMapper.insert(memberUpdateHistoryDO);
return ConstantUtils.SUCCESS_UPDATE;
}
}