
11 changed files with 767 additions and 1 deletions
@ -0,0 +1,43 @@ |
|||
package com.yxt.supervise.enterprisecentre.api.paymentapply; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Data |
|||
public class PaymentApplyDetailsVo { |
|||
|
|||
private String sid; |
|||
private String userSid; |
|||
@ApiModelProperty("创建人名称") |
|||
private String createByName; |
|||
@ApiModelProperty("项目名称") |
|||
private String projectName; |
|||
@ApiModelProperty("项目sid") |
|||
private String projectSid; |
|||
@ApiModelProperty("用款企业") |
|||
private String enterpriseName; |
|||
@ApiModelProperty("用款企业sid") |
|||
private String enterpriseSid; |
|||
@ApiModelProperty("用款申请用途") |
|||
private String applyUse; |
|||
@ApiModelProperty("用款金额") |
|||
private String money; |
|||
@ApiModelProperty("回款凭证") |
|||
private List<String> voucherUrlList; |
|||
@ApiModelProperty("实例id") |
|||
private String procInstId; |
|||
@ApiModelProperty("任务id") |
|||
private String taskId; |
|||
@ApiModelProperty("申请日期") |
|||
private String createTime; |
|||
@JsonIgnore |
|||
private String voucherUrl; |
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.yxt.supervise.enterprisecentre.api.paymentapply; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Data |
|||
public class PaymentApplyDto { |
|||
|
|||
private String sid; |
|||
@ApiModelProperty("用户sid") |
|||
private String userSid; |
|||
@ApiModelProperty("创建人名称") |
|||
private String createByName; |
|||
@ApiModelProperty("项目名称") |
|||
private String projectName; |
|||
@ApiModelProperty("项目sid") |
|||
private String projectSid; |
|||
@ApiModelProperty("用款企业") |
|||
private String enterpriseName; |
|||
@ApiModelProperty("用款企业sid") |
|||
private String enterpriseSid; |
|||
@ApiModelProperty("用款申请用途") |
|||
private String applyUse; |
|||
@ApiModelProperty("用款金额") |
|||
private String money; |
|||
@ApiModelProperty("回款凭证") |
|||
private List<String> voucherUrlList; |
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.yxt.supervise.enterprisecentre.api.paymentapply; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Data |
|||
public class PaymentApplyQuery implements Query { |
|||
private static final long serialVersionUID = -9175414060598978982L; |
|||
|
|||
@ApiModelProperty("项目名称") |
|||
private String projectName; |
|||
@ApiModelProperty("企业名称") |
|||
private String enterpriseName; |
|||
@ApiModelProperty("创建时间开始") |
|||
private String createTimeStart; |
|||
@ApiModelProperty("创建时间结束") |
|||
private String createTimeEnd; |
|||
@ApiModelProperty("用户sid") |
|||
private String userSid; |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.yxt.supervise.enterprisecentre.api.paymentapply; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Data |
|||
public class PaymentApplyVo { |
|||
|
|||
|
|||
private String sid; |
|||
@ApiModelProperty("流程状态") |
|||
private String nodeState; |
|||
@ApiModelProperty("申请人") |
|||
private String createByName; |
|||
|
|||
@ApiModelProperty("项目名称") |
|||
private String projectName; |
|||
|
|||
@ApiModelProperty("企业名称") |
|||
private String enterpriseName; |
|||
|
|||
@ApiModelProperty("用款用途") |
|||
private String applyUse; |
|||
|
|||
@ApiModelProperty("创建时间") |
|||
private String createTime; |
|||
|
|||
@ApiModelProperty("用款金额") |
|||
private String money; |
|||
} |
@ -0,0 +1,43 @@ |
|||
package com.yxt.supervise.enterprisecentre.api.paymentapply.flowable; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Data |
|||
public class PaymentApplyTaskQuery { |
|||
|
|||
/** |
|||
* 终止、驳回、撤回 |
|||
*/ |
|||
@ApiModelProperty("任务Id") |
|||
@NotBlank(message = "参数错误:taskId") |
|||
private String taskId; |
|||
/** |
|||
* 终止、驳回、撤回 |
|||
*/ |
|||
@ApiModelProperty("业务sid") |
|||
@NotBlank(message = "参数错误:businessSid") |
|||
private String businessSid; |
|||
/** |
|||
* 终止、驳回 |
|||
*/ |
|||
@ApiModelProperty("任务意见") |
|||
private String comment; |
|||
/** |
|||
* 终止、撤回、驳回 |
|||
*/ |
|||
@ApiModelProperty("用户Sid") |
|||
private String userSid; |
|||
/** |
|||
* 终止 |
|||
*/ |
|||
@ApiModelProperty("流程实例Id") |
|||
private String instanceId; |
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.yxt.supervise.enterprisecentre.api.paymentapply.flowable; |
|||
|
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.PaymentApplyDto; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Data |
|||
public class SubmitPaymentApplyDto extends PaymentApplyDto { |
|||
|
|||
@ApiModelProperty("流程实例id") |
|||
private String instanceId; |
|||
@ApiModelProperty("任务id") |
|||
private String taskId; |
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.yxt.supervise.enterprisecentre.biz.paymentapply; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.PaymentApply; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.PaymentApplyDetailsVo; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.PaymentApplyVo; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Mapper |
|||
public interface PaymentApplyMappper extends BaseMapper<PaymentApply> { |
|||
IPage<PaymentApplyVo> selectPageVo(IPage<PaymentApply> page, @Param(Constants.WRAPPER)QueryWrapper<PaymentApply> qw); |
|||
|
|||
PaymentApplyDetailsVo details(String sid); |
|||
|
|||
int selectBySid(String join); |
|||
|
|||
int updateFlowFiled(Map<String, Object> map); |
|||
} |
@ -0,0 +1,60 @@ |
|||
<?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.yxt.supervise.enterprisecentre.biz.paymentapply.PaymentApplyMappper"> |
|||
<select id="selectPageVo" resultType="com.yxt.supervise.enterprisecentre.api.paymentapply.PaymentApplyVo"> |
|||
select sid, |
|||
enterpriseName, |
|||
projectName, |
|||
createByName, |
|||
applyUse, |
|||
money, |
|||
DATE_FORMAT(createTime, '%Y-%m-%d') as createTime, |
|||
if(length(nodeState) > 0, nodeState, '待提交') as nodeState |
|||
from payment_apply |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
order by id desc |
|||
</select> |
|||
|
|||
<select id="details" resultType="com.yxt.supervise.enterprisecentre.api.paymentapply.PaymentApplyDetailsVo"> |
|||
select sid, |
|||
createBySid as userSid, |
|||
projectName, |
|||
projectSid, |
|||
enterpriseName, |
|||
enterpriseSid, |
|||
procInstId, |
|||
taskId, |
|||
createByName, |
|||
applyUse, |
|||
money, |
|||
voucherUrl, |
|||
DATE_FORMAT(createTime, '%Y-%m-%d') as createTime |
|||
from payment_apply |
|||
where sid = #{sid} |
|||
</select> |
|||
|
|||
<select id="selectBySid" resultType="int"> |
|||
select count(*) |
|||
from payment_apply |
|||
where length(nodeState) > 0 |
|||
and find_in_set(sid, #{list}) |
|||
</select> |
|||
|
|||
<update id="updateFlowFiled"> |
|||
UPDATE payment_apply |
|||
SET nodeState=#{nodeState} |
|||
, taskDefKey=#{taskDefKey} |
|||
<if test="procDefId != null and procDefId != ''"> |
|||
, procDefId=#{procDefId} |
|||
</if> |
|||
<if test="procInsId != null and procInsId != ''"> |
|||
, procInstId=#{procInsId} |
|||
</if> |
|||
<if test="taskId != null and taskId != ''"> |
|||
, taskId=#{taskId} |
|||
</if> |
|||
WHERE sid = #{sid} |
|||
</update> |
|||
</mapper> |
@ -0,0 +1,104 @@ |
|||
package com.yxt.supervise.enterprisecentre.biz.paymentapply; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.enterprisecentre.api.flowable.BusinessVariables; |
|||
import com.yxt.supervise.enterprisecentre.api.flowable.GetNodeQuery; |
|||
import com.yxt.supervise.enterprisecentre.api.flowable.GetNodeVo; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.*; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.flowable.CompletePaymentApplyDto; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.flowable.PaymentApplyTaskQuery; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.flowable.SubmitPaymentApplyDto; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.cloud.openfeign.SpringQueryMap; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@RestController |
|||
@RequestMapping("v1/PaymentApply") |
|||
public class PaymentApplyRest { |
|||
|
|||
@Autowired |
|||
private PaymentApplyService paymentApplyService; |
|||
|
|||
@ApiOperation("新增或修改") |
|||
@PostMapping("/saveorUpdate") |
|||
ResultBean<String> saveorUpdate(@RequestBody PaymentApplyDto dto) { |
|||
return paymentApplyService.saveorUpdatePayment(dto); |
|||
} |
|||
|
|||
@ApiOperation("分页列表") |
|||
@PostMapping("/listPage") |
|||
ResultBean<PagerVo<PaymentApplyVo>> listPage(@RequestBody PagerQuery<PaymentApplyQuery> pagerQuery) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PagerVo<PaymentApplyVo> pv = paymentApplyService.listPageVo(pagerQuery); |
|||
return rb.success().setData(pv); |
|||
} |
|||
|
|||
@ApiOperation("详情") |
|||
@GetMapping("/details") |
|||
ResultBean<PaymentApplyDetailsVo> details(@RequestParam("sid") String sid) { |
|||
return paymentApplyService.details(sid); |
|||
} |
|||
|
|||
@ApiOperation("删除") |
|||
@DeleteMapping("/delete") |
|||
ResultBean delete(@RequestBody String[] sids) { |
|||
return paymentApplyService.delete(sids); |
|||
} |
|||
|
|||
@ApiOperation("提交") |
|||
@PostMapping("/submit") |
|||
ResultBean submit(@RequestBody SubmitPaymentApplyDto dto) { |
|||
return paymentApplyService.submit(dto); |
|||
} |
|||
|
|||
@ApiOperation("办理") |
|||
@PostMapping("/complete") |
|||
ResultBean complete(@RequestBody CompletePaymentApplyDto dto) { |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
BeanUtil.copyProperties(dto, bv); |
|||
return paymentApplyService.complete(bv); |
|||
} |
|||
|
|||
@ApiOperation("获取上一环节") |
|||
@GetMapping(value = "/getPreviousNodesForReject") |
|||
ResultBean<List<GetNodeVo>> getPreviousNodesForReject(@SpringQueryMap GetNodeQuery query) { |
|||
return paymentApplyService.getPreviousNodesForReject(query); |
|||
} |
|||
|
|||
@ApiOperation("获取下一环节") |
|||
@GetMapping(value = "/getNextNodesForSubmit") |
|||
ResultBean<List<GetNodeVo>> getNextNodesForSubmit(@SpringQueryMap GetNodeQuery query) { |
|||
return paymentApplyService.getNextNodesForSubmit(query); |
|||
} |
|||
|
|||
@ApiOperation("驳回") |
|||
@PostMapping(value = "/taskReject") |
|||
public ResultBean taskReject(PaymentApplyTaskQuery query) { |
|||
return paymentApplyService.taskReject(query); |
|||
} |
|||
|
|||
@ApiOperation("撤回") |
|||
@PostMapping(value = "/revokeProcess") |
|||
public ResultBean revokeProcess(PaymentApplyTaskQuery query) { |
|||
return paymentApplyService.revokeProcess(query); |
|||
} |
|||
|
|||
@ApiOperation("终止") |
|||
@PostMapping(value = "/breakProcess") |
|||
public ResultBean breakProcess(PaymentApplyTaskQuery query) { |
|||
return paymentApplyService.breakProcess(query); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,367 @@ |
|||
package com.yxt.supervise.enterprisecentre.biz.paymentapply; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.yxt.common.base.config.component.FileUploadComponent; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import com.yxt.supervise.enterprisecentre.api.flowable.*; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.*; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.flowable.PaymentApplyTaskQuery; |
|||
import com.yxt.supervise.enterprisecentre.api.paymentapply.flowable.SubmitPaymentApplyDto; |
|||
import com.yxt.supervise.enterprisecentre.api.sealrecord.SysUserVo; |
|||
import com.yxt.supervise.enterprisecentre.biz.feign.FlowTaskFeign; |
|||
import com.yxt.supervise.enterprisecentre.biz.feign.FlowableFeign; |
|||
import com.yxt.supervise.enterprisecentre.biz.feign.SysUserFeign; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: dimengzhe |
|||
* @date: 2023/11/22 |
|||
**/ |
|||
@Service |
|||
public class PaymentApplyService extends MybatisBaseService<PaymentApplyMappper, PaymentApply> { |
|||
|
|||
@Autowired |
|||
private SysUserFeign sysUserFeign; |
|||
@Autowired |
|||
private FileUploadComponent fileUploadComponent; |
|||
@Autowired |
|||
private FlowableFeign flowableFeign; |
|||
@Autowired |
|||
private FlowTaskFeign flowTaskFeign; |
|||
|
|||
public ResultBean<String> saveorUpdatePayment(PaymentApplyDto dto) { |
|||
ResultBean<String> rb = ResultBean.fireFail(); |
|||
String sid = dto.getSid(); |
|||
if (StringUtils.isBlank(sid)) {//新增
|
|||
PaymentApply paymentApply = new PaymentApply(); |
|||
BeanUtil.copyProperties(dto, paymentApply, "sid"); |
|||
String userSid = dto.getUserSid(); |
|||
paymentApply.setCreateBySid(userSid); |
|||
//根据userSid查询申请人的名称
|
|||
ResultBean<SysUserVo> resultBean = sysUserFeign.getUserByUserSid(userSid); |
|||
if (resultBean.getData() != null) { |
|||
SysUserVo sysUserVo = resultBean.getData(); |
|||
String name = sysUserVo.getName(); |
|||
paymentApply.setCreateByName(name); |
|||
} |
|||
List<String> voucherUrlList = dto.getVoucherUrlList(); |
|||
voucherUrlList.removeAll(Collections.singleton(null)); |
|||
if (!voucherUrlList.isEmpty()) { |
|||
String voucherUrl = String.join(",", voucherUrlList).replaceAll(fileUploadComponent.getUrlPrefix(), ""); |
|||
paymentApply.setVoucherUrl(voucherUrl); |
|||
} |
|||
baseMapper.insert(paymentApply); |
|||
sid = paymentApply.getSid(); |
|||
|
|||
} else {//修改
|
|||
PaymentApply paymentApply = fetchBySid(sid); |
|||
if (paymentApply == null) { |
|||
return rb.setMsg("该用款申请不存在"); |
|||
} |
|||
BeanUtil.copyProperties(dto, paymentApply, "sid"); |
|||
List<String> voucherUrlList = dto.getVoucherUrlList(); |
|||
voucherUrlList.removeAll(Collections.singleton(null)); |
|||
if (!voucherUrlList.isEmpty()) { |
|||
String voucherUrl = String.join(",", voucherUrlList).replaceAll(fileUploadComponent.getUrlPrefix(), ""); |
|||
paymentApply.setVoucherUrl(voucherUrl); |
|||
} |
|||
baseMapper.updateById(paymentApply); |
|||
} |
|||
return rb.success().setData(sid); |
|||
} |
|||
|
|||
public PagerVo<PaymentApplyVo> listPageVo(PagerQuery<PaymentApplyQuery> pagerQuery) { |
|||
PaymentApplyQuery query = pagerQuery.getParams(); |
|||
QueryWrapper<PaymentApply> qw = new QueryWrapper<>(); |
|||
if (query != null) { |
|||
qw.eq("createBySid", query.getUserSid()); |
|||
//企业名称
|
|||
if (StringUtils.isNotBlank(query.getEnterpriseName())) { |
|||
qw.like("enterpriseName", query.getEnterpriseName()); |
|||
} |
|||
//项目名称
|
|||
if (StringUtils.isNotBlank(query.getProjectName())) { |
|||
qw.like("projectName", query.getProjectName()); |
|||
} |
|||
//创建时间开始、创建时间结束
|
|||
qw.apply(StringUtils.isNotBlank(query.getCreateTimeStart()), "date_format (createTime,'%Y-%m-%d') >= date_format('" + query.getCreateTimeStart() + "','%Y-%m-%d')"). |
|||
apply(StringUtils.isNotBlank(query.getCreateTimeEnd()), "date_format (createTime,'%Y-%m-%d') <= date_format('" + query.getCreateTimeEnd() + "','%Y-%m-%d')" |
|||
); |
|||
} |
|||
IPage<PaymentApply> page = PagerUtil.queryToPage(pagerQuery); |
|||
IPage<PaymentApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|||
PagerVo<PaymentApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
|
|||
public ResultBean<PaymentApplyDetailsVo> details(String sid) { |
|||
ResultBean<PaymentApplyDetailsVo> rb = ResultBean.fireFail(); |
|||
PaymentApply paymentApply = fetchBySid(sid); |
|||
if (paymentApply == null) { |
|||
return rb.setMsg("该用款申请不存在"); |
|||
} |
|||
PaymentApplyDetailsVo paymentApplyDetailsVo = baseMapper.details(sid); |
|||
String voucherUrl = paymentApplyDetailsVo.getVoucherUrl(); |
|||
if (StringUtils.isNotBlank(voucherUrl)) { |
|||
List<String> voucherUrlList = Arrays.asList(voucherUrl.split(",")).stream().map(c -> fileUploadComponent.getUrlPrefix() + c).collect(Collectors.toList()); |
|||
voucherUrlList.removeAll(Collections.singleton(null)); |
|||
if (!voucherUrlList.isEmpty()) { |
|||
paymentApplyDetailsVo.setVoucherUrlList(voucherUrlList); |
|||
} |
|||
} |
|||
return rb.success().setData(paymentApplyDetailsVo); |
|||
} |
|||
|
|||
public ResultBean delete(String[] sids) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
//查询该sid中是否有流程不是待提交的
|
|||
int count = baseMapper.selectBySid(StringUtils.join(sids, ",")); |
|||
if (count > 0) { |
|||
return rb.setMsg("删除的数据中包含已经提交审批的数据,删除失败"); |
|||
} |
|||
delBySids(sids); |
|||
return rb.success(); |
|||
} |
|||
|
|||
public ResultBean submit(SubmitPaymentApplyDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PaymentApply paymentApply = fetchBySid(dto.getSid()); |
|||
int r = submitBusinessData(dto, paymentApply); |
|||
if (r == 3) { |
|||
return rb.setMsg("该申请不存在"); |
|||
} |
|||
if (r == 0) { |
|||
return rb.setMsg("操作失败!提交的数据不一致"); |
|||
} |
|||
ResultBean<String> resultBean = saveorUpdatePayment(dto); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
String businessSid = resultBean.getData(); |
|||
//创建BusinessVariables实体对象
|
|||
BusinessVariables bv = new BusinessVariables(); |
|||
//业务sid
|
|||
bv.setBusinessSid(businessSid); |
|||
//用户sid
|
|||
bv.setUserSid(dto.getUserSid()); |
|||
bv.setProjectSid(dto.getProjectSid()); |
|||
if (r == 1) { |
|||
bv.setModelId(ProcDefEnum.PAYMENTAPPLY.getProDefId()); |
|||
ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv); |
|||
if (!voResultBean.getSuccess()) { |
|||
return rb.setMsg(voResultBean.getMsg()); |
|||
} |
|||
UpdateFlowFieldVo ufVo = voResultBean.getData(); |
|||
updateFlowFiled(BeanUtil.beanToMap(ufVo)); |
|||
return voResultBean; |
|||
} |
|||
if (r == 2) { |
|||
paymentApply = fetchBySid(businessSid); |
|||
// ToDo:驳回到发起人后再次提交
|
|||
if (StringUtils.isBlank(dto.getInstanceId())) { |
|||
return rb.setMsg("参数错误:procInstId"); |
|||
} |
|||
bv.setTaskId(paymentApply.getTaskId()); |
|||
bv.setTaskDefKey(paymentApply.getTaskDefKey()); |
|||
bv.setComment("重新提交"); |
|||
bv.setInstanceId(dto.getInstanceId()); |
|||
return complete(bv); |
|||
} |
|||
return rb; |
|||
} |
|||
|
|||
/** |
|||
* 判断提交的流程是否被允许 |
|||
* |
|||
* @param dto |
|||
* @return |
|||
*/ |
|||
private synchronized int submitBusinessData(SubmitPaymentApplyDto dto, PaymentApply paymentApply) { |
|||
int r = 0; |
|||
if (StringUtils.isBlank(dto.getSid())) { |
|||
r = 1; |
|||
} else { |
|||
if (paymentApply != null) { |
|||
String businessTaskId = paymentApply.getTaskId(); |
|||
if (StringUtils.isBlank(businessTaskId) && StringUtils.isBlank(dto.getTaskId())) { |
|||
//新提交
|
|||
r = 1; |
|||
} else if (StringUtils.isNotBlank(businessTaskId) && businessTaskId.equals(dto.getTaskId())) { |
|||
//二次提交//只有数据一致的时候才能进行下一步
|
|||
r = 2; |
|||
} |
|||
} else { |
|||
r = 3; |
|||
} |
|||
|
|||
} |
|||
return r; |
|||
} |
|||
|
|||
/** |
|||
* 更新流程相关的状态 |
|||
* |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
private int updateFlowFiled(Map<String, Object> map) { |
|||
return baseMapper.updateFlowFiled(map); |
|||
} |
|||
|
|||
public ResultBean complete(BusinessVariables bv) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String businessSid = bv.getBusinessSid(); |
|||
PaymentApply paymentApply = fetchBySid(businessSid); |
|||
if (paymentApply == null) { |
|||
return rb.setMsg("该用款申请不存在"); |
|||
} |
|||
Map<String, Object> variables = new HashMap<>(); |
|||
bv.setModelId(paymentApply.getProcDefId()); |
|||
bv.setProjectSid(paymentApply.getProjectSid()); |
|||
if (bv.getTaskId().equals(paymentApply.getTaskId())) { |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.handleProsess(bv); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|||
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|||
return rb.success().setData(resultBean.getData()); |
|||
} else { |
|||
return rb.setMsg("操作失败!提交的数据不一致"); |
|||
} |
|||
} |
|||
|
|||
public ResultBean<List<GetNodeVo>> getPreviousNodesForReject(GetNodeQuery query) { |
|||
ResultBean<List<GetNodeVo>> rb = ResultBean.fireFail(); |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
BeanUtil.copyProperties(query, bv); |
|||
PaymentApply paymentApply = fetchBySid(query.getBusinessSid()); |
|||
bv.setModelId(paymentApply.getProcDefId()); |
|||
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|||
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|||
List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList()); |
|||
return rb.success().setData(voList); |
|||
} |
|||
|
|||
public ResultBean<List<GetNodeVo>> getNextNodesForSubmit(GetNodeQuery query) { |
|||
ResultBean<List<GetNodeVo>> rb = ResultBean.fireFail(); |
|||
BusinessVariables bv = new BusinessVariables(); |
|||
BeanUtil.copyProperties(query, bv); |
|||
PaymentApply paymentApply = fetchBySid(query.getBusinessSid()); |
|||
bv.setModelId(paymentApply.getProcDefId()); |
|||
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|||
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|||
List<GetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), GetNodeVo.class)).collect(Collectors.toList()); |
|||
return rb.success().setData(voList); |
|||
} |
|||
|
|||
public ResultBean taskReject(PaymentApplyTaskQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String businessSid = query.getBusinessSid(); |
|||
PaymentApply paymentApply = fetchBySid(businessSid); |
|||
if (paymentApply == null) { |
|||
return rb.setMsg("该用款申请不存在"); |
|||
} |
|||
String businessTaskId = paymentApply.getTaskId(); |
|||
if (StringUtils.isNotBlank(businessTaskId)) { |
|||
if (businessTaskId.equals(query.getTaskId())) { |
|||
if (StringUtils.isBlank(query.getComment())) { |
|||
return rb.setMsg("请填写意见"); |
|||
} |
|||
if (StringUtils.isBlank(query.getUserSid())) { |
|||
return rb.setMsg("参数错误:userSid"); |
|||
} |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
Map<String, Object> variables = new HashMap<>(); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.taskReject(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|||
Map<String, Object> map = BeanUtil.beanToMap(ufVo); |
|||
//更新业务中的流程相关的参数
|
|||
updateFlowFiled(map); |
|||
return rb.success(); |
|||
} |
|||
} |
|||
return rb.setMsg("操作失败!提交的数据不一致!"); |
|||
} |
|||
|
|||
public ResultBean revokeProcess(PaymentApplyTaskQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
if (StringUtils.isNotBlank(query.getUserSid())) { |
|||
return rb.setMsg("参数错误:userSid"); |
|||
} |
|||
PaymentApply paymentApply = fetchBySid(query.getBusinessSid()); |
|||
String businessTaskId = paymentApply.getTaskId(); |
|||
if (StringUtils.isNotBlank(businessTaskId)) { |
|||
if (businessTaskId.equals(query.getTaskId())) { |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.revokeProcess(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|||
return rb.success().setData(resultBean.getData()); |
|||
} |
|||
} |
|||
return rb.setMsg("操作失败,提交的数据不一致!"); |
|||
} |
|||
|
|||
public ResultBean breakProcess(PaymentApplyTaskQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
if (StringUtils.isBlank(query.getInstanceId())) { |
|||
return rb.setMsg("参数错误:instanceId"); |
|||
} |
|||
if (StringUtils.isBlank(query.getUserSid())) { |
|||
return rb.setMsg("参数错误:userSid"); |
|||
} |
|||
if (StringUtils.isBlank(query.getComment())) { |
|||
return rb.setMsg("请填写意见"); |
|||
} |
|||
PaymentApply paymentApply = fetchBySid(query.getBusinessSid()); |
|||
String businessTaskId = paymentApply.getTaskId(); |
|||
if (StringUtils.isNotBlank(businessTaskId)) { |
|||
if (query.getUserSid().equals(paymentApply.getCreateBySid())) { |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|||
updateFlowFiled(map); |
|||
return rb.success().setData(resultBean.getData()); |
|||
} else { |
|||
if (businessTaskId.equals(query.getTaskId())) { |
|||
FlowTaskVo flowTaskVo = new FlowTaskVo(); |
|||
BeanUtil.copyProperties(query, flowTaskVo); |
|||
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.breakProcess(flowTaskVo); |
|||
if (!resultBean.getSuccess()) { |
|||
return rb.setMsg(resultBean.getMsg()); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(resultBean.getData()); |
|||
updateFlowFiled(map); |
|||
return rb.success().setData(resultBean.getData()); |
|||
} |
|||
} |
|||
|
|||
} |
|||
return rb.setMsg("操作失败!提交的数据不一致!"); |
|||
} |
|||
} |
Loading…
Reference in new issue