|
|
@@ -222,6 +222,7 @@ class Facility extends Api
|
|
|
$data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
|
|
|
$endTime = \db('工单_工艺资料')
|
|
|
->where('Gy0_gdbh',$data['工单编号'])
|
|
|
+ ->where('Gy0_gxh',$data['工序号'])
|
|
|
->where('Gy0_sbbh','like','%'.$machine.'%')
|
|
|
->find();
|
|
|
$list = [];
|
|
|
@@ -1556,44 +1557,79 @@ class Facility extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //首页数据
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 首页数据
|
|
|
+ * @return void
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
public function index()
|
|
|
{
|
|
|
- $data = [
|
|
|
- 'workOrderData' => [
|
|
|
- '计划中' => 100,
|
|
|
- '排程中' => 100,
|
|
|
- '制程中' => 100,
|
|
|
- '已完工' => 100,
|
|
|
- ],
|
|
|
- 'MonthlyData' => [
|
|
|
- '1' => 100,
|
|
|
- '2' => 100,
|
|
|
- '3' => 100,
|
|
|
- '4' => 100,
|
|
|
- '5' => 100,
|
|
|
- '6' => 100,
|
|
|
- '7' => 100,
|
|
|
- '8' => 100,
|
|
|
- '9' => 100,
|
|
|
- '10' => 100,
|
|
|
- '11' => 100,
|
|
|
- '12' => 100,
|
|
|
- ],
|
|
|
- 'customer' => [
|
|
|
- '0' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '1' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '2' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '3' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '4' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '5' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '6' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '7' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '8' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- '9' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
|
|
|
- ],
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
+ $this->error('请求错误');
|
|
|
+ }
|
|
|
+ $nowTime = date('Y-m-d H:i:s',time());
|
|
|
+ $oldTime = (date('Y')-1).'-'.date('m-d H:i:s');
|
|
|
+ $where =[
|
|
|
+ 'Mod_rq' => ['between',[$oldTime,$nowTime]],
|
|
|
+ '行号' => '1'
|
|
|
];
|
|
|
- return json($data);
|
|
|
+ $data = [];
|
|
|
+ //按状态查询工单信息
|
|
|
+ $orderList = \db('工单_基本资料')
|
|
|
+ ->where($where)
|
|
|
+ ->field('count(Gd_gdbh) as 数量,rtrim(gd_statu) as 状态')
|
|
|
+ ->group('gd_statu')
|
|
|
+ ->select();
|
|
|
+ foreach ($orderList as $value){
|
|
|
+ if ($value['状态'] === '1-已完工'){
|
|
|
+ $data['workOrderData']['已完工'] = $value['数量'];
|
|
|
+ }
|
|
|
+ if ($value['状态'] === '3-计划中'){
|
|
|
+ $data['workOrderData']['计划中'] = $value['数量'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data['workOrderData']['排程中'] = db('工单_基本资料')->alias('a')
|
|
|
+ ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
|
|
|
+ ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
|
|
|
+ ->where([
|
|
|
+ 'a.gd_statu' => '2-生产中',
|
|
|
+ 'a.行号' => '1',
|
|
|
+ 'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
|
|
|
+ 'b.PD_WG' => '1900-01-01 00:00:00',
|
|
|
+ 'b.Gy0_sj1' => '1900-01-01 00:00:00',
|
|
|
+ 'c.状态' => '',
|
|
|
+ ])
|
|
|
+ ->group('a.Gd_gdbh')
|
|
|
+ ->count();
|
|
|
+ $data['workOrderData']['制程中'] = db('工单_基本资料')->alias('a')
|
|
|
+ ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
|
|
|
+ ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
|
|
|
+ ->where([
|
|
|
+ 'a.gd_statu' => '2-生产中',
|
|
|
+ 'a.行号' => '1',
|
|
|
+ 'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
|
|
|
+ 'b.PD_WG' => '1900-01-01 00:00:00',
|
|
|
+ 'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
|
|
|
+ 'c.状态' => '',
|
|
|
+ ])
|
|
|
+ ->group('a.Gd_gdbh')
|
|
|
+ ->count();
|
|
|
+ //按月份查询工单信息
|
|
|
+ $data['monthData'] = \db('工单_基本资料')
|
|
|
+ ->where('Mod_rq', 'between', [$oldTime, $nowTime])
|
|
|
+ ->field('DATE_FORMAT(Mod_rq, "%Y-%m") as month, COUNT(*) as count')
|
|
|
+ ->group('month')
|
|
|
+ ->order('month')
|
|
|
+ ->select();
|
|
|
+ //查询最近十条客诉信息
|
|
|
+ $data['customer'] = \db('db_客诉记录')
|
|
|
+ ->field('rtrim(客诉描述) as 客诉描述,DATE_FORMAT(客诉日期, "%Y-%m-%d") as 日期,rtrim(UniqID) as UniqId')
|
|
|
+ ->limit(10)
|
|
|
+ ->order('Sys_rq desc')
|
|
|
+ ->select();
|
|
|
+ $this->success('成功',$data);
|
|
|
}
|
|
|
}
|