diff --git a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java index 7a1b47b7..6dc2df41 100644 --- a/src/main/java/com/lz/modules/app/controller/ResultRecordController.java +++ b/src/main/java/com/lz/modules/app/controller/ResultRecordController.java @@ -10,9 +10,15 @@ import com.lz.modules.app.resp.ResultDetailResp; import com.lz.modules.app.service.DepartmentsService; import com.lz.modules.app.service.DepartmentsStaffRelateService; import com.lz.modules.app.service.StaffService; +import com.lz.modules.flow.entity.Flow; +import com.lz.modules.flow.entity.FlowDepartment; +import com.lz.modules.flow.entity.FlowRelation; import com.lz.modules.flow.entity.RecordAuth; import com.lz.modules.flow.model.Auth; import com.lz.modules.flow.req.ResultDetailReq; +import com.lz.modules.flow.service.FlowDepartmentService; +import com.lz.modules.flow.service.FlowRelationService; +import com.lz.modules.flow.service.FlowService; import com.lz.modules.flow.service.RecordAuthService; import com.lz.modules.sys.controller.AbstractController; import com.lz.modules.sys.entity.SysUserEntity; @@ -64,8 +70,14 @@ public class ResultRecordController extends AbstractController { @Autowired private RecordAuthService recordAuthService; + @Autowired + private FlowDepartmentService flowDepartmentService; + @Autowired + private FlowRelationService flowRelationService; + @Autowired + private FlowService flowService; /** * 列表 @@ -74,7 +86,7 @@ public class ResultRecordController extends AbstractController { @RequiresPermissions("user:lzresultrecord:list") public R list(ResultRecordReq req) { SysUserEntity user = getUser(); - PageUtils page = lzResultRecordService.queryPage(req,user); + PageUtils page = lzResultRecordService.queryPage(req, user); List departmentList1 = departmentsService.selectByParentDepartmentId("0"); return R.ok().put("page", page) .put("departmentList1", departmentList1); @@ -136,7 +148,7 @@ public class ResultRecordController extends AbstractController { } //保存文件价值观 - recordType =3; + recordType = 3; insertWenHuaJiaZhiGua("做人:相信、包容、担当", resultRecordNew.getId(), getUserId()); insertWenHuaJiaZhiGua("做事:用户第一、求真、极致", resultRecordNew.getId(), getUserId()); recordResultId = resultRecordNew.getId(); @@ -152,11 +164,11 @@ public class ResultRecordController extends AbstractController { int type1 = tempType1; int type2 = tempType2; if (tempType1 == 0) { - type1 = 1 ; + type1 = 1; list.add(getYeJi()); list.add(getYeJiKaoHe()); } - if(tempType2 == 0 ){ + if (tempType2 == 0) { type2 = 2; } firstRowspan = type1; @@ -189,7 +201,7 @@ public class ResultRecordController extends AbstractController { list.add(getWenHuaJiaZhiGua1(auth)); list.add(getWenHuaJiaZhiGua2(auth)); } - }else{ + } else { int type1 = 1; int type2 = 2; firstRowspan = type1; @@ -223,6 +235,39 @@ public class ResultRecordController extends AbstractController { .put("recordResultId", recordResultId); } + @RequestMapping("/commitApproval") + public R commitApproval(ResultRecordReq req) { + ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId()); + StaffEntity staffEntity = staffService.selectStaffById(resultRecord.getStaffId()); + FlowDepartment flowDepartment = flowDepartmentService.selectByStaffId(staffEntity.getId()); + Long flowId = flowDepartment.getSelfFlowId(); // 表示是部门主管自己 + if(flowDepartment == null){ + DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectLastDepartmentByStaffId(staffEntity.getId()); + DepartmentsStaffRelateEntity leader = departmentsStaffRelateService.selectLeaderByDepartmentId(departmentsStaffRelateEntity.getDepartmentId()); + flowDepartment = flowDepartmentService.selectByStaffId(leader.getId()); + flowId = flowDepartment.getChildFlowId();//表示是部门下的普通员工 + } + List list = new ArrayList<>(); + list.add(flowDepartment); + for (int i = 0; i < 10; i++) { + if (flowDepartment.getParentId() != null && flowDepartment.getParentId() > 0) { + flowDepartment = flowDepartmentService.selectFlowDepartmentById(flowDepartment.getParentId()); + } + } + List flowRelations = flowRelationService.selectFlowRelationAll(); + Map staffEntityMap = list.stream().collect(Collectors.toMap(FlowDepartment::getDepartmentLevel, p -> p)); + // approvalList = [ONE_D,TWO_D,HR,BOSS] + List approvalList = new ArrayList<>(); + for(FlowRelation flowRelation : flowRelations){ + if(staffEntityMap.get(flowRelation.getChild()) != null || flowRelation.getCanReplace() == 0){ + approvalList.add(flowRelation.getChild()); + } + } + List flows = flowService.selectByFlowId(flowId); + return R.ok("提交审批成功"); + } + + public void insertWenHuaJiaZhiGua(String target, Long recordId, Long staffId) { ResultDetail wenhua1 = new ResultDetail(); wenhua1.setTarget(target); @@ -243,7 +288,7 @@ public class ResultRecordController extends AbstractController { return result; } - public ResultDetailResp getYeJiKaoHe(){ + public ResultDetailResp getYeJiKaoHe() { ResultDetailResp respHeader = new ResultDetailResp(); respHeader.setKeyResult("业务考核结果"); respHeader.setCheckWeight(new BigDecimal(0.7)); @@ -274,7 +319,7 @@ public class ResultRecordController extends AbstractController { return wenhua2; } - public ResultDetailResp getWenHuaJiaZhiGuaResult1(){ + public ResultDetailResp getWenHuaJiaZhiGuaResult1() { ResultDetailResp tail1 = new ResultDetailResp(); tail1.setKeyResult("文化价值观考核结果"); tail1.setCheckWeight(new BigDecimal(0.3)); @@ -286,7 +331,7 @@ public class ResultRecordController extends AbstractController { } - public ResultDetailResp getWenHuaJiaZhiGuaResult2(){ + public ResultDetailResp getWenHuaJiaZhiGuaResult2() { ResultDetailResp tail2 = new ResultDetailResp(); tail2.setCheckRange("文化价值观考核结果"); tail2.setAcquireScore(new BigDecimal(0)); @@ -295,7 +340,7 @@ public class ResultRecordController extends AbstractController { return tail2; } - public ResultDetailResp getLastResult(){ + public ResultDetailResp getLastResult() { ResultDetailResp tail3 = new ResultDetailResp(); tail3.setCheckRange("最终绩效考核结果等级"); tail3.setAcquireScore(new BigDecimal(3.25)); @@ -427,7 +472,7 @@ public class ResultRecordController extends AbstractController { return R.ok("保存成功").put("recordId", recordId); } - public ResultRecord createResultRecord(int type ){ + public ResultRecord createResultRecord(int type) { ResultRecord resultRecord = new ResultRecord(); resultRecord.setMonthTime(new Date()); resultRecord.setCurrentFlowStaffId(getUserId()); @@ -442,6 +487,7 @@ public class ResultRecordController extends AbstractController { resultRecordService.insertResultRecord(resultRecord); return resultRecord; } + /** * 保存 */ diff --git a/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java b/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java index 20d0b7f1..d5268ea8 100644 --- a/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java +++ b/src/main/java/com/lz/modules/app/dao/DepartmentsStaffRelateDao.java @@ -49,4 +49,8 @@ public interface DepartmentsStaffRelateDao extends BaseMapper selectByStaffIds(@Param("staffIds") List staffIds); List selectAll(); + + DepartmentsStaffRelateEntity selectLastDepartmentByStaffId(@Param("staffId") Long staffId); + + DepartmentsStaffRelateEntity selectLeaderByDepartmentId(@Param("departmentId") String departmentId); } diff --git a/src/main/java/com/lz/modules/app/service/DepartmentsStaffRelateService.java b/src/main/java/com/lz/modules/app/service/DepartmentsStaffRelateService.java index f6830fc5..c6fc0abf 100644 --- a/src/main/java/com/lz/modules/app/service/DepartmentsStaffRelateService.java +++ b/src/main/java/com/lz/modules/app/service/DepartmentsStaffRelateService.java @@ -31,5 +31,9 @@ public interface DepartmentsStaffRelateService extends IService selectAll(); List selectByStaffIds(List staffIds); + + DepartmentsStaffRelateEntity selectLastDepartmentByStaffId(Long staffId); + + DepartmentsStaffRelateEntity selectLeaderByDepartmentId(String departmentId); } diff --git a/src/main/java/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.java b/src/main/java/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.java index e726ea4e..dfb8acc2 100644 --- a/src/main/java/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.java +++ b/src/main/java/com/lz/modules/app/service/impl/DepartmentsStaffRelateServiceImpl.java @@ -70,5 +70,15 @@ public class DepartmentsStaffRelateServiceImpl extends ServiceImpl { FlowDepartment selectByStaffId(@Param("staffId") Long staffId); + + FlowDepartment selectByParentId(@Param("parentId") Long parentId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/dao/FlowMapper.java b/src/main/java/com/lz/modules/flow/dao/FlowMapper.java index 9d3a22f9..5889418e 100644 --- a/src/main/java/com/lz/modules/flow/dao/FlowMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/FlowMapper.java @@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.lz.modules.flow.entity.Flow; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + +import java.util.List; + @Mapper public interface FlowMapper extends BaseMapper { @@ -30,4 +33,5 @@ public interface FlowMapper extends BaseMapper { int deleteFlowById(@Param("id")Long id); + List selectByFlowId(@Param("flowId") Long flowId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/dao/FlowRelationMapper.java b/src/main/java/com/lz/modules/flow/dao/FlowRelationMapper.java index b0d874e3..ae8ec3c5 100644 --- a/src/main/java/com/lz/modules/flow/dao/FlowRelationMapper.java +++ b/src/main/java/com/lz/modules/flow/dao/FlowRelationMapper.java @@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.lz.modules.flow.entity.FlowRelation; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + +import java.util.List; + @Mapper public interface FlowRelationMapper extends BaseMapper { @@ -30,4 +33,5 @@ public interface FlowRelationMapper extends BaseMapper { int deleteFlowRelationById(@Param("id")Long id); + List selectFlowRelationAll(); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java b/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java index a76bf13d..788cfa52 100644 --- a/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java +++ b/src/main/java/com/lz/modules/flow/entity/FlowDepartment.java @@ -9,7 +9,7 @@ import java.util.Date; * 菜单权限表 *

*流转关系表 * @author quyixiao -* @since 2020-08-18 +* @since 2020-08-19 */ @Data @@ -24,8 +24,6 @@ public class FlowDepartment implements java.io.Serializable { private Date gmtCreate; //最后修改时间 private Date gmtModified; - // - private Long departmentId; //员工 id private Long taffId; //自己部门小伙伴 走的 流程id @@ -34,6 +32,8 @@ public class FlowDepartment implements java.io.Serializable { private Long selfFlowId; //部门级别 private String departmentLevel; + // + private Long parentId; /** * * @return @@ -94,21 +94,6 @@ public class FlowDepartment implements java.io.Serializable { this.gmtModified = gmtModified; } - /** - * - * @return - */ - public Long getDepartmentId() { - return departmentId; - } - /** - * - * @param departmentId - */ - public void setDepartmentId(Long departmentId) { - this.departmentId = departmentId; - } - /** * 员工 id * @return @@ -169,6 +154,21 @@ public class FlowDepartment implements java.io.Serializable { this.departmentLevel = departmentLevel; } + /** + * + * @return + */ + public Long getParentId() { + return parentId; + } + /** + * + * @param parentId + */ + public void setParentId(Long parentId) { + this.parentId = parentId; + } + @Override public String toString() { return "FlowDepartment{" + @@ -176,11 +176,11 @@ public class FlowDepartment implements java.io.Serializable { ",isDelete=" + isDelete + ",gmtCreate=" + gmtCreate + ",gmtModified=" + gmtModified + - ",departmentId=" + departmentId + ",taffId=" + taffId + ",childFlowId=" + childFlowId + ",selfFlowId=" + selfFlowId + ",departmentLevel=" + departmentLevel + + ",parentId=" + parentId + "}"; } } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/FlowDepartmentService.java b/src/main/java/com/lz/modules/flow/service/FlowDepartmentService.java index d81b307b..723d0c73 100644 --- a/src/main/java/com/lz/modules/flow/service/FlowDepartmentService.java +++ b/src/main/java/com/lz/modules/flow/service/FlowDepartmentService.java @@ -31,4 +31,6 @@ public interface FlowDepartmentService extends IService { FlowDepartment selectByStaffId(Long staffId); + + FlowDepartment selectByParentId(Long parentId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/FlowRelationService.java b/src/main/java/com/lz/modules/flow/service/FlowRelationService.java index 99110a24..f01c855b 100644 --- a/src/main/java/com/lz/modules/flow/service/FlowRelationService.java +++ b/src/main/java/com/lz/modules/flow/service/FlowRelationService.java @@ -3,6 +3,8 @@ package com.lz.modules.flow.service; import com.baomidou.mybatisplus.extension.service.IService; import com.lz.modules.flow.entity.FlowRelation; +import java.util.List; + /** *

* 流转关系表 服务类 @@ -30,6 +32,5 @@ public interface FlowRelationService extends IService { int deleteFlowRelationById(Long id); - - + List selectFlowRelationAll(); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/FlowService.java b/src/main/java/com/lz/modules/flow/service/FlowService.java index fc3f60c4..80a5a1f0 100644 --- a/src/main/java/com/lz/modules/flow/service/FlowService.java +++ b/src/main/java/com/lz/modules/flow/service/FlowService.java @@ -3,6 +3,8 @@ package com.lz.modules.flow.service; import com.baomidou.mybatisplus.extension.service.IService; import com.lz.modules.flow.entity.Flow; +import java.util.List; + /** *

* 流转表 服务类 @@ -30,6 +32,5 @@ public interface FlowService extends IService { int deleteFlowById(Long id); - - + List selectByFlowId(Long flowId); } \ No newline at end of file diff --git a/src/main/java/com/lz/modules/flow/service/impl/FlowDepartmentServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/FlowDepartmentServiceImpl.java index a654cd16..21fd4cfb 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/FlowDepartmentServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/FlowDepartmentServiceImpl.java @@ -63,5 +63,10 @@ public class FlowDepartmentServiceImpl extends ServiceImpl * 流转关系表 服务类 @@ -58,8 +60,11 @@ public class FlowRelationServiceImpl extends ServiceImpl selectFlowRelationAll() { - + return flowRelationMapper.selectFlowRelationAll(); + } } diff --git a/src/main/java/com/lz/modules/flow/service/impl/FlowServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/FlowServiceImpl.java index 113e5369..fe6a4aec 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/FlowServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/FlowServiceImpl.java @@ -7,6 +7,8 @@ import com.lz.modules.flow.service.FlowService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 流转表 服务类 @@ -58,6 +60,10 @@ public class FlowServiceImpl extends ServiceImpl implements Fl return flowMapper.deleteFlowById(id); } + @Override + public List selectByFlowId(Long flowId) { + return flowMapper.selectByFlowId(flowId); + } } diff --git a/src/main/resources/mapper/flow/FlowDepartmentMapper.xml b/src/main/resources/mapper/flow/FlowDepartmentMapper.xml index 1cf152d8..d587b675 100644 --- a/src/main/resources/mapper/flow/FlowDepartmentMapper.xml +++ b/src/main/resources/mapper/flow/FlowDepartmentMapper.xml @@ -8,62 +8,61 @@ - + - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_id AS departmentId, taff_id AS taffId, child_flow_id AS childFlowId, self_flow_id AS selfFlowId, department_level AS departmentLevel + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, taff_id AS taffId, child_flow_id AS childFlowId, self_flow_id AS selfFlowId, department_level AS departmentLevel, parent_id AS parentId - insert into lz_flow_department( - department_id, - taff_id, - child_flow_id, - self_flow_id, - department_level, - is_delete, - gmt_create, - gmt_modified + taff_id, + child_flow_id, + self_flow_id, + department_level, + parent_id, + is_delete, + gmt_create, + gmt_modified )values( - #{ departmentId}, - #{ taffId}, - #{ childFlowId}, - #{ selfFlowId}, - #{ departmentLevel}, - 0, - now(), - now() + #{ taffId}, + #{ childFlowId}, + #{ selfFlowId}, + #{ departmentLevel}, + #{ parentId}, + 0, + now(), + now() ) update - lz_flow_department + lz_flow_department is_delete = #{isDelete}, gmt_create = #{gmtCreate}, - department_id = #{departmentId}, taff_id = #{taffId}, child_flow_id = #{childFlowId}, self_flow_id = #{selfFlowId}, - department_level = #{departmentLevel} + department_level = #{departmentLevel}, + parent_id = #{parentId} ,gmt_modified = now() where id = #{id} @@ -72,29 +71,33 @@ update - lz_flow_department - set + lz_flow_department + set is_delete = #{isDelete}, gmt_create = #{gmtCreate}, - department_id = #{departmentId}, taff_id = #{taffId}, child_flow_id = #{childFlowId}, self_flow_id = #{selfFlowId}, - department_level = #{departmentLevel} + department_level = #{departmentLevel}, + parent_id = #{parentId} ,gmt_modified = now() where id = #{id} - update lz_flow_department set is_delete = 1 where id=#{id} limit 1 + update lz_flow_department set is_delete = 1 where id=#{id} limit 1 - + + + diff --git a/src/main/resources/mapper/flow/FlowMapper.xml b/src/main/resources/mapper/flow/FlowMapper.xml index 290efbd3..8ea0fd1f 100644 --- a/src/main/resources/mapper/flow/FlowMapper.xml +++ b/src/main/resources/mapper/flow/FlowMapper.xml @@ -14,20 +14,15 @@ - id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, flow_id AS flowId, opt AS opt, opt_desc AS optDesc, role_id AS roleId - - - - insert into lz_flow( flow_id, @@ -79,10 +74,13 @@ where id = #{id} - update lz_flow set is_delete = 1 where id=#{id} limit 1 + + diff --git a/src/main/resources/mapper/flow/FlowRelationMapper.xml b/src/main/resources/mapper/flow/FlowRelationMapper.xml index a4806bc9..a2088363 100644 --- a/src/main/resources/mapper/flow/FlowRelationMapper.xml +++ b/src/main/resources/mapper/flow/FlowRelationMapper.xml @@ -27,6 +27,7 @@ + insert into lz_flow_relation( child, @@ -79,5 +80,11 @@ update lz_flow_relation set is_delete = 1 where id=#{id} limit 1 + + + + diff --git a/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml b/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml index 66caff3f..57b4030c 100644 --- a/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml +++ b/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml @@ -61,5 +61,15 @@ select * from lz_departments_staff_relate + + + + diff --git a/src/test/java/com/lz/mysql/MysqlMain.java b/src/test/java/com/lz/mysql/MysqlMain.java index 94a0e25d..25d2366b 100644 --- a/src/test/java/com/lz/mysql/MysqlMain.java +++ b/src/test/java/com/lz/mysql/MysqlMain.java @@ -61,7 +61,7 @@ public class MysqlMain { } List list = new ArrayList(); - list.add(new TablesBean("sys_user_token")); + list.add(new TablesBean("lz_flow_department")); List list2 = new ArrayList(); Map map = MysqlUtil2ShowCreateTable.getComments();