|
@@ -34,7 +34,7 @@ class Facility extends Api
|
|
|
$department = \db('设备_基本资料')->distinct(true)->column('使用部门');
|
|
$department = \db('设备_基本资料')->distinct(true)->column('使用部门');
|
|
|
$date = date('Y-m-d H:i:s',time()-3888000);
|
|
$date = date('Y-m-d H:i:s',time()-3888000);
|
|
|
if (empty($department)){
|
|
if (empty($department)){
|
|
|
- $this->error('未获取到机台数据');
|
|
|
|
|
|
|
+ $this->success('未获取到机台数据');
|
|
|
}
|
|
}
|
|
|
foreach ($department as $value){
|
|
foreach ($department as $value){
|
|
|
if (rtrim($value) !== '研发中心'){
|
|
if (rtrim($value) !== '研发中心'){
|
|
@@ -97,7 +97,7 @@ class Facility extends Api
|
|
|
$totalA = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
|
|
$totalA = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
|
|
|
$totalB = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
|
|
$totalB = \db('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
- $this->error('未找到机台数据');
|
|
|
|
|
|
|
+ $this->success('',[]);
|
|
|
}
|
|
}
|
|
|
foreach ($list as $key=>$value){
|
|
foreach ($list as $key=>$value){
|
|
|
$list[$key]['产品名称'] = $value['工单编号'].'---'.$productName[$value['工单编号']];
|
|
$list[$key]['产品名称'] = $value['工单编号'].'---'.$productName[$value['工单编号']];
|
|
@@ -148,14 +148,10 @@ class Facility extends Api
|
|
|
'设备编号' => $machine,
|
|
'设备编号' => $machine,
|
|
|
'开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
|
|
'开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
|
|
|
'类别' => ['in',['IPQC检验','机台检验']],
|
|
'类别' => ['in',['IPQC检验','机台检验']],
|
|
|
-// 'UniqId' => ['>',$startId],
|
|
|
|
|
];
|
|
];
|
|
|
- $begin = \db('制程检验_记录')->where($where)->field('UniqId')->find();
|
|
|
|
|
- $end = \db('制程检验_记录')->where($where)->order('UniqId desc')->field('UniqId')->find();
|
|
|
|
|
- $where['UniqId'] = ['between',[$begin['UniqId'],$end['UniqId']+1]];
|
|
|
|
|
//检验项目筛选
|
|
//检验项目筛选
|
|
|
- $itemA = \db('制程检验_记录')->where($where)->distinct(true)->where('班组编号','A班')->column('rtrim(检验项目)');
|
|
|
|
|
- $itemB = \db('制程检验_记录')->where($where)->distinct(true)->where('班组编号','B班')->column('rtrim(检验项目)');
|
|
|
|
|
|
|
+ $itemA = \db('制程检验_记录')->where($where)->distinct(true)->cache(true,3600)->where('班组编号','A班')->column('rtrim(检验项目)');
|
|
|
|
|
+ $itemB = \db('制程检验_记录')->where($where)->distinct(true)->cache(true,3600)->where('班组编号','B班')->column('rtrim(检验项目)');
|
|
|
//检验时间
|
|
//检验时间
|
|
|
$InspectionTime = \db('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
|
|
$InspectionTime = \db('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
|
|
|
foreach ($InspectionTime as $k=>$v){
|
|
foreach ($InspectionTime as $k=>$v){
|
|
@@ -163,8 +159,8 @@ class Facility extends Api
|
|
|
}
|
|
}
|
|
|
//检测记录详情
|
|
//检测记录详情
|
|
|
$field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
|
|
$field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
|
|
|
- $nameDetailA = \db('制程检验_记录')->where($where)->field($field)->where('班组编号','A班')->find();
|
|
|
|
|
- $nameDetailB = \db('制程检验_记录')->where($where)->field($field)->where('班组编号','B班')->find();
|
|
|
|
|
|
|
+ $nameDetailA = \db('制程检验_记录')->cache(true,3600)->where($where)->field($field)->where('班组编号','A班')->find();
|
|
|
|
|
+ $nameDetailB = \db('制程检验_记录')->cache(true,3600)->where($where)->field($field)->where('班组编号','B班')->find();
|
|
|
$list = $data1 = $data2 = [];
|
|
$list = $data1 = $data2 = [];
|
|
|
//A班检测数据
|
|
//A班检测数据
|
|
|
foreach ($itemA as $key=>$value){
|
|
foreach ($itemA as $key=>$value){
|
|
@@ -258,7 +254,7 @@ class Facility extends Api
|
|
|
LIMIT 1";
|
|
LIMIT 1";
|
|
|
$list = Db::query($sql);
|
|
$list = Db::query($sql);
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
- $this->error('未找到排产工单');
|
|
|
|
|
|
|
+ $this->success('未找到排产工单',[]);
|
|
|
}
|
|
}
|
|
|
foreach ($list as $key=>$value){
|
|
foreach ($list as $key=>$value){
|
|
|
if ($value['gxh']<10){
|
|
if ($value['gxh']<10){
|
|
@@ -325,7 +321,7 @@ class Facility extends Api
|
|
|
ORDER BY b.Gy0_sj1";
|
|
ORDER BY b.Gy0_sj1";
|
|
|
$orderList = Db::query($sql);
|
|
$orderList = Db::query($sql);
|
|
|
if (empty($orderList)){
|
|
if (empty($orderList)){
|
|
|
- $this->error('未找到排产工单');
|
|
|
|
|
|
|
+ $this->success('未找到排产工单');
|
|
|
}
|
|
}
|
|
|
foreach ($orderList as $key=>$value){
|
|
foreach ($orderList as $key=>$value){
|
|
|
$orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
|
|
$orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
|
|
@@ -486,7 +482,7 @@ class Facility extends Api
|
|
|
rtrim(sczl_sj1) as sj1,rtrim(sczl_sj2) as sj2';
|
|
rtrim(sczl_sj1) as sj1,rtrim(sczl_sj2) as sj2';
|
|
|
$list = \db('设备_产量计酬')->where($where)->field($field)->order('UniqId desc')->select();
|
|
$list = \db('设备_产量计酬')->where($where)->field($field)->order('UniqId desc')->select();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
- $this->error('未找到生产记录');
|
|
|
|
|
|
|
+ $this->success('未找到生产记录');
|
|
|
}
|
|
}
|
|
|
foreach ($list as $k=>$v){
|
|
foreach ($list as $k=>$v){
|
|
|
if ($v['yjno']<10){
|
|
if ($v['yjno']<10){
|
|
@@ -605,7 +601,7 @@ class Facility extends Api
|
|
|
}
|
|
}
|
|
|
$list = \db('设备_基本资料')->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
|
|
$list = \db('设备_基本资料')->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
- $this->error('未找到机台编号');
|
|
|
|
|
|
|
+ $this->success('未找到机台编号');
|
|
|
}
|
|
}
|
|
|
$data = [];
|
|
$data = [];
|
|
|
foreach ($list as $key=>$value){
|
|
foreach ($list as $key=>$value){
|
|
@@ -1008,7 +1004,7 @@ class Facility extends Api
|
|
|
rtrim(机长) as 机长,rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员';
|
|
rtrim(机长) as 机长,rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员';
|
|
|
$list = \db('制程_换型清场')->where('UniqId',$param['UniqId'])->field($field)->find();
|
|
$list = \db('制程_换型清场')->where('UniqId',$param['UniqId'])->field($field)->find();
|
|
|
if (empty($list)){
|
|
if (empty($list)){
|
|
|
- $this->error('未找到该条清场记录');
|
|
|
|
|
|
|
+ $this->success('未找到该条清场记录');
|
|
|
}
|
|
}
|
|
|
$list['日期'] = date('Y-m-d',strtotime($list['日期']));
|
|
$list['日期'] = date('Y-m-d',strtotime($list['日期']));
|
|
|
$list['印件名称A'] = \db('工单_印件资料')->where('Yj_Gdbh',$list['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
|
|
$list['印件名称A'] = \db('工单_印件资料')->where('Yj_Gdbh',$list['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
|
|
@@ -1034,5 +1030,105 @@ class Facility extends Api
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 车间机台状态列表展示
|
|
|
|
|
+ * @ApiMethod (GET)
|
|
|
|
|
+ * @param void
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function MachineDetailList()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $workshop = $param['workshop'];
|
|
|
|
|
+ $sql = "SELECT
|
|
|
|
|
+ RTRIM( a.`设备编号` ) AS 设备编号,
|
|
|
|
|
+ RTRIM( a.`设备名称` ) AS 设备名称,
|
|
|
|
|
+ RTRIM( d.`当前状态` ) AS 状态
|
|
|
|
|
+ FROM
|
|
|
|
|
+ `设备_基本资料` AS a
|
|
|
|
|
+ JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ b.`设备编号`,
|
|
|
|
|
+ b.`当前状态`,
|
|
|
|
|
+ b.`开工时间`
|
|
|
|
|
+ FROM
|
|
|
|
|
+ `设备_产量采集` AS b
|
|
|
|
|
+ JOIN ( SELECT `设备编号`, MAX( `开工时间` ) AS `最新开工时间` FROM `设备_产量采集` GROUP BY `设备编号` ) AS c ON b.`设备编号` = c.`设备编号`
|
|
|
|
|
+ AND b.`开工时间` = c.`最新开工时间`
|
|
|
|
|
+ ) AS d ON a.`设备编号` = d.`设备编号`
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.`使用部门` = '{$workshop}'
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ a.`设备编号`";
|
|
|
|
|
+ $list = \db()->query($sql);
|
|
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
|
|
+ if ($value['状态'] == ''){
|
|
|
|
|
+ $list[$key]['状态'] = '待单';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //机台当前参数展示
|
|
|
|
|
+
|
|
|
|
|
+ public function MachineDetail()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ //机台状态时间
|
|
|
|
|
+
|
|
|
|
|
+ $startTime = \db('设备_产量采集')
|
|
|
|
|
+ ->where('设备编号',$param['machine'])
|
|
|
|
|
+ ->where('开工时间',$param['start'])
|
|
|
|
|
+ ->field('rtrim()')
|
|
|
|
|
+ ->order('UniqId')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ if (!empty($startTime) && !empty($endTime)){
|
|
|
|
|
+ $timeDifference = ($startTime($endTime['时间'])-strtotime($startTime['时间']))/3600;
|
|
|
|
|
+ $data['timeDifference'] = $timeDifference;
|
|
|
|
|
+ $data['field'] = $endTime['当班产量']-$startTime['当班产量'];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $data['timeDifference'] = 0;
|
|
|
|
|
+ $data['field'] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ //机台产能/时间明细
|
|
|
|
|
+ $row = \db('设备_产量采集')
|
|
|
|
|
+ ->where('设备编号',$param['machine'])
|
|
|
|
|
+ ->where('开工时间',$param['start'])
|
|
|
|
|
+ ->field('rtrim(时间) as 时间,rtrim(当前产量) as 产量,rtrim(当前状态) as 状态')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (empty($row)){
|
|
|
|
|
+ $data['row'] = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($row as $key=>$value){
|
|
|
|
|
+ $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['时间']));
|
|
|
|
|
+ $data['row'][$key]['状态'] = $value['状态'];
|
|
|
|
|
+ if ($key<2){
|
|
|
|
|
+ $data['row'][$key]['产能'] = 0;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $data['row'][$key]['产能'] = ($row[$key-1]['产能']-$row[$key-2]['产能'])*60;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //机台状态
|
|
|
|
|
+ $status = end($row)['状态'];
|
|
|
|
|
+ if (empty($status['状态'])){
|
|
|
|
|
+ $data['status'] = '待单';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $data['status'] = $status['状态'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|