提交修改

This commit is contained in:
quyixiao 2020-08-12 14:54:06 +08:00
parent 2bd3bb4262
commit c0adbaad1b
13 changed files with 419 additions and 25 deletions

View File

@ -1,13 +1,20 @@
package com.lz.modules.app.controller;
import com.lz.modules.app.dao.DepartmentsDao;
import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.service.DepartmentsService;
import com.lz.modules.app.service.DepartmentsStaffRelateService;
import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ResultRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.swing.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@RestController
public class TestController {
@ -15,6 +22,13 @@ public class TestController {
@Autowired
private ResultRecordService resultRecordService;
@Autowired
private DepartmentsService departmentsService;
@Autowired
private DepartmentsStaffRelateService departmentsStaffRelateService;
@RequestMapping("/test/xx")
public void test(){
ResultRecord resultRecord = new ResultRecord();
@ -23,4 +37,45 @@ public class TestController {
resultRecord.setMonthTime(new Date());
resultRecordService.insertResultRecord(resultRecord);
}
@RequestMapping("/test/department")
public void department(){
List<DepartmentsEntity> departmentsEntityList = departmentsService.selectEntityByParentDepartmentId("0");
for(DepartmentsEntity child1:departmentsEntityList){
child1.setLevel(1);
departmentsService.updateById(child1);
List<DepartmentsEntity> departmentsEntityList2 = departmentsService.selectEntityByParentDepartmentId(child1.getDepartmentId());
for(DepartmentsEntity child2: departmentsEntityList2){
child2.setLevel(2);
departmentsService.updateById(child2);
List<DepartmentsEntity> departmentsEntityList3 = departmentsService.selectEntityByParentDepartmentId(child2.getDepartmentId());
for(DepartmentsEntity child3: departmentsEntityList3){
child3.setLevel(3);
departmentsService.updateById(child3);
List<DepartmentsEntity> departmentsEntityList4 = departmentsService.selectEntityByParentDepartmentId(child3.getDepartmentId());
for(DepartmentsEntity child4: departmentsEntityList4){
child4.setLevel(4);
departmentsService.updateById(child4);
}
}
}
}
}
@RequestMapping("/test/relate")
public void relate(){
List<DepartmentsStaffRelateEntity> list = departmentsStaffRelateService.selectAll();
for(DepartmentsStaffRelateEntity l:list){
DepartmentsEntity departmentsEntity = departmentsService.selectByDepartmentId(l.getDepartmentId());
l.setLevel(departmentsEntity.getLevel());
departmentsStaffRelateService.updateById(l);
}
}
}

View File

@ -30,4 +30,8 @@ public interface DepartmentsDao extends BaseMapper<DepartmentsEntity> {
List<DepartmentsEntity> selectAll();
List<DepartmentsEntity> selectEntityByParentDepartmentId(@Param("parentId") String parentId);
DepartmentsEntity selectByDepartmentId(@Param("departmentId") String departmentId);
}

View File

@ -46,4 +46,6 @@ public interface DepartmentsStaffRelateDao extends BaseMapper<DepartmentsStaffRe
List<DepartmentsStaffRelateEntity> selectByDepartmentIds(@Param("departmentIds") List<String> departmentIds);
List<DepartmentsStaffRelateEntity> selectByStaffIds(@Param("staffIds") List<Long> staffIds);
List<DepartmentsStaffRelateEntity> selectAll();
}

View File

@ -1,5 +1,6 @@
package com.lz.modules.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -18,55 +19,245 @@ import lombok.Data;
@TableName("lz_departments")
public class DepartmentsEntity implements Serializable {
private static final long serialVersionUID = 1L;
//自增主键
@TableId(value = "id", type = IdType.AUTO)
private Long id;
//是否删除状态1删除0有效
private Integer isDelete;
//创建时间
private Date createTime;
//更新时间
private Date updateTime;
//飞书部门id
private String departmentId;
//飞书上级部门id
private String departmentParentId;
//飞书显示部门人数
private Integer memberCount;
//组织架构名称/部门名称
private String departmentName;
//飞书部门群id
private String chatId;
//飞书部门leader_id
private String leaderEmployeeId;
//飞书部门leader的open_id
private String leaderOpenId;
//部门状态0 无效1 有效
private Integer status;
//第几级部门
private Integer level;
/**
* 自增主键
* @return
*/
@TableId
private Long id;
public Long getId() {
return id;
}
/**
* 自增主键
* @param id
*/
public void setId(Long id) {
this.id = id;
}
/**
* 是否删除状态1删除0有效
* @return
*/
private Integer isDelete;
public Integer getIsDelete() {
return isDelete;
}
/**
* 是否删除状态1删除0有效
* @param isDelete
*/
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
/**
* 创建时间
* @return
*/
private Date createTime;
public Date getCreateTime() {
return createTime;
}
/**
* 创建时间
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 更新时间
* @return
*/
private Date updateTime;
public Date getUpdateTime() {
return updateTime;
}
/**
* 更新时间
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 飞书部门id
* @return
*/
private String departmentId;
public String getDepartmentId() {
return departmentId;
}
/**
* 飞书部门id
* @param departmentId
*/
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId;
}
/**
* 飞书上级部门id
* @return
*/
private String departmentParentId;
public String getDepartmentParentId() {
return departmentParentId;
}
/**
* 飞书上级部门id
* @param departmentParentId
*/
public void setDepartmentParentId(String departmentParentId) {
this.departmentParentId = departmentParentId;
}
/**
* 飞书显示部门人数
* @return
*/
private Integer memberCount;
public Integer getMemberCount() {
return memberCount;
}
/**
* 飞书显示部门人数
* @param memberCount
*/
public void setMemberCount(Integer memberCount) {
this.memberCount = memberCount;
}
/**
* 组织架构名称/部门名称
* @return
*/
private String departmentName;
public String getDepartmentName() {
return departmentName;
}
/**
* 组织架构名称/部门名称
* @param departmentName
*/
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
/**
* 飞书部门群id
* @return
*/
private String chatId;
public String getChatId() {
return chatId;
}
/**
* 飞书部门群id
* @param chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
/**
* 飞书部门leader_id
* @return
*/
private String leaderEmployeeId;
public String getLeaderEmployeeId() {
return leaderEmployeeId;
}
/**
* 飞书部门leader_id
* @param leaderEmployeeId
*/
public void setLeaderEmployeeId(String leaderEmployeeId) {
this.leaderEmployeeId = leaderEmployeeId;
}
/**
* 飞书部门leader的open_id
* @return
*/
private String leaderOpenId;
public String getLeaderOpenId() {
return leaderOpenId;
}
/**
* 飞书部门leader的open_id
* @param leaderOpenId
*/
public void setLeaderOpenId(String leaderOpenId) {
this.leaderOpenId = leaderOpenId;
}
/**
* 部门状态0 无效1 有效
* @return
*/
private Integer status;
public Integer getStatus() {
return status;
}
/**
* 部门状态0 无效1 有效
* @param status
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* 第几级部门
* @return
*/
public Integer getLevel() {
return level;
}
/**
* 第几级部门
* @param level
*/
public void setLevel(Integer level) {
this.level = level;
}
@Override
public String toString() {
return "Departments{" +
",id=" + id +
",isDelete=" + isDelete +
",createTime=" + createTime +
",updateTime=" + updateTime +
",departmentId=" + departmentId +
",departmentParentId=" + departmentParentId +
",memberCount=" + memberCount +
",departmentName=" + departmentName +
",chatId=" + chatId +
",leaderEmployeeId=" + leaderEmployeeId +
",leaderOpenId=" + leaderOpenId +
",status=" + status +
",level=" + level +
"}";
}
}

View File

@ -1,5 +1,6 @@
package com.lz.modules.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -19,30 +20,137 @@ import lombok.Data;
public class DepartmentsStaffRelateEntity implements Serializable {
private static final long serialVersionUID = 1L;
//自增主键
@TableId(value = "id", type = IdType.AUTO)
private Long id;
//是否删除状态1删除0有效
private Integer isDelete;
//创建时间
private Date createTime;
//更新时间
private Date updateTime;
//部门id
private String departmentId;
//员工id
private Long staffId;
//第几级部门
private Integer level;
/**
* 自增主键
* @return
*/
@TableId
private Long id;
public Long getId() {
return id;
}
/**
* 自增主键
* @param id
*/
public void setId(Long id) {
this.id = id;
}
/**
* 是否删除状态1删除0有效
* @return
*/
private Integer isDelete;
public Integer getIsDelete() {
return isDelete;
}
/**
* 是否删除状态1删除0有效
* @param isDelete
*/
public void setIsDelete(Integer isDelete) {
this.isDelete = isDelete;
}
/**
* 创建时间
* @return
*/
private Date createTime;
public Date getCreateTime() {
return createTime;
}
/**
* 创建时间
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 更新时间
* @return
*/
private Date updateTime;
public Date getUpdateTime() {
return updateTime;
}
/**
* 更新时间
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 部门id
* @return
*/
private String departmentId;
public String getDepartmentId() {
return departmentId;
}
/**
* 部门id
* @param departmentId
*/
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId;
}
/**
* 员工id
* @return
*/
private Long staffId;
public Long getStaffId() {
return staffId;
}
/**
* 员工id
* @param staffId
*/
public void setStaffId(Long staffId) {
this.staffId = staffId;
}
/**
* 第几级部门
* @return
*/
public Integer getLevel() {
return level;
}
/**
* 第几级部门
* @param level
*/
public void setLevel(Integer level) {
this.level = level;
}
@Override
public String toString() {
return "DepartmentsStaffRelate{" +
",id=" + id +
",isDelete=" + isDelete +
",createTime=" + createTime +
",updateTime=" + updateTime +
",departmentId=" + departmentId +
",staffId=" + staffId +
",level=" + level +
"}";
}
}

View File

@ -27,5 +27,9 @@ public interface DepartmentsService extends IService<DepartmentsEntity> {
List<DepartmentsDto> getDepartmentTree();
List<DepartmentsDto> selectByParentDepartmentId(String deparentId);
List<DepartmentsEntity> selectEntityByParentDepartmentId(String parentId);
DepartmentsEntity selectByDepartmentId(String departmentId);
}

View File

@ -27,5 +27,6 @@ public interface DepartmentsStaffRelateService extends IService<DepartmentsStaff
void deleteAllRelates();
List<DepartmentsStaffRelateEntity> selectAll();
}

View File

@ -63,6 +63,16 @@ public class DepartmentsServiceImpl extends ServiceImpl<DepartmentsDao, Departme
return departmentsDao.getDepartmentsByparentId(deparentId+"");
}
@Override
public List<DepartmentsEntity> selectEntityByParentDepartmentId(String parentId) {
return departmentsDao.selectEntityByParentDepartmentId(parentId);
}
@Override
public DepartmentsEntity selectByDepartmentId(String departmentId) {
return departmentsDao.selectByDepartmentId(departmentId);
}
private List<DepartmentsDto> getDepartmentTreeList(List<DepartmentsDto> departmentList) {
List<DepartmentsDto> DepartmentsList = Lists.newArrayList();
for (DepartmentsDto departmentsDto : departmentList) {

View File

@ -58,5 +58,10 @@ public class DepartmentsStaffRelateServiceImpl extends ServiceImpl<DepartmentsSt
}
@Override
public List<DepartmentsStaffRelateEntity> selectAll() {
return departmentsStaffRelateDao.selectAll();
}
}

View File

@ -171,7 +171,7 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
for(DepartmentsEntity department : tDepartments) {
List<DepartmentsEntity> list = new ArrayList<>();
for(DepartmentsEntity child : tDepartments) {
if(child.getDepartmentId().equals(department.getDepartmentParentId())){
if(child.getDepartmentParentId().equals(department.getDepartmentId())){
list.add(child);
}
}

View File

@ -17,6 +17,7 @@
<result property="leaderEmployeeId" column="leader_employee_id"/>
<result property="leaderOpenId" column="leader_open_id"/>
<result property="status" column="status"/>
<result column="level" property="level"/>
</resultMap>
<select id="getDepartmentByDepartmentId" resultType="com.lz.modules.app.entity.DepartmentsEntity">
@ -74,7 +75,12 @@
<select id="selectAll" resultType="com.lz.modules.app.entity.DepartmentsEntity">
select * from lz_departments where is_delete=0
</select>
<select id="selectEntityByParentDepartmentId" resultType="com.lz.modules.app.entity.DepartmentsEntity">
select * from lz_departments where is_delete=0 and department_parent_id = #{parentId}
</select>
<select id="selectByDepartmentId" resultType="com.lz.modules.app.entity.DepartmentsEntity">
select * from lz_departments where is_delete=0 and department_id =#{departmentId}
</select>
</mapper>

View File

@ -11,8 +11,11 @@
<result property="updateTime" column="update_time"/>
<result property="departmentId" column="department_id"/>
<result property="staffId" column="staff_id"/>
<result column="level" property="level"/>
</resultMap>
<insert id="addDepartmentStaffRelateBatch">
INSERT INTO lz_departments_staff_relate(department_id, staff_id)
VALUES
@ -46,12 +49,16 @@
</select>
<select id="selectByStaffIds" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
select * from lz_departments_staff_relate where is_delete=0 and staff_id in
select * from ( select * from lz_departments_staff_relate where is_delete=0 and staff_id in
<foreach collection="staffIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by level desc) t
group by staff_id
</select>
<select id="selectAll" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
select * from lz_departments_staff_relate
</select>
</mapper>

View File

@ -60,7 +60,8 @@ public class MysqlMain {
file.mkdirs();
}
List<TablesBean> list = new ArrayList<TablesBean>();
list.add(new TablesBean("lz_result_record"));
list.add(new TablesBean("lz_departments_staff_relate"));
list.add(new TablesBean("lz_departments"));
List<TablesBean> list2 = new ArrayList<TablesBean>();
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();