审核之后,数据库置有result更新了,审核时间,state,reason都没有变,而且页面上审核完之后没有消失,是不是也是因为state没有变的原因?

审核之后,数据库置有result更新了,审核时间,state,reason都没有变,而且页面上审核完之后没有消失,是不是也是因为state没有变的原因?

相关代码:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.imooc.oa.dao.ProcessFlowDao">
<insert id="insert" parameterType="com.imooc.oa.entity.ProcessFlow" useGeneratedKeys="true" keyProperty="processId" keyColumn="process_id">
INSERT INTO adm_process_flow (form_id , operator_id , action , result , reason , create_time , audit_time , order_no , state , is_last ) VALUES (#{formId}, #{operatorId}, #{action}, #{ result}, #{reason}, #{createTime}, #{auditTime},#{orderNo}, #{state}, #{isLast});
</insert>
<update id="update" parameterType="com.imooc.oa.entity.ProcessFlow">
UPDATE adm_process_flow SET state = #{state}, form_id = #{formId}, operator_id = #{operatorId}, action = #{action }, result = #{result}, reason = #{reason}, create_time = #{createTime}, audit_time = #{auditTime}, order_no = #{orderNo}, is_last = #{isLast} WHERE process_id = #{processId};

</update>
<select id="selectById" parameterType="Long" resultType="com.imooc.oa.entity.ProcessFlow">
select * from adm_process_flow where form_id = #{value } order by order_no;
</select>
</mapper>

相关代码:

package com.imooc.oa.dao;

import com.imooc.oa.entity.ProcessFlow;

import java.util.List;

public interface ProcessFlowDao {
public void insert(ProcessFlow processFlow);

public void update(ProcessFlow processFlow);

public List<ProcessFlow> selectById(Long formId);
}

相关代码:

package com.imooc.oa.controller;

import com.alibaba.fastjson.JSON;
import com.imooc.oa.entity.LeaveForm;
import com.imooc.oa.entity.User;
import com.imooc.oa.service.LeaveFormService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet(name = "LeaveFormServlet", urlPatterns = "/leave/*")
public class LeaveFormServlet extends HttpServlet {
//实例化LeaveFormService
private LeaveFormService leaveFormService = new LeaveFormService();
//引入日志文件
private Logger logger = LoggerFactory.getLogger(LeaveFormServlet.class);
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
//得到当前URL字符串
String uri = request.getRequestURI();
//得到http://localhost/leave/*的那个*是什么
String methodName = uri.substring(uri.lastIndexOf("/") + 1);
if (methodName.equals("create")) {
this.create(request, response);//创建请假单
} else if (methodName.equals("list")) {
this.getLeaveForm(request,response);//审核时查看请假单
} else if (methodName.equals("audit")) {
this.audit(request, response);//审核
}
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}

/**
* 创建请假单
* @param request
* @param response
* @throws IOException
*/
private void create(HttpServletRequest request, HttpServletResponse response) throws IOException {
//再session中获取到用户信息
HttpSession session = request.getSession();
User user = (User) session.getAttribute("login_user");
//得到请假单信息
String formType = request.getParameter("formType");
String strStartTime = request.getParameter("startTime");
String strEndStTime = request.getParameter("endTime");
String reason = request.getParameter("reason");
//字符串日期转化为Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH");

//返回集
Map resolts = new HashMap();
try {
//封装信息
LeaveForm leaveForm = new LeaveForm();
leaveForm.setEmployeeId(user.getEmployeeId());
leaveForm.setStartTime(sdf.parse(strStartTime));
leaveForm.setEndTime(sdf.parse(strEndStTime));
leaveForm.setFormType(Integer.parseInt(formType));
leaveForm.setReason(reason);
leaveForm.setCreateTime(new Date());
//调用业务逻辑方法
leaveFormService.CreateLeaveForm(leaveForm);
resolts.put("code", "0");
resolts.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
logger.error("请假申请异常",e);
resolts.put("code", e.getClass().getSimpleName());
resolts.put("message", e.getMessage());
}
//组织响应结果
//转化为JSON
String json = JSON.toJSONString(resolts);
//对外输出
response.getWriter().println(json);
}

public void getLeaveForm(HttpServletRequest request,HttpServletResponse response) {
User user = (User) request.getSession().getAttribute("login_user");
List<Map> list = leaveFormService.getLeaveForm("process", user.getEmployeeId());
//封装输出结果
Map map = new HashMap();
map.put("code", "0");
map.put("msg", "");
map.put("count", list.size());
map.put("data", list);
//序列化结果
String json = JSON.toJSONString(map);
try {
response.getWriter().println(json);
} catch (IOException e) {
e.printStackTrace();
}
}

public void audit(HttpServletRequest request,HttpServletResponse response) throws IOException {
String formId = request.getParameter("formId");
String result = request.getParameter("result");
String reason = request.getParameter("reason");
User user = (User) request.getSession().getAttribute("login_user");
//结果集
Map mresult = new HashMap();
try {
leaveFormService.audit(Long.parseLong(formId), user.getEmployeeId(), result, reason);
mresult.put("code", "0");
mresult.put("message", "success");
} catch (Exception e) {
logger.error("请假单审核失败", e);
mresult.put("code", e.getClass().getSimpleName());
mresult.put("message", e.getMessage());
}
String json = JSON.toJSONString(mresult);
response.getWriter().println(json);
}
}

相关代码:

package com.imooc.oa.service;

import com.imooc.oa.dao.EmployeeDao;
import com.imooc.oa.dao.LeaveFormDao;
import com.imooc.oa.dao.ProcessFlowDao;
import com.imooc.oa.entity.Employee;
import com.imooc.oa.entity.LeaveForm;
import com.imooc.oa.entity.ProcessFlow;
import com.imooc.oa.service.exception.BussinessException;
import com.imooc.oa.utils.MybatisUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

//请假单service
public class LeaveFormService {
/**
* 创建请假单
* @param leaveForm
* @return
*/
public LeaveForm CreateLeaveForm(LeaveForm leaveForm) {
LeaveForm savedForm = (LeaveForm) MybatisUtils.excuteUpdate(sqlSession -> {
LeaveFormDao leaveFormDao = sqlSession.getMapper(LeaveFormDao.class);
//1.获取当前创建请假单的员工的级别,并根据不同级别处理业务
EmployeeDao employeeDao = sqlSession.getMapper(EmployeeDao.class);
Employee employee = employeeDao.selectById(leaveForm.getEmployeeId());
if (employee.getLevel()==8){//总经理直接通过
leaveForm.setState("approved");
}else {
leaveForm.setState("processing");
}
//持久化表单
leaveFormDao.insert(leaveForm);
//2.创建第一条流程数据,说明表单已提交
ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);
ProcessFlow f1 = new ProcessFlow();
f1.setFormId(leaveForm.getFormId());
f1.setOrderNo(1);//任务序号
f1.setOperatorId(employee.getEmployeeId());//经手人ID
f1.setAction("apply");//申请行为
f1.setCreateTime(new Date());
f1.setState("complete");//提交行文完成
f1.setIsLast(0);//不是最后一个节点
processFlowDao.insert(f1);
//3.分情况处理其他流程数据
//3.1 七级一下员工生成部门经理审批,36小时以上生成总经理审批
if (employee.getLevel()<7){
//获取上级领导
Employee leader = employeeDao.selectLeader(employee);
//生成领导审批的流程
ProcessFlow f2 = new ProcessFlow();
f2.setFormId(leaveForm.getFormId());
f2.setOperatorId(leader.getEmployeeId());//领导经办
f2.setAction("audit");//审批惹我你
f2.setOrderNo(2);//流程号
f2.setCreateTime(new Date());
f2.setState("process");//领导正在审批
//判断还用不用项总经理审批
Long diff = leaveForm.getEndTime().getTime() - leaveForm.getStartTime().getTime();//得到时间差
Float hours = diff / (1000 * 60 * 60) * 1f;//毫秒数转换为浮点小时
if(hours>=BussinessContants.MANAGER_AUDIT_HOURS){
f2.setIsLast(0);//不是最后一个节点
processFlowDao.insert(f2);//持久化
//总经理审批
Employee manager = employeeDao.selectLeader(leader);//得到总经理
ProcessFlow f3 = new ProcessFlow();//总经理审批流程
f3.setFormId(leaveForm.getFormId());
f3.setOperatorId(leader.getEmployeeId());//领导经办
f3.setAction("audit");//审批惹我你
f3.setOrderNo(3);//流程号
f3.setCreateTime(new Date());
f3.setIsLast(1);//是最后一个节点
f3.setState("ready");//部门经理正在审批,总经理就要先等待
processFlowDao.insert(f3);
}else {//不用总经理
f2.setIsLast(1);
processFlowDao.insert(f2);
}
}else if (employee.getLevel()==7){//部门经理
//生成总经理审批
Employee manager = employeeDao.selectLeader(employee);
ProcessFlow f = new ProcessFlow();
f.setFormId(leaveForm.getFormId());
f.setOperatorId(manager.getEmployeeId());//领导经办
f.setAction("audit");//审批惹我你
f.setOrderNo(2);//流程号
f.setCreateTime(new Date());
f.setIsLast(1);//是最后一个节点
f.setState("process");//部门经理正在
processFlowDao.insert(f);
} else if (employee.getLevel() == 8) {//总经理请假
ProcessFlow f = new ProcessFlow();
f.setFormId(leaveForm.getFormId());
f.setOperatorId(employee.getEmployeeId());//领导经办
f.setAction("audit");//审批惹我你
f.setResult("approved");//自动审批通过
f.setReason("自动通过");
f.setCreateTime(new Date());
f.setAuditTime(new Date());
f.setState("complete");//完成
f.setOrderNo(2);//第二部
f.setIsLast(1);//最后一个节点
processFlowDao.insert(f);
}
return leaveForm;
});
return savedForm;//返回最终的请假单
}

public List<Map> getLeaveForm(String state, Long id) {
return (List<Map>) MybatisUtils.excuteQuery(sqlSession -> {
LeaveFormDao leaveFormDao = sqlSession.getMapper(LeaveFormDao.class);
List<Map> list = leaveFormDao.selectByParam(state, id);
return list;
});
}

public void audit(Long formId,Long operatorId,String result,String reason){

MybatisUtils.excuteUpdate(sqlSession -> {
ProcessFlow process = null;
//1.无论统一还是驳回,当前任务状态都变为complete
ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);//实例化
List<ProcessFlow> list = processFlowDao.selectById(formId);//得到进程流
if (list.size()==0){//没有进程
throw new BussinessException("PF001", "无效进程");
}
//获取当前进程(筛选条件为:1.状态为process。2.操作员为operatorId)并将筛选后的结果生成为新的List
List<ProcessFlow> pfList = list.stream().filter(p -> (p.getState().equals("process") )&&( p.getOperatorId() == operatorId)).collect(Collectors.toList());
if (pfList.size()==0){//没有进程
throw new BussinessException("PF002", "未找到待处理任务");
}else{
process = pfList.get(0);
process.setState("complete");
process.setAuditTime(new Date());
process.setReason(reason);
process.setResult(result);
processFlowDao.update(process);
}
//2.当前是最后一个节点,更新请假单为approved/refused
LeaveFormDao leaveFormDao = sqlSession.getMapper(LeaveFormDao.class);
LeaveForm leaveForm = new LeaveForm();
if(process.getIsLast()==1){
leaveForm.setState(result);//更新请假单为approved/refused
leaveFormDao.update(leaveForm);
}else{//有后续节点
//3.当前不是最后一个节点,下一个节点从ready变为process
// 从进程流中获取后续所有的任务节点(进程为ready的就是后续进程)
List<ProcessFlow> readyList = list.stream().filter(p -> p.getState().equals("ready")).collect(Collectors.toList());
if (result.equals("approved")){//审批结果为统一,进行下一个节点
ProcessFlow fistReady = readyList.get(0);//获取第一个后继节点
fistReady.setState("process");
processFlowDao.update(fistReady);
}else if(result.equals("refused")){//当前节点拒绝
//4.当前不是最后一个节点,但是当前节点是驳回,则之后所有任务变为cancel,请假单状态变为refused
for (ProcessFlow p:readyList){//对每个后继结点修改
p.setState("cancel");
processFlowDao.update(p);
}
//修改表单状态
leaveForm.setState("refused");
leaveFormDao.update(leaveForm);
}
}
return null;
});

}
}

相关截图:

http://img1.sycdn.imooc.com//climg/6033a84d082f703417080537.jpg

http://img1.sycdn.imooc.com//climg/6033a8630832e1f012400105.jpg


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕小班 2021-02-23 19:20:15

同学你好,测试同学最新贴出代码是可以正确创建的,例如:

http://img1.sycdn.imooc.com//climg/6034e43509fb32e018770308.jpg

请求流程正确创建了。

同学使用之前的代码可以正常创建请假流程,那同学可以对比一下自己的代码与源码中创建步骤是否有差异。

另外,同学是否有缓存问题呐,同学清理缓存重启试试。

祝学习愉快!

好帮手慕小班 2021-02-23 14:52:53

同学你好,测试贴出代码运行,可以正常更新,在数据库中也有对应的审核时间,state,reason,比如:

http://img1.sycdn.imooc.com//climg/6034a6340948420210660123.jpg

同学尝试清理缓存再来试试呐

页面上审核完之后没有消失,同学刷新一下数据库看看,另外,同学可以查看一下其他位置是否有报错信息呐。

祝学习愉快!


  • 提问者 Java小彩鸡 #1

    本来是解决了,但是审核的时候,项目经理可以审核两次,直接就把总经理的那个完成了。我就把LeaveFormService的​代码换成老师的代码了,现在就填写完请假单之后,没有通知成功,项目经理也没有收到要审核的,数据库也没有这个请假数据


    2021-02-23 18:50:06
  • 提问者 Java小彩鸡 #2
    public class LeaveFormService {
    /**
    * 创建请假单
    * @param form 前端输入的请假单数据
    * @return 持久化后的请假单对象
    */
    public LeaveForm createLeaveForm(LeaveForm form){
    LeaveForm savedForm = (LeaveForm)MybatisUtils.excuteQuery(sqlSession -> {
    //1.持久化form表单数据,8级以下员工表单状态为processing,8级(总经理)状态为approved
    EmployeeDao employeeDao = sqlSession.getMapper(EmployeeDao.class);
    Employee employee = employeeDao.selectById(form.getEmployeeId());
    if(employee.getLevel() == 8){
    form.setState("approved");
    }else{
    form.setState("processing");
    }
    LeaveFormDao leaveFormDao = sqlSession.getMapper(LeaveFormDao.class);
    leaveFormDao.insert(form);
    //2.增加第一条流程数据,说明表单已提交,状态为complete
    ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);
    ProcessFlow flow1 = new ProcessFlow();
    flow1.setFormId(form.getFormId());
    flow1.setOperatorId(employee.getEmployeeId());
    flow1.setAction("apply");
    flow1.setCreateTime(new Date());
    flow1.setOrderNo(1);
    flow1.setState("complete");
    flow1.setIsLast(0);
    processFlowDao.insert(flow1);
    //3.分情况创建其余流程数据
    //3.1 7级以下员工,生成部门经理审批任务,请假时间大于72小时,还需生成总经理审批任务
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH时");
    NoticeDao noticeDao = sqlSession.getMapper(NoticeDao.class);
    if(employee.getLevel() < 7){
    Employee dmanager = employeeDao.selectLeader(employee);
    ProcessFlow flow2 = new ProcessFlow();
    flow2.setFormId(form.getFormId());
    flow2.setOperatorId(dmanager.getEmployeeId());
    flow2.setAction("audit");
    flow2.setCreateTime(new Date());
    flow2.setOrderNo(2);
    flow2.setState("process");
    long diff = form.getEndTime().getTime() - form.getStartTime().getTime();
    float hours = diff/(1000*60*60) * 1f;
    if(hours >= BussinessContants.MANAGER_AUDIT_HOURS){
    flow2.setIsLast(0);
    processFlowDao.insert(flow2);
    Employee manager = employeeDao.selectLeader(dmanager);
    ProcessFlow flow3 = new ProcessFlow();
    flow3.setFormId(form.getFormId());
    flow3.setOperatorId(manager.getEmployeeId());
    flow3.setAction("audit");
    flow3.setCreateTime(new Date());
    flow3.setState("ready");
    flow3.setOrderNo(3);
    flow3.setIsLast(1);
    processFlowDao.insert(flow3);
    }else {
    flow2.setIsLast(1);
    processFlowDao.insert(flow2);
    }
    //请假单已提交消息
    String noticeContent = String.format("您的请假申请[%s-%s]已提交,请等待上级审批."
    , sdf.format(form.getStartTime()), sdf.format(form.getEndTime()));
    noticeDao.insert(new Notice(employee.getEmployeeId(),noticeContent));

    //通知部门经理审批消息
    noticeContent = String.format("%s-%s提起请假申请[%s-%s],请尽快审批",
    employee.getTitle() , employee.getName() ,sdf.format(form.getStartTime()),sdf.format(form.getEndTime()));
    noticeDao.insert(new Notice(dmanager.getEmployeeId(),noticeContent));
    }else if(employee.getLevel() == 7){ //部门经理
    //3.2 7级员工,生成总经理审批任务
    Employee manager = employeeDao.selectLeader(employee);
    ProcessFlow flow = new ProcessFlow();
    flow.setFormId(form.getFormId());
    flow.setOperatorId(manager.getEmployeeId());
    flow.setAction("audit");
    flow.setCreateTime(new Date());
    flow.setState("process");
    flow.setOrderNo(2);
    flow.setIsLast(1);
    processFlowDao.insert(flow);
    //请假单已提交消息
    String noticeContent = String.format("您的请假申请[%s-%s]已提交,请等待上级审批."
    , sdf.format(form.getStartTime()), sdf.format(form.getEndTime()));
    noticeDao.insert(new Notice(employee.getEmployeeId(),noticeContent));

    //通知总经理审批消息
    noticeContent = String.format("%s-%s提起请假申请[%s-%s],请尽快审批",
    employee.getTitle() , employee.getName() ,sdf.format(form.getStartTime()),sdf.format(form.getEndTime()));
    noticeDao.insert(new Notice(manager.getEmployeeId(),noticeContent));

    }else if(employee.getLevel() == 8){
    //3.3 8级员工,生成总经理审批任务,系统自动通过
    ProcessFlow flow = new ProcessFlow();
    flow.setFormId(form.getFormId());
    flow.setOperatorId(employee.getEmployeeId());
    flow.setAction("audit");
    flow.setResult("approved");
    flow.setReason("自动通过");
    flow.setCreateTime(new Date());
    flow.setAuditTime(new Date());
    flow.setState("complete");
    flow.setOrderNo(2);
    flow.setIsLast(1);
    processFlowDao.insert(flow);
    String noticeContent = String.format("您的请假申请[%s-%s]系统已自动批准通过." ,
    sdf.format(form.getStartTime()) , sdf.format(form.getEndTime()));
    noticeDao.insert(new Notice(employee.getEmployeeId(),noticeContent));
    }
    return form;

    });
    return savedForm;
    }


    2021-02-23 18:51:05
  • 提问者 Java小彩鸡 #3
       /**
    * 获取指定任务状态及指定经办人对应的请假单列表
    * @param pfState ProcessFlow任务状态
    * @param operatorId 经办人编号
    * @return 请假单及相关数据列表
    */
    public List<Map> getLeaveFormList(String pfState , Long operatorId){
    return (List<Map>)MybatisUtils.excuteQuery(sqlSession -> {
    LeaveFormDao dao = sqlSession.getMapper(LeaveFormDao.class);
    List<Map> formList = dao.selectByParam(pfState, operatorId);
    return formList;
    });
    }

    /**
    * 审核请假单
    * @param formId 表单编号
    * @param operatorId 经办人(当前登录员工)
    * @param result 审批结果
    * @param reason 审批意见
    */
    public void audit(Long formId , Long operatorId , String result , String reason){
    MybatisUtils.excuteUpdate(sqlSession -> {
    //1.无论同意/驳回,当前任务状态变更为complete
    ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);
    List<ProcessFlow> flowList = processFlowDao.selectById(formId);
    if(flowList.size() == 0){
    throw new BussinessException("PF001", "无效的审批流程");
    }
    //获取当前任务ProcessFlow对象
    List<ProcessFlow> processList = flowList.stream().filter(p -> p.getOperatorId() == operatorId && p.getState().equals("process")).collect(Collectors.toList());
    ProcessFlow process = null;
    if(processList.size()==0){
    throw new BussinessException("PF002", "未找到待处理任务");
    }else{
    process = processList.get(0);
    process.setState("complete");
    process.setResult(result);
    process.setReason(reason);
    process.setAuditTime(new Date());
    processFlowDao.update(process);
    }


    LeaveFormDao leaveFormDao = sqlSession.getMapper(LeaveFormDao.class);
    LeaveForm form = leaveFormDao.selectById(formId);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH时");
    EmployeeDao employeeDao = sqlSession.getMapper(EmployeeDao.class);
    Employee employee = employeeDao.selectById(form.getEmployeeId());//表单提交人信息
    Employee operator = employeeDao.selectById(operatorId);//任务经办人信息
    NoticeDao noticeDao = sqlSession.getMapper(NoticeDao.class);
    //2.如果当前任务是最后一个节点,代表流程结束,更新请假单状态为对应的approved/refused
    if(process.getIsLast() == 1){
    form.setState(result);//approved|refused
    leaveFormDao.update(form);

    String strResult = null;
    if(result.equals("approved")){
    strResult = "批准";
    }else if (result.equals("refused")){
    strResult = "驳回";
    }
    String noticeContent = String.format("您的请假申请[%s-%s]%s%s已%s,审批意见:%s,审批流程已结束",
    sdf.format(form.getStartTime()) , sdf.format(form.getEndTime()),
    operator.getTitle(),operator.getName(),
    strResult,reason);//发给表单提交人的通知
    noticeDao.insert(new Notice(form.getEmployeeId(),noticeContent));

    noticeContent = String.format("%s-%s提起请假申请[%s-%s]您已%s,审批意见:%s,审批流程已结束" ,
    employee.getTitle() , employee.getName() , sdf.format( form.getStartTime()) , sdf.format(form.getEndTime()),
    strResult , reason);//发给审批人的通知
    noticeDao.insert(new Notice(operator.getEmployeeId(),noticeContent));
    }else{
    //readyList包含所有后续任务节点
    List<ProcessFlow> readyList = flowList.stream().filter(p -> p.getState().equals("ready")).collect(Collectors.toList());
    //3.如果当前任务不是最后一个节点且审批通过,那下一个节点的状态从ready变为process
    if(result.equals("approved")){
    ProcessFlow readyProcess = readyList.get(0);
    readyProcess.setState("process");
    processFlowDao.update(readyProcess);
    //消息1: 通知表单提交人,部门经理已经审批通过,交由上级继续审批
    String noticeContent1 = String.format("您的请假申请[%s-%s]%s%s已批准,审批意见:%s ,请继续等待上级审批" ,
    sdf.format(form.getStartTime()) , sdf.format(form.getEndTime()),
    operator.getTitle() , operator.getName(),reason);
    noticeDao.insert(new Notice(form.getEmployeeId(),noticeContent1));

    //消息2: 通知总经理有新的审批任务
    String noticeContent2 = String.format("%s-%s提起请假申请[%s-%s],请尽快审批" ,
    employee.getTitle() , employee.getName() , sdf.format( form.getStartTime()) , sdf.format(form.getEndTime()));
    noticeDao.insert(new Notice(readyProcess.getOperatorId(),noticeContent2));

    //消息3: 通知部门经理(当前经办人),员工的申请单你已批准,交由上级继续审批
    String noticeContent3 = String.format("%s-%s提起请假申请[%s-%s]您已批准,审批意见:%s,申请转至上级领导继续审批" ,
    employee.getTitle() , employee.getName() , sdf.format( form.getStartTime()) , sdf.format(form.getEndTime()), reason);
    noticeDao.insert(new Notice(operator.getEmployeeId(),noticeContent3));

    }else if(result.equals("refused")) {
    //4.如果当前任务不是最后一个节点且审批驳回,则后续所有任务状态变为cancel,请假单状态变为refused
    for(ProcessFlow p:readyList){
    p.setState("cancel");
    processFlowDao.update(p);
    }
    form.setState("refused");
    leaveFormDao.update(form);
    //消息1: 通知申请人表单已被驳回
    String noticeContent1 = String.format("您的请假申请[%s-%s]%s%s已驳回,审批意见:%s,审批流程已结束" ,
    sdf.format(form.getStartTime()) , sdf.format(form.getEndTime()),
    operator.getTitle() , operator.getName(),reason);
    noticeDao.insert(new Notice(form.getEmployeeId(),noticeContent1));

    //消息2: 通知经办人表单"您已驳回"
    String noticeContent2 = String.format("%s-%s提起请假申请[%s-%s]您已驳回,审批意见:%s,审批流程已结束" ,
    employee.getTitle() , employee.getName() , sdf.format( form.getStartTime()) , sdf.format(form.getEndTime()), reason);
    noticeDao.insert(new Notice(operator.getEmployeeId(),noticeContent2));


    }
    }
    return null;
    });
    }
    }
    2021-02-23 18:51:19
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师