-- 版本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';

-- 调整结算字段
ALTER TABLE `d_inout_settle`
CHANGE COLUMN `PAY_SUM_` `PAY_MONEY_`  double NULL DEFAULT NULL AFTER `PAY_PRICE_`;


-- 更新化验项
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '020101' WHERE CODE_ ='C01';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01010301' WHERE CODE_ ='C02';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01010701' WHERE CODE_ ='C03';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01010401' WHERE CODE_ ='C04';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01010304' WHERE CODE_ ='C05';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '010101' WHERE CODE_ ='C06';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '040302' WHERE CODE_ ='C07';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '040103' WHERE CODE_ ='C08';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01012101' WHERE CODE_ ='C09';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01012104' WHERE CODE_ ='C10';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01012102' WHERE CODE_ ='C11';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01012103' WHERE CODE_ ='C12';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01010201' WHERE CODE_ ='C13';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '02010306' WHERE CODE_ ='C14';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01010405' WHERE CODE_ ='C15';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '010105' WHERE CODE_ ='C16';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '02010301' WHERE CODE_ ='C18';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '02010401' WHERE CODE_ ='C19';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01012114' WHERE CODE_ ='C20';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '01020303' WHERE CODE_ ='C21';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '02010331' WHERE CODE_ ='C22';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '02010332' WHERE CODE_ ='C23';
UPDATE D_DIC_CHECK_ITEM SET CODE_ = '02030922' WHERE CODE_ ='C24';

-- 更新化验数据
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '020101' WHERE SETSTANDARD_ID_ ='C01';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01010301' WHERE SETSTANDARD_ID_ ='C02';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01010701' WHERE SETSTANDARD_ID_ ='C03';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01010401' WHERE SETSTANDARD_ID_ ='C04';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01010304' WHERE SETSTANDARD_ID_ ='C05';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '010101' WHERE SETSTANDARD_ID_ ='C06';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '040302' WHERE SETSTANDARD_ID_ ='C07';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '040103' WHERE SETSTANDARD_ID_ ='C08';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01012101' WHERE SETSTANDARD_ID_ ='C09';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01012104' WHERE SETSTANDARD_ID_ ='C10';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01012102' WHERE SETSTANDARD_ID_ ='C11';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01012103' WHERE SETSTANDARD_ID_ ='C12';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01010201' WHERE SETSTANDARD_ID_ ='C13';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '02010306' WHERE SETSTANDARD_ID_ ='C14';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01010405' WHERE SETSTANDARD_ID_ ='C15';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '010105' WHERE SETSTANDARD_ID_ ='C16';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '02010301' WHERE SETSTANDARD_ID_ ='C18';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '02010401' WHERE SETSTANDARD_ID_ ='C19';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01012114' WHERE SETSTANDARD_ID_ ='C20';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '01020303' WHERE SETSTANDARD_ID_ ='C21';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '02010331' WHERE SETSTANDARD_ID_ ='C22';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '02010332' WHERE SETSTANDARD_ID_ ='C23';
UPDATE D_CHECK_ITEM SETSTANDARD_ID_ = '02030922' WHERE SETSTANDARD_ID_ ='C24';
