| | |
| | | package com.ltkj.web.controller.system; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.hosp.domain.TjHzReplyLog; |
| | | import com.ltkj.hosp.domain.TjOrder; |
| | | import com.ltkj.hosp.service.ITjHzReplyLogService; |
| | | import com.ltkj.hosp.service.ITjOrderService; |
| | | import com.ltkj.system.service.ISysDeptService; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | 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; |
| | |
| | | @Autowired |
| | | private ITjHzLogService tjHzLogService; |
| | | |
| | | @Resource |
| | | private ISysDeptService deptService; |
| | | @Resource |
| | | private ITjOrderService tjOrderService; |
| | | @Autowired |
| | | private ITjHzReplyLogService tjHzReplyLogService; |
| | | |
| | | |
| | | /** |
| | | * 查询会诊申请记录列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(TjHzLog tjHzLog) { |
| | | startPage(); |
| | | LambdaQueryWrapper<TjHzLog> wq=new LambdaQueryWrapper<>(); |
| | | if (tjHzLog.getTjNumber()!=null){ |
| | | wq.eq(TjHzLog::getTjNumber,tjHzLog.getTjNumber()); |
| | | LambdaQueryWrapper<TjHzLog> wq = new LambdaQueryWrapper<>(); |
| | | if (tjHzLog.getTjNumber() != null) { |
| | | wq.eq(TjHzLog::getTjNumber, tjHzLog.getTjNumber()); |
| | | } |
| | | if (tjHzLog.getUserName()!=null){ |
| | | wq.like(TjHzLog::getUserName,tjHzLog.getUserName()); |
| | | if (tjHzLog.getUserName() != null) { |
| | | wq.like(TjHzLog::getUserName, tjHzLog.getUserName()); |
| | | } |
| | | if (tjHzLog.getHzType()!=null){ |
| | | wq.eq(TjHzLog::getHzType,tjHzLog.getHzType()); |
| | | if (tjHzLog.getHzType() != null) { |
| | | wq.eq(TjHzLog::getHzType, tjHzLog.getHzType()); |
| | | } |
| | | List<TjHzLog> list = tjHzLogService.list(wq); |
| | | |
| | | for (TjHzLog hzLog : list) { |
| | | |
| | | List<String> a = new ArrayList<>(); |
| | | List<String> b = new ArrayList<>(); |
| | | if ("0".equals(tjHzLog.getHzType())) { |
| | | continue; |
| | | } |
| | | if (hzLog.getHzDeptId() != null) { |
| | | StringBuffer aa = new StringBuffer(); |
| | | final String[] split = hzLog.getHzDeptId().split(","); |
| | | for (String s : split) { |
| | | final SysDept byId = deptService.getById(s); |
| | | a.add(byId.getDeptName()); |
| | | b.add(String.valueOf(byId.getDeptId())); |
| | | aa.append(byId.getDeptName()); |
| | | aa.append(";"); |
| | | } |
| | | hzLog.setHzDeptName(String.valueOf(aa)); |
| | | } |
| | | |
| | | hzLog.setHzDeptNameList(a); |
| | | hzLog.setHzDeptIdList(b); |
| | | //会诊记录的评论 |
| | | if (hzLog.getId() != null) { |
| | | LambdaQueryWrapper<TjHzReplyLog> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjHzReplyLog::getHzId, hzLog.getId()); |
| | | wq1.orderByDesc(TjHzReplyLog::getCreateTime); |
| | | List<TjHzReplyLog> list1 = tjHzReplyLogService.list(wq1); |
| | | hzLog.setHzReplyLogsList(list1); |
| | | } |
| | | |
| | | } |
| | | return getDataTable(list); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Log(title = "会诊申请记录", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody TjHzLog tjHzLog){ |
| | | public AjaxResult add(@RequestBody TjHzLog tjHzLog) { |
| | | if (tjHzLog.getHzDeptIdList() == null && "1".equals(tjHzLog.getHzType()) && tjHzLog.getHzDeptIdList().size() == 0) { |
| | | return AjaxResult.error("请选择科室"); |
| | | } |
| | | if (tjHzLog.getHzDeptIdList() != null && tjHzLog.getHzDeptIdList().size() > 0) { |
| | | StringBuilder str = new StringBuilder(); |
| | | for (int i = 0; i < tjHzLog.getHzDeptIdList().size(); i++) { |
| | | str = str.append(tjHzLog.getHzDeptIdList().get(i)); |
| | | if (i != tjHzLog.getHzDeptIdList().size() - 1) { |
| | | str = str.append(","); |
| | | } |
| | | } |
| | | tjHzLog.setHzDeptId(String.valueOf(str)); |
| | | } |
| | | if (tjHzLog.getOrderId() == null) { |
| | | return AjaxResult.error("出错了,请联系工作人员"); |
| | | } |
| | | final TjOrder byId = tjOrderService.getById(tjHzLog.getOrderId()); |
| | | if (byId != null) { |
| | | byId.setIsHz(1); |
| | | tjOrderService.updateById(byId); |
| | | } |
| | | |
| | | return toAjax(tjHzLogService.save(tjHzLog)); |
| | | } |
| | | |
| | | /** |
| | | * 修改会诊申请记录 |
| | | |
| | | */ |
| | | @Log(title = "会诊申请记录 ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody TjHzLog tjHzLog){ |
| | | public AjaxResult edit(@RequestBody TjHzLog tjHzLog) { |
| | | if ("1".equals(tjHzLog.getHzType())) { |
| | | if (tjHzLog.getHzDeptIdList() != null && tjHzLog.getHzDeptIdList().size() > 0) { |
| | | StringBuilder str = new StringBuilder(); |
| | | for (int i = 0; i < tjHzLog.getHzDeptIdList().size(); i++) { |
| | | str = str.append(tjHzLog.getHzDeptIdList().get(i)); |
| | | if (i != tjHzLog.getHzDeptIdList().size() - 1) { |
| | | str = str.append(","); |
| | | } |
| | | } |
| | | tjHzLog.setHzDeptId(String.valueOf(str)); |
| | | }else { |
| | | return AjaxResult.error("请选择科室"); |
| | | } |
| | | } |
| | | return toAjax(tjHzLogService.saveOrUpdate(tjHzLog)); |
| | | } |
| | | |
| | |
| | | * 删除会诊申请记录 |
| | | */ |
| | | @Log(title = "会诊申请记录 ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[]ids) { |
| | | @DeleteMapping("/remove") |
| | | public AjaxResult remove(@RequestBody Long[] ids) { |
| | | return toAjax(tjHzLogService.removeByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | /** |
| | | * 判断会诊记录是否含有当前登录的部门 |
| | | */ |
| | | @GetMapping("/hzHasDept") |
| | | public AjaxResult hzHasDept(@RequestParam String tjNumber, |
| | | @RequestParam String deptId) { |
| | | List<TjHzLog> res = new ArrayList<>(); |
| | | LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjOrder::getTjNumber, tjNumber); |
| | | wq1.eq(TjOrder::getIsHz, 1); |
| | | final List<TjOrder> list = tjOrderService.list(wq1); |
| | | if (list == null || list.isEmpty()) { |
| | | return AjaxResult.success(0); |
| | | } |
| | | for (TjOrder tjOrder : list) { |
| | | LambdaQueryWrapper<TjHzLog> wq2 = new LambdaQueryWrapper<>(); |
| | | wq2.eq(TjHzLog::getOrderId, tjOrder.getOrderId()); |
| | | List<TjHzLog> list1 = tjHzLogService.list(wq2); |
| | | for (TjHzLog tjHzLog : list1) { |
| | | if ("0".equals(tjHzLog.getHzType())) { |
| | | res.add(tjHzLog); |
| | | } else if ("1".equals(tjHzLog.getHzType())) { |
| | | final String[] split = tjHzLog.getHzDeptId().split(","); |
| | | // if ("100".equals(deptId)){ |
| | | // res.add(tjHzLog); |
| | | // continue; |
| | | // } |
| | | if (Arrays.asList(split).contains(deptId)) { |
| | | res.add(tjHzLog); |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | for (TjHzLog re : res) { |
| | | List<String> a = new ArrayList<>(); |
| | | List<String> b = new ArrayList<>(); |
| | | if (re.getHzDeptId() != null) { |
| | | final String[] split = re.getHzDeptId().split(","); |
| | | for (String s : split) { |
| | | final SysDept byId = deptService.getById(s); |
| | | a.add(byId.getDeptName()); |
| | | b.add(String.valueOf(byId.getDeptId())); |
| | | } |
| | | } |
| | | re.setHzDeptNameList(a); |
| | | re.setHzDeptIdList(b); |
| | | //会诊记录的评论 |
| | | LambdaQueryWrapper<TjHzReplyLog> wq11 = new LambdaQueryWrapper<>(); |
| | | wq11.eq(TjHzReplyLog::getHzId, re.getId()); |
| | | List<TjHzReplyLog> list1 = tjHzReplyLogService.list(wq11); |
| | | re.setHzReplyLogsList(list1); |
| | | } |
| | | return AjaxResult.success(res); |
| | | } |
| | | |
| | | } |