|
@ -1,12 +1,30 @@
|
|
|
package com.yihu.jw.care.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.course.CourseDao;
|
|
|
import com.yihu.jw.care.dao.course.CourseSalesOrderRecordDao;
|
|
|
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
|
|
|
import com.yihu.jw.care.dao.course.RecruitStudentsRecordDao;
|
|
|
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
import com.yihu.jw.entity.care.course.CourseDO;
|
|
|
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
|
|
|
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
|
|
|
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
|
|
|
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
|
|
|
import com.yihu.jw.im.dao.ConsultTeamDao;
|
|
|
import io.swagger.models.auth.In;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.swing.table.TableModel;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 教师与新生儿 入学关系更新工具
|
|
@ -17,6 +35,18 @@ public class EntranceUtil {
|
|
|
|
|
|
@Autowired
|
|
|
private DoctorPatientTmpDao doctorPatientTmpDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorHospitalDao doctorHospitalDao;
|
|
|
@Autowired
|
|
|
private RecruitStudentsRecordDao recruitStudentsRecordDao;
|
|
|
@Autowired
|
|
|
private BaseDoorCoachOrderDao doorCoachOrderDao;
|
|
|
@Autowired
|
|
|
private ConsultTeamDao consultTeamDao;
|
|
|
@Autowired
|
|
|
private CourseDao courseDao;
|
|
|
@Autowired
|
|
|
private CourseSalesOrderRecordDao courseSalesOrderRecordDao;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@ -29,7 +59,7 @@ public class EntranceUtil {
|
|
|
*/
|
|
|
public void newRecord(String patient,Integer type,Integer del,String doctorCode,String orgCode,String relationCode){
|
|
|
if (1==type||2==type){//在线咨询与上门辅导不重复保存
|
|
|
if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,orgCode,type)!=0){
|
|
|
if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctorCode,type)!=0){
|
|
|
return ;
|
|
|
}
|
|
|
}
|
|
@ -37,14 +67,23 @@ public class EntranceUtil {
|
|
|
tmpDO.setPatient(patient);
|
|
|
tmpDO.setType(type);
|
|
|
tmpDO.setDel(del);
|
|
|
tmpDO.setStatus(0);
|
|
|
if (StringUtils.isBlank(orgCode)){
|
|
|
List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(doctorCode);
|
|
|
if (list.size()>0){
|
|
|
orgCode = list.get(0).getOrgCode();
|
|
|
}
|
|
|
}
|
|
|
if (doctorPatientTmpDao.findByPatientAndOrgCodeAndTypeAndStatus(patient,orgCode,3,1)!=0){
|
|
|
tmpDO.setDel(0);
|
|
|
}
|
|
|
tmpDO.setOrgCode(orgCode);
|
|
|
tmpDO.setDoctorCode(doctorCode);
|
|
|
tmpDO.setRelationCode(relationCode);
|
|
|
doctorPatientTmpDao.save(tmpDO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新状态
|
|
|
* 更新状态 状态为1 已入学,将该幼儿咨询、上门、课程数据失效
|
|
|
* @param relationCode
|
|
|
*/
|
|
|
public void updateStatus(Integer status,String relationCode){
|
|
@ -52,7 +91,13 @@ public class EntranceUtil {
|
|
|
if (tmpDO!=null){
|
|
|
tmpDO.setStatus(status);
|
|
|
doctorPatientTmpDao.save(tmpDO);
|
|
|
if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
|
|
|
List<DoctorPatientTmpDO> list = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
|
|
|
List<String> relationCodes = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
|
|
|
deleteRecord2List(relationCodes);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -61,18 +106,25 @@ public class EntranceUtil {
|
|
|
*/
|
|
|
public void updateStatus2(Integer status,String[] relationCode) {
|
|
|
List<DoctorPatientTmpDO> list = new ArrayList<>();
|
|
|
List<String>relationCodes = new ArrayList<>();
|
|
|
for (String id : relationCode) {
|
|
|
DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
|
|
|
if (tmpDO != null) {
|
|
|
tmpDO.setStatus(status);
|
|
|
list.add(tmpDO);
|
|
|
if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
|
|
|
List<DoctorPatientTmpDO> listTmp = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
|
|
|
List<String> relationCodeTmp = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
|
|
|
relationCodes.addAll(relationCodeTmp);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
doctorPatientTmpDao.save(list);
|
|
|
deleteRecord2List(relationCodes);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除记录
|
|
|
* 删除记录 单条
|
|
|
* @param relationCode
|
|
|
*/
|
|
|
public void deleteRecord(String relationCode){
|
|
@ -100,4 +152,116 @@ public class EntranceUtil {
|
|
|
doctorPatientTmpDao.save(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除记录
|
|
|
* @param relationCode
|
|
|
*/
|
|
|
public void deleteRecord2List(List<String> relationCode){
|
|
|
List<DoctorPatientTmpDO> list = new ArrayList<>();
|
|
|
for (String id : relationCode) {
|
|
|
DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
|
|
|
if (tmpDO!=null){
|
|
|
tmpDO.setDel(0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
doctorPatientTmpDao.save(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化数据
|
|
|
*/
|
|
|
public void initData(){
|
|
|
List<DoctorPatientTmpDO> saveList = new ArrayList<>();
|
|
|
//入学
|
|
|
List<RecruitStudentsRecordDO> enList = recruitStudentsRecordDao.findByDelAndStatus(1,"2");
|
|
|
List<String> patients = enList.stream().map(RecruitStudentsRecordDO::getPatient).collect(Collectors.toList());
|
|
|
for (RecruitStudentsRecordDO tmp:enList){
|
|
|
DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
|
|
|
tmpDO.setPatient(tmp.getPatient());
|
|
|
tmpDO.setType(3);
|
|
|
tmpDO.setDel(1);
|
|
|
tmpDO.setStatus(1);
|
|
|
tmpDO.setOrgCode(tmp.getOrgCode());
|
|
|
tmpDO.setRelationCode(tmp.getId());
|
|
|
saveList.add(tmpDO);
|
|
|
}
|
|
|
//上门
|
|
|
List<BaseDoorCoachOrderDO> doorlist = doorCoachOrderDao.queryByStatusIn(new Integer[]{3,4,5,6,});
|
|
|
for (BaseDoorCoachOrderDO tmp:doorlist){
|
|
|
DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
|
|
|
tmpDO.setPatient(tmp.getPatient());
|
|
|
tmpDO.setType(2);
|
|
|
if (patients.contains(tmp.getPatient())){
|
|
|
tmpDO.setDel(0);
|
|
|
}
|
|
|
else {
|
|
|
tmpDO.setDel(1);
|
|
|
}
|
|
|
tmpDO.setStatus(0);
|
|
|
tmpDO.setDoctorCode(tmp.getDoctor());
|
|
|
tmpDO.setOrgCode(tmp.getHospital());
|
|
|
tmpDO.setRelationCode(tmp.getId());
|
|
|
saveList.add(tmpDO);
|
|
|
}
|
|
|
//咨询
|
|
|
List<ConsultTeamDo> consultList = consultTeamDao.findByTypeAndDel(23,"1");
|
|
|
for (ConsultTeamDo tmp:consultList){
|
|
|
DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
|
|
|
tmpDO.setPatient(tmp.getPatient());
|
|
|
tmpDO.setType(1);
|
|
|
if (patients.contains(tmp.getPatient())){
|
|
|
tmpDO.setDel(0);
|
|
|
}
|
|
|
else {
|
|
|
tmpDO.setDel(1);
|
|
|
}
|
|
|
tmpDO.setStatus(0);
|
|
|
tmpDO.setDoctorCode(tmp.getDoctor());
|
|
|
if (StringUtils.isNotBlank(tmp.getDoctor())){
|
|
|
List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(tmp.getDoctor());
|
|
|
if (list.size()>0){
|
|
|
tmpDO.setOrgCode(list.get(0).getOrgCode());
|
|
|
}
|
|
|
}
|
|
|
tmpDO.setRelationCode(tmp.getConsult());
|
|
|
saveList.add(tmpDO);
|
|
|
}
|
|
|
//课程
|
|
|
List<CourseSalesOrderRecordDO> courseList = courseSalesOrderRecordDao.findByStatus("2");
|
|
|
for (CourseSalesOrderRecordDO tmp:courseList){
|
|
|
DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
|
|
|
tmpDO.setPatient(tmp.getPatient());
|
|
|
tmpDO.setType(4);
|
|
|
if (patients.contains(tmp.getPatient())){
|
|
|
tmpDO.setDel(0);
|
|
|
}
|
|
|
else {
|
|
|
tmpDO.setDel(1);
|
|
|
}
|
|
|
tmpDO.setStatus(0);
|
|
|
CourseDO courseDO = courseDao.findOne(tmp.getCourseId());
|
|
|
if (courseDO!=null){
|
|
|
tmpDO.setDoctorCode(courseDO.getDoctor());
|
|
|
}
|
|
|
tmpDO.setOrgCode(tmp.getOrgCode());
|
|
|
tmpDO.setRelationCode(tmp.getId());
|
|
|
saveList.add(tmpDO);
|
|
|
}
|
|
|
for (DoctorPatientTmpDO tmp:saveList){
|
|
|
if (1==tmp.getType()||2==tmp.getType()){//在线咨询与上门辅导不重复保存
|
|
|
if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(tmp.getPatient(),tmp.getDoctorCode(),tmp.getType())!=0){
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
doctorPatientTmpDao.save(tmp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 清除所有数据
|
|
|
*/
|
|
|
public void deleteAll(){
|
|
|
doctorPatientTmpDao.deleteAll();
|
|
|
}
|
|
|
}
|