DrawLotGroupDictServiceImpl.java
5.25 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
package com.zhongzhi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhongzhi.common.constant.RoleType;
import com.zhongzhi.common.exception.HttpException;
import com.zhongzhi.common.utils.ConstantUtils;
import com.zhongzhi.dao.DrawLotsGroupItemsMapper;
import com.zhongzhi.dao.DrawLotsGroupJudgesMapper;
import com.zhongzhi.dao.MatchDictDAO;
import com.zhongzhi.model.DrawLotGroupDictDO;
import com.zhongzhi.dao.DrawLotGroupDictMapper;
import com.zhongzhi.model.DrawLotsGroupItemsDO;
import com.zhongzhi.model.DrawLotsGroupJudgesDO;
import com.zhongzhi.service.DrawLotGroupDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongzhi.vo.drawlots.AllGroupsVO;
import com.zhongzhi.vo.drawlots.GroupJudgesVO;
import com.zhongzhi.vo.drawlots.SceneGroupsVO;
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 DengMin
* @since 2025-06-19
*/
@Service
public class DrawLotGroupDictServiceImpl extends ServiceImpl<DrawLotGroupDictMapper, DrawLotGroupDictDO> implements DrawLotGroupDictService {
@Autowired
private DrawLotsGroupJudgesMapper drawLotsGroupJudgesMapper;
@Autowired
private DrawLotsGroupItemsMapper drawLotsGroupItemsMapper;
@Override
public List<AllGroupsVO> allGroups(DrawLotGroupDictDO drawLotGroupDictDO) {
List<AllGroupsVO> result = new ArrayList<>();
List<DrawLotGroupDictDO> drawLotGroupDictDOS = this.baseMapper.selectList(new QueryWrapper<DrawLotGroupDictDO>()
.lambda()
.eq(DrawLotGroupDictDO::getSceneId, drawLotGroupDictDO.getSceneId()));
for (DrawLotGroupDictDO dlgd : drawLotGroupDictDOS){
AllGroupsVO allGroupsVO = new AllGroupsVO();
BeanUtils.copyProperties(dlgd,allGroupsVO);
//组长
List<GroupJudgesVO> leader = this.baseMapper.groupJudges(dlgd.getId(), RoleType.TEAMLEADER);
allGroupsVO.setLeader(leader);
//成员
List<GroupJudgesVO> member = this.baseMapper.groupJudges(dlgd.getId(), RoleType.TEAMMEMBER);
allGroupsVO.setMember(member);
result.add(allGroupsVO);
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String addGroup(DrawLotGroupDictDO drawLotGroupDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<DrawLotGroupDictDO>()
.lambda()
.eq(DrawLotGroupDictDO::getSceneId, drawLotGroupDictDO.getSceneId())
.eq(DrawLotGroupDictDO::getGroupName, drawLotGroupDictDO.getGroupName()));
if (count > 0) {
throw new HttpException(10035);
}
this.baseMapper.insert(drawLotGroupDictDO);
return ConstantUtils.ADD_SUCCESS;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String updateGroup(DrawLotGroupDictDO drawLotGroupDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<DrawLotGroupDictDO>()
.lambda()
.eq(DrawLotGroupDictDO::getSceneId, drawLotGroupDictDO.getSceneId())
.eq(DrawLotGroupDictDO::getGroupName, drawLotGroupDictDO.getGroupName())
.ne(DrawLotGroupDictDO::getId, drawLotGroupDictDO.getId()));
if (count > 0) {
throw new HttpException(10035);
}
this.baseMapper.updateById(drawLotGroupDictDO);
return ConstantUtils.SUCCESS_UPDATE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String deleteGroup(DrawLotGroupDictDO drawLotGroupDictDO) {
//删除专家
drawLotsGroupJudgesMapper.delete(new QueryWrapper<DrawLotsGroupJudgesDO>()
.lambda()
.eq(DrawLotsGroupJudgesDO::getGroupId,drawLotGroupDictDO.getId()));
//删除组别
drawLotsGroupItemsMapper.delete(new QueryWrapper<DrawLotsGroupItemsDO>()
.lambda()
.eq(DrawLotsGroupItemsDO::getGroupId,drawLotGroupDictDO.getId()));
this.baseMapper.deleteById(drawLotGroupDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Override
public List<SceneGroupsVO> sceneGroups(DrawLotGroupDictDO drawLotGroupDictDO) {
List<SceneGroupsVO> result = new ArrayList<>();
List<DrawLotGroupDictDO> drawLotGroupDictDOS = this.baseMapper.selectList(new QueryWrapper<DrawLotGroupDictDO>()
.lambda()
.eq(DrawLotGroupDictDO::getSceneId,drawLotGroupDictDO.getSceneId())
.orderByAsc(DrawLotGroupDictDO::getId));
for (DrawLotGroupDictDO drawLotGroupDictDO1 : drawLotGroupDictDOS){
SceneGroupsVO sceneGroupsVO = new SceneGroupsVO();
sceneGroupsVO.setGroupId(drawLotGroupDictDO1.getId());
sceneGroupsVO.setGroupName(drawLotGroupDictDO1.getGroupName());
//编号
List<Integer> integer = this.baseMapper.groupNums(drawLotGroupDictDO1.getId());
sceneGroupsVO.setGroupNums(integer);
result.add(sceneGroupsVO);
}
return result;
}
}