opt:发货区管理接口优化
This commit is contained in:
@@ -90,6 +90,7 @@ public interface StructattrService {
|
||||
* @return
|
||||
*/
|
||||
JSONArray getStructByCodesFs(JSONArray json);
|
||||
Map getStructByCodesFsAnNum(JSONArray json);
|
||||
|
||||
/**
|
||||
* 解锁点位
|
||||
|
||||
@@ -28,9 +28,12 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zhouz
|
||||
@@ -319,6 +322,33 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
public JSONArray getStructByCodesFs(JSONArray jsonArray) {
|
||||
WQLObject attrTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray arr = new JSONArray();
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject js = jsonArray.getJSONObject(i);
|
||||
String struct_id = js.getString("struct_id");
|
||||
if (ObjectUtil.isEmpty(struct_id)) {
|
||||
continue;
|
||||
}
|
||||
list.add(struct_id);
|
||||
}
|
||||
String sql = "('" + list.stream().collect(Collectors.joining("','")) + "')";
|
||||
JSONArray array = WQL
|
||||
.getWO("QST_STRUCTATTR")
|
||||
.addParamMap(MapOf.of("struct_ids", sql, "flag", "3"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
Map<String, JSONObject> pointMap = array.stream().collect(HashMap::new, (BiConsumer<HashMap<String, JSONObject>, Object>) (m, o) -> {
|
||||
JSONObject item = (JSONObject) o;
|
||||
m.put(item.getString("point_id"), item);
|
||||
}, HashMap::putAll);
|
||||
|
||||
JSONArray attrs = attrTab.query("point_id in " + sql).getResultJSONArray(0);
|
||||
Map<String, JSONObject> attrMap = attrs.stream().collect(HashMap::new, (BiConsumer<HashMap<String, JSONObject>, Object>) (m, o) -> {
|
||||
JSONObject item = (JSONObject) o;
|
||||
m.put(item.getString("point_id"), item);
|
||||
}, HashMap::putAll);
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject obj = new JSONObject();
|
||||
JSONObject js = jsonArray.getJSONObject(i);
|
||||
@@ -327,18 +357,10 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
if (ObjectUtil.isEmpty(struct_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int struct_status = 2;
|
||||
// 获取信息 1蓝色空载具 2黄色木箱 3绿色空位 4灰色禁用
|
||||
// 查找详细信息, 这里可能是有多条数据
|
||||
JSONArray array = WQL
|
||||
.getWO("QST_STRUCTATTR")
|
||||
.addParamMap(MapOf.of("struct_id", struct_id, "flag", "2"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
// 计算子卷净重
|
||||
JSONObject json = array.getJSONObject(0);
|
||||
JSONObject json = pointMap.get(struct_id);
|
||||
if (ObjectUtil.isNotEmpty(json.getString("net_weight"))) {
|
||||
BigDecimal container_weight = array.stream().map(row -> ((JSONObject) row).getBigDecimal("net_weight")).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
@@ -348,11 +370,8 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取仓位表中的信息
|
||||
JSONObject strInfo = attrTab
|
||||
.query("point_id = '" + struct_id + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(strInfo.getString("vehicle_code"))) {
|
||||
JSONObject strInfo = attrMap.get(struct_id);
|
||||
if (strInfo !=null && ObjectUtil.isEmpty(strInfo.getString("vehicle_code"))) {
|
||||
// 空位
|
||||
struct_status = 3;
|
||||
}
|
||||
@@ -368,6 +387,76 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getStructByCodesFsAnNum(JSONArray jsonArray) {
|
||||
WQLObject attrTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray arr = new JSONArray();
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject js = jsonArray.getJSONObject(i);
|
||||
String struct_id = js.getString("struct_id");
|
||||
if (ObjectUtil.isEmpty(struct_id)) {
|
||||
continue;
|
||||
}
|
||||
list.add(struct_id);
|
||||
}
|
||||
String sql = "('" + list.stream().collect(Collectors.joining("','")) + "')";
|
||||
JSONArray array = WQL
|
||||
.getWO("QST_STRUCTATTR")
|
||||
.addParamMap(MapOf.of("struct_ids", sql, "flag", "3"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
Map<String, JSONObject> pointMap = array.stream().collect(HashMap::new, (BiConsumer<HashMap<String, JSONObject>, Object>) (m, o) -> {
|
||||
JSONObject item = (JSONObject) o;
|
||||
m.put(item.getString("point_id"), item);
|
||||
}, HashMap::putAll);
|
||||
|
||||
JSONArray attrs = attrTab.query("point_id in " + sql).getResultJSONArray(0);
|
||||
Map<String, JSONObject> attrMap = attrs.stream().collect(HashMap::new, (BiConsumer<HashMap<String, JSONObject>, Object>) (m, o) -> {
|
||||
JSONObject item = (JSONObject) o;
|
||||
m.put(item.getString("point_id"), item);
|
||||
}, HashMap::putAll);
|
||||
int unMoney = 0;
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject obj = new JSONObject();
|
||||
JSONObject js = jsonArray.getJSONObject(i);
|
||||
String struct_id = js.getString("struct_id");
|
||||
|
||||
if (ObjectUtil.isEmpty(struct_id)) {
|
||||
continue;
|
||||
}
|
||||
int struct_status = 2;
|
||||
// 获取信息 1蓝色空载具 2黄色木箱 3绿色空位 4灰色禁用
|
||||
// 计算子卷净重
|
||||
JSONObject json = pointMap.get(struct_id);
|
||||
if (ObjectUtil.isNotEmpty(json.getString("net_weight"))) {
|
||||
BigDecimal container_weight = array.stream().map(row -> ((JSONObject) row).getBigDecimal("net_weight")).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
for (int j = 0; j < array.size(); j++) {
|
||||
JSONObject jsonObject = array.getJSONObject(j);
|
||||
jsonObject.put("container_weight", container_weight);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject strInfo = attrMap.get(struct_id);
|
||||
if (strInfo !=null && ObjectUtil.isEmpty(strInfo.getString("vehicle_code"))) {
|
||||
// 空位
|
||||
unMoney++;
|
||||
struct_status = 3;
|
||||
}
|
||||
|
||||
// 剩余层数货位信息没统计,统计可以用obj.put(key, value)返给前端,前端在initStatus()就可以遍历去获取,给节点赋值
|
||||
obj.put("data", array);
|
||||
obj.put("struct_status", struct_status);
|
||||
obj.put("struct_id", strInfo.getString("point_id"));
|
||||
obj.put("struct_code", strInfo.getString("point_code"));
|
||||
obj.put("id", js.getString("id")); // 设备不存在就只保留id,方便前端查看
|
||||
arr.add(obj);
|
||||
}
|
||||
return MapOf.of("data",arr,"haveMoney",arr.size()-unMoney,"unMoney",unMoney);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject unLockPoint(JSONObject whereJson) {
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.struct_id TYPEAS s_string
|
||||
输入.struct_id TYPEAS s_string
|
||||
输入.struct_ids TYPEAS f_string
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
@@ -83,3 +84,26 @@
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
QUERY
|
||||
SELECT
|
||||
attr.*,
|
||||
sub.package_box_sn,
|
||||
sub.quanlity_in_box,
|
||||
sub.box_weight,
|
||||
sub.sale_order_name,
|
||||
sub.container_name,
|
||||
sub.product_description,
|
||||
sub.net_weight
|
||||
FROM
|
||||
sch_base_point attr
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = attr.vehicle_code
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.struct_ids <> ""
|
||||
attr.point_id in 输入.struct_ids
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user