| | |
| | | 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.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | 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) { |
| | |
| | | newStockInventory.setBatchNo(stockInventoryDto.getBatchNo()); |
| | | newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity()); |
| | | newStockInventory.setWarnNum(stockInventoryDto.getWarnNum()); |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | try { |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | } catch (org.springframework.dao.DuplicateKeyException e) { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } |
| | | } else { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | IPage<StockInventoryDto> result = stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | // 照片库里存的是上传时的签名URL(默认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; |
| | | } |
| | | } |
| | | } |