|
@ -17,6 +17,7 @@ import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.third.guahao.ImmuneService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import io.searchbox.client.JestClient;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@ -128,21 +129,56 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
|
|
|
|
/**
|
|
|
* 获取签约居民待接种疫苗列表
|
|
|
* @param doctorcode
|
|
|
* @param doctorcode,limitType 1要分页 0不用分页
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> getImmVaccinList(String doctorcode,int pageNo,int pageSize) {
|
|
|
String sql = "select t.*,m.family_name,m.child_name,m.birthday from wlyy_child_immune_vaccin t " +
|
|
|
public List<Map<String,Object>> getImmVaccinList(String doctorcode,int pageNo,int pageSize,int limitType) {
|
|
|
String sql = "select DISTINCT t.*,m.child_name,m.birthday,m.childCode from wlyy_child_immune_vaccin t " +
|
|
|
" inner join ( " +
|
|
|
" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday from wlyy_child_family_immune a " +
|
|
|
" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday,c.`code` AS childCode from wlyy_child_family_immune a " +
|
|
|
" inner join (select patient,name from wlyy_sign_family where type in (1,2) and `status` = 1 and expenses_status = 1 and doctor = '"+doctorcode+"') b " +
|
|
|
" on a.family_code = b.patient " +
|
|
|
" left join wlyy_child_info c on c.`code` = a.child_code " +
|
|
|
") m on m.barcode = t.barcode ";
|
|
|
int start = (pageNo-1)*pageSize;
|
|
|
sql +=" limit "+start+","+pageSize;
|
|
|
|
|
|
if (limitType==1){
|
|
|
int start = (pageNo-1)*pageSize;
|
|
|
sql +=" limit "+start+","+pageSize;
|
|
|
}
|
|
|
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map : rs){
|
|
|
String childCode = String.valueOf(map.get("childCode"));
|
|
|
String familyName="";
|
|
|
String familySql ="SELECT" +
|
|
|
" a.*, b. NAME AS family_name," +
|
|
|
" c. NAME AS child_name," +
|
|
|
" c.barcode AS barcode," +
|
|
|
" c.birthday AS birthday," +
|
|
|
" c.`code` AS childCode" +
|
|
|
" FROM" +
|
|
|
" wlyy_child_family_immune a" +
|
|
|
" INNER JOIN (" +
|
|
|
" SELECT" +
|
|
|
" patient," +
|
|
|
" NAME" +
|
|
|
" FROM" +
|
|
|
" wlyy_sign_family" +
|
|
|
" WHERE" +
|
|
|
" type IN (1, 2)" +
|
|
|
" AND `status` = 1" +
|
|
|
" AND expenses_status = 1" +
|
|
|
" AND doctor = '"+doctorcode+"'" +
|
|
|
" ) b ON a.family_code = b.patient" +
|
|
|
" LEFT JOIN wlyy_child_info c ON c.`code` = a.child_code where a.child_code='"+childCode+"'";
|
|
|
List<Map<String,Object>> familyList = jdbcTemplate.queryForList(familySql);
|
|
|
for (Map<String,Object> map1 : familyList){
|
|
|
familyName +=String.valueOf(map1.get("family_name"))+"、";
|
|
|
}
|
|
|
if (familyName.length()>1){
|
|
|
familyName = familyName.substring(0,familyName.length()-1);
|
|
|
}
|
|
|
map.put("family_name",familyName);
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
@ -157,9 +193,10 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
|
return childImmuneVaccinDao.getChildImmuneVaccinByBarcode(barcode);
|
|
|
}
|
|
|
|
|
|
public boolean alertImmVacclinByChildInfoCodes(String alertDataJsonStr, String doctor)throws Exception{
|
|
|
|
|
|
public int alertImmVacclinByChildInfoCodes(String alertDataJsonStr, String doctor)throws Exception{
|
|
|
if (StringUtils.isEmpty(alertDataJsonStr)){
|
|
|
return false;
|
|
|
return -1;
|
|
|
}
|
|
|
Doctor doctorObj = doctorDao.findByCode(doctor);
|
|
|
String doctorName = "";
|
|
@ -197,6 +234,9 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
|
" cfi.child_code = '"+childCode+"'" +
|
|
|
" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if (list.size()==0){
|
|
|
return -10000;
|
|
|
}
|
|
|
List<String> openIdList = new ArrayList<>();
|
|
|
for (Map<String,Object> map : list){
|
|
|
//如果父母亲都在就都发
|
|
@ -239,7 +279,93 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
//保存到es的提醒日志表中
|
|
|
return esSavePatientRemindRecord(patientRemindRecordESDOList);
|
|
|
esSavePatientRemindRecord(patientRemindRecordESDOList);
|
|
|
return 200;
|
|
|
}
|
|
|
|
|
|
public int alertImmVacclinByChildInfoCode(String alertDataJsonStr, String doctor)throws Exception{
|
|
|
if (StringUtils.isEmpty(alertDataJsonStr)){
|
|
|
return -1;
|
|
|
}
|
|
|
Doctor doctorObj = doctorDao.findByCode(doctor);
|
|
|
String doctorName = "";
|
|
|
String doctorLevel = "";
|
|
|
if (doctorObj!=null){
|
|
|
doctorName = doctorObj.getName();
|
|
|
if (doctorObj.getLevel()==1) {
|
|
|
doctorLevel="专科";
|
|
|
}
|
|
|
if (doctorObj.getLevel()==2) {
|
|
|
doctorLevel="全科";
|
|
|
}
|
|
|
if (doctorObj.getLevel()==3){
|
|
|
doctorLevel="健管";
|
|
|
}
|
|
|
}
|
|
|
List<PatientRemindRecordESDO> patientRemindRecordESDOList = new ArrayList<>();
|
|
|
JSONObject jsonObject = new JSONObject(alertDataJsonStr);
|
|
|
String childCode = jsonObject.getString("childCode");
|
|
|
String childName = jsonObject.getString("childName");
|
|
|
String vaccinName = jsonObject.getString("vaccinName");
|
|
|
String vaccinCode = jsonObject.getString("vaccinCode");
|
|
|
String sql ="SELECT" +
|
|
|
" cfi.relation," +
|
|
|
" p.`code`," +
|
|
|
" p.`name`," +
|
|
|
" p.openid" +
|
|
|
" FROM" +
|
|
|
" wlyy_child_family_immune cfi" +
|
|
|
" LEFT JOIN wlyy_patient p ON cfi.family_code = p.`code`" +
|
|
|
" WHERE" +
|
|
|
" cfi.child_code = '"+childCode+"'" +
|
|
|
" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if (list.size()==0){
|
|
|
return -10000;
|
|
|
}
|
|
|
List<String> openIdList = new ArrayList<>();
|
|
|
for (Map<String,Object> map : list){
|
|
|
//如果父母亲都在就都发
|
|
|
if (!openIdList.contains(String.valueOf(map.get("openid")))){
|
|
|
if (("1".equals(String.valueOf(map.get("relation"))) || "2".equals(String.valueOf(map.get("relation")))) && StringUtils.isNotBlank(String.valueOf(map.get("openid")))){
|
|
|
boolean flag =true;
|
|
|
try {
|
|
|
WechatTemplateConfig temp = templateConfigDao.findByScene("template_deal_with", "ymjztx");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("toUser",String.valueOf(map.get("code")));
|
|
|
json.put("keyword1", temp.getKeyword1().replace("key1",DateUtil.dateToStr(new Date(), "yyyy-MM-dd")));
|
|
|
json.put("keyword2", temp.getKeyword2().replace("key1", doctorName+"("+doctorLevel+")"));
|
|
|
json.put("remark", temp.getRemark());
|
|
|
json.put("first", temp.getFirst().replace("key1",String.valueOf(map.get("name"))).replace("key2", childName).replace("key3",vaccinName));
|
|
|
logger.info("weiTempJOSN:"+json.toString());
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 24,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
flag = false;
|
|
|
}
|
|
|
//发送微信消息并且插入一条es提醒数据
|
|
|
PatientRemindRecordESDO patientRemindRecordESDO = new PatientRemindRecordESDO();
|
|
|
patientRemindRecordESDO.setCode(getCode());
|
|
|
patientRemindRecordESDO.setPatient(String.valueOf(map.get("code")));
|
|
|
patientRemindRecordESDO.setPatientName(String.valueOf(map.get("name")));
|
|
|
patientRemindRecordESDO.setDoctor(doctor);
|
|
|
patientRemindRecordESDO.setDoctorName(doctorName);
|
|
|
patientRemindRecordESDO.setCreateDate(new Date());
|
|
|
patientRemindRecordESDO.setRemindType(1);
|
|
|
if (flag) {
|
|
|
patientRemindRecordESDO.setStatus(1);
|
|
|
String update="UPDATE wlyy_child_immune_vaccin SET alert_tag=1,alert_time='"+DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"' where `code`='"+vaccinCode+"'";
|
|
|
jdbcTemplate.update(update);
|
|
|
}else {
|
|
|
patientRemindRecordESDO.setStatus(0);
|
|
|
}
|
|
|
patientRemindRecordESDOList.add(patientRemindRecordESDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//保存到es的提醒日志表中
|
|
|
esSavePatientRemindRecord(patientRemindRecordESDOList);
|
|
|
return 200;
|
|
|
}
|
|
|
|
|
|
|
|
@ -371,4 +497,22 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public int alertImmVacclinByDoctor(String doctor)throws Exception{
|
|
|
List<Map<String, Object>> immVaccinList = getImmVaccinList(doctor,0,0,0);
|
|
|
String alertJsonStr="";
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (immVaccinList != null) {
|
|
|
for (Map<String, Object> map : immVaccinList) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("vaccinCode",map.get("code"));//待接种疫苗记录code
|
|
|
jsonObject.put("childName", map.get("child_name"));//儿童姓名
|
|
|
jsonObject.put("childCode", map.get("childCode"));//儿童code
|
|
|
jsonObject.put("vaccinName", map.get("ymmc"));//疫苗名称
|
|
|
jsonArray.put(jsonObject);
|
|
|
}
|
|
|
}
|
|
|
alertJsonStr = jsonArray.toString();
|
|
|
return alertImmVacclinByChildInfoCodes(alertJsonStr,doctor);
|
|
|
}
|
|
|
}
|