|
|
@@ -372,37 +372,42 @@ class ReportingWork extends Api
|
|
|
$data['码结束行'] = 0;
|
|
|
$data['mod_rq'] = '1900-01-01 00:00:00';
|
|
|
$data['sys_rq'] = date('Y-m-d H:i:s');
|
|
|
-
|
|
|
- $batchData = explode(',',$batch);
|
|
|
- $newData = [];
|
|
|
- $batchUniqId = \db('物料_批次跟踪')->order('UniqId desc')->value('UniqId');
|
|
|
- if ($batchUniqId < 10000000){
|
|
|
- $batchUniqId = 10000000;
|
|
|
- }
|
|
|
- foreach ($batchData as $key=>$item){
|
|
|
- $batchUniqId++;
|
|
|
- $val = explode('-',$item);
|
|
|
- $newData[$key]['wlbh'] = $val[0];
|
|
|
- $newData[$key]['wlBatch'] = $val[1];
|
|
|
- $newData[$key]['sczl_gdbh'] = $data['sczl_gdbh'];
|
|
|
- $newData[$key]['sczl_yjno'] = $data['sczl_yjno'];
|
|
|
- $newData[$key]['sczl_gxh'] = $data['sczl_gxh'];
|
|
|
- $newData[$key]['sczl_gxmc'] = $data['sczl_gxmc'];
|
|
|
- $newData[$key]['sczl_num'] = $data['sczl_num'];
|
|
|
- $newData[$key]['sys_id'] = $data['sys_id'];
|
|
|
- $newData[$key]['sys_rq'] = $data['sys_rq'];
|
|
|
- $newData[$key]['UniqID'] = $batchUniqId;
|
|
|
+ if (!empty($batch)){
|
|
|
+ $batchData = explode(',',$batch);
|
|
|
+ $newData = [];
|
|
|
+ $batchUniqId = \db('物料_批次跟踪')->order('UniqId desc')->value('UniqId');
|
|
|
+ if ($batchUniqId < 10000000){
|
|
|
+ $batchUniqId = 10000000;
|
|
|
+ }
|
|
|
+ foreach ($batchData as $key=>$item){
|
|
|
+ $batchUniqId++;
|
|
|
+ $val = explode('-',$item);
|
|
|
+ $newData[$key]['wlbh'] = $val[0];
|
|
|
+ $newData[$key]['wlBatch'] = $val[1];
|
|
|
+ $newData[$key]['sczl_gdbh'] = $data['sczl_gdbh'];
|
|
|
+ $newData[$key]['sczl_yjno'] = $data['sczl_yjno'];
|
|
|
+ $newData[$key]['sczl_gxh'] = $data['sczl_gxh'];
|
|
|
+ $newData[$key]['sczl_gxmc'] = $data['sczl_gxmc'];
|
|
|
+ $newData[$key]['sczl_num'] = $data['sczl_num'];
|
|
|
+ $newData[$key]['sys_id'] = $data['sys_id'];
|
|
|
+ $newData[$key]['sys_rq'] = $data['sys_rq'];
|
|
|
+ $newData[$key]['UniqID'] = $batchUniqId;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
$res = false;
|
|
|
$batch_res = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$sql = \db('设备_产量计酬')->fetchSql(true)->insert($data);
|
|
|
$res = Db::query($sql);
|
|
|
- $batch_sql = \db('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
|
|
|
- $batch_res = Db::query($batch_sql);
|
|
|
+ if (!empty($batch)){
|
|
|
+ $batch_sql = \db('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
|
|
|
+ $batch_res = Db::query($batch_sql);
|
|
|
+ }else{
|
|
|
+ $batch_res = true;
|
|
|
+ }
|
|
|
+
|
|
|
Db::commit();
|
|
|
cache('MachineProductReport-getList',null);
|
|
|
}catch (\Exception $e){
|