零件选择和排序的4个程序
戻る
mscenq1_parts.pl,零件输入管理程序(旧)
sub mscenq1_parts {
my $self = shift;
my(%t,$n,@loop1,@engine_loop,@parts_loop,%tablelist);
# Get CGI query object
$t{q} = $self->query();
$t{enq1_id} = $t{q}->param("id");
# HTMLファイル
$t{template} = $self->load_tmpl('mscenq1_parts.htm') || die "error loading tmpl";
# time
$t{time1} = $self->dbh->selectrow_array("SELECT time FROM enq1 WHERE id = $t{enq1_id}");
# ourref
$t{ourref1} = $self->dbh->selectrow_array("SELECT ourref FROM enq1 WHERE id = $t{enq1_id}");
# 主機タイプ(main_type1)
$t{name1id} = $self->dbh->selectrow_array("SELECT type1id FROM enq1 WHERE id = $t{enq1_id}");
@engine_loop = ();
$t{NO} = 0;
if ( $t{name1id} ne 'NULL' ) {
@{ $t{name1id_list} } = split(/==/,$t{name1id});
for $n ( 0 .. $#{ $t{name1id_list} } ) {
$t{name1id1} = $t{name1id_list}[$n];
($t{id1},$t{name1}) = $self->dbh->selectrow_array("select id, name from main_type1 where id = $t{name1id1}");
$t{NO}++;
my %row = (
enq1_id => $t{enq1_id},
NO1 => $t{NO},
name1 => $t{name1},
main_type1id => $t{id1}
);
push(@engine_loop, \%row);
}
}
# パーツテーブルを生成
if ( $t{name1id} ne 'NULL' ) {
for $n ( 0 .. $#{ $t{name1id_list} } ) {
$t{name1id1} = $t{name1id_list}[$n];
($t{id1},$t{name1}) = $self->dbh->selectrow_array("select id, name from main_type1 where id = $t{name1id1}");
$t{ptable1} = sprintf("%06d",$t{id1});
$t{ptable1} = 'a' . $t{ptable1};
$tablelist{$t{name1id1}} = $t{ptable1};
my %row = (
ptable1 => $t{ptable1}
);
push(@parts_loop, \%row);
}
}
# パーツデータ処理
($t{partsid},$t{QTY}) = $self->dbh->selectrow_array("SELECT partsid,QTY FROM enq1 WHERE id = $t{enq1_id}");
if ( $t{partsid} ) {
@loop1 = ();
@{ $t{partsid_list0} } = split(/==/,$t{partsid});
@{ $t{QTY_list0} } = split(/==/,$t{QTY});
$t{NO2} = 0;
for $n (0 .. $#{ $t{partsid_list0} } ) {
$t{name1id1} = $t{name1id_list}[$n];
$t{p_list1} = $t{partsid_list0}[$n];
$t{Q_list1} = $t{QTY_list0}[$n];
@{ $t{partsid_list} } = split(/=/,$t{p_list1});
@{ $t{QTY_list} } = split(/=/,$t{Q_list1});
$t{NO} = $n + 1;
for $n1 ( 0 .. $#{ $t{partsid_list} } ) {
$t{partsid1} = $t{partsid_list}[$n1];
$t{QTY1} = $t{QTY_list}[$n1];
@{ $t{parts} } = $self->dbh->selectrow_array("select name, code from $tablelist{$t{name1id1}} where id = $t{partsid1}");
$t{NO2}++;
my %row = (
enq1_id => $t{enq1_id}, # 主機タイプID
NO1 => $t{NO}, # 順番
NO2 => $t{NO2}, # パーツ順番
partsid => $t{partsid1}, # パーツID
QTY1 => $t{QTY1}, # パーツ数量
parts_name => $t{parts}[0], # パーツ名
parts_code => $t{parts}[1] # パーツコート
);
# put this row into the loop by reference
push(@loop1, \%row);
}
}
}
$t{template}->param(pro => "mscenq1_parts.pl");
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(time1 => $t{time1});
$t{template}->param(ourref1 => $t{ourref1});
$t{template}->param(engine_loop => \@engine_loop);
$t{template}->param(parts_loop => \@parts_loop);
$t{template}->param(LOOP1 => \@loop1);
return $t{template}->output;
}
1;
mscenq1_parts.htm,零件输入管理界面(旧)
mscenq1_parts
mscenq1_parts
目的:enq1のパーツデータ入力
mode:mscenq1_parts;table:enq1;Perl:
enq1_id==>
time1==>
ourref1==>
ptable1==>
NO |
Engine NO |
Engine Name |
パーツ選択 |
|
|
|
|
mscenq1_parts1.pl,零件选择开始程序(之一)
sub mscenq1_parts1 {
my $self = shift;
my(%t,@rec,@loop,$n);
# Get CGI query object
$t{q} = $self->query();
$t{NE1} = $t{q}->param("NE1");
$t{enq1_id} = $t{q}->param("enq1_id");
$t{main_type1id} = $t{q}->param("main_type1id");
$t{name1} = $t{q}->param("name1");
$t{template} = $self->load_tmpl('mscenq1_parts1.htm') || die "error loading tmpl";
# Parts table
$t{ptable} = sprintf("%06d",$t{main_type1id});
$t{ptable} = 'a' . $t{ptable};
# Parts namecodeo
$t{sth} = $self->dbh->prepare("SELECT id, name, code FROM $t{ptable}");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
$t{NO} = 'ss' . $rec[0];
$t{list_NO}{$rec[2]} = $t{NO};
$t{list_id}{$rec[2]} = $rec[0];
$t{list_name}{$rec[2]} = $rec[1];
$t{list_code}{$rec[2]} = $rec[2];
}
$t{sth}->finish;
@loop = ();
# R[g̏
for $n ( sort keys %{ $t{list_code} } ) {
$t{NO} = $t{list_NO}{$n};
$t{id} = $t{list_id}{$n};
$t{name} = $t{list_name}{$n};
$t{code} = $t{list_code}{$n};
my %row = (
NO => $t{NO},
id => $t{id},
name => $t{name},
code => $n
);
push(@loop, \%row);
}
$t{template}->param(LOOP => \@loop);
$t{template}->param(NE1 => $t{NE1});
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(ptable => $t{ptable});
$t{template}->param(main_type1id => $t{main_type1id});
$t{template}->param(name1 => $t{name1});
$t{template}->param(pro => "mscenq1_parts1.pl");
return $t{template}->output;
}
1;
mscenq1_parts1.htm,零件选择画面
enq1_parts1
enq1_parts1
mode:modeenq1_parts1
列出属于该主机的全部Parts供挑选。
ptable=;主机名=
enq1_id=>
pro=>
mscenq1_parts2.pl,零件选择完成程序(之二)
sub mscenq1_parts2 {
my $self = shift;
my(%t,$n);
# Get CGI query object
$t{q} = $self->query();
$t{NE1} = $t{q}->param("NE1"); # 選択された主機の順番
$t{enq1_id} = $t{q}->param("enq1_id");
$t{main_type1id} = $t{q}->param("main_type1id");
$t{name1} = $t{q}->param("name1");
# Parts table名
$t{ptable} = sprintf("%06d",$t{main_type1id});
$t{ptable} = 'a' . $t{ptable};
# 選択したParts のnameとcodeを取り出す
$t{sth} = $self->dbh->prepare("SELECT id, name, code FROM $t{ptable}");
$t{sth}->execute;
$t{list} = '';
$t{listq} = '';
while ( @rec = $t{sth}->fetchrow_array ) {
$t{NO} = 'ss' . $rec[0];
$t{s1} = $t{q}->param($t{NO});
if ( $t{s1} ) {
$t{list} .= '=' . $rec[0];
$t{listq} .= '=1';
$t{list_NO}{$rec[2]} = $t{NO};
$t{list_id}{$rec[2]} = $rec[0];
$t{list_name}{$rec[2]} = $rec[1];
$t{list_code}{$rec[2]} = $rec[2];
}
}
$t{sth}->finish;
@loop = ();
# コートの順番
$t{NO1} = 0;
for $n ( sort keys %{ $t{list_code} } ) {
$t{NO1}++;
$t{NO} = $t{list_NO}{$n};
$t{id} = $t{list_id}{$n};
$t{name} = $t{list_name}{$n};
$t{code} = $t{list_code}{$n};
my %row = (
NO => $t{NO},
NO1 => $t{NO1},
id => $t{id},
name => $t{name},
code => $n
);
push(@loop, \%row);
}
($t{old1},$t{old1q}) = $self->dbh->selectrow_array("SELECT partsid,QTY FROM enq1 WHERE id = $t{enq1_id}");
@{ $t{olds} } = split(/==/,$t{old1});
@{ $t{oldsq} } = split(/==/,$t{old1q});
@{ $t{news} } = ();
@{ $t{newsq} } = ();
$t{N1} = $t{NE1} - 1;
for $n ( 0 .. $#{ $t{olds} } ) {
if ( $n == $t{N1} ) {
substr($t{list},0,1)='';
substr($t{listq},0,1)='';
push(@{ $t{news} },$t{list});
push(@{ $t{newsq} },$t{listq});
} else {
push(@{ $t{news} },$t{olds}[$n]);
push(@{ $t{newsq} },$t{oldsq}[$n]);
}
}
$t{new1} = join('==',@{ $t{news} });
$t{new1q} = join('==',@{ $t{newsq} });
$t{sql} = 'UPDATE enq1 set partsid = "';
$t{sql} .= $t{new1} . '" where id = ' . $t{enq1_id};
$t{DO} = $self->dbh->do($t{sql});
$t{sql} = 'UPDATE enq1 set QTY = "';
$t{sql} .= $t{new1q} . '" where id = ' . $t{enq1_id};
$t{DO} = $self->dbh->do($t{sql});
$t{template} = $self->load_tmpl('mscenq1_parts2.htm') || die "error loading tmpl";
$t{template}->param(NE1 => $t{NE1});
$t{template}->param(LOOP => \@loop);
$t{template}->param(sql => $t{sql});
$t{template}->param(DO => $t{DO});
$t{template}->param(list => $t{new1});
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(main_type1id => $t{main_type1id});
$t{template}->param(name1 => $t{name1});
$t{template}->param(pro => "mscenq1_parts2.pl");
return $t{template}->output;
}
1;
mscenq1_parts2.htm,零件排序画面
enq1_parts2
enq1_parts2
mode:modeenq1_parts2
NE1==>
sql==>
DO==>
list==>
挑选后的Parts写入DB,并列表排序。
主机NO=;主机名=
enq1_id=>
pro=>
">
">
">
">
mscenq1_parts3.pl(之三)
sub mscenq1_parts3 {
my $self = shift;
my(%t,$n,$n1,@loop0,@loop,$ref);
# Get CGI query object
$t{q} = $self->query();
$t{NE1} = $t{q}->param("NE1");
$t{enq1_id} = $t{q}->param("enq1_id");
$t{main_type1id} = $t{q}->param("main_type1id");
$t{name1} = $t{q}->param("name1");
# パーツデータを読む
@loop0 = ();
($t{ps},$t{Qs}) = $self->dbh->selectrow_array("SELECT partsid,QTY FROM enq1 WHERE id = $t{enq1_id}");
@{ $t{pss} } = split(/==/,$t{ps});
@{ $t{Qss} } = split(/==/,$t{Qs});
$t{N1} = $t{NE1} - 1;
for $n ( 0 .. $#{ $t{pss} } ) {
if ( $n == $t{N1} ) {
$t{partsid} = $t{pss}[$n];
$t{QTY1s} = $t{Qss}[$n];
$t{NEn} = $n;
}
}
@{ $t{parts} } = split(/=/,$t{partsid});
@{ $t{QTY2} } = split(/=/,$t{QTY1s});
for $n ( 0 .. $#{ $t{parts} } ) {
$t{NO} = 'ss' . $t{parts}[$n];
$t{list1} = $t{q}->param($t{NO});
$t{list}{$t{parts}[$n]} = $t{list1};
$t{Qlist}{$t{parts}[$n]} = $t{QTY2}[$n];
# データを転送する
my %row = (
NO => $t{NO}
);
push(@loop0, \%row);
}
# Parts table名
$t{ptable} = sprintf("%06d",$t{main_type1id});
$t{ptable} = 'a' . $t{ptable};
$t{NO} = 0;
@loop = ();
$t{list1} = '';
for $n ( sort { $t{list}{$a}<=>$t{list}{$b} } keys %{ $t{list} } ) {
($t{id},$t{name},$t{code}) = $self->dbh->selectrow_array("SELECT id, name, code FROM $t{ptable} WHERE id = $n");
$t{NO}++;
$t{QTY} = 'QTY' . $t{id};
$t{list1} .= '=' . $t{id};
$t{QTY1} = $t{Qlist}{$t{id}};
my %row = (
QTY => $t{QTY},
QTY1 => $t{QTY1},
NO => $t{NO},
id => $t{id},
name => $t{name},
code => $t{code}
);
push(@loop, \%row);
}
substr($t{list1},0,1) = '';
$t{pss}[$t{NEn}] = $t{list1};
$t{new1} = join("==",@{ $t{pss} });
$t{sql} = 'UPDATE enq1 set partsid = "';
$t{sql} .= $t{new1} . '" where id = ' . $t{enq1_id};
$t{DO} = $self->dbh->do($t{sql});
$t{template} = $self->load_tmpl('mscenq1_parts3.htm') || die "error loading tmpl";
$t{template}->param(LOOP0 => \@loop0);
$t{template}->param(LOOP => \@loop);
$t{template}->param(NE1 => $t{NE1});
$t{template}->param(sql => $t{sql});
$t{template}->param(DO => $t{DO});
$t{template}->param(partsid => $t{new1});
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(main_type1id => $t{main_type1id});
$t{template}->param(name1 => $t{name1});
$t{template}->param(pro => "mscenq1_parts3.pl");
return $t{template}->output;
}
1;
mscenq1_part3.htm
enq1_parts3
enq1_parts3
mode:modeenq1_parts3
排序后的Parts写入DB,并输入数量。
主机NO=;主机名=
enq1_id=>
pro=>
partsid=>
DO=>
sql=>
mscenq1_parts4.pl(之四)
sub mscenq1_parts4 {
my $self = shift;
my(%t,$n,@loop);
# Get CGI query object
$t{q} = $self->query();
$t{NE1} = $t{q}->param("NE1");
$t{enq1_id} = $t{q}->param("enq1_id");
$t{main_type1id} = $t{q}->param("main_type1id");
$t{name1} = $t{q}->param("name1");
# パーツデータを読む
@loop = ();
$t{list1} = '';
($t{ps},$t{Qs}) = $self->dbh->selectrow_array("SELECT partsid,QTY FROM enq1 WHERE id = $t{enq1_id}");
@{ $t{pss} } = split(/==/,$t{ps});
@{ $t{Qss} } = split(/==/,$t{Qs});
$t{N1} = $t{NE1} - 1;
for $n ( 0 .. $#{ $t{pss} } ) {
if ( $n == $t{N1} ) {
$t{partsid} = $t{pss}[$n];
$t{QTY1s} = $t{Qss}[$n];
$t{NEn} = $n;
}
}
@{ $t{parts} } = split(/=/,$t{partsid});
for $n ( 0 .. $#{ $t{parts} } ) {
$t{QTY} = 'QTY' . $t{parts}[$n];
$t{QTY1} = $t{q}->param($t{QTY});
# データを転送する
$t{list1} .= '=' . $t{QTY1};
my %row = (
QTY => $t{QTY1}
);
push(@loop, \%row);
}
# パーツ数量のUPDATE
substr($t{list1},0,1) = '';
$t{Qss}[$t{NEn}] = $t{list1};
$t{new1} = join("==",@{ $t{Qss} });
$t{sql} = 'UPDATE enq1 set QTY = "';
$t{sql} .= $t{new1} . '" where id = ' . $t{enq1_id};
$t{DO} = $self->dbh->do($t{sql});
$t{template} = $self->load_tmpl('mscenq1_parts4.htm') || die "error loading tmpl";
$t{template}->param(sql => $t{sql});
$t{template}->param(DO => $t{DO});
$t{template}->param(LOOP => \@loop);
$t{template}->param(NE1 => $t{NE1});
$t{template}->param(enq1_id => $t{enq1_id});
$t{template}->param(main_type1id => $t{main_type1id});
$t{template}->param(name1 => $t{name1});
$t{template}->param(pro => "mscenq1_parts4.pl");
return $t{template}->output;
}
1;
mscenq1_parts4.htm
enq1_parts4
enq1_parts4
mode:modeenq1_parts4
输入数量完成。
主机NO=;主机名=
enq1_id=>
pro=>
QTY==>
sql==>
DO==>
戻る