fix:产品库存导出功能

dev_1.0.2
jiangpeng 2026-08-24 17:31:56 +08:00
parent 6e6d29511c
commit 625519c2c2
4 changed files with 50 additions and 28 deletions

View File

@ -38,9 +38,9 @@
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">-->
<!-- <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['inventory:info:remove']"></el-button>--> <!-- <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['inventory:info:remove']"></el-button>-->
<!-- </el-col>--> <!-- </el-col>-->
<!-- <el-col :span="1.5">--> <el-col :span="1.5">
<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['inventory:info:export']"></el-button>--> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['inventory:info:export']"></el-button>
<!-- </el-col>--> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -345,7 +345,7 @@
</template> </template>
<script> <script>
import { listInfo, getInfo, addInfo, updateInfo, delInfo, listAllVendors, listAllWarehouses, getPurchaseStock, getBindOrder, getInventoryInner } from "@/api/inventory/info"; import { listInfo, getInfo, addInfo, updateInfo, delInfo, exportInfo, listAllVendors, listAllWarehouses, getPurchaseStock, getBindOrder, getInventoryInner } from "@/api/inventory/info";
import { checkPermi } from "@/utils/permission"; import { checkPermi } from "@/utils/permission";
import { getInner } from "@/api/inventory/inner"; import { getInner } from "@/api/inventory/inner";
import InnerLog from './innerLog'; import InnerLog from './innerLog';
@ -599,12 +599,14 @@ export default {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$modal.confirm('是否确认导出所有产品库存数据项?').then(() => { this.$modal.confirm('是否确认导出所有产品库存数据项?').then(() => {
this.exportLoading = true; this.exportLoading = true;
return this.download('inventory/info/vue/export', { return exportInfo(queryParams);
...queryParams
}, `inventory_info_${new Date().getTime()}.xlsx`)
}).then(response => { }).then(response => {
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); const fileName = response.msg;
window.location.href = process.env.VUE_APP_BASE_API + "/common/download?fileName=" + encodeURIComponent(fileName) + "&delete=" + true;
}).catch(() => {
this.exportLoading = false;
});
}, },
/** 库存颜色 */ /** 库存颜色 */
getStockColor(stock) { getStockColor(stock) {

View File

@ -2,6 +2,7 @@ package com.ruoyi.sip.domain;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
@ -27,42 +28,42 @@ public class ProductInfo extends BaseEntity
/** ID */ /** ID */
private Long id; private Long id;
@Excel(name = "产品编码") @Excel(name = "产品编码", sort = 1)
private String productCode; private String productCode;
private List<String> productCodeList; private List<String> productCodeList;
@Excel(name = "华智编码") @Excel(name = "华智编码", sort = 2)
private String hzCode; private String hzCode;
@Excel(name = "产品名称") @Excel(name = "产品名称", sort = 4)
private String productName; private String productName;
@Excel(name = "产品代码") @Excel(name = "产品代码", sort = 3)
private String model; private String model;
private String type; private String type;
@Excel(name = "产品类型") @Excel(name = "产品类型", sort = 11)
private String typeName; private String typeName;
private String level2Type; private String level2Type;
@Excel(name = "二级类型") @Excel(name = "二级类型", sort = 12)
private String level2TypeName; private String level2TypeName;
private String value; private String value;
@Excel(name = "目录单价") @Excel(name = "目录单价", sort = 13)
private String cataloguePrice; private String cataloguePrice;
@Excel(name = "指导折扣") @Excel(name = "指导折扣", sort = 14)
private String guidanceDiscount; private String guidanceDiscount;
@Excel(name = "制造商") @Excel(name = "制造商", sort = 15)
private String vendorCode; private String vendorCode;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd", sort = 16)
private Date createdAt; private Date createdAt;
@Excel(name = "备注") @Excel(name = "备注", sort = 17)
private String remark; private String remark;
@Excel(name = "产品描述") @Excel(name = "产品描述", sort = 18)
private String description; private String description;
@Excel(name = "终端类型") @Excel(name = "终端类型", sort = 19)
private String terminalType; private String terminalType;
@Excel(name = "国产化") @Excel(name = "国产化", sort = 20)
private String localization; private String localization;
@Excel(name = "CPU品牌") @Excel(name = "CPU品牌", sort = 21)
private String cpuBrand; private String cpuBrand;
@Excel(name = "CPU架构") @Excel(name = "CPU架构", sort = 22)
private String cpuArchitecture; private String cpuArchitecture;
/** 更新时间 */ /** 更新时间 */
@ -78,18 +79,32 @@ public class ProductInfo extends BaseEntity
// 累计发货 // 累计发货
private Long cumulativeCount; private Long cumulativeCount;
/** 在库现存 */ /** 在库现存 */
@Excel(name = "在库现存", sort = 5)
private Long inventoryNum; private Long inventoryNum;
/** 入库总价 */
@Excel(name = "入库总价", sort = 6)
private BigDecimal sumInnerPrice;
/** 累计发货 */ /** 累计发货 */
private Long outerNum; private Long outerNum;
/** 在途库存 */ /** 在途库存 */
@Excel(name = "在途库存", sort = 7)
private Long purchaseNum; private Long purchaseNum;
/** 采购总价 */
@Excel(name = "采购总价", sort = 8)
private BigDecimal sumPurchasePrice;
/** 锁单量 */ /** 锁单量 */
@Excel(name = "锁单量", sort = 10)
private Long bindNum; private Long bindNum;
/** 可用量 */ /** 可用量 */
@Excel(name = "可用量", sort = 9)
private Long usableNum; private Long usableNum;
private Long inventoryCount; private Long inventoryCount;
private Long warehouseId; private Long warehouseId;
private String warehouseName; private String warehouseName;
/** 排序列 */
private String orderByColumn;
/** 排序方向 */
private String isAsc;
@Getter @Getter
public enum ProductTypeEnum { public enum ProductTypeEnum {
/** /**

View File

@ -213,7 +213,6 @@ public class ProductInfoServiceImpl implements IProductInfoService
@Override @Override
public List<ProductInfo> listInventory(ProductInfo info) { public List<ProductInfo> listInventory(ProductInfo info) {
return productInfoMapper.listInventory(info); return productInfoMapper.listInventory(info);
} }
} }

View File

@ -137,7 +137,9 @@
t2.outer_num, t2.outer_num,
t4.purchase_num, t4.purchase_num,
ifnull(t2.bind_num,0) - ifnull(t2.outer_num,0) as bind_num, ifnull(t2.bind_num,0) - ifnull(t2.outer_num,0) as bind_num,
ifnull(t2.inventory_num,0) + ifnull(t4.purchase_num,0) - (ifnull(t2.bind_num,0) - ifnull(t2.outer_num,0)) as usable_num ifnull(t2.inventory_num,0) + ifnull(t4.purchase_num,0) - (ifnull(t2.bind_num,0) - ifnull(t2.outer_num,0)) as usable_num,
round(t2.sum_inner_price, 2) as sum_inner_price,
round(t4.sum_purchase_price, 2) as sum_purchase_price
FROM product_info t1 FROM product_info t1
LEFT JOIN ( LEFT JOIN (
SELECT product_code, SELECT product_code,
@ -147,13 +149,17 @@
select sum(bind_num) from oms_purchase_order as tt2 select sum(bind_num) from oms_purchase_order as tt2
inner join oms_purchase_order_map as tt3 on tt2.id = tt3.purchase_id inner join oms_purchase_order_map as tt3 on tt2.id = tt3.purchase_id
where tt1.product_code = tt3.product_code where tt1.product_code = tt3.product_code
) as bind_num ) as bind_num,
sum((case when inventory_status = 0 then inner_price else 0 end)) as sum_inner_price
FROM oms_inventory_info as tt1 FROM oms_inventory_info as tt1
GROUP BY product_code GROUP BY product_code
) t2 ON t1.product_code = t2.product_code ) t2 ON t1.product_code = t2.product_code
left join oms_vendor_info t3 on t1.vendor_code = t3.vendor_code left join oms_vendor_info t3 on t1.vendor_code = t3.vendor_code
left join ( left join (
select tt1.product_code, sum(tt1.quantity) - sum(tt1.inner_quantity) as purchase_num select
tt1.product_code,
sum(tt1.quantity) - sum(tt1.inner_quantity) as purchase_num,
sum((tt1.quantity - tt1.inner_quantity) * tt1.price) as sum_purchase_price
from oms_purchase_order_item as tt1 from oms_purchase_order_item as tt1
inner join oms_purchase_order as tt2 on tt1.purchase_id = tt2.id inner join oms_purchase_order as tt2 on tt1.purchase_id = tt2.id
group by product_code group by product_code