|
|
@@ -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;
|
|
|
}
|