|
@ -0,0 +1,79 @@
|
|
|
package com.yihu.jw.care.util;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.log.BasePatientPadPushOnOffDao;
|
|
|
import com.yihu.jw.entity.log.BasePatientPadPushOnOffEntity;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by wsl on 2022/8/2
|
|
|
*/
|
|
|
@Component
|
|
|
public class PatientPushOnOffUtil {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private BasePatientPadPushOnOffDao basePatientPadPushOnOffDao;
|
|
|
|
|
|
//初始化居民推送开关
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String patientPushOnOff(){
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
|
|
jsonObject.put("1","时间整点报时");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("2","智能安居设备状态播报(必选)");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("3","体征测量消息");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("4","用药提醒");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("5","天气预报");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("6","服务预约提醒");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("7","生日祝福提醒");
|
|
|
jsonArray.add(jsonObject);
|
|
|
jsonObject.put("8","热点新闻播报");
|
|
|
jsonArray.add(jsonObject);
|
|
|
|
|
|
String sql = "SELECT p.id FROM base_patient p WHERE p.sign_status = 1 AND p.del = 1 ";
|
|
|
|
|
|
List<String> patientList = jdbcTemplate.queryForList(sql, String.class);
|
|
|
|
|
|
List<BasePatientPadPushOnOffEntity> onOffEntityList = new ArrayList<>();
|
|
|
|
|
|
patientList.forEach(patientId -> {
|
|
|
for (int i = 1; i <= jsonArray.size(); i++) {
|
|
|
BasePatientPadPushOnOffEntity onOffEntity = new BasePatientPadPushOnOffEntity();
|
|
|
onOffEntity.setPatient(patientId);
|
|
|
onOffEntity.setType(i);
|
|
|
onOffEntity.setTypeName(jsonArray.getJSONObject(0).getString(i+""));
|
|
|
if (jsonArray.getJSONObject(0).getString(i+"").equals("智能安居设备状态播报(必选)")){
|
|
|
onOffEntity.setOnOff(1);
|
|
|
}else {
|
|
|
onOffEntity.setOnOff(0);
|
|
|
}
|
|
|
onOffEntity.setCreateTime(new Date());
|
|
|
onOffEntityList.add(onOffEntity);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
basePatientPadPushOnOffDao.save(onOffEntityList);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|