入库明细excel导出

This commit is contained in:
zjf committed 2025-10-16 17:44:55 +08:00
1 parent efc2ef5045
commit 58dd71c0c2
5 files changed
+79 -12

No files matched your search

@@ -12,17 +12,26 @@ import java.time.LocalDate;
public class InventoryDetailQueryDTO {
/**
* 编号
* 编号、商品名称、供应商(模糊查询)
*/
@Schema(description="关键字")
@Schema(description="关键字(单据编号/商品名称/供应商)")
private String key;
/**
* 单据日期
* 开始日期
*/
@Schema(description="单据日期")
private LocalDate inventoryDate;
@Schema(description="开始日期")
private LocalDate startDate;
@Schema(description="1入库 2出库")
/**
* 结束日期
*/
@Schema(description="结束日期")
private LocalDate endDate;
/**
* 1入库 2出库
*/
@Schema(description="订单类型:1=入库,2=出库")
private Integer orderType;
}
@@ -323,15 +323,30 @@ public class SmErpInventoryRecordsController {
/**
* 分页查询
* 分页查询出入库明细
* @param page 分页对象
* @param inventoryDetailQueryDTO 查询条件
* @return
*/
@Operation(summary = "分页获取出入库明细" , description = "出库明细,入库明细" )
@Operation(summary = "分页获取出入库明细" , description = "出库明细,入库明细,支持日期区间查询" )
@GetMapping("/inventoryType/page" )
public R getinventoryTypePage(@ParameterObject Page page, @ParameterObject InventoryDetailQueryDTO inventoryDetailQueryDTO) {
return R.ok(smErpInventoryRecordsService.getInventoryDetailPage(page, inventoryDetailQueryDTO));
}
/**
* 导出出入库明细
* @param inventoryDetailQueryDTO 查询条件
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/inventoryType/export")
@Operation(summary = "导出出入库明细", description = "导出出入库明细数据为Excel文件")
@SysLog("导出出入库明细")
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_export')")
public List<InventoryDetailExcelDTO> exportInventoryDetail(@ParameterObject InventoryDetailQueryDTO inventoryDetailQueryDTO) {
return smErpInventoryRecordsService.exportInventoryDetail(inventoryDetailQueryDTO);
}
/**
*
*根据单号获取明细
@@ -102,6 +102,13 @@ public interface SmErpInventoryRecordsService extends IService<SmErpInventoryRec
*/
List<SmErpInventoryRecordsSummaryExcelDto> exportInventoryRecordsSummary(SmErpInventoryRecordsEntity smErpInventoryRecords, Long[] ids);
/**
* 导出出入库明细
* @param inventoryDetailQueryDTO 查询条件
* @return 明细导出数据列表
*/
List<InventoryDetailExcelDTO> exportInventoryDetail(InventoryDetailQueryDTO inventoryDetailQueryDTO);
/**
* 批量删除
* @param list
@@ -1285,6 +1285,38 @@ public class SmErpInventoryRecordsServiceImpl extends ServiceImpl<SmErpInventory
return new ArrayList<>(summaryMap.values());
}
@Override
public List<InventoryDetailExcelDTO> exportInventoryDetail(InventoryDetailQueryDTO inventoryDetailQueryDTO) {
// 查询明细数据(不分页)
Page<InventoryRecordPageVo> page = new Page<>(1, 10000);
Page<InventoryRecordPageVo> pageData = baseMapper.getInventoryDetailPageByScope(page, inventoryDetailQueryDTO, DataScope.of());
List<InventoryRecordPageVo> records = pageData.getRecords();
// 转换为导出DTO
return records.stream().map(vo -> {
InventoryDetailExcelDTO dto = new InventoryDetailExcelDTO();
dto.setInventoryCode(vo.getInventoryCode());
dto.setInventoryDate(vo.getInventoryDate());
dto.setProductName(vo.getProductName());
dto.setSpec(vo.getSpec());
dto.setUnit(vo.getUnit());
dto.setPackageNum(vo.getPackageNum());
dto.setQuantity(vo.getQuantity());
// 金额从分转换为元
if (vo.getUnitPrice() != null) {
dto.setUnitPrice(BigDecimal.valueOf(vo.getUnitPrice()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
}
if (vo.getTotalAmount() != null) {
dto.setTotalAmount(BigDecimal.valueOf(vo.getTotalAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
}
dto.setSupplierName(vo.getSupplierName());
dto.setRemark(vo.getRemark());
return dto;
}).collect(Collectors.toList());
}
}
@@ -45,7 +45,8 @@
u.package_num,
u.retail_price,
supp.supplier_name,
r.inventory_date
r.inventory_date,
r.dept_id
FROM sm_erp_inventory_records_item i
LEFT JOIN sm_erp_inventory_records r
on i.inventory_id = r.id
@@ -62,8 +63,11 @@
<if test="inventoryDetailQueryDTO.orderType != null and inventoryDetailQueryDTO.orderType != ''">
and r.order_type = #{inventoryDetailQueryDTO.orderType}
</if>
<if test="inventoryDetailQueryDTO.inventoryDate != null">
and r.inventory_date = #{inventoryDetailQueryDTO.inventoryDate}
<if test="inventoryDetailQueryDTO.startDate != null">
and r.inventory_date &gt;= #{inventoryDetailQueryDTO.startDate}
</if>
<if test="inventoryDetailQueryDTO.endDate != null">
and r.inventory_date &lt;= #{inventoryDetailQueryDTO.endDate}
</if>
<if test="inventoryDetailQueryDTO.key != null and inventoryDetailQueryDTO.key != ''">
and (r.inventory_code like concat('%',#{inventoryDetailQueryDTO.key},'%')