package com.ltkj.web.controller.system; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.framework.config.MatchUtils; import com.ltkj.hosp.domain.TjAskHistorys; import com.ltkj.hosp.domain.TjCustomer; import com.ltkj.hosp.service.ITjAskHistorysService; import com.ltkj.hosp.service.ITjCustomerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.enums.BusinessType; import com.ltkj.hosp.domain.TjAskMedicalHistory; import com.ltkj.hosp.service.ITjAskMedicalHistoryService; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.common.core.page.TableDataInfo; /** * 问诊Controller * * @author ltkj_赵佳豪&李格 * @date 2023-04-11 */ @RestController @RequestMapping("/hosp/history") @Api(tags = "问诊接口") public class TjAskMedicalHistoryController extends BaseController { @Autowired private ITjAskMedicalHistoryService tjAskMedicalHistoryService; @Autowired private ITjAskHistorysService historysService; @Autowired private ITjCustomerService customerService; @Resource private ITjCustomerService tjCustomerService; /** * 查询问诊列表 */ // @PreAuthorize("@ss.hasPermi('hosp:history:list')") @GetMapping("/list") public TableDataInfo list(TjAskMedicalHistory tjAskMedicalHistory) { startPage(); List list = tjAskMedicalHistoryService.selectTjAskMedicalHistoryList(tjAskMedicalHistory); return getDataTable(list); } /** * 导出问诊列表 */ // @PreAuthorize("@ss.hasPermi('hosp:history:export')") @Log(title = "问诊", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TjAskMedicalHistory tjAskMedicalHistory) { List list = tjAskMedicalHistoryService.selectTjAskMedicalHistoryList(tjAskMedicalHistory); ExcelUtil util = new ExcelUtil(TjAskMedicalHistory.class); util.exportExcel(response, list, "问诊数据"); } /** * 获取问诊详细信息 */ // @PreAuthorize("@ss.hasPermi('hosp:history:query')") @GetMapping(value = "/{askId}") public AjaxResult getInfo(@PathVariable("askId") Long askId) { return success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(askId)); } /** * 根据客户id获取问诊详细信息 */ @GetMapping(value = "/getInfoById") @ApiOperation(value = "根据客户id获取问诊详细信息") public AjaxResult getInfoById(@RequestParam String userId) { if (null != userId && !"".equals(userId)) { LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); wq.eq(TjAskMedicalHistory::getCusId, Long.valueOf(userId)); TjAskMedicalHistory one = tjAskMedicalHistoryService.getOne(wq); if (one != null) { return success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(one.getAskId())); } TjAskMedicalHistory a = new TjAskMedicalHistory(); a.setCusId(Long.valueOf(userId)); TjCustomer byId = customerService.getById(a.getCusId()); if (byId != null) { a.setCusName(MatchUtils.hideCusName(byId.getCusName())); } return AjaxResult.success(a); } return AjaxResult.success(); } /** * 新增问诊 */ //@PreAuthorize("@ss.hasPermi('hosp:history:add')") @Log(title = "问诊", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TjAskMedicalHistory tjAskMedicalHistory) { return toAjax(tjAskMedicalHistoryService.insertTjAskMedicalHistory(tjAskMedicalHistory)); } /** * pc端修改问诊 */ @ApiOperation(value = "pc端修改问诊") //@PreAuthorize("@ss.hasPermi('hosp:history:edit')") @Log(title = "问诊", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TjAskMedicalHistory tjAskMedicalHistory) { boolean b =false; tjAskMedicalHistory.setFromBy("PC端"); if (tjAskMedicalHistory.getAskId()!=null){ b = tjAskMedicalHistoryService.updateById(tjAskMedicalHistory); }else { b = tjAskMedicalHistoryService.save(tjAskMedicalHistory); } //boolean b = tjAskMedicalHistoryService.saveOrUpdate(tjAskMedicalHistory); if (b){ List tjAskHistorysList = tjAskMedicalHistory.getTjAskHistorysList(); if (tjAskHistorysList!=null&&tjAskHistorysList.size()>0){ for (TjAskHistorys tjAskHistorys : tjAskMedicalHistory.getTjAskHistorysList()) { tjAskHistorys.setAskId(tjAskMedicalHistory.getAskId()); boolean b1 = historysService.saveOrUpdate(tjAskHistorys); if (!b1){ return AjaxResult.error(); } } } return AjaxResult.success(); } return AjaxResult.error(); //return toAjax(tjAskMedicalHistoryService.updateTjAskMedicalHistory(tjAskMedicalHistory)); } /** * 小程序根据客户身份证号获取问诊详细信息 */ @GetMapping(value = "/appGetInfoById") @ApiOperation(value = "小程序根据客户身份证号获取问诊详细信息") public AjaxResult appGetInfoById(@RequestParam("cusIdCard") String cusIdCard) { LambdaQueryWrapper wqqq=new LambdaQueryWrapper<>(); wqqq.eq(TjCustomer::getCusIdcard,cusIdCard); TjCustomer one1 = tjCustomerService.getOne(wqqq); if (one1!=null){ LambdaQueryWrapper wq=new LambdaQueryWrapper<>(); wq.eq(TjAskMedicalHistory::getCusId,one1.getCusId()); TjAskMedicalHistory one = tjAskMedicalHistoryService.getOne(wq); if (one!=null){ return success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(one.getAskId())); }else { TjAskMedicalHistory a=new TjAskMedicalHistory(); a.setCusId(Long.valueOf(one1.getCusId())); TjCustomer byId = customerService.getById(a.getCusId()); if (byId!=null){ a.setCusName(byId.getCusName()); } return AjaxResult.success(a); } } return AjaxResult.error("查无此人"); } /** * 小程序修改问诊 */ @ApiOperation(value = "小程序修改问诊") @PostMapping("/appEdit") public AjaxResult appEdit(@RequestBody TjAskMedicalHistory tjAskMedicalHistory) { boolean b =false; tjAskMedicalHistory.setFromBy("小程序端"); if (tjAskMedicalHistory.getAskId()!=null){ b = tjAskMedicalHistoryService.updateById(tjAskMedicalHistory); }else { b = tjAskMedicalHistoryService.save(tjAskMedicalHistory); } if (b){ List tjAskHistorysList = tjAskMedicalHistory.getTjAskHistorysList(); if (tjAskHistorysList!=null&&tjAskHistorysList.size()>0){ for (TjAskHistorys tjAskHistorys : tjAskMedicalHistory.getTjAskHistorysList()) { tjAskHistorys.setAskId(tjAskMedicalHistory.getAskId()); boolean b1 = historysService.saveOrUpdate(tjAskHistorys); if (!b1){ return AjaxResult.error(); } } } return AjaxResult.success("修改成功"); } return AjaxResult.error("修改失败"); } /** * 删除问诊 */ // @PreAuthorize("@ss.hasPermi('hosp:history:remove')") @Log(title = "问诊", businessType = BusinessType.DELETE) @DeleteMapping("/{askIds}") public AjaxResult remove(@PathVariable Long[] askIds) { return toAjax(tjAskMedicalHistoryService.deleteTjAskMedicalHistoryByAskIds(askIds)); } }