|
|
@@ -362,44 +362,22 @@ class Manufacture extends Api
|
|
|
* @throws \think\Exception
|
|
|
* @throws \think\exception\PDOException
|
|
|
*/
|
|
|
- public function StatusEdit()
|
|
|
+ public function StatusEdit()
|
|
|
{
|
|
|
- if ($this->request->isPost() === false) {
|
|
|
+ if (Request::instance()->isPost() === false){
|
|
|
$this->error('请求错误');
|
|
|
}
|
|
|
- $param = $this->request->param();
|
|
|
- $workOrder = $param['workOrder'] ?? input('workOrder');
|
|
|
- $status = $param['status'] ?? input('status');
|
|
|
- if (empty($workOrder) || empty($status)) {
|
|
|
+ $workOrder = input('workOrder');
|
|
|
+ $status = input('status');
|
|
|
+ if (empty($workOrder) || empty($status)){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
- $oldStatus = \db('工单_基本资料')->where('Gd_gdbh', $workOrder)->value('gd_statu');
|
|
|
- $modifyUser = $param['sys_id'] ?? $param['Sys_id'] ?? '';
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $res = \db('工单_基本资料')->where('Gd_gdbh', $workOrder)->update([
|
|
|
- 'gd_statu' => $status,
|
|
|
- 'Mod_rq' => date('Y-m-d H:i:s')
|
|
|
- ]);
|
|
|
- if ($res === false) {
|
|
|
- throw new \Exception('更新工单状态失败');
|
|
|
- }
|
|
|
- \db('系统操作日志表')->insert([
|
|
|
- 'Gd_gdbh' => $workOrder,
|
|
|
- 'ModifyUser' => $modifyUser,
|
|
|
- 'ModifyTime' => date('Y-m-d H:i:s'),
|
|
|
- 'FieldName' => 'gd_statu',
|
|
|
- 'OldValue' => $oldStatus,
|
|
|
- 'NewValue' => $status,
|
|
|
- 'ModifySource' => '工单状态变更'
|
|
|
- ]);
|
|
|
- Db::commit();
|
|
|
+ $sql = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
|
|
|
+ $res = Db::query($sql);
|
|
|
+ if ($res !== false){
|
|
|
$this->success('成功');
|
|
|
- } catch (\think\exception\HttpResponseException $e) {
|
|
|
- throw $e;
|
|
|
- } catch (\Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage() ?: '失败');
|
|
|
+ }else{
|
|
|
+ $this->error('失败');
|
|
|
}
|
|
|
}
|
|
|
|