提交修改

This commit is contained in:
quyixiao 2020-09-21 20:59:39 +08:00
parent ca746a8804
commit 546b964a1e
15 changed files with 140 additions and 54 deletions

View File

@ -1,6 +1,6 @@
package com.lz.common.emun;
import javax.security.auth.message.AuthStatus;
/**
* 绩效通知相关type
@ -13,11 +13,17 @@ public enum WorkMsgTypeEnum {
//绩效通过领导审核的通知这一步提交到HR提交的type
LEADER_PASS(2, "绩效已打分", "去提交给人事", "# 绩效已打分\n ## 你的绩效已经打分"),
//绩效通过人事老板审核的最终审核通知
PASS(3, "绩效通过", "去查看", "# 绩效通过\n ## 你的绩效已经通过"),;
PASS(3, "绩效通过", "去查看", "# 绩效通过\n ## 你的绩效已经通过"),
URGING(4, "绩效催办", "去审批", "# 绩效催办\n ## @提醒您审批"),
;
int type;
String title;
String btnText;
String content;
WorkMsgTypeEnum(int type, String title, String btnText, String content){
this.type = type;
this.title = title;
@ -25,6 +31,8 @@ public enum WorkMsgTypeEnum {
this.content = content;
}
public static WorkMsgTypeEnum findRoleTypeByCode(int code) {
for (WorkMsgTypeEnum workMsgTypeEnum : WorkMsgTypeEnum.values()) {
if (workMsgTypeEnum.getType() == code) {

View File

@ -169,4 +169,5 @@ public class Constant {
public static final String OSS_BUCCKET = "my-wallet";
public static final Integer TWO = 2;
public static final Integer ONE = 1;
}

View File

@ -662,4 +662,16 @@ public class StringUtil extends StringUtils {
}
return randomNum.toString();
}
public static boolean in(Integer status, Integer ... is) {
if(is == null || is.length <= 0){
return false;
}
for(Integer i:is){
if(i.equals(status)){
return true;
}
}
return false;
}
}

View File

@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@ -266,6 +267,10 @@ public class ResultRecordController extends AbstractController {
}
String superStaff = recordAuthService.selectByStaffId(resultRecord.getStaffId());
int fileCount = recordFileService.selectRecordFileCountByRecordId(resultRecord.getId());
if(resultRecord.getStaffId().equals(getUserId()) && StringUtil.in(resultRecord.getStatus() ,1,2,3,5)){
auth.setSubmited(1);
}
return R.ok()
.put("staffName", staffEntity.getName())
.put("department1", departmentDto.getDepartment1())

View File

@ -44,4 +44,6 @@ public interface FlowRecordMapper extends BaseMapper<FlowRecord> {
List<FlowRecord> selectFlowRecordByFlowId(@Param("recordId") Long recordId);
FlowRecord selectLastFlowNoStatusRecordByRecordId(@Param("recordId") Long recordId);
List<FlowRecord> selectFlowRecordByResultRecordIdType(@Param("resultRecordId") Long resultRecordId, @Param("type") Integer type);
}

View File

@ -46,6 +46,8 @@ public class FlowRecord implements java.io.Serializable {
private String flowStaffIdRole;
//状态名称
private String statusName;
//类型 ,1 表示提交目标2 表示提交结果
private Integer type;
/**
*
* @return
@ -271,6 +273,14 @@ public class FlowRecord implements java.io.Serializable {
this.statusName = statusName;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
@Override
public String toString() {
return "FlowRecord{" +

View File

@ -28,4 +28,7 @@ public class Auth {
private int keyResult37;
private int editScore;
private int deleteDetail;
private int dissatisfied;
private int submited;//是否己经提交
}

View File

@ -46,4 +46,6 @@ public interface FlowRecordService extends IService<FlowRecord> {
List<FlowRecord> selectFlowRecordByFlowId(Long recordId);
FlowRecord selectLastFlowNoStatusRecordByRecordId(Long resultRecordId);
List<FlowRecord> selectFlowRecordByResultRecordIdType(Long recordResultId, Integer type);
}

View File

@ -102,6 +102,7 @@ public class FlowRecordServiceImpl extends ServiceImpl<FlowRecordMapper, FlowRec
flowRecord.setRecordStaffId(resultRecord.getStaffId());
flowRecord.setRecordId(resultRecord.getId());
flowRecord.setStatus(0);
flowRecord.setType(resultRecord.getType());
flowRecord.setDepartmentLevel(Constant.ME);
flowRecord.setStatusName(FlowRecordEnum.START.getName());
flowRecordMapper.insertFlowRecord(flowRecord);
@ -122,5 +123,10 @@ public class FlowRecordServiceImpl extends ServiceImpl<FlowRecordMapper, FlowRec
return flowRecordMapper.selectLastFlowNoStatusRecordByRecordId(resultRecordId);
}
@Override
public List<FlowRecord> selectFlowRecordByResultRecordIdType(Long resultRecordId, Integer type) {
return flowRecordMapper.selectFlowRecordByResultRecordIdType(resultRecordId,type);
}
}

View File

@ -2,6 +2,7 @@ package com.lz.modules.sys.service.app;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.modules.app.req.ResultRecordReq;
import com.lz.modules.flow.entity.FlowRecord;
import com.lz.modules.sys.entity.app.ResultComment;
import java.util.List;
@ -38,5 +39,5 @@ public interface ResultCommentService extends IService<ResultComment> {
ResultComment selectLastComment(Long recordId);
void addOrUpdateComment(ResultRecordReq req,Long userId,int status );
void addOrUpdateComment(ResultRecordReq req, Long userId, int status , FlowRecord lastUsedFlowRecord);
}

View File

@ -91,4 +91,6 @@ public interface ResultRecordService extends IService<ResultRecord> {
Map<String, List<DepartmentsEntity>> getStringListMap(List<DepartmentsEntity> tDepartments);
ResultRecord selectResultRecordByStaffIdStatus(Long staffId, int status);
R reject( ResultRecord resultRecord,ResultRecordReq req, Long userId);
}

View File

@ -84,7 +84,7 @@ public class ResultCommentServiceImpl extends ServiceImpl<ResultCommentMapper, R
}
@Override
public void addOrUpdateComment(ResultRecordReq req, Long staffId, int status) {
public void addOrUpdateComment(ResultRecordReq req, Long staffId, int status,FlowRecord lastUsedFlowRecord) {
ResultComment comment = resultCommentService.selectResultCommentById(req.getResultCommitId());
//如果评论不为空
String resultComment = StringUtil.decodeBase64(req.getResultComment());
@ -92,7 +92,7 @@ public class ResultCommentServiceImpl extends ServiceImpl<ResultCommentMapper, R
if (StringUtil.isNotBlank(content)) { //如果不为空,
if (comment == null) {
StaffEntity mySelf = staffService.selectStaffById(staffId);
FlowRecord lastUsedFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId());
comment = new ResultComment();
comment.setStaffId(staffId);
comment.setRecordId(req.getRecordResultId());

View File

@ -346,6 +346,7 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
for(FlowRecord flowRecord : flowRecords){
flowRecord.setRecordId(resultRecordOld.getId());
flowRecord.setId(null);
flowRecord.setType(Constant.ONE);
//新增record
flowRecordService.insertFlowRecord(flowRecord);
}
@ -475,6 +476,7 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
flowRecord.setFlowStaffIdRole(staffRoles);
flowRecord.setStatusName(FlowRecordEnum.APPROVALING.getName());
flowRecord.setType(resultRecord.getType());
FlowRecord lastFlowRecordNoStatus = flowRecordService.selectLastFlowNoStatusRecordByRecordId(resultRecordId);
// 如果上一步是开始则不进行修改如果上一步是确认中改成提交如果上一点是审批中将上一步改成通过
@ -556,11 +558,14 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
@Override
public R commitApproval(ResultRecordReq req, Long userId) {
ResultRecord resultRecord = resultRecordService.selectResultRecordById(req.getRecordResultId());
if (resultRecord.getCurrentApprovalStaffId() !=null && !userId.equals(resultRecord.getCurrentApprovalStaffId())) {
return R.error("请勿重复提交");
if(req.getStatus() == 2 || req.getStatus() == 3 || req.getStatus() == 5 ){
if (resultRecord.getCurrentApprovalStaffId() !=null && !userId.equals(resultRecord.getCurrentApprovalStaffId())) {
return R.error("请勿重复提交");
}
}
R r = null;
int status = 1;
FlowRecord lastUsedFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId());
if (req.getStatus() == 2) {
r = resultRecordService.approval(req.getRecordResultId(), userId);
} else if (req.getStatus() == 3) { //侍提交
@ -568,49 +573,25 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
resultRecordService.updateResultRecordById(resultRecord);
} else if (req.getStatus() == 5) { // 驳回
status = 5;
List<FlowRecord> flowRecords = flowRecordService.selectFlowRecordByResultRecordIdFlowId(req.getRecordResultId());
StaffEntity mySelf = staffService.selectStaffById(resultRecord.getStaffId());
StaffEntity approvalStaff = mySelf;
if (flowRecords.size() >= 2) {
FlowRecord secondFlowRecord = flowRecords.get(flowRecords.size() - 2);
resultRecord.setFlowStaffIdRole(secondFlowRecord.getFlowStaffIdRole());
resultRecord.setStatus(req.getStatus());
List<StaffRoleDto> list = JSONObject.parseArray(resultRecord.getFlowStaffIdRole(), StaffRoleDto.class);
if (CollectionUtils.isNotEmpty(list)) {
StaffRoleDto staffRoleDto = list.get(0);
approvalStaff = staffService.selectStaffById(staffRoleDto.getStaffId());
resultRecord.setCurrentApprovalStaffId(approvalStaff != null ? approvalStaff.getId() : null);
resultRecord.setCurrentApprovalStaffName(approvalStaff != null ? approvalStaff.getName() : null);
}
resultRecordService.updateResultRecordById(resultRecord);
FlowRecord lastFlowRecord = flowRecords.get(flowRecords.size() - 1);
lastFlowRecord.setStatus(1);
flowRecordService.updateFlowRecordById(lastFlowRecord);
FlowRecord lastFlowRecordNoStatus = flowRecordService.selectLastFlowNoStatusRecordByRecordId(req.getRecordResultId());
lastFlowRecordNoStatus.setStatusName(FlowRecordEnum.REJECT.getName());
lastFlowRecordNoStatus.setGmtCreate(new Date()); //更新驳回时间
flowRecordService.updateFlowRecordById(lastFlowRecordNoStatus);
// 可能会被删除
FlowRecord lastUsedFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId());
lastUsedFlowRecord.setId(null);
lastUsedFlowRecord.setGmtCreate(new Date());
lastUsedFlowRecord.setGmtModified(new Date());
lastUsedFlowRecord.setStatus(1);
lastUsedFlowRecord.setStatusName(FlowRecordEnum.CONFIRM.getName());
flowRecordService.insertFlowRecord(lastUsedFlowRecord);// 新插入一条提交记录
if(mySelf.getId().longValue() == approvalStaff.getId().longValue()){//同一个人
mySelf.setName("");//用于替换消息中的@符号无其他任何作用不保存
}
r = R.ok("成功")
.put("from", mySelf)
.put("to", approvalStaff)
.put("type", WorkMsgTypeEnum.REJECT);
r = reject(resultRecord,req,userId);
}else if (req.getStatus() == 7){
List<FlowRecord> flowRecords = flowRecordService.selectFlowRecordByResultRecordIdType(req.getRecordResultId(),resultRecord.getType());
if(flowRecords!=null && flowRecords.size() == 2){ // 表示可以撤回
r = reject(resultRecord,req,userId);
}else if(flowRecords!=null && flowRecords.size() > 2){
return R.error("你的领导己经审批,不能撤回了");
}
}else if(req.getStatus() == 8 ){
Long staffId = resultRecord.getStaffId();
Long approvalStaffId = resultRecord.getCurrentApprovalStaffId();
StaffEntity mySelf = staffService.selectStaffById(staffId);
StaffEntity approvalStaff = staffService.selectStaffById(approvalStaffId);
r = R.ok("成功")
.put("from", mySelf)
.put("to", approvalStaff)
.put("type", WorkMsgTypeEnum.URGING);
}
resultCommentService.addOrUpdateComment(req, userId, status);
resultCommentService.addOrUpdateComment(req, userId, status,lastUsedFlowRecord);
if(r != null){//下面推送消息
if(r.isSuccess()){
StaffEntity mySelf = (StaffEntity)r.get("from");
@ -624,6 +605,50 @@ public class ResultRecordServiceImpl extends ServiceImpl<ResultRecordMapper, Res
return R.ok("成功");
}
@Override
public R reject( ResultRecord resultRecord,ResultRecordReq req, Long userId){
List<FlowRecord> flowRecords = flowRecordService.selectFlowRecordByResultRecordIdFlowId(req.getRecordResultId());
StaffEntity mySelf = staffService.selectStaffById(resultRecord.getStaffId());
StaffEntity approvalStaff = mySelf;
if (flowRecords.size() >= 2) {
FlowRecord secondFlowRecord = flowRecords.get(flowRecords.size() - 2);
resultRecord.setFlowStaffIdRole(secondFlowRecord.getFlowStaffIdRole());
resultRecord.setStatus(req.getStatus());
List<StaffRoleDto> list = JSONObject.parseArray(resultRecord.getFlowStaffIdRole(), StaffRoleDto.class);
if (CollectionUtils.isNotEmpty(list)) {
StaffRoleDto staffRoleDto = list.get(0);
approvalStaff = staffService.selectStaffById(staffRoleDto.getStaffId());
resultRecord.setCurrentApprovalStaffId(approvalStaff != null ? approvalStaff.getId() : null);
resultRecord.setCurrentApprovalStaffName(approvalStaff != null ? approvalStaff.getName() : null);
}
resultRecordService.updateResultRecordById(resultRecord);
FlowRecord lastFlowRecord = flowRecords.get(flowRecords.size() - 1);
lastFlowRecord.setStatus(1);
flowRecordService.updateFlowRecordById(lastFlowRecord);
FlowRecord lastFlowRecordNoStatus = flowRecordService.selectLastFlowNoStatusRecordByRecordId(req.getRecordResultId());
lastFlowRecordNoStatus.setStatusName(FlowRecordEnum.REJECT.getName());
lastFlowRecordNoStatus.setGmtCreate(new Date()); //更新驳回时间
flowRecordService.updateFlowRecordById(lastFlowRecordNoStatus);
// 可能会被删除
FlowRecord lastUsedFlowRecord = flowRecordService.selectLastFlowRecordByRecordId(req.getRecordResultId());
lastUsedFlowRecord.setId(null);
lastUsedFlowRecord.setStatus(1);
lastUsedFlowRecord.setStatusName(FlowRecordEnum.CONFIRM.getName());
flowRecordService.insertFlowRecord(lastUsedFlowRecord);// 新插入一条提交记录
if(mySelf.getId().longValue() == approvalStaff.getId().longValue()){//同一个人
mySelf.setName("");//用于替换消息中的@符号无其他任何作用不保存
}
return R.ok("成功")
.put("from", mySelf)
.put("to", approvalStaff)
.put("type", WorkMsgTypeEnum.REJECT);
}
return R.error("驳回失败");
}
public void sendWorkMSG(StaffEntity mySelf, StaffEntity toSelf, WorkMsgTypeEnum workMsgTypeEnum
, Long recordResultId, int count){
String url = domain + "/management/dingtalklogin?url=";//免登接口

View File

@ -19,12 +19,13 @@
<result column="status" property="status"/>
<result column="flow_staff_id_role" property="flowStaffIdRole"/>
<result column="status_name" property="statusName"/>
<result column="type" property="type"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_level AS departmentLevel, record_id AS recordId, approval_staff_id AS approvalStaffId, approval_staff_name AS approvalStaffName, flow_name AS flowName, record_staff_id AS recordStaffId, flow_id AS flowId, flow_index AS flowIndex, status AS status, flow_staff_id_role AS flowStaffIdRole, status_name AS statusName
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, department_level AS departmentLevel, record_id AS recordId, approval_staff_id AS approvalStaffId, approval_staff_name AS approvalStaffName, flow_name AS flowName, record_staff_id AS recordStaffId, flow_id AS flowId, flow_index AS flowIndex, status AS status, flow_staff_id_role AS flowStaffIdRole, status_name AS statusName, type AS type
</sql>
@ -48,6 +49,7 @@
<if test="status != null">status, </if>
<if test="flowStaffIdRole != null">flow_staff_id_role, </if>
<if test="statusName != null">status_name, </if>
<if test="type != null">type, </if>
is_delete,
gmt_create,
gmt_modified
@ -63,6 +65,7 @@
<if test="status != null">#{ status}, </if>
<if test="flowStaffIdRole != null">#{ flowStaffIdRole}, </if>
<if test="statusName != null">#{ statusName}, </if>
<if test="type != null">#{ type}, </if>
0,
now(),
now()
@ -86,7 +89,8 @@
<if test="flowIndex != null">flow_index = #{flowIndex},</if>
<if test="status != null">status = #{status},</if>
<if test="flowStaffIdRole != null">flow_staff_id_role = #{flowStaffIdRole},</if>
<if test="statusName != null">status_name = #{statusName}</if>
<if test="statusName != null">status_name = #{statusName},</if>
<if test="type != null">type = #{type}</if>
</trim>
,gmt_modified = now()
where id = #{id}
@ -109,7 +113,8 @@
flow_index = #{flowIndex},
status = #{status},
flow_staff_id_role = #{flowStaffIdRole},
status_name = #{statusName}
status_name = #{statusName},
type = #{type}
,gmt_modified = now()
where id = #{id}
</update>
@ -122,8 +127,6 @@
<select id="selectLastFlowRecordByRecordId" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0 and record_id = #{recordId} and status = 0 order by id desc limit 1
</select>
@ -151,5 +154,11 @@
</select>
<select id="selectFlowRecordByResultRecordIdType" resultType="com.lz.modules.flow.entity.FlowRecord">
select * from lz_flow_record where is_delete = 0 and record_id = #{resultRecordId} and type = #{type} and status = 0
</select>
</mapper>

View File

@ -63,7 +63,7 @@ public class MysqlMain {
}
List<TablesBean> list = new ArrayList<TablesBean>();
list.add(new TablesBean("lz_result_comment"));
list.add(new TablesBean("lz_flow_record"));
List<TablesBean> list2 = new ArrayList<TablesBean>();
Map<String, String> map = MysqlUtil2ShowCreateTable.getComments();