采购订单 导出功能

采购订单 导出功能
pull/4/head
siontion 8 months ago
parent 8130db9f25
commit ebb112f8b3

@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.math.BigDecimal;
import java.util.*;
import java.io.IOException;
@ -103,4 +104,28 @@ public class PurchaseOrderController {
BeanUtils.toBean(list, PurchaseOrderRespVO.class));
}
@GetMapping("/export-excel-with-tax")
@Operation(summary = "导出采购订单 Excel")
@PreAuthorize("@ss.hasPermission('heli:purchase-order:export')")
@OperateLog(type = EXPORT)
public void exportPurchaseOrderExcelWithTax(@Valid PurchaseOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PurchaseOrderDO> list = purchaseOrderService.getPurchaseOrderPageWithTax(pageReqVO).getList();
for(PurchaseOrderDO item : list) {
if(item.getEstimatedPrice() != null && item.getTaxRatio() !=null) {
item.setEstimatedPrice(item.getEstimatedPrice().multiply(BigDecimal.valueOf(item.getTaxRatio())).divide(BigDecimal.valueOf(100)));
}
if(item.getActualPrice() != null && item.getTaxRatio() !=null) {
item.setActualPrice(item.getActualPrice().multiply(BigDecimal.valueOf(item.getTaxRatio())).divide(BigDecimal.valueOf(100)));
}
}
// 导出 Excel
ExcelUtils.write(response, "采购订单.xls", "数据", PurchaseOrderRespVO.class,
BeanUtils.toBean(list, PurchaseOrderRespVO.class));
}
}

@ -17,78 +17,78 @@ import com.chanko.yunxi.mes.framework.excel.core.convert.DictConvert;
public class PurchaseOrderRespVO {
@Schema(description = "自增字段,唯一", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("自增字段,唯一")
private Long id;
@Schema(description = "采购单号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("采购单号")
private String purchaseNo;
@Schema(description = "创建时间")
@ExcelProperty("单据日期")
private LocalDateTime createTime;
@Schema(description = "供应商id")
@ExcelProperty("供应商id")
private Long supplierId;
@Schema(description = "供应商名称")
@ExcelProperty("供应商")
private String supplierName;
@Schema(description = "采购合同号")
@ExcelProperty("采购合同号")
private String contractNo;
@Schema(description = "采购单类型1按物料需求计划采购2备库采购")
@ExcelProperty(value = "采购单类型1按物料需求计划采购2备库采购", converter = DictConvert.class)
@ExcelProperty(value = "采购单类型", converter = DictConvert.class)
@DictFormat("heli_project_purchase_order_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer purchaseType;
@Schema(description = "供应商id")
@ExcelProperty("供应商id")
private Long projectMaterialPlanId;
@Schema(description = "物料需求计划单号")
@ExcelProperty("物料需求计划单号")
private String materialPlanNp;
private String materialPlanNo;
@Schema(description = "采购物类型1物料2加工件", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty(value = "采购物类型1物料2加工件", converter = DictConvert.class)
@ExcelProperty(value = "采购物类型", converter = DictConvert.class)
@DictFormat("heli_project_purchase_goods_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer goodsType;
@Schema(description = "采购合同号")
@ExcelProperty("采购合同号")
private String contractNo;
@Schema(description = "物料需求计划id")
private Long projectMaterialPlanId;
@Schema(description = "结算币种")
@ExcelProperty("结算币种")
@ExcelProperty(value ="结算币种",converter = DictConvert.class)
@DictFormat("heli_currency")
private Integer currencyType;
@Schema(description = "税率")
@ExcelProperty("税率")
private Integer taxRatio;
@Schema(description = "暂估价金额")
@ExcelProperty("暂估价金额")
@ExcelProperty("暂估价金额(元)")
private BigDecimal estimatedPrice;
@Schema(description = "实际价金额")
@ExcelProperty("实际价金额")
@ExcelProperty("实际价金额(元)")
private BigDecimal actualPrice;
@Schema(description = "税率")
@ExcelProperty("税率(%)")
private Integer taxRatio;
@Schema(description = "状态,1已保存2已送审3已审核4已打回 默认是1")
@ExcelProperty(value = "状态,1已保存2已送审3已审核4已打回 默认是1", converter = DictConvert.class)
@ExcelProperty(value = "单据状态", converter = DictConvert.class)
@DictFormat("heli_purchase_order_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer status;
@Schema(description = "送审人")
@ExcelProperty("送审人")
private Long submitUserId;
@Schema(description = "送审时间")
@ExcelProperty("送审时间")
private LocalDateTime submitTime;
@Schema(description = "审核人")
@ExcelProperty("审核人")
private Long auditor;
@Schema(description = "审核时间")
@ExcelProperty("审核时间")
private LocalDateTime auditTime;
@Schema(description = "备注")
@ -96,11 +96,8 @@ public class PurchaseOrderRespVO {
private String description;
@Schema(description = "创建者")
@ExcelProperty("创建者")
private String creator;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -65,7 +65,7 @@ public interface PurchaseOrderMapper extends BaseMapperX<PurchaseOrderDO> {
return selectPage(reqVO, query);
}
default PageResult<PurchaseOrderDO> selectListWithRatio(PurchaseOrderPageReqVO reqVO) {
default PageResult<PurchaseOrderDO> selectListWithTax(PurchaseOrderPageReqVO reqVO) {
MPJLambdaWrapper<PurchaseOrderDO> query = new MPJLambdaWrapper<>();
query.selectAll(PurchaseOrderDO.class)

@ -54,6 +54,7 @@ public interface PurchaseOrderService {
* @return
*/
PageResult<PurchaseOrderDO> getPurchaseOrderPage(PurchaseOrderPageReqVO pageReqVO);
PageResult<PurchaseOrderDO> getPurchaseOrderPageWithTax(PurchaseOrderPageReqVO pageReqVO);
PageResult<PurchaseOrderDO> getPurchaseOrderPageByStatus(PurchaseOrderPageReqVO pageReqVO);
}

@ -100,6 +100,11 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
return purchaseOrderMapper.selectPage(pageReqVO);
}
@Override
public PageResult<PurchaseOrderDO> getPurchaseOrderPageWithTax(PurchaseOrderPageReqVO pageReqVO) {
return purchaseOrderMapper.selectListWithTax(pageReqVO);
}
@Override
public PageResult<PurchaseOrderDO> getPurchaseOrderPageByStatus(PurchaseOrderPageReqVO pageReqVO) {
return purchaseOrderMapper.selectPageByStatus(pageReqVO);

@ -53,3 +53,8 @@ export const deletePurchaseOrder = async (id: number) => {
export const exportPurchaseOrder = async (params) => {
return await request.download({ url: `/heli/purchase-order/export-excel`, params })
}
// 导出采购订单 Excel
export const exportPurchaseOrderWithTax = async (params) => {
return await request.download({ url: `/heli/purchase-order/export-excel-with-tax`, params })
}

@ -43,6 +43,12 @@
<el-button type="primary" plain @click="openForm('create')" v-hasPermi="['heli:purchase-order:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button type="primary" plain @click="handleExportWithTax()" v-hasPermi="['heli:purchase-order:create']">
<Icon icon="ep:plus" class="mr-5px" /> 乘税率导出
</el-button>
<el-button type="primary" plain @click="handleExport()" v-hasPermi="['heli:purchase-order:create']">
<Icon icon="ep:plus" class="mr-5px" /> 直接导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
@ -220,6 +226,19 @@ const handleExport = async () => {
exportLoading.value = false
}
}
const handleExportWithTax = async ()=>{
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await PurchaseOrderApi.exportPurchaseOrderWithTax(queryParams)
download.excel(data, '采购订单.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(async () => {

Loading…
Cancel
Save