| Line 209... |
Line 209... |
| 209 |
|
209 |
|
| 210 |
private static final DateTimeFormatter leadTimeFormatter = DateTimeFormatter.ofPattern("d LLL, hh:mm a");
|
210 |
private static final DateTimeFormatter leadTimeFormatter = DateTimeFormatter.ofPattern("d LLL, hh:mm a");
|
| 211 |
|
211 |
|
| 212 |
@Autowired
|
212 |
@Autowired
|
| 213 |
private PartnerRegionRepository partnerRegionRepository;
|
213 |
private PartnerRegionRepository partnerRegionRepository;
|
| 214 |
|
214 |
|
| 215 |
@Autowired
|
215 |
@Autowired
|
| 216 |
private EmployeeAttendanceRepository employeeAttendanceRepository;
|
216 |
private EmployeeAttendanceRepository employeeAttendanceRepository;
|
| 217 |
|
217 |
|
| 218 |
@Autowired
|
218 |
@Autowired
|
| 219 |
private PartnerTypeChangeService partnerTypeChangeService;
|
219 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| Line 306... |
Line 306... |
| 306 |
"niranjan.kala@smartdukaan.com" };
|
306 |
"niranjan.kala@smartdukaan.com" };
|
| 307 |
|
307 |
|
| 308 |
private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[] { "uday.singh@smartdukaan.com",
|
308 |
private static final String[] INDENT_TERTIARY_MAIL_LIST = new String[] { "uday.singh@smartdukaan.com",
|
| 309 |
"kuldeep.kumar@smartdukaan.com" };
|
309 |
"kuldeep.kumar@smartdukaan.com" };
|
| 310 |
|
310 |
|
| - |
|
311 |
private static final String[] EMPLOYEE_ATTENDANCE_MAIL_LIST = new String[] { "jyoti.rawat@smartdukaan.com",
|
| - |
|
312 |
"sm@smartdukaan.com" };
|
| - |
|
313 |
|
| 311 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
314 |
private List<OrderStatus> orderStatusList = Arrays.asList(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 312 |
|
315 |
|
| 313 |
@Autowired
|
316 |
@Autowired
|
| 314 |
private ReporticoService reporticoService;
|
317 |
private ReporticoService reporticoService;
|
| 315 |
|
318 |
|
| Line 1102... |
Line 1105... |
| 1102 |
isr);
|
1105 |
isr);
|
| 1103 |
Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report",
|
1106 |
Utils.sendMailWithAttachments(googleMailSender, INDENT_TERTIARY_MAIL_LIST, null, "Indent Tertiary Report",
|
| 1104 |
"PFA", attachment);
|
1107 |
"PFA", attachment);
|
| 1105 |
|
1108 |
|
| 1106 |
}
|
1109 |
}
|
| 1107 |
|
1110 |
|
| 1108 |
public void sendAttendanceMorningAlert() throws Exception {
|
1111 |
public void sendAttendanceMorningAlert() throws Exception {
|
| 1109 |
LocalDateTime moriningTime = LocalDate.now().atTime(10, 30);
|
1112 |
LocalDateTime moriningTime = LocalDate.now().atTime(10, 30);
|
| 1110 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
1113 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 1111 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x->x.isActive()).collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
1114 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive())
|
| - |
|
1115 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1112 |
|
1116 |
|
| 1113 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
1117 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
| 1114 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
1118 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1115 |
|
1119 |
|
| - |
|
1120 |
List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository
|
| 1116 |
List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now());
|
1121 |
.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now());
|
| 1117 |
|
1122 |
|
| 1118 |
Map<Integer, Optional<EmployeeAttendance>> employeeMorningAttendance = employeeAttendances.stream().collect(Collectors.groupingBy(EmployeeAttendance::getUserId,
|
1123 |
Map<Integer, Optional<EmployeeAttendance>> employeeMorningAttendance = employeeAttendances.stream()
|
| - |
|
1124 |
.collect(Collectors.groupingBy(EmployeeAttendance::getUserId,
|
| 1119 |
Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp)
|
1125 |
Collectors.minBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))));
|
| 1120 |
)));
|
1126 |
int i = 0;
|
| 1121 |
|
- |
|
| 1122 |
for(AuthUser authUser: authUsers) {
|
1127 |
for (AuthUser authUser : authUsers) {
|
| 1123 |
User user = userMap.get(authUser.getEmailId());
|
1128 |
User user = userMap.get(authUser.getEmailId());
|
| 1124 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
|
1129 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
|
| 1125 |
if(employeeAttendanceOptional==null
|
- |
|
| 1126 |
|| employeeAttendanceOptional.orElse(null)==null
|
1130 |
if (employeeAttendanceOptional == null || employeeAttendanceOptional.orElse(null) == null
|
| 1127 |
|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
|
1131 |
|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
|
| - |
|
1132 |
String body = String.format(
|
| 1128 |
String body = String.format("Dear %s,\n Pls note that you haven't punched your attendance by 10:30am. You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
1133 |
"Dear %s,\n Pls note that you haven't punched your attendance by 10:30am. You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team",
|
| - |
|
1134 |
authUser.getFullName());
|
| - |
|
1135 |
// Utils.sendMailWithAttachments(googleMailSender, new String[] {
|
| - |
|
1136 |
// authUser.getEmailId() }, new String[] { "jyoti.rawat@smartdukaan.com" },
|
| - |
|
1137 |
// "Attendance Alert",
|
| 1129 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { authUser.getEmailId() }, new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert",
|
1138 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" },
|
| - |
|
1139 |
new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert", body);
|
| - |
|
1140 |
if (i == 5)
|
| 1130 |
body);
|
1141 |
break;
|
| 1131 |
}
|
1142 |
}
|
| 1132 |
}
|
1143 |
}
|
| 1133 |
|
1144 |
|
| 1134 |
}
|
1145 |
}
|
| 1135 |
|
1146 |
|
| 1136 |
public void sendAttendanceEveningAlert() throws Exception {
|
1147 |
public void sendAttendanceEveningAlert() throws Exception {
|
| 1137 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
1148 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 1138 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x->x.isActive()).collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
1149 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x -> x.isActive())
|
| - |
|
1150 |
.collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1139 |
|
1151 |
|
| 1140 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
1152 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
| 1141 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
1153 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x -> x.getEmailId(), x -> x));
|
| 1142 |
|
- |
|
| 1143 |
Map<Integer, List<EmployeeAttendance>> employeeAttendancesMap = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now())
|
- |
|
| 1144 |
.stream().collect(Collectors.groupingBy(x->x.getUserId()));
|
- |
|
| 1145 |
|
1154 |
|
| - |
|
1155 |
Map<Integer, List<EmployeeAttendance>> employeeAttendancesMap = employeeAttendanceRepository
|
| - |
|
1156 |
.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now()).stream()
|
| - |
|
1157 |
.collect(Collectors.groupingBy(x -> x.getUserId()));
|
| - |
|
1158 |
|
| 1146 |
for(AuthUser authUser: authUsers) {
|
1159 |
for (AuthUser authUser : authUsers) {
|
| 1147 |
User user = userMap.get(authUser.getEmailId());
|
1160 |
User user = userMap.get(authUser.getEmailId());
|
| 1148 |
String body = null;
|
1161 |
String body = null;
|
| 1149 |
List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
|
1162 |
List<EmployeeAttendance> employeeAttendances = employeeAttendancesMap.get(user.getId());
|
| 1150 |
if(employeeAttendances==null ) {
|
1163 |
if (employeeAttendances == null) {
|
| - |
|
1164 |
body = String.format(
|
| 1151 |
body = String.format("Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
1165 |
"Dear %s,\n No attendance has been registered by you today. You have been marked absent for the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team",
|
| - |
|
1166 |
authUser.getFullName());
|
| 1152 |
} else {
|
1167 |
} else {
|
| - |
|
1168 |
List<LocalDateTime> punchTimes = employeeAttendances.stream()
|
| 1153 |
List<LocalDateTime> punchTimes = employeeAttendances.stream().sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp)).map(x->x.getCreateTimestamp()).collect(Collectors.toList());
|
1169 |
.sorted(Comparator.comparing(EmployeeAttendance::getCreateTimestamp))
|
| - |
|
1170 |
.map(x -> x.getCreateTimestamp()).collect(Collectors.toList());
|
| 1154 |
if(punchTimes.size()==1) {
|
1171 |
if (punchTimes.size() == 1) {
|
| - |
|
1172 |
// body = String.format("Dear %s,\n Pls note that you haven't punched out yet.
|
| 1155 |
//body = String.format("Dear %s,\n Pls note that you haven't punched out yet. You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
1173 |
// You have been marked absent for half the day. You may contact your manager
|
| - |
|
1174 |
// and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
| 1156 |
} else {
|
1175 |
} else {
|
| 1157 |
LocalDateTime firstPunch = punchTimes.get(0);
|
1176 |
LocalDateTime firstPunch = punchTimes.get(0);
|
| 1158 |
LocalDateTime lastPunch = punchTimes.get(punchTimes.size()-1);
|
1177 |
LocalDateTime lastPunch = punchTimes.get(punchTimes.size() - 1);
|
| 1159 |
boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
|
1178 |
boolean hoursCompleted = lastPunch.isAfter(firstPunch.plusHours(8).plusMinutes(30));
|
| 1160 |
if(!hoursCompleted) {
|
1179 |
if (!hoursCompleted) {
|
| - |
|
1180 |
body = String.format(
|
| 1161 |
body = String.format("Dear %s,\n Pls note that you have punched your attendance before 6pm. You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team", authUser.getFullName());
|
1181 |
"Dear %s,\n Pls note that you have punched your attendance before 6pm. You have been marked absent for half the day. You may contact your manager and get it regularise.\n\nRegards\nHR Team",
|
| - |
|
1182 |
authUser.getFullName());
|
| 1162 |
}
|
1183 |
}
|
| 1163 |
}
|
1184 |
}
|
| 1164 |
|
1185 |
|
| 1165 |
}
|
1186 |
}
|
| 1166 |
if(body != null) {
|
1187 |
if (body != null) {
|
| 1167 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { authUser.getEmailId() }, new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert",
|
1188 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { authUser.getEmailId() },
|
| 1168 |
body);
|
1189 |
new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert", body);
|
| 1169 |
}
|
1190 |
}
|
| 1170 |
}
|
1191 |
}
|
| - |
|
1192 |
|
| - |
|
1193 |
this.sendMailToHR();
|
| - |
|
1194 |
|
| 1171 |
|
1195 |
}
|
| - |
|
1196 |
|
| - |
|
1197 |
private void sendMailToHR() throws Exception {
|
| - |
|
1198 |
Map<String, String> map = new HashMap<>();
|
| - |
|
1199 |
String reporticoDate = FormattingUtils.formatReporitcoDate(LocalDateTime.now());
|
| - |
|
1200 |
map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
|
| - |
|
1201 |
map.put("MANUAL_datesBetween_FROMDATE", reporticoDate);
|
| - |
|
1202 |
InputStreamSource isr = reporticoService.getReportInputStreamSource(ReporticoProject.FOCO,
|
| - |
|
1203 |
"employeeattendance.xml");
|
| - |
|
1204 |
Attachment attachment = new Attachment("attendance-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv",
|
| - |
|
1205 |
isr);
|
| - |
|
1206 |
Utils.sendMailWithAttachments(googleMailSender, EMPLOYEE_ATTENDANCE_MAIL_LIST, null,
|
| - |
|
1207 |
"Attendance - " + FormattingUtils.formatDate(LocalDateTime.now()), "PFA Attendance", attachment);
|
| 1172 |
}
|
1208 |
}
|
| 1173 |
|
1209 |
|
| 1174 |
public void checkPartnerActiveStore() throws Exception {
|
1210 |
public void checkPartnerActiveStore() throws Exception {
|
| 1175 |
|
1211 |
|
| 1176 |
List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
|
1212 |
List<FofoStore> fofoStores = fofoStoreRepository.selectByStatus(true);
|
| 1177 |
|
1213 |
|
| 1178 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
1214 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
| Line 2832... |
Line 2868... |
| 2832 |
mailSender.send(message);
|
2868 |
mailSender.send(message);
|
| 2833 |
}
|
2869 |
}
|
| 2834 |
|
2870 |
|
| 2835 |
@Autowired
|
2871 |
@Autowired
|
| 2836 |
WarehouseRepository warehouseRepository;
|
2872 |
WarehouseRepository warehouseRepository;
|
| - |
|
2873 |
|
| 2837 |
public void getVendorWarehouses(int warehouseId) {
|
2874 |
public void getVendorWarehouses(int warehouseId) {
|
| 2838 |
LOGGER.info("Warehouses - {}", warehouseRepository.getVendorWarehouses().get(warehouseId));
|
2875 |
LOGGER.info("Warehouses - {}", warehouseRepository.getVendorWarehouses().get(warehouseId));
|
| 2839 |
|
2876 |
|
| 2840 |
}
|
2877 |
}
|
| 2841 |
|
2878 |
|
| 2842 |
}
|
2879 |
}
|
| 2843 |
//2284
|
2880 |
//2284
|
| 2844 |
|
2881 |
|