feat(sales): 新增目标应收字段并优化销售出库处理逻辑

- 在 TocofsSaleoutDetailedEntity 和 DetailsDto 中新增目标应收字段
- 优化销售出库插件初始化器中的金额计算逻辑
- 调整批量插入/更新操作的批次大小- 在测试类中更新相关测试用例
This commit is contained in:
liuy 2024-11-14 18:27:05 +08:00
parent 7e7a3631bf
commit 7a1a4c630f
6 changed files with 58 additions and 25 deletions

View File

@ -1009,7 +1009,7 @@
<!-- TOB更新推送状态适合确认收入蓝字--> <!-- TOB更新推送状态适合确认收入蓝字-->
<insert id="entityInsertOrUpdateBatchStock6" keyProperty="id" useGeneratedKeys="true"> <insert id="entityInsertOrUpdateBatchStock6" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary) insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary,def7)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
( (
@ -1018,7 +1018,8 @@
#{entity.newtransmitinfo}, #{entity.newtransmitinfo},
#{entity.newstate}, #{entity.newstate},
#{entity.newsystemnumber}, #{entity.newsystemnumber},
#{entity.newsystemprimary} #{entity.newsystemprimary},
#{entity.def7}
) )
</foreach> </foreach>
on duplicate key update on duplicate key update
@ -1027,7 +1028,8 @@
newTransmitInfo = values(newTransmitInfo), newTransmitInfo = values(newTransmitInfo),
newState = values(newState), newState = values(newState),
newSystemNumber = values(newSystemNumber), newSystemNumber = values(newSystemNumber),
newSystemPrimary = values(newSystemPrimary) newSystemPrimary = values(newSystemPrimary),
def7 = values(def7)
</insert> </insert>
<!-- TOB更新推送状态适合确认收入蓝字--> <!-- TOB更新推送状态适合确认收入蓝字-->
@ -1051,7 +1053,7 @@
<!-- TOB更新推送状态适合确认收入蓝字--> <!-- TOB更新推送状态适合确认收入蓝字-->
<insert id="entityInsertOrUpdateBatchStock8" keyProperty="id" useGeneratedKeys="true"> <insert id="entityInsertOrUpdateBatchStock8" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_saleout_detailed(id,def5,def6,newState4,newSystemNumber4,newSystemPrimary4) insert into tocofs_saleout_detailed(id,def5,def6,newState4,newSystemNumber4,newSystemPrimary4,def7)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
( (
@ -1060,7 +1062,8 @@
#{entity.def6}, #{entity.def6},
#{entity.newstate4}, #{entity.newstate4},
#{entity.newsystemnumber4}, #{entity.newsystemnumber4},
#{entity.newsystemprimary4} #{entity.newsystemprimary4},
#{entity.def7}
) )
</foreach> </foreach>
on duplicate key update on duplicate key update
@ -1069,7 +1072,8 @@
def6 = values(def6), def6 = values(def6),
newState4 = values(newState4), newState4 = values(newState4),
newSystemNumber4 = values(newSystemNumber4), newSystemNumber4 = values(newSystemNumber4),
newSystemPrimary4 = values(newSystemPrimary4) newSystemPrimary4 = values(newSystemPrimary4),
def7 = values(def7)
</insert> </insert>
<!--通过主键修改方法--> <!--通过主键修改方法-->

View File

@ -787,8 +787,10 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
BigDecimal noriginalcursummny = null;//价税合计 BigDecimal noriginalcursummny = null;//价税合计
BigDecimal noriginalcurtaxmny = null;//税额 BigDecimal noriginalcurtaxmny = null;//税额
try { try {
//综合判断对应的目标金额 //判断目标金额O实收结存价采购价
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto); String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto);
detailsDto.setTargetAccountsReceivable(totalPayAmount);
noriginalcurtaxprice = new BigDecimal(totalPayAmount).divide(new BigDecimal(detailsDto.getShipQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurtaxprice = new BigDecimal(totalPayAmount).divide(new BigDecimal(detailsDto.getShipQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurmny = noriginalcurprice.multiply(new BigDecimal(detailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP); noriginalcurmny = noriginalcurprice.multiply(new BigDecimal(detailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
@ -1908,6 +1910,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
try { try {
//综合判断对应的目标金额 //综合判断对应的目标金额
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto); String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto);
detailsDto.setTargetAccountsReceivable(totalPayAmount);
noriginalcurtaxprice = new BigDecimal(totalPayAmount).divide(new BigDecimal(detailsDto.getShipQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurtaxprice = new BigDecimal(totalPayAmount).divide(new BigDecimal(detailsDto.getShipQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) { } catch (Exception e) {
logger.error("含税单价金额计算失败!", e); logger.error("含税单价金额计算失败!", e);
@ -2355,6 +2358,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
tocofsSaleoutDetailedEntity.setNewpushdate(getNewDateStr()); tocofsSaleoutDetailedEntity.setNewpushdate(getNewDateStr());
tocofsSaleoutDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo); tocofsSaleoutDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo);
tocofsSaleoutDetailedEntity.setNewstate(newstate); tocofsSaleoutDetailedEntity.setNewstate(newstate);
tocofsSaleoutDetailedEntity.setDef7(detailsDto.getTargetAccountsReceivable());
if (successY.equals(newstate)) { if (successY.equals(newstate)) {
//只有成功才填充下游系统主键和编码 //只有成功才填充下游系统主键和编码
tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber); tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber);
@ -2365,7 +2369,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
//以50行为一个批次推送到Mysql //以50行为一个批次推送到Mysql
if (tocofsSaleoutDetailedEntityList.size() > 0) { if (tocofsSaleoutDetailedEntityList.size() > 0) {
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
for (int i = 0; i < splitListByCount.size(); i++) { for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock6(tocofsSaleoutDetailedEntityList1); iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock6(tocofsSaleoutDetailedEntityList1);
@ -2411,6 +2415,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
tocofsSaleoutDetailedEntity.setDef5(getNewDateStr()); tocofsSaleoutDetailedEntity.setDef5(getNewDateStr());
tocofsSaleoutDetailedEntity.setDef6(finalNewTransmitInfo); tocofsSaleoutDetailedEntity.setDef6(finalNewTransmitInfo);
tocofsSaleoutDetailedEntity.setNewstate4(newstate); tocofsSaleoutDetailedEntity.setNewstate4(newstate);
tocofsSaleoutDetailedEntity.setDef7(detailsDto.getTargetAccountsReceivable());
if (successY.equals(newstate)) { if (successY.equals(newstate)) {
//只有成功才填充下游系统主键和编码 //只有成功才填充下游系统主键和编码
tocofsSaleoutDetailedEntity.setNewsystemnumber4(newsystemnumber); tocofsSaleoutDetailedEntity.setNewsystemnumber4(newsystemnumber);
@ -2421,7 +2426,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
//以50行为一个批次推送到Mysql //以50行为一个批次推送到Mysql
if (tocofsSaleoutDetailedEntityList.size() > 0) { if (tocofsSaleoutDetailedEntityList.size() > 0) {
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
for (int i = 0; i < splitListByCount.size(); i++) { for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock8(tocofsSaleoutDetailedEntityList1); iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock8(tocofsSaleoutDetailedEntityList1);
@ -2493,7 +2498,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
//以50行为一个批次更新状态 //以50行为一个批次更新状态
if (tocofsSaleoutDetailedEntityList.size() > 0) { if (tocofsSaleoutDetailedEntityList.size() > 0) {
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
for (int i = 0; i < splitListByCount.size(); i++) { for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1(tocofsSaleoutDetailedEntityList1); iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1(tocofsSaleoutDetailedEntityList1);
@ -2555,7 +2560,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
//以50行为一个批次更新状态 //以50行为一个批次更新状态
if (tocofsSaleoutDetailedEntityList.size() > 0) { if (tocofsSaleoutDetailedEntityList.size() > 0) {
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
for (int i = 0; i < splitListByCount.size(); i++) { for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock7(tocofsSaleoutDetailedEntityList1); iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock7(tocofsSaleoutDetailedEntityList1);
@ -2661,25 +2666,38 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
Assert.notNull(header, "header不能为空"); Assert.notNull(header, "header不能为空");
Assert.notNull(detailsDto, "detailsDto不能为空"); Assert.notNull(detailsDto, "detailsDto不能为空");
//这里只能是金额
String totalPayAmount = null; String totalPayAmount = null;
if (isCheckShopChoose) { if (isCheckShopChoose) {
//取结存价 //取结存价
//结存金额=U结存金额/U结存数量*O明细行实出数量
List<BdInvmandocEntity> bdInvmandocEntityArrayList = new ArrayList<>(); List<BdInvmandocEntity> bdInvmandocEntityArrayList = new ArrayList<>();
bdInvmandocEntityArrayList.add(bdInvmandocEntity); bdInvmandocEntityArrayList.add(bdInvmandocEntity);
List<IaPeriodaccountEntity> iaPeriodaccountEntityList = balanceUnitPriceUtil.queryBalanceUnitPrice(bdInvmandocEntityArrayList); List<IaPeriodaccountEntity> iaPeriodaccountEntityList = balanceUnitPriceUtil.queryBalanceUnitPrice(bdInvmandocEntityArrayList);
if (iaPeriodaccountEntityList != null && iaPeriodaccountEntityList.size() > 0) { if (iaPeriodaccountEntityList != null && iaPeriodaccountEntityList.size() > 0) {
//结存金额
logger.info("店铺:{} 取O结存价", header.getStoreCode()); logger.info("店铺:{} 取O结存价", header.getStoreCode());
//结存金额
IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0); IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0);
String nabmny = iaPeriodaccountEntity.getNabmny(); String nabmny = iaPeriodaccountEntity.getNabmny();
if (nabmny == null || "".equals(nabmny)) { if (nabmny == null || "".equals(nabmny)) {
nabmny = "0"; nabmny = "0";
} }
BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny); BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString())) {
totalPayAmount = nabmnyBigDecimal.stripTrailingZeros().toPlainString(); //结存数量
String nabnum = iaPeriodaccountEntity.getNabnum();
if (nabnum == null || "".equals(nabnum)) {
nabnum = "0";
}
BigDecimal nabnumBigDecimal = new BigDecimal(nabnum);
if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString()) && !"0".equals(nabnumBigDecimal.stripTrailingZeros().toPlainString())) {
BigDecimal bigDecimal = nabmnyBigDecimal.divide(nabnumBigDecimal, 20, BigDecimal.ROUND_HALF_UP);
BigDecimal totalPayAmountBigDecimal = bigDecimal.multiply(new BigDecimal(detailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
} else { } else {
//如果结存金额为0则设置为0 //如果结存金额为或者数量为0则设置为0
totalPayAmount = "0"; totalPayAmount = "0";
} }
} else { } else {
@ -2690,15 +2708,15 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) { if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) {
logger.info("店铺:{} 取O采购价", header.getStoreCode()); logger.info("店铺:{} 取O采购价", header.getStoreCode());
String norgtaxprice = poOrderBEntityList.get(0).getNorgtaxprice(); String norgtaxprice = poOrderBEntityList.get(0).getNorgtaxprice();
String nordernum = poOrderBEntityList.get(0).getNordernum(); // String nordernum = poOrderBEntityList.get(0).getNordernum();
if ("0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString()) || "0".equals(new BigDecimal(nordernum).stripTrailingZeros().toPlainString())) { if (!"0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) {
// BigDecimal norgtaxpriceBigDecimal = new BigDecimal(norgtaxprice);
// BigDecimal nordernumBigDecimal = new BigDecimal(nordernum);
BigDecimal totalPayAmountBigDecimal = new BigDecimal(norgtaxprice).multiply(new BigDecimal(detailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
} else {
//如果采购单价都为0那么金额也为0 //如果采购单价都为0那么金额也为0
totalPayAmount = "0"; totalPayAmount = "0";
} else {
BigDecimal norgtaxpriceBigDecimal = new BigDecimal(norgtaxprice);
BigDecimal nordernumBigDecimal = new BigDecimal(nordernum);
BigDecimal multiply = norgtaxpriceBigDecimal.multiply(nordernumBigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPayAmount = multiply.stripTrailingZeros().toPlainString();
} }
} else { } else {
Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc()); Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc());

View File

@ -83,8 +83,8 @@ public class SoSaleOutPluginInitializerToBTest {
// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-23 16:09:59", "2024-10-23 16:10:01"); // soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-23 16:09:59", "2024-10-23 16:10:01");
// String aaa = "LETS-SH2024103100016169"; String aaa = "LETS-SH2024102100023018";
// soSaleOutPluginInitializerToB.startImplementByCode(aaa, "stock"); soSaleOutPluginInitializerToB.startImplementByCode(aaa, "tran");
// soSaleOutPluginInitializerToB.startImplementByTranTime("2024-10-28 00:00:00", "2024-10-28 23:59:59"); // soSaleOutPluginInitializerToB.startImplementByTranTime("2024-10-28 00:00:00", "2024-10-28 23:59:59");
// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-31 14:48:41", "2024-10-31 14:48:41"); // soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-31 14:48:41", "2024-10-31 14:48:41");
@ -95,7 +95,7 @@ public class SoSaleOutPluginInitializerToBTest {
// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-11-08 19:18:02", "2024-11-08 19:18:02"); // soSaleOutPluginInitializerToB.startImplementByStockTime("2024-11-08 19:18:02", "2024-11-08 19:18:02");
soSaleOutPluginInitializerToB.startImplementByTranTime("2000-11-08 19:18:02", "2000-11-08 19:18:02"); // soSaleOutPluginInitializerToB.startImplementByTranTime("2000-11-08 19:18:02", "2000-11-08 19:18:02");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -85,4 +85,9 @@ public class TobofsSaleoutDetailedDto {
@ExcelProperty(value = "交易-U8C主键") @ExcelProperty(value = "交易-U8C主键")
private String newsystemprimary4; private String newsystemprimary4;
//TOB交易红 结束 //TOB交易红 结束
//应收 开始
@ExcelProperty(value = "计算应收")
private String def7;
//应收 结束
} }

View File

@ -473,6 +473,8 @@
<result property="newsystemprimary4" column="newSystemPrimary4" jdbcType="VARCHAR"/> <result property="newsystemprimary4" column="newSystemPrimary4" jdbcType="VARCHAR"/>
<result property="businessDate" column="businessDate" jdbcType="VARCHAR"/> <result property="businessDate" column="businessDate" jdbcType="VARCHAR"/>
<result property="successfulTradeDate" column="successfulTradeDate" jdbcType="VARCHAR"/> <result property="successfulTradeDate" column="successfulTradeDate" jdbcType="VARCHAR"/>
<result property="def7" column="def7" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<!-- TOC通用查询 采用==查询 --> <!-- TOC通用查询 采用==查询 -->

View File

@ -57,4 +57,8 @@ public class DetailsDto {
* OFS销售订单 * OFS销售订单
*/ */
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
/**
* 目标应收
*/
private String targetAccountsReceivable;
} }