From b667a1264a2346939833ed85c13250ba330a88c7 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 19 Mar 2024 19:44:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BF-=E6=88=90=E6=9C=AC?= =?UTF-8?q?=E5=88=86=E6=91=8A=E8=AE=A1=E7=AE=97=202.=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8C=85=E4=BB=B6=E7=8A=B6=E6=80=81=E4=B8=BA=E5=9C=A8=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/DictBizConstant.java | 2 + .../TrunklineCostShareRecordEntity.java | 114 +++++++++++ .../entity/WarehouseWaybillEntity.java | 9 + .../jobhandle/SyncOrderInfoToPlatform.java | 22 ++ .../patch/service/ISyncOrderInfoService.java | 2 + .../impl/SyncOrderInfoServiceImpl.java | 14 ++ .../controller/CarsLoadController.java | 31 +++ .../mapper/TrunklineCarsLoadMapper.xml | 4 + .../mapper/TrunklineCarsLoadScanMapper.java | 3 + .../mapper/TrunklineCarsLoadScanMapper.xml | 10 + .../TrunklineCostShareRecordMapper.java | 23 +++ .../mapper/TrunklineCostShareRecordMapper.xml | 40 ++++ .../service/ICarsLoadAsyncService.java | 4 + .../ITrunklineCarsLoadScanService.java | 2 + .../service/ITrunklineCarsLoadService.java | 2 + .../ITrunklineCostShareRecordService.java | 18 ++ .../impl/CarsLoadAsyncServiceImpl.java | 192 +++++++++++++++++- .../TrunklineCarsLoadScanServiceImpl.java | 5 + .../impl/TrunklineCarsLoadServiceImpl.java | 43 ++++ .../TrunklineCostShareRecordServiceImpl.java | 41 ++++ 20 files changed, 572 insertions(+), 9 deletions(-) create mode 100644 blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCostShareRecordEntity.java create mode 100644 blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.java create mode 100644 blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.xml create mode 100644 blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCostShareRecordService.java create mode 100644 blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCostShareRecordServiceImpl.java diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/DictBizConstant.java b/blade-biz-common/src/main/java/org/springblade/common/constant/DictBizConstant.java index 15dfb257d..42defa89b 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/DictBizConstant.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/DictBizConstant.java @@ -141,4 +141,6 @@ public class DictBizConstant { // 运费计件单位 public static final String BASIC_FREIGHT_FORMULAMODE = "basic_freight_formulamode"; + public static final String TRUNKLINE_COST_PROPORTION = "trunkline_cost_proportion";//干线成本分摊比例值 + } diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCostShareRecordEntity.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCostShareRecordEntity.java new file mode 100644 index 000000000..a139b2c94 --- /dev/null +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/entity/TrunklineCostShareRecordEntity.java @@ -0,0 +1,114 @@ +package com.logpm.trunkline.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.math.BigDecimal; + +@Data +@TableName("logpm_trunkline_cost_share_record") +@ApiModel(value = "TrunklineCostShareRecord对象", description = "干线收入与成本分摊记录表") +@EqualsAndHashCode(callSuper = true) +public class TrunklineCostShareRecordEntity extends TenantEntity { + + /** 预留1 */ + @ApiModelProperty(name = "预留1",notes = "") + private String reserve1 ; + /** 预留2 */ + @ApiModelProperty(name = "预留2",notes = "") + private String reserve2 ; + /** 预留3 */ + @ApiModelProperty(name = "预留3",notes = "") + private String reserve3 ; + /** 预留4 */ + @ApiModelProperty(name = "预留4",notes = "") + private String reserve4 ; + /** 预留5 */ + @ApiModelProperty(name = "预留5",notes = "") + private String reserve5 ; + + /** 配载id */ + @ApiModelProperty(name = "配载id",notes = "") + private Long loadId; + /** 配载车次 */ + @ApiModelProperty(name = "配载车次",notes = "") + private String carsNo ; + /** 运单id */ + @ApiModelProperty(name = "运单id",notes = "") + private Long waybillId ; + /** 运单号 */ + @ApiModelProperty(name = "运单号",notes = "") + private String waybillNo ; + /** 订单id */ + @ApiModelProperty(name = "订单id",notes = "") + private Long orderId ; + /** 订单号 */ + @ApiModelProperty(name = "订单号",notes = "") + private String orderCode ; + + /** 货物类型1包件 2零担 */ + @ApiModelProperty(name = "货物类型1包件 2零担",notes = "") + private Integer productType ; + + /** 码值 */ + @ApiModelProperty(name = "码值",notes = "") + private String productCode; + /** 数量 */ + @ApiModelProperty(name = "数量",notes = "") + private Integer num ; + + + /** 装车仓库id */ + @ApiModelProperty(name = "装车仓库id",notes = "") + private Long loadingWarehouseId ; + /** 装车仓库名称 */ + @ApiModelProperty(name = "装车仓库名称",notes = "") + private String loadingWarehouseName ; + + /** 计划卸车仓库id */ + @ApiModelProperty(name = "计划卸车仓库id",notes = "") + private Long planUnloadWarehouseId ; + /** 计划卸车仓库名称 */ + @ApiModelProperty(name = "计划卸车仓库名称",notes = "") + private String planUnloadWarehouseName ; + + /** 计划卸车仓库id */ + @ApiModelProperty(name = "实际卸车仓库id",notes = "") + private Long realUnloadWarehouseId ; + /** 计划卸车仓库名称 */ + @ApiModelProperty(name = "实际卸车仓库名称",notes = "") + private String realUnloadWarehouseName ; + + /** 计划卸车仓库id */ + @ApiModelProperty(name = "运单起始仓库id",notes = "") + private Long waybillStartWarehouseId ; + /** 计划卸车仓库名称 */ + @ApiModelProperty(name = "运单起始仓库名称",notes = "") + private String waybillStartWarehouseName ; + + /** 计划卸车仓库id */ + @ApiModelProperty(name = "运单目的仓库id",notes = "") + private Long waybillEndWarehouseId ; + /** 计划卸车仓库名称 */ + @ApiModelProperty(name = "运单目的仓库名称",notes = "") + private String waybillEndWarehouseName ; + + /** 收入 */ + @ApiModelProperty(name = "收入",notes = "") + private BigDecimal income ; + /** 成本-件 */ + @ApiModelProperty(name = "成本-件",notes = "") + private BigDecimal costPiece ; + /** 成本-张 */ + @ApiModelProperty(name = "成本-张",notes = "") + private BigDecimal costZhang ; + + /** 比例 */ + @ApiModelProperty(name = "比例",notes = "") + private String proportion; + +} diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java index b73326184..c84a94390 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWaybillEntity.java @@ -429,4 +429,13 @@ public class WarehouseWaybillEntity extends TenantEntity { @ApiModelProperty(value = "审核人名称") private String checkUserName; + @ApiModelProperty(value = "按件成本") + private BigDecimal costPiece; + + @ApiModelProperty(value = "按张逻辑成本") + private BigDecimal costZhang; + + @ApiModelProperty(value = "成本件数") + private Integer costNum; + } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java index a425180b3..0e5e4e235 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java @@ -386,6 +386,28 @@ public class SyncOrderInfoToPlatform { } + @XxlJob("clearOrderPackageStatusStock") + public ReturnT clearOrderPackageStatusStock(String param) { + log.info("############clearOrderPackageStatusStock: 清理包件数据为在库 开始"); + + List ls = warehouseMappingDataService.findAllOrderPackage(); + + for (JSONObject l : ls) { + String orderPackageCode = l.getStr("orderPackageCode"); + Long warehouseId = l.getLong("warehouseId"); + + syncOrderInfoService.clearOrderPackageStatusStock(orderPackageCode,warehouseId); + + warehouseMappingDataService.updateClearOrderPackageStatusSignStatus(orderPackageCode,warehouseId,1); + } + + + + log.info("############repairNoOpenOrderOrderInfo: 清理包件数据为已签收 完成"); + + return ReturnT.SUCCESS; + } + @XxlJob("syncZeroOrderInfo") diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java index 316d486d0..179011cee 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java @@ -20,4 +20,6 @@ public interface ISyncOrderInfoService { void repairNoOpenOrderOrderInfo(String orderCode); void clearOrderPackageStatusSign(String orderPackageCode, Long warehouseId); + + void clearOrderPackageStatusStock(String orderPackageCode, Long warehouseId); } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java index 710849bfb..63d9d5e9b 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java @@ -317,6 +317,20 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { } } + @Override + public void clearOrderPackageStatusStock(String orderPackageCode, Long warehouseId) { + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); + if(!Objects.isNull(parcelListEntity)){ + String orderCode = parcelListEntity.getOrderCode(); + parcelListEntity.setOrderPackageStatus("20"); + parcelListEntity.setOrderPackageGroundingStatus("10"); + + distributionParcelListClient.update(parcelListEntity); + distributionStockArticleClient.updateOrderInfo(orderCode,warehouseId); + warehouseUpdownTypeClient.downPackageOrDelTray(orderPackageCode,warehouseId); + } + } + @Transactional(rollbackFor = Exception.class) @Override diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java index 62fa1e18f..ac87468bb 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java @@ -2143,4 +2143,35 @@ public class CarsLoadController { } + @ResponseBody + @PostMapping("/costShareByLoadId") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "成本分摊", notes = "传入loadCarsDTO") + public R costShareByLoadId(@RequestBody LoadCarsDTO loadCarsDTO) { + String method = "############costShareByLoadId: "; + log.info(method + "请求参数{}", loadCarsDTO); + Long loadId = loadCarsDTO.getLoadId(); + try{ + + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(405,"仓库信息为空"); + } + loadCarsDTO.setWarehouseId(myCurrentWarehouse.getId()); + if(Objects.isNull(loadId)){ + log.warn(method+"配载id为空 loadId={}",loadId); + return R.fail(405,"配载id为空"); + } + + return carsLoadService.costShareByLoadId(loadId); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } } 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 e06799bf1..36537c10e 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 @@ -9,6 +9,7 @@ ltcl.plan_loading_number planLoadingNumber, ltcl.real_loading_number realLoadingNumber, ltcl.unload_number unloadNumber, + ltcl.loading_type loadingType, ltcl.full_load_rate fullLoadRate, ltcl.is_customer isCustomer, ltcl.load_status loadStatus, @@ -47,6 +48,7 @@ ltcl.plan_loading_number, ltcl.real_loading_number, ltcl.unload_number, + ltcl.loading_type, ltcl.full_load_rate, ltcl.is_customer, ltcl.load_status, @@ -71,6 +73,7 @@ ltcl.full_load_rate fullLoadRate, ltcl.is_customer isCustomer, ltcl.load_status loadStatus, + ltcl.loading_type loadingType, ltcl.driver_name driverName, ltcl.driver_mobile driverMobile, ltcl.car_number carNumber, @@ -108,6 +111,7 @@ ltcl.full_load_rate, ltcl.is_customer, ltcl.load_status, + ltcl.loading_type, ltcl.driver_name, ltcl.driver_mobile, ltcl.car_number, diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java index 56b5439ee..a4aea78bc 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java @@ -96,4 +96,7 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper findUnloadLoadScanWaybillList(@Param("loadId") Long loadId, @Param("nodeId") Long nodeId); List findListNoDataByLoadId(@Param("loadId") Long loadId); + + List findListByLoadIdOrderByCreateTimeAsc(@Param("loadId") Long loadId); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml index 7fc2c6123..36f4f4aa2 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml @@ -453,4 +453,14 @@ and is_data = 0 + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.java new file mode 100644 index 000000000..26995bda2 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.java @@ -0,0 +1,23 @@ +package com.logpm.trunkline.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.trunkline.entity.TrunklineCostShareRecordEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface TrunklineCostShareRecordMapper extends BaseMapper { + + + TrunklineCostShareRecordEntity findPackageDataByLoadIdAndCode(@Param("scanCode") String scanCode, @Param("loadId") Long loadId); + + Integer findTotalUnloadNumByLoad(@Param("loadId") Long loadId); + + List findListByLoadId(@Param("loadId") Long loadId); + + List findUpdateWaybill(@Param("loadId") Long loadId); + + TrunklineCostShareRecordEntity sumTotalCost(@Param("waybillNo") String waybillNo); +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.xml new file mode 100644 index 000000000..b1232da92 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java index 693834ece..ebfdde9ae 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ICarsLoadAsyncService.java @@ -7,4 +7,8 @@ public interface ICarsLoadAsyncService { void saveLog(TrunklineCarsLoadEntity carsLoadEntity, TrunklineCarsLoadLineEntity carsLoadLineEntity, int cardLoadType,String nickName,Long userId); + void saveCostShareRecord(Long loadId,TrunklineCarsLoadEntity carsLoadEntity); + + void costShareByLoadId(Long loadId,TrunklineCarsLoadEntity carsLoadEntity); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java index 6fb84ab3c..edb0d4943 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java @@ -92,4 +92,6 @@ public interface ITrunklineCarsLoadScanService extends BaseService findListNoDataByLoadId(Long loadId); + List findListByLoadIdOrderByCreateTimeAsc(Long loadId); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java index 849ef7336..300e5bdba 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java @@ -184,4 +184,6 @@ public interface ITrunklineCarsLoadService extends BaseService { + TrunklineCostShareRecordEntity findPackageDataByLoadIdAndCode(String scanCode, Long loadId); + + Integer findTotalUnloadNumByLoad(Long loadId); + + List findListByLoadId(Long loadId); + + List findUpdateWaybill(Long loadId); + + TrunklineCostShareRecordEntity sumTotalCost(String waybillNo); +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java index 03711985e..d4f9334a3 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/CarsLoadAsyncServiceImpl.java @@ -1,28 +1,46 @@ package com.logpm.trunkline.service.impl; -import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; -import com.logpm.trunkline.entity.TrunklineCarsLoadLineEntity; -import com.logpm.trunkline.entity.TrunklineCarsLoadLogEntity; -import com.logpm.trunkline.service.ICarsLoadAsyncService; -import com.logpm.trunkline.service.ITrunklineCarsLoadLogService; -import lombok.AllArgsConstructor; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.feign.IDistributionStockArticleClient; +import com.logpm.trunkline.entity.*; +import com.logpm.trunkline.service.*; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; +import com.logpm.warehouse.feign.IWarehouseWaybillClient; import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.DictBizConstant; import org.springblade.common.constant.TenantNum; import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant; +import org.springblade.common.exception.CustomerException; import org.springblade.common.utils.CommonUtil; -import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.system.cache.DictBizCache; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Date; +import java.util.List; import java.util.Objects; @Slf4j -@AllArgsConstructor @Service public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { - private final ITrunklineCarsLoadLogService trunklineCarsLoadLogService; + @Autowired + private ITrunklineCarsLoadLogService trunklineCarsLoadLogService; + @Autowired + private ITrunklineCarsLoadScanService trunklineCarsLoadScanService; + @Autowired + private IWarehouseWaybillClient warehouseWaybillClient; + @Autowired + private ITrunklineCostShareRecordService trunklineCostShareRecordService; + @Autowired + private IDistributionStockArticleClient distributionStockArticleClient; + @Autowired + private IBasicdataWarehouseClient warehouseClient; @Async @Override @@ -134,4 +152,160 @@ public class CarsLoadAsyncServiceImpl implements ICarsLoadAsyncService { trunklineCarsLoadLogService.save(carsLoadLogEntity); } + @Async + @Override + public void saveCostShareRecord(Long loadId,TrunklineCarsLoadEntity carsLoadEntity) { + + List scanEntities = trunklineCarsLoadScanService.findListByLoadIdOrderByCreateTimeAsc(loadId); + + for (TrunklineCarsLoadScanEntity scanEntity : scanEntities) { + Integer type = scanEntity.getType(); + String waybillNo = scanEntity.getWaybillNo(); + String orderCode = scanEntity.getOrderCode(); + String scanCode = scanEntity.getScanCode(); + Integer num = scanEntity.getUnloadNum(); + Long fromWarehouseId = scanEntity.getFromWarehouseId(); + Long warehouseId = scanEntity.getWarehouseId(); + String warehouseName = scanEntity.getWarehouseName(); + Long finalNodeId = scanEntity.getFinalNodeId(); + Long unloadNodeId = scanEntity.getUnloadNodeId(); + String unloadNodeName = scanEntity.getUnloadNodeName(); + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, fromWarehouseId); + + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if(Objects.isNull(waybillEntity)){ + log.warn("##############saveCostShareRecord: 运单信息不存在 waybillNo={}",waybillNo); + continue; + } + Long waybillId = waybillEntity.getId(); + Long departureWarehouseId = waybillEntity.getDepartureWarehouseId(); + String departureWarehouseName = waybillEntity.getDepartureWarehouseName(); + Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); + String destinationWarehouseName = waybillEntity.getDestinationWarehouseName(); + + + TrunklineCostShareRecordEntity trunklineCostShareRecordEntity = null; + if(type.equals(1)){ + trunklineCostShareRecordEntity = trunklineCostShareRecordService.findPackageDataByLoadIdAndCode(scanCode,loadId); + } + + if(Objects.isNull(trunklineCostShareRecordEntity)){ + trunklineCostShareRecordEntity = new TrunklineCostShareRecordEntity(); + trunklineCostShareRecordEntity.setLoadId(loadId); + trunklineCostShareRecordEntity.setCarsNo(carsLoadEntity.getCarsNo()); + trunklineCostShareRecordEntity.setWaybillId(waybillId); + trunklineCostShareRecordEntity.setWaybillNo(waybillNo); + if(!Objects.isNull(stockArticleEntity)){ + trunklineCostShareRecordEntity.setOrderId(stockArticleEntity.getId()); + } + trunklineCostShareRecordEntity.setOrderCode(orderCode); + trunklineCostShareRecordEntity.setProductType(type); + trunklineCostShareRecordEntity.setProductCode(scanCode); + trunklineCostShareRecordEntity.setNum(num); + trunklineCostShareRecordEntity.setLoadingWarehouseId(warehouseId); + trunklineCostShareRecordEntity.setLoadingWarehouseName(warehouseName); + trunklineCostShareRecordEntity.setPlanUnloadWarehouseId(finalNodeId); + BasicdataWarehouseEntity finalWarehouse = warehouseClient.getEntityWarehouseId(finalNodeId); + if(!Objects.isNull(finalWarehouse)){ + trunklineCostShareRecordEntity.setPlanUnloadWarehouseName(finalWarehouse.getName()); + } + trunklineCostShareRecordEntity.setRealUnloadWarehouseId(unloadNodeId); + trunklineCostShareRecordEntity.setRealUnloadWarehouseName(unloadNodeName); + trunklineCostShareRecordEntity.setWaybillStartWarehouseId(departureWarehouseId); + trunklineCostShareRecordEntity.setWaybillStartWarehouseName(departureWarehouseName); + trunklineCostShareRecordEntity.setWaybillEndWarehouseId(destinationWarehouseId); + trunklineCostShareRecordEntity.setWaybillEndWarehouseName(destinationWarehouseName); + trunklineCostShareRecordService.save(trunklineCostShareRecordEntity); + + }else{ + trunklineCostShareRecordEntity.setRealUnloadWarehouseId(scanEntity.getUnloadNodeId()); + trunklineCostShareRecordEntity.setRealUnloadWarehouseName(scanEntity.getUnloadNodeName()); + trunklineCostShareRecordService.updateById(trunklineCostShareRecordEntity); + } + + } + + } + + @Async + @Override + public void costShareByLoadId(Long loadId,TrunklineCarsLoadEntity carsLoadEntity) { + + String proportion1 = DictBizCache.getValue(DictBizConstant.TRUNKLINE_COST_PROPORTION, "1"); + String proportion2 = DictBizCache.getValue(DictBizConstant.TRUNKLINE_COST_PROPORTION, "2"); + if(new BigDecimal(proportion1).add(new BigDecimal(proportion2)).compareTo(BigDecimal.ONE) != 0){ + log.warn("###############costShareZhang: 配置比例有误"); + throw new CustomerException(405,"配置比例有误"); + } + + BigDecimal countTransportCost = carsLoadEntity.getCountTransportCost(); + Integer totalUnloadNum = trunklineCostShareRecordService.findTotalUnloadNumByLoad(loadId); + + //计算单件成本 + BigDecimal costPiece = countTransportCost.divide(new BigDecimal(totalUnloadNum),2, RoundingMode.HALF_UP); + + //先查询出该车次的所有记录 + List list = trunklineCostShareRecordService.findListByLoadId(loadId); + + BigDecimal totalIncome = BigDecimal.ZERO; + for (TrunklineCostShareRecordEntity trunklineCostShareRecordEntity : list) { + Integer num = trunklineCostShareRecordEntity.getNum(); + trunklineCostShareRecordEntity.setCostPiece(costPiece.multiply(new BigDecimal(num))); + + Long waybillStartWarehouseId = trunklineCostShareRecordEntity.getWaybillStartWarehouseId(); + Long waybillEndWarehouseId = trunklineCostShareRecordEntity.getWaybillEndWarehouseId(); + Long loadingWarehouseId = trunklineCostShareRecordEntity.getLoadingWarehouseId(); + Long realUnloadWarehouseId = trunklineCostShareRecordEntity.getRealUnloadWarehouseId(); + + //收入 + String waybillNo = trunklineCostShareRecordEntity.getWaybillNo(); + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + if(!Objects.isNull(waybillEntity)){ + BigDecimal totalFreight = waybillEntity.getTotalFreight();//运单运费 + if(waybillStartWarehouseId.equals(loadingWarehouseId)){ + //装车仓库 就是 运单起始仓 + if(realUnloadWarehouseId.equals(waybillEndWarehouseId)){ + //卸车仓库 就是 运单目的仓 + totalFreight = totalFreight.multiply(BigDecimal.ONE);//运费收入就是100% + }else{ + //卸车仓库 不是 运单目的仓 + totalFreight = totalFreight.multiply(new BigDecimal(proportion1));//运费收入就是80% + } + }else{ + totalFreight = totalFreight.multiply(new BigDecimal(proportion2));//运费收入就是20% + } + + Integer totalCount = waybillEntity.getTotalCount();//总件数 + BigDecimal xincome = totalFreight.divide(new BigDecimal(totalCount),2, RoundingMode.HALF_DOWN); + BigDecimal income = xincome.multiply(new BigDecimal(num)); + trunklineCostShareRecordEntity.setIncome(income); + totalIncome = totalIncome.add(income); + + trunklineCostShareRecordEntity.setProportion(proportion1+":"+proportion2); + + } + } + + + for (TrunklineCostShareRecordEntity trunklineCostShareRecordEntity : list) { + BigDecimal income = trunklineCostShareRecordEntity.getIncome(); + trunklineCostShareRecordEntity.setCostZhang(countTransportCost.multiply(income.divide(totalIncome))); + } + + trunklineCostShareRecordService.updateBatchById(list); + + //更新需要更新成本的运单 + List waybillNos = trunklineCostShareRecordService.findUpdateWaybill(loadId); + for (String waybillNo : waybillNos) { + WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + //统计成本值 + TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.sumTotalCost(waybillNo); + warehouseWaybillEntity.setCostPiece(costShareRecordEntity.getCostPiece()); + warehouseWaybillEntity.setCostZhang(costShareRecordEntity.getCostZhang()); + warehouseWaybillEntity.setCostNum(costShareRecordEntity.getNum()); + warehouseWaybillClient.updateEntity(warehouseWaybillEntity); + } + + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java index de0db9a10..489a25de3 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java @@ -222,4 +222,9 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl findListByLoadIdOrderByCreateTimeAsc(Long loadId) { + return baseMapper.findListByLoadIdOrderByCreateTimeAsc(loadId); + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 43759dfc0..30a604911 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -774,6 +774,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl noDataList = trunklineCarsLoadScanService.findListNoDataByLoadId(loadId); + int size = noDataList.size(); + if(size != 0){ + log.warn("#################costShareByLoadId: 配载计划存在未有数据来源的包件 loadId={}",loadId); + return R.fail(405,"配载计划存在未有数据来源的包件,请先处理"); + } + + TrunklineCarsLoadLineEntity endLoadLineEntity = trunklineCarsLoadLineService.findEndNodeByLoadId(loadId); + if(Objects.isNull(endLoadLineEntity)){ + log.warn("#################costShareByLoadId: 配载计划最终节点信息不存在 loadId={}",loadId); + return R.fail(405,"配载计划最终节点信息不存在"); + } + String unloadStatus = endLoadLineEntity.getUnloadStatus(); + if(!unloadStatus.equals("2")){ + log.warn("#################costShareByLoadId: 配载计划最终节点还未卸车确认 loadId={}",loadId); + return R.fail(405,"配载计划最终节点还未卸车确认"); + } + + carsLoadAsyncService.costShareByLoadId(loadId,carsLoadEntity); + + carsLoadEntity.setCostAllocationType("1"); + carsLoadEntity.setCostAllocationAdminId(AuthUtil.getUserId()); + carsLoadEntity.setCostAllocationAdmin(AuthUtil.getNickName()); + updateById(carsLoadEntity); + + return R.success("成本计算开始,几分钟后请刷新页面查看"); + } + @Override public R loadingTrayInfo(LoadCarsDTO loadCarsDTO) { log.info("##############loadingTrayInfo: 查询托盘的货物信息"); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCostShareRecordServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCostShareRecordServiceImpl.java new file mode 100644 index 000000000..c5037764a --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCostShareRecordServiceImpl.java @@ -0,0 +1,41 @@ +package com.logpm.trunkline.service.impl; + +import com.logpm.trunkline.entity.TrunklineCostShareRecordEntity; +import com.logpm.trunkline.mapper.TrunklineCostShareRecordMapper; +import com.logpm.trunkline.service.ITrunklineCostShareRecordService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Slf4j +@Service +@AllArgsConstructor +public class TrunklineCostShareRecordServiceImpl extends BaseServiceImpl implements ITrunklineCostShareRecordService { + @Override + public TrunklineCostShareRecordEntity findPackageDataByLoadIdAndCode(String scanCode, Long loadId) { + return baseMapper.findPackageDataByLoadIdAndCode(scanCode,loadId); + } + + @Override + public Integer findTotalUnloadNumByLoad(Long loadId) { + return baseMapper.findTotalUnloadNumByLoad(loadId); + } + + @Override + public List findListByLoadId(Long loadId) { + return baseMapper.findListByLoadId(loadId); + } + + @Override + public List findUpdateWaybill(Long loadId) { + return baseMapper.findUpdateWaybill(loadId); + } + + @Override + public TrunklineCostShareRecordEntity sumTotalCost(String waybillNo) { + return baseMapper.sumTotalCost(waybillNo); + } +}