|
|
@ -26,46 +26,50 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmcollectionrebatecheckapply; |
|
|
|
|
|
|
|
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.yxt.anrui.base.api.basemanufacturer.BaseManufacturer; |
|
|
|
import com.yxt.anrui.base.api.basemanufacturer.BaseManufacturerFeign; |
|
|
|
import com.yxt.anrui.base.api.basevehiclebrand.BaseVehicleBrand; |
|
|
|
import com.yxt.anrui.base.api.basevehiclebrand.BaseVehicleBrandFeign; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.GeneralVoucher; |
|
|
|
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.flowable.api.flow2.FlowFeign; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign; |
|
|
|
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.scm.api.flow.FlowTaskVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebate; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapply.*; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapply.flow.SubmitScmCollectionRebateCheckApplyDto; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapplydetail.ScmCollectionrebateCheckapplydetail; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapplydetail.ScmCollectionrebateCheckapplydetailDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapplydetail.ScmCollectionrebateCheckapplydetailDto; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapplydetail.ScmCollectionrebateCheckapplydetailVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.ScmCollectionRebateWithApplyVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.flow.GetNodeQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatewithapply.flow.GetNodeVo; |
|
|
|
import com.yxt.anrui.scm.biz.scmcollectionrebate.ScmCollectionRebateService; |
|
|
|
import com.yxt.anrui.scm.biz.scmcollectionrebatecheckapplydetail.ScmCollectionrebateCheckapplydetailService; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
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.anrui.scm.api.scmcollectionrebatecheckapply.ScmCollectionrebateCheckapply; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapply.ScmCollectionrebateCheckapplyQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapply.ScmCollectionrebateCheckapplyVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapply.ScmCollectionrebateCheckapplyDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatecheckapply.ScmCollectionrebateCheckapplyDto; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -85,6 +89,14 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class ScmCollectionrebateCheckapplyService extends MybatisBaseService<ScmCollectionrebateCheckapplyMapper, ScmCollectionrebateCheckapply> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FinKingDeeFeign finKingDeeFeign; |
|
|
|
@Autowired |
|
|
|
private BaseVehicleBrandFeign baseVehicleBrandFeign; |
|
|
|
@Autowired |
|
|
|
private BaseManufacturerFeign baseManufacturerFeign; |
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private ScmCollectionrebateCheckapplydetailService scmCollectionrebateCheckapplydetailService; |
|
|
|
@Autowired |
|
|
@ -97,6 +109,8 @@ public class ScmCollectionrebateCheckapplyService extends MybatisBaseService<Scm |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
@Autowired |
|
|
|
private ScmCollectionRebateService scmCollectionRebateService; |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionrebateCheckapplyVo> listPageVo(PagerQuery<ScmCollectionrebateCheckapplyQuery> pq) { |
|
|
|
ScmCollectionrebateCheckapplyQuery query = pq.getParams(); |
|
|
@ -345,6 +359,179 @@ public class ScmCollectionrebateCheckapplyService extends MybatisBaseService<Scm |
|
|
|
return baseMapper.updateFlowFiled(beanToMap); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 推送回款返利核对凭证 |
|
|
|
* |
|
|
|
* @param sid |
|
|
|
*/ |
|
|
|
public void pusCollectionRebateWithVoucher(String sid) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
int month = calendar.get(Calendar.MONTH); |
|
|
|
calendar.set(Calendar.MONTH, month - 1); |
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); |
|
|
|
Date endTime = calendar.getTime();//上个月最后一天
|
|
|
|
String format = sdf.format(endTime); |
|
|
|
String summaryTag = "";//摘要前缀
|
|
|
|
ScmCollectionrebateCheckapply entity = fetchBySid(sid); |
|
|
|
if (null != entity) { |
|
|
|
if (StringUtils.isNotBlank(entity.getCheckApply())) { |
|
|
|
summaryTag = entity.getCheckApply(); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScmCollectionRebate> scmVehRebates = new ArrayList<>(); |
|
|
|
List<ScmCollectionrebateCheckapplydetailVo> scmVehrebateCheckapplydetailVos = scmCollectionrebateCheckapplydetailService.selByMainSid(sid); |
|
|
|
if (!scmVehrebateCheckapplydetailVos.isEmpty()) { |
|
|
|
for (ScmCollectionrebateCheckapplydetailVo s : scmVehrebateCheckapplydetailVos) { |
|
|
|
ScmCollectionRebate v = scmCollectionRebateService.fetchBySid(s.getCollectionRebateSid()); |
|
|
|
if (null != v) { |
|
|
|
scmVehRebates.add(v); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//按照采购系统分组
|
|
|
|
if (!scmVehRebates.isEmpty()) { |
|
|
|
Map<String, List<ScmCollectionRebate>> map = scmVehRebates.stream().collect(Collectors.groupingBy(ScmCollectionRebate::getPurchaseSystemSid)); |
|
|
|
String finalSummaryTag = summaryTag; |
|
|
|
String[] split = finalSummaryTag.split("年"); |
|
|
|
String y1 = split[0]; //预提申请标题年份
|
|
|
|
map.forEach((k, v) -> { |
|
|
|
List<ScmCollectionRebate> rebates = v; |
|
|
|
GeneralVoucher generalVoucher = new GeneralVoucher(); |
|
|
|
generalVoucher.setBussDate(format); |
|
|
|
List<GeneralVoucher.GeneralVoucherDetail> voucherDetails = new ArrayList<>(); |
|
|
|
if (!v.isEmpty()) { |
|
|
|
for (ScmCollectionRebate rebate : v) { |
|
|
|
if (StringUtils.isNotBlank(rebate.getUseOrgSid())) { |
|
|
|
String useOrgSid = rebate.getUseOrgSid(); |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); |
|
|
|
if (null != organizationVo) { |
|
|
|
generalVoucher.setUseOrgCode(organizationVo.getOrgCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
String deptCode = "";//部门编码
|
|
|
|
String gysCode = "";//厂商编码
|
|
|
|
SysOrganizationVo data = sysOrganizationFeign.fetchBySid(rebate.getPurchaseSystemSid()).getData(); |
|
|
|
if (null != data) { |
|
|
|
deptCode = data.getOrgCode(); |
|
|
|
|
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(rebate.getBrandSid())) { |
|
|
|
String brandSid = rebate.getBrandSid(); |
|
|
|
BaseVehicleBrand baseVehicleBrand = baseVehicleBrandFeign.fetchBySid(brandSid); |
|
|
|
if (null != baseVehicleBrand) { |
|
|
|
String manufacturerSid = baseVehicleBrand.getManufacturerSid(); |
|
|
|
if (StringUtils.isNotBlank(manufacturerSid)) { |
|
|
|
BaseManufacturer baseManufacturer = baseManufacturerFeign.fetchBySid(manufacturerSid).getData(); |
|
|
|
if (null != baseManufacturer) { |
|
|
|
gysCode = baseManufacturer.getManufacturerCode(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
BigDecimal shangchuanMoney = BigDecimal.ZERO;//上传金额
|
|
|
|
BigDecimal chaMoney = BigDecimal.ZERO;//差额
|
|
|
|
if (null != rebate.getUploadMoney()) { |
|
|
|
shangchuanMoney = rebate.getUploadMoney(); |
|
|
|
} |
|
|
|
if (null != rebate.getAdjustmentMoney()) { |
|
|
|
chaMoney = rebate.getAdjustmentMoney(); |
|
|
|
} |
|
|
|
String palceGenDate = rebate.getCollectionDate(); |
|
|
|
String[] palceGenDateSplit = palceGenDate.split("-"); |
|
|
|
String y2 = palceGenDateSplit[0];//所属年份
|
|
|
|
if (y1.equals(y2)) { |
|
|
|
//本年
|
|
|
|
if (shangchuanMoney.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail.setManufacturer(gysCode); |
|
|
|
voucherDetail.setAmount(shangchuanMoney); |
|
|
|
voucherDetail.setSceneCode("1161.01.16"); |
|
|
|
voucherDetail.setRemarks("返利上传"); |
|
|
|
voucherDetails.add(voucherDetail); |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail2 = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail2.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail2.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail2.setManufacturer(gysCode); |
|
|
|
voucherDetail2.setAmount(shangchuanMoney); |
|
|
|
voucherDetail2.setSceneCode("1161.01.15"); |
|
|
|
voucherDetail2.setRemarks("返利上传"); |
|
|
|
voucherDetails.add(voucherDetail2); |
|
|
|
} |
|
|
|
|
|
|
|
if (chaMoney.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail.setAmount(chaMoney); |
|
|
|
voucherDetail.setSceneCode("6401.13"); |
|
|
|
voucherDetail.setRemarks("返利调整"); |
|
|
|
voucherDetails.add(voucherDetail); |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail2 = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail2.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail2.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail2.setManufacturer(gysCode); |
|
|
|
voucherDetail2.setAmount(chaMoney); |
|
|
|
voucherDetail2.setSceneCode("1161.01.15"); |
|
|
|
voucherDetail2.setRemarks("返利调整"); |
|
|
|
voucherDetails.add(voucherDetail2); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
//上年
|
|
|
|
if (shangchuanMoney.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail.setManufacturer(gysCode); |
|
|
|
voucherDetail.setAmount(shangchuanMoney); |
|
|
|
voucherDetail.setSceneCode("1161.01.16"); |
|
|
|
voucherDetail.setRemarks("返利上传"); |
|
|
|
voucherDetails.add(voucherDetail); |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail2 = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail2.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail2.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail2.setManufacturer(gysCode); |
|
|
|
voucherDetail2.setAmount(shangchuanMoney); |
|
|
|
voucherDetail2.setSceneCode("1161.02.15"); |
|
|
|
voucherDetail2.setRemarks("返利上传"); |
|
|
|
voucherDetails.add(voucherDetail2); |
|
|
|
} |
|
|
|
|
|
|
|
if (chaMoney.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail.setAmount(chaMoney); |
|
|
|
voucherDetail.setSceneCode("6801"); |
|
|
|
voucherDetail.setRemarks("返利调整"); |
|
|
|
voucherDetails.add(voucherDetail); |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail2 = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail2.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail2.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail2.setManufacturer(gysCode); |
|
|
|
voucherDetail2.setAmount(chaMoney); |
|
|
|
voucherDetail2.setSceneCode("1161.02.15"); |
|
|
|
voucherDetail2.setRemarks("返利调整"); |
|
|
|
voucherDetails.add(voucherDetail2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (!voucherDetails.isEmpty()) { |
|
|
|
generalVoucher.setVoucherDetails(voucherDetails); |
|
|
|
finKingDeeFeign.saveRebateCollectionReviewVoucher(generalVoucher); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean complete(BusinessVariables bv) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionrebateCheckapply scmCollectionrebateCheckapply = fetchBySid(bv.getBusinessSid()); |
|
|
@ -355,6 +542,8 @@ public class ScmCollectionrebateCheckapplyService extends MybatisBaseService<Scm |
|
|
|
} |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
|
|
|
|
pusCollectionRebateWithVoucher(bv.getBusinessSid()); //推送回款返利核对凭证
|
|
|
|
} |
|
|
|
return rb.success().setData(resultBean.getData()); |
|
|
|
} else { |
|
|
|