|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package digital.laboratory.platform.reagent.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
|
import cn.hutool.core.io.IoUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
@ -28,16 +29,28 @@ import digital.laboratory.platform.sys.entity.CellAndStoreSupplyData; |
|
|
|
|
import digital.laboratory.platform.sys.feign.RemoteCabinetService; |
|
|
|
|
import feign.Response; |
|
|
|
|
import io.seata.spring.annotation.GlobalTransactional; |
|
|
|
|
import org.apache.commons.fileupload.FileItem; |
|
|
|
|
import org.apache.commons.fileupload.FileItemFactory; |
|
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|
|
|
|
import org.apache.commons.io.output.ByteArrayOutputStream; |
|
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
|
import org.apache.poi.ss.usermodel.*; |
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.mock.web.MockMultipartFile; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.io.*; |
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.*; |
|
|
|
@ -103,11 +116,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
|
|
|
|
|
List<ReagentConsumableInventoryVO> reagentConsumableInventoryVOList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
List<BatchDetails> list = batchDetailsService.list(Wrappers.<BatchDetails>query() |
|
|
|
|
.eq("warning_information", "即将过期").or() |
|
|
|
|
.eq("warning_information", "已过期").or() |
|
|
|
|
.eq("warning_information", "即将到达存储期限").or() |
|
|
|
|
.eq("warning_information", "已超过存储期限")); |
|
|
|
|
List<BatchDetails> list = batchDetailsService.list(Wrappers.<BatchDetails>query().eq("warning_information", "即将过期").or().eq("warning_information", "已过期").or().eq("warning_information", "即将到达存储期限").or().eq("warning_information", "已超过存储期限")); |
|
|
|
|
|
|
|
|
|
if (list.size() != 0) { |
|
|
|
|
for (BatchDetails batchDetails : list) { |
|
|
|
@ -146,46 +155,27 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
|
|
|
|
|
@Override//试剂耗材管理列表
|
|
|
|
|
public IPage<ReagentConsumableInventoryVO> getReagentConsumableInventoryREVOList(IPage<ReagentConsumableInventory> page, QueryWrapper<ReagentConsumableInventory> qw, Integer warning) { |
|
|
|
|
|
|
|
|
|
if (warning != null) { |
|
|
|
|
|
|
|
|
|
if (warning == 2) { |
|
|
|
|
|
|
|
|
|
List<ReagentConsumableInventoryVO> reagentConsumableInventoryVOList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
List<BatchDetails> list = batchDetailsService.list(Wrappers.<BatchDetails>query() |
|
|
|
|
.eq("warning_information", "即将过期").or() |
|
|
|
|
.eq("warning_information", "已过期").or() |
|
|
|
|
.eq("warning_information", "即将到达存储期限").or() |
|
|
|
|
.eq("warning_information", "已超过存储期限")); |
|
|
|
|
//查找具有到期批次物品的试剂耗材类信息
|
|
|
|
|
if (list.size() != 0) { |
|
|
|
|
for (BatchDetails batchDetails : list) { |
|
|
|
|
|
|
|
|
|
ReagentConsumableInventory byId = this.getById(batchDetails.getReagentConsumableInventoryId()); |
|
|
|
|
if (warning != null && warning == 2) { |
|
|
|
|
List<ReagentConsumableInventoryVO> reagentConsumableInventoryVOList = new ArrayList<>(); |
|
|
|
|
List<BatchDetails> list = batchDetailsService.list(Wrappers.<BatchDetails>query().eq("warning_information", "即将过期").or().eq("warning_information", "已过期").or().eq("warning_information", "即将到达存储期限").or().eq("warning_information", "已超过存储期限")); |
|
|
|
|
//查找具有到期批次物品的试剂耗材类信息
|
|
|
|
|
if (list != null && list.size() != 0) { |
|
|
|
|
for (BatchDetails batchDetails : list) { |
|
|
|
|
ReagentConsumableInventory reagentConsumableInventory = this.getOne(new LambdaQueryWrapper<ReagentConsumableInventory>().eq(ReagentConsumableInventory::getReagentConsumableInventoryId, batchDetails.getReagentConsumableInventoryId()).ne(ReagentConsumableInventory::getCategory, "标准物质").ne(ReagentConsumableInventory::getCategory, "标准储备溶液")); |
|
|
|
|
if (reagentConsumableInventory != null) { |
|
|
|
|
ReagentConsumableInventoryVO reagentConsumableInventoryVO = new ReagentConsumableInventoryVO(); |
|
|
|
|
BeanUtils.copyProperties(byId, reagentConsumableInventoryVO); |
|
|
|
|
BeanUtils.copyProperties(reagentConsumableInventory, reagentConsumableInventoryVO); |
|
|
|
|
reagentConsumableInventoryVO.setBatchDetailsVOS(batchDetailsService.getBatchDetailsList(reagentConsumableInventoryVO.getReagentConsumableInventoryId())); |
|
|
|
|
|
|
|
|
|
if (!reagentConsumableInventoryVOList.contains(reagentConsumableInventoryVO)) { |
|
|
|
|
if (reagentConsumableInventoryVO.getCategory().equals("试剂") || reagentConsumableInventoryVO.getCategory().equals("耗材")) { |
|
|
|
|
reagentConsumableInventoryVOList.add(reagentConsumableInventoryVO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reagentConsumableInventoryVOList.add(reagentConsumableInventoryVO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
PageUtils pageUtils = new PageUtils(); |
|
|
|
|
|
|
|
|
|
return pageUtils.getPages((int) page.getCurrent(), (int) page.getSize(), reagentConsumableInventoryVOList); |
|
|
|
|
} |
|
|
|
|
PageUtils pageUtils = new PageUtils(); |
|
|
|
|
return pageUtils.getPages((int) page.getCurrent(), (int) page.getSize(), reagentConsumableInventoryVOList); |
|
|
|
|
} |
|
|
|
|
IPage<ReagentConsumableInventoryVO> reagentConsumableInventoryVOPage = baseMapper.getReagentConsumableInventoryVOPage(page, qw); |
|
|
|
|
|
|
|
|
|
List<ReagentConsumableInventoryVO> records = reagentConsumableInventoryVOPage.getRecords(); |
|
|
|
|
|
|
|
|
|
for (ReagentConsumableInventoryVO reagentConsumableInventoryVO : records) { |
|
|
|
|
|
|
|
|
|
List<BatchDetailsVO> batchDetailsVOList = batchDetailsService.getBatchDetailsList(reagentConsumableInventoryVO.getReagentConsumableInventoryId()); |
|
|
|
|
//赋值试剂耗材批次明细
|
|
|
|
|
reagentConsumableInventoryVO.setBatchDetailsVOS(batchDetailsVOList); |
|
|
|
@ -262,24 +252,6 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
|
|
|
|
|
IPage<ReferenceMaterialFullVO> referenceMaterialPage = baseMapper.getReferenceMaterialPage(page, qw); |
|
|
|
|
|
|
|
|
|
// List<ReferenceMaterialFullVO> referenceMaterialPageRecords = referenceMaterialPage.getRecords();
|
|
|
|
|
//
|
|
|
|
|
// LambdaQueryWrapper<StandardReserveSolution> standardReserveSolutionQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
//
|
|
|
|
|
// for (ReferenceMaterialFullVO referenceMaterialPageRecord : referenceMaterialPageRecords) {
|
|
|
|
|
// standardReserveSolutionQueryWrapper.eq(StandardReserveSolution::getReferenceMaterialId,referenceMaterialPageRecord.getReferenceMaterialId());
|
|
|
|
|
// StandardReserveSolution standardReserveSolution = standardReserveSolutionService.getOne(standardReserveSolutionQueryWrapper);
|
|
|
|
|
//
|
|
|
|
|
// if (standardReserveSolution != null) {
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// referenceMaterialPageRecord.setConfigurationConcentration(standardReserveSolution.getConfigurationConcentration());
|
|
|
|
|
// referenceMaterialPageRecord.setConfigurationDate(standardReserveSolution.getConfigurationDate());
|
|
|
|
|
// referenceMaterialPageRecord.setSolutionNumbering(standardReserveSolution.getSolutionNumbering());
|
|
|
|
|
// referenceMaterialPageRecord.setValidityPeriod(standardReserveSolution.getValidityPeriod());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return referenceMaterialPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -331,7 +303,6 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
return reagentConsumableInventoryFullVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//分页查询试剂耗材
|
|
|
|
|
@Override |
|
|
|
|
public IPage<ReagentConsumableInventoryFullVO> getAllRM(IPage<ReagentConsumableInventory> page, QueryWrapper<ReagentConsumableInventory> qw) { |
|
|
|
@ -342,9 +313,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
|
|
|
|
|
for (ReagentConsumableInventory reagentConsumableInventory : list) { |
|
|
|
|
|
|
|
|
|
List<BatchDetails> list1 = batchDetailsService.list(Wrappers.<BatchDetails>query() |
|
|
|
|
.eq("reagent_consumable_inventory_id", reagentConsumableInventory.getReagentConsumableInventoryId()) |
|
|
|
|
.eq("service_status", 1)); |
|
|
|
|
List<BatchDetails> list1 = batchDetailsService.list(Wrappers.<BatchDetails>query().eq("reagent_consumable_inventory_id", reagentConsumableInventory.getReagentConsumableInventoryId()).eq("service_status", 1)); |
|
|
|
|
|
|
|
|
|
//将不同批次的物品展示出来
|
|
|
|
|
for (BatchDetails batchDetails : list1) { |
|
|
|
@ -383,8 +352,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<BatchDetails> batchDetailsLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
|
|
batchDetailsLambdaQueryWrapper.eq(BatchDetails::getReagentConsumableInventoryId, reagentConsumableInventory.getReagentConsumableInventoryId()) |
|
|
|
|
.or().eq(BatchDetails::getServiceStatus, 1); |
|
|
|
|
batchDetailsLambdaQueryWrapper.eq(BatchDetails::getReagentConsumableInventoryId, reagentConsumableInventory.getReagentConsumableInventoryId()).or().eq(BatchDetails::getServiceStatus, 1); |
|
|
|
|
|
|
|
|
|
List<BatchDetails> list1 = batchDetailsService.list(batchDetailsLambdaQueryWrapper); |
|
|
|
|
//将不同批次的物品展示出来
|
|
|
|
@ -444,12 +412,10 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
/** |
|
|
|
|
* 循环表格 |
|
|
|
|
*/ |
|
|
|
|
XWPFTemplate template = XWPFTemplate.compile(bis, builder.build()).render( |
|
|
|
|
new HashMap<String, Object>() {{ |
|
|
|
|
put("voList", voList); |
|
|
|
|
put("year", year); |
|
|
|
|
}} |
|
|
|
|
); |
|
|
|
|
XWPFTemplate template = XWPFTemplate.compile(bis, builder.build()).render(new HashMap<String, Object>() {{ |
|
|
|
|
put("voList", voList); |
|
|
|
|
put("year", year); |
|
|
|
|
}}); |
|
|
|
|
bis.close(); |
|
|
|
|
|
|
|
|
|
ByteArrayOutputStream fosWord = new ByteArrayOutputStream(); |
|
|
|
@ -486,8 +452,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
|
|
|
|
|
ReagentConsumables byId = reagentConsumablesService.getById(id); |
|
|
|
|
|
|
|
|
|
ReagentConsumableInventory one = this.getOne(Wrappers.<ReagentConsumableInventory>query() |
|
|
|
|
.eq("reagent_consumable_id", id)); |
|
|
|
|
ReagentConsumableInventory one = this.getOne(Wrappers.<ReagentConsumableInventory>query().eq("reagent_consumable_id", id)); |
|
|
|
|
|
|
|
|
|
if (byId != null & one != null) { |
|
|
|
|
byId.setCode(code); |
|
|
|
@ -568,10 +533,11 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
for (ReagentConsumableInventoryDTO reagentConsumableInventoryDTO : reagentConsumableInventoryDTOList) { |
|
|
|
|
Integer quantity = reagentConsumableInventoryDTO.getTotalQuantity() * reagentConsumableInventoryDTO.getPackagedCopies(); |
|
|
|
|
SupplierInformation supplier = supplierInformationService.getOne(Wrappers.<SupplierInformation>query().eq("supplier_name", reagentConsumableInventoryDTO.getSupplierName())); |
|
|
|
|
|
|
|
|
|
String location = "F" + reagentConsumableInventoryDTO.getRoomNo().charAt(0) + "-" + reagentConsumableInventoryDTO.getRoomNo() + "_试剂柜-" + reagentConsumableInventoryDTO |
|
|
|
|
.getLocation().charAt(0) + "_" + reagentConsumableInventoryDTO.getLocation(); |
|
|
|
|
|
|
|
|
|
R<CabinetCell> cabinetCellR = remoteCabinetService.queryCellByRoomNoAndLocation(reagentConsumableInventoryDTO.getRoomNo(), reagentConsumableInventoryDTO.getLocation()); |
|
|
|
|
CabinetCell cabinetCell = cabinetCellR.getData(); |
|
|
|
|
String cabinetId = cabinetCellR.getData().getCabinetId(); |
|
|
|
|
String cellName = baseMapper.getCellName(cabinetId); |
|
|
|
|
String location = "F" + reagentConsumableInventoryDTO.getRoomNo().charAt(0) + "-" + reagentConsumableInventoryDTO.getRoomNo() + "_" + cellName + "_" + reagentConsumableInventoryDTO.getLocation(); |
|
|
|
|
if (!StrUtil.isNotBlank(reagentConsumableInventoryDTO.getStandardValueOrPurity())) { |
|
|
|
|
reagentConsumableInventoryDTO.setStandardValueOrPurity(""); |
|
|
|
|
} |
|
|
|
@ -597,22 +563,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
reagentConsumableInventoryDTO.setAlias(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReagentConsumableInventory one = this.getOne(Wrappers.<ReagentConsumableInventory>query() |
|
|
|
|
.eq("reagent_consumable_name", reagentConsumableInventoryDTO.getReagentConsumableName()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getBrand()), "brand", reagentConsumableInventoryDTO.getBrand()) |
|
|
|
|
.eq("category", reagentConsumableInventoryDTO.getCategory()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getSpecificationAndModel()), "specification_and_model", reagentConsumableInventoryDTO.getSpecificationAndModel()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getStandardValueOrPurity()), "standard_value_or_purity", reagentConsumableInventoryDTO.getStandardValueOrPurity()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getCasNumber()), "cas_number", reagentConsumableInventoryDTO.getCasNumber()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getSpecies()), "species", reagentConsumableInventoryDTO.getSpecies()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getEnglishName()), "english_name", reagentConsumableInventoryDTO.getEnglishName()) |
|
|
|
|
.eq(reagentConsumableInventoryDTO.getPackagedCopies() != null, "packaged_copies", reagentConsumableInventoryDTO.getPackagedCopies()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getAlias()), "alias", reagentConsumableInventoryDTO.getAlias()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getPurityGrade()), "purity_grade", reagentConsumableInventoryDTO.getPurityGrade()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getDeviationOrUncertainty()), "deviation_or_uncertainty", reagentConsumableInventoryDTO.getDeviationOrUncertainty()) |
|
|
|
|
.eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getMinimumUnit()), "minimum_unit", reagentConsumableInventoryDTO.getMinimumUnit()) |
|
|
|
|
); |
|
|
|
|
ReagentConsumableInventory one = this.getOne(Wrappers.<ReagentConsumableInventory>query().eq("reagent_consumable_name", reagentConsumableInventoryDTO.getReagentConsumableName()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getBrand()), "brand", reagentConsumableInventoryDTO.getBrand()).eq("category", reagentConsumableInventoryDTO.getCategory()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getSpecificationAndModel()), "specification_and_model", reagentConsumableInventoryDTO.getSpecificationAndModel()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getStandardValueOrPurity()), "standard_value_or_purity", reagentConsumableInventoryDTO.getStandardValueOrPurity()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getCasNumber()), "cas_number", reagentConsumableInventoryDTO.getCasNumber()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getSpecies()), "species", reagentConsumableInventoryDTO.getSpecies()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getEnglishName()), "english_name", reagentConsumableInventoryDTO.getEnglishName()).eq(reagentConsumableInventoryDTO.getPackagedCopies() != null, "packaged_copies", reagentConsumableInventoryDTO.getPackagedCopies()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getAlias()), "alias", reagentConsumableInventoryDTO.getAlias()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getPurityGrade()), "purity_grade", reagentConsumableInventoryDTO.getPurityGrade()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getDeviationOrUncertainty()), "deviation_or_uncertainty", reagentConsumableInventoryDTO.getDeviationOrUncertainty()).eq(StrUtil.isNotBlank(reagentConsumableInventoryDTO.getMinimumUnit()), "minimum_unit", reagentConsumableInventoryDTO.getMinimumUnit())); |
|
|
|
|
BatchDetails batchDetails = new BatchDetails(); |
|
|
|
|
batchDetails.setServiceStatus(1); |
|
|
|
|
batchDetails.setQuantity(quantity); |
|
|
|
@ -639,8 +590,6 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
} else { |
|
|
|
|
batchDetails.setExpirationDate(LocalDate.now().plusYears(99)); |
|
|
|
|
} |
|
|
|
|
R<CabinetCell> cabinetCellR = remoteCabinetService.queryCellByRoomNoAndLocation(reagentConsumableInventoryDTO.getRoomNo(), reagentConsumableInventoryDTO.getLocation()); |
|
|
|
|
CabinetCell cabinetCell = cabinetCellR.getData(); |
|
|
|
|
batchDetails.setLatticeId(cabinetCell.getId()); |
|
|
|
|
batchDetails.setBoxId(cabinetCell.getCabinetId()); |
|
|
|
|
batchDetails.setLocation(location); |
|
|
|
@ -659,9 +608,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
batchDetails.setReagentConsumableInventoryId(one.getReagentConsumableInventoryId()); |
|
|
|
|
ReagentConsumables reagentConsumables = reagentConsumablesService.getById(one.getReagentConsumableId()); |
|
|
|
|
if (!one.getCategory().equals("标准物质")) { |
|
|
|
|
ReagentConsumableStash reagentConsumableStash = reagentConsumableStashService.getOne(Wrappers.<ReagentConsumableStash>query() |
|
|
|
|
.eq("room_no", reagentConsumableInventoryDTO.getRoomNo()) |
|
|
|
|
.eq("reagent_consumable_id", reagentConsumables.getReagentConsumableId())); |
|
|
|
|
ReagentConsumableStash reagentConsumableStash = reagentConsumableStashService.getOne(Wrappers.<ReagentConsumableStash>query().eq("room_no", reagentConsumableInventoryDTO.getRoomNo()).eq("reagent_consumable_id", reagentConsumables.getReagentConsumableId())); |
|
|
|
|
if (reagentConsumableStash != null) { |
|
|
|
|
reagentConsumableStash.setTotalQuantity(reagentConsumableStash.getTotalQuantity() + quantity); |
|
|
|
|
batchDetails.setReagentConsumableStashId(reagentConsumableStash.getId()); |
|
|
|
@ -717,9 +664,7 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
this.updateCabinet(cabinetCell.getId(), reagentConsumables.getReagentConsumableId(), 1); |
|
|
|
|
|
|
|
|
|
if (!reagentConsumableInventory.getCategory().equals("标准物质")) { |
|
|
|
|
ReagentConsumableStash reagentConsumableStash = reagentConsumableStashService.getOne(Wrappers.<ReagentConsumableStash>query() |
|
|
|
|
.eq("room_no", reagentConsumableInventoryDTO.getRoomNo()) |
|
|
|
|
.eq("reagent_consumable_id", reagentConsumables.getReagentConsumableId())); |
|
|
|
|
ReagentConsumableStash reagentConsumableStash = reagentConsumableStashService.getOne(Wrappers.<ReagentConsumableStash>query().eq("room_no", reagentConsumableInventoryDTO.getRoomNo()).eq("reagent_consumable_id", reagentConsumables.getReagentConsumableId())); |
|
|
|
|
if (reagentConsumableStash != null) { |
|
|
|
|
reagentConsumableStash.setTotalQuantity(reagentConsumableStash.getTotalQuantity() + quantity); |
|
|
|
|
batchDetails.setReagentConsumableStashId(reagentConsumableStash.getId()); |
|
|
|
@ -801,16 +746,19 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
BatchDetails oldBatchDetails = batchDetailsService.getById(batchDetails.getBatchDetailsId()); |
|
|
|
|
String oldLocation = oldBatchDetails.getLocation(); |
|
|
|
|
this.updateCabinet(oldBatchDetails.getLatticeId(), oldBatchDetails.getReagentConsumableInventoryId(), -1);//清除原来位置信息ID
|
|
|
|
|
|
|
|
|
|
//需同步至试剂耗材仓库库存表
|
|
|
|
|
ReagentConsumableStash reagentConsumableStash = reagentConsumableStashService.getById(oldBatchDetails.getReagentConsumableStashId()); |
|
|
|
|
oldBatchDetails.setLocation(batchDetails.getLocation()); |
|
|
|
|
oldBatchDetails.setBoxId(batchDetails.getBoxId()); |
|
|
|
|
oldBatchDetails.setLatticeId(batchDetails.getLatticeId()); |
|
|
|
|
String[] split = batchDetails.getLocation().split("_"); |
|
|
|
|
String roomNo = split[1]; |
|
|
|
|
oldBatchDetails.setRoomNo(roomNo); |
|
|
|
|
reagentConsumableStash.setRoomNo(roomNo); |
|
|
|
|
|
|
|
|
|
if (batchDetailsService.updateById(oldBatchDetails)) { |
|
|
|
|
this.updateCabinet(oldBatchDetails.getLatticeId(), oldBatchDetails.getReagentConsumableInventoryId(), 1); |
|
|
|
|
reagentConsumableStashService.updateById(reagentConsumableStash); |
|
|
|
|
locationInfoService.addInfo(oldBatchDetails.getBatchDetailsId(), oldLocation, batchDetails.getLocation()); |
|
|
|
|
return true; |
|
|
|
|
} else return false; |
|
|
|
@ -839,4 +787,257 @@ public class ReagentConsumableInventoryServiceImpl extends ServiceImpl<ReagentCo |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getExcel() throws IOException { |
|
|
|
|
|
|
|
|
|
String Path = "C:\\tmp\\upload\\"; |
|
|
|
|
|
|
|
|
|
List<ReagentConsumableInventoryFullVO> reagentConsumableList = baseMapper.getReagentConsumableList(); |
|
|
|
|
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook(); |
|
|
|
|
HSSFCellStyle cellStyle = workbook.createCellStyle(); |
|
|
|
|
HSSFCellStyle cellStyle1 = workbook.createCellStyle(); |
|
|
|
|
cellStyle1.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
HSSFFont font1 = workbook.createFont(); |
|
|
|
|
font1.setFontHeightInPoints((short) 15); |
|
|
|
|
cellStyle1.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
|
|
|
|
cellStyle1.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
cellStyle1.setFont(font1); |
|
|
|
|
HSSFCellStyle cellStyle2 = workbook.createCellStyle(); |
|
|
|
|
cellStyle2.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
HSSFFont font2 = workbook.createFont(); |
|
|
|
|
font2.setFontName("微软雅黑"); |
|
|
|
|
cellStyle2.setFont(font2); |
|
|
|
|
// cellStyle2.setWrapText(true);
|
|
|
|
|
|
|
|
|
|
HSSFSheet workbookSheet = workbook.createSheet("试剂耗材库存表"); |
|
|
|
|
workbookSheet.setColumnWidth(0, 15000); |
|
|
|
|
workbookSheet.setColumnWidth(1, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(2, 4000); |
|
|
|
|
workbookSheet.setColumnWidth(3, 15000); |
|
|
|
|
workbookSheet.setColumnWidth(4, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(5, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(6, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(7, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(8, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(9, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(10, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(11, 3500); |
|
|
|
|
workbookSheet.setColumnWidth(12, 10000); |
|
|
|
|
HSSFFont font = workbook.createFont(); |
|
|
|
|
HSSFRow row0 = workbookSheet.createRow(0); |
|
|
|
|
cellStyle.setAlignment(HorizontalAlignment.CENTER); |
|
|
|
|
|
|
|
|
|
row0.setRowStyle(cellStyle); |
|
|
|
|
for (int i = 0; i < 13; i++) { |
|
|
|
|
HSSFCell cell = row0.createCell(i); |
|
|
|
|
if (i == 0) { |
|
|
|
|
LocalDateTime dateTime = LocalDateTime.now(); |
|
|
|
|
cell.setCellValue(LocalDateTimeUtil.format(dateTime, "yyyy 年 MM 月 dd 日") + "试剂耗材实时库存报表"); |
|
|
|
|
font.setFontHeightInPoints((short) 28); |
|
|
|
|
font.setColor((short) 25); |
|
|
|
|
// font.setBoldweight((short) 1);
|
|
|
|
|
//设置字体斜体
|
|
|
|
|
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
|
|
|
|
cellStyle.setFillForegroundColor(IndexedColors.TAN.getIndex()); |
|
|
|
|
font.setItalic(true); |
|
|
|
|
cellStyle.setFont(font); |
|
|
|
|
cell.setCellStyle(cellStyle); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, 0, 12); |
|
|
|
|
workbookSheet.addMergedRegion(cellRangeAddress); |
|
|
|
|
HSSFRow row = workbookSheet.createRow(1); |
|
|
|
|
HSSFCell cell0 = row.createCell(0); |
|
|
|
|
cell0.setCellValue("试剂耗材名称"); |
|
|
|
|
HSSFCell cell1 = row.createCell(1); |
|
|
|
|
cell1.setCellValue("类型"); |
|
|
|
|
HSSFCell cell2 = row.createCell(2); |
|
|
|
|
cell2.setCellValue("品牌"); |
|
|
|
|
cell2.setCellStyle(cellStyle1); |
|
|
|
|
HSSFCell cell3 = row.createCell(3); |
|
|
|
|
cell3.setCellValue("规格型号"); |
|
|
|
|
HSSFCell cell4 = row.createCell(4); |
|
|
|
|
cell4.setCellValue("批次"); |
|
|
|
|
HSSFCell cell5 = row.createCell(5); |
|
|
|
|
cell5.setCellValue("房间号"); |
|
|
|
|
HSSFCell cell6 = row.createCell(6); |
|
|
|
|
cell6.setCellValue("位置信息"); |
|
|
|
|
HSSFCell cell7 = row.createCell(7); |
|
|
|
|
cell7.setCellValue("入库时间"); |
|
|
|
|
HSSFCell cell8 = row.createCell(8); |
|
|
|
|
cell8.setCellValue("数量"); |
|
|
|
|
HSSFCell cell9 = row.createCell(9); |
|
|
|
|
cell9.setCellValue("实际房间"); |
|
|
|
|
HSSFCell cell10 = row.createCell(10); |
|
|
|
|
cell10.setCellValue("实际位置"); |
|
|
|
|
HSSFCell cell111 = row.createCell(11); |
|
|
|
|
cell111.setCellValue("实际数量"); |
|
|
|
|
HSSFCell cell12 = row.createCell(12); |
|
|
|
|
cell12.setCellValue("批次ID(请勿修改)"); |
|
|
|
|
|
|
|
|
|
cell0.setCellStyle(cellStyle1); |
|
|
|
|
cell1.setCellStyle(cellStyle1); |
|
|
|
|
cell2.setCellStyle(cellStyle1); |
|
|
|
|
cell3.setCellStyle(cellStyle1); |
|
|
|
|
cell4.setCellStyle(cellStyle1); |
|
|
|
|
cell5.setCellStyle(cellStyle1); |
|
|
|
|
cell6.setCellStyle(cellStyle1); |
|
|
|
|
cell7.setCellStyle(cellStyle1); |
|
|
|
|
cell8.setCellStyle(cellStyle1); |
|
|
|
|
cell9.setCellStyle(cellStyle1); |
|
|
|
|
cell10.setCellStyle(cellStyle1); |
|
|
|
|
cell111.setCellStyle(cellStyle1); |
|
|
|
|
cell12.setCellStyle(cellStyle1); |
|
|
|
|
|
|
|
|
|
int index = 2; |
|
|
|
|
for (ReagentConsumableInventoryFullVO reagentConsumableInventoryFullVO : reagentConsumableList) { |
|
|
|
|
HSSFRow row1 = workbookSheet.createRow(index); |
|
|
|
|
HSSFCell cell00 = row1.createCell(0); |
|
|
|
|
cell00.setCellStyle(cellStyle2); |
|
|
|
|
cell00.setCellValue(reagentConsumableInventoryFullVO.getReagentConsumableName()); |
|
|
|
|
HSSFCell cell11 = row1.createCell(1); |
|
|
|
|
cell11.setCellValue(reagentConsumableInventoryFullVO.getCategory()); |
|
|
|
|
HSSFCell cell22 = row1.createCell(2); |
|
|
|
|
cell22.setCellValue(reagentConsumableInventoryFullVO.getBrand()); |
|
|
|
|
HSSFCell cell33 = row1.createCell(3); |
|
|
|
|
cell33.setCellValue(reagentConsumableInventoryFullVO.getSpecificationAndModel()); |
|
|
|
|
HSSFCell cell44 = row1.createCell(4); |
|
|
|
|
cell44.setCellValue(reagentConsumableInventoryFullVO.getBatch()); |
|
|
|
|
HSSFCell cell55 = row1.createCell(5); |
|
|
|
|
cell55.setCellValue(reagentConsumableInventoryFullVO.getRoomNo()); |
|
|
|
|
HSSFCell cell66 = row1.createCell(6); |
|
|
|
|
String location = reagentConsumableInventoryFullVO.getLocation(); |
|
|
|
|
String substring = location.substring(location.length() - 4, location.length()); |
|
|
|
|
cell66.setCellValue(substring); |
|
|
|
|
HSSFCell cell77 = row1.createCell(7); |
|
|
|
|
cell77.setCellValue(LocalDateTimeUtil.format(reagentConsumableInventoryFullVO.getBatchPurchaseTime(), "yyyy-MM-dd")); |
|
|
|
|
HSSFCell cell88 = row1.createCell(8); |
|
|
|
|
cell88.setCellValue(reagentConsumableInventoryFullVO.getQuantity()); |
|
|
|
|
HSSFCell cell99 = row1.createCell(12); |
|
|
|
|
cell99.setCellValue(reagentConsumableInventoryFullVO.getBatchDetailsId()); |
|
|
|
|
index++; |
|
|
|
|
cell00.setCellStyle(cellStyle2); |
|
|
|
|
cell11.setCellStyle(cellStyle2); |
|
|
|
|
cell22.setCellStyle(cellStyle2); |
|
|
|
|
cell33.setCellStyle(cellStyle2); |
|
|
|
|
cell44.setCellStyle(cellStyle2); |
|
|
|
|
cell55.setCellStyle(cellStyle2); |
|
|
|
|
cell66.setCellStyle(cellStyle2); |
|
|
|
|
cell77.setCellStyle(cellStyle2); |
|
|
|
|
cell88.setCellStyle(cellStyle2); |
|
|
|
|
cell99.setCellStyle(cellStyle2); |
|
|
|
|
} |
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
String format = LocalDateTimeUtil.format(now, "yyyy-MM-dd"); |
|
|
|
|
String fileName = format + "试剂耗材库存表.xls"; |
|
|
|
|
FileOutputStream fileOutputStream = new FileOutputStream(Path + fileName); |
|
|
|
|
workbook.write(fileOutputStream); |
|
|
|
|
fileOutputStream.close(); |
|
|
|
|
File file = new File(Path + fileName); |
|
|
|
|
FileItem fileItem = this.getMultipartFile(file, file.getName()); |
|
|
|
|
MultipartFile multipartFile = new CommonsMultipartFile(fileItem); |
|
|
|
|
String ossPath = "document" + "/" + "reagentConsumableInventory"; |
|
|
|
|
boolean ret = ossFile.fileUpload(multipartFile, ossPath); |
|
|
|
|
if (ret) { |
|
|
|
|
Files.delete(Paths.get(Path + fileName)); |
|
|
|
|
return fileName; |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private FileItem getMultipartFile(File file, String fieldName) { |
|
|
|
|
FileItemFactory factory = new DiskFileItemFactory(16, null); |
|
|
|
|
FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName()); |
|
|
|
|
int bytesRead = 0; |
|
|
|
|
byte[] buffer = new byte[8192]; |
|
|
|
|
try { |
|
|
|
|
FileInputStream fis = new FileInputStream(file); |
|
|
|
|
OutputStream os = item.getOutputStream(); |
|
|
|
|
while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) { |
|
|
|
|
os.write(buffer, 0, bytesRead); |
|
|
|
|
} |
|
|
|
|
os.close(); |
|
|
|
|
fis.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
return item; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
@Override |
|
|
|
|
public boolean checkObj(List<ReagentConsumableInventoryFullVO> reagentConsumableInventoryFullVOList) { |
|
|
|
|
ArrayList<ReagentConsumableInventory> reagentConsumableInventoryArrayList = new ArrayList<>(); |
|
|
|
|
ArrayList<ReagentConsumableStash> reagentConsumableStashArrayList = new ArrayList<>(); |
|
|
|
|
ArrayList<BatchDetails> batchDetailsArrayList = new ArrayList<>(); |
|
|
|
|
int index = 1; |
|
|
|
|
|
|
|
|
|
long s = System.currentTimeMillis(); |
|
|
|
|
for (ReagentConsumableInventoryFullVO reagentConsumableInventoryFullVO : reagentConsumableInventoryFullVOList) { |
|
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
|
boolean loop = false; |
|
|
|
|
String practicalRoomNo = reagentConsumableInventoryFullVO.getPracticalRoomNo(); |
|
|
|
|
String practicalLocation = reagentConsumableInventoryFullVO.getPracticalLocation(); |
|
|
|
|
Integer practicalQuantity = reagentConsumableInventoryFullVO.getPracticalQuantity(); |
|
|
|
|
|
|
|
|
|
//若没修改,则无需操作数据库,下面的判断是为了减轻查询压力
|
|
|
|
|
if (practicalQuantity != null || StrUtil.isNotBlank(practicalLocation) || StrUtil.isNotBlank(practicalRoomNo)) { |
|
|
|
|
BatchDetails batchDetails = batchDetailsService.getById(reagentConsumableInventoryFullVO.getBatchDetailsId()); |
|
|
|
|
ReagentConsumableInventory reagentConsumableInventory = this.getById(batchDetails.getReagentConsumableInventoryId()); |
|
|
|
|
ReagentConsumableStash reagentConsumableStash = reagentConsumableStashService.getById(batchDetails.getReagentConsumableStashId()); |
|
|
|
|
|
|
|
|
|
if (practicalQuantity != null) {//修改数量
|
|
|
|
|
reagentConsumableInventory.setTotalQuantity(reagentConsumableInventory.getTotalQuantity() - batchDetails.getQuantity() + practicalQuantity); |
|
|
|
|
batchDetails.setQuantity(practicalQuantity); |
|
|
|
|
reagentConsumableStash.setTotalQuantity(practicalQuantity); |
|
|
|
|
if (practicalQuantity == 0) { |
|
|
|
|
batchDetails.setServiceStatus(-1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isNotBlank(practicalRoomNo)) { |
|
|
|
|
loop = true;//证明修改了位置,就要进行处理
|
|
|
|
|
} |
|
|
|
|
if (StrUtil.isNotBlank(practicalLocation)) { |
|
|
|
|
loop = true; |
|
|
|
|
} |
|
|
|
|
if (loop) { |
|
|
|
|
// String location = practicalLocation;
|
|
|
|
|
// String substring = location.substring(location.length() - 4, location.length());
|
|
|
|
|
//修改位置,需清除原有位置信息,且需同步试剂耗材仓库库存信息表
|
|
|
|
|
R<CabinetCell> cabinetCellR = remoteCabinetService.queryCellByRoomNoAndLocation(practicalRoomNo, practicalLocation); |
|
|
|
|
if (cabinetCellR == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有查询到你输入的房间与位置对应的柜子信息,是不是输错了呢?")); |
|
|
|
|
} |
|
|
|
|
CabinetCell cell = cabinetCellR.getData(); |
|
|
|
|
String cabinetId = cell.getCabinetId(); |
|
|
|
|
String cellName = baseMapper.getCellName(cabinetId); |
|
|
|
|
String latticeId = cell.getId(); |
|
|
|
|
String boxId = cell.getCabinetId(); |
|
|
|
|
batchDetails.setRoomNo(practicalRoomNo); |
|
|
|
|
reagentConsumableStash.setRoomNo(practicalRoomNo); |
|
|
|
|
this.updateCabinet(batchDetails.getLatticeId(), batchDetails.getReagentConsumableInventoryId(), -1);//清除原来位置信息
|
|
|
|
|
batchDetails.setLatticeId(latticeId); |
|
|
|
|
batchDetails.setBoxId(boxId); |
|
|
|
|
String newLocation = "F" + batchDetails.getRoomNo().charAt(0) + "-" + batchDetails.getRoomNo() + "_" + cellName + "_" + practicalLocation; |
|
|
|
|
batchDetails.setLocation(newLocation); |
|
|
|
|
this.updateCabinet(latticeId, batchDetails.getReagentConsumableInventoryId(), 1); |
|
|
|
|
} |
|
|
|
|
reagentConsumableInventoryArrayList.add(reagentConsumableInventory); |
|
|
|
|
batchDetailsArrayList.add(batchDetails); |
|
|
|
|
reagentConsumableStashArrayList.add(reagentConsumableStash); |
|
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
System.out.println("消耗了" + (end - start) + "毫秒,修改了第" + index + "个试剂耗材"); |
|
|
|
|
index++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (this.updateBatchById(reagentConsumableInventoryArrayList) && batchDetailsService.updateBatchById(batchDetailsArrayList) && reagentConsumableStashService.updateBatchById(reagentConsumableStashArrayList)) { |
|
|
|
|
long e = System.currentTimeMillis(); |
|
|
|
|
System.out.println("~~~~~~~~~~~~~~~~~消耗了" + (e - s) + "毫秒,共修改了" + index + "个试剂耗材"); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|