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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user