qiuenguang 1 rok pred
rodič
commit
5dc3241421

+ 31 - 13
application/api/controller/Facility.php

@@ -5,6 +5,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use think\Db;
+use think\Request;
 
 /**
  * 设备运行跟踪
@@ -93,7 +94,6 @@ class Facility extends Api
         $productName = Db::table('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
         //组员信息
         $list = Db::table('设备_产量计酬')->where($where)->field($field)->select();
-        halt($list);
         $totalA = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
         $totalB = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
         if (empty($list)){
@@ -257,7 +257,10 @@ class Facility extends Api
         $data = [];
         foreach ($Ctaff as $key=>$value){
             if (!empty($value)){
-                $staffName = Db::table('人事_基本资料')->where('员工编号',$value)->field('员工姓名,员工编号')->find();
+                $staffName = Db::table('人事_基本资料')
+                    ->where('员工编号',$value)
+                    ->field('员工姓名,员工编号')
+                    ->find();
                 $data[$key] = [
                     '员工编号' => rtrim($staffName['员工编号']),
                     '员工姓名' => rtrim($staffName['员工姓名']),
@@ -273,7 +276,11 @@ class Facility extends Api
         $data['工单编号'] = rtrim($list['Gy0_gdbh']);
         $data['印件编号'] = rtrim($list['Gy0_yjno']);
         $data['工序名称'] = rtrim($list['Gy0_gxh']).'-'.rtrim($list['Gy0_gxmc']).'【'.rtrim($list['Add_gxmc']).'】';
-        $data['产品名称'] = Db::table('工单_基本资料')->where('Gd_gdbh',rtrim($list['Gy0_gdbh']))->field('rtrim(Gd_cpmc) as 产品名称')->find()['产品名称'];
+        $data['产品名称'] = Db::table('工单_基本资料')
+            ->where('Gd_gdbh',rtrim($list['Gy0_gdbh']))
+            ->field('rtrim(Gd_cpmc) as 产品名称')
+            ->find()['产品名称'];
+        $data['班组'] = Db::table('设备_产量计酬')->where($facilityWhere)->field('rtrim(sczl_bzdh) as bzdh')->order('UniqId desc')->find()['bzdh'];
         $this->success('成功',$data);
     }
 
@@ -300,8 +307,19 @@ class Facility extends Api
         $startTechonUniqId = $lastTechonUniqId['UniqId']-10000;
 //        $lastYieldUniqId = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
 //        $startYieldUniqId = $lastYieldUniqId['UniqId']-100000;
-        $workOrder = Db::table('设备_产量计酬')->where('sczl_jtbh',$machine)->field('sczl_gdbh')->where('UniqId','>',$startYieldUniqId)->order('UniqId desc')->find();
-        $startTime = Db::table('工单_工艺资料')->where('Gy0_gdbh',$workOrder['sczl_gdbh'])->where('Gy0_sbbh',$machine)->where('UniqId','>',$startTechonUniqId)->field('Gy0_sj1')->order('UniqId desc')->find();
+        $workOrder = Db::table('设备_产量计酬')
+            ->where('sczl_jtbh',$machine)
+            ->field('sczl_gdbh')
+//            ->where('UniqId','>',$startYieldUniqId)
+            ->order('UniqId desc')
+            ->find();
+        $startTime = Db::table('工单_工艺资料')
+            ->where('Gy0_gdbh',$workOrder['sczl_gdbh'])
+            ->where('Gy0_sbbh',$machine)
+            ->where('UniqId','>',$startTechonUniqId)
+            ->field('Gy0_sj1')
+            ->order('UniqId desc')
+            ->find();
         $where = [
 //            'UniqId' => ['>',$startTechonUniqId],
             'Gy0_sbbh' => $machine,
@@ -575,10 +593,10 @@ class Facility extends Api
 
     public function TeamMaintenance()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $data = $this->request->param();
+        $data = Request::instance()->post();
         if (empty($data)){
             $this->error('参数错误');
         }
@@ -619,10 +637,10 @@ class Facility extends Api
      */
     public function teamDel()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
@@ -713,10 +731,10 @@ class Facility extends Api
 
     public function FieldInspectionRecordAdd()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
@@ -822,10 +840,10 @@ class Facility extends Api
      */
     public  function InspectionItemAdd()
     {
-        if ($this->request->isPost()  === false){
+        if (Request::instance()->isPost()  === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }

+ 99 - 19
application/api/controller/Manufacture.php

@@ -4,7 +4,9 @@ namespace app\api\controller;
 
 
 use app\common\controller\Api;
+use Monolog\Handler\IFTTTHandler;
 use think\Db;
+use think\Request;
 /**
  *
  * 生产排单管理
@@ -55,15 +57,24 @@ class Manufacture extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        if ($param['status'] === '计划中'){
+            $status = '计划中';
+        }else{
+            $status = '已完工';
+        }
         $where = [
-            'gd_statu' => '3-计划中',
+            'gd_statu' => ['LIKE','%'.$status],
             '行号' => '1',
         ];
         $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,
         rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
         rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
         rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
-        $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
+        $list = Db::table('工单_基本资料')->where($where)->field($field)->limit(1000)->order('Uniqid desc')->select();
         if (empty($list)){
             $this->error('失败');
         }
@@ -168,14 +179,65 @@ class Manufacture extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
-        $where = [
-            'gd_statu' => '2-生产中',
-            '行号' => 1
-        ];
-        $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(接单日期) as 接单日期,
-        rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(销售订单号) as 销售订单号,rtrim(Gd_客户代号) as 客户编号,
-        rtrim(Gd_客户名称) as 客户名称,rtrim(客户料号) as 客户料号,rtrim(Uniqid) as GDUID';
-        $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        if ($param['status'] === '排程中'){
+            $sql = "SELECT
+                rtrim(a.Gd_gdbh) AS 工单编号,
+                rtrim(a.Gd_cpdh) AS 产品代号,
+                rtrim(a.Gd_cpmc) AS 产品名称,
+                rtrim(a.接单日期) AS 接单日期,
+                rtrim(a.交货日期) AS 交货日期,
+                rtrim(a.订单数量) AS 订单数量,
+                rtrim(a.计量单位) AS 计量单位,
+                rtrim(a.销售订单号) AS 销售订单号,
+                rtrim(a.Gd_客户代号) AS 客户编号,
+                rtrim(a.Gd_客户名称) AS 客户名称,
+                rtrim(a.客户料号) AS 客户料号,
+                rtrim(a.Uniqid) AS GDUID
+            FROM
+                `工单_基本资料` AS a
+            INNER JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+            JOIN `产品_基本资料` AS c ON a.Gd_cpdh = c.产品编号
+            WHERE
+                a.gd_statu = '2-生产中'
+                AND a.行号 = '1'
+                AND b.PD_WG = '1900-01-01 00:00:00'
+                AND b.Gy0_sj1 = '1900-01-01 00:00:00'
+                    AND c.状态 = ''
+            GROUP BY a.Gd_gdbh ";
+        }else{
+            $sql = "SELECT
+                rtrim(a.Gd_gdbh) AS 工单编号,
+                rtrim(a.Gd_cpdh) AS 产品代号,
+                rtrim(a.Gd_cpmc) AS 产品名称,
+                rtrim(a.接单日期) AS 接单日期,
+                rtrim(a.交货日期) AS 交货日期,
+                rtrim(a.订单数量) AS 订单数量,
+                rtrim(a.计量单位) AS 计量单位,
+                rtrim(a.销售订单号) AS 销售订单号,
+                rtrim(a.Gd_客户代号) AS 客户编号,
+                rtrim(a.Gd_客户名称) AS 客户名称,
+                rtrim(a.客户料号) AS 客户料号,
+                rtrim(a.Uniqid) AS GDUID
+            FROM
+                `工单_基本资料` AS a
+            INNER JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+            JOIN `产品_基本资料` AS c ON a.Gd_cpdh = c.产品编号
+            WHERE
+                a.gd_statu = '2-生产中'
+                AND a.行号 = '1'
+                AND b.PD_WG = '1900-01-01 00:00:00'
+                AND b.Gy0_sj1 != '1900-01-01 00:00:00'
+                    AND c.状态 = ''
+            GROUP BY a.Gd_gdbh ";
+        }
+        $list = Db::query($sql);
+        if (empty($list)){
+            $this->error('未找到工单信息');
+        }
         $this->success('成功',$list);
     }
 
@@ -280,7 +342,7 @@ class Manufacture extends Api
      */
     public function StatusEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
         $workOrder = input('workOrder');
@@ -341,10 +403,10 @@ class Manufacture extends Api
 
     public function ProductionSchedulingAdd()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $data = $this->request->param();
+        $data = Request::instance()->post();
         if (empty($data)){
             $this->error('参数错误');
         }
@@ -363,6 +425,9 @@ class Manufacture extends Api
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
             ->find();
+        if (empty($row)){
+            $this->error('未找到该工单工艺资料');
+        }
         $endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
         $sql = Db::table('工单_工艺资料')
             ->where($where)
@@ -390,10 +455,10 @@ class Manufacture extends Api
 
     public function ProductionSchedulingPause()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $data = $this->request->param();
+        $data = Request::instance()->post();
         if (empty($data)){
             $this->error('参数错误');
         }
@@ -405,6 +470,9 @@ class Manufacture extends Api
         ];
         $machine = $where['Gy0_sbbh'];
         $endTime = Db::table('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
+        if (empty($endTime)){
+            $this->error('未找到该工序');
+        }
         if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
             $this->error('该工单不是制程中工单');
         }
@@ -416,6 +484,9 @@ class Manufacture extends Api
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
             ->find();
+        if (empty($row)){
+            $this->error('未找到该工序');
+        }
         $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
         $res = Db::query($sql);
         $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh = '{$machine}' AND Gy0_sj1 >= '{$endTime}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
@@ -467,7 +538,7 @@ class Manufacture extends Api
             $list[$key]['印件及工序'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
             foreach ($yield as $k=>$v){
                 if ($v['gxh'] === $list[$key]['gxh']){
-                    $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/'.$v['cl'];
+                    $list[$key]['计划产量/已完成'] = (int)($value['计划接货数']/$value['ls']).'/'.$v['cl'];
                     $list[$key]['完成率'] = number_format($v['cl']/($value['计划接货数']/$value['ls']),4)*100 . '%';
                 }else{
                     $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/0';
@@ -482,6 +553,15 @@ class Manufacture extends Api
         $this->success('成功',$list);
     }
 
+    //工序状态更正->工序状态编辑
+    public function ProcessStatusCorrectionEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+
+    }
+
     /**
      * 班次选择
      * @ApiMethod (GET)
@@ -507,7 +587,7 @@ class Manufacture extends Api
     }
 
     /**
-     * 车间设备程展示
+     * 车间设备程展示
      * @ApiMethod (GET)
      * @param  void $param
      * @return void
@@ -577,11 +657,11 @@ class Manufacture extends Api
      */
     public function EquipmentSchedulingEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
 
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }

+ 11 - 11
application/api/controller/WorkOrder.php

@@ -354,10 +354,10 @@ class WorkOrder extends Api
 
     public function WorkOrderEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param) || isset($param['Uniqid']) === false){
             $this->error('参数错误');
         }
@@ -487,7 +487,7 @@ class WorkOrder extends Api
 
     public function ProductInformationEdit()
     {
-        if ($this->request->isPost() === false)
+        if (Request::instance()->isPost() === false)
         {
             $this->error('请求错误');
         }
@@ -614,7 +614,7 @@ class WorkOrder extends Api
      */
     public function ProcessCopy()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
         $oldWorkOrder = input('oldWorkOrder');
@@ -772,7 +772,7 @@ class WorkOrder extends Api
      */
     public function TestCoefficientEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
         $workOrder = input('workOrder');
@@ -900,10 +900,10 @@ class WorkOrder extends Api
 
     public function PrintedEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param) || isset($param['Uniqid']) === false){
             $this->error('参数错误');
         }
@@ -954,10 +954,10 @@ class WorkOrder extends Api
      */
     public function ProcessDetailEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param) || isset($param['UniqId']) === false){
             $this->error('参数错误');
         }
@@ -1028,10 +1028,10 @@ class WorkOrder extends Api
      */
     public function PrintJobOrder()
     {
-        if ($this->request->isPost() === false) {
+        if (Request::instance()->isPost() === false) {
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }