package com.ltkj.web.controller.mall;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.framework.config.UserHoder;
|
import com.ltkj.hosp.domain.TjAskHistorys;
|
import com.ltkj.hosp.domain.TjAskMedicalHistory;
|
import com.ltkj.hosp.domain.TjCustomer;
|
import com.ltkj.hosp.service.ITjAskHistorysService;
|
import com.ltkj.hosp.service.ITjAskMedicalHistoryService;
|
import com.ltkj.hosp.service.ITjCustomerService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
|
/**
|
* @Company: 西安路泰科技有限公司
|
* @Author: zjh
|
* @Date: 2023/7/26 08:53
|
*/
|
|
|
|
@RestController
|
@RequestMapping("/cus/history")
|
@Api(tags = "体检小程序端问诊记录接口")
|
public class WxTjAskMedicalHistoryController {
|
|
@Resource
|
private ITjAskMedicalHistoryService tjAskMedicalHistoryService;
|
@Resource
|
private ITjAskHistorysService historysService;
|
@Resource
|
private ITjCustomerService customerService;
|
@Resource
|
private ITjCustomerService tjCustomerService;
|
|
|
/**
|
* 小程序根据客户身份证号获取问诊详细信息
|
*/
|
@GetMapping(value = "/appGetInfoById")
|
@ApiOperation(value = "小程序根据客户身份证号获取问诊详细信息")
|
public AjaxResult appGetInfoById(@RequestParam("cusIdCard") String cusIdCard) {
|
LambdaQueryWrapper<TjCustomer> wqqq=new LambdaQueryWrapper<>();
|
wqqq.eq(TjCustomer::getCusIdcard,cusIdCard);
|
TjCustomer one1 = tjCustomerService.getOne(wqqq);
|
|
if (one1!=null){
|
LambdaQueryWrapper<TjAskMedicalHistory> wq=new LambdaQueryWrapper<>();
|
wq.eq(TjAskMedicalHistory::getCusId,one1.getCusId());
|
TjAskMedicalHistory one = tjAskMedicalHistoryService.getOne(wq);
|
if (one!=null){
|
return AjaxResult.success(tjAskMedicalHistoryService.selectTjAskMedicalHistoryByAskId(one.getAskId()));
|
}else {
|
TjAskMedicalHistory a=new TjAskMedicalHistory();
|
a.setCusId(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) {
|
TjCustomer customer = customerService.getOne(new LambdaQueryWrapper<TjCustomer>().eq(TjCustomer::getCusIdcard, tjAskMedicalHistory.getCusIdCard()));
|
if(null !=customer){
|
LambdaQueryWrapper<TjAskMedicalHistory> wq=new LambdaQueryWrapper<>();
|
wq.eq(TjAskMedicalHistory::getCusId,customer.getCusId());
|
wq.isNull(TjAskMedicalHistory::getTjNum);
|
tjAskMedicalHistoryService.remove(wq);
|
tjAskMedicalHistory.setCusId(customer.getCusId());
|
}
|
tjAskMedicalHistory.setFromBy("小程序端");
|
tjAskMedicalHistory.setCreateId(String.valueOf(UserHoder.getWxuser().getId()));
|
// tjAskMedicalHistory.setUpdateId(String.valueOf(UserHoder.getWxuser().getId()));
|
if (tjAskMedicalHistoryService.saveOrUpdate(tjAskMedicalHistory)){
|
List<TjAskHistorys> tjAskHistorysList = tjAskMedicalHistory.getTjAskHistorysList();
|
if (tjAskHistorysList!=null&&tjAskHistorysList.size()>0){
|
for (TjAskHistorys tjAskHistorys : tjAskMedicalHistory.getTjAskHistorysList()) {
|
tjAskHistorys.setAskId(tjAskMedicalHistory.getAskId());
|
if (!historysService.saveOrUpdate(tjAskHistorys)){
|
return AjaxResult.error();
|
}
|
}
|
}
|
return AjaxResult.success("操作成功!");
|
}
|
return AjaxResult.error("操作失败!");
|
}
|
}
|