|
|
@@ -411,11 +411,21 @@ class Manufacture extends Api
|
|
|
'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 辅助工时')
|
|
|
@@ -423,11 +433,11 @@ class Manufacture extends Api
|
|
|
if (empty($row)){
|
|
|
$this->success('未找到该工单工艺资料');
|
|
|
}
|
|
|
- $endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
|
|
|
+ $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'=>$lastTime['sj2'],'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
|
|
|
+ ->update(['Gy0_sj1'=>$newTime,'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
|
|
|
$res = Db::query($sql);
|
|
|
if ($res !== false){
|
|
|
$this->success('成功');
|
|
|
@@ -738,6 +748,13 @@ class Manufacture extends Api
|
|
|
if (empty($param)){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
+ $where = '';
|
|
|
+ if (isset($param['search'])){
|
|
|
+ $where = "
|
|
|
+ a.Gd_gdbh LIKE '%{$param['search']}%'
|
|
|
+ OR a.`成品名称` LIKE '%{$param['search']}%'
|
|
|
+ ";
|
|
|
+ }
|
|
|
$list = \db('工单_基本资料')
|
|
|
->alias('a')
|
|
|
->field([
|
|
|
@@ -780,8 +797,8 @@ class Manufacture extends Api
|
|
|
'b.Gy0_sbbh' => ['LIKE','%'.$param['machine'].'%'],
|
|
|
'b.PD_WG' => '1900-01-01 00:00:00'
|
|
|
])
|
|
|
+ ->where($where)
|
|
|
->group('a.Gd_gdbh')
|
|
|
- ->cache(true,720)
|
|
|
->select();
|
|
|
if (empty($list)){
|
|
|
$this->success('',[]);
|