|
@ -131,77 +131,86 @@ public class SyncWlyyHospitalService {
|
|
|
//同步签约信息
|
|
|
public void synSign(){
|
|
|
try {
|
|
|
String configId = "commonGet";
|
|
|
String param = "?type=2";
|
|
|
JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "findSignAll" + param);
|
|
|
if(re!=null&&re.getInteger("status")==200){
|
|
|
List<WlyySign> list = wlyySignDao.findAll();
|
|
|
Map<String,WlyySign> signMap = list.stream().collect(Collectors.toMap(WlyySign::getIdcard, v -> v, (o1, o2) -> o1));
|
|
|
List<WlyySign> signList = new ArrayList<>(list.size());
|
|
|
JSONArray jsonArray = re.getJSONArray("data");
|
|
|
if(jsonArray.size()>0){
|
|
|
String sysTime = DateUtil.getStringDate();
|
|
|
Date createTime = new Date();
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
logger.info("i="+i);
|
|
|
JSONObject json = jsonArray.getJSONObject(i);
|
|
|
String idcard = json.getString("idcard");
|
|
|
WlyySign sign = signMap.get(idcard);
|
|
|
if(sign!=null){
|
|
|
sign.setStatus(json.getString("status"));
|
|
|
sign.setYearNum(json.getString("year_num"));
|
|
|
sign.setHospitalName(json.getString("hospital_name"));
|
|
|
sign.setDoctorName(json.getString("doctor_name"));
|
|
|
sign.setHealthDoctorName(json.getString("doctor_health_name"));
|
|
|
sign.setBegin(json.getString("begin"));
|
|
|
sign.setEnd(json.getString("end"));
|
|
|
sign.setSignYear(json.getString("sign_year"));
|
|
|
sign.setSignSource(json.getString("sign_source"));
|
|
|
sign.setDiseaseCondition(json.getString("disease_condition"));
|
|
|
sign.setAdminTeamId(json.getString("admin_team_id"));
|
|
|
sign.setSysTime(sysTime);
|
|
|
}else {
|
|
|
//新增
|
|
|
sign = new WlyySign();
|
|
|
sign.setIsNcd(0);
|
|
|
sign.setIdcard(json.getString("idcard"));
|
|
|
sign.setSsc(json.getString("ssc"));
|
|
|
sign.setSex(json.getString("sex"));
|
|
|
sign.setBirthday(json.getString("birthday"));
|
|
|
sign.setMobile(json.getString("mobile"));
|
|
|
sign.setName(json.getString("name"));
|
|
|
sign.setAddress(json.getString("address"));
|
|
|
sign.setSysTime(sysTime);
|
|
|
sign.setCreateTime(createTime);
|
|
|
sign.setStatus(json.getString("status"));
|
|
|
sign.setYearNum(json.getString("year_num"));
|
|
|
sign.setHospitalName(json.getString("hospital_name"));
|
|
|
sign.setDoctorName(json.getString("doctor_name"));
|
|
|
sign.setHealthDoctorName(json.getString("doctor_health_name"));
|
|
|
sign.setBegin(json.getString("begin"));
|
|
|
sign.setEnd(json.getString("end"));
|
|
|
sign.setSignYear(json.getString("sign_year"));
|
|
|
sign.setSignSource(json.getString("sign_source"));
|
|
|
sign.setDiseaseCondition(json.getString("disease_condition"));
|
|
|
sign.setAdminTeamId(json.getString("admin_team_id"));
|
|
|
//查询所有数据量太大 接口返回容易失败,改成按社区查询
|
|
|
String sql = "SELECT code from dm_hospital WHERE town='350212' and del=1 and LENGTH(code)=10";
|
|
|
List<String> hospitalList = jdbcTemplate.queryForList(sql,String.class);
|
|
|
List<WlyySign> list = wlyySignDao.findAll();
|
|
|
Map<String,WlyySign> signMap = list.stream().collect(Collectors.toMap(WlyySign::getIdcard, v -> v, (o1, o2) -> o1));
|
|
|
for (String code:hospitalList){
|
|
|
try {
|
|
|
String configId = "commonGet";
|
|
|
String param = "?type=2&hospital="+code;
|
|
|
JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "findSignAll" + param);
|
|
|
if(re!=null&&re.getInteger("status")==200){
|
|
|
List<WlyySign> signList = new ArrayList<>(list.size());
|
|
|
JSONArray jsonArray = re.getJSONArray("data");
|
|
|
if(jsonArray.size()>0){
|
|
|
String sysTime = DateUtil.getStringDate();
|
|
|
Date createTime = new Date();
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
logger.info("i="+i);
|
|
|
JSONObject json = jsonArray.getJSONObject(i);
|
|
|
String idcard = json.getString("idcard");
|
|
|
WlyySign sign = signMap.get(idcard);
|
|
|
if(sign!=null){
|
|
|
sign.setStatus(json.getString("status"));
|
|
|
sign.setYearNum(json.getString("year_num"));
|
|
|
sign.setHospitalName(json.getString("hospital_name"));
|
|
|
sign.setDoctorName(json.getString("doctor_name"));
|
|
|
sign.setHealthDoctorName(json.getString("doctor_health_name"));
|
|
|
sign.setBegin(json.getString("begin"));
|
|
|
sign.setEnd(json.getString("end"));
|
|
|
sign.setSignYear(json.getString("sign_year"));
|
|
|
sign.setSignSource(json.getString("sign_source"));
|
|
|
sign.setDiseaseCondition(json.getString("disease_condition"));
|
|
|
sign.setAdminTeamId(json.getString("admin_team_id"));
|
|
|
sign.setSysTime(sysTime);
|
|
|
}else {
|
|
|
//新增
|
|
|
sign = new WlyySign();
|
|
|
sign.setIsNcd(0);
|
|
|
sign.setIdcard(json.getString("idcard"));
|
|
|
sign.setSsc(json.getString("ssc"));
|
|
|
sign.setSex(json.getString("sex"));
|
|
|
sign.setBirthday(json.getString("birthday"));
|
|
|
sign.setMobile(json.getString("mobile"));
|
|
|
sign.setName(json.getString("name"));
|
|
|
sign.setAddress(json.getString("address"));
|
|
|
sign.setSysTime(sysTime);
|
|
|
sign.setCreateTime(createTime);
|
|
|
sign.setStatus(json.getString("status"));
|
|
|
sign.setYearNum(json.getString("year_num"));
|
|
|
sign.setHospitalName(json.getString("hospital_name"));
|
|
|
sign.setDoctorName(json.getString("doctor_name"));
|
|
|
sign.setHealthDoctorName(json.getString("doctor_health_name"));
|
|
|
sign.setBegin(json.getString("begin"));
|
|
|
sign.setEnd(json.getString("end"));
|
|
|
sign.setSignYear(json.getString("sign_year"));
|
|
|
sign.setSignSource(json.getString("sign_source"));
|
|
|
sign.setDiseaseCondition(json.getString("disease_condition"));
|
|
|
sign.setAdminTeamId(json.getString("admin_team_id"));
|
|
|
}
|
|
|
signList.add(sign);
|
|
|
}
|
|
|
wlyySignDao.saveAll(signList);
|
|
|
}
|
|
|
signList.add(sign);
|
|
|
signList = null;
|
|
|
}
|
|
|
wlyySignDao.saveAll(signList);
|
|
|
//更新居民id
|
|
|
String updateSql1 = "UPDATE base_patient p,wlyy_sign s set s.patient=p.id WHERE p.idcard=s.idcard and p.del='1' and s.patient is null ";
|
|
|
jdbcTemplate.execute(updateSql1);
|
|
|
|
|
|
//更新病情
|
|
|
String updateSql2 = "UPDATE base_patient p,wlyy_sign s set p.disease_condition=s.disease_condition" +
|
|
|
" WHERE p.id=s.patient and p.del='1' ";
|
|
|
jdbcTemplate.execute(updateSql2);
|
|
|
re = null;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
list = null;
|
|
|
signMap = null;
|
|
|
signList = null;
|
|
|
}
|
|
|
re = null;
|
|
|
//更新居民id
|
|
|
String updateSql1 = "UPDATE base_patient p,wlyy_sign s set s.patient=p.id WHERE p.idcard=s.idcard and p.del='1' and s.patient is null ";
|
|
|
jdbcTemplate.execute(updateSql1);
|
|
|
|
|
|
//更新病情
|
|
|
String updateSql2 = "UPDATE base_patient p,wlyy_sign s set p.disease_condition=s.disease_condition" +
|
|
|
" WHERE p.id=s.patient and p.del='1' ";
|
|
|
jdbcTemplate.execute(updateSql2);
|
|
|
list = null;
|
|
|
signMap = null;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|