This commit is contained in:
linfso 2025-03-16 10:44:15 +08:00
parent 27b50d5248
commit 708297d244
10 changed files with 178 additions and 73 deletions

View File

@ -89,6 +89,33 @@ public class EmisCommissionProfitController extends BaseController
}
}
/**
* 按批次号重算
* @param batchNo
* @return
*/
@GetMapping(value = "/batchReCalcProfitByBatchNo")
public AjaxResult batchReCalcProfitByBatchNo(String batchNo)
{
if(!StringUtils.isEmpty(batchNo)){
batchNo=WaybillHelper.formatQueryValue(batchNo);
String[] batchNoSortList = batchNo.split(",");
if(batchNoSortList.length>0){
for (int i=0;i<batchNoSortList.length;i++){
String subBillCode=batchNoSortList[i];
try {
emisCommissionProfitService.reCalcProfitByBillCode(subBillCode);
}catch (Exception ex){
return AjaxResult.error("计算失败-单号:["+subBillCode+"]");
}
}
}
return AjaxResult.success("计算成功");
}else{
return AjaxResult.error("计算失败-单号不能为空");
}
}
/**
* 查询员工提成表列表
*/

View File

@ -44,6 +44,8 @@ public class EmisCommissionDtl extends BaseEntity
private BigDecimal money;
/* 月份 202402 */
private String billMonth;
/* 1-运单 2-批次 */
private String billType;
/* 运单号 */
private String billCode;
/* 报价ID */
@ -83,8 +85,7 @@ public class EmisCommissionDtl extends BaseEntity
/* 确认网点代码 */
private String confirmSiteCode;
// 扩展参数
// 扩展参数
private EmisWaybill waybillDetail;
}

View File

@ -78,9 +78,16 @@ public interface EmisCommissionDtlMapper extends BaseMapper<EmisCommissionDtl>
*/
public int deleteEmisCommissionDtlByBillCode(String billCode);
/**
* 根据批次号删除
* @param batchNo
* @return
*/
public int deleteEmisCommissionDtlByBatchNo(String batchNo);
/**
* 批量删除
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/

View File

@ -13,6 +13,8 @@ package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisTmsSiteBatch;
import com.xdadan.erp.emis.domain.EmisWaybill;
/**
* @ClassName EmisTmsSiteBatchMapper
* @Description <p> 一级网点TMS组批次 Mapper 接口 </p>
@ -28,6 +30,9 @@ public interface EmisTmsSiteBatchMapper extends BaseMapper<EmisTmsSiteBatch>
*/
public EmisTmsSiteBatch selectEmisTmsSiteBatchById(Long id);
public EmisTmsSiteBatch selectTmsSiteBatchByBatchNo(String batchNo);
/**
* 查询列表
*
@ -67,4 +72,8 @@ public interface EmisTmsSiteBatchMapper extends BaseMapper<EmisTmsSiteBatch>
* @return 结果
*/
public int deleteEmisTmsSiteBatchByIds(Long[] ids);
// 打提成标识
public int updateHasDoProfit(String batchNo);
}

View File

@ -165,10 +165,10 @@ public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
public int cancelHasDoBill(EmisWaybill emisWaybill);
// 打提成标识
public int updateHasDoProfit(EmisWaybill emisWaybill);
public int updateHasDoProfit(String billCode);
// 取消出账标识
public int cancelHasDoProfit(EmisWaybill emisWaybill);
public int cancelHasDoProfit(String billCode);
// 更新问题件状态
public int updateProblemStatus(EmisWaybill emisWaybill);

View File

@ -55,6 +55,8 @@ package com.xdadan.erp.emis.service;
@Slf4j
public class EmisBaseService {
@Autowired
private EmisTmsSiteBatchMapper emisTmsSiteBatchMapper;
@Autowired
private EmisCreditCustomerMapper emisCreditCustomerMapper;
@ -1308,6 +1310,20 @@ public class EmisBaseService {
}
/**
* 根据batchNo获取单号信息
* @param batchNo
* @return
*/
public EmisTmsSiteBatch getTmsSiteBatchByBatchNo(String batchNo){
if(StringUtils.isEmpty(batchNo)){
return null;
}
return emisTmsSiteBatchMapper.selectTmsSiteBatchByBatchNo(batchNo);
}
/**
* 增加站点结算记录
* @param emisSiteSettleRecord

View File

@ -42,6 +42,13 @@ public interface IEmisCommissionProfitService
*/
public void reCalcProfitByBillCode(String billCode);
/**
* 重新计算提成根据批次号
* @param batchNo
*/
public void reCalcProfitByBatchNo(String batchNo);
/**
* 查询员工提成表列表
*

View File

@ -28,9 +28,7 @@ import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.common.utils.DictUtils;
import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.ProfitPostType;
import com.xdadan.erp.emis.mapper.EmisCommissionDtlMapper;
import com.xdadan.erp.emis.mapper.EmisCommissionQuoteMapper;
import com.xdadan.erp.emis.mapper.EmisWaybillMapper;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.utils.WaybillHelper;
import lombok.extern.slf4j.Slf4j;
@ -39,7 +37,6 @@ 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;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -54,6 +51,10 @@ import org.springframework.util.CollectionUtils;
@Service
public class EmisCommissionProfitServiceImpl extends EmisBaseService implements IEmisCommissionProfitService
{
@Autowired
private EmisTmsSiteBatchMapper emisTmsSiteBatchMapper;
@Autowired
private EmisCommissionProfitMapper emisCommissionProfitMapper;
@ -162,6 +163,39 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
}
@Override
@Transactional
public void reCalcProfitByBatchNo(String batchNo)
{
String lockKey="reCalcProfitByBatchNo"+batchNo;
// 加锁查询
log.info("reCalcProfitByBatchNo start:"+batchNo);
redissonService.lock(lockKey, 300);
try {
// 获取批次信息
EmisTmsSiteBatch tmsBatch = getTmsSiteBatchByBatchNo(batchNo);
// 先删除该运单已经计算的提成
emisCommissionDtlMapper.deleteEmisCommissionDtlByBatchNo(batchNo);
/*
单证员 8
*/
// 单证提成计算
calcHyLyDzProfit(tmsBatch);
// 运单打上已计算提成标记
emisTmsSiteBatchMapper.updateHasDoProfit(batchNo);
}catch (Exception ex){
redissonService.unlock(lockKey);
ex.printStackTrace();
}
redissonService.unlock(lockKey);
log.info("reCalcProfitByBatchNo end:"+batchNo);
}
/**
* 根据单号重新计算提成
*/
@ -222,14 +256,14 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
else if (postTypeIndex == ProfitPostType.MID_OP_EMP.typeCode) {
calcMidOpProfit(waybill);
}
// 8.单证员
// 8.陆运海运单证员,按柜计算,不按单计算
else if (postTypeIndex == ProfitPostType.DZ_EMP.typeCode) {
calcDzProfit(waybill);
}
}
// 运单打上已计算提成标记
emisWaybillMapper.updateHasDoProfit(waybill);
emisWaybillMapper.updateHasDoProfit(waybill.getBillCode());
}catch (Exception ex){
redissonService.unlock(lockKey);
ex.printStackTrace();
@ -1140,23 +1174,36 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 计算单证提成
* @param waybill
* 计算海运陆运单证提成
* @param siteBatch
*/
private void calcDzProfit(EmisWaybill waybill){
String billMonth= DateUtils.parseDateToStr(DateUtils.YYYY_MM,waybill.getSendDate());
private void calcHyLyDzProfit(EmisTmsSiteBatch siteBatch){
EmisTransLine transLine=getTransLineByCode(waybill.getTransLineType());
Date sendDate = siteBatch.getEtd();
if(sendDate==null){
sendDate=siteBatch.getCreateTime();
}
String billMonth= DateUtils.parseDateToStr(DateUtils.YYYY_MM,sendDate);
// 获取起始国家
EmisSite startSite=getSiteByCode(siteBatch.getStartSiteCode());
EmisCommissionQuote emisCommissionQuote = new EmisCommissionQuote();
emisCommissionQuote.setCountry(waybill.getReceiveCountry());
emisCommissionQuote.setFromCountry(waybill.getSendCountry());
emisCommissionQuote.setTransLine(waybill.getTransLineType());
emisCommissionQuote.setProdCode(waybill.getProductType());
emisCommissionQuote.setTransType(transLine.getTransType());
emisCommissionQuote.setCountry(siteBatch.getDestCountry());
emisCommissionQuote.setFromCountry(startSite.getCountryCode());
emisCommissionQuote.setTransType(siteBatch.getTransType());
// 起始网点,目的网点
emisCommissionQuote.setSendSiteCode(siteBatch.getStartSiteCode());
emisCommissionQuote.setNextSiteCode(siteBatch.getNextSiteCode());
// 海运单证类型
emisCommissionQuote.setPostType("8");
emisCommissionQuote.getParams().put("validDate",waybill.getSendDate());
// 按柜计算
emisCommissionQuote.setCalcType("5");
emisCommissionQuote.getParams().put("validDate",sendDate);
// 获取提成方案
List<EmisCommissionQuote> listQuote = emisCommissionQuoteMapper.selectValidQuoteList(emisCommissionQuote);
@ -1168,61 +1215,30 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
String calcExprStr="";
for (EmisCommissionExpression exprItem : exprList) {
log.info("计算项目表达式:" + JSONObject.toJSONString(exprItem));
String calcExp = exprItem.getCalculateExpression();
double profitMoney = 0.0D;
// 按票计算
if ("1".equals(quoteItem.getCalcType())) {
calcExprStr = calcExp.replaceAll("w", "1")
// 按柜内票数
if ("5".equals(quoteItem.getCalcType())) {
calcExprStr = calcExp.replaceAll("w", siteBatch.getTotalWaybillQty())
.replaceAll("s", exprItem.getInitialWeight().toString())
.replaceAll("d", exprItem.getAdditionalWeight().toString());
log.info("按票计算:计算公式:" + calcExprStr + ",票数:1");
profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
}
// 重量计算
else if ("2".equals(quoteItem.getCalcType())) {
calcExprStr = calcExp.replaceAll("w", waybill.getSettlementWeight().stripTrailingZeros().toPlainString())
.replaceAll("s", exprItem.getInitialWeight().toString())
.replaceAll("d", exprItem.getAdditionalWeight().toString());
log.info("按重量计算:计算公式:" + calcExprStr + ",重量:"+waybill.getSettlementWeight().stripTrailingZeros().toPlainString());
profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
}
// 体积计算
else if ("3".equals(quoteItem.getCalcType())) {
calcExprStr = calcExp.replaceAll("w", waybill.getTotalVolume().stripTrailingZeros().toPlainString())
.replaceAll("s", exprItem.getInitialWeight().toString())
.replaceAll("d", exprItem.getAdditionalWeight().toString());
log.info("按体积计算:计算公式:" + calcExprStr + ",体积:"+waybill.getTotalVolume().stripTrailingZeros().toPlainString());
profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
}
// 包裹数
else if ("4".equals(quoteItem.getCalcType())) {
calcExprStr = calcExp.replaceAll("w", "1")
.replaceAll("s", exprItem.getInitialWeight().toString())
.replaceAll("d", exprItem.getAdditionalWeight().toString());
log.info("按包裹数:计算公式:" + calcExprStr + ",包裹数:"+1);
log.info("按柜内票数:计算公式:" + calcExprStr + ",按柜内票数:"+siteBatch.getTotalWaybillQty());
profitMoney = Double.valueOf(AviatorEvaluator.execute(calcExprStr).toString());
}
// 插入参与分成人员
String empCode=quoteItem.getEmpCode();
String empName=quoteItem.getEmpName();
// 插入提成
if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) {
String[] empCodeArr = empCode.split(",");
String[] empCodeArr = empName.split(",");
for(int i=0;i<empCodeArr.length;i++) {
SysUser empUser = getEmisStaffByCode(empCodeArr[i]);
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
emisCommissionDtl.setBillCode(waybill.getBillCode());
emisCommissionDtl.setBillCode(siteBatch.getBatchNo());
emisCommissionDtl.setBillType
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
emisCommissionDtl.setBillMonth(billMonth);

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="feeType" column="fee_type" />
<result property="money" column="money" />
<result property="billMonth" column="bill_month" />
<result property="billType" column="bill_type" />
<result property="billCode" column="bill_code" />
<result property="quoteId" column="quote_id" />
<result property="quoteName" column="quote_name" />
@ -39,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectEmisCommissionDtlVo">
select id, fee_type, money, bill_month, bill_code, quote_id, quote_name, expr_id, calc_expr, fee_remark, emp_code, emp_name, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_commission_dtl
select id, fee_type, money, bill_month, bill_type, bill_code, quote_id, quote_name, expr_id, calc_expr, fee_remark, emp_code, emp_name, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_commission_dtl
</sql>
<select id="selectEmisCommissionDtlList" parameterType="EmisCommissionDtl" resultMap="EmisCommissionDtlResult">
@ -47,23 +48,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="feeType != null and feeType != ''"> and fee_type like concat('%', #{feeType}, '%')</if>
<if test="feeType != null and feeType != ''"> and fee_type=#{feeType}</if>
<if test="money != null "> and money = #{money}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month like concat('%', #{billMonth}, '%')</if>
<if test="billCode != null and billCode != ''"> and bill_code like concat('%', #{billCode}, '%')</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth},</if>
<if test="billType != null and billType != ''"> and bill_type=#{billType}</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(bill_code,#{billCode}) or bill_code like concat('%', #{billCode}, '%') )</if>
<if test="feeRemark != null and feeRemark != ''"> and fee_remark like concat('%', #{feeRemark}, '%')</if>
<if test="empCode != null and empCode != ''"> and emp_code=#{empCode}</if>
<if test="empName != null and empName != ''"> and emp_name=#{empName}</if>
<if test="blConfirmCenter != null and blConfirmCenter != ''"> and bl_confirm_center like concat('%', #{blConfirmCenter}, '%')</if>
<if test="blConfirmCenter != null and blConfirmCenter != ''"> and bl_confirm_center=#{blConfirmCenter}</if>
<if test="confirmCenterDate != null "> and confirm_center_date = #{confirmCenterDate}</if>
<if test="confirmCenterNote != null and confirmCenterNote != ''"> and confirm_center_note like concat('%', #{confirmCenterNote}, '%')</if>
<if test="confirmCenterManCode != null and confirmCenterManCode != ''"> and confirm_center_man_code like concat('%', #{confirmCenterManCode}, '%')</if>
<if test="confirmCenterCode != null and confirmCenterCode != ''"> and confirm_center_code like concat('%', #{confirmCenterCode}, '%')</if>
<if test="blConfirmSite != null and blConfirmSite != ''"> and bl_confirm_site like concat('%', #{blConfirmSite}, '%')</if>
<if test="confirmCenterManCode != null and confirmCenterManCode != ''"> and confirm_center_man_code= #{confirmCenterManCode}</if>
<if test="confirmCenterCode != null and confirmCenterCode != ''"> and confirm_center_code=#{confirmCenterCode}</if>
<if test="blConfirmSite != null and blConfirmSite != ''"> and bl_confirm_site=#{blConfirmSite}</if>
<if test="confirmSiteDate != null "> and confirm_site_date = #{confirmSiteDate}</if>
<if test="confirmSiteManCode != null and confirmSiteManCode != ''"> and confirm_site_man_code like concat('%', #{confirmSiteManCode}, '%')</if>
<if test="confirmSiteManCode != null and confirmSiteManCode != ''"> and confirm_site_man_code=#{confirmSiteManCode}</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''"> and confirm_site_note like concat('%', #{confirmSiteNote}, '%')</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''"> and confirm_site_code like concat('%', #{confirmSiteCode}, '%')</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''"> and confirm_site_code=#{confirmSiteCode}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
@ -109,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectEmisCommissionDtlById" parameterType="Long" resultMap="EmisCommissionDtlResult">
select id, fee_type, money, bill_month, bill_code, quote_id, quote_name, expr_id, calc_expr, fee_remark, emp_code, emp_name, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, fee_type, money, bill_month, bill_type, bill_code, quote_id, quote_name, expr_id, calc_expr, fee_remark, emp_code, emp_name, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_commission_dtl a
where a.id = #{id}
</select>
@ -120,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="feeType != null and feeType != ''">fee_type,</if>
<if test="money != null">money,</if>
<if test="billMonth != null and billMonth != ''">bill_month,</if>
<if test="billType != null and billType != ''">bill_type,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="quoteId != null">quote_id,</if>
<if test="quoteName != null and quoteName != ''">quote_name,</if>
@ -151,6 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="feeType != null and feeType != ''">#{feeType},</if>
<if test="money != null">#{money},</if>
<if test="billMonth != null and billMonth != ''">#{billMonth},</if>
<if test="billType != null and billType != ''">#{billType},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="quoteId != null">#{quoteId},</if>
<if test="quoteName != null and quoteName != ''">#{quoteName},</if>
@ -186,6 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
<if test="money != null">money = #{money},</if>
<if test="billMonth != null and billMonth != ''">bill_month = #{billMonth},</if>
<if test="billType != null and billType != ''">bill_type = #{billType},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="quoteId != null">quote_id = #{quoteId},</if>
<if test="quoteName != null and quoteName != ''">quote_name = #{quoteName},</if>
@ -217,7 +222,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteEmisCommissionDtlByBillCode" parameterType="String">
update emis_commission_dtl set del_flag='1' where bill_code = #{billCode}
update emis_commission_dtl set del_flag='1' where bill_code = #{billCode} and bill_type='1'
</delete>
<delete id="deleteEmisCommissionDtlByBatchNo" parameterType="String">
update emis_commission_dtl set del_flag='1' where bill_code = #{batchNo} and bill_type='2'
</delete>
<delete id="deleteEmisCommissionDtlById" parameterType="Long">

View File

@ -188,6 +188,19 @@
where a.id = #{id}
</select>
<select id="selectTmsSiteBatchByBatchNo" parameterType="String" resultMap="EmisTmsSiteBatchResult">
select id, batch_no, batch_name, batch_date, supplier_code, supplier_name, trans_line_type, product_type, batch_type, trans_type, start_site_code, send_country, next_site_code, air_billl_no, etd, eta, car_no, ship_no, clearance_res_status, declare_res_status, dest_country, dest_country_name, trans_weight, pack_num, total_parcel_qty, total_waybill_qty, total_volume, total_weight, op_man, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_site_batch a
where a.batch_no = #{batchNo}
</select>
<!-- 打提成标识 -->
<update id="updateHasDoProfit" parameterType="String">
update emis_tms_site_batch set
bl_profit = '1'
where batch_no=#{batchNo}
</update>
<insert id="insertEmisTmsSiteBatch" parameterType="EmisTmsSiteBatch" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_site_batch
<trim prefix="(" suffix=")" suffixOverrides=",">