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; /** *

* 监管计划 前端控制器 *

* * @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> 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 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.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.lambdaQuery() .eq(PersonSupervisePlanDetails::getPlanId, id)); return Result.success(); } @ApiOperation(value = "查询 年度计划详情") @GetMapping("/yearPlanDetailList") public Result> 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); } }