栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

项目实训—任课老师申请工作流具体实现

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

项目实训—任课老师申请工作流具体实现

任课老师提交申请 后端

首先要根据教师登录的tid来获取教师任教的实验课

xml文件编写

sql查询语句:

id=“”’,方法名

parameterType =“”,对应查询字段(status)的数据类型

resultType=“”,对应的实体文件名


        select *
        from les_info
        where
        tea_id = #{tid} and les_type = "理论课(含实践)" or tea_id = #{tid} and les_type = "集中性实践环节"
    
mapper文件编写
List getCourse(@Param("tid") String tid);
service文件编写
List getCourse(String tid);
serviceImpl文件编写
@Override
    public List getCourse(String tid) {
        return this.baseMapper.getCourse(tid);
    }
controller文件编写

defaultValue=“1”,规定默认参数为1,不需要前端传参
如果需要传参,只需要改为如下:required = true

@RequestMapping(value = "/course",method = RequestMethod.GET)
	 public Result allList(@RequestParam(name="tid",defaultValue="1")String tid){
		 SysUser sysUser = iFlowThirdService.getLoginUser();
		 tid = sysUser.getUsername();
		List allList = excApplyService.getCourse(tid);
		return Result.ok(allList);
	 }
前端

先从后端获取数据:

 getCourse(){
            getAction("/ExcApply/excApply/course",{username:""}).then(res=>{
                if(res.success){
                    this.resultList = res.result;
                    console.log(this.resultList);
                }else{
                    this.$message.error("发送失败")
                }
            })
        },

修改选项信息:

            
              
                {{item.lesName+" "+item.courseclass+" 实验周次:"+item.exWeek+" 实验周学时:"+item.exWeektime}}
              
            
          

使用v-on:click=""设置点击事件,让被选择的数据传入到result1(item)中,然后通过add方法插入到数据库中

 result1(itemN){
            this.model.tid = itemN.teaId;
            this.model.coursename = itemN.lesName;
            this.model.classes = itemN.courseclass;
            this.model.teaName = itemN.teaName;
            this.model.term = itemN.lesSem;
            this.model.testweek = itemN.exWeek;
            this.model.weektime = itemN.exWeektime;
            this.model.courseid = itemN.lesId;
            this.model.courseord = itemN.lesOrd;
        },

点击添加调用add()方法将数据插入表中

add () {

          this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
实验管理员处理申请 不需要实验老师——后端

FlowTaskServiceImpl.java中包含获取待办列表的方法:

    @Override
    public Result todoList(Integer pageNum, Integer pageSize) {
        Page page = new Page<>();
        String username = iFlowThirdService.getLoginUser().getUsername();
        TaskQuery taskQuery = taskService.createTaskQuery()
                .active()
                .includeProcessVariables()
                .taskAssignee(username)
                .orderByTaskCreateTime().desc();
        page.setTotal(taskQuery.count());
        List taskList = taskQuery.listPage((pageNum - 1)*pageSize, pageSize);
        List flowList = new ArrayList<>();
        for (Task task : taskList) {
            FlowTaskDto flowTask = new FlowTaskDto();
            // 当前流程信息
            flowTask.setTaskId(task.getId());
            flowTask.setTaskDefKey(task.getTaskDefinitionKey());
            flowTask.setCreateTime(task.getCreateTime());
            flowTask.setProcDefId(task.getProcessDefinitionId());
            flowTask.setTaskName(task.getName());
            // 流程定义信息
            ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
                    .processDefinitionId(task.getProcessDefinitionId())
                    .singleResult();
            flowTask.setDeployId(pd.getDeploymentId());
            flowTask.setProcDefName(pd.getName());
            flowTask.setProcDefVersion(pd.getVersion());
            flowTask.setProcInsId(task.getProcessInstanceId());

            // 流程发起人信息
            HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
                    .processInstanceId(task.getProcessInstanceId())
                    .singleResult();
            SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId());
            List departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId());
            flowTask.setStartUserId(startUser.getUsername());
            flowTask.setStartUserName(startUser.getRealname());
            flowTask.setStartDeptName(CollUtil.join(departNamesByUsername,","));
            flowList.add(flowTask);
        }

        page.setRecords(flowList);
        return Result.OK(page);
    }

后端url为"/flowable/task/todoList"的接口调用FlowTaskService的todoList()方法

@ApiOperation(value = "获取待办列表", response = FlowTaskDto.class)
    @GetMapping(value = "/todoList")
    public Result todoList(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
                               @ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
        return flowTaskService.todoList(pageNum, pageSize);
    }

若通过此申请需要将任课教师的tid插入到此条数据的实验教师中,因此要写相应的后端

xml


        update exc_apply set testteacher = #{tid}
        where id=#{id}
    

mapper

void setTestTea(@Param("tid") String tid,@Param("id") String id);

service

void setTestTea(String tid,String id)

serviceImpl

@Override
    public void setTestTea(String tid, String id) {
        this.baseMapper.setTestTea(tid, id);
    }

controller

@RequestMapping(value = "/setTestTea",method = RequestMethod.GET)
	 public Result setTestTea(@RequestParam(name = "tid",required = true) String tid,
									  @RequestParam(name = "id",required = true) String id
							){
		System.out.println(tid+id);
		excApplyService.setTestTea(tid,id);
		return Result.OK();
	 } 
需要实验老师——后端 

xml


        update exc_apply set isvisiable = "fasle"
        where id=#{id}
    

mapper

void isVisiable(@Param("id") String id);

service

void isVisiable(String id);

serviceImpl

@Override
    public void isVisiable(String id) {
        this.baseMapper.isVisiable(id);
    }

controller

@RequestMapping(value = "/isVisiable",method = RequestMethod.GET)
	 public Result isVisiable(@RequestParam(name = "id",required = true) String id){
		excApplyService.isVisiable(id);
		return Result.OK();
	 } 
前端 
待办事项 

首先获取工作流中candidateUsers为实验管理员的列表

常规表单操作不再赘述

表单加载时需要获取实验管理员的待办事项:

created() {
            this.getSuperFieldList();
            this.getToDoList();
        }
getToDoList(){
                getAction("/flowable/task/todoList",{pageNum:1,pageSize:10}).then(res=>{
                    if(res.success){
                        this.$message.success("操作成功")
                        this.loadData()
                    }else{
                        this.$message.error("操作失败")
                    }
                })
            }

连接后端"/flowable/task/todoList"接口

其次实验管理员通过申请时需要判断是否需要实验管理员,从而执行不同的操作,要修改ActHandleBtn中的点击事件

若不需要实验管理员,则调用后端"ExcApply/excApply/setTestTea"

若需要实验管理员,则调用后端"ExcApply/excApply/isVisiable"

passTask() {
            if(this.serviceType == this.handleSerType.excApply){
                if((this.recordOne.type == "任课教师") || (this.recordOne.type == "任课教师、助教")){
                    console.log(1111111111+this.recordOne.type)
                    getAction("/ExcApply/excApply/setTestTea",{tid:this.recordOne.tid,zhujiao:this.recordOne.zhujiao,id:this.recordOne.id}).then(res=>{
                        if(res.success){
                            this.loadData()
                        }else{
                            console.log("444444444"+res.toString());
                            this.$message.error("操作失败")
                        }
                    })
                }else if(this.recordOne.type == "任课教师、实验教师"){
                    getAction("/ExcApply/excApply/setTestTea",{tid:this.recordOne.tid,zhujiao:this.recordOne.zhujiao,id:this.recordOne.id}).then(res=>{
                        if(res.success){
                            this.loadData()
                        }else{
                            console.log("444444444"+res.toString());
                            this.$message.error("操作失败")
                        }
                    })
                    getAction("ExcApply/excApply/isVisiable",{id:this.recordOne.id}).then(res=>{
                        if(res.success){
                            this.loadData()
                        }else{
                            this.$message.error("操作失败")
                        }
                    })
                }else if(this.recordOne.type == "实验老师"){
                    getAction("ExcApply/excApply/isVisiable",{id:this.recordOne.id}).then(res=>{
                        if(res.success){
                            this.loadData()
                        }else{
                            this.$message.error("操作失败")
                        }
                    })
                }else{
                    console.log(1111111111+this.recordOne.type)
                    console.log("没进入if");
                }
            }else{
                this.$message,error("excApply错误")
            }
            const v = this;
            this.modalTaskTitle = '审批通过';
            this.modalTaskVisible = true;
        }
已做事项

转载请注明:文章转载自 www.mshxw.com
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号