|
|
@@ -754,9 +754,7 @@ class QcodeBach extends Backend
|
|
|
'l_flow' => ltrim(substr($code, 53, 6), '0'),
|
|
|
'qrcode' => $code,
|
|
|
'pCode' => $this->qrcode($code),
|
|
|
- 'batch' => (substr($code, 76, 10) == '0000000000') ?
|
|
|
- ltrim(substr($code, 66, 10), '0') :
|
|
|
- ltrim(substr($code, 66, 10), '0') . '、' . ltrim(substr($code, 76, 10), '0')
|
|
|
+ 'batch' => $this->getPrintBatch($bachArr),
|
|
|
];
|
|
|
|
|
|
// 数量处理
|
|
|
@@ -829,9 +827,7 @@ class QcodeBach extends Backend
|
|
|
'l_flow' => ltrim(substr($code, 53, 6), '0'),
|
|
|
'qrcode' => $code,
|
|
|
'pCode' => $this->qrcode($code),
|
|
|
- 'batch' => (substr($code, 76, 10) == '0000000000') ?
|
|
|
- ltrim(substr($code, 66, 10), '0') :
|
|
|
- ltrim(substr($code, 66, 10), '0') . '、' . ltrim(substr($code, 76, 10), '0')
|
|
|
+ 'batch' => $this->getPrintBatch($bachArr),
|
|
|
];
|
|
|
|
|
|
if ($rowData['l_num'] === null) {
|
|
|
@@ -938,9 +934,7 @@ class QcodeBach extends Backend
|
|
|
'l_flow' => ltrim(substr($large['code'], 53, 6), '0') . '-' . $small['l_flow'],
|
|
|
'qrcode' => $code,
|
|
|
// 'pCode' => $this->qrcode($code), // 如需启用二维码图像,取消注释
|
|
|
- 'batch' => (substr($code, 76, 10) == '0000000000') ?
|
|
|
- ltrim(substr($code, 66, 10), '0') :
|
|
|
- ltrim(substr($code, 66, 10), '0') . '、' . ltrim(substr($code, 76, 10), '0'),
|
|
|
+ 'batch' => $this->getPrintBatch($bachArr),
|
|
|
];
|
|
|
$key++;
|
|
|
}
|
|
|
@@ -964,9 +958,10 @@ class QcodeBach extends Backend
|
|
|
|
|
|
$large = $qcodeLarge->name($tableLarge)->where('_id', $ids[0])->find();
|
|
|
$bach = $this->model->name($tableBach)->where('_id', json_decode($large, true)['bach_id'])->find();
|
|
|
+ $bachArr = json_decode($bach, true);
|
|
|
|
|
|
- $company_name = json_decode($bach, true)['supplier_name'];
|
|
|
- $product_name = json_decode($bach, true)['matter_name'];
|
|
|
+ $company_name = $bachArr['supplier_name'];
|
|
|
+ $product_name = $bachArr['matter_name'];
|
|
|
|
|
|
foreach ($ids as $value) {
|
|
|
$large = $qcodeLarge->name($tableLarge)->where('_id', $value)->find();
|
|
|
@@ -987,9 +982,7 @@ class QcodeBach extends Backend
|
|
|
'l_flow' => ltrim(substr($large['code'], 53, 6), '0') . '-' . $small['l_flow'],
|
|
|
'qrcode' => $code,
|
|
|
// 'pCode' => $this->qrcode($code),
|
|
|
- 'batch' => (substr($code, 76, 10) == '0000000000') ?
|
|
|
- ltrim(substr($code, 66, 10), '0') :
|
|
|
- ltrim(substr($code, 66, 10), '0') . '、' . ltrim(substr($code, 76, 10), '0'),
|
|
|
+ 'batch' => $this->getPrintBatch($bachArr),
|
|
|
];
|
|
|
$key++;
|
|
|
}
|
|
|
@@ -1062,9 +1055,7 @@ class QcodeBach extends Backend
|
|
|
'l_flow' => ltrim(substr($large['code'], 53, 6), '0') . '-' . $small['l_flow'],
|
|
|
'qrcode' => $code,
|
|
|
// 'pCode' => $this->qrcode($code),
|
|
|
- 'batch' => (substr($code, 76, 10) == '0000000000') ?
|
|
|
- ltrim(substr($code, 66, 10), '0') :
|
|
|
- ltrim(substr($code, 66, 10), '0') . '、' . ltrim(substr($code, 76, 10), '0'),
|
|
|
+ 'batch' => $this->getPrintBatch($bach),
|
|
|
];
|
|
|
|
|
|
break; // 查到就退出循环
|
|
|
@@ -1099,9 +1090,7 @@ class QcodeBach extends Backend
|
|
|
'l_flow' => ltrim(substr($large['code'], 53, 6), '0') . '-' . $small['l_flow'],
|
|
|
'qrcode' => $code,
|
|
|
// 'pCode' => $this->qrcode($code),
|
|
|
- 'batch' => (substr($code, 76, 10) == '0000000000') ?
|
|
|
- ltrim(substr($code, 66, 10), '0') :
|
|
|
- ltrim(substr($code, 66, 10), '0') . '、' . ltrim(substr($code, 76, 10), '0'),
|
|
|
+ 'batch' => $this->getPrintBatch($bach),
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -1199,9 +1188,13 @@ class QcodeBach extends Backend
|
|
|
$code = json_decode($large,true)['code'];
|
|
|
|
|
|
if($code){
|
|
|
- $code1 = substr($code,0,59);
|
|
|
- $code2 = substr($code,65,85);
|
|
|
- $data['code'] = $code1.str_pad(intval($req['row']['numn'])*100,6, '0', STR_PAD_LEFT).$code2;
|
|
|
+ $weightVal = intval(round($req['row']['numn'] * 100));
|
|
|
+ if ($weightVal > 999999) {
|
|
|
+ $this->error('重量超出编码范围');
|
|
|
+ }
|
|
|
+ $code1 = substr($code, 0, 59);
|
|
|
+ $code2 = substr($code, 65);
|
|
|
+ $data['code'] = $code1 . str_pad((string)$weightVal, 6, '0', STR_PAD_LEFT) . $code2;
|
|
|
//修改code和大件重量
|
|
|
$qcodeLarge->name($company_id.'_'."qcode_large")->where('_id',$val)->update($data);
|
|
|
}
|
|
|
@@ -1589,4 +1582,17 @@ class QcodeBach extends Backend
|
|
|
// echo "成功插入 " . count($differences) . " 条记录";
|
|
|
// }
|
|
|
|
|
|
+ /**
|
|
|
+ * 打印标签批次号(优先批次表,避免code字段错位解析)
|
|
|
+ * @param array $bachArr
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ private function getPrintBatch($bachArr)
|
|
|
+ {
|
|
|
+ if (!is_array($bachArr) || !isset($bachArr['bach_num']) || $bachArr['bach_num'] === '') {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return (string)$bachArr['bach_num'];
|
|
|
+ }
|
|
|
+
|
|
|
}
|