From aa2d520a06c371e76ef26c78d426a01fca76a2fc Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期五, 07 二月 2025 14:56:35 +0800
Subject: [PATCH] 1

---
 src/main/java/com/zy/asrs/utils/Utils.java |  161 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 159 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index d2754c8..5dc6c20 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -1,15 +1,23 @@
 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;
 import com.core.common.Cools;
+import com.core.common.SpringUtils;
+import com.zy.asrs.entity.AdjDetl;
+import com.zy.asrs.service.AdjDetlService;
 import com.zy.common.properties.SlaveProperties;
 import com.zy.common.service.CommonService;
 
 import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -250,7 +258,52 @@
     }
 
     public static void main(String[] args) {
-        System.out.println(JSON.toJSONString(getGroupLoc("1305908")));
+        System.out.println(JSON.toJSONString(getGroupInnerLoc("1505908")));
+    }
+
+    /**
+     * 鑾峰彇娣辨祬搴撲綅缁�
+     * @param locNo 搴撲綅鍙�
+     * @return
+     */
+    public static List<String> getGroupDeepLoc(String locNo){
+        int row = getRow(locNo);
+        int bay = getBay(locNo);
+
+        //(1,3,4,10,11)娌℃湁澶栦晶鏂瑰悜搴撲綅缁�,(13,14,16)59鍒椾箣鍐呮病鏈夊渚ф柟鍚戝簱浣嶇粍
+        if (CommonService.FIRST_GROUP_ROW_LIST.contains(row)) {//1鎺�
+            return new ArrayList<>();
+        }
+        if (CommonService.SECOND_GROUP_ROW_LIST.contains(row)) {//3-4鎺�
+            return new ArrayList<>();
+        }
+        if (CommonService.THIRD_GROUP_ROW_LIST.contains(row)) {//6-7鎺�
+            List<String> result = new ArrayList<>();
+            for (Integer row0 : CommonService.THIRD_GROUP_ROW_LIST) {
+                result.add(zerofill(String.valueOf(row0), 2) + locNo.substring(2));
+            }
+            return result;
+        }
+        if (CommonService.FOURTH_GROUP_ROW_LIST.contains(row)) {//8鎺�
+            return new ArrayList<>();
+        }
+        if (CommonService.FIFTH_GROUP_ROW_LIST.contains(row)) {//10-11鎺�
+            return new ArrayList<>();
+        }
+        if (CommonService.SIXTH_GROUP_ROW_LIST.contains(row) && (bay >= 59 && bay <= 61)) {//13-16鎺�59-61鍒楀渚ф柟鍚戝簱浣嶇粍
+            List<String> result = new ArrayList<>();
+            for (Integer row0 : CommonService.SIXTH_GROUP_ROW_LIST) {
+                result.add(zerofill(String.valueOf(row0), 2) + locNo.substring(2));
+            }
+            return result;
+        }
+        if (CommonService.SEVENTH_GROUP_ROW_LIST.contains(row) && bay < 59) {//13-14鎺�59鍒椾箣鍐呮病鏈夊渚ф柟鍚戝簱浣嶇粍
+            return new ArrayList<>();
+        }
+        if (CommonService.EIGHTH_GROUP_ROW_LIST.contains(row) && bay < 59) {//16鎺�59鍒椾箣鍐呮病鏈夊渚ф柟鍚戝簱浣嶇粍
+            return new ArrayList<>();
+        }
+        throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
     }
 
     /**
@@ -390,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);
         }
     }
 
@@ -400,4 +453,108 @@
         wapperSetCondition(wrapper,"isoseq",isoseq);
     }
 
+    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);
+    }
+
+    //鐢熸垚搴撳瓨璋冩暣璁板綍鍗曟嵁鍙� (骞存湀鏃�+4浣嶆祦姘�)
+    public static String generateAdjustOrderNo(){
+        Date date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+        String dateStr = sdf.format(date);
+
+        try {
+            AdjDetlService adjDetlService = SpringUtils.getBean(AdjDetlService.class);
+            AdjDetl adjDetl = adjDetlService.selectOne(new EntityWrapper<AdjDetl>().orderBy("adj_id",false));
+            if(!Cools.isEmpty(adjDetl)){
+                String orderNo = adjDetl.getOrderNo();
+                String lastDateStr = orderNo.substring(0, 8);
+                if(Cools.eq(dateStr,lastDateStr)){
+                    int index = Integer.parseInt(orderNo.substring(8, 12));
+                    index++;
+                    if(index < 10){
+                        return dateStr + "000" + index;
+                    }
+                    if(index < 100){
+                        return dateStr + "00" + index;
+                    }
+                    if(index < 1000){
+                        return dateStr + "0" + index;
+                    }
+                    return dateStr + index;
+                }else {
+                    return dateStr + "0000";
+                }
+            }else {
+                return dateStr + "0000";
+            }
+        }catch (Exception e){
+            return dateStr + "0000";
+        }
+    }
+
+    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;
+        }
+    }
+
 }

--
Gitblit v1.9.1