惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
雷峰网
雷峰网
S
Securelist
V
Vulnerabilities – Threatpost
S
SegmentFault 最新的问题
T
The Exploit Database - CXSecurity.com
A
About on SuperTechFans
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
V2EX
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
L
Lohrmann on Cybersecurity
S
Security Affairs
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
H
Heimdal Security Blog
L
LINUX DO - 热门话题
月光博客
月光博客
Apple Machine Learning Research
Apple Machine Learning Research
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
D
DataBreaches.Net
N
Netflix TechBlog - Medium
The Hacker News
The Hacker News
N
News and Events Feed by Topic
C
Check Point Blog
博客园_首页
Scott Helme
Scott Helme
T
Troy Hunt's Blog
U
Unit 42

博客园 - hi-justin

O.O 一次蛮搞笑的面试 为什么老是这么忙呢? 祝自己生日快乐:) 反省一下 实现了一个一直以来梦想 Time 如何用正确的方法来写出质量好的软件的75条体会[收藏] 還有一塊錢哪去了? 爆強ERP Never forget :) 終於可以稍微輕松一下了 美好的一天,耶 [備忘]用於分解字符串的自定義函數 [備忘]动态显示图片 寫下來,免得下次又忘了 小記一下 過梅林海關的幾次有趣經歷
遇到這種問題,你會怎麼做?
hi-justin · 2005-03-14 · via 博客园 - hi-justin

最近在項目中遇到了這樣一個爆復雜的問題,請教各位前輩,可以用什麼比較好的方法來解決類似問題?請給出您的寶貴的Idea,非常感謝!
問題相關描述如下:

需實現一個功能,就是將某些東東(如A、B、C、D)放入某個倉庫中的某一個盒子中,用程序來得出如數量50個A物品需要放到哪些盒子中,這些盒子需要
符合物品的某些條件且必須是空的(用一個UseStatus來表示該盒子的狀態,如0為空閒2為占用)
然而,產品A可能有一些預設的存放條件,比如說該物品必須要放在某一個倉庫?某一個區域等等。
去找這些盒子的時候,如果發現符合預設條件的盒子沒有,則找出與該條件最相近的。
這個功能目前已經基本實現,不過采用的算法比較笨拙,就是列舉出某個物品預設條件是6個預設條件(StoreCode,AreaCode,PipeCode,ShelfCode,LayerCode,RowCode)中的任意一個組合
而且在並法控制上做得不理想,這個處理過程是我在存儲過程中來實現的。
哎,狂暈,不知道描述清楚了沒,請看以下數據表

如存在表LocationInfo用於存放倉庫中儲位(也就是上面所說的盒子)的信息,結構如下:
LocationID(儲位代碼) 
StoreCode(倉庫代碼)
AreaCode(區域代碼)
PipeCode(管道代碼)
ShelfCode(貨架代碼)
LayerCode(層級代碼)
RowCode(格級代碼)
UseStatus(使用狀態:0為空閒,1為鎖定,2為占用)

LocationID StoreCode AreaCode PipeCode ShelfCode LayerCode RowCode UseStatus
----------------------------------------------------------------------------------------------------------------------------
A-P13-1     A              03           P             P              01            13             0
A-B15-4     A              03           P             P              04            15             0
B-C12-3     B              03           C             C              03            12             0
B-P13-7     B              02           P             P              07            13             0
C-T19-6     C              03           T              T              06            19             0
C-T19-7     C              03           T              T              07            19              0
C-T19-8     C              03           T              T              08            19              0
C-T19-9     C              03           T              T              09            19              0
C-T20-1     C              03           T              T              01            20              0
C-T20-2     C              03           T              T              02            20              0

以上記錄內容說明:
如A-P13-1的位置是倉庫A中03區域中P管道P貨架01層13格
...

如存在表ProductInfo用於存放產品信息,結構如下:
ProductID(產品編號)
ProductName(產品名稱)
StorageLife(保存期限)
PileNum(堆放箱數)
StoreCode(預設存放倉庫)
AreaCode(預設存放區域)
PipeCode(預設存放管道)
ShelfCode(預設存放貨架)
LayerCode(預設存放層級)
RowCode(預設存放格級)

ProductID ProductName StorageLife PileNum StoreCode AreaCode PipeCode ShelfCode LayerCode RowCode
----------------------------------------------------------------------------------------------------------------------------
5171001  Product1         365              50         A              A              P             S1                                    
5171002  Product2         365              48         B                              H                                2  
5171003  Product3         180              35                 
5171004  Product4         120              50         C                                                                 1
5171005  Product5         365              60         D              D              N            
5171006  Product6         180              50         B
5171007  Product7         365              48         A              A                         S2    
5171008  Product8         365              65

以上記錄內容說明:
如5171001產品設定了預設存放條件(該產品需存放在A倉庫的A區域的P1管道的S1貨架上的任何一個Location(儲位)中)
如5171002產品設定了預設存放條件(該產品需存放在B倉庫的任何區域的P3管道的任何貨架的第2層的任何一個Location(儲位)中)
如5171003產品並沒有設定任何預設條件,也就是說該產品可以被存放在任何倉庫任何區域任何管道任何貨架任何層級的任何一個儲位中)
堆放箱數即一個Location中可以存放的數量
該Table中的產品可能預設條件是6個預設條件(StoreCode,AreaCode,PipeCode,ShelfCode,LayerCode,RowCode)中的任意一個組合
...

For example:
現在有編號為5171003的產品70個,我們知道該產品的堆放箱數為35,且該產品沒有預設存放條件(即可以放到任何儲位中)
那麼可以輕松的從LocationInfo(儲位信息表)中Select出狀態為0(空閒)的儲位2個(數量70除以堆放箱數35得出需要2個儲位)
如:
A-P13-1   A    03   P                                 P  01  13                               0
A-B15-4   A    03   P                                 P  04  15                               0

再比如說有編號為5171007的產品50個,這個產品有預設的存放條件:需存放在A倉庫,A-3區域,S2貨架上的任一儲位,則可以到
LocationInfo(儲位信息表)中找狀態為0的倉庫為A區域為A-3貨架為S2的儲位,如果沒有則找條件相近的,如倉庫為A區域為A-3的
或倉庫為A貨架為S2的