diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/QuestDetailEntity.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/QuestDetailEntity.java index 6d40df814..f76dd69e3 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/QuestDetailEntity.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/QuestDetailEntity.java @@ -148,11 +148,16 @@ public class QuestDetailEntity extends TenantEntity { @ApiModelProperty(value = "货位id") private Long allocationId; - /** * 是否是新增数据 */ @ApiModelProperty(value = "是否是新增数据") private Integer isNew; + /** + * 货位 + */ + @ApiModelProperty(value = "上架后的完整库位") + private String groundingPositionCode; + } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskStripApiVO.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskStripApiVO.java index bef00cb5f..8dcc00103 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskStripApiVO.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskStripApiVO.java @@ -31,6 +31,12 @@ import lombok.Data; public class TaskStripApiVO { private static final long serialVersionUID = 1L; + /** + * 明细详情id + */ + @ApiModelProperty(value = "明细详情id") + private Long questDetailId; + /** * 包条id */ @@ -61,5 +67,22 @@ public class TaskStripApiVO { @ApiModelProperty(value = "状态") private String state; + /** + * 货物类型 1订制品 2零担 3库存品 + */ + private Integer goodsType; + + /** + * 数量 + */ + private Integer num; + + + private String materialCode; + private String materialName; + + private String waybillNo; + + private Integer isNew; } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseTaskApiController.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseTaskApiController.java index 40fb187db..90e3f4068 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseTaskApiController.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseTaskApiController.java @@ -3,21 +3,26 @@ package com.logpm.warehouse.api; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.warehouse.dto.QuestDetailDTO; import com.logpm.warehouse.dto.TaskSearchDTO; +import com.logpm.warehouse.entity.QuestDetailEntity; import com.logpm.warehouse.service.ITaskQuestService; -import com.logpm.warehouse.vo.*; -import com.logpm.warehouse.wrapper.TaskQuestVOWrapper; +import com.logpm.warehouse.vo.TaskContractVO; +import com.logpm.warehouse.vo.TaskQuestApiVO; +import com.logpm.warehouse.vo.TaskallocationVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; +import org.springblade.common.exception.CustomerException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; -import java.util.List; -import java.util.Optional; +import java.util.*; @Log4j2 @@ -28,6 +33,7 @@ import java.util.Optional; public class WarehouseTaskApiController { private final ITaskQuestService taskQuestService; + private final IBasicdataWarehouseClient warehouseClient; /** * 盘点任务列表 @@ -87,11 +93,286 @@ public class WarehouseTaskApiController { /** * 库位明细(定制品) */ - @GetMapping("/allocationDetailByStrip") + @GetMapping("/allocationDetailByPackage") @ApiOperationSupport(order = 1) @ApiOperation(value = "库位明细(定制品)", notes = "code,type") - public R> allocationDetailByStrip(TaskSearchDTO taskSearchDTO, Query query) { - IPage taskStripApiVOList = taskQuestService.selectallocationDetailByStrip(Condition.getPage(query), taskSearchDTO); - return R.data(taskStripApiVOList); + public R allocationDetailByPackage(TaskSearchDTO taskSearchDTO) { + String method = "###########allocationDetailByPackage: "; + log.info(method+"库位明细(定制品) 参数:{}",taskSearchDTO); + Long questId = taskSearchDTO.getQuestId();//任务id + Long allocationId = taskSearchDTO.getAllocationId();//库位id + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + taskSearchDTO.setWarehouseId(myCurrentWarehouse.getId()); + + if(Objects.isNull(questId)){ + log.warn(method+"任务id为空 questId={}",questId); + return R.fail(403,"任务id为空"); + } + + if(Objects.isNull(allocationId)){ + log.warn(method+"库位id为空 allocationId={}",allocationId); + return R.fail(403,"库位id为空"); + } + + List list = taskQuestService.allocationDetailByPackage(taskSearchDTO); + String allocationCode = ""; + Integer allNUm = 0; + Integer finishNUm = 0; + for (QuestDetailEntity entity:list){ + Integer stockNum = entity.getStockNum(); + Integer questStatus = entity.getQuestStatus(); + String positionCode = entity.getPositionCode(); + allNUm = allNUm + stockNum; + allocationCode = positionCode; + if(questStatus == 1){ + finishNUm = finishNUm + stockNum; + } + } + + Map map = new HashMap<>(); + map.put("allocationCode",allocationCode); + map.put("allNUm",allNUm); + map.put("finishNUm",finishNUm); + map.put("list",list); + return R.data(map); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + + /** + * 库位明细(零担) + */ + @GetMapping("/allocationDetailByZero") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "库位明细(零担)", notes = "code,type") + public R allocationDetailByZero(TaskSearchDTO taskSearchDTO) { + String method = "###########allocationDetailByZero: "; + log.info(method+"库位明细(零担) 参数:{}",taskSearchDTO); + Long questId = taskSearchDTO.getQuestId();//任务id + Long allocationId = taskSearchDTO.getAllocationId();//库位id + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + taskSearchDTO.setWarehouseId(myCurrentWarehouse.getId()); + + if(Objects.isNull(questId)){ + log.warn(method+"任务id为空 questId={}",questId); + return R.fail(403,"任务id为空"); + } + + if(Objects.isNull(allocationId)){ + log.warn(method+"库位id为空 allocationId={}",allocationId); + return R.fail(403,"库位id为空"); + } + + List list = taskQuestService.allocationDetailByZero(taskSearchDTO); + String allocationCode = ""; + Integer allNUm = 0; + Integer finishNUm = 0; + for (QuestDetailEntity entity:list){ + Integer stockNum = entity.getStockNum(); + Integer questStatus = entity.getQuestStatus(); + String positionCode = entity.getPositionCode(); + allNUm = allNUm + stockNum; + allocationCode = positionCode; + if(questStatus == 1){ + finishNUm = finishNUm + stockNum; + } + } + + Map map = new HashMap<>(); + map.put("allocationCode",allocationCode); + map.put("allNUm",allNUm); + map.put("finishNUm",finishNUm); + map.put("list",list); + return R.data(map); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + /** + * 库位明细(库存品) + */ + @GetMapping("/allocationDetailByStock") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "库位明细(库存品)", notes = "code,type") + public R allocationDetailByStock(TaskSearchDTO taskSearchDTO) { + String method = "###########allocationDetailByStock: "; + log.info(method+"库位明细(库存品) 参数:{}",taskSearchDTO); + Long questId = taskSearchDTO.getQuestId();//任务id + Long allocationId = taskSearchDTO.getAllocationId();//库位id + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + taskSearchDTO.setWarehouseId(myCurrentWarehouse.getId()); + + if(Objects.isNull(questId)){ + log.warn(method+"任务id为空 questId={}",questId); + return R.fail(403,"任务id为空"); + } + + if(Objects.isNull(allocationId)){ + log.warn(method+"库位id为空 allocationId={}",allocationId); + return R.fail(403,"库位id为空"); + } + + List list = taskQuestService.allocationDetailByStock(taskSearchDTO); + String allocationCode = ""; + Integer allNUm = 0; + Integer finishNUm = 0; + for (QuestDetailEntity entity:list){ + Integer stockNum = entity.getStockNum(); + Integer questStatus = entity.getQuestStatus(); + String positionCode = entity.getPositionCode(); + allNUm = allNUm + stockNum; + allocationCode = positionCode; + if(questStatus == 1){ + finishNUm = finishNUm + stockNum; + } + } + + Map map = new HashMap<>(); + map.put("allocationCode",allocationCode); + map.put("allNUm",allNUm); + map.put("finishNUm",finishNUm); + map.put("list",list); + return R.data(map); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + @PostMapping("/updateQuestDetail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "更新盘点数据(处理)", notes = "code,type") + public R updateQuestDetail(@RequestBody TaskSearchDTO taskSearchDTO) { + String method = "###########updateQuestDetail: "; + log.info(method+"更新盘点数据(处理) 参数:{}",taskSearchDTO); + List questDetailList = taskSearchDTO.getQuestDetailList(); + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + taskSearchDTO.setWarehouseId(myCurrentWarehouse.getId()); + + int size = questDetailList.size(); + if(size == 0){ + log.warn(method+"请选择正确的数量 questDetailList={}",questDetailList); + return R.fail(403,"请选择正确的数量"); + } + + taskQuestService.updateQuestSetail(taskSearchDTO); + return R.success("更新成功"); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + + @PostMapping("/updateQuestDetailAllocation") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "更新盘点数据(库位)", notes = "code,type") + public R updateQuestDetailAllocation(@RequestBody TaskSearchDTO taskSearchDTO) { + String method = "###########updateQuestDetailAllocation: "; + log.info(method+"更新盘点数据(库位) 参数:{}",taskSearchDTO); + List questDetailList = taskSearchDTO.getQuestDetailList(); + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + taskSearchDTO.setWarehouseId(myCurrentWarehouse.getId()); + + int size = questDetailList.size(); + if(size == 0){ + log.warn(method+"请选择正确的数量 questDetailList={}",questDetailList); + return R.fail(403,"请选择正确的数量"); + } + + taskQuestService.updateQuestDetailAllocation(taskSearchDTO); + return R.success("更新成功"); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } } + + + @PostMapping("/deleteQuestDetail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "排除盘点数据", notes = "code,type") + public R deleteQuestDetail(@RequestBody TaskSearchDTO taskSearchDTO) { + String method = "###########deleteQuestDetail: "; + log.info(method+"更新盘点数据 参数:{}",taskSearchDTO); + List questDetailList = taskSearchDTO.getQuestDetailList(); + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + taskSearchDTO.setWarehouseId(myCurrentWarehouse.getId()); + + int size = questDetailList.size(); + if(size == 0){ + log.warn(method+"请选择正确的数量 questDetailList={}",questDetailList); + return R.fail(403,"请选择正确的数量"); + } + + taskQuestService.deleteQuestDetail(taskSearchDTO); + return R.success("更新成功"); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } + + + + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/QuestDetailDTO.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/QuestDetailDTO.java index bf51a8773..aa05b1f5a 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/QuestDetailDTO.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/QuestDetailDTO.java @@ -31,4 +31,20 @@ import lombok.EqualsAndHashCode; public class QuestDetailDTO extends QuestDetailEntity { private static final long serialVersionUID = 1L; + + private Integer stockNum;//在库数量 + + private Integer lossNum;//丢失数量 + + private Integer deliveNum;//配送数量 + + private Integer wornNum;//破损数量 + + private Integer noRepairNum;//不可修复数量 + + private Integer noReceivedNum;//未入库数量 + + private Long allocationId;//上架后的库位id + + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/TaskSearchDTO.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/TaskSearchDTO.java index efde5890f..0a8363d46 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/TaskSearchDTO.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/TaskSearchDTO.java @@ -20,6 +20,9 @@ package com.logpm.warehouse.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.ArrayList; +import java.util.List; + /** * 盘点任务 搜索 @@ -31,8 +34,13 @@ import lombok.Data; public class TaskSearchDTO { private static final long serialVersionUID = 1L; /** - * 搜索code + * 库位id */ + @ApiModelProperty(value = "库位id") + private Long allocationId; + + @ApiModelProperty(value = "任务id") + private Long questId; @ApiModelProperty(value = "搜索code") private String trayCode; @@ -47,4 +55,18 @@ public class TaskSearchDTO { */ @ApiModelProperty(value = "盘点任务Id") private Long taskId; + + /** + * 商场名称 + */ + private List marketNames; + + /** + * 当前仓库id + */ + private Long warehouseId; + + private List questDetailList = new ArrayList<>(); + + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java index 3b22af7cb..7438467b4 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java @@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.warehouse.dto.TaskSearchDTO; +import com.logpm.warehouse.entity.QuestDetailEntity; import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity; import com.logpm.warehouse.excel.WarehouseUpdownGoodsExcel; import com.logpm.warehouse.vo.*; @@ -96,7 +97,11 @@ public interface WarehouseUpdownGoodsMapper extends BaseMapper selectListByTaskStrip(IPage page,@Param("param") TaskSearchDTO taskSearchDTO); + List allocationDetailByPackage(@Param("param") TaskSearchDTO taskSearchDTO); + + List allocationDetailByZero(@Param("param") TaskSearchDTO taskSearchDTO); + + List allocationDetailByStock(@Param("param") TaskSearchDTO taskSearchDTO); // /** diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml index 7d5d5c173..ecacb2548 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml @@ -297,17 +297,99 @@ - + select ldpl.order_code orderCode, + ldpl.stock_article_id orderId, + 2 questType, + 1 questTarget, + ldpl.order_package_code orderPackageCode, + ldpl.id orderPackageId, + 0 questStatus, + ldpl.quantity stockNum, + ldpl.warehouse_id warehouseId, + lwug.position_code positionCode, + lwta.tray_id trayId, + lwt.tray_code trayCode, + lwug.allocation_id allocationId, + 0 isNew + from logpm_warehouse_updown_goods lwug + left join logpm_warehouse_tary_allocation lwta on lwta.allocation_id = lwug.allocation_id and lwta.is_deleted = 0 + left join logpm_warehouse_tray lwt on lwta.tray_id = lwt.id and lwt.is_deleted = 0 + left join logpm_distribution_parcel_list ldpl on ldpl.order_package_code = lwug.association_value and ldpl.is_deleted = 0 + left join logpm_distribution_stock_article ldsa on ldsa.id = ldpl.stock_article_id and ldsa.is_deleted = 0 + where lwug.association_type = 3 + and lwug.allocation_id = #{param.allocationId} + and lwug.warehouse_id = #{param.warehouseId} + and ldpl.warehouse_id = #{param.warehouseId} + + and ldsa.dealer_name in + + #{item} + + + + + + + + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IQuestDetailService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IQuestDetailService.java index 4535b29d8..2fb2cb508 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IQuestDetailService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IQuestDetailService.java @@ -49,4 +49,5 @@ public interface IQuestDetailService extends BaseService { */ List exportQuestDetail(Wrapper queryWrapper); + void saveList(List list, Long questId); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ITaskQuestService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ITaskQuestService.java index 5eff87e1e..efddc3b06 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ITaskQuestService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/ITaskQuestService.java @@ -17,12 +17,13 @@ package com.logpm.warehouse.service; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.warehouse.dto.TaskQuestDTO; import com.logpm.warehouse.dto.TaskSearchDTO; +import com.logpm.warehouse.entity.QuestDetailEntity; import com.logpm.warehouse.entity.TaskQuestEntity; -import com.logpm.warehouse.vo.*; import com.logpm.warehouse.excel.TaskQuestExcel; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.warehouse.vo.*; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -75,5 +76,16 @@ public interface ITaskQuestService extends BaseService { */ R selecttrayList(IPage page, TaskSearchDTO taskSearchDTO); - IPage selectallocationDetailByStrip(IPage page, TaskSearchDTO taskSearchDTO); + List allocationDetailByPackage(TaskSearchDTO taskSearchDTO); + + List allocationDetailByZero(TaskSearchDTO taskSearchDTO); + + List allocationDetailByStock(TaskSearchDTO taskSearchDTO); + + void updateQuestSetail(TaskSearchDTO taskSearchDTO); + + void updateQuestDetailAllocation(TaskSearchDTO taskSearchDTO); + + void deleteQuestDetail(TaskSearchDTO taskSearchDTO); + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/QuestDetailServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/QuestDetailServiceImpl.java index 332d25ca0..2c99d4079 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/QuestDetailServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/QuestDetailServiceImpl.java @@ -51,4 +51,13 @@ public class QuestDetailServiceImpl extends BaseServiceImpl list, Long questId) { + + for (QuestDetailEntity entity:list){ + entity.setQuestId(questId); + } + saveBatch(list); + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java index 865f8189d..2911d47bc 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java @@ -16,45 +16,42 @@ */ package com.logpm.warehouse.service.impl; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.logpm.basicdata.entity.BasicdataTrayEntity; -import com.logpm.basicdata.entity.BasicdataWarehouseEntity; -import com.logpm.basicdata.feign.IBasicdataTrayClient; -import com.logpm.basicdata.feign.IBasicdataWarehouseClient; -import com.logpm.basicdata.vo.BasicdataClientVO; +import com.logpm.basicdata.entity.*; +import com.logpm.basicdata.feign.*; import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.distribution.entity.DistributionStockListEntity; import com.logpm.distribution.feign.IDistributionParcelListClient; import com.logpm.distribution.feign.IDistributionStockArticleClient; -import com.logpm.distribution.feign.IDistributionStockClient; import com.logpm.distribution.feign.IDistributionStockListClient; import com.logpm.distribution.vo.DistributionStockListVO; -import com.logpm.oldproject.feign.IWarehouseClient; import com.logpm.warehouse.bean.Resp; +import com.logpm.warehouse.dto.QuestDetailDTO; import com.logpm.warehouse.dto.TaskQuestDTO; import com.logpm.warehouse.dto.TaskSearchDTO; import com.logpm.warehouse.entity.*; -import com.logpm.warehouse.mapper.QuestDetailMapper; +import com.logpm.warehouse.excel.TaskQuestExcel; +import com.logpm.warehouse.mapper.TaskQuestMapper; import com.logpm.warehouse.mapper.WarehouseTrayGoodsMapper; import com.logpm.warehouse.mapper.WarehouseUpdownGoodsMapper; +import com.logpm.warehouse.service.IQuestDetailChildService; import com.logpm.warehouse.service.IQuestDetailService; import com.logpm.warehouse.service.ITaskQuestChildService; -import com.logpm.warehouse.vo.*; -import com.logpm.warehouse.excel.TaskQuestExcel; -import com.logpm.warehouse.mapper.TaskQuestMapper; import com.logpm.warehouse.service.ITaskQuestService; +import com.logpm.warehouse.vo.*; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; -import org.springblade.core.log.exception.ServiceException; +import org.springblade.common.exception.CustomerException; +import org.springblade.common.utils.CommonUtil; +import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springframework.stereotype.Service; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.w3c.dom.css.Rect; +import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.util.*; @@ -87,6 +84,13 @@ public class TaskQuestServiceImpl extends BaseServiceImpl selectTaskQuestPage(IPage page, TaskQuestVO taskQuest) { @@ -359,18 +363,299 @@ public class TaskQuestServiceImpl extends BaseServiceImpl selectallocationDetailByStrip(IPage page, TaskSearchDTO taskSearchDTO) { + public List allocationDetailByPackage(TaskSearchDTO taskSearchDTO) { + + Long allocationId = taskSearchDTO.getAllocationId(); + Long warehouseId = taskSearchDTO.getWarehouseId(); + Long questId = taskSearchDTO.getQuestId(); + //先判定盘点任务是否已结束 + verifyTask(questId,warehouseId); + + //先查询任务的过滤商场 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("quest_id",questId) + .eq("is_deleted",0); + List questChildEntitys = taskQuestChildService.list(queryWrapper); + List marketNames = null; + for (TaskQuestChildEntity childEntity:questChildEntitys) { + if(Objects.isNull(marketNames)){ + marketNames = new ArrayList<>(); + } + marketNames.add(childEntity.getRefName()); + } + taskSearchDTO.setMarketNames(marketNames); + + //判断是否有明细数据存入 + QueryWrapper questDetailEntityQueryWrapper = new QueryWrapper<>(); + questDetailEntityQueryWrapper.eq("quest_id",questId) + .eq("quest_type",2) + .eq("quest_target",1) + .eq("warehouse_id",warehouseId) + .eq("allocation_id",allocationId) + .eq("is_deleted",0); + List questDetailEntities = questDetailService.list(questDetailEntityQueryWrapper); + if(!questDetailEntities.isEmpty()){ + return questDetailEntities; + } + + //如果还没有存入 //查询货位上的所有包条 - List list = warehouseUpdownGoodsMapper.selectListByTaskStrip(page, taskSearchDTO); - for (TaskStripApiVO taskStripApiVO : list) { + //然后存入detail表 + List list = warehouseUpdownGoodsMapper.allocationDetailByPackage(taskSearchDTO); + if(list.isEmpty()){ + log.warn("###########allocationDetailByPackage: 未有数据在盘点计划中 questId={}",questId); + throw new CustomerException(403,"未有数据在盘点计划中"); + } + + questDetailService.saveList(list,questId); + return list; + } + + @Override + public List allocationDetailByZero(TaskSearchDTO taskSearchDTO) { + Long questId = taskSearchDTO.getQuestId(); + Long allocationId = taskSearchDTO.getAllocationId(); + Long warehouseId = taskSearchDTO.getWarehouseId(); + + //先判定盘点任务是否已结束 + verifyTask(questId,warehouseId); + + //先查询任务的过滤商场 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("quest_id",questId) + .eq("is_deleted",0); + List questChildEntitys = taskQuestChildService.list(queryWrapper); + List marketNames = null; + for (TaskQuestChildEntity childEntity:questChildEntitys) { + if(Objects.isNull(marketNames)){ + marketNames = new ArrayList<>(); + } + marketNames.add(childEntity.getRefName()); } - return page.setRecords(list); + taskSearchDTO.setMarketNames(marketNames); + + //判断是否有明细数据存入 + QueryWrapper questDetailEntityQueryWrapper = new QueryWrapper<>(); + questDetailEntityQueryWrapper.eq("quest_id",questId) + .eq("quest_type",2) + .eq("quest_target",2) + .eq("warehouse_id",warehouseId) + .eq("allocation_id",allocationId) + .eq("is_deleted",0); + List questDetailEntities = questDetailService.list(questDetailEntityQueryWrapper); + if(!questDetailEntities.isEmpty()){ + return questDetailEntities; + } + + //如果还没有存入 + //查询货位上的所有包条 + //然后存入detail表 + List list = warehouseUpdownGoodsMapper.allocationDetailByZero(taskSearchDTO); + if(list.isEmpty()){ + log.warn("###########allocationDetailByZero: 未有数据在盘点计划中 questId={}",questId); + throw new CustomerException(403,"未有数据在盘点计划中"); + } + questDetailService.saveList(list,questId); + + return list; } + @Override + public List allocationDetailByStock(TaskSearchDTO taskSearchDTO) { + Long questId = taskSearchDTO.getQuestId(); + Long allocationId = taskSearchDTO.getAllocationId(); + Long warehouseId = taskSearchDTO.getWarehouseId(); + + //先判定盘点任务是否已结束 + verifyTask(questId,warehouseId); + + //先查询任务的过滤商场 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("quest_id",questId) + .eq("is_deleted",0); + List questChildEntitys = taskQuestChildService.list(queryWrapper); + List marketNames = null; + for (TaskQuestChildEntity childEntity:questChildEntitys) { + if(Objects.isNull(marketNames)){ + marketNames = new ArrayList<>(); + } + marketNames.add(childEntity.getRefName()); + } + taskSearchDTO.setMarketNames(marketNames); + + //判断是否有明细数据存入 + QueryWrapper questDetailEntityQueryWrapper = new QueryWrapper<>(); + questDetailEntityQueryWrapper.eq("quest_id",questId) + .eq("quest_type",2) + .eq("quest_target",3) + .eq("warehouse_id",warehouseId) + .eq("allocation_id",allocationId) + .eq("is_deleted",0); + List questDetailEntities = questDetailService.list(questDetailEntityQueryWrapper); + if(!questDetailEntities.isEmpty()){ + return questDetailEntities; + } + + //如果还没有存入 + //查询货位上的所有包条 + //然后存入detail表 + List list = warehouseUpdownGoodsMapper.allocationDetailByStock(taskSearchDTO); + if(list.isEmpty()){ + log.warn("###########allocationDetailByStock: 未有数据在盘点计划中 questId={}",questId); + throw new CustomerException(403,"未有数据在盘点计划中"); + } + questDetailService.saveList(list,questId); + + return list; + } + + @Transactional + @Override + public void updateQuestSetail(TaskSearchDTO taskSearchDTO) { + Long warehouseId = taskSearchDTO.getWarehouseId(); + Long questId = taskSearchDTO.getQuestId(); + + //先判定盘点任务是否已结束 + verifyTask(questId,warehouseId); + + List questDetailList = taskSearchDTO.getQuestDetailList(); + for (QuestDetailDTO questDetailDTO:questDetailList){ + Long questDetaiId = questDetailDTO.getId();//明细id + QuestDetailEntity detailEntity = questDetailService.getById(questDetaiId); + if(Objects.isNull(detailEntity)){ + log.warn("###########updateQuestSetail: 存在不在盘点计划中的数据 questDetaiId={}",questDetaiId); + throw new CustomerException(403,"存在不在盘点计划中的数据"); + } + Integer stockNum = questDetailDTO.getStockNum(); + Integer lossNum = questDetailDTO.getLossNum(); + Integer deliveNum = questDetailDTO.getDeliveNum(); + Integer wornNum = questDetailDTO.getWornNum(); + Integer noReceivedNum = questDetailDTO.getNoReceivedNum(); + Integer noRepairNum = questDetailDTO.getNoRepairNum(); + List childList = new ArrayList<>(); + childList.add(addQuestDetailChild(stockNum,"10",questDetaiId,warehouseId)); + childList.add(addQuestDetailChild(wornNum,"20",questDetaiId,warehouseId)); + childList.add(addQuestDetailChild(lossNum,"30",questDetaiId,warehouseId)); + childList.add(addQuestDetailChild(noRepairNum,"40",questDetaiId,warehouseId)); + childList.add(addQuestDetailChild(deliveNum,"50",questDetaiId,warehouseId)); + childList.add(addQuestDetailChild(noReceivedNum,"60",questDetaiId,warehouseId)); + questDetailChildService.saveBatch(childList); + detailEntity.setQuestStatus(1); + questDetailService.updateById(detailEntity); + } + } + + + @Transactional + @Override + public void updateQuestDetailAllocation(TaskSearchDTO taskSearchDTO) { + Long warehouseId = taskSearchDTO.getWarehouseId(); + Long allocationId = taskSearchDTO.getAllocationId(); + Long questId = taskSearchDTO.getQuestId(); + + //先判定盘点任务是否已结束 + verifyTask(questId,warehouseId); + + BasicdataGoodsAllocationEntity goodsAllocationEntity = basicdataGoodsAllocationClient.getEntityByAllocationId(allocationId); + if(Objects.isNull(goodsAllocationEntity)){ + log.warn("###########updateQuestDetailAllocation: 库位信息不存在 allocationId={}",allocationId); + throw new CustomerException(403,"库位信息不存在"); + } + Long wid = goodsAllocationEntity.getWarehouseId(); + if(!wid.equals(warehouseId)){ + log.warn("###########updateQuestDetailAllocation: 库位不在当前仓 allocationId={}",allocationId); + throw new CustomerException(403,"库位不在当前仓"); + } + Long goodsShelfId = goodsAllocationEntity.getGoodsShelfId(); + BasicdataGoodsShelfEntity basicdataGoodsShelfEntity = basicdataGoodsShelfClient.getEntityByGoodsShelfId(goodsShelfId); + if(Objects.isNull(basicdataGoodsShelfEntity)){ + log.warn("###########updateQuestDetailAllocation: 货架信息不存在 goodsShelfId={}",goodsShelfId); + throw new CustomerException(403,"货架信息不存在"); + } + Long goodsAreaId = basicdataGoodsShelfEntity.getGoodsAreaId(); + BasicdataGoodsAreaEntity goodsAreaEntity = basicdataGoodsAreaClient.getEntityByGoodsAreaId(goodsAreaId); + if(Objects.isNull(goodsAreaEntity)){ + log.warn("###########updateQuestDetailAllocation: 货区信息不存在 goodsAreaId={}",goodsAreaId); + throw new CustomerException(403,"货区信息不存在"); + } + + List questDetailList = taskSearchDTO.getQuestDetailList(); + List ls = new ArrayList<>(); + for (QuestDetailDTO questDetailDTO:questDetailList){ + Long questDetaiId = questDetailDTO.getId();//明细id + QuestDetailEntity detailEntity = questDetailService.getById(questDetaiId); + if(Objects.isNull(detailEntity)){ + log.warn("###########updateQuestSetail: 存在不在盘点计划中的数据 questDetaiId={}",questDetaiId); + throw new CustomerException(403,"存在不在盘点计划中的数据"); + } + detailEntity.setGroundingAllocationId(allocationId); + detailEntity.setGroundingPositionCode(goodsAreaEntity.getHeadline()+"-"+basicdataGoodsShelfEntity.getGoodsShelfName()+"-"+goodsAllocationEntity.getGoodsAllocationName()); + ls.add(detailEntity); + } + questDetailService.updateBatchById(ls); + } + + + @Transactional + @Override + public void deleteQuestDetail(TaskSearchDTO taskSearchDTO) { + Long warehouseId = taskSearchDTO.getWarehouseId(); + Long questId = taskSearchDTO.getQuestId(); + + //先判定盘点任务是否已结束 + verifyTask(questId,warehouseId); + + List questDetailList = taskSearchDTO.getQuestDetailList(); + List ls = new ArrayList<>(); + for (QuestDetailDTO questDetailDTO:questDetailList){ + Long questDetaiId = questDetailDTO.getId();//明细id + QuestDetailEntity detailEntity = questDetailService.getById(questDetaiId); + if(Objects.isNull(detailEntity)){ + log.warn("###########deleteQuestDetail: 存在不在盘点计划中的数据 questDetaiId={}",questDetaiId); + throw new CustomerException(403,"存在不在盘点计划中的数据"); + } + detailEntity.setQuestStatus(3); + ls.add(detailEntity); + } + questDetailService.updateBatchById(ls); + } + + + private QuestDetailChildEntity addQuestDetailChild(Integer num,String cargoName,Long questDetaiId,Long warehouseId){ + QuestDetailChildEntity questDetailChildEntity = new QuestDetailChildEntity(); + questDetailChildEntity.setQuestDetailId(questDetaiId); + questDetailChildEntity.setCargoName(cargoName); + questDetailChildEntity.setQuestNum(num); + questDetailChildEntity.setWarehouseId(warehouseId); + return questDetailChildEntity; + } + + private String getQuestNum(String warehouseCode) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); return "PDRW-" + warehouseCode + "-" + simpleDateFormat.format(new Date()) + new Random().nextInt(900) + 100; } + + private void verifyTask(Long taskId,Long warehouseId){ + TaskQuestEntity questEntity = getById(taskId); + if(Objects.isNull(questEntity)){ + log.warn("###########verifyTask: 盘点任务不存在 taskId={}",taskId); + throw new CustomerException(403,"盘点任务不存在"); + } + Long wid = questEntity.getWarehouseId(); + if(!wid.equals(warehouseId)){ + log.warn("###########verifyTask: 盘点任务不属于当前仓 taskId={}",taskId); + throw new CustomerException(403,"盘点任务不属于当前仓"); + } + Long now = new Date().getTime(); + String endTime = questEntity.getEndTime(); + Long end = CommonUtil.StringToDate(endTime).getTime(); + if(now > end){ + log.warn("###########verifyTask: 盘点任务已结束 taskId={}",taskId); + throw new CustomerException(403,"盘点任务已结束"); + } + } + }