diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml index e5e42fda0..b1a1c4ae5 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadMapper.xml @@ -320,6 +320,12 @@ and ldpl.is_transfer = 1 + + and ldpl.accept_warehouse_id in + + #{item} + + group by ldpl.order_code, ldpl.waybill_id, ldpl.waybill_number, diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 4bf796de8..92e3aae6c 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -81,6 +81,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; @@ -267,7 +268,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { map.put("total_volume",waybillEntity.getTotalVolume()); map.put("shipper",waybillEntity.getShipper()); map.put("shipperName",waybillEntity.getShipperName()); - map.put("shipperMobile",waybillEntity.getShipperName()); + map.put("shipperMobile",waybillEntity.getShipperMobile()); map.put("shipperAddress",waybillEntity.getShipperAddress()); map.put("consignee",waybillEntity.getConsignee()); map.put("consigneeName",waybillEntity.getConsigneeName()); @@ -842,12 +843,30 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setIsDeleted(0); warehouseWayBillDetail.setProductId(goodsId); warehouseWayBillDetail.setProductName(goodsName); - warehouseWayBillDetail.setNum(waybillDetailDTO.getNum()); - warehouseWayBillDetail.setVolume(waybillDetailDTO.getVolume()); - warehouseWayBillDetail.setWeight(waybillDetailDTO.getWeight()); - warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice()); - warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight()); - warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType()); + Integer num = waybillDetailDTO.getNum(); + BigDecimal volume = waybillDetailDTO.getVolume(); + BigDecimal weight = waybillDetailDTO.getWeight(); + warehouseWayBillDetail.setNum(num); + warehouseWayBillDetail.setVolume(volume); + warehouseWayBillDetail.setWeight(weight); + BigDecimal price = waybillDetailDTO.getPrice(); + Integer chargeType = waybillDetailDTO.getChargeType(); + BigDecimal subtotalFreight = waybillDetailDTO.getSubtotalFreight(); + if(price.compareTo(BigDecimal.ZERO) == 0){ + + if(chargeType.equals(1)){ + price = subtotalFreight.divide(new BigDecimal(num),6, RoundingMode.HALF_UP); + }else if(chargeType.equals(2)){ + price = subtotalFreight.divide(volume,6, RoundingMode.HALF_UP); + }else if(chargeType.equals(3)){ + price = subtotalFreight.divide(weight,6, RoundingMode.HALF_UP); + } + + } + + warehouseWayBillDetail.setPrice(price); + warehouseWayBillDetail.setSubtotalFreight(subtotalFreight); + warehouseWayBillDetail.setChargeType(chargeType); warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); warehouseWayBillDetail.setPickupPrice(waybillDetailDTO.getPickupPrice()); @@ -966,20 +985,38 @@ public class OpenOrderServiceImpl implements IOpenOrderService { //根据订单id获取每个订单的运单拼接数据 if (!stockArticleIds.isEmpty()) { - List stockArticleEntities = distributionStockArticleClient.findWaybillNoByOrderIds(stockArticleIds); + List newList = new ArrayList<>(stockArticleIds); + List stockArticleEntities = distributionStockArticleClient.findStockListByIds(newList); + +// List stockArticleEntities = distributionStockArticleClient.findWaybillNoByOrderIds(stockArticleIds); + List updateStockArticleList = new ArrayList<>(); stockArticleEntities.forEach(stockArticleEntity -> { - stockArticleEntity.setMallId(consigneeId1); - stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); - stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); - stockArticleEntity.setTypeService(basicdataClientEntity.getTypeService() + ""); - stockArticleEntity.setConsigneePerson(waybillEntity.getConsigneeName()); - stockArticleEntity.setConsigneeMobile(waybillEntity.getConsigneeMobile()); - stockArticleEntity.setConsigneeAddress(waybillEntity.getConsigneeAddress()); - stockArticleEntity.setConsigneeUnit(basicdataClientEntity.getClientName()); + String waybillNumber = stockArticleEntity.getWaybillNumber(); + DistributionStockArticleEntity updateEntity = new DistributionStockArticleEntity(); + updateEntity.setId(stockArticleEntity.getId()); + if(StringUtil.isBlank(waybillNumber)){ + updateEntity.setWaybillNumber(finalWaybillNo); + }else{ + if(!waybillNumber.contains(finalWaybillNo)){ + waybillNumber = waybillNumber + "," + finalWaybillNo; + updateEntity.setWaybillNumber(waybillNumber); + } + } + + updateEntity.setMallId(consigneeId1); + updateEntity.setMallCode(basicdataClientEntity.getClientCode()); + updateEntity.setMallName(basicdataClientEntity.getClientName()); + updateEntity.setTypeService(basicdataClientEntity.getTypeService() + ""); + updateEntity.setConsigneePerson(waybillEntity.getConsigneeName()); + updateEntity.setConsigneeMobile(waybillEntity.getConsigneeMobile()); + updateEntity.setConsigneeAddress(waybillEntity.getConsigneeAddress()); + updateEntity.setConsigneeUnit(basicdataClientEntity.getClientName()); + updateStockArticleList.add(updateEntity); + }); - if (CollUtil.isNotEmpty(stockArticleEntities)) { - distributionStockArticleClient.updateByBatchId(stockArticleEntities); + if (CollUtil.isNotEmpty(updateStockArticleList)) { + distributionStockArticleClient.updateByBatchId(updateStockArticleList); } } @@ -1211,12 +1248,29 @@ public class OpenOrderServiceImpl implements IOpenOrderService { } warehouseWayBillDetail.setProductId(goodsId); warehouseWayBillDetail.setProductName(goodsName); - warehouseWayBillDetail.setNum(waybillDetailDTO.getNum()); - warehouseWayBillDetail.setVolume(waybillDetailDTO.getVolume()); - warehouseWayBillDetail.setWeight(waybillDetailDTO.getWeight()); - warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice()); - warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight()); - warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType()); + Integer num = waybillDetailDTO.getNum(); + BigDecimal volume = waybillDetailDTO.getVolume(); + BigDecimal weight = waybillDetailDTO.getWeight(); + warehouseWayBillDetail.setNum(num); + warehouseWayBillDetail.setVolume(volume); + warehouseWayBillDetail.setWeight(weight); + BigDecimal price = waybillDetailDTO.getPrice(); + Integer chargeType = waybillDetailDTO.getChargeType(); + BigDecimal subtotalFreight = waybillDetailDTO.getSubtotalFreight(); + if(price.compareTo(BigDecimal.ZERO) == 0){ + + if(chargeType.equals(1)){ + price = subtotalFreight.divide(new BigDecimal(num),6, RoundingMode.HALF_UP); + }else if(chargeType.equals(2)){ + price = subtotalFreight.divide(volume,6, RoundingMode.HALF_UP); + }else if(chargeType.equals(3)){ + price = subtotalFreight.divide(weight,6, RoundingMode.HALF_UP); + } + + } + warehouseWayBillDetail.setPrice(price); + warehouseWayBillDetail.setSubtotalFreight(subtotalFreight); + warehouseWayBillDetail.setChargeType(chargeType); warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); warehouseWayBillDetail.setPickupPrice(waybillDetailDTO.getPickupPrice()); @@ -5697,12 +5751,29 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setProductId(goodsId); warehouseWayBillDetail.setProductName(waybillDetailDTO.getGoodsName()); - warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType()); - warehouseWayBillDetail.setNum(waybillDetailDTO.getNum()); - warehouseWayBillDetail.setVolume(waybillDetailDTO.getVolume()); - warehouseWayBillDetail.setWeight(waybillDetailDTO.getWeight()); - warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice()); - warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight()); + Integer num = waybillDetailDTO.getNum(); + BigDecimal volume = waybillDetailDTO.getVolume(); + BigDecimal weight = waybillDetailDTO.getWeight(); + warehouseWayBillDetail.setNum(num); + warehouseWayBillDetail.setVolume(volume); + warehouseWayBillDetail.setWeight(weight); + BigDecimal price = waybillDetailDTO.getPrice(); + Integer chargeType = waybillDetailDTO.getChargeType(); + BigDecimal subtotalFreight = waybillDetailDTO.getSubtotalFreight(); + if(price.compareTo(BigDecimal.ZERO) == 0){ + + if(chargeType.equals(1)){ + price = subtotalFreight.divide(new BigDecimal(num),6, RoundingMode.HALF_UP); + }else if(chargeType.equals(2)){ + price = subtotalFreight.divide(volume,6, RoundingMode.HALF_UP); + }else if(chargeType.equals(3)){ + price = subtotalFreight.divide(weight,6, RoundingMode.HALF_UP); + } + + } + + warehouseWayBillDetail.setPrice(price); + warehouseWayBillDetail.setSubtotalFreight(subtotalFreight); warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); warehouseWayBillDetail.setPickupPrice(waybillDetailDTO.getPickupPrice()); @@ -5757,12 +5828,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setWeight(newWeight); } - BigDecimal newPrice = waybillDetailDTO.getPrice(); - BigDecimal price = warehouseWayBillDetail.getPrice(); - if (price.compareTo(newPrice) != 0) { - stringBuilder.append("明细更新:").append(warehouseWayBillDetail.getProductName()).append(" 单价修改").append(price).append("-->").append(newPrice).append(";"); - warehouseWayBillDetail.setPrice(newPrice); - } + Integer newChargeType = waybillDetailDTO.getChargeType(); Integer chargeType = warehouseWayBillDetail.getChargeType(); @@ -5778,6 +5844,25 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setSubtotalFreight(newSubtotalFreight); } + BigDecimal newPrice = waybillDetailDTO.getPrice(); + if(newPrice.compareTo(BigDecimal.ZERO) == 0){ + + if(chargeType.equals(1)){ + newPrice = newSubtotalFreight.divide(new BigDecimal(newNum),6, RoundingMode.HALF_UP); + }else if(chargeType.equals(2)){ + newPrice = newSubtotalFreight.divide(newVolume,6, RoundingMode.HALF_UP); + }else if(chargeType.equals(3)){ + newPrice = newSubtotalFreight.divide(newWeight,6, RoundingMode.HALF_UP); + } + + } + + BigDecimal price = warehouseWayBillDetail.getPrice(); + if (price.compareTo(newPrice) != 0) { + stringBuilder.append("明细更新:").append(warehouseWayBillDetail.getProductName()).append(" 单价修改").append(price).append("-->").append(newPrice).append(";"); + warehouseWayBillDetail.setPrice(newPrice); + } + warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); warehouseWayBillDetail.setPickupPrice(waybillDetailDTO.getPickupPrice());