|
|
@@ -155,6 +155,9 @@ class Whlabel_bh extends Start_Controller {
|
|
|
else if($arg == 'check_by_number'){
|
|
|
$this->_check_by_number();
|
|
|
}
|
|
|
+ else if($arg == 'czbmsfcz'){
|
|
|
+ $this->_czbmIsOutExcel();
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
$this->_index();
|
|
|
@@ -3291,4 +3294,255 @@ class Whlabel_bh extends Start_Controller {
|
|
|
exit($str);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出excel 操作部门是否出库
|
|
|
+ */
|
|
|
+ public function _czbmIsOutExcel(){
|
|
|
+
|
|
|
+ if($this->input->method() == 'get'){
|
|
|
+ $number = $this->input->get('number',true);
|
|
|
+ $color = $this->input->get('color',true);
|
|
|
+ $purchase = $this->input->get('purchase',true);
|
|
|
+ $transfer = $this->input->get('transfer',true);
|
|
|
+ $lx = $this->input->get('lx',true);
|
|
|
+ $type = $this->input->get('type',true);
|
|
|
+ $pm = $this->input->get('pm',true);
|
|
|
+ $timetk = $this->input->get('timetk',true);
|
|
|
+ $timetj = $this->input->get('timetj',true);
|
|
|
+ $timetk = strtotime($timetk);
|
|
|
+ $timetj = strtotime($timetj);
|
|
|
+ $where = '1=1';
|
|
|
+ if($number)
|
|
|
+ {
|
|
|
+ $where .= " and number = '$number'";
|
|
|
+ }
|
|
|
+ if($pm){
|
|
|
+ $where .= " and pm like '%".$pm."%'";
|
|
|
+ }
|
|
|
+ if($purchase)
|
|
|
+ {
|
|
|
+ $where .= " and purchase = '$purchase'";
|
|
|
+ }
|
|
|
+ if($color)
|
|
|
+ {
|
|
|
+ $where .= " and fpdata like '%-".$color."-%'";
|
|
|
+ }
|
|
|
+ if($lx)
|
|
|
+ {
|
|
|
+ if($lx == 1)
|
|
|
+ {
|
|
|
+ $where .= " and ordernumber = ''";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $where .= " and ordernumber != ''";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //数据排序
|
|
|
+ $order_str = "id desc";
|
|
|
+
|
|
|
+ $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
|
|
|
+ if($type)
|
|
|
+ {
|
|
|
+ if($type == 3){
|
|
|
+ if($transfer)
|
|
|
+ {
|
|
|
+ $where .= " and rk like '%|".$transfer."|%' and rk != ck";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $type = ($type==1)?'rk':'ck';
|
|
|
+ if($transfer)
|
|
|
+ {
|
|
|
+ $where .= " and $type like '%|".$transfer."|%'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if($transfer)
|
|
|
+ {
|
|
|
+ $where .= " and rk like '%|".$transfer."|%'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //取得信息列表
|
|
|
+ $info_list = $this->whlabel_bh_transfer->find_all($where,'*',$order_str);
|
|
|
+ $transfer = $this->transfer->find_all();
|
|
|
+ $t = array();
|
|
|
+ foreach ($transfer as $v)
|
|
|
+ {
|
|
|
+ $t[$v['id']] = $v['title'];
|
|
|
+ $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
|
|
|
+ }
|
|
|
+ $final_list = [];
|
|
|
+ //格式化数据
|
|
|
+
|
|
|
+
|
|
|
+ foreach ($info_list as $key=>$value)
|
|
|
+ {
|
|
|
+ $transfer_list = $this->_get_transfer_data($value,$t);
|
|
|
+ $final_list[] = [
|
|
|
+ 'number'=>$value['number'],
|
|
|
+ 'pm'=>$value['pm'],
|
|
|
+ 'transfer_list'=>$transfer_list,
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $filename = date("Y-m-d")."操作部门库存是否存在.xls";
|
|
|
+ $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
|
|
|
+ <head>
|
|
|
+ <!--[if gte mso 9]><xml>
|
|
|
+ <x:ExcelWorkbook>
|
|
|
+ <x:ExcelWorksheets>
|
|
|
+ <x:ExcelWorksheet>
|
|
|
+ <x:Name>EXCEL</x:Name>
|
|
|
+ <x:WorksheetOptions>
|
|
|
+ <x:Print>
|
|
|
+ <x:ValidPrinterInfo />
|
|
|
+ </x:Print>
|
|
|
+ </x:WorksheetOptions>
|
|
|
+ </x:ExcelWorksheet>
|
|
|
+ </x:ExcelWorksheets>
|
|
|
+ </x:ExcelWorkbook>
|
|
|
+ </xml>
|
|
|
+ <![endif]-->
|
|
|
+ </head><body>";
|
|
|
+ $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
|
|
|
+ $str .= "<tr><td>订单编号</td><td>品名</td><td>操作部门</td><td>扫入日期</td><td>扫出日期</td><td>是否出库</td></tr>";
|
|
|
+ foreach ($final_list as $key=>$value)
|
|
|
+ {
|
|
|
+ if(empty($value['number'])){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $str .= "<tr>";
|
|
|
+ $str .= "<td>". $value['number']. "</td>";
|
|
|
+ $str .= "<td>". $value['pm']. "</td>";
|
|
|
+
|
|
|
+ $tmp_czbm = '';
|
|
|
+ $tmp_srrq = '';
|
|
|
+ $tmp_scrq = '';
|
|
|
+ $tmp_is_out = '';
|
|
|
+ foreach ($value['transfer_list'] as $k=>$v)
|
|
|
+ {
|
|
|
+ $tmp_czbm .= $v['lx_show'].'<br/>';
|
|
|
+ $tmp_srrq .= empty($v['rk_time'])?'无<br/>': date('Y-m-d H:i:s',$v['rk_time']).'<br/>';
|
|
|
+ $tmp_scrq .= empty($v['ck_time'])?'无<br/>': date('Y-m-d H:i:s',$v['ck_time']).'<br/>';
|
|
|
+ if($v['is_over'] == 2){
|
|
|
+ $tmp_is_out .= '是<br/>';
|
|
|
+ }elseif($v['is_over'] == 1){
|
|
|
+ $tmp_is_out .= '否<br/>';
|
|
|
+ }else{
|
|
|
+ $tmp_is_out .= '异常<br/>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $tmp_czbm = trim($tmp_czbm,'<br/>');
|
|
|
+ $tmp_srrq = trim($tmp_srrq,'<br/>');
|
|
|
+ $tmp_scrq = trim($tmp_scrq,'<br/>');
|
|
|
+ $tmp_is_out = trim($tmp_is_out,'<br/>');
|
|
|
+ $str .= "<td>". $tmp_czbm. "</td>";
|
|
|
+ $str .= "<td>". $tmp_srrq. "</td>";
|
|
|
+ $str .= "<td>". $tmp_scrq. "</td>";
|
|
|
+ $str .= "<td>". $tmp_is_out. "</td>";
|
|
|
+
|
|
|
+ $str .= "</tr>";
|
|
|
+ }
|
|
|
+ $str .= "</table></body></html>";
|
|
|
+ header( "Content-Type: application/vnd.ms-excel; name='excel'" );
|
|
|
+ header( "Content-type: application/octet-stream" );
|
|
|
+ header( "Content-Disposition: attachment; filename=".$filename );
|
|
|
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
|
|
|
+ header( "Pragma: no-cache" );
|
|
|
+ header( "Expires: 0" );
|
|
|
+ exit($str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _get_transfer_data($info,$t){
|
|
|
+
|
|
|
+ $rk_list = explode('|',trim($info['rk'],'|'));
|
|
|
+ $rk_time = explode('|',trim($info['rktime'],'|'));
|
|
|
+ $ck_list = explode('|',trim($info['ck'],'|'));
|
|
|
+ $ck_time = explode('|',trim($info['cktime'],'|'));
|
|
|
+
|
|
|
+ if(count($rk_time) < count($ck_time)){
|
|
|
+ return [
|
|
|
+ 'code'=>-1,
|
|
|
+ 'msg'=>'数据异常,('.$info['id'].')联系技术',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $tran_list = [];
|
|
|
+ $len = count($rk_list);
|
|
|
+ $ck_index = 0;
|
|
|
+ for($i = 0;$i < $len;$i++){
|
|
|
+
|
|
|
+ if(isset($rk_list[$i]) && empty($ck_list[$ck_index]) ){
|
|
|
+ $tran_list[] = [
|
|
|
+ 'lx'=>$rk_list[$i],
|
|
|
+ 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
|
|
|
+ 'rk_time'=>$rk_time[$i],
|
|
|
+ 'ck_time'=>'',
|
|
|
+ 'is_over'=>1,//未出库
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ if($rk_list[$i] == $ck_list[$ck_index]){
|
|
|
+ $tran_list[] = [
|
|
|
+ 'lx'=>$rk_list[$i],
|
|
|
+ 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
|
|
|
+ 'rk_time'=>$rk_time[$i],
|
|
|
+ 'ck_time'=>$ck_time[$ck_index],
|
|
|
+ 'is_over'=>2,//已出库
|
|
|
+ ];
|
|
|
+ $ck_index++;
|
|
|
+ }else if($rk_list[$i] != $ck_list[$ck_index]){
|
|
|
+ if($rk_list[$i] == $ck_list[$ck_index-1]){
|
|
|
+ //估计是之前完成 或者 成品库 强制扫入
|
|
|
+ $tran_list[] = [
|
|
|
+ 'lx'=>$rk_list[$i],
|
|
|
+ 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
|
|
|
+ 'rk_time'=>$rk_time[$i],
|
|
|
+ 'ck_time'=>$ck_time[$ck_index-1],
|
|
|
+ 'is_over'=>2,//已出库
|
|
|
+ ];
|
|
|
+ }else if( !empty($ck_list[$ck_index+1]) &&($rk_list[$i] == $ck_list[$ck_index+1])){
|
|
|
+ //估计是完成 或者 成品库 强制扫出了
|
|
|
+ $tran_list[] = [
|
|
|
+ 'lx'=>$rk_list[$i],
|
|
|
+ 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
|
|
|
+ 'rk_time'=>$rk_time[$i],
|
|
|
+ 'ck_time'=>$ck_time[$ck_index+1],
|
|
|
+ 'is_over'=>2,//已出库
|
|
|
+ ];
|
|
|
+ $ck_index++;
|
|
|
+ $ck_index++;
|
|
|
+ }else{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //估计是完成 或者 成品库 强制扫出了
|
|
|
+ $tran_list[] = [
|
|
|
+ 'lx'=>$rk_list[$i],
|
|
|
+ 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
|
|
|
+ 'rk_time'=>$rk_time[$i],
|
|
|
+ 'ck_time'=>'',
|
|
|
+ 'is_over'=>-3,//已出库
|
|
|
+ ];
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return $tran_list;
|
|
|
+ }
|
|
|
}
|