|
@ -4,10 +4,20 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
|
|
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
|
|
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
|
|
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
|
|
|
|
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.hospital.mapping.DoctorMappingDO;
|
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.utils.network.HttpResponse;
|
|
import com.yihu.utils.network.HttpResponse;
|
|
import com.yihu.utils.network.HttpUtils;
|
|
import com.yihu.utils.network.HttpUtils;
|
|
|
|
import com.yihu.utils.security.MD5;
|
|
import javafx.scene.DepthTest;
|
|
import javafx.scene.DepthTest;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@ -19,6 +29,7 @@ import javax.transaction.Transactional;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 眼科医院专用service
|
|
* 眼科医院专用service
|
|
@ -35,9 +46,23 @@ public class YkyyEntranceService {
|
|
|
|
|
|
private final static String orgCode ="350211A5004";
|
|
private final static String orgCode ="350211A5004";
|
|
|
|
|
|
|
|
private final static String orgName ="厦门大学附属厦门眼科中心";
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private DictHospitalDeptDao hospitalDeptDao;
|
|
private DictHospitalDeptDao hospitalDeptDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorRoleDao baseDoctorRoleDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DoctorMappingDao doctorMappingDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private HibenateUtils hibenateUtils;
|
|
private HibenateUtils hibenateUtils;
|
|
|
|
|
|
@ -54,10 +79,10 @@ public class YkyyEntranceService {
|
|
String sql ="select code AS \"code\",name as \"name\",consultdeptflag as \"consultDeptFlag\" from V_HLW_KSXX";
|
|
String sql ="select code AS \"code\",name as \"name\",consultdeptflag as \"consultDeptFlag\" from V_HLW_KSXX";
|
|
Map<String,Object> params = new HashedMap();
|
|
Map<String,Object> params = new HashedMap();
|
|
params.put("sql",sql);
|
|
params.put("sql",sql);
|
|
|
|
|
|
|
|
logger.info("updateYkyyDept:"+sql);
|
|
HttpResponse response = HttpUtils.doGet(url,params);
|
|
HttpResponse response = HttpUtils.doGet(url,params);
|
|
String content = response.getContent();
|
|
String content = response.getContent();
|
|
logger.info(content);
|
|
|
|
|
|
logger.info("response:"+content);
|
|
JSONObject rs = JSON.parseObject(content);
|
|
JSONObject rs = JSON.parseObject(content);
|
|
Integer status = rs.getInteger("status");
|
|
Integer status = rs.getInteger("status");
|
|
if(status!=null&&status == 200){
|
|
if(status!=null&&status == 200){
|
|
@ -91,4 +116,127 @@ public class YkyyEntranceService {
|
|
}
|
|
}
|
|
return "success";
|
|
return "success";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String updateYkyyDoctor()throws Exception{
|
|
|
|
String sql ="select y.code AS \"code\",y.name AS \"name\",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";
|
|
|
|
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){
|
|
|
|
|
|
|
|
List<BaseDoctorDO> doctorDOs = baseDoctorDao.findByIdcard(idCard);
|
|
|
|
|
|
|
|
if(doctorDOs!=null&&doctorDOs.size()>0){
|
|
|
|
|
|
|
|
BaseDoctorDO doctor = doctorDOs.get(0);
|
|
|
|
|
|
|
|
doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
|
|
|
|
doctor.setJobTitleName(doctorJson.getString("jobTitleName"));
|
|
|
|
|
|
|
|
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(IdCardUtil.getSexForIdcard_new(idCard)));
|
|
|
|
doctor.setBirthday(IdCardUtil.getBirthdayForIdcard(idCard));
|
|
|
|
|
|
|
|
doctor.setProvinceCode("350000");
|
|
|
|
doctor.setProvinceName("福建省");
|
|
|
|
doctor.setTownCode("350203");
|
|
|
|
doctor.setTownName("思明区");
|
|
|
|
doctor.setCityCode("350200");
|
|
|
|
doctor.setCityName("厦门市");
|
|
|
|
|
|
|
|
//认证信息设置
|
|
|
|
String salt = randomString(5);
|
|
|
|
String pw = idCard.substring(idCard.length() - 6);
|
|
|
|
doctor.setPassword(MD5.md5Hex(pw + "{" + 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";
|
|
|
|
}
|
|
|
|
|
|
|
|
public String randomString(int length) {
|
|
|
|
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
|
Random random = new Random();
|
|
|
|
|
|
|
|
for(int i = 0; i < length; ++i) {
|
|
|
|
int pos = random.nextInt(str.length());
|
|
|
|
buffer.append(str.charAt(pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer.toString();
|
|
|
|
}
|
|
}
|
|
}
|