新增科室预约工作时间维护页面
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.openhis.web.appointmentmanage.appservice;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.appointmentmanage.domain.DeptAppointmentHours;
|
||||
|
||||
public interface IDeptAppointmentHoursAppService {
|
||||
|
||||
R<?> getDeptAppthoursList(DeptAppointmentHours deptAppointmentHours, Integer pageNum, Integer pageSize);
|
||||
|
||||
R<?> getDeptAppthoursDetail(Long id);
|
||||
|
||||
R<?> addDeptAppthours(DeptAppointmentHours deptAppointmentHours);
|
||||
|
||||
R<?> updateDeptAppthours(DeptAppointmentHours deptAppointmentHours);
|
||||
|
||||
R<?> deleteDeptAppthours(Long id);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.openhis.web.appointmentmanage.appservice.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.appointmentmanage.domain.DeptAppointmentHours;
|
||||
import com.openhis.appointmentmanage.mapper.DeptAppointmentHoursMapper;
|
||||
import com.openhis.appointmentmanage.service.IDeptAppointmentHoursService;
|
||||
import com.openhis.web.appointmentmanage.appservice.IDeptAppointmentHoursAppService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeptAppointmentHoursAppServiceImpl implements IDeptAppointmentHoursAppService {
|
||||
|
||||
@Resource
|
||||
private IDeptAppointmentHoursService deptAppointmentHoursService;
|
||||
|
||||
@Resource
|
||||
private DeptAppointmentHoursMapper deptAppointmentHoursMapper;
|
||||
|
||||
@Override
|
||||
public R<?> getDeptAppthoursList(DeptAppointmentHours deptAppointmentHours, Integer pageNum, Integer pageSize) {
|
||||
LambdaQueryWrapper<DeptAppointmentHours> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(deptAppointmentHours.getInstitution())) {
|
||||
wrapper.eq(DeptAppointmentHours::getInstitution, deptAppointmentHours.getInstitution());
|
||||
}
|
||||
if (StrUtil.isNotBlank(deptAppointmentHours.getDepartment())) {
|
||||
wrapper.eq(DeptAppointmentHours::getDepartment, deptAppointmentHours.getDepartment());
|
||||
}
|
||||
wrapper.orderByDesc(DeptAppointmentHours::getCreatedTime);
|
||||
|
||||
Page<DeptAppointmentHours> page = new Page<>(pageNum, pageSize);
|
||||
Page<DeptAppointmentHours> resultPage = deptAppointmentHoursMapper.selectPage(page, wrapper);
|
||||
|
||||
return R.ok(resultPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getDeptAppthoursDetail(Long id) {
|
||||
if (ObjectUtil.isNull(id)) {
|
||||
return R.fail("ID不能为空");
|
||||
}
|
||||
DeptAppointmentHours deptAppointmentHours = deptAppointmentHoursService.getById(id);
|
||||
if (ObjectUtil.isNull(deptAppointmentHours)) {
|
||||
return R.fail("数据不存在");
|
||||
}
|
||||
return R.ok(deptAppointmentHours);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addDeptAppthours(DeptAppointmentHours deptAppointmentHours) {
|
||||
if (ObjectUtil.isNull(deptAppointmentHours)) {
|
||||
return R.fail("数据不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(deptAppointmentHours.getInstitution())) {
|
||||
return R.fail("所属机构不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(deptAppointmentHours.getDepartment())) {
|
||||
return R.fail("科室名称不能为空");
|
||||
}
|
||||
|
||||
deptAppointmentHours.setCreatedTime(LocalDateTime.now());
|
||||
boolean save = deptAppointmentHoursService.save(deptAppointmentHours);
|
||||
return R.ok(save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> updateDeptAppthours(DeptAppointmentHours deptAppointmentHours) {
|
||||
if (ObjectUtil.isNull(deptAppointmentHours) || ObjectUtil.isNull(deptAppointmentHours.getId())) {
|
||||
return R.fail("ID不能为空");
|
||||
}
|
||||
|
||||
DeptAppointmentHours existing = deptAppointmentHoursService.getById(deptAppointmentHours.getId());
|
||||
if (ObjectUtil.isNull(existing)) {
|
||||
return R.fail("数据不存在");
|
||||
}
|
||||
|
||||
deptAppointmentHours.setUpdatedTime(LocalDateTime.now());
|
||||
boolean update = deptAppointmentHoursService.updateById(deptAppointmentHours);
|
||||
return R.ok(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> deleteDeptAppthours(Long id) {
|
||||
if (ObjectUtil.isNull(id)) {
|
||||
return R.fail("ID不能为空");
|
||||
}
|
||||
|
||||
DeptAppointmentHours existing = deptAppointmentHoursService.getById(id);
|
||||
if (ObjectUtil.isNull(existing)) {
|
||||
return R.fail("数据不存在");
|
||||
}
|
||||
|
||||
boolean remove = deptAppointmentHoursService.removeById(id);
|
||||
return R.ok(remove);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.openhis.web.appointmentmanage.controller;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.appointmentmanage.domain.DeptAppointmentHours;
|
||||
import com.openhis.web.appointmentmanage.appservice.IDeptAppointmentHoursAppService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 科室预约工作时间维护 Controller
|
||||
*
|
||||
* @author openhis
|
||||
* @date 2025-12-12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/appoinment/dept-appthours")
|
||||
public class DeptAppthoursController {
|
||||
|
||||
@Resource
|
||||
private IDeptAppointmentHoursAppService deptAppointmentHoursAppService;
|
||||
|
||||
/**
|
||||
* 获取科室预约工作时间列表
|
||||
*
|
||||
* @param deptAppointmentHours 查询条件
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @return 列表数据
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public R<?> getDeptAppthoursList(
|
||||
DeptAppointmentHours deptAppointmentHours,
|
||||
@RequestParam(defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
return deptAppointmentHoursAppService.getDeptAppthoursList(deptAppointmentHours, pageNum, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取科室预约工作时间详情
|
||||
*
|
||||
* @param id 记录ID
|
||||
* @return 详情数据
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<?> getDeptAppthoursDetail(@PathVariable("id") Long id) {
|
||||
return deptAppointmentHoursAppService.getDeptAppthoursDetail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增科室预约工作时间
|
||||
*
|
||||
* @param deptAppointmentHours 新增数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping
|
||||
public R<?> addDeptAppthours(@RequestBody DeptAppointmentHours deptAppointmentHours) {
|
||||
return deptAppointmentHoursAppService.addDeptAppthours(deptAppointmentHours);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改科室预约工作时间
|
||||
*
|
||||
* @param deptAppointmentHours 修改数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PutMapping
|
||||
public R<?> updateDeptAppthours(@RequestBody DeptAppointmentHours deptAppointmentHours) {
|
||||
return deptAppointmentHoursAppService.updateDeptAppthours(deptAppointmentHours);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除科室预约工作时间
|
||||
*
|
||||
* @param id 记录ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
public R<?> deleteDeptAppthours(@PathVariable("id") Long id) {
|
||||
return deptAppointmentHoursAppService.deleteDeptAppthours(id);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,9 @@ core:
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 应用上下文路径
|
||||
servlet:
|
||||
context-path: /openhis
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.openhis.appointmentmanage.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 科室预约工作时间Entity
|
||||
*
|
||||
* @date 2025-12-12
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "dept_appointment_hours", autoResultMap = true)
|
||||
@Accessors(chain = true)
|
||||
public class DeptAppointmentHours {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("institution")
|
||||
private String institution;
|
||||
|
||||
@TableField("department")
|
||||
private String department;
|
||||
|
||||
@TableField("morning_start")
|
||||
private String morningStart;
|
||||
|
||||
@TableField("morning_end")
|
||||
private String morningEnd;
|
||||
|
||||
@TableField("afternoon_start")
|
||||
private String afternoonStart;
|
||||
|
||||
@TableField("afternoon_end")
|
||||
private String afternoonEnd;
|
||||
|
||||
@TableField("quota")
|
||||
private Integer quota;
|
||||
|
||||
@TableField("operator")
|
||||
private String operator;
|
||||
|
||||
@TableField("created_time")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
@TableField("updated_time")
|
||||
private LocalDateTime updatedTime;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.openhis.appointmentmanage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.openhis.appointmentmanage.domain.DeptAppointmentHours;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DeptAppointmentHoursMapper extends BaseMapper<DeptAppointmentHours> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.openhis.appointmentmanage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.appointmentmanage.domain.DeptAppointmentHours;
|
||||
|
||||
public interface IDeptAppointmentHoursService extends IService<DeptAppointmentHours> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.openhis.appointmentmanage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.openhis.appointmentmanage.domain.DeptAppointmentHours;
|
||||
import com.openhis.appointmentmanage.mapper.DeptAppointmentHoursMapper;
|
||||
import com.openhis.appointmentmanage.service.IDeptAppointmentHoursService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DeptAppointmentHoursServiceImpl extends ServiceImpl<DeptAppointmentHoursMapper, DeptAppointmentHours> implements IDeptAppointmentHoursService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getDeptAppthoursList(query) {
|
||||
return request({
|
||||
url: '/appoinment/dept-appthours/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getDeptAppthoursDetail(id) {
|
||||
return request({
|
||||
url: '/appoinment/dept-appthours/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function addDeptAppthours(data) {
|
||||
return request({
|
||||
url: '/appoinment/dept-appthours',
|
||||
method: 'post',
|
||||
data: {
|
||||
institution: data.institution,
|
||||
department: data.department,
|
||||
morningStart: data.morningStart,
|
||||
morningEnd: data.morningEnd,
|
||||
afternoonStart: data.afternoonStart,
|
||||
afternoonEnd: data.afternoonEnd,
|
||||
quota: data.quota,
|
||||
operator: data.operator
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function updateDeptAppthours(data) {
|
||||
return request({
|
||||
url: '/appoinment/dept-appthours',
|
||||
method: 'put',
|
||||
data: {
|
||||
id: data.id,
|
||||
institution: data.institution,
|
||||
department: data.department,
|
||||
morningStart: data.morningStart,
|
||||
morningEnd: data.morningEnd,
|
||||
afternoonStart: data.afternoonStart,
|
||||
afternoonEnd: data.afternoonEnd,
|
||||
quota: data.quota,
|
||||
operator: data.operator
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteDeptAppthours(id) {
|
||||
return request({
|
||||
url: '/appoinment/dept-appthours/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getDepartmentList() {
|
||||
return request({
|
||||
url: '/app-common/department-list',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getTenantList() {
|
||||
return request({
|
||||
url: '/system/tenant/page',
|
||||
method: 'get',
|
||||
params: {
|
||||
pageNum: 1,
|
||||
pageSize: 1000
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -24,3 +24,12 @@ export function cleanOperlog() {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增操作日志
|
||||
export function addLog(data) {
|
||||
return request({
|
||||
url: '/monitor/operlog',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M512 128c-70.69 0-128 57.31-128 128 0 70.69 57.31 128 128 128s128-57.31 128-128c0-70.69-57.31-128-128-128z m0 192c-35.34 0-64-28.66-64-64 0-35.34 28.66-64 64-64 35.34 0 64 28.66 64 64 0 35.34-28.66 64-64 64z" fill="currentColor"/>
|
||||
<path d="M512 128c-70.69 0-128 57.31-128 128 0 70.69 57.31 128 128 70.69 0 128-57.31 128-128 0-70.69-57.31-128-128-128zm0 192c-35.34 0-64-28.66-64-64 0-35.34 28.66-64 64-64 35.34 0 64 28.66 64 64 0 35.34-28.66 64-64 64z" fill="currentColor"/>
|
||||
<path d="M832 832c0-88.36-28.7-172.6-80.4-242.4C702 521 608 480 512 480s-190 41-239.6 109.6C221 659.4 192 743.64 192 832v64h640v-64z" fill="currentColor"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 488 B |
@@ -202,7 +202,7 @@ export const dynamicRoutes = [
|
||||
},
|
||||
],
|
||||
},
|
||||
//租户合同管理路由
|
||||
// 租户合同管理路由
|
||||
{
|
||||
path: '/system/tenant-contract',
|
||||
component: Layout,
|
||||
@@ -217,6 +217,22 @@ export const dynamicRoutes = [
|
||||
},
|
||||
],
|
||||
},
|
||||
// 预约管理路由
|
||||
{
|
||||
path: '/appoinmentmanage',
|
||||
component: Layout,
|
||||
redirect: '/appoinmentmanage/deptappthoursManage',
|
||||
name: 'AppoinmentManage',
|
||||
meta: { title: '预约管理', icon: 'appointment' },
|
||||
children: [
|
||||
{
|
||||
path: 'deptappthoursManage',
|
||||
component: () => import('@/views/appoinmentmanage/deptappthoursManage/index.vue'),
|
||||
name: 'DeptAppthoursManage',
|
||||
meta: { title: '科室预约工作时间维护', icon: 'appointment' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/system/user-auth',
|
||||
component: Layout,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
163
迁移记录-DB变更记录/20250105_add_columns_dept_appointment_hours.sql
Normal file
163
迁移记录-DB变更记录/20250105_add_columns_dept_appointment_hours.sql
Normal file
@@ -0,0 +1,163 @@
|
||||
-- ============================================
|
||||
-- 科室预约工作时间维护表结构
|
||||
-- 创建日期: 2025-01-05
|
||||
-- ============================================
|
||||
|
||||
-- 如果表不存在,创建表
|
||||
CREATE TABLE IF NOT EXISTS dept_appointment_hours (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
institution_name VARCHAR(100) DEFAULT NULL,
|
||||
dept_name VARCHAR(100) DEFAULT NULL,
|
||||
morning_start VARCHAR(20) DEFAULT NULL,
|
||||
morning_end VARCHAR(20) DEFAULT NULL,
|
||||
afternoon_start VARCHAR(20) DEFAULT NULL,
|
||||
afternoon_end VARCHAR(20) DEFAULT NULL,
|
||||
limit_count INTEGER DEFAULT NULL,
|
||||
create_by VARCHAR(50) DEFAULT NULL,
|
||||
create_time TIMESTAMP DEFAULT NULL,
|
||||
update_time TIMESTAMP DEFAULT NULL
|
||||
);
|
||||
|
||||
-- 如果表已存在但缺少列,添加缺失的列
|
||||
-- 添加 institution_name 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'institution_name'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN institution_name VARCHAR(100) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 dept_name 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'dept_name'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN dept_name VARCHAR(100) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 morning_start 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'morning_start'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN morning_start VARCHAR(20) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 morning_end 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'morning_end'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN morning_end VARCHAR(20) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 afternoon_start 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'afternoon_start'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN afternoon_start VARCHAR(20) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 afternoon_end 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'afternoon_end'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN afternoon_end VARCHAR(20) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 limit_count 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'limit_count'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN limit_count INTEGER DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 create_by 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'create_by'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN create_by VARCHAR(50) DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 create_time 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'create_time'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN create_time TIMESTAMP DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加 update_time 列
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
AND column_name = 'update_time'
|
||||
) THEN
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN update_time TIMESTAMP DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 添加注释
|
||||
COMMENT ON TABLE dept_appointment_hours IS '科室预约工作时间维护表';
|
||||
COMMENT ON COLUMN dept_appointment_hours.institution_name IS '所属机构名称';
|
||||
COMMENT ON COLUMN dept_appointment_hours.dept_name IS '科室名称';
|
||||
COMMENT ON COLUMN dept_appointment_hours.morning_start IS '上午开始时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.morning_end IS '上午结束时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.afternoon_start IS '下午开始时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.afternoon_end IS '下午结束时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.limit_count IS '限号数量';
|
||||
COMMENT ON COLUMN dept_appointment_hours.create_by IS '操作人';
|
||||
COMMENT ON COLUMN dept_appointment_hours.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.update_time IS '更新时间';
|
||||
|
||||
-- 验证表结构
|
||||
SELECT
|
||||
column_name,
|
||||
data_type,
|
||||
is_nullable,
|
||||
column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'dept_appointment_hours'
|
||||
ORDER BY ordinal_position;
|
||||
667
迁移记录-DB变更记录/20250106_insert_test_data_dept_appointment_hours.sql
Normal file
667
迁移记录-DB变更记录/20250106_insert_test_data_dept_appointment_hours.sql
Normal file
@@ -0,0 +1,667 @@
|
||||
-- ============================================
|
||||
-- 科室预约工作时间维护 - 字段修改及测试数据
|
||||
-- 生成日期: 2025-01-06
|
||||
-- 说明: 字段统一命名 + 基于系统科室管理生成测试数据
|
||||
-- ============================================
|
||||
|
||||
-- ============================================
|
||||
-- 第一步:修改表结构(如果尚未执行)
|
||||
-- ============================================
|
||||
|
||||
-- 1. 添加新字段
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN IF NOT EXISTS institution VARCHAR(100);
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN IF NOT EXISTS department VARCHAR(100);
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN IF NOT EXISTS quota INTEGER;
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN IF NOT EXISTS operator VARCHAR(50);
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN IF NOT EXISTS created_time TIMESTAMP;
|
||||
ALTER TABLE dept_appointment_hours ADD COLUMN IF NOT EXISTS updated_time TIMESTAMP;
|
||||
|
||||
-- 2. 将旧字段数据复制到新字段
|
||||
UPDATE dept_appointment_hours SET institution = institution_name WHERE institution IS NULL AND institution_name IS NOT NULL;
|
||||
UPDATE dept_appointment_hours SET department = dept_name WHERE department IS NULL AND dept_name IS NOT NULL;
|
||||
UPDATE dept_appointment_hours SET quota = limit_count WHERE quota IS NULL AND limit_count IS NOT NULL;
|
||||
UPDATE dept_appointment_hours SET operator = create_by WHERE operator IS NULL AND create_by IS NOT NULL;
|
||||
UPDATE dept_appointment_hours SET created_time = create_time WHERE created_time IS NULL AND create_time IS NOT NULL;
|
||||
UPDATE dept_appointment_hours SET updated_time = update_time WHERE updated_time IS NULL AND update_time IS NOT NULL;
|
||||
|
||||
-- 3. 删除旧字段
|
||||
ALTER TABLE dept_appointment_hours DROP COLUMN IF EXISTS institution_name;
|
||||
ALTER TABLE dept_appointment_hours DROP COLUMN IF EXISTS dept_name;
|
||||
ALTER TABLE dept_appointment_hours DROP COLUMN IF EXISTS limit_count;
|
||||
ALTER TABLE dept_appointment_hours DROP COLUMN IF EXISTS create_by;
|
||||
ALTER TABLE dept_appointment_hours DROP COLUMN IF EXISTS create_time;
|
||||
ALTER TABLE dept_appointment_hours DROP COLUMN IF EXISTS update_time;
|
||||
|
||||
-- 4. 重置序列,使id从1开始
|
||||
SELECT setval('dept_appointment_hours_id_seq', 1, false);
|
||||
|
||||
-- ============================================
|
||||
-- 第二步:更新列注释
|
||||
-- ============================================
|
||||
|
||||
COMMENT ON COLUMN dept_appointment_hours.institution IS '所属机构';
|
||||
COMMENT ON COLUMN dept_appointment_hours.department IS '科室名称';
|
||||
COMMENT ON COLUMN dept_appointment_hours.morning_start IS '上午开始时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.morning_end IS '上午结束时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.afternoon_start IS '下午开始时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.afternoon_end IS '下午结束时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.quota IS '限号数量';
|
||||
COMMENT ON COLUMN dept_appointment_hours.operator IS '操作人';
|
||||
COMMENT ON COLUMN dept_appointment_hours.created_time IS '创建时间';
|
||||
COMMENT ON COLUMN dept_appointment_hours.updated_time IS '更新时间';
|
||||
|
||||
-- ============================================
|
||||
-- 第三步:清空现有数据并插入测试数据
|
||||
-- ============================================
|
||||
|
||||
-- 清空表数据(如果需要保留现有数据,请注释此行)
|
||||
TRUNCATE TABLE dept_appointment_hours RESTART IDENTITY;
|
||||
|
||||
-- ============================================
|
||||
-- 插入测试数据 - 基于系统管理-基础数据-科室管理中的科室
|
||||
-- ============================================
|
||||
|
||||
-- 1. 内科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'内科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
80,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 2. 外科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'外科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
60,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 3. 妇产科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'妇产科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
50,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 4. 儿科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'儿科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:30',
|
||||
'17:30',
|
||||
70,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 5. 眼科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'眼科门诊',
|
||||
'08:30',
|
||||
'11:30',
|
||||
'14:00',
|
||||
'17:00',
|
||||
40,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 6. 耳鼻喉科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'耳鼻喉科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
45,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 7. 口腔科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'口腔科门诊',
|
||||
'08:00',
|
||||
'11:30',
|
||||
'14:00',
|
||||
'17:00',
|
||||
35,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 8. 皮肤科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'皮肤科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
55,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 9. 中医科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'中医科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
40,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 10. 心内科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'心内科门诊',
|
||||
'08:00',
|
||||
'11:30',
|
||||
'14:00',
|
||||
'17:00',
|
||||
50,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 11. 神经内科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'神经内科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
45,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 12. 呼吸科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'呼吸科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
55,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 13. 消化内科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'消化内科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
50,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 14. 骨科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'骨科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
45,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 15. 泌尿外科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'泌尿外科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
40,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 16. 精神科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'精神科门诊',
|
||||
'09:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
30,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 17. 感染科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'感染科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
50,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 18. 急诊科
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'急诊科',
|
||||
'00:00',
|
||||
'23:59',
|
||||
'00:00',
|
||||
'23:59',
|
||||
100,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 19. 康复科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'康复科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
35,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 20. 体检中心
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'体检中心',
|
||||
'07:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
100,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 21. 血液科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'血液科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
35,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 22. 内分泌科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'内分泌科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
45,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 23. 普外科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'普外科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:30',
|
||||
55,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 24. 神经外科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'神经外科门诊',
|
||||
'08:30',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
40,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- 25. 烧伤科门诊
|
||||
INSERT INTO dept_appointment_hours (
|
||||
institution,
|
||||
department,
|
||||
morning_start,
|
||||
morning_end,
|
||||
afternoon_start,
|
||||
afternoon_end,
|
||||
quota,
|
||||
operator,
|
||||
created_time
|
||||
) VALUES (
|
||||
'演示医院',
|
||||
'烧伤科门诊',
|
||||
'08:00',
|
||||
'12:00',
|
||||
'14:00',
|
||||
'17:00',
|
||||
30,
|
||||
'admin',
|
||||
NOW()
|
||||
);
|
||||
|
||||
-- ============================================
|
||||
-- 验证插入的数据
|
||||
-- ============================================
|
||||
SELECT
|
||||
id,
|
||||
institution AS "所属机构",
|
||||
department AS "科室名称",
|
||||
morning_start AS "上午开始",
|
||||
morning_end AS "上午结束",
|
||||
afternoon_start AS "下午开始",
|
||||
afternoon_end AS "下午结束",
|
||||
quota AS "限号数量",
|
||||
operator AS "操作人",
|
||||
created_time AS "创建时间"
|
||||
FROM dept_appointment_hours
|
||||
ORDER BY id;
|
||||
|
||||
-- 统计总记录数
|
||||
SELECT
|
||||
COUNT(*) AS "总记录数"
|
||||
FROM dept_appointment_hours;
|
||||
|
||||
-- 按科室统计
|
||||
SELECT
|
||||
department AS "科室",
|
||||
COUNT(*) AS "数量"
|
||||
FROM dept_appointment_hours
|
||||
GROUP BY department
|
||||
ORDER BY "数量" DESC;
|
||||
Reference in New Issue
Block a user