增加统计

main
yanzai 1 year ago
parent 9a6cb79dab
commit 3c208ce5de

@ -28,6 +28,7 @@ class AppointmentController extends Controller
$source='接口';
$info=request('info');
$sfz_mingwen=$info['id_card_num'];
//HSM加密
$HSM_sfz =\App\Lib\HSM::HsmEncrypt($info['id_card_num']);
if($HSM_sfz['status']!=true){
@ -72,6 +73,8 @@ class AppointmentController extends Controller
'type'=>$info['type'],
'name'=>$info['name'],
'id_card_num'=>$info['id_card_num'],
'age'=>\App\Lib\Tools::calculateAgeFromID($sfz_mingwen,$currentDateTime),
'birthday'=>\App\Lib\Tools::getBirthdayFromIDCard($sfz_mingwen),
'sex'=>$info['sex'],
'tel'=>$info['tel'],
'status'=>2, //1预约2到检 只要调用这个接口 直接到检
@ -135,6 +138,35 @@ class AppointmentController extends Controller
->where([['a.is_del','=',0],['a.created_at','>=',$searchInfo['start']],['a.created_at','<=',$searchInfo['end']]])
->groupBy('a.org_code','b.org_name')
->get();
return \Yz::Return(true,'查询成功',$list);
return \Yz::Return(true,'查询成功',['list'=>$list,'dateRange'=>[$searchInfo['start'],$searchInfo['end']]]);
}
//统计预约数量按月
public function AppointmentCountByMonth(Request $request)
{
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数
$searchInfo=request('searchInfo');
if($group<>1){
$cha=DB::table('medical_institution')->where(['link_user_id'=>$userid])->first();
$searchInfo['sn']=$cha->sn;
}
$list=DB::table('appointment_record as a')
->select(DB::raw('DATE_FORMAT(a.created_at, "%Y-%m") as month, COUNT(*) as count'))
->leftJoin('medical_institution as b','a.org_code','=','b.sn');
if(empty( $searchInfo['dateRange'])){
$searchInfo['start']=date('Y')."-01-01 00:00:00";
$searchInfo['end']= date('Y-m')."-31 23:59:59";
}else{
$searchInfo['start']=$searchInfo['dateRange'][0]." 00:00:00";
$searchInfo['end']=$searchInfo['dateRange'][1]." 23:59:59";
}
if(isset($searchInfo['sn'])){
$list=$list->where('a.org_code',$searchInfo['sn']);
}
$list=$list
->where([['a.is_del','=',0],['a.created_at','>=',$searchInfo['start']],['a.created_at','<=',$searchInfo['end']]])
->groupBy(DB::raw('DATE_FORMAT(a.created_at, "%Y-%m")'))
->get();
return \Yz::Return(true,'查询成功',['list'=>$list,'dateRange'=>[$searchInfo['start'],$searchInfo['end']]]);
}
}

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Services\Admin\YeWu\AppointmentService;
use DateTime;
use Illuminate\Http\Request;
use App\Lib\HSM;
use Illuminate\Support\Facades\DB;
@ -83,4 +84,35 @@ class TestController extends Controller
echo"执行完毕,共有待处理:".$count[0]->c."条,共更新".$shu."条";
}
public function jiemi_age()
{
$count=DB::select("select count(*) as c from appointment_record where age is null ");
$list=DB::select("select * from appointment_record where age is null limit 10");
$shu=0;
if(count($list)>0){
foreach ($list as $item){
$HSM_sfz =\App\Lib\HSM::HsmDecrypt($item->id_card_num);
if($HSM_sfz['status']!=true){
return \Yz::echoError1('调用HSM解密失败');
}
$sfz=$HSM_sfz['data'];
$u=DB::table('appointment_record')->where('id',$item->id)->update([
'age'=> \App\Lib\Tools::calculateAgeFromID($sfz,$item->created_at),
'birthday'=>\App\Lib\Tools::getBirthdayFromIDCard($sfz)
]);
if($u){
$shu++;
}
sleep(0.5);
}
}
echo"执行完毕,共有待处理:".$count[0]->c."条,共更新".$shu."条";
}
}

@ -0,0 +1,67 @@
<?php
namespace App\Lib;
use DateTime;
class Tools{
//根据当前日期和身份证获取年龄
public static function calculateAgeFromID($idNumber, $targetDate) {
// // 提取出生年月日
// $birthYear = substr($idNumber, 6, 4);
// $birthMonth = substr($idNumber, 10, 2);
// $birthDay = substr($idNumber, 12, 2);
//
// // 创建出生日期和目标日期的 DateTime 对象
// $birthdate = new DateTime("$birthYear-$birthMonth-$birthDay");
// $target = new DateTime($targetDate);
//
// // 计算年龄
// $interval = $birthdate->diff($target);
// $age = $interval->y;
//
// // 如果生日还没到,减一岁
// if ($target->format('m-d') < $birthdate->format('m-d')) {
// $age--;
// }
//
// return $age;
// 提取出生年月日
$birthYear = substr($idNumber, 6, 4);
$birthMonth = substr($idNumber, 10, 2);
$birthDay = substr($idNumber, 12, 2);
// 创建出生日期和目标日期的 DateTime 对象
$birthdate = new DateTime("$birthYear-$birthMonth-$birthDay");
$target = new DateTime($targetDate);
// 计算年龄
$interval = $birthdate->diff($target);
// 使用正确的属性获取年龄
$age = $interval->y;
return $age;
}
//根据身份证获取生日
public static function getBirthdayFromIDCard($idCard) {
// 检查身份证号码是否有效
if (!preg_match("/^(\d{15}$|^\d{17}[xX\d]$)/", $idCard)) {
return false;
}
// 提取出生日期部分
$birthday = substr($idCard, 6, 8);
// 如果是15位的身份证号码需要将年份从两位扩展到四位假设1900-2000
if (strlen($idCard) == 15) {
$year = substr($birthday, 0, 2);
if ($year >= 0 && $year <= 20) { // 2000-2020
$birthday = '20' . $birthday;
} else { // 1900-1999
$birthday = '19' . $birthday;
}
}
// 格式化并返回日期字符串
return date('Y-m-d', strtotime($birthday));
}
}

@ -67,7 +67,7 @@ class OrganizationService
$info=$arr['info'];
//判断用户是否有效
$cha_info=DB::table('persons')->select(['id','name','id_card_num'])->where(['openid'=>$openid,'status'=>1])->get();
$cha_info=DB::table('persons')->select(['id','name','id_card_num','sex'])->where(['openid'=>$openid,'status'=>1])->get();
if(!count($cha_info)){
return \Yz::Return(false,'未找到有效用户');
}
@ -107,7 +107,11 @@ class OrganizationService
if($Hmac['status']!=true){
return \Yz::echoError1('HMAC摘要失败');
}
$sfz_HSM=\App\Lib\HSM::HsmDecrypt($cha_info[0]->id_card_num);
if($sfz_HSM['status']!=true){
return \Yz::echoError1('身份证解密失败');
}
$sfz_mingwen=$sfz_HSM['data'];
//如果都通过则继续
DB::beginTransaction();
try {
@ -117,6 +121,9 @@ class OrganizationService
'calendar_id' => $info['calendar_id'],
'name' => $cha_info[0]->name,
'id_card_num' => $cha_info[0]->id_card_num,
'sex'=>$cha_info[0]->sex,
'age'=>\App\Lib\Tools::calculateAgeFromID($sfz_mingwen,$nowtime),
'birthday'=>\App\Lib\Tools::getBirthdayFromIDCard($sfz_mingwen),
'person_id'=>$cha_info[0]->id,
'openid'=>$openid,
'date'=>$q_date[0]->date,

@ -53,6 +53,7 @@ Route::group(['middleware'=>['checktoken','log'],'prefix'=>'v1'],function () {
Route::post('admin/XTSignBindUser','App\Http\Controllers\API\XTSignController@bindUser');//admin后台用户绑定协同签名useid
Route::post('admin/UkeyBindUser','App\Http\Controllers\API\UkeyController@Bind');//admin后台用户绑定协同签名useid
Route::post('admin/AppointmentCount','App\Http\Controllers\API\Admin\YeWu\AppointmentController@AppointmentCount'); //admin后台预约统计
Route::post('admin/AppointmentCountByMonth','App\Http\Controllers\API\Admin\YeWu\AppointmentController@AppointmentCountByMonth'); //admin后台预约统计
Route::post('admin/InstitutionGetList','App\Http\Controllers\API\Admin\YeWu\InstitutionController@GetList');//获取体检机构列表
Route::post('admin/InstitutionSavdSeting','App\Http\Controllers\API\Admin\YeWu\InstitutionController@SavdSeting');//保存机构设置
Route::post('admin/InstitutionGetSetingDetail','App\Http\Controllers\API\Admin\YeWu\InstitutionController@GetSetingDetail');//获取机构设置详情

@ -37,3 +37,4 @@ Route::any('/yuju_test', function () { //测试 语句
Route::any('/pljm','App\Http\Controllers\TestController@jiami' );
Route::any('/jiemage','App\Http\Controllers\TestController@jiemi_age' );

@ -137,6 +137,10 @@ export const GetLogTableName = (data={}) => {
export const AppointmentCount = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/AppointmentCount',data:data})
}
//预约登记统计(按月)
export const AppointmentCountByMonth = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/AppointmentCountByMonth',data:data})
}
//机构管理获取列表
export const InstitutionGetList = (data={}) => {
return axios({url:import.meta.env.VITE_APP_API+'v1/admin/InstitutionGetList',data:data})

@ -1,20 +1,38 @@
<template>
<div class="Dashboard" style="display: none;">
<el-alert show-icon title="因未对接体检数据接口,以下数据均为演示.报表内容和类型可根据需求调整" type="warning" :closable="false" style="margin-bottom: 20px;"/>
<div class="Dashboard" v-loading="loading">
<div class="head">
<el-row>
<el-form-item style="margin-left: 8px;">
<el-date-picker v-model="searchInfo.dateRange" value-format="YYYY-MM-DD" type="daterange"
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
</el-form-item>
<el-form-item>
<el-button type="primary" style="margin-left: 20px;" @click="GetInfo"></el-button>
</el-form-item>
</el-row>
</div>
<!-- <el-alert show-icon title="因未对接体检数据接口,以下数据均为演示.报表内容和类型可根据需求调整" type="warning" :closable="false" style="margin-bottom: 20px;"/> -->
<el-row class="row1" :gutter="20">
<el-col :span="12">
<div id="MonthCount" class="MonthCount"></div>
<div id="JiGouCount" class="MonthCount"></div>
</el-col>
<el-col :span="12">
<div id="TypeCount" class="TypeCount"></div>
<!-- <div id="TypeCount" class="TypeCount"></div> -->
<div id="JiGouCountByMonth" class="TypeCount"></div>
</el-col>
</el-row>
<el-row class="row2">
<el-col :span="24">
<div class="title">各体检机构体检量统计</div>
<el-table :data="tableData" style="width: 100%;" row-key="id">
<el-table :data="tableData" style="width: 100%;" show-summary row-key="id">
<!-- <el-table-column prop="id" label="Id" width="100" /> -->
<el-table-column prop="name" label="机构名称" />
<el-table-column prop="org_name" label="机构名称" />
<el-table-column prop="count" label="数量" />
</el-table>
<!-- <div class="page">
@ -32,21 +50,12 @@
ref,
onMounted
} from 'vue'
import {
AppointmentCount,AppointmentCountByMonth,GetHealthOrganizationEnableList
} from '@/api/api.js'
import * as echarts from 'echarts';
let loading = ref(false)
let tableData = ref([{
name:'医管中心',
count:'500'
},{
name:'亦庄医院',
count:'636'
},{
name:'采育卫生院',
count:'425'
},{
name:'西红门医院',
count:'266'
}])
let tableData = ref([])
let currentPage = ref(1) //
let pageSize = ref(15) //
let total = 0 //
@ -61,71 +70,141 @@
const GetList=()=>{
}
onMounted(()=>{
var ChartMonthCount = echarts.init(document.getElementById('MonthCount'));
let searchInfo=ref({});
//
const GetJiGouAppointmentCount=()=>{
loading.value=true
AppointmentCount({searchInfo:searchInfo.value}).then(res => {
loading.value=false
if (res.status) {
AppointmentZhuZhuangTu(res.data)
tableData.value=res.data.list
searchInfo.value.dateRange=[res.data.dateRange[0],res.data.dateRange[1]]
} else {
ElMessage.error(res.msg)
}
})
}
//
const GetJiGouAppointmentCountByMonth=()=>{
AppointmentCountByMonth({searchInfo:searchInfo.value}).then(res => {
if (res.status) {
AppointmentZheXianTu(res.data)
} else {
ElMessage.error(res.msg)
}
})
}
//
const AppointmentZhuZhuangTu=(resdata)=>{
let jigou_list=[];
let count_list=[];
resdata.list.forEach((v,i)=>{
jigou_list.push(v.org_name)
count_list.push(v.count)
})
var ChartJiGouCount = echarts.init(document.getElementById('JiGouCount'));
//
ChartMonthCount.setOption({
ChartJiGouCount.setOption({
title: {
text: '2023-01-01~2023-06-30体检数量统计'
text: resdata.dateRange[0].substr(0,10)+'~'+resdata.dateRange[1].substr(0,10)+'体检数量统计'
},
tooltip: {},
xAxis: {
data: ['1月', '2月', '3月', '4月', '5月', '6月']
data: jigou_list
},
yAxis: {},
series: [
{
name: '数量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
data: count_list
}
]
});
var ChartTypeCount = echarts.init(document.getElementById('TypeCount'));
ChartTypeCount.setOption(
{
title: {
text: '2023-01-01~2023-06-30体检行业分类统计'
},
tooltip: {
trigger: 'item'
},
legend: {
top: '5%',
left: 'center'
},
series: [
{
name: '数量',
type: 'pie',
radius: ['40%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: 40,
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{ value: 1048, name: '食品类' },
{ value: 735, name: '化妆品类' },
{ value: 580, name: '公共场所类' },
{ value: 484, name: '生活饮用水类' },
{ value: 300, name: '消毒产品生产类' }
]
}
]
}
//线
const AppointmentZheXianTu=(resdata)=>{
let month_list=[];
let count_list=[];
resdata.list.forEach((v,i)=>{
month_list.push(v.month.substr(6,8)+'月')
count_list.push(v.count)
})
var JiGouCountByMonth = echarts.init(document.getElementById('JiGouCountByMonth'));
//
JiGouCountByMonth.setOption({
title: {
text: resdata.dateRange[0].substr(0,7)+'~'+resdata.dateRange[1].substr(0,7)+'体检数量走势'
},
tooltip: {},
xAxis: {
data: month_list
},
yAxis: {},
series: [
{
name: '数量',
type: 'line',
data: count_list
}
]
});
}
const GetInfo=()=>{
GetJiGouAppointmentCount()
GetJiGouAppointmentCountByMonth()
}
onMounted(()=>{
GetJiGouAppointmentCount()
GetJiGouAppointmentCountByMonth()
// var ChartTypeCount = echarts.init(document.getElementById('TypeCount'));
// ChartTypeCount.setOption(
// {
// title: {
// text: '2023-01-01~2023-06-30'
// },
// tooltip: {
// trigger: 'item'
// },
// legend: {
// top: '5%',
// left: 'center'
// },
// series: [
// {
// name: '',
// type: 'pie',
// radius: ['40%', '70%'],
// avoidLabelOverlap: false,
// label: {
// show: false,
// position: 'center'
// },
// emphasis: {
// label: {
// show: true,
// fontSize: 40,
// fontWeight: 'bold'
// }
// },
// labelLine: {
// show: false
// },
// data: [
// { value: 1048, name: '' },
// { value: 735, name: '' },
// { value: 580, name: '' },
// { value: 484, name: '' },
// { value: 300, name: '' }
// ]
// }
// ]
// })
})

@ -8,7 +8,7 @@
<el-option label="老年人" value="2" />
</el-select>
</el-form-item>
<el-form-item style="margin-left: 8px;">
<el-form-item style="margin-left: 8px;" v-if="org_list.length>0">
<el-select filterable clearable v-model="searchInfo.sn" placeholder="请选择体检机构">
<el-option v-for="(item, index) in org_list" :key="index" :label="item.org_name" :value="item.sn" />
</el-select>
@ -27,7 +27,7 @@
</el-row>
</div>
<el-table :data="tableData" style="width: 100%;" row-key="id" v-loading="loading">
<el-table :data="tableData" style="width: 100%;" row-key="id" show-summary v-loading="loading">
<el-table-column prop="org_name" label="体检机构" />
<el-table-column prop="org_code" label="Code" />
<el-table-column prop="count" label="数量" />
@ -47,6 +47,7 @@
import {
AppointmentCount,GetHealthOrganizationEnableList
} from '@/api/api.js'
let loading = ref(false)
let searchInfo = ref({
checkType:"2",
dateRange: [],
@ -54,16 +55,18 @@
})
let tableData = ref([])
const GetInfo=()=>{
loading.value=true
AppointmentCount({searchInfo:searchInfo.value}).then(res => {
loading.value=false
if (res.status) {
tableData.value = res.data
tableData.value = res.data.list
} else {
ElMessage.error(res.msg)
}
})
}
let org_list = ref([]) //
let org_list = ref('') //
const getHealthOrganizationEnableList = () => {
GetHealthOrganizationEnableList().then(res => {
if (res.status) {

Loading…
Cancel
Save