CommonController.java 2.73 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
package com.lyms.talkonlineweb.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.lyms.talkonlineweb.domain.LymsChatgroup;
import com.lyms.talkonlineweb.domain.LymsDoctor;
import com.lyms.talkonlineweb.domain.LymsPatient;
import com.lyms.talkonlineweb.domain.LymsTkrecord;
import com.lyms.talkonlineweb.result.BaseResponse;
import com.lyms.talkonlineweb.service.LymsChatgroupService;
import com.lyms.talkonlineweb.service.LymsDoctorService;
import com.lyms.talkonlineweb.service.LymsPatientService;
import com.lyms.talkonlineweb.service.LymsTkrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("com")
public class CommonController {
@Autowired
private LymsTkrecordService lymsTkrecordService;
@Autowired
private LymsChatgroupService lymsChatgroupService;
@Autowired
private LymsDoctorService lymsDoctorService;
@Autowired
private LymsPatientService lymsPatientService;

@GetMapping("endTalk")
public BaseResponse endTalk(LymsTkrecord tkrecord){
BaseResponse baseResponse=new BaseResponse();
tkrecord.setStat(0);
baseResponse.setErrorcode(1);
int updateby=tkrecord.getUpdatedby();
tkrecord.setUpdatedby(null);
LymsChatgroup group=new LymsChatgroup();
LymsPatient patient=lymsPatientService.getById(tkrecord.getPid());
LymsDoctor doctor=lymsDoctorService.getById(tkrecord.getDid());
group.setFromp(patient.getIdno());
group.setTarget(doctor.getDlogin());
List<LymsChatgroup> gLst = lymsChatgroupService.list(Wrappers.query(group).orderByDesc("id"));

if(gLst.size()>0){
tkrecord.setHxgroupid(gLst.get(0).getHxgroupid());
}

String hxgroupid=tkrecord.getHxgroupid();
tkrecord.setHxgroupid(null);
List<LymsTkrecord> tLst=lymsTkrecordService.list(Wrappers.query(tkrecord).orderByDesc("createdtime"));
if (tLst.size()>0){
tkrecord=tLst.get(0);
tkrecord.setStat(1);
tkrecord.setUpdatedtime(new Date());
tkrecord.setUpdatedby(updateby);
tkrecord.setHxgroupid(hxgroupid);
boolean f=lymsTkrecordService.saveOrUpdate(tkrecord);

baseResponse.setErrorcode(f==true?0:1);
}
if(baseResponse.getErrorcode()==1){
baseResponse.setErrormsg("该问诊已结束!");
}
return baseResponse;
}
}