|
|
|
@ -19,6 +19,7 @@ import digital.laboratory.platform.imr.feign.dto.UpdateHolderDTO; |
|
|
|
|
import digital.laboratory.platform.imr.mapper.*; |
|
|
|
|
import digital.laboratory.platform.imr.service.DrugMaterialInfoService; |
|
|
|
|
import digital.laboratory.platform.imr.service.SamplePutInStorageService; |
|
|
|
|
import digital.laboratory.platform.imr.service.SampleStorageService; |
|
|
|
|
import digital.laboratory.platform.imr.vo.InboundRecordVO; |
|
|
|
|
import digital.laboratory.platform.imr.vo.OutSampleVO; |
|
|
|
|
import digital.laboratory.platform.imr.vo.RepositorySampleVO; |
|
|
|
@ -34,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@ -50,6 +52,8 @@ public class SamplePutInStorageServiceImpl implements SamplePutInStorageService |
|
|
|
|
|
|
|
|
|
private final SampleStorageMapper storageMapper; |
|
|
|
|
|
|
|
|
|
private final SampleStorageService sampleStorageService; |
|
|
|
|
|
|
|
|
|
private final TransferFeignService transferFeignService; |
|
|
|
|
|
|
|
|
|
private final CabinetOpeningRecordMapper openingRecordMapper; |
|
|
|
@ -449,16 +453,24 @@ public class SamplePutInStorageServiceImpl implements SamplePutInStorageService |
|
|
|
|
@Override |
|
|
|
|
@GlobalTransactional |
|
|
|
|
public List<OutSampleVO> sampleDepositRepository(DepositDTO dto) { |
|
|
|
|
/** |
|
|
|
|
* 优化接口效率,不在循环中操作数据库,提前获取需要的数据,转成map操作 |
|
|
|
|
*/ |
|
|
|
|
List<String> ids = dto.getIds(); |
|
|
|
|
Map<String, SampleStorage> sampleStorageMap = storageMapper |
|
|
|
|
.selectList(Wrappers.<SampleStorage>lambdaQuery().in(SampleStorage::getId, ids)) |
|
|
|
|
.stream().collect(Collectors.toMap(SampleStorage::getId, Function.identity())); |
|
|
|
|
|
|
|
|
|
ArrayList<String> sampleIds = new ArrayList<>(); |
|
|
|
|
List<OutSampleVO> outSampleVOS = new ArrayList<>(); |
|
|
|
|
for (String id:dto.getIds()) {//这里的id是样本存储表的id
|
|
|
|
|
SampleStorage sampleStorage = storageMapper.selectById(id); |
|
|
|
|
if(sampleStorage==null){ |
|
|
|
|
throw new RuntimeException(String.format("当前"+id+"样本存储数据为空")); |
|
|
|
|
List<SampleStorage> sampleStorageList = ids.stream().map(id -> { |
|
|
|
|
//这里的id是样本存储表的id
|
|
|
|
|
SampleStorage sampleStorage = sampleStorageMap.get(id); |
|
|
|
|
if (sampleStorage == null) { |
|
|
|
|
throw new RuntimeException(String.format("当前id为 %s 样本存储数据为空", id)); |
|
|
|
|
} |
|
|
|
|
if(sampleStorage.getStatus()!=1){ |
|
|
|
|
throw new RuntimeException(String.format("当前"+id+"样本不是待存放的状态")); |
|
|
|
|
if (sampleStorage.getStatus() != 1) { |
|
|
|
|
throw new RuntimeException(String.format("当前id为 %s 样本不是待存放的状态", id)); |
|
|
|
|
} |
|
|
|
|
sampleStorage.setStorageLocation(dto.getStorageLocation()); |
|
|
|
|
sampleStorage.setStatus(2);//入库已经存放
|
|
|
|
@ -467,24 +479,28 @@ public class SamplePutInStorageServiceImpl implements SamplePutInStorageService |
|
|
|
|
sampleStorage.setBoxId(dto.getBoxId()); |
|
|
|
|
sampleStorage.setCabinetName(dto.getCabinetName());//柜子名称
|
|
|
|
|
sampleStorage.setBuildingLv(dto.getBuildingLv());//楼层
|
|
|
|
|
//数据修改
|
|
|
|
|
storageMapper.updateById(sampleStorage); |
|
|
|
|
|
|
|
|
|
//添加样本id
|
|
|
|
|
sampleIds.add(sampleStorage.getSampleId()); |
|
|
|
|
OutSampleVO sampleVO; |
|
|
|
|
if (dto.getType() == 0) { |
|
|
|
|
sampleVO = storageMapper.getSampleById(sampleStorage.getSampleId()); |
|
|
|
|
} else { |
|
|
|
|
sampleVO = drugMaterialInfoService.drugMaterialToOutSampleVO(sampleStorage, sampleStorage.getSampleId()); |
|
|
|
|
//3.毒品库中的毒品检材信息样本状态为已入库
|
|
|
|
|
drugMaterialInfoService.update(Wrappers.<DrugMaterialInfo>lambdaUpdate().eq(DrugMaterialInfo::getId, sampleStorage.getSampleId()) |
|
|
|
|
.set(DrugMaterialInfo::getStatus, DrugMaterialStatus.FINISH_INBOUND.getStatus())); |
|
|
|
|
} |
|
|
|
|
sampleVO.setStorageLocation(dto.getStorageLocation()); |
|
|
|
|
outSampleVOS.add(sampleVO); |
|
|
|
|
return sampleStorage; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
// 批量更新
|
|
|
|
|
sampleStorageService.updateBatchById(sampleStorageList); |
|
|
|
|
// 根据检材的类型做对应的处理
|
|
|
|
|
if (dto.getType() == 0) { |
|
|
|
|
sampleStorageList.forEach(sampleStorage -> { |
|
|
|
|
OutSampleVO sampleVO = storageMapper.getSampleById(sampleStorage.getSampleId()); |
|
|
|
|
sampleVO.setStorageLocation(dto.getStorageLocation()); |
|
|
|
|
outSampleVOS.add(sampleVO); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
sampleStorageList.forEach(sampleStorage -> |
|
|
|
|
outSampleVOS.add(drugMaterialInfoService.drugMaterialToOutSampleVO(sampleStorage, sampleStorage.getSampleId())) |
|
|
|
|
); |
|
|
|
|
//3.毒品库中的毒品检材信息样本状态为已入库
|
|
|
|
|
drugMaterialInfoService.update(Wrappers.<DrugMaterialInfo>lambdaUpdate().in(DrugMaterialInfo::getId, sampleIds) |
|
|
|
|
.set(DrugMaterialInfo::getStatus, DrugMaterialStatus.FINISH_INBOUND.getStatus())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//去除最后一个“,”
|
|
|
|
|
//String str = sampleIds.substring(0,sampleIds.lastIndexOf(","));
|
|
|
|
|
|
|
|
|
|