|
@@ -192,6 +192,12 @@ class Entrust extends Backend
|
|
|
$this->assign('report_grant',$report_grant);
|
|
$this->assign('report_grant',$report_grant);
|
|
|
$this->assign('sample_stand',$sample_stand);
|
|
$this->assign('sample_stand',$sample_stand);
|
|
|
$this->view->assign('row', $row);
|
|
$this->view->assign('row', $row);
|
|
|
|
|
+ //修改判定标准
|
|
|
|
|
+// $entrust = Db::name('entrust')->where('id',$ids)->find();
|
|
|
|
|
+// $item_judge = $entrust['standard_id'];
|
|
|
|
|
+// $this->assign('item_judge',$item_judge);
|
|
|
|
|
+ $judgeData = Db::name('item_judge')->whereNull('delete')->column('id,name');
|
|
|
|
|
+ $this->view->assign('judgeData', $judgeData);
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
}
|
|
}
|
|
|
$params = $this->request->post('row/a');
|
|
$params = $this->request->post('row/a');
|
|
@@ -201,6 +207,9 @@ class Entrust extends Backend
|
|
|
$params['project'] = implode(',',$params['project']);
|
|
$params['project'] = implode(',',$params['project']);
|
|
|
$params['report_grant'] = implode(',',$params['report_grant']);
|
|
$params['report_grant'] = implode(',',$params['report_grant']);
|
|
|
$params['sample_stand'] = implode(',',$params['sample_stand']);
|
|
$params['sample_stand'] = implode(',',$params['sample_stand']);
|
|
|
|
|
+ $item_judge = Db::name('item_judge')->field('id,name')->where('id',$params['standard_id'])->find();
|
|
|
|
|
+ $params['standard_id'] = $item_judge['id'];
|
|
|
|
|
+ $params['standard_name'] = $item_judge['name'];
|
|
|
$params = $this->preExcludeFields($params);
|
|
$params = $this->preExcludeFields($params);
|
|
|
$result = false;
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
@@ -283,19 +292,10 @@ class Entrust extends Backend
|
|
|
//提交到检测
|
|
//提交到检测
|
|
|
public function submit()
|
|
public function submit()
|
|
|
{
|
|
{
|
|
|
-// if (false === $this->request->isPost()) {
|
|
|
|
|
-// $id = input('id');
|
|
|
|
|
-// $judgeData = Db::name('item_judge')->whereNull('delete')->column('id,name');
|
|
|
|
|
-// $this->view->assign('judgeData', $judgeData);
|
|
|
|
|
-// $this->view->assign('id', $id);
|
|
|
|
|
-// return $this->view->fetch();
|
|
|
|
|
-// }
|
|
|
|
|
-// $id = input('id');//委托单id
|
|
|
|
|
-// $temp_id = input('temp');//判定标准id
|
|
|
|
|
-// if (empty($id) || empty($temp_id)){
|
|
|
|
|
-// $this->error('参数错误');
|
|
|
|
|
-// }
|
|
|
|
|
$idList = explode(',', input('id'));//委托单id
|
|
$idList = explode(',', input('id'));//委托单id
|
|
|
|
|
+ if (empty($idList)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
//检测结果数据
|
|
//检测结果数据
|
|
|
$params = [];
|
|
$params = [];
|
|
|
//更新数据
|
|
//更新数据
|
|
@@ -315,7 +315,6 @@ class Entrust extends Backend
|
|
|
* 生成检测结果
|
|
* 生成检测结果
|
|
|
*/
|
|
*/
|
|
|
$entrust = Db::name('entrust')->where('id', $id)->find();
|
|
$entrust = Db::name('entrust')->where('id', $id)->find();
|
|
|
-
|
|
|
|
|
/***
|
|
/***
|
|
|
* 无法确认是哪台机器(GC、GCMS)检测
|
|
* 无法确认是哪台机器(GC、GCMS)检测
|
|
|
* 1、先去找gcms表 没有查到数据 再找gc表
|
|
* 1、先去找gcms表 没有查到数据 再找gc表
|
|
@@ -368,7 +367,7 @@ class Entrust extends Backend
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$judge = Db::name('item_judge_detail')->where('pid', $temp_id[$ke])->select();
|
|
$judge = Db::name('item_judge_detail')->where('pid', $temp_id[$ke])->select();
|
|
|
- $class = Db::name('item_judge')->where('id', $temp_id[$ke])->value('class');//获取判定标准类别
|
|
|
|
|
|
|
+ $class = Db::name('item_judge')->where('id', $id)->value('class');//获取判定标准类别
|
|
|
$sum_all_dis_data = array_sum($all_dis_data);
|
|
$sum_all_dis_data = array_sum($all_dis_data);
|
|
|
if ($class == 1) {//常规类 26项减去乙醇 杂质总量14项
|
|
if ($class == 1) {//常规类 26项减去乙醇 杂质总量14项
|
|
|
$dis = $sum_all_dis_data - $ethanol; //残留总量
|
|
$dis = $sum_all_dis_data - $ethanol; //残留总量
|
|
@@ -416,44 +415,41 @@ class Entrust extends Backend
|
|
|
if ($is_pass == 4) {
|
|
if ($is_pass == 4) {
|
|
|
$params[$ke]['judge'] = 1;
|
|
$params[$ke]['judge'] = 1;
|
|
|
}
|
|
}
|
|
|
- $params[$ke]['entrust_no'] = $entrust['no'];
|
|
|
|
|
- $params[$ke]['entrust_id'] = $entrust['id'];
|
|
|
|
|
- $params[$ke]['machine'] = 'GCMS';
|
|
|
|
|
|
|
+ $params[$ke]['entrust_no'] = $entrust['no'];
|
|
|
|
|
+ $params[$ke]['entrust_id'] = $entrust['id'];
|
|
|
|
|
+ $params[$ke]['machine'] = 'GCMS';
|
|
|
if ($gather_tab == 'gather_txt_check_gc') {
|
|
if ($gather_tab == 'gather_txt_check_gc') {
|
|
|
$params[$ke]['machine'] = 'GC';
|
|
$params[$ke]['machine'] = 'GC';
|
|
|
}
|
|
}
|
|
|
- $params[$ke]['name'] = $entrust['name'];
|
|
|
|
|
- $params[$ke]['bach'] = $entrust['bach'];
|
|
|
|
|
- $params[$ke]['sample_no'] = $entrust['sample_no'];
|
|
|
|
|
- $params[$ke]['standard_id'] = $temp_id[$ke];
|
|
|
|
|
- $params[$ke]['standard_name'] = $judge[0]['name'];
|
|
|
|
|
- $params[$ke]['dis'] = $dis;
|
|
|
|
|
- $params[$ke]['dis_impurity'] = $dis_impurity;
|
|
|
|
|
- $params[$ke]['ben_total'] = $ben_total;
|
|
|
|
|
- $params[$ke]['ben'] = $ben;
|
|
|
|
|
- $params[$ke]['unit'] = 'mg/m2';
|
|
|
|
|
- $params[$ke]['create'] = date('Y-m-d H:i:s');
|
|
|
|
|
- $params[$ke]['maker'] = Session::get('admin')['username'];
|
|
|
|
|
- $params[$ke]['params'] = Db::name('item_judge')->where('id', $temp_id[$ke])->value('list_name');
|
|
|
|
|
- $params[$ke]['userid'] = Session::get('admin')['id'];;
|
|
|
|
|
- $params[$ke]['status'] = 0;
|
|
|
|
|
- $params[$ke]['work_unit'] = $entrust['work_unit'];
|
|
|
|
|
- $params[$ke]['work_name'] = $entrust['work_name'];
|
|
|
|
|
|
|
+ $params[$ke]['name'] = $entrust['name'];
|
|
|
|
|
+ $params[$ke]['bach'] = $entrust['bach'];
|
|
|
|
|
+ $params[$ke]['sample_no'] = $entrust['sample_no'];
|
|
|
|
|
+ $params[$ke]['standard_id'] = $temp_id[$ke];
|
|
|
|
|
+ $params[$ke]['standard_name'] = $judge[0]['name'];
|
|
|
|
|
+ $params[$ke]['dis'] = $dis;
|
|
|
|
|
+ $params[$ke]['dis_impurity'] = $dis_impurity;
|
|
|
|
|
+ $params[$ke]['ben_total'] = $ben_total;
|
|
|
|
|
+ $params[$ke]['ben'] = $ben;
|
|
|
|
|
+ $params[$ke]['unit'] = 'mg/m2';
|
|
|
|
|
+ $params[$ke]['create'] = date('Y-m-d H:i:s');
|
|
|
|
|
+ $params[$ke]['maker'] = Session::get('admin')['username'];
|
|
|
|
|
+ $params[$ke]['params'] = Db::name('item_judge')->where('id', $temp_id[$ke])->value('list_name');
|
|
|
|
|
+ $params[$ke]['userid'] = Session::get('admin')['id'];;
|
|
|
|
|
+ $params[$ke]['status'] = 0;
|
|
|
|
|
+ $params[$ke]['work_unit'] = $entrust['work_unit'];
|
|
|
|
|
+ $params[$ke]['work_name'] = $entrust['work_name'];
|
|
|
// $entrust_update[$ke]['standard_id'] = $temp_id[$ke];
|
|
// $entrust_update[$ke]['standard_id'] = $temp_id[$ke];
|
|
|
// $entrust_update[$ke]['standard_name'] = $judge[0]['name'];
|
|
// $entrust_update[$ke]['standard_name'] = $judge[0]['name'];
|
|
|
- $entrust_update[$ke]['status'] = 2;
|
|
|
|
|
- $entrust_update[$ke]['gather_id'] = $gather['id'];
|
|
|
|
|
- $entrust_update[$ke]['gather_tab'] = $gather_tab;
|
|
|
|
|
|
|
+ $entrust_update[$ke]['status'] = 2;
|
|
|
|
|
+ $entrust_update[$ke]['gather_id'] = $gather['id'];
|
|
|
|
|
+ $entrust_update[$ke]['gather_tab'] = $gather_tab;
|
|
|
|
|
|
|
|
$log[$ke]['userid'] = Session::get('admin')['id'];
|
|
$log[$ke]['userid'] = Session::get('admin')['id'];
|
|
|
- $log[$ke]['username'] = Session::get('admin')['username'];
|
|
|
|
|
- $log[$ke]['operate'] = '提交委托单id值为' . $id . '到检测';
|
|
|
|
|
- $log[$ke]['content'] = '选用检测标准为:"' . $judge[0]['name']. '",检测数据为:' . $gather_tab . '/' . $gather['id'];
|
|
|
|
|
- $log[$ke]['e_id'] = $id;
|
|
|
|
|
- $log[$ke]['create'] = date('Y-m-d H:i:s');
|
|
|
|
|
-// if ($result === false) {
|
|
|
|
|
-// $this->error(__('No rows were inserted'));
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ $log[$ke]['username'] = Session::get('admin')['username'];
|
|
|
|
|
+ $log[$ke]['operate'] = '提交委托单id值为' . $id . '到检测';
|
|
|
|
|
+ $log[$ke]['content'] = '选用检测标准为:"' . $judge[0]['name']. '",检测数据为:' . $gather_tab . '/' . $gather['id'];
|
|
|
|
|
+ $log[$ke]['e_id'] = $id;
|
|
|
|
|
+ $log[$ke]['create'] = date('Y-m-d H:i:s');
|
|
|
}
|
|
}
|
|
|
$result = 0;
|
|
$result = 0;
|
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
@@ -465,14 +461,24 @@ class Entrust extends Backend
|
|
|
*/
|
|
*/
|
|
|
for ($i=0;$i<count($idList);$i++){
|
|
for ($i=0;$i<count($idList);$i++){
|
|
|
$entrust_res = Db::name('entrust')->where('id', $idList[$i])->update($entrust_update[$i]);
|
|
$entrust_res = Db::name('entrust')->where('id', $idList[$i])->update($entrust_update[$i]);
|
|
|
- $res_check = Db::name('res')->insert($params[$i]);
|
|
|
|
|
|
|
+ $entrust_id = Db::name('res')->where('entrust_id',$idList[$i])->find();
|
|
|
|
|
+ if (empty($entrust_id)) {
|
|
|
|
|
+ $res_check = Db::name('res')->insert($params[$i]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $data =Db::name('res')
|
|
|
|
|
+ ->whereIn('entrust_id',$idList[$i])
|
|
|
|
|
+ ->update(['delete_time'=>date('Y-m-d H:i:s')]);
|
|
|
|
|
+ if (!$data){
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ $res_check = Db::name('res')->insert($params[$i]);
|
|
|
|
|
+ }
|
|
|
$log_res = Db::name('entrust_log')->insert($log[$i]);
|
|
$log_res = Db::name('entrust_log')->insert($log[$i]);
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!$log_res || !$res_check) {
|
|
|
|
|
- $result = false;
|
|
|
|
|
- }else{
|
|
|
|
|
- $result += 1;
|
|
|
|
|
|
|
+ if (!$log_res || !$res_check) {
|
|
|
|
|
+ $result = false;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $result += 1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
} catch (ValidateException|PDOException|Exception $e) {
|