|
|
@@ -62,7 +62,6 @@ import com.sckw.transport.model.vo.execlVo.AcceptCarriageOrderExcelVo;
|
|
|
import com.sckw.transport.repository.*;
|
|
|
import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import jakarta.annotation.Resource;
|
|
|
-import jakarta.validation.constraints.NotNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
@@ -3186,6 +3185,7 @@ public class KwtAcceptCarriageOrderService {
|
|
|
commonService.getRedisGenerateOrderNo();
|
|
|
/**生成订单编号*/
|
|
|
String lOrderNo = OrderGenerateSeqNoUtils.getSeqNo(RedisOrderGenerateEnum.LOGISTICS_ORDER, OrderRuleEnum.LOGISTICS_ORDER, "2", "0", "0");
|
|
|
+ log.info("生成物流订单编号:{}", lOrderNo);
|
|
|
/**保存新建数据*/
|
|
|
|
|
|
List<LogisticData> logisticInfo = orderDTO.getLogisticInfo();
|
|
|
@@ -3226,11 +3226,62 @@ public class KwtAcceptCarriageOrderService {
|
|
|
setLogisticUnitInfo(orderDTO, x, lOrderId, savelogOrderUnitList);
|
|
|
|
|
|
});
|
|
|
- logisticsOrderRepository.saveBatch(saveLogisticsOrderList);
|
|
|
- logisticsOrderAddressRepository.saveBatch(saveAddressList);
|
|
|
- logisticsOrderGoodsRepository.saveBatch(savelogOrderGoodsList);
|
|
|
- logisticsOrderContractRepository.saveBatch(saveContractList);
|
|
|
- logisticsOrderUnitRepository.saveBatch(savelogOrderUnitList);
|
|
|
+
|
|
|
+ // 批量保存并检查结果
|
|
|
+ saveBatch(saveLogisticsOrderList, saveAddressList, savelogOrderGoodsList, saveContractList, savelogOrderUnitList, lOrderNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveBatch(List<KwtLogisticsOrder> saveLogisticsOrderList, List<KwtLogisticsOrderAddress> saveAddressList, List<KwtLogisticsOrderGoods> savelogOrderGoodsList, List<KwtLogisticsOrderContract> saveContractList, List<KwtLogisticsOrderUnit> savelogOrderUnitList, String lOrderNo) {
|
|
|
+ log.info("开始批量保存物流订单数据,订单数量:{},地址数量:{},商品数量:{},合同数量:{},单位数量:{}",
|
|
|
+ saveLogisticsOrderList.size(), saveAddressList.size(), savelogOrderGoodsList.size(),
|
|
|
+ saveContractList.size(), savelogOrderUnitList.size());
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (!saveLogisticsOrderList.isEmpty()) {
|
|
|
+ boolean result1 = logisticsOrderRepository.saveBatch(saveLogisticsOrderList);
|
|
|
+ log.info("物流订单保存结果:{}", result1);
|
|
|
+ if (!result1) {
|
|
|
+ throw new BusinessException("物流订单保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!saveAddressList.isEmpty()) {
|
|
|
+ boolean result2 = logisticsOrderAddressRepository.saveBatch(saveAddressList);
|
|
|
+ log.info("物流订单地址保存结果:{}", result2);
|
|
|
+ if (!result2) {
|
|
|
+ throw new BusinessException("物流订单地址保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!savelogOrderGoodsList.isEmpty()) {
|
|
|
+ boolean result3 = logisticsOrderGoodsRepository.saveBatch(savelogOrderGoodsList);
|
|
|
+ log.info("物流订单商品保存结果:{}", result3);
|
|
|
+ if (!result3) {
|
|
|
+ throw new BusinessException("物流订单商品保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!saveContractList.isEmpty()) {
|
|
|
+ boolean result4 = logisticsOrderContractRepository.saveBatch(saveContractList);
|
|
|
+ log.info("物流订单合同保存结果:{}", result4);
|
|
|
+ if (!result4) {
|
|
|
+ throw new BusinessException("物流订单合同保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!savelogOrderUnitList.isEmpty()) {
|
|
|
+ boolean result5 = logisticsOrderUnitRepository.saveBatch(savelogOrderUnitList);
|
|
|
+ log.info("物流订单单位保存结果:{}", result5);
|
|
|
+ if (!result5) {
|
|
|
+ throw new BusinessException("物流订单单位保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("物流订单批量保存成功,订单编号:{}", lOrderNo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("物流订单批量保存失败,订单编号:{},错误信息:{}", lOrderNo, e.getMessage(), e);
|
|
|
+ throw new BusinessException("物流订单保存失败:" + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void setLogisticUnitInfo(AddLogisticOrderDTO orderDTO, LogisticData x, Long lOrderId, List<KwtLogisticsOrderUnit> savelogOrderUnitList) {
|