Evaluate the correspondence in the array

Source: Internet
Author: User
Find the corresponding relationship in the array. This post was last edited by lazygc520 at 12:12:16.

Array 1: Array ([0] => Array ([cust_no] => 237033AW0A [lotno] => 3207 [lotno_count] => 360) Array 2: array ([SU13061301033] => Array ([0] => Array ([0] => 2013-06-19 09:00:00 [1] => X02B [2] => 237033AW0A [3] => 15 [4] => 14 [5] => 210 )) [SU13061301032] => Array ([0] => Array ([0] => 2013-06-19 09:00:00 [1] => X02B [2] => 237033AW0A [3] => 15 [4] => 17 [5] => 255 )) [SU13061301037] => Array ([0] => Array ([0] => 2013-06-19 09:00:00 [1] => X11Q [2] => 237033AW0A [3] => 15 [4] => 3 [5] => 45) [1] => Array ([0] => 09:00:00 [1] => X11Q [2] => 237033AW0A [3] => 15 [4] => 2 [5] => 30 ))) array 3: Array ([0] => SU13061301033 [1] => SU13061301032 [2] => SU13061301037)

Array 1 indicates the total number obtained.
Array 2 indicates the quantity corresponding to stockno (part starting with SU). The value is entry [5.
Array 3 represents the sequence of stockno in the array.

Can it be obtained based on the sequence of array 3,
When stockno is SU13061301033, the first 210 items in the corresponding array 1 correspond to stockno is SU13061301033,
When stockno is SU13061301032, the remaining items in the corresponding array 1 correspond to stockno is SU13061301033.
And so on.

Does this correspondence exist?


Reply to discussion (solution)

Isn't your array 1 only a group of data?

Isn't your array 1 only a group of data?
In this way, it cannot be matched, right? Only the correspondence between array 1 and array 3 can be obtained.

If no corresponding relationship is found, the required value cannot be obtained?

Which of the following statements correspond to the first 210 items in array 1?

Which of the following statements correspond to the first 210 items in array 1?
I mean the stockno in array 3 is in the front. for example, the first SU13061301033 corresponds to the value 210 in array 2. Then, the value 210 is allocated with the total number in array 1, and the subsequent stockno is allocated with the result of the total number-210.
PS: A problem may occur, so I need to re-view the SQL statement. Reply to you later.

If queuing is used, yes.
But the key lies in the dependency between your data.

If queuing is used, yes.
But the key lies in the dependency between your data.
Okay. Please give me your guidance tomorrow.

You need to clarify your thoughts
When posting data, post the var_export result instead of the result of print_r.
Convenience and convenience

About result storage

You need to clarify your thoughts
When posting data, post the var_export result instead of the result of print_r.
Convenience and convenience

There are three tables: kw_manage, vp_barcode_2d_y, stock_detail, which correspond to inventory, inventory corresponding batch lotno, and warehouse picking information.

Inventory is stored in the database in packageno units. the batch lotno and quantity corresponding to packageno in the database are obtained through the vp_barcode_2d_y table. the custock_detail contains the information stock_no, corresponding to the relationship: one stock_no corresponds to multiple cust_no and the corresponding quantity.
For example:

SU13061301012(stock_no) A2 2013-06-19 09:00:00 B12D(3) K25B460 237033AW0A(cust_no) 10 15 2013-06-15 15:00:00 2013-06-15 15:30:00SU13061301012(stock_no)  A2 2013-06-19 09:00:00 B12D(3) K25B459 237033AW0A(cust_no)10 15 2013-06-15 15:00:00 2013-06-15 15:30:00

PS: the number in the figure is 10*15 (number of bins * number of bins)
That is to say, there is no inevitable relationship between stock_no and packageno. can I process the correspondence by batch of lotno's first in first?
Or what part of var_export results do you need?

Or a few specific varieties, that is, the discussed values for a single variety
There are two attributes: warehouse receiving batch and quantity.
There are two attributes: warehouse picking batch and quantity.

You seem to need statistics: in a warehouse receiving batch, which warehouse receiving batches are composed

I understand it, right?

Or a few specific varieties, that is, the discussed values for a single variety
There are two attributes: warehouse receiving batch and quantity.
There are two attributes: warehouse picking batch and quantity.

You seem to need statistics: in a warehouse receiving batch, which warehouse receiving batches are composed

I understand it, right?
Yes. Correct understanding.

In general, I normally store data in the database first, and then use the data in the database to match the requirements according to the requirements of the database (stock_detail table.

Warehouse receiving:

CREATE TABLE `kw_manage` (  `ID` int(11) NOT NULL auto_increment,  `username` varchar(10) NOT NULL,  `rkno` varchar(25) NOT NULL,  `packageno` varchar(20) NOT NULL,  `type` varchar(20) NOT NULL,  `cust_no` varchar(20) NOT NULL,  `snp` int(4) NOT NULL,  `wh_info` varchar(20) NOT NULL,  `date` datetime NOT NULL,  PRIMARY KEY  (`ID`),  KEY `packageno` (`packageno`),  KEY `date` (`date`)) ENGINE=MyISAM;INSERT INTO `kw_manage` VALUES (1, 'admin', '201302190001', 'VP3.0 130219001', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-27 10:56:10');INSERT INTO `kw_manage` VALUES (2, 'admin', '201302190001', 'VP3.0 130219002', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-27 10:56:12');INSERT INTO `kw_manage` VALUES (3, 'admin', '201302190001', 'VP3.0 130219003', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-27 10:56:14');INSERT INTO `kw_manage` VALUES (4, 'admin', '201302190001', 'VP3.0 130219004', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:20');INSERT INTO `kw_manage` VALUES (5, 'admin', '201302190001', 'VP3.0 130219005', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:23');INSERT INTO `kw_manage` VALUES (6, 'admin', '201302190001', 'VP3.0 130219006', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:26');INSERT INTO `kw_manage` VALUES (7, 'admin', '201302190001', 'VP3.0 130219007', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:28');INSERT INTO `kw_manage` VALUES (8, 'admin', '201302190001', 'VP3.0 130219008', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:30');INSERT INTO `kw_manage` VALUES (9, 'admin', '201302190001', 'VP3.0 130219009', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:32');INSERT INTO `kw_manage` VALUES (10, 'admin', '201302190001', 'VP3.0 130219010', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:35');INSERT INTO `kw_manage` VALUES (11, 'admin', '201302190001', 'VP3.0 130219011', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:38');INSERT INTO `kw_manage` VALUES (12, 'admin', '201302190001', 'VP3.0 130219012', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:45:42');INSERT INTO `kw_manage` VALUES (13, 'admin', '201302190002', 'VP3.0 130219013', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:06');INSERT INTO `kw_manage` VALUES (14, 'admin', '201302190002', 'VP3.0 130219014', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:09');INSERT INTO `kw_manage` VALUES (15, 'admin', '201302190002', 'VP3.0 130219015', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:11');INSERT INTO `kw_manage` VALUES (16, 'admin', '201302190002', 'VP3.0 130219016', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:13');INSERT INTO `kw_manage` VALUES (17, 'admin', '201302190002', 'VP3.0 130219017', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:15');INSERT INTO `kw_manage` VALUES (18, 'admin', '201302190002', 'VP3.0 130219018', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:18');INSERT INTO `kw_manage` VALUES (19, 'admin', '201302190002', 'VP3.0 130219019', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:19');INSERT INTO `kw_manage` VALUES (20, 'admin', '201302190002', 'VP3.0 130219020', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:22');INSERT INTO `kw_manage` VALUES (21, 'admin', '201302190002', 'VP3.0 130219021', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:27');INSERT INTO `kw_manage` VALUES (22, 'admin', '201302190002', 'VP3.0 130219022', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:30');INSERT INTO `kw_manage` VALUES (23, 'admin', '201302190002', 'VP3.0 130219023', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:33');INSERT INTO `kw_manage` VALUES (24, 'admin', '201302190002', 'VP3.0 130219024', 'BEM330-500', '23703 3AW0A', 15, 'YE-00-01', '2013-06-28 08:46:36');INSERT INTO `kw_manage` VALUES (25, 'admin', '201302190023', 'VP3.0 130219048', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:16:57');INSERT INTO `kw_manage` VALUES (26, 'admin', '201302190023', 'VP3.0 130219049', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:01');INSERT INTO `kw_manage` VALUES (27, 'admin', '201302190023', 'VP3.0 130219050', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:08');INSERT INTO `kw_manage` VALUES (28, 'admin', '201302190023', 'VP3.0 130219051', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:13');INSERT INTO `kw_manage` VALUES (29, 'admin', '201302190023', 'VP3.0 130219052', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:23');INSERT INTO `kw_manage` VALUES (30, 'admin', '201302190023', 'VP3.0 130219053', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:30');INSERT INTO `kw_manage` VALUES (31, 'admin', '201302190023', 'VP3.0 130219054', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:39');INSERT INTO `kw_manage` VALUES (32, 'admin', '201302190023', 'VP3.0 130219055', 'MEC718-000', '23710 JE22A', 15, 'YQ-00-01', '2013-07-08 11:17:54');

Based on the principle of first-in-first-out, the warehouse picking process is as follows:
Warehouse picking quantity known
Traverse the warehouse receiving table and deduct the number of warehouse receiving batches from the warehouse picking quantity until the warehouse picking quantity is less than or equal to 0.
If the outbound quantity is negative, the absolute value is added back.

Based on the principle of first-in-first-out, the warehouse picking process is as follows:
Warehouse picking quantity known
Traverse the warehouse receiving table and deduct the number of warehouse receiving batches from the warehouse picking quantity until the warehouse picking quantity is less than or equal to 0.
If the outbound quantity is negative, the absolute value is added back.
Warehouse picking:

$ Sql4 = "select arr_time, c_type, cust_no, snp, mount, mount * snp as m_total, stock_no from "'. $ t. "'Where stock_no = '". $ stockno [$ j-1]. "'"; // echo $ sql4 .'
'; $ Result4 = mysql_query ($ sql4); $ ar = array (); while ($ var = mysql_fetch_array ($ result4, MYSQL_NUM )) {$ ar [] = $ var;} $ a = array (); foreach ($ ar as $ item) {$ key = array_pop ($ item); if (! Isset ($ a [$ key]) $ a [$ key] = array (); $ a [$ key] [] = $ item;} var_xeport result: array ('su13061301033' => array (0 => array (0 => '2017-06-19 09:00:00 ', 1 => 'x02b', 2 => '237033aw0a ', 3 => '15', 4 => '14', 5 => '123 ',),),)


Warehouse receiving:
$ SQL = "select DISTINCT B. packageno,. stock_no from 'stock _ detail 'as a, 'kw _ manage' as B where. stock_no = '". $ stockno [$ j-1]. "'and. cust_no = replace (B. cust_no, '','') "; // echo $ SQL.'
'; $ Result = mysql_query ($ SQL); $ res = array (); // Set an array for storing results while ($ row = mysql_fetch_array ($ result, MYSQL_ASSOC )) {$ sql2 = "select lotno, count (lotno) from 'VP _ barcode_2d_y 'where packageno = '". $ row ['packageno']. "'group by lotno, packageno order by lotno asc"; // echo $ sql2 .'
'; $ Result2 = mysql_query ($ sql2); $ var = array (); while ($ row2 = mysql_fetch_array ($ result2, MYSQL_NUM )) {if (isset ($ res [$ row2 [0]) $ res [$ row2 [0] ['count'] + = $ row2 [1]; else $ res [$ row2 [0] = array ('lotno' => $ row2 [0], 'count' => $ row2 [1]);} ksort ($ res); // print_r ($ res); $ arrs = array (); foreach ($ res as $ v2) {$ arrs [] = $ v2 ;} var_export ($ arrs); result: array (0 => array ('lotno' => '000000', 'count' => 3207 ,),) // The result is the total number of input records. Quantity. do you need the number of scores?

What do you mean by the stored code?

What do you mean by the stored code?
Do not need to know the total warehouse receiving amount? How can I determine whether the incoming batch has been matched and does not return to other stock_no results?

The data you provided is not compatible with the code.
Unknown column 'Arr _ time' in 'Field list'

The data just passed out of the warehouse is not complete and cannot be pasted. Make up now.

CREATE TABLE `stock_detail` (  `ID` int(11) NOT NULL auto_increment,`stock_no` varchar(20) NOT NULL,`adress` varchar(10) NOT NULL,`arr_time` datetime NOT NULL,`c_type` varchar(20) NOT NULL,`pu_no` varchar(20) NOT NULL,`cust_no` varchar(20) NOT NULL,`mount` int(10) NOT NULL,`snp` int(10) NOT NULL,`c1_time` datetime NOT NULL,`c2_time` datetime NOT NULL, PRIMARY KEY  (`ID`)) ENGINE=MyISAM;INSERT INTO `stock_detail` VALUES (42, 'SU13061301029', 'B', '2013-06-20 22:00:00', 'P32L', 'K25K498', '310F61VA5A', 9, 16, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (43, 'SU13061301029', 'B', '2013-06-20 22:00:00', 'P32L', 'K25K497', '310F61VA5A', 10, 16, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (44, 'SU13061301031', 'A1', '2013-06-20 09:00:00', 'X02B', 'K25B418', '237033AW0A', 14, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (45, 'SU13061301030', 'A1', '2013-06-20 09:00:00', 'X02B', 'K25B417', '237033AW0A', 17, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (46, 'SU13061301033', 'A1', '2013-06-19 09:00:00', 'X02B', 'K25B416', '237033AW0A', 14, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (47, 'SU13061301032', 'A1', '2013-06-19 09:00:00', 'X02B', 'K25B415', '237033AW0A', 17, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (48, 'SU13061301034', 'A1', '2013-06-19 09:00:00', 'X11Q', 'K25B407', '237033AW0A', 6, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (49, 'SU13061301034', 'A1', '2013-06-19 09:00:00', 'X11Q', 'K25B408', '237033AW0A', 9, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (50, 'SU13061301035', 'A1', '2013-06-20 09:00:00', 'X11Q', 'K25B409', '237033AW0A', 7, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (51, 'SU13061301035', 'A1', '2013-06-20 09:00:00', 'X11Q', 'K25B410', '237033AW0A', 9, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (52, 'SU13061301036', 'A1', '2013-06-20 09:00:00', 'X11Q', 'K25B434', '237033AW0A', 3, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (53, 'SU13061301036', 'A1', '2013-06-20 09:00:00', 'X11Q', 'K25B433', '237033AW0A', 2, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (54, 'SU13061301037', 'A1', '2013-06-19 09:00:00', 'X11Q', 'K25B431', '237033AW0A', 3, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (55, 'SU13061301037', 'A1', '2013-06-19 09:00:00', 'X11Q', 'K25B432', '237033AW0A', 2, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (56, 'SU13061500001', 'A1', '2013-06-20 09:00:00', 'L11K', 'C6E0085', '23703EX80A', 2, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');INSERT INTO `stock_detail` VALUES (57, 'SU13061500002', 'A1', '2013-06-20 09:00:00', 'X11Q', 'C6E0084', '237033AW0A', 1, 15, '2013-06-15 15:00:00', '2013-06-15 15:30:00');

The data you provided is not compatible with the code.
Unknown column 'Arr _ time' in 'Field list'
Annoying: 20 #

Based on the principle of first-in-first-out, the warehouse picking process is as follows:
Warehouse picking quantity known
Traverse the warehouse receiving table and deduct the number of warehouse receiving batches from the warehouse picking quantity until the warehouse picking quantity is less than or equal to 0.
If the outbound quantity is negative, the absolute value is added back.

For example, I don't understand the meaning of this sentence.
Traverse the warehouse receiving table and deduct the number of warehouse receiving batches from the warehouse picking quantity.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.