Преглед изворни кода

提交仓库的 库位录入

lvhao пре 9 часа
родитељ
комит
42142a949d
2 измењених фајлова са 68 додато и 26 уклоњено
  1. 49 24
      core/CoreApp/controllers/Whlabel.php
  2. 19 2
      template/erp/whlabel_type.html

+ 49 - 24
core/CoreApp/controllers/Whlabel.php

@@ -4661,51 +4661,84 @@ class Whlabel extends Start_Controller
 		foreach ($list as $key => $value) {
 			$time = time();
 			if ($value['0'] == "") {
+				$ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
+				$j++;
 				continue;
 			}
 		
 			$warehouse = $this->warehouse->get_title($value['0']);
+			if(empty($warehouse)){
+				$ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
+				$j++;
+				continue;
+			}
 			$purchase = $this->purchase->get_bm($value['1']);
 			$sku =  $value['2'];
 			$num =  $value['3']; //调整数量
 			$text =  $value['4']; //扣减说明
-			$type =  $value['5']; //调整方式0扣减1删除
+			$type =  0; //调整方式0扣减1删除
+			$details = empty($value['5'])?'':$value['5']; //库位
 			$rktype =  $value['6'] != '' ? $value['6'] : 0; //增加库存
 			$cktype =  $value['7'] != '' ? $value['7'] : 0; //减少库存
 			
 			$d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
 			if (!$purchase) //如果没有这个SKU
 			{
-				$ed[] = array($value['1'] . '-不存在此供应商编码');
+				$ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
 				$j++;
 				continue;
 			}
 			if (!$d) //如果没有这个SKU
 			{
-				$ed[] = array($sku . '-库存中不存在此SKU');
+				$ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
 				$j++;
 				continue;
 			}
 			if (!isset($warehouse['id'])) {
-				$ed[] = array($sku . '-仓库名错误!');
+				$ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
 				$j++;
 				continue;
 			}
 			if ($type != '0' && $type != '1') {
-				$ed[] = array($sku . '-扣减方式填写错误!');
+				$ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
 				$j++;
 				continue;
 			}
+			
+			if($details != 'DZ001'){
+				$kw_info = $this->whlabel->find('warehouse = '.$warehouse['id'].' and sku = "' . $sku . '" and  state = 0 and details != "DZ001"');
+				//判断是否有货
+				if(!empty($kw_info)){
+					//判断是否有录入库位了
+					if(empty($kw_info['details'])){
+						if($kw_info['details'] != $details){
+							$ed[] = ['msg'=>$sku . '的在系统中没有库位!'] ;
+							$j++;
+							continue;
+						}
+					}else{
+						//如果有库位了 但是库位不匹配
+						if($kw_info['details'] != $details){
+							$ed[] = ['msg'=>$sku . '的系统库位是'.$kw_info['details'].'!'] ;
+							$j++;
+							continue;
+						}
+					}
+				}
+				
+				
+			}
+			
 			if ($num < 0) //扣减库存
 			{
 				if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
-					$ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
+					$ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
 					$j++;
 					continue;
 				}
-				$data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
+				$data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null)and state = 0 and details = "'. $details .'"');
 				if (count($data) < abs($num)) {
-					$ed[] = array($sku . '-扣减数量大于库存剩余数量!');
+					$ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
 					$j++;
 					continue;
 				}
@@ -4717,7 +4750,7 @@ class Whlabel extends Start_Controller
 				} else if ($type == 1) {
 					$zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
 					if (count($zt) > 0) {
-						$ed[] = array($sku . '-有在途库存无法删除!');
+						$ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
 						$j++;
 						continue;
 					}
@@ -4728,7 +4761,7 @@ class Whlabel extends Start_Controller
 			} else if ($num > 0) //增加库存
 			{
 				if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
-					$ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
+					$ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
 					$j++;
 					continue;
 				}
@@ -4741,6 +4774,7 @@ class Whlabel extends Start_Controller
 				$post['title'] = $d['title'];
 				$post['number'] = $d['number'];
 				$post['features'] = $d['features'];
+				$post['details'] = $details;
 				$post['enter'] = $time;
 				$post['time'] = $time; //操作时间
 				$post['rktype'] = $rktype;
@@ -4753,25 +4787,16 @@ class Whlabel extends Start_Controller
 			}
 			sleep(1); //防止入库时间一样,需要延迟1秒
 		}
+
 		if ($j > 0) {
 			$tt = date('Ymd', time());
 			$title = '库存导入错误信息-' . $tt;
-			$titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
-			$tail = "\n";
-			$filename = $title . ".xls";
-			$ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
-			$dir = '/data/excel/' . $time . '/';
-			$file_name = 'error_' . $time . rand(1000, 9999);
-			if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
-			$myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
-			fwrite($myfile, $ecl);
-			fclose($myfile);
-			$error = $dir . $file_name . '.xls';
-			$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
-			echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
+			$error =  $title . '.xls';
+			//$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
+			echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
 			exit;
 		} else {
-			$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
+			//$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
 			echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
 			exit;
 		}

+ 19 - 2
template/erp/whlabel_type.html

@@ -428,8 +428,15 @@ function whlabeldr_two(dr){
                 success: function(a) {
                     layx.destroy('loadId');
                     if (a && a.success) {
-                        if (a.error == 1) errora(a);
-                        else errorb(a);
+                        if (a.error == 1){
+                            errora(a);
+                        } 
+                        else {
+                           layx.alert('提示', a.msg, function(id, button) {
+                                console.log(a.ed)
+                                downloadexcel(a.ed,a.error)
+			                }, { dialogIcon: 'error' });
+                        }
                     } else {
                         errorc(a);
                     }
@@ -452,6 +459,16 @@ function whlabeldr_two(dr){
     };
     reader.readAsArrayBuffer(file); // 以 ArrayBuffer 读取
 }
+function downloadexcel(data,filename){
+    let  sheet = XLSX.utils.json_to_sheet(data)
+
+
+
+    let workbook = XLSX.utils.book_new();
+
+    XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
+    XLSX.writeFile(workbook, filename);
+}
 
 </script>
 <script type="text/javascript" src="{$theme}js/excel/xlxs.js" ></script>