¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.manage.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.alibaba.excel.read.listener.PageReadListener; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.manage.pojo.ManageControlPlanList; |
| | | import com.ruoyi.manage.service.ManageControlPlanListService; |
| | | import com.ruoyi.manage.vo.ManageControlPlanListVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | 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; |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "å页æ¥è¯¢") |
| | | @GetMapping("/getPageList") |
| | | public Result<IPage<ManageControlPlanListVo>> getPageList(Page page) { |
| | | return Result.success(manageControlPlanListService.getPageList(page)); |
| | | } |
| | | |
| | | @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(); |
| | | } |
| | | |
| | | @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(); |
| | | } |
| | | |
| | | @PostMapping("/importControlPlanList") |
| | | public void importControlPlanList(MultipartFile file) throws IOException { |
| | | boolean excelFile = isExcelFile(file); |
| | | if (!excelFile) { |
| | | throw new ErrorException("请导å
¥excelæä»¶ï¼"); |
| | | } |
| | | EasyExcel.read(file.getInputStream(), ManageControlPlanList.class, new PageReadListener<ManageControlPlanList>(dataList -> { |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | dataList.forEach(i -> { |
| | | i.setEditor(userId); |
| | | i.setEditorDate(LocalDateTime.now()); |
| | | i.setApproveStatus(0); |
| | | i.setApprovalStatus(0); |
| | | }); |
| | | manageControlPlanListService.saveOrUpdateBatch(dataList); |
| | | })).sheet().doRead(); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°å¢") |
| | | @PostMapping("/analysisOfMajorRiskFactorsAdded") |
| | | public void analysisOfMajorRiskFactorsAdded(@RequestBody ManageControlPlanList manageControlPlanList) throws IOException { |
| | | Integer userId = SecurityUtils.getUserId().intValue(); |
| | | manageControlPlanList.setEditor(userId); |
| | | manageControlPlanList.setEditorDate(LocalDateTime.now()); |
| | | manageControlPlanListService.saveOrUpdate(manageControlPlanList); |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤") |
| | | @GetMapping("/deleteSignificantRiskFactorAnalysis") |
| | | public void deleteSignificantRiskFactorAnalysis(Integer id) throws IOException { |
| | | manageControlPlanListService.removeById(id); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @return |
| | | */ |
| | | |
| | | @ApiOperation(value = "é大é£é©å ç´ åæåæ§å¶è®¡åæ¸
å") |
| | | @GetMapping("/exportSignificantRiskFactors") |
| | | public void exportSignificantRiskFactors(HttpServletResponse response){ |
| | | manageControlPlanListService.exportPersonTraining(response); |
| | | } |
| | | |
| | | public static boolean isExcelFile(MultipartFile file) { |
| | | if (file.isEmpty()) { |
| | | return false; |
| | | } |
| | | String originalFilename = file.getOriginalFilename(); |
| | | if (originalFilename == null) { |
| | | return false; |
| | | } |
| | | String[] parts = originalFilename.split("\\."); |
| | | if (parts.length == 0) { |
| | | return false; |
| | | } |
| | | String fileExtension = parts[parts.length - 1].toLowerCase(); |
| | | return fileExtension.equals("xls") || fileExtension.equals("xlsx"); |
| | | } |
| | | } |