|
@@ -278,6 +278,33 @@ class WorkOrderProcess extends Api
|
|
|
$this->success('成功', $list);
|
|
$this->success('成功', $list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 工单工艺列表
|
|
|
|
|
+ * @param workorder 工单编号
|
|
|
|
|
+ */
|
|
|
|
|
+ // public function GetProcessList()
|
|
|
|
|
+ // {
|
|
|
|
|
+ // if (!$this->request->isGet()) {
|
|
|
|
|
+ // $this->error('请求方法错误');
|
|
|
|
|
+ // }
|
|
|
|
|
+ // $params = $this->request->param();
|
|
|
|
|
+ // if (empty($params['workorder'])) {
|
|
|
|
|
+ // $this->error('工单编号不能为空');
|
|
|
|
|
+ // }
|
|
|
|
|
+ // $list = db('工单_基础工艺资料')
|
|
|
|
|
+ // ->alias('a')
|
|
|
|
|
+ // ->join('工单_部件资料 b', 'a.part_code = b.part_code and a.work_order = b.work_order')
|
|
|
|
|
+ // ->where('a.del_rq', null)
|
|
|
|
|
+ // ->where('a.work_order', $params['workorder'])
|
|
|
|
|
+ // ->where('b.del_rq', null)
|
|
|
|
|
+ // ->field('a.id,a.part_code as 部件编号,b.part_name as 部件名称,a.process_code as 序号,
|
|
|
|
|
+ // a.process_name as 工序名称,a.big_process as 大工艺,a.standard_hour as 秒,a.standard_minutes as 分钟,
|
|
|
|
|
+ // a.standard_score as 标准公分,a.money as 金额,a.remark as 备注,a.coefficient as 难度系数,a.sys_id as 操作人员,
|
|
|
|
|
+ // a.sys_rq as 系统时间,a.mod_id as 修改人,a.mod_rq as 修改时间')
|
|
|
|
|
+ // ->order('process_code')
|
|
|
|
|
+ // ->select();
|
|
|
|
|
+ // $this->success('成功', $list);
|
|
|
|
|
+ // }
|
|
|
/**
|
|
/**
|
|
|
* 获取部件列表
|
|
* 获取部件列表
|
|
|
* @param workorder 工单编号
|
|
* @param workorder 工单编号
|
|
@@ -855,4 +882,151 @@ class WorkOrderProcess extends Api
|
|
|
}
|
|
}
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取工单信息和工单制造工分
|
|
|
|
|
+ * @param workorder 工单编号
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getWorkOrderInfo()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
|
|
+ $this->error('请求方法错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->request->param();
|
|
|
|
|
+ if (empty($params['workorder'])) {
|
|
|
|
|
+ $this->error('工单编号不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ '订单编号' => $params['workorder'],
|
|
|
|
|
+ 'Mod_rq' => null,
|
|
|
|
|
+ ];
|
|
|
|
|
+ $workOrderInfo = Db::table('工单_基本资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field('订单编号,客户编号,生产款号,款式,落货日期,审核日期,接单日期,审核,订单数量,计划制造工分')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ if (empty($workOrderInfo)) {
|
|
|
|
|
+ $this->error('工单不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功', $workOrderInfo);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取工单工艺信息
|
|
|
|
|
+ * @param workorder 工单编号
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
+ * @throws \think\exception\DbException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getWorkOrderProcess()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$this->request->isGet()) {
|
|
|
|
|
+ $this->error('请求方法错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->request->param();
|
|
|
|
|
+ if (empty($params['workorder'])) {
|
|
|
|
|
+ $this->error('工单编号不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+ $where = [
|
|
|
|
|
+ 'work_order' => $params['workorder'],
|
|
|
|
|
+ 'del_rq' => null,
|
|
|
|
|
+ ];
|
|
|
|
|
+ $workOrderProcess = Db::table('工单_基础工艺资料')
|
|
|
|
|
+ ->where($where)
|
|
|
|
|
+ ->field('id,part_code as 部件编号,part_name as 部件名称,process_code as 工序编号,process_name as 工序名称,
|
|
|
|
|
+ big_process as 大工序,standard_hour as 秒,standard_minutes as 分,standard_score as 定额分,money as 金额,
|
|
|
|
|
+ coefficient as 难度系数,remark as 备注,status as 状态')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+ if (empty($workOrderProcess)) {
|
|
|
|
|
+ $this->error('工单工艺不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('成功', $workOrderProcess);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改工单计划制造工分
|
|
|
|
|
+ * @param id 工单Uniqid或订单编号
|
|
|
|
|
+ * @param number 计划制造工分
|
|
|
|
|
+ * @param sys_id 操作人
|
|
|
|
|
+ */
|
|
|
|
|
+ public function updateWorkOrderPlanManufacture()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$this->request->isPost()) {
|
|
|
|
|
+ $this->error('请求方法错误');
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = $this->request->post();
|
|
|
|
|
+ if (empty($params['id'])) {
|
|
|
|
|
+ $this->error('工单ID不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($params['number']) || $params['number'] === '') {
|
|
|
|
|
+ $this->error('制造工分不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($params['sys_id'])) {
|
|
|
|
|
+ $this->error('操作人不能为空');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $workOrder = Db::table('工单_基本资料')
|
|
|
|
|
+ ->where('Uniqid', $params['id'])
|
|
|
|
|
+ ->where('Mod_rq', null)
|
|
|
|
|
+ ->field('Uniqid,订单编号,计划制造工分')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ if (empty($workOrder)) {
|
|
|
|
|
+ $workOrder = Db::table('工单_基本资料')
|
|
|
|
|
+ ->where('订单编号', $params['id'])
|
|
|
|
|
+ ->where('Mod_rq', null)
|
|
|
|
|
+ ->field('Uniqid,订单编号,计划制造工分')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($workOrder)) {
|
|
|
|
|
+ $this->error('工单不存在');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $oldValue = $workOrder['计划制造工分'];
|
|
|
|
|
+ $newValue = $params['number'];
|
|
|
|
|
+ if ((string)$oldValue === (string)$newValue) {
|
|
|
|
|
+ $this->error('计划制造工分未发生变化');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $operTime = date('Y-m-d H:i:s');
|
|
|
|
|
+ $logData = [
|
|
|
|
|
+ 'order_no' => $workOrder['订单编号'],
|
|
|
|
|
+ 'change_field' => '计划制造工分',
|
|
|
|
|
+ 'old_value' => $oldValue === null ? '' : (string)$oldValue,
|
|
|
|
|
+ 'new_value' => (string)$newValue,
|
|
|
|
|
+ 'oper_type' => '修改工单计划制造工分',
|
|
|
|
|
+ 'oper_user_name' => $params['sys_id'],
|
|
|
|
|
+ 'oper_time' => $operTime,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ Db::startTrans();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $updateResultSql = Db::table('工单_基本资料')
|
|
|
|
|
+ ->where('Uniqid', $workOrder['Uniqid'])
|
|
|
|
|
+ ->fetchSql(true)
|
|
|
|
|
+ ->update(['计划制造工分' => $newValue]);
|
|
|
|
|
+ $updateResult = Db::query($updateResultSql);
|
|
|
|
|
+ if ($updateResult === false) {
|
|
|
|
|
+ throw new \Exception('更新工单失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ $logResult = Db::name('work_order_operation_log')->insert($logData);
|
|
|
|
|
+ if ($logResult === false) {
|
|
|
|
|
+ throw new \Exception('写入操作日志失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ Db::commit();
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ Db::rollback();
|
|
|
|
|
+ $this->error('修改失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('修改成功');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|