# mes_cx_ydm_zc_initialnew_hand 存储过程（什么什么热轧）

## 模板下载

[模板](./mes_cx_ydm_zc_initialnew_hand.sql)

用{0}表达 当前月份 替换成02

用{1}表达 下个月份 替换成03

用{2}表达 下个月份 替换成01

## 原始脚本内容

```sql
CREATE OR REPLACE procedure mes_cx_ydm_zc_initialnew_hand is
begin

  insert into cx_ydm_zc_initial
    (bal_year_month, ckmc, material_no, material_name, spec_code, spec_name,
     std_code, std_name, produccode, producname, gradecode, gradename,
     steelcode, steelname, act_count, act_weight, act_in_count,
     act_in_weight, act_out_count, act_out_weight, is_lljg, process_name,
     is_ckc, dimater, height, pass, model_desc, buyer, orderid, bc_type,
     judge_stove_no,instock_time,INSERT_TIME)
    select substr(t1.bal_year_month, 0, 4) || '-' ||
            substr(t1.bal_year_month, 5, 2) as bal_year_month,
           '天淮成品库' as ckmc, t2.material_code as material_no,
           t2.material_name as material_name, spec_code,
           t2.outer_diam || '*' || t2.wall_thickness as spec_name, std_code,
           std_name, produccode,
           nvl(t2.prod_name, t1.producname) as producname, gradecode,
           nvl(t2.sg_grade, t1.gradename) as gradename, steelcode,
           nvl(t2.sg_sign, t1.steelname) as steelname, act_count, act_weight,
           0 as act_in_count, 0 as act_in_weight, 0 as act_out_count,
           0 as act_out_weight,
           getislljg(t1.judge_stove_no,
                      nvl(replace(pro_order_no, '/', ''),
                          replace(get_cp_order(t1.judge_stove_no), '/', ''))) as is_lljg,
           case PLINE_CODE when 'C108' then '车丝' else
           (case process_desc
              when '轧制' then
               '热轧'
              when '加工线' then
               '加工'
              else
               process_desc
            end) end as process_name, 
            
            --'否' as is_ckc, 
             (case
             when nvl(t2.if_export,'内贸') ='内贸' then
              '否'
             when nvl(t2.if_export,'内贸') ='外贸' then
              '是'
             else
              '否'
            end) is_ckc, 
            
            dimater, height,
           get_cp_pass(nvl(t1.pro_order_no, get_cp_order(t1.judge_stove_no))) as pass,
           model_desc,
           get_cp_buyer(nvl(t1.pro_order_no,
                             get_cp_order(t1.judge_stove_no))) as buyer,
           nvl(replace(t1.pro_order_no, '/', ''),nvl(t1.order_no||t1.order_seq,replace(get_cp_order(t1.judge_stove_no), '/', ''))) as orderid,
           '成品期初库存' as bc_type, t1.judge_stove_no,T1.instock_time,SYSDATE
           
      from cxuser.ydm_zc_initial t1, mvm_order_matno_info t2 --增加MVN
      
     where nvl(replace(t1.pro_order_no, '/', ''),nvl(t1.order_no||t1.order_seq,replace(get_cp_order(t1.judge_stove_no), '/', ''))) =t2.contractno_num(+)
           
       and t1.handle_log = '1'
       and t1.bal_year_month in ('202602')
       and belong_code in ('100101', '100102', '100105')
       and t1.supply_unit_code = '120504'
       and nvl(replace(t1.pro_order_no, '/', ''),
               replace(get_cp_order(t1.judge_stove_no), '/', '')) not like
           'ZZBY%'
       and t1.judge_stove_no = 'A25120129'
       --and t1.judge_stove_no like 'F%'
    /*AND NVL((t1.order_no || t1.order_seq), REPLACE(GET_CP_ORDER(T1.Judge_Stove_No), '/', '')) NOT IN (
        'XSXPQ-21A1666001',
        'XSXPQ-21A0068001',
        'XSXPQ-21A0067001',
        'XSXPQ-20A2850002',
        'XSXPQ-20A2496001',
        'XSXPQ-20A2487001',
        'XSXPQ-20A2458002',
        'XSXPQ-20A2398001',
        'XSXPQ-20A2378001',
        'XSXPQ-20A2292001',
        'XSXPQ-20A2247001',
        'XSXPQ-20A1104001',
        'GMXPQ-20A2235002',
        'GMXPQ-20A2235001',
        'EXSPQ-200072X001',
        'EXMGQ-210634E003',
        'EXMGQ-210604E012',
        'EXMGQ-210263E001',
        'EXMGQ-200457E001',
        'ZZBY-D230116007'
    )*/
    ;
  commit;

  /*
  
  exception
    when others then
      null;*/
end mes_cx_ydm_zc_initialnew_hand;
```
