This commit is contained in:
2024-08-08 00:24:09 +08:00
parent 992ff09f49
commit 9ab5393c45
3 changed files with 544 additions and 482 deletions

View File

@@ -84,6 +84,7 @@ class Hdrfollowup extends BaseHttpApi
} }
} }
/** /**
* desc获取统一随访记录 * desc获取统一随访记录
* *
@@ -155,6 +156,7 @@ class Hdrfollowup extends BaseHttpApi
return json(Tools::set_res(500,'操作异常',[])); return json(Tools::set_res(500,'操作异常',[]));
} }
} }
/** /**
* 修改统一随访记录 * 修改统一随访记录
* 参数: * 参数:
@@ -208,4 +210,37 @@ class Hdrfollowup extends BaseHttpApi
} }
} }
/**
* 删除随访
* 参数:
* id ID
* api/Hdrfollowup/del
*/
function del(){
Tools::log_to_write_txt(['删除统一随访记录'=>input()]);
$api_desc = '删除统一随访记录';
try {
$id = input('id');
if(empty($id)){
return json(Tools::set_fail('参数错误。0'));
}
Db::table(TabConf::$fa_hdrfollowup)
->where('id',$id)
->delete();
return json(Tools::set_ok('ok'));
} catch (\Exception $e) {
Tools::log_to_write_txt([
'error'=>'删除统一随访记录.异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
} }

View File

@@ -14,6 +14,181 @@ class Hdrquestionnairequestion extends BaseHttpApi
protected $controller_comments = '科室问卷问题(一个问题对应多个答案)'; protected $controller_comments = '科室问卷问题(一个问题对应多个答案)';
/**
* 新增科室问卷问题(一个问题对应多个答案)
*
* 参数:
* hdrdepartment_id 所属科室 所属科室 必须
* question 问卷问题 问卷问题 必须
* is_common 是否通用:yes=是,no=否 是否通用:yes=是,no=否 必须
* is_only_boy 只适合男:yes=是,no=否 只适合男:yes=是,no=否 必须
* is_only_girl 只适合女:yes=是,no=否 只适合女:yes=是,no=否 必须
* type 选项类型:one=单选,more=多选 选项类型:one=单选,more=多选 必须
* api/Hdrquestionnairequestion/addHdrquestionnairequestion
*/
function addHdrquestionnairequestion()
{
Tools::log_to_write_txt(['新增科室问卷问题(一个问题对应多个答案)' => input()]);
$api_desc = '新增科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
if (empty($hdrdepartment_id)) {
return json(Tools::set_fail('参数错误.0'));
}
$question = input('question');
if (empty($question)) {
return json(Tools::set_fail('参数错误.1'));
}
$is_common = input('is_common');
if (empty($is_common)) {
return json(Tools::set_fail('参数错误.2'));
}
$is_only_boy = input('is_only_boy');
if (empty($is_only_boy)) {
return json(Tools::set_fail('参数错误.3'));
}
$is_only_girl = input('is_only_girl');
if (empty($is_only_girl)) {
return json(Tools::set_fail('参数错误.4'));
}
$type = input('type');
if (empty($type)) {
return json(Tools::set_fail('参数错误.5'));
}
$data = [
'hdrdepartment_id' => $hdrdepartment_id ?: '',
'question' => $question ?: '',
'is_common' => $is_common ?: '',
'is_only_boy' => $is_only_boy ?: '',
'is_only_girl' => $is_only_girl ?: '',
'type' => $type ?: '',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)->insertGetId($data);
$this->operateLog('新增科室问卷问题(一个问题对应多个答案)', api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok', $dataid));
} catch (\Exception $e) {
Db::rollback();
Tools::log_to_write_txt([
'error' => '新增科室问卷问题(一个问题对应多个答案).异常.' . $e->getMessage(),
'input' => input(),
'error_info' => $e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* 修改科室问卷问题(一个问题对应多个答案)
* 参数:
* id ID ID 必须
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
* api/Hdrquestionnairequestion/updateHdrquestionnairequestion
*/
function updateHdrquestionnairequestion()
{
Tools::log_to_write_txt(['修改科室问卷问题(一个问题对应多个答案)' => input()]);
$api_desc = '修改科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
$question = input('question');
$is_common = input('is_common');
$is_only_boy = input('is_only_boy');
$is_only_girl = input('is_only_girl');
$type = input('type');
if (empty(input('id'))) {
return json(Tools::set_fail('参数错误。0'));
}
$data = [
'hdrdepartment_id' => $hdrdepartment_id ?: '',
'question' => $question ?: '',
'is_common' => $is_common ?: '',
'is_only_boy' => $is_only_boy ?: '',
'is_only_girl' => $is_only_girl ?: '',
'type' => $type ?: '',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)
->data($data)
->where('id', input('id'))
->update();
$this->operateLog('修改科室问卷问题(一个问题对应多个答案)', api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok', $dataid));
} catch (\Exception $e) {
Db::rollback();
Tools::log_to_write_txt([
'error' => '修改科室问卷问题(一个问题对应多个答案).异常.' . $e->getMessage(),
'input' => input(),
'error_info' => $e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc 删除科室问卷问题(一个问题对应多个答案)
* authorwh
*
* 参数:
* id 数据id 必须
*
* api/Hdrquestionnairequestion/del
*/
function del()
{
Tools::log_to_write_txt(['删除科室问卷问题(一个问题对应多个答案)' => input()]);
$api_desc = '删除科室问卷问题(一个问题对应多个答案)';
try {
$id = input('id');
if (empty($id)) {
return json(Tools::set_fail('参数错误。0'));
}
Db::table(TabConf::$fa_hdrquestionnairequestion)
->where('id', $id)
->delete();
return json(Tools::set_ok('ok'));
} catch (\Exception $e) {
Tools::log_to_write_txt([
'error' => '删除科室问卷问题(一个问题对应多个答案).异常.' . $e->getMessage(),
'input' => input(),
'error_info' => $e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/** /**
@@ -24,14 +199,7 @@ class Hdrquestionnairequestion extends BaseHttpApi
* 参数: * 参数:
* 带分页 * 带分页
* current_page 当前页码 * current_page 当前页码
* question 问卷问题 * list_rows 每页显示条数 默认15
* id ID
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
* *
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span> * 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>
@@ -51,49 +219,64 @@ class Hdrquestionnairequestion extends BaseHttpApi
Tools::log_to_write_txt(['获取科室问卷问题(一个问题对应多个答案) 入参:'=>input()]); Tools::log_to_write_txt(['获取科室问卷问题(一个问题对应多个答案) 入参:'=>input()]);
$api_desc = '获取科室问卷问题(一个问题对应多个答案)'; $api_desc = '获取科室问卷问题(一个问题对应多个答案)';
try { try {
$id = input('id');
$hdrdepartment_id = input('hdrdepartment_id');
if(empty($hdrdepartment_id)){
return json(Tools::set_fail('hdrdepartment_id参数错误'));
}
$question = input('question');
$is_common = input('is_common');
$is_only_boy = input('is_only_boy');
$is_only_girl = input('is_only_girl');
$type = input('type');
$model_obj = Db::table(TabConf::$fa_hdrquestionnairequestion); $model_obj = Db::table(TabConf::$fa_hdrquestionnairequestion);
if(input('question')){
$model_obj->whereLike('question','%'.input('question').'%');
}
if(input('id')){
$model_obj->where('id',input('id'));
}
if(input('hdrdepartment_id')){
$model_obj->where('hdrdepartment_id',input('hdrdepartment_id'));
}
if(input('is_common')){
$model_obj->where('is_common',input('is_common'));
}
if(input('is_only_boy')){
$model_obj->where('is_only_boy',input('is_only_boy'));
}
if(input('is_only_girl')){
$model_obj->where('is_only_girl',input('is_only_girl'));
}
if(input('type')){
$model_obj->where('type',input('type'));
}
$data = $model_obj->paginate(['page'=>input('current_page',1),'list_rows'=>input('list_rows',15)]) $data = $model_obj->paginate(['page'=>input('current_page',1),'list_rows'=>input('list_rows',15)])
->each(function($item, $key){
$ret_field_name_arr = Tools::delete_str_empty_ele('id--testname,,,,,,,,');
//处理为外键字段+外键对应数据的字段名 egusers_id=>nickname
$ret_field_name2 = [];
foreach ($ret_field_name_arr as $ret_typ_field) {
$exp_arr = explode('--',$ret_typ_field);
//$exp_arr[0] 主表字段,$exp_arr[1] 副表字段
$ret_field_name2[$exp_arr[0]] = [$exp_arr[0],$exp_arr[1]];
}
//返回数据类型处理
$return_type_exp_arr = Tools::delete_str_empty_ele('id==two_arr,,,,,,,,');
//处理为类型+字段
$return_type_exp_arr2 = [];
foreach ($return_type_exp_arr as $ret_type_field) {
$exp_arr = explode('==',$ret_type_field);
$return_type_exp_arr2[$exp_arr[0]] = $exp_arr[1];
}
//返回数组 eg: [id-fa_goods_deal==goods_id,id-fa_goods_deal==goods_id]
$rel_table_arr = Tools::delete_str_empty_ele('id-fa_hdrquestionnaireanswer==id,,,,,,,,');
//关联的字段和表
$rel_field_table_arr2 = [];
//关系
foreach ($rel_table_arr as $rel_str) {
$exp_arr = explode('-',$rel_str);
$rel_field_table_arr2[$exp_arr[0]] = [explode('==',$exp_arr[1])[0],explode('==',$exp_arr[1])[1]];
} }
foreach($item as $it_key=>$it_val){
if(empty($rel_field_table_arr2[$it_key])){
continue;
}
foreach($return_type_exp_arr as $key=>$val){
$val_arr = explode('==',$val);
if($it_key == $val_arr[0]){
switch($val_arr[1]){
case 'two_arr':
$item[$it_key.'_data'] = Db::table($rel_field_table_arr2[$it_key][0])->where("{$rel_field_table_arr2[$it_key][1]}",$it_val)->select();
break;
case 'one_arr':
$item[$it_key.'_data'] = Db::table($rel_field_table_arr2[$it_key][0])->where("{$rel_field_table_arr2[$it_key][1]}",$it_val)->find();
break;
case 'field_val':
$item[$it_key.'_data'] = Db::table($rel_field_table_arr2[$it_key][0])->where("{$rel_field_table_arr2[$it_key][1]}",$it_val)->value("{$ret_field_name2[$it_key][1]}");
break;
}
}
}
} }
return $item; return $item;
}); });
@@ -116,176 +299,4 @@ class Hdrquestionnairequestion extends BaseHttpApi
]); ]);
return json(Tools::set_res(500,'操作异常',[])); return json(Tools::set_res(500,'操作异常',[]));
} }
/**
* 新增科室问卷问题(一个问题对应多个答案)
*
* 参数:
* hdrdepartment_id 所属科室 所属科室 必须
* question 问卷问题 问卷问题 必须
* is_common 是否通用:yes=是,no=否 是否通用:yes=是,no=否 必须
* is_only_boy 只适合男:yes=是,no=否 只适合男:yes=是,no=否 必须
* is_only_girl 只适合女:yes=是,no=否 只适合女:yes=是,no=否 必须
* type 选项类型:one=单选,more=多选 选项类型:one=单选,more=多选 必须
* api/Hdrquestionnairequestion/addHdrquestionnairequestion
*/
function addHdrquestionnairequestion(){
Tools::log_to_write_txt(['新增科室问卷问题(一个问题对应多个答案)'=>input()]);
$api_desc = '新增科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
if(empty($hdrdepartment_id)){
return json(Tools::set_fail('参数错误.0'));
}
$question = input('question');
if(empty($question)){
return json(Tools::set_fail('参数错误.1'));
}
$is_common = input('is_common');
if(empty($is_common)){
return json(Tools::set_fail('参数错误.2'));
}
$is_only_boy = input('is_only_boy');
if(empty($is_only_boy)){
return json(Tools::set_fail('参数错误.3'));
}
$is_only_girl = input('is_only_girl');
if(empty($is_only_girl)){
return json(Tools::set_fail('参数错误.4'));
}
$type = input('type');
if(empty($type)){
return json(Tools::set_fail('参数错误.5'));
}
$data = [
'hdrdepartment_id'=>$hdrdepartment_id?:'',
'question'=>$question?:'',
'is_common'=>$is_common?:'',
'is_only_boy'=>$is_only_boy?:'',
'is_only_girl'=>$is_only_girl?:'',
'type'=>$type?:'',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)->insertGetId($data);
$this->operateLog('新增科室问卷问题(一个问题对应多个答案)',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'新增科室问卷问题(一个问题对应多个答案).异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* 修改科室问卷问题(一个问题对应多个答案)
* 参数:
* id ID ID 必须
* hdrdepartment_id 所属科室
* question 问卷问题
* is_common 是否通用:yes=是,no=否
* is_only_boy 只适合男:yes=是,no=否
* is_only_girl 只适合女:yes=是,no=否
* type 选项类型:one=单选,more=多选
* api/Hdrquestionnairequestion/updateHdrquestionnairequestion
*/
function updateHdrquestionnairequestion(){
Tools::log_to_write_txt(['修改科室问卷问题(一个问题对应多个答案)'=>input()]);
$api_desc = '修改科室问卷问题(一个问题对应多个答案)';
Db::startTrans();
try {
$hdrdepartment_id = input('hdrdepartment_id');
$question = input('question');
$is_common = input('is_common');
$is_only_boy = input('is_only_boy');
$is_only_girl = input('is_only_girl');
$type = input('type');
if(empty(input('id'))){
return json(Tools::set_fail('参数错误。0'));
}
$data = [
'hdrdepartment_id'=>$hdrdepartment_id?:'',
'question'=>$question?:'',
'is_common'=>$is_common?:'',
'is_only_boy'=>$is_only_boy?:'',
'is_only_girl'=>$is_only_girl?:'',
'type'=>$type?:'',
];
$dataid = Db::table(TabConf::$fa_hdrquestionnairequestion)
->data($data)
->where('id',input('id'))
->update();
$this->operateLog('修改科室问卷问题(一个问题对应多个答案)',api_user_info('id'));
Db::commit();
return json(Tools::set_ok('ok',$dataid));
}catch (\Exception $e){
Db::rollback();
Tools::log_to_write_txt([
'error'=>'修改科室问卷问题(一个问题对应多个答案).异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
/**
* desc 删除科室问卷问题(一个问题对应多个答案)
* authorwh
*
* 参数:
* id 数据id 必须
*
* api/Hdrquestionnairequestion/del
*/
function del(){
Tools::log_to_write_txt(['删除科室问卷问题(一个问题对应多个答案)'=>input()]);
$api_desc = '删除科室问卷问题(一个问题对应多个答案)';
try {
$id = input('id');
if(empty($id)){
return json(Tools::set_fail('参数错误。0'));
}
Db::table(TabConf::$fa_hdrquestionnairequestion)
->where('id',$id)
->delete();
return json(Tools::set_ok('ok'));
} catch (\Exception $e) {
Tools::log_to_write_txt([
'error'=>'删除科室问卷问题(一个问题对应多个答案).异常.'.$e->getMessage(),
'input'=>input(),
'error_info'=>$e->getTraceAsString()
]);
return json(Tools::set_fail());
}
}
} }

View File

@@ -88,8 +88,24 @@ dump($requestUrl);
// 运行事件循环 // 运行事件循环
$loop->run(); $loop->run();
} }
function stringToColor($string) {
// 使用crc32函数计算字符串的哈希值
$hash = crc32($string);
// 将整数哈希值转换为16进制并填充0以确保6位长度
$color = sprintf("%06X", $hash & 0xFFFFFF);
// 返回颜色码
return '#' . $color;
}
function test() function test()
{ {
// 使用示例
$color = $this->stringToColor("example string");
echo $color; // 输出颜色码
die;
// 配置您的讯飞应用信息 // 配置您的讯飞应用信息
$appId = 'd482af59'; $appId = 'd482af59';
$apiKey = '0d20dab630904ad8676d9075375a1914'; $apiKey = '0d20dab630904ad8676d9075375a1914';