|
@@ -26,9 +26,9 @@ use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class ItemService extends Service
|
|
class ItemService extends Service
|
|
|
{
|
|
{
|
|
|
- public function itemGannetCommon($data,$user, $field = []){
|
|
|
|
|
|
|
+ public function itemGannetCommon($data,$user){
|
|
|
if(empty($data['time'][0]) || empty($data['time'][1])) return [false, '请选择开始与结束时间'];
|
|
if(empty($data['time'][0]) || empty($data['time'][1])) return [false, '请选择开始与结束时间'];
|
|
|
- $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|
|
|
|
|
|
|
+ $return = $this->changeDateToTimeStampAboutRange($data['time']);
|
|
|
$start = $return[0];
|
|
$start = $return[0];
|
|
|
$end = $return[1];
|
|
$end = $return[1];
|
|
|
$oneYearLater = strtotime('+1 year', $start);
|
|
$oneYearLater = strtotime('+1 year', $start);
|
|
@@ -38,40 +38,82 @@ class ItemService extends Service
|
|
|
'item_node' => ItemNode::class,
|
|
'item_node' => ItemNode::class,
|
|
|
'item_node_mission' => ItemNodeMission::class,
|
|
'item_node_mission' => ItemNodeMission::class,
|
|
|
];
|
|
];
|
|
|
|
|
+ $field = [
|
|
|
|
|
+ 'item' => ['id','code', 'title', 'start_time', 'end_time', 'charge_id', 'state', 'crt_id'],
|
|
|
|
|
+ 'item_node' => ['id','code', 'title', 'start_time', 'end_time', 'charge_id', 'state', 'crt_id'],
|
|
|
|
|
+ 'item_node_mission' => ['id','code', 'title', 'start_time', 'end_time', 'charge_id', 'state', 'progress', 'crt_id'],
|
|
|
|
|
+ ];
|
|
|
if (empty($data['type']) && ! isset($type[$data['type']])) return [false , '类型错误'];
|
|
if (empty($data['type']) && ! isset($type[$data['type']])) return [false , '类型错误'];
|
|
|
$class = $type[$data['type']];
|
|
$class = $type[$data['type']];
|
|
|
|
|
+ $select = $field[$data['type']];
|
|
|
$model = $class::TopAndEmployeeClear($user,$data);
|
|
$model = $class::TopAndEmployeeClear($user,$data);
|
|
|
-
|
|
|
|
|
- $model = ItemNodeMission::TopAndEmployeeClear($user,$data);
|
|
|
|
|
$model = $model->where('del_time',0)
|
|
$model = $model->where('del_time',0)
|
|
|
-// ->when(! empty($item_id),function ($query) use($item_id){
|
|
|
|
|
-// return $query->where('item_id', $item_id);
|
|
|
|
|
-// })
|
|
|
|
|
-// ->when(! empty($item_node_id),function ($query) use($item_node_id){
|
|
|
|
|
-// return $query->where('item_node_id', $item_node_id);
|
|
|
|
|
-// })
|
|
|
|
|
- ->select($field)
|
|
|
|
|
|
|
+ ->where('start_time', ">=" , $start)
|
|
|
|
|
+ ->where('end_time', ">=" , $start)
|
|
|
|
|
+ ->select($select)
|
|
|
->orderby('id', 'desc');
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
|
|
|
|
|
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
|
|
if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
|
|
|
- if(! empty($data['id'])) $model->whereIn('id', $data['id']);
|
|
|
|
|
if(isset($data['state'])) $model->where('state', $data['state']);
|
|
if(isset($data['state'])) $model->where('state', $data['state']);
|
|
|
- if(isset($data['approval_state'])) $model->where('approval_state', $data['approval_state']);
|
|
|
|
|
- if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
|
|
|
|
|
- $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|
|
|
|
|
- $model->where('crt_time','>=',$return[0]);
|
|
|
|
|
- $model->where('crt_time','<=',$return[1]);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
return $model;
|
|
return $model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function itemGannetCommon1($data,$user){
|
|
|
|
|
- $model = $this->itemNodeMissionCommon($data, $user);
|
|
|
|
|
- $list = $this->limit($model,'',$data);
|
|
|
|
|
- $list = $this->fillNodeMissionData($list);
|
|
|
|
|
|
|
+ public function itemGannetList($data,$user){
|
|
|
|
|
+ $model = $this->itemGannetCommon($data, $user);
|
|
|
|
|
+ $list = $model->get()->toArray();
|
|
|
|
|
+ $list = $this->fillItemGannetList($list);
|
|
|
|
|
+
|
|
|
|
|
+ return [true, $list];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function fillItemGannetList($data){
|
|
|
|
|
+ if(empty($data)) return $data;
|
|
|
|
|
+
|
|
|
|
|
+ $emp = (new EmployeeService())->getEmployeeMap(array_unique(array_merge_recursive(array_column($data,'charge_id'), array_column($data,'crt_id'))));
|
|
|
|
|
+ foreach ($data as $key => $value){
|
|
|
|
|
+ $data[$key]['start_time'] = $value['start_time'] ? date('Y-m-d',$value['start_time']) : '';
|
|
|
|
|
+ $data[$key]['end_time'] = $value['end_time'] ? date('Y-m-d',$value['end_time']) : '';
|
|
|
|
|
+ $data[$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
|
|
|
|
|
+ $data[$key]['charge_name'] = $emp[$value['charge_id']] ?? '';
|
|
|
|
|
+ $data[$key]['state_title'] = ItemNodeMission::State_Type[$value['state']] ?? "";
|
|
|
|
|
+ if(! isset($value['progress'])) $data[$key]['progress'] = rand(1,100); // todo
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function itemGannetGetSonData($data,$user){
|
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
|
+ $type = [
|
|
|
|
|
+ 'item' => ItemNode::class,
|
|
|
|
|
+ 'item_node' => ItemNodeMission::class,
|
|
|
|
|
+ 'item_node_mission' => ItemNodeMission::class,
|
|
|
|
|
+ ];
|
|
|
|
|
+ $field = [
|
|
|
|
|
+ 'item' => ['id','code', 'title', 'start_time', 'end_time', 'charge_id', 'state', 'crt_id'],
|
|
|
|
|
+ 'item_node' => ['id','code', 'title', 'start_time', 'end_time', 'charge_id', 'state', 'crt_id'],
|
|
|
|
|
+ 'item_node_mission' => ['id','code', 'title', 'start_time', 'end_time', 'charge_id', 'state', 'progress', 'crt_id'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $search = [
|
|
|
|
|
+ 'item' => "(id = {$data['id']})",
|
|
|
|
|
+ 'item_node' => "(id = {$data['id']})",
|
|
|
|
|
+ 'item_node_mission' => "(parent_item_node_mission_id = {$data['id']})",
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (empty($data['type']) && ! isset($type[$data['type']])) return [false , '类型错误'];
|
|
|
|
|
+ $class = $type[$data['type']];
|
|
|
|
|
+ $select = $field[$data['type']];
|
|
|
|
|
+ $whereRaw = $search[$data['type']];
|
|
|
|
|
+ $model = $class::TopAndEmployeeClear($user,$data);
|
|
|
|
|
+ $list = $model->where('del_time',0)
|
|
|
|
|
+ ->whereRaw($whereRaw)
|
|
|
|
|
+ ->select($select)
|
|
|
|
|
+ ->orderby('id', 'desc')
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $list = $this->fillItemGannetList($list);
|
|
|
|
|
|
|
|
return [true, $list];
|
|
return [true, $list];
|
|
|
}
|
|
}
|
|
@@ -206,7 +248,7 @@ class ItemService extends Service
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
if (empty($data['opt_type']) || !isset($typeMap[$data['opt_type']])) return [false, '操作标识错误'];
|
|
if (empty($data['opt_type']) || !isset($typeMap[$data['opt_type']])) return [false, '操作标识错误'];
|
|
|
- if (empty($data['data']) || !is_array($data['data'])) return [false, '文件数据不能为空'];
|
|
|
|
|
|
|
+ if (empty($data) || !is_array($data['data'])) return [false, '文件数据不能为空'];
|
|
|
|
|
|
|
|
// 状态值映射
|
|
// 状态值映射
|
|
|
$statusValue = ($data['opt_type'] == 1) ? 1 : 0;
|
|
$statusValue = ($data['opt_type'] == 1) ? 1 : 0;
|