feat(plugin): 新增计算公式字段并优化相关功能

- 在 TocofsReturngoodsDetailedEntity 和 DetailsDto 中添加计算公式字段
- 修改相关方法以支持计算公式存储和传递
- 优化批量插入或更新操作,支持新字段- 调整分页查询大小
This commit is contained in:
liuy 2024-11-20 13:41:48 +08:00
parent c48f9fa4bb
commit 94e32ffa12
10 changed files with 108 additions and 43 deletions

View File

@ -911,10 +911,10 @@
<!-- 批量新增或者修改TOB退货-库存--> <!-- 批量新增或者修改TOB退货-库存-->
<insert id="entityInsertOrUpdateBatchByTobRerturnStock" keyProperty="id" useGeneratedKeys="true"> <insert id="entityInsertOrUpdateBatchByTobRerturnStock" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_returngoods_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary) insert into tocofs_returngoods_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary,def7,def8)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.newpushdate},#{entity.newtransmitinfo},#{entity.newstate},#{entity.newsystemnumber},#{entity.newsystemprimary}) (#{entity.id},#{entity.newpushdate},#{entity.newtransmitinfo},#{entity.newstate},#{entity.newsystemnumber},#{entity.newsystemprimary},#{entity.def7},#{entity.def8})
</foreach> </foreach>
on duplicate key update on duplicate key update
id = values(id), id = values(id),
@ -922,7 +922,9 @@
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),
def8 = values(def8)
</insert> </insert>
<!-- 批量新增或者修改TOB退货-库存--> <!-- 批量新增或者修改TOB退货-库存-->
@ -941,10 +943,10 @@
<!-- 批量新增或者修改TOB退货-确认收入--> <!-- 批量新增或者修改TOB退货-确认收入-->
<insert id="entityInsertOrUpdateBatchByTobRerturnTran" keyProperty="id" useGeneratedKeys="true"> <insert id="entityInsertOrUpdateBatchByTobRerturnTran" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_returngoods_detailed(id,newPushDate2,newTransmitInfo2,newState2,newSystemNumber2,newSystemPrimary2) insert into tocofs_returngoods_detailed(id,newPushDate2,newTransmitInfo2,newState2,newSystemNumber2,newSystemPrimary2,def7,def8)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.newpushdate2},#{entity.newtransmitinfo2},#{entity.newstate2},#{entity.newsystemnumber2},#{entity.newsystemprimary2}) (#{entity.id},#{entity.newpushdate2},#{entity.newtransmitinfo2},#{entity.newstate2},#{entity.newsystemnumber2},#{entity.newsystemprimary2},#{entity.def7},#{entity.def8})
</foreach> </foreach>
on duplicate key update on duplicate key update
id = values(id), id = values(id),
@ -952,7 +954,9 @@
newTransmitInfo2 = values(newTransmitInfo2), newTransmitInfo2 = values(newTransmitInfo2),
newState2 = values(newState2), newState2 = values(newState2),
newSystemNumber2 = values(newSystemNumber2), newSystemNumber2 = values(newSystemNumber2),
newSystemPrimary2 = values(newSystemPrimary2) newSystemPrimary2 = values(newSystemPrimary2),
def7 = values(def7),
def8 = values(def8)
</insert> </insert>
<!-- 批量新增或者修改TOB退货-确认收入--> <!-- 批量新增或者修改TOB退货-确认收入-->

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,def7) insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary,def7,def8)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
( (
@ -1019,7 +1019,8 @@
#{entity.newstate}, #{entity.newstate},
#{entity.newsystemnumber}, #{entity.newsystemnumber},
#{entity.newsystemprimary}, #{entity.newsystemprimary},
#{entity.def7} #{entity.def7},
#{entity.def8}
) )
</foreach> </foreach>
on duplicate key update on duplicate key update
@ -1029,7 +1030,8 @@
newState = values(newState), newState = values(newState),
newSystemNumber = values(newSystemNumber), newSystemNumber = values(newSystemNumber),
newSystemPrimary = values(newSystemPrimary), newSystemPrimary = values(newSystemPrimary),
def7 = values(def7) def7 = values(def7),
def8 = values(def8)
</insert> </insert>
<!-- TOB更新推送状态适合确认收入蓝字--> <!-- TOB更新推送状态适合确认收入蓝字-->
@ -1053,7 +1055,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,def7) insert into tocofs_saleout_detailed(id,def5,def6,newState4,newSystemNumber4,newSystemPrimary4,def7,def8)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
( (
@ -1063,7 +1065,8 @@
#{entity.newstate4}, #{entity.newstate4},
#{entity.newsystemnumber4}, #{entity.newsystemnumber4},
#{entity.newsystemprimary4}, #{entity.newsystemprimary4},
#{entity.def7} #{entity.def7},
#{entity.def8}
) )
</foreach> </foreach>
on duplicate key update on duplicate key update
@ -1073,7 +1076,8 @@
newState4 = values(newState4), newState4 = values(newState4),
newSystemNumber4 = values(newSystemNumber4), newSystemNumber4 = values(newSystemNumber4),
newSystemPrimary4 = values(newSystemPrimary4), newSystemPrimary4 = values(newSystemPrimary4),
def7 = values(def7) def7 = values(def7),
def8 = values(def8)
</insert> </insert>
<!--通过主键修改方法--> <!--通过主键修改方法-->

View File

@ -781,15 +781,16 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
tax = "0"; tax = "0";
} }
StringBuffer calculationFormula = new StringBuffer();//计算公式
BigDecimal noriginalcurprice = null;//无税单价 BigDecimal noriginalcurprice = null;//无税单价
BigDecimal noriginalcurmny = null;//无税金额 BigDecimal noriginalcurmny = null;//无税金额
BigDecimal noriginalcurtaxprice = null;//含税单价 BigDecimal noriginalcurtaxprice = null;//含税单价
BigDecimal noriginalcursummny = null;//价税合计 BigDecimal noriginalcursummny = null;//价税合计
BigDecimal noriginalcurtaxmny = null;//税额 BigDecimal noriginalcurtaxmny = null;//税额
String totalPayAmount = null;
try { try {
//判断目标金额O实收结存价采购价 //判断目标金额O实收结存价采购价
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto); totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto, calculationFormula);
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);
@ -843,6 +844,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
detailsDto.setDef7(totalPayAmount);
detailsDto.setDef8(calculationFormula.toString());
} }
//记录成功 //记录成功
//销售订单单据推送到u8c //销售订单单据推送到u8c
@ -1905,12 +1909,14 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity); // BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity);
// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity); // BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity);
//计算公式
StringBuffer calculationFormula = new StringBuffer();
//含税单价 //含税单价
BigDecimal noriginalcurtaxprice = null; BigDecimal noriginalcurtaxprice = null;
String totalPayAmount = null;
try { try {
//综合判断对应的目标金额 //综合判断对应的目标金额
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto); totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, detailsDto, calculationFormula);
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);
@ -1951,6 +1957,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// salesInvoiceBodyDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); // salesInvoiceBodyDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
salesInvoiceBodyDtoList.add(salesInvoiceBodyDto); salesInvoiceBodyDtoList.add(salesInvoiceBodyDto);
detailsDto.setDef7(totalPayAmount);
detailsDto.setDef8(calculationFormula.toString());
} }
SalesInvoiceDto salesInvoiceDto = new SalesInvoiceDto(); SalesInvoiceDto salesInvoiceDto = new SalesInvoiceDto();
salesInvoiceDto.setParentvo(salesInvoiceHeadDto); salesInvoiceDto.setParentvo(salesInvoiceHeadDto);
@ -2358,7 +2367,8 @@ 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()); tocofsSaleoutDetailedEntity.setDef7(detailsDto.getDef7());
tocofsSaleoutDetailedEntity.setDef8(detailsDto.getDef8());
if (successY.equals(newstate)) { if (successY.equals(newstate)) {
//只有成功才填充下游系统主键和编码 //只有成功才填充下游系统主键和编码
tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber); tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber);
@ -2415,7 +2425,8 @@ 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()); tocofsSaleoutDetailedEntity.setDef7(detailsDto.getDef7());
tocofsSaleoutDetailedEntity.setDef8(detailsDto.getDef8());
if (successY.equals(newstate)) { if (successY.equals(newstate)) {
//只有成功才填充下游系统主键和编码 //只有成功才填充下游系统主键和编码
tocofsSaleoutDetailedEntity.setNewsystemnumber4(newsystemnumber); tocofsSaleoutDetailedEntity.setNewsystemnumber4(newsystemnumber);
@ -2660,11 +2671,12 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
* @param detailsDto 对应的销售出库单明细行对象 * @param detailsDto 对应的销售出库单明细行对象
* @author liuyang * @author liuyang
*/ */
private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, HeaderDto header, DetailsDto detailsDto) throws Exception { private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, HeaderDto header, DetailsDto detailsDto, StringBuffer calculationFormula) throws Exception {
Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空");
Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空"); Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空");
Assert.notNull(header, "header不能为空"); Assert.notNull(header, "header不能为空");
Assert.notNull(detailsDto, "detailsDto不能为空"); Assert.notNull(detailsDto, "detailsDto不能为空");
Assert.notNull(calculationFormula, "calculationFormula不能为空");
//这里只能是金额 //这里只能是金额
String totalPayAmount = null; String totalPayAmount = null;
@ -2676,6 +2688,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
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());
calculationFormula.append("U结存金额");
//结存金额 //结存金额
IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0); IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0);
@ -2707,6 +2720,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
List<PoOrderBEntity> poOrderBEntityList = balanceUnitPriceUtil.queryPurchaseUnitPriceByInvcodes(bdInvmandocEntityArrayList1); List<PoOrderBEntity> poOrderBEntityList = balanceUnitPriceUtil.queryPurchaseUnitPriceByInvcodes(bdInvmandocEntityArrayList1);
if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) { if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) {
logger.info("店铺:{} 取O采购价", header.getStoreCode()); logger.info("店铺:{} 取O采购价", header.getStoreCode());
calculationFormula.append("U采购金额");
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())) { if (!"0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) {
@ -2724,6 +2738,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
} }
} else { } else {
logger.info("店铺:{} 取O实付金额", header.getStoreCode()); logger.info("店铺:{} 取O实付金额", header.getStoreCode());
calculationFormula.append("O实退金额");
totalPayAmount = detailsDto.getTotalPayAmount(); totalPayAmount = detailsDto.getTotalPayAmount();
} }
return totalPayAmount; return totalPayAmount;

View File

@ -201,7 +201,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
private static final String NOTHING = ""; private static final String NOTHING = "";
private static final String ADD = "(*)"; private static final String ADD = "&";
@Autowired @Autowired
private ShopTobOrToCUtil shopTobOrToCUtil; private ShopTobOrToCUtil shopTobOrToCUtil;
@ -849,6 +849,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
List<SonDetailsDto> sonDetailsDtoList = queryBasicArchivesStock(headerDetailsDtos, sceneType); List<SonDetailsDto> sonDetailsDtoList = queryBasicArchivesStock(headerDetailsDtos, sceneType);
// 分组汇总 // 分组汇总
// String dimension = "1001(*)dy-intoyou(*)B2CHA20240010(*)6973391735605(*)SALES(*)002"; // String dimension = "1001(*)dy-intoyou(*)B2CHA20240010(*)6973391735605(*)SALES(*)002";
// String dimension = "1001(*)dy-intoyou(*)B2CHA20240010(*)6973391732482(*)SALES(*)002";
String dimension = null; String dimension = null;
Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummaryStock(sonDetailsDtoList, dimension); Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummaryStock(sonDetailsDtoList, dimension);
// 查询U8C业务流程 // 查询U8C业务流程
@ -1673,6 +1674,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空");
Assert.notNull(mapList, "mapLists不能为空"); Assert.notNull(mapList, "mapLists不能为空");
StringBuffer aaa = new StringBuffer();
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
BigDecimal groupTotalPayAmount = new BigDecimal("0"); BigDecimal groupTotalPayAmount = new BigDecimal("0");
BigDecimal groupShipQty = new BigDecimal("0"); BigDecimal groupShipQty = new BigDecimal("0");
@ -1723,6 +1725,8 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
BigDecimal detailedLineUnitPrice = new BigDecimal(targetDetails.getPayableAmount()).divide(new BigDecimal(targetDetails.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP); BigDecimal detailedLineUnitPrice = new BigDecimal(targetDetails.getPayableAmount()).divide(new BigDecimal(targetDetails.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP);
BigDecimal totalPayAmountBigDecimal = detailedLineUnitPrice.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal totalPayAmountBigDecimal = detailedLineUnitPrice.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString(); totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
aaa.append(totalPayAmount);
aaa.append(",");
String format = StrUtil.format("{}/{}*{}", targetDetails.getPayableAmount(), targetDetails.getRequestQty(), sonDetailsDto.getShipQty()); String format = StrUtil.format("{}/{}*{}", targetDetails.getPayableAmount(), targetDetails.getRequestQty(), sonDetailsDto.getShipQty());
calculationFormulaStr.append(format); calculationFormulaStr.append(format);
@ -1777,6 +1781,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//累加各类优惠 //累加各类优惠
// logger.info("{}个明细行发生了合并!", sonDetailsDtoList.size()); // logger.info("{}个明细行发生了合并!", sonDetailsDtoList.size());
System.out.println(aaa.toString());
return sonDetailsDto; return sonDetailsDto;
} else { } else {
logger.error("sonDetailsDtoList集合是空的"); logger.error("sonDetailsDtoList集合是空的");

View File

@ -779,17 +779,18 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
tax = "0"; tax = "0";
} }
StringBuffer calculationFormula = new StringBuffer();//计算公式
BigDecimal noriginalcurprice = null;//无税单价 BigDecimal noriginalcurprice = null;//无税单价
BigDecimal noriginalcurmny = null;//无税金额 BigDecimal noriginalcurmny = null;//无税金额
BigDecimal noriginalcurtaxprice = null;//含税单价 BigDecimal noriginalcurtaxprice = null;//含税单价
BigDecimal noriginalcursummny = null;//价税合计 BigDecimal noriginalcursummny = null;//价税合计
BigDecimal noriginalcurtaxmny = null;//税额 BigDecimal noriginalcurtaxmny = null;//税额
String totalAmount = null;
try { try {
// Assert.notNull(stockinB.getTotalAmount(), "退货入库单总金额不能为空 明细行对象:{}", JSON.toJSONString(stockinB)); // Assert.notNull(stockinB.getTotalAmount(), "退货入库单总金额不能为空 明细行对象:{}", JSON.toJSONString(stockinB));
Assert.notNull(stockinB.getReceivedQty(), "实收数量不能为空 明细行对象:{}", JSON.toJSONString(stockinB)); Assert.notNull(stockinB.getReceivedQty(), "实收数量不能为空 售后订单:{} 售后订单主键:{}", header.getCode(), stockinB.getId());
//确定实退金额可能为O的实退金额也可能是结存价和采购价
//确定好实退金额可能为O的实退金额也可能是结存价和采购价 totalAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, afterSalesOrder, calculationFormula, stockinB);
String totalAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, afterSalesOrder);
noriginalcurtaxprice = new BigDecimal(totalAmount).divide(new BigDecimal(stockinB.getReceivedQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurtaxprice = new BigDecimal(totalAmount).divide(new BigDecimal(stockinB.getReceivedQty()), 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);
@ -833,6 +834,9 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
stockinB.setDef7(totalAmount);//计算应收
stockinB.setDef8(calculationFormula.toString());//计算公式
} }
//记录成功 //记录成功
//销售订单单据推送到u8c //销售订单单据推送到u8c
@ -1847,6 +1851,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity); // BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity);
// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity); // BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity);
StringBuffer calculationFormula = new StringBuffer();//计算公式
calculationFormula.append("O实退金额");
BigDecimal noriginalcurtaxprice = null;//含税单价 BigDecimal noriginalcurtaxprice = null;//含税单价
try { try {
noriginalcurtaxprice = new BigDecimal(afterSalesOrder.getTotalAmount()).divide(new BigDecimal(stockinB.getReceivedQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurtaxprice = new BigDecimal(afterSalesOrder.getTotalAmount()).divide(new BigDecimal(stockinB.getReceivedQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
@ -1877,6 +1883,9 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// salesInvoiceBodyDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // salesInvoiceBodyDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
// salesInvoiceBodyDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); // salesInvoiceBodyDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
salesInvoiceBodyDtoList.add(salesInvoiceBodyDto); salesInvoiceBodyDtoList.add(salesInvoiceBodyDto);
stockinB.setDef7("-" + new BigDecimal(afterSalesOrder.getTotalAmount()).stripTrailingZeros().toPlainString());
stockinB.setDef8(calculationFormula.toString());//计算公式
} }
SalesInvoiceDto salesInvoiceDto = new SalesInvoiceDto(); SalesInvoiceDto salesInvoiceDto = new SalesInvoiceDto();
salesInvoiceDto.setParentvo(salesInvoiceHeadDto); salesInvoiceDto.setParentvo(salesInvoiceHeadDto);
@ -2283,6 +2292,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
tocofsReturngoodsDetailedEntity.setNewpushdate(getNewDateStr()); tocofsReturngoodsDetailedEntity.setNewpushdate(getNewDateStr());
tocofsReturngoodsDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo); tocofsReturngoodsDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo);
tocofsReturngoodsDetailedEntity.setNewstate(newstate); tocofsReturngoodsDetailedEntity.setNewstate(newstate);
tocofsReturngoodsDetailedEntity.setDef7(stockinB.getDef7());
tocofsReturngoodsDetailedEntity.setDef8(stockinB.getDef8());
if (successY.equals(newstate)) { if (successY.equals(newstate)) {
tocofsReturngoodsDetailedEntity.setNewsystemnumber(newsystemnumber); tocofsReturngoodsDetailedEntity.setNewsystemnumber(newsystemnumber);
tocofsReturngoodsDetailedEntity.setNewsystemprimary(newsystemprimary); tocofsReturngoodsDetailedEntity.setNewsystemprimary(newsystemprimary);
@ -2292,7 +2303,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
//以50行为一个批次推送到Mysql //以50行为一个批次推送到Mysql
if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) { if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) {
List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 50); List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 200);
for (int i = 0; i < splitListByCount.size(); i++) { for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = splitListByCount.get(i); List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = splitListByCount.get(i);
iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTobRerturnStock(tocofsReturngoodsDetailedEntities); iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTobRerturnStock(tocofsReturngoodsDetailedEntities);
@ -2349,6 +2360,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
tocofsReturngoodsDetailedEntity.setNewpushdate2(getNewDateStr()); tocofsReturngoodsDetailedEntity.setNewpushdate2(getNewDateStr());
tocofsReturngoodsDetailedEntity.setNewtransmitinfo2(finalNewTransmitInfo); tocofsReturngoodsDetailedEntity.setNewtransmitinfo2(finalNewTransmitInfo);
tocofsReturngoodsDetailedEntity.setNewstate2(newstate); tocofsReturngoodsDetailedEntity.setNewstate2(newstate);
tocofsReturngoodsDetailedEntity.setDef7(stockinB.getDef7());
tocofsReturngoodsDetailedEntity.setDef8(stockinB.getDef8());
if (successY.equals(newstate)) { if (successY.equals(newstate)) {
tocofsReturngoodsDetailedEntity.setNewsystemnumber2(newsystemnumber); tocofsReturngoodsDetailedEntity.setNewsystemnumber2(newsystemnumber);
tocofsReturngoodsDetailedEntity.setNewsystemprimary2(newsystemprimary); tocofsReturngoodsDetailedEntity.setNewsystemprimary2(newsystemprimary);
@ -2511,18 +2524,23 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
* 获取结存金额或者采购金额 * 获取结存金额或者采购金额
* Boolean isCheckShopChoose * Boolean isCheckShopChoose
* *
* @param isCheckShopChoose true取OFS实付金额false取结存金额或者采购价 * @param isCheckShopChoose true取OFS实付金额false取结存金额或者采购价
* @param bdInvmandocEntity 存货管理档案 * @param bdInvmandocEntity 存货管理档案
* @param header OFS收入入库单表头 * @param header OFS售后入库单表头
* @param afterSalesOrder OFS售后订单明细行 * @param afterSalesOrder OFS售后订单明细行
* @param calculationFormula 计算公式
* @param stockinB OFS售后入库单明细行
* @author liuyang * @author liuyang
*/ */
private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, StockinOrderSearchResponse.StockinOrder.StockinH header, RerturnGoodsOrderSearchDetails afterSalesOrder) throws Exception { private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, StockinOrderSearchResponse.StockinOrder.StockinH header, RerturnGoodsOrderSearchDetails afterSalesOrder, StringBuffer calculationFormula, StockinOrderSearchResponse.StockinOrder.StockinB stockinB) throws Exception {
Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空");
Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空"); Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空");
Assert.notNull(header, "header不能为空"); Assert.notNull(header, "header不能为空");
Assert.notNull(afterSalesOrder, "afterSalesOrder不能为空"); Assert.notNull(afterSalesOrder, "afterSalesOrder不能为空");
Assert.notNull(calculationFormula, "calculationFormula不能为空");
Assert.notNull(stockinB, "stockinB不能为空");
//totalPayAmount只能是金额
String totalPayAmount = null; String totalPayAmount = null;
if (isCheckShopChoose) { if (isCheckShopChoose) {
//取结存 //取结存
@ -2530,6 +2548,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
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) {
calculationFormula.append("U结存金额");
//结存金额 //结存金额
logger.info("店铺:{} 取O结存价", header.getStoreCode()); logger.info("店铺:{} 取O结存价", header.getStoreCode());
IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0); IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0);
@ -2550,17 +2569,21 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
bdInvmandocEntityArrayList1.add(bdInvmandocEntity); bdInvmandocEntityArrayList1.add(bdInvmandocEntity);
List<PoOrderBEntity> poOrderBEntityList = balanceUnitPriceUtil.queryPurchaseUnitPriceByInvcodes(bdInvmandocEntityArrayList1); List<PoOrderBEntity> poOrderBEntityList = balanceUnitPriceUtil.queryPurchaseUnitPriceByInvcodes(bdInvmandocEntityArrayList1);
if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) { if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) {
calculationFormula.append("U采购金额");
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())) {
//如果采购单价都为0那么金额也为0 //如果采购单价都为0那么金额也为0
totalPayAmount = "0"; totalPayAmount = "0";
} else { } else {
BigDecimal norgtaxpriceBigDecimal = new BigDecimal(norgtaxprice); //采购金额的确定=原币含税单价*O实退数量
BigDecimal nordernumBigDecimal = new BigDecimal(nordernum); // BigDecimal norgtaxpriceBigDecimal = new BigDecimal(norgtaxprice);
BigDecimal multiply = norgtaxpriceBigDecimal.multiply(nordernumBigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP); // BigDecimal nordernumBigDecimal = new BigDecimal(nordernum);
totalPayAmount = multiply.stripTrailingZeros().toPlainString(); // BigDecimal multiply = norgtaxpriceBigDecimal.multiply(nordernumBigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
// totalPayAmount = multiply.stripTrailingZeros().toPlainString();
BigDecimal totalPayAmountBigDecimal = new BigDecimal(norgtaxprice).multiply(new BigDecimal(stockinB.getReceivedQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
} }
} else { } else {
Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc()); Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc());
@ -2569,6 +2592,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
} else { } else {
//O用户实退 //O用户实退
logger.info("店铺:{} 取O实付金额", header.getStoreCode()); logger.info("店铺:{} 取O实付金额", header.getStoreCode());
calculationFormula.append("O实退金额");
totalPayAmount = afterSalesOrder.getTotalAmount(); totalPayAmount = afterSalesOrder.getTotalAmount();
} }
return totalPayAmount; return totalPayAmount;

View File

@ -170,7 +170,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
private static final String NOTHING = ""; private static final String NOTHING = "";
private static final String ADD = "(*)"; private static final String ADD = "&";
@Autowired @Autowired
private ITocofsReturngoodsDao iTocofsReturngoodsDao; private ITocofsReturngoodsDao iTocofsReturngoodsDao;

View File

@ -55,7 +55,7 @@ public class OfsStandardUtil {
Assert.notNull(pageNo, "pageNo不能为空"); Assert.notNull(pageNo, "pageNo不能为空");
Assert.notNull(api, "api不能为空"); Assert.notNull(api, "api不能为空");
Long pageSize = 400L; Long pageSize = 500L;
queryOfsSoSaleOutVo.setPageNo(pageNo); queryOfsSoSaleOutVo.setPageNo(pageNo);
queryOfsSoSaleOutVo.setPageSize(pageSize); queryOfsSoSaleOutVo.setPageSize(pageSize);

View File

@ -112,7 +112,7 @@ class SoSaleOutPluginInitializerToCTest {
// String aaa = "LETS-SH2024102800021196"; // String aaa = "LETS-SH2024102800021196";
// soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-05 10:28:06", "2024-11-05 10:28:06"); // soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-05 10:28:06", "2024-11-05 10:28:06");
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-11-01 00:00:00", "2024-11-01 23:59:59"); soSaleOutPluginInitializerToC.startImplementStockByTime("2024-11-15 00:00:00", "2024-11-15 23:59:59");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -120,7 +120,7 @@ class SoSaleOutPluginInitializerToCTest {
// soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446"); // soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446");
try { try {
soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024103100030329", "stock"); // soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024103100030329", "stock");
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110500013375", "tran"); // soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110500013375", "tran");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -60,5 +60,10 @@ public class DetailsDto {
/** /**
* 目标应收 * 目标应收
*/ */
private String targetAccountsReceivable; private String def7;
/**
* 计算公式
*/
private String def8;
} }

View File

@ -107,6 +107,14 @@ public class StockinOrderSearchResponse extends ReturnMessageBasics {
private String newstate4; private String newstate4;
//表头对象 //表头对象
private StockinH returnGoodSearchHeaderDto; private StockinH returnGoodSearchHeaderDto;
/**
* 计算应收
*/
private String def7;
/**
* 计算公式
*/
private String def8;
} }
} }
} }