部门人员接口哟划

This commit is contained in:
wulin 2020-10-20 15:48:42 +08:00
parent 62bacf2dda
commit 8b51e6edfb
13 changed files with 65 additions and 27 deletions

View File

@ -4,10 +4,7 @@ import java.util.Arrays;
import java.util.List;
import com.lz.modules.app.dto.DepartmentsDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -36,14 +33,23 @@ public class DepartmentsController {
*/
@PostMapping("/list")
// @RequiresPermissions("staff:structure:list")
@ApiOperation("获取全部有效部门树列表")
@ApiResponses({@ApiResponse(code = 200, message = "成功", response = DepartmentsDto.class)})
public List<DepartmentsDto> list() {
List<DepartmentsDto> departmentList = departmentsService.getDepartmentTree();
List<DepartmentsDto> departmentList = departmentsService.getDepartmentTree(0);
return departmentList;
}
@GetMapping("/deplist")
// @RequiresPermissions("staff:structure:list")
@ApiOperation("获取全部有效部门树列表")
@ApiResponses({@ApiResponse(code = 200, message = "成功", response = DepartmentsDto.class)})
public List<DepartmentsDto> deplist(@RequestParam @ApiParam(value = "请求类型0 请求部门不包含人员列表1同时返回人员列表") int type) {
List<DepartmentsDto> departmentList = departmentsService.getDepartmentTree(1);
return departmentList;
}
/**
* 信息

View File

@ -104,7 +104,7 @@ public class ReportResultController extends AbstractController{
public R departmentTreeByStaffId(){
Long userId = getUserId();
if(chartService.hrOrBoss(userId)){
List<DepartmentsDto> data = departmentsService.getDepartmentTree();
List<DepartmentsDto> data = departmentsService.getDepartmentTree(0);
return R.ok().put("data",data);
}
if(chartService.leader(getUserId())){

View File

@ -82,4 +82,6 @@ public interface StaffDao extends BaseMapper<StaffEntity> {
List<ReportProgressListDto> getPositionByStaffIds(@Param("req") ReportListReq req, @Param("staffIds") List<String> staffIds, @Param("page") IPage page);
List<StaffSimpleDto> selectStaffSimpleInfoByIds(@Param("ids") List<Long> ids);
List<StaffDto> getDepatAllStaffInfos(@Param("departmentId") String departmentId);
}

View File

@ -21,12 +21,11 @@ import java.util.List;
public class DepartmentsDto implements Serializable{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "部门id", name = "id")
private Integer id;
/**
* 飞书部门id
*/
@ApiModelProperty(value = "钉钉飞书部门id", name = "departmentId")
@ApiModelProperty(value = "部门id钉钉飞书部门id", name = "departmentId")
private String departmentId;
/**
* 飞书上级部门id
@ -53,5 +52,7 @@ public class DepartmentsDto implements Serializable{
@TableField(exist = false)
@ApiModelProperty(value = "部门id", name = "id")
private List<?> list;
@ApiModelProperty(value = "部门人员集合", name = "staffDtos")
private List<StaffDto> staffDtos;
}

View File

@ -27,7 +27,7 @@ public interface DepartmentsService extends IService<DepartmentsEntity> {
List<DepartmentsDto> getDepartmentTree();
List<DepartmentsDto> getDepartmentTree(int type);
List<DepartmentsDto> selectByParentDepartmentId(String deparentId);

View File

@ -84,5 +84,7 @@ public interface StaffService extends IService<StaffEntity> {
List<StaffEntity> selectAll();
List<StaffSimpleDto> selectStaffSimpleInfoByIds(List<Long> ids);
List<StaffDto> getDepatAllStaffInfos(String departmentId);
}

View File

@ -13,14 +13,17 @@ import com.lz.modules.app.dao.StaffDao;
import com.lz.modules.app.dto.DepartmentInfos;
import com.lz.modules.app.dto.DepartmentsDto;
import com.lz.modules.app.dto.StaffDepartmentDto;
import com.lz.modules.app.dto.StaffDto;
import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.DepartmentsService;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.job.model.responseBo.DepartmentInfosBo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -37,6 +40,9 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
@Resource
DepartmentsStaffRelateDao departmentsStaffRelateDao;
@Autowired
StaffService staffService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<DepartmentsEntity> page = this.page(
@ -62,9 +68,17 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
}
@Override
public List<DepartmentsDto> getDepartmentTree() {
public List<DepartmentsDto> getDepartmentTree(int type) {
List<DepartmentsDto> departmentsParentsList = departmentsDao.getDepartmentsByparentId("1");
getDepartmentTreeList(departmentsParentsList);
if(type == 1){
for (DepartmentsDto dto: departmentsParentsList
) {
List<StaffDto> staffDtos = staffService.getDepatAllStaffInfos(dto.getDepartmentId());
dto.setStaffDtos(staffDtos);
}
}
getDepartmentTreeList(departmentsParentsList, type);
return departmentsParentsList;
}
@ -98,12 +112,17 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
return staffDepartmentDto;
}
private List<DepartmentsDto> getDepartmentTreeList(List<DepartmentsDto> departmentList) {
private List<DepartmentsDto> getDepartmentTreeList(List<DepartmentsDto> departmentList, int type) {
List<DepartmentsDto> DepartmentsList = Lists.newArrayList();
for (DepartmentsDto departmentsDto : departmentList) {
List<DepartmentsDto> departmentsChirdList = departmentsDao.getDepartmentsByparentId(departmentsDto.getDepartmentId());
if (departmentsChirdList.size() > 0) {
departmentsDto.setList(getDepartmentTreeList(departmentsChirdList));
departmentsDto.setList(getDepartmentTreeList(departmentsChirdList, type));
}
if(type == 1){
List<StaffDto> staffDtos = staffService.getDepatAllStaffInfos(departmentsDto.getDepartmentId());
departmentsDto.setStaffDtos(staffDtos);
}
DepartmentsList.add(departmentsDto);
}
@ -232,7 +251,7 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
public List<DepartmentsDto> getDepartmentTreeByStaffId(String staffId,boolean containSelf) {
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateDao.selectByStaffId(Long.valueOf(staffId));
List<DepartmentsDto> departmentsParentsList = departmentsDao.getDepartmentsByparentId(departmentsStaffRelateEntity.getDepartmentId());
getDepartmentTreeList(departmentsParentsList);
getDepartmentTreeList(departmentsParentsList, 0);
if(containSelf){
List<DepartmentsDto> result = new ArrayList<>();
DepartmentsDto departmentsDto = new DepartmentsDto();

View File

@ -458,6 +458,11 @@ public class StaffServiceImpl extends ServiceImpl<StaffDao, StaffEntity> impleme
return staffDao.selectStaffSimpleInfoByIds(ids);
}
@Override
public List<StaffDto> getDepatAllStaffInfos(String departmentId){
return staffDao.getDepatAllStaffInfos(departmentId);
}
}

View File

@ -1,4 +1,4 @@
package com.lz.modules.flow.service.impl;
package com.lz.modules.flow.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.modules.flow.entity.ResultCalculate;

View File

@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lz.modules.flow.dao.ResultCalculateMapper;
import com.lz.modules.flow.entity.ResultCalculate;
import com.lz.modules.flow.model.ResultCalculateDto;
import com.lz.modules.flow.service.impl.ResultCalculateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,14 +1,10 @@
package com.lz.modules.performance.controller;
import com.alibaba.fastjson.JSONObject;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
import com.lz.common.utils.StringUtil;
import com.lz.modules.flow.entity.FlowChart;
import com.lz.modules.flow.entity.ResultCalculate;
import com.lz.modules.flow.model.ResultCalculateDto;
import com.lz.modules.flow.service.impl.ResultCalculateService;
import com.lz.modules.flow.service.ResultCalculateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
@ -19,9 +15,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/resultCalculate")

View File

@ -25,7 +25,7 @@
</select>
<select id="getDepartmentsByparentId" resultType="com.lz.modules.app.dto.DepartmentsDto">
select department_id,department_parent_id,member_count,department_name from lz_departments where department_parent_id=#{parentId}
select id, department_id,department_parent_id,member_count,department_name from lz_departments where department_parent_id=#{parentId}
</select>
<update id="updateDepartment">

View File

@ -469,4 +469,14 @@
</foreach>
) and occupation.staff_status=0
</select>
<select id="getDepatAllStaffInfos" resultType="com.lz.modules.app.dto.StaffDto">
select jj.staff_id, jj.name, jj.department_leader, occ.position as position,
case occ.staff_status when 0 then '在职' else '离职' end staff_status
from (select staff.id as staff_id, staff.name as name, relate.is_leader as department_leader
from lz_departments_staff_relate relate join lz_staff staff on staff.id = relate.staff_id
where relate.department_id = #{departmentId}) jj
join lz_staff_occupation occ on jj.staff_id=occ.staff_id where occ.staff_status=0
</select>
</mapper>