@ -16,11 +16,10 @@
* /
package com.logpm.warehouse.service.impl ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.Wrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.logpm.basicdata.entity.* ;
import com.logpm.basicdata.feign.* ;
@ -58,7 +57,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.concurrent.atomic.AtomicInteger ;
import java.util.function.Function ;
import java.util.concurrent.atomic.AtomicReference ;
import java.util.stream.Collectors ;
@ -211,18 +209,16 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
}
@Override
public IPage < TaskallocationVO > selectallocationList ( IPage < TaskallocationVO > page , TaskSearchDTO taskSearchDTO ) {
List < Long > collect = this . getmyWarehouseList ( ) ;
baseMapper . setSqlMode ( ) ;
List < TaskallocationVO > list = baseMapper . selectallocationList ( page , taskSearchDTO , collect ) ;
if ( ! list . isEmpty ( ) ) {
for ( TaskallocationVO taskallocationVO : list ) {
Long allocationId = taskallocationVO . getAllocationId ( ) ;
Integer i = warehouseUpdownGoodsMapper . selectCountSumByallocation ( allocationId ) ;
taskallocationVO . setTotal ( i ) ;
}
}
return page . setRecords ( list ) ;
public List < TaskallocationVO > selectallocationList ( TaskSearchDTO taskSearchDTO ) {
List < TaskallocationVO > list = baseMapper . selectallocationList ( taskSearchDTO ) ;
// if (!list.isEmpty()) {
// for (TaskallocationVO taskallocationVO : list) {
// Long allocationId = taskallocationVO.getAllocationId();
// Integer i = warehouseUpdownGoodsMapper.selectCountSumByallocation(allocationId);
// taskallocationVO.setTotal(i);
// }
// }
return list ;
}
@Override
@ -465,7 +461,7 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
* @return
* /
@Transactional ( rollbackFor = Exception . class )
private int getTaskInventory ( Long taskId , Long warehouseId , BasicdataTrayEntity trayByTrayCode ) {
public int getTaskInventory ( Long taskId , Long warehouseId , BasicdataTrayEntity trayByTrayCode ) {
//查询是否在当前任务内
List < TaskQuestChildEntity > list = taskQuestChildService . list ( Wrappers . < TaskQuestChildEntity > query ( ) . lambda ( )
. eq ( TaskQuestChildEntity : : getQuestId , taskId )
@ -647,6 +643,17 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
//先判定盘点任务是否已结束
verifyTask ( questId , warehouseId ) ;
//先判断库位是否有数据
List < QuestDetailEntity > lsPackage = warehouseUpdownGoodsMapper . allocationDetailByPackage ( taskSearchDTO ) ;
List < QuestDetailEntity > lsZero = warehouseUpdownGoodsMapper . allocationDetailByZero ( taskSearchDTO ) ;
List < QuestDetailEntity > lsStock = warehouseUpdownGoodsMapper . allocationDetailByStock ( taskSearchDTO ) ;
Integer size = lsPackage . size ( ) + lsZero . size ( ) + lsStock . size ( ) ;
if ( size = = 0 ) {
log . warn ( "###########allocationDetailByPackage: 未有数据在盘点计划中 questId={}" , questId ) ;
throw new CustomerException ( 403 , "未有数据在盘点计划中" ) ;
}
//先查询任务的过滤商场
QueryWrapper < TaskQuestChildEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "quest_id" , questId )
@ -678,10 +685,10 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
//查询货位上的所有包条
//然后存入detail表
List < QuestDetailEntity > list = warehouseUpdownGoodsMapper . allocationDetailByPackage ( taskSearchDTO ) ;
if ( list . isEmpty ( ) ) {
log . warn ( "###########allocationDetailByPackage: 未有数据在盘点计划中 questId={}" , questId ) ;
throw new CustomerException ( 403 , "未有数据在盘点计划中" ) ;
}
// if(list.isEmpty()){
// log.warn( "###########allocationDetailByPackage: 未有数据在盘点计划中 questId={}",questId);
// throw new CustomerException(403,"未有数据在盘点计划中");
// }
questDetailService . saveList ( list , questId ) ;
@ -728,10 +735,10 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
//查询货位上的所有包条
//然后存入detail表
List < QuestDetailEntity > list = warehouseUpdownGoodsMapper . allocationDetailByZero ( taskSearchDTO ) ;
if ( list . isEmpty ( ) ) {
log . warn ( "###########allocationDetailByZero: 未有数据在盘点计划中 questId={}" , questId ) ;
throw new CustomerException ( 403 , "未有数据在盘点计划中" ) ;
}
// if(list.isEmpty()){
// log.warn( "###########allocationDetailByZero: 未有数据在盘点计划中 questId={}",questId);
// throw new CustomerException(403,"未有数据在盘点计划中");
// }
questDetailService . saveList ( list , questId ) ;
return list ;
@ -777,10 +784,10 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
//查询货位上的所有包条
//然后存入detail表
List < QuestDetailEntity > list = warehouseUpdownGoodsMapper . allocationDetailByStock ( taskSearchDTO ) ;
if ( list . isEmpty ( ) ) {
log . warn ( "###########allocationDetailByStock: 未有数据在盘点计划中 questId={}" , questId ) ;
throw new CustomerException ( 403 , "未有数据在盘点计划中" ) ;
}
// if(list.isEmpty()){
// log.warn( "###########allocationDetailByStock: 未有数据在盘点计划中 questId={}",questId);
// throw new CustomerException(403,"未有数据在盘点计划中");
// }
questDetailService . saveList ( list , questId ) ;
return list ;
@ -800,8 +807,8 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
Long questDetaiId = questDetailDTO . getId ( ) ; //明细id
QuestDetailEntity detailEntity = questDetailService . getById ( questDetaiId ) ;
if ( Objects . isNull ( detailEntity ) ) {
log . warn ( "###########updateQuestSetail: 存在不在盘点计划中的数据 questDetaiId={}" , questDetaiId ) ;
throw new CustomerException ( 403 , "存在不在盘点计划中的数据 " ) ;
log . warn ( "###########updateQuestSetail: 盘点明细不存在 questDetaiId={}" , questDetaiId ) ;
throw new CustomerException ( 403 , "盘点明细不存在 " ) ;
}
Integer stockNum = questDetailDTO . getStockNum ( ) ;
Integer lossNum = questDetailDTO . getLossNum ( ) ;
@ -816,7 +823,7 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
childList . add ( addQuestDetailChild ( noRepairNum , "40" , questDetaiId , warehouseId ) ) ;
childList . add ( addQuestDetailChild ( deliveNum , "50" , questDetaiId , warehouseId ) ) ;
childList . add ( addQuestDetailChild ( noReceivedNum , "60" , questDetaiId , warehouseId ) ) ;
questDetailChildService . saveBatch ( childList ) ;
questDetailChildService . saveOrUpdate Batch ( childList ) ;
detailEntity . setQuestStatus ( 1 ) ;
questDetailService . updateById ( detailEntity ) ;
}
@ -1027,6 +1034,11 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
questDetailService . save ( questDetailEntity ) ;
}
@Override
public List < WarehouseMaterialVO > findMaterialList ( TaskSearchDTO taskSearchDTO ) {
return baseMapper . findMaterialList ( taskSearchDTO ) ;
}
@Override
public IPage < QuestDetailVO > SelectStrip ( IPage < TaskQuestVO > page , Long id ) {
IPage < QuestDetailVO > questDetailVOList = baseMapper . selectStripListByQuestId ( page , id ) ;
@ -1047,11 +1059,31 @@ public class TaskQuestServiceImpl extends BaseServiceImpl<TaskQuestMapper, TaskQ
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 ) ;
if ( Objects . isNull ( questDetaiId ) ) {
log . warn ( "###########addQuestDetailChild: 明细id不存在 questDetaiId={}" , questDetaiId ) ;
throw new CustomerException ( 403 , "明细id不存在" ) ;
}
if ( Objects . isNull ( num ) ) {
log . warn ( "###########addQuestDetailChild: 数量不正确 num={}" , num ) ;
throw new CustomerException ( 403 , "数量不正确" ) ;
}
QueryWrapper < QuestDetailChildEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "quest_detail_id" , questDetaiId )
. eq ( "cargo_name" , cargoName )
. eq ( "is_deleted" , 0 ) ;
QuestDetailChildEntity questDetailChildEntity = questDetailChildService . getOne ( queryWrapper ) ;
if ( Objects . isNull ( questDetailChildEntity ) ) {
questDetailChildEntity = new QuestDetailChildEntity ( ) ;
questDetailChildEntity . setQuestDetailId ( questDetaiId ) ;
questDetailChildEntity . setCargoName ( cargoName ) ;
questDetailChildEntity . setQuestNum ( num ) ;
questDetailChildEntity . setWarehouseId ( warehouseId ) ;
} else {
questDetailChildEntity . setQuestNum ( num ) ;
}
return questDetailChildEntity ;
}