|
@ -328,18 +328,19 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
for (Map<String,Object> map : list){
|
|
for (Map<String,Object> map : list){
|
|
//如果父母亲都在就都发
|
|
//如果父母亲都在就都发
|
|
if (!openIdList.contains(String.valueOf(map.get("openid")))){
|
|
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")))){
|
|
|
|
|
|
if (StringUtils.isNotBlank(String.valueOf(map.get("openid")))){
|
|
boolean flag =true;
|
|
boolean flag =true;
|
|
try {
|
|
try {
|
|
WechatTemplateConfig temp = templateConfigDao.findByScene("template_deal_with", "ymjztx");
|
|
|
|
|
|
WechatTemplateConfig temp = templateConfigDao.findByScene("template_doctor_survey", "ymjztx");
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
json.put("toUser",String.valueOf(map.get("code")));
|
|
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("keyword1", temp.getKeyword1());
|
|
|
|
json.put("keyword2", temp.getKeyword2().replace("key1",DateUtil.dateToStr(new Date(), "yyyy-MM-dd")));
|
|
json.put("remark", temp.getRemark());
|
|
json.put("remark", temp.getRemark());
|
|
json.put("first", temp.getFirst().replace("key1",String.valueOf(map.get("name"))).replace("key2", childName).replace("key3",vaccinName));
|
|
|
|
|
|
json.put("first", temp.getFirst().replace("key1",String.valueOf(map.get("name"))).replace("key2", childName));
|
|
|
|
json.put("url",temp.getUrl().replace("key1",childCode));
|
|
logger.info("weiTempJOSN:"+json.toString());
|
|
logger.info("weiTempJOSN:"+json.toString());
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 24,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
|
|
|
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
flag = false;
|
|
flag = false;
|
|
@ -390,115 +391,6 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public int getChildImmuneVaccinEveryDay()throws Exception{
|
|
|
|
int result = 0;
|
|
|
|
try {
|
|
|
|
String sql ="SELECT" +
|
|
|
|
" DISTINCT ci.`code`," +
|
|
|
|
" ci.idcard," +
|
|
|
|
" ci.`name`," +
|
|
|
|
" ci.ssc," +
|
|
|
|
" ci.barcode" +
|
|
|
|
" FROM" +
|
|
|
|
" wlyy_child_family_immune fi" +
|
|
|
|
" LEFT JOIN wlyy_child_info ci ON fi.child_code = ci.`code`" +
|
|
|
|
" WHERE" +
|
|
|
|
" fi.del = 0";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
for (Map<String,Object> map : list){
|
|
|
|
String barcode = String.valueOf(map.get("barcode"));
|
|
|
|
System.out.println("===============barcode=============="+barcode);
|
|
|
|
String deptStr = immuneService.findDept(barcode);
|
|
|
|
if (StringUtils.isNotBlank(deptStr)){
|
|
|
|
JSONObject jsonObject = new JSONObject(deptStr);
|
|
|
|
if (jsonObject.getInt("status")==200) {
|
|
|
|
JSONObject json = new JSONObject(jsonObject.getString("data"));
|
|
|
|
JSONArray jsonArray = json.getJSONArray("body");
|
|
|
|
for (int i = 0;i<jsonArray.length();i++){
|
|
|
|
String deptNum = jsonArray.getJSONObject(i).getString("deptNum");
|
|
|
|
String vaccinStr = immuneService.findMyVaccin(barcode,deptNum);
|
|
|
|
JSONObject vaccinJson = new JSONObject(vaccinStr);
|
|
|
|
if (vaccinJson.getInt("status")==200) {
|
|
|
|
JSONObject vaccinJson2 = new JSONObject(vaccinJson.getString("data"));
|
|
|
|
JSONArray vaccinJsonJSONArray = vaccinJson2.getJSONArray("body");
|
|
|
|
List<ChildImmuneVaccin> vaccinList = childImmuneVaccinDao.findByBarcode(barcode);
|
|
|
|
//原来有的则不用新增,原来有的但是在返回回来的数据没有的话删除数据
|
|
|
|
for (ChildImmuneVaccin childImmuneVaccin : vaccinList){
|
|
|
|
int count = 0;
|
|
|
|
for (int j=0;j<vaccinJsonJSONArray.length();j++){
|
|
|
|
String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
|
|
|
|
String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
|
|
|
|
if (childImmuneVaccin.getYmbm().equals(ymbm) && childImmuneVaccin.getJzzc().equals(jzzc)){
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//原来有的疫苗要判断是否有超过预约时间的7天,并且看提醒是否超过7天,超过7天可以重新提醒
|
|
|
|
if (count>0 && childImmuneVaccin.getIsOut()==1){
|
|
|
|
if (DateUtil.getPreDays(childImmuneVaccin.getJzrq(),7).before(new Date())){
|
|
|
|
//过了预约时间7天,更新为isOut=0,则不能预约了
|
|
|
|
childImmuneVaccinDao.updateIsOutByCode(childImmuneVaccin.getCode());
|
|
|
|
}else {
|
|
|
|
//判断是否过了7天提醒时间
|
|
|
|
if (childImmuneVaccin.getAlert_tag()==1 && DateUtil.getPreDays(childImmuneVaccin.getAlert_time(),7).before(new Date())){
|
|
|
|
childImmuneVaccinDao.updateAlertTagByCode(childImmuneVaccin.getCode(),0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count==0){
|
|
|
|
result+= childImmuneVaccinDao.updateDelByCode(childImmuneVaccin.getCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果本地没有就是新增的
|
|
|
|
List<ChildImmuneVaccin> vaccins = new ArrayList<>();
|
|
|
|
for (int j=0;j<vaccinJsonJSONArray.length();j++){
|
|
|
|
String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
|
|
|
|
String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
|
|
|
|
int count = 0;
|
|
|
|
for (ChildImmuneVaccin childImmuneVaccin : vaccinList){
|
|
|
|
if (childImmuneVaccin.getYmbm().equals(ymbm) && childImmuneVaccin.getJzzc().equals(jzzc)){
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count==0){
|
|
|
|
ChildImmuneVaccin childImmuneVaccin = new ChildImmuneVaccin();
|
|
|
|
childImmuneVaccin.setCode(getUUID());
|
|
|
|
childImmuneVaccin.setName(String.valueOf(map.get("name")));
|
|
|
|
childImmuneVaccin.setIdcard(String.valueOf(map.get("idcard")));
|
|
|
|
childImmuneVaccin.setSsc(String.valueOf(map.get("ssc")));
|
|
|
|
childImmuneVaccin.setBarcode(barcode);
|
|
|
|
childImmuneVaccin.setChildInfoCode(String.valueOf(map.get("code")));
|
|
|
|
childImmuneVaccin.setYmkc(vaccinJsonJSONArray.getJSONObject(j).getString("ymkc"));
|
|
|
|
childImmuneVaccin.setYmmc(vaccinJsonJSONArray.getJSONObject(j).getString("ymmc"));
|
|
|
|
childImmuneVaccin.setYmkcsm(vaccinJsonJSONArray.getJSONObject(j).getString("ymkcsm"));
|
|
|
|
childImmuneVaccin.setYmbm(ymbm);
|
|
|
|
childImmuneVaccin.setJzzc(jzzc);
|
|
|
|
childImmuneVaccin.setJzrq(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq"),DateUtil.YYYY_MM_DD));
|
|
|
|
childImmuneVaccin.setAlert_tag(0);
|
|
|
|
childImmuneVaccin.setDel(0);
|
|
|
|
childImmuneVaccin.setCreate_time(new Date());
|
|
|
|
if (DateUtil.getPreDays(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq")),7).before(new Date())){
|
|
|
|
//过了预约时间7天,更新为isOut=0,则不能预约了
|
|
|
|
childImmuneVaccin.setIsOut(0);
|
|
|
|
}else {
|
|
|
|
childImmuneVaccin.setIsOut(1);
|
|
|
|
}
|
|
|
|
vaccins.add(childImmuneVaccin);
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
childImmuneVaccinDao.save(vaccins);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int alertImmVacclinByDoctor(String doctor)throws Exception{
|
|
public int alertImmVacclinByDoctor(String doctor)throws Exception{
|
|
List<Map<String, Object>> immVaccinList = getImmVaccinList(doctor,0,0,0);
|
|
List<Map<String, Object>> immVaccinList = getImmVaccinList(doctor,0,0,0);
|
|
String alertJsonStr="";
|
|
String alertJsonStr="";
|
|
@ -516,46 +408,4 @@ public class ChildFamilyImmuneService extends BaseService {
|
|
alertJsonStr = jsonArray.toString();
|
|
alertJsonStr = jsonArray.toString();
|
|
return alertImmVacclinByChildInfoCodes(alertJsonStr,doctor);
|
|
return alertImmVacclinByChildInfoCodes(alertJsonStr,doctor);
|
|
}
|
|
}
|
|
|
|
|
|
public int alertBefore()throws Exception{
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
String sql ="SELECT" +
|
|
|
|
" v.*, i.birthday" +
|
|
|
|
" FROM" +
|
|
|
|
" wlyy_child_immune_vaccin v" +
|
|
|
|
" LEFT JOIN wlyy_child_info i ON v.child_info_code = i.`code`" +
|
|
|
|
" WHERE" +
|
|
|
|
" v.del = 0" +
|
|
|
|
" AND ymkc = 'true'";
|
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
|
String nowDate = DateUtil.dateToStrShort(new Date());
|
|
|
|
for (Map<String,Object> map : mapList){
|
|
|
|
Calendar calendar=Calendar.getInstance();
|
|
|
|
String birthDayStr = String.valueOf(map.get("birthday"));
|
|
|
|
if (StringUtils.isNotBlank(birthDayStr)){
|
|
|
|
String[] biStr = birthDayStr.split("-");
|
|
|
|
int birthdayDate = Integer.valueOf(biStr[biStr.length-1]);
|
|
|
|
int nowDayDate = calendar.get(GregorianCalendar.DAY_OF_MONTH);
|
|
|
|
int nowMonthDate = calendar.get(GregorianCalendar.MONTH)+1;
|
|
|
|
int nowYearDate = calendar.get(GregorianCalendar.YEAR);
|
|
|
|
//如果生日在今天的日期之前,则取下个月生日的日期的15天的是否是今天.
|
|
|
|
if (birthdayDate<nowDayDate){
|
|
|
|
calendar.set(nowYearDate,nowMonthDate+1,birthdayDate);
|
|
|
|
}else {
|
|
|
|
//如果生日在今天之前后,则看生日的15天之前是否是今天
|
|
|
|
calendar.set(nowYearDate,nowMonthDate,birthdayDate);
|
|
|
|
}
|
|
|
|
String needAlertDate = DateUtil.dateToStrShort(DateUtil.getPreDays(calendar.getTime(),-15));
|
|
|
|
if (needAlertDate.equals(nowDate)){
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put("vaccinCode",map.get("code"));//待接种疫苗记录code
|
|
|
|
jsonObject.put("childName", map.get("name"));//儿童姓名
|
|
|
|
jsonObject.put("childCode", map.get("child_info_code"));//儿童code
|
|
|
|
jsonObject.put("vaccinName", map.get("ymmc"));//疫苗名称
|
|
|
|
jsonArray.put(jsonObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return alertImmVacclinByChildInfoCodes(jsonArray.toString(),"rll201703150222");
|
|
|
|
}
|
|
|
|
}
|
|
}
|