|
@@ -23,7 +23,6 @@ use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class ItemService extends Service
|
|
class ItemService extends Service
|
|
|
{
|
|
{
|
|
|
- // 项目 任务 节点 都可以用的 文件上传 文件删除 更改交付物状态
|
|
|
|
|
public function itemFileUpLoad($data,$user){
|
|
public function itemFileUpLoad($data,$user){
|
|
|
// 1. 基础校验
|
|
// 1. 基础校验
|
|
|
$from = $data['from'] ?? null;
|
|
$from = $data['from'] ?? null;
|
|
@@ -64,6 +63,7 @@ class ItemService extends Service
|
|
|
$file['item_node_id'] = $itemNodeId;
|
|
$file['item_node_id'] = $itemNodeId;
|
|
|
$file['item_node_mission_id'] = $missionId;
|
|
$file['item_node_mission_id'] = $missionId;
|
|
|
$file['crt_time'] = $time;
|
|
$file['crt_time'] = $time;
|
|
|
|
|
+ $file['crt_id'] = $user['id'];
|
|
|
|
|
|
|
|
$pendingTasks[] = ['type' => SysOssTasks::type_two, 'url' => $file['url'], 'top_depart_id' => $user['top_depart_id'], 'crt_time' => $time];
|
|
$pendingTasks[] = ['type' => SysOssTasks::type_two, 'url' => $file['url'], 'top_depart_id' => $user['top_depart_id'], 'crt_time' => $time];
|
|
|
}
|
|
}
|
|
@@ -190,9 +190,29 @@ class ItemService extends Service
|
|
|
|
|
|
|
|
return [true, ''];
|
|
return [true, ''];
|
|
|
}
|
|
}
|
|
|
- // 项目 任务 节点 都可以用的 文件上传 文件删除 更改交付物状态
|
|
|
|
|
|
|
|
|
|
|
|
+ public function itemFinish($data, $user){
|
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
|
+ $item = Item::where('id',$data['id'])
|
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(empty($item)) return [false, '项目不存在或已被删除'];
|
|
|
|
|
+ if($item->state == Item::TYPE_THREE) return [false, '项目已完成,请勿重复操作'];
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
|
|
|
|
|
+ $item->state = Item::TYPE_THREE;
|
|
|
|
|
+ $item->save();
|
|
|
|
|
+
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ }catch (\Exception $exception){
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ return [false,$exception->getMessage()];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true, ''];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public function itemEdit($data,$user){
|
|
public function itemEdit($data,$user){
|
|
|
list($status,$msg) = $this->itemRule($data, $user, false);
|
|
list($status,$msg) = $this->itemRule($data, $user, false);
|
|
@@ -491,23 +511,33 @@ class ItemService extends Service
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getNodeFile($data,$user, $item){
|
|
public function getNodeFile($data,$user, $item){
|
|
|
|
|
+ $file = ItemFile::where('del_time',0)
|
|
|
|
|
+ ->where('item_id', $data['id'])
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $employee_id = array_unique(array_merge_recursive(array_column($file,'crt_id'), array_column($item['custom_fields'],'crt_id')));
|
|
|
|
|
+ $map = (new EmployeeService())->getEmployeeMap($employee_id);
|
|
|
|
|
+
|
|
|
$return = [];
|
|
$return = [];
|
|
|
if(! empty($item['custom_fields'])){
|
|
if(! empty($item['custom_fields'])){
|
|
|
foreach ($item['custom_fields'] as $value){
|
|
foreach ($item['custom_fields'] as $value){
|
|
|
- $return[] = [
|
|
|
|
|
- 'id' => $value['id'],
|
|
|
|
|
- 'url' => $value['field_value'],
|
|
|
|
|
- 'name' => $value['field_name'],
|
|
|
|
|
- 'show_url' => $value['field_value_show'],
|
|
|
|
|
- 'type_name' => '项目',
|
|
|
|
|
- 'type_name_2' => CustomFieldValue::type[CustomFieldValue::type_two],
|
|
|
|
|
- 'type' => 'custom_fields',
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ if($value['field_type'] == CustomFieldValue::type_two){
|
|
|
|
|
+ $return[] = [
|
|
|
|
|
+ 'id' => $value['id'],
|
|
|
|
|
+ 'url' => $value['field_value'],
|
|
|
|
|
+ 'name' => $value['field_name'],
|
|
|
|
|
+ 'show_url' => $value['field_value_show'],
|
|
|
|
|
+ 'type_name' => '项目',
|
|
|
|
|
+ 'type_name_2' => CustomFieldValue::type[CustomFieldValue::type_two],
|
|
|
|
|
+ 'type' => 'custom_fields',
|
|
|
|
|
+ 'from' => ItemFile::from_one,
|
|
|
|
|
+ 'crt_name' => $map[$value['crt_id']],
|
|
|
|
|
+ 'crt_id' => $value['crt_id'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $file = ItemFile::where('del_time',0)
|
|
|
|
|
- ->where('item_id', $data['id'])
|
|
|
|
|
- ->get()->toArray();
|
|
|
|
|
|
|
+
|
|
|
if(! empty($file)){
|
|
if(! empty($file)){
|
|
|
$fileUploadService = new FileUploadService();
|
|
$fileUploadService = new FileUploadService();
|
|
|
foreach ($file as $value){
|
|
foreach ($file as $value){
|
|
@@ -519,6 +549,9 @@ class ItemService extends Service
|
|
|
'type_name' => ItemFile::from[$value['from']],
|
|
'type_name' => ItemFile::from[$value['from']],
|
|
|
'type_name_2' => ItemFile::type[$value['type']],
|
|
'type_name_2' => ItemFile::type[$value['type']],
|
|
|
'type' => 'item_file',
|
|
'type' => 'item_file',
|
|
|
|
|
+ 'from' => $value['from'],
|
|
|
|
|
+ 'crt_name' => $map[$value['crt_id']],
|
|
|
|
|
+ 'crt_id' => $value['crt_id'],
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -758,6 +791,28 @@ class ItemService extends Service
|
|
|
return $res;
|
|
return $res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function itemNodeFinish($data, $user){
|
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
|
+ $item = ItemNode::where('id',$data['id'])
|
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(empty($item)) return [false, '项目节点不存在或已被删除'];
|
|
|
|
|
+ if($item->state == ItemNode::TYPE_THREE) return [false, '项目节点已完成,请勿重复操作'];
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+
|
|
|
|
|
+ $item->state = ItemNode::TYPE_THREE;
|
|
|
|
|
+ $item->save();
|
|
|
|
|
+
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ }catch (\Exception $exception){
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ return [false,$exception->getMessage()];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true, ''];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//项目节点
|
|
//项目节点
|
|
|
public function itemNodeEdit($data,$user){
|
|
public function itemNodeEdit($data,$user){
|
|
@@ -1010,6 +1065,99 @@ class ItemService extends Service
|
|
|
return [true, $customer];
|
|
return [true, $customer];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function itemNodeDetailBoard($data, $user){
|
|
|
|
|
+ list($status, $msg) = $this->itemNodeDetail($data, $user);
|
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
|
+ $customer = $msg;
|
|
|
|
|
+
|
|
|
|
|
+ //节点信息
|
|
|
|
|
+ $customer['mission_list'] = $this->itemMissionBoard($data, $user);
|
|
|
|
|
+
|
|
|
|
|
+ //文件归档
|
|
|
|
|
+ $customer['file_list'] = $this->getMissionFile($data, $user, $customer);
|
|
|
|
|
+
|
|
|
|
|
+ return [true, $customer];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function itemMissionBoard($data,$user){
|
|
|
|
|
+ $model = ItemNodeMission::TopAndEmployeeClear($user, $data);
|
|
|
|
|
+ $list = $model->where('del_time',0)
|
|
|
|
|
+ ->where('item_node_id', $data['id'])
|
|
|
|
|
+ ->select('*')
|
|
|
|
|
+ ->orderby('upd_time', 'desc')
|
|
|
|
|
+ ->orderby('id', 'desc')
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $emp = (new EmployeeService())->getEmployeeMap(array_unique(array_merge_recursive(array_column($list,'charge_id'), array_column($list,'crt_id'))));
|
|
|
|
|
+ $tag = (new TagService())->getTagMap(array_unique(array_merge_recursive(array_column($list,'priority_id'),array_column($list,'mission_id'))));
|
|
|
|
|
+ foreach ($list as $key => $value){
|
|
|
|
|
+ $list[$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
|
|
+ $list[$key]['start_time'] = $value['start_time'] ? date('Y-m-d',$value['start_time']) : '';
|
|
|
|
|
+ $list[$key]['end_time'] = $value['end_time'] ? date('Y-m-d',$value['end_time']) : '';
|
|
|
|
|
+ $list[$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
|
|
|
|
|
+ $list[$key]['charge_name'] = $emp[$value['charge_id']] ?? '';
|
|
|
|
|
+ $list[$key]['state_title'] = ItemNodeMission::State_Type[$value['state']] ?? "";
|
|
|
|
|
+ $priority_tmp = $tag[$value['priority_id']] ?? [];
|
|
|
|
|
+ $list[$key]['priority_title'] = $priority_tmp['title'] ?? '';
|
|
|
|
|
+ $list[$key]['priority_code'] = $priority_tmp['code'] ?? '';
|
|
|
|
|
+ $node_tmp = $tag[$value['mission_id']] ?? [];
|
|
|
|
|
+ $list[$key]['mission_title'] = $node_tmp['title'] ?? '';
|
|
|
|
|
+ $list[$key]['mission_code'] = $node_tmp['code'] ?? '';
|
|
|
|
|
+ $list[$key]['progress'] = rand(1, 100); //todo
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getMissionFile($data, $user, $item){
|
|
|
|
|
+ $file = ItemFile::where('del_time',0)
|
|
|
|
|
+ ->where('item_node_id', $data['id'])
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $employee_id = array_unique(array_merge_recursive(array_column($file,'crt_id'), array_column($item['custom_fields'],'crt_id')));
|
|
|
|
|
+ $map = (new EmployeeService())->getEmployeeMap($employee_id);
|
|
|
|
|
+
|
|
|
|
|
+ $return = [];
|
|
|
|
|
+ if(! empty($item['custom_fields'])){
|
|
|
|
|
+ foreach ($item['custom_fields'] as $value){
|
|
|
|
|
+ if($value['field_type'] == CustomFieldValue::type_two){
|
|
|
|
|
+ $return[] = [
|
|
|
|
|
+ 'id' => $value['id'],
|
|
|
|
|
+ 'url' => $value['field_value'],
|
|
|
|
|
+ 'name' => $value['field_name'],
|
|
|
|
|
+ 'show_url' => $value['field_value_show'],
|
|
|
|
|
+ 'type_name' => '节点',
|
|
|
|
|
+ 'type_name_2' => CustomFieldValue::type[CustomFieldValue::type_two],
|
|
|
|
|
+ 'type' => 'custom_fields',
|
|
|
|
|
+ 'from' => ItemFile::type_two,
|
|
|
|
|
+ 'crt_name' => $map[$value['crt_id']],
|
|
|
|
|
+ 'crt_id' => $value['crt_id'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(! empty($file)){
|
|
|
|
|
+ $fileUploadService = new FileUploadService();
|
|
|
|
|
+ foreach ($file as $value){
|
|
|
|
|
+ $return[] = [
|
|
|
|
|
+ 'id' => $value['id'],
|
|
|
|
|
+ 'url' => $value['url'],
|
|
|
|
|
+ 'name' => $value['name'],
|
|
|
|
|
+ 'show_url' => $fileUploadService->getFileShow($value['url']),
|
|
|
|
|
+ 'type_name' => ItemFile::from[$value['from']],
|
|
|
|
|
+ 'type_name_2' => ItemFile::type[$value['type']],
|
|
|
|
|
+ 'type' => 'item_file',
|
|
|
|
|
+ 'from' => $value['from'],
|
|
|
|
|
+ 'crt_name' => $map[$value['crt_id']],
|
|
|
|
|
+ 'crt_id' => $value['crt_id'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function itemNodeCommon($data,$user, $field = []){
|
|
public function itemNodeCommon($data,$user, $field = []){
|
|
|
if(empty($field)) $field = ItemNode::$field;
|
|
if(empty($field)) $field = ItemNode::$field;
|
|
|
|
|
|
|
@@ -1128,6 +1276,28 @@ class ItemService extends Service
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function itemNodeMissionFinish($data, $user){
|
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
|
+ $item = ItemNodeMission::where('id',$data['id'])
|
|
|
|
|
+ ->where('del_time',0)
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(empty($item)) return [false, '节点任务不存在或已被删除'];
|
|
|
|
|
+ if($item->state == ItemNodeMission::TYPE_THREE) return [false, '节点任务已完成,请勿重复操作'];
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+
|
|
|
|
|
+ $item->state = ItemNodeMission::TYPE_THREE;
|
|
|
|
|
+ $item->save();
|
|
|
|
|
+
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ }catch (\Exception $exception){
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ return [false,$exception->getMessage()];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true, ''];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//项目节点任务
|
|
//项目节点任务
|
|
|
public function itemNodeMissionEdit($data,$user){
|
|
public function itemNodeMissionEdit($data,$user){
|