Subversion Repositories SmartDukaan

Rev

Rev 28820 | Rev 28865 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28820 Rev 28839
Line 1099... Line 1099...
1099
	public void sendIndentTertiary() throws Exception {
1099
	public void sendIndentTertiary() throws Exception {
1100
 
1100
 
1101
		InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
1101
		InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
1102
				"indentandtertiary.xml");
1102
				"indentandtertiary.xml");
1103
		Attachment attachment = new Attachment(
1103
		Attachment attachment = new Attachment(
1104
				"indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now().minusDays(1)) + ".csv",
1104
				"indentandtertiary-report-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv", isr);
1105
				isr);
-
 
1106
		Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report",
1105
		Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report",
1107
				"PFA", attachment);
1106
				"PFA", attachment);
1108
 
1107
 
1109
	}
1108
	}
1110
 
1109
 
Line 1125... Line 1124...
1125
						Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))));
1124
						Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))));
1126
		for (AuthUser authUser : authUsers) {
1125
		for (AuthUser authUser : authUsers) {
1127
			User user = userMap.get(authUser.getEmailId());
1126
			User user = userMap.get(authUser.getEmailId());
1128
			Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
1127
			Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
1129
			LOGGER.info("AuthUser - {}, employeeAttendanceOptional {}", authUser.getName(), employeeAttendanceOptional);
1128
			LOGGER.info("AuthUser - {}, employeeAttendanceOptional {}", authUser.getName(), employeeAttendanceOptional);
1130
			if(employeeAttendanceOptional!=null) {
1129
			if (employeeAttendanceOptional != null) {
1131
				LOGGER.info("employeeAttendanceOptional.orElse {}", employeeAttendanceOptional.orElse(null));
1130
				LOGGER.info("employeeAttendanceOptional.orElse {}", employeeAttendanceOptional.orElse(null));
1132
				if(employeeAttendanceOptional.orElse(null) !=null) {
1131
				if (employeeAttendanceOptional.orElse(null) != null) {
1133
					LOGGER.info("employeeAttendanceOptional.get().getCreateTimestamp() {}", employeeAttendanceOptional.get().getCreateTimestamp());
1132
					LOGGER.info("employeeAttendanceOptional.get().getCreateTimestamp() {}",
-
 
1133
							employeeAttendanceOptional.get().getCreateTimestamp());
1134
				}
1134
				}
1135
			}
1135
			}
1136
			if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null
1136
			if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null
1137
					|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
1137
					|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
1138
				LOGGER.info("Will Send Email to {}", authUser.getFullName());
1138
				LOGGER.info("Will Send Email to {}", authUser.getFullName());
1139
				String body = String.format(
1139
				String body = String.format(
1140
						"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team",
1140
						"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am%s. You have been marked absent for half the day.\n\nRegards\nHR Team",
-
 
1141
						authUser.getFullName(),
1141
						authUser.getFullName(), (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? "" 
1142
						(employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null) ? ""
-
 
1143
								: "(Punched at "
1142
								: "(Punched at " + FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp()) +")" );
1144
										+ FormattingUtils.format(employeeAttendanceOptional.get().getCreateTimestamp())
-
 
1145
										+ ")");
1143
				
1146
 
1144
				  Utils.sendMailWithAttachments(googleMailSender, new String[] {
1147
				Utils.sendMailWithAttachments(googleMailSender, new String[] { authUser.getEmailId() },
1145
				  authUser.getEmailId() }, new String[] { "jyoti.rawat@smartdukaan.com" },
1148
						new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert", body);
1146
				  "Attendance Alert", body);
-
 
1147
				 
1149
 
1148
			}
1150
			}
1149
		}
1151
		}
1150
 
1152
 
1151
	}
1153
	}
1152
 
1154
 
Line 1184... Line 1186...
1184
					Duration duration = Duration.between(firstPunch, lastPunch);
1186
					Duration duration = Duration.between(firstPunch, lastPunch);
1185
					boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
1187
					boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
1186
					if (!hoursCompleted) {
1188
					if (!hoursCompleted) {
1187
						body = String.format(
1189
						body = String.format(
1188
								"Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day.\n\nRegards\nHR Team",
1190
								"Dear %s,\n Pls note that you haven't completed 8.30 Hrs (%d.%d Hrs). You have been marked absent for half the day.\n\nRegards\nHR Team",
-
 
1191
								authUser.getFullName(), duration.toHours(),
1189
								authUser.getFullName(), duration.toHours(), duration.toMinutes() - duration.toHours()*60);
1192
								duration.toMinutes() - duration.toHours() * 60);
1190
					}
1193
					}
1191
				}
1194
				}
1192
 
1195
 
1193
			}
1196
			}
1194
			if (body != null) {
1197
			if (body != null) {