@ -26,20 +26,36 @@
package com.yxt.anrui.scm.biz.scmfinanceadjustapply ;
import cn.hutool.core.bean.BeanUtil ;
import cn.hutool.core.date.DateUtil ;
import com.alibaba.fastjson.JSON ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.google.common.util.concurrent.ThreadFactoryBuilder ;
import com.yxt.anrui.base.api.commonappendix.CommonAttachTypeEnum ;
import com.yxt.anrui.base.common.enums.BillTypeEnum ;
import com.yxt.anrui.base.common.utils.Rule ;
import com.yxt.anrui.base.common.utils.domain.BillNo ;
import com.yxt.anrui.flowable.api.flow.FlowableFeign ;
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo ;
import com.yxt.anrui.flowable.api.flow2.FlowDelegateQuery ;
import com.yxt.anrui.flowable.api.flow2.FlowFeign ;
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign ;
import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo ;
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo ;
import com.yxt.anrui.flowable.api.utils.ProcDefEnum ;
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables ;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign ;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo ;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrg ;
import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign ;
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery ;
import com.yxt.anrui.portal.api.sysuser.PrivilegeVo ;
import com.yxt.anrui.portal.api.sysuser.SysUserFeign ;
import com.yxt.anrui.portal.api.sysuser.SysUserVo ;
import com.yxt.anrui.scm.api.scmfile.ScmFileDto ;
import com.yxt.anrui.scm.api.scmfile.ScmFileVo ;
import com.yxt.anrui.scm.api.scmfinanceadjustapply.* ;
import com.yxt.anrui.scm.api.scmfinanceadjustapply.flow.* ;
import com.yxt.anrui.scm.api.scmfinanceadjustdetails.ScmFinanceAdjustDetails ;
import com.yxt.anrui.scm.biz.scmfile.ScmFileService ;
import com.yxt.anrui.scm.biz.scmfinanceadjustdetails.ScmFinanceAdjustDetailsService ;
@ -50,12 +66,17 @@ import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery ;
import com.yxt.common.core.result.ResultBean ;
import com.yxt.common.core.vo.PagerVo ;
import com.yxt.messagecenter.api.message.MessageFeign ;
import com.yxt.messagecenter.api.message.MessageFlowVo ;
import com.yxt.messagecenter.api.message.MessageFlowableQuery ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import java.util.ArrayList ;
import java.util.List ;
import java.math.BigDecimal ;
import java.util.* ;
import java.util.concurrent.* ;
import java.util.stream.Collectors ;
/ * *
* Project : scm ( 金融贴息 ) < br / >
@ -73,6 +94,16 @@ import java.util.List;
@Service
public class ScmFinanceAdjustApplyService extends MybatisBaseService < ScmFinanceAdjustApplyMapper , ScmFinanceAdjustApply > {
@Autowired
private MessageFeign messageFeign ;
@Autowired
private FlowTaskFeign flowTaskFeign ;
@Autowired
private FlowFeign flowFeign ;
@Autowired
private FlowableFeign flowableFeign ;
@Autowired
private SysStaffOrgFeign sysStaffOrgFeign ;
@Autowired
private ScmFileService scmFileService ;
@Autowired
@ -173,7 +204,7 @@ public class ScmFinanceAdjustApplyService extends MybatisBaseService<ScmFinanceA
ScmFinanceAdjustApply entity = new ScmFinanceAdjustApply ( ) ;
sid = entity . getSid ( ) ;
BeanUtil . copyProperties ( dto , entity , "id" , "sid" ) ;
entity . setNodeState ( "未 提交" ) ;
entity . setNodeState ( "待 提交" ) ;
String applyCode = getApplyCode ( dto . getUseOrgSid ( ) ) ;
entity . setBillNo ( applyCode ) ;
baseMapper . insert ( entity ) ;
@ -239,6 +270,7 @@ public class ScmFinanceAdjustApplyService extends MybatisBaseService<ScmFinanceA
if ( StringUtils . isNotBlank ( entity . getProcInstId ( ) ) ) {
vo . setInstanceId ( entity . getProcInstId ( ) ) ;
}
vo . setCreateTime ( DateUtil . formatDate ( entity . getCreateTime ( ) ) ) ;
List < ScmFileVo > scmFileVos = scmFileService . fetchByMainSid ( sid ) ;
if ( ! scmFileVos . isEmpty ( ) & & scmFileVos . size ( ) > 0 ) {
for ( ScmFileVo scmFileVo : scmFileVos ) {
@ -288,6 +320,14 @@ public class ScmFinanceAdjustApplyService extends MybatisBaseService<ScmFinanceA
if ( StringUtils . isNotBlank ( query . getStaffSid ( ) ) ) {
qw . eq ( "bo.createBySid" , query . getStaffSid ( ) ) ;
}
String [ ] sids = query . getSids ( ) ;
if ( sids ! = null ) {
for ( String sid : sids ) {
if ( StringUtils . isNotBlank ( sid ) ) {
qw . ne ( "n.vehSid" , sid ) ;
}
}
}
qw . apply ( "n.nowDiffAmount != 0" ) ;
qw . eq ( "n.useOrgSid" , query . getUseOrgSid ( ) ) ;
IPage < ScmFinanceAdjustApply > page = PagerUtil . queryToPage ( pq ) ;
@ -357,4 +397,520 @@ public class ScmFinanceAdjustApplyService extends MybatisBaseService<ScmFinanceA
public int selectBySid ( String join ) {
return baseMapper . selectBySid ( join ) ;
}
//-------------------------------------流程------------------------------------------------/
/ * *
* 判断提交的流程是否被允许
*
* @param dto
* @return
* /
private synchronized int submitBusinessData ( SubmitAdjustDto dto , ScmFinanceAdjustApply scmFinanceAdjustApply ) {
int r = 0 ;
if ( StringUtils . isBlank ( dto . getSid ( ) ) ) {
r = 1 ;
} else {
if ( scmFinanceAdjustApply ! = null ) {
String businessTaskId = scmFinanceAdjustApply . 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 submitRecordApplication ( SubmitAdjustDto dto ) {
ResultBean rb = ResultBean . fireFail ( ) ;
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( dto . getSid ( ) ) ;
int r = submitBusinessData ( dto , scmFinanceAdjustApply ) ;
if ( r = = 3 ) {
return rb . setMsg ( "该申请不存在" ) ;
}
if ( r = = 0 ) {
return rb . setMsg ( "操作失败!提交的数据不一致" ) ;
}
//新增修改保存
String businessSid = saveBill ( dto ) ;
ScmFinanceAdjustApply entity = fetchBySid ( businessSid ) ;
String orgSidPath = "" ;
if ( StringUtils . isNotBlank ( entity . getDeptSid ( ) ) ) {
SysOrganizationVo organizationVo = sysOrganizationFeign . fetchBySid ( entity . getDeptSid ( ) ) . getData ( ) ;
if ( null ! = organizationVo ) {
orgSidPath = organizationVo . getOrgSidPath ( ) ;
}
} else {
SysUserVo data = sysUserFeign . fetchBySid ( entity . getCreateBySid ( ) ) . getData ( ) ;
if ( null ! = data ) {
//根据staffSid获取用户的组织全路径
ResultBean < SysStaffOrg > staffOrgResultBean = sysStaffOrgFeign . getOrgByStaffSid ( data . getStaffSid ( ) ) ;
if ( ! staffOrgResultBean . getSuccess ( ) ) {
return rb . setMsg ( staffOrgResultBean . getMsg ( ) ) ;
}
//用户的组织全路径
orgSidPath = staffOrgResultBean . getData ( ) . getOrgSidPath ( ) ;
}
}
List < String > orgPathList = Arrays . asList ( orgSidPath . split ( "/" ) ) ;
SysOrganizationVo sysOrganization = sysOrganizationFeign . fetchBySid ( orgPathList . get ( orgPathList . size ( ) - 1 ) ) . getData ( ) ;
if ( sysOrganization = = null ) {
return rb . setMsg ( "当前所在的组织机构不存在" ) ;
}
if ( StringUtils . isBlank ( sysOrganization . getManagerSid ( ) ) ) {
// return rb.setMsg("当前所在的组织机构未设置主管人员");
sysOrganization . setManagerSid ( ProcDefEnum . DEFAUL_TADMIN_SID . getProDefId ( ) ) ;
}
//创建BusinessVariables实体对象
BusinessVariables bv = new BusinessVariables ( ) ;
//流程中的参数赋值
Map < String , Object > variables = BeanUtil . beanToMap ( dto ) ;
Map < String , Object > appMap = new HashMap < > ( ) ;
//若有网关,则赋值网关中判断的字段。
boolean isCustomer = false ; //调整方式是否为客户交纳
boolean isMoney = false ; //认损金额是否>2000
//去查询调整方式是否为客户交纳
if ( entity . getAdjustWay ( ) . equals ( "客户交纳" ) ) {
isCustomer = true ;
} else {
List < ScmFinanceAdjustDetails > details = scmFinanceAdjustDetailsService . selByMainSid ( businessSid ) ;
if ( ! details . isEmpty ( ) ) {
for ( ScmFinanceAdjustDetails detail : details ) {
BigDecimal rensunMoney = BigDecimal . ZERO ;
if ( null ! = detail . getNowAdjustmentMoney ( ) ) {
rensunMoney = detail . getNowAdjustmentMoney ( ) ;
}
if ( rensunMoney . compareTo ( new BigDecimal ( "2000" ) ) > 0 ) {
//判断认损金额>2000
isMoney = true ;
}
}
}
}
variables . put ( "isCustomer" , isCustomer ) ;
variables . put ( "isMoney" , isMoney ) ;
variables . put ( "businessSid" , businessSid ) ;
appMap . put ( "sid" , businessSid ) ;
variables . put ( "app" , appMap ) ;
String orderNames = "金融贴息差异调整申请" ;
variables . put ( "orderNames" , orderNames ) ;
ScmFinanceAdjustApply scmFinanceAdjustApply1 = fetchBySid ( businessSid ) ;
String msgBusinessSid = scmFinanceAdjustApply1 . getSid ( ) ;
//用户的部门全路径sid
bv . setOrgSidPath ( orgSidPath ) ;
//业务sid
bv . setBusinessSid ( businessSid ) ;
//用户sid
bv . setUserSid ( dto . getCreateBySid ( ) ) ;
bv . setFormVariables ( variables ) ;
String nextNodeUserSids_ = sysOrganization . getManagerSid ( ) ;
if ( isCustomer ) {
if ( StringUtils . isNotBlank ( entity . getStaffSid ( ) ) ) {
bv . setNextNodeUserSids ( entity . getStaffSid ( ) ) ;
} else {
bv . setNextNodeUserSids ( ProcDefEnum . DEFAUL_TADMIN_SID . getProDefId ( ) ) ;
}
}
//流程定义id
bv . setModelId ( ProcDefEnum . JTTXCYSQ . getProDefId ( ) ) ;
if ( r = = 1 ) {
//流程定义id
bv . setModelId ( ProcDefEnum . JTTXCYSQ . getProDefId ( ) ) ;
ResultBean < UpdateFlowFieldVo > voResultBean = flowFeign . startProcess ( bv ) ;
if ( ! voResultBean . getSuccess ( ) ) {
return rb . setMsg ( voResultBean . getMsg ( ) ) ;
}
UpdateFlowFieldVo ufVo = voResultBean . getData ( ) ;
int i = updateFlowFiled ( BeanUtil . beanToMap ( ufVo ) ) ;
//==================================添加线程
try {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder ( )
. setNameFormat ( "demo-pool-%d" ) . build ( ) ;
ExecutorService pool = new ThreadPoolExecutor ( 2 , 100 ,
0L , TimeUnit . MILLISECONDS ,
new LinkedBlockingQueue < Runnable > ( 1024 ) , namedThreadFactory , new ThreadPoolExecutor . AbortPolicy ( ) ) ;
Future future1 = pool . submit ( ( ) - > {
//极光推送
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery ( ) ;
MessageFlowVo messageFlowVo = new MessageFlowVo ( ) ;
BeanUtil . copyProperties ( ufVo , messageFlowVo ) ;
messageFlowableQuery . setUfVo ( messageFlowVo ) ;
messageFlowableQuery . setAppMap ( appMap ) ;
messageFlowableQuery . setBusinessSid ( msgBusinessSid ) ;
messageFlowableQuery . setModuleName ( "金融贴息差异调整申请" ) ;
SysUserVo userVo = sysUserFeign . fetchBySid ( scmFinanceAdjustApply1 . getCreateBySid ( ) ) . getData ( ) ;
if ( userVo ! = null ) {
if ( StringUtils . isNotBlank ( userVo . getName ( ) ) ) {
messageFlowableQuery . setMsgContent ( userVo . getName ( ) + "提交的" + messageFlowableQuery . getModuleName ( ) + ",请审批" ) ;
}
}
messageFlowableQuery . setMsgTitle ( "金融贴息差异调整申请" ) ;
ResultBean < String > stringResultBean = messageFeign . pushMessage ( messageFlowableQuery ) ;
} ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
//==================================添加线程
return voResultBean ;
}
if ( r = = 2 ) {
// ToDo:驳回到发起人后再次提交
if ( StringUtils . isBlank ( dto . getInstanceId ( ) ) ) {
return rb . setMsg ( "参数错误:instanceId" ) ;
}
ScmFinanceAdjustApply scmFinanceAdjustApply2 = fetchBySid ( dto . getSid ( ) ) ;
bv . setTaskId ( dto . getTaskId ( ) ) ;
bv . setTaskDefKey ( scmFinanceAdjustApply2 . getNodeSid ( ) ) ;
bv . setComment ( "重新提交" ) ;
bv . setInstanceId ( dto . getInstanceId ( ) ) ;
return complete ( bv ) ;
}
return rb ;
}
public ResultBean complete ( BusinessVariables bv ) {
ResultBean rb = ResultBean . fireFail ( ) ;
String businessSid = bv . getBusinessSid ( ) ;
ScmFinanceAdjustApply entity = this . fetchBySid ( businessSid ) ;
if ( bv . getTaskId ( ) . equals ( entity . getTaskId ( ) ) ) {
String orgSidPath = "" ;
if ( StringUtils . isNotBlank ( entity . getDeptSid ( ) ) ) {
SysOrganizationVo organizationVo = sysOrganizationFeign . fetchBySid ( entity . getDeptSid ( ) ) . getData ( ) ;
if ( null ! = organizationVo ) {
orgSidPath = organizationVo . getOrgSidPath ( ) ;
}
}
bv . setOrgSidPath ( orgSidPath ) ;
//流程中的参数赋值
Map < String , Object > variables = new HashMap < > ( ) ;
Map < String , Object > appMap = new HashMap < > ( ) ;
//若有网关,则赋值网关中判断的字段。
boolean isCustomer = false ; //调整方式是否为客户交纳
boolean isMoney = false ; //认损金额是否>2000
//去查询调整方式是否为客户交纳
if ( entity . getAdjustWay ( ) . equals ( "客户交纳" ) ) {
isCustomer = true ;
} else {
List < ScmFinanceAdjustDetails > details = scmFinanceAdjustDetailsService . selByMainSid ( businessSid ) ;
if ( ! details . isEmpty ( ) ) {
for ( ScmFinanceAdjustDetails detail : details ) {
BigDecimal rensunMoney = BigDecimal . ZERO ;
if ( null ! = detail . getNowAdjustmentMoney ( ) ) {
rensunMoney = detail . getNowAdjustmentMoney ( ) ;
}
if ( rensunMoney . compareTo ( new BigDecimal ( "2000" ) ) > 0 ) {
//判断认损金额>2000
isMoney = true ;
}
}
}
}
variables . put ( "isCustomer" , isCustomer ) ;
variables . put ( "isMoney" , isMoney ) ;
if ( bv . getTaskDefKey ( ) . equals ( "Activity_049lvok" ) ) {
if ( StringUtils . isNotBlank ( entity . getSalesManageSid ( ) ) ) {
bv . setNextNodeUserSids ( entity . getSalesManageSid ( ) ) ;
} else {
bv . setNextNodeUserSids ( ProcDefEnum . DEFAUL_TADMIN_SID . getProDefId ( ) ) ;
}
}
variables . put ( "businessSid" , businessSid ) ;
appMap . put ( "sid" , businessSid ) ;
variables . put ( "app" , appMap ) ;
bv . setFormVariables ( variables ) ;
ResultBean < UpdateFlowFieldVo > resultBean = flowFeign . handleProsess ( bv ) ;
if ( ! resultBean . getSuccess ( ) ) {
return rb . setMsg ( resultBean . getMsg ( ) ) ;
}
UpdateFlowFieldVo ufVo = resultBean . getData ( ) ;
int i = updateFlowFiled ( BeanUtil . beanToMap ( resultBean . getData ( ) ) ) ;
if ( "Event_end" . equals ( resultBean . getData ( ) . getTaskDefKey ( ) ) ) {
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( businessSid ) ;
scmFinanceAdjustApply . setClosingDate ( new Date ( ) ) ;
baseMapper . updateById ( scmFinanceAdjustApply ) ;
} else {
//极光推送
entity = fetchBySid ( businessSid ) ;
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery ( ) ;
MessageFlowVo messageFlowVo = new MessageFlowVo ( ) ;
BeanUtil . copyProperties ( ufVo , messageFlowVo ) ;
messageFlowVo . setProcDefId ( entity . getProcDefId ( ) ) ;
messageFlowVo . setProcInsId ( entity . getProcInstId ( ) ) ;
messageFlowableQuery . setUfVo ( messageFlowVo ) ;
messageFlowableQuery . setAppMap ( appMap ) ;
messageFlowableQuery . setBusinessSid ( businessSid ) ;
messageFlowableQuery . setModuleName ( "金融贴息差异调整申请" ) ;
messageFlowableQuery . setMsgContent ( entity . getCreateByName ( ) + "提交的" + messageFlowableQuery . getModuleName ( ) + ",请审批" ) ;
messageFlowableQuery . setMsgTitle ( "金融贴息差异调整申请" ) ;
ResultBean < String > stringResultBean = messageFeign . pushMessage ( messageFlowableQuery ) ;
}
return rb . success ( ) . setData ( resultBean . getData ( ) ) ;
} else {
return rb . setMsg ( "操作失败!提交的数据不一致" ) ;
}
}
public ResultBean revokeProcess ( AdjustTaskQuery query ) {
ResultBean rb = ResultBean . fireFail ( ) ;
if ( StringUtils . isBlank ( query . getUserSid ( ) ) ) {
return rb . setMsg ( "参数错误:userSid" ) ;
}
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( query . getBusinessSid ( ) ) ;
String businessTaskId = scmFinanceAdjustApply . 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 taskReject ( AdjustTaskQuery query ) {
ResultBean rb = ResultBean . fireFail ( ) ;
String businessSid = query . getBusinessSid ( ) ;
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( businessSid ) ;
if ( scmFinanceAdjustApply = = null ) {
return rb . setMsg ( "该申请不存在" ) ;
}
String businessTaskId = scmFinanceAdjustApply . getTaskId ( ) ;
if ( StringUtils . isNotBlank ( businessTaskId ) ) {
if ( businessTaskId . equals ( query . getTaskId ( ) ) ) {
if ( StringUtils . isBlank ( query . getComment ( ) ) ) {
return rb . setMsg ( "请填写意见" ) ;
}
if ( org . apache . commons . lang3 . StringUtils . isBlank ( query . getUserSid ( ) ) ) {
return rb . setMsg ( "参数错误:userSid" ) ;
}
FlowTaskVo flowTaskVo = new FlowTaskVo ( ) ;
BeanUtil . copyProperties ( query , flowTaskVo ) ;
Map < String , Object > variables = new HashMap < > ( ) ;
Map < String , Object > appMap = new HashMap < > ( ) ;
appMap . put ( "sid" , businessSid ) ;
variables . put ( "app" , appMap ) ;
//若有网关,则赋值网关中判断的字段。
boolean isCustomer = false ; //调整方式是否为客户交纳
boolean isMoney = false ; //认损金额是否>2000
//去查询调整方式是否为客户交纳
if ( scmFinanceAdjustApply . getAdjustWay ( ) . equals ( "客户交纳" ) ) {
isCustomer = true ;
} else {
List < ScmFinanceAdjustDetails > details = scmFinanceAdjustDetailsService . selByMainSid ( businessSid ) ;
if ( ! details . isEmpty ( ) ) {
for ( ScmFinanceAdjustDetails detail : details ) {
BigDecimal rensunMoney = BigDecimal . ZERO ;
if ( null ! = detail . getNowAdjustmentMoney ( ) ) {
rensunMoney = detail . getNowAdjustmentMoney ( ) ;
}
if ( rensunMoney . compareTo ( new BigDecimal ( "2000" ) ) > 0 ) {
//判断认损金额>2000
isMoney = true ;
}
}
}
}
variables . put ( "isCustomer" , isCustomer ) ;
variables . put ( "isMoney" , isMoney ) ;
flowTaskVo . setValues ( variables ) ;
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 ) ;
//极光推送
scmFinanceAdjustApply = fetchBySid ( businessSid ) ;
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery ( ) ;
MessageFlowVo messageFlowVo = new MessageFlowVo ( ) ;
BeanUtil . copyProperties ( ufVo , messageFlowVo ) ;
String procId = scmFinanceAdjustApply . getProcInstId ( ) ;
messageFlowVo . setProcInsId ( procId ) ;
messageFlowVo . setProcDefId ( scmFinanceAdjustApply . getProcDefId ( ) ) ;
messageFlowableQuery . setUfVo ( messageFlowVo ) ;
messageFlowableQuery . setAppMap ( appMap ) ;
messageFlowableQuery . setBusinessSid ( businessSid ) ;
messageFlowableQuery . setModuleName ( "金融贴息差异调整申请" ) ;
ResultBean < List < LatestTaskVo > > listResultBean = flowTaskFeign . getLatestTasks ( procId ) ;
String nextName = listResultBean . getData ( ) . get ( 0 ) . getName_ ( ) ;
String nextNodeUserSids = listResultBean . getData ( ) . get ( 0 ) . getASSIGNEE_ ( ) ;
List < String > receiveSidList = Arrays . asList ( nextNodeUserSids . split ( "," ) ) ;
// if (receiveSidList.size() == 1 && receiveSidList.get(0).equals(busVehicleApply.getCreateBySid())) {
if ( "发起申请" . equals ( nextName ) ) {
messageFlowableQuery . setMsgContent ( "您提交的" + messageFlowableQuery . getModuleName ( ) + "已被驳回,请重新提交" ) ;
} else {
SysUserVo userVo = sysUserFeign . fetchBySid ( scmFinanceAdjustApply . getCreateBySid ( ) ) . getData ( ) ;
if ( userVo ! = null ) {
if ( org . apache . commons . lang3 . StringUtils . isNotBlank ( userVo . getName ( ) ) ) {
messageFlowableQuery . setMsgContent ( userVo . getName ( ) + "提交的" + messageFlowableQuery . getModuleName ( ) + ",请审批" ) ;
}
}
}
messageFlowableQuery . setMsgTitle ( "金融贴息差异调整申请" ) ;
ResultBean < String > stringResultBean = messageFeign . pushMessage ( messageFlowableQuery ) ;
return rb . success ( ) ;
}
}
return rb . setMsg ( "操作失败!提交的数据不一致!" ) ;
}
public ResultBean breakProcess ( AdjustTaskQuery query ) {
ResultBean rb = ResultBean . fireFail ( ) ;
if ( org . apache . commons . lang3 . StringUtils . isBlank ( query . getInstanceId ( ) ) ) {
return rb . setMsg ( "参数错误:instanceId" ) ;
}
if ( org . apache . commons . lang3 . StringUtils . isBlank ( query . getUserSid ( ) ) ) {
return rb . setMsg ( "参数错误:userSid" ) ;
}
if ( org . apache . commons . lang3 . StringUtils . isBlank ( query . getComment ( ) ) ) {
return rb . setMsg ( "请填写意见" ) ;
}
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( query . getBusinessSid ( ) ) ;
String businessTaskId = scmFinanceAdjustApply . getTaskId ( ) ;
if ( StringUtils . isNotBlank ( businessTaskId ) ) {
if ( query . getUserSid ( ) . equals ( scmFinanceAdjustApply . 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 ( "操作失败!提交的数据不一致!" ) ;
}
public ResultBean flowRecord ( String procInsId ) {
return flowTaskFeign . businessFlowRecord ( procInsId ) ;
}
public ResultBean < List < AdjustGetNodeVo > > getNextNodesForSubmit ( AdjustGetNodeQuery query ) {
ResultBean < List < AdjustGetNodeVo > > rb = ResultBean . fireFail ( ) ;
BusinessVariables bv = new BusinessVariables ( ) ;
BeanUtil . copyProperties ( query , bv ) ;
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
Map < String , Object > variables = new HashMap < > ( ) ;
//根据业务sid查询信息
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( query . getBusinessSid ( ) ) ;
//若有网关,则赋值网关中判断的字段。
boolean isCustomer = false ; //调整方式是否为客户交纳
boolean isMoney = false ; //认损金额是否>2000
//去查询调整方式是否为客户交纳
if ( scmFinanceAdjustApply . getAdjustWay ( ) . equals ( "客户交纳" ) ) {
isCustomer = true ;
} else {
List < ScmFinanceAdjustDetails > details = scmFinanceAdjustDetailsService . selByMainSid ( query . getBusinessSid ( ) ) ;
if ( ! details . isEmpty ( ) ) {
for ( ScmFinanceAdjustDetails detail : details ) {
BigDecimal rensunMoney = BigDecimal . ZERO ;
if ( null ! = detail . getNowAdjustmentMoney ( ) ) {
rensunMoney = detail . getNowAdjustmentMoney ( ) ;
}
if ( rensunMoney . compareTo ( new BigDecimal ( "2000" ) ) > 0 ) {
//判断认损金额>2000
isMoney = true ;
}
}
}
}
variables . put ( "isCustomer" , isCustomer ) ;
variables . put ( "isMoney" , isMoney ) ;
bv . setFormVariables ( variables ) ;
bv . setModelId ( scmFinanceAdjustApply . getProcDefId ( ) ) ;
ResultBean < List < Map < String , Object > > > resultBean = flowTaskFeign . getNextNodesForSubmit ( bv ) ;
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
List < AdjustGetNodeVo > voList = Optional . ofNullable ( resultBean . getData ( ) ) . orElse ( new ArrayList < > ( ) ) . stream ( ) . map ( m - > JSON . parseObject ( JSON . toJSONString ( m ) , AdjustGetNodeVo . class ) ) . collect ( Collectors . toList ( ) ) ;
return rb . success ( ) . setData ( voList ) ;
}
public ResultBean < List < AdjustGetNodeVo > > getPreviousNodesForReject ( AdjustGetNodeQuery query ) {
ResultBean < List < AdjustGetNodeVo > > rb = ResultBean . fireFail ( ) ;
BusinessVariables bv = new BusinessVariables ( ) ;
BeanUtil . copyProperties ( query , bv ) ;
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
Map < String , Object > variables = new HashMap < > ( ) ;
//根据业务sid查询排产
ScmFinanceAdjustApply scmFinanceAdjustApply = fetchBySid ( query . getBusinessSid ( ) ) ;
//若有网关,则赋值网关中判断的字段。
boolean isCustomer = false ; //调整方式是否为客户交纳
boolean isMoney = false ; //认损金额是否>2000
//去查询调整方式是否为客户交纳
if ( scmFinanceAdjustApply . getAdjustWay ( ) . equals ( "客户交纳" ) ) {
isCustomer = true ;
} else {
List < ScmFinanceAdjustDetails > details = scmFinanceAdjustDetailsService . selByMainSid ( query . getBusinessSid ( ) ) ;
if ( ! details . isEmpty ( ) ) {
for ( ScmFinanceAdjustDetails detail : details ) {
BigDecimal rensunMoney = BigDecimal . ZERO ;
if ( null ! = detail . getNowAdjustmentMoney ( ) ) {
rensunMoney = detail . getNowAdjustmentMoney ( ) ;
}
if ( rensunMoney . compareTo ( new BigDecimal ( "2000" ) ) > 0 ) {
//判断认损金额>2000
isMoney = true ;
}
}
}
}
variables . put ( "isCustomer" , isCustomer ) ;
variables . put ( "isMoney" , isMoney ) ;
bv . setFormVariables ( variables ) ;
bv . setModelId ( scmFinanceAdjustApply . getProcDefId ( ) ) ;
ResultBean < List < Map < String , Object > > > resultBean = flowTaskFeign . getPreviousNodesForReject ( bv ) ;
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
List < AdjustGetNodeVo > voList = Optional . ofNullable ( resultBean . getData ( ) ) . orElse ( new ArrayList < > ( ) ) . stream ( ) . map ( m - > JSON . parseObject ( JSON . toJSONString ( m ) , AdjustGetNodeVo . class ) ) . collect ( Collectors . toList ( ) ) ;
return rb . success ( ) . setData ( voList ) ;
}
public ResultBean delegate ( AdjustDelegateQuery adjustDelegateQuery ) {
ResultBean rb = ResultBean . fireFail ( ) ;
FlowDelegateQuery delegateQuery = new FlowDelegateQuery ( ) ;
BeanUtil . copyProperties ( adjustDelegateQuery , delegateQuery ) ;
flowFeign . delegate ( delegateQuery ) ;
return rb . success ( ) ;
}
}