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
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
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.ConsultationQuery;
import com.ruoyi.web.controller.query.DeclareNoticeQuery;
import io.swagger.annotations.ApiOperation;
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.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 申报通知 前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-09-19
 */
@RestController
@RequestMapping("/t-declare-notice")
public class TDeclareNoticeController {
    @Resource
    private TDeclareNoticeService tDeclareNoticeService;
    @Resource
    private TDeclareNoticeFileService tDeclareNoticeFileService;
    @Resource
    private TDeclareNoticeTechnicalService tDeclareNoticeTechnicalService;
    @Resource
    private TDeclareNoticeMajorService tDeclareNoticeMajorService;
    @Resource
    private TRegionService regionService;
    @Resource
    private TTechnicalTitleService tTechnicalTitleService;
    @Resource
    private TTitleMajorService majorService;
 
    //添加
    @ApiOperation(value = "添加",tags = "后台-申报通知")
    @PostMapping(value = "/add")
    public R add(@RequestBody TDeclareNotice tDeclareNotice) {
        tDeclareNoticeService.save(tDeclareNotice);
        //附件要求
        for (TDeclareNoticeFile declareNoticeFile : tDeclareNotice.getDeclareNoticeFiles()) {
            declareNoticeFile.setId(null);
            declareNoticeFile.setDeclareId(tDeclareNotice.getId());
        }
        tDeclareNoticeFileService.saveBatch(tDeclareNotice.getDeclareNoticeFiles());
        //评审职称
        for (TDeclareNoticeTechnical declareNoticeTechnical : tDeclareNotice.getDeclareNoticeTechnicals()) {
            declareNoticeTechnical.setId(null);
            declareNoticeTechnical.setDeclareId(tDeclareNotice.getId());
        }
        tDeclareNoticeTechnicalService.saveBatch(tDeclareNotice.getDeclareNoticeTechnicals());
        //评审专业
        for (TDeclareNoticeMajor declareNoticeMajor : tDeclareNotice.getDeclareNoticeMajors()) {
            declareNoticeMajor.setId(null);
            declareNoticeMajor.setDeclareId(tDeclareNotice.getId());
        }
        tDeclareNoticeMajorService.saveBatch(tDeclareNotice.getDeclareNoticeMajors());
        return R.ok();
    }
    //修改
    @ApiOperation(value = "修改",tags = "后台-申报通知")
    @PostMapping(value = "/edit")
    public R edit(@RequestBody TDeclareNotice tDeclareNotice) {
        tDeclareNoticeService.updateById(tDeclareNotice);
        //删除关联数据
        tDeclareNoticeFileService.remove(Wrappers.lambdaQuery(TDeclareNoticeFile.class).eq(TDeclareNoticeFile::getDeclareId, tDeclareNotice.getId()));
        tDeclareNoticeTechnicalService.remove(Wrappers.lambdaQuery(TDeclareNoticeTechnical.class).eq(TDeclareNoticeTechnical::getDeclareId, tDeclareNotice.getId()));
        tDeclareNoticeMajorService.remove(Wrappers.lambdaQuery(TDeclareNoticeMajor.class).eq(TDeclareNoticeMajor::getDeclareId, tDeclareNotice.getId()));
        //附件要求
        for (TDeclareNoticeFile declareNoticeFile : tDeclareNotice.getDeclareNoticeFiles()) {
            declareNoticeFile.setId(null);
            declareNoticeFile.setDeclareId(tDeclareNotice.getId());
        }
        tDeclareNoticeFileService.saveBatch(tDeclareNotice.getDeclareNoticeFiles());
        //评审职称
        for (TDeclareNoticeTechnical declareNoticeTechnical : tDeclareNotice.getDeclareNoticeTechnicals()) {
            declareNoticeTechnical.setDeclareId(tDeclareNotice.getId());
            declareNoticeTechnical.setId(null);
        }
        tDeclareNoticeTechnicalService.saveBatch(tDeclareNotice.getDeclareNoticeTechnicals());
        //评审专业
        for (TDeclareNoticeMajor declareNoticeMajor : tDeclareNotice.getDeclareNoticeMajors()) {
            declareNoticeMajor.setDeclareId(tDeclareNotice.getId());
            declareNoticeMajor.setId(null);
        }
        tDeclareNoticeMajorService.saveBatch(tDeclareNotice.getDeclareNoticeMajors());
 
        return R.ok();
    }
    @Resource
    private TCommitteeService committeeService;
    //删除
    @ApiOperation(value = "删除",tags = "后台-申报通知")
    @PostMapping(value = "/deleteByIds")
    public R deleteByIds(String ids) {
        List<String> list = Arrays.asList(ids.split(","));
        tDeclareNoticeService.removeByIds(list);
 
        Long count = committeeService.lambdaQuery().in(TCommittee::getDeclareId, list).count();
        if (count>0){
            return R.fail("当前通知已设置委员会,无法删除");
        }
 
        //删除相关数据
        tDeclareNoticeFileService.remove(Wrappers.lambdaQuery(TDeclareNoticeFile.class).in(TDeclareNoticeFile::getDeclareId, list));
        tDeclareNoticeTechnicalService.remove(Wrappers.lambdaQuery(TDeclareNoticeTechnical.class).in(TDeclareNoticeTechnical::getDeclareId, list));
        tDeclareNoticeMajorService.remove(Wrappers.lambdaQuery(TDeclareNoticeMajor.class).in(TDeclareNoticeMajor::getDeclareId, list));
 
        return R.ok();
    }
 
    //列表
    @ApiOperation(value = "查询",tags = {"后台-申报通知","web-职称申报"})
    @PostMapping(value = "/list")
    public R<Page<TDeclareNotice>> list(@RequestBody DeclareNoticeQuery informationQuery) {
        Page<TDeclareNotice> page;
        if(informationQuery.getSortType()==1){
            page = tDeclareNoticeService.lambdaQuery()
                    .like(!StringUtils.isEmpty(informationQuery.getDeclareNoticeName()), TDeclareNotice::getDeclareNoticeName, informationQuery.getDeclareNoticeName())
                    .eq(informationQuery.getRegionId() != null, TDeclareNotice::getRegionId, informationQuery.getRegionId())
                    .eq(informationQuery.getTechnicalId() != null, TDeclareNotice::getTechnicalId, informationQuery.getTechnicalId())
                    .eq(informationQuery.getMajorId() != null, TDeclareNotice::getMajorId, informationQuery.getMajorId())
                    .eq(informationQuery.getLevel() != null, TDeclareNotice::getLevel, informationQuery.getLevel())
                    .eq(informationQuery.getIsOnline()!=null, TDeclareNotice::getIsOnline, informationQuery.getIsOnline())
                    .between(informationQuery.getDeclareStartTime1()!=null,TDeclareNotice::getDeclareStartTime,informationQuery.getDeclareStartTime1(),informationQuery.getDeclareStartTime2())
                    .between(informationQuery.getDeclareEndTime1()!=null,TDeclareNotice::getDeclareEndTime,informationQuery.getDeclareEndTime1(),informationQuery.getDeclareEndTime2())
                    .orderByDesc(TDeclareNotice::getCreateTime)
                    .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize()));
        }else {
            page = tDeclareNoticeService.lambdaQuery()
                    .like(!StringUtils.isEmpty(informationQuery.getDeclareNoticeName()), TDeclareNotice::getDeclareNoticeName, informationQuery.getDeclareNoticeName())
                    .eq(informationQuery.getRegionId() != null, TDeclareNotice::getRegionId, informationQuery.getRegionId())
                    .eq(informationQuery.getTechnicalId() != null, TDeclareNotice::getTechnicalId, informationQuery.getTechnicalId())
                    .eq(informationQuery.getMajorId() != null, TDeclareNotice::getMajorId, informationQuery.getMajorId())
                    .eq(informationQuery.getLevel() != null, TDeclareNotice::getLevel, informationQuery.getLevel())
                    .eq(informationQuery.getIsOnline()!=null, TDeclareNotice::getIsOnline, informationQuery.getIsOnline())
                    .between(informationQuery.getDeclareStartTime1()!=null,TDeclareNotice::getDeclareStartTime,informationQuery.getDeclareStartTime1(),informationQuery.getDeclareStartTime2())
                    .between(informationQuery.getDeclareEndTime1()!=null,TDeclareNotice::getDeclareEndTime,informationQuery.getDeclareEndTime1(),informationQuery.getDeclareEndTime2())
                    .orderByDesc(TDeclareNotice::getNoticeSort)
                    .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize()));
        }
 
        for (TDeclareNotice 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());
        }
        return R.ok(page);
    }
    //详情
    @ApiOperation(value = "详情",tags = {"后台-申报通知","web-职称申报"})
    @PostMapping(value = "/getById")
    public R<TDeclareNotice> getById(Long id){
        TDeclareNotice tDeclareNotice = tDeclareNoticeService.getById(id);
        List<TDeclareNoticeFile> tDeclareNoticeFiles = tDeclareNoticeFileService.lambdaQuery().eq(TDeclareNoticeFile::getDeclareId, id).list();
        List<TDeclareNoticeTechnical> tDeclareNoticeTechnicals = tDeclareNoticeTechnicalService.lambdaQuery().eq(TDeclareNoticeTechnical::getDeclareId, id).list();
        List<TDeclareNoticeMajor> tDeclareNoticeMajors = tDeclareNoticeMajorService.lambdaQuery().eq(TDeclareNoticeMajor::getDeclareId, id).list();
        tDeclareNotice.setDeclareNoticeFiles(tDeclareNoticeFiles);
        tDeclareNotice.setDeclareNoticeTechnicals(tDeclareNoticeTechnicals);
        tDeclareNotice.setDeclareNoticeMajors(tDeclareNoticeMajors);
        if(StringUtils.isEmpty(tDeclareNotice.getDeclareLevel())){
            tDeclareNotice.setDeclareLevel(tDeclareNoticeTechnicals.stream().map(TDeclareNoticeTechnical::getLevelName).collect(Collectors.joining("/")));
        }
        return R.ok(tDeclareNotice);
    }
 
 
 
}