unknown 1 день назад
Родитель
Сommit
f94cd0314e
2 измененных файлов с 34 добавлено и 26 удалено
  1. 0 15
      application/api/controller/Index.php
  2. 34 11
      application/api/controller/Manufacture.php

+ 0 - 15
application/api/controller/Index.php

@@ -19,21 +19,6 @@ class Index extends Api
      */
     public function index()
     {
-        $serve = new SalaryCalculationService();
-        $data = $serve->calculateSalary([
-            'date' => '202512',
-            'start_date'=> '2025-12-01',
-            'end_date'=>'2025-12-31',
-            'sys_id'=> '950509_邱恩光',
-            'vacation_one_start'=> '',
-            'vacation_one_end'=> '',
-            'vacation_two_start'=> '',
-            'vacation_two_end'=> '',
-            'user_id'=> 0,
-            'user_name'=> '系统',
-            'request_time'=> '2026-01-27 18:03:44'
-        ]);
-        halt($data);
         $this->success('请求成功');
     }
 

+ 34 - 11
application/api/controller/Manufacture.php

@@ -354,29 +354,52 @@ class Manufacture extends Api
 
     /**
      * 工单状态设置
-     * @ApiMethod (GET)
+     * @ApiMethod (POST)
      * @param string $workOrder  工单编号
-     * @param string $status   工单状态
+     * @param string $status    工单状态
+     * @param string $sys_id    操作用户(可选)
      * @return void
      * @throws \think\Exception
      * @throws \think\exception\PDOException
      */
     public function StatusEdit()
     {
-        if (Request::instance()->isPost() === false){
+        if ($this->request->isPost() === false) {
             $this->error('请求错误');
         }
-        $workOrder = input('workOrder');
-        $status = input('status');
-        if (empty($workOrder) || empty($status)){
+        $param = $this->request->param();
+        $workOrder = $param['workOrder'] ?? input('workOrder');
+        $status = $param['status'] ?? input('status');
+        if (empty($workOrder) || empty($status)) {
             $this->error('参数错误');
         }
-        $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){
+        $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();
             $this->success('成功');
-        }else{
-            $this->error('失败');
+        } catch (\think\exception\HttpResponseException $e) {
+            throw $e;
+        } catch (\Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage() ?: '失败');
         }
     }