package com.ltkj.web.jmreport;
|
|
import cn.hutool.core.date.DateUtil;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ltkj.common.utils.StringUtils;
|
import com.ltkj.hosp.domain.*;
|
import com.ltkj.hosp.mapper.TjAskHistorysMapper;
|
import com.ltkj.hosp.service.*;
|
import com.ltkj.system.service.ISysDeptService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpHeaders;
|
import org.springframework.util.Base64Utils;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestTemplate;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
import java.net.URLEncoder;
|
import java.util.*;
|
|
|
/**
|
* @Company: 西安路泰科技有限公司
|
* @Author: lige
|
* @Date: 2023/3/7 11:56
|
*/
|
@RestController
|
@RequestMapping("/hosp/order")
|
@Api(tags = "报表数据填充接口")
|
@Slf4j
|
public class ReportDataController {
|
@Resource
|
private ITjOrderService tjOrderService;
|
|
@Resource
|
private ITjCustomerService tjCustomerService;
|
|
@Resource
|
private IDictCompService compService;
|
|
@Resource
|
private ITjPackageService packageService;
|
|
@Resource
|
private ISysDeptService deptService;
|
|
@Resource
|
private ITjProjectService projectService;
|
|
@Autowired
|
private ITjOrderDetailService detailService;
|
|
@Resource
|
private ITjOrderRemarkService tjOrderRemarkService;
|
@Resource
|
private ITjStandardService tjStandardService;
|
@Resource
|
private ITjAdviceService tjAdviceService;
|
|
|
@Resource
|
private TjAskHistorysMapper tjAskHistorysMapper;
|
|
/**
|
* 该体检号是否可生成导检单
|
*/
|
@GetMapping("/hasReport/{tjNumber}")
|
@ApiOperation(value = "该体检号是否可生成导检单")
|
public int hasReport(@PathVariable("tjNumber") String tjNumber) {
|
LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
|
wq.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder tjOrder = tjOrderService.getOne(wq);
|
LambdaQueryWrapper<TjOrderDetail> wq1 = new LambdaQueryWrapper<>();
|
wq1.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId());
|
//排除未付款项目
|
//wq1.isNotNull(TjOrderDetail::getFlowingWaterId);
|
List<TjOrderDetail> detailList = detailService.list(wq1);
|
if (detailList.size()==0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 生成导诊单报表
|
*/
|
@GetMapping("/getCusInfoByTjNum")
|
@ApiOperation(value = "生成导诊单报表")
|
public Map<String, Object> getCusInfoByTjNum(@RequestParam("tjNumber") String tjNumber) {
|
Map<String, Object> map = new HashMap<>();
|
List<ReportVo> list1 = new ArrayList<>();
|
LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
|
wq.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder tjOrder = tjOrderService.getOne(wq);
|
if (null != tjOrder) {
|
//该客户信息
|
LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>();
|
wq1.eq(TjCustomer::getCusId, tjOrder.getUserId());
|
TjCustomer tjCustomer = tjCustomerService.getOne(wq1);
|
ReportVo reportVo = new ReportVo();
|
reportVo.setTjNumber(tjNumber);
|
if (tjCustomer!=null){
|
reportVo.setCusName(tjCustomer.getCusName());
|
if (tjCustomer.getCusSex()!=null){
|
switch (String.valueOf(tjCustomer.getCusSex())) {
|
case "0":
|
reportVo.setCusSex("男");
|
break;
|
case "1":
|
reportVo.setCusSex("女");
|
break;
|
default:
|
reportVo.setCusSex("未知");
|
break;
|
}
|
}else {
|
reportVo.setCusSex("/");
|
}
|
if (tjCustomer.getCusMarryStatus()!=null){
|
switch (tjCustomer.getCusMarryStatus()) {
|
case "1":
|
reportVo.setCusMarryStatus("未婚");
|
break;
|
case "8":
|
reportVo.setCusMarryStatus("未知");
|
break;
|
default:
|
reportVo.setCusMarryStatus("已婚");
|
break;
|
}
|
}else {
|
reportVo.setCusMarryStatus("/");
|
}
|
|
if (compService.getById(tjOrder.getFirmId()) != null) {
|
reportVo.setComp(compService.getById(tjOrder.getFirmId()).getCnName());
|
} else {
|
reportVo.setComp("无");
|
}
|
if (null != packageService.getById(tjOrder.getPacId())) {
|
reportVo.setPacName(packageService.getById(tjOrder.getPacId()).getPacName());
|
} else {
|
reportVo.setPacName("无");
|
}
|
reportVo.setCusPhone(tjCustomer.getCusPhone());
|
}
|
reportVo.setTm(tjOrder.getTm());
|
reportVo.setTjTime(DateUtil.format(tjOrder.getCreateTime(), "yyyy-MM-DD"));
|
list1.add(reportVo);
|
}
|
map.put("data", list1);
|
return map;
|
}
|
|
|
/**
|
* 生成导诊单报表-科室项目列表
|
*/
|
@GetMapping("/getDeptProByTjNum")
|
@ApiOperation(value = "生成导诊单报表-科室项目列表")
|
public Map<String, Object> getDeptProByTjNum(@RequestParam("tjNumber") String tjNumber) {
|
Map<String, Object> map = new HashMap<>();
|
List<ReportVo> list = new ArrayList<>();
|
LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
|
wq0.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder order = tjOrderService.getOne(wq0);
|
if (null != order) {
|
LambdaQueryWrapper<TjOrderDetail> wq1 = new LambdaQueryWrapper<>();
|
wq1.eq(TjOrderDetail::getOrderId, order.getOrderId());
|
//排除未付款项目
|
//wq1.isNotNull(TjOrderDetail::getFlowingWaterId);
|
List<TjOrderDetail> detailList = detailService.list(wq1);
|
if (null != detailList && detailList.size() > 0) {
|
for (TjOrderDetail detail : detailList) {
|
TjProject byId = projectService.getById(detail.getProId());
|
if (null != byId && byId.getProParentId() == 0) {
|
ReportVo reportVo = new ReportVo();
|
reportVo.setDeptName(deptService.getById(byId.getDeptId()).getDeptName());
|
reportVo.setProName(byId.getProName());
|
list.add(reportVo);
|
}
|
}
|
}
|
}
|
map.put("data", list);
|
return map;
|
}
|
|
|
/**
|
* 该体检号是否可生成体检报告
|
*/
|
@GetMapping("/hasReportEnd/{tjNumber}")
|
@ApiOperation(value = "该体检号是否可生成体检报告")
|
public int hasReportEnd(@PathVariable("tjNumber") String tjNumber) {
|
LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
|
wq.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder tjOrder = tjOrderService.getOne(wq);
|
if (tjOrder.getFinishTime()==null) {
|
return 0;
|
}
|
return 1;
|
}
|
|
|
/**
|
* 体检报告封面页
|
*/
|
@GetMapping("/getReportByTjNumber")
|
@ApiOperation(value = "体检报告封面页")
|
public Map<String, Object> getReportByTjNumber(@RequestParam("tjNumber") String tjNumber) {
|
Map<String, Object> map = new HashMap<>();
|
List<ReportVo> list1 = new ArrayList<>();
|
LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
|
wq.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder tjOrder = tjOrderService.getOne(wq);
|
if (null != tjOrder) {
|
//该客户信息
|
LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>();
|
wq1.eq(TjCustomer::getCusId, tjOrder.getUserId());
|
TjCustomer tjCustomer = tjCustomerService.getOne(wq1);
|
if(tjCustomer!=null){
|
ReportVo reportVo = new ReportVo();
|
reportVo.setTjNumber(tjNumber);
|
reportVo.setCusName(tjCustomer.getCusName());
|
if (tjCustomer.getCusSex()!=null){
|
switch (String.valueOf(tjCustomer.getCusSex())) {
|
case "0":
|
reportVo.setCusSex("男");
|
break;
|
case "1":
|
reportVo.setCusSex("女");
|
break;
|
default:
|
reportVo.setCusSex("未知");
|
break;
|
}
|
}else {
|
reportVo.setCusSex("未知");
|
}
|
if (tjCustomer.getCusMarryStatus()!=null){
|
switch (tjCustomer.getCusMarryStatus()) {
|
case "1":
|
reportVo.setCusMarryStatus("未婚");
|
break;
|
case "8":
|
reportVo.setCusMarryStatus("未知");
|
break;
|
default:
|
reportVo.setCusMarryStatus("已婚");
|
break;
|
}
|
}else {
|
reportVo.setCusMarryStatus("未知");
|
}
|
|
if (compService.getById(tjOrder.getFirmId()) != null) {
|
reportVo.setComp(compService.getById(tjOrder.getFirmId()).getCnName());
|
} else {
|
reportVo.setComp("无");
|
}
|
if (null != packageService.getById(tjOrder.getPacId())) {
|
reportVo.setPacName(packageService.getById(tjOrder.getPacId()).getPacName());
|
} else {
|
reportVo.setPacName("无");
|
}
|
Date cusBrithday = tjCustomer.getCusBrithday();
|
int age = DateUtil.ageOfNow(cusBrithday);
|
reportVo.setCusAge(age);
|
reportVo.setCusPhone(tjCustomer.getCusPhone());
|
reportVo.setTjTime(DateUtil.format(tjOrder.getCreateTime(), "yyyy-MM-DD"));
|
reportVo.setCheckAdvice(tjOrder.getCheckAdvice());
|
list1.add(reportVo);
|
}
|
|
}
|
map.put("data", list1);
|
return map;
|
}
|
|
|
/**
|
* 体检报告项目列表
|
*/
|
@GetMapping("/getReportDetail")
|
@ApiOperation(value = "体检报告项目列表")
|
public Map<String, Object> getReportDetail(@RequestParam("tjNumber") String tjNumber) {
|
Map<String, Object> map = new HashMap<>();
|
List<ReportDetailVo> list = new ArrayList<>();
|
LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
|
wq0.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder order = tjOrderService.getOne(wq0);
|
if (null != order) {
|
LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>();
|
wq2.eq(TjOrderDetail::getOrderId, order.getOrderId());
|
wq2.isNotNull(TjOrderDetail::getFlowingWaterId);
|
List<TjOrderDetail> detailList = detailService.list(wq2);
|
if (null != detailList && detailList.size() > 0) {
|
for (TjOrderDetail detail : detailList) {
|
TjProject byId = projectService.getById(detail.getProId());
|
if (byId.getProParentId() != 0) {
|
ReportDetailVo rd = new ReportDetailVo();
|
TjProject byId1 = projectService.getById(byId.getProParentId());
|
rd.setProParentName(byId1.getProName());
|
rd.setDoctorName(detail.getDoctorName());
|
rd.setProName(byId.getProName());
|
rd.setResult(detail.getProResult());
|
LambdaQueryWrapper<TjStandard> wq3 = new LambdaQueryWrapper<>();
|
wq3.eq(TjStandard::getProId, byId.getProId());
|
List<TjStandard> list2 = tjStandardService.list(wq3);
|
if (list2.size() == 0) {
|
rd.setCompany("/");
|
rd.setStandard("/");
|
} else if (list2.size() == 1) {
|
rd.setCompany(list2.get(0).getCompany());
|
String tjStandardGtValue = list2.get(0).getTjStandardGtValue();
|
String tjStandardLtValue = list2.get(0).getTjStandardLtValue();
|
rd.setStandard(tjStandardLtValue + "-" + tjStandardGtValue);
|
} else {
|
//该客户信息
|
LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
|
wq.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder tjOrder = tjOrderService.getOne(wq);
|
LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>();
|
wq1.eq(TjCustomer::getCusId, tjOrder.getUserId());
|
TjCustomer tjCustomer = tjCustomerService.getOne(wq1);
|
int age = DateUtil.ageOfNow(tjCustomer.getCusBrithday());
|
for (TjStandard tjStandard : list2) {
|
LambdaQueryWrapper<TjStandard> wq4 = new LambdaQueryWrapper<>();
|
if (tjStandard.getTjSex() != null) {
|
wq4.eq(TjStandard::getTjSex, tjCustomer.getCusSex());
|
}
|
if (tjStandard.getTjType() != null) {
|
wq4.eq(TjStandard::getTjType, StringUtils.getAgeType(age));
|
}
|
TjStandard standard = tjStandardService.getOne(wq4);
|
rd.setCompany(standard.getCompany());
|
String tjStandardGtValue = standard.getTjStandardGtValue();
|
String tjStandardLtValue = standard.getTjStandardLtValue();
|
rd.setStandard(tjStandardLtValue + "-" + tjStandardGtValue);
|
}
|
}
|
list.add(rd);
|
}
|
}
|
}
|
}
|
map.put("data", list);
|
return map;
|
}
|
|
/**
|
* 体检报告项目列表备注和医生
|
*/
|
@GetMapping("/getReportDetailRemark")
|
@ApiOperation(value = "体检报告项目列表备注和医生")
|
public Map<String, Object> getReportDetailRemark(@RequestParam("tjNumber") String tjNumber) {
|
Map<String, Object> map = new HashMap<>();
|
List<ReportDetailVo> list = new ArrayList<>();
|
LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
|
wq0.eq(TjOrder::getTjNumber, tjNumber);
|
TjOrder order = tjOrderService.getOne(wq0);
|
if (null != order) {
|
LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>();
|
wq2.eq(TjOrderDetail::getOrderId, order.getOrderId());
|
wq2.isNotNull(TjOrderDetail::getFlowingWaterId);
|
List<TjOrderDetail> detailList = detailService.list(wq2);
|
if (null != detailList && detailList.size() > 0) {
|
for (TjOrderDetail detail : detailList) {
|
TjProject byId = projectService.getById(detail.getProId());
|
if (byId.getProParentId() == 0) {
|
ReportDetailVo rd = new ReportDetailVo();
|
LambdaQueryWrapper<TjOrderRemark> wq3 = new LambdaQueryWrapper<>();
|
wq3.eq(TjOrderRemark::getTjNumber, tjNumber);
|
List<TjOrderRemark> a = tjOrderRemarkService.list(wq3);
|
for (TjOrderRemark tjOrderRemark : a) {
|
rd.setProName(byId.getProName() + ":");
|
rd.setRemark(tjOrderRemark.getRemark());
|
rd.setDoctorName(tjOrderRemark.getDoctorName());
|
}
|
list.add(rd);
|
}
|
}
|
}
|
}
|
map.put("data", list);
|
return map;
|
}
|
|
|
|
/**
|
* 职业健康报告查询既往病史
|
*/
|
@GetMapping("/jiwangbingshi")
|
@ApiOperation(value = "职业健康报告查询既往病史")
|
public String jiwangbingshi(@RequestParam("tjNumber") String tjNumber) {
|
final String jiwangbingshi = tjAskHistorysMapper.jiwangbingshi(tjNumber);
|
return jiwangbingshi;
|
}
|
|
|
}
|