sl_box_opt.pl 2.59 KB
Newer Older
Scott Sun's avatar
Scott Sun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
=head
 NAME:ZWZ_output_drill_table
 DESCRIPTION: 
 PARAMETER:
	[

	]
	
 VERSION_HISTORY:
	V1.01 2014-01-07 Sting
		1.新版本
 HELP:
	<html><body bgcolor="#DDECFE">
		<font size="3" color="#003DB2"><p>功能简介</p></font>
		  <p> 钻孔表输出 </p>
		  <br>
		<font size="3" color="#003DB2"><p>参数配置</p></font>
		 <p> ● 无</p>
		<font size="3" color="#003DB2"><p>注意事项</p></font>
		  <p> ● 无 </p>
		  <br>
	</body></html>
  
=cut

use Data::Dump 'dump';
dump('+-+-+-+-+-+-+-+++-+------1');
$GEN->PAUSE('1');

use strict;
use utf8;
use Encode;

use Number::Format 'round';
use File::Path 'make_path';
use File::Copy;
use_module('TL_GenMath');
use_module('TL_OLE_Excel');

dump('+-+-+-+-+-+-+-+++-+------2');

try{
	my $EX = TL::OLE::Excel->new();
	$GEN->PAUSE('2');
	unless ($GEN->{STATUS}){
		show_loading("孔表资料制作完成....!",0,position=>'center');
		sleep(1);
	}
	else{
		$GUI->msgbox(-icon=>'error',-text=>join("\n",@{$GEN->{STATUS}}));
		addFlowNotes(-notes=>"   Genesis Error:\n   ".join("\n   ",@{$GEN->{STATUS}}));
		return 'Error';
	}
}
catch Error::Simple with {
	my $error = encode("utf8",shift);
	$GUI->msgbox(-icon=>'error',-text=>$error);
	return 'Error';
}
finally{
	
};




=head
	钻孔信息写入Excel template_file=>,file=>,data=>,
	A 刀具 
	C 产品孔径
	D PTH
	E 公差(+)
	F 公差(-)
	G 钻咀直接
	N PA孔数
	P 类型
	Q 备注
=cut
sub output_excel
{
	my %par = @_;
	if(defined$par{data}){
		my $template_file = $par{template_file};
		my %drl_layer;
		#多层钻孔时数据是合在一起的
		foreach my $tmp (keys %{$par{data}}){
			my ($tmp_data,) = split /\-/,$tmp;
			if(defined($drl_layer{$tmp_data})){
				next;
			}else{
				$drl_layer{$tmp_data} = 1;
			}
		}
		foreach my $tmp (keys %drl_layer){
			my $cam = $IKM->get_jobinfo(-jobname=>$Job,-jobid=>$JOB_ID,-jobcategory=>'work',-jobinfo=>'cam_serial_number',-withspec=>1);
			my $folder = 'drill';
			my $path = $PAR->{Outpath}."$cam/$folder";
			my $excel_file = $path.'/'.$Job.'_'."$tmp.xls";
			unlink $excel_file if (-e $excel_file);
			if (-e $excel_file) {
				$GUI->msgbox(-icon=>'error',-text=>"你正打开${excel_file},请关闭${excel_file}后再运行脚本!");
				return 'Error';
			}
			copy($template_file,$excel_file);

			my @data = grep($_ =~ /($tmp)/,sort{$par{data}->{$a}{sequence} <=> $par{data}->{$b}{sequence}} keys %{$par{data}});
			foreach my $tmp (@data){


			}
			# my $EX = TL::OLE::Excel->new();
			# my $tol_row = 2;#从第2行开始
			# $EX->open_file($excel_file);
			# $EX->select_ws('drill_table');
			# $EX->set_range_value('A'.$tol_row => 'T01');
			# $EX->save();
		}

	}
}

__END__