PositionRequireItemServiceImpl.java
8.65 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
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.dto.position.AddRequirementsDTO;
import com.laowu.dto.position.RequirementsDTO;
import com.laowu.mapper.*;
import com.laowu.model.*;
import com.laowu.service.PositionRequireItemService;
import com.laowu.util.ConstantUtils;
import com.laowu.vo.position.*;
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.List;
/**
* <p>
* 项目职位需求信息 服务实现类
* </p>
*
* @author Tuyp
* @since 2023-03-27
*/
@Service
public class PositionRequireItemServiceImpl extends ServiceImpl<PositionRequireItemMapper, PositionRequireItemDO> implements PositionRequireItemService {
@Autowired
private PositionItemInfoMapper positionItemInfoMapper;
@Autowired
private PositionItemJobMappingMapper positionItemJobMappingMapper;
@Autowired
private PositionRequireHistoryMapper positionRequireHistoryMapper;
@Autowired
private WorkstationRequireMappingMapper workstationRequireMappingMapper;
@Autowired
private CompanyDictMapper companyDictMapper;
public IPage<RequirementsVO> requirements(RequirementsDTO requirementsDTO) {
Page pager = new Page(requirementsDTO.getPageNum(), requirementsDTO.getPageSize());
IPage<RequirementsVO> iPage = this.baseMapper.requirements(pager, requirementsDTO.getItemName(), requirementsDTO.getItemStatus(), requirementsDTO.getProvince(), requirementsDTO.getCity(), requirementsDTO.getCounty(), requirementsDTO.getPositionId());
List<RequirementsVO> records = iPage.getRecords();
for (RequirementsVO rv : records) {
//预招人数
List<PositionCountsVO> positionItemInfoDOS = positionItemInfoMapper.positionCounts(rv.getId());
rv.setPositionItemInfoDOS(positionItemInfoDOS);
//职位分类
List<LibJobSortDO> libJobSortDOS = positionItemJobMappingMapper.positionSorts(rv.getId());
rv.setLibJobSortDOS(libJobSortDOS);
}
return iPage;
}
public String deleteRequirements(AddRequirementsDTO addRequirementsDTO) {
List<PositionItemInfoDO> itemInfoDOS = positionItemInfoMapper.selectList(new QueryWrapper<PositionItemInfoDO>()
.lambda()
.eq(PositionItemInfoDO::getPositionRequireId, addRequirementsDTO.getId()));
for (PositionItemInfoDO piid : itemInfoDOS) {
List<PositionItemJobMappingDO> positionItemJobMappingDOS = positionItemJobMappingMapper.selectList(new QueryWrapper<PositionItemJobMappingDO>()
.lambda()
.eq(PositionItemJobMappingDO::getItemInfoId, piid.getId()));
positionItemJobMappingDOS.stream().forEach(x -> {
positionItemJobMappingMapper.deleteById(x.getId());
});
positionItemInfoMapper.deleteById(piid.getId());
}
this.baseMapper.deleteById(addRequirementsDTO.getId());
PositionRequireHistoryDO positionRequireHistoryDO = new PositionRequireHistoryDO();
positionRequireHistoryDO.setRequireId(addRequirementsDTO.getId());
positionRequireHistoryDO.setAdministerId(addRequirementsDTO.getUserId());
positionRequireHistoryDO.setModule(addRequirementsDTO.getModule());
positionRequireHistoryDO.setOpr("删除了项目职位需求信息");
return ConstantUtils.DELETE_SUCCESS;
}
public String updateRequirements(AddRequirementsDTO addRequirementsDTO) {
PositionRequireItemDO positionRequireItemDO1 = this.baseMapper.selectById(addRequirementsDTO.getId());
PositionRequireItemDO positionRequireItemDO = new PositionRequireItemDO();
BeanUtils.copyProperties(addRequirementsDTO,positionRequireItemDO);
this.baseMapper.updateById(positionRequireItemDO);
//修改内容
PositionRequireHistoryDO positionRequireHistoryDO = new PositionRequireHistoryDO();
positionRequireHistoryDO.setAdministerId(addRequirementsDTO.getUserId());
positionRequireHistoryDO.setModule(addRequirementsDTO.getModule());
positionRequireHistoryDO.setRequireId(positionRequireItemDO.getId());
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("变更了“");
//id itemName itemStatus companyId jobId infoOrigin province city county
if (null != positionRequireItemDO1.getItemName() && !positionRequireItemDO1.getItemName().equals(addRequirementsDTO.getItemName())){
stringBuffer.append("项目名称、");
}
if (null != positionRequireItemDO1.getCompanyId() && !positionRequireItemDO1.getCompanyId().equals(addRequirementsDTO.getCompanyId())){
stringBuffer.append("企业名称、");
}
if (null != positionRequireItemDO1.getItemStatus() && !positionRequireItemDO1.getItemStatus().equals(addRequirementsDTO.getItemStatus())){
stringBuffer.append("招聘状态、");
}
if (null != positionRequireItemDO1.getInfoOrigin() && !positionRequireItemDO1.getInfoOrigin().equals(addRequirementsDTO.getInfoOrigin())){
stringBuffer.append("关联信息、");
}
if (null != positionRequireItemDO1.getProvince() && !positionRequireItemDO1.getProvince().equals(addRequirementsDTO.getProvince())||!positionRequireItemDO1.getCity().equals(addRequirementsDTO.getCity())||!positionRequireItemDO1.getCounty().equals(addRequirementsDTO.getCounty())){
stringBuffer.append("就业地区");
}
String opr = stringBuffer.substring(0, stringBuffer.length() - 1) + "”";
positionRequireHistoryDO.setOpr(opr);
positionRequireHistoryMapper.insert(positionRequireHistoryDO);
return ConstantUtils.SUCCESS_UPDATE;
}
@Transactional(rollbackFor = Exception.class)
public String addRequirements(AddRequirementsDTO addRequirementsDTO) {
PositionRequireItemDO positionRequireItemDO = new PositionRequireItemDO();
BeanUtils.copyProperties(addRequirementsDTO,positionRequireItemDO);
this.baseMapper.insert(positionRequireItemDO);
WorkstationRequireMappingDO workstationRequireMappingDO = new WorkstationRequireMappingDO();
workstationRequireMappingDO.setStationId(addRequirementsDTO.getStationId());
workstationRequireMappingDO.setRequireId(positionRequireItemDO.getId());
workstationRequireMappingMapper.insert(workstationRequireMappingDO);
PositionRequireHistoryDO positionRequireHistoryDO = new PositionRequireHistoryDO();
positionRequireHistoryDO.setRequireId(positionRequireHistoryDO.getId());
positionRequireHistoryDO.setAdministerId(addRequirementsDTO.getUserId());
positionRequireHistoryDO.setModule(addRequirementsDTO.getModule());
positionRequireHistoryDO.setOpr("创建了项目职位需求信息");
positionRequireHistoryMapper.insert(positionRequireHistoryDO);
return ConstantUtils.ADD_SUCCESS;
}
public OneRequirementVO oneRequirement(PositionRequireItemDO positionRequireItemDO) {
OneRequirementVO oneRequirementVO = new OneRequirementVO();
PositionRequireItemDO positionRequireItemDO1 = this.baseMapper.selectById(positionRequireItemDO.getId());
BeanUtils.copyProperties(positionRequireItemDO1,oneRequirementVO);
CompanyDictDO companyDictDO = companyDictMapper.selectById(positionRequireItemDO1.getCompanyId());
oneRequirementVO.setCompanyName(companyDictDO.getCompanyName());
//预招人数
List<PositionCountsVO> positionItemInfoDOS = positionItemInfoMapper.positionCounts(positionRequireItemDO.getId());
oneRequirementVO.setPositionItemInfoDOS(positionItemInfoDOS);
//职位分类
List<LibJobSortDO> libJobSortDOS = positionItemJobMappingMapper.positionSorts(positionRequireItemDO.getId());
oneRequirementVO.setLibJobSortDOS(libJobSortDOS);
//关联业务
List<RequireWorkstationsVO> requireWorkstationsVOS = workstationRequireMappingMapper.requireWorkstations(positionRequireItemDO.getId());
oneRequirementVO.setRequireWorkstationsVOS(requireWorkstationsVOS);
//更新日志
List<RequireHistoryVO> requireHistoryVOS = positionRequireHistoryMapper.requireHistory(positionRequireItemDO.getId());
oneRequirementVO.setRequireHistoryVOS(requireHistoryVOS);
return oneRequirementVO;
}
}