|
|
@ -26,10 +26,13 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmvehrebatecheckapply; |
|
|
|
|
|
|
|
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.basevehicle.BaseVehicle; |
|
|
|
import com.yxt.anrui.base.api.basevehicle.BaseVehicleFeign; |
|
|
|
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.FlowDelegateQuery; |
|
|
@ -37,6 +40,8 @@ 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; |
|
|
@ -44,33 +49,27 @@ 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.scmvehrebate.ScmVehRebate; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebateVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.*; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.flow.GetNodeQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.flow.GetNodeVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.flow.ScmVehRebateCheckApplyDelegateQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.flow.SubmitScmVehRebateCheckApplyDto; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapplydetail.ScmVehrebateCheckapplydetail; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapplydetail.ScmVehrebateCheckapplydetailDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapplydetail.ScmVehrebateCheckapplydetailDto; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapplydetail.ScmVehrebateCheckapplydetailVo; |
|
|
|
import com.yxt.anrui.scm.biz.scmvehrebate.ScmVehRebateService; |
|
|
|
import com.yxt.anrui.scm.biz.scmvehrebatecheckapplydetail.ScmVehrebateCheckapplydetailService; |
|
|
|
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.scmvehrebatecheckapply.ScmVehrebateCheckapply; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.ScmVehrebateCheckapplyQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.ScmVehrebateCheckapplyVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.ScmVehrebateCheckapplyDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebatecheckapply.ScmVehrebateCheckapplyDto; |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
@ -104,7 +103,12 @@ public class ScmVehrebateCheckapplyService extends MybatisBaseService<ScmVehreba |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysOrganizationFeign sysOrganizationFeign; |
|
|
|
@Autowired |
|
|
|
private BaseVehicleFeign baseVehicleFeign; |
|
|
|
@Autowired |
|
|
|
private FinKingDeeFeign finKingDeeFeign; |
|
|
|
public PagerVo<ScmVehrebateCheckapplyVo> listPageVo(PagerQuery<ScmVehrebateCheckapplyQuery> pq) { |
|
|
|
ScmVehrebateCheckapplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmVehrebateCheckapply> qw = new QueryWrapper<>(); |
|
|
@ -420,6 +424,128 @@ public class ScmVehrebateCheckapplyService extends MybatisBaseService<ScmVehreba |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 推送单车返利核对凭证 |
|
|
|
* @param sid,tag (0代表核对申请通过推送,1代表重推功能) |
|
|
|
*/ |
|
|
|
public void pushVehRebateWithVoucher(String sid,String tag) { |
|
|
|
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 = "";//摘要前缀
|
|
|
|
ScmVehrebateCheckapply entity = fetchBySid(sid); |
|
|
|
if (null != entity) { |
|
|
|
if (StringUtils.isNotBlank(entity.getCheckApply())) { |
|
|
|
summaryTag = entity.getCheckApply(); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ScmVehRebate> scmVehRebates = new ArrayList<>(); |
|
|
|
List<ScmVehrebateCheckapplydetailVo> scmVehrebateCheckapplydetailVos = scmVehrebateCheckapplydetailService.selByMainSid(sid); |
|
|
|
if (!scmVehrebateCheckapplydetailVos.isEmpty()) { |
|
|
|
for (ScmVehrebateCheckapplydetailVo s : scmVehrebateCheckapplydetailVos) { |
|
|
|
ScmVehRebate v = scmVehRebateService.fetchBySid(s.getVehRebateSid()); |
|
|
|
if (null != v) { |
|
|
|
scmVehRebates.add(v); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//按照采购系统分组
|
|
|
|
if (!scmVehRebates.isEmpty()) { |
|
|
|
Map<String, List<ScmVehRebate>> map = scmVehRebates.stream().collect(Collectors.groupingBy(ScmVehRebate::getPurchaseSystemSid)); |
|
|
|
String finalSummaryTag = summaryTag; |
|
|
|
String[] split = finalSummaryTag.split("年"); |
|
|
|
String y1 = split[0]; //预提申请标题年份
|
|
|
|
map.forEach((k, v) -> { |
|
|
|
List<ScmVehRebate> rebates = v; |
|
|
|
GeneralVoucher generalVoucher = new GeneralVoucher(); |
|
|
|
generalVoucher.setBussDate(format); |
|
|
|
List<GeneralVoucher.GeneralVoucherDetail> voucherDetails = new ArrayList<>(); |
|
|
|
if (!v.isEmpty()) { |
|
|
|
for (ScmVehRebate rebate : v) { |
|
|
|
String deptCode = ""; //采购系统部门编码
|
|
|
|
String salesDeptCode = ""; //销售部门编码
|
|
|
|
String customerCode = ""; //出库单客户编码
|
|
|
|
String vinCode = ""; //物料
|
|
|
|
String gysCode = ""; //供应商
|
|
|
|
SysOrganizationVo data = sysOrganizationFeign.fetchBySid(rebate.getPurchaseSystemSid()).getData(); |
|
|
|
if (null != data) { |
|
|
|
deptCode = data.getOrgCode(); |
|
|
|
} |
|
|
|
BaseVehicle vehicle = baseVehicleFeign.fetchBySid(rebate.getVehSid()).getData(); |
|
|
|
if (null != vehicle) { |
|
|
|
if (StringUtils.isNotBlank(vehicle.getManufacturerCode())) { |
|
|
|
gysCode = vehicle.getManufacturerCode(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(rebate.getUseOrgSid())) { |
|
|
|
String useOrgSid = rebate.getUseOrgSid(); |
|
|
|
SysOrganizationVo organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid).getData(); |
|
|
|
if (null != organizationVo) { |
|
|
|
generalVoucher.setUseOrgCode(organizationVo.getOrgCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (tag.equals("0")) { |
|
|
|
if (!rebate.getRebateTypeValue().equals("金融贴息")) { |
|
|
|
//确认调整时
|
|
|
|
if (rebate.getOnceCheckState().intValue() == 0) { |
|
|
|
//没有进行过核对申请
|
|
|
|
if (StringUtils.isNotBlank(rebate.getUploadMoney())) { |
|
|
|
//一次上传金额
|
|
|
|
BigDecimal oneMoney = new BigDecimal(rebate.getUploadMoney()); |
|
|
|
if (oneMoney.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
GeneralVoucher.GeneralVoucherDetail voucherDetail = new GeneralVoucher.GeneralVoucherDetail(); |
|
|
|
voucherDetail.setTimeFlag(finalSummaryTag); |
|
|
|
voucherDetail.setSceneCode("1161.01.16"); |
|
|
|
voucherDetail.setDeptCode(deptCode); //部门编码赋值
|
|
|
|
voucherDetail.setManufacturer(gysCode); |
|
|
|
voucherDetail.setAmount(oneMoney); |
|
|
|
voucherDetails.add(voucherDetail); |
|
|
|
// String palceGenDate = rebate.getPalceGenDate();
|
|
|
|
// String[] palceGenDateSplit = palceGenDate.split("-");
|
|
|
|
// String y2 = palceGenDateSplit[0];//所属年份
|
|
|
|
// if (y1.equals(y2)) {
|
|
|
|
// voucherDetail.setSceneCode("本年");
|
|
|
|
// } else {
|
|
|
|
// voucherDetail.setSceneCode("上年");
|
|
|
|
// }
|
|
|
|
} |
|
|
|
BigDecimal yicifanli = BigDecimal.ZERO;//一次上传返利
|
|
|
|
BigDecimal yicidaizhifu= BigDecimal.ZERO;//一次待支付
|
|
|
|
BigDecimal yicidaiqueding = BigDecimal.ZERO;//一次待确定
|
|
|
|
// if (StringUtils.isNotBlank())
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (tag.equals("1")) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!voucherDetails.isEmpty()) { |
|
|
|
generalVoucher.setVoucherDetails(voucherDetails); |
|
|
|
finKingDeeFeign.saveRebateReviewVoucher(generalVoucher); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean revokeProcess(FlowTaskVo query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(query.getUserSid())) { |
|
|
|