自动化立体仓库 - WMS系统
whycq
2024-11-25 bcb19e8c93c3cabf0d8eb3ee34ed819b3c5a10ef
src/main/java/com/zy/asrs/utils/Utils.java
@@ -1,6 +1,8 @@
package com.zy.asrs.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.Arith;
@@ -441,7 +443,7 @@
        if(Cools.isEmpty(condition) || "null".equals(condition)){
            wrapper.andNew().eq(column,"").or().isNull(column);
        }else {
            wrapper.eq(column,condition);
            wrapper.andNew().eq(column,condition);
        }
    }
@@ -453,6 +455,14 @@
    public static void confirmOnlyMat(Wrapper wrapper, String matnr, String batch, String threeCode, String deadTime){
        wapperSetCondition(wrapper,"matnr",matnr);
        wapperSetCondition(wrapper,"three_code",threeCode);
        wapperSetCondition(wrapper,"dead_time",deadTime);
        wapperSetCondition(wrapper,"batch",batch);
    }
    public static void confirmOnlyMat2(Wrapper wrapper, String orderNo, String matnr, String batch, String threeCode, String deadTime){
        wapperSetCondition(wrapper,"matnr",matnr);
        wapperSetCondition(wrapper,"order_no",orderNo);
        wapperSetCondition(wrapper,"three_code",threeCode);
        wapperSetCondition(wrapper,"dead_time",deadTime);
        wapperSetCondition(wrapper,"batch",batch);
@@ -494,4 +504,57 @@
        }
    }
    public static String getOrderNo(String orderNo, double anfme){
        JSONArray orderArray = new JSONArray();
        //如果订单号为jsonString
        if(orderNo.contains("{")){
            JSONArray jsonArray = JSON.parseArray(orderNo);
            //遍历所有订单号及订单数量
            for (Object o : jsonArray){
                JSONObject orderJson = (JSONObject) o;
                Double orderAnfme = orderJson.getDouble("anfme");
                //如果订单数量为0,则跳过
                if(orderAnfme <= 0){
                    continue;
                }
                if(orderAnfme > anfme){
                    //如果订单数量大于该库存数量,且订单数组为空,则直接返回该订单号,否则就将该订单添加到订单数组
                    if(orderArray.isEmpty()){
                        return orderJson.getString("orderNo");
                    }else {
                        orderJson.put("anfme",anfme);
                        orderArray.add(orderJson);
                    }
                }else {
                    anfme -= orderAnfme;
                    orderArray.add(orderJson);
                }
            }
            return orderArray.toJSONString();
        }else {
            return orderNo;
        }
    }
    public static String orderMergeUpdate(String orderNo, double anfme){
        if(orderNo.contains("{")){
            JSONArray jsonArray = JSON.parseArray(orderNo);
            for(int i=0; i<jsonArray.size(); i++){
                JSONObject orderJson = (JSONObject)jsonArray.get(i);
                Double orderAnfme = orderJson.getDouble("anfme");
                if(orderAnfme > anfme){
                    ((JSONObject) jsonArray.get(i)).put("anfme",orderAnfme - anfme);
                    return jsonArray.toJSONString();
                }else {
                    ((JSONObject) jsonArray.get(i)).put("anfme",0);
                    anfme -= orderAnfme;
                }
            }
            return jsonArray.toJSONString();
        }else {
            return orderNo;
        }
    }
}