package com.ims.eval.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ims.eval.config.CustomException; import com.ims.eval.entity.DeptResponsibility; import com.ims.eval.entity.Indicator; import com.ims.eval.entity.dto.response.DeptResponsibilityResDTO; import com.ims.eval.entity.dto.result.R; import com.ims.eval.service.IDeptResponsibilityService; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.List; import java.util.Map; /** *

* 部门目标责任表 前端控制器 *

* * @author wang * @since 2023-02-27 */ @RestController @RequestMapping("//dept-responsibility") public class DeptResponsibilityController { @Autowired private IDeptResponsibilityService deptResponsibilityService; @Autowired private HttpServletRequest request; /** * 分页查询 * * @param pageNum 当前页数 * @param pageSize 当前页大小 * @param id 主键 * @param responsibilityCode 业务编码 * @param cycleUnit 周期单位 * @param checkCycle 周期 * @param beginDate 考核开始时间 * @param endDate 考核截止时间 * @param stage 审批状态 * @param createBy 创建者 * @param year 年 * @param month 月 * @param des 描述 * @return */ //@ImsPreAuth("eval:deptResponsibility:view") @GetMapping(value = "list") public R list(@RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize, @RequestParam(value = "id", required = false) String id, @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode, @RequestParam(value = "cycleUnit", required = false) String cycleUnit, @RequestParam(value = "checkCycle", required = false) List checkCycle, @RequestParam(value = "beginDate", required = false) String beginDate, @RequestParam(value = "endDate", required = false) String endDate, @RequestParam(value = "stage", required = false) String stage, @RequestParam(value = "createBy", required = false) String createBy, @RequestParam(value = "year", required = false) String year, @RequestParam(value = "month", required = false) String month, @RequestParam(value = "des", required = false) String des) { IPage list = deptResponsibilityService.list(pageNum, pageSize, id, responsibilityCode, cycleUnit, checkCycle, beginDate, endDate, stage, createBy, year, month, des); return R.ok().data(list); } /** * 添加 * * @param deptResponsibility * @return */ //@ImsPreAuth("eval:deptResponsibility:edit") @PostMapping(value = "/save") @ApiOperation(value = "新增(修改)", notes = "新增(修改)") public R add(@RequestBody DeptResponsibility deptResponsibility) { try { boolean b = deptResponsibilityService.saveOrUpdate(deptResponsibility); if (b) { return R.ok().data(b); } else { return R.error().data("保存失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * 生成目标责任书 * * @param responsibilityIds 目标责任书ids * @return */ //@ImsPreAuth("eval:deptResponsibility:edit") @PostMapping(value = "/generate") @ApiOperation(value = "生成部门责任书", notes = "生成部门责任书") public R generateResponsibility(@RequestParam(value = "responsibilityIds", required = true) String responsibilityIds) { try { List orgEvalRuleIdList = Arrays.asList(responsibilityIds.split(",")); boolean b = false; for (String id : orgEvalRuleIdList) { b = deptResponsibilityService.generateResponsibility(id); if (!b) { return R.error().data("保存失败!"); } } return R.ok().data(b); } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } /** * * @param id 目标责任书id * @return */ //@ImsPreAuth("eval:responsibilityIndicatorInfo:view") @GetMapping(value = "getByidAndInfo") public R planValueList( @RequestParam(value = "id", required = false) String id, @RequestParam(value = "dept", required = false) String dept) { DeptResponsibilityResDTO resDTO = deptResponsibilityService.getByidAndInfo(id, dept); return R.ok().data(resDTO); } /** * 批量删除 * * @param ids * @return */ //@ImsPreAuth("eval:deptResponsibility:remove") @PostMapping(value = "/remove/{ids}") @ApiOperation(value = "删除", notes = "删除") public R deleteAll(@PathVariable("ids") String ids) { try { String[] strings = ids.split(","); boolean b = deptResponsibilityService.removeByIds(Arrays.asList(strings)); if (b) { return R.ok().data(b); } else { return R.error().data("删除失败!"); } } catch (CustomException e) { return R.customError(e.getMessage()).data("失败!"); } } @GetMapping(value = "targetValueeport") public R targetValueeport( @RequestParam(value = "id", required = false) String id, @RequestParam(value = "dept", required = false) String dept) { List list = deptResponsibilityService.targetValueeport(id, dept,request); return R.ok().data(list); } }