chenrui
2025-03-13 f0afb2b17f2f6e13925ffe1b6fd8c8ae724aec0e
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.ruoyi.personnel.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.personnel.dto.PersonSupervisePlanDetailsDto;
import com.ruoyi.personnel.dto.PersonSupervisePlanDto;
import com.ruoyi.personnel.pojo.PersonSupervisePlan;
import com.ruoyi.personnel.pojo.PersonSupervisePlanDetails;
import com.ruoyi.personnel.service.PersonSupervisePlanDetailsService;
import com.ruoyi.personnel.service.PersonSupervisePlanService;
import com.ruoyi.system.mapper.UserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.Map;
 
/**
 * <p>
 * 监管计划 前端控制器
 * </p>
 *
 * @author tangbowen
 * @since 2024-09-29 11:13:25
 */
@Api(tags = "人员 - 监督计划")
@AllArgsConstructor
@RestController
@RequestMapping("/superVisePlan")
public class SuperVisePlanController {
 
    private PersonSupervisePlanDetailsService personSupervisePlanDetailsService;
 
    private PersonSupervisePlanService personSupervisePlanService;
 
    private UserMapper userMapper;
 
    @ApiOperation(value = "查询 年度计划")
    @GetMapping("/yearPlanList")
    public Result<IPage<PersonSupervisePlanDto>> yearPlanList(Integer size, Integer current, @RequestParam(value = "organizationPerson",required = false) String organizationPerson, Integer departId) {
        if(departId.equals(1)) {
            departId = null;
        }
       return Result.success(personSupervisePlanService.yearPlanDtoIPage(new Page<>(current, size), organizationPerson,departId));
    }
 
    @ApiOperation(value = "批准 年度计划")
    @PostMapping("/yearPlanDetailApproval")
    public Result yearPlanDetailApproval(@RequestBody Map<String,Object> map ) {
        Integer id = (Integer)map.get("id");
        Integer approvalStatus =(Integer) map.get("approvalStatus");
        PersonSupervisePlan byId = personSupervisePlanService.getById(id);
        // 通信的为许军 电力的是刘建德
        Integer approvalId = null;
        if (ObjectUtils.isNull(byId.getDepartId())){
            throw new ErrorException("该用户没有配置相关实验室部门信息!!");
        }
        Integer departId = byId.getDepartId();
        if(departId.equals(18)) {
            approvalId = 11;
        } else if (departId.equals(19)) {
            approvalId = 35;
        }
        personSupervisePlanService.update(Wrappers.<PersonSupervisePlan>lambdaUpdate()
                .eq(PersonSupervisePlan::getId, id)
                .set(PersonSupervisePlan::getApprovalStatus, approvalStatus)
                .set(PersonSupervisePlan::getApprovalId,approvalId)
                .set(PersonSupervisePlan::getApprovalDate, LocalDateTime.now()));
        return Result.success("更新成功");
    }
 
    @ApiOperation(value = "删除 年度计划")
    @DeleteMapping("/yearPlanDel")
    public Result yearPlanDel(String id) {
        personSupervisePlanService.removeById(id);
        // 对应的年度计划详情也需删除
        personSupervisePlanDetailsService.remove(Wrappers.<PersonSupervisePlanDetails>lambdaQuery()
                .eq(PersonSupervisePlanDetails::getPlanId, id));
        return Result.success();
    }
 
    @ApiOperation(value = "查询 年度计划详情")
    @GetMapping("/yearPlanDetailList")
    public Result<IPage<PersonSupervisePlanDetailsDto>> yearPlanDetailList(Page page,
                                                                           Integer planId,
                                                                           @RequestParam(value = "date",required = false) String date,
                                                                           @RequestParam(value = "project",required = false) String project) {
        return Result.success(personSupervisePlanDetailsService.yearPlanDetailPage(page, date,project, planId));
    }
 
    /**
     * 可能是excel 也可能是word
     * @param file
     * @param suffix 文件后缀
     * @return
     */
    @ApiOperation(value = "导入 年度计划")
    @PostMapping("/yearPlanDetailImport")
    public Result yearPlanDetailImport(@RequestParam("file") MultipartFile file,@RequestParam("suffix")String suffix) {
        personSupervisePlanService.yearPlanDetailImport(file,suffix);
        return Result.success();
    }
 
    @ApiOperation(value = "删除 年度计划详情")
    @DeleteMapping("/yearPlanDetailDel")
    public Result yearPlanDetailDel(String id) {
        return Result.success(personSupervisePlanDetailsService.removeById(id));
    }
 
    @ApiOperation(value = "新增 年度计划详情")
    @PostMapping("/yearPlanDetailAdd")
    public Result yearPlanDetailAdd(@RequestBody PersonSupervisePlanDetails personSupervisePlanDetails) {
        personSupervisePlanDetailsService.save(personSupervisePlanDetails);
        return Result.success();
    }
 
    @ApiOperation(value = "编辑 年度计划详情")
    @PostMapping("/yearPlanDetailEdit")
    public Result yearPlanDetailEdit(@RequestBody PersonSupervisePlanDetails personSupervisePlanDetails) {
        personSupervisePlanDetailsService.updateById(personSupervisePlanDetails);
        return Result.success("保存成功");
    }
 
    /**
     * 导出人员监督计划
     * @return
     */
    @ApiOperation(value = "导出人员监督计划")
    @GetMapping("/exportSuperVisePlan")
    public void exportSuperVisePlan(Integer id, HttpServletResponse response){
        personSupervisePlanService.exportSuperVisePlan(id, response);
    }
}