|
@@ -42,14 +42,6 @@ class Entrust extends Backend
|
|
|
public function add()
|
|
public function add()
|
|
|
{
|
|
{
|
|
|
if (false === $this->request->isPost()) {
|
|
if (false === $this->request->isPost()) {
|
|
|
- $num = Db::name('entrust')->whereTime('create', 'd')->count();
|
|
|
|
|
- $num = $num + 1;
|
|
|
|
|
- if ($num < 10){
|
|
|
|
|
- $num = '0'.$num;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $sample_no = date('Ymd').$num;
|
|
|
|
|
- $this->view->assign('sample_no', $sample_no);
|
|
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
}
|
|
}
|
|
|
$params = $this->request->post('row/a');
|
|
$params = $this->request->post('row/a');
|
|
@@ -59,11 +51,14 @@ class Entrust extends Backend
|
|
|
$params['name'] = preg_replace('/\s+/','',$params['name']);//去掉所有空格
|
|
$params['name'] = preg_replace('/\s+/','',$params['name']);//去掉所有空格
|
|
|
$params['user_id'] = Session::get('admin')['id'];
|
|
$params['user_id'] = Session::get('admin')['id'];
|
|
|
$params['user_name'] = Session::get('admin')['username'];
|
|
$params['user_name'] = Session::get('admin')['username'];
|
|
|
-
|
|
|
|
|
$params = $this->preExcludeFields($params);
|
|
$params = $this->preExcludeFields($params);
|
|
|
-
|
|
|
|
|
- if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
|
|
|
|
- $params[$this->dataLimitField] = $this->auth->id;
|
|
|
|
|
|
|
+ if ($params['is_two'] == 1){//双样
|
|
|
|
|
+ for ($i=0;$i<2;$i++){
|
|
|
|
|
+ $data[$i] = $params;
|
|
|
|
|
+ $data[$i]['sample_no'] = $params['sample_no'].'-'.($i+1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{//单样
|
|
|
|
|
+ $data = $params;
|
|
|
}
|
|
}
|
|
|
$result = false;
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
@@ -74,7 +69,7 @@ class Entrust extends Backend
|
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
|
|
$this->model->validateFailException()->validate($validate);
|
|
$this->model->validateFailException()->validate($validate);
|
|
|
}
|
|
}
|
|
|
- $result = $this->model->allowField(true)->save($params);
|
|
|
|
|
|
|
+ $result = $this->model->saveAll($data);
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
Db::rollback();
|
|
@@ -102,21 +97,29 @@ 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、先去找gc表 没有查到数据 再找gcms表
|
|
|
|
|
|
|
+ * 1、先去找gcms表 没有查到数据 再找gc表
|
|
|
*/
|
|
*/
|
|
|
- $gather = Db::name('gather_txt_gcms')->where('bach',$entrust['bach'])->find();
|
|
|
|
|
- if (empty($gather)){
|
|
|
|
|
- $this->error('未获取到检测数据');
|
|
|
|
|
|
|
+ $data_txt = $entrust['sample_no'].'MS.D'; //如果是GCMS机台,数据文件为委托编号+MS.D
|
|
|
|
|
+ $gather_gcms = Db::name('gather_txt_gcms')->where('data_txt_name',$data_txt)->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)->find();
|
|
|
|
|
+ if (empty($gather_gc)){
|
|
|
|
|
+ $this->error('未获取到检测数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ $gather = $gather_gc;
|
|
|
|
|
+ $gather_tab = 'gather_txt_check_gc';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $gather = $gather_gcms;
|
|
|
|
|
+ $gather_tab = 'gather_txt_check_gcms';
|
|
|
}
|
|
}
|
|
|
- $detail_data = Db::name('gather_txt_check_gcms')->where('pid',$gather['id'])->field('chemical_compound,potency')->select();
|
|
|
|
|
-
|
|
|
|
|
- $gather_tab = 'gather_txt_gcms';//默认gcms表,后续根据实际查到的数据 更改
|
|
|
|
|
|
|
+ $detail_data = Db::name($gather_tab)->where('pid',$gather['id'])->field('chemical_compound,potency')->select();
|
|
|
|
|
|
|
|
$is_qualified = 1;//默认合格,当有一项不合格时,判定此次检测不合格
|
|
$is_qualified = 1;//默认合格,当有一项不合格时,判定此次检测不合格
|
|
|
$dis= 0;//溶剂残留总量
|
|
$dis= 0;//溶剂残留总量
|
|
@@ -142,14 +145,13 @@ class Entrust extends Backend
|
|
|
$ben_total_data[$value['chemical_compound']] = $value['potency'];
|
|
$ben_total_data[$value['chemical_compound']] = $value['potency'];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
$judge = Db::name('item_judge_detail')->where('pid',$temp_id)->select();
|
|
$judge = Db::name('item_judge_detail')->where('pid',$temp_id)->select();
|
|
|
$sum_all_dis_data = array_sum($all_dis_data);
|
|
$sum_all_dis_data = array_sum($all_dis_data);
|
|
|
$dis = $sum_all_dis_data - $ethanol; //残留总量
|
|
$dis = $sum_all_dis_data - $ethanol; //残留总量
|
|
|
$dis_impurity = array_sum($dis_impurity_data); //杂质总量
|
|
$dis_impurity = array_sum($dis_impurity_data); //杂质总量
|
|
|
$ben_total = array_sum($ben_total_data); //苯系物重量
|
|
$ben_total = array_sum($ben_total_data); //苯系物重量
|
|
|
foreach ($judge as $k=>$v){
|
|
foreach ($judge as $k=>$v){
|
|
|
-// $v['min'] = $v['min'] * 10000;
|
|
|
|
|
-// $v['max'] = $v['max'] * 10000;
|
|
|
|
|
if ($v['params'] == '溶剂残留总量'){
|
|
if ($v['params'] == '溶剂残留总量'){
|
|
|
if ( $dis < $v['max']){
|
|
if ( $dis < $v['max']){
|
|
|
$is_qualified = 1;
|
|
$is_qualified = 1;
|
|
@@ -163,7 +165,6 @@ class Entrust extends Backend
|
|
|
$is_qualified = 0;
|
|
$is_qualified = 0;
|
|
|
}
|
|
}
|
|
|
}if ($v['params'] == '溶剂杂质苯系物' || $v['params'] == '苯系物'){
|
|
}if ($v['params'] == '溶剂杂质苯系物' || $v['params'] == '苯系物'){
|
|
|
-// $ben_total_ten_thousand = $ben_total * 10000;
|
|
|
|
|
if ( $ben_total < $v['max']){
|
|
if ( $ben_total < $v['max']){
|
|
|
$is_qualified = 1;
|
|
$is_qualified = 1;
|
|
|
}else{
|
|
}else{
|
|
@@ -219,7 +220,7 @@ class Entrust extends Backend
|
|
|
* 生成检测结果
|
|
* 生成检测结果
|
|
|
*/
|
|
*/
|
|
|
$entrust_res = Db::name('entrust')->where('id',$id)->update($entrust_update);
|
|
$entrust_res = Db::name('entrust')->where('id',$id)->update($entrust_update);
|
|
|
- $res_check = Db::name('res_check')->insert($params);
|
|
|
|
|
|
|
+ $res_check = Db::name('res')->insert($params);
|
|
|
$log_res = Db::name('entrust_log')->insert($log);
|
|
$log_res = Db::name('entrust_log')->insert($log);
|
|
|
if (!$entrust_res || !$res_check){
|
|
if (!$entrust_res || !$res_check){
|
|
|
$result = false;
|
|
$result = false;
|
|
@@ -264,7 +265,6 @@ class Entrust extends Backend
|
|
|
//检测数据查看
|
|
//检测数据查看
|
|
|
public function data(){
|
|
public function data(){
|
|
|
$params = input('id');
|
|
$params = input('id');
|
|
|
-
|
|
|
|
|
if (empty($params)){
|
|
if (empty($params)){
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
@@ -273,18 +273,18 @@ class Entrust extends Backend
|
|
|
$this->error('此委托单还未提交检测,暂无检测数据');
|
|
$this->error('此委托单还未提交检测,暂无检测数据');
|
|
|
}
|
|
}
|
|
|
//此处根据实际获取到的采集表的数据 gather_tab 去对应表里查数据 重新写一个gc表格页面 js加代码
|
|
//此处根据实际获取到的采集表的数据 gather_tab 去对应表里查数据 重新写一个gc表格页面 js加代码
|
|
|
- if ($gather_id['gather_tab'] == 'gather_txt_gcms'){
|
|
|
|
|
|
|
+ if ($gather_id['gather_tab'] == 'gather_txt_check_gcms'){
|
|
|
$gather = Db::name('gather_txt_gcms')->where('id',$gather_id['gather_id'])->find();
|
|
$gather = Db::name('gather_txt_gcms')->where('id',$gather_id['gather_id'])->find();
|
|
|
$data = Db::name('gather_txt_check_gcms')->where('pid',$gather_id['gather_id'])->select();
|
|
$data = Db::name('gather_txt_check_gcms')->where('pid',$gather_id['gather_id'])->select();
|
|
|
$this->view->assign('gather', $gather);
|
|
$this->view->assign('gather', $gather);
|
|
|
$this->view->assign('data', $data);
|
|
$this->view->assign('data', $data);
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
- }else{
|
|
|
|
|
- $gather = Db::name('gather_txt')->where('id',$gather_id['gather_id'])->find();
|
|
|
|
|
- $data = Db::name('gather_txt_check')->where('pid',$gather_id['gather_id'])->select();
|
|
|
|
|
|
|
+ }else if ($gather_id['gather_tab'] == 'gather_txt_check_gc'){
|
|
|
|
|
+ $gather = Db::name('gather_txt_gc')->where('id',$gather_id['gather_id'])->find();
|
|
|
|
|
+ $data = Db::name('gather_txt_check_gc')->where('pid',$gather_id['gather_id'])->select();
|
|
|
$this->view->assign('gather', $gather);
|
|
$this->view->assign('gather', $gather);
|
|
|
$this->view->assign('data', $data);
|
|
$this->view->assign('data', $data);
|
|
|
- return $this->view->fetch('data_gc.html');//此处页面没写
|
|
|
|
|
|
|
+ return $this->fetch('datagc');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -293,6 +293,25 @@ class Entrust extends Backend
|
|
|
|
|
|
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //生成委托单号
|
|
|
|
|
+ public function getNo(){
|
|
|
|
|
+ $params = input('temp');
|
|
|
|
|
+ $company = input('company');
|
|
|
|
|
+ if (empty($params) || empty($company)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $num = Db::name('entrust')->where('sample_no','like','%'.$params.'%')->whereTime('create','d')->count();
|
|
|
|
|
+
|
|
|
|
|
+ if ($company == '亚欣'){//亚欣送样从100开始
|
|
|
|
|
+ $num = $num+100;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $num = $num+1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($num < 10){
|
|
|
|
|
+ $num = '0'.$num;
|
|
|
|
|
+ }
|
|
|
|
|
+ //一位样品代号+8位日期+当前样品代号第几次送样+2位检测方式(01代表vocs)
|
|
|
|
|
+ $sample_no = date('Ymd').$num.'01';
|
|
|
|
|
+ return array('code'=>1,'data'=>$sample_no);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|