数据库插入和更新批处理及列表处理优化

- 修改了数据库批处理插入或更新逻辑,将集合属性名从`entities`更改为`list`,以确保代码一致性和清晰性。
- 在多个XML配置文件中进行了调整,包括`toco fs_returngoods_detailed`和`toco fs_returngoods`实体的处理。
- 精简了SoSaleOut和SoSaleReturn插件初始化器中的列表处理逻辑,移除了不必要的空列表检查,提高了代码的简洁性和可读性。- 通过这些调整,优化了代码结构,减少了潜在的逻辑错误,并提高了整体代码质量。
This commit is contained in:
liuy 2024-09-18 10:50:16 +08:00
parent 1743875471
commit b16d708566
7 changed files with 16 additions and 36 deletions

View File

@ -837,7 +837,7 @@
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_returngoods_detailed(id,receiptId, receiptCode, refOrderId, refOrderDetailId, sourceOrderCode, sourceLineNum, clientCode, companyCode, facilityCode, skuCode, skuName, requestQty, receivedQty, openQty, quantityUM, totalWeight, totalVolume, totalVolumeWeight, totalAmount, weightUM, volumeUM, inventorySts, inTransInvId, closed, created, createdBy, lastUpdated, lastUpdatedBy, discountPrice, mainTableId, businessDate, refundedAt, businessType)
values
<foreach collection="entities" item="entity" separator=",">
<foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.receiptid},#{entity.receiptcode},#{entity.reforderid},#{entity.reforderdetailid},#{entity.sourceordercode},#{entity.sourcelinenum},#{entity.clientcode},#{entity.companycode},#{entity.facilitycode},#{entity.skucode},#{entity.skuname},#{entity.requestqty},#{entity.receivedqty},#{entity.openqty},#{entity.quantityum},#{entity.totalweight},#{entity.totalvolume},#{entity.totalvolumeweight},#{entity.totalamount},#{entity.weightum},#{entity.volumeum},#{entity.inventorysts},#{entity.intransinvid},#{entity.closed},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby},#{entity.discountprice},#{entity.maintableid},#{entity.businessdate},#{entity.refundedat},#{entity.businesstype})
</foreach>
on duplicate key update

View File

@ -514,7 +514,7 @@
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_returngoods(id,clientCode, companyCode, storeCode, facilityCode, code, internalInstructionType, bizChannel, refOrderId, refOrderCode, refOrderType, closed, closedBy, status, allowOverReceive, shipFromAttentionTo, shipFromAddress, shipFromCountry, shipFromState, shipFromCity, shipFromDistrict, shipFromPostalCode, shipFromMobile, shipFromEmail, totalLines, totalQty, totalAmount, totalWeight, totalVolume, totalVolumeWeight, totalFulfillAmount, totalFulfillWeight, totalFulfillVolume, totalFulfillVolumeWeight, totalFulfillQty, totalCases, totalContainers, closeAtQty, quantityUM, weightUM, volumeUM, checkInFrom, checkInTo, closedAt, sourcePlatformCode, sourceOrderCode, created, createdBy, lastUpdated, lastUpdatedBy, returnWaybillCode, returnCarrier, refundedAt, refundStatus)
values
<foreach collection="entities" item="entity" separator=",">
<foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.clientcode},#{entity.companycode},#{entity.storecode},#{entity.facilitycode},#{entity.code},#{entity.internalinstructiontype},#{entity.bizchannel},#{entity.reforderid},#{entity.refordercode},#{entity.refordertype},#{entity.closed},#{entity.closedby},#{entity.status},#{entity.allowoverreceive},#{entity.shipfromattentionto},#{entity.shipfromaddress},#{entity.shipfromcountry},#{entity.shipfromstate},#{entity.shipfromcity},#{entity.shipfromdistrict},#{entity.shipfrompostalcode},#{entity.shipfrommobile},#{entity.shipfromemail},#{entity.totallines},#{entity.totalqty},#{entity.totalamount},#{entity.totalweight},#{entity.totalvolume},#{entity.totalvolumeweight},#{entity.totalfulfillamount},#{entity.totalfulfillweight},#{entity.totalfulfillvolume},#{entity.totalfulfillvolumeweight},#{entity.totalfulfillqty},#{entity.totalcases},#{entity.totalcontainers},#{entity.closeatqty},#{entity.quantityum},#{entity.weightum},#{entity.volumeum},#{entity.checkinfrom},#{entity.checkinto},#{entity.closedat},#{entity.sourceplatformcode},#{entity.sourceordercode},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby},#{entity.returnwaybillcode},#{entity.returncarrier},#{entity.refundedat},#{entity.refundstatus})
</foreach>
on duplicate key update

View File

@ -409,10 +409,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList);
}
}
if (allTocofsSaleoutDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
return null;
return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
/**
@ -523,10 +520,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList);
}
}
if (allTocofsSaleoutDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedTran(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
return null;
return filterDataRowsAsPushOrFailedTran(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
/**

View File

@ -408,10 +408,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList);
}
}
if (allTocofsSaleoutDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
return null;
return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
/**
@ -430,10 +427,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList);
}
}
if (allTocofsSaleoutDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedTran(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
return null;
return filterDataRowsAsPushOrFailedTran(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
}
/**

View File

@ -344,7 +344,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
queryOfsSoSaleOutVo.setClientCode("LETS");
queryOfsSoSaleOutVo.setPageNo(1L);
queryOfsSoSaleOutVo.setPageSize(50L);
queryOfsSoSaleOutVo.setStoreCode(tobShop);
//TODO 测试
// queryOfsSoSaleOutVo.setStoreCode(tobShop);
queryOfsSoSaleOutVo.setCode(code);
queryOfsSoSaleOutVo.setInternalInstructionType("RETURN");
ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
@ -415,10 +416,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
}
}
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
/**
@ -530,10 +528,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
}
}
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
/**

View File

@ -392,10 +392,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
}
}
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
/**
@ -414,10 +411,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
}
}
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedTran(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
return filterDataRowsAsPushOrFailedTran(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
/**

View File

@ -33,7 +33,10 @@ public class SoSaleReturnPluginInitializerToBTest {
//测试TOB退货
//测试TOB退货-确认收入
soSaleReturnPluginInitializerToB.startImplementByTradeTime("2024-08-30 15:54:41", "2024-08-30 15:54:43");
// soSaleReturnPluginInitializerToB.startImplementByTradeTime("2024-08-30 15:54:41", "2024-08-30 15:54:43");
soSaleReturnPluginInitializerToB.startImplementByCode("LETS-RE2024091400000001");
} catch (Exception e) {
e.printStackTrace();
}