智慧保安后台管理-外网项目备份
zhongrj
2022-08-24 9aed2297ee3f1bf1ffd14c139f5c77e3f36e16cb
请假流程恢复
2 files renamed
1 files modified
2 files added
9 files deleted
656 ■■■■ changed files
src/main/java/org/springblade/flow/demo/leave/controller/LeaveController.java 65 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/controller/LeaveTestController.java 65 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.xml 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/service/ILeaveService.java 74 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/service/impl/LeaveServiceImpl.java 79 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/service/impl/LeaveTestServiceImpl.java 79 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/controller/LeaveController.java 91 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/entity/Leave.java 84 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/mapper/LeaveMapper.java 28 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/mapper/LeaveMapper.xml 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/service/LeaveService.java 27 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/service/impl/LeaveServiceImpl.java 31 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/leave/vo/LeaveVO.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/flow/demo/leave/controller/LeaveController.java
New file
@@ -0,0 +1,65 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.flow.demo.leave.controller;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.UserCache;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.flow.demo.leave.entity.ProcessLeave;
import org.springblade.flow.demo.leave.service.ILeaveService;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
/**
 * 控制器
 *
 * @author Chill
 */
@NonDS
@ApiIgnore
@RestController
@RequestMapping(AppConstant.APPLICATION_DESK_NAME + "/process/leave")
@AllArgsConstructor
public class LeaveController {
    private final ILeaveService leaveService;
    /**
     * 详情
     *
     * @param businessId 主键
     */
    @GetMapping("detail")
    public R<ProcessLeave> detail(Long businessId) {
        ProcessLeave detail = leaveService.getById(businessId);
        detail.getFlow().setAssigneeName(UserCache.getUser(detail.getCreateUser()).getName());
        return R.data(detail);
    }
    /**
     * 新增或修改
     *
     * @param leave 请假信息
     */
    @PostMapping("start-process")
    public R startProcess(@RequestBody ProcessLeave leave) {
        return R.status(leaveService.startProcess(leave));
    }
}
src/main/java/org/springblade/flow/demo/leave/controller/LeaveTestController.java
File was deleted
src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.java
File was renamed from src/main/java/org/springblade/flow/demo/leave/mapper/LeaveTestMapper.java
@@ -24,6 +24,6 @@
 *
 * @author Chill
 */
public interface LeaveTestMapper extends BaseMapper<ProcessLeave> {
public interface LeaveMapper extends BaseMapper<ProcessLeave> {
}
src/main/java/org/springblade/flow/demo/leave/mapper/LeaveMapper.xml
File was renamed from src/main/java/org/springblade/flow/demo/leave/mapper/LeaveTestMapper.xml
@@ -1,6 +1,6 @@
<?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="org.springblade.flow.demo.leave.mapper.LeaveTestMapper">
<mapper namespace="org.springblade.flow.demo.leave.mapper.LeaveMapper">
</mapper>
src/main/java/org/springblade/flow/demo/leave/service/ILeaveService.java
@@ -1,37 +1,37 @@
///*
// *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
// *
// *  Redistribution and use in source and binary forms, with or without
// *  modification, are permitted provided that the following conditions are met:
// *
// *  Redistributions of source code must retain the above copyright notice,
// *  this list of conditions and the following disclaimer.
// *  Redistributions in binary form must reproduce the above copyright
// *  notice, this list of conditions and the following disclaimer in the
// *  documentation and/or other materials provided with the distribution.
// *  Neither the name of the dreamlu.net developer nor the names of its
// *  contributors may be used to endorse or promote products derived from
// *  this software without specific prior written permission.
// *  Author: Chill 庄骞 (smallchill@163.com)
// */
//package org.springblade.flow.demo.leave.service;
//
//import org.springblade.core.mp.base.BaseService;
//import org.springblade.flow.demo.leave.entity.ProcessLeave;
//
///**
// * 服务类
// *
// * @author Chill
// */
//public interface ILeaveService extends BaseService<ProcessLeave> {
//
//    /**
//     * 开启流程
//     *
//     * @param leave 请假实体
//     * @return boolean
//     */
//    boolean startProcess(ProcessLeave leave);
//
//}
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.flow.demo.leave.service;
import org.springblade.core.mp.base.BaseService;
import org.springblade.flow.demo.leave.entity.ProcessLeave;
/**
 * 服务类
 *
 * @author Chill
 */
public interface ILeaveService extends BaseService<ProcessLeave> {
    /**
     * 开启流程
     *
     * @param leave 请假实体
     * @return boolean
     */
    boolean startProcess(ProcessLeave leave);
}
src/main/java/org/springblade/flow/demo/leave/service/impl/LeaveServiceImpl.java
New file
@@ -0,0 +1,79 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.flow.demo.leave.service.impl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.flow.business.service.IFlowService;
import org.springblade.flow.core.constant.ProcessConstant;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.utils.FlowUtil;
import org.springblade.flow.core.utils.TaskUtil;
import org.springblade.flow.demo.leave.entity.ProcessLeave;
import org.springblade.flow.demo.leave.mapper.LeaveMapper;
import org.springblade.flow.demo.leave.service.ILeaveService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * 服务实现类
 *
 * @author Chill
 */
@Slf4j
@Service
@AllArgsConstructor
public class LeaveServiceImpl extends BaseServiceImpl<LeaveMapper, ProcessLeave> implements ILeaveService {
    private final IFlowService flowService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean startProcess(ProcessLeave leave) {
        String businessTable = FlowUtil.getBusinessTable(ProcessConstant.LEAVE_KEY);
        if (Func.isEmpty(leave.getId())) {
            // 保存leave
            leave.setApplyTime(DateUtil.now());
            save(leave);
            // 启动流程
            Kv variables = Kv.create()
                .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserName())
                .set("taskUser", TaskUtil.getTaskUser(leave.getTaskUser()))
                .set("days", DateUtil.between(leave.getStartTime(), leave.getEndTime()).toDays());
            BladeFlow flow = flowService.startProcessInstanceById(leave.getProcessDefinitionId(), FlowUtil.getBusinessKey(businessTable, String.valueOf(leave.getId())), variables);
            if (Func.isNotEmpty(flow)) {
                log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId());
                // 返回流程id写入leave
                leave.setProcessInstanceId(flow.getProcessInstanceId());
                updateById(leave);
            } else {
                throw new ServiceException("开启流程失败");
            }
        } else {
            updateById(leave);
        }
        return true;
    }
}
src/main/java/org/springblade/flow/demo/leave/service/impl/LeaveTestServiceImpl.java
File was deleted
src/main/java/org/springblade/modules/leave/controller/LeaveController.java
File was deleted
src/main/java/org/springblade/modules/leave/entity/Leave.java
File was deleted
src/main/java/org/springblade/modules/leave/mapper/LeaveMapper.java
File was deleted
src/main/java/org/springblade/modules/leave/mapper/LeaveMapper.xml
File was deleted
src/main/java/org/springblade/modules/leave/service/LeaveService.java
File was deleted
src/main/java/org/springblade/modules/leave/service/impl/LeaveServiceImpl.java
File was deleted
src/main/java/org/springblade/modules/leave/vo/LeaveVO.java
File was deleted