|
@ -1,9 +1,17 @@ |
|
|
package com.qs.serve.modules.vtb.service.impl; |
|
|
package com.qs.serve.modules.vtb.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
import com.qs.serve.common.config.properties.ProjectProperties; |
|
|
import com.qs.serve.common.framework.redis.RedisService; |
|
|
import com.qs.serve.common.framework.redis.RedisService; |
|
|
|
|
|
import com.qs.serve.common.model.dto.R; |
|
|
|
|
|
import com.qs.serve.common.model.oa.OaFormMainProcess; |
|
|
|
|
|
import com.qs.serve.common.model.oa.OaUploadFile; |
|
|
import com.qs.serve.common.util.*; |
|
|
import com.qs.serve.common.util.*; |
|
|
|
|
|
import com.qs.serve.common.util.model.DateFormatString; |
|
|
import com.qs.serve.modules.bms.entity.*; |
|
|
import com.qs.serve.modules.bms.entity.*; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
@ -13,28 +21,39 @@ import com.qs.serve.modules.bms.service.BmsSubjectService; |
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
import com.qs.serve.modules.pay.entity.PayWay; |
|
|
import com.qs.serve.modules.pay.entity.PayWay; |
|
|
import com.qs.serve.modules.pay.mapper.PayWayMapper; |
|
|
import com.qs.serve.modules.pay.mapper.PayWayMapper; |
|
|
|
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateCallbackBo; |
|
|
|
|
|
import com.qs.serve.modules.seeyon.service.SeeYonRequestService; |
|
|
|
|
|
import com.qs.serve.modules.sys.entity.SysAttach; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
|
|
|
import com.qs.serve.modules.sys.service.SysAttachService; |
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
|
|
|
import com.qs.serve.modules.tag.mapper.TagInfoMapper; |
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
|
|
|
import com.qs.serve.modules.tbs.common.TbsSeeYonConst; |
|
|
import com.qs.serve.modules.tbs.entity.TbsActivity; |
|
|
import com.qs.serve.modules.tbs.entity.TbsActivity; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsActivityCenter; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.TbsActivitySubject; |
|
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
|
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
|
|
|
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsCostSubItem; |
|
|
|
|
|
import com.qs.serve.modules.tbs.service.TbsActivityCenterService; |
|
|
import com.qs.serve.modules.tbs.service.TbsActivityService; |
|
|
import com.qs.serve.modules.tbs.service.TbsActivityService; |
|
|
|
|
|
import com.qs.serve.modules.tbs.service.TbsActivitySubjectService; |
|
|
import com.qs.serve.modules.tbs.service.TbsCostApplyService; |
|
|
import com.qs.serve.modules.tbs.service.TbsCostApplyService; |
|
|
import com.qs.serve.modules.vtb.common.VerificationUtil; |
|
|
import com.qs.serve.modules.vtb.common.VerificationUtil; |
|
|
import com.qs.serve.modules.vtb.common.VtbVerificationState; |
|
|
import com.qs.serve.modules.vtb.common.VtbVerificationState; |
|
|
import com.qs.serve.modules.vtb.entity.*; |
|
|
import com.qs.serve.modules.vtb.entity.*; |
|
|
import com.qs.serve.modules.vtb.entity.bo.*; |
|
|
import com.qs.serve.modules.vtb.entity.bo.*; |
|
|
|
|
|
import com.qs.serve.modules.vtb.entity.dto.VtbSubjectDTO; |
|
|
import com.qs.serve.modules.vtb.service.*; |
|
|
import com.qs.serve.modules.vtb.service.*; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.qs.serve.modules.vtb.mapper.VtbVerificationBatchMapper; |
|
|
import com.qs.serve.modules.vtb.mapper.VtbVerificationBatchMapper; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.HashMap; |
|
|
import java.util.*; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -53,6 +72,8 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
private final BmsSupplierService bmsSupplierService; |
|
|
private final BmsSupplierService bmsSupplierService; |
|
|
private final TbsActivityService tbsActivityService; |
|
|
private final TbsActivityService tbsActivityService; |
|
|
private final TbsCostApplyService tbsCostApplyService; |
|
|
private final TbsCostApplyService tbsCostApplyService; |
|
|
|
|
|
private final TbsActivitySubjectService tbsActivitySubjectService; |
|
|
|
|
|
private final TbsActivityCenterService tbsActivityCenterService; |
|
|
private final SysUserService sysUserService; |
|
|
private final SysUserService sysUserService; |
|
|
private final VtbVerificationService vtbVerificationService; |
|
|
private final VtbVerificationService vtbVerificationService; |
|
|
private final PayWayMapper payWayMapper; |
|
|
private final PayWayMapper payWayMapper; |
|
@ -64,16 +85,21 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
private final VtbVerificationSubjectService verificationSubjectService; |
|
|
private final VtbVerificationSubjectService verificationSubjectService; |
|
|
private final VtbVerificationSubjectCenterService vtbVerificationSubjectCenterService; |
|
|
private final VtbVerificationSubjectCenterService vtbVerificationSubjectCenterService; |
|
|
private final VtbFundFlowService vtbFundFlowService; |
|
|
private final VtbFundFlowService vtbFundFlowService; |
|
|
|
|
|
private final ProjectProperties projectProperties; |
|
|
|
|
|
private final TagInfoMapper tagInfoMapper; |
|
|
|
|
|
private SysAttachService sysAttachService; |
|
|
|
|
|
private SeeYonRequestService seeYonService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void submit(VtbVerificationBatchBo submitBo) { |
|
|
public void submit(VtbVerificationBatchBo submitBo) { |
|
|
|
|
|
String templateCode = TbsSeeYonConst.BatchCostCheckConf.Code(); |
|
|
TbsCostApply costApply = tbsCostApplyService.getById(submitBo.getCostApplyId()); |
|
|
TbsCostApply costApply = tbsCostApplyService.getById(submitBo.getCostApplyId()); |
|
|
BmsSupplier supplier = bmsSupplierService.getById(costApply.getSupplierId()); |
|
|
BmsSupplier supplier = bmsSupplierService.getById(costApply.getSupplierId()); |
|
|
List<TbsActivity> activityList = tbsActivityService.listByCostApplyId(costApply.getId()); |
|
|
List<TbsActivity> activityList = tbsActivityService.listByCostApplyId(costApply.getId()); |
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
sysUser.checkSyAccount(); |
|
|
sysUser.checkSyAccount(); |
|
|
redisService.throwResLock(VtbVerificationBatch.class.getSimpleName(),submitBo.getCostApplyId()+""); |
|
|
//redisService.throwResLock(VtbVerificationBatch.class.getSimpleName(),submitBo.getCostApplyId()+"");
|
|
|
// 校验核销状态
|
|
|
// 校验核销状态
|
|
|
VerificationUtil.verifyCostState(costApply); |
|
|
VerificationUtil.verifyCostState(costApply); |
|
|
|
|
|
|
|
@ -117,7 +143,186 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
List<VtbVerificationSubject> allVerificationSubjects = new ArrayList<>(); |
|
|
List<VtbVerificationSubject> allVerificationSubjects = new ArrayList<>(); |
|
|
List<VtbVerificationSubjectCenter> allVerificationCenters = new ArrayList<>(); |
|
|
List<VtbVerificationSubjectCenter> allVerificationCenters = new ArrayList<>(); |
|
|
|
|
|
|
|
|
//校验BO参数
|
|
|
//主创建方法,校验BO参数和创建数据
|
|
|
|
|
|
this.mainCheckAndCreateBatchItemData(submitBo, costApply, supplier, activityList, sysUser, payWay, |
|
|
|
|
|
orgVerificationIds, newVerificationList, allVerificationChannelList, allVerificationChannelPointList, |
|
|
|
|
|
allVerificationSubjects, allVerificationCenters); |
|
|
|
|
|
|
|
|
|
|
|
VtbVerificationBatch verificationBatch = new VtbVerificationBatch(); |
|
|
|
|
|
verificationBatch.setVtbBatchCode("VB"+ CodeGenUtil.generate(CodeGenUtil.SourceKey.VerificationBatch)); |
|
|
|
|
|
verificationBatch.setVtbBatchStatus(0); |
|
|
|
|
|
verificationBatch.setCostApplyId(costApply.getId()); |
|
|
|
|
|
//verificationBatch.setRemark();
|
|
|
|
|
|
//verificationBatch.setSyFormId();
|
|
|
|
|
|
//verificationBatch.setSyFlowId();
|
|
|
|
|
|
verificationBatch.setSupplierId(supplier.getId()); |
|
|
|
|
|
verificationBatch.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
verificationBatch.setSupplierName(supplier.getName()); |
|
|
|
|
|
verificationBatch.setUserId(sysUser.getId()); |
|
|
|
|
|
verificationBatch.setUserCode(sysUser.getCode()); |
|
|
|
|
|
verificationBatch.setUserName(sysUser.getName()); |
|
|
|
|
|
this.save(verificationBatch); |
|
|
|
|
|
|
|
|
|
|
|
String batchId = verificationBatch.getId()+""; |
|
|
|
|
|
Map<String, Object> newWayData = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>(); |
|
|
|
|
|
data.put("title", verificationBatch.getVtbBatchCode()); |
|
|
|
|
|
data.put("orgId", batchId); |
|
|
|
|
|
data.put("targetId", batchId); |
|
|
|
|
|
data.put("targetCode", verificationBatch.getVtbBatchCode()); |
|
|
|
|
|
data.put("applyUserCode", sysUser.getCode()); |
|
|
|
|
|
data.put("applyUserName", sysUser.getName()); |
|
|
|
|
|
data.put("supplierName", supplier.getName()); |
|
|
|
|
|
data.put("supplierCode", supplier.getCode()); |
|
|
|
|
|
data.put("exsp1",templateCode); |
|
|
|
|
|
data.put("exsp2", saleBizNames); |
|
|
|
|
|
data.put("biz_region", bizBizNames); |
|
|
|
|
|
//添加跳转地址业务
|
|
|
|
|
|
String urlKey = "exsp5"; |
|
|
|
|
|
String baseJumpUrl = JumpToUtil.getJumpUrl(projectProperties.getWebUrl(),TbsSeeYonConst.BatchCostCheckConf.Code(),batchId); |
|
|
|
|
|
data.put("exsp5",urlKey); |
|
|
|
|
|
data.put("cmsLink",baseJumpUrl); |
|
|
|
|
|
data.put("rowDate",DateUtils.format(LocalDateTime.now(), DateFormatString.DATE_TIME)); |
|
|
|
|
|
data.put("rowState","00"); |
|
|
|
|
|
//添加客户标签
|
|
|
|
|
|
List<String> tags = tagInfoMapper.lisTagsBySupplierCode(supplier.getCode()); |
|
|
|
|
|
data.put("tags",tags); |
|
|
|
|
|
|
|
|
|
|
|
List<String> oaAttachmentsIdList = new ArrayList<>(); |
|
|
|
|
|
submitBo.getVerificationList().forEach(obj->{ |
|
|
|
|
|
if(obj.getAttachIds()!=null && obj.getAttachIds().length>0){ |
|
|
|
|
|
oaAttachmentsIdList.addAll(Arrays.asList(obj.getAttachIds())); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//科目
|
|
|
|
|
|
List<TbsActivitySubject> subjectList = tbsActivitySubjectService.listByCostApplyId(costApply.getId()); |
|
|
|
|
|
List<VtbSubjectDTO> subjectDTOList = new ArrayList<>(); |
|
|
|
|
|
for (TbsActivitySubject activitySubject : subjectList) { |
|
|
|
|
|
VtbSubjectDTO subjectDTO = new VtbSubjectDTO(); |
|
|
|
|
|
subjectDTO.setKeMuName(activitySubject.getSubjectName()); |
|
|
|
|
|
subjectDTOList.add(subjectDTO); |
|
|
|
|
|
} |
|
|
|
|
|
newWayData.put("formson_2180",subjectDTOList); |
|
|
|
|
|
|
|
|
|
|
|
//成本中心
|
|
|
|
|
|
List<Object> centerDataList = new ArrayList<>(); |
|
|
|
|
|
List<TbsActivityCenter> activityCenter = tbsActivityCenterService.listByCostApplyId(costApply.getId()); |
|
|
|
|
|
for(TbsActivityCenter center : activityCenter){ |
|
|
|
|
|
TbsCostSubItem.CostCenterTranStr costCenter = new TbsCostSubItem.CostCenterTranStr(); |
|
|
|
|
|
if(costCenter.getChengBenZhongXin()==null){ |
|
|
|
|
|
costCenter.setChengBenZhongXin(center.getCenterName()); |
|
|
|
|
|
costCenter.setChengBenZhongXinId(center.getCenterType()+"-"+center.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
centerDataList.add(costCenter); |
|
|
|
|
|
} |
|
|
|
|
|
newWayData.put("formson_2179",centerDataList); |
|
|
|
|
|
|
|
|
|
|
|
//加载附件
|
|
|
|
|
|
List<OaUploadFile> uploadFileList = new ArrayList<>(); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(oaAttachmentsIdList)){ |
|
|
|
|
|
List<SysAttach> attachList = sysAttachService.listByIds(oaAttachmentsIdList); |
|
|
|
|
|
for (SysAttach sysAttach : attachList) { |
|
|
|
|
|
OaUploadFile uploadFile = new OaUploadFile(); |
|
|
|
|
|
uploadFile.setField("file"); |
|
|
|
|
|
uploadFile.setName("核销附件"+sysAttach.getName()); |
|
|
|
|
|
uploadFile.setUrl("https://qsjslservice.oss-cn-guangzhou.aliyuncs.com/"+sysAttach.getRelativePath()); |
|
|
|
|
|
uploadFileList.add(uploadFile); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OaFormMainProcess mainProcess = new OaFormMainProcess(); |
|
|
|
|
|
mainProcess.setTargetId(batchId); |
|
|
|
|
|
mainProcess.setUploadFiles(uploadFileList); |
|
|
|
|
|
newWayData.put("formmain_2178",data); |
|
|
|
|
|
mainProcess.setTableName("formmain_2178"); |
|
|
|
|
|
mainProcess.setData(newWayData); |
|
|
|
|
|
mainProcess.setTemplateCode(templateCode); |
|
|
|
|
|
mainProcess.setUserId(sysUser.getId()); |
|
|
|
|
|
mainProcess.setSenderLoginName(sysUser.getAccount()); |
|
|
|
|
|
R flowIdResult = seeYonService.newCreateProcess(mainProcess); |
|
|
|
|
|
|
|
|
|
|
|
if(flowIdResult==null||flowIdResult.getStatus()!=200){ |
|
|
|
|
|
assert flowIdResult != null; |
|
|
|
|
|
Assert.throwEx("远程服务调用失败:"+flowIdResult.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
if(flowIdResult.getMsg()!=null && flowIdResult.getMsg().length()>45){ |
|
|
|
|
|
log.error(flowIdResult.getMsg()); |
|
|
|
|
|
JSONObject object = JSON.parseObject(flowIdResult.getMsg()); |
|
|
|
|
|
if(!object.get("code").toString().equals("0")){ |
|
|
|
|
|
Assert.throwEx("流程发起被拦截了"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//移除历史提交记录
|
|
|
|
|
|
for (Long orgVerificationId : orgVerificationIds) { |
|
|
|
|
|
verificationChannelService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
verificationChannelPointService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
verificationSubjectService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
vtbVerificationSubjectCenterService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
vtbFundFlowService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<Long,List<VtbVerificationChannel>> allVerificationChannelListMap = allVerificationChannelList.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(VtbVerificationChannel::getVerificationId)); |
|
|
|
|
|
Map<Long,List<VtbVerificationChannelPoint>> allVerificationChannelPointListMap = allVerificationChannelPointList.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(VtbVerificationChannelPoint::getVerificationId)); |
|
|
|
|
|
|
|
|
|
|
|
Map<Long,List<VtbVerificationSubject>> allVerificationSubjectsMap = allVerificationSubjects.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(VtbVerificationSubject::getVerificationId)); |
|
|
|
|
|
Map<Long,List<VtbVerificationSubjectCenter>> allVerificationCentersMap = allVerificationCenters.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(VtbVerificationSubjectCenter::getVerificationId)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (VtbVerification verification : newVerificationList) { |
|
|
|
|
|
//临时ID,实际是活动ID
|
|
|
|
|
|
Long tmpId = verification.getId(); |
|
|
|
|
|
|
|
|
|
|
|
verification.setId(null); |
|
|
|
|
|
//关联批量ID
|
|
|
|
|
|
verification.setBatchId(batchId); |
|
|
|
|
|
vtbVerificationService.save(verification); |
|
|
|
|
|
Long verificationId = verification.getId(); |
|
|
|
|
|
|
|
|
|
|
|
this.saveVerificationRelateData(allVerificationChannelListMap, allVerificationChannelPointListMap, allVerificationSubjectsMap, allVerificationCentersMap, tmpId, verificationId); |
|
|
|
|
|
|
|
|
|
|
|
//更新活动状态
|
|
|
|
|
|
TbsActivity activityParam = new TbsActivity(); |
|
|
|
|
|
activityParam.setId(verification.getActivityId()); |
|
|
|
|
|
activityParam.setActivityState(TbsActivityState.STATE_1_Checking); |
|
|
|
|
|
activityParam.setCurrVerificationId(verification.getId()+""); |
|
|
|
|
|
tbsActivityService.updateById(activityParam); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//更变费用申请的活动状态
|
|
|
|
|
|
TbsCostApply costApplyParam = new TbsCostApply(); |
|
|
|
|
|
costApplyParam.setId(costApply.getId()); |
|
|
|
|
|
costApplyParam.setCheckState(1); |
|
|
|
|
|
tbsCostApplyService.updateById(costApplyParam); |
|
|
|
|
|
|
|
|
|
|
|
BaseCreateCallbackBo callbackBo = new BaseCreateCallbackBo(templateCode,batchId); |
|
|
|
|
|
seeYonService.createCallbackStatus(callbackBo); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 主创建方法,校验BO参数和创建数据 |
|
|
|
|
|
* @param submitBo |
|
|
|
|
|
* @param costApply |
|
|
|
|
|
* @param supplier |
|
|
|
|
|
* @param activityList |
|
|
|
|
|
* @param sysUser |
|
|
|
|
|
* @param payWay |
|
|
|
|
|
* @param orgVerificationIds |
|
|
|
|
|
* @param newVerificationList |
|
|
|
|
|
* @param allVerificationChannelList |
|
|
|
|
|
* @param allVerificationChannelPointList |
|
|
|
|
|
* @param allVerificationSubjects |
|
|
|
|
|
* @param allVerificationCenters |
|
|
|
|
|
*/ |
|
|
|
|
|
private void mainCheckAndCreateBatchItemData(VtbVerificationBatchBo submitBo, TbsCostApply costApply, BmsSupplier supplier, List<TbsActivity> activityList, SysUser sysUser, PayWay payWay, List<Long> orgVerificationIds, List<VtbVerification> newVerificationList, List<VtbVerificationChannel> allVerificationChannelList, List<VtbVerificationChannelPoint> allVerificationChannelPointList, List<VtbVerificationSubject> allVerificationSubjects, List<VtbVerificationSubjectCenter> allVerificationCenters) { |
|
|
for (VtbVerificationBo verificationBo : submitBo.getVerificationList()) { |
|
|
for (VtbVerificationBo verificationBo : submitBo.getVerificationList()) { |
|
|
for (TbsActivity activity : activityList) { |
|
|
for (TbsActivity activity : activityList) { |
|
|
if(verificationBo.getActivityId().equals(activity.getId())){ |
|
|
if(verificationBo.getActivityId().equals(activity.getId())){ |
|
@ -141,9 +346,59 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
|
|
|
|
|
|
//创建 verification
|
|
|
//创建 verification
|
|
|
VtbVerification verification = new VtbVerification(); |
|
|
VtbVerification verification = new VtbVerification(); |
|
|
//临时ID
|
|
|
//临时ID 使用活动ID
|
|
|
verification.setId(activity.getId()); |
|
|
verification.setId(activity.getId()); |
|
|
|
|
|
// 给核销赋值
|
|
|
|
|
|
this.verificationSetAssign(costApply, sysUser, payWay, verificationBo, activity, verification); |
|
|
|
|
|
//创建核销相关数据(未存入数据库)
|
|
|
|
|
|
this.buildVerificationRelateData(costApply, allVerificationChannelList, allVerificationChannelPointList, |
|
|
|
|
|
verificationBo, activity, verification); |
|
|
|
|
|
|
|
|
|
|
|
List<VtbVerificationSubject> verificationSubjects = new ArrayList<>(); |
|
|
|
|
|
List<VtbVerificationSubjectCenter> verificationCenters = new ArrayList<>(); |
|
|
|
|
|
String verificationCode = verification.getVerificationCode(); |
|
|
|
|
|
if(isCenterCheck){ |
|
|
|
|
|
//建立核销 VtbVerificationSubjectCenter
|
|
|
|
|
|
vtbVerificationService.validCreateVeriSubjectAndCenter(activity, subjectCenterBoList, costApply, supplier, verificationSubjects, verificationCenters, verificationCode); |
|
|
|
|
|
}else { |
|
|
|
|
|
//建立核销 VtbVerificationSubject
|
|
|
|
|
|
verificationSubjects = vtbVerificationService.validCreateVeriSubject(verificationCode,verificationBo, activity, costApply, supplier); |
|
|
|
|
|
} |
|
|
|
|
|
//设置总金额
|
|
|
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO; |
|
|
|
|
|
for (VtbVerificationSubject verificationSubject : verificationSubjects) { |
|
|
|
|
|
totalAmount = totalAmount.add(verificationSubject.getUsedAmount()); |
|
|
|
|
|
} |
|
|
|
|
|
verification.setAmount(totalAmount); |
|
|
|
|
|
verification.setAmountRecord(totalAmount); |
|
|
|
|
|
|
|
|
|
|
|
//保存
|
|
|
|
|
|
newVerificationList.add(verification); |
|
|
|
|
|
|
|
|
|
|
|
//保存科目费用
|
|
|
|
|
|
verificationSubjects.forEach(obj->obj.setVerificationId(verification.getId())); |
|
|
|
|
|
verificationCenters.forEach(obj->obj.setVerificationId(verification.getId())); |
|
|
|
|
|
|
|
|
|
|
|
allVerificationSubjects.addAll(verificationSubjects); |
|
|
|
|
|
allVerificationCenters.addAll(verificationCenters); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 给核销赋值 |
|
|
|
|
|
* @param costApply |
|
|
|
|
|
* @param sysUser |
|
|
|
|
|
* @param payWay |
|
|
|
|
|
* @param verificationBo |
|
|
|
|
|
* @param activity |
|
|
|
|
|
* @param verification |
|
|
|
|
|
*/ |
|
|
|
|
|
private void verificationSetAssign(TbsCostApply costApply, SysUser sysUser, PayWay payWay, |
|
|
|
|
|
VtbVerificationBo verificationBo, TbsActivity activity, |
|
|
|
|
|
VtbVerification verification) { |
|
|
verification.setCostApplyCode(costApply.getCode()); |
|
|
verification.setCostApplyCode(costApply.getCode()); |
|
|
verification.setActivityCode(activity.getActivityCode()); |
|
|
verification.setActivityCode(activity.getActivityCode()); |
|
|
verification.setPayConditionId(verificationBo.getPayConditionId()); |
|
|
verification.setPayConditionId(verificationBo.getPayConditionId()); |
|
@ -154,7 +409,7 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
verification.setActivityId(verificationBo.getActivityId()); |
|
|
verification.setActivityId(verificationBo.getActivityId()); |
|
|
verification.setAttachIds(verificationBo.getAttachIds()); |
|
|
verification.setAttachIds(verificationBo.getAttachIds()); |
|
|
verification.setInputReleaseFlag(verificationBo.getInputReleaseFlag()); |
|
|
verification.setInputReleaseFlag(verificationBo.getInputReleaseFlag()); |
|
|
if(verificationBo.getInputReleaseFlag()!=null&&verificationBo.getInputReleaseFlag().equals(0)){ |
|
|
if(verificationBo.getInputReleaseFlag()!=null&& verificationBo.getInputReleaseFlag().equals(0)){ |
|
|
verification.setRegReleaseFlag(1); |
|
|
verification.setRegReleaseFlag(1); |
|
|
} |
|
|
} |
|
|
verification.setSupplierId(activity.getSupplierId()); |
|
|
verification.setSupplierId(activity.getSupplierId()); |
|
@ -169,6 +424,21 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
verification.setSupplierBizRegionFirstName(costApply.getSupplierBizRegionFirstName()); |
|
|
verification.setSupplierBizRegionFirstName(costApply.getSupplierBizRegionFirstName()); |
|
|
verification.setSupplierBizRegionSecondName(costApply.getSupplierBizRegionSecondName()); |
|
|
verification.setSupplierBizRegionSecondName(costApply.getSupplierBizRegionSecondName()); |
|
|
verification.setSupplierBizRegionThirdName(costApply.getSupplierBizRegionThirdName()); |
|
|
verification.setSupplierBizRegionThirdName(costApply.getSupplierBizRegionThirdName()); |
|
|
|
|
|
verification.setRemark(verificationBo.getRemark()); |
|
|
|
|
|
verification.setWayId(verificationBo.getPayWayId()); |
|
|
|
|
|
verification.setWayTitle(payWay.getTitle()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建核销相关数据(未存入数据库) |
|
|
|
|
|
* @param costApply |
|
|
|
|
|
* @param allVerificationChannelList |
|
|
|
|
|
* @param allVerificationChannelPointList |
|
|
|
|
|
* @param verificationBo |
|
|
|
|
|
* @param activity |
|
|
|
|
|
* @param verification |
|
|
|
|
|
*/ |
|
|
|
|
|
private void buildVerificationRelateData(TbsCostApply costApply, List<VtbVerificationChannel> allVerificationChannelList, List<VtbVerificationChannelPoint> allVerificationChannelPointList, VtbVerificationBo verificationBo, TbsActivity activity, VtbVerification verification) { |
|
|
List<VtbVerificationChannelBo> channelBoList = verificationBo.getChannelList(); |
|
|
List<VtbVerificationChannelBo> channelBoList = verificationBo.getChannelList(); |
|
|
List<VtbVerificationChannelPointBo> pointBoList = verificationBo.getPointList(); |
|
|
List<VtbVerificationChannelPointBo> pointBoList = verificationBo.getPointList(); |
|
|
if(CollectionUtil.isNotEmpty(channelBoList)){ |
|
|
if(CollectionUtil.isNotEmpty(channelBoList)){ |
|
@ -205,72 +475,18 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
allVerificationChannelPointList.add(channelPoint1); |
|
|
allVerificationChannelPointList.add(channelPoint1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
List<VtbVerificationSubject> verificationSubjects = new ArrayList<>(); |
|
|
|
|
|
List<VtbVerificationSubjectCenter> verificationCenters = new ArrayList<>(); |
|
|
|
|
|
String verificationCode = verification.getVerificationCode(); |
|
|
|
|
|
if(isCenterCheck){ |
|
|
|
|
|
//建立核销 VtbVerificationSubjectCenter
|
|
|
|
|
|
vtbVerificationService.validCreateVeriSubjectAndCenter(activity, subjectCenterBoList, costApply, supplier, verificationSubjects, verificationCenters, verificationCode); |
|
|
|
|
|
}else { |
|
|
|
|
|
//建立核销 VtbVerificationSubject
|
|
|
|
|
|
verificationSubjects = vtbVerificationService.validCreateVeriSubject(verificationCode,verificationBo, activity, costApply, supplier); |
|
|
|
|
|
} |
|
|
|
|
|
//设置总金额
|
|
|
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO; |
|
|
|
|
|
for (VtbVerificationSubject verificationSubject : verificationSubjects) { |
|
|
|
|
|
totalAmount = totalAmount.add(verificationSubject.getUsedAmount()); |
|
|
|
|
|
} |
|
|
|
|
|
verification.setAmount(totalAmount); |
|
|
|
|
|
verification.setAmountRecord(totalAmount); |
|
|
|
|
|
|
|
|
|
|
|
//保存
|
|
|
|
|
|
newVerificationList.add(verification); |
|
|
|
|
|
|
|
|
|
|
|
//保存科目费用
|
|
|
|
|
|
verificationSubjects.forEach(obj->obj.setVerificationId(verification.getId())); |
|
|
|
|
|
verificationCenters.forEach(obj->obj.setVerificationId(verification.getId())); |
|
|
|
|
|
|
|
|
|
|
|
allVerificationSubjects.addAll(verificationSubjects); |
|
|
|
|
|
allVerificationCenters.addAll(verificationCenters); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO 提交审批
|
|
|
|
|
|
|
|
|
|
|
|
//移除历史提交记录
|
|
|
|
|
|
for (Long orgVerificationId : orgVerificationIds) { |
|
|
|
|
|
verificationChannelService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
verificationChannelPointService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
verificationSubjectService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
vtbVerificationSubjectCenterService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
vtbFundFlowService.removeByVerificationId(orgVerificationId); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//获取临时ID重新赋值
|
|
|
/** |
|
|
//List<Long> activityIds = newVerificationList.stream().map(VtbVerification::getId).collect(Collectors.toList());
|
|
|
* 保存核销相关数据 |
|
|
|
|
|
* @param allVerificationChannelListMap |
|
|
Map<Long,List<VtbVerificationChannel>> allVerificationChannelListMap = allVerificationChannelList.stream() |
|
|
* @param allVerificationChannelPointListMap |
|
|
.collect(Collectors.groupingBy(VtbVerificationChannel::getVerificationId)); |
|
|
* @param allVerificationSubjectsMap |
|
|
Map<Long,List<VtbVerificationChannelPoint>> allVerificationChannelPointListMap = allVerificationChannelPointList.stream() |
|
|
* @param allVerificationCentersMap |
|
|
.collect(Collectors.groupingBy(VtbVerificationChannelPoint::getVerificationId)); |
|
|
* @param tmpId |
|
|
|
|
|
* @param verificationId |
|
|
Map<Long,List<VtbVerificationSubject>> allVerificationSubjectsMap = allVerificationSubjects.stream() |
|
|
*/ |
|
|
.collect(Collectors.groupingBy(VtbVerificationSubject::getVerificationId)); |
|
|
private void saveVerificationRelateData(Map<Long, List<VtbVerificationChannel>> allVerificationChannelListMap, Map<Long, List<VtbVerificationChannelPoint>> allVerificationChannelPointListMap, Map<Long, List<VtbVerificationSubject>> allVerificationSubjectsMap, Map<Long, List<VtbVerificationSubjectCenter>> allVerificationCentersMap, Long tmpId, Long verificationId) { |
|
|
Map<Long,List<VtbVerificationSubjectCenter>> allVerificationCentersMap = allVerificationCenters.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(VtbVerificationSubjectCenter::getVerificationId)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (VtbVerification verification : newVerificationList) { |
|
|
|
|
|
//临时ID,实际是活动ID
|
|
|
|
|
|
Long tmpId = verification.getId(); |
|
|
|
|
|
|
|
|
|
|
|
verification.setId(null); |
|
|
|
|
|
vtbVerificationService.save(verification); |
|
|
|
|
|
Long verificationId = verification.getId(); |
|
|
|
|
|
|
|
|
|
|
|
List<VtbVerificationChannel> vtbVerificationChannels = allVerificationChannelListMap.get(tmpId); |
|
|
List<VtbVerificationChannel> vtbVerificationChannels = allVerificationChannelListMap.get(tmpId); |
|
|
if(vtbVerificationChannels!=null){ |
|
|
if(vtbVerificationChannels!=null){ |
|
|
vtbVerificationChannels.forEach(a->a.setVerificationId(verificationId)); |
|
|
vtbVerificationChannels.forEach(a->a.setVerificationId(verificationId)); |
|
@ -294,22 +510,6 @@ public class VtbVerificationBatchServiceImpl extends ServiceImpl<VtbVerification |
|
|
vtbVerificationSubjectCenterList.forEach(a->a.setVerificationId(verificationId)); |
|
|
vtbVerificationSubjectCenterList.forEach(a->a.setVerificationId(verificationId)); |
|
|
vtbVerificationSubjectCenterService.saveBatch(vtbVerificationSubjectCenterList); |
|
|
vtbVerificationSubjectCenterService.saveBatch(vtbVerificationSubjectCenterList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//更新活动状态
|
|
|
|
|
|
TbsActivity activityParam = new TbsActivity(); |
|
|
|
|
|
activityParam.setId(verification.getActivityId()); |
|
|
|
|
|
activityParam.setActivityState(TbsActivityState.STATE_1_Checking); |
|
|
|
|
|
activityParam.setCurrVerificationId(verification.getId()+""); |
|
|
|
|
|
tbsActivityService.updateById(activityParam); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//更变费用申请的活动状态
|
|
|
|
|
|
TbsCostApply costApplyParam = new TbsCostApply(); |
|
|
|
|
|
costApplyParam.setId(costApply.getId()); |
|
|
|
|
|
costApplyParam.setCheckState(1); |
|
|
|
|
|
tbsCostApplyService.updateById(costApplyParam); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|