|
|
@ -1,26 +1,47 @@ |
|
|
|
package com.yxt.anrui.riskcenter.biz.loanrepurchaseapply; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
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.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign; |
|
|
|
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.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfile.LoanFile; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfile.LoanFileEnum; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanparameter.*; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanSolutionsDetailsssVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanoverduefin.UrlQuery; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchaseapply.*; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchaseapply.app.AppRepurchaseDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.LoanSolutions; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchaseapply.flow.*; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchasecompanycost.LoanRepurchaseCompanyCost; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchasecost.LoanRepurchaseCost; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettleapply.LoanSettleApplyDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettleapply.SettleApplyCommonVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettlebankcost.LoanSettleBankCostVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansettlecompanycost.LoanSettleCompanyCostVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansolutions.app.SolutionsDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansubletapply.LoanSubletApply; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansubletapply.LoanSubletApplyFile; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansubletapply.LoanSubletApplyQuery; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansubletapply.LoanSubletApplyVo; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanfile.LoanFileService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepurchasecompanycost.LoanRepurchaseCompanyCostService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepurchasecost.LoanRepurchaseCostService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loansettleapply.LoanSettleApplyService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loansolutions.LoanSolutionsService; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -28,13 +49,18 @@ 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 org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -58,6 +84,22 @@ public class LoanRepurchaseApplyService extends MybatisBaseService<LoanRepurchas |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private LoanSolutionsService loanSolutionsService; |
|
|
|
@Autowired |
|
|
|
private LoanRepurchaseCompanyCostService loanRepurchaseCompanyCostService; |
|
|
|
@Autowired |
|
|
|
private LoanRepurchaseCostService loanRepurchaseCostService; |
|
|
|
@Autowired |
|
|
|
private LoanSettleApplyService loanSettleApplyService; |
|
|
|
@Autowired |
|
|
|
private BusSalesOrderVehicleFeign busSalesOrderVehicleFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Autowired |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private FlowableFeign flowableFeign; |
|
|
|
@Autowired |
|
|
|
private MessageFeign messageFeign; |
|
|
|
|
|
|
|
public PagerVo<LoanRepurchaseApplyVo> listPage(PagerQuery<LoanRepurchaseApplyQuery> pq) { |
|
|
|
IPage<LoanRepurchaseApply> page = PagerUtil.queryToPage(pq); |
|
|
@ -167,27 +209,55 @@ public class LoanRepurchaseApplyService extends MybatisBaseService<LoanRepurchas |
|
|
|
|
|
|
|
public ResultBean<LoanRepurchaseApplyDetailsVo> fetchDetailsBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
LoanRepurchaseApplyDetailsVo vo = baseMapper.fetchDetailsBySid(sid); |
|
|
|
if (vo != null) { |
|
|
|
LoanRepurchaseApplyDetailsVo vo = new LoanRepurchaseApplyDetailsVo(); |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(sid); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (loanRepurchaseApply != null) { |
|
|
|
BeanUtil.copyProperties(loanRepurchaseApply, vo); |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getCreateBySid())) { |
|
|
|
vo.setUserSid(loanRepurchaseApply.getCreateBySid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getOrgSidPath())) { |
|
|
|
vo.setOrgPath(loanRepurchaseApply.getOrgSidPath()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getProcInstId())) { |
|
|
|
vo.setInstanceId(loanRepurchaseApply.getProcInstId()); |
|
|
|
} |
|
|
|
if (null != loanRepurchaseApply.getApplyDate()) { |
|
|
|
vo.setApplyDate(sdf.format(loanRepurchaseApply.getApplyDate())); |
|
|
|
} |
|
|
|
if (null != loanRepurchaseApply.getPrepareDate()) { |
|
|
|
vo.setPrepareDate(sdf.format(loanRepurchaseApply.getPrepareDate())); |
|
|
|
} |
|
|
|
//------金融方案-----------
|
|
|
|
ResultBean<SolutionsDetailsVo> solutionsDetailsVoResultBean = loanSolutionsService.selectDetailss(vo.getSalesOrderSid()); |
|
|
|
ResultBean<SolutionsDetailsVo> solutionsDetailsVoResultBean = loanSolutionsService.selectDetailss(loanRepurchaseApply.getSalesOrderSid()); |
|
|
|
if (solutionsDetailsVoResultBean.getData() != null) { |
|
|
|
LoanRepurchaseSolutionsDetailsssVo solutionsDetailsssVo = new LoanRepurchaseSolutionsDetailsssVo(); |
|
|
|
BeanUtil.copyProperties(solutionsDetailsVoResultBean.getData(), solutionsDetailsssVo); |
|
|
|
vo.setSolutionsDetailsssVo(solutionsDetailsssVo); |
|
|
|
} |
|
|
|
List<LoanFile> fileList1 = loanFileService.selectByLinkSid(sid, LoanFileEnum.REPURCHASE_BANKFILE.getAttachType()); |
|
|
|
fileList1.removeAll(Collections.singleton(null)); |
|
|
|
if (!fileList1.isEmpty()) { |
|
|
|
List<String> files = fileList1.stream().map(c -> fileUploadComponent.getUrlPrefix() + c.getFilePath()). |
|
|
|
collect(Collectors.toList()); |
|
|
|
List<LoanRepurchaseApplyFile> applyFiles = new ArrayList<>(); |
|
|
|
for (String file : files) { |
|
|
|
LoanRepurchaseApplyFile applyFile = new LoanRepurchaseApplyFile(); |
|
|
|
applyFile.setUrl(file); |
|
|
|
applyFiles.add(applyFile); |
|
|
|
//资方结清费用
|
|
|
|
LoanRepurchaseBankCostVo bankCostVo = loanRepurchaseCostService.getByMainSid(sid); |
|
|
|
if (null != bankCostVo) { |
|
|
|
List<LoanFile> fileList1 = loanFileService.selectByLinkSid(sid, LoanFileEnum.REPURCHASE_BANKFILE.getAttachType()); |
|
|
|
fileList1.removeAll(Collections.singleton(null)); |
|
|
|
if (!fileList1.isEmpty()) { |
|
|
|
List<String> files = fileList1.stream().map(c -> fileUploadComponent.getUrlPrefix() + c.getFilePath()). |
|
|
|
collect(Collectors.toList()); |
|
|
|
List<LoanRepurchaseApplyFile> applyFiles = new ArrayList<>(); |
|
|
|
for (String file : files) { |
|
|
|
LoanRepurchaseApplyFile applyFile = new LoanRepurchaseApplyFile(); |
|
|
|
applyFile.setUrl(file); |
|
|
|
applyFiles.add(applyFile); |
|
|
|
} |
|
|
|
bankCostVo.setBankfiles(applyFiles); |
|
|
|
} |
|
|
|
vo.setBankfiles(applyFiles); |
|
|
|
vo.setBankCostVo(bankCostVo); |
|
|
|
} |
|
|
|
//公司结清费用
|
|
|
|
LoanRepurchaseCompanyCostVo companyCostVo = loanRepurchaseCompanyCostService.getByMainSid(sid); |
|
|
|
if (null != companyCostVo) { |
|
|
|
vo.setCompanyCostVo(companyCostVo); |
|
|
|
} |
|
|
|
List<LoanFile> fileList2 = loanFileService.selectByLinkSid(sid, LoanFileEnum.REPURCHASE_BACKBUYFILE.getAttachType()); |
|
|
|
fileList2.removeAll(Collections.singleton(null)); |
|
|
@ -225,4 +295,760 @@ public class LoanRepurchaseApplyService extends MybatisBaseService<LoanRepurchas |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<LoanRepurchaseApplyDetailsVo> repurchaseInit(LoanRepurchaseApplyDetailsQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
LoanRepurchaseApplyDetailsVo vo = new LoanRepurchaseApplyDetailsVo(); |
|
|
|
String busVinSid = query.getBusVinSid(); |
|
|
|
String orgPath = query.getOrgPath(); |
|
|
|
String userSid = query.getUserSid(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String date = ""; |
|
|
|
if (StringUtils.isNotBlank(query.getPrepareDate())) { |
|
|
|
date = query.getPrepareDate(); |
|
|
|
} else { |
|
|
|
date = sdf.format(new Date()); |
|
|
|
} |
|
|
|
//根据用户查询发起人、发起部门、发起日期为当前日期
|
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
String useOrgSid = ""; |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
useOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
} |
|
|
|
//根据用户sid查询人员姓名
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(userSid); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
vo.setCreateDept(deptName); |
|
|
|
vo.setCreateDeptSid(deptSid); |
|
|
|
vo.setCreateByName(userVoResultBean.getData().getName()); |
|
|
|
vo.setOrgPath(query.getOrgPath()); |
|
|
|
vo.setUserSid(query.getUserSid()); |
|
|
|
vo.setPrepareDate(date); |
|
|
|
SettleApplyCommonVo settleApplyCommonVo = loanSettleApplyService.getInfo(busVinSid, date); |
|
|
|
BeanUtil.copyProperties(settleApplyCommonVo, vo); |
|
|
|
LoanRepurchaseCompanyCostVo companyCostVo = new LoanRepurchaseCompanyCostVo(); |
|
|
|
BeanUtil.copyProperties(settleApplyCommonVo, companyCostVo); |
|
|
|
vo.setCompanyCostVo(companyCostVo); |
|
|
|
vo.setBusVinSid(busVinSid); |
|
|
|
vo.setApplyDate(sdf.format(new Date())); |
|
|
|
//金融方案
|
|
|
|
BusSalesOrderVehicle data = busSalesOrderVehicleFeign.details(busVinSid).getData(); |
|
|
|
if (null != data) { |
|
|
|
ResultBean<SolutionsDetailsVo> solutionsDetailsVoResultBean = loanSolutionsService.selectDetailss(data.getSalesOrderSid()); |
|
|
|
if (solutionsDetailsVoResultBean.getData() != null) { |
|
|
|
LoanRepurchaseSolutionsDetailsssVo solutionsDetailsssVo = new LoanRepurchaseSolutionsDetailsssVo(); |
|
|
|
BeanUtil.copyProperties(solutionsDetailsVoResultBean.getData(), solutionsDetailsssVo); |
|
|
|
vo.setSolutionsDetailsssVo(solutionsDetailsssVo); |
|
|
|
} |
|
|
|
vo.setSalesOrderSid(data.getSalesOrderSid()); |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean<String> repurchaseSave(LoanRepurchaseApplyDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = ""; |
|
|
|
if (StringUtils.isNotBlank(dto.getSid())) { |
|
|
|
sid = dto.getSid(); |
|
|
|
LoanRepurchaseApply updateEntity = fetchBySid(sid); |
|
|
|
if (null != updateEntity) { |
|
|
|
BeanUtil.copyProperties(dto, updateEntity, "id", "sid"); |
|
|
|
baseMapper.updateById(updateEntity); |
|
|
|
//资方费用
|
|
|
|
int b = loanRepurchaseCostService.delByMainSid(sid); |
|
|
|
LoanRepurchaseBankCostVo bankCostVo = dto.getBankCostVo(); |
|
|
|
LoanRepurchaseCost bankCost = new LoanRepurchaseCost(); |
|
|
|
BeanUtil.copyProperties(bankCostVo, bankCost); |
|
|
|
bankCost.setMainSid(sid); |
|
|
|
loanRepurchaseCostService.insert(bankCost); |
|
|
|
//公司费用
|
|
|
|
int c = loanRepurchaseCompanyCostService.delByMainSid(sid); |
|
|
|
LoanRepurchaseCompanyCostVo companyCostVo = dto.getCompanyCostVo(); |
|
|
|
LoanRepurchaseCompanyCost companyCost = new LoanRepurchaseCompanyCost(); |
|
|
|
BeanUtil.copyProperties(companyCostVo, companyCost); |
|
|
|
companyCost.setMainSid(sid); |
|
|
|
loanRepurchaseCompanyCostService.insert(companyCost); |
|
|
|
//删除附件表中关于该linkSid的文件
|
|
|
|
loanFileService.deleteByLinkSid(sid); |
|
|
|
List<LoanRepurchaseApplyFile> filess = bankCostVo.getBankfiles(); |
|
|
|
if (!filess.isEmpty()) { |
|
|
|
List<String> files = new ArrayList<>(); |
|
|
|
for (LoanRepurchaseApplyFile file : filess) { |
|
|
|
files.add(file.getUrl()); |
|
|
|
} |
|
|
|
loanFileService.saveAll(sid, files, LoanFileEnum.REPURCHASE_BANKFILE.getAttachType()); |
|
|
|
} |
|
|
|
List<LoanRepurchaseApplyFile> filess2 = dto.getBuyfiles(); |
|
|
|
if (!filess2.isEmpty()) { |
|
|
|
List<String> files = new ArrayList<>(); |
|
|
|
for (LoanRepurchaseApplyFile file : filess2) { |
|
|
|
files.add(file.getUrl()); |
|
|
|
} |
|
|
|
loanFileService.saveAll(sid, files, LoanFileEnum.REPURCHASE_BACKBUYFILE.getAttachType()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
LoanRepurchaseApply apply = new LoanRepurchaseApply(); |
|
|
|
BeanUtil.copyProperties(dto, apply, "id", "sid"); |
|
|
|
sid = apply.getSid(); |
|
|
|
apply.setCreateBySid(dto.getUserSid()); |
|
|
|
apply.setOrgSidPath(dto.getOrgPath()); |
|
|
|
ResultBean<String> orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(dto.getOrgPath()); |
|
|
|
if (orgSidByPath.getSuccess()) { |
|
|
|
String userOrgSid = orgSidByPath.getData(); |
|
|
|
apply.setUseOrgSid(userOrgSid); |
|
|
|
ResultBean<SysOrganizationVo> organizationVo = sysOrganizationFeign.fetchBySid(userOrgSid); |
|
|
|
if (organizationVo.getSuccess()) { |
|
|
|
SysOrganizationVo organizationVoData = organizationVo.getData(); |
|
|
|
if (null != organizationVoData) { |
|
|
|
apply.setUseOrgName(organizationVoData.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
apply.setNodeState("待提交"); |
|
|
|
baseMapper.insert(apply); |
|
|
|
LoanRepurchaseBankCostVo bankCostVo = dto.getBankCostVo(); |
|
|
|
LoanRepurchaseCost bankCost = new LoanRepurchaseCost(); |
|
|
|
BeanUtil.copyProperties(bankCostVo, bankCost); |
|
|
|
bankCost.setMainSid(sid); |
|
|
|
loanRepurchaseCostService.insert(bankCost); |
|
|
|
LoanRepurchaseCompanyCostVo companyCostVo = dto.getCompanyCostVo(); |
|
|
|
LoanRepurchaseCompanyCost companyCost = new LoanRepurchaseCompanyCost(); |
|
|
|
BeanUtil.copyProperties(companyCostVo, companyCost); |
|
|
|
companyCost.setMainSid(sid); |
|
|
|
loanRepurchaseCompanyCostService.insert(companyCost); |
|
|
|
//删除附件表中关于该linkSid的文件
|
|
|
|
loanFileService.deleteByLinkSid(sid); |
|
|
|
List<LoanRepurchaseApplyFile> filess = bankCostVo.getBankfiles(); |
|
|
|
if (!filess.isEmpty()) { |
|
|
|
List<String> files = new ArrayList<>(); |
|
|
|
for (LoanRepurchaseApplyFile file : filess) { |
|
|
|
files.add(file.getUrl()); |
|
|
|
} |
|
|
|
loanFileService.saveAll(sid, files, LoanFileEnum.REPURCHASE_BANKFILE.getAttachType()); |
|
|
|
} |
|
|
|
List<LoanRepurchaseApplyFile> filess2 = dto.getBuyfiles(); |
|
|
|
if (!filess2.isEmpty()) { |
|
|
|
List<String> files = new ArrayList<>(); |
|
|
|
for (LoanRepurchaseApplyFile file : filess2) { |
|
|
|
files.add(file.getUrl()); |
|
|
|
} |
|
|
|
loanFileService.saveAll(sid, files, LoanFileEnum.REPURCHASE_BACKBUYFILE.getAttachType()); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean deleteBySids(String[] sids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//查询该sid中是否有流程不是待提交的
|
|
|
|
int count = baseMapper.selectBySid(StringUtils.join(sids, ",")); |
|
|
|
if (count > 0) { |
|
|
|
return rb.setMsg("删除的数据中包含已经提交审批的数据,删除失败"); |
|
|
|
} |
|
|
|
delBySids(sids); |
|
|
|
loanRepurchaseCostService.deleteByApplySid(sids); |
|
|
|
loanRepurchaseCompanyCostService.deleteByApplySid(sids); |
|
|
|
return ResultBean.fireSuccess().setMsg("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
//---------------------------流程接口------------------------------------------
|
|
|
|
|
|
|
|
/** |
|
|
|
* 判断提交的流程是否被允许 |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private synchronized int submitBusinessData(SubmitRepurchaseDto dto, LoanRepurchaseApply loanRepurchaseApply) { |
|
|
|
int r = 0; |
|
|
|
if (StringUtils.isBlank(dto.getSid())) { |
|
|
|
r = 1; |
|
|
|
} else { |
|
|
|
if (loanRepurchaseApply != null) { |
|
|
|
String businessTaskId = loanRepurchaseApply.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(SubmitRepurchaseDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(dto.getSid()); |
|
|
|
int r = submitBusinessData(dto, loanRepurchaseApply); |
|
|
|
if (r == 3) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
if (r == 0) { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
String busVinSid = dto.getBusVinSid(); |
|
|
|
//判断当前车辆是否已在审批中
|
|
|
|
int count = baseMapper.selCountByBusVinSid(busVinSid); |
|
|
|
if (count > 0) { |
|
|
|
return rb.setMsg("当前所选车辆已经处于回购申请审批状态,无法提交!"); |
|
|
|
} |
|
|
|
String businessSid = ""; |
|
|
|
//新增修改保存
|
|
|
|
ResultBean<String> resultBean = repurchaseSave(dto); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
businessSid = resultBean.getData(); |
|
|
|
} else { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
LoanRepurchaseApply entity = fetchBySid(businessSid); |
|
|
|
String orgSidPath = ""; |
|
|
|
if (StringUtils.isNotBlank(entity.getOrgSidPath())) { |
|
|
|
orgSidPath = entity.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 isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(entity.getSalesUserSid())) {
|
|
|
|
// if (!entity.getCreateBySid().equals(entity.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
variables.put("businessSid", businessSid); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
// String orderNames = "<" + entity.getCustomer() + ">" + "欠款客户备案";
|
|
|
|
// variables.put("orderNames", orderNames);
|
|
|
|
LoanRepurchaseApply loanRepurchaseApply1 = fetchBySid(businessSid); |
|
|
|
String msgBusinessSid = loanRepurchaseApply1.getSid(); |
|
|
|
//用户的部门全路径sid
|
|
|
|
bv.setOrgSidPath(loanRepurchaseApply1.getOrgSidPath()); |
|
|
|
//业务sid
|
|
|
|
bv.setBusinessSid(businessSid); |
|
|
|
//用户sid
|
|
|
|
bv.setUserSid(dto.getUserSid()); |
|
|
|
bv.setFormVariables(variables); |
|
|
|
String nextNodeUserSids_ = sysOrganization.getManagerSid(); |
|
|
|
bv.setNextNodeUserSids(nextNodeUserSids_); |
|
|
|
// if (isTure) {
|
|
|
|
// bv.setNextNodeUserSids(nextNodeUserSids_);
|
|
|
|
// } else {
|
|
|
|
// bv.setNextNodeUserSids(entity.getSalesUserSid());
|
|
|
|
// }
|
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.LOANREPURCHASEAPPLY.getProDefId()); |
|
|
|
if (r == 1) { |
|
|
|
//流程定义id
|
|
|
|
bv.setModelId(ProcDefEnum.LOANREPURCHASEAPPLY.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(loanRepurchaseApply1.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"); |
|
|
|
} |
|
|
|
LoanRepurchaseApply loanRepurchaseApply2 = fetchBySid(dto.getSid()); |
|
|
|
bv.setTaskId(dto.getTaskId()); |
|
|
|
bv.setTaskDefKey(loanRepurchaseApply2.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(); |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = this.fetchBySid(businessSid); |
|
|
|
if (bv.getTaskId().equals(loanRepurchaseApply.getTaskId())) { |
|
|
|
bv.setOrgSidPath(loanRepurchaseApply.getOrgSidPath()); |
|
|
|
//流程中的参数赋值
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
// if (bv.getTaskDefKey().equals("Activity_1078xxs")) {
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getManageSid())) {
|
|
|
|
// bv.setNextNodeUserSids(loanCustomerRecord.getManageSid());
|
|
|
|
// } 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())) { |
|
|
|
LoanRepurchaseApply repurchaseApply = fetchBySid(businessSid); |
|
|
|
repurchaseApply.setCloseDate(new DateTime()); |
|
|
|
baseMapper.updateById(repurchaseApply); |
|
|
|
} else { |
|
|
|
//极光推送
|
|
|
|
loanRepurchaseApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
messageFlowVo.setProcDefId(loanRepurchaseApply.getProcDefId()); |
|
|
|
messageFlowVo.setProcInsId(loanRepurchaseApply.getProcInstId()); |
|
|
|
messageFlowableQuery.setUfVo(messageFlowVo); |
|
|
|
messageFlowableQuery.setAppMap(appMap); |
|
|
|
messageFlowableQuery.setBusinessSid(businessSid); |
|
|
|
messageFlowableQuery.setModuleName("回购申请"); |
|
|
|
messageFlowableQuery.setMsgContent(loanRepurchaseApply.getCreateByName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批"); |
|
|
|
messageFlowableQuery.setMsgTitle("回购申请"); |
|
|
|
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery); |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("操作失败!提交的数据不一致"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 撤回 |
|
|
|
* |
|
|
|
* @param query |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean revokeProcess(RepurchaseTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|
return rb.setMsg("参数错误:userSid"); |
|
|
|
} |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = loanRepurchaseApply.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())); |
|
|
|
loanRepurchaseApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String procId = loanRepurchaseApply.getProcInstId(); |
|
|
|
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskFeign.getLatestTasks(procId); |
|
|
|
String nextNodeUserSids = listResultBean.getData().get(0).getASSIGNEE_(); |
|
|
|
String nextName = listResultBean.getData().get(0).getName_(); |
|
|
|
List<String> receiveSidList = Arrays.asList(nextNodeUserSids.split(",")); |
|
|
|
if ("发起申请".equals(nextName)) { |
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.setMsg("操作失败,提交的数据不一致!"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean taskReject(RepurchaseTaskQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String businessSid = query.getBusinessSid(); |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(businessSid); |
|
|
|
if (loanRepurchaseApply == null) { |
|
|
|
return rb.setMsg("该申请不存在"); |
|
|
|
} |
|
|
|
String businessTaskId = loanRepurchaseApply.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<>(); |
|
|
|
Map<String, Object> appMap = new HashMap<>(); |
|
|
|
appMap.put("sid", businessSid); |
|
|
|
variables.put("app", appMap); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
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); |
|
|
|
//极光推送
|
|
|
|
loanRepurchaseApply = fetchBySid(businessSid); |
|
|
|
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(ufVo, messageFlowVo); |
|
|
|
String procId = loanRepurchaseApply.getProcInstId(); |
|
|
|
messageFlowVo.setProcInsId(procId); |
|
|
|
messageFlowVo.setProcDefId(loanRepurchaseApply.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(loanRepurchaseApply.getCreateBySid()).getData(); |
|
|
|
if (userVo != null) { |
|
|
|
if (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(RepurchaseTaskQuery 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("请填写意见"); |
|
|
|
} |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(query.getBusinessSid()); |
|
|
|
String businessTaskId = loanRepurchaseApply.getTaskId(); |
|
|
|
if (StringUtils.isNotBlank(businessTaskId)) { |
|
|
|
if (query.getUserSid().equals(loanRepurchaseApply.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<RepurchaseGetNodeVo>> getNextNodesForSubmit(RepurchaseGetNodeQuery query) { |
|
|
|
ResultBean<List<RepurchaseGetNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
|
|
|
|
//根据业务sid查询排产信息
|
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(query.getBusinessSid()); |
|
|
|
//若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
bv.setFormVariables(variables); |
|
|
|
bv.setModelId(loanRepurchaseApply.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getNextNodesForSubmit(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<RepurchaseGetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), RepurchaseGetNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<RepurchaseGetNodeVo>> getPreviousNodesForReject(RepurchaseGetNodeQuery query) { |
|
|
|
ResultBean<List<RepurchaseGetNodeVo>> rb = ResultBean.fireFail(); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(query, bv); |
|
|
|
//流程中的参数赋值、若有网关,则赋值网关中判断的字段。
|
|
|
|
Map<String, Object> variables = new HashMap<>(); |
|
|
|
//根据业务sid查询排产信息
|
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(query.getBusinessSid()); |
|
|
|
// //若有网关,则赋值网关中判断的字段。
|
|
|
|
// boolean isTure = true;
|
|
|
|
// //去查询是否同意
|
|
|
|
// if (StringUtils.isNotBlank(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// if (!loanCustomerRecord.getCreateBySid().equals(loanCustomerRecord.getSalesUserSid())) {
|
|
|
|
// isTure = false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// variables.put("isTure", isTure);
|
|
|
|
bv.setFormVariables(variables); |
|
|
|
bv.setModelId(loanRepurchaseApply.getProcDefId()); |
|
|
|
ResultBean<List<Map<String, Object>>> resultBean = flowTaskFeign.getPreviousNodesForReject(bv); |
|
|
|
//判断数组是否为空,若为空则赋值,若不为空,则遍历循环将map中的数据赋值给getNodeVo
|
|
|
|
List<RepurchaseGetNodeVo> voList = Optional.ofNullable(resultBean.getData()).orElse(new ArrayList<>()).stream().map(m -> JSON.parseObject(JSON.toJSONString(m), RepurchaseGetNodeVo.class)).collect(Collectors.toList()); |
|
|
|
return rb.success().setData(voList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delegate(RepurchaseDelegateQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FlowDelegateQuery delegateQuery = new FlowDelegateQuery(); |
|
|
|
BeanUtil.copyProperties(query, delegateQuery); |
|
|
|
flowFeign.delegate(delegateQuery); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<LoanSettleApplyDetailsVo> settleRepoInit(LoanRepoSettleApplyDetailsQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
LoanSettleApplyDetailsVo loanSettleApplyDetailsVo = new LoanSettleApplyDetailsVo(); |
|
|
|
String sid = query.getSid(); |
|
|
|
String orgPath = query.getOrgPath(); |
|
|
|
String userSid = query.getUserSid(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
LoanRepurchaseApply loanRepurchaseApply = fetchBySid(sid); |
|
|
|
if (null != loanRepurchaseApply) { |
|
|
|
//根据用户查询发起人、发起部门、发起日期为当前日期
|
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
String useOrgSid = ""; |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
useOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
} |
|
|
|
//根据用户sid查询人员姓名
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(userSid); |
|
|
|
if (!userVoResultBean.getSuccess()) { |
|
|
|
return rb.setMsg(userVoResultBean.getMsg()); |
|
|
|
} |
|
|
|
loanSettleApplyDetailsVo.setCreateDept(deptName); |
|
|
|
loanSettleApplyDetailsVo.setCreateDeptSid(deptSid); |
|
|
|
loanSettleApplyDetailsVo.setCreateByName(userVoResultBean.getData().getName()); |
|
|
|
loanSettleApplyDetailsVo.setCreateTime(DateUtil.today()); |
|
|
|
loanSettleApplyDetailsVo.setOrgPath(query.getOrgPath()); |
|
|
|
loanSettleApplyDetailsVo.setUserSid(query.getUserSid()); |
|
|
|
loanSettleApplyDetailsVo.setUseOrgSid(useOrgSid); |
|
|
|
loanSettleApplyDetailsVo.setSettingDate(DateUtil.today()); |
|
|
|
loanSettleApplyDetailsVo.setBusVinSid(loanRepurchaseApply.getBusVinSid()); |
|
|
|
loanSettleApplyDetailsVo.setSaleOrderSid(loanRepurchaseApply.getSalesOrderSid()); |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getVinNo())) { |
|
|
|
loanSettleApplyDetailsVo.setVinNo(loanRepurchaseApply.getVinNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getVehMark())) { |
|
|
|
loanSettleApplyDetailsVo.setVehMark(loanRepurchaseApply.getVehMark()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getCustomerName())) { |
|
|
|
loanSettleApplyDetailsVo.setCustomerName(loanRepurchaseApply.getCustomerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getCustomerSid())) { |
|
|
|
loanSettleApplyDetailsVo.setCustomerSid(loanRepurchaseApply.getCustomerSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getLoanName())) { |
|
|
|
loanSettleApplyDetailsVo.setLoanName(loanRepurchaseApply.getLoanName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getLoanSid())) { |
|
|
|
loanSettleApplyDetailsVo.setLoanSid(loanRepurchaseApply.getLoanSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getLoanContractNo())) { |
|
|
|
loanSettleApplyDetailsVo.setLoanContractNo(loanRepurchaseApply.getLoanContractNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getBankName())) { |
|
|
|
loanSettleApplyDetailsVo.setBankName(loanRepurchaseApply.getBankName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(loanRepurchaseApply.getBankContractNo())) { |
|
|
|
loanSettleApplyDetailsVo.setBankContractNo(loanRepurchaseApply.getBankContractNo()); |
|
|
|
} |
|
|
|
if (null != loanRepurchaseApply.getOverdueMonthPrice()) { |
|
|
|
loanSettleApplyDetailsVo.setOverdueMonthPrice(loanRepurchaseApply.getOverdueMonthPrice().toString()); |
|
|
|
} |
|
|
|
if (null != loanRepurchaseApply.getCurrentNotDuePrice()) { |
|
|
|
loanSettleApplyDetailsVo.setCurrentNotDuePrice(loanRepurchaseApply.getCurrentNotDuePrice().toString()); |
|
|
|
} |
|
|
|
if (null != loanRepurchaseApply.getNotDuePrice()) { |
|
|
|
loanSettleApplyDetailsVo.setNotDuePrice(loanRepurchaseApply.getNotDuePrice().toString()); |
|
|
|
} |
|
|
|
//资方结清费用
|
|
|
|
LoanSettleBankCostVo loanSettleBankCostVo = new LoanSettleBankCostVo(); |
|
|
|
LoanRepurchaseBankCostVo bankCostVo = loanRepurchaseCostService.getByMainSid(sid); |
|
|
|
BeanUtil.copyProperties(bankCostVo, loanSettleBankCostVo); |
|
|
|
List<LoanFile> bankFile = loanFileService.selectByLinkSid(sid, LoanFileEnum.REPURCHASE_BANKFILE.getAttachType()); |
|
|
|
bankFile.removeAll(Collections.singleton(null)); |
|
|
|
if (!bankFile.isEmpty()) { |
|
|
|
List<String> files = bankFile.stream().map(c -> fileUploadComponent.getUrlPrefix() + c.getFilePath()). |
|
|
|
collect(Collectors.toList()); |
|
|
|
List<UrlQuery> filesList = new ArrayList<>(); |
|
|
|
for (String file : files) { |
|
|
|
UrlQuery urlQuery = new UrlQuery(); |
|
|
|
urlQuery.setUrl(file); |
|
|
|
filesList.add(urlQuery); |
|
|
|
} |
|
|
|
loanSettleBankCostVo.setFilesList(filesList); |
|
|
|
} |
|
|
|
loanSettleApplyDetailsVo.setLoanSettleBankCostVo(loanSettleBankCostVo); |
|
|
|
//公司结清费用
|
|
|
|
LoanSettleCompanyCostVo loanSettleCompanyCostVo = new LoanSettleCompanyCostVo(); |
|
|
|
LoanRepurchaseCompanyCostVo companyCostVo = loanRepurchaseCompanyCostService.getByMainSid(sid); |
|
|
|
BeanUtil.copyProperties(companyCostVo, loanSettleCompanyCostVo); |
|
|
|
BigDecimal settleAll = new BigDecimal(0); //回购申请中正常合计
|
|
|
|
BigDecimal amount = new BigDecimal(0); //回购金额
|
|
|
|
if (StringUtils.isNotBlank(companyCostVo.getSettleAll())) { |
|
|
|
settleAll = new BigDecimal(companyCostVo.getSettleAll()); |
|
|
|
} |
|
|
|
if (null != loanRepurchaseApply.getAmount()) { |
|
|
|
amount = loanRepurchaseApply.getAmount(); |
|
|
|
} |
|
|
|
loanSettleCompanyCostVo.setSettleAll((settleAll.subtract(amount)).toString()); |
|
|
|
loanSettleApplyDetailsVo.setLoanSettleCompanyCostVo(loanSettleCompanyCostVo); |
|
|
|
} |
|
|
|
return rb.success().setData(loanSettleApplyDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|