|
|
@@ -54,9 +54,9 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查看
|
|
|
+ * 主表查询
|
|
|
*/
|
|
|
- public function table1()
|
|
|
+ public function bach()
|
|
|
{
|
|
|
//当前是否为关联查询
|
|
|
$this->relationSearch = false;
|
|
|
@@ -107,9 +107,9 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查看
|
|
|
+ * 大件列表
|
|
|
*/
|
|
|
- public function table2()
|
|
|
+ public function large()
|
|
|
{
|
|
|
//当前是否为关联查询
|
|
|
$this->relationSearch = false;
|
|
|
@@ -231,7 +231,7 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 修改小件导出状态
|
|
|
+ * 小件导出状态修改
|
|
|
*/
|
|
|
public function small_status()
|
|
|
{
|
|
|
@@ -484,7 +484,7 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 设置打印数量
|
|
|
+ * 打印数量设置
|
|
|
*/
|
|
|
public function set_num()
|
|
|
{
|
|
|
@@ -518,92 +518,8 @@ class QcodeBach extends Backend
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function vo2()
|
|
|
- {
|
|
|
- $num1 = 0;
|
|
|
- $num2 = 1;
|
|
|
- if($num2<=$num1){
|
|
|
- $this->error('同步num1到num2之间的数据, 要求num2大于num1');
|
|
|
- }
|
|
|
-
|
|
|
- // 连接到其他数据库
|
|
|
- $config = [
|
|
|
- 'type' => 'mysql',
|
|
|
- 'hostname' => '127.0.0.1',
|
|
|
- 'database' => 'dm_7in6_com',
|
|
|
- 'username' => 'root',
|
|
|
- 'password' => 'root',
|
|
|
- 'charset' => 'utf8mb4',
|
|
|
- 'prefix' => 'qr_',
|
|
|
- ];
|
|
|
- $db = Db::connect($config);
|
|
|
-
|
|
|
- //查询主表记录
|
|
|
- $rows1 = $db->name('qcode_bach')
|
|
|
- ->limit($num1,$num2-$num1)
|
|
|
- ->order('id desc')
|
|
|
- ->select();
|
|
|
- $userInfo = Session::get('admin');
|
|
|
- $company_id = (int)$userInfo['company'];
|
|
|
- foreach($rows1 as $v){
|
|
|
- //1. 查询mongodb中是否存在该条记录
|
|
|
- $bool = $this->model->name($company_id.'_'."qcode_bach")->where('oid_id',$v['id'])->find();
|
|
|
- if ($bool) continue;
|
|
|
-
|
|
|
- //2. 获取设置主表数据
|
|
|
- $row = $v;
|
|
|
- unset($row['id']);
|
|
|
- $row = array_merge(['oid_id'=>$v['id']],$row);
|
|
|
-
|
|
|
- //3. 插入主表记录到mongodb中
|
|
|
- $qcodeBach = new \app\admin\model\QcodeBach();
|
|
|
- $qcodeBach->save($row);
|
|
|
- $pid = $qcodeBach->getLastInsID();
|
|
|
- $rows2 = $db->name('qcode_large')
|
|
|
- ->where('bach_id',$v['id'])
|
|
|
- ->select();
|
|
|
-
|
|
|
- foreach ($rows2 as $value){
|
|
|
- //1. 查询mongodb中是否存在该条记录
|
|
|
- $qcodeLarge = new QcodeLarge();
|
|
|
- $bool = $qcodeLarge->name($company_id.'_'."qcode_large")->where('oid_id',$value['id'])->find();
|
|
|
- if ($bool) continue;
|
|
|
-
|
|
|
- $row = $value;
|
|
|
- $row['old_bach_id'] = $value['bach_id'];
|
|
|
- $row['bach_id'] = $pid;
|
|
|
- $row['old_id'] = $value['id'];
|
|
|
- unset($row['id']);
|
|
|
- $qcodeLarge->save($row);
|
|
|
- $pid3 = $qcodeLarge->getLastInsID();
|
|
|
- $rows3 = $db->name('qcode_small')
|
|
|
- ->where('large_id',$value['id'])
|
|
|
- ->select();
|
|
|
-
|
|
|
- foreach ($rows3 as $value3){
|
|
|
- //1. 查询mongodb中是否存在该条记录
|
|
|
- $qcodeSmall = new QcodeSmall();
|
|
|
- $bool = $qcodeSmall->name($company_id.'_'."qcode_large")->where('oid_id',$value3['id'])->find();
|
|
|
- if ($bool) continue;
|
|
|
-
|
|
|
- $row = $value3;
|
|
|
- $row['old_bach_id'] = $value3['bach_id'];
|
|
|
- $row['old_large_id'] = $value3['large_id'];
|
|
|
- $row['old_id'] = $value3['id'];
|
|
|
- $row['bach_id'] = $pid;
|
|
|
- $row['large_id'] = $pid3;
|
|
|
- unset($row['id']);
|
|
|
- $qcodeSmall->save($row);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('成功');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * 跳转
|
|
|
+ * 导出excel跳转
|
|
|
*/
|
|
|
public function exp()
|
|
|
{
|
|
|
@@ -617,69 +533,7 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 新增
|
|
|
- */
|
|
|
- public function add()
|
|
|
- {
|
|
|
- if ($this->request->isAjax()){
|
|
|
- $req = $this->request->post();
|
|
|
- if(!isset($req['row']['product_code']) || empty($req['row']['product_code'])){
|
|
|
- $this->error('请填写编号');
|
|
|
- }else{
|
|
|
- $data = [
|
|
|
- 'product_code'=>$req['row']['product_code'],
|
|
|
- 'delete_time'=>'',
|
|
|
- ];
|
|
|
- if ($this->model->where($data)->find()){
|
|
|
- $this->error('编号已存在');
|
|
|
- }
|
|
|
- }
|
|
|
- if(!isset($req['row']['product_name']) || empty($req['row']['product_name'])){
|
|
|
- $this->error('请填写名称');
|
|
|
- }else{
|
|
|
- $data = [
|
|
|
- 'product_name'=>$req['row']['product_name'],
|
|
|
- 'delete_time'=>'',
|
|
|
- ];
|
|
|
- if ($this->model->where($data)->find()){
|
|
|
- $this->error('名称已存在');
|
|
|
- }
|
|
|
- }
|
|
|
- if(!isset($req['row']['temple']) || empty($req['row']['temple'])){
|
|
|
- $this->error('请填写辅料代号');
|
|
|
- }
|
|
|
- if(!isset($req['row']['main_unit'])){
|
|
|
- $this->error('请填写主计量单位');
|
|
|
- }
|
|
|
- if(!isset($req['row']['sec_unit'])){
|
|
|
- $this->error('请填写辅计量单位');
|
|
|
- }
|
|
|
- if(!isset($req['row']['proportion'])){
|
|
|
- $this->error('请填写换算关系');
|
|
|
- }
|
|
|
- $data = [
|
|
|
- 'product_code' =>$req['row']['product_code'],
|
|
|
- 'product_name' =>$req['row']['product_name'],
|
|
|
- 'temple' =>$req['row']['temple'],
|
|
|
- 'main_unit' =>$req['row']['main_unit'],
|
|
|
- 'sec_unit' =>$req['row']['sec_unit'],
|
|
|
- 'proportion' =>$req['row']['proportion'],
|
|
|
- 'create_time' =>time(),
|
|
|
- ];
|
|
|
- //插入数据
|
|
|
- $re = $this->model->save($data);
|
|
|
- if($re){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- }
|
|
|
- return $this->view->fetch();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑
|
|
|
+ * 修改大件重量数量
|
|
|
*/
|
|
|
public function edit($ids = NULL)
|
|
|
{
|
|
|
@@ -745,7 +599,7 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除
|
|
|
+ * 删除批次
|
|
|
*/
|
|
|
public function del($ids = NULL)
|
|
|
{
|
|
|
@@ -768,54 +622,6 @@ class QcodeBach extends Backend
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 绑定
|
|
|
- */
|
|
|
- public function bind($ids = NULL)
|
|
|
- {
|
|
|
- $userInfo = Session::get('admin');
|
|
|
- $company_id = (int)$userInfo['company'];
|
|
|
- $db = new QcodeCompany();
|
|
|
- //查询是否已经添加
|
|
|
- $row = $db->name($company_id.'_'."qcode_company")
|
|
|
- ->where(['delete_time'=>'','product_id'=>$ids])
|
|
|
- ->find();
|
|
|
- if($row) $this->success('已添加');
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'product_id'=>$ids,
|
|
|
- 'create_time'=>time(),
|
|
|
- ];
|
|
|
-
|
|
|
- //插入qcode_company数据
|
|
|
- $bool = $db->save($data);
|
|
|
- if($bool){
|
|
|
- $this->success('添加成功');
|
|
|
- }else{
|
|
|
- $this->error('添加失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 解绑
|
|
|
- */
|
|
|
- public function unbind($ids = NULL)
|
|
|
- {
|
|
|
- $userInfo = Session::get('admin');
|
|
|
- $company_id = (int)$userInfo['company'];
|
|
|
- $db = new QcodeCompany();
|
|
|
- //查询是否已经添加
|
|
|
- $bool = $db->name($company_id.'_'."qcode_company")
|
|
|
- ->where(['delete_time'=>'','product_id'=>$ids])
|
|
|
- ->update(['delete_time'=>time()]);
|
|
|
-
|
|
|
- if($bool){
|
|
|
- $this->success('删除成功');
|
|
|
- }else{
|
|
|
- $this->error('删除失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 补打标签
|
|
|
*/
|
|
|
@@ -886,7 +692,9 @@ class QcodeBach extends Backend
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
- //公司搜索
|
|
|
+ /**
|
|
|
+ * 公司名称搜索
|
|
|
+ */
|
|
|
public function sel_n()
|
|
|
{
|
|
|
$name = $this->request->param()['q_word'][0];
|
|
|
@@ -907,7 +715,9 @@ class QcodeBach extends Backend
|
|
|
|
|
|
}
|
|
|
|
|
|
- //辅料名称搜索
|
|
|
+ /**
|
|
|
+ * 辅料名称搜索
|
|
|
+ */
|
|
|
public function sel_p()
|
|
|
{
|
|
|
$name = $this->request->param()['q_word'][0];
|
|
|
@@ -930,7 +740,10 @@ class QcodeBach extends Backend
|
|
|
return json(['list' => $sel, 'total' => count($sel)]);
|
|
|
|
|
|
}
|
|
|
- //辅料编码搜索
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 辅料编码搜索
|
|
|
+ */
|
|
|
public function sel_c()
|
|
|
{
|
|
|
$name = $this->request->param()['q_word'][0];
|