|
@ -4,6 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
import com.yihu.jw.entity.base.role.RoleDO;
|
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
|
import com.yihu.jw.entity.equipment.WlyyUserAreaDO;
|
|
|
import com.yihu.jw.entity.equipment.WlyyUserEquipmentDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
|
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
|
|
|
import com.yihu.jw.security.dao.OauthWlyyConfigDao;
|
|
@ -11,6 +15,10 @@ import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
|
|
|
import com.yihu.jw.security.dao.doctor.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.security.dao.doctor.BaseDoctorRoleDao;
|
|
|
import com.yihu.jw.security.dao.doctor.DoctorMappingDao;
|
|
|
import com.yihu.jw.security.dao.iot.UserDao;
|
|
|
import com.yihu.jw.security.dao.user.RoleDao;
|
|
|
import com.yihu.jw.security.dao.user.WlyyUserAreaDao;
|
|
|
import com.yihu.jw.security.dao.user.WlyyUserEquipmentDao;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
@ -49,6 +57,14 @@ public class OauthWlyyConfigService {
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private DoctorMappingDao doctorMappingDao;
|
|
|
@Autowired
|
|
|
private UserDao userDao;
|
|
|
@Autowired
|
|
|
private WlyyUserAreaDao userAreaDao;
|
|
|
@Autowired
|
|
|
private WlyyUserEquipmentDao userEquipmentDao;
|
|
|
@Autowired
|
|
|
private RoleDao roleDao;
|
|
|
|
|
|
public JSONObject checkWlyyDoctor(String code)throws Exception{
|
|
|
|
|
@ -221,6 +237,139 @@ public class OauthWlyyConfigService {
|
|
|
|
|
|
}
|
|
|
|
|
|
public JSONObject checkWlyyUserDoctor(String doctor)throws Exception{
|
|
|
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("wlyyConfig");
|
|
|
//token获取accesstoken
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
|
|
|
params.add(new BasicNameValuePair("appSecret",oauthWlyyConfigDO.getAppSecret()));
|
|
|
String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(),params,"UTF-8");
|
|
|
String token = null;
|
|
|
JSONObject rsjson = JSONObject.parseObject(res);
|
|
|
|
|
|
logger.info("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
|
p.add(new BasicNameValuePair("doctor", doctor));
|
|
|
|
|
|
//设置头部
|
|
|
token = rsjson.getJSONObject("result").getString("accesstoken");
|
|
|
Map<String,Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken",token);
|
|
|
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
|
|
|
logger.info("checkWlyyDoctor doctorInfo :"+rs);
|
|
|
|
|
|
JSONObject auth = JSONObject.parseObject(rs);
|
|
|
Integer s = auth.getInteger("status");
|
|
|
|
|
|
if(s == 200){
|
|
|
JSONObject data = auth.getJSONObject("data");
|
|
|
String authCode = data.getString("authCode");
|
|
|
if("1".equals(authCode)){
|
|
|
JSONObject doctorJson = data.getJSONObject("doctor");
|
|
|
String idcard = doctorJson.getString("idcard");
|
|
|
String mobile = doctorJson.getString("mobile");
|
|
|
|
|
|
if(StringUtils.isBlank(idcard)){
|
|
|
data.put("authCode","-3");
|
|
|
data.put("mes","I健康账户信息不完整,授权失败");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
UserDO userDO = userDao.findByMobile(mobile);
|
|
|
if(userDO!=null){
|
|
|
return data;
|
|
|
}else{
|
|
|
//存储医生全科医生信息
|
|
|
userDO = new UserDO();
|
|
|
userDO.setSaasId("808080eb7bc87123017bf16ba0ad0046");
|
|
|
userDO.setName(doctorJson.getString("name"));
|
|
|
userDO.setIdcard(doctorJson.getString("idcard"));
|
|
|
userDO.setUsername(doctorJson.getString("mobile"));
|
|
|
userDO.setMobile(doctorJson.getString("mobile"));
|
|
|
if (doctorJson.getInteger("sex")==1){
|
|
|
userDO.setGender(UserDO.Gender.male);
|
|
|
}else if (doctorJson.getInteger("sex")==2){
|
|
|
userDO.setGender(UserDO.Gender.female);
|
|
|
}
|
|
|
//认证信息设置
|
|
|
String salt = randomString(5);
|
|
|
String pw = idcard.substring(idcard.length()-6);
|
|
|
userDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
userDO.setSalt(salt);
|
|
|
userDO.setEnabled(1);
|
|
|
userDO.setLocked(0);
|
|
|
userDO.setCreateTime(new Date());
|
|
|
userDO.setUpdateTime(new Date());
|
|
|
userDO = userDao.save(userDO);
|
|
|
//18补货员19社区药柜管理员20药柜区域管理员21药柜超级管理员
|
|
|
String expandLevel = doctorJson.getString("expandLevel");
|
|
|
RoleDO roleDO = roleDao.findOne(expandLevel);
|
|
|
userDO.setRoleId(roleDO.getId());
|
|
|
userDO = userDao.save(userDO);
|
|
|
List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByUserId(userDO.getId());
|
|
|
if (userAreaDOList==null||userAreaDOList.size()==0){
|
|
|
WlyyUserAreaDO userAreaDO = new WlyyUserAreaDO();
|
|
|
userAreaDO.setUserId(userDO.getId());
|
|
|
userAreaDO.setCity(doctorJson.getString("city"));
|
|
|
userAreaDO.setCityName(doctorJson.getString("cityName"));
|
|
|
userAreaDO.setTown(doctorJson.getString("town"));
|
|
|
userAreaDO.setTownName(doctorJson.getString("townName"));
|
|
|
userAreaDO.setHospital(doctorJson.getString("hospital"));
|
|
|
userAreaDO.setHospitalName(doctorJson.getString("hospitalName"));
|
|
|
userAreaDO.setUpdateTime(new Date());
|
|
|
userAreaDO.setCreateTime(new Date());
|
|
|
userAreaDO.setDel(1);
|
|
|
userAreaDao.save(userAreaDO);
|
|
|
}
|
|
|
if (roleDO.getCode().equalsIgnoreCase("replenisher")){
|
|
|
String sql = "select d.id as id,d.equ_name as name from t_mediicine_device d where d.belong_community ='"+doctorJson.getString("hospital")+"' ";
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
WlyyUserEquipmentDO equipmentDO = new WlyyUserEquipmentDO();
|
|
|
String id = map.get("id").toString();
|
|
|
String name = map.get("name")==null?"":map.get("name").toString();
|
|
|
equipmentDO.setEquipmentId(id);
|
|
|
equipmentDO.setEquipmentName(name);
|
|
|
equipmentDO.setUserId(userDO.getId());
|
|
|
equipmentDO.setDel(1);
|
|
|
equipmentDO.setCityName(doctorJson.getString("cityName"));
|
|
|
equipmentDO.setCity(doctorJson.getString("city"));
|
|
|
equipmentDO.setTown(doctorJson.getString("town"));
|
|
|
equipmentDO.setTownName(doctorJson.getString("townName"));
|
|
|
equipmentDO.setHospital(doctorJson.getString("hospital"));
|
|
|
equipmentDO.setHospitalName(doctorJson.getString("hospitalName"));
|
|
|
equipmentDO.setCreateTime(new Date());
|
|
|
equipmentDO.setUpdateTime(new Date());
|
|
|
userEquipmentDao.save(equipmentDO);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
}else{
|
|
|
return data;
|
|
|
}
|
|
|
}else{
|
|
|
//请求异常
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("authCode","-2");
|
|
|
return data;
|
|
|
}
|
|
|
}else {
|
|
|
//请求异常
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("authCode","-2");
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取全部职称
|