基于springboot+mybatis+jsp简单的报销工作流

一、系统介绍

系统主要功能:
员工:填写报销单
账务审批:报销金额小于1000账务经理审批,报销金额大于1000总经理审批
账务经理审批:同意流程结束
总经理:同意流程结束

二、功能展示

1.填写报销单

在这里插入图片描述

3.账务经理审批

在这里插入图片描述

4.总经理审批

在这里插入图片描述

三、代码展示

package com.example.workflow.controller;

import com.example.workflow.model.Account;
import com.example.workflow.model.Flow;
import com.example.workflow.service.AccountService;
import com.example.workflow.service.FlowService;
import com.example.workflow.service.UserService;
import com.example.workflow.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService uService;
    @Autowired
    private AccountService accountService;

    @Autowired
    private FlowService flowService;
    //进入登录页面(地址:localhost:8080/worlkflow/admin/login)
    @RequestMapping("/login")
    public String login(){

        return "user/login";
    }

    @RequestMapping("/dologin")
    @ResponseBody
    public String dologin(@RequestParam("username") String username, @RequestParam("password")String password, HttpSession session){

        User user = uService.getUser(username,password);

        if(user!=null){
            if(user.getRole().equals("员工")){
                session.setAttribute("userid",user.getUserid());
                session.setAttribute("username",user.getUsername());
                session.setAttribute("role",user.getRole());
                session.setAttribute("realname",user.getRealname());
                return "emp";
            }else{
                session.setAttribute("userid",user.getUserid());
                session.setAttribute("username", user.getUsername());
                session.setAttribute("role", user.getRole());
                session.setAttribute("realname", user.getRealname());
                return "flow";
            }
        }
        return "false";
    }
    //用户登录成功后跳转首页
    @RequestMapping("emp")
    public String toEmp(){
        return "emplist";
    }

    //跳转到主页面
    @RequestMapping("emplist")
    public String getEmpList(Map map,HttpSession session){
        String userid = session.getAttribute("userid").toString();
        List<Account> account = accountService.getAccount(userid);
        map.put("accountList",account);
        return "user/emplist";
    }

    //跳转到添加报销单页面
    @RequestMapping("addAccountUi")
    public String addRepairUi(){

        return "user/addAccount";
    }

    //添加报销单
    @RequestMapping("addAccount")
    @ResponseBody
    public String addAccount(@RequestParam("reason") String reason,@RequestParam("money") String money,HttpSession session) throws ParseException {
        String userid = session.getAttribute("userid").toString();
        String username = session.getAttribute("username").toString();
        Date date=new Date();
        SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dtime=formatter.format(date);

        SimpleDateFormat formatter2=new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String id=formatter2.format(date);
        Account account = new Account();
        account.setId(id);
        account.setReason(reason);
        account.setMoney(money);
        account.setStatus("0");
        account.setUserid(userid);
        account.setUsername(username);
        account.setDtime(dtime);
        account.setRole("账务审批");
        int i = accountService.addAccount(account);
        if(i>0){
            Flow flow = new Flow();
            flow.setAccountid(id);
            flow.setReason(reason);
            flow.setMoney(money);
            flow.setDtime(dtime);
            flow.setUsername(username);
            flow.setStatus("0");
            flow.setRole("账务审批");
            flowService.addFlow(flow);
            return "success";
        }else{
            return "error";
        }
    }

    //跳转到流程页面
    @RequestMapping("flowlist")
    public String getFlow(Map map,HttpSession session){
        String userid = session.getAttribute("userid").toString();
        String role = session.getAttribute("role").toString();
        List<Flow> flow = flowService.getFlow(role);
        map.put("flowList",flow);
        return "user/flowlist";
    }

    //跳转到审批页面
    @RequestMapping("eflow")
    @ResponseBody
    public String eflow(@RequestParam("id") String id,@RequestParam("money") String money
            ,@RequestParam("accountid") String accountid,@RequestParam("agree") String agree,
            @RequestParam("reason") String reason, @RequestParam("dtime") String dtime,HttpSession session){
        String userid = session.getAttribute("userid").toString();
        String username = session.getAttribute("username").toString();
        String role = session.getAttribute("role").toString();
        Date date=new Date();
        SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String etime=formatter.format(date);

        if(role.equals("账务审批")){
            if(agree.equals("1")){
                if(Integer.parseInt(money)<1000){
                    int i=flowService.updateFlow(id,username,userid,etime,"1","同意");
                    if(i>0){
                        int j =accountService.updateAccount(accountid,"账务经理","1","");
                        if(j>0){
                            Flow flow = new Flow();
                            flow.setAccountid(accountid);
                            flow.setReason(reason);
                            flow.setMoney(money);
                            flow.setDtime(dtime);
                            flow.setUsername(username);
                            flow.setStatus("0");
                            flow.setRole("账务经理");
                            flowService.addFlow(flow);
                        }
                    }
                }else{
                    int i=flowService.updateFlow(id,username,userid,etime,"1","同意");
                    if(i>0){
                       int j= accountService.updateAccount(accountid,"总经理","1","");
                        if(j>0){
                            Flow flow = new Flow();
                            flow.setAccountid(accountid);
                            flow.setReason(reason);
                            flow.setMoney(money);
                            flow.setDtime(dtime);
                            flow.setUsername(username);
                            flow.setStatus("0");
                            flow.setRole("总经理");
                            flowService.addFlow(flow);
                        }
                    }
                }

            }else{
                int i=flowService.updateFlow(id,username,userid,etime,"1","不同意");
                if(i>0){
                    accountService.updateAccount(accountid,"","2","不同意");
                }
            }
        }else{
            if(agree.equals("1")){
                int i=flowService.updateFlow(id,username,userid,etime,"1","同意");
                if(i>0){
                    accountService.updateAccount(accountid,"","2","同意");
                }
            }else{
                int i=flowService.updateFlow(id,username,userid,etime,"1","同意");
                if(i>0){
                    accountService.updateAccount(accountid,"","2","不同意");
                }
            }
        }
        List<Flow> flow = flowService.getFlow(role);
        return "user/flowlist";
    }

    //注销
    @RequestMapping("logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "user/login";
    }
}

四、获取源码

点击下载
基于springboot+mybatis+jsp简单的报销工作流

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小码叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值