Commit 835ab1b5 by wangchunyang

统计相关功能

parent bdfed8f5
import request from '@/utils/request'
// 查询库存列表
export function listInventoryCount(query) {
return request({
url: '/inventory/inventory/listCount',
method: 'get',
params: query
})
}
// 查询库存列表
export function listInventory(query) {
return request({
url: '/inventory/inventory/list',
......@@ -65,7 +74,7 @@ export function listInventoryByMaterialId(params) {
url: '/inventory/inventory/listByMaterialId',
method: 'post',
// 改为data传递JSON对象,适配后端实体类接收
data: params
data: params
// 若后端仍要求用params(URL参数)传递,保留下面这行,注释上面的data
// params: params
})
......
......@@ -83,7 +83,6 @@
<div class="table-container">
<el-table v-loading="loading" :data="statisticsList" border height="100%">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column label="物料ID" align="center" prop="materialId" width="150" />
<el-table-column label="物料名称" align="center" prop="materialName" min-width="150" show-overflow-tooltip />
<el-table-column label="入库次数" align="center" prop="inboundCount" width="100" />
<el-table-column label="出库次数" align="center" prop="outboundCount" width="100" />
......@@ -200,7 +199,7 @@ export default {
params.endDate = params.dateRange[1]
}
delete params.dateRange
listInboundOutboundStatistics(params).then(response => {
this.statisticsList = response.rows || []
this.total = response.total || 0
......@@ -295,7 +294,7 @@ export default {
delete params.dateRange
delete params.pageNum
delete params.pageSize
this.download('inventory/statistics/inboundOutbound/export', {
...params
}, `出入库统计数据_${new Date().getTime()}.xlsx`)
......
package com.ruoyi.inventory.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.inventory.domain.vo.InboundOutboundStatisticsVO;
import com.ruoyi.inventory.service.IInventoryStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 出入库统计
*/
@RestController
@RequestMapping("/inventory/statistics")
public class InventoryStatisticsController extends BaseController {
@Autowired
private IInventoryStatisticsService inventoryStatisticsService;
/**
* 出入库统计列表
*/
@PreAuthorize("@ss.hasPermi('inventory:statistics:list')")
@GetMapping("/inboundOutbound")
public TableDataInfo list(InboundOutboundStatisticsVO query) {
startPage();
List<InboundOutboundStatisticsVO> list = inventoryStatisticsService.selectInboundOutboundStatistics(query);
return getDataTable(list);
}
/**
* 导出出入库统计
*/
@PreAuthorize("@ss.hasPermi('inventory:statistics:export')")
@Log(title = "出入库统计", businessType = BusinessType.EXPORT)
@PostMapping("/inboundOutbound/export")
public void export(HttpServletResponse response, InboundOutboundStatisticsVO query) {
List<InboundOutboundStatisticsVO> list = inventoryStatisticsService.selectInboundOutboundStatistics(query);
ExcelUtil<InboundOutboundStatisticsVO> util = new ExcelUtil<>(InboundOutboundStatisticsVO.class);
util.exportExcel(response, list, "出入库统计数据");
}
}
package com.ruoyi.inventory.domain;
import java.util.Date;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
......@@ -13,6 +16,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2025-12-03
*/
@Data
public class Inventory extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -112,243 +116,60 @@ public class Inventory extends BaseEntity
/** 预警类型 */
private String alertType;
public String getWarehousesId() {
return warehousesId;
}
public void setWarehousesId(String warehousesId) {
this.warehousesId = warehousesId;
}
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setInventoryType(Long inventoryType)
{
this.inventoryType = inventoryType;
}
public Long getInventoryType()
{
return inventoryType;
}
public void setOrderId(String orderId)
{
this.orderId = orderId;
}
public String getOrderId()
{
return orderId;
}
public void setMaterialId(String materialId)
{
this.materialId = materialId;
}
public String getMaterialId()
{
return materialId;
}
public void setBatchId(String batchId)
{
this.batchId = batchId;
}
public String getBatchId()
{
return batchId;
}
public void setLocationId(String locationId)
{
this.locationId = locationId;
}
public String getLocationId()
{
return locationId;
}
public void setOwnerId(String ownerId)
{
this.ownerId = ownerId;
}
public String getOwnerId()
{
return ownerId;
}
public void setQuantity(Long quantity)
{
this.quantity = quantity;
}
public Long getQuantity()
{
return quantity;
}
public void setLockedQuantity(Long lockedQuantity)
{
this.lockedQuantity = lockedQuantity;
}
public Long getLockedQuantity()
{
return lockedQuantity;
}
public void setUnitWeight(Long unitWeight)
{
this.unitWeight = unitWeight;
}
/** 物料名称 */
@ExcelProperty(value = "物料名称", index = 1)
private String materialName;
public Long getUnitWeight()
{
return unitWeight;
}
/** 最低库存 */
private Long minStockLevel;
/** 最高库存 */
private Long maxStockLevel;
public void setTotalWeight(Long totalWeight)
{
this.totalWeight = totalWeight;
}
/** SAP物料号 */
@Excel(name = "SAP物料号")
private String sapNo;
public Long getTotalWeight()
{
return totalWeight;
}
/** TS Code */
@Excel(name = "TS Code")
private String tsCode;
public void setTotalVolume(Long totalVolume)
{
this.totalVolume = totalVolume;
}
/** 危险类别 */
private String hazardId;
public Long getTotalVolume()
{
return totalVolume;
}
/** 危险类别 */
@Excel(name = "危险类别")
private String hazard;
public void setProductionDate(Date productionDate)
{
this.productionDate = productionDate;
}
/** 规格型号 */
@Excel(name = "规格型号")
private String specification;
public Date getProductionDate()
{
return productionDate;
}
/** 计量单位 */
@Excel(name = "计量单位")
private String materialUnit;
public void setExpirationDate(Date expirationDate)
{
this.expirationDate = expirationDate;
}
/** 包装重量 */
// @Excel(name = "包装重量")
private Double packageWeight;
public Date getExpirationDate()
{
return expirationDate;
}
/** 体积 */
private Double volume;
public void setInventoryStatus(Long inventoryStatus)
{
this.inventoryStatus = inventoryStatus;
}
/** 保质期天数 */
private Integer shelfLifeDays;
public Long getInventoryStatus()
{
return inventoryStatus;
}
public void setLastInboundTime(Date lastInboundTime)
{
this.lastInboundTime = lastInboundTime;
}
public Date getLastInboundTime()
{
return lastInboundTime;
}
/** 存储温度要求 */
// @Excel(name = "存储温度要求")
private String storageTemperature;
public void setLastOutboundTime(Date lastOutboundTime)
{
this.lastOutboundTime = lastOutboundTime;
}
/** 特殊存储要求 */
// @Excel(name = "特殊存储要求")
private String specialRequirements;
public Date getLastOutboundTime()
{
return lastOutboundTime;
}
private String warehousesName;
private String locationName;
private String ownerName;
public void setIsUsed(Long isUsed)
{
this.isUsed = isUsed;
}
public Long getIsUsed()
{
return isUsed;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
public void setWarehousesCode(String warehousesCode)
{
this.warehousesCode = warehousesCode;
}
public String getWarehousesCode()
{
return warehousesCode;
}
public void setAlertType(String alertType)
{
this.alertType = alertType;
}
public String getAlertType()
{
return alertType;
}
@Override
public String toString() {
......
package com.ruoyi.inventory.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 出入库统计视图对象
* 按物料汇总入库/出库次数、数量及金额
*/
@Data
public class InboundOutboundStatisticsVO extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 物料ID */
// @Excel(name = "物料ID")
private String materialId;
/** 物料名称 */
@Excel(name = "物料名称")
private String materialName;
/** 入库次数 */
@Excel(name = "入库次数")
private Integer inboundCount;
/** 出库次数 */
@Excel(name = "出库次数")
private Integer outboundCount;
/** 入库数量 */
@Excel(name = "入库数量")
private BigDecimal inboundQuantity;
/** 出库数量 */
@Excel(name = "出库数量")
private BigDecimal outboundQuantity;
/** 入库总额 */
@Excel(name = "入库总额")
private BigDecimal inboundAmount;
/** 出库总额 */
@Excel(name = "出库总额")
private BigDecimal outboundAmount;
/** 金额差(入库-出库) */
@Excel(name = "总额差")
private BigDecimal amountDiff;
/** 开始日期(主表日期过滤) */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startDate;
/** 结束日期(主表日期过滤) */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endDate;
/** 仓库ID */
private String warehouseId;
/** 仓库编码(支持模糊) */
private String warehousesCode;
/** 库位ID */
private String locationId;
/** 物料编码/ID查询 */
private String materialCode;
}
......@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
//import org.apache.poi.ss.usermodel.FillPatternType;
......@@ -32,176 +33,72 @@ public class InventorySummaryVO implements Serializable
@ExcelProperty(value = "物料名称", index = 1)
private String materialName;
/** 库存类别 */
@ExcelProperty(value = "库存类别", index = 2)
private String inventoryTypeName;
/** 最低库存 */
private Long minStockLevel;
/** 最高库存 */
private Long maxStockLevel;
/** 仓库编码 */
@ExcelProperty(value = "仓库编码", index = 3)
private String warehousesCode;
/** SAP物料号 */
@Excel(name = "SAP物料号")
private String sapNo;
/** 仓库名称 */
@ExcelProperty(value = "仓库名称", index = 4)
private String warehouseName;
/** TS Code */
@Excel(name = "TS Code")
private String tsCode;
/** 库位ID */
@ExcelProperty(value = "库位ID", index = 5)
private String locationId;
/** 危险类别 */
private String hazardId;
/** 库位名称 */
@ExcelProperty(value = "库位名称", index = 6)
private String locationName;
/** 危险类别 */
@Excel(name = "危险类别")
private String hazard;
/** 货主ID */
@ExcelProperty(value = "货主ID", index = 7)
private String ownerId;
/** 规格型号 */
@Excel(name = "规格型号")
private String specification;
/** 货主名称 */
@ExcelProperty(value = "货主名称", index = 8)
private String ownerName;
/** 计量单位 */
@Excel(name = "计量单位")
private String materialUnit;
/** 总库存数量 */
@ExcelProperty(value = "总库存数量", index = 9)
private Long totalQuantity;
/** 单位重量 */
@Excel(name = "单位重量")
private Double unitWeight;
/** 总锁定数量 */
@ExcelProperty(value = "总锁定数量", index = 10)
private Long totalLockedQuantity;
/** 总可用数量 */
@ExcelProperty(value = "总可用数量", index = 11)
private Long totalAvailableQuantity;
/** 包装重量 */
// @Excel(name = "包装重量")
private Double packageWeight;
/** 总重量 */
@ExcelProperty(value = "总重量", index = 12)
private Double totalWeight;
/** 总体积 */
@ExcelProperty(value = "总体积", index = 13)
private Double totalVolume;
/** 库存状态 */
@ExcelProperty(value = "库存状态", index = 14)
private String inventoryStatusName;
public String getMaterialId() {
return materialId;
}
public void setMaterialId(String materialId) {
this.materialId = materialId;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public String getInventoryTypeName() {
return inventoryTypeName;
}
public void setInventoryTypeName(String inventoryTypeName) {
this.inventoryTypeName = inventoryTypeName;
}
public String getWarehousesCode() {
return warehousesCode;
}
public void setWarehousesCode(String warehousesCode) {
this.warehousesCode = warehousesCode;
}
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
/** 体积 */
private Double volume;
public String getLocationId() {
return locationId;
}
/** 保质期天数 */
private Integer shelfLifeDays;
public void setLocationId(String locationId) {
this.locationId = locationId;
}
/** 存储温度要求 */
// @Excel(name = "存储温度要求")
private String storageTemperature;
public String getLocationName() {
return locationName;
}
/** 特殊存储要求 */
// @Excel(name = "特殊存储要求")
private String specialRequirements;
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public String getOwnerId() {
return ownerId;
}
public void setOwnerId(String ownerId) {
this.ownerId = ownerId;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public Long getTotalQuantity() {
return totalQuantity;
}
public void setTotalQuantity(Long totalQuantity) {
this.totalQuantity = totalQuantity;
}
public Long getTotalLockedQuantity() {
return totalLockedQuantity;
}
public void setTotalLockedQuantity(Long totalLockedQuantity) {
this.totalLockedQuantity = totalLockedQuantity;
}
public Long getTotalAvailableQuantity() {
return totalAvailableQuantity;
}
public void setTotalAvailableQuantity(Long totalAvailableQuantity) {
this.totalAvailableQuantity = totalAvailableQuantity;
}
public Double getTotalWeight() {
return totalWeight;
}
public void setTotalWeight(Double totalWeight) {
this.totalWeight = totalWeight;
}
/** 总库存数量 */
@ExcelProperty(value = "总库存数量", index = 9)
private Long totalQuantity;
public Double getTotalVolume() {
return totalVolume;
}
/** 总锁定数量 */
@ExcelProperty(value = "总锁定数量", index = 10)
private Long totalLockedQuantity;
public void setTotalVolume(Double totalVolume) {
this.totalVolume = totalVolume;
}
/** 总可用数量 */
@ExcelProperty(value = "总可用数量", index = 11)
private Long totalAvailableQuantity;
public String getInventoryStatusName() {
return inventoryStatusName;
}
private String alterType;
public void setInventoryStatusName(String inventoryStatusName) {
this.inventoryStatusName = inventoryStatusName;
}
}
package com.ruoyi.inventory.domain.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 库存对象 inventory
*
* @author cy
* @date 2025-12-03
*/
@Data
public class InventoryVo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 编号 */
private String id;
/** 库存类别1普通2退库 */
// @Excel(name = "库存类别")
private Long inventoryType;
/** 入库单号 */
// @Excel(name = "入库单号")
private String orderId;
/** 物料ID 检索条件 */
// @Excel(name = "物料ID 检索条件")
private String materialId;
/** SAP物料号 */
@Excel(name = "SAP物料号")
private String sapNo;
/** TS Code */
@Excel(name = "TS Code")
private String tsCode;
/** 物料名称 */
@Excel(name = "物料名称")
private String materialName;
/** 批次ID 检索条件 */
@Excel(name = "批次")
private String batchId;
/** 批次ID 检索条件 */
// @Excel(name = "仓库ID ")
private String warehousesId;
/** 仓库编码 检索条件 */
private String warehousesCode;
@Excel(name = "仓库 ")
private String warehousesName;
/** 库位ID 检索条件 */
private String locationId;
@Excel(name = "库位")
private String locationName;
@Excel(name = "货主")
private String ownerName;
/** 货主ID 检索条件 */
private String ownerId;
/** 库存数量 */
@Excel(name = "库存数量")
private Long quantity;
/** 锁定数量 */
@Excel(name = "锁定数量")
private Long lockedQuantity;
/** 单位重量 */
// @Excel(name = "单位重量")
private Long unitWeight;
/** 总重量 暂无用 */
// @Excel(name = "总重量")
private Long totalWeight;
/** 总体积 暂无用 */
// @Excel(name = "总体积")
private Long totalVolume;
/** 生产日期 暂无用 */
// @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生产日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date productionDate;
/** 失效日期 */
// @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "失效日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date expirationDate;
/** 库存状态 0-已出库 1-正常 字典,检索条件 */
// @Excel(name = "库存状态 0-已出库 1-正常 字典,检索条件")
private Long inventoryStatus;
/** 最后入库时间 */
// @JsonFormat(pattern = "yyyy-MM-dd")
// @Excel(name = "最后入库时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastInboundTime;
/** 最后出库时间 */
// @JsonFormat(pattern = "yyyy-MM-dd")
// @Excel(name = "最后出库时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date lastOutboundTime;
/** 应用数据1使用0删除 删除用 */
private Long isUsed;
/** 排序 */
private Long sortNo;
/** 创建日期 */
private String createUserCode;
/** 排序号 */
private String updateUserCode;
/** 预警类型 */
private String alertType;
/** 最低库存 */
private Long minStockLevel;
/** 最高库存 */
private Long maxStockLevel;
/** 危险类别 */
private String hazardId;
/** 危险类别 */
// @Excel(name = "危险类别")
private String hazard;
/** 规格型号 */
// @Excel(name = "规格型号")
private String specification;
/** 计量单位 */
// @Excel(name = "计量单位")
private String materialUnit;
/** 包装重量 */
// @Excel(name = "包装重量")
private Double packageWeight;
/** 体积 */
private Double volume;
/** 保质期天数 */
private Integer shelfLifeDays;
/** 存储温度要求 */
// @Excel(name = "存储温度要求")
private String storageTemperature;
/** 特殊存储要求 */
// @Excel(name = "特殊存储要求")
private String specialRequirements;
}
package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.inventory.domain.Inventory;
import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakeItemsTo;
import com.ruoyi.inventory.domain.vo.InventoryExceedWarnVO;
import com.ruoyi.inventory.domain.vo.InventoryVo;
import java.util.List;
/**
* 库存Mapper接口
......@@ -100,6 +100,14 @@ public interface InventoryMapper
public List<Inventory> selectInventoryDetailList(Inventory inventory);
/**
* 查询库存明细列表(根据物料标识及检索条件)
*
* @param inventory 库存查询条件
* @return 库存明细集合
*/
public List<InventoryVo> selectInventoryVoList(Inventory inventory);
/**
* 统计物料库存超出预警库存数量
*
* @return 超出预警值物料信息集合
......
package com.ruoyi.inventory.mapper;
import com.ruoyi.inventory.domain.vo.InboundOutboundStatisticsVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 出入库统计Mapper
*/
@Mapper
public interface InventoryStatisticsMapper {
/**
* 按物料汇总出入库统计
*
* @param query 查询条件
* @return 汇总结果
*/
List<InboundOutboundStatisticsVO> selectInboundOutboundStatistics(InboundOutboundStatisticsVO query);
}
......@@ -97,4 +97,13 @@ public interface StorageLocationsMapper
* @return 库位集合
*/
List<StorageLocations> getStorageLocationsList(StorageLocations storageLocations);
/**
* 根据库位名称和仓库ID精确查询(is_used=1)
* @param locationName 库位名
* @param warehouseId 仓库ID
* @return 库位
*/
StorageLocations selectStorageLocationsByNameAndWarehouse(@Param("locationName") String locationName,
@Param("warehouseId") String warehouseId);
}
......@@ -79,4 +79,11 @@ public interface WarehousesMapper
*/
public List<Map<String, Object>> getMapList();
/**
* 根据仓库名称精确查询(仅is_used=1)
* @param name 仓库名称
* @return 仓库
*/
Warehouses selectWarehousesByName(String name);
}
......@@ -10,6 +10,7 @@ import com.ruoyi.inventory.domain.OutboundOrderItems;
import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakeItemsTo;
import com.ruoyi.inventory.domain.vo.InventoryExceedWarnVO;
import com.ruoyi.inventory.domain.vo.InventoryVo;
/**
* 库存Service接口
......@@ -109,6 +110,7 @@ public interface IInventoryService
*/
public List<Inventory> selectInventoryDetailList(Inventory inventory);
public List<InventoryVo> selectInventoryVoList(Inventory inventory);
/**
* 统计库存物料超出预警值
......
package com.ruoyi.inventory.service;
import com.ruoyi.inventory.domain.vo.InboundOutboundStatisticsVO;
import java.util.List;
/**
* 出入库统计 Service
*/
public interface IInventoryStatisticsService {
/**
* 按物料汇总出入库统计
*
* @param query 查询条件
* @return 统计列表
*/
List<InboundOutboundStatisticsVO> selectInboundOutboundStatistics(InboundOutboundStatisticsVO query);
}
......@@ -11,6 +11,7 @@ import com.ruoyi.inventory.domain.OutboundOrderLog;
import com.ruoyi.inventory.domain.TO.StocktakeItemsTo;
import com.ruoyi.inventory.domain.vo.InventoryExceedWarnVO;
import com.ruoyi.inventory.domain.vo.InventorySummaryVO;
import com.ruoyi.inventory.domain.vo.InventoryVo;
import com.ruoyi.inventory.mapper.OutboundOrderItemsMapper;
import com.ruoyi.inventory.mapper.OutboundOrderLogMapper;
import org.apache.commons.collections4.CollectionUtils;
......@@ -268,6 +269,12 @@ public class InventoryServiceImpl implements IInventoryService
}
@Override
public List<InventoryVo> selectInventoryVoList(Inventory inventory)
{
return inventoryMapper.selectInventoryVoList(inventory);
}
@Override
public List<InventoryExceedWarnVO> selectInventoryExceedWarnList() {
return inventoryMapper.selectInventoryExceedWarnList();
}
......
package com.ruoyi.inventory.service.impl;
import com.ruoyi.inventory.domain.vo.InboundOutboundStatisticsVO;
import com.ruoyi.inventory.mapper.InventoryStatisticsMapper;
import com.ruoyi.inventory.service.IInventoryStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出入库统计 Service实现
*/
@Service
public class InventoryStatisticsServiceImpl implements IInventoryStatisticsService {
@Autowired
private InventoryStatisticsMapper inventoryStatisticsMapper;
@Override
public List<InboundOutboundStatisticsVO> selectInboundOutboundStatistics(InboundOutboundStatisticsVO query) {
return inventoryStatisticsMapper.selectInboundOutboundStatistics(query);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.inventory.mapper.InventoryStatisticsMapper">
<resultMap id="InboundOutboundStatisticsResult" type="com.ruoyi.inventory.domain.vo.InboundOutboundStatisticsVO">
<result column="material_id" property="materialId"/>
<result column="material_name" property="materialName"/>
<result column="inbound_count" property="inboundCount"/>
<result column="outbound_count" property="outboundCount"/>
<result column="inbound_quantity" property="inboundQuantity"/>
<result column="outbound_quantity" property="outboundQuantity"/>
<result column="inbound_amount" property="inboundAmount"/>
<result column="outbound_amount" property="outboundAmount"/>
<result column="amount_diff" property="amountDiff"/>
</resultMap>
<select id="selectInboundOutboundStatistics"
parameterType="com.ruoyi.inventory.domain.vo.InboundOutboundStatisticsVO"
resultMap="InboundOutboundStatisticsResult">
SELECT
t.material_id,
IFNULL(m.material_name, t.material_id) AS material_name,
SUM(t.inbound_count) AS inbound_count,
SUM(t.outbound_count) AS outbound_count,
SUM(t.inbound_quantity) AS inbound_quantity,
SUM(t.outbound_quantity) AS outbound_quantity,
SUM(t.inbound_amount) AS inbound_amount,
SUM(t.outbound_amount) AS outbound_amount,
SUM(t.inbound_amount) - SUM(t.outbound_amount) AS amount_diff
FROM (
SELECT
i.material_id,
COUNT(DISTINCT o.id) AS inbound_count,
0 AS outbound_count,
IFNULL(SUM(IFNULL(i.actual_quantity, 0)),0) AS inbound_quantity,
0 AS outbound_quantity,
IFNULL(SUM(IFNULL(i.unit_price, 0) * IFNULL(i.actual_quantity, 0)),0) AS inbound_amount,
0 AS outbound_amount
FROM inbound_order_items i
LEFT JOIN inbound_orders o ON i.inbound_order_id = o.id
LEFT JOIN warehouses w ON w.id = i.warehouse_id
LEFT JOIN materials m1 ON m1.id = i.material_id
<where>
i.is_used = 1
<if test="warehouseId != null and warehouseId != ''">
AND i.warehouse_id = #{warehouseId}
</if>
<if test="locationId != null and locationId != ''">
AND i.location_id = #{locationId}
</if>
<if test="materialId != null and materialId != ''">
AND (i.material_id = #{materialId}
OR m1.material_code LIKE CONCAT('%', #{materialId}, '%')
OR m1.material_name LIKE CONCAT('%', #{materialId}, '%'))
</if>
<if test="warehousesCode != null and warehousesCode != ''">
AND w.warehouses_code LIKE CONCAT('%', #{warehousesCode}, '%')
</if>
<if test="startDate != null">
AND o.inbound_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND o.inbound_date &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
</where>
GROUP BY i.material_id
UNION ALL
SELECT
oi.material_id,
0 AS inbound_count,
COUNT(DISTINCT oo.id) AS outbound_count,
0 AS inbound_quantity,
IFNULL(SUM(IFNULL(oi.actual_quantity, 0)),0) AS outbound_quantity,
0 AS inbound_amount,
IFNULL(SUM(IFNULL(oi.unit_price, 0) * IFNULL(oi.actual_quantity, 0)),0) AS outbound_amount
FROM outbound_order_items oi
LEFT JOIN outbound_orders oo ON oi.outbound_order_id = oo.id
LEFT JOIN warehouses w2 ON w2.id = oi.warehouse_id
LEFT JOIN materials m2 ON m2.id = oi.material_id
<where>
oi.is_used = 1
<if test="warehouseId != null and warehouseId != ''">
AND oi.warehouse_id = #{warehouseId}
</if>
<if test="locationId != null and locationId != ''">
AND oi.location_id = #{locationId}
</if>
<if test="materialId != null and materialId != ''">
AND (oi.material_id = #{materialId}
OR m2.material_code LIKE CONCAT('%', #{materialId}, '%')
OR m2.material_name LIKE CONCAT('%', #{materialId}, '%'))
</if>
<if test="warehousesCode != null and warehousesCode != ''">
AND w2.warehouses_code LIKE CONCAT('%', #{warehousesCode}, '%')
</if>
<if test="startDate != null">
AND oo.inbound_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND oo.inbound_date &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
</where>
GROUP BY oi.material_id
) t
LEFT JOIN materials m ON t.material_id = m.id
GROUP BY t.material_id, m.material_name
ORDER BY m.material_name ASC
</select>
</mapper>
......@@ -107,6 +107,19 @@
where sl.id = #{id}
</select>
<select id="selectStorageLocationsByNameAndWarehouse" resultMap="StorageLocationsResult">
select sl.id, sl.location_code, sl.location_name, sl.warehouses_code, sl.location_type,
sl.zone_code, sl.row_code, sl.column_code, sl.layer_code, sl.capacity,
sl.volume_capacity, sl.allowed_hazard_levels, sl.allowed_category_ids,
sl.temperature_zone, sl.is_enabled, sl.is_used, sl.sort_no,
sl.create_time, sl.create_user_code, sl.update_time, sl.update_user_code, sl.warehouses_id
from storage_locations sl
where sl.is_used = 1
and sl.location_name = #{locationName}
and sl.warehouses_id = #{warehouseId}
limit 1
</select>
<!-- 关联仓库表的ID查询 -->
<select id="selectStorageLocationsByIdWithWarehouses" parameterType="String" resultMap="StorageLocationsWithWarehousesResult">
select sl.id, sl.location_code, sl.location_name, sl.warehouses_code, sl.location_type,
......
......@@ -50,6 +50,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectWarehousesVo"/>
where id = #{id}
</select>
<select id="selectWarehousesByName" parameterType="String" resultMap="WarehousesResult">
<include refid="selectWarehousesVo"/>
where warehouses_name = #{name} and is_used = 1
limit 1
</select>
<!-- 获取仓库 的 warehouses_code 仓库编码 warehouses_name 做成字典-->
<select id="getMapList" resultType="java.util.Map">
select id, IFNULL(warehouses_name, '') as warehouses_name from warehouses where is_used = 1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论