|
@@ -140,58 +140,61 @@ public class PushController {
|
|
|
String pushContent = list.get(i).getPushContent();
|
|
|
String pushPayLoad1 = list.get(i).getPushPayLoad1();
|
|
|
String sendTime = list.get(i).getSendTime();
|
|
|
+ String useYn = list.get(i).getUseYn().trim();
|
|
|
int logIdx = 0;
|
|
|
|
|
|
- if (pushUtils.compareTime(sendTime) == true) {
|
|
|
- int idx = service.insertEveryDayPushLog(list.get(i));
|
|
|
- logIdx = list.get(i).getIdx();
|
|
|
- if (idx == 0) {
|
|
|
- } else {
|
|
|
- list.get(i).setSendState("I");
|
|
|
- service.updatePushSchedule(list.get(i));
|
|
|
- // sendType : D(즉시), R(발송중), E(매일 발송)
|
|
|
- // sendState : W(대기), I(발송중), C(완료)
|
|
|
- // targetType : A(전체), N(건강정보 미엽락자), M(본인관리환자), P(환자개별선택)
|
|
|
- List<DeviceInfoDTO> pushTargetList = service.selectPushTarget(targetType, list.get(i));
|
|
|
- for (int j = 0; j <pushTargetList.size(); j++) {
|
|
|
- String token = pushTargetList.get(j).getDeviceToken();
|
|
|
- int patientIdx = pushTargetList.get(j).getPatientIdx();
|
|
|
-
|
|
|
- PushResultDTO pushResultDto = new PushResultDTO();
|
|
|
- pushResultDto.setYm(pushUtils.getNowYm());
|
|
|
- pushResultDto.setLogIdx(logIdx);
|
|
|
- pushResultDto.setPushIdx(pushIdx);
|
|
|
- pushResultDto.setPatientIdx(patientIdx);
|
|
|
- pushResultDto.setDeviceToken(token);
|
|
|
- pushResultDto.setState("W"); // 결과 대기
|
|
|
- service.insertPushResult(pushResultDto);
|
|
|
-
|
|
|
- HashMap<String, String> response = new HashMap<String, String>();
|
|
|
- if (!token.equals("")) {
|
|
|
- response = pushUtils.sendFcm(token, pushTitle, pushContent, pushPayLoad1);
|
|
|
- } else {
|
|
|
- response.put("NOT_FOUND", "Requested entity was not found.");
|
|
|
- }
|
|
|
-
|
|
|
- for (String key : response.keySet()) {
|
|
|
- pushResultDto.setSuccessYn("N");
|
|
|
- if (key.equals("success")) {
|
|
|
- pushResultDto.setSuccessYn("Y");
|
|
|
+ if (useYn.equals("Y")) { // 사용중인 생활치료센터만
|
|
|
+ if (pushUtils.compareTime(sendTime) == true) {
|
|
|
+ int idx = service.insertEveryDayPushLog(list.get(i));
|
|
|
+ logIdx = list.get(i).getIdx();
|
|
|
+ if (idx == 0) {
|
|
|
+ } else {
|
|
|
+ list.get(i).setSendState("I");
|
|
|
+ service.updatePushSchedule(list.get(i));
|
|
|
+ // sendType : D(즉시), R(발송중), E(매일 발송)
|
|
|
+ // sendState : W(대기), I(발송중), C(완료)
|
|
|
+ // targetType : A(전체), N(건강정보 미엽락자), M(본인관리환자), P(환자개별선택), T(정신건강 미입력자)
|
|
|
+ List<DeviceInfoDTO> pushTargetList = service.selectPushTarget(targetType, list.get(i));
|
|
|
+ for (int j = 0; j <pushTargetList.size(); j++) {
|
|
|
+ String token = pushTargetList.get(j).getDeviceToken();
|
|
|
+ int patientIdx = pushTargetList.get(j).getPatientIdx();
|
|
|
+
|
|
|
+ PushResultDTO pushResultDto = new PushResultDTO();
|
|
|
+ pushResultDto.setYm(pushUtils.getNowYm());
|
|
|
+ pushResultDto.setLogIdx(logIdx);
|
|
|
+ pushResultDto.setPushIdx(pushIdx);
|
|
|
+ pushResultDto.setPatientIdx(patientIdx);
|
|
|
+ pushResultDto.setDeviceToken(token);
|
|
|
+ pushResultDto.setState("W"); // 결과 대기
|
|
|
+ service.insertPushResult(pushResultDto);
|
|
|
+
|
|
|
+ HashMap<String, String> response = new HashMap<String, String>();
|
|
|
+ if (!token.equals("")) {
|
|
|
+ response = pushUtils.sendFcm(token, pushTitle, pushContent, pushPayLoad1);
|
|
|
} else {
|
|
|
+ response.put("NOT_FOUND", "Requested entity was not found.");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String key : response.keySet()) {
|
|
|
pushResultDto.setSuccessYn("N");
|
|
|
- pushResultDto.setFailCode(key);
|
|
|
- pushResultDto.setNote(response.get(key));
|
|
|
+ if (key.equals("success")) {
|
|
|
+ pushResultDto.setSuccessYn("Y");
|
|
|
+ } else {
|
|
|
+ pushResultDto.setSuccessYn("N");
|
|
|
+ pushResultDto.setFailCode(key);
|
|
|
+ pushResultDto.setNote(response.get(key));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ pushResultDto.setState("C"); // 발송 완료
|
|
|
+ service.updatePushResult(pushResultDto);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- pushResultDto.setState("C"); // 발송 완료
|
|
|
- service.updatePushResult(pushResultDto);
|
|
|
-
|
|
|
+ service.updatePushLog(list.get(i));
|
|
|
+ list.get(i).setSendState("W");
|
|
|
+ service.updatePushSchedule(list.get(i));
|
|
|
}
|
|
|
-
|
|
|
- service.updatePushLog(list.get(i));
|
|
|
- list.get(i).setSendState("W");
|
|
|
- service.updatePushSchedule(list.get(i));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -200,7 +203,15 @@ public class PushController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Connection con;
|
|
|
+ public void deleteEndCenterSchedule() {
|
|
|
+ int cnt = service.selectEndCenterScheduleCount();
|
|
|
+
|
|
|
+ if (cnt > 0) {
|
|
|
+ service.deleteEndCenterSchedule();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Connection con;
|
|
|
private Statement stmt;
|
|
|
@RequestMapping(value = "/createResultTable", method = RequestMethod.GET)
|
|
|
public void createResultTable() {
|