导出优化
This commit is contained in:
parent
4a646654cd
commit
36b559c7e8
|
|
@ -21,6 +21,11 @@
|
||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-system</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>mybatis-plus-api</artifactId>
|
<artifactId>mybatis-plus-api</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.cyl.wms.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.cyl.wms.pojo.vo.PlaceAndItem;
|
import com.cyl.wms.pojo.vo.PlaceAndItem;
|
||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|
@ -50,4 +51,16 @@ public class Inventory extends BaseAudit implements PlaceAndItem {
|
||||||
@ApiModelProperty("删除标识")
|
@ApiModelProperty("删除标识")
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String itemNo;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String itemName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String warehouseName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String areaName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,17 +22,19 @@ public class InventoryHistoryVO extends BaseAudit implements AreaAndItemInfo {
|
||||||
/**
|
/**
|
||||||
* 操作id(出库、入库、库存移动表单id)
|
* 操作id(出库、入库、库存移动表单id)
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作id" , readConverterExp = "出库、入库、库存移动表单id" )
|
|
||||||
private Long formId;
|
private Long formId;
|
||||||
/**
|
/**
|
||||||
* 操作类型
|
* 操作类型
|
||||||
*/
|
*/
|
||||||
@Excel(name = "操作类型", handler = DictDealHandler.class, args = {"wms_receipt_type", "wms_shipment_type", "wms_movement_type"})
|
|
||||||
private Integer formType;
|
private Integer formType;
|
||||||
|
/**
|
||||||
|
* 操作类型名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "操作类型")
|
||||||
|
private String formTypeName;
|
||||||
/**
|
/**
|
||||||
* 物料ID
|
* 物料ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "物料ID" )
|
|
||||||
private Long itemId;
|
private Long itemId;
|
||||||
@Excel(name = "物料名称" )
|
@Excel(name = "物料名称" )
|
||||||
private String itemName;
|
private String itemName;
|
||||||
|
|
@ -41,15 +43,11 @@ public class InventoryHistoryVO extends BaseAudit implements AreaAndItemInfo {
|
||||||
/**
|
/**
|
||||||
* 货架id
|
* 货架id
|
||||||
*/
|
*/
|
||||||
@Excel(name = "货架id" )
|
|
||||||
private Long rackId;
|
private Long rackId;
|
||||||
@Excel(name = "货架名称" )
|
|
||||||
private String rackName;
|
private String rackName;
|
||||||
@Excel(name = "仓库id" )
|
|
||||||
private Long warehouseId;
|
private Long warehouseId;
|
||||||
@Excel(name = "仓库名称" )
|
@Excel(name = "仓库名称" )
|
||||||
private String warehouseName;
|
private String warehouseName;
|
||||||
@Excel(name = "库区id" )
|
|
||||||
private Long areaId;
|
private Long areaId;
|
||||||
|
|
||||||
@Excel(name = "库区名称" )
|
@Excel(name = "库区名称" )
|
||||||
|
|
|
||||||
|
|
@ -15,25 +15,24 @@ public class InventoryVO extends BaseAudit implements AreaAndItemInfo {
|
||||||
/** ID */
|
/** ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
/** 物料ID */
|
/** 物料ID */
|
||||||
@Excel(name = "物料ID")
|
|
||||||
private Long itemId;
|
private Long itemId;
|
||||||
// 物料名称
|
|
||||||
private String itemName;
|
|
||||||
// 物料编号
|
// 物料编号
|
||||||
|
@Excel(name = "物料编码")
|
||||||
private String itemNo;
|
private String itemNo;
|
||||||
|
// 物料名称
|
||||||
|
@Excel(name = "物料名称")
|
||||||
|
private String itemName;
|
||||||
/** 货架id */
|
/** 货架id */
|
||||||
@Excel(name = "货架id")
|
|
||||||
private Long rackId;
|
private Long rackId;
|
||||||
// 货架 名称
|
// 货架 名称
|
||||||
private String rackName;
|
private String rackName;
|
||||||
@Excel(name = "仓库id")
|
|
||||||
private Long warehouseId;
|
private Long warehouseId;
|
||||||
// 仓库 名称
|
// 仓库 名称
|
||||||
|
@Excel(name = "仓库")
|
||||||
private String warehouseName;
|
private String warehouseName;
|
||||||
@Excel(name = "库区id")
|
|
||||||
private Long areaId;
|
private Long areaId;
|
||||||
// 库区 名称
|
// 库区 名称
|
||||||
|
@Excel(name = "库区")
|
||||||
private String areaName;
|
private String areaName;
|
||||||
/** 库存 */
|
/** 库存 */
|
||||||
@Excel(name = "库存")
|
@Excel(name = "库存")
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ public class InventoryHistoryService {
|
||||||
List<InventoryHistory> list = queryInventoryHistories(query);
|
List<InventoryHistory> list = queryInventoryHistories(query);
|
||||||
List<InventoryHistoryVO> res = inventoryHistoryConvert.dos2vos(list);
|
List<InventoryHistoryVO> res = inventoryHistoryConvert.dos2vos(list);
|
||||||
inventoryService.injectAreaAndItemInfo(res);
|
inventoryService.injectAreaAndItemInfo(res);
|
||||||
|
inventoryService.injectDictDataLabel(res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,15 @@ import com.cyl.wms.domain.*;
|
||||||
import com.cyl.wms.mapper.InventoryMapper;
|
import com.cyl.wms.mapper.InventoryMapper;
|
||||||
import com.cyl.wms.pojo.query.InventoryQuery;
|
import com.cyl.wms.pojo.query.InventoryQuery;
|
||||||
import com.cyl.wms.pojo.vo.AreaAndItemInfo;
|
import com.cyl.wms.pojo.vo.AreaAndItemInfo;
|
||||||
|
import com.cyl.wms.pojo.vo.InventoryHistoryVO;
|
||||||
import com.cyl.wms.pojo.vo.InventoryVO;
|
import com.cyl.wms.pojo.vo.InventoryVO;
|
||||||
import com.cyl.wms.pojo.vo.PlaceAndItem;
|
import com.cyl.wms.pojo.vo.PlaceAndItem;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.ruoyi.common.constant.CommonConstant;
|
import com.ruoyi.common.constant.CommonConstant;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.SortUtil;
|
import com.ruoyi.common.utils.SortUtil;
|
||||||
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Example;
|
import org.springframework.data.domain.Example;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
@ -45,6 +48,8 @@ public class InventoryService {
|
||||||
private RackService rackService;
|
private RackService rackService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ItemService itemService;
|
private ItemService itemService;
|
||||||
|
@Autowired
|
||||||
|
private ISysDictDataService sysDictDataService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询库存
|
* 查询库存
|
||||||
|
|
@ -89,7 +94,7 @@ public class InventoryService {
|
||||||
if (query.getQuantityEnd() != null) {
|
if (query.getQuantityEnd() != null) {
|
||||||
qw.le("quantity" , query.getQuantityEnd());
|
qw.le("quantity" , query.getQuantityEnd());
|
||||||
}
|
}
|
||||||
return inventoryMapper.selectList(qw);
|
return getInventoryList(qw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -144,6 +149,14 @@ public class InventoryService {
|
||||||
return inventoryMapper.updateDelFlagByIds(ids);
|
return inventoryMapper.updateDelFlagByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Inventory> getInventoryList(QueryWrapper<Inventory> qw){
|
||||||
|
List<Inventory> items = inventoryMapper.selectList(qw);
|
||||||
|
injectItemNoAndItemName(items);
|
||||||
|
injectWarehouseName(items);
|
||||||
|
injectAreaName(items);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canOutStock(Long itemId, Long warehouseId, Long areaId, Long rackId, BigDecimal quantity) {
|
public boolean canOutStock(Long itemId, Long warehouseId, Long areaId, Long rackId, BigDecimal quantity) {
|
||||||
QueryWrapper<Inventory> qw = new QueryWrapper<>();
|
QueryWrapper<Inventory> qw = new QueryWrapper<>();
|
||||||
qw.eq("item_id" , itemId)
|
qw.eq("item_id" , itemId)
|
||||||
|
|
@ -334,4 +347,71 @@ public class InventoryService {
|
||||||
injectAreaAndItemInfo(res);
|
injectAreaAndItemInfo(res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入物料编码和名称
|
||||||
|
*
|
||||||
|
* @param res 物料
|
||||||
|
*/
|
||||||
|
public void injectItemNoAndItemName(List<Inventory> res) {
|
||||||
|
if (CollUtil.isEmpty(res)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Long> items = res.stream().map(Inventory::getItemId).collect(Collectors.toSet());
|
||||||
|
Map<Long, Item> itemMap = itemService.selectByIdIn(items).stream().collect(Collectors.toMap(Item::getId, it -> it));
|
||||||
|
res.forEach(it -> {
|
||||||
|
if (it.getItemId() != null && itemMap.containsKey(it.getItemId())) {
|
||||||
|
it.setItemNo(itemMap.get(it.getItemId()).getItemNo());
|
||||||
|
it.setItemName(itemMap.get(it.getItemId()).getItemName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入仓库名称
|
||||||
|
* @param res 物料
|
||||||
|
*/
|
||||||
|
public void injectWarehouseName(List<Inventory> res){
|
||||||
|
if (CollUtil.isEmpty(res)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Long> warehouses = res.stream().map(Inventory::getWarehouseId).collect(Collectors.toSet());
|
||||||
|
Map<Long, Warehouse> warehouseMap = warehouseService.selectByIdIn(warehouses).stream().collect(Collectors.toMap(Warehouse::getId, it -> it));
|
||||||
|
res.forEach(it -> {
|
||||||
|
if (it.getWarehouseId() != null && warehouseMap.containsKey(it.getWarehouseId())){
|
||||||
|
it.setWarehouseName(warehouseMap.get(it.getWarehouseId()).getWarehouseName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入库区名称
|
||||||
|
* @param res 物料
|
||||||
|
*/
|
||||||
|
public void injectAreaName(List<Inventory> res){
|
||||||
|
if (CollUtil.isEmpty(res)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Long> areas = res.stream().map(Inventory::getAreaId).collect(Collectors.toSet());
|
||||||
|
Map<Long, Area> areaMap = areaService.selectByIdIn(areas).stream().collect(Collectors.toMap(Area::getId, it -> it));
|
||||||
|
res.forEach(it -> {
|
||||||
|
if (it.getAreaId() != null && areaMap.containsKey(it.getAreaId())){
|
||||||
|
it.setAreaName(areaMap.get(it.getAreaId()).getAreaName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void injectDictDataLabel(List<InventoryHistoryVO> res){
|
||||||
|
if (CollUtil.isEmpty(res)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<String> dictTypes = new HashSet<>();
|
||||||
|
dictTypes.add("wms_inventory_oper_type");
|
||||||
|
Map<String, SysDictData> sysDictDataMap = sysDictDataService.selectDictDataByTypes(dictTypes).stream().collect(Collectors.toMap(SysDictData::getDictValue, it -> it));
|
||||||
|
res.forEach(it -> {
|
||||||
|
if (it.getFormType() != null && sysDictDataMap.containsKey(String.valueOf(it.getFormType()))){
|
||||||
|
it.setFormTypeName(sysDictDataMap.get(String.valueOf(it.getFormType())).getDictLabel());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue