|
@@ -1,19 +1,29 @@
|
|
|
package com.ims.eval.controller;
|
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
import com.ims.eval.config.CustomException;
|
|
|
import com.ims.eval.entity.EvaluationDept;
|
|
|
+import com.ims.eval.entity.dto.request.PostDTO;
|
|
|
+import com.ims.eval.entity.dto.request.PostUserDTO;
|
|
|
import com.ims.eval.entity.dto.result.R;
|
|
|
import com.ims.eval.service.IEvaluationDeptService;
|
|
|
+import com.ims.eval.service.custom.PostService;
|
|
|
+import com.ims.eval.service.custom.PostUserService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 考评部门配置
|
|
@@ -30,6 +40,15 @@ public class DepartmentAllocationController {
|
|
|
@Autowired
|
|
|
private IEvaluationDeptService evaluationDeptService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PostService postService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PostUserService postUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HttpServletRequest request;
|
|
|
+
|
|
|
/**
|
|
|
* 考评部门配置列表信息(分页)
|
|
|
*
|
|
@@ -64,6 +83,8 @@ public class DepartmentAllocationController {
|
|
|
*/
|
|
|
@GetMapping(value = "/listAll")
|
|
|
public R listAll() {
|
|
|
+ QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(EvaluationDept::getJxjgkhsbType, "1");
|
|
|
List<EvaluationDept> list = evaluationDeptService.list();
|
|
|
return R.ok().data(list);
|
|
|
}
|
|
@@ -77,6 +98,14 @@ public class DepartmentAllocationController {
|
|
|
@PostMapping(value = "/save")
|
|
|
public R addAll(@RequestBody EvaluationDept evaluationDept) {
|
|
|
try {
|
|
|
+ QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(evaluationDept.getDeptId())) {
|
|
|
+ qw.lambda().eq(EvaluationDept::getDeptId, evaluationDept.getDeptId());
|
|
|
+ }
|
|
|
+ EvaluationDept obj = evaluationDeptService.getOne(qw);
|
|
|
+ if (obj != null) {
|
|
|
+ return R.customError("部门重复,请重新添加!");
|
|
|
+ }
|
|
|
boolean b = evaluationDeptService.saveOrUpdate(evaluationDept);
|
|
|
if (b) {
|
|
|
return R.ok().data(b);
|
|
@@ -89,6 +118,39 @@ public class DepartmentAllocationController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取部门领导
|
|
|
+ *
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/getDepartmentLeader/{id}")
|
|
|
+ public R getDepartmentLeader(@PathVariable String id) {
|
|
|
+ List<PostUserDTO> list = new ArrayList<>();
|
|
|
+ Object postList = postService.getPostList(1, 500, "23031005", request);
|
|
|
+ if (null != postList) {
|
|
|
+ JSONObject postJsonArr = (JSONObject) postList;
|
|
|
+ JSONObject postDataJsonArr = (JSONObject) postJsonArr.get("data");
|
|
|
+ JSONArray postArray = JSONUtil.parseArray(postDataJsonArr.get("records"));
|
|
|
+ List<PostDTO> postArrList = JSONUtil.toList(postArray, PostDTO.class);
|
|
|
+ List<PostDTO> postDeptList = postArrList.stream().filter(item -> item.getDeptId().equals(id)).collect(Collectors.toList());
|
|
|
+ for (PostDTO post : postDeptList) {
|
|
|
+ if (post.getName().contains("主任")) {
|
|
|
+ Object postPersonnelList = postUserService.getPostUserList(1, 500, post.getId(), request);
|
|
|
+ if (null != postPersonnelList) {
|
|
|
+ JSONObject postPersonnelJsonArr = (JSONObject) postPersonnelList;
|
|
|
+ JSONObject postPersonnelDataJsonArr = (JSONObject) postPersonnelJsonArr.get("data");
|
|
|
+ JSONArray postPersonnelArray = JSONUtil.parseArray(postPersonnelDataJsonArr.get("records"));
|
|
|
+ List<PostUserDTO> userArrList = JSONUtil.toList(postPersonnelArray, PostUserDTO.class);
|
|
|
+ if (userArrList.size() > 0) {
|
|
|
+ list.addAll(userArrList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 批量删除考评部门配置信息
|
|
|
*
|
|
|
* @param ids 主键s
|