|
|
@@ -53,12 +53,13 @@ class Formula extends Backend
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
// 获取搜索框的值
|
|
|
+ $map = [];
|
|
|
$filter=input('filter');
|
|
|
if($filter){
|
|
|
$filter=urldecode($filter);
|
|
|
$filter=json_decode($filter,TRUE);
|
|
|
foreach($filter as $k=>$v){
|
|
|
- $where[$k]=['like',"%{$v}%"];
|
|
|
+ $map[$k]=['like',"%{$v}%"];
|
|
|
}
|
|
|
}
|
|
|
//如果发送的来源是 Selectpage,则转发到 Selectpage
|
|
|
@@ -67,21 +68,29 @@ class Formula extends Backend
|
|
|
}
|
|
|
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
|
|
$user_info = Session::get('admin');
|
|
|
- $map = [];
|
|
|
- if ($user_info['id'] !== 1){
|
|
|
+ if ($user_info['id'] !== 1){//管理员
|
|
|
$map['company_id'] = $user_info['company_id'];
|
|
|
$map['examine_status'] = 2;
|
|
|
}
|
|
|
- $sort = 'f.id';
|
|
|
- $list = DB::name('formula')
|
|
|
- ->where($where)
|
|
|
- ->where($map)
|
|
|
- ->alias('f')
|
|
|
- ->group('f.id')
|
|
|
- ->field('f.id,f.name,f.version,f.examine_status,f.create')
|
|
|
- ->join('formula_detail fd','fd.pid=f.id','left')
|
|
|
- ->order($sort, $order)
|
|
|
- ->paginate($limit);
|
|
|
+
|
|
|
+ if(!empty($map['name'])){
|
|
|
+ $sort = 'f.id';
|
|
|
+ $list = DB::name('formula')
|
|
|
+ ->where($where)
|
|
|
+ ->where($map)
|
|
|
+ ->alias('f')
|
|
|
+ ->group('f.id')
|
|
|
+ ->field('f.id,f.name,f.version,f.examine_status,f.create')
|
|
|
+ ->join('formula_detail fd','fd.pid=f.id','left')
|
|
|
+ ->order($sort, $order)
|
|
|
+ ->paginate($limit);
|
|
|
+ }else{
|
|
|
+ $list = $this->model
|
|
|
+ ->where($where)
|
|
|
+ ->where($map)
|
|
|
+ ->order($sort, $order)
|
|
|
+ ->paginate($limit);
|
|
|
+ }
|
|
|
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
|
|
return json($result);
|
|
|
}
|
|
|
@@ -94,14 +103,10 @@ class Formula extends Backend
|
|
|
*/
|
|
|
public function add()
|
|
|
{
|
|
|
+
|
|
|
if (false === $this->request->isPost()) {
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
-// $ceshi = encrypt('111');
|
|
|
-// $ceshitwo = decode('eGWIu/HvS5g4CbzdItvkig==');
|
|
|
-// print_r($ceshi);
|
|
|
-// print_r('-------------------------------');
|
|
|
-// print_r($ceshitwo);die;
|
|
|
$base = $this->request->post('baseData/a');
|
|
|
$formula = $this->request->post('formulaData/a');
|
|
|
if (empty($base) || empty($formula)){
|
|
|
@@ -109,7 +114,7 @@ class Formula extends Backend
|
|
|
}
|
|
|
$params = [];
|
|
|
$params['name'] = $base[0];
|
|
|
- $params['formula_no'] = $base[1];
|
|
|
+ $params['no'] = $base[1];
|
|
|
$params['charge_name'] = $base[2];
|
|
|
$params['examine_name'] = $base[3];
|
|
|
$params['remark'] = $base[4];
|
|
|
@@ -138,7 +143,7 @@ class Formula extends Backend
|
|
|
}
|
|
|
$data = [];
|
|
|
$is_replace = 0;
|
|
|
- $gy_num = 1;
|
|
|
+// $gy_num = 1;
|
|
|
foreach($formula as $key=>$value){
|
|
|
if (strpos($value[0],'/') === false){
|
|
|
$data[$key]['is_replace'] = 0;
|
|
|
@@ -149,31 +154,32 @@ class Formula extends Backend
|
|
|
$data[$key]['material'] = $value[0];
|
|
|
$data[$key]['percentage'] = encrypt($value[1]);
|
|
|
$data[$key]['gy_name'] = $value[2];
|
|
|
- $data[$key]['gy_num'] = $gy_num;
|
|
|
+// $data[$key]['gy_num'] = $gy_num;
|
|
|
+ $data[$key]['gy_num'] = $value[3];
|
|
|
$data[$key]['pid'] = $pid;
|
|
|
$data[$key]['version'] = $params['version'];
|
|
|
$data[$key]['create'] = $params['create'];
|
|
|
- if(!$value[0]&&!$value[1]&&$value[2]){
|
|
|
- $gy_num++;
|
|
|
- }
|
|
|
+// if(!$value[0]&&!$value[1]&&$value[2]){
|
|
|
+// $gy_num++;
|
|
|
+// }
|
|
|
}
|
|
|
$result = Db::name('formula_detail')->insertAll($data);
|
|
|
- //有替代料的话 查出所有替代料 然后分解 插入到数据库
|
|
|
- if ($is_replace == 1){
|
|
|
- $replace = Db::name('formula_detail')->where('pid',$pid)->where('is_replace',1)->field('id,material')->select();
|
|
|
- $replaceData = [];
|
|
|
- $j = 0;
|
|
|
- foreach ($replace as $k=>$v){
|
|
|
- $material = explode('/',$v['material']);
|
|
|
- for ($i=0;$i<count($material);$i++){
|
|
|
- $replaceData[$j]['fid'] = $v['id'];
|
|
|
- $replaceData[$j]['material'] = $material[$i];
|
|
|
- $replaceData[$j]['create'] = date('Y-m-d H:i:s');
|
|
|
- $j++;
|
|
|
- }
|
|
|
- }
|
|
|
- $result = Db::name('formula_replace')->insertAll($replaceData);
|
|
|
- }
|
|
|
+ //有替代料的话 查出所有替代料 然后分解 插入到数据库 2022年9月19日14:20:37 替代料功能改变
|
|
|
+// if ($is_replace == 1){
|
|
|
+// $replace = Db::name('formula_detail')->where('pid',$pid)->where('is_replace',1)->field('id,material')->select();
|
|
|
+// $replaceData = [];
|
|
|
+// $j = 0;
|
|
|
+// foreach ($replace as $k=>$v){
|
|
|
+// $material = explode('/',$v['material']);
|
|
|
+// for ($i=0;$i<count($material);$i++){
|
|
|
+// $replaceData[$j]['fid'] = $v['id'];
|
|
|
+// $replaceData[$j]['material'] = $material[$i];
|
|
|
+// $replaceData[$j]['create'] = date('Y-m-d H:i:s');
|
|
|
+// $j++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $result = Db::name('formula_replace')->insertAll($replaceData);
|
|
|
+// }
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
@@ -211,6 +217,7 @@ class Formula extends Backend
|
|
|
foreach ($list['gyinfo'] as $key=>$value){
|
|
|
$list['gyinfo'][$key]['percentage'] = decode($value['percentage']);
|
|
|
}
|
|
|
+// dump($list);die;
|
|
|
$this->view->assign('ids',$ids);
|
|
|
$this->view->assign('name',$name);
|
|
|
$this->view->assign('row', $list);
|
|
|
@@ -235,7 +242,7 @@ class Formula extends Backend
|
|
|
//基础数据
|
|
|
$params = [];
|
|
|
$params['name'] = $base[0];
|
|
|
- $params['formula_no'] = $base[1];
|
|
|
+ $params['no'] = $base[1];
|
|
|
$params['charge_name'] = $base[2];
|
|
|
$params['examine_name'] = $base[3];
|
|
|
$params['remark'] = $base[4];
|
|
|
@@ -314,7 +321,7 @@ class Formula extends Backend
|
|
|
}
|
|
|
//新工艺信息
|
|
|
$is_replace = 0;
|
|
|
- $gy_num = 1;
|
|
|
+
|
|
|
for($i=0;$i<count($formula);$i++){
|
|
|
if (strpos($formula[$i][0],'/') === false){
|
|
|
$data[$i]['is_replace'] = 0;
|
|
|
@@ -325,34 +332,31 @@ class Formula extends Backend
|
|
|
$data[$i]['material'] = $formula[$i][0];
|
|
|
$data[$i]['percentage'] = encrypt($formula[$i][1]);
|
|
|
$data[$i]['gy_name'] = $formula[$i][2];
|
|
|
-// $data[$i]['gy_num'] = $formula[$i][3];
|
|
|
- $data[$i]['gy_num'] = $gy_num;
|
|
|
+ $data[$i]['gy_num'] = $formula[$i][3];
|
|
|
+// $data[$i]['gy_num'] = $gy_num;
|
|
|
$data[$i]['pid'] = $ids;
|
|
|
$data[$i]['version'] = 'v'.$version;
|
|
|
$data[$i]['create'] = date('Y-m-d H:i:s');
|
|
|
- if(!$formula[$i][0]&&!$formula[$i][1]&&$formula[$i][2]){
|
|
|
- $gy_num++;
|
|
|
- }
|
|
|
}
|
|
|
if ($isChange === true){
|
|
|
Db::name('formula_detail')->insertAll($data);
|
|
|
}
|
|
|
- //有替代料的话 查出所有替代料 然后分解 插入到数据库
|
|
|
- if ($is_replace == 1 && ($materialChange == 1 || $change == 1)){
|
|
|
- $replace = Db::name('formula_detail')->where('pid',$ids)->where('is_replace',1)->field('id,material')->select();
|
|
|
- $replaceData = [];
|
|
|
- $j = 0;
|
|
|
- foreach ($replace as $k=>$v){
|
|
|
- $material = explode('/',$v['material']);
|
|
|
- for ($i=0;$i<count($material);$i++){
|
|
|
- $replaceData[$j]['fid'] = $v['id'];
|
|
|
- $replaceData[$j]['material'] = $material[$i];
|
|
|
- $replaceData[$j]['create'] = date('Y-m-d H:i:s');
|
|
|
- $j++;
|
|
|
- }
|
|
|
- }
|
|
|
- $result = Db::name('formula_replace')->insertAll($replaceData);
|
|
|
- }
|
|
|
+ //有替代料的话 查出所有替代料 然后分解 插入到数据库 //2022年9月19日14:19:09 替代料更改
|
|
|
+// if ($is_replace == 1 && ($materialChange == 1 || $change == 1)){
|
|
|
+// $replace = Db::name('formula_detail')->where('pid',$ids)->where('is_replace',1)->field('id,material')->select();
|
|
|
+// $replaceData = [];
|
|
|
+// $j = 0;
|
|
|
+// foreach ($replace as $k=>$v){
|
|
|
+// $material = explode('/',$v['material']);
|
|
|
+// for ($i=0;$i<count($material);$i++){
|
|
|
+// $replaceData[$j]['fid'] = $v['id'];
|
|
|
+// $replaceData[$j]['material'] = $material[$i];
|
|
|
+// $replaceData[$j]['create'] = date('Y-m-d H:i:s');
|
|
|
+// $j++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $result = Db::name('formula_replace')->insertAll($replaceData);
|
|
|
+// }
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
@@ -365,6 +369,13 @@ class Formula extends Backend
|
|
|
}
|
|
|
//生成作业单
|
|
|
public function task(){
|
|
|
+// $ceshi = Db::name('formula_detail')->where('id','>',52459)->limit(10000)->select();
|
|
|
+// foreach ($ceshi as $key=>$value){
|
|
|
+// $ceshi[$key]['percentage'] = encrypt($value['percentage']);
|
|
|
+// }
|
|
|
+// Db::name('formula_detail_c')->insertAll($ceshi);
|
|
|
+// print_r('-------------------------------');
|
|
|
+// die;
|
|
|
$ids = input('ids');
|
|
|
if (!$ids) {
|
|
|
$this->error(__('No Results were found'));
|