From d8c86797adaef6c416efae16586f350ae77bde4b Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期六, 12 九月 2026 12:43:08 +0800
Subject: [PATCH] feat: 库存入库/出库字段全链路、采购台账申请提交时间、储罐租客信息、油库储罐模块
---
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java | 162 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 141 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
index c6b32b4..0f70cfe 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -7,10 +7,18 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.alibaba.fastjson2.JSON;
+import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.mapper.CustomerMapper;
+import com.ruoyi.basic.mapper.OilDepotMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
+import com.ruoyi.basic.mapper.TankInfoMapper;
+import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.basic.pojo.OilDepot;
import com.ruoyi.basic.pojo.ProductModel;
+import com.ruoyi.basic.pojo.TankInfo;
+import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -30,7 +38,7 @@
import com.ruoyi.stock.service.StockOutRecordService;
import com.ruoyi.stock.service.StockUninventoryService;
import jakarta.servlet.http.HttpServletResponse;
-import lombok.AllArgsConstructor;
+import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -52,15 +60,20 @@
* @since 2026-01-21 04:16:36
*/
@Service
-@AllArgsConstructor
+@RequiredArgsConstructor
public class StockInventoryServiceImpl extends ServiceImpl<StockInventoryMapper, StockInventory> implements StockInventoryService {
- private StockInventoryMapper stockInventoryMapper;
- private StockInRecordService stockInRecordService;
- private StockOutRecordService stockOutRecordService;
- private StockUninventoryService stockUninventoryService;
- private SalesLedgerProductMapper salesLedgerProductMapper;
- private ProductModelMapper productModelMapper;
+ private final StockInventoryMapper stockInventoryMapper;
+ private final StockInRecordService stockInRecordService;
+ private final StockOutRecordService stockOutRecordService;
+ private final StockUninventoryService stockUninventoryService;
+ private final SalesLedgerProductMapper salesLedgerProductMapper;
+ private final ProductModelMapper productModelMapper;
+ private final OilDepotMapper oilDepotMapper;
+ private final TankInfoMapper tankInfoMapper;
+ private final CustomerMapper customerMapper;
+ private final FileUtil fileUtil;
+
@Override
public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) {
return stockInventoryMapper.pagestockInventory(page, stockInventoryDto);
@@ -105,9 +118,13 @@
newStockInventory.setBatchNo(stockInventoryDto.getBatchNo());
newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
- stockInventoryMapper.insert(newStockInventory);
- }else {
- stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
+ try {
+ stockInventoryMapper.insert(newStockInventory);
+ } catch (org.springframework.dao.DuplicateKeyException e) {
+ stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
+ }
+ } else {
+ stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
}
return true;
}
@@ -117,7 +134,7 @@
@Transactional(rollbackFor = Exception.class)
public Boolean subtractStockInventory(StockInventoryDto stockInventoryDto) {
LambdaQueryWrapper<StockInventory> eq = new QueryWrapper<StockInventory>().lambda()
- .eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId());
+ .eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId());
if (StringUtils.isEmpty(stockInventoryDto.getBatchNo())) {
eq.isNull(StockInventory::getBatchNo);
stockInventoryDto.setBatchNo(null);
@@ -168,6 +185,55 @@
stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
stockInRecordDto.setType("0");
stockInRecordDto.setRemark(stockInventoryDto.getRemark());
+ stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum());
+ stockInRecordDto.setOilDepotId(stockInventoryDto.getOilDepotId());
+ stockInRecordDto.setOilDepotName(stockInventoryDto.getOilDepotName());
+ stockInRecordDto.setInboundCategory(stockInventoryDto.getInboundCategory());
+ if (stockInventoryDto.getOilDepotId() != null && StringUtils.isEmpty(stockInRecordDto.getOilDepotName())) {
+ OilDepot oilDepot = oilDepotMapper.selectById(stockInventoryDto.getOilDepotId());
+ if (oilDepot != null) {
+ stockInRecordDto.setOilDepotName(oilDepot.getDepotName());
+ }
+ }
+ stockInRecordDto.setTankId(stockInventoryDto.getTankId());
+ stockInRecordDto.setTankNo(stockInventoryDto.getTankNo());
+ if (stockInventoryDto.getTankId() != null && StringUtils.isEmpty(stockInRecordDto.getTankNo())) {
+ TankInfo tankInfo = tankInfoMapper.selectById(stockInventoryDto.getTankId());
+ if (tankInfo != null) {
+ stockInRecordDto.setTankNo(tankInfo.getTankNo());
+ }
+ }
+ stockInRecordDto.setInboundTime(stockInventoryDto.getInboundTime());
+ stockInRecordDto.setOilProduct(stockInventoryDto.getOilProduct());
+ stockInRecordDto.setOriginalQuantity(stockInventoryDto.getOriginalQuantity());
+ stockInRecordDto.setCustomerId(stockInventoryDto.getCustomerId());
+ stockInRecordDto.setCustomerName(stockInventoryDto.getCustomerName());
+ stockInRecordDto.setContactPerson(stockInventoryDto.getContactPerson());
+ stockInRecordDto.setContactPhone(stockInventoryDto.getContactPhone());
+ stockInRecordDto.setDriverName(stockInventoryDto.getDriverName());
+ stockInRecordDto.setDriverPhone(stockInventoryDto.getDriverPhone());
+ stockInRecordDto.setEscortName(stockInventoryDto.getEscortName());
+ stockInRecordDto.setEscortPhone(stockInventoryDto.getEscortPhone());
+ stockInRecordDto.setTruckPlateNo(stockInventoryDto.getTruckPlateNo());
+ stockInRecordDto.setTrailerPlateNo(stockInventoryDto.getTrailerPlateNo());
+ stockInRecordDto.setTankInspectionStatus(stockInventoryDto.getTankInspectionStatus());
+ stockInRecordDto.setUnloadingCranePosition(stockInventoryDto.getUnloadingCranePosition());
+ stockInRecordDto.setDensity(stockInventoryDto.getDensity());
+ stockInRecordDto.setUnloadPhotos(stockInventoryDto.getUnloadPhotos() == null
+ ? null : JSON.toJSONString(stockInventoryDto.getUnloadPhotos()));
+ stockInRecordDto.setGrossWeight(stockInventoryDto.getGrossWeight());
+ stockInRecordDto.setTareWeight(stockInventoryDto.getTareWeight());
+ stockInRecordDto.setNetWeight(stockInventoryDto.getNetWeight());
+ stockInRecordDto.setLossQuantity(stockInventoryDto.getLossQuantity());
+ stockInRecordDto.setActualVolume(stockInventoryDto.getActualVolume());
+ stockInRecordDto.setPoundPhotos(stockInventoryDto.getPoundPhotos() == null
+ ? null : JSON.toJSONString(stockInventoryDto.getPoundPhotos()));
+ if (stockInventoryDto.getCustomerId() != null && StringUtils.isEmpty(stockInRecordDto.getCustomerName())) {
+ Customer customer = customerMapper.selectById(stockInventoryDto.getCustomerId());
+ if (customer != null) {
+ stockInRecordDto.setCustomerName(customer.getCustomerName());
+ }
+ }
stockInRecordService.add(stockInRecordDto);
return true;
}
@@ -337,7 +403,7 @@
}
stockInventoryDto.setProductModelId(matchedProduct.getProductModelId());
- this.addstockInventory(stockInventoryDto);
+ this.addStockInRecordOnly(stockInventoryDto);
successCount++;
}
@@ -345,7 +411,7 @@
if (dto.getUnQualifiedQuantity() != null && dto.getUnQualifiedQuantity().compareTo(BigDecimal.ZERO) > 0) {
StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
stockUninventoryDto.setRecordId(0L);
- stockUninventoryDto.setRecordType(StockInUnQualifiedRecordTypeEnum.CUSTOMIZATION_UNSTOCK_IN.getCode());
+ stockUninventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_UNSTOCK_IN.getCode());
stockUninventoryDto.setQualitity(dto.getUnQualifiedQuantity());
stockUninventoryDto.setRemark(dto.getRemark());
@@ -393,28 +459,28 @@
List<StockInventoryExportData> list = stockInventoryMapper.listStockInventoryExportData(stockInventoryDto);
ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class);
- util.exportExcel(response,list, "搴撳瓨淇℃伅");
+ util.exportExcel(response, list, "搴撳瓨淇℃伅");
}
@Override
public IPage<StockInRecordDto> stockInventoryPage(StockInventoryDto stockInventoryDto, Page page) {
- return stockInventoryMapper.stockInventoryPage(stockInventoryDto,page);
+ return stockInventoryMapper.stockInventoryPage(stockInventoryDto, page);
}
@Override
public IPage<StockInventoryDto> stockInAndOutRecord(StockInventoryDto stockInventoryDto, Page page) {
- return stockInventoryMapper.stockInAndOutRecord(stockInventoryDto,page);
+ return stockInventoryMapper.stockInAndOutRecord(stockInventoryDto, page);
}
@Override
public Boolean frozenStock(StockInventoryDto stockInventoryDto) {
StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId());
- if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity())<0) {
+ if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
throw new RuntimeException("鍐荤粨鏁伴噺涓嶈兘瓒呰繃搴撳瓨鏁伴噺");
}
if (ObjectUtils.isEmpty(stockInventory.getLockedQuantity())) {
stockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
- }else {
+ } else {
stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().add(stockInventoryDto.getLockedQuantity()));
}
return this.updateById(stockInventory);
@@ -423,10 +489,64 @@
@Override
public Boolean thawStock(StockInventoryDto stockInventoryDto) {
StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId());
- if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity())<0) {
+ if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
throw new RuntimeException("瑙e喕鏁伴噺涓嶈兘瓒呰繃鍐荤粨鏁伴噺");
}
stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().subtract(stockInventoryDto.getLockedQuantity()));
return this.updateById(stockInventory);
}
+
+ @Override
+ public List<StockInventory> getByModelId(Long modelId) {
+ return stockInventoryMapper.getByModelId(modelId);
+ }
+
+ @Override
+ public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) {
+ IPage<StockInventoryDto> result = stockInventoryMapper.getBatchNoQty(page, stockInventoryDto);
+ // 鐓х墖搴撻噷瀛樼殑鏄笂浼犳椂鐨勭鍚峌RL锛堥粯璁�2灏忔椂杩囨湡锛夛紝杩斿洖鍓嶉噸鏂扮鍙戯紝閬垮厤鍓嶇鍥剧墖鍔犺浇澶辫触
+ for (StockInventoryDto record : result.getRecords()) {
+ record.setUnloadPhotos(refreshPhotoUrls(record.getUnloadPhotos()));
+ record.setPoundPhotos(refreshPhotoUrls(record.getPoundPhotos()));
+ record.setLoadingPhotos(refreshPhotoUrls(record.getLoadingPhotos()));
+ record.setOutPoundPhotos(refreshPhotoUrls(record.getOutPoundPhotos()));
+ }
+ return result;
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Boolean addOilOutRecordOnly(StockOutRecordDto stockOutRecordDto) {
+ stockOutRecordDto.setStockOutNum(stockOutRecordDto.getOutTonnage());
+ stockOutRecordDto.setApprovalStatus(0);
+ return stockOutRecordService.add(stockOutRecordDto) > 0;
+ }
+
+ /**
+ * 閲嶆柊绛惧彂鐓х墖棰勮/涓嬭浇URL
+ */
+ private Object refreshPhotoUrls(Object photos) {
+ if (!(photos instanceof String)) {
+ return photos;
+ }
+ String json = (String) photos;
+ if (StringUtils.isEmpty(json)) {
+ return photos;
+ }
+ try {
+ List<StorageBlobVO> list = JSON.parseArray(json, StorageBlobVO.class);
+ if (list == null || list.isEmpty()) {
+ return photos;
+ }
+ for (StorageBlobVO vo : list) {
+ String previewUrl = fileUtil.buildSignedUrl(vo, "/preview/", null);
+ vo.setPreviewURL(previewUrl);
+ vo.setUrl(previewUrl);
+ vo.setDownloadURL(fileUtil.buildSignedUrl(vo, "/download/", null));
+ }
+ return JSON.toJSONString(list);
+ } catch (Exception e) {
+ return photos;
+ }
+ }
}
--
Gitblit v1.9.3