|
@@ -4,6 +4,7 @@ namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
use app\common\controller\Api;
|
|
use app\common\controller\Api;
|
|
|
|
|
+use think\Db;
|
|
|
use think\Request;
|
|
use think\Request;
|
|
|
|
|
|
|
|
class GluingReport extends Api
|
|
class GluingReport extends Api
|
|
@@ -232,7 +233,7 @@ class GluingReport extends Api
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
$param['sys_rq'] = date('Y-m-d H:i:s',time());
|
|
$param['sys_rq'] = date('Y-m-d H:i:s',time());
|
|
|
- $res = db('机台_糊盒班组资料')->insert($param);
|
|
|
|
|
|
|
+ $res = db('设备_糊盒班组资料')->insert($param);
|
|
|
if ($res === false){
|
|
if ($res === false){
|
|
|
$this->error('新增失败');
|
|
$this->error('新增失败');
|
|
|
}else{
|
|
}else{
|
|
@@ -269,14 +270,228 @@ class GluingReport extends Api
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// public function AddGluingReportData()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 糊盒机台报工
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\BindParamException
|
|
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function AddGluingReportData()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isPost() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param = Request::instance()->post();
|
|
|
|
|
+ if (empty($param)){
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $param['sys_rq'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
+ $Sql = db('设备_糊盒报工资料')->fetchSql(true)->insert($param);
|
|
|
|
|
+ $res = db()->query($Sql);
|
|
|
|
|
+ if ($res === false){
|
|
|
|
|
+ $this->error('报工失败');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $this->success('报工成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 糊盒机台报工数据菜单
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getTab()
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($this->request->isGet() === false){
|
|
|
|
|
+ $this->error('请求错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ $date = date('Y-m-d 00:00:00',time()-3888000);
|
|
|
|
|
+ $sist = ['印后糊盒车间','精品自动化车间','数字化车间'];
|
|
|
|
|
+ $department = \db('设备_基本资料')
|
|
|
|
|
+ ->distinct(true)
|
|
|
|
|
+ ->where('使用部门','in',$sist)
|
|
|
|
|
+ ->where('设备编组','<>','')
|
|
|
|
|
+ ->where('sys_sbID','<>','')
|
|
|
|
|
+ ->order('设备编组')
|
|
|
|
|
+ ->column('rtrim(使用部门) as 使用部门');
|
|
|
|
|
+ if (empty($department)){
|
|
|
|
|
+ $this->success('为获取到机台数据');
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = \db('设备_糊盒报工资料')
|
|
|
|
|
+ ->field([
|
|
|
|
|
+ 'DISTINCT(sczl_rq)' => '时间',
|
|
|
|
|
+ 'rtrim(sczl_jtbh)' => '机台编号'
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->where('sczl_rq','>',$date)
|
|
|
|
|
+ ->order('sczl_rq desc')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (empty($list)){
|
|
|
|
|
+ $this->success('未找到机台生产记录');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($department as $value){
|
|
|
|
|
+ $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->order('设备编号')->select();
|
|
|
|
|
+ foreach ($machine as $k=>$v){
|
|
|
|
|
+ $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
|
|
|
|
|
+ foreach ($list as $kk=>$vv){
|
|
|
|
|
+ if ($v['设备编号'] === $vv['机台编号']){
|
|
|
|
|
+ array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功',$data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// public function gitGluingReportList()
|
|
|
// {
|
|
// {
|
|
|
-// if ($this->request->isPost() === false){
|
|
|
|
|
|
|
+// if ($this->request->isGet() === false){
|
|
|
// $this->error('请求错误');
|
|
// $this->error('请求错误');
|
|
|
// }
|
|
// }
|
|
|
-// $param = Request::instance()->post();
|
|
|
|
|
|
|
+// $param = $this->request->param();
|
|
|
// if (empty($param)){
|
|
// if (empty($param)){
|
|
|
// $this->error('参数错误');
|
|
// $this->error('参数错误');
|
|
|
// }
|
|
// }
|
|
|
|
|
+// $where = [
|
|
|
|
|
+// 'a.sczl_jtbh' => $param['machine'],
|
|
|
|
|
+// 'a.sys_rq' => $param['date'],
|
|
|
|
|
+// ];
|
|
|
|
|
+// $list = \db('设备_糊盒报工资料')
|
|
|
|
|
+// ->alias('a')
|
|
|
|
|
+// ->join('工单_基本资料 b','a.sczl_gdbh = b.Gd_gdbh')
|
|
|
|
|
+// ->join('设备_糊盒班组资料 c','a. = c.Gd_gdbh')
|
|
|
// }
|
|
// }
|
|
|
|
|
+
|
|
|
|
|
+ public function GetProduction()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Request::instance()->isGet() == false) {
|
|
|
|
|
+ $this->error('非法请求');
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = Request::instance()->param();
|
|
|
|
|
+ if (!isset($params['machine']) || empty($params['machine'])) {
|
|
|
|
|
+ $this->error('参数错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $machine = $params['machine'];
|
|
|
|
|
+ $machineCode = \db('dic_lzde')->where('适用机型',$machine)->value('sys_bh');
|
|
|
|
|
+ $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
|
|
|
|
|
+ $list = [];
|
|
|
|
|
+ $row = [];
|
|
|
|
|
+ if (!empty($data['工单编号'])){
|
|
|
|
|
+ $endTime = \db('工单_工艺资料')
|
|
|
|
|
+ ->where('Gy0_gdbh',$data['工单编号'])
|
|
|
|
|
+ ->where('Gy0_yjno',$data['印件号'])
|
|
|
|
|
+ ->where('Gy0_gxh',$data['工序号'])
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ $list['工单编号'] = $data['工单编号'];
|
|
|
|
|
+ if (!empty($endTime)){
|
|
|
|
|
+ $list['印件号'] = $data['印件号'];
|
|
|
|
|
+ $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
|
|
|
|
|
+ $code = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品代号');
|
|
|
|
|
+ $list['产品名称'] = rtrim($name);
|
|
|
|
|
+ $list['产品代号'] = rtrim($code);
|
|
|
|
|
+ $list['工序名称'] = $data['工序名称'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $list['状态'] = rtrim($data['当前状态']);
|
|
|
|
|
+ $list['开工时间'] = $data['开工时间'];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $list['工单编号'] = '';
|
|
|
|
|
+ $list['印件号'] = 0;
|
|
|
|
|
+ $list['产品名称'] = '';
|
|
|
|
|
+ $list['工序名称'] = '';
|
|
|
|
|
+ $list['产品代号'] = '';
|
|
|
|
|
+ $list['状态'] = '';
|
|
|
|
|
+ $list['开工时间'] = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ $list['班组编号'] = rtrim($data['班组编号']);
|
|
|
|
|
+ $list['班组Id'] = rtrim($data['班组ID']);
|
|
|
|
|
+ $class = \db('设备_班组资料')->where('UniqId',$data['班组ID'])->field("rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
|
|
|
|
|
+ rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
|
|
|
|
|
+ rtrim(sczl_bh10) as bh10")->find();
|
|
|
|
|
+ if (!empty($class)){
|
|
|
|
|
+ for ($i=1;$i<11;$i++) {
|
|
|
|
|
+ if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
|
|
|
|
|
+ $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
|
|
|
|
|
+ $row[$i] = [
|
|
|
|
|
+ '编号' => $class['bh' . $i],
|
|
|
|
|
+ '姓名' => $name['姓名']
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $row = array_values($row);
|
|
|
|
|
+ }
|
|
|
|
|
+ $list['班组成员'] = $row;
|
|
|
|
|
+ $list['定额代号'] = $machineCode;
|
|
|
|
|
+ $this->success('成功',$list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function setMachineTeam()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (Request::instance()->isPost() == false) {
|
|
|
|
|
+ $this->error('非法请求');
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = Request::instance()->post();
|
|
|
|
|
+ if (!isset($params['machine']) || empty($params['machine'] )) {
|
|
|
|
|
+ $this->error('参数不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($params['team_id']) || empty($params['sczl_bzdh'])){
|
|
|
|
|
+ $this->error('请先选择班组成员');
|
|
|
|
|
+ }
|
|
|
|
|
+ $machine = $params['machine'] . '#';
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ $lastData = \db('设备_产量采集')
|
|
|
|
|
+ ->order('UniqId desc')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ $id = $lastData['UniqId']+1;
|
|
|
|
|
+ $data['当前状态'] = $params['status'];
|
|
|
|
|
+ $data['时间'] = date('Y-m-d H:i:s');
|
|
|
|
|
+ $data['设备编号'] = $machine;
|
|
|
|
|
+ $data['工单编号'] = empty($params['order']) ? '':$params['order'];
|
|
|
|
|
+ $data['印件号'] = empty($params['yjno']) ? '':$params['yjno'];
|
|
|
|
|
+ $data['工序号'] = empty($params['gy_name']) ? '' : (int)substr($params['gy_name'], 0, 2);
|
|
|
|
|
+ $data['工序名称'] = empty($params['gy_name']) ? '' : $params['gy_name'];
|
|
|
|
|
+ $data['当班产量'] = $params['production_now'];
|
|
|
|
|
+ $data['累计产量'] = $params['production_all'];
|
|
|
|
|
+ $data['班组编号'] = $params['sczl_bzdh'];
|
|
|
|
|
+ $data['班组ID'] = $params['team_id'];
|
|
|
|
|
+ // 获取当前时间
|
|
|
|
|
+ $current_time = time();
|
|
|
|
|
+ // 设置时间范围
|
|
|
|
|
+ $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
|
|
|
|
|
+ $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
|
|
|
|
|
+ $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
|
|
|
|
|
+ $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
|
|
|
|
|
+ $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
|
|
|
|
|
+ // 判断当前时间属于哪个时间范围
|
|
|
|
|
+ if ($current_time >= $start_time1 && $current_time <= $end_time1) {
|
|
|
|
|
+ $data['开工时间'] = date('Y-m-d') . ' 08:30:00';
|
|
|
|
|
+ } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
|
|
|
|
|
+ $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
|
|
|
|
|
+
|
|
|
|
|
+ } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
|
|
|
|
|
+ $data['开工时间'] = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
|
|
|
|
|
+ }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
|
|
|
|
|
+ $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($params['order']) && !empty($params['yjno'])){
|
|
|
|
|
+ $option['Gy0_gdbh'] = $params['order'];
|
|
|
|
|
+ $option['Gy0_yjno'] = $params['yjno'];
|
|
|
|
|
+ $option['Gy0_gxh'] = $data['工序号'];
|
|
|
|
|
+ $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $data['任务ID'] = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ $data['UniqId'] = $id;
|
|
|
|
|
+ $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
|
|
|
|
|
+ $res = Db::query($sql);
|
|
|
|
|
+ if ($res === false) {
|
|
|
|
|
+ $this->error('设置失败');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $this->success('设置成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|