|
@ -1,21 +1,37 @@
|
|
|
package com.yihu.jw.security.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
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.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
|
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.patient.BasePatientDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
|
import com.yihu.utils.network.HttpResponse;
|
|
|
import com.yihu.utils.network.HttpUtils;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import static com.yihu.jw.util.common.PwdUtil.randomString;
|
|
|
|
|
|
/**
|
|
|
* 眼科医院
|
|
|
* Created by yeshijie on 2020/4/24.
|
|
@ -35,6 +51,24 @@ public class YkyyService {
|
|
|
@Autowired
|
|
|
private BasePatientDao patientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDoctorRoleDao baseDoctorRoleDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctorMappingDao doctorMappingDao;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
|
|
|
private final static String orgCode ="350211A5004";
|
|
|
|
|
|
private final static String orgName ="厦门大学附属厦门眼科中心";
|
|
|
|
|
|
private final static String url="http://192.168.20.55:10023/ykyy/createSQLQuery";
|
|
|
|
|
|
private static String yktUrl = "http://www.yanketong.com:133/api/";
|
|
|
|
|
|
/**
|
|
@ -288,4 +322,144 @@ public class YkyyService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生端眼科通登陆
|
|
|
* @param loginId 账户
|
|
|
* @param password 密码
|
|
|
* @return
|
|
|
*/
|
|
|
public String DoctorLogin(String loginId,String password){
|
|
|
String response="";
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("loginId",loginId);//账户
|
|
|
jsonObject.put("password",password);//密码
|
|
|
String url = "http://www.yanketong.com:90/api/Doctor/DoctorLogin";
|
|
|
response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
|
|
|
logger.info("医生端登陆:"+response);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String updateYkyyDoctor(String idCard)throws Exception{
|
|
|
String sql ="select y.code AS \"code\",y.name AS \"name\",y.expertise AS \"expertise\",y.introduce AS \"introduce\",y.mobile AS \"mobile\",y.idCard AS \"idcard\",y.jobtitlecode AS \"jobTitleCode\",y.jobTitleName AS \"jobTitleName\",y.dept AS \"dept\",y.deptName AS \"deptName\" from v_Hlw_Ysxx y where y.idcard is not null";
|
|
|
sql +=" and y.idcard ='"+idCard+"' ";
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
HttpResponse response = HttpUtils.doGet(url,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
if(status!=null&&status == 200){
|
|
|
JSONArray array = rs.getJSONArray("detailModelList");
|
|
|
logger.info("doctor size:"+array.size());
|
|
|
if(array!=null&&array.size()>0) {
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
JSONObject doctorJson = array.getJSONObject(i);
|
|
|
String idcard = doctorJson.getString("idcard");
|
|
|
|
|
|
//过滤身份证脏数据
|
|
|
if(idcard.length()>=15){
|
|
|
|
|
|
BaseDoctorDO doctorDOs = baseDoctorDao.findByIdcard(idcard);
|
|
|
|
|
|
if(doctorDOs!=null){
|
|
|
|
|
|
BaseDoctorDO doctor = doctorDOs;
|
|
|
|
|
|
String salt = randomString(5);
|
|
|
String pw = idcard.substring(idcard.length() - 6);
|
|
|
doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
doctor.setSalt(salt);
|
|
|
|
|
|
doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
|
|
|
doctor.setJobTitleName(doctorJson.getString("jobTitleName"));
|
|
|
// doctor.setExpertise(doctorJson.getString("expertise"));
|
|
|
// doctor.setIntroduce(doctorJson.getString("introduce"));
|
|
|
// doctor.setMobile(doctorJson.getString("mobile"));
|
|
|
|
|
|
BaseDoctorDO temp = baseDoctorDao.save(doctor);
|
|
|
|
|
|
List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByOrgCodeAndDeptCodeAndDoctorCode(orgCode,doctorJson.getString("dept"),doctor.getId());
|
|
|
if(hospitalDOs!=null&&hospitalDOs.size()>0){
|
|
|
//机构信息部门信息
|
|
|
BaseDoctorHospitalDO hospitalDO = hospitalDOs.get(0);
|
|
|
hospitalDO.setDeptCode(doctorJson.getString("dept"));
|
|
|
hospitalDO.setDeptName(doctorJson.getString("deptName"));
|
|
|
hospitalDO.setDel("1");
|
|
|
baseDoctorHospitalDao.save(hospitalDO);
|
|
|
}
|
|
|
|
|
|
|
|
|
}else{
|
|
|
//新增医生
|
|
|
BaseDoctorDO doctor = new BaseDoctorDO();
|
|
|
doctor.setName(doctorJson.getString("name"));
|
|
|
doctor.setIdcard(idcard);
|
|
|
|
|
|
doctor.setSex(Integer.parseInt(com.yihu.jw.util.common.IdCardUtil.getSexForIdcard_new(idcard)));
|
|
|
doctor.setBirthday(com.yihu.jw.util.common.IdCardUtil.getBirthdayForIdcard(idcard));
|
|
|
|
|
|
doctor.setProvinceCode("350000");
|
|
|
doctor.setProvinceName("福建省");
|
|
|
doctor.setTownCode("350203");
|
|
|
doctor.setTownName("思明区");
|
|
|
doctor.setCityCode("350200");
|
|
|
doctor.setCityName("厦门市");
|
|
|
// doctor.setExpertise(doctorJson.getString("expertise"));
|
|
|
// doctor.setIntroduce(doctorJson.getString("introduce"));
|
|
|
// doctor.setMobile(doctorJson.getString("mobile"));
|
|
|
//认证信息设置
|
|
|
String salt = randomString(5);
|
|
|
String pw = idcard.substring(idcard.length() - 6);
|
|
|
doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
doctor.setSalt(salt);
|
|
|
doctor.setDel("1");
|
|
|
doctor.setEnabled(1);
|
|
|
doctor.setLocked(0);
|
|
|
doctor.setCreateTime(new Date());
|
|
|
|
|
|
doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
|
|
|
doctor.setJobTitleName(doctorJson.getString("jobTitleName"));
|
|
|
|
|
|
BaseDoctorDO temp = baseDoctorDao.save(doctor);
|
|
|
|
|
|
//机构信息部门信息
|
|
|
BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
|
|
|
hospitalDO.setDoctorCode(temp.getId());
|
|
|
hospitalDO.setOrgCode(orgCode);
|
|
|
hospitalDO.setOrgName(orgName);
|
|
|
hospitalDO.setDeptCode(doctorJson.getString("dept"));
|
|
|
hospitalDO.setDeptName(doctorJson.getString("deptName"));
|
|
|
hospitalDO.setDel("1");
|
|
|
baseDoctorHospitalDao.save(hospitalDO);
|
|
|
|
|
|
//保存角色
|
|
|
BaseDoctorRoleDO role = new BaseDoctorRoleDO();
|
|
|
role.setDoctorCode(temp.getId());
|
|
|
role.setRoleCode("specialist");
|
|
|
baseDoctorRoleDao.save(role);
|
|
|
|
|
|
//保存mapping
|
|
|
DoctorMappingDO mappingDO = new DoctorMappingDO();
|
|
|
mappingDO.setIdcard(idcard);
|
|
|
mappingDO.setDoctor(temp.getId());
|
|
|
mappingDO.setDoctorName(temp.getName());
|
|
|
|
|
|
mappingDO.setOrgCode(orgCode);
|
|
|
mappingDO.setOrgName(orgName);
|
|
|
|
|
|
mappingDO.setMappingCode(doctorJson.getString("code"));
|
|
|
mappingDO.setMappingName(temp.getName());
|
|
|
mappingDO.setCreateTime(new Date());
|
|
|
|
|
|
doctorMappingDao.save(mappingDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
}
|