refactor(buildpackage): 重构查询逻辑并优化数据处理

-将 IaPeriodaccountEntity 中的 BigDecimal 字段改为 String 类型- 优化了 SoSaleOutPluginInitializerToB、SoSaleOutPluginInitializerToC 和 SoSaleReturnPluginInitializerToB 中的结存金额处理逻辑
- 重构了 TocOrderBasicArchivesCacheUtil 中的查询方法,提高了查询效率- 新增 BalanceUnitPriceUtilTest 测试类
This commit is contained in:
liuy 2024-10-21 20:31:10 +08:00
parent 429c160501
commit 24218ce79e
8 changed files with 193 additions and 67 deletions

View File

@ -33,8 +33,8 @@ public class IaPeriodaccountEntity extends BaseEntity {
private String dr;
private String fpricemodeflag;
private String nabassistnum;
private BigDecimal nabmny;
private BigDecimal nabnum;
private String nabmny;
private String nabnum;
private String nabplanedmny;
private String nabvarymny;
private String ndrawsummny;

View File

@ -23,8 +23,8 @@
<result property="dr" column="DR" jdbcType="VARCHAR"/>
<result property="fpricemodeflag" column="FPRICEMODEFLAG" jdbcType="VARCHAR"/>
<result property="nabassistnum" column="NABASSISTNUM" jdbcType="VARCHAR"/>
<result property="nabmny" column="NABMNY" jdbcType="NUMBER"/>
<result property="nabnum" column="NABNUM" jdbcType="NUMBER"/>
<result property="nabmny" column="NABMNY" jdbcType="VARCHAR"/>
<result property="nabnum" column="NABNUM" jdbcType="VARCHAR"/>
<result property="nabplanedmny" column="NABPLANEDMNY" jdbcType="VARCHAR"/>
<result property="nabvarymny" column="NABVARYMNY" jdbcType="VARCHAR"/>
<result property="ndrawsummny" column="NDRAWSUMMNY" jdbcType="VARCHAR"/>

View File

@ -2647,11 +2647,11 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
//结存金额
logger.info("店铺:{} 取O结存价", header.getStoreCode());
IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0);
BigDecimal nabmnyBigDecimal = iaPeriodaccountEntity.getNabmny();
if (nabmnyBigDecimal == null) {
nabmnyBigDecimal = new BigDecimal("0");
String nabmny = iaPeriodaccountEntity.getNabmny();
if (nabmny == null || "".equals(nabmny)) {
nabmny = "0";
}
// BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString())) {
totalPayAmount = nabmnyBigDecimal.stripTrailingZeros().toPlainString();
} else {

View File

@ -2598,18 +2598,18 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
logger.info("店铺:{} 取O结存价", header.getStoreCode());
//结存金额
BigDecimal nabmnyBigDecimal = iaPeriodaccountEntity1.getNabmny();
if (nabmnyBigDecimal == null) {
nabmnyBigDecimal = new BigDecimal("0");
String nabmny = iaPeriodaccountEntity1.getNabmny();
if (nabmny == null || "".equals(nabmny)) {
nabmny = "0";
}
// BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
//结存数量
BigDecimal nabnumBigDecimal = iaPeriodaccountEntity1.getNabnum();
if (nabnumBigDecimal == null) {
nabnumBigDecimal = new BigDecimal("0");
String nabnum = iaPeriodaccountEntity1.getNabnum();
if (nabnum == null || "".equals(nabnum)) {
nabnum = "0";
}
// BigDecimal nabnumBigDecimal = new BigDecimal(nabnum);
BigDecimal nabnumBigDecimal = new BigDecimal(nabnum);
if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString()) && !"0".equals(nabnumBigDecimal.stripTrailingZeros().toPlainString())) {
//得到结存单价

View File

@ -2503,11 +2503,11 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
//结存金额
logger.info("店铺:{} 取O结存价", header.getStoreCode());
IaPeriodaccountEntity iaPeriodaccountEntity = iaPeriodaccountEntityList.get(0);
BigDecimal nabmnyBigDecimal = iaPeriodaccountEntity.getNabmny();
if (nabmnyBigDecimal == null) {
nabmnyBigDecimal = new BigDecimal("0");
String nabmny = iaPeriodaccountEntity.getNabmny();
if (nabmny == null || "".equals(nabmny)) {
nabmny = "0";
}
// BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny);
if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString())) {
totalPayAmount = nabmnyBigDecimal.stripTrailingZeros().toPlainString();
} else {

View File

@ -220,25 +220,43 @@ public class TocOrderBasicArchivesCacheUtil {
private Map<String, BdCubasdocEntity> initBdCubasdocV2(List<HeaderDto> headerDtoList) {
Map<String, BdCubasdocEntity> stringBdCubasdocEntityMap = new HashMap<>();
List<BdCubasdocEntity> allBdCumandocEntityList = new ArrayList<>();
if (headerDtoList != null && headerDtoList.size() > 0) {
List<List<HeaderDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDtoList, 900);
for (int i = 0; i < splitListByCount.size(); i++) {
List<HeaderDto> headerDtoList1 = splitListByCount.get(i);
Set<String> storeCodeHashSet = headerDtoList1.stream().map(HeaderDto::getStoreCode).collect(Collectors.toSet());
String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
// String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
//测试
// codesStr = "'dy-off-01'";
if (codesStr != null && codesStr.length() > 0) {
// List<List<HeaderDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDtoList, 900);
// for (int i = 0; i < splitListByCount.size(); i++) {
// List<HeaderDto> headerDtoList1 = splitListByCount.get(i);
// Set<String> storeCodeHashSet = headerDtoList1.stream().map(HeaderDto::getStoreCode).collect(Collectors.toSet());
// String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
//// String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
// //测试
//// codesStr = "'dy-off-01'";
// if (codesStr != null && codesStr.length() > 0) {
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1s(codesStr);
// List<BdCubasdocEntity> bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// allBdCumandocEntityList.addAll(bdCumandocEntityList);
// }
// }
Set<String> stringSet = headerDtoList.stream().map(HeaderDto::getStoreCode).collect(Collectors.toSet());
List<String> stringList = stringSet.stream().collect(Collectors.toList());
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
for (int i = 0; i < lists.size(); i++) {
List<String> strings = lists.get(i);
String result = strings.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (result != null && result.length() > 0) {
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1s(codesStr);
bdCubasdocEntity.setDef1s(result);
List<BdCubasdocEntity> bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
allBdCumandocEntityList.addAll(bdCumandocEntityList);
}
}
}
if (allBdCumandocEntityList.size() > 0) {
for (int i = 0; i < allBdCumandocEntityList.size(); i++) {
BdCubasdocEntity bdCubasdocEntity = allBdCumandocEntityList.get(i);
@ -281,20 +299,36 @@ public class TocOrderBasicArchivesCacheUtil {
List<BdCumandocEntity> allBdCumandocEntityList = new ArrayList<>();
if (headerDtoList != null && headerDtoList.size() > 0) {
List<List<HeaderDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDtoList, 900);
for (int i = 0; i < splitListByCount.size(); i++) {
List<HeaderDto> headerDtoList1 = splitListByCount.get(i);
Set<String> storeCodeHashSet = headerDtoList1.stream().map(HeaderDto::getStoreCode).collect(Collectors.toSet());
String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
// String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
//测试
// codesStr = "'dy-off-01'";
// List<List<HeaderDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDtoList, 900);
// for (int i = 0; i < splitListByCount.size(); i++) {
// List<HeaderDto> headerDtoList1 = splitListByCount.get(i);
// Set<String> storeCodeHashSet = headerDtoList1.stream().map(HeaderDto::getStoreCode).collect(Collectors.toSet());
// String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
//// String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
// //测试
//// codesStr = "'dy-off-01'";
//
// if (codesStr != null && codesStr.length() > 0) {
// BdCumandocEntity bdCumandocEntity = new BdCumandocEntity();
// bdCumandocEntity.setDataSourceCode("lets_u8c");
// bdCumandocEntity.setDr(0L);
// bdCumandocEntity.setDef1s(codesStr);
// List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity);
// allBdCumandocEntityList.addAll(bdCumandocEntityList);
// }
// }
if (codesStr != null && codesStr.length() > 0) {
Set<String> stringSet = headerDtoList.stream().map(HeaderDto::getStoreCode).collect(Collectors.toSet());
List<String> stringList = stringSet.stream().collect(Collectors.toList());
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
for (int i = 0; i < lists.size(); i++) {
List<String> strings = lists.get(i);
String result = strings.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (result != null && result.length() > 0) {
BdCumandocEntity bdCumandocEntity = new BdCumandocEntity();
bdCumandocEntity.setDataSourceCode("lets_u8c");
bdCumandocEntity.setDr(0L);
bdCumandocEntity.setDef1s(codesStr);
bdCumandocEntity.setDef1s(result);
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity);
allBdCumandocEntityList.addAll(bdCumandocEntityList);
}
@ -333,22 +367,40 @@ public class TocOrderBasicArchivesCacheUtil {
List<BdInvmandocEntity> allBdInvmandocEntity = new ArrayList<>();
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = new HashMap<>();
if (detailsDtos != null && detailsDtos.size() > 0) {
List<List<DetailsDto>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 900);
for (int i = 0; i < lists.size(); i++) {
List<DetailsDto> detailsDtos1 = lists.get(i);
Set<String> storeCodeHashSet = detailsDtos1.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
// String idsStr = detailsDtos1.stream().map(DetailsDto::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
if (codesStr != null && codesStr.length() > 0) {
if (detailsDtos != null && detailsDtos.size() > 0) {
Set<String> stringSet = detailsDtos.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
List<String> stringList = stringSet.stream().collect(Collectors.toList());
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
for (int i = 0; i < lists.size(); i++) {
List<String> strings = lists.get(i);
String result = strings.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (result != null && result.length() > 0) {
BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
bdInvmandocEntity.setInvcodes(codesStr);
bdInvmandocEntity.setInvcodes(result);
List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
allBdInvmandocEntity.addAll(bdInvmandocEntity2);
}
}
}
// if (detailsDtos != null && detailsDtos.size() > 0) {
// List<List<DetailsDto>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 900);
// for (int i = 0; i < lists.size(); i++) {
// List<DetailsDto> detailsDtos1 = lists.get(i);
// Set<String> storeCodeHashSet = detailsDtos1.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
// String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
//// String idsStr = detailsDtos1.stream().map(DetailsDto::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
//
// if (codesStr != null && codesStr.length() > 0) {
// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
// bdInvmandocEntity.setInvcodes(codesStr);
// List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
// allBdInvmandocEntity.addAll(bdInvmandocEntity2);
// }
// }
// }
if (allBdInvmandocEntity.size() > 0) {
for (int i = 0; i < allBdInvmandocEntity.size(); i++) {
BdInvmandocEntity bdInvmandocEntity = allBdInvmandocEntity.get(i);
@ -386,14 +438,14 @@ public class TocOrderBasicArchivesCacheUtil {
*/
private Map<String, BdInvbasdocEntity> initBasicInventoryFileV2(List<DetailsDto> detailsDtoList) throws Exception {
List<BdInvbasdocEntity> allBdInvbasdocEntityList = new ArrayList<>();
if (detailsDtoList != null && detailsDtoList.size() > 0) {
List<List<DetailsDto>> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 900);
for (int i = 0; i < lists.size(); i++) {
List<DetailsDto> detailsDtos = lists.get(i);
// String idsStr = detailsDtos.stream().map(DetailsDto::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
Set<String> storeCodeHashSet = detailsDtos.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (detailsDtoList != null && detailsDtoList.size() > 0) {
Set<String> stringSet = detailsDtoList.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
List<String> stringList = stringSet.stream().collect(Collectors.toList());
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
for (int i = 0; i < lists.size(); i++) {
List<String> strings = lists.get(i);
String codesStr = strings.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (codesStr != null && codesStr.length() > 0) {
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setInvcodes(codesStr);
@ -402,6 +454,23 @@ public class TocOrderBasicArchivesCacheUtil {
}
}
}
// if (detailsDtoList != null && detailsDtoList.size() > 0) {
// List<List<DetailsDto>> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 900);
// for (int i = 0; i < lists.size(); i++) {
// List<DetailsDto> detailsDtos = lists.get(i);
//// String idsStr = detailsDtos.stream().map(DetailsDto::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
// Set<String> storeCodeHashSet = detailsDtos.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
// String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
//
// if (codesStr != null && codesStr.length() > 0) {
// BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
// bdInvbasdocEntity.setInvcodes(codesStr);
// List<BdInvbasdocEntity> bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity);
// allBdInvbasdocEntityList.addAll(bdInvbasdocEntities);
// }
// }
// }
Map<String, BdInvbasdocEntity> stringBdInvbasdocEntityMap = new HashMap<>();
for (int i = 0; i < allBdInvbasdocEntityList.size(); i++) {
BdInvbasdocEntity bdInvbasdocEntity = allBdInvbasdocEntityList.get(i);
@ -437,21 +506,38 @@ public class TocOrderBasicArchivesCacheUtil {
List<BdTaxitemsEntity> allBdTaxitemsEntityList = new ArrayList<>();
Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = new HashMap<>();
if (detailsDtos != null && detailsDtos.size() > 0) {
List<List<DetailsDto>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 900);
Set<String> stringSet = detailsDtos.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
List<String> stringList = stringSet.stream().collect(Collectors.toList());
List<List<String>> lists = SplitListByCountUtil.splitListByCount(stringList, 900);
for (int i = 0; i < lists.size(); i++) {
List<DetailsDto> detailsDtos1 = lists.get(i);
// String codesStr = detailsDtos1.stream().map(DetailsDto::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
Set<String> storeCodeHashSet = detailsDtos1.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (codesStr != null && codesStr.length() > 0) {
List<String> strings = lists.get(i);
String result = strings.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
if (result != null && result.length() > 0) {
BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity();
bdTaxitemsEntity.setInvcodes(codesStr);
bdTaxitemsEntity.setInvcodes(result);
List<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList);
}
}
}
// List<BdTaxitemsEntity> allBdTaxitemsEntityList = new ArrayList<>();
// Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = new HashMap<>();
// if (detailsDtos != null && detailsDtos.size() > 0) {
// List<List<DetailsDto>> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 900);
// for (int i = 0; i < lists.size(); i++) {
// List<DetailsDto> detailsDtos1 = lists.get(i);
//// String codesStr = detailsDtos1.stream().map(DetailsDto::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
// Set<String> storeCodeHashSet = detailsDtos1.stream().map(DetailsDto::getSkuCode).collect(Collectors.toSet());
// String codesStr = storeCodeHashSet.stream().map(s -> "'" + s + "'").collect(Collectors.joining(","));
//
// if (codesStr != null && codesStr.length() > 0) {
// BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity();
// bdTaxitemsEntity.setInvcodes(codesStr);
// List<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
// allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList);
// }
// }
// }
if (allBdTaxitemsEntityList.size() > 0) {
for (int i = 0; i < allBdTaxitemsEntityList.size(); i++) {
BdTaxitemsEntity bdTaxitemsEntity = allBdTaxitemsEntityList.get(i);

View File

@ -96,9 +96,9 @@ class SoSaleOutPluginInitializerToCTest {
// soSaleOutPluginInitializerToC.startImplementStockByCode(s, "stock");
try {
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-17 00:00:00", "2024-10-17 23:59:59");
String code = "LETS-SH2024101600027243";
soSaleOutPluginInitializerToC.startImplementStockByCode(code, "stock");
soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-18 00:00:00", "2024-10-18 23:59:59");
// String code = "LETS-SH2024101600027243";
// soSaleOutPluginInitializerToC.startImplementStockByCode(code, "stock");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -0,0 +1,40 @@
package com.hzya.frame.plugin.lets.util;
import com.hzya.frame.WebappApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.util
* @ProjectkangarooDataCenterV3
* @nameBalanceUnitPriceUtilTest
* @Date2024/10/21 17:58
* @FilenameBalanceUnitPriceUtilTest
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebappApplication.class)
public class BalanceUnitPriceUtilTest {
@Autowired
private BalanceUnitPriceUtil balanceUnitPriceUtil;
@Test
public void initBalancePrice() {
try {
balanceUnitPriceUtil.initBalancePrice();
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void initPurchasePrice() {
}
}