liuqq 6 سال پیش
والد
کامیت
523c299e57

+ 48 - 31
tran-service/src/main/java/com/diagbot/facade/DoctorInfoFacade.java

@@ -42,21 +42,19 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
 	
 	 /**
 	 * 保存医生信息
+	 * 如果医生存在,医院、科室不存在,也无法查询到数据
+	 * 查询之前先查询医院和科室信息,如果不存在则保存
 	 * @param doctorInfoVo
 	 * @return 医生信息
 	 */
-	public DoctorInfoDTO saveDoctorInfo(DoctorInfoVO doctorInfoVo){
-		DoctorInfoDTO doctorInfoDTO = new DoctorInfoDTO();
-        if("view".equals(doctorInfoVo.getType())){
-			//从视图或数据库中获取医生信息保存到本系统
-        	doctorInfoDTO=DBConn.getDoctorInfo(doctorInfoVo);
-		}else if("api".equals(doctorInfoVo.getType())){
-			//通过HIS接口获取信息保存到本系统
-			Response<DoctorInfoDTO> data=aiServiceClient.getDoctorInfo(doctorInfoVo);
-			doctorInfoDTO=data.getData();
-		}
-        updateOrInsert(doctorInfoDTO,doctorInfoVo);
-        return doctorInfoDTO;
+	public List<DoctorInfoDTO> saveDoctorInfo(DoctorInfoVO doctorInfoVo){
+		//初始化医院科室的信息
+		getHospitalInfo(doctorInfoVo);
+		getDeptInfo(doctorInfoVo);
+		//查询是否有内部存储
+		List<DoctorInfoDTO> doctorInfoDTOList=this.getDoctorInfos(doctorInfoVo.getDoctorCode(), doctorInfoVo.getHosptialCode(), doctorInfoVo.getDeptCode());
+		updateOrInsert(doctorInfoDTOList,doctorInfoVo);
+        return doctorInfoDTOList;
 	}
 	
 	/**
@@ -64,28 +62,46 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
 	 * @param doctorInfoDTO
 	 * @param doctorInfoVo
 	 */
-	private void updateOrInsert(DoctorInfoDTO doctorInfoDTO,DoctorInfoVO doctorInfoVo){
-		getHospitalInfo(doctorInfoVo);//遍历医院信息,是否存在,不存在则新增
-		getDeptInfo(doctorInfoVo);//遍历科室信息,是否存在,不存在则新增
+	private void updateOrInsert(List<DoctorInfoDTO> doctorInfoDTOList,DoctorInfoVO doctorInfoVo){
+		DoctorInfoDTO doctorInfoDTO = new DoctorInfoDTO();
 		
-		BeanUtil.copyProperties(doctorInfoVo, doctorInfoDTO);
-		doctorInfoDTO.setHospitalCode(doctorInfoVo.getHosptialCode());
-		doctorInfoDTO.setHospitalDeptCode(doctorInfoVo.getDeptCode());
-		doctorInfoDTO.setCode(doctorInfoVo.getDoctorCode());
-		if(doctorInfoDTO!=null){
-			//优先在本地数据库查看医生信息是否存在
-			List<DoctorInfoDTO> doctorInfoDTOList=this.getDoctorInfos(doctorInfoDTO.getCode(), doctorInfoDTO.getHospitalCode(), doctorInfoDTO.getHospitalDeptCode());
+		if(doctorInfoDTOList.size()>0){
+			//更新
+			getDoctorInfo(doctorInfoDTO,doctorInfoVo);//从不同的来源获取医生信息
+			
+			doctorInfoDTO.setId(doctorInfoDTOList.get(0).getId());
+			doctorInfoDTO.setGmtModified(new Date());
+			this.updateById(doctorInfoDTO);
+			
+		}else{
+			//新增
+			getDoctorInfo(doctorInfoDTO,doctorInfoVo);//从不同的来源获取医生信息
 			
+			doctorInfoDTO.setGmtCreate(new Date());
+            this.save(doctorInfoDTO);
+		}
+		doctorInfoDTOList.add(doctorInfoDTO);
+	}
+	
+	/**
+	 * 从不同的来源获取医生信息
+	 * @param doctorInfoDTO
+	 * @param doctorInfoVo
+	 */
+	private void getDoctorInfo(DoctorInfoDTO doctorInfoDTO,DoctorInfoVO doctorInfoVo){
+		if("view".equals(doctorInfoVo.getType())){
+			//从视图或数据库中获取医生信息保存到本系统
+        	List<DoctorInfoDTO> list=DBConn.getDoctorInfo(doctorInfoVo);
+        	BeanUtil.copyProperties(list.get(0), doctorInfoDTO);
+		}else if("api".equals(doctorInfoVo.getType())){
 			//通过HIS接口获取信息保存到本系统
-			if(doctorInfoDTOList.size()>0){
-				doctorInfoDTO.setId(doctorInfoDTOList.get(0).getId());
-				doctorInfoDTO.setGmtModified(new Date());
-				this.updateById(doctorInfoDTO);
-        	}else{
-        		//不存在则insert新增
-        		doctorInfoDTO.setGmtCreate(new Date());
-                this.save(doctorInfoDTO);
-        	}
+			Response<DoctorInfoDTO> data=aiServiceClient.getDoctorInfo(doctorInfoVo);
+			BeanUtil.copyProperties(data.getData(), doctorInfoDTO);
+		}else{
+			BeanUtil.copyProperties(doctorInfoVo, doctorInfoDTO);
+			doctorInfoDTO.setHospitalCode(doctorInfoVo.getHosptialCode());
+			doctorInfoDTO.setHospitalDeptCode(doctorInfoVo.getDeptCode());
+			doctorInfoDTO.setCode(doctorInfoVo.getDoctorCode());
 		}
 	}
 	
@@ -148,6 +164,7 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
      */
     public List<DoctorInfoDTO> getDoctorInfo(DoctorInfoVO doctorInfoVo) {
         List<DoctorInfoDTO> doctorInfoDTOList = this.getDoctorInfos(doctorInfoVo.getDoctorCode(), doctorInfoVo.getHosptialCode(), doctorInfoVo.getDeptCode());
+        //updateOrInsert(doctorInfoDTOList,doctorInfoVo);
         return doctorInfoDTOList;
     }
     

+ 39 - 25
tran-service/src/main/java/com/diagbot/facade/HospitalDeptFacade.java

@@ -12,14 +12,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.AIServiceClient;
 import com.diagbot.client.bean.Response;
 import com.diagbot.dto.HospitalDeptInfoDTO;
-import com.diagbot.dto.HospitalInfoDTO;
 import com.diagbot.entity.HospitalDept;
-import com.diagbot.entity.HospitalInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.impl.HospitalDeptServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.vo.HospitalDeptInfoVO;
-import com.diagbot.vo.HospitalInfoVO;
 import com.diagbot.web.config.DBConn;
 
 /**
@@ -33,8 +30,8 @@ public class HospitalDeptFacade extends HospitalDeptServiceImpl {
 	@Autowired
 	private AIServiceClient aiServiceClient;
 	
-	@Autowired
-	private HospitalInfoFacade hospitalInfoFacade;
+	/*@Autowired
+	private HospitalInfoFacade hospitalInfoFacade;*/
 	
 	/**
 	 * 根据科室编码、医院编码
@@ -42,40 +39,57 @@ public class HospitalDeptFacade extends HospitalDeptServiceImpl {
 	 * @return
 	 */
 	public HospitalDeptInfoDTO saveHospitalDeptInfo(HospitalDeptInfoVO hospitalDeptInfoVO){
-		HospitalDeptInfoDTO hospitalDeptInfoDTO=new HospitalDeptInfoDTO();
-		if("view".equals(hospitalDeptInfoVO.getType())){
-			hospitalDeptInfoDTO=DBConn.getHospitalDeptInfo(hospitalDeptInfoVO);
-		}else if("api".equals(hospitalDeptInfoVO.getType())){
-			Response<HospitalDeptInfoDTO> data=aiServiceClient.getHospitalDeptInfo(hospitalDeptInfoVO);
-			BeanUtil.copyProperties(data.getData(),hospitalDeptInfoDTO);
-		}
-		
+		//更新对应医院的信息
+        //getHospitalInfo(hospitalDeptInfoVO);
 		//查询数据库中是否存在
-		hospitalDeptInfoDTO=this.getHospitalDeptInfo(hospitalDeptInfoVO);
-				
-		BeanUtil.copyProperties(hospitalDeptInfoVO,hospitalDeptInfoDTO);
-		hospitalDeptInfoDTO.setCode(hospitalDeptInfoVO.getDeptCode());
-		hospitalDeptInfoDTO.setName(hospitalDeptInfoVO.getDeptName());
+        HospitalDeptInfoDTO hospitalDeptInfoDTO=this.getHospitalDeptInfo(hospitalDeptInfoVO);
+		
+		updateOrInsert(hospitalDeptInfoDTO,hospitalDeptInfoVO);
+
+		return hospitalDeptInfoDTO;
+	}
+	
+	private void updateOrInsert(HospitalDeptInfoDTO hospitalDeptInfoDTO,HospitalDeptInfoVO hospitalDeptInfoVO){
 		if(hospitalDeptInfoDTO!=null && hospitalDeptInfoDTO.getId()!=null){
+			//更新
+			getHospitalDept(hospitalDeptInfoDTO,hospitalDeptInfoVO);
+			
 			hospitalDeptInfoDTO.setGmtModified(new Date());
 			this.updateById(hospitalDeptInfoDTO);
-		}else {
+		}else{
+			//新增
+			getHospitalDept(hospitalDeptInfoDTO,hospitalDeptInfoVO);
+			
 			hospitalDeptInfoDTO.setDeptId(Long.valueOf("1"));//默认为全科
 			hospitalDeptInfoDTO.setGmtCreate(new Date());
 			this.save(hospitalDeptInfoDTO);
 		}
-		 
-		//更新对应医院的信息
-		getHospitalInfo(hospitalDeptInfoVO);
 		
-		return hospitalDeptInfoDTO;
+	}
+	
+	/**
+	 * 从不同来源获取科室信息
+	 * @param hospitalDeptInfoDTO
+	 * @param hospitalDeptInfoVO
+	 */
+	private void getHospitalDept(HospitalDeptInfoDTO hospitalDeptInfoDTO,HospitalDeptInfoVO hospitalDeptInfoVO){
+		if("view".equals(hospitalDeptInfoVO.getType())){
+			hospitalDeptInfoDTO=DBConn.getHospitalDeptInfo(hospitalDeptInfoVO);
+		}else if("api".equals(hospitalDeptInfoVO.getType())){
+			Response<HospitalDeptInfoDTO> data=aiServiceClient.getHospitalDeptInfo(hospitalDeptInfoVO);
+			BeanUtil.copyProperties(data.getData(),hospitalDeptInfoDTO);
+		}else{
+			BeanUtil.copyProperties(hospitalDeptInfoVO,hospitalDeptInfoDTO);
+			hospitalDeptInfoDTO.setCode(hospitalDeptInfoVO.getDeptCode());
+			hospitalDeptInfoDTO.setName(hospitalDeptInfoVO.getDeptName());
+		}
 	}
 	
 	/**
 	 * 遍历医院信息,是否存在,不存在则新增
 	 * @param doctorInfoVo
 	 */
-	private void getHospitalInfo(HospitalDeptInfoVO hospitalDeptInfoVO){
+	/*private void getHospitalInfo(HospitalDeptInfoVO hospitalDeptInfoVO){
 		HospitalInfo hospitalInfo=new HospitalInfo(); 
 		HospitalInfoVO hospitalInfoVO=new HospitalInfoVO();
 		
@@ -92,7 +106,7 @@ public class HospitalDeptFacade extends HospitalDeptServiceImpl {
 			hospitalInfo.setGmtModified(new Date());
 			hospitalInfoFacade.updateById(hospitalInfo);
 		}
-	}
+	}*/
 	
     /**
      * 获取科室信息

+ 35 - 8
tran-service/src/main/java/com/diagbot/facade/HospitalInfoFacade.java

@@ -3,12 +3,16 @@ package com.diagbot.facade;
 import java.util.Date;
 import java.util.List;
 
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import com.diagbot.client.AIServiceClient;
+import com.diagbot.client.bean.Response;
 import com.diagbot.dto.HospitalInfoDTO;
 import com.diagbot.service.impl.HospitalInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.vo.HospitalInfoVO;
+import com.diagbot.web.config.DBConn;
 
 /**
  * @Description:
@@ -18,6 +22,8 @@ import com.diagbot.vo.HospitalInfoVO;
 @Component
 public class HospitalInfoFacade extends HospitalInfoServiceImpl {
 
+	@Autowired
+	 private AIServiceClient aiServiceClient;
     /**
      * 获取医院信息
      *
@@ -36,21 +42,42 @@ public class HospitalInfoFacade extends HospitalInfoServiceImpl {
      */
     public HospitalInfoDTO saveHospitalInfo(HospitalInfoVO hospitalInfoVO){
     	HospitalInfoDTO hospitalInfoDTO=new HospitalInfoDTO();
-    	if("view".equals(hospitalInfoVO.getType())){
-    		//从HIS数据库或视图中读取医院信息
-    	}else if("api".equals(hospitalInfoVO.getType())){
-    		
-    	}
+    	
     	List<HospitalInfoDTO> list=this.getHospitalInfo(hospitalInfoVO);
-    	BeanUtil.copyProperties(hospitalInfoVO, hospitalInfoDTO);
     	if(list.size()>0){
-    		hospitalInfoDTO.setId(list.get(0).getId());
+    		BeanUtil.copyProperties(list.get(0), hospitalInfoDTO);
+    	}
+    	
+    	updateOrInsert(hospitalInfoDTO,hospitalInfoVO);
+    	
+    	return hospitalInfoDTO;
+    }
+    
+    private void updateOrInsert(HospitalInfoDTO hospitalInfoDTO,HospitalInfoVO hospitalInfoVO){
+    	if(hospitalInfoDTO!=null && hospitalInfoDTO.getId()!=null){
+    		hospitalInfoVO.setId(hospitalInfoDTO.getId());
+    		getHospitalData(hospitalInfoDTO,hospitalInfoVO);
     		hospitalInfoDTO.setGmtModified(new Date());
     		this.updateById(hospitalInfoDTO);
     	}else{
+    		getHospitalData(hospitalInfoDTO,hospitalInfoVO);
+    		
     		hospitalInfoDTO.setGmtCreate(new Date());
     		this.save(hospitalInfoDTO);
     	}
-    	return hospitalInfoDTO;
+    }
+    
+    private void getHospitalData(HospitalInfoDTO hospitalInfoDTO,HospitalInfoVO hospitalInfoVO){
+    	if("view".equals(hospitalInfoVO.getType())){
+    		//从HIS数据库或视图中读取医院信息
+    		HospitalInfoDTO data=DBConn.getHospitalInfo(hospitalInfoVO);
+    		BeanUtil.copyProperties(data, hospitalInfoDTO);
+    	}else if("api".equals(hospitalInfoVO.getType())){
+    		//通过HIS接口获取信息保存到本系统
+			Response<HospitalInfoDTO> data=aiServiceClient.getHospitalInfo(hospitalInfoVO);
+			BeanUtil.copyProperties(data.getData(), hospitalInfoDTO);
+    	}else{
+    		BeanUtil.copyProperties(hospitalInfoVO, hospitalInfoDTO);
+    	}
     }
 }

+ 46 - 13
tran-service/src/main/java/com/diagbot/facade/PatientInfoFacade.java

@@ -6,9 +6,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestBody;
 
+import com.diagbot.client.AIServiceClient;
+import com.diagbot.client.bean.Response;
 import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.PatientInfoDTO;
 import com.diagbot.entity.PatientInfo;
@@ -17,6 +20,7 @@ import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.PatientInfoVO;
+import com.diagbot.web.config.DBConn;
 
 /**
  * @Description: 患者业务逻辑
@@ -30,33 +34,62 @@ public class PatientInfoFacade extends PatientInfoServiceImpl {
     private DoctorPageModeFacade doctorPageModeFacade;*/
     /*@Autowired
     private DeptInfoFacade deptInfoFacade;*/
+	
+	 @Autowired
+	 private AIServiceClient aiServiceClient;
 
 	public PatientInfoDTO savePatientInfo(PatientInfoVO patientInfoVO){
-		//从数据库或视图获取患者信息
-		//从接口获取患者信息
-		//根据患者编码、医院编码查询本地数据库数据是否存在
-		PatientInfo patientInfo=new PatientInfo();
 		PatientInfoDTO patientInfoDTO=baseMapper.getPatientInfos(patientInfoVO.getPatientCode(), patientInfoVO.getHospitalCode());
 		
-		BeanUtil.copyProperties(patientInfoVO,patientInfo);
-		patientInfo.setCode(patientInfoVO.getPatientCode());
-		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-		try {
-			patientInfo.setBirthday(dateFormat.parse(patientInfoVO.getBirthday()));
-		} catch (Exception e) {
-			patientInfo.setBirthday(null);
-		}
-		if(patientInfoDTO!=null){
+		PatientInfoDTO dto=updateOrInsert(patientInfoDTO,patientInfoVO);
+		return dto;
+	}
+	
+	private PatientInfoDTO updateOrInsert(PatientInfoDTO patientInfoDTO,PatientInfoVO patientInfoVO){
+		PatientInfo patientInfo=new PatientInfo();
+		if(patientInfoDTO!=null && patientInfoDTO.getId()!=null){
 			//更新
+			patientInfoVO.setId(patientInfoDTO.getId());
+			getPatientData(patientInfoDTO,patientInfoVO);
+			BeanUtil.copyProperties(patientInfoDTO,patientInfo);
+			
 			patientInfo.setId(patientInfoDTO.getId());
 			patientInfo.setGmtModified(new Date());
 			baseMapper.updateById(patientInfo);
 		}else{
 			//新增
+			getPatientData(patientInfoDTO,patientInfoVO);
+			BeanUtil.copyProperties(patientInfoDTO,patientInfo);
+			
 			patientInfo.setGmtCreate(new Date());
 			baseMapper.insert(patientInfo);
 		}
 		return patientInfoDTO;
+	} 
+	
+	/**
+	 * 从不同来源获取患者信息
+	 */
+	private void getPatientData(PatientInfoDTO patientInfoDTO,PatientInfoVO patientInfoVO){
+		if("view".equals(patientInfoVO.getType())){
+			//从视图或数据库中获取医生信息保存到本系统
+        	PatientInfoDTO data=DBConn.getPatientInfo(patientInfoVO);
+        	BeanUtil.copyProperties(data, patientInfoDTO);
+		}else if("api".equals(patientInfoVO.getType())){
+			//通过HIS接口获取信息保存到本系统
+			Response<PatientInfoDTO> data=aiServiceClient.getPatientInfo(patientInfoVO);
+			BeanUtil.copyProperties(data.getData(), patientInfoDTO);
+		}else{
+			BeanUtil.copyProperties(patientInfoVO, patientInfoDTO);
+			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+			try {
+				patientInfoDTO.setBirthday(dateFormat.parse(patientInfoVO.getBirthday()));
+			} catch (Exception e) {
+				patientInfoDTO.setBirthday(null);
+			}
+			patientInfoDTO.setHospitalCode(patientInfoVO.getHospitalCode());
+			patientInfoDTO.setCode(patientInfoVO.getPatientCode());
+		}
 	}
 	
     /**

+ 2 - 0
tran-service/src/main/java/com/diagbot/vo/PatientInfoVO.java

@@ -56,4 +56,6 @@ public class PatientInfoVO {
 
     private String remark;
     
+    private String type;
+    
 }

+ 4 - 3
tran-service/src/main/java/com/diagbot/web/DoctorInfoController.java

@@ -35,7 +35,7 @@ import springfox.documentation.annotations.ApiIgnore;
 @RequestMapping("/doctorInfo")
 @Api(value = "医生信息API", tags = { "医生信息API" })
 @SuppressWarnings("unchecked")
-/*@ApiIgnore*/
+@ApiIgnore
 public class DoctorInfoController {
 
     @Autowired
@@ -55,8 +55,8 @@ public class DoctorInfoController {
                     "remark:备注,选填<br>")
     @PostMapping("/saveDoctorInfo")
     @SysLogger("saveDoctorInfo")
-    public RespDTO<DoctorInfoDTO> saveDoctorInfo(@Valid @RequestBody DoctorInfoVO doctorInfoVo){
-    	DoctorInfoDTO data = doctorInfoFacade.saveDoctorInfo(doctorInfoVo);
+    public RespDTO<List<DoctorInfoDTO>> saveDoctorInfo(@Valid @RequestBody DoctorInfoVO doctorInfoVo){
+    	List<DoctorInfoDTO> data = doctorInfoFacade.saveDoctorInfo(doctorInfoVo);
     	return RespDTO.onSuc(data);
     }
 
@@ -66,6 +66,7 @@ public class DoctorInfoController {
                     "doctorCode: 医生编号,必填<br>")
     @PostMapping("/getDoctorInfo")
     @SysLogger("getDoctorInfo")
+    @ApiIgnore
     public RespDTO<List<DoctorInfoDTO>> getDoctorInfo(@Valid @RequestBody DoctorInfoVO doctorInfoVo) {
         List<DoctorInfoDTO> data = doctorInfoFacade.getDoctorInfo(doctorInfoVo);
         return RespDTO.onSuc(data);

+ 2 - 0
tran-service/src/main/java/com/diagbot/web/HospitalDeptInfoController.java

@@ -58,6 +58,8 @@ public class HospitalDeptInfoController {
     
     @PostMapping(value = "/saveHospitalDeptInfo")
     @SysLogger("saveHospitalDeptInfo")
+    @ApiOperation(value = "保存科室信息map[by:QQ]")
+    @ApiIgnore
     public RespDTO<HospitalDeptInfoDTO> saveHospitalDeptInfo(@Valid @RequestBody HospitalDeptInfoVO hospitalDeptInfoVO){
     	HospitalDeptInfoDTO data=hospitalDeptFacade.saveHospitalDeptInfo(hospitalDeptInfoVO);
     	return RespDTO.onSuc(data);

+ 2 - 2
tran-service/src/main/java/com/diagbot/web/config/DBConn.java

@@ -64,7 +64,7 @@ public class DBConn {
     final static ArrayList<String> dictid = new ArrayList<>();
     
     @SuppressWarnings({ "unused"})
-    public static DoctorInfoDTO getDoctorInfo(DoctorInfoVO doctorInfoVo){
+    public static List<DoctorInfoDTO> getDoctorInfo(DoctorInfoVO doctorInfoVo){
     	List<DoctorInfoDTO> list = new ArrayList<DoctorInfoDTO>();
     	String sql="select * from at_choose_info where id=344";
     	try {
@@ -88,7 +88,7 @@ public class DBConn {
 			conn.close();
 		} catch (Exception e) {
 		}
-    	return list.get(0);
+    	return list;
     }
     
     /**