package com.ruoyi.outpatientvisit.controller;
|
|
import com.ruoyi.common.annotation.AddOrgId;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.service.dto.PatMedReq;
|
import com.ruoyi.common.core.service.dto.PatMedRes;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.utils.PageUtils;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.outpatientvisit.domain.PatMedOuthosp;
|
import com.ruoyi.outpatientvisit.service.OuthospDataService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.collections4.CollectionUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.lang.reflect.Array;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 患者门诊记录 Controller —— 从 {@code ruoyi-admin} 的 {@code PatMedOuthospController}
|
* <b>整体迁入</b>。
|
*
|
* <h3>⚠️ URL 一个都不能变</h3>
|
* 类级路径仍是 {@code /smartor/patouthosp},方法级路径逐字照抄。
|
* 前端 {@code smartor-web/src/api/AiCentre/EChartsdata.js} 在用其中的
|
* {@code selectPatMedOuthospCount},改了就无法回归。
|
* 由 {@code sql/_probe/verify_outhosp_url_equivalence.py} 把关。
|
*
|
* <h3>与原实现的等价改写(已登记)</h3>
|
* <ol>
|
* <li>不再经 smartor 的 {@code IPatMedOuthospService},改为本模块
|
* {@link OuthospDataService} —— 原 Service 的 10 个方法<b>全部</b>已迁入本模块
|
* (含跨域富化与统计,它们改走 ruoyi-common 契约);</li>
|
* <li>原文件里注释掉的 {@code /getInfo/{id}} 端点<b>保持注释状态</b>,不启用
|
* (启用会新增一个前端未知的端点,且底层 {@code selectPatMedOuthospById} 是空壳);</li>
|
* <li>{@code list} 仍<b>调用两次</b> {@code selectList}(第一次带分页取列表、
|
* 第二次去掉分页只为拿 count)—— 这是原实现的写法,原样保留。
|
* 注意富化只在 {@code pageNum != null} 时发生,故第二次调用不会重复富化。</li>
|
* </ol>
|
*
|
* <h3>开关</h3>
|
* 本类<b>不挂</b>开关拦截器:这 8 个端点都是门诊记录的基础查询/CRUD
|
* (前端管理页在用),{@code outpatientvisit.enabled} 只该控制"要不要生成门诊随访"。
|
*
|
* <h3>⚠️ 保留的原实现缺陷(原样保留,勿"顺手修")</h3>
|
* <ul>
|
* <li>{@code getDeptCodeByPatId} 底层在列表为空时会越界(见 {@link OuthospDataService});</li>
|
* <li>{@code remove} / {@code selectById} 底层是空壳(恒返回 0 / null)。</li>
|
* </ul>
|
*/
|
@Slf4j
|
@Api(description = "患者门诊记录")
|
@RestController
|
@RequestMapping("/smartor/patouthosp")
|
public class OuthospController extends BaseController {
|
|
@Autowired
|
private OuthospDataService service;
|
|
/**
|
* 查询患者门诊记录列表。
|
* <p>逐行对应原 {@code selectPatMedOuthosplist}(L64-75)。
|
*/
|
//@PreAuthorize("@ss.hasPermi('smartor:patouthosp:list')")
|
@AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
|
@PostMapping("/selectPatMedOuthospList")
|
@ApiOperation("查询患者门诊记录列表")
|
public Map<String, Object> selectPatMedOuthosplist(@RequestBody PatMedOuthosp patMedOuthosp) {
|
patMedOuthosp.setPageNum(PageUtils.getOffset(patMedOuthosp.getPageNum(), patMedOuthosp.getPageSize()));
|
SysUser user = getLoginUser().getUser();
|
patMedOuthosp.setOrgid(user.getOrgid());
|
List<PatMedOuthosp> list = service.selectList(patMedOuthosp);
|
patMedOuthosp.setPageNum(null);
|
patMedOuthosp.setPageSize(null);
|
List<PatMedOuthosp> all = service.selectList(patMedOuthosp);
|
Integer count = 0;
|
if (CollectionUtils.isNotEmpty(all)) {
|
count = all.size();
|
}
|
return getDataTable3(count, list);
|
}
|
|
/**
|
* 查询门诊看病人次和人数。
|
*/
|
@AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
|
@PostMapping("/selectPatMedOuthospCount")
|
@ApiOperation("查询门诊看病人次和人数")
|
public AjaxResult selectPatMedOuthospCount(@RequestBody PatMedReq patMedReq) {
|
SysUser user = getLoginUser().getUser();
|
patMedReq.setOrgid(user.getOrgid());
|
PatMedRes patMedRes = service.selectCount(patMedReq);
|
return success(patMedRes);
|
}
|
|
/**
|
* 查询部门编码通过 userId。
|
*/
|
@PostMapping("/getDeptCodeByPatId")
|
@ApiOperation("查询部门编码通过userId")
|
public AjaxResult getDeptCodeByPatId(@RequestBody PatMedOuthosp patMedOuthosp) {
|
return success(service.getDeptCodeByPatId(patMedOuthosp));
|
}
|
|
/**
|
* 导出患者门诊记录列表。
|
*/
|
//@PreAuthorize("@ss.hasPermi('smartor:patouthosp:export')")
|
@Log(title = "患者门诊记录", businessType = BusinessType.EXPORT)
|
@ApiOperation("患者门诊记录")
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, PatMedOuthosp patMedOuthosp) {
|
List<PatMedOuthosp> list = service.selectList(patMedOuthosp);
|
ExcelUtil<PatMedOuthosp> util = new ExcelUtil<PatMedOuthosp>(PatMedOuthosp.class);
|
util.exportExcel(response, list, "患者门诊记录数据");
|
}
|
|
// /**
|
// * 获取患者门诊记录详细信息
|
// */
|
// @ApiOperation("获取患者门诊记录详细信息")
|
// @ApiImplicitParam(name = "getInfo", value = "主键ID", dataType = "long", dataTypeClass = Long.class)
|
// //@PreAuthorize("@ss.hasPermi('smartor:patouthosp:query')")
|
// @GetMapping(value = "getInfo/{id}")
|
// public AjaxResult getInfo(@PathVariable("id") Long id) {
|
// return success(service.selectById(id));
|
// }
|
|
/**
|
* 新增患者门诊记录。
|
*/
|
@ApiOperation("新增患者门诊记录")
|
//@PreAuthorize("@ss.hasPermi('smartor:patouthosp:add')")
|
@Log(title = "患者门诊记录", businessType = BusinessType.INSERT)
|
@AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
|
@PostMapping("/add")
|
public AjaxResult add(@RequestBody PatMedOuthosp patMedOuthosp) {
|
SysUser user = getLoginUser().getUser();
|
patMedOuthosp.setOrgid(user.getOrgid());
|
return toAjax(service.insert(patMedOuthosp));
|
}
|
|
/**
|
* 修改患者门诊记录。
|
*/
|
@ApiOperation("修改患者门诊记录")
|
//@PreAuthorize("@ss.hasPermi('smartor:patouthosp:edit')")
|
@Log(title = "患者门诊记录", businessType = BusinessType.UPDATE)
|
@AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
|
@PostMapping("/edit")
|
public AjaxResult edit(@RequestBody PatMedOuthosp patMedOuthosp) {
|
return toAjax(service.update(patMedOuthosp));
|
}
|
|
/**
|
* 删除患者门诊记录。
|
*/
|
@ApiOperation("删除患者门诊记录")
|
//@PreAuthorize("@ss.hasPermi('smartor:patouthosp:remove')")
|
@ApiImplicitParam(name = "remove", value = "主键ID", dataType = "long", dataTypeClass = Array.class)
|
@Log(title = "患者门诊记录", businessType = BusinessType.DELETE)
|
@GetMapping("/remove/{ids}")
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
return toAjax(service.deleteByIds(ids));
|
}
|
}
|