|
|
@@ -611,4 +611,57 @@ class WorkOrderProcess extends Api
|
|
|
}
|
|
|
$this->success('成功', $list);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工单工艺排序
|
|
|
+ * @param workorder 工单编号
|
|
|
+ * @param part_code 部件编号
|
|
|
+ * @param process_code 工艺编号
|
|
|
+ * @param process_name 工艺名称
|
|
|
+ * @param big_process 大工艺
|
|
|
+ * @param standard_hour 标准工时
|
|
|
+ * @param standard_score 标准公分
|
|
|
+ * @param coefficient 系数
|
|
|
+ * @param remark 备注
|
|
|
+ */
|
|
|
+ public function sortProcess()
|
|
|
+ {
|
|
|
+ if (!$this->request->isPost()) {
|
|
|
+ $this->error('请求方法错误');
|
|
|
+ }
|
|
|
+ $params = $this->request->post();
|
|
|
+ if (empty($params)) {
|
|
|
+ $this->error('参数不能为空');
|
|
|
+ }
|
|
|
+ if (!is_array($params)) {
|
|
|
+ $this->error('参数格式错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ foreach ($params as $value) {
|
|
|
+ if (empty($value['id'])) {
|
|
|
+ throw new \Exception('缺少工艺ID');
|
|
|
+ }
|
|
|
+ if (!isset($value['process_code']) || $value['process_code'] === '') {
|
|
|
+ throw new \Exception('缺少工艺编号');
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = db('工单_基础工艺资料')
|
|
|
+ ->where('id', intval($value['id']))
|
|
|
+ ->whereNull('del_rq')
|
|
|
+ ->update(['process_code' => intval($value['process_code'])]);
|
|
|
+ if ($result === false) {
|
|
|
+ throw new \Exception('排序失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('排序成功');
|
|
|
+ }
|
|
|
+
|
|
|
}
|