@PreAuthorize("@ss.hasPermi('manage:material:export')")
@Log(title = "下料管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Material material) {
List<Material> list = materialService.selectMaterialList(material);
List<Material> resultList = new ArrayList<>(); // 创建用于存储查询结果的集合
for (Material item : list) {
Material result = materialService.selectMaterialByMaterialId(item.getMaterialId());
if (result != null) {
// 根据id查询子表数据
List<IotMaterialColors> iotMaterialColors = materialService.selectIotMaterialColorsByMaterialId(item.getMaterialId());
result.setIotMaterialColorsList(iotMaterialColors);
resultList.add(result); // 将处理后的对象添加到结果集
}
}
ExcelUtil<Material> util = new ExcelUtil<>(Material.class);
util.exportExcel(response, resultList, "下料管理数据");
}
实体类设置主表 :
width = 20, needMerge = true
/** 客户名称 */
@Excel(name = "客户名称",width = 20, needMerge = true)
private String name;
/** 下料人 */
@Excel(name = "下料人",width = 20, needMerge = true)
private String xialiaoren;
/** 下料时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "下料时间", dateFormat = "yyyy-MM-dd",width = 20, needMerge = true)
private Date cuttingTime;
/** 子表信息 */
@Excel
private List<IotMaterialColors> iotMaterialColorsList;
实体类关联子表 :
cellType = Excel.ColumnType.STRING
/** 板材颜色 */
@Excel(name = "板材颜色", cellType = Excel.ColumnType.STRING)
private String color;
/** 该颜色板材的数量 */
@Excel(name = "板材数量(/张)")
private BigDecimal quantity;
/** 该颜色背板数量的数量 */
@Excel(name = "背板数量(/张)")
private Long quantitybb;