$battery_id) { // 判断电池是否为空 if (empty($battery_id)) { throw new Exception("电池条码数组第[{$k}]位置的电池条码不能是:[0, '0', '', null, NAN]等,请上传电池条码"); } $sql = sprintf( "SELECT tray,lot,batch,subbatch FROM hf_mes_production_battery_map WHERE battery_id='%s' ORDER BY id DESC LIMIT 1;", $battery_id ); $ret = Db::fetch($sql); list($tray, $lot, $batch, $subbatch) = [ $ret['tray'], $ret['lot'], $ret['batch'], $ret['subbatch'] ]; $sql = sprintf( "SELECT flow_id FROM hf_mes_production_planning_management_batch WHERE batch='%s' LIMIT 1;", $batch ); $ret = Db::fetch($sql); $flow_id = $ret['flow_id']; $sql = sprintf( "SELECT class,classname,next_process_code FROM \"%s\" WHERE battery_id='%s' AND tray='%s' AND lot='%s' LIMIT 1;", config('app.bkv_prefix') . $subbatch, $battery_id, $tray, $lot ); $ret = Db::fetch($sql); // 判断当前工序单元与下一个工序单元是否一致 $current_process_code = "{$flow_id}_{$param['workingsubclass']}"; if ($current_process_code != $ret['next_process_code']) { throw new Exception("电池条码[{$battery_id}]当前工序[{$current_process_code}]与系统当前工序[{$ret['next_process_code']}]不一致"); } $sql = sprintf( "UPDATE \"%s\" SET \"{$current_process_code}.START_TIME\"='%s' WHERE battery_id='%s' AND tray='%s' AND lot='%s';", config('app.bkv_prefix') . $subbatch, $date, $battery_id, $tray, $lot ); Db::query($sql); } } catch (Exception $e) { throw new Exception($e->getMessage()); } return ''; } }