109 lines
3.5 KiB
PHP
109 lines
3.5 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
namespace app\api\controller;
|
|||
|
|
|
|||
|
|
use think\Config;
|
|||
|
|
use think\Controller;
|
|||
|
|
use think\Db;
|
|||
|
|
use think\Log;
|
|||
|
|
use think\Model;
|
|||
|
|
use think\Request;
|
|||
|
|
use think\cache\driver\Memcache;
|
|||
|
|
|
|||
|
|
|
|||
|
|
header("Access-Control-Allow-Origin:*");
|
|||
|
|
header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
|
|||
|
|
header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
|
|||
|
|
|
|||
|
|
|
|||
|
|
class Operation extends Common
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1>Ӫ<EFBFBD><D3AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
|
public function GetOperationWorkTypeList()
|
|||
|
|
{
|
|||
|
|
$allTypes = db('operation_info')->field('work_id as id, super_work_id, work_name as name')->select();
|
|||
|
|
|
|||
|
|
$tree = [];
|
|||
|
|
foreach ($allTypes as $item) {
|
|||
|
|
if ($item['super_work_id'] == 0) {
|
|||
|
|
$tree[$item['id']] = $item;
|
|||
|
|
} else {
|
|||
|
|
$parentId = $item['super_work_id'];
|
|||
|
|
if (isset($tree[$parentId])) {
|
|||
|
|
$tree[$parentId]['sub_type'][] = $item;
|
|||
|
|
} else {
|
|||
|
|
foreach ($tree as &$node) {
|
|||
|
|
if (isset($node['sub_type'])) {
|
|||
|
|
foreach ($node['sub_type'] as &$subNode) {
|
|||
|
|
if ($subNode['id'] == $parentId) {
|
|||
|
|
$subNode['sub_type'][] = $item;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$tree = array_values($tree);
|
|||
|
|
return $this->sendSuccess($tree);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӫ<EFBFBD><D3AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public function AddOperationWorkType()
|
|||
|
|
{
|
|||
|
|
$param = request()->post();
|
|||
|
|
$ret = [];
|
|||
|
|
|
|||
|
|
if ($param['work_id'] > 0) {
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
$ret = db('operation_info')->where('work_id', $param['work_id'])->field('work_id,super_work_id')->find();
|
|||
|
|
} else {
|
|||
|
|
//<2F><><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
$ret['work_id'] = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($ret != null) {
|
|||
|
|
$insert = [];
|
|||
|
|
$insert['work_name'] = $param['work_name'];
|
|||
|
|
$insert['super_work_id'] = $ret['work_id'];
|
|||
|
|
$insert['work_manager'] = $param['story_manager'];
|
|||
|
|
$insert['work_member'] = $param['story_member'];
|
|||
|
|
$insert['create_time'] = date('Y-m-d H:i:s');
|
|||
|
|
$ret1 = db('operation_info')->insert($insert);
|
|||
|
|
if($ret1){
|
|||
|
|
return $this->sendSuccess('<27><><EFBFBD>ӳɹ<D3B3>');
|
|||
|
|
}else{
|
|||
|
|
return $this->sendError('','<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public function upTaskType()
|
|||
|
|
{
|
|||
|
|
$param = request()->post();
|
|||
|
|
if($param){
|
|||
|
|
$update = [];
|
|||
|
|
$task_info = db('work_task_info')->where('task_id',$param['task_id'])->find();
|
|||
|
|
if($task_info && $param['task_type'] === 4){
|
|||
|
|
$createTime = $task_info['create_time'];
|
|||
|
|
$createTimestamp = strtotime($createTime);
|
|||
|
|
$currentTimestamp = time();
|
|||
|
|
$timeDifference = $currentTimestamp - $createTimestamp;
|
|||
|
|
$update['consuming_time'] = $timeDifference;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
$update['task_state'] = $param['task_type'];
|
|||
|
|
$ret = db('work_task_info')->where('task_id',$param['task_id'])->update($update);
|
|||
|
|
if($ret){
|
|||
|
|
return $this->sendSuccess('<27>ijɹ<C4B3>');
|
|||
|
|
}else{
|
|||
|
|
return $this->sendError('','<27><EFBFBD>ʧ<EFBFBD><CAA7>');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|