Przeglądaj źródła

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

曹鹤洋 1 rok temu
rodzic
commit
67aa1e28f6

+ 7 - 11
application/api/controller/Facility.php

@@ -98,10 +98,6 @@ class Facility extends Api
         sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId,rtrim(sczl_工价系数) as 难度系数';
         //机台信息
         $machineDetail = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
-        //工单编号
-        $Gd_gdbh = \db('设备_产量计酬')->where($where)->distinct(true)->column('sczl_gdbh');
-        //产品名称
-        $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
         //组员信息
         $list = \db('设备_产量计酬')->where($where)->field($field)->select();
         $totalA = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
@@ -110,12 +106,11 @@ class Facility extends Api
             $this->success('',[]);
         }
         foreach ($list as $key=>$value){
+            //产品名称
+            $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$value['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
             if (!empty($productName['成品名称'])){
                 $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
                 $list[$key]['cpmc'] = $productName['成品名称'];
-            }elseif (empty($productName['成品名称']) && !empty($productName['cpmc'])){
-                $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['cpmc'];
-                $list[$key]['cpmc'] = $productName['cpmc'];
             }else{
                 $list[$key]['产品名称'] = $value['工单编号'];
                 $list[$key]['cpmc'] = '';
@@ -353,7 +348,7 @@ class Facility extends Api
                 AND b.PD_WG = '1900-01-01 00:00:00' 
                 AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
                 AND b.Gy0_sj1 < '2099-01-01 00:00:00'
-            GROUP BY a.Gd_gdbh
+            GROUP BY a.Gd_gdbh,b.Gy0_yjno,b.Gy0_gxh
             ORDER BY b.Gy0_sj1";
         $orderList = Db::query($sql);
         if (empty($orderList)){
@@ -369,7 +364,7 @@ class Facility extends Api
             }
             $orderList[$key]['印件资料'] = $orderList[$key]['yjno'].'-'.$value['印件名称'];
             $orderList[$key]['工序名称'] = $orderList[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
-            $orderList[$key]['计划产量/已完成'] = (int)($value['计划接货数']/$value['ls']).'/'.$value['已完成']=null?'':(int)$value['已完成'];
+            $orderList[$key]['计划产量/已完成'] = (int)$value['计划接货数'].'/'.$value['已完成']=null?'':(int)$value['已完成'];
             $orderList[$key]['计划生产时段'] =substr($value['sj1'],5,5).' '.substr($value['sj1'],11,5).'<-->'.substr($value['sj2'],5,5).' '.substr($value['sj2'],11,5);
             unset($orderList[$key]['gdbh'],$orderList[$key]['质量信息'],$orderList[$key]['yjno'],$orderList[$key]['gxh'],$orderList[$key]['gxmc'],$orderList[$key]['add_gxmc'],$orderList[$key]['计划接货数'],$orderList[$key]['已完成'],$orderList[$key]['印件名称'],$orderList[$key]['ls']);
         }
@@ -2215,7 +2210,7 @@ class Facility extends Api
     }
 
     /**
-     * 色度系数修改
+     * 凹印版距修改
      * @return void
      * @throws \think\Exception
      * @throws \think\db\exception\BindParamException
@@ -2232,7 +2227,7 @@ class Facility extends Api
         }
         $idList = explode(',',$params['id']);
         //获取工单印件工序
-        $orderList = \db('工单_产量计酬')
+        $orderList = \db('设备_产量计酬')
             ->where('UniqId',$idList[0])
             ->field('rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as 印件号,rtrim(sczl_gxh) as 工序号')
             ->find();
@@ -2252,4 +2247,5 @@ class Facility extends Api
             $this->success('修改成功');
         }
     }
+
 }

+ 1 - 3
application/api/controller/Manufacture.php

@@ -223,13 +223,11 @@ class Manufacture extends Api
                     'rtrim(a.Uniqid)' => 'GDUID',
                 ])
                 ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
-                ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
                 ->where([
                     'a.gd_statu' => '2-生产中',
                     'a.行号' => '1',
                     'b.PD_WG' => '1900-01-01 00:00:00',
                     'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
-                    'c.状态' => '',
                 ])
                 ->where($where)
                 ->group('a.Gd_gdbh')
@@ -813,7 +811,7 @@ class Manufacture extends Api
                 'b.PD_WG' => '1900-01-01 00:00:00',
             ])
             ->where($where)
-            ->group('a.Gd_gdbh,b.Gy0_gxh')
+            ->group('a.Gd_gdbh,b.Gy0_yjno,b.Gy0_gxh')
             ->order('Gy0_sj1')
             ->select();
         if (empty($list)){

+ 14 - 7
application/api/controller/Product.php

@@ -2,10 +2,10 @@
 
 namespace app\api\controller;
 
-use app\admin\model\EntrustLog;
 use app\common\controller\Api;
 use \think\Request;
 use \think\Db;
+use think\Cache;
 /**
  * 产品管理接口
  */
@@ -613,13 +613,13 @@ class Product extends Api
             $sql = "SELECT DISTINCT rtrim(a.`物料代码`) AS `物料代码`,rtrim(a.`物料名称`) AS `物料名称`,rtrim(b.`客户编号`) AS `客户编号`,rtrim(b.`客户名称`) AS `客户名称` FROM
                     `物料_存货编码` a
                     JOIN `产品_基本资料` b ON LEFT(a.`物料代码`,$num) = LEFT(b.`客户编号`,$num)
-                    WHERE  (a.`物料名称` LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%') and LEFT(a.物料代码,1) = 'Y'
+                    WHERE  (a.`物料名称` LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%') 
                     ORDER BY a.`物料代码` ASC";
         }else{
             $sql = "SELECT DISTINCT rtrim(a.`物料代码`) as `物料代码`, rtrim(a.`物料名称`) as `物料名称`,rtrim(b.客户编号) as 客户编号,rtrim(b.客户名称) as 客户名称
                 FROM `物料_存货编码` a
                 JOIN `产品_基本资料` b ON LEFT(a.`物料代码`,$num) = LEFT(b.`客户编号`,$num)
-                where LEFT(a.物料代码,1) = 'Y'
+               
                 ORDER BY a.`物料代码` ASC";
         }
         $data = Db::query($sql);
@@ -668,7 +668,9 @@ class Product extends Api
                 LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,$num-2) = b.编号
                 LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,$num) = c.编号
                 LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = d.编号
-                WHERE a.物料名称 LIKE '%{$search}%' AND (a.物料代码 LIKE 'J00%' or a.物料代码 LIKE 'J01%' or a.物料代码 LIKE 'J30%')";
+                WHERE (a.物料名称 LIKE '%{$search}%' or a.物料代码 LIKE '%{$search}%') and 
+                  (a.物料代码 LIKE 'Y00%' or a.物料代码 LIKE 'Y01%' or a.物料代码 LIKE 'Y04%' or a.物料代码 LIKE 'J03%' or a.物料代码 LIKE 'Y14%')";
+            $data = Db::query($sql);
         }else{
             $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,rtrim(b.编号) as oneCode,rtrim(b.名称) as oneName,
                 rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
@@ -676,9 +678,9 @@ class Product extends Api
                 LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,$num-2) = b.编号
                 LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,$num) = c.编号
                 LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,$num+2) = d.编号
-                WHERE  a.物料代码 LIKE 'J00%' or a.物料代码 LIKE 'J01%' or a.物料代码 LIKE 'J30%'";
+                WHERE a.物料代码 LIKE 'Y00%' or a.物料代码 LIKE 'Y01%' or a.物料代码 LIKE 'Y04%' or a.物料代码 LIKE 'J03%' or a.物料代码 LIKE 'Y14%'";
+            $data = Db::query($sql);
         }
-        $data = Db::query($sql);
         $mergedArray = [];
         foreach ($data as $item) {
             $oneCode = $item['oneCode'];
@@ -789,6 +791,9 @@ class Product extends Api
             ->join('产品_工艺资料 b','a.YB_cpdh = b.Gy0_cpdh and a.YB_Yjno = b.Gy0_yjno and a.YB_gxh = b.Gy0_gxh','left')
             ->join('物料_存货编码 c','a.存货编码 = c.物料代码','left')
             ->where('a.UniqID',$params['UniqID'])->field($field)->order('存货编码')->find();
+        if (empty($data)){
+            $this->error('未查询到产品印版资料');
+        }
         $where['Gy0_site'] = [
             ['like','胶印%'],
             ['like','烫模%'],
@@ -940,7 +945,9 @@ class Product extends Api
             $this->error('参数不能为空');
         }
         $code = $params['code'];
-        $data = \db('dic_lzsh')->where('sys_bh','like',$code.'%')->field('rtrim(sys_bh) as sys_bh, rtrim(sys_mc) as sys_mc,sys_rate0,sys_rate1')->select();
+        $data = \db('dic_lzsh')->where('sys_bh','like',$code.'%')->whereOr('sys_mc','like',$code.'%')
+            ->field('rtrim(sys_bh) as sys_bh, rtrim(sys_mc) as sys_mc,sys_rate0,sys_rate1')
+            ->select();
         $this->success('请求成功',$data);
     }
 

+ 5 - 2
application/api/controller/ReportingWork.php

@@ -217,8 +217,8 @@ class ReportingWork extends Api
         }
 //        $res = \db('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
         $res = \db('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
-        if ($res['UniqId'] < 100000000){
-            $data['UniqId'] = 100000000;
+        if (empty($res['UniqId'])){
+            $data['UniqId'] = 1;
         }else{
             $data['UniqId'] = $res['UniqId'] + 1;
         }
@@ -432,6 +432,9 @@ class ReportingWork extends Api
             $this->error('非法请求');
         }
         $params = Request::instance()->get();
+        if (empty($params['addr'])){
+            $this->error('参数不能为空');
+        }
         $data = \db('设备_基本资料')->where('sys_sbID',$params['addr'])->field('设备编号,rtrim(使用部门) as 使用部门')->find();
         $this->success('请求成功',$data);
     }

+ 43 - 10
application/api/controller/WorkOrder.php

@@ -121,6 +121,7 @@ class WorkOrder extends Api
         if (!empty($startTime) && !empty($endTime)){
             $where['接单日期'] = ['between',[$startTime,$endTime]];
         }
+        $where['行号'] = 1;
         $total = \db('工单_基本资料')->where($where)->count();
         $list = \db('工单_基本资料')
             ->where($where)
@@ -250,11 +251,16 @@ class WorkOrder extends Api
                     '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
                     '备选工序' => rtrim($value['备选工序']),
                     '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
+                    '印件号' => rtrim($value['Gy0_yjno']),
+                    '工序号' => rtrim($value['Gy0_gxh']),
+                    '工艺名称' => rtrim($value['Gy0_gxmc']),
+                    'gxmc' => rtrim($value['Add_gxmc']),
                     '计划产量' => $value['Gy0_计划接货数'],
                     '基础损耗' => rtrim($value['Gy0_Rate0']),
                     '损耗率' => rtrim($value['Gy0_Rate1']),
                     '机台编号' => rtrim($value['Gy0_sbbh']),
                     '报废定额' => rtrim($value['Gy0_计划损耗']),
+                    '计损色数' => rtrim($value['Gy0_ms']),
                     '允损比例' => $number,
                     '难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
                     '损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
@@ -928,6 +934,10 @@ class WorkOrder extends Api
         }
         $i = 0;
         foreach ($param as $key=>$value){
+            $data = [
+                'rate0' => 0,
+                'rate1' => 0,
+            ];
             if (!empty($value['loss'])){
                 $data = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
             }
@@ -1057,12 +1067,16 @@ class WorkOrder extends Api
         //修改工艺资料
         $sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
         $res = Db::query($sql);
+        //获取工艺资料数据
+        $list = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->field('Gy0_yjno,Gy0_gxh,rtrim(Gy0_计划接货数) as 计划接货数')->find();
         //修改工单状态
         $status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
         if ($status['status'] !== '2-生产中'){
             $statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
             Db::query($statusSql);
         }
+        //重新分配工序计划产量
+        $result = $this->PlannedProcessYield($param['workOrder'],$list['Gy0_yjno'],$list['Gy0_gxh'],$list['计划接货数']);
         if ($res !== false){
             $this->success('成功');
         }else{
@@ -1176,9 +1190,6 @@ class WorkOrder extends Api
             $this->success('未找到工单信息');
         }
         $materiel = $this->MaterielDetailGet($param['workOrder']);
-        if (empty($materiel)){
-            $this->success('未找到物料信息');
-        }
         $printDetail = $this->PrintDetailGet($param['workOrder'],$param['yjno'],$param['gxh']);
         if (empty($printDetail)){
             $this->success('未找到工艺信息');
@@ -1264,13 +1275,12 @@ class WorkOrder extends Api
         ];
         $filed = 'rtrim(BOM_物料编码) as 物料编码,rtrim(BOM_物料名称) as 物料名称,rtrim(BOM_投料单位) as 投料单位,rtrim(BOM_计划用量) as 计划用量';
         $list = \db('工单_bom资料')->where($where)->field($filed)->select();
-        if (empty($list)){
-            $this->success('未找到物料资料信息');
-        }
-        foreach ($list as $key=>$value){
-            $list[$key]['物料代码及名称'] = $value['物料编码'].' '.$value['物料名称'];
-            $list[$key]['计划用量'] = (float)$value['计划用量'];
-            unset($list[$key]['物料编码'],$list[$key]['物料名称']);
+        if (!empty($list)){
+            foreach ($list as $key=>$value){
+                $list[$key]['物料代码及名称'] = $value['物料编码'].' '.$value['物料名称'];
+                $list[$key]['计划用量'] = (float)$value['计划用量'];
+                unset($list[$key]['物料编码'],$list[$key]['物料名称']);
+            }
         }
         return $list;
     }
@@ -2313,4 +2323,27 @@ class WorkOrder extends Api
             $this->error('删除失败');
         }
     }
+
+    /**
+     * 修正核算参数-》工单产品信息获取
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ProductNameData()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $workOrder = input('workOrder');
+        if (empty($workOrder)){
+            $this->error('参数错误');
+        }
+        $orderList = \db('工单_基本资料')
+            ->field('rtrim(Gd_cpdh) as 印件代号,rtrim(Gd_cpmc) as 印件名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称')
+            ->where('Gd_gdbh',$workOrder)
+            ->find();
+        $this->success('成功',$orderList);
+    }
 }