zss
6 天以前 51ec98113c6d49d0f7eec4e3c030e55e337e97db
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
package com.yuanchu.mom.controller;
 
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.pojo.ManageControlPlanList;
import com.yuanchu.mom.service.ManageControlPlanListService;
import com.yuanchu.mom.utils.MyUtil;
import com.yuanchu.mom.vo.ManageControlPlanListVo;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
 
/**
 * <p>
 * 重大风险因素分析及控制计划清单 前端控制器
 * </p>
 *
 * @author 
 * @since 2024-11-15 02:58:30
 */
@Api(tags = "重大风险因素分析及控制计划清单")
@RestController
@RequestMapping("/manageControlPlanList")
public class ManageControlPlanListController {
 
 
    @Resource
    private ManageControlPlanListService manageControlPlanListService;
 
    @Autowired
    private GetLook getLook;
 
    @ValueClassify(value = "重大风险因素分析及控制计划清单")
    @ApiOperation(value = "分页查询")
    @GetMapping("/getPageList")
    public Result<IPage<ManageControlPlanListVo>> getPageList(Page page){
        IPage<ManageControlPlanListVo> ipage = manageControlPlanListService.getPageList(page);
        return Result.success(ipage);
    }
 
    @ValueClassify(value = "重大风险因素分析及控制计划清单")
    @ApiOperation(value = "批准")
    @GetMapping("/approvalOfControlPlanChecklist")
    public Result<?> approvalOfControlPlanChecklist(Integer approve, Integer status){
        manageControlPlanListService.update(Wrappers.<ManageControlPlanList>lambdaUpdate()
                .set(ManageControlPlanList::getApprove, approve)
                .set(ManageControlPlanList::getApproveStatus, status)
                .set(ManageControlPlanList::getApproveDate, LocalDateTime.now()));
        return Result.success();
    }
 
    @ValueClassify(value = "重大风险因素分析及控制计划清单")
    @ApiOperation(value = "审批")
    @GetMapping("/riskAnalysisApprovalOfControlPlanChecklist")
    public Result<?> riskAnalysisApprovalOfControlPlanChecklist(Integer approval, Integer status){
        manageControlPlanListService.update(Wrappers.<ManageControlPlanList>lambdaUpdate()
                .set(ManageControlPlanList::getApproval, approval)
                .set(ManageControlPlanList::getApprovalStatus, status)
                .set(ManageControlPlanList::getApprovalDate, LocalDateTime.now()));
        return Result.success();
    }
 
    @ValueClassify(value = "重大风险因素分析及控制计划清单")
    @ApiOperation(value = "导入")
    @PostMapping("/importControlPlanList")
    public void importControlPlanList(MultipartFile file) throws IOException {
        boolean excelFile = MyUtil.isExcelFile(file);
        if (!excelFile) {
            throw new ErrorException("请导入excel文件!");
        }
        EasyExcel.read(file.getInputStream(), ManageControlPlanList.class, new PageReadListener<ManageControlPlanList>(dataList -> {
            Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
            dataList.forEach(i -> {
                i.setEditor(userId);
                i.setEditorDate(LocalDateTime.now());
                i.setApproveStatus(0);
                i.setApprovalStatus(0);
            });
            manageControlPlanListService.saveOrUpdateBatch(dataList);
        })).sheet().doRead();
    }
 
    @ValueClassify(value = "重大风险因素分析及控制计划清单")
    @ApiOperation(value = "新增")
    @PostMapping("/analysisOfMajorRiskFactorsAdded")
    public void analysisOfMajorRiskFactorsAdded(@RequestBody ManageControlPlanList manageControlPlanList) throws IOException {
        Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
        manageControlPlanList.setEditor(userId);
        manageControlPlanList.setEditorDate(LocalDateTime.now());
        manageControlPlanListService.saveOrUpdate(manageControlPlanList);
    }
 
    @ValueClassify(value = "重大风险因素分析及控制计划清单")
    @ApiOperation(value = "删除")
    @GetMapping("/deleteSignificantRiskFactorAnalysis")
    public void deleteSignificantRiskFactorAnalysis(Integer id) throws IOException {
        manageControlPlanListService.removeById(id);
    }
 
    /**
     * 导出人员培训计划
     * @return
     */
    @ValueAuth
    @ApiOperation(value = "重大风险因素分析及控制计划清单")
    @GetMapping("/exportSignificantRiskFactors")
    public void exportSignificantRiskFactors(HttpServletResponse response){
        manageControlPlanListService.exportPersonTraining(response);
    }
}