This commit is contained in:
linfso 2024-10-13 20:32:26 +08:00
parent 535e0166ef
commit cc5d45080b
8 changed files with 84 additions and 5 deletions

View File

@ -46,4 +46,6 @@ public class EmisTmsCostProfit extends BaseEntity
/* 运单利润 */
private BigDecimal billProfit;
// 扩展参数
private EmisWaybill waybillDetail;
}

View File

@ -10,6 +10,7 @@
*/
package com.xdadan.erp.emis.mapper;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisSettleSubBill;
@ -40,6 +41,17 @@ public interface EmisTmsCostFeeRelMapper extends BaseMapper<EmisTmsCostFeeRel>
public List<EmisTmsCostFeeRel> selectEmisTmsCostFeeRelListByCostNo(String costNo);
/**
* 根据运单号获取关联费用
* @param billCode
* @return
*/
public List<EmisTmsCostFeeRel> selectEmisTmsCostFeeRelListByBillCode(String billCode);
public double getCostFeeByBillCode(String billCode);
/**
* 检查是否重复
*

View File

@ -28,6 +28,9 @@ public interface EmisTmsCostProfitMapper extends BaseMapper<EmisTmsCostProfit>
*/
public EmisTmsCostProfit selectEmisTmsCostProfitById(Long id);
public EmisTmsCostProfit selectEmisTmsCostProfitByBillCode(String billCode);
/**
* 查询列表
*

View File

@ -80,4 +80,6 @@ public interface IEmisTmsCostFeeService
public int reCalcSplitCostFee(String costNo) throws EmisBizError;
public int reCalcCostFeeByBillCode(String billCode) throws EmisBizError;
}

View File

@ -18,10 +18,13 @@ import com.xdadan.erp.emis.domain.*;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.mapper.EmisTmsCostFeeRelMapper;
import com.xdadan.erp.emis.mapper.EmisTmsCostProfitMapper;
import com.xdadan.erp.emis.mapper.EmisWaybillMapper;
import com.xdadan.erp.emis.utils.WaybillHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.mapper.EmisTmsCostFeeMapper;
import com.xdadan.erp.emis.service.IEmisTmsCostFeeService;
@ -43,6 +46,12 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
@Autowired
private EmisTmsCostFeeRelMapper emisTmsCostFeeRelMapper;
@Autowired
private EmisTmsCostProfitMapper emisTmsCostProfitMapper;
@Autowired
protected EmisWaybillMapper emisWaybillMapper;
/**
* 查询TMS运输成本账单
*
@ -185,12 +194,15 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
emisTmsCostFeeRelMapper.updateEmisTmsCostFeeRel(updRel);
}
// 更新信息
return emisTmsCostFeeMapper.updateEmisTmsCostFee(emisTmsCostFee);
emisTmsCostFeeMapper.updateEmisTmsCostFee(emisTmsCostFee);
// 重算单个运单费用
for (EmisTmsCostFeeRel feeRel: listFeeRel) {
reCalcCostFeeByBillCode(feeRel.getBillCode())
}
return 1;
}
/**
* 重算每一单成本分摊重算
* @param billCode
@ -198,9 +210,30 @@ public class EmisTmsCostFeeServiceImpl implements IEmisTmsCostFeeService
* @throws EmisBizError
*/
@Override
@Transactional
public int reCalcCostFeeByBillCode(String billCode) throws EmisBizError {
// 更新信息
EmisTmsCostProfit emisTmsCostProfit=emisTmsCostProfitMapper.selectEmisTmsCostProfitByBillCode(billCode);
if(emisTmsCostProfit==null){
// 初始化成本数据
EmisWaybill emisWaybill=emisWaybillMapper.selectEmisWaybillByBillCode(billCode);
emisTmsCostProfit = new EmisTmsCostProfit();
emisTmsCostProfit.setBillCode(emisWaybill.getBillCode());
emisTmsCostProfit.setBillFee(emisWaybill.getFreight());
emisTmsCostProfit.setStandardFee(emisWaybill.getRealFee());
emisTmsCostProfitMapper.insertEmisTmsCostProfit(emisTmsCostProfit);
}
EmisTmsCostProfit updProfit = new EmisTmsCostProfit();
updProfit.setId(emisTmsCostProfit.getId());
// 获取成本费用
double costFee=emisTmsCostFeeRelMapper.getCostFeeByBillCode(billCode);
updProfit.setCostFee(BigDecimal.valueOf(costFee));
updProfit.setBillProfit(updProfit.getBillFee().subtract(updProfit.getCostFee()));
emisTmsCostProfitMapper.updateEmisTmsCostProfit(updProfit);
log.error("==>费用计算:==>:{}: {}-{}=",billCode,updProfit.getBillFee(),updProfit.getCostFee(),updProfit.getBillProfit());
return 1;
}

View File

@ -604,6 +604,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectSubBillListBySettleBillNo" parameterType="String" resultMap="EmisSettleSubBillResult">
select id, bill_no, parent_bill_no, settle_bill_no, bill_code, bill_date, bill_fee, currency, settle_type, bl_split, bl_merge, bill_month, cust_no, cust_name, customer_code, customer_name, payee, salesmen, bl_special_quote, bl_sensitive, 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, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_sub_bill a

View File

@ -89,6 +89,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where del_flag='0' and a.cost_no = #{costNo}
</select>
<select id="selectEmisTmsCostFeeRelListByBillCode" parameterType="String" resultMap="EmisTmsCostFeeRelWithSubBillResult">
select id, cost_no, bill_code, fee_type, split_type, cost_fee, total_volume, bill_weight, calc_remark, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_cost_fee_rel a
where del_flag='0' and a.bill_code = #{billCode}
</select>
<select id="getCostFeeByBillCode" parameterType="String" resultType="double">
select IFNULL(sum(cost_fee),0) as costFee
from emis_tms_cost_fee_rel a
where del_flag='0' and a.bill_code = #{billCode}
</select>
<insert id="insertEmisTmsCostFeeRel" parameterType="EmisTmsCostFeeRel" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_cost_fee_rel

View File

@ -13,6 +13,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="billProfit" column="bill_profit" />
</resultMap>
<resultMap id="EmisTmsCostProfitWithSubBillResult" type="EmisTmsCostProfit" extends="EmisTmsCostProfitResult" >
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
</resultMap>
<sql id="selectEmisTmsCostProfitVo">
select id, bill_code, standard_fee, bill_fee, cost_fee, bill_profit, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_cost_profit
</sql>
@ -64,6 +72,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from emis_tms_cost_profit a
where a.id = #{id}
</select>
<select id="selectEmisTmsCostProfitByBillCode" parameterType="String" resultMap="EmisTmsCostProfitWithSubBillResult">
select id, bill_code, standard_fee, bill_fee, cost_fee, bill_profit, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_tms_cost_profit a
where a.bill_code = #{billCode}
</select>
<insert id="insertEmisTmsCostProfit" parameterType="EmisTmsCostProfit" useGeneratedKeys="true" keyProperty="id">
insert into emis_tms_cost_profit