123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- 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.DeptDTO;
- import com.ims.eval.entity.dto.request.UserDTO;
- import com.ims.eval.entity.dto.result.R;
- import com.ims.eval.service.IEvaluationDeptService;
- import com.ims.eval.service.IUserService;
- 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.*;
- /**
- * 考评部门配置
- *
- * @author hlf
- * @date 2023/7/14 16:54
- * 文件说明:
- */
- @Slf4j
- @RestController
- @RequestMapping("//evaluation-dept-allocation")
- public class DepartmentAllocationController {
- @Autowired
- private IEvaluationDeptService evaluationDeptService;
- @Autowired
- private HttpServletRequest request;
- @Autowired
- private IUserService userService;
- /**
- * 考评部门配置列表信息(分页)
- *
- * @param pageNum 当前记录起始索引
- * @param pageSize 每页显示记录数
- * @param deptName 部门名称
- * @param chargePersonName 部门领导名称
- * @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 = "chargePersonName", required = false) String chargePersonName) {
- QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(deptName)) {
- qw.lambda().like(EvaluationDept::getDeptName, deptName);
- }
- if (StringUtils.isNotEmpty(chargePersonName)) {
- qw.lambda().like(EvaluationDept::getChargePersonName, chargePersonName);
- }
- qw.lambda().orderByAsc(EvaluationDept::getSerialNumber);
- Page<EvaluationDept> page = new Page<>(pageNum, pageSize);
- IPage<EvaluationDept> list = evaluationDeptService.page(page, qw);
- return R.ok().data(list);
- }
- /**
- * 考评部门配置信息
- *
- * @return 结果
- */
- @GetMapping(value = "/listAll")
- public R listAll() {
- QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
- qw.lambda().eq(EvaluationDept::getJxjgkhsbType, "1");
- qw.lambda().orderByAsc(EvaluationDept::getSerialNumber);
- List<EvaluationDept> list = evaluationDeptService.list(qw);
- return R.ok().data(list);
- }
- /**
- * 新增/修改考评部门配置信息
- *
- * @param evaluationDept 考评部门配置实体
- * @return 结果
- */
- @PostMapping(value = "/save")
- public R addAll(@RequestBody EvaluationDept evaluationDept) {
- try {
- if (StringUtils.isEmpty(evaluationDept.getId())) {
- QueryWrapper<EvaluationDept> qw = new QueryWrapper<>();
- if (StringUtils.isNotEmpty(evaluationDept.getParentId())) {
- qw.lambda().eq(EvaluationDept::getParentId, evaluationDept.getParentId());
- }
- if (StringUtils.isNotEmpty(evaluationDept.getDeptId())) {
- qw.lambda().eq(EvaluationDept::getDeptId, evaluationDept.getDeptId());
- }
- EvaluationDept obj = evaluationDeptService.getOne(qw);
- if (obj != null) {
- return R.error("部门重复,请重新添加!");
- }
- }
- boolean b = evaluationDeptService.saveOrUpdate(evaluationDept);
- if (b) {
- return R.ok().data(b);
- } else {
- return R.error("保存失败!");
- }
- } catch (CustomException e) {
- return R.customError(e.getMessage()).data("失败!");
- }
- }
- /**
- * 获取部门领导
- *
- * @return 结果
- */
- @GetMapping(value = "/getDepartmentLeader/{id}")
- public R getDepartmentLeader(@PathVariable String id) {
- JSONObject jsonArr = userService.pageList(1, 500, id, "", "", "", "", "", request);
- JSONObject jsonArr1 = (JSONObject) jsonArr.get("data");
- JSONArray array = JSONUtil.parseArray(jsonArr1.get("records"));
- List<UserDTO> list = JSONUtil.toList(array, UserDTO.class);
- return R.ok().data(list);
- }
- /**
- * 批量删除考评部门配置信息
- *
- * @param ids 主键s
- * @return 结果
- */
- @PostMapping(value = "/removeAll/{ids}")
- public R deleteAll(@PathVariable("ids") String ids) {
- try {
- String[] strings = ids.split(",");
- boolean b = evaluationDeptService.removeByIds(Arrays.asList(strings));
- if (b) {
- return R.ok().data(b);
- } else {
- return R.error("删除失败!");
- }
- } catch (CustomException e) {
- return R.customError(e.getMessage()).data("失败!");
- }
- }
- /**
- * 人员假数据
- *
- * @return 结果
- */
- @GetMapping(value = "/getUser")
- public R getUser() {
- List<UserDTO> userList = new ArrayList<>();
- Map<String, String> map = new HashMap<>();
- map.put("bffe73e031d44e00a8c8506e317aa41f", "孙志廷");
- map.put("48063c851236d1347900e6e9667ac0d6", "云天宝");
- map.put("df2c3798f5b14994aac7eb3410cf1c69", "孙严冬");
- map.put("06a45127a25f49e798d13233f881b382", "李宝岩");
- map.put("53c5bb07e6834d928aea5f9d2f57aa7f", "任晓霞");
- map.put("972f3f68fac44c9b95c2e479bb3de815", "李金柱");
- map.put("b4ee5ccdec1941f889176e3d913b1994", "刘全");
- map.put("5014b41d06dd4b428348cbfcdf36c160", "宫广正");
- map.put("8cfbb27966264920b24635f95ca6b0a7", "孙纳新");
- map.put("f9305976eaab4edca55538238914b07c", "刘景春");
- map.put("34c57c2ad8184e9795b2a77501e97671", "车晔");
- map.put("5b7c61a5556742baa9018d17ee5f42c2", "杨建国");
- map.put("9ea19aa48cc1483b9efcf3210e50de4f", "陈宏");
- map.put("5eca483c13c94639bdfae0754c314164", "王颖聪");
- map.put("aa300762de524c27b9ca3439b76c9e26", "朱传兴");
- for (Map.Entry<String, String> entry : map.entrySet()) {
- UserDTO user = new UserDTO();
- user.setId(entry.getKey());
- user.setName(entry.getValue());
- userList.add(user);
- }
- return R.ok().data(userList);
- }
- /**
- * 部门假数据
- *
- * @return 结果
- */
- @GetMapping(value = "/getDept")
- public R getDept() {
- List<DeptDTO> deptList = new ArrayList<>();
- Map<String, String> map = new HashMap<>();
- map.put("23031004", "综合管理部(党委办公室)");
- map.put("23031015", "纪委办公室(党委巡察办)");
- map.put("23031006", "计划发展部");
- map.put("23031007", "市场营销部");
- map.put("23031008", "资本运营部(董事会办公室)");
- map.put("23031010", "财务部");
- map.put("23031005", "企业管理与法律事务部");
- map.put("23031023", "安全环保监察部");
- map.put("23031014", "生产调运部(调度中心)");
- map.put("23032496", "科技信息部");
- map.put("23031016", "审计部");
- map.put("23031018", "工会工作部");
- map.put("23031019", "采购与物资管理部");
- map.put("23031020", "国际业务部");
- map.put("23031022", "工程建设部");
- for (Map.Entry<String, String> entry : map.entrySet()) {
- DeptDTO dept = new DeptDTO();
- dept.setId(entry.getKey());
- dept.setName(entry.getValue());
- deptList.add(dept);
- }
- return R.ok().data(deptList);
- }
- /**
- * 子部门假数据
- *
- * @return 结果
- */
- @GetMapping(value = "/getSubdepartment/{id}")
- public R getSubdepartment(@PathVariable String id) {
- List<DeptDTO> deptList = new ArrayList<>();
- Map<String, String> map = new HashMap<>();
- if ("23031004".equals(id)) {
- map.put("11111111", "子部门1");
- map.put("22222222", "子部门2");
- map.put("33333333", "子部门3");
- map.put("44444444", "子部门4");
- }
- if ("23031015".equals(id)) {
- map.put("55555555", "子部门1");
- map.put("66666666", "子部门2");
- map.put("77777777", "子部门3");
- map.put("88888888", "子部门4");
- }
- for (Map.Entry<String, String> entry : map.entrySet()) {
- DeptDTO dept = new DeptDTO();
- dept.setId(entry.getKey());
- dept.setName(entry.getValue());
- deptList.add(dept);
- }
- return R.ok().data(deptList);
- }
- }
|