ALTER TABLE `zh_pos_0`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_1`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_2`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_3`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_4`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_5`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_6`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_7`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_8`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_9`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_10`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_11`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_12`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_13`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_14`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_15`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_16`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_17`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_18`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_pos_19`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

Update zh_pos_0 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_1 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_2 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_3 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_4 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_5 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_6 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_7 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_8 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_9 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_10 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_11 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_12 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_13 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_14 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_15 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_16 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_17 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_18 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_pos_19 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;

ALTER TABLE `zh_revise_pos_0`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_1`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_2`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_3`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_4`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_5`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_6`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_7`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_8`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_9`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_10`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_11`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_12`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_13`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_14`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_15`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_16`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_17`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_18`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

ALTER TABLE `zh_revise_pos_19`
MODIFY COLUMN `add_stage`  int(11) NOT NULL COMMENT '新增期id' AFTER `quantity`,
ADD COLUMN `add_stage_order`  tinyint(4) NOT NULL DEFAULT 0 COMMENT '新增期序号' AFTER `add_stage`;

Update zh_revise_pos_0 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_1 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_2 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_3 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_4 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_5 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_6 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_7 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_8 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_9 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_10 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_11 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_12 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_13 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_14 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_15 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_16 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_17 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_18 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;
Update zh_revise_pos_19 p Left Join zh_stage s ON p.add_stage = s.id Set p.add_stage_order = s.order where p.add_stage_order > 0;

CREATE TABLE `zh_change_revise_log`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL,
  `cid` int(11) NOT NULL COMMENT '变更令id',
  `lid` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '插入的清单uuid',
  `pid` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '插入的计量单元uuid',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '清单名称或计量单元编号',
  `create_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更新增部位记录表';
