|
@@ -1,23 +1,37 @@
|
|
|
package com.ims.eval.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+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.EvaluationDeptIndicator;
|
|
|
+import com.ims.eval.entity.EvaluationDeptIndicatorItem;
|
|
|
+import com.ims.eval.entity.OrganizationEvaluationInfo;
|
|
|
import com.ims.eval.entity.dto.result.R;
|
|
|
import com.ims.eval.entity.EvaluationDept;
|
|
|
+import com.ims.eval.service.IEvaluationDeptIndicatorItemService;
|
|
|
+import com.ims.eval.service.IEvaluationDeptIndicatorService;
|
|
|
import com.ims.eval.service.IEvaluationDeptService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static java.util.stream.Collectors.collectingAndThen;
|
|
|
+import static java.util.stream.Collectors.toCollection;
|
|
|
|
|
|
|
|
|
- * <p>
|
|
|
- * 考评部门 前端控制器
|
|
|
- * </p>
|
|
|
+ * 考评部门配置
|
|
|
*
|
|
|
- * @author wang
|
|
|
- * @since 2023-03-06
|
|
|
+ * @author hlf
|
|
|
+ * @date 2023/4/25 9:34
|
|
|
+ * 文件说明:
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("//evaluation-dept")
|
|
@@ -26,39 +40,215 @@ public class EvaluationDeptController {
|
|
|
@Autowired
|
|
|
private IEvaluationDeptService evaluationDeptService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptIndicatorService evaluationDeptIndicatorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEvaluationDeptIndicatorItemService evaluationDeptIndicatorItemService;
|
|
|
+
|
|
|
+
|
|
|
+ * 考评部门配置列表信息(分页)
|
|
|
+ *
|
|
|
+ * @param pageNum 当前记录起始索引
|
|
|
+ * @param pageSize 每页显示记录数
|
|
|
+ * @param deptName 部门名称
|
|
|
+ * @param annual 年度
|
|
|
+ * @param monthly 月度
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+
|
|
|
+ @GetMapping(value = "list")
|
|
|
+ public R list(
|
|
|
+ @RequestParam(value = "pageNum") Integer pageNum,
|
|
|
+ @RequestParam(value = "pageSize") Integer pageSize,
|
|
|
+ @RequestParam(value = "deptName", required = false) String deptName,
|
|
|
+ @RequestParam(value = "annual", required = false) String annual,
|
|
|
+ @RequestParam(value = "monthly", required = false) String monthly) {
|
|
|
+ IPage<EvaluationDept> list = evaluationDeptService.listPage(pageNum, pageSize, deptName, annual, monthly);
|
|
|
+ List<EvaluationDept> evaluationDeptList = list.getRecords();
|
|
|
+ for (EvaluationDept evaluationDept : evaluationDeptList) {
|
|
|
+ List<EvaluationDeptIndicator> evaluationDeptIndicatorList = evaluationDeptIndicatorService.selectEvaluationDeptIndicatorListByEvaluationDeptId(evaluationDept.getId());
|
|
|
+ for (EvaluationDeptIndicator evaluationDeptIndicator : evaluationDeptIndicatorList) {
|
|
|
+ List<EvaluationDeptIndicatorItem> evaluationDeptIndicatorItemList = evaluationDeptIndicatorItemService.selectEvaluationDeptIndicatorItemListByEvaluationDeptIndicatorId(evaluationDeptIndicator.getId());
|
|
|
+ evaluationDeptIndicator.setEvaluationDeptIndicatorItemList(evaluationDeptIndicatorItemList);
|
|
|
+ }
|
|
|
+ evaluationDept.setEvaluationDeptIndicatorList(evaluationDeptIndicatorList);
|
|
|
+ }
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ * 考评部门配置信息
|
|
|
+ *
|
|
|
+ * @param deptId 部门主键
|
|
|
+ * @param annual 年度
|
|
|
+ * @param monthly 月度
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
|
|
|
@GetMapping(value = "listAll")
|
|
|
public R listAll(
|
|
|
- @RequestParam(value = "id", required = false) String id,
|
|
|
- @RequestParam(value = "enable", required = false) boolean enable) {
|
|
|
- List<EvaluationDept> list = evaluationDeptService.listAll(id, enable);
|
|
|
+ @RequestParam(value = "deptId", required = false) String deptId,
|
|
|
+ @RequestParam(value = "annual", required = false) String annual,
|
|
|
+ @RequestParam(value = "monthly", required = false) String monthly) {
|
|
|
+ List<EvaluationDept> list = evaluationDeptService.listAll(deptId, annual, monthly);
|
|
|
+ for (EvaluationDept evaluationDept : list) {
|
|
|
+ List<EvaluationDeptIndicator> evaluationDeptIndicatorList = evaluationDeptIndicatorService.selectEvaluationDeptIndicatorListByEvaluationDeptId(evaluationDept.getId());
|
|
|
+ for (EvaluationDeptIndicator evaluationDeptIndicator : evaluationDeptIndicatorList) {
|
|
|
+ List<EvaluationDeptIndicatorItem> evaluationDeptIndicatorItemList = evaluationDeptIndicatorItemService.selectEvaluationDeptIndicatorItemListByEvaluationDeptIndicatorId(evaluationDeptIndicator.getId());
|
|
|
+ evaluationDeptIndicator.setEvaluationDeptIndicatorItemList(evaluationDeptIndicatorItemList);
|
|
|
+ }
|
|
|
+ evaluationDept.setEvaluationDeptIndicatorList(evaluationDeptIndicatorList);
|
|
|
+ }
|
|
|
return R.ok().data(list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
- * 添加
|
|
|
+ * 新增考评部门配置信息
|
|
|
*
|
|
|
- * @param dept
|
|
|
- * @return
|
|
|
+ * @param dept 考评部门实体
|
|
|
+ * @return 结果
|
|
|
*/
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
@PostMapping(value = "/save")
|
|
|
@ApiOperation(value = "新增(修改)", notes = "新增(修改)")
|
|
|
- public R addAll(@RequestBody List<EvaluationDept> dept) {
|
|
|
-
|
|
|
+ public R addAll(@RequestBody EvaluationDept dept) {
|
|
|
try {
|
|
|
- boolean b = evaluationDeptService.saveBatch(dept);
|
|
|
+ boolean b;
|
|
|
+ if (StringUtils.isEmpty(dept.getId())) {
|
|
|
+ String edId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ dept.setId(edId);
|
|
|
+
|
|
|
+ dept.setEnable(true);
|
|
|
+
|
|
|
+ b = evaluationDeptService.save(dept);
|
|
|
+ for (EvaluationDeptIndicator evaluationDeptIndicator : dept.getEvaluationDeptIndicatorList()) {
|
|
|
+ if (evaluationDeptIndicator.getEvaluationDeptIndicatorItemList().size() > 0) {
|
|
|
+ String ediId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ evaluationDeptIndicator.setId(ediId);
|
|
|
+ evaluationDeptIndicator.setEvaluationDeptId(edId);
|
|
|
+
|
|
|
+ b = evaluationDeptIndicatorService.save(evaluationDeptIndicator);
|
|
|
+ for (EvaluationDeptIndicatorItem evaluationDeptIndicatorItem : evaluationDeptIndicator.getEvaluationDeptIndicatorItemList()) {
|
|
|
+ String ediiId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ evaluationDeptIndicatorItem.setId(ediiId);
|
|
|
+ evaluationDeptIndicatorItem.setEvaluationDeptId(edId);
|
|
|
+ evaluationDeptIndicatorItem.setEvaluationDeptIndicatorId(ediId);
|
|
|
+ evaluationDeptIndicatorItem.setIndicatorName(evaluationDeptIndicator.getIndicatorName());
|
|
|
+ evaluationDeptIndicatorItem.setIndicatorCode(evaluationDeptIndicator.getIndicatorCode());
|
|
|
+
|
|
|
+ b = evaluationDeptIndicatorItemService.save(evaluationDeptIndicatorItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ dept.setEnable(true);
|
|
|
+ b = evaluationDeptService.updateById(dept);
|
|
|
+ Iterator<EvaluationDeptIndicator> iterator = dept.getEvaluationDeptIndicatorList().iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ EvaluationDeptIndicator evaluationDeptIndicator = iterator.next();
|
|
|
+
|
|
|
+ if (evaluationDeptIndicator.getEvaluationDeptIndicatorItemList().size() > 0) {
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(evaluationDeptIndicator.getId())) {
|
|
|
+ String ediId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ evaluationDeptIndicator.setId(ediId);
|
|
|
+ evaluationDeptIndicator.setEvaluationDeptId(dept.getId());
|
|
|
+
|
|
|
+ b = evaluationDeptIndicatorService.save(evaluationDeptIndicator);
|
|
|
+ for (EvaluationDeptIndicatorItem evaluationDeptIndicatorItem : evaluationDeptIndicator.getEvaluationDeptIndicatorItemList()) {
|
|
|
+ String ediiId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ evaluationDeptIndicatorItem.setId(ediiId);
|
|
|
+ evaluationDeptIndicatorItem.setEvaluationDeptId(dept.getId());
|
|
|
+ evaluationDeptIndicatorItem.setEvaluationDeptIndicatorId(ediId);
|
|
|
+ evaluationDeptIndicatorItem.setIndicatorName(evaluationDeptIndicator.getIndicatorName());
|
|
|
+ evaluationDeptIndicatorItem.setIndicatorCode(evaluationDeptIndicator.getIndicatorCode());
|
|
|
+
|
|
|
+ b = evaluationDeptIndicatorItemService.save(evaluationDeptIndicatorItem);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ b = evaluationDeptIndicatorService.updateById(evaluationDeptIndicator);
|
|
|
+ for (EvaluationDeptIndicatorItem evaluationDeptIndicatorItem : evaluationDeptIndicator.getEvaluationDeptIndicatorItemList()) {
|
|
|
+ if (StringUtils.isEmpty(evaluationDeptIndicatorItem.getId())) {
|
|
|
+ String ediiId = Convert.toStr(IdUtil.getSnowflake(1, 1).nextId());
|
|
|
+ evaluationDeptIndicatorItem.setId(ediiId);
|
|
|
+ evaluationDeptIndicatorItem.setEvaluationDeptId(dept.getId());
|
|
|
+ evaluationDeptIndicatorItem.setEvaluationDeptIndicatorId(evaluationDeptIndicator.getId());
|
|
|
+ evaluationDeptIndicatorItem.setIndicatorName(evaluationDeptIndicator.getIndicatorName());
|
|
|
+ evaluationDeptIndicatorItem.setIndicatorCode(evaluationDeptIndicator.getIndicatorCode());
|
|
|
+
|
|
|
+ b = evaluationDeptIndicatorItemService.save(evaluationDeptIndicatorItem);
|
|
|
+ } else {
|
|
|
+ b = evaluationDeptIndicatorItemService.updateById(evaluationDeptIndicatorItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ boolean flag = evaluationDeptIndicatorService.removeById(evaluationDeptIndicator.getId());
|
|
|
+ if (flag) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (b) {
|
|
|
return R.ok().data(b);
|
|
|
} else {
|
|
|
return R.error().data("保存失败!");
|
|
|
}
|
|
|
- } catch (CustomException e){
|
|
|
+ } catch (CustomException e) {
|
|
|
return R.customError(e.getMessage()).data("失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 批量删除考评部门配置信息
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ @PostMapping(value = "/removeAll/{ids}")
|
|
|
+ @ApiOperation(value = "批量删除", notes = "批量删除")
|
|
|
+ public R deleteAll(@PathVariable("ids") String ids) {
|
|
|
+ String[] strings = ids.split(",");
|
|
|
+ boolean b;
|
|
|
+ b = evaluationDeptService.removeByIds(Arrays.asList(strings));
|
|
|
+ for (String id : strings) {
|
|
|
+ QueryWrapper<EvaluationDeptIndicator> qw1 = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ qw1.lambda().eq(EvaluationDeptIndicator::getEvaluationDeptId, id);
|
|
|
+ }
|
|
|
+ b = evaluationDeptIndicatorService.remove(qw1);
|
|
|
+ QueryWrapper<EvaluationDeptIndicatorItem> qw2 = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ qw2.lambda().eq(EvaluationDeptIndicatorItem::getEvaluationDeptId, id);
|
|
|
+ }
|
|
|
+ b = evaluationDeptIndicatorItemService.remove(qw2);
|
|
|
+ }
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 删除考评部门指标项信息
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ @PostMapping(value = "/remove/{id}")
|
|
|
+ @ApiOperation(value = "删除", notes = "删除")
|
|
|
+ public R delete(@PathVariable("id") String id) {
|
|
|
+ boolean b = evaluationDeptIndicatorItemService.removeById(id);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|