|
|
@@ -427,45 +427,51 @@ class Manufacture extends Api
|
|
|
if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
- $data = Request::instance()->post();
|
|
|
- if (empty($data)){
|
|
|
+ $datas = Request::instance()->post();
|
|
|
+ if (empty($datas)){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $where = [
|
|
|
- 'Gy0_gdbh' => $data['workOrder'],
|
|
|
- 'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
|
|
|
- 'Gy0_yjno' => $data['printCode'],
|
|
|
- 'Gy0_gxh' => $data['processCode']
|
|
|
- ];
|
|
|
- $result = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj1) as sj1')->find();
|
|
|
- if ($result['sj1'] != '1900-01-01 00:00:00'){
|
|
|
- $this->error('该工单已经是制程中');
|
|
|
- }
|
|
|
- $lastTime = \db('工单_工艺资料')
|
|
|
- ->where(['Gy0_sbbh'=>$where['Gy0_sbbh'],'Gy0_sj2'=>['<>','1900-01-01 00:00:00'],'Gy0_sj2'=>['<','2099-01-01 00:00:00']])
|
|
|
- ->field('rtrim(Gy0_sj2) as sj2')
|
|
|
- ->order('Gy0_sj2 desc')
|
|
|
- ->find();
|
|
|
- $date = date('Y-m-d H:i:s',time());
|
|
|
- if ($lastTime['sj2'] < $date){
|
|
|
- $newTime = $date;
|
|
|
- }else{
|
|
|
- $newTime = $lastTime['sj2'];
|
|
|
- }
|
|
|
- $row = \db('工单_工艺资料')
|
|
|
- ->where($where)
|
|
|
- ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
- ->find();
|
|
|
- if (empty($row)){
|
|
|
- $this->success('未找到该工单工艺资料');
|
|
|
+ $i = 0;
|
|
|
+ foreach ($datas as $data){
|
|
|
+ $where = [
|
|
|
+ 'Gy0_gdbh' => $data['workOrder'],
|
|
|
+ 'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
|
|
|
+ 'Gy0_yjno' => $data['printCode'],
|
|
|
+ 'Gy0_gxh' => $data['processCode']
|
|
|
+ ];
|
|
|
+ $result = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj1) as sj1')->find();
|
|
|
+ if ($result['sj1'] != '1900-01-01 00:00:00'){
|
|
|
+ $this->error('该工单已经是制程中');
|
|
|
+ }
|
|
|
+ $lastTime = \db('工单_工艺资料')
|
|
|
+ ->where(['Gy0_sbbh'=>$where['Gy0_sbbh'],'Gy0_sj2'=>['<>','1900-01-01 00:00:00'],'Gy0_sj2'=>['<','2099-01-01 00:00:00']])
|
|
|
+ ->field('rtrim(Gy0_sj2) as sj2')
|
|
|
+ ->order('Gy0_sj2 desc')
|
|
|
+ ->find();
|
|
|
+ $date = date('Y-m-d H:i:s',time());
|
|
|
+ if ($lastTime['sj2'] < $date){
|
|
|
+ $newTime = $date;
|
|
|
+ }else{
|
|
|
+ $newTime = $lastTime['sj2'];
|
|
|
+ }
|
|
|
+ $row = \db('工单_工艺资料')
|
|
|
+ ->where($where)
|
|
|
+ ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
+ ->find();
|
|
|
+ if (empty($row)){
|
|
|
+ $this->success('未找到该工单工艺资料');
|
|
|
+ }
|
|
|
+ $endTime = date('Y-m-d H:i:s',strtotime($newTime) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
|
|
|
+ $sql = \db('工单_工艺资料')
|
|
|
+ ->where($where)
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update(['Gy0_sj1'=>$newTime,'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($res === false){
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
}
|
|
|
- $endTime = date('Y-m-d H:i:s',strtotime($newTime) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
|
|
|
- $sql = \db('工单_工艺资料')
|
|
|
- ->where($where)
|
|
|
- ->fetchSql(true)
|
|
|
- ->update(['Gy0_sj1'=>$newTime,'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false){
|
|
|
+ if ($i === 0){
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
@@ -489,41 +495,51 @@ class Manufacture extends Api
|
|
|
if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
- $data = Request::instance()->post();
|
|
|
- if (empty($data)){
|
|
|
+ $datas = Request::instance()->post();
|
|
|
+ if (empty($datas)){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $where = [
|
|
|
- 'Gy0_gdbh' => $data['workOrder'],
|
|
|
- 'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
|
|
|
- 'Gy0_yjno' => $data['printCode'],
|
|
|
- 'Gy0_gxh' => $data['processCode']
|
|
|
- ];
|
|
|
- $machine = $data['machine'];
|
|
|
- $endTime = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2,rtrim(PD_WG) as wg')->find();
|
|
|
- if (empty($endTime)){
|
|
|
- $this->success('未找到该工序');
|
|
|
- }
|
|
|
- $time = $endTime['sj2'];
|
|
|
- if ($endTime['sj2'] == '1900-01-01 00:00:00' || $endTime['wg'] != '1900-01-01 00:00:00'){
|
|
|
- $this->error('该工单不是制程中工单');
|
|
|
+ $i = $j = 0;
|
|
|
+ foreach ($datas as $data){
|
|
|
+ $where = [
|
|
|
+ 'Gy0_gdbh' => $data['workOrder'],
|
|
|
+ 'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
|
|
|
+ 'Gy0_yjno' => $data['printCode'],
|
|
|
+ 'Gy0_gxh' => $data['processCode']
|
|
|
+ ];
|
|
|
+ $machine = $data['machine'];
|
|
|
+ $endTime = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2,rtrim(PD_WG) as wg')->find();
|
|
|
+ if (empty($endTime)){
|
|
|
+ $this->success('未找到该工序');
|
|
|
+ }
|
|
|
+ $time = $endTime['sj2'];
|
|
|
+ if ($endTime['sj2'] == '1900-01-01 00:00:00' || $endTime['wg'] != '1900-01-01 00:00:00'){
|
|
|
+ $this->error('该工单不是制程中工单');
|
|
|
+ }
|
|
|
+ $sql = \db('工单_工艺资料')
|
|
|
+ ->where($where)
|
|
|
+ ->fetchSql(true)
|
|
|
+ ->update(['Gy0_sj1'=>'1900-01-01 00:00:00','Gy0_sj2'=>'1900-01-01 00:00:00','Mod_rq'=>date('Y-m-d H:i:s')]);
|
|
|
+ $row = \db('工单_工艺资料')
|
|
|
+ ->where($where)
|
|
|
+ ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
+ ->find();
|
|
|
+ if (empty($row)){
|
|
|
+ $this->success('未找到该工序');
|
|
|
+ }
|
|
|
+ $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
|
|
|
+ $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh LIKE '%{$machine}%' AND Gy0_sj1 >= '{$time}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
|
|
|
+ $rechres = Db::query($rechSql);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($rechres === false){
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ if ($res === false){
|
|
|
+ $j++;
|
|
|
+ }
|
|
|
}
|
|
|
- $sql = \db('工单_工艺资料')
|
|
|
- ->where($where)
|
|
|
- ->fetchSql(true)
|
|
|
- ->update(['Gy0_sj1'=>'1900-01-01 00:00:00','Gy0_sj2'=>'1900-01-01 00:00:00','Mod_rq'=>date('Y-m-d H:i:s')]);
|
|
|
- $row = \db('工单_工艺资料')
|
|
|
- ->where($where)
|
|
|
- ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
|
|
|
- ->find();
|
|
|
- if (empty($row)){
|
|
|
- $this->success('未找到该工序');
|
|
|
- }
|
|
|
- $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
|
|
|
- $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh LIKE '%{$machine}%' AND Gy0_sj1 >= '{$time}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
|
|
|
- $rechres = Db::query($rechSql);
|
|
|
- $res = Db::query($sql);
|
|
|
- if ($res !== false && $rechres !== false){
|
|
|
+
|
|
|
+ if ($i === 0 && $j === 0){
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
@@ -912,8 +928,9 @@ class Manufacture extends Api
|
|
|
if (empty($param) || isset($param['UniqId']) === false){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
+ $uid = explode(',',$param['UniqId']);
|
|
|
$sql = \db('工单_工艺资料')
|
|
|
- ->where('UniqId',$param['UniqId'])
|
|
|
+ ->where('UniqId','in',$uid)
|
|
|
->fetchSql(true)
|
|
|
->update(['Gy0_sbbh'=>$param['machine']]);
|
|
|
$res = \db()->query($sql);
|