|
@@ -63,7 +63,7 @@ class WorkOrderProcess extends Api
|
|
|
->order('part_code')
|
|
->order('part_code')
|
|
|
->select();
|
|
->select();
|
|
|
if(empty($list)){
|
|
if(empty($list)){
|
|
|
- $this->error('该工单没有部件,请先添加部件');
|
|
|
|
|
|
|
+ // $this->error('该工单没有部件,请先添加部件');
|
|
|
}
|
|
}
|
|
|
$this->success('成功', $list);
|
|
$this->success('成功', $list);
|
|
|
}
|
|
}
|
|
@@ -89,7 +89,7 @@ class WorkOrderProcess extends Api
|
|
|
if (empty($params['part_name'])) {
|
|
if (empty($params['part_name'])) {
|
|
|
$this->error('部件名称不能为空');
|
|
$this->error('部件名称不能为空');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查是否传入了part_code
|
|
// 检查是否传入了part_code
|
|
|
if (!empty($params['part_code'])) {
|
|
if (!empty($params['part_code'])) {
|
|
|
$code = $params['part_code'];
|
|
$code = $params['part_code'];
|
|
@@ -98,7 +98,7 @@ class WorkOrderProcess extends Api
|
|
|
->where('work_order', $params['workorder'])
|
|
->where('work_order', $params['workorder'])
|
|
|
->where('part_code', '>=', $code)
|
|
->where('part_code', '>=', $code)
|
|
|
->count();
|
|
->count();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($exists > 0) {
|
|
if ($exists > 0) {
|
|
|
// 如果存在冲突,将后续编号自动加1
|
|
// 如果存在冲突,将后续编号自动加1
|
|
|
db('工单_部件资料')
|
|
db('工单_部件资料')
|
|
@@ -113,7 +113,7 @@ class WorkOrderProcess extends Api
|
|
|
->max('part_code');
|
|
->max('part_code');
|
|
|
$code = $code ? $code + 1 : 1;
|
|
$code = $code ? $code + 1 : 1;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$data = [
|
|
$data = [
|
|
|
'work_order' => $params['workorder'],
|
|
'work_order' => $params['workorder'],
|
|
|
'part_code' => $code,
|
|
'part_code' => $code,
|
|
@@ -209,39 +209,39 @@ class WorkOrderProcess extends Api
|
|
|
if (!$this->request->isPost()) {
|
|
if (!$this->request->isPost()) {
|
|
|
$this->error('请求方法错误');
|
|
$this->error('请求方法错误');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$params = $this->request->post();
|
|
$params = $this->request->post();
|
|
|
if (empty($params['id'])) {
|
|
if (empty($params['id'])) {
|
|
|
$this->error('部件ID不能为空');
|
|
$this->error('部件ID不能为空');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$ids = explode(',', $params['id']);
|
|
$ids = explode(',', $params['id']);
|
|
|
$ids = array_filter(array_map('intval', $ids));
|
|
$ids = array_filter(array_map('intval', $ids));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (empty($ids)) {
|
|
if (empty($ids)) {
|
|
|
$this->error('无效的部件ID');
|
|
$this->error('无效的部件ID');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = db('工单_部件资料')
|
|
$result = db('工单_部件资料')
|
|
|
->whereIn('id', $ids)
|
|
->whereIn('id', $ids)
|
|
|
->whereNull('del_rq')
|
|
->whereNull('del_rq')
|
|
|
->update(['del_rq' => date('Y-m-d H:i:s')]);
|
|
->update(['del_rq' => date('Y-m-d H:i:s')]);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($result === false) {
|
|
if ($result === false) {
|
|
|
$this->error('删除失败');
|
|
$this->error('删除失败');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($result === 0) {
|
|
if ($result === 0) {
|
|
|
$this->error('未找到可删除的部件');
|
|
$this->error('未找到可删除的部件');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$this->success('删除成功');
|
|
$this->success('删除成功');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 工单工艺列表
|
|
* 工单工艺列表
|
|
|
- * @param workorder 工单编号
|
|
|
|
|
|
|
+ * @param workorder 工单编号
|
|
|
*/
|
|
*/
|
|
|
public function GetProcessList()
|
|
public function GetProcessList()
|
|
|
{
|
|
{
|
|
@@ -252,22 +252,32 @@ class WorkOrderProcess extends Api
|
|
|
if (empty($params['workorder'])) {
|
|
if (empty($params['workorder'])) {
|
|
|
$this->error('工单编号不能为空');
|
|
$this->error('工单编号不能为空');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
$list = db('工单_基础工艺资料')
|
|
$list = db('工单_基础工艺资料')
|
|
|
->alias('a')
|
|
->alias('a')
|
|
|
- ->join('工单_部件资料 b', 'a.part_code = b.part_code and a.work_order = b.work_order')
|
|
|
|
|
|
|
+ ->join('工单_部件资料 b', 'a.part_code = b.part_code and a.work_order = b.work_order', 'LEFT')
|
|
|
->where('a.del_rq', null)
|
|
->where('a.del_rq', null)
|
|
|
->where('a.work_order', $params['workorder'])
|
|
->where('a.work_order', $params['workorder'])
|
|
|
->where('b.del_rq', null)
|
|
->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_score 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')
|
|
|
|
|
|
|
+ ->field('a.id,a.part_code as 部件编号,
|
|
|
|
|
+ IFNULL(b.part_name, "") as 部件名称,
|
|
|
|
|
+ a.process_code as 工艺编号,
|
|
|
|
|
+ a.process_name as 工艺名称,
|
|
|
|
|
+ a.big_process as 大工艺,
|
|
|
|
|
+ a.standard_hour as 标准工时,
|
|
|
|
|
+ a.standard_score as 标准公分,
|
|
|
|
|
+ a.remark as 备注,
|
|
|
|
|
+ a.coefficient as 系数,
|
|
|
|
|
+ a.sys_id as 系统人,
|
|
|
|
|
+ a.sys_rq as 系统时间,
|
|
|
|
|
+ a.mod_id as 修改人,
|
|
|
|
|
+ a.mod_rq as 修改时间')
|
|
|
|
|
+ ->order('a.id')
|
|
|
->select();
|
|
->select();
|
|
|
|
|
+
|
|
|
$this->success('成功', $list);
|
|
$this->success('成功', $list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取部件列表
|
|
* 获取部件列表
|
|
|
* @param workorder 工单编号
|
|
* @param workorder 工单编号
|
|
@@ -281,7 +291,7 @@ class WorkOrderProcess extends Api
|
|
|
if (empty($params['workorder'])) {
|
|
if (empty($params['workorder'])) {
|
|
|
$this->error('工单编号不能为空');
|
|
$this->error('工单编号不能为空');
|
|
|
}
|
|
}
|
|
|
- $list = db('工单_部件资料')
|
|
|
|
|
|
|
+ $list = db('工单_部件资料')
|
|
|
->where('work_order', $params['workorder'])
|
|
->where('work_order', $params['workorder'])
|
|
|
->where('del_rq', null)
|
|
->where('del_rq', null)
|
|
|
->field('part_code as 部件编号,part_name as 部件名称')
|
|
->field('part_code as 部件编号,part_name as 部件名称')
|
|
@@ -336,7 +346,7 @@ class WorkOrderProcess extends Api
|
|
|
if (empty($params['sys_id'])) {
|
|
if (empty($params['sys_id'])) {
|
|
|
$this->error('系统人不能为空');
|
|
$this->error('系统人不能为空');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查是否传入了process_code
|
|
// 检查是否传入了process_code
|
|
|
if (!empty($params['process_code'])) {
|
|
if (!empty($params['process_code'])) {
|
|
|
$code = $params['process_code'];
|
|
$code = $params['process_code'];
|
|
@@ -346,7 +356,7 @@ class WorkOrderProcess extends Api
|
|
|
->where('part_code', $params['part_code'])
|
|
->where('part_code', $params['part_code'])
|
|
|
->where('process_code', '>=', $code)
|
|
->where('process_code', '>=', $code)
|
|
|
->count();
|
|
->count();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($exists > 0) {
|
|
if ($exists > 0) {
|
|
|
// 如果存在冲突,将后续编号自动加1
|
|
// 如果存在冲突,将后续编号自动加1
|
|
|
db('工单_基础工艺资料')
|
|
db('工单_基础工艺资料')
|
|
@@ -363,7 +373,7 @@ class WorkOrderProcess extends Api
|
|
|
->max('process_code');
|
|
->max('process_code');
|
|
|
$code = $code ? $code + 1 : 1;
|
|
$code = $code ? $code + 1 : 1;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$data = [
|
|
$data = [
|
|
|
'work_order' => $params['workorder'],
|
|
'work_order' => $params['workorder'],
|
|
|
'part_code' => $params['part_code'],
|
|
'part_code' => $params['part_code'],
|
|
@@ -484,8 +494,8 @@ class WorkOrderProcess extends Api
|
|
|
/**
|
|
/**
|
|
|
* 工单工艺复制
|
|
* 工单工艺复制
|
|
|
* @param workorder 工单编号
|
|
* @param workorder 工单编号
|
|
|
- * @param product_code 产品编号
|
|
|
|
|
- * @param sys_id 操作人
|
|
|
|
|
|
|
+ * @param product_code 产品编号
|
|
|
|
|
+ * @param sys_id 操作人
|
|
|
* @return array
|
|
* @return array
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
@@ -664,12 +674,12 @@ class WorkOrderProcess extends Api
|
|
|
|
|
|
|
|
$this->success('排序成功');
|
|
$this->success('排序成功');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 工单工艺excel导入
|
|
* 工单工艺excel导入
|
|
|
* @param workorder 工单编号
|
|
* @param workorder 工单编号
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
*/
|
|
*/
|
|
|
public function importProcess()
|
|
public function importProcess()
|
|
|
{
|
|
{
|