xuhy
2024-12-11 5be07b1a021f596b003eac001f4cb77416ae6c7b
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
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import com.ruoyi.web.controller.query.CommitteeQuery;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.jcajce.provider.symmetric.AES;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
 
/**
 * <p>
 * 评审委员会 前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-09-19
 */
@RestController
@RequestMapping("/t-committee")
public class TCommitteeController {
    @Resource
    private TCommitteeService tCommitteeService;
    @Resource
    private TCommitteeTechnicalService committeeTechnicalService;
    @Resource
    private TCommitteeMajorService tCommitteeMajorService;
    @Resource
    private TRegionService regionService;
    @Resource
    private TTechnicalTitleService tTechnicalTitleService;
    @Resource
    private TTitleMajorService majorService;
 
 
    //添加
    @ApiOperation(value = "添加",tags = "后台-评审委员会管理")
    @PostMapping("/add")
    public R add(@RequestBody TCommittee committee){
        tCommitteeService.save(committee);
        for (TCommitteeTechnical tCommitteeTechnical : committee.getTCommitteeTechnicals()) {
            tCommitteeTechnical.setCommitteeId(committee.getId());
        }
        committeeTechnicalService.saveBatch(committee.getTCommitteeTechnicals());
        for (TCommitteeMajor tCommitteeMajor : committee.getTCommitteeMajors()) {
            tCommitteeMajor.setCommitteeId(committee.getId());
        }
        tCommitteeMajorService.saveBatch(committee.getTCommitteeMajors());
        return R.ok();
    }
 
    //修改
    @ApiOperation(value = "编辑",tags = "后台-评审委员会管理")
    @PostMapping("/edit")
    public R edit(@RequestBody TCommittee committee){
        tCommitteeService.updateById(committee);
      //删除相关数据
        committeeTechnicalService.remove(Wrappers.lambdaQuery(TCommitteeTechnical.class).eq(TCommitteeTechnical::getCommitteeId, committee.getId()));
        tCommitteeMajorService.remove(Wrappers.lambdaQuery(TCommitteeMajor.class).eq(TCommitteeMajor::getCommitteeId, committee.getId()));
        for (TCommitteeTechnical tCommitteeTechnical : committee.getTCommitteeTechnicals()) {
            tCommitteeTechnical.setId(null);
            tCommitteeTechnical.setCommitteeId(committee.getId());
        }
        committeeTechnicalService.saveBatch(committee.getTCommitteeTechnicals());
        for (TCommitteeMajor tCommitteeMajor : committee.getTCommitteeMajors()) {
            tCommitteeMajor.setCommitteeId(committee.getId());
            tCommitteeMajor.setId(null);
        }
        tCommitteeMajorService.saveBatch(committee.getTCommitteeMajors());
        return R.ok();
    }
    //删除
    @ApiOperation(value = "删除",tags = "后台-评审委员会管理")
    @PostMapping("/deleteByIds")
    public R deleteByIds(String ids){
        List<String> list = Arrays.asList(ids.split(","));
        tCommitteeService.removeByIds(list);
        //删除相关数据
        committeeTechnicalService.remove(Wrappers.lambdaQuery(TCommitteeTechnical.class).in(TCommitteeTechnical::getCommitteeId, list));
        tCommitteeMajorService.remove(Wrappers.lambdaQuery(TCommitteeMajor.class).in(TCommitteeMajor::getCommitteeId, list));
 
        return R.ok();
    }
    //列表
    @ApiOperation(value = "查询",tags = {"后台-评审委员会管理"})
    @PostMapping("/list")
    public R<Page<TCommittee>> list(@RequestBody CommitteeQuery informationQuery){
        Page<TCommittee> page;
        if(informationQuery.getSortType() == 1){
            page = tCommitteeService.lambdaQuery()
                    .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName())
                    .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeUnit, informationQuery.getCommitteeUnit())
                    .eq(informationQuery.getRegionId() != null, TCommittee::getRegionId, informationQuery.getRegionId())
                    .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId())
                    .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId())
                    .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel())
                    .orderByDesc(TCommittee::getCreateTime)
                    .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize()));
        }else {
            page = tCommitteeService.lambdaQuery()
                    .like(!StringUtils.isEmpty(informationQuery.getName()), TCommittee::getCommitteeName, informationQuery.getName())
                    .like(!StringUtils.isEmpty(informationQuery.getCommitteeUnit()), TCommittee::getCommitteeUnit, informationQuery.getCommitteeUnit())
                    .eq(informationQuery.getRegionId() != null, TCommittee::getRegionId, informationQuery.getRegionId())
                    .eq(informationQuery.getTechnicalId() != null, TCommittee::getTechnicalId, informationQuery.getTechnicalId())
                    .eq(informationQuery.getMajorId() != null, TCommittee::getMajorId, informationQuery.getMajorId())
                    .eq(informationQuery.getLevel() != null, TCommittee::getLevel, informationQuery.getLevel())
                    .orderByDesc(TCommittee::getCommitteeSort)
                    .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize()));
        }
 
        for (TCommittee record : page.getRecords()) {
            TRegion byId = regionService.getById(record.getRegionId());
            record.setRegionName(byId.getProvinceName()+"-"+byId.getName());
            TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId() );
            TTitleMajor byId2 = majorService.getById(record.getMajorId());
            record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName());
 
 
            List<TCommitteeTechnical> tCommitteeTechnicals = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getCommitteeId, record.getId()).list();
            List<TCommitteeMajor> tCommitteeMajors =tCommitteeMajorService.lambdaQuery().eq(TCommitteeMajor::getCommitteeId, record.getId()).list();
 
            record.setTCommitteeTechnicals(tCommitteeTechnicals);
            record.setTCommitteeMajors(tCommitteeMajors);
        }
        return R.ok(page);
    }
    @Resource
    private TDeclareNoticeService noticeService;
 
    //详情
    @ApiOperation(value = "详情",tags = {"后台-评审委员会管理","web-评审委员会"})
    @PostMapping("/getById")
    public R<TCommittee> getById(Long id){
        TCommittee tCommittee = tCommitteeService.getById(id);
        List<TCommitteeTechnical> tCommitteeTechnicals = committeeTechnicalService.lambdaQuery().eq(TCommitteeTechnical::getCommitteeId, id).list();
        List<TCommitteeMajor> tCommitteeMajors =tCommitteeMajorService.lambdaQuery().eq(TCommitteeMajor::getCommitteeId, id).list();
        if (tCommittee.getDeclareId()!=null) {
            String[] split = tCommittee.getDeclareId().split(",");
            List<TDeclareNotice> list = noticeService.lambdaQuery().in(TDeclareNotice::getId, split).list();
            tCommittee.setDeclareNotice(list);
        }
        tCommittee.setTCommitteeTechnicals(tCommitteeTechnicals);
        tCommittee.setTCommitteeMajors(tCommitteeMajors);
        return R.ok(tCommittee);
    }
 
}