| Line 20... |
Line 20... |
| 20 |
import java.util.Map;
|
20 |
import java.util.Map;
|
| 21 |
import java.util.Map.Entry;
|
21 |
import java.util.Map.Entry;
|
| 22 |
import java.util.Optional;
|
22 |
import java.util.Optional;
|
| 23 |
import java.util.Set;
|
23 |
import java.util.Set;
|
| 24 |
import java.util.stream.Collectors;
|
24 |
import java.util.stream.Collectors;
|
| - |
|
25 |
import java.util.stream.IntStream;
|
| 25 |
|
26 |
|
| 26 |
import javax.mail.MessagingException;
|
27 |
import javax.mail.MessagingException;
|
| 27 |
import javax.mail.internet.InternetAddress;
|
28 |
import javax.mail.internet.InternetAddress;
|
| 28 |
import javax.mail.internet.MimeMessage;
|
29 |
import javax.mail.internet.MimeMessage;
|
| 29 |
|
30 |
|
| Line 164... |
Line 165... |
| 164 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
165 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
| 165 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
166 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 166 |
import com.spice.profitmandi.dao.repository.fofo.RazorPayRepository;
|
167 |
import com.spice.profitmandi.dao.repository.fofo.RazorPayRepository;
|
| 167 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
168 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 168 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
169 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| - |
|
170 |
import com.spice.profitmandi.dao.repository.inventory.WarehouseRepository;
|
| 169 |
import com.spice.profitmandi.dao.repository.transaction.HdfcPaymentRepository;
|
171 |
import com.spice.profitmandi.dao.repository.transaction.HdfcPaymentRepository;
|
| 170 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
172 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 171 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
173 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
| 172 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
174 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 173 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
175 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| Line 1103... |
Line 1105... |
| 1103 |
|
1105 |
|
| 1104 |
}
|
1106 |
}
|
| 1105 |
|
1107 |
|
| 1106 |
public void sendAttendanceMorningAlert() throws Exception {
|
1108 |
public void sendAttendanceMorningAlert() throws Exception {
|
| 1107 |
LocalDateTime moriningTime = LocalDate.now().atTime(10, 45);
|
1109 |
LocalDateTime moriningTime = LocalDate.now().atTime(10, 45);
|
| 1108 |
List<AuthUser> authUsers = authRepository.selectHOUsers();
|
1110 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| 1109 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x->x.isActive()).collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
1111 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x->x.isActive()).collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
| 1110 |
|
1112 |
|
| 1111 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
1113 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
| 1112 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
1114 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
| 1113 |
|
1115 |
|
| Line 1121... |
Line 1123... |
| 1121 |
User user = userMap.get(authUser.getEmailId());
|
1123 |
User user = userMap.get(authUser.getEmailId());
|
| 1122 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
|
1124 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeMorningAttendance.get(user.getId());
|
| 1123 |
if(employeeAttendanceOptional==null
|
1125 |
if(employeeAttendanceOptional==null
|
| 1124 |
|| employeeAttendanceOptional.orElseGet(null)==null
|
1126 |
|| employeeAttendanceOptional.orElseGet(null)==null
|
| 1125 |
|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
|
1127 |
|| employeeAttendanceOptional.get().getCreateTimestamp().isAfter(moriningTime)) {
|
| 1126 |
String body = String.format("Dear %s\n, Pls note that you haven't punched your attendance ONSITE by 10:45am. You have been marked absent for half the day. You may contact your manager and get it regularise.\nRegards\nHR Team", authUser.getFullName());
|
1128 |
String body = String.format("Dear %s,\n Pls note that you haven't punched your attendance by 10:45am. You have been marked absent for half the day. You may contact your manager and get it regularise.\nRegards\nHR Team", authUser.getFullName());
|
| - |
|
1129 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert",
|
| - |
|
1130 |
body);
|
| - |
|
1131 |
break;
|
| - |
|
1132 |
}
|
| - |
|
1133 |
}
|
| - |
|
1134 |
|
| - |
|
1135 |
}
|
| - |
|
1136 |
|
| - |
|
1137 |
public void sendAttendanceEveningAlert() throws Exception {
|
| - |
|
1138 |
LocalDateTime eveningTime = LocalDate.now().atTime(18, 0);
|
| - |
|
1139 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| - |
|
1140 |
Map<String, AuthUser> authUserEmailMap = authUsers.stream().filter(x->x.isActive()).collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
| - |
|
1141 |
|
| - |
|
1142 |
List<User> users = dtrUserRepository.selectAllByEmailIds(new ArrayList<>(authUserEmailMap.keySet()));
|
| - |
|
1143 |
Map<String, User> userMap = users.stream().collect(Collectors.toMap(x->x.getEmailId(), x->x));
|
| - |
|
1144 |
|
| - |
|
1145 |
List<EmployeeAttendance> employeeAttendances = employeeAttendanceRepository.selectAllByDatesBetween(LocalDate.now().atStartOfDay(), LocalDateTime.now());
|
| - |
|
1146 |
//Get punchouts only
|
| - |
|
1147 |
List<EmployeeAttendance> employeeAttendancesOut = IntStream.range(1, employeeAttendances.size()).filter(x->x%2==1).mapToObj(i->employeeAttendances.get(i)).collect(Collectors.toList());
|
| - |
|
1148 |
|
| - |
|
1149 |
Map<Integer, Optional<EmployeeAttendance>> employeeEveningAttendanceMap = employeeAttendancesOut.stream().collect(Collectors.groupingBy(EmployeeAttendance::getUserId,
|
| - |
|
1150 |
Collectors.maxBy(Comparator.comparing(EmployeeAttendance::getCreateTimestamp)
|
| - |
|
1151 |
)));
|
| - |
|
1152 |
|
| - |
|
1153 |
for(AuthUser authUser: authUsers) {
|
| - |
|
1154 |
User user = userMap.get(authUser.getEmailId());
|
| - |
|
1155 |
Optional<EmployeeAttendance> employeeAttendanceOptional = employeeEveningAttendanceMap.get(user.getId());
|
| - |
|
1156 |
if(employeeAttendanceOptional!=null
|
| - |
|
1157 |
&& employeeAttendanceOptional.orElseGet(null)!=null
|
| - |
|
1158 |
&& employeeAttendanceOptional.get().getCreateTimestamp().isBefore(eveningTime)) {
|
| - |
|
1159 |
String 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.\nRegards\nHR Team", authUser.getFullName());
|
| 1127 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert",
|
1160 |
Utils.sendMailWithAttachments(googleMailSender, new String[] { "amit.gupta@shop2020.in" }, new String[] { "jyoti.rawat@smartdukaan.com" }, "Attendance Alert",
|
| 1128 |
body);
|
1161 |
body);
|
| 1129 |
break;
|
1162 |
break;
|
| 1130 |
}
|
1163 |
}
|
| 1131 |
}
|
1164 |
}
|
| Line 2791... |
Line 2824... |
| 2791 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
2824 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smart Dukaan");
|
| 2792 |
helper.setFrom(senderAddress);
|
2825 |
helper.setFrom(senderAddress);
|
| 2793 |
mailSender.send(message);
|
2826 |
mailSender.send(message);
|
| 2794 |
}
|
2827 |
}
|
| 2795 |
|
2828 |
|
| - |
|
2829 |
@Autowired
|
| - |
|
2830 |
WarehouseRepository warehouseRepository;
|
| - |
|
2831 |
public void getVendorWarehouses(int warehouseId) {
|
| - |
|
2832 |
LOGGER.info("Warehouses - {}", warehouseRepository.getVendorWarehouses());
|
| - |
|
2833 |
|
| - |
|
2834 |
}
|
| - |
|
2835 |
|
| 2796 |
}
|
2836 |
}
|
| 2797 |
//2284
|
2837 |
//2284
|
| 2798 |
|
2838 |
|