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);
|
}
|
}
|