|
@ -2,17 +2,21 @@ package com.yihu.wlyy.service.manager.specialist;/**
|
|
|
* Created by nature of king on 2018/8/28.
|
|
|
*/
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.Hospital;
|
|
|
import com.yihu.wlyy.repository.HospitalDao;
|
|
|
import com.yihu.wlyy.repository.SystemDictDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@ -27,25 +31,55 @@ import java.util.Map;
|
|
|
public class SpecialistHospitalItemService extends BaseService {
|
|
|
|
|
|
private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistHospitalItemService.class);
|
|
|
|
|
|
private static String URL = "specialist:url";
|
|
|
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Value("${specialist.url}")
|
|
|
private String specialistUrl;
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
@Autowired
|
|
|
private SystemDictDao systemDictDao;
|
|
|
|
|
|
|
|
|
public String getBaseUrl(){
|
|
|
String url = (String) redisTemplate.opsForValue().get(URL);
|
|
|
String url1 = systemDictDao.findByDictNameAndCode3("SPECIALIST_URL","SPECIALIST_URL");
|
|
|
if (url != null && url1.equalsIgnoreCase(url)){
|
|
|
return url;
|
|
|
}else {
|
|
|
redisTemplate.opsForValue().set(URL,url1);
|
|
|
return url1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Hospital> selectHospital(){
|
|
|
List<Hospital> hospitals = hospitalDao.findAllHospital();
|
|
|
public List<Hospital> selectHospital(String hospitalName){
|
|
|
List<Hospital> hospitals = new ArrayList<>();
|
|
|
if (StringUtils.isNoneBlank(hospitalName)){
|
|
|
Hospital hospital = new Hospital();
|
|
|
hospital = hospitalDao.findByName(hospitalName);
|
|
|
hospitals.add(hospital);
|
|
|
}else {
|
|
|
hospitals = hospitalDao.findAllHospital();
|
|
|
}
|
|
|
return hospitals;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加机构服务项目
|
|
|
*
|
|
|
* @param hospitalServiceItem
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject insert(String hospitalServiceItem){
|
|
|
String response = null;
|
|
|
String url =specialistUrl + "svr-specialist/createHospitalServiceItem";
|
|
|
String url =getBaseUrl() + "createHospitalServiceItem";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("hospitalServiceItem",hospitalServiceItem);
|
|
|
try {
|
|
@ -66,7 +100,7 @@ public class SpecialistHospitalItemService extends BaseService {
|
|
|
*/
|
|
|
public JSONObject selectItemByHospital(String hospital){
|
|
|
String response = null;
|
|
|
String url =specialistUrl + "svr-specialist/selectItemByHospital";
|
|
|
String url =getBaseUrl() + "selectItemByHospital";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("hospital",hospital);
|
|
|
try {
|
|
@ -78,4 +112,28 @@ public class SpecialistHospitalItemService extends BaseService {
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据条件查找机构服务项目
|
|
|
*
|
|
|
* @param serviceName
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selectByCondition(String serviceName,String hospital){
|
|
|
String response = null;
|
|
|
JSONArray array = new JSONArray();
|
|
|
array.add(hospital);
|
|
|
String url =getBaseUrl() + "selectItemByHospital";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("hospitals",array.toJSONString());
|
|
|
params.put("serviceName",serviceName);
|
|
|
try {
|
|
|
response = httpClientUtil.httpPost(url,params);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
logger.error(e.getMessage());
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
}
|