rev:出库报表新增原销售订单

This commit is contained in:
2024-07-10 08:51:07 +08:00
parent 254b4f4a65
commit 93c1c11f04
2 changed files with 39 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package org.nl.wms.stat.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author Liuxy
@@ -114,7 +116,28 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
JSONObject json = WQL.getWO("ST_IVT_OUTBILLQUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "mst.input_time DESC,dis.box_no");
// 查询此子卷转单之前的销售订单号
List<JSONObject> content = json.getJSONArray("content").toJavaList(JSONObject.class);
String pcsn_in = content.stream()
.map(row -> row.getString("pcsn"))
.collect(Collectors.joining("','"));
List<JSONObject> subList = WQLObject.getWQLObject("pdm_bi_subpackagerelationrecord")
.query("container_name IN ('" + pcsn_in + "') AND io_type = '0' ORDER BY insert_time")
.getResultJSONArray(0).toJavaList(JSONObject.class);
// 查询所有子卷最早的入库时间
for (JSONObject item : content) {
JSONObject jsonSub = subList.stream()
.filter(row -> row.getString("container_name").equals(item.getString("pcsn")))
.min(Comparator.comparing(row -> row.getString("insert_time")))
.orElse(null);
item.put("old_sale_order_name", ObjectUtil.isEmpty(jsonSub) ? item.getString("sale_order_name") : jsonSub.getString("sale_order_name"));
}
json.put("content", content);
return json;
}
@@ -281,6 +304,11 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
JSONObject json = resultJSONArray.getJSONObject(i);
Map<String, Object> mp = new LinkedHashMap<>();
// 查询第一次入库的源销售订单
JSONObject jsonSub = WQLObject.getWQLObject("pdm_bi_subpackagerelationrecord")
.query("container_name = '" + json.getString("pcsn") + "' AND io_type = '0' ORDER BY insert_time")
.uniqueResult(0);
mp.put("仓库", json.getString("stor_name"));
if (ObjectUtil.isNotEmpty(bill_type) && "1004".equals(bill_type)) {
mp.put("移入仓库", json.getString("in_stor_name"));
@@ -312,6 +340,15 @@ public class OutBillQueryServiceImpl implements OutBillQueryService {
mp.put("销售订单", json.getString("sale_order_name"));
mp.put("行号", "");
}
// 原销售订单
try {
mp.put("原销售订单", jsonSub.getString("sale_order_name").substring(0, jsonSub.getString("sale_order_name").indexOf("-")));
mp.put("原行号", jsonSub.getString("sale_order_name").substring(jsonSub.getString("sale_order_name").indexOf("-") + 1, jsonSub.getString("sale_order_name").length()));
} catch (Exception e) {
mp.put("原销售订单", jsonSub.getString("sale_order_name"));
mp.put("原行号", "");
}
mp.put("业务员", json.getString("sales_owner"));
mp.put("出库日期", json.getString("input_time"));
mp.put("产品规格", String.format("%.0f", json.getDoubleValue("width")));