chenlong
11 months ago
7 changed files with 190 additions and 3 deletions
@ -0,0 +1,39 @@
|
||||
package com.logpm.report.controller; |
||||
|
||||
import com.logpm.report.service.StockOutDetailService; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.tool.api.R; |
||||
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 java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 库存品出库明细 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(path = "/stock-out-detail") |
||||
public class StockOutDetailController extends BladeController { |
||||
|
||||
private StockOutDetailService test; |
||||
|
||||
/** |
||||
* 报表数据 |
||||
* @param query 所有请求参数 |
||||
* @param current 当前页 |
||||
* @param size 每页数据量 |
||||
*/ |
||||
@GetMapping("/report") |
||||
public R<List<Map<String, Object>>> report( |
||||
@RequestParam Map<String, Object> query, |
||||
@RequestParam Integer current, |
||||
@RequestParam Integer size){ |
||||
List<Map<String, Object>> data = test.report(current, size, query); |
||||
return data(data); |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.logpm.report.mapper; |
||||
|
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 库存出库明细 |
||||
*/ |
||||
@Mapper |
||||
public interface StockOutDetailMapper { |
||||
|
||||
List<Map<String, Object>> getList(Map<String, Object> where); |
||||
|
||||
Integer getCount(Map<String, Object> where); |
||||
} |
@ -0,0 +1,71 @@
|
||||
<?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="com.logpm.report.mapper.StockOutDetailMapper"> |
||||
|
||||
<!-- |
||||
提示:以下表信息需要加索引,以增加查询速度 |
||||
logpm_distribution_stock 表的 coding |
||||
logpm_distribution_stock_list_info 表的 package_code |
||||
--> |
||||
<select id="getList" resultType="java.util.Map"> |
||||
SELECT b.goods_allocation_name -- 货位 |
||||
, a.stock_quantity -- 数量 |
||||
, a.coding -- 包条码 |
||||
, w.name as warehouse_name -- 仓库 |
||||
, c.market_name -- 商场 |
||||
, c.cargo_number -- 物料编码 |
||||
, m.name as material_name -- 物料名称 |
||||
, a.create_time -- 时间 |
||||
, a.conditions as out_type -- 出库类型 |
||||
, e.note_number -- 配送单号 |
||||
, e.train_number -- 车次号 |
||||
, a.reservation_code -- 预约单号 |
||||
, r.consignee as client_name -- 收货人(客户名称) |
||||
, e.id |
||||
|
||||
<include refid="tables" /> |
||||
|
||||
<include refid="wheres" /> |
||||
|
||||
LIMIT #{offset}, #{size} |
||||
</select> |
||||
|
||||
<select id="getCount" resultType="java.lang.Integer"> |
||||
SELECT count(*) |
||||
<include refid="tables" /> |
||||
|
||||
<include refid="wheres" /> |
||||
</select> |
||||
|
||||
<sql id="tables"> |
||||
FROM logpm_distribution_stock a |
||||
INNER JOIN logpm_warehouse_goods_allocation b ON a.allocation_id = b.id AND b.is_deleted = 0 |
||||
INNER JOIN logpm_warehouse_warehouse w ON w.id = b.warehouse_id AND w.is_deleted = 0 |
||||
INNER JOIN logpm_distribution_stock_list_info c ON c.package_code = a.coding AND c.is_deleted = 0 |
||||
INNER JOIN logpm_basicdata_material m ON m.id = c.material_id AND c.is_deleted = 0 |
||||
INNER JOIN logpm_distribution_signfor d |
||||
ON d.reservation_id = a.reservation_id AND a.outbound_type IN (1, 2) AND d.is_deleted = 0 |
||||
INNER JOIN logpm_distribution_delivery_list e ON e.id = d.delivery_id AND e.is_deleted = 0 |
||||
INNER JOIN logpm_distribution_reservation r ON r.id = d.reservation_id AND r.is_deleted = 0 |
||||
</sql> |
||||
|
||||
<sql id="wheres"> |
||||
WHERE 1 = 1 |
||||
<if test="warehouse_id != null"> |
||||
AND b.warehouse_id = #{warehouse_id} |
||||
</if> |
||||
<if test="market_name != null"> |
||||
AND c.market_name LIKE CONCAT('%', #{market_name} , '%') |
||||
</if> |
||||
<if test="note_number != null"> |
||||
AND e.note_number = #{note_number} |
||||
</if> |
||||
<if test="reservation_code != null"> |
||||
AND a.reservation_code = #{reservation_code} |
||||
</if> |
||||
<if test="client_name != null"> |
||||
AND r.consignee LIKE CONCAT('%', #{client_name}, '%') |
||||
</if> |
||||
</sql> |
||||
|
||||
</mapper> |
@ -0,0 +1,9 @@
|
||||
package com.logpm.report.service; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface StockOutDetailService { |
||||
|
||||
List<Map<String, Object>> report(Integer current, Integer size, Map<String, Object> where); |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.logpm.report.service.impl; |
||||
|
||||
import com.logpm.report.mapper.StockOutDetailMapper; |
||||
import com.logpm.report.service.StockOutDetailService; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 库存品出口明细报表 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
public class StockOutDetailServiceImp implements StockOutDetailService { |
||||
|
||||
private StockOutDetailMapper testMapper; |
||||
|
||||
/** |
||||
* 报表统计信息 |
||||
* |
||||
* @param current 当前页 |
||||
* @param size 每页大小 |
||||
* @param query 所有的query参数 |
||||
* @return 查询结果 |
||||
*/ |
||||
@Override |
||||
public List<Map<String, Object>> report(Integer current, Integer size, Map<String, Object> query) { |
||||
Integer offset = (current - 1) * size; |
||||
boolean getCacheCount = true; |
||||
long whereCount = query.entrySet().stream().filter((entry) -> entry.getValue() != null) |
||||
.filter(entry -> !entry.getKey().equals("current") && !entry.getKey().equals("size")) |
||||
.count(); |
||||
if (whereCount > 0) { |
||||
getCacheCount = false; |
||||
} |
||||
|
||||
query.put("offset", offset); |
||||
query.put("size", size); |
||||
|
||||
List<Map<String, Object>> List = testMapper.getList(query); |
||||
Integer count = testMapper.getCount(query); |
||||
|
||||
return List; |
||||
} |
||||
} |
Loading…
Reference in new issue