|
|
@@ -99,6 +99,8 @@ class Entrust extends Backend
|
|
|
$company = Db::name('company')->where('id',$company_id)->column('id,name');
|
|
|
}
|
|
|
$this->assign('company',$company);
|
|
|
+ $judgeData = Db::name('item_judge')->whereNull('delete')->column('id,name');
|
|
|
+ $this->view->assign('judgeData', $judgeData);
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
$params = $this->request->post('row/a');
|
|
|
@@ -113,6 +115,9 @@ class Entrust extends Backend
|
|
|
$params['report_grant'] = implode(',',$params['report_grant']);
|
|
|
$params['sample_stand'] = implode(',',$params['sample_stand']);
|
|
|
$params['manufacturer'] = preg_replace('/\s+/','',$params['manufacturer']);
|
|
|
+ $params['standard_id'] = preg_replace('/\s+/','',$params['standard_id']);
|
|
|
+ $judge = Db::name('item_judge')->where('id',$params['standard_id'])->find();
|
|
|
+ $params['standard_name'] = $judge['name'];
|
|
|
$params['user_name'] = $userinfo['username'];
|
|
|
$params['work_unit'] = $userinfo['company'];
|
|
|
$params['work_name'] = Db::name('company')->where('id',$userinfo['company'])->value('name');
|
|
|
@@ -276,49 +281,62 @@ class Entrust extends Backend
|
|
|
$this->error(__('No rows were deleted'));
|
|
|
}
|
|
|
//提交到检测
|
|
|
- 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('参数错误');
|
|
|
- }
|
|
|
+ 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
|
|
|
+ //检测结果数据
|
|
|
+ $params = [];
|
|
|
+ //更新数据
|
|
|
+ $entrust_update = [];
|
|
|
+ //日志记录
|
|
|
+ $log = [];
|
|
|
+ foreach ($idList as $ke => $id) {
|
|
|
+ $temp_id[$ke] = Db::name('entrust')->where('id', $id)->value('standard_id');
|
|
|
+ //$temp_id[$kk] 判断标准id
|
|
|
+ //$vv 委托单id
|
|
|
+ if (empty($temp_id[$ke])) {
|
|
|
+ $this->error($id . '未获取到判断标准');
|
|
|
+ }
|
|
|
/***
|
|
|
* 提交后,更新此数据的 判定标准、委托状态
|
|
|
* 根据数据文件名称绑定检测数据
|
|
|
* 生成检测结果
|
|
|
- */
|
|
|
- $entrust = Db::name('entrust')->where('id',$id)->find();
|
|
|
+ */
|
|
|
+ $entrust = Db::name('entrust')->where('id', $id)->find();
|
|
|
+
|
|
|
/***
|
|
|
* 无法确认是哪台机器(GC、GCMS)检测
|
|
|
* 1、先去找gcms表 没有查到数据 再找gc表
|
|
|
- */
|
|
|
- $data_txt = $entrust['sample_no'].'MS.D'; //如果是GCMS机台,数据文件为委托编号+MS.D
|
|
|
- $gather_gcms = Db::name('gather_txt_gcms')->where('data_txt_name',$data_txt)->order('id desc')->find();
|
|
|
- if (empty($gather_gcms)){
|
|
|
- $data_txt_gc = $entrust['sample_no'].'.D';
|
|
|
- $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name',$data_txt_gc)->order('id desc')->find();
|
|
|
- if (empty($gather_gc)){
|
|
|
+ */
|
|
|
+ $data_txt = $entrust['sample_no'] . 'MS.D'; //如果是GCMS机台,数据文件为委托编号+MS.D
|
|
|
+ $gather_gcms = Db::name('gather_txt_gcms')->where('data_txt_name', $data_txt)->order('id desc')->find();
|
|
|
+ if (empty($gather_gcms)) {
|
|
|
+ $data_txt_gc = $entrust['sample_no'] . '.D';
|
|
|
+ $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name', $data_txt_gc)->order('id desc')->find();
|
|
|
+ if (empty($gather_gc)) {
|
|
|
$this->error('未获取到检测数据');
|
|
|
}
|
|
|
$gather = $gather_gc;
|
|
|
$gather_tab = 'gather_txt_check_gc';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$gather = $gather_gcms;
|
|
|
$gather_tab = 'gather_txt_check_gcms';
|
|
|
}
|
|
|
-
|
|
|
- $detail_data = Db::name($gather_tab)->where('pid',$gather['id'])->field('chemical_compound,potency')->select();
|
|
|
-
|
|
|
+ $detail_data = Db::name($gather_tab)->where('pid', $gather['id'])->field('chemical_compound,potency')->select();
|
|
|
$is_qualified = [];//默认合格,当有一项不合格时,判定此次检测不合格
|
|
|
- $dis= 0;//溶剂残留总量
|
|
|
+ $dis = 0;//溶剂残留总量
|
|
|
$dis_impurity_data = [];//溶剂杂质总量
|
|
|
$ben_total_data = [];//苯系物总量
|
|
|
$ben = 0; //苯含量
|
|
|
@@ -326,115 +344,118 @@ class Entrust extends Backend
|
|
|
$ethanol = 0; //乙醇含量
|
|
|
$methanol = 0; //甲醇含量
|
|
|
$ethylacetate = 0; //乙酸乙酯含量
|
|
|
- $dis_impurity_arr = ['甲醇','丙酮','正丁醇','苯','2-乙氧基乙醇','4-甲基-2-戊酮','甲苯','乙酸正丁酯','乙苯','间对二甲苯','邻-二甲苯','苯乙烯','2-乙氧基乙基乙酸酯','环己酮'];
|
|
|
- $ben_arr = ['甲苯','乙苯','间对二甲苯','邻-二甲苯'];
|
|
|
- foreach ($detail_data as $key=>$value){
|
|
|
+ $dis_impurity_arr = ['甲醇', '丙酮', '正丁醇', '苯', '2-乙氧基乙醇', '4-甲基-2-戊酮', '甲苯', '乙酸正丁酯', '乙苯', '间对二甲苯', '邻-二甲苯', '苯乙烯', '2-乙氧基乙基乙酸酯', '环己酮'];
|
|
|
+ $ben_arr = ['甲苯', '乙苯', '间对二甲苯', '邻-二甲苯'];
|
|
|
+ foreach ($detail_data as $key => $value) {
|
|
|
$all_dis_data[$key] = $value['potency'];
|
|
|
- if ($value['chemical_compound'] == '乙醇'){//乙醇含量
|
|
|
+ if ($value['chemical_compound'] == '乙醇') {//乙醇含量
|
|
|
$ethanol = $value['potency'];
|
|
|
}
|
|
|
- if ($value['chemical_compound'] == '苯'){//苯含量
|
|
|
+ if ($value['chemical_compound'] == '苯') {//苯含量
|
|
|
$ben = $value['potency'];
|
|
|
}
|
|
|
- if (in_array($value['chemical_compound'],$dis_impurity_arr)){//溶剂杂质总量
|
|
|
+ if (in_array($value['chemical_compound'], $dis_impurity_arr)) {//溶剂杂质总量
|
|
|
$dis_impurity_data[$value['chemical_compound']] = $value['potency'];
|
|
|
}
|
|
|
- if (in_array($value['chemical_compound'],$ben_arr)){//苯系物总量
|
|
|
+ if (in_array($value['chemical_compound'], $ben_arr)) {//苯系物总量
|
|
|
$ben_total_data[$value['chemical_compound']] = $value['potency'];
|
|
|
}
|
|
|
- if ($value['chemical_compound'] == '甲醇'){//甲醇含量
|
|
|
+ if ($value['chemical_compound'] == '甲醇') {//甲醇含量
|
|
|
$methanol = $value['potency'];
|
|
|
}
|
|
|
- if ($value['chemical_compound'] == '乙酸乙酯'){//乙酸乙酯含量
|
|
|
+ if ($value['chemical_compound'] == '乙酸乙酯') {//乙酸乙酯含量
|
|
|
$ethylacetate = $value['potency'];
|
|
|
}
|
|
|
}
|
|
|
- $judge = Db::name('item_judge_detail')->where('pid',$temp_id)->select();
|
|
|
- $class = Db::name('item_judge')->where('id',$temp_id)->value('class');//获取判定标准类别
|
|
|
+ $judge = Db::name('item_judge_detail')->where('pid', $temp_id[$ke])->select();
|
|
|
+ $class = Db::name('item_judge')->where('id', $temp_id[$ke])->value('class');//获取判定标准类别
|
|
|
$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_impurity = array_sum($dis_impurity_data); //杂质总量
|
|
|
- }elseif ($class == 2){//特殊类1 26项减去乙醇、甲醇、乙酸乙酯,杂质总量减去甲醇
|
|
|
+ } elseif ($class == 2) {//特殊类1 26项减去乙醇、甲醇、乙酸乙酯,杂质总量减去甲醇
|
|
|
$dis = $sum_all_dis_data - $ethanol - $methanol - $ethylacetate; //残留总量
|
|
|
$dis_impurity = array_sum($dis_impurity_data) - $methanol; //杂质总量
|
|
|
- }else{//特殊类2 26项减去乙醇 杂质总量14项减去甲醇
|
|
|
+ } else {//特殊类2 26项减去乙醇 杂质总量14项减去甲醇
|
|
|
$dis = $sum_all_dis_data - $ethanol; //残留总量
|
|
|
$dis_impurity = array_sum($dis_impurity_data) - $methanol; //杂质总量
|
|
|
}
|
|
|
$ben_total = array_sum($ben_total_data); //苯系物重量
|
|
|
- foreach ($judge as $k=>$v){
|
|
|
- if ($v['params'] == '溶剂残留总量'){
|
|
|
- if ( $dis < $v['max']){
|
|
|
+ foreach ($judge as $k => $v) {
|
|
|
+ if ($v['params'] == '溶剂残留总量') {
|
|
|
+ if ($dis < $v['max']) {
|
|
|
$is_qualified[$k] = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$is_qualified[$k] = 0;
|
|
|
}
|
|
|
- }if ($v['params'] == '溶剂杂质总量' || $v['params'] == '总量'){
|
|
|
- if ( $dis_impurity < $v['max']){
|
|
|
+ }
|
|
|
+ if ($v['params'] == '溶剂杂质总量' || $v['params'] == '总量') {
|
|
|
+ if ($dis_impurity < $v['max']) {
|
|
|
$is_qualified[$k] = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$is_qualified[$k] = 0;
|
|
|
}
|
|
|
- }if ($v['params'] == '溶剂杂质苯系物' || $v['params'] == '苯系物总量' || $v['params'] == '苯系物'){
|
|
|
- if ( $ben_total < $v['max'] ){
|
|
|
+ }
|
|
|
+ if ($v['params'] == '溶剂杂质苯系物' || $v['params'] == '苯系物总量' || $v['params'] == '苯系物') {
|
|
|
+ if ($ben_total < $v['max']) {
|
|
|
$is_qualified[$k] = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$is_qualified[$k] = 0;
|
|
|
}
|
|
|
- }if ($v['params'] == '溶剂杂质苯' || $v['params'] == '苯含量' || $v['params'] == '苯' ){
|
|
|
- if ($ben < $v['max']){
|
|
|
+ }
|
|
|
+ if ($v['params'] == '溶剂杂质苯' || $v['params'] == '苯含量' || $v['params'] == '苯') {
|
|
|
+ if ($ben < $v['max']) {
|
|
|
$is_qualified[$k] = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$is_qualified[$k] = 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$is_pass = array_sum($is_qualified);//4项都合格,sum=4才判定合格 不等于4就说明有不合格的
|
|
|
- $params = [];//检测结果数据
|
|
|
- $params['judge'] = 0;
|
|
|
- if ($is_pass == 4){
|
|
|
- $params['judge'] = 1;
|
|
|
- }
|
|
|
- $params['entrust_no'] = $entrust['no'];
|
|
|
- $params['entrust_id'] = $entrust['id'];
|
|
|
- $params['machine'] = 'GCMS';
|
|
|
- if ($gather_tab == 'gather_txt_check_gc'){
|
|
|
- $params['machine'] = 'GC';
|
|
|
- }
|
|
|
- $params['name'] = $entrust['name'];
|
|
|
- $params['bach'] = $entrust['bach'];
|
|
|
- $params['sample_no'] = $entrust['sample_no'];
|
|
|
- $params['standard_id'] = $temp_id;
|
|
|
- $params['standard_name'] = $judge[0]['name'];
|
|
|
- $params['dis'] = $dis;
|
|
|
- $params['dis_impurity'] = $dis_impurity;
|
|
|
- $params['ben_total'] = $ben_total;
|
|
|
- $params['ben'] = $ben;
|
|
|
- $params['unit'] = 'mg/m2';
|
|
|
- $params['create'] = date('Y-m-d H:i:s');
|
|
|
- $params['maker'] = Session::get('admin')['username'];
|
|
|
- $params['params'] = Db::name('item_judge')->where('id',$temp_id)->value('list_name');
|
|
|
- $params['userid'] = Session::get('admin')['id'];;
|
|
|
- $params['status'] = 0;
|
|
|
- $params['work_unit'] = $entrust['work_unit'];
|
|
|
- $params['work_name'] = $entrust['work_name'];
|
|
|
- //更新数据
|
|
|
- $entrust_update = [];
|
|
|
- $entrust_update['standard_id'] =$temp_id;
|
|
|
- $entrust_update['standard_name'] =$judge[0]['name'];
|
|
|
- $entrust_update['status'] =2;
|
|
|
- $entrust_update['gather_id'] =$gather['id'];
|
|
|
- $entrust_update['gather_tab'] = $gather_tab;
|
|
|
- //日志记录
|
|
|
- $log = [];
|
|
|
- $log['userid'] = Session::get('admin')['id'];
|
|
|
- $log['username'] = Session::get('admin')['username'];
|
|
|
- $log['operate'] = '提交委托单id值为'.$id.'到检测';
|
|
|
- $log['content'] = '选用检测标准为:"'.$entrust_update['standard_name'].'",检测数据为:'.$gather_tab.'/'.$gather['id'];
|
|
|
- $log['e_id'] = $id;
|
|
|
- $log['create'] = date('Y-m-d H:i:s');
|
|
|
- $result = true;
|
|
|
+ $params[$ke]['judge'] = 0;
|
|
|
+ if ($is_pass == 4) {
|
|
|
+ $params[$ke]['judge'] = 1;
|
|
|
+ }
|
|
|
+ $params[$ke]['entrust_no'] = $entrust['no'];
|
|
|
+ $params[$ke]['entrust_id'] = $entrust['id'];
|
|
|
+ $params[$ke]['machine'] = 'GCMS';
|
|
|
+ if ($gather_tab == 'gather_txt_check_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'];
|
|
|
+// $entrust_update[$ke]['standard_id'] = $temp_id[$ke];
|
|
|
+// $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;
|
|
|
+
|
|
|
+ $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'));
|
|
|
+// }
|
|
|
+ }
|
|
|
+ $result = 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
/***
|
|
|
@@ -442,11 +463,16 @@ class Entrust extends Backend
|
|
|
* 根据批次号绑定检测数据
|
|
|
* 生成检测结果
|
|
|
*/
|
|
|
- $entrust_res = Db::name('entrust')->where('id',$id)->update($entrust_update);
|
|
|
- $res_check = Db::name('res')->insert($params);
|
|
|
- $log_res = Db::name('entrust_log')->insert($log);
|
|
|
- if (!$log_res || !$res_check){
|
|
|
+ for ($i=0;$i<count($idList);$i++){
|
|
|
+ $entrust_res = Db::name('entrust')->where('id', $idList[$i])->update($entrust_update[$i]);
|
|
|
+ $res_check = Db::name('res')->insert($params[$i]);
|
|
|
+ $log_res = Db::name('entrust_log')->insert($log[$i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$log_res || !$res_check) {
|
|
|
$result = false;
|
|
|
+ }else{
|
|
|
+ $result += 1;
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|