rev:库存分析
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package org.nl.wms.basedata_manage.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.basedata_manage.service.IOutsideIvtService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/outsideivt")
|
||||
@Slf4j
|
||||
public class OutsideIvtController {
|
||||
|
||||
@Resource
|
||||
private final IOutsideIvtService outsideIvtService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询库外库存")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
IPage<JSONObject> pageData = outsideIvtService.queryAll(whereJson, page);
|
||||
TableDataInfo<JSONObject> result = new TableDataInfo<>(pageData.getRecords(), pageData.getTotal());
|
||||
result.setCode(String.valueOf(HttpStatus.OK.value()));
|
||||
result.setMsg("查询成功");
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
@Log("查询库外库存汇总")
|
||||
public ResponseEntity<Object> querySummary(@RequestParam Map whereJson) {
|
||||
JSONObject summary = outsideIvtService.querySummary(whereJson);
|
||||
List<JSONObject> regionSummary = outsideIvtService.queryRegionSummary(whereJson);
|
||||
List<JSONObject> regionTransitSummary = outsideIvtService.queryRegionTransitSummary(whereJson);
|
||||
summary.put("region_total_list", regionSummary.stream().map(item -> {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("region_code", item.getString("region_code"));
|
||||
row.put("region_name", item.getString("region_name"));
|
||||
row.put("value", item.getBigDecimal("total_qty"));
|
||||
return row;
|
||||
}).collect(Collectors.toList()));
|
||||
summary.put("region_transit_list", regionTransitSummary.stream().map(item -> {
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("region_code", item.getString("region_code"));
|
||||
row.put("region_name", item.getString("region_name"));
|
||||
row.put("value", item.getBigDecimal("total_qty"));
|
||||
return row;
|
||||
}).collect(Collectors.toList()));
|
||||
return new ResponseEntity<>(summary, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@Log("导出库外库存")
|
||||
public void download(@RequestParam Map whereJson, HttpServletResponse response) {
|
||||
String[] headers = {"点位编码", "点位名称", "区域", "物料编码", "物料名称", "批次", "载具号", "重量", "计量单位"};
|
||||
List<JSONObject> rows = outsideIvtService.queryAll(whereJson);
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = workbook.createSheet("库外库存");
|
||||
Row header = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = header.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
sheet.setColumnWidth(i, 18 * 256);
|
||||
}
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject item = rows.get(i);
|
||||
Row row = sheet.createRow(i + 1);
|
||||
row.createCell(0).setCellValue(getString(item, "point_code"));
|
||||
row.createCell(1).setCellValue(getString(item, "point_name"));
|
||||
row.createCell(2).setCellValue(getString(item, "region_name"));
|
||||
row.createCell(3).setCellValue(getString(item, "material_code"));
|
||||
row.createCell(4).setCellValue(getString(item, "material_name"));
|
||||
row.createCell(5).setCellValue(getString(item, "batch_no"));
|
||||
row.createCell(6).setCellValue(getString(item, "storagevehicle_code"));
|
||||
row.createCell(7).setCellValue(item.getBigDecimal("weight") == null ? 0D : item.getBigDecimal("weight").doubleValue());
|
||||
row.createCell(8).setCellValue(getString(item, "qty_unit_name"));
|
||||
}
|
||||
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
String fileName = URLEncoder.encode("库外库存.xlsx", StandardCharsets.UTF_8.name()).replace("+", "%20");
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + fileName);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 导出库外库存失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getString(JSONObject item, String key) {
|
||||
Object value = item.get(key);
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,20 @@
|
||||
package org.nl.wms.basedata_manage.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -15,6 +22,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -40,4 +51,61 @@ public class StructIvtController {
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(iMdPbStoragevehicleextService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
@Log("查询库存汇总")
|
||||
public ResponseEntity<Object> querySummary(@RequestParam Map whereJson) {
|
||||
return new ResponseEntity<>(iMdPbStoragevehicleextService.querySummary(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@Log("导出库存")
|
||||
public void download(@RequestParam Map whereJson, HttpServletResponse response) {
|
||||
String[] headers = {"仓位编码", "仓位名称", "仓库", "库区", "物料编码", "物料名称", "批次号", "载具号", "总数", "可用数", "冻结数", "计量单位", "备注", "入库时间", "供应商编码", "供应商名称"};
|
||||
List<JSONObject> rows = iMdPbStoragevehicleextService.queryAll(whereJson);
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
Sheet sheet = workbook.createSheet("库内库存");
|
||||
Row header = sheet.createRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = header.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
sheet.setColumnWidth(i, 18 * 256);
|
||||
}
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject item = rows.get(i);
|
||||
Row row = sheet.createRow(i + 1);
|
||||
row.createCell(0).setCellValue(getString(item, "struct_code"));
|
||||
row.createCell(1).setCellValue(getString(item, "struct_name"));
|
||||
row.createCell(2).setCellValue(getString(item, "stor_name"));
|
||||
row.createCell(3).setCellValue(getString(item, "sect_name"));
|
||||
row.createCell(4).setCellValue(getString(item, "material_code"));
|
||||
row.createCell(5).setCellValue(getString(item, "material_name"));
|
||||
row.createCell(6).setCellValue(getString(item, "pcsn"));
|
||||
row.createCell(7).setCellValue(getString(item, "storagevehicle_code"));
|
||||
row.createCell(8).setCellValue(item.getBigDecimal("qty") == null ? 0D : item.getBigDecimal("qty").doubleValue());
|
||||
double qty = item.getBigDecimal("qty") == null ? 0D : item.getBigDecimal("qty").doubleValue();
|
||||
double frozenQty = item.getBigDecimal("frozen_qty") == null ? 0D : item.getBigDecimal("frozen_qty").doubleValue();
|
||||
row.createCell(9).setCellValue(qty - frozenQty);
|
||||
row.createCell(10).setCellValue(frozenQty);
|
||||
row.createCell(11).setCellValue(getString(item, "qty_unit_name"));
|
||||
row.createCell(12).setCellValue(getString(item, "remark"));
|
||||
row.createCell(13).setCellValue(getString(item, "create_time"));
|
||||
row.createCell(14).setCellValue(getString(item, "supp_code"));
|
||||
row.createCell(15).setCellValue(getString(item, "supp_name"));
|
||||
}
|
||||
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
String fileName = URLEncoder.encode("库内库存.xlsx", StandardCharsets.UTF_8.name()).replace("+", "%20");
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + fileName);
|
||||
workbook.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
log.error(">>> 导出库存失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getString(JSONObject item, String key) {
|
||||
Object value = item.get(key);
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,18 @@ public interface IMdPbStoragevehicleextService extends IService<MdPbStoragevehic
|
||||
*/
|
||||
IPage<JSONObject> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
/**
|
||||
* 列表查询,不分页
|
||||
* @param whereJson 查询条件
|
||||
* @return 列表
|
||||
*/
|
||||
List<JSONObject> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 库存汇总查询
|
||||
* @param whereJson 查询条件
|
||||
* @return 汇总结果
|
||||
*/
|
||||
JSONObject querySummary(Map whereJson);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.wms.basedata_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IOutsideIvtService {
|
||||
|
||||
IPage<JSONObject> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
List<JSONObject> queryAll(Map whereJson);
|
||||
|
||||
JSONObject querySummary(Map whereJson);
|
||||
|
||||
List<JSONObject> queryRegionSummary(Map whereJson);
|
||||
|
||||
List<JSONObject> queryRegionTransitSummary(Map whereJson);
|
||||
}
|
||||
@@ -60,6 +60,13 @@ public interface MdPbStoragevehicleextMapper extends BaseMapper<MdPbStoragevehic
|
||||
*/
|
||||
IPage<JSONObject> queryAllByPage(Page<JSONObject> page, @Param("param") Map whereJson);
|
||||
|
||||
/**
|
||||
* 库存汇总
|
||||
* @param whereJson 查询条件
|
||||
* @return 汇总结果
|
||||
*/
|
||||
JSONObject querySummary(@Param("param") Map whereJson);
|
||||
|
||||
/**
|
||||
* erp查询库存
|
||||
* @param whereJson {
|
||||
|
||||
@@ -114,12 +114,73 @@
|
||||
AND
|
||||
ext.pcsn LIKE #{param.pcsn}
|
||||
</if>
|
||||
|
||||
<if test="param.storagevehicle_code != null and param.storagevehicle_code != ''">
|
||||
AND
|
||||
ext.storagevehicle_code LIKE CONCAT('%', #{param.storagevehicle_code}, '%')
|
||||
</if>
|
||||
AND 0 = (SELECT COUNT(*) FROM sch_base_task t WHERE t.task_status <![CDATA[ < ]]> '5'
|
||||
AND t.is_delete = '0' AND (t.vehicle_code = ext.storagevehicle_code OR t.vehicle_code2 = ext.storagevehicle_code))
|
||||
</where>
|
||||
ORDER BY ext.create_time Desc
|
||||
</select>
|
||||
|
||||
<select id="querySummary" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
COALESCE(SUM(ext.qty), 0) AS total_qty,
|
||||
COALESCE(SUM(ext.frozen_qty), 0) AS frozen_qty,
|
||||
COALESCE(SUM(ext.qty - ext.frozen_qty), 0) AS available_qty,
|
||||
COUNT(DISTINCT ext.storagevehicle_code) AS vehicle_count,
|
||||
COUNT(DISTINCT mater.material_code) AS material_count
|
||||
FROM
|
||||
md_pb_groupplate ext
|
||||
INNER JOIN st_ivt_structattr attr ON ext.storagevehicle_code = attr.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<where>
|
||||
1 = 1
|
||||
And ext.`status`='02'
|
||||
AND attr.occupancy_state = 3
|
||||
<if test="param.stor_id != null and param.stor_id != ''">
|
||||
AND
|
||||
attr.stor_id = #{param.stor_id}
|
||||
</if>
|
||||
|
||||
<if test="param.sect_id != null and param.sect_id != ''">
|
||||
AND
|
||||
attr.sect_id = #{param.sect_id}
|
||||
</if>
|
||||
|
||||
<if test="param.sect_code != null and param.sect_code != ''">
|
||||
AND
|
||||
attr.sect_code = #{param.sect_code}
|
||||
</if>
|
||||
|
||||
<if test="param.struct_code != null and param.struct_code != ''">
|
||||
AND
|
||||
(attr.struct_code LIKE #{param.struct_code} or
|
||||
attr.struct_name LIKE #{param.struct_code} )
|
||||
</if>
|
||||
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND
|
||||
(mater.material_code LIKE CONCAT('%', #{param.material_code},'%') or
|
||||
mater.material_name LIKE CONCAT('%', #{param.material_code},'%') )
|
||||
</if>
|
||||
|
||||
<if test="param.pcsn != null and param.pcsn != ''">
|
||||
AND
|
||||
ext.pcsn LIKE #{param.pcsn}
|
||||
</if>
|
||||
|
||||
<if test="param.storagevehicle_code != null and param.storagevehicle_code != ''">
|
||||
AND
|
||||
ext.storagevehicle_code LIKE CONCAT('%', #{param.storagevehicle_code}, '%')
|
||||
</if>
|
||||
AND 0 = (SELECT COUNT(*) FROM sch_base_task t WHERE t.task_status <![CDATA[ < ]]> '5'
|
||||
AND t.is_delete = '0' AND (t.vehicle_code = ext.storagevehicle_code OR t.vehicle_code2 = ext.storagevehicle_code))
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DISTINCT
|
||||
ext.group_id as storagevehicleext_id,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.nl.wms.basedata_manage.service.dao.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface OutsideIvtMapper {
|
||||
|
||||
IPage<JSONObject> queryPage(Page<JSONObject> page, @Param("param") Map whereJson);
|
||||
|
||||
List<JSONObject> queryAll(@Param("param") Map whereJson);
|
||||
|
||||
JSONObject querySummary(@Param("param") Map whereJson);
|
||||
|
||||
List<JSONObject> queryRegionSummary(@Param("param") Map whereJson);
|
||||
|
||||
List<JSONObject> queryRegionTransitSummary(@Param("param") Map whereJson);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.basedata_manage.service.dao.mapper.OutsideIvtMapper">
|
||||
|
||||
<sql id="OutsideIvtWhere">
|
||||
<where>
|
||||
1 = 1
|
||||
AND ext.`status` IN ('01', '02')
|
||||
AND p.point_status = '3'
|
||||
AND p.is_used = 1
|
||||
|
||||
<if test="param.region_code != null and param.region_code != ''">
|
||||
AND p.region_code = #{param.region_code}
|
||||
</if>
|
||||
|
||||
<if test="param.point_code != null and param.point_code != ''">
|
||||
AND (
|
||||
p.point_code LIKE CONCAT('%', #{param.point_code}, '%')
|
||||
OR p.point_name LIKE CONCAT('%', #{param.point_code}, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND (
|
||||
mater.material_code LIKE CONCAT('%', #{param.material_code}, '%')
|
||||
OR mater.material_name LIKE CONCAT('%', #{param.material_code}, '%')
|
||||
OR mater.material_model LIKE CONCAT('%', #{param.material_code}, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="param.pcsn != null and param.pcsn != ''">
|
||||
AND ext.pcsn LIKE CONCAT('%', #{param.pcsn}, '%')
|
||||
</if>
|
||||
|
||||
<if test="param.storagevehicle_code != null and param.storagevehicle_code != ''">
|
||||
AND ext.storagevehicle_code LIKE CONCAT('%', #{param.storagevehicle_code}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<sql id="OutsideIvtListTaskWhere">
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task t
|
||||
WHERE t.task_status <![CDATA[ < ]]> '5'
|
||||
AND t.is_delete = '0'
|
||||
AND (
|
||||
t.point_code1 = p.point_code
|
||||
OR t.point_code2 = p.point_code
|
||||
OR t.point_code3 = p.point_code
|
||||
OR t.point_code4 = p.point_code
|
||||
OR t.vehicle_code = ext.storagevehicle_code
|
||||
OR t.vehicle_code2 = ext.storagevehicle_code
|
||||
)
|
||||
)
|
||||
</sql>
|
||||
|
||||
<select id="queryPage" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DISTINCT
|
||||
ext.group_id AS storagevehicleext_id,
|
||||
p.point_code,
|
||||
p.point_name,
|
||||
p.region_code,
|
||||
p.region_name,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
ext.pcsn AS batch_no,
|
||||
ext.storagevehicle_code,
|
||||
ext.qty AS weight,
|
||||
ext.qty AS qty,
|
||||
ext.frozen_qty,
|
||||
ext.qty_unit_name,
|
||||
ext.create_time
|
||||
FROM md_pb_groupplate ext
|
||||
INNER JOIN sch_base_point p ON p.vehicle_code = ext.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<include refid="OutsideIvtWhere"/>
|
||||
<include refid="OutsideIvtListTaskWhere"/>
|
||||
ORDER BY ext.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="queryAll" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT DISTINCT
|
||||
ext.group_id AS storagevehicleext_id,
|
||||
p.point_code,
|
||||
p.point_name,
|
||||
p.region_code,
|
||||
p.region_name,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
ext.pcsn AS batch_no,
|
||||
ext.storagevehicle_code,
|
||||
ext.qty AS weight,
|
||||
ext.qty AS qty,
|
||||
ext.frozen_qty,
|
||||
ext.qty_unit_name,
|
||||
ext.create_time
|
||||
FROM md_pb_groupplate ext
|
||||
INNER JOIN sch_base_point p ON p.vehicle_code = ext.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<include refid="OutsideIvtWhere"/>
|
||||
<include refid="OutsideIvtListTaskWhere"/>
|
||||
ORDER BY ext.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="querySummary" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
COALESCE(SUM(ext.qty), 0) AS total_qty,
|
||||
COALESCE(SUM(ext.frozen_qty), 0) AS frozen_qty,
|
||||
COALESCE(SUM(ext.qty - ext.frozen_qty), 0) AS available_qty,
|
||||
COUNT(DISTINCT ext.storagevehicle_code) AS vehicle_count,
|
||||
COUNT(DISTINCT mater.material_code) AS material_count
|
||||
FROM md_pb_groupplate ext
|
||||
INNER JOIN sch_base_point p ON p.vehicle_code = ext.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<include refid="OutsideIvtWhere"/>
|
||||
</select>
|
||||
|
||||
<select id="queryRegionSummary" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
p.region_code,
|
||||
p.region_name,
|
||||
COALESCE(SUM(ext.qty), 0) AS total_qty,
|
||||
COALESCE(SUM(ext.frozen_qty), 0) AS frozen_qty,
|
||||
COALESCE(SUM(ext.qty - ext.frozen_qty), 0) AS available_qty
|
||||
FROM md_pb_groupplate ext
|
||||
INNER JOIN sch_base_point p ON p.vehicle_code = ext.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<include refid="OutsideIvtWhere"/>
|
||||
GROUP BY p.region_code, p.region_name
|
||||
ORDER BY p.region_code
|
||||
</select>
|
||||
|
||||
<select id="queryRegionTransitSummary" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
p.region_code,
|
||||
p.region_name,
|
||||
COALESCE(SUM(ext.qty), 0) AS total_qty
|
||||
FROM md_pb_groupplate ext
|
||||
INNER JOIN sch_base_point p ON p.vehicle_code = ext.storagevehicle_code
|
||||
INNER JOIN md_me_materialbase mater ON mater.material_id = ext.material_id
|
||||
<where>
|
||||
1 = 1
|
||||
AND ext.`status` IN ('01', '02')
|
||||
AND p.point_status = '3'
|
||||
AND p.is_used = 1
|
||||
AND IFNULL(p.ing_task_code, '') <![CDATA[ <> ]]> ''
|
||||
|
||||
<if test="param.region_code != null and param.region_code != ''">
|
||||
AND p.region_code = #{param.region_code}
|
||||
</if>
|
||||
|
||||
<if test="param.point_code != null and param.point_code != ''">
|
||||
AND (
|
||||
p.point_code LIKE CONCAT('%', #{param.point_code}, '%')
|
||||
OR p.point_name LIKE CONCAT('%', #{param.point_code}, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND (
|
||||
mater.material_code LIKE CONCAT('%', #{param.material_code}, '%')
|
||||
OR mater.material_name LIKE CONCAT('%', #{param.material_code}, '%')
|
||||
OR mater.material_model LIKE CONCAT('%', #{param.material_code}, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="param.pcsn != null and param.pcsn != ''">
|
||||
AND ext.pcsn LIKE CONCAT('%', #{param.pcsn}, '%')
|
||||
</if>
|
||||
|
||||
<if test="param.storagevehicle_code != null and param.storagevehicle_code != ''">
|
||||
AND ext.storagevehicle_code LIKE CONCAT('%', #{param.storagevehicle_code}, '%')
|
||||
</if>
|
||||
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sch_base_task t
|
||||
WHERE t.task_status <![CDATA[ < ]]> '5'
|
||||
AND t.is_delete = '0'
|
||||
AND (
|
||||
t.point_code1 = p.point_code
|
||||
OR t.point_code2 = p.point_code
|
||||
OR t.point_code3 = p.point_code
|
||||
OR t.point_code4 = p.point_code
|
||||
OR t.vehicle_code = ext.storagevehicle_code
|
||||
OR t.vehicle_code2 = ext.storagevehicle_code
|
||||
)
|
||||
)
|
||||
</where>
|
||||
GROUP BY p.region_code, p.region_name
|
||||
ORDER BY p.region_code
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -10,6 +10,7 @@ import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -31,4 +32,14 @@ public class MdPbStoragevehicleextServiceImpl extends ServiceImpl<MdPbStorageveh
|
||||
whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryAll(Map whereJson) {
|
||||
return this.baseMapper.queryAll(whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject querySummary(Map whereJson) {
|
||||
return this.baseMapper.querySummary(whereJson);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.nl.wms.basedata_manage.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.basedata_manage.service.IOutsideIvtService;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.OutsideIvtMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OutsideIvtServiceImpl implements IOutsideIvtService {
|
||||
|
||||
private final OutsideIvtMapper outsideIvtMapper;
|
||||
|
||||
@Override
|
||||
public IPage<JSONObject> queryAll(Map whereJson, PageQuery page) {
|
||||
return outsideIvtMapper.queryPage(new Page<>(page.getPage() + 1, page.getSize()), whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryAll(Map whereJson) {
|
||||
return outsideIvtMapper.queryAll(whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject querySummary(Map whereJson) {
|
||||
return outsideIvtMapper.querySummary(whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryRegionSummary(Map whereJson) {
|
||||
return outsideIvtMapper.queryRegionSummary(whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryRegionTransitSummary(Map whereJson) {
|
||||
return outsideIvtMapper.queryRegionTransitSummary(whereJson);
|
||||
}
|
||||
}
|
||||
345
lms/nladmin-ui/src/views/wms/statement/outsideivt/index.vue
Normal file
345
lms/nladmin-ui/src/views/wms/statement/outsideivt/index.vue
Normal file
@@ -0,0 +1,345 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div class="summary-container">
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">总库存</div>
|
||||
<div class="summary-value">{{ formatNum(summary.total_qty) }} <span class="summary-unit">KG</span></div>
|
||||
<div class="summary-section">
|
||||
<div class="summary-list">
|
||||
<div class="summary-list-header">
|
||||
<span class="summary-list-head">区域</span>
|
||||
<span class="summary-list-head">总量</span>
|
||||
<span class="summary-list-head">折钨</span>
|
||||
</div>
|
||||
<div v-for="item in displayRegionTotalList" :key="item.region_code || item.region_name" class="summary-list-row">
|
||||
<span class="summary-list-name">{{ item.region_name }}</span>
|
||||
<span class="summary-list-value">{{ formatNum(item.value) }} <span class="summary-unit">KG</span></span>
|
||||
<span class="summary-list-value">{{ formatNum(getEquivalentWeight(item)) }} <span class="summary-unit">KG</span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="90px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="区域">
|
||||
<el-select
|
||||
v-model="query.region_code"
|
||||
clearable
|
||||
filterable
|
||||
size="mini"
|
||||
placeholder="区域类型"
|
||||
class="filter-item"
|
||||
style="width: 200px;"
|
||||
@clear="handleClear"
|
||||
@change="hand"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in regionList"
|
||||
:key="item.region_code"
|
||||
:label="item.region_name"
|
||||
:value="item.region_code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="点位搜索">
|
||||
<el-input
|
||||
v-model="query.point_code"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="点位编码或名称"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="物料搜索">
|
||||
<el-input
|
||||
v-model="query.material_code"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="物料编码、名称或规格"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="批次号">
|
||||
<el-input
|
||||
v-model="query.pcsn"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="批次号"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="载具号">
|
||||
<el-input
|
||||
v-model="query.storagevehicle_code"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="载具号"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation :crud="crud" />
|
||||
</el-form>
|
||||
</div>
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
:loading="exportLoading"
|
||||
@click="downdtl"
|
||||
>
|
||||
导出
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column prop="point_code" label="点位编码" :min-width="flexWidth('point_code',crud.data,'点位编码')" />
|
||||
<el-table-column prop="point_name" label="点位名称" :min-width="flexWidth('point_name',crud.data,'点位名称')" />
|
||||
<el-table-column prop="region_name" label="区域" :min-width="flexWidth('region_name',crud.data,'区域')" />
|
||||
<el-table-column prop="material_code" label="物料编码" :min-width="flexWidth('material_code',crud.data,'物料编码')" />
|
||||
<el-table-column prop="material_name" label="物料名称" :min-width="flexWidth('material_name',crud.data,'物料名称')" />
|
||||
<el-table-column prop="batch_no" label="批次" :min-width="flexWidth('batch_no',crud.data,'批次')" />
|
||||
<el-table-column prop="storagevehicle_code" label="载具号" :min-width="flexWidth('storagevehicle_code',crud.data,'载具号')" />
|
||||
<el-table-column prop="weight" label="重量" :formatter="crud.formatNum3" :min-width="100" />
|
||||
<el-table-column prop="qty_unit_name" label="计量单位" :min-width="flexWidth('qty_unit_name',crud.data,'计量单位')" />
|
||||
</el-table>
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudOutsideivt from '@/views/wms/statement/outsideivt/outsideivt'
|
||||
import CRUD, { presenter, header, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import crudSchBaseRegion from '@/views/wms/sch/region/schBaseRegion'
|
||||
import { download } from '@/api/data'
|
||||
import { downloadFile } from '@/utils'
|
||||
|
||||
export default {
|
||||
name: 'Outsideivt',
|
||||
components: { pagination, crudOperation, rrOperation },
|
||||
mixins: [presenter(), header(), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '库外库存', url: 'api/outsideivt', idField: 'storagevehicleext_id', sort: 'storagevehicleext_id,desc',
|
||||
optShow: {
|
||||
add: false,
|
||||
edit: false,
|
||||
showDtlLoading: false,
|
||||
del: false,
|
||||
download: false,
|
||||
reset: true
|
||||
},
|
||||
crudMethod: { ...crudOutsideivt }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
regionList: [],
|
||||
permission: {},
|
||||
rules: {},
|
||||
exportLoading: false,
|
||||
summary: {
|
||||
total_qty: 0,
|
||||
available_qty: 0,
|
||||
frozen_qty: 0,
|
||||
vehicle_count: 0,
|
||||
material_count: 0,
|
||||
region_total_list: []
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getRegionList()
|
||||
},
|
||||
computed: {
|
||||
displayRegionTotalList() {
|
||||
if (this.summary.region_total_list && this.summary.region_total_list.length) {
|
||||
return this.summary.region_total_list
|
||||
}
|
||||
const regionCode = this.query && this.query.region_code
|
||||
if (regionCode) {
|
||||
const region = this.regionList.find(item => item.region_code === regionCode)
|
||||
return [{
|
||||
region_code: regionCode,
|
||||
region_name: region ? region.region_name : regionCode,
|
||||
value: 0
|
||||
}]
|
||||
}
|
||||
return [{
|
||||
region_code: 'empty',
|
||||
region_name: '全部区域',
|
||||
value: 0
|
||||
}]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
this.fetchSummary()
|
||||
return true
|
||||
},
|
||||
formatNum(value) {
|
||||
const num = Number(value || 0)
|
||||
return num.toFixed(3).replace(/\.?0+$/, '')
|
||||
},
|
||||
getEquivalentWeight(item) {
|
||||
const qty = Number(item && item.value ? item.value : 0)
|
||||
const regionName = item && item.region_name ? item.region_name : ''
|
||||
return qty * this.getEquivalentWeightFactor(regionName)
|
||||
},
|
||||
getEquivalentWeightFactor(regionName) {
|
||||
if (!regionName) {
|
||||
return 1
|
||||
}
|
||||
if (regionName.includes('超细还原炉') || regionName.includes('中粗还原炉')) {
|
||||
return 0.793
|
||||
}
|
||||
return 1
|
||||
},
|
||||
fetchSummary() {
|
||||
crudOutsideivt.getSummary(this.query).then(res => {
|
||||
this.summary = Object.assign({}, this.summary, res || {})
|
||||
}).catch(() => {
|
||||
this.summary = {
|
||||
total_qty: 0,
|
||||
available_qty: 0,
|
||||
frozen_qty: 0,
|
||||
vehicle_count: 0,
|
||||
material_count: 0,
|
||||
region_total_list: []
|
||||
}
|
||||
})
|
||||
},
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
getRegionList() {
|
||||
crudSchBaseRegion.getRegionList().then(res => {
|
||||
this.regionList = res
|
||||
})
|
||||
},
|
||||
handleClear() {
|
||||
this.crud.query.region_code = null
|
||||
this.hand()
|
||||
},
|
||||
querytable() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
downdtl() {
|
||||
this.exportLoading = true
|
||||
download('/api/outsideivt/download', this.crud.query).then(result => {
|
||||
downloadFile(result, '库外库存', 'xlsx')
|
||||
this.exportLoading = false
|
||||
}).catch(() => {
|
||||
this.exportLoading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.summary-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
max-width: 760px;
|
||||
}
|
||||
|
||||
.summary-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
margin-bottom: 8px;
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
color: #303133;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.summary-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.summary-list-header,
|
||||
.summary-list-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
align-items: baseline;
|
||||
column-gap: 12px;
|
||||
}
|
||||
|
||||
.summary-list-header {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.summary-list-head {
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.summary-list-name {
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary-list-value {
|
||||
color: #303133;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.summary-unit {
|
||||
margin-left: 4px;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.summary-container {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,34 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getSummary(params) {
|
||||
return request({
|
||||
url: 'api/outsideivt/summary',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
add(data) {
|
||||
return request({
|
||||
url: 'api/outsideivt',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
},
|
||||
edit(data) {
|
||||
return request({
|
||||
url: 'api/outsideivt',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
},
|
||||
del(ids) {
|
||||
return request({
|
||||
url: 'api/outsideivt/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
},
|
||||
getSummary
|
||||
}
|
||||
@@ -2,6 +2,20 @@
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div class="summary-container">
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">总库存</div>
|
||||
<div class="summary-value">{{ formatNum(summary.total_qty) }} <span class="summary-unit">KG</span></div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">可用库存</div>
|
||||
<div class="summary-value">{{ formatNum(summary.available_qty) }} <span class="summary-unit">KG</span></div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">冻结库存</div>
|
||||
<div class="summary-value">{{ formatNum(summary.frozen_qty) }} <span class="summary-unit">KG</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
@@ -52,22 +66,32 @@
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="载具号">
|
||||
<el-input
|
||||
v-model="query.storagevehicle_code"
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="载具号"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation :crud="crud" />
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission">
|
||||
<!-- <el-button
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-check"
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
:loading="showDtlLoading"
|
||||
:loading="exportLoading"
|
||||
@click="downdtl"
|
||||
>
|
||||
导出Excel
|
||||
</el-button>-->
|
||||
导出
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
@@ -95,7 +119,7 @@
|
||||
<el-table-column prop="frozen_qty" label="冻结数" :formatter="crud.formatNum3" :min-width="100" />
|
||||
<el-table-column prop="qty_unit_name" label="计量单位" :min-width="flexWidth('qty_unit_name',crud.data,'计量单位')" />
|
||||
<el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')" />
|
||||
<el-table-column prop="create_time" label="入库时间" :min-width="flexWidth('insert_time',crud.data,'入库时间')" />
|
||||
<el-table-column prop="create_time" label="入库时间" width="170" />
|
||||
<el-table-column prop="supp_code" label="供应商编码" :min-width="flexWidth('supp_code',crud.data,'供应商编码')" />
|
||||
<el-table-column prop="supp_name" label="供应商名称" :min-width="flexWidth('supp_name',crud.data,'供应商名称')" />
|
||||
</el-table>
|
||||
@@ -137,7 +161,15 @@ export default {
|
||||
return {
|
||||
sects: [],
|
||||
permission: {},
|
||||
rules: {}
|
||||
rules: {},
|
||||
exportLoading: false,
|
||||
summary: {
|
||||
total_qty: 0,
|
||||
available_qty: 0,
|
||||
frozen_qty: 0,
|
||||
vehicle_count: 0,
|
||||
material_count: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -148,8 +180,26 @@ export default {
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
this.fetchSummary()
|
||||
return true
|
||||
},
|
||||
formatNum(value) {
|
||||
const num = Number(value || 0)
|
||||
return num.toFixed(3).replace(/\.?0+$/, '')
|
||||
},
|
||||
fetchSummary() {
|
||||
crudStructivt.getSummary(this.query).then(res => {
|
||||
this.summary = Object.assign({}, this.summary, res || {})
|
||||
}).catch(() => {
|
||||
this.summary = {
|
||||
total_qty: 0,
|
||||
available_qty: 0,
|
||||
frozen_qty: 0,
|
||||
vehicle_count: 0,
|
||||
material_count: 0
|
||||
}
|
||||
})
|
||||
},
|
||||
hand(value) {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
@@ -172,20 +222,62 @@ export default {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
downdtl() {
|
||||
if (this.currentRow !== null) {
|
||||
this.showDtlLoading = true
|
||||
download('/api/structivt/download', this.crud.query).then(result => {
|
||||
downloadFile(result, '成品库存', 'xlsx')
|
||||
this.showDtlLoading = false
|
||||
}).catch(() => {
|
||||
this.showDtlLoading = false
|
||||
})
|
||||
}
|
||||
this.exportLoading = true
|
||||
download('/api/structivt/download', this.crud.query).then(result => {
|
||||
downloadFile(result, '库内库存', 'xlsx')
|
||||
this.exportLoading = false
|
||||
}).catch(() => {
|
||||
this.exportLoading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.summary-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(220px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
margin-bottom: 8px;
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
color: #303133;
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.summary-unit {
|
||||
margin-left: 4px;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.summary-container {
|
||||
grid-template-columns: repeat(2, minmax(180px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.summary-container {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -62,4 +62,12 @@ export function excelImport(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getStruct, getStructById, getUnits, save, excelImport }
|
||||
export function getSummary(params) {
|
||||
return request({
|
||||
url: 'api/structivt/summary',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getStruct, getStructById, getUnits, save, excelImport, getSummary }
|
||||
|
||||
Reference in New Issue
Block a user