This commit is contained in:
linfso 2024-11-18 06:29:33 +08:00
parent 6dcdbbfe9e
commit 35868f2933
3 changed files with 67 additions and 52 deletions

View File

@ -652,16 +652,10 @@ public class EmisCommonController extends EmisBaseController
*/
@GetMapping("/reCalcEmpProfitByBillCode")
public AjaxResult reCalcEmpProfitByBillCode(String billCode){
log.error("reCalcEmpProfitByBillCode start");
String lockKey="reCalcEmpProfitByBillCode"+billCode;
// 加锁查询
redissonService.lock(lockKey,300);
try{
emisCommissionProfitService.reCalcProfitByBillCode(billCode);
}
catch (Exception ex){
redissonService.unlock(lockKey);
ex.printStackTrace();
// 返回子定义异常
if(ex instanceof EmisBizError){
@ -670,8 +664,6 @@ public class EmisCommonController extends EmisBaseController
return AjaxResult.error("确认异常,联系客服");
}
redissonService.unlock(lockKey);
log.error("reCalcEmpProfitByBillCode end");
return AjaxResult.success("发送成功");
}

View File

@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.googlecode.aviator.AviatorEvaluator;
import com.xdadan.erp.common.core.domain.entity.SysUser;
import com.xdadan.erp.common.core.redis.RedissonService;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.common.utils.DictUtils;
import com.xdadan.erp.emis.domain.*;
@ -31,6 +32,7 @@ import com.xdadan.erp.emis.utils.WaybillHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.mapper.EmisCommissionProfitMapper;
import com.xdadan.erp.emis.service.IEmisCommissionProfitService;
@ -59,6 +61,9 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
@Autowired
protected EmisWaybillMapper emisWaybillMapper;
@Autowired
RedissonService redissonService;
/**
* 自动计算提成
*/
@ -82,17 +87,24 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 根据单号重新计算提成
*/
@Async
@Override
@Transactional
public int reCalcProfitByBillCode(String billCode)
{
// 获取运单信息
EmisWaybill waybill = getWaybillByBillCode(billCode);
// 先删除该运单已经计算的提成
emisCommissionDtlMapper.deleteEmisCommissionDtlByBillCode(billCode);
String lockKey="reCalcProfitByBillCode"+billCode;
// 加锁查询
log.error("reCalcProfitByBillCode start:"+billCode);
redissonService.lock(lockKey, 300);
try {
// 获取运单信息
EmisWaybill waybill = getWaybillByBillCode(billCode);
// 计算每个岗位的提成方案
// 先删除该运单已经计算的提成
emisCommissionDtlMapper.deleteEmisCommissionDtlByBillCode(billCode);
// 计算每个岗位的提成方案
/*
网点客服 1
快件单证 2
@ -104,45 +116,52 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
单证员 8
*/
// 根据不同岗位计算
for(int postTypeIndex=1;postTypeIndex<=8;postTypeIndex++) {
// 1.网点客服
if(postTypeIndex == ProfitPostType.SITE_KEFU_EMP.typeCode) {
calcSiteFefuProfit(waybill);
}
// 2.快件单证
else if(postTypeIndex == ProfitPostType.KJDZ_EMP.typeCode) {
calcKjdzProfit(waybill);
}
// 3.取件员
else if(postTypeIndex == ProfitPostType.TAKE_EMP.typeCode) {
calcTakeProfit(waybill);
}
// 4.网点操作员
else if(postTypeIndex == ProfitPostType.SITE_OP_EMP.typeCode) {
calcOpProfit(waybill);
}
// 5.派件员
else if(postTypeIndex == ProfitPostType.DISPATCH_EMP.typeCode) {
calcDispatchProfit(waybill);
}
// 6.销售联系人
else if(postTypeIndex == ProfitPostType.SALES_EMP.typeCode) {
calcSalesProfit(waybill);
}
// 7.中转操作员
else if(postTypeIndex == ProfitPostType.MID_OP_EMP.typeCode) {
calcMidOpProfit(waybill);
}
// 8.单证员
else if(postTypeIndex == ProfitPostType.DZ_EMP.typeCode) {
calcDzProfit(waybill);
// 根据不同岗位计算
for (int postTypeIndex = 1; postTypeIndex <= 8; postTypeIndex++) {
// 1.网点客服
if (postTypeIndex == ProfitPostType.SITE_KEFU_EMP.typeCode) {
calcSiteFefuProfit(waybill);
}
// 2.快件单证
else if (postTypeIndex == ProfitPostType.KJDZ_EMP.typeCode) {
calcKjdzProfit(waybill);
}
// 3.取件员
else if (postTypeIndex == ProfitPostType.TAKE_EMP.typeCode) {
calcTakeProfit(waybill);
}
// 4.网点操作员
else if (postTypeIndex == ProfitPostType.SITE_OP_EMP.typeCode) {
calcOpProfit(waybill);
}
// 5.派件员
else if (postTypeIndex == ProfitPostType.DISPATCH_EMP.typeCode) {
calcDispatchProfit(waybill);
}
// 6.销售联系人
else if (postTypeIndex == ProfitPostType.SALES_EMP.typeCode) {
calcSalesProfit(waybill);
}
// 7.中转操作员
else if (postTypeIndex == ProfitPostType.MID_OP_EMP.typeCode) {
calcMidOpProfit(waybill);
}
// 8.单证员
else if (postTypeIndex == ProfitPostType.DZ_EMP.typeCode) {
calcDzProfit(waybill);
}
}
// 运单打上已计算提成标记
emisWaybillMapper.updateHasDoProfit(waybill);
}catch (Exception ex){
redissonService.unlock(lockKey);
ex.printStackTrace();
}
redissonService.unlock(lockKey);
log.error("reCalcProfitByBillCode end:"+billCode);
// 运单打上已计算提成标记
emisWaybillMapper.updateHasDoProfit(waybill);
return 1;

View File

@ -37,10 +37,7 @@ package com.xdadan.erp.emis.service.impl;
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
import com.xdadan.erp.emis.domain.vo.scan.ScanInfo;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.service.IEmisElectronicSitePagService;
import com.xdadan.erp.emis.service.IEmisTmsScanRecordService;
import com.xdadan.erp.emis.service.IEmisWaybillService;
import com.xdadan.erp.emis.service.*;
import com.xdadan.erp.emis.service.print.IXddTplPrint;
import com.xdadan.erp.emis.service.print.tanex.TanexPdfPrinter;
import com.xdadan.erp.emis.service.warehouse.DocUtils;
@ -110,6 +107,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
@Autowired
private EmisWaybillOrigDataMapper emisWaybillOrigDataMapper;
@Autowired
private IEmisCommissionProfitService emisCommissionProfitService;
@Autowired
private ISysFileInfoService sysFileInfoService;
@ -2868,6 +2868,10 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
try {
// 判断是否需要重新出账
redoGenerateBill(emisWaybillSave.getBillCode());
// 重新计算提成
emisCommissionProfitService.reCalcProfitByBillCode(emisWaybillSave.getBillCode());
}catch (Exception ex){
ex.printStackTrace();
}