|
@@ -1,7 +1,22 @@
|
|
|
package com.ims.eval.controller;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.ims.common.utils.StringUtils;
|
|
|
+import com.ims.eval.config.CustomException;
|
|
|
+import com.ims.eval.entity.*;
|
|
|
+import com.ims.eval.entity.dto.result.R;
|
|
|
+import com.ims.eval.service.*;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 部门业绩指标计划
|
|
@@ -14,6 +29,178 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("//evaluation-dept-plan")
|
|
|
public class DepartmentalPerformanceIndicatorPlanController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptBusinessPlanService evaluationDeptBusinessPlanService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptService evaluationDeptService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptIndicatorService evaluationDeptIndicatorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptIndicatorItemService evaluationDeptIndicatorItemService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptPlanContentService evaluationDeptPlanContentService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 部门考评业务列表信息(分页)
|
|
|
+ *
|
|
|
+ * @param pageNum 当前记录起始索引
|
|
|
+ * @param pageSize 每页显示记录数
|
|
|
+ * @param responsibilityCode 业务编码
|
|
|
+ * @param des 业务简述
|
|
|
+ * @param appraisalYear 月度
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ //@ImsPreAuth("eval:evaluationDeptBusinessPlan:view")
|
|
|
+ @GetMapping(value = "list")
|
|
|
+ public R list(
|
|
|
+ @RequestParam(value = "pageNum") Integer pageNum,
|
|
|
+ @RequestParam(value = "pageSize") Integer pageSize,
|
|
|
+ @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode,
|
|
|
+ @RequestParam(value = "des", required = false) String des,
|
|
|
+ @RequestParam(value = "appraisalYear", required = false) String appraisalYear) {
|
|
|
+ IPage<EvaluationDeptBusinessPlan> list = evaluationDeptBusinessPlanService.listPage(pageNum, pageSize, responsibilityCode, des, appraisalYear);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 部门考评业务信息
|
|
|
+ *
|
|
|
+ * @param responsibilityCode 业务编码
|
|
|
+ * @param des 业务简述
|
|
|
+ * @param appraisalYear 月度
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ //@ImsPreAuth("eval:evaluationDeptBusinessPlan:view")
|
|
|
+ @GetMapping(value = "listAll")
|
|
|
+ public R listAll(
|
|
|
+ @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode,
|
|
|
+ @RequestParam(value = "des", required = false) String des,
|
|
|
+ @RequestParam(value = "appraisalYear", required = false) String appraisalYear) {
|
|
|
+ List<EvaluationDeptBusinessPlan> list = evaluationDeptBusinessPlanService.listAll(responsibilityCode, des, appraisalYear);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增部门考评业务信息
|
|
|
+ *
|
|
|
+ * @param deptBusinessPlan 部门考评业务实体
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ //@ImsPreAuth("eval:evaluationDeptBusinessPlan:edit")
|
|
|
+ @PostMapping(value = "/save")
|
|
|
+ @ApiOperation(value = "新增", notes = "新增")
|
|
|
+ public R addAll(@RequestBody EvaluationDeptBusinessPlan deptBusinessPlan) {
|
|
|
+ try {
|
|
|
+ String businessPlanId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ deptBusinessPlan.setId(businessPlanId);
|
|
|
+ deptBusinessPlan.setResponsibilityCode("bmkp_" + deptBusinessPlan.getAppraisalYear() + RandomUtil.randomString(6));
|
|
|
+ deptBusinessPlan.setBusinessClass("年度考评");
|
|
|
+ deptBusinessPlan.setDocumentStatus("有效");
|
|
|
+ deptBusinessPlan.setStage("流程未启动");
|
|
|
+ QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(deptBusinessPlan.getAppraisalYear())) {
|
|
|
+ qw.lambda().eq(EvaluationDept::getAnnual, deptBusinessPlan.getAppraisalYear());
|
|
|
+ }
|
|
|
+ List<EvaluationDept> evaluationDeptList = evaluationDeptService.list(qw);
|
|
|
+ StringBuilder deptIds = new StringBuilder();
|
|
|
+ StringBuilder deptNames = new StringBuilder();
|
|
|
+ for (int i = 0; i < evaluationDeptList.size(); i++) {
|
|
|
+ EvaluationDept evaluationDept = evaluationDeptList.get(i);
|
|
|
+ List<EvaluationDeptIndicatorItem> evaluationDeptIndicatorItemList = evaluationDeptIndicatorItemService.selectEvaluationDeptIndicatorItemListByEvaluationDeptId(evaluationDept.getDeptId());
|
|
|
+ for (EvaluationDeptIndicatorItem evaluationDeptIndicatorItem : evaluationDeptIndicatorItemList) {
|
|
|
+ EvaluationDeptIndicator evaluationDeptIndicator = evaluationDeptIndicatorService.getById(evaluationDeptIndicatorItem.getEvaluationDeptIndicatorId());
|
|
|
+ EvaluationDeptPlanContent evaluationDeptPlanContent = new EvaluationDeptPlanContent();
|
|
|
+ evaluationDeptPlanContent.setBusinessPlanId(businessPlanId);
|
|
|
+ evaluationDeptPlanContent.setDeptId(evaluationDept.getDeptId());
|
|
|
+ evaluationDeptPlanContent.setDeptName(evaluationDept.getDeptName());
|
|
|
+ evaluationDeptPlanContent.setIndicatorId(evaluationDeptIndicator.getId());
|
|
|
+ evaluationDeptPlanContent.setIndicatorName(evaluationDeptIndicator.getIndicatorName());
|
|
|
+ evaluationDeptPlanContent.setIndicatorItemId(evaluationDeptIndicatorItem.getId());
|
|
|
+ evaluationDeptPlanContent.setIndicatorItemName(evaluationDeptIndicatorItem.getIndicatorItemName());
|
|
|
+ evaluationDeptPlanContent.setAuditStatus("审批未开始");
|
|
|
+ evaluationDeptPlanContentService.save(evaluationDeptPlanContent);
|
|
|
+ }
|
|
|
+ if (i == evaluationDeptList.size() - 1) {
|
|
|
+ deptIds.append(evaluationDept.getDeptId());
|
|
|
+ deptNames.append(evaluationDept.getDeptName());
|
|
|
+ } else {
|
|
|
+ deptIds.append(evaluationDept.getDeptId()).append(",");
|
|
|
+ deptNames.append(evaluationDept.getDeptName()).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ deptBusinessPlan.setDeptId(deptIds.toString());
|
|
|
+ deptBusinessPlan.setDeptName(deptNames.toString());
|
|
|
+ boolean b = evaluationDeptBusinessPlanService.save(deptBusinessPlan);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除部门考评业务信息
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ //@ImsPreAuth("eval:evaluationDeptBusinessPlan:remove")
|
|
|
+ @PostMapping(value = "/removeAll/{ids}")
|
|
|
+ @ApiOperation(value = "批量删除", notes = "批量删除")
|
|
|
+ public R deleteAll(@PathVariable("ids") String ids) {
|
|
|
+ String[] strings = ids.split(",");
|
|
|
+ boolean b = evaluationDeptBusinessPlanService.removeByIds(Arrays.asList(strings));
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情
|
|
|
+ *
|
|
|
+ * @param id 业务主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ //@ImsPreAuth("eval:evaluationDeptBusinessPlan:view")
|
|
|
+ @GetMapping(value = "details")
|
|
|
+ public R details(@RequestParam(value = "id", required = false) String id) {
|
|
|
+ QueryWrapper<EvaluationDeptPlanContent> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ qw.lambda().eq(EvaluationDeptPlanContent::getBusinessPlanId, id);
|
|
|
+ }
|
|
|
+ List<EvaluationDeptPlanContent> list = evaluationDeptPlanContentService.list(qw);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 详情里指标内容修改
|
|
|
+ *
|
|
|
+ * @param evaluationDeptPlanContent
|
|
|
+ * @return
|
|
|
+ */
|
|
|
|
|
|
+ //@ImsPreAuth("eval:evaluationDeptBusinessPlan:edit")
|
|
|
+ @PostMapping(value = "/update")
|
|
|
+ @ApiOperation(value = "修改", notes = "修改")
|
|
|
+ public R update(@RequestBody EvaluationDeptPlanContent evaluationDeptPlanContent) {
|
|
|
+ try {
|
|
|
+ boolean b = evaluationDeptPlanContentService.updateById(evaluationDeptPlanContent);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("修改失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e) {
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|