Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
micnori committed Aug 30, 2024
2 parents 55b230a + b337f0b commit de0d344
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public class CompanyLocation {
@NotNull
private String id;
@NotNull
private String address, streetNumber, zip, city, province, region, country;
private String name;
@NotNull
private String address, streetNumber, zip, city;
private String province, region, country;
@NotNull
private Double latitude, longitude, radius;
private List<Integer> nonWorking;
Expand Down Expand Up @@ -217,5 +220,11 @@ public Set<String> getNonWorkingDays() {
public void setNonWorkingDays(Set<String> nonWorkingDays) {
this.nonWorkingDays = nonWorkingDays;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public interface UserRepository extends MongoRepository<User, String> {

// @Query("{'roles.subscriptions': {$elemMatch: {campaign: ?0, companyCode:?1}}}")
// List<User> findByCampaignAndCompany(String campaign, String companyCode);

@Query("{'roles.subscriptions': {$elemMatch: {campaign: ?0, companyCode:?1, key:{$regex:?2, $options: 'i'}}}}")
Optional<User> findOneByCampaignAndCompanyAndKey(String campaign, String companyCode, String key);


@Query("{'roles.subscriptions': {$elemMatch: {companyCode:?0, key:{$regex:?1, $options: 'i'}, abandoned: {$ne: true}}}}")
Optional<User> findOneByCompanyCodeAndEmployeeCodeAndActive(String companyCode, String key);
}
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,18 @@ public void importLocations(String companyId, InputStream inputStream) throws Ex
locationIds.add(id);

loc.setId(id);
loc.setAddress(stringValue(l[1], i+1, 1, true));
loc.setStreetNumber(stringValue(l[2], i+1, 2, false));
loc.setZip(stringValue(l[3], i+1, 3, true));
loc.setCity(stringValue(l[4], i+1, 4, true));
loc.setProvince(stringValue(l[5], i+1, 5, true));
loc.setRegion(stringValue(l[6], i+1, 6, true));
loc.setCountry(stringValue(l[7], i+1, 7, false));

Double radius = doubeValue(l[8], i+1, 8, false);
if (radius == null) radius = 200d;
loc.setRadius(radius);
loc.setName(stringValue(l[1], i+1, 1, true));
loc.setAddress(stringValue(l[2], i+1, 2, true));
loc.setStreetNumber(stringValue(l[3], i+1, 3, false));
loc.setZip(stringValue(l[4], i+1, 4, true));
loc.setCity(stringValue(l[5], i+1, 5, true));
loc.setProvince(stringValue(l[6], i+1, 6, false));
loc.setRegion(stringValue(l[7], i+1, 7, false));
loc.setCountry(stringValue(l[8], i+1, 8, false));

//Double radius = doubeValue(l[9], i+1, 8, false);
//if (radius == null) radius = 200d;
loc.setRadius(200d);
loc.setLatitude(doubeValue(l[9], i+1, 9, true));
loc.setLongitude(doubeValue(l[10], i+1, 10, true));

Expand Down Expand Up @@ -607,9 +608,9 @@ public Employee setBlockedEmployee(String companyId, String employeeId, boolean
if(blocked) {
List<String> campaigns = new ArrayList<>(employee.getCampaigns());
for(String campaignId : campaigns) {
Optional<User> opt = userService.getUserByCampaignAndCompanyAndKey(campaignId, company.getCode(), employee.getCode());
if(opt.isPresent()) {
User user = opt.get();
List<User> users = userService.getUserByEmployeeCode(campaignId, company.getCode(), employee.getCode());
if(!users.isEmpty()) {
User user = users.get(0);
try {
campaignService.unsubscribePlayer(campaignId, user.getPlayerId());
campaignService.unsubscribeUser(user, campaignId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public List<DayStat> statistics(
}
List<User> users = new LinkedList<>();
for (Employee e: employees) {
users.addAll(userRepo.findByCampaignAndCompanyAndEmployeeCode(campaignId, c.getCode(), e.getCode()));
users.addAll(userRepo.findByCampaignAndCompanyAndEmployeeCode(campaignId, c.getCode(), "^" + e.getCode()+"$"));
}
criteria = criteria.and("playerId").in(users.stream().map(u -> u.getPlayerId()).collect(Collectors.toList()));
} else if (location != null && companyId != null) {
Expand Down Expand Up @@ -960,7 +960,6 @@ private List<String> extractValues(String id, Collection<DayStat> list, GROUP_BY
String[] ids = id.split(";");
res.add(ids[0]);
res.add(ids[1]);
return res;
} else {
res.add(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,6 @@ public UserInfo getUserDetail() {
public List<User> getUserByEmployeeCode(String campaign, String companyCode, String userCode) {
return userRepository.findByCampaignAndCompanyAndEmployeeCode(campaign, companyCode, "^" + userCode+"$");
}
public Optional<User> getUserByCampaignAndCompanyAndKey(String campaign, String companyCode, String userCode) {
return userRepository.findOneByCampaignAndCompanyAndKey(campaign, companyCode, userCode);
}
public User getUserByPlayerId(String playerId) {
return userRepository.findByPlayerId(playerId).orElse(null);
}
Expand Down
4 changes: 2 additions & 2 deletions console_aziendale/public/files/exampleLocations.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Identificativo;Indirizzo;Numero;CAP;Citta;Provincia;Regione;Stato;Raggio;Latitudine;Longitudine;GiorniNonLavorativi;GiorniDiChiusura
Sede 8;Via Marconi;35;44122;Ferrara;Ferrara;Emilia-Romagna;Italy;200;44.85203;11.59929;sab,dom;25/04/2021,02/06/2021
Identificativo;Denominazione;Indirizzo;Numero;CAP;Citta;Provincia;Regione;Stato;Latitudine;Longitudine;GiorniNonLavorativi;GiorniDiChiusura
Sede8;Sede 8;Via Marconi;35;44122;Ferrara;Ferrara;Emilia-Romagna;Italy;44.85203;11.59929;sab,dom;25/04/2021,02/06/2021

0 comments on commit de0d344

Please sign in to comment.