-- 版本V35升级V40脚本 ---2023年5月

-- 修改计划表名称
RENAME TABLE D_M_PLAN TO D_INOUT_PLAN
RENAME TABLE D_M_PLAN_DETAIL TO D_INOUT_PLAN_DETAIL;

--修改合同信息
RENAME TABLE D_M_CONTRACT TO D_INOUT_CONTRACT;

--性质变更
RENAME TABLE D_M_VARIETY_CHANGE TO D_INOUT_VARIETY_CHANGE;

--质量管理-检验类型升级--待配置
UPDATE D_M_QUALITY SET TYPE_ = '', WHERE TYPE_ ='';

UPDATE D_M_QUALITY SET STANDARD_ = '1', WHERE STANDARD_ ='01';
UPDATE D_M_QUALITY SET STANDARD_ = '0', WHERE STANDARD_ ='02';

-- 损溢表
RENAME TABLE D_M_LOSS_OVER TO D_INOUT_LOSS_OVER;

-- 倒仓
RENAME TABLE D_M_STOCK_CHANGE TO D_INOUT_STOCK_CHANGE;

--客户信用
RENAME TABLE D_CREDIT TO D_INTOU_CREDIT;


-- 升级仓房状态 1=空仓、2=入库中、3=满仓、4=出库中、9=其他 、31气调中、32熏蒸中、33通风中 34温控中
UPDATE D_DEPOT SET DEPOT_STATUS_ = '1' WHERE DEPOT_STATUS_ ='01';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '2' WHERE DEPOT_STATUS_ ='03';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '3' WHERE DEPOT_STATUS_ ='02';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '4' WHERE DEPOT_STATUS_ ='04';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '31' WHERE DEPOT_STATUS_ ='05';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '32' WHERE DEPOT_STATUS_ ='06';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '33' WHERE DEPOT_STATUS_ ='07';
UPDATE D_DEPOT SET DEPOT_STATUS_ = '34' WHERE DEPOT_STATUS_ ='09';

UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '1' WHERE DEPOT_STATUS_ ='01';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '2' WHERE DEPOT_STATUS_ ='03';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '3' WHERE DEPOT_STATUS_ ='02';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '4' WHERE DEPOT_STATUS_ ='04';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '31' WHERE DEPOT_STATUS_ ='05';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '32' WHERE DEPOT_STATUS_ ='06';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '33' WHERE DEPOT_STATUS_ ='07';
UPDATE D_DEPOT_STORE SET DEPOT_STATUS_ = '34' WHERE DEPOT_STATUS_ ='09';

-- 调整出入库数据状态
UPDATE D_INOUT_RECORD SET RECORD_STATUS_ ='DEL' WHERE RECORD_STATUS_='ERROR';

