/*
* April 28
* Add packageListStatus
*/

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('fa38d088e1084764b083c9640e5a51bf', 'packageListStatus', '装箱单状态', '0', '待处理', 'Pending', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('52fb1ddee71046bface6ff55b719450e', 'packageListStatus', '装箱单状态', '1', '处理中', 'In Processing', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('63145867d1994644a6e48861dc364b31', 'packageListStatus', '装箱单状态', '2', '已完成', 'Completed', '1', 1000, null);

/*
* April 29
* Add whsOutStatus
*/

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('3ba807d3247a4887a1c63af3d8685fad', 'whsOutStatus', '出库任务状态', '0', '待处理', 'Pending', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('8e3743612565483aa07e6ea32011e36c', 'whsOutStatus', '出库任务状态', '1', '处理中', 'In Processing', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('ac8e5d6a19a74758b1000a9bff98344a', 'whsOutStatus', '出库任务状态', '2', '已完成', 'Completed', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('d7b42924888c437f9156cae6771012fb', 'whsOutStatus', '出库任务状态', '3', '已关闭', 'Completed', '1', 1000, null);

/*
* May 10
* Add Inventory Check data
*/
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('40a3499373c04cf7a2656a0d2a89556f', 'inventoryCheckCategory', '盘点类别', '1', '日常盘点', '日常盘点', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('1d056727800c47fe8c6b7b946d195f31', 'inventoryCheckCategory', '盘点类别', '2', '月度盘点', '月度盘点', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('81a376de6c3744489456650aac8f39e3', 'inventoryCheckMold', '盘点类型', '1', '明盘', '明盘', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('50186dc42e874fbca46c57d571efb0de', 'inventoryCheckMold', '盘点类型', '2', '盲盘', '盲盘', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('d96a379b409a4f4c845fc69f95bd3fe8', 'inventoryCheckResult', '盘点结果', '1', '账实相符', '账实相符', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('a09c4b14a9554593bbc4838bd8cac8ac', 'inventoryCheckResult', '盘点结果', '2', '盘盈', '盘盈', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('53cf26371c3b4bb6a9fd90d4b33be529', 'inventoryCheckResult', '盘点结果', '3', '盘亏', '盘亏', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('ca998a865dd84472a9efe06af3e0b940', 'inventoryCheckResult', '盘点结果', '4', '盘盈盘亏', '盘盈盘亏', '1', 1000, '');

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('5a455643d61d461c9a826621941be5b5', 'isInventoryCheckReview', '是否复盘', '1', '初盘', '初盘', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('665229a04ac645f3b1d5906fad33ecd6', 'isInventoryCheckReview', '是否复盘', '2', '复盘', '复盘', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('9b608fc7205241c5b57728f380a54423', 'inventoryCheckStatus', '盘点状态', '1', '待盘点', '待盘点', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('7cbe985ae57d47b1aabb87b1378e3f57', 'inventoryCheckStatus', '盘点状态', '2', '盘点中', '盘点中', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('9577d9660c2444ef99501f1b0b3d7430', 'inventoryCheckStatus', '盘点状态', '3', '复盘中', '复盘中', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('57cbe79e239b4b09840555a6f3b23958', 'inventoryCheckStatus', '盘点状态', '4', '处理中', '处理中', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('1e82d1ffb6554ffdaded58c087611813', 'inventoryCheckStatus', '盘点状态', '5', '关闭(完成)', '关闭(完成)', '1', 1000, null);

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('dd77a22d160a425792e91aabaeb4cef1', 'INVCheckActionType', '盘盈盘亏类别', '701', '盘盈', '盘盈', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('ae0bfa3eda9e40d3a153a1f6157543cf', 'INVCheckActionType', '盘盈盘亏类别', '702', '盘亏', '盘亏', '1', 1000, '');

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('c4e504c0664d463dae14eb5d4ea5be4d', 'INVCheckActionStatus', '盘盈盘亏任务状态', '6', '提交SAP失败', 'Failed send SAP', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('dc4cff7fb115402db2978c9e5c733430', 'INVCheckActionStatus', '盘盈盘亏任务状态', '1', '待处理', 'Pending', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('cc708cead71746a2aac7e6a1ffd6f635', 'INVCheckActionStatus', '盘盈盘亏任务状态', '2', '审批中', '审批中', '0', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('175451917339449d8ee785564add684c', 'INVCheckActionStatus', '盘盈盘亏任务状态', '5', '审批不通过', '审批不通过', '0', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('884580298748416a88168977ab8b58ec', 'INVCheckActionStatus', '盘盈盘亏任务状态', '3', '审批通过(待上传SAP)', '审批通过(待上传SAP)', '0', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('e516216d352f4548ad5b54a07b11dd3e', 'INVCheckActionStatus', '盘盈盘亏任务状态', '4', '关闭(完成)', 'Completed', '1', 1000, 'update');

/**
  *May 11 添加盘点选取范围
  */

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('02ccff64e61144189918b194ce82e5ac', 'InvChkScope', '盘点范围', '1', '按备件手册', 'By Material Menu', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('bb333d91b08041fe95d94c80209f0290', 'InvChkScope', '盘点范围', '2', '按货架', 'By Warehouse Scope', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('1d17450b654a4889ab2612565eadbbff', 'InvChkScope', '盘点范围', '3', '按出入日期', 'By Date', '1', 1000, '');

/*
* May 26,
*/
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('bf5492a7b6b0403289ddac069104ef73', 'whsOperateLogType', '日志类型', '1', '自管仓仓库库存日志', 'Nansha WH Inventory', '1', 1000, '4');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('bddb068d68ff45a89dae0b9a3a0c5b1c', 'whsOperateLogType', '日志类型', '2', '自管仓储位库存日志', 'Nansha Storage Inventory', '1', 1000, '2');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('2f3bebc544a045c09d709b15fa017d14', 'whsOperateLogType', '日志类型', '3', '海外仓仓库库存日志', 'Oversea WH Inventory', '1', 1000, '3');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('9825a395cb4046b2bff2df4caf82480a', 'whsOperateLogType', '日志类型', '4', '海外仓储位库存日志', 'Oversea Storage Inventory', '1', 1000, '5');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('287a017b0dfe49e683ba0f50b630e97b', 'whsOperationType', '日志类型', '1', '入库(加仓库库存)', 'In-House(WHS Inv Increase)', '1', 1000, '4');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('86431de34fce43d9bf46a13a12ae3782', 'whsOperationType', '日志类型', '2', '上架(加储位库存)', 'In-Storage(Stoage Inv Increase)', '1', 1000, '2');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('442563398199421ca4084b38edfc029d', 'whsOperationType', '日志类型', '3', '下架(减储位库存)', 'Out-Storage(Stoage Inv Decrease)', '1', 1000, '3');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('dcfbc68b94ab4a689e7e2fa0f9f321f2', 'whsOperationType', '日志类型', '4', '出库(减仓库库存)', 'Out-House(WHS Inv Decrease)', '1', 1000, '5');

/** June 1*/

INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('5c40e965b8154f9b9e026a432cd20c8f', 'whsMoveStatus', '移仓单状态', '1', '草稿', 'Draft', '1', 1000, '4');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('dede2379ecd54ccebde886e8fa674be1', 'whsMoveStatus', '移仓单状态', '2', '移出可执行', 'MoveOut InProcess', '1', 1000, '2');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('49d58f33410b44f590641e7b2de9765b', 'whsMoveStatus', '移仓单状态', '3', '移入可执行', 'MoveIn InProcess', '1', 1000, '3');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('c13e0cba3cc1461abf5983c595125176', 'whsMoveStatus', '移仓单状态', '4', '移入提交(待上传SAP)', 'Waiting for SAP', '1', 1000, '5');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('d186b76d449348daaeb0d518ed9c5209', 'whsMoveStatus', '移仓单状态', '5', '提交SAP成功', 'Submitted SAP Successed', '1', 1000, '6');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('608d2c9605ee4e20b29b1c774bd4d5f4', 'whsMoveStatus', '移仓单状态', '6', '完成', 'Completed', '1', 1000, '7');

/** June 3*/
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('2e2a1beb40de471ab1c6b4e50e132f1d', 'DocumentType', '单据类型', 'SAPDN', 'SAP DN', 'SAP DN', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('1a3ab18b27d047b3be35e254dfbf240c', 'DocumentType', '单据类型', 'NS-OUT-HOUSE', '南沙出库', 'NS PUR Out-House', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('769285d005e04e818e413b49c882429b', 'DocumentType', '单据类型', 'NS-INVCHK', '南沙盘点', 'NS INV Check', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('88f5b37948554e64b6aeccabd0fe4e3d', 'DocumentType', '单据类型', 'PACK-LIST', '装箱单号', 'Pack List', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('3dcef747bad94a71958b881b265b202d', 'DocumentType', '单据类型', 'SHELF-ON-OFF', '南沙上下架', 'NS Shef On/Off', '1', 1000, 'update');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('185b428544b84d7f8595743df5542431', 'DocumentType', '单据类型', 'NS-WHS-MOVE', '南沙移仓', 'NS WHS Move', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('246a5a22fa794bf3bcd2335373b77d48', 'DocumentType', '单据类型', 'NS-WITHDRAW', '南沙移动冲销', 'NS WithDraw', '1', 1000, null);
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('caffd77f2bdc4f19ae731cb8037abdd2', 'DocumentType', '单据类型', 'NS-EXCEPTION', '南沙异常出入库', 'NS Exception IN/Out House', '1', 1000, 'Update');


--增加项目合同号工厂编码数据配置项  -hzc  -20220316
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('aa586a7650df428b8e92fd8d5aa1bc0c', 'factoryProjectCode', '项目合同号工厂编码', 'BJ31_BZ', '贝宁纸尿裤厂', '贝宁纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('7bcba6c1d91342d3815d76fbe77f0ed7', 'factoryProjectCode', '项目合同号工厂编码', 'CI31_CW', '科特五金厂', '科特五金厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('36a385a92b9c47d0a28e4e972ce7631e', 'factoryProjectCode', '项目合同号工厂编码', 'CI61_CT', '科特陶瓷厂', '科特陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('f504de29b7234b8dbc999e4e4e6fce67', 'factoryProjectCode', '项目合同号工厂编码', 'CM31_CZ', '喀麦隆纸尿裤厂', '喀麦隆纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('716bac972f6a415fad7778a3bcd22e55', 'factoryProjectCode', '项目合同号工厂编码', 'CM61_CT', '喀麦隆陶瓷厂', '喀麦隆陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('ee08f44456f74d5ab788daa1b8a95986', 'factoryProjectCode', '项目合同号工厂编码', 'GF01_GX', '加纳洗衣粉厂', '加纳洗衣粉厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('8650deb946ff4c13afebe760d7ea65aa', 'factoryProjectCode', '项目合同号工厂编码', 'GF01_GGX', '加纳后山洗衣粉厂', '加纳后山洗衣粉厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('92b0ccb8b8794111a3d7859aab8b61c4', 'factoryProjectCode', '项目合同号工厂编码', 'GF02_GW', '加纳五金厂', '加纳五金厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('cac99b08489c4f03b70dcefda4028ff9', 'factoryProjectCode', '项目合同号工厂编码', 'GF03_GT', '加纳陶瓷厂', '加纳陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('0be5a50ec9a941ff8b766f09ec669210', 'factoryProjectCode', '项目合同号工厂编码', 'GF31_GZ', '加纳纸尿裤厂', '加纳纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('39902626804c4d619b2ba9c4c06654af', 'factoryProjectCode', '项目合同号工厂编码', 'GN11_JW', '几内亚五金厂', '几内亚五金厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('287caf3bdace4024a8911f833788a356', 'factoryProjectCode', '项目合同号工厂编码', 'GN31_GNZ', '几内亚纸尿裤厂', '几内亚纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('e230af185d384586939eb036759ea19d', 'factoryProjectCode', '项目合同号工厂编码', 'KF01_KT', '肯尼亚陶瓷厂', '肯尼亚陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('010168439724454f811ccfcf8d8d2a07', 'factoryProjectCode', '项目合同号工厂编码', 'KF31_KZ', '肯尼亚纸尿裤厂', '肯尼亚纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('02399fa6753843438641e3226dffec3e', 'factoryProjectCode', '项目合同号工厂编码', 'KF71_KT-JSM', '肯尼亚基苏木陶瓷厂', '肯尼亚基苏木陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('560c684a51194cd0b99d3a4114f07745', 'factoryProjectCode', '项目合同号工厂编码', 'NG31_NZ', '尼日利亚纸尿裤厂', '尼日利亚纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('ef2b3a12e1ab464d93ff8073abb10d84', 'factoryProjectCode', '项目合同号工厂编码', 'SN31_SZ', '塞内纸尿裤厂', '塞内纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('b6ce26ad64d14999a2136d5ade52fee7', 'factoryProjectCode', '项目合同号工厂编码', 'SN61_ST', '塞内陶瓷厂', '塞内陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('e9d855500e3b4e9e9d55a849853af324', 'factoryProjectCode', '项目合同号工厂编码', 'TF01_TX', '坦桑洗衣粉厂', '坦桑洗衣粉厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('33398667749541fdbf4649946240c4b2', 'factoryProjectCode', '项目合同号工厂编码', 'TF02_TT', '坦桑陶瓷厂', '坦桑陶瓷厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('fd3e6cce40c64753a4b347fb72e3ef66', 'factoryProjectCode', '项目合同号工厂编码', 'TF11_TZ', '坦桑纸尿裤厂', '坦桑纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('713fdb335cbb436888a06c87f3662c95', 'factoryProjectCode', '项目合同号工厂编码', 'UG31_UZ', '乌干达纸尿裤厂', '乌干达纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('709357b993b44ffcbe398db70776ce77', 'factoryProjectCode', '项目合同号工厂编码', 'ZM31_ZZ', '赞比亚纸尿裤厂', '赞比亚纸尿裤厂', '1', 1000, '');
INSERT INTO SPMS.ORDER_KEY_VALUE_CONFIG (UUID, FIELD_KEY, FIELD_NAME, KEY_CODE, KEY_CODE_DESC, KEY_CODE_EN_DESC, ENABLED, SORT_NO, REMARK) VALUES ('4658deb219a34ed4be9bb0d60a00faad', 'factoryProjectCode', '项目合同号工厂编码', 'ZM61_ZT', '赞比亚陶瓷厂', '赞比亚陶瓷厂', '1', 1000, '');


--增加常用清单行表字段  -hzc  -20220322
alter table SHOPPING_SCENARIO_DTL add EQUIPMENT_PARTS VARCHAR2(255);
alter table SHOPPING_SCENARIO_DTL add SAFETY_QTY_BASIC_UNIT NUMBER;
alter table SHOPPING_SCENARIO_DTL add SAFETY_INVENTORY_YEAR NUMBER;
alter table SHOPPING_SCENARIO_DTL add STANDARD_CONSUMPTION_LAST_YEAR NUMBER;
alter table SHOPPING_SCENARIO_DTL add INVENTORY_QUANTITY NUMBER;
alter table SHOPPING_SCENARIO_DTL add WAY_QUANTITY NUMBER;
alter table SHOPPING_SCENARIO_DTL add SUPPLEMENT_QUANTITY NUMBER;
alter table SHOPPING_SCENARIO_DTL add CENTRALIZED_PROCUREMENT VARCHAR2(255);
alter table SHOPPING_SCENARIO_DTL add STRATEGIC_GOODS VARCHAR2(255);
comment on column SHOPPING_SCENARIO_DTL.EQUIPMENT_PARTS is '设备部位';
comment on column SHOPPING_SCENARIO_DTL.SAFETY_QTY_BASIC_UNIT is '安全库存';
comment on column SHOPPING_SCENARIO_DTL.SAFETY_INVENTORY_YEAR is '安全库存年限';
comment on column SHOPPING_SCENARIO_DTL.STANDARD_CONSUMPTION_LAST_YEAR is '上年度使用量';
comment on column SHOPPING_SCENARIO_DTL.INVENTORY_QUANTITY is '仓库库存';
comment on column SHOPPING_SCENARIO_DTL.WAY_QUANTITY is '在途库存';
comment on column SHOPPING_SCENARIO_DTL.SUPPLEMENT_QUANTITY is '补充数量';
comment on column SHOPPING_SCENARIO_DTL.CENTRALIZED_PROCUREMENT is '集中采购';
comment on column SHOPPING_SCENARIO_DTL.STRATEGIC_GOODS is '战略物资';


--增加常用清单头表字段  -hzc  -20220331
alter table SHOPPING_SCENARIO add WORKSHOP_CODE VARCHAR2(255);
comment on column SHOPPING_SCENARIO.WORKSHOP_CODE is '车间编号';


--增加海外仓仓库盘点头表字段  -hzc  -20220401
alter table OVERSEA_INV_CHECK add NATURE_OF_THE_FACTORY VARCHAR2(255);
comment on column OVERSEA_INV_CHECK.NATURE_OF_THE_FACTORY is '工厂性质 1-贸易公司  2-生产工厂';

alter table OVERSEA_INV_CHECK_ACTION add NATURE_OF_THE_FACTORY VARCHAR2(255);
comment on column OVERSEA_INV_CHECK_ACTION.NATURE_OF_THE_FACTORY is '工厂性质 1-贸易公司  2-生产工厂';


--工厂请购单修改触发器  -hzc  -20220516
DROP TRIGGER "SPMS"."TR_ORDER_WERKS_BEF";
CREATE TRIGGER "SPMS"."TR_ORDER_WERKS_BEF" BEFORE INSERT ON "SPMS"."ORDER_WERKS" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
	if(:NEW.REQUEST_TYPE!=1)
	 then
		SELECT NVL(TO_NUMBER(SUBSTR(MAX(OW.SPMS_ID), 11, 13)), 0)
    INTO V_NUM1
    FROM ORDER_WERKS OW
    WHERE SUBSTR(OW.APPLICATION_DATE, 0, 4) = SUBSTR(:NEW.APPLICATION_DATE, 0, 4)
    AND SUBSTR(OW.SPMS_ID, 0, 4) = :NEW.WERKS
      AND OW.WERKS = :NEW.WERKS;
    :NEW.SPMS_ID := :NEW.WERKS || '-' || SUBSTR(:NEW.APPLICATION_DATE, 0, 4) || '-' || SUBSTR(1001 + V_NUM1, 2, 4);
		else
		SELECT NVL(TO_NUMBER(SUBSTR(MAX(OW.SPMS_ID), 11, 13)), 0)
    INTO V_NUM1
    FROM ORDER_WERKS OW
    WHERE SUBSTR(OW.APPLICATION_DATE, 0, 4) = SUBSTR(:NEW.APPLICATION_DATE, 0, 4)
      AND OW.MODULE_TYPE = :NEW.MODULE_TYPE;
    :NEW.SPMS_ID := :NEW.MODULE_TYPE || '-' || SUBSTR(:NEW.APPLICATION_DATE, 0, 4) || '-' || SUBSTR(1001 + V_NUM1, 2, 4);
		end if;
END;









--海外仓其他出入库修改触发器  -hzc  -20221123（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_OTHER_TASK_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_OTHER_TASK_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_OTHER_TASK" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OOT.SPMS_ID), -3, 3)), 0) INTO V_NUM1 FROM OVERSEA_OTHER_TASK OOT
    WHERE OOT.CREATE_DATE = :NEW.CREATE_DATE
      AND OOT.WERKS = :NEW.WERKS
      AND OOT.WHS_LOCATION_CODE = :NEW.WHS_LOCATION_CODE;
    :NEW.SPMS_ID := :NEW.WERKS||'-'||:NEW.WHS_LOCATION_CODE||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'||SUBSTR(1001 + V_NUM1, 2, 4);
END;


--海外仓其他出入库修改触发器  -hzc  -20221123（新版）TF01OIN00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_OTHER_TASK_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_OTHER_TASK_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_OTHER_TASK" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OOT.SPMS_ID), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_OTHER_TASK OOT
    WHERE OOT.SPMS_ID LIKE '%COS%'
      AND OOT.WERKS = :NEW.WERKS;
    :NEW.SPMS_ID := :NEW.WERKS||'COS'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;



--海运入库修改触发器  -hzc  -20221123（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_IN_BEF_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_IN_BEF_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_IN" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(WI.WHS_IN_NO), 15, 17)), 0) INTO V_NUM1 FROM OVERSEA_WHS_IN WI
    WHERE WI.CREATE_DATE = :NEW.CREATE_DATE AND WI.WERKS = :NEW.WERKS;
    :NEW.WHS_IN_NO := :NEW.WERKS||'-'||REPLACE(:NEW.CREATE_DATE, '-', '')|| '-'|| SUBSTR(1001 + V_NUM1, 2, 4);
END;




--海运入库修改触发器  -hzc  -20221123（新版）TF01SIN00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_IN_BEF_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_IN_BEF_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_IN" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(WI.WHS_IN_NO), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_WHS_IN WI
    WHERE WI.WHS_IN_NO LIKE '%SIN%'
     AND WI.WERKS = :NEW.WERKS;
    :NEW.WHS_IN_NO := :NEW.WERKS||'SIN'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;




--领用出库修改触发器  -hzc  -20221123（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_OUT_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_OUT_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_OUT" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWO.SPMS_ID), -3, 3)), 0) INTO V_NUM1 FROM OVERSEA_WHS_OUT OWO
    WHERE OWO.CREATE_DATE = :NEW.CREATE_DATE
      AND OWO.WERKS = :NEW.WERKS
      AND OWO.WHS_LOCATION_CODE = :NEW.WHS_LOCATION_CODE;
    :NEW.SPMS_ID := :NEW.WERKS||'-'||:NEW.WHS_LOCATION_CODE||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'||SUBSTR(1001 + V_NUM1, 2, 4);
END;




--领用出库修改触发器  -hzc  -20221123（新版）TF01SIN00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_OUT_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_OUT_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_OUT" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWO.SPMS_ID), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_WHS_OUT OWO
    WHERE OWO.SPMS_ID LIKE '%OUT%'
      AND OWO.WERKS = :NEW.WERKS ;
    :NEW.SPMS_ID := :NEW.WERKS||'OUT'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;



--国内仓转储任务表触发器  -hzc  -20230210（原版）
DROP TRIGGER "SPMS"."TR_WHS_DUMP_BEF";
CREATE TRIGGER "SPMS"."TR_WHS_DUMP_BEF" BEFORE INSERT ON "SPMS"."WHS_DUMP" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(WD.WHS_DUMP_NO), -3, 3)), 0) INTO V_NUM1 FROM WHS_DUMP WD
    WHERE WD.CREATE_DATE = :NEW.CREATE_DATE
      AND WD.WERKS_DUMP_OUT = :NEW.WERKS_DUMP_OUT
      AND WD.WHS_LOCATION_CODE_DUMP_OUT = :NEW.WHS_LOCATION_CODE_DUMP_OUT;
    :NEW.WHS_DUMP_NO := :NEW.WERKS_DUMP_OUT||'-'||:NEW.WHS_LOCATION_CODE_DUMP_OUT||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'|| SUBSTR(1001 + V_NUM1, 2, 4);
END;


--国内仓转储任务表触发器  -hzc  -20230210（新版）TF01DUM00000001。8位流水号
DROP TRIGGER "SPMS"."TR_WHS_DUMP_BEF";
CREATE TRIGGER "SPMS"."TR_WHS_DUMP_BEF" BEFORE INSERT ON "SPMS"."WHS_DUMP" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(WD.WHS_DUMP_NO), -8, 8)), 0) INTO V_NUM1 FROM WHS_DUMP WD
    WHERE WD.WHS_DUMP_NO LIKE '%DUM%'
      AND WD.WERKS_DUMP_OUT = :NEW.WERKS_DUMP_OUT;
    :NEW.WHS_DUMP_NO := :NEW.WERKS_DUMP_OUT||'DUM'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;




--海外仓转储任务表触发器  -hzc  -20230210（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_DUMP_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_DUMP_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_DUMP" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.WHS_DUMP_NO), -3, 3)), 0) INTO V_NUM1 FROM OVERSEA_WHS_DUMP OWD
    WHERE OWD.CREATE_DATE = :NEW.CREATE_DATE
      AND OWD.WERKS_DUMP_OUT = :NEW.WERKS_DUMP_OUT
      AND OWD.WHS_LOCATION_CODE_DUMP_OUT = :NEW.WHS_LOCATION_CODE_DUMP_OUT;
    :NEW.WHS_DUMP_NO := :NEW.WERKS_DUMP_OUT||'-'||:NEW.WHS_LOCATION_CODE_DUMP_OUT||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'||SUBSTR(1001 + V_NUM1, 2, 4);
END;


--海外仓转储任务表触发器  -hzc  -20230210（新版）TF01DUM00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_DUMP_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_DUMP_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_DUMP" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.WHS_DUMP_NO), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_WHS_DUMP OWD
    WHERE OWD.WHS_DUMP_NO LIKE '%DUP%'
      AND OWD.WERKS_DUMP_OUT = :NEW.WERKS_DUMP_OUT;
    :NEW.WHS_DUMP_NO := :NEW.WERKS_DUMP_OUT||'DUP'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;


--国内仓其他出入库任务表触发器  -hzc  -20230211（原版）
DROP TRIGGER "SPMS"."TR_WHS_OTHER_TASK_BEF";
CREATE TRIGGER "SPMS"."TR_WHS_OTHER_TASK_BEF" BEFORE INSERT ON "SPMS"."WHS_OTHER_TASK" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(WO.SPMS_ID), -3, 3)), 0) INTO V_NUM1 FROM WHS_OTHER_TASK WO
    WHERE WO.CREATE_DATE = :NEW.CREATE_DATE
      AND WO.WERKS = :NEW.WERKS
      AND WO.WHS_LOCATION_CODE = :NEW.WHS_LOCATION_CODE;
    :NEW.SPMS_ID := :NEW.WERKS||'-'||:NEW.WHS_LOCATION_CODE||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'|| SUBSTR(1001 + V_NUM1, 2, 4);
END;


--国内仓其他出入库任务表触发器  -hzc  -20230211（新版）TF01WIN00000001。8位流水号
DROP TRIGGER "SPMS"."TR_WHS_OTHER_TASK_BEF";
CREATE TRIGGER "SPMS"."TR_WHS_OTHER_TASK_BEF" BEFORE INSERT ON "SPMS"."WHS_OTHER_TASK" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.SPMS_ID), -8, 8)), 0) INTO V_NUM1 FROM WHS_OTHER_TASK OWD
    WHERE OWD.SPMS_ID LIKE '%WIN%'
      AND OWD.WERKS = :NEW.WERKS;
    :NEW.SPMS_ID := :NEW.WERKS||'WIN'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;


--海外仓调拨业务表触发器  -hzc  -20230211（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_MOVE_BEF";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_MOVE_BEF" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_MOVE" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWM.WHS_MOVE_NO), -3, 3)), 0) INTO V_NUM1 FROM OVERSEA_WHS_MOVE OWM
    WHERE OWM.CREATE_DATE = :NEW.CREATE_DATE
      AND OWM.WERKS_MOVE_OUT = :NEW.WERKS_MOVE_OUT;
    :NEW.WHS_MOVE_NO := :NEW.WERKS_MOVE_OUT||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'|| SUBSTR(1001 + V_NUM1, 2, 4);
END;


--海外仓调拨业务表触发器  -hzc  -20230211（新版）TF01WIN00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_WHS_MOVE_BEF";
CREATE TRIGGER "SPMS"."TR_OVERSEA_WHS_MOVE_BEF" BEFORE INSERT ON "SPMS"."OVERSEA_WHS_MOVE" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.WHS_MOVE_NO), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_WHS_MOVE OWD
    WHERE OWD.WHS_MOVE_NO LIKE '%STM%'
      AND OWD.WERKS_MOVE_OUT = :NEW.WERKS_MOVE_OUT;
    :NEW.WHS_MOVE_NO := :NEW.WERKS_MOVE_OUT||'STM'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;


--国内移仓任务表触发器  -hzc  -20230211（原版）
DROP TRIGGER "SPMS"."TR_WHS_MOVE_BEF";
CREATE TRIGGER "SPMS"."TR_WHS_MOVE_BEF" BEFORE INSERT ON "SPMS"."WHS_MOVE" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(WM.WHS_MOVE_NO), -3, 3)), 0) INTO V_NUM1 FROM WHS_MOVE WM
    WHERE WM.CREATE_DATE = :NEW.CREATE_DATE
      AND WM.WERKS_MOVE_OUT = :NEW.WERKS_MOVE_OUT;
    :NEW.WHS_MOVE_NO := :NEW.WERKS_MOVE_OUT||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'|| SUBSTR(1001 + V_NUM1, 2, 4);
END;


--国内移仓任务表触发器  -hzc  -20230211（新版）TF01WTM00000001。8位流水号
DROP TRIGGER "SPMS"."TR_WHS_MOVE_BEF";
CREATE TRIGGER "SPMS"."TR_WHS_MOVE_BEF" BEFORE INSERT ON "SPMS"."WHS_MOVE" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.WHS_MOVE_NO), -8, 8)), 0) INTO V_NUM1 FROM WHS_MOVE OWD
    WHERE OWD.WHS_MOVE_NO LIKE '%WTM%'
      AND OWD.WERKS_MOVE_OUT = :NEW.WERKS_MOVE_OUT;
    :NEW.WHS_MOVE_NO := :NEW.WERKS_MOVE_OUT||'WTM'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;


--国内仓库盘盈盘亏表触发器  -hzc  -20230211（原版）
DROP TRIGGER "SPMS"."TR_INVENTORY_CHECK_ACTION_ID";
CREATE TRIGGER "SPMS"."TR_INVENTORY_CHECK_ACTION_ID" BEFORE INSERT ON "SPMS"."INVENTORY_CHECK_ACTION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(SOT.SPMS_ID), -3, 3)), 0) INTO V_NUM1 FROM INVENTORY_CHECK_ACTION SOT
    WHERE SOT.CREATE_DATE = :NEW.CREATE_DATE
      AND SOT.WERKS = :NEW.WERKS
      AND SOT.WHS_LOCATION_CODE = :NEW.WHS_LOCATION_CODE;
    :NEW.SPMS_ID := :NEW.WERKS||'-'||:NEW.WHS_LOCATION_CODE||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'||SUBSTR(1001 + V_NUM1, 2, 4);
END;


--国内仓库盘盈盘亏表触发器  -hzc  -20230211（新版）TF01WTM00000001。8位流水号
DROP TRIGGER "SPMS"."TR_INVENTORY_CHECK_ACTION_ID";
CREATE TRIGGER "SPMS"."TR_INVENTORY_CHECK_ACTION_ID" BEFORE INSERT ON "SPMS"."INVENTORY_CHECK_ACTION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.SPMS_ID), -8, 8)), 0) INTO V_NUM1 FROM INVENTORY_CHECK_ACTION OWD
    WHERE OWD.SPMS_ID LIKE '%INP%'
      AND OWD.WERKS = :NEW.WERKS;
    :NEW.SPMS_ID := :NEW.WERKS||'INP'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;


--海外仓库盘盈盘亏表触发器  -hzc  -20230211（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_INV_CHECK_ACTION_ID";
CREATE TRIGGER "SPMS"."TR_OVERSEA_INV_CHECK_ACTION_ID" BEFORE INSERT ON "SPMS"."OVERSEA_INV_CHECK_ACTION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(SOT.SPMS_ID), -3, 3)), 0) INTO V_NUM1 FROM OVERSEA_INV_CHECK_ACTION SOT
    WHERE SOT.CREATE_DATE = :NEW.CREATE_DATE
      AND SOT.WERKS = :NEW.WERKS
      AND SOT.WHS_LOCATION_CODE = :NEW.WHS_LOCATION_CODE;
    :NEW.SPMS_ID := :NEW.WERKS||'-'||:NEW.WHS_LOCATION_CODE||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'||SUBSTR(1001 + V_NUM1, 2, 4);
END;


--海外仓库盘盈盘亏表触发器  -hzc  -20230211（新版）TF01WTM00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_INV_CHECK_ACTION_ID";
CREATE TRIGGER "SPMS"."TR_OVERSEA_INV_CHECK_ACTION_ID" BEFORE INSERT ON "SPMS"."OVERSEA_INV_CHECK_ACTION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(OWD.SPMS_ID), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_INV_CHECK_ACTION OWD
    WHERE OWD.SPMS_ID LIKE '%ONP%'
      AND OWD.WERKS = :NEW.WERKS;
    :NEW.SPMS_ID := :NEW.WERKS||'ONP'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;



--领用申请表触发器  -hzc  -20230419（原版）
DROP TRIGGER "SPMS"."TR_OVERSEA_REQUISITION_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_REQUISITION_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_REQUISITION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(ORQ.SPMS_ID), -3, 3)), 0) INTO V_NUM1 FROM OVERSEA_REQUISITION ORQ
    WHERE ORQ.CREATE_DATE = :NEW.CREATE_DATE
      AND ORQ.WERKS = :NEW.WERKS
      AND ORQ.WORKSHOP_CODE = :NEW.WORKSHOP_CODE;
    :NEW.SPMS_ID := :NEW.WERKS||'-'||:NEW.WORKSHOP_CODE||'-'||REPLACE(:NEW.CREATE_DATE, '-')||'-'||SUBSTR(1001 + V_NUM1, 2, 4);
END;


--领用申请表触发器  -hzc  -20230419（新版）CM51LYD00000001。8位流水号
DROP TRIGGER "SPMS"."TR_OVERSEA_REQUISITION_INSERT";
CREATE TRIGGER "SPMS"."TR_OVERSEA_REQUISITION_INSERT" BEFORE INSERT ON "SPMS"."OVERSEA_REQUISITION" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW
DECLARE
    V_NUM1 NUMBER := 0;
BEGIN
    SELECT NVL(TO_NUMBER(SUBSTR(MAX(ORQ.SPMS_ID), -8, 8)), 0) INTO V_NUM1 FROM OVERSEA_REQUISITION ORQ
    WHERE ORQ.SPMS_ID LIKE '%LYD%'
      AND ORQ.WERKS = :NEW.WERKS;
    :NEW.SPMS_ID := :NEW.WERKS||'LYD'||SUBSTR(100000001 + V_NUM1, 2, 9);
END;

