项目实训——flowable开发(四)

目录

ExcApply:

ExcApplyMapper.xml: 

ExcApplyServiceImpl:

 ExcApplyController:

ExtApply:

ExtApplyMapper.xml:

ExtApplyServiceImpl:


ExcApply:

任课老师申请

ExcApplyMapper.xml: 

<select id="getCourse" resultType="org.jeecg.modules.demo.atupai.entity.LesInfo">
        select *
        from les_info
        where
        tea_id = #{tid} and les_type = "理论课(含实践)" or tea_id = #{tid} and les_type = "集中性实践环节"
    </select>

    <insert id="setTestTea">
        update exc_apply
        set testteacher = #{tid}
        where id=#{id}
    </insert>

    <insert id="setService">
        update exc_apply
        set servicekey = "excApply" , isapply = "是",isvisiable = "否",ischoose = "否"
        where id=#{id}
    </insert>


    <insert id="isVisiable">
        update exc_apply
        set isvisiable = "否",ischoose = "否"
        where id=#{id}
    </insert>

    <select id="getPublishCourse" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply
        where isapply = "是" and isvisiable = "否"
    </select>

    <select id="getPublishDoneCourse" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply
        where isapply = "是" and isvisiable = "是"
    </select>

    <update id="sendPublishCourse">
        update exc_apply
        set isvisiable = "是"
        where isvisiable = "否"
    </update>

    <select id="getAllPublish" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply
        where needextea = "是" and isvisiable = "是"
    </select>



    <select id="getExcApply" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply
        where servicekey = "excApply" and act_status = "审批通过"
    </select>

    <select id="getMyList" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply a left join flow_my_business b on a.id =b.data_id
        where (a.tid = #{tid} and b.act_status != "审批通过" and a.isapply = "是") or (a.isapply = "否" and a.tid = #{tid})
    </select>



    <select id="getThisCourse" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply
        where courseid = #{courseid} and courseord = #{courseord}
    </select>

    <update id="cancelApply">
        update exc_apply set isapply = "否"
        where id = #{id}
    </update>



    <select id="getDataId" resultType="java.lang.String">
        select data_id
        from flow_my_business
        where task_id = #{id}
    </select>

根据名称可基本了解到这些sql语句的含义

ExcApplyServiceImpl:

其他操作不再赘述

/**
     * 初始生成业务与流程的关联信息<br/>
     * 当业务模块新增一条数据后调用,此时业务数据关联一个流程定义,以备后续流程使用
     * @return 是否成功
     * @param title 必填。流程业务简要描述。例:2021年11月26日xxxxx申请
     * @param dataId 必填。业务数据Id,如果是一对多业务关系,传入主表的数据Id
     * @param serviceImplName 必填。业务service注入spring容器的名称。
     *                        例如:@Service("demoService")则传入 demoService
     * @param processDefinitionKey 必填。流程定义Key,传入此值,未来启动的会是该类流程的最新一个版本
     * @param processDefinitionId 选填。流程定义Id,传入此值,未来启动的为指定版本的流程
     */
    public void initActBusiness(String title, String dataId, String serviceImplName, String processDefinitionKey, String processDefinitionId){
        flowCommonService.initActBusiness(title,dataId,"excApplyService","ExcApply","process_f2z7yyub:4:f300fdbb-e6ff-11ec-8471-98fa9b690463");
    }


 //关联流程
    @Override
    public void relationAct(String dataId) {
        flowCommonService.initActBusiness("实验授课申请:dataId"+dataId,dataId,"excApplyService","ExcApply","process_f2z7yyub:4:f300fdbb-e6ff-11ec-8471-98fa9b690463");
    }
 
//寻找候选人candidateUser
    @Override
    public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
        //修改候选人
        if(values.get("candidateUsers") == null){
            return Lists.newArrayList("teaAdmin");
        }else{
            String user = (String) values.get("candidateUsers");
            return Lists.newArrayList(user);
        }
    }
    @Override
    public boolean save(ExcApply excApply){
        /**新增数据,初始化流程关联信息**/
        excApply.setId(IdUtil.fastSimpleUUID());
        this.relationAct(excApply.getId());
        return super.save(excApply);
    }

    @Override
    public boolean removeById(Serializable id){
        /**删除数据,移除流程关联信息**/
        flowCommonService.delActBusiness(id.toString());
        return super.removeById(id);
    }

 ExcApplyController:

 简单操作不再赘述:

//健壮性保证,不重复添加
/**
	 *   添加
	 *
	 * @param excApply
	 * @return
	 */
	@AutoLog(value = "任课老师申请-添加")
	@ApiOperation(value="任课老师申请-添加", notes="任课老师申请-添加")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody ExcApply excApply) {
		List<ExcApply> list = excApplyService.getThisCourse(excApply.getCourseid(),excApply.getCourseord());
		//若数据库中没有此条数据
		if(list.size() == 0){
			//若此条数据有冲突
			if((excApply.getNeedextea().equals("是")  && excApply.getType().equals("任课教师") )||(excApply.getNeedextea().equals("是")  && excApply.getType().equals("任课教师、助教"))||(excApply.getNeedextea().equals("否") && excApply.getType().equals("实验教师"))||(excApply.getNeedextea().equals("否") && excApply.getType().equals("任课教师、实验教师"))){
				return Result.error("'授课方式'和'是否需要实验老师'有冲突!");
			}else if((excApply.getType().equals("任课教师、助教")  && excApply.getZhujiao() == null)||(!excApply.getType().equals("任课教师、助教")  && excApply.getZhujiao() != null)){
				return Result.error("'授课方式'和'助教id'有冲突!");
			}else{
				excApplyService.save(excApply);
				return Result.OK("添加成功!");
			}
		}else{
			ExcApply excApply1 = list.get(0);
			//若数据库中有此条数据,返回错误信息
			if(excApply1.getIsapply()=="否"){
				//此条申请已经被撤回
				excApplyService.save(excApply);
				return Result.OK("添加成功!");
			}else{
				//此条申请未被撤回
				return  Result.error("此课程已申请,不可重复申请!");
			}

		}

	}

ExtApply:

实验老师申请实验课

ExtApplyMapper.xml:

<select id="selectAll"  resultType="org.jeecg.modules.demo.Excourse.entity.ExtApply">
        SELECT *
        FROM ext_apply
    </select>

    <select id="getMyList" resultType="org.jeecg.modules.demo.Excourse.entity.ExtApply">
        select *
        from ext_apply a left join flow_my_business b on a.id =b.data_id
        where (a.extid = #{extid} and b.act_status != "审批通过" and a.ischoose = "是") or (a.ischoose = "否" and a.extid = #{extid})
    </select>

    <update id="setChoose" >
        update ext_apply set ischoose = "是", serviceKey = "extApply"
        where id = #{id}
    </update>

    <update id="cancelApply">
        update ext_apply set ischoose = "否"
        where id = #{id}
    </update>

    <select id="getExtApply" resultType="org.jeecg.modules.demo.Excourse.entity.ExtApply">
        select *
        from ext_apply
        where servicekey = "extApply"
    </select>

    <update id="setTestteacher">
        update ext_apply set testteacher = #{testteacher}
        where id = #{id}
    </update>

    <select id="getExcApply" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply
        where id = #{id}
    </select>

    <select id="getOwnExClass" resultType="org.jeecg.modules.demo.Excourse.entity.ExcApply">
        select *
        from exc_apply a left join flow_my_business b on a.id =b.data_id
        where a.needextea = "否" and a.isvisiable = "是" and a.tid = #{tid} and b.act_status ="审批通过"
    </select>

    <select id="getOwnExtClass" resultType="org.jeecg.modules.demo.Excourse.entity.ExtApply">
        select *
        from ext_apply a left join flow_my_business b on a.id =b.data_id
        where a.tid=#{tid} and a.courseid = #{courseid} and a.courseord = #{courseord} and a.needextea = "否" and b.act_status != "审批通过"
    </select>

    <select id="getOnlyOne" resultType="org.jeecg.modules.demo.Excourse.entity.ExtApply">
        select *
        from ext_apply
        where courseid = #{courseid} and courseord = #{courseord}
    </select>

ExtApplyServiceImpl:

/**
     * 初始生成业务与流程的关联信息<br/>
     * 当业务模块新增一条数据后调用,此时业务数据关联一个流程定义,以备后续流程使用
     * @return 是否成功
     * @param title 必填。流程业务简要描述。例:2021年11月26日xxxxx申请
     * @param dataId 必填。业务数据Id,如果是一对多业务关系,传入主表的数据Id
     * @param serviceImplName 必填。业务service注入spring容器的名称。
     *                        例如:@Service("demoService")则传入 demoService
     * @param processDefinitionKey 必填。流程定义Key,传入此值,未来启动的会是该类流程的最新一个版本
     * @param processDefinitionId 选填。流程定义Id,传入此值,未来启动的为指定版本的流程
     */
    public void initActBusiness(String title, String dataId, String serviceImplName, String processDefinitionKey, String processDefinitionId){
        flowCommonService.initActBusiness(title,dataId,"extApplyService","ExtApply","process_fwfz99zv:4:9ba40807-e6ff-11ec-8471-98fa9b690463");
    }

    //关联流程
    @Override
    public void relationAct(String dataId) {
        flowCommonService.initActBusiness("申请实验课:dataId"+dataId,dataId,"extApplyService","ExtApply","process_fwfz99zv:4:9ba40807-e6ff-11ec-8471-98fa9b690463");
    }

     @Override
    public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
        //修改候选人
        if(values.get("candidateUsers") == null){
            return Lists.newArrayList("teaAdmin");
        }else{
            String user = (String) values.get("candidateUsers");
            return Lists.newArrayList(user);
        }
    }

    @Override
    public boolean save(ExtApply extApply){
        /**新增数据,初始化流程关联信息**/
        extApply.setId(IdUtil.fastSimpleUUID());
        this.relationAct(extApply.getId());
        return super.save(extApply);
    }

    @Override
    public boolean removeById(Serializable id){
        /**删除数据,移除流程关联信息**/
        flowCommonService.delActBusiness(id.toString());
        return super.removeById(id);
    }

 ExtApplyController:

@AutoLog(value = "关联流程")
	 @ApiOperation(value="关联流程", notes="关联流程")
	 @RequestMapping(value = "/relationAct",method = RequestMethod.GET)
	 public Result<?> relationAct(HttpServletRequest request,HttpServletResponse response){
		 String dataId = request.getParameter("dataId");
		 extApplyService.relationAct(dataId);
		 return Result.OK();
	 }

     //任课老师授课实验课,需要先将其插入ext_apply中
     @RequestMapping(value = "/insertTeaExtApply",method = RequestMethod.GET)
	 public Result<Object> insertTeaExtApply(@RequestParam(name = "id",required = true) String id){
		ExtApply extApply = new ExtApply();
		ExcApply excApply = extApplyService.getExcApply(id);
		extApply.setTid(excApply.getTid());
		extApply.setTeaName(excApply.getTeaName());
		extApply.setCoursename(excApply.getCoursename());
		extApply.setClasses(excApply.getClasses());
		extApply.setType(excApply.getType());
		extApply.setZhujiao(excApply.getZhujiao());
		extApply.setTerm(excApply.getTerm());
		extApply.setNeedextea(excApply.getNeedextea());
		extApply.setTestteacher(excApply.getTid());
		extApply.setTestweek(excApply.getTestweek());
		extApply.setWeektime(String.valueOf(excApply.getWeektime()));
		extApply.setCourseid(excApply.getCourseid());
		extApply.setCourseord(excApply.getCourseord());
		extApply.setServicekey("extApply");
		 System.out.println(excApply);
		System.out.println(extApply);
		 extApplyService.save(extApply);
		 return Result.OK();
	 }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值