物料管理导出优化
This commit is contained in:
parent
2ca013d71a
commit
4a646654cd
|
|
@ -9,6 +9,8 @@ import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
@ -821,6 +823,9 @@ public class ExcelUtil<T>
|
||||||
String dictType = attr.dictType();
|
String dictType = attr.dictType();
|
||||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
|
if (value instanceof LocalDateTime){
|
||||||
|
value = Date.from(((LocalDateTime) value).atZone(ZoneId.systemDefault()).toInstant());
|
||||||
|
}
|
||||||
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,10 @@ public class Item extends BaseAudit {
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String itemTypeName;
|
private String itemTypeName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String warehouseName;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String areaName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ public class ItemVO extends BaseAudit {
|
||||||
@Excel(name = "名称")
|
@Excel(name = "名称")
|
||||||
private String itemName;
|
private String itemName;
|
||||||
/** 分类 */
|
/** 分类 */
|
||||||
@Excel(name = "分类")
|
|
||||||
private String itemType;
|
private String itemType;
|
||||||
/**
|
/**
|
||||||
* 所属类别
|
* 所属类别
|
||||||
|
|
@ -36,13 +35,16 @@ public class ItemVO extends BaseAudit {
|
||||||
@Excel(name = "单位类别")
|
@Excel(name = "单位类别")
|
||||||
private String unit;
|
private String unit;
|
||||||
/** 所属货架 */
|
/** 所属货架 */
|
||||||
@Excel(name = "所属货架")
|
|
||||||
private Long rackId;
|
private Long rackId;
|
||||||
/** 所属库区 */
|
/** 所属库区 */
|
||||||
@Excel(name = "所属库区")
|
|
||||||
private Long areaId;
|
private Long areaId;
|
||||||
/** 所属仓库 */
|
/** 所属仓库名称 */
|
||||||
@Excel(name = "所属仓库")
|
@Excel(name = "所属仓库")
|
||||||
|
private String warehouseName;
|
||||||
|
/** 所属库区名称 */
|
||||||
|
@Excel(name = "所属库区")
|
||||||
|
private String areaName;
|
||||||
|
/** 所属仓库 */
|
||||||
private Long warehouseId;
|
private Long warehouseId;
|
||||||
/** 安全库存 */
|
/** 安全库存 */
|
||||||
@Excel(name = "安全库存")
|
@Excel(name = "安全库存")
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.cyl.wms.convert.ItemConvert;
|
import com.cyl.wms.convert.ItemConvert;
|
||||||
import com.cyl.wms.domain.Item;
|
import com.cyl.wms.domain.*;
|
||||||
import com.cyl.wms.domain.ItemType;
|
|
||||||
import com.cyl.wms.domain.Rack;
|
|
||||||
import com.cyl.wms.mapper.ItemMapper;
|
import com.cyl.wms.mapper.ItemMapper;
|
||||||
import com.cyl.wms.pojo.query.ItemQuery;
|
import com.cyl.wms.pojo.query.ItemQuery;
|
||||||
import com.cyl.wms.pojo.vo.ItemVO;
|
import com.cyl.wms.pojo.vo.ItemVO;
|
||||||
|
|
@ -37,6 +35,10 @@ public class ItemService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ItemTypeService itemTypeService;
|
private ItemTypeService itemTypeService;
|
||||||
|
@Autowired
|
||||||
|
private WarehouseService warehouseService;
|
||||||
|
@Autowired
|
||||||
|
private AreaService areaService;
|
||||||
|
|
||||||
public List<ItemVO> toVos(List<Item> items) {
|
public List<ItemVO> toVos(List<Item> items) {
|
||||||
List<ItemVO> list = convert.dos2vos(items);
|
List<ItemVO> list = convert.dos2vos(items);
|
||||||
|
|
@ -210,6 +212,8 @@ public class ItemService {
|
||||||
private List<Item> getItemList(QueryWrapper<Item> qw) {
|
private List<Item> getItemList(QueryWrapper<Item> qw) {
|
||||||
List<Item> items = itemMapper.selectList(qw);
|
List<Item> items = itemMapper.selectList(qw);
|
||||||
injectTypeName(items);
|
injectTypeName(items);
|
||||||
|
injectWarehouseName(items);
|
||||||
|
injectAreaName(items);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,6 +235,40 @@ public class ItemService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入仓库名称
|
||||||
|
* @param res 物料
|
||||||
|
*/
|
||||||
|
public void injectWarehouseName(List<Item> res){
|
||||||
|
if (CollUtil.isEmpty(res)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Long> warehouses = res.stream().map(Item::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<Item> res){
|
||||||
|
if (CollUtil.isEmpty(res)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Long> areas = res.stream().map(Item::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());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询过期物料
|
* 查询过期物料
|
||||||
* @param page 分页条件
|
* @param page 分页条件
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue