|
|
@@ -1 +1,129 @@
|
|
|
<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+use think\Request;
|
|
|
+use function fast\e;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 生产进程管理
|
|
|
+ */
|
|
|
+
|
|
|
+class Course extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = ['*'];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 左侧菜单
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function getTab()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ //获取总计划中数量和总生产中数量
|
|
|
+ $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','2-生产中')->cache(true)->count();
|
|
|
+ $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','3-计划中')->cache(true)->count();
|
|
|
+ $data = [
|
|
|
+ '印刷工单' => [],
|
|
|
+ '糊盒工单' => []
|
|
|
+ ];
|
|
|
+ $sql = "SELECT DISTINCT
|
|
|
+ (客户编号),rtrim(客户名称 ) as 客户名称
|
|
|
+ FROM
|
|
|
+ `产品_基本资料`
|
|
|
+ WHERE
|
|
|
+ 客户编号 <> ''
|
|
|
+ GROUP BY
|
|
|
+ 客户编号
|
|
|
+ order by
|
|
|
+ 客户编号";
|
|
|
+ $list = \db()->query($sql);
|
|
|
+ if (empty($list)){
|
|
|
+ $this->success('',[]);
|
|
|
+ }
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
+ $value['客户编号'] = rtrim($value['客户编号']);
|
|
|
+ $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
|
|
|
+ $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
|
|
|
+ $string = '';
|
|
|
+ if ($productIng != 0){
|
|
|
+ $string = $string."生产中:".$productIng;
|
|
|
+ }
|
|
|
+ if ($proGress != 0){
|
|
|
+ $string = $string."计划中:".$proGress;
|
|
|
+ }
|
|
|
+ if ($string !== ''){
|
|
|
+ $name = $value['客户编号'].$value['客户名称'];
|
|
|
+ if (strpos($value['客户编号'],'J') !== false){
|
|
|
+ array_push($data['糊盒工单'],$name);
|
|
|
+ }else{
|
|
|
+ array_push($data['印刷工单'],$name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success('成功',$data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 右侧工单详情
|
|
|
+ * @return void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function workOrderDetail()
|
|
|
+ {
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $param = $this->request->param();
|
|
|
+ $where = [];
|
|
|
+ if (!empty($param['order'])){
|
|
|
+ $where['a.Gd_cpdh|a.成品代号'] = ['like',$param['order'].'%'];
|
|
|
+ }
|
|
|
+ if (!empty($param['search'])){
|
|
|
+ $where['a.Gd_gdbh'] = ['like','%'.$param['search'].'%'];
|
|
|
+ }
|
|
|
+ $list = \db('工单_基本资料')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh')
|
|
|
+ ->field('b.Yj_Gdbh as 工单编号,b.yj_Yjno,b.yj_Yjdh as 印件代号,b.yj_yjmc as 印件名称,b.yj_ls as 联数,a.投料大箱 as 投料大箱,b.yj_平张投料 as 计划投料')
|
|
|
+ ->where($where)
|
|
|
+ ->where('gd_statu','2-生产中')
|
|
|
+ ->group('b.Yj_Gdbh,b.yj_Yjno')
|
|
|
+ ->select();
|
|
|
+ if (empty($list)){
|
|
|
+ $this->success('');
|
|
|
+ }
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
+ $process = \db('工单_工艺资料')
|
|
|
+ ->alias('a')
|
|
|
+ ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_yjno = b.sczl_yjno AND a.Gy0_gxh = b.sczl_gxh','left')
|
|
|
+ ->where('a.Gy0_gdbh',$value['工单编号'])
|
|
|
+ ->where('a.Gy0_yjno',$value['yj_Yjno'])
|
|
|
+ ->field('a.Gy0_gxh,a.Gy0_gxmc,a.PD_WG,SUM(b.sczl_cl) as 产量')
|
|
|
+ ->group('a.Gy0_gxh')
|
|
|
+ ->select();
|
|
|
+ foreach ($process as $k=>$v){
|
|
|
+ $status = '';
|
|
|
+ if ($v['PD_WG'] !== '1900-01-01 00:00:00'){
|
|
|
+ $status = '完工';
|
|
|
+ }
|
|
|
+ $list[$key]['工序'.$k] = $value['yj_Yjno'].'-'.$v['Gy0_gxh'].'-'.rtrim($v['Gy0_gxmc']).'['.$v['产量'].'/'.']'.$status;
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($list[$key]['yj_Yjno']);
|
|
|
+ }
|
|
|
+ $this->success('成功',$list);
|
|
|
+ }
|
|
|
+}
|