Compare commits
27 Commits
feature/Re
...
feature/Fe
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bbc01c4ef | |||
| d981e59a7d | |||
| c1c39b76e6 | |||
| 3a5bccab1b | |||
| c376b967ed | |||
| fc5b6ae3d6 | |||
| b3ac0f8755 | |||
| dac2e6cc71 | |||
| d46667d442 | |||
| ab8733b2ff | |||
| 62e3a824c9 | |||
| 9f28aebf78 | |||
| 398513b0cc | |||
| c3ad19b51f | |||
| b8453cd688 | |||
| 84dc40249f | |||
| b544a9e0d4 | |||
| 77aee05f12 | |||
| 41dbd2ac51 | |||
| 0060ac32e7 | |||
| 413da7ec86 | |||
| e79e9e107f | |||
| 9d7a0f8e22 | |||
| 9f8d1af53e | |||
| a4ae2e70bd | |||
| 76ff6f4371 | |||
| 2bf1779c23 |
@@ -1,18 +0,0 @@
|
||||
FROM tomcat:9-jre8-alpine
|
||||
|
||||
RUN apk add --no-cache fontconfig ttf-dejavu
|
||||
|
||||
ENV TZ="Europe/Rome"
|
||||
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx1G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
||||
ENV USERDOMAIN="STUDIO-ML"
|
||||
|
||||
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
||||
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
||||
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
||||
COPY ems-engine/target/ems-api.war /usr/local/tomcat/webapps/
|
||||
|
||||
#COPY docker/FontTest.class .
|
||||
#ENTRYPOINT ["java","FontTest"]
|
||||
|
||||
EXPOSE 8080
|
||||
EXPOSE 5005
|
||||
@@ -42,7 +42,7 @@ pipeline {
|
||||
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
||||
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
||||
}
|
||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Containerfile', name: 'container-files'
|
||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Dockerfile', name: 'container-files'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
||||
}
|
||||
|
||||
// bat "docker buildx build --platform linux/amd64,linux/arm64 --push -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||
bat "podman build -f .\\Containerfile -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||
bat "podman build -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||
bat "podman push \"git.studioml.it/integry/ems-api${branchVersion}:latest\""
|
||||
|
||||
//containerImageLink "git.studioml.it/integry/ems-api-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}:latest}"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251027170624 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if (!isCustomer(IntegryCustomer.Integry)) return;
|
||||
|
||||
executeStatement("UPDATE jtb_rlavr set da_ora = stb_activity.effective_time,\n" +
|
||||
" a_ora = stb_activity.effective_endtime\n" +
|
||||
" from jtb_rlavr inner join stb_activity on jtb_rlavr.activity_id = stb_activity.activity_id\n" +
|
||||
" inner join jvw_flav_nominativo on jtb_rlavr.cod_jflav = jvw_flav_nominativo.cod_jflav\n" +
|
||||
" where data_lav >= '2025/01/01'\n" +
|
||||
" and ore > 0\n" +
|
||||
" and da_ora is null",
|
||||
"update jtb_rlavr\n" +
|
||||
" set a_ora = DateAdd(MINUTE, (ore * 0.6) * 100, da_ora)\n" +
|
||||
" from jtb_rlavr\n" +
|
||||
" where data_lav >= '2025/01/01'\n" +
|
||||
" and ore > 0\n" +
|
||||
" and da_ora = a_ora",
|
||||
" update stb_activity\n" +
|
||||
" set effective_endtime = DateAdd(MINUTE, (ore * 0.6) * 100, effective_time)\n" +
|
||||
" from jtb_rlavr inner join stb_activity on stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" where data_lav >= '2025/01/01'\n" +
|
||||
" and ore > 0\n" +
|
||||
" and effective_endtime = effective_time");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -276,9 +276,7 @@ public class EmsRestConstants {
|
||||
public static final String PATH_ACTIVITY_CHANGE_COD_JCOM = PATH + "activity/changeCodJcom";
|
||||
public static final String PATH_ACTIVITY_UPDATE_WRIKE_ID = PATH + "activity/updateWrikeId";
|
||||
public static final String PATH_ACTIVITY_REMOVE_ALL_WRIKE_ID = PATH + "activity/removeAllWrikeId";
|
||||
public static final String PATH_ACTIVITY_GET_ACTIVITY = PATH + "activity/getActivity";
|
||||
public static final String PATH_ACTIVITY_GET_RESULT = PATH + "activity/getActivityResult";
|
||||
public static final String PATH_ACTIVITY_GET_TASKS = PATH + "activity/getActivityTasks";
|
||||
public static final String PATH_ACTIVITY_GET_TYPE = PATH + "activity/getActivityType";
|
||||
public static final String PATH_ACTIVITY_GET_TYPE_TASK = PATH + "activity/getActivityTypeTask";
|
||||
public static final String PATH_ACTIVITY_GET_FILE = PATH + "activity/getActivityFile";
|
||||
@@ -289,8 +287,6 @@ public class EmsRestConstants {
|
||||
public static final String PATH_ACTIVITY_GET_ALL_ACTIVITIES_BY_ACTIVE_CUSTOMERS = PATH + "activity/getAllActivitiesByActiveCustomers";
|
||||
public static final String PATH_ACTIVITY_GET_PERSONE_RIF = PATH + "activity/getPersoneRif";
|
||||
public static final String PATH_ACTIVITY_GET_TREE_VIEW = PATH + "activity/getTreeView";
|
||||
public static final String PATH_GET_ACTIVITY_CALENDAR = PATH + "activity/getActivityCalendar";
|
||||
public static final String PATH_DELETE_ACTIVITY = PATH + "activity/delete";
|
||||
public static final String PATH_GET_COMMESSA_FROM_USERNAME = PATH + "activity/getCommessaFromUsername";
|
||||
public static final String PATH_GET_ACTIVITY_HISTORY = PATH + "activity/getActivityHistory";
|
||||
public static final String PATH_SET_ACTIVITY_SOLVED = PATH + "activity/activitySolved";
|
||||
|
||||
@@ -150,18 +150,6 @@ public class ActivityController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_ACTIVITY, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivity(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(value = "daInstallare") boolean daInstallare,
|
||||
@RequestParam(value = "isTable") boolean isTable,
|
||||
@RequestParam(required = false) Integer year) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivity(isTable, daInstallare, activityId, year));
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_RESULT, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivityResult(HttpServletRequest request,
|
||||
@@ -170,18 +158,6 @@ public class ActivityController {
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivityResult());
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_TASKS, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivityTasks(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(required = false) Date effectiveDateStart,
|
||||
@RequestParam(required = false) Date effectiveDateEnd) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivityTasks(activityId, requestDataDTO.getUsername(), effectiveDateStart, effectiveDateEnd));
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_TYPE, method = RequestMethod.GET)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ServiceRestResponse getActivityType(HttpServletRequest request,
|
||||
@@ -284,27 +260,6 @@ public class ActivityController {
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_ACTIVITY_CALENDAR, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getActivityCalendar(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "startDate") String startDate,
|
||||
@RequestParam(value = "endDate") String endDate) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.getActivityCalendar(requestDataDTO.getUsername(), startDate, endDate));
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DELETE_ACTIVITY, method = RequestMethod.GET)
|
||||
public ServiceRestResponse deleteActivity(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String activityId,
|
||||
@RequestParam(required = false) boolean deleteSubActivity) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(activityService.deleteActivity(activityId, deleteSubActivity));
|
||||
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_COMMESSA_FROM_USERNAME, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getCommessaFromUsername(HttpServletRequest request,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package it.integry.ems.activity.controller;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.Task.TaskMemoRequestDTO;
|
||||
import it.integry.ems.activity.service.TaskService;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@Scope(value = "request")
|
||||
@RequestMapping("/task")
|
||||
public class TaskController {
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "getActivity")
|
||||
public ServiceRestResponse getActivity(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(value = "daInstallare") boolean daInstallare,
|
||||
@RequestParam(value = "isTable") boolean isTable,
|
||||
@RequestParam(required = false) Integer year) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.getActivity(isTable, daInstallare, activityId, year));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "getActivityTasks")
|
||||
public ServiceRestResponse getActivityTasks(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String activityId,
|
||||
@RequestParam(required = false) Date effectiveDateStart,
|
||||
@RequestParam(required = false) Date effectiveDateEnd) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.getActivityTasks(activityId, requestDataDTO.getUsername(), effectiveDateStart, effectiveDateEnd));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "getActivityCalendar")
|
||||
public ServiceRestResponse getActivityCalendar(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "startDate") String startDate,
|
||||
@RequestParam(value = "endDate") String endDate) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.getActivityCalendar(requestDataDTO.getUsername(), startDate, endDate));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "delete")
|
||||
public ServiceRestResponse deleteActivity(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam String activityId,
|
||||
@RequestParam(required = false) boolean deleteSubActivity) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.deleteActivity(activityId, deleteSubActivity));
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping(value = "insertOrUpdateMemo")
|
||||
public ServiceRestResponse insertOrUpdateMemo(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestBody TaskMemoRequestDTO taskMemoRequest) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(taskService.insertOrUpdateMemo(taskMemoRequest));
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,10 @@ public class UserAbsenceController {
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/retrieve", method = RequestMethod.GET)
|
||||
public ServiceRestResponse retrieveAssenze(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(required = false) String username,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(userAbsenceService.retrieveAssenze(startDate, endDate));
|
||||
return ServiceRestResponse.createPositiveResponse(userAbsenceService.retrieveAssenze(username, startDate, endDate));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/available-justifications", method = RequestMethod.GET)
|
||||
|
||||
@@ -2,18 +2,17 @@ package it.integry.ems.activity.controller;
|
||||
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockInRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockOutRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursDeleteDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursUpdateDTO;
|
||||
import it.integry.ems.activity.service.UserWorkHoursService;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@RestController()
|
||||
@@ -21,44 +20,55 @@ import java.time.LocalDate;
|
||||
@Scope(value = "request")
|
||||
public class UserWorkHoursController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private UserWorkHoursService userWorkHoursService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/clock-in", method = RequestMethod.POST)
|
||||
public ServiceRestResponse clockIn(HttpServletRequest request,
|
||||
@RequestBody UserWorkHoursClockInRequestDTO userWorkHoursClockInRequestDTO) throws Exception {
|
||||
@PostMapping(value = "/clock-in")
|
||||
public ServiceRestResponse clockIn(@RequestBody UserWorkHoursClockInRequestDTO userWorkHoursClockInRequestDTO) throws Exception {
|
||||
|
||||
userWorkHoursService.clockIn(requestDataDTO.getUsername(), userWorkHoursClockInRequestDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/clock-out", method = RequestMethod.POST)
|
||||
public ServiceRestResponse clockIn(HttpServletRequest request,
|
||||
@RequestBody UserWorkHoursClockOutRequestDTO userWorkHoursClockOutRequestDTO) throws Exception {
|
||||
@PostMapping(value = "/clock-out")
|
||||
public ServiceRestResponse clockOut(@RequestBody UserWorkHoursClockOutRequestDTO userWorkHoursClockOutRequestDTO) throws Exception {
|
||||
|
||||
userWorkHoursService.clockOut(requestDataDTO.getUsername(), userWorkHoursClockOutRequestDTO);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping(value = "/update-worked-hours")
|
||||
public ServiceRestResponse updateWorkedHours(@RequestBody UserWorkHoursUpdateDTO requestUpdate) throws Exception {
|
||||
|
||||
userWorkHoursService.updateWorkedHours(requestDataDTO.getUsername(), requestUpdate);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/clock-status", method = RequestMethod.GET)
|
||||
public ServiceRestResponse clockStatus(HttpServletRequest request,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@PostMapping(value = "/delete-worked-hours")
|
||||
public ServiceRestResponse deleteWorkedHours(@RequestBody UserWorkHoursDeleteDTO requestDelete) throws Exception {
|
||||
|
||||
userWorkHoursService.deleteWorkedHours(requestDataDTO.getUsername(), requestDelete);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping(value = "/clock-status")
|
||||
public ServiceRestResponse clockStatus(@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
|
||||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(userWorkHoursService.clockStatus(requestDataDTO.getUsername(), startDate, endDate));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/global-clocks-check")
|
||||
public ServiceRestResponse globalClocksCheck() throws Exception {
|
||||
|
||||
@RequestMapping(value = "/global-clocks-check", method = RequestMethod.POST)
|
||||
public ServiceRestResponse globalClocksCheck(HttpServletRequest request) throws Exception {
|
||||
userWorkHoursService.globalClocksCheck();
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ public class ActivityDTO {
|
||||
@SqlField(value = "tags")
|
||||
private String tags;
|
||||
|
||||
@SqlField(value = "scaduta")
|
||||
private Boolean scaduta;
|
||||
@SqlField(value = "stato_scadenza")
|
||||
private Integer statoScadenza;
|
||||
|
||||
@SqlField(value = "user_creator")
|
||||
private String userCreator;
|
||||
@@ -130,6 +130,9 @@ public class ActivityDTO {
|
||||
@SqlField(value = "ultima_modifica")
|
||||
private LocalDateTime ultimaModifica;
|
||||
|
||||
@SqlField(value = "user_modifier")
|
||||
private String userModifier;
|
||||
|
||||
@SqlField(value = "rag_soc")
|
||||
private String ragSoc;
|
||||
|
||||
@@ -189,6 +192,15 @@ public class ActivityDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserModifier() {
|
||||
return userModifier;
|
||||
}
|
||||
|
||||
public ActivityDTO setUserModifier(String userModifier) {
|
||||
this.userModifier = userModifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagTipologia() {
|
||||
return flagTipologia;
|
||||
}
|
||||
@@ -535,12 +547,12 @@ public class ActivityDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getScaduta() {
|
||||
return scaduta;
|
||||
public Integer getStatoScadenza() {
|
||||
return statoScadenza;
|
||||
}
|
||||
|
||||
public ActivityDTO setScaduta(Boolean scaduta) {
|
||||
this.scaduta = scaduta;
|
||||
public ActivityDTO setStatoScadenza(Integer statoScadenza) {
|
||||
this.statoScadenza = statoScadenza;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -662,6 +674,9 @@ public class ActivityDTO {
|
||||
@SqlField(value = "done_previous_quarter")
|
||||
private boolean donePreviousQuarter;
|
||||
|
||||
@SqlField(value = "activity_status")
|
||||
private Integer activityStatus;
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
@@ -770,5 +785,14 @@ public class ActivityDTO {
|
||||
this.donePreviousQuarter = donePreviousQuarter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getActivityStatus() {
|
||||
return activityStatus;
|
||||
}
|
||||
|
||||
public WorkedHours setActivityStatus(Integer activityStatus) {
|
||||
this.activityStatus = activityStatus;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ public class ActivityTaskDTO {
|
||||
@SqlField(value = "effective_endtime")
|
||||
private LocalDateTime effectiveEndtime;
|
||||
|
||||
@SqlField(value = "alarm_time")
|
||||
private LocalDateTime alarmTime;
|
||||
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
@@ -222,4 +225,13 @@ public class ActivityTaskDTO {
|
||||
this.effectiveEndtime = effectiveEndtime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getAlarmTime() {
|
||||
return alarmTime;
|
||||
}
|
||||
|
||||
public ActivityTaskDTO setAlarmTime(LocalDateTime alarmTime) {
|
||||
this.alarmTime = alarmTime;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.integry.ems.activity.dto.Task;
|
||||
|
||||
import it.integry.ems.activity.dto.ActivityTaskDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class TaskMemoRequestDTO {
|
||||
|
||||
private ActivityTaskDTO activityTaskDTO;
|
||||
private LocalDateTime notificationDate;
|
||||
|
||||
public ActivityTaskDTO getActivityTaskDTO() {
|
||||
return activityTaskDTO;
|
||||
}
|
||||
|
||||
public TaskMemoRequestDTO setActivityTaskDTO(ActivityTaskDTO activityTaskDTO) {
|
||||
this.activityTaskDTO = activityTaskDTO;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getNotificationDate() {
|
||||
return notificationDate;
|
||||
}
|
||||
|
||||
public TaskMemoRequestDTO setNotificationDate(LocalDateTime notificationDate) {
|
||||
this.notificationDate = notificationDate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -11,7 +13,7 @@ public class UserWorkHoursClockInRequestDTO {
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
public boolean isValidPosition() {
|
||||
return positionLatitude != null && positionLongitude != null;
|
||||
return !UtilityBigDecimal.isNullOrZero(positionLatitude) && !UtilityBigDecimal.isNullOrZero(positionLongitude);
|
||||
}
|
||||
|
||||
public BigDecimal getPositionLatitude() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -29,7 +31,7 @@ public class UserWorkHoursClockOutRequestDTO {
|
||||
|
||||
|
||||
public boolean isValidPosition() {
|
||||
return positionLatitude != null && positionLongitude != null;
|
||||
return !UtilityBigDecimal.isNullOrZero(positionLatitude) && !UtilityBigDecimal.isNullOrZero(positionLongitude);
|
||||
}
|
||||
|
||||
public boolean isTrasfertaEstera() {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class UserWorkHoursDeleteDTO {
|
||||
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
private boolean clockIn;
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public UserWorkHoursDeleteDTO setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isClockIn() {
|
||||
return clockIn;
|
||||
}
|
||||
|
||||
public UserWorkHoursDeleteDTO setClockIn(boolean clockIn) {
|
||||
this.clockIn = clockIn;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems.activity.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class UserWorkHoursUpdateDTO {
|
||||
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
private LocalDateTime oldTimestamp;
|
||||
|
||||
private boolean clockIn;
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public UserWorkHoursUpdateDTO setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getOldTimestamp() {
|
||||
return oldTimestamp;
|
||||
}
|
||||
|
||||
public UserWorkHoursUpdateDTO setOldTimestamp(LocalDateTime oldTimestamp) {
|
||||
this.oldTimestamp = oldTimestamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isClockIn() {
|
||||
return clockIn;
|
||||
}
|
||||
|
||||
public UserWorkHoursUpdateDTO setClockIn(boolean clockIn) {
|
||||
this.clockIn = clockIn;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.activity.service;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.*;
|
||||
import it.integry.ems.activity.utility.TaskUtility;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.media.MediaImageService;
|
||||
import it.integry.ems.media.MediaVideoService;
|
||||
@@ -861,7 +862,8 @@ public class ActivityService {
|
||||
}
|
||||
|
||||
String newActivityId = ((StbActivity) entityBase).getActivityId();
|
||||
List<ActivityDTO> activityDTO = getActivity(true, false, newActivityId, null);
|
||||
//List<ActivityDTO> activityDTO = getActivity(true, false, newActivityId, null);
|
||||
List<ActivityDTO> activityDTO = new ArrayList<>();
|
||||
|
||||
return Stream.of(activityDTO).findFirst().orElse(null);
|
||||
}
|
||||
@@ -923,288 +925,12 @@ public class ActivityService {
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public List<ActivityDTO> getActivity(boolean isTable, boolean daInstallare, String activityId, Integer year) throws Exception {
|
||||
String username = requestDataDTO.getUsername();
|
||||
|
||||
String sql = Query.format("SELECT case when key_group = 3 THEN IsNull(user_name_rif, user_name) ELSE user_name END AS user_name, \n" +
|
||||
"CAST( case when key_group = 3 THEN 1 ELSE 0 END as BIT) as isCliente,\n" +
|
||||
"CAST( case when key_group = 3 and user_name_rif is not null THEN 1 ELSE 0 END as BIT) as isPersonaRif FROM stb_user WHERE user_name = %s", username);
|
||||
|
||||
HashMap<String, Object> datiUtente = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
boolean isPersonaRif = false;
|
||||
boolean isCliente = false;
|
||||
if (!datiUtente.isEmpty()) {
|
||||
username = UtilityHashMap.getValueIfExists(datiUtente, "user_name");
|
||||
isCliente = UtilityHashMap.getValueIfExists(datiUtente, "isCliente");
|
||||
isPersonaRif = UtilityHashMap.getValueIfExists(datiUtente, "isPersonaRif");
|
||||
}
|
||||
|
||||
sql = "WITH escludi_commesse AS (SELECT value cod_jcom\n" +
|
||||
" FROM string_split((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'STB_ACTIVITY'\n" +
|
||||
" AND section = 'SETUP'\n" +
|
||||
" AND key_section = 'ESCLUDI_COMMESSE'), '|') s)\n" +
|
||||
" SELECT stb_activity.cod_jcom as 'Commessa',\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_id as 'Id_Attivita',\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.activity_description as 'Descrizione',\n" +
|
||||
" stb_activity.estimated_time as 'Data_Inizio_prev',\n" +
|
||||
" stb_activity.estimated_endtime as 'data_fine_prev',\n" +
|
||||
" stb_activity.effective_time as 'Data_Inizio_Effettiva',\n" +
|
||||
" stb_activity.effective_endtime as 'Data_Fine_Effettiva',\n" +
|
||||
" stb_activity.flag_risolto,\n" +
|
||||
" stb_activity.estimated_hours as 'Ore_Stimate',\n" +
|
||||
" CAST(CASE WHEN stb_activity.effective_endtime IS NULL THEN 0 ELSE 1 END AS BIT) AS 'attivita_chiusa', \n" +
|
||||
" stb_activity.activity_result_id AS 'Esito',\n" +
|
||||
" stb_activity.result_description AS 'descr_esito',\n" +
|
||||
" ISNULL(stb_activity.priorita, 0) AS 'priorita',\n" +
|
||||
" stb_activity.activity_type_id AS 'tipo_attivita',\n" +
|
||||
" IsNull(stb_activity.ora_ins_act, stb_activity.data_ins_act) AS 'data_inserimento',\n" +
|
||||
" stb_activity.ora_mod_act AS 'ultima_modifica'," +
|
||||
" CAST(CASE WHEN estimated_enddate < CAST(GETDATE() AS DATE) THEN 1 ELSE 0 END AS BIT) AS scaduta,\n" +
|
||||
" stb_activity.persona_rif AS 'richiedente',\n" +
|
||||
" stb_activity.estimated_enddate,\n" +
|
||||
" stb_activity.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity.cod_mart IS NULL THEN 'NESSUN PRODOTTO'\n" +
|
||||
" ELSE ISNULL(mtb_aart.descr_cassa, mtb_aart.descrizione) END AS descr_prodotto,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_user.full_name as 'Responsabile',\n" +
|
||||
" parent.responabile_progetto,\n" +
|
||||
" ISNULL(parent.project_description, '') AS 'project_description',\n" +
|
||||
" ISNULL(parent.activity_description, 'Altre Attività') AS 'parent_activity_description',\n" +
|
||||
" creator.full_name AS 'creata_da',\n" +
|
||||
" parent.activity_type_id AS 'parent_activity_type',\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita IS NULL THEN 0 --backlog\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 0 THEN 1 --programmato\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 1 THEN 2 --in corso\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 2 AND\n" +
|
||||
" stb_activity_result.flag_activity_result = -1 THEN 3 --sospesa\n" +
|
||||
" WHEN stb_activity_result.flag_stato_attivita = 2 AND\n" +
|
||||
" stb_activity_result.flag_activity_result = 1 THEN 4 --test\n" +
|
||||
" ELSE 5 /*completata*/ END AS stato_attivita,\n" +
|
||||
" CAST(ISNULL(integry_tag.is_bug, 0) AS BIT) AS is_bug,\n" +
|
||||
" integry_tag.tags,\n" +
|
||||
" DENSE_RANK() OVER (ORDER BY parent.project_description, parent.activity_description) AS id_processo,\n" +
|
||||
" gtb_anag.rag_soc,\n " +
|
||||
" task.dapagare AS da_pagare,\n " +
|
||||
" task.acanone AS a_canone\n ";
|
||||
if (daInstallare) {
|
||||
sql += ", CAST(lastUpdt.data AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
} else {
|
||||
sql += ", CAST(NULL AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
}
|
||||
sql += " FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" INNER JOIN stb_user creator ON stb_activity.user_creator = creator.user_name\n" +
|
||||
" LEFT OUTER JOIN pvw_clienti_prospect gtb_anag on stb_activity.cod_anag = gtb_anag.cod_ppro and stb_activity.tipo_anag = gtb_anag.tipologia\n" +
|
||||
" AND gtb_anag.flag_stato = 'A'\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN (SELECT parent.activity_description AS project_description,\n" +
|
||||
" stb_activity.activity_description AS activity_description,\n" +
|
||||
" stb_activity.activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.persona_rif AS responabile_progetto\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN stb_activity parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" WHERE stb_activity.flag_tipologia = 'P') parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" LEFT OUTER JOIN stb_activity_result\n" +
|
||||
" ON stb_activity.activity_result_id = stb_activity_result.activity_result_id\n" +
|
||||
" LEFT OUTER JOIN integry_tag ON stb_activity.activity_id = integry_tag.activity_id \n" +
|
||||
" OUTER APPLY ( SELECT CAST(MAX(CASE WHEN task.cod_jfas <> 'C01' THEN 0 ELSE 1 END) AS BIT) AS daPagare,\n" +
|
||||
" CAST(MAX(CASE WHEN task.cod_jfas = 'C01' THEN 0 ELSE 1 END) AS BIT) AS aCanone \n" +
|
||||
" FROM stb_activity task WHERE stb_activity.activity_id = task.parent_activity_id) task ";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " LEFT OUTER JOIN integry_last_upd_clie lastUpdt ON stb_activity.cod_anag = lastUpdt.cod_anag\n";
|
||||
}
|
||||
|
||||
sql += " WHERE stb_activity.flag_tipologia = 'P'\n" +
|
||||
" AND NOT EXISTS(SELECT *\n" +
|
||||
" FROM escludi_commesse\n" +
|
||||
" WHERE stb_activity.cod_jcom = escludi_commesse.cod_jcom)\n" +
|
||||
" AND EXISTS (SELECT *\n" +
|
||||
" FROM srl_activity_type inner join stb_activity_type a on srl_activity_type.activity_type_id_next = a.activity_type_id\n" +
|
||||
" WHERE stb_activity.activity_type_id = srl_activity_type.activity_type_id\n" +
|
||||
" and srl_activity_type.flag_tipologia = 'P' \n";
|
||||
if (activityId == null) {
|
||||
sql += " and srl_activity_type.flag_tipologia_next = 'A' \n";
|
||||
}
|
||||
sql += " and a.flag_attiva = 's'\n" +
|
||||
" GROUP BY srl_activity_type.activity_type_id\n" +
|
||||
" HAVING sum(IIF(flag_tipologia_next = 'A',0,1)) = 0 )\n ";
|
||||
|
||||
if (year == null && activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA')\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom) \n";
|
||||
} else if (activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa = 'CHIUSA'\n" +
|
||||
" AND (YEAR(data_inizi_lav) = " + year + " OR YEAR(data_cons) = " + year + ")\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom )\n";
|
||||
}
|
||||
|
||||
if (!isTable) {
|
||||
sql += " AND stb_activity.effective_endtime IS NULL " +
|
||||
" AND stb_activity.activity_type_id <> 'AGGIORNAMENTI SOFTWARE'";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " AND stb_activity.activity_result_id = 'DA INSTALLARE' AND cod_jcom not like 'INTEGRY%'";
|
||||
}
|
||||
} else if (activityId != null) {
|
||||
sql += " AND stb_activity.activity_id = " + UtilityDB.valueToString(activityId);
|
||||
} else if (isCliente) {
|
||||
sql += " AND stb_activity.activity_result_id NOT IN ('ANNULLATA', 'SOSPESA')";
|
||||
|
||||
if (isPersonaRif) {
|
||||
String whereCondPersRif =
|
||||
Query.format(" AND EXISTS( SELECT *\n" +
|
||||
" from stb_user s inner join vtb_clie_pers_rif on s.e_mail = vtb_clie_pers_rif.e_mail\n" +
|
||||
" where S.USER_NAME = %s and vtb_clie_pers_rif.persona_rif = stb_activity.persona_rif)",
|
||||
requestDataDTO.getUsername());
|
||||
sql += whereCondPersRif;
|
||||
}
|
||||
}
|
||||
|
||||
List<ActivityDTO> activityDTOS = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.class);
|
||||
|
||||
if (activityDTOS != null) {
|
||||
List<String> elencoId = Stream.of(activityDTOS).map(ActivityDTO::getIdAttivita).toList();
|
||||
sql =
|
||||
"SELECT stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL), stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_this_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_previous_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_next_week,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())), 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore_fatte\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.parent_activity_id IN (" + UtilityDB.listValueToString(elencoId) + ")\n" +
|
||||
"GROUP BY stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name";
|
||||
|
||||
List<ActivityDTO.WorkedHours> activityResponseDtoWorkedHours = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.WorkedHours.class);
|
||||
|
||||
if (activityResponseDtoWorkedHours != null) {
|
||||
final HashMap<String, List<ActivityDTO.WorkedHours>> subActivityList = activityResponseDtoWorkedHours.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ActivityDTO.WorkedHours::getParentActivityId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
for (ActivityDTO activityResponse : activityDTOS) {
|
||||
if (subActivityList.containsKey(activityResponse.getIdAttivita())) {
|
||||
List<ActivityDTO.WorkedHours> workedHours = subActivityList.get(activityResponse.getIdAttivita());
|
||||
|
||||
for (ActivityDTO.WorkedHours workedHour : workedHours) {
|
||||
if (workedHour.getActivityDescription() != null &&
|
||||
workedHour.getActivityDescription().equals(activityResponse.getDescrizione())) {
|
||||
workedHour.setActivityDescription(null);
|
||||
}
|
||||
}
|
||||
|
||||
activityResponse.setWorkedHours(workedHours);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return activityDTOS;
|
||||
}
|
||||
|
||||
public List<ActivityResultDTO> getActivityResult() throws Exception {
|
||||
String sql = "select activity_result_id from stb_activity_result where flag_attivo LIKE 'S'";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityResultDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityTasks(String activityId, String username, Date effectiveDateStart, Date effectiveDateEnd) throws Exception {
|
||||
String sql = "SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" effective_date,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_date,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n";
|
||||
|
||||
List<String> conditions = new ArrayList<>();
|
||||
|
||||
if (activityId != null && !activityId.isEmpty()) {
|
||||
conditions.add("stb_activity.parent_activity_id = " + UtilityDB.valueToString(activityId));
|
||||
} else {
|
||||
conditions.add("stb_activity.user_name LIKE " + UtilityDB.valueToString(username));
|
||||
}
|
||||
|
||||
if (effectiveDateStart != null && effectiveDateEnd != null) {
|
||||
conditions.add("effective_date BETWEEN " +
|
||||
UtilityDB.valueToString(effectiveDateStart) + " AND " +
|
||||
UtilityDB.valueToString(effectiveDateEnd));
|
||||
}
|
||||
|
||||
conditions.add("stb_activity.flag_tipologia = 'A'");
|
||||
|
||||
sql += "WHERE " + String.join(" AND ", conditions);
|
||||
|
||||
sql += "\nGROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.activity_type_id, stb_activity.parent_activity_id, activity_description, stb_activity.user_name, full_name, effective_date, activity_result_id, result_description, stb_activity.note, estimated_date, estimated_time, estimated_endtime, effective_time, effective_endtime";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTypeDTO> getActivityType() throws Exception {
|
||||
String sql = "SELECT DISTINCT srl_activity_type.activity_type_id, \n" +
|
||||
"srl_activity_type.flag_tipologia,\n" +
|
||||
@@ -1587,75 +1313,6 @@ public class ActivityService {
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, TreeViewDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityCalendar(String username, String startDate, String endDate) throws Exception {
|
||||
String sql = "WITH sottoattivita AS (SELECT stb_activity.activity_id, stb_activity.activity_type_id\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" AND stb_activity.user_name = " + UtilityDB.valueToString(username) + "\n" +
|
||||
" GROUP BY stb_activity.activity_id, stb_activity.activity_type_id)\n" +
|
||||
"\n" +
|
||||
"SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
"\t sottoattivita.activity_type_id AS 'parent_activity_type_id',\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" effective_date,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) AS ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_date,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime\n" +
|
||||
"\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN sottoattivita ON stb_activity.parent_activity_id = sottoattivita.activity_id\n" +
|
||||
"\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.user_name = " + UtilityDB.valueToString(username) + "\n" +
|
||||
" AND (estimated_date BETWEEN " + UtilityDB.valueToString(startDate) + " AND " + UtilityDB.valueToString(endDate) + "\n" +
|
||||
" OR effective_date BETWEEN " + UtilityDB.valueToString(startDate) + " AND " + UtilityDB.valueToString(endDate) + ")\n" +
|
||||
"\n" +
|
||||
"GROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.parent_activity_id, sottoattivita.activity_type_id, stb_activity.activity_type_id, activity_description,\n" +
|
||||
" stb_activity.user_name, full_name, effective_date, activity_result_id, result_description, stb_activity.note,\n" +
|
||||
" estimated_date, estimated_time, estimated_endtime, effective_time, effective_endtime;";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public boolean deleteActivity(String activityId, boolean deleteSubActivity) throws Exception {
|
||||
StbActivity activity = new StbActivity();
|
||||
activity.setActivityId(activityId);
|
||||
activity.setOperation(OperationType.DELETE);
|
||||
|
||||
if (deleteSubActivity) {
|
||||
List<StbActivity> stbActivityList = new ArrayList<>();
|
||||
|
||||
List<ActivityTaskDTO> activityTasks = getActivityTasks(activityId, null, null, null);
|
||||
for (ActivityTaskDTO activityTask : activityTasks) {
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
stbActivity.setActivityId(activityTask.getActivityId());
|
||||
stbActivity.setOperation(OperationType.DELETE);
|
||||
|
||||
stbActivityList.add(stbActivity);
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(stbActivityList, true);
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(activity, multiDBTransactionManager);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getCommessaFromUsername(String username) throws Exception {
|
||||
String sql = "SELECT DISTINCT jc.cod_jcom\n" +
|
||||
"FROM stb_user\n" +
|
||||
@@ -1721,8 +1378,8 @@ public class ActivityService {
|
||||
|
||||
public List<OldUpdateDTO> getOldUpdate() throws Exception {
|
||||
String sql = "WITH commesse AS (SELECT cod_jcom,\n" +
|
||||
" jtb_comt.cod_anag,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY jtb_comt.cod_anag ORDER BY cod_jcom DESC, servers.updated_at DESC, vtb_clie.flag_stato) AS conta,\n" +
|
||||
" wtb_clie2.cod_anag,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY wtb_clie2.cod_anag ORDER BY cod_jcom DESC, servers.updated_at DESC, vtb_clie.flag_stato) AS conta,\n" +
|
||||
" servers.last_update,\n" +
|
||||
" gtb_anag.rag_soc\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
package it.integry.ems.activity.service;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems.activity.dto.ActivityDTO;
|
||||
import it.integry.ems.activity.dto.ActivityTaskDTO;
|
||||
import it.integry.ems.activity.dto.Task.TaskMemoRequestDTO;
|
||||
import it.integry.ems.activity.utility.TaskUtility;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.order.crm.service.CrmService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.StbActivity;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class TaskService {
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private CrmService crmService;
|
||||
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
public List<ActivityDTO> getActivity(boolean isTable, boolean daInstallare, String activityId, Integer year) throws Exception {
|
||||
String username = requestDataDTO.getUsername();
|
||||
|
||||
String sql = Query.format("SELECT case when key_group = 3 THEN IsNull(user_name_rif, user_name) ELSE user_name END AS user_name, \n" +
|
||||
"CAST( case when key_group = 3 THEN 1 ELSE 0 END as BIT) as isCliente,\n" +
|
||||
"CAST( case when key_group = 3 and user_name_rif is not null THEN 1 ELSE 0 END as BIT) as isPersonaRif FROM stb_user WHERE user_name = %s", username);
|
||||
|
||||
HashMap<String, Object> datiUtente = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
boolean isPersonaRif = false;
|
||||
boolean isCliente = false;
|
||||
if (!datiUtente.isEmpty()) {
|
||||
username = UtilityHashMap.getValueIfExists(datiUtente, "user_name");
|
||||
isCliente = UtilityHashMap.getValueIfExists(datiUtente, "isCliente");
|
||||
isPersonaRif = UtilityHashMap.getValueIfExists(datiUtente, "isPersonaRif");
|
||||
}
|
||||
|
||||
sql = "WITH escludi_commesse AS (SELECT value cod_jcom\n" +
|
||||
" FROM string_split((SELECT value\n" +
|
||||
" FROM stb_gest_setup\n" +
|
||||
" WHERE gest_name = 'STB_ACTIVITY'\n" +
|
||||
" AND section = 'SETUP'\n" +
|
||||
" AND key_section = 'ESCLUDI_COMMESSE'), '|') s)\n" +
|
||||
" SELECT stb_activity.cod_jcom as 'Commessa',\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_id as 'Id_Attivita',\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.activity_description as 'Descrizione',\n" +
|
||||
" stb_activity.estimated_time as 'Data_Inizio_prev',\n" +
|
||||
" stb_activity.estimated_endtime as 'data_fine_prev',\n" +
|
||||
" stb_activity.effective_time as 'Data_Inizio_Effettiva',\n" +
|
||||
" stb_activity.effective_endtime as 'Data_Fine_Effettiva',\n" +
|
||||
" stb_activity.flag_risolto,\n" +
|
||||
" stb_activity.estimated_hours as 'Ore_Stimate',\n" +
|
||||
" CAST(CASE WHEN stb_activity.effective_endtime IS NULL THEN 0 ELSE 1 END AS BIT) AS attivita_chiusa, \n" +
|
||||
" stb_activity.activity_result_id AS Esito,\n" +
|
||||
" stb_activity.result_description AS descr_esito,\n" +
|
||||
" ISNULL(stb_activity.priorita, 0) AS priorita,\n" +
|
||||
" stb_activity.activity_type_id AS tipo_attivita,\n" +
|
||||
" IsNull(stb_activity.ora_ins_act, stb_activity.data_ins_act) AS data_inserimento,\n" +
|
||||
" stb_activity.ora_mod_act AS ultima_modifica,\n" +
|
||||
" stb_activity.user_modifier AS user_modifier,\n" +
|
||||
" CASE WHEN estimated_enddate is null then 0\n" +
|
||||
" WHEN estimated_enddate < CAST(GETDATE() AS DATE) THEN 4\n" +
|
||||
" WHEN estimated_enddate between DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()), 0) AND DATEADD(DAY, 6, DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()), 0)) THEN 3\n" +
|
||||
" WHEN estimated_enddate between DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()) + 1, 0) and DATEADD(DAY, 6, DATEADD(WEEK, DATEDIFF(WEEK, 0, GETDATE()) + 1, 0)) THEN 2\n " +
|
||||
" ELSE 1 END AS stato_scadenza,\n" +
|
||||
" stb_activity.persona_rif AS 'richiedente',\n" +
|
||||
" stb_activity.estimated_enddate,\n" +
|
||||
" stb_activity.cod_mart AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN stb_activity.cod_mart IS NULL THEN 'NESSUN PRODOTTO'\n" +
|
||||
" ELSE ISNULL(mtb_aart.descr_cassa, mtb_aart.descrizione) END AS descr_prodotto,\n" +
|
||||
" stb_activity.user_creator,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" stb_user.full_name as 'Responsabile',\n" +
|
||||
" parent.responabile_progetto,\n" +
|
||||
" ISNULL(parent.project_description, '') AS 'project_description',\n" +
|
||||
" ISNULL(parent.activity_description, 'Altre Attività') AS 'parent_activity_description',\n" +
|
||||
" creator.full_name AS 'creata_da',\n" +
|
||||
" parent.activity_type_id AS 'parent_activity_type',\n" +
|
||||
" dbo.f_integry_gestStatusTask(stb_activity.activity_result_id) AS stato_attivita,\n" +
|
||||
" CAST(ISNULL(integry_tag.is_bug, 0) AS BIT) AS is_bug,\n" +
|
||||
" integry_tag.tags,\n" +
|
||||
" DENSE_RANK() OVER (ORDER BY parent.project_description, parent.activity_description) AS id_processo,\n" +
|
||||
" gtb_anag.rag_soc,\n " +
|
||||
" task.dapagare AS da_pagare,\n " +
|
||||
" task.acanone AS a_canone\n ";
|
||||
if (daInstallare) {
|
||||
sql += ", CAST(lastUpdt.data AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
} else {
|
||||
sql += ", CAST(NULL AS DATETIME) AS ultimo_aggiornamento\n";
|
||||
}
|
||||
sql += " FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" INNER JOIN stb_user creator ON stb_activity.user_creator = creator.user_name\n" +
|
||||
" LEFT OUTER JOIN pvw_clienti_prospect gtb_anag on stb_activity.cod_anag = gtb_anag.cod_ppro and stb_activity.tipo_anag = gtb_anag.tipologia\n" +
|
||||
" AND gtb_anag.flag_stato = 'A'\n" +
|
||||
" LEFT OUTER JOIN mtb_aart ON stb_activity.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN (SELECT parent.activity_description AS project_description,\n" +
|
||||
" stb_activity.activity_description AS activity_description,\n" +
|
||||
" stb_activity.activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.persona_rif AS responabile_progetto\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN stb_activity parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" WHERE stb_activity.flag_tipologia = 'P') parent\n" +
|
||||
" ON stb_activity.parent_activity_id = parent.activity_id\n" +
|
||||
" LEFT OUTER JOIN stb_activity_result\n" +
|
||||
" ON stb_activity.activity_result_id = stb_activity_result.activity_result_id\n" +
|
||||
" LEFT OUTER JOIN integry_tag ON stb_activity.activity_id = integry_tag.activity_id \n" +
|
||||
" OUTER APPLY ( SELECT CAST(MAX(CASE WHEN task.cod_jfas <> 'C01' THEN 0 ELSE 1 END) AS BIT) AS daPagare,\n" +
|
||||
" CAST(MAX(CASE WHEN task.cod_jfas = 'C01' THEN 0 ELSE 1 END) AS BIT) AS aCanone \n" +
|
||||
" FROM stb_activity task WHERE stb_activity.activity_id = task.parent_activity_id) task ";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " LEFT OUTER JOIN integry_last_upd_clie lastUpdt ON stb_activity.cod_anag = lastUpdt.cod_anag\n";
|
||||
}
|
||||
|
||||
sql += " WHERE stb_activity.flag_tipologia = 'P'\n" +
|
||||
" AND NOT EXISTS(SELECT *\n" +
|
||||
" FROM escludi_commesse\n" +
|
||||
" WHERE stb_activity.cod_jcom = escludi_commesse.cod_jcom)\n" +
|
||||
" AND EXISTS (SELECT *\n" +
|
||||
" FROM srl_activity_type inner join stb_activity_type a on srl_activity_type.activity_type_id_next = a.activity_type_id\n" +
|
||||
" WHERE stb_activity.activity_type_id = srl_activity_type.activity_type_id\n" +
|
||||
" and srl_activity_type.flag_tipologia = 'P' \n";
|
||||
if (activityId == null) {
|
||||
sql += " and srl_activity_type.flag_tipologia_next = 'A' \n";
|
||||
}
|
||||
sql += " and a.flag_attiva = 's'\n" +
|
||||
" GROUP BY srl_activity_type.activity_type_id\n" +
|
||||
" HAVING sum(IIF(flag_tipologia_next = 'A',0,1)) = 0 )\n ";
|
||||
|
||||
if (year == null && activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA')\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom) \n";
|
||||
} else if (activityId == null) {
|
||||
sql += " AND EXISTS (SELECT *\n" +
|
||||
" FROM jtb_comt\n" +
|
||||
" WHERE stato_commessa = 'CHIUSA'\n" +
|
||||
" AND (YEAR(data_inizi_lav) = " + year + " OR YEAR(data_cons) = " + year + ")\n" +
|
||||
" AND stb_activity.cod_jcom = jtb_comt.cod_jcom )\n";
|
||||
}
|
||||
|
||||
if (!isTable) {
|
||||
sql += " AND stb_activity.effective_endtime IS NULL " +
|
||||
" AND stb_activity.activity_type_id <> 'AGGIORNAMENTI SOFTWARE'";
|
||||
|
||||
if (daInstallare) {
|
||||
sql += " AND stb_activity.activity_result_id = 'DA INSTALLARE' AND cod_jcom not like 'INTEGRY%'";
|
||||
}
|
||||
} else if (activityId != null) {
|
||||
sql += " AND stb_activity.activity_id = " + UtilityDB.valueToString(activityId);
|
||||
} else if (isCliente) {
|
||||
sql += " AND stb_activity.activity_result_id NOT IN ('ANNULLATA', 'SOSPESA')";
|
||||
|
||||
if (isPersonaRif) {
|
||||
String whereCondPersRif =
|
||||
Query.format(" AND EXISTS( SELECT *\n" +
|
||||
" from stb_user s inner join vtb_clie_pers_rif on s.e_mail = vtb_clie_pers_rif.e_mail\n" +
|
||||
" where S.USER_NAME = %s and vtb_clie_pers_rif.persona_rif = stb_activity.persona_rif)",
|
||||
requestDataDTO.getUsername());
|
||||
sql += whereCondPersRif;
|
||||
}
|
||||
}
|
||||
|
||||
List<ActivityDTO> activityDTOS = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.class);
|
||||
|
||||
if (activityDTOS != null) {
|
||||
List<String> elencoId = Stream.of(activityDTOS).map(ActivityDTO::getIdAttivita).toList();
|
||||
sql =
|
||||
"SELECT stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name,\n" +
|
||||
" MAX(IIF(effective_date <= CAST(GETDATE() AS DATE), effective_date, NULL)) AS last_activity_date,\n" +
|
||||
" MIN(IIF(estimated_date >= CAST(GETDATE() AS DATE), estimated_date, NULL)) AS next_activity_date,\n" +
|
||||
" MAX(IIF(((estimated_date BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()) OR\n" +
|
||||
" estimated_date IS NULL) AND effective_date IS NULL), stb_activity.activity_description,\n" +
|
||||
" NULL)) AS activity_description,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(GETDATE()) AND dbo.f_getlastdayofweek(GETDATE()),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_this_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, -1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_previous_week,\n" +
|
||||
" CAST(MAX(IIF(\n" +
|
||||
" ISNULL(effective_date, estimated_date) BETWEEN dbo.f_getfirstdayofweek(DATEADD(WEEK, 1, GETDATE())) AND dbo.f_getlastdayofweek(DATEADD(WEEK, 1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS planned_next_week,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(GETDATE()) AND EOMONTH(GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" effective_date BETWEEN dbo.f_getfirstdayofmonth(DATEADD(MONTH, -1, GETDATE())) AND EOMONTH(DATEADD(MONTH, -1, GETDATE())),\n" +
|
||||
" 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_month,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND\n" +
|
||||
" DATEPART(QUARTER, effective_date) = DATEPART(QUARTER, GETDATE()), 1,\n" +
|
||||
" 0)) AS BIT) AS done_this_quarter,\n" +
|
||||
" CAST(MAX(IIF(effective_date IS NOT NULL AND DATEPART(QUARTER, effective_date) =\n" +
|
||||
" DATEPART(QUARTER, DATEADD(MONTH, -3, GETDATE())), 1,\n" +
|
||||
" 0)) AS BIT) AS done_previous_quarter,\n" +
|
||||
" SUM(jtb_rlavr.ore) AS ore_fatte,\n" +
|
||||
" min(dbo.f_integry_gestStatusTask(stb_activity.activity_result_id)) AS activity_status \n" +
|
||||
"FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.parent_activity_id IN (" + UtilityDB.listValueToString(elencoId) + ")\n" +
|
||||
"GROUP BY stb_activity.parent_activity_id,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" stb_user.full_name";
|
||||
|
||||
List<ActivityDTO.WorkedHours> activityResponseDtoWorkedHours = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityDTO.WorkedHours.class);
|
||||
|
||||
if (activityResponseDtoWorkedHours != null) {
|
||||
final HashMap<String, List<ActivityDTO.WorkedHours>> subActivityList = activityResponseDtoWorkedHours.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ActivityDTO.WorkedHours::getParentActivityId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
for (ActivityDTO activityResponse : activityDTOS) {
|
||||
if (subActivityList.containsKey(activityResponse.getIdAttivita())) {
|
||||
List<ActivityDTO.WorkedHours> workedHours = subActivityList.get(activityResponse.getIdAttivita());
|
||||
|
||||
for (ActivityDTO.WorkedHours workedHour : workedHours) {
|
||||
if (workedHour.getActivityDescription() != null &&
|
||||
workedHour.getActivityDescription().equals(activityResponse.getDescrizione())) {
|
||||
workedHour.setActivityDescription(null);
|
||||
}
|
||||
}
|
||||
|
||||
activityResponse.setWorkedHours(workedHours);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return activityDTOS;
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityTasks(String activityId, String username, Date effectiveDateStart, Date effectiveDateEnd) throws Exception {
|
||||
String sql = "SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" effective_date,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_date,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" effective_time,\n" +
|
||||
" effective_endtime\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n";
|
||||
|
||||
List<String> conditions = new ArrayList<>();
|
||||
|
||||
if (activityId != null && !activityId.isEmpty()) {
|
||||
conditions.add("stb_activity.parent_activity_id = " + UtilityDB.valueToString(activityId));
|
||||
} else {
|
||||
conditions.add("stb_activity.user_name LIKE " + UtilityDB.valueToString(username));
|
||||
}
|
||||
|
||||
if (effectiveDateStart != null && effectiveDateEnd != null) {
|
||||
conditions.add("effective_date BETWEEN " +
|
||||
UtilityDB.valueToString(effectiveDateStart) + " AND " +
|
||||
UtilityDB.valueToString(effectiveDateEnd));
|
||||
}
|
||||
|
||||
conditions.add("stb_activity.flag_tipologia = 'A'");
|
||||
|
||||
sql += "WHERE " + String.join(" AND ", conditions);
|
||||
|
||||
sql += "\nGROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.activity_type_id, stb_activity.parent_activity_id, activity_description, stb_activity.user_name, full_name, effective_date, activity_result_id, result_description, stb_activity.note, estimated_date, estimated_time, estimated_endtime, effective_time, effective_endtime";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public List<ActivityTaskDTO> getActivityCalendar(String username, String startDate, String endDate) throws Exception {
|
||||
String sql = Query.format(
|
||||
"WITH progetto AS (SELECT stb_activity.activity_id, stb_activity.activity_type_id\n" +
|
||||
" FROM stb_activity\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" AND stb_activity.user_name = %s\n" +
|
||||
" GROUP BY stb_activity.activity_id, stb_activity.activity_type_id)\n" +
|
||||
"\n" +
|
||||
"SELECT stb_activity.activity_id,\n" +
|
||||
" stb_activity.cod_jcom,\n" +
|
||||
" stb_activity.parent_activity_id,\n" +
|
||||
" progetto.activity_type_id AS 'parent_activity_type_id',\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" activity_description,\n" +
|
||||
" stb_activity.user_name,\n" +
|
||||
" full_name,\n" +
|
||||
" activity_result_id,\n" +
|
||||
" result_description,\n" +
|
||||
" SUM(ore) AS ore_lav,\n" +
|
||||
" stb_activity.note,\n" +
|
||||
" estimated_time,\n" +
|
||||
" estimated_endtime,\n" +
|
||||
" ISNULL(jtb_rlavr.da_ora, effective_time) AS effective_time,\n" +
|
||||
" ISNULL(jtb_rlavr.a_ora, effective_endtime) AS effective_endtime\n" +
|
||||
"FROM stb_activity\n" +
|
||||
" LEFT OUTER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id\n" +
|
||||
" INNER JOIN stb_user ON stb_activity.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN progetto ON stb_activity.parent_activity_id = progetto.activity_id\n" +
|
||||
"WHERE stb_activity.flag_tipologia = 'A'\n" +
|
||||
" AND stb_activity.user_name = %s\n" +
|
||||
" AND (estimated_date BETWEEN %s AND %s\n" +
|
||||
" OR CAST(ISNULL(jtb_rlavr.da_ora, effective_time) AS DATE) BETWEEN %s AND %s)\n" +
|
||||
"GROUP BY stb_activity.activity_id, stb_activity.cod_jcom, stb_activity.parent_activity_id,\n" +
|
||||
" progetto.activity_type_id, stb_activity.activity_type_id, activity_description,\n" +
|
||||
" stb_activity.user_name, full_name, activity_result_id, result_description, stb_activity.note,\n" +
|
||||
" estimated_time, estimated_endtime, ISNULL(jtb_rlavr.da_ora, effective_time),\n" +
|
||||
" ISNULL(jtb_rlavr.a_ora, effective_endtime)",
|
||||
username, username, startDate, endDate, startDate, endDate
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityTaskDTO.class);
|
||||
}
|
||||
|
||||
public boolean deleteActivity(String activityId, boolean deleteSubActivity) throws Exception {
|
||||
StbActivity activity = new StbActivity().setActivityId(activityId);
|
||||
|
||||
if (deleteSubActivity) {
|
||||
List<StbActivity> stbActivityList = new ArrayList<>();
|
||||
|
||||
List<ActivityTaskDTO> activityTasks = getActivityTasks(activityId, null, null, null);
|
||||
for (ActivityTaskDTO activityTask : activityTasks) {
|
||||
StbActivity stbActivity = new StbActivity().setActivityId(activityTask.getActivityId());
|
||||
|
||||
stbActivity.setOperation(OperationType.DELETE);
|
||||
stbActivityList.add(stbActivity);
|
||||
}
|
||||
|
||||
entityProcessor.processEntityList(stbActivityList, true);
|
||||
}
|
||||
|
||||
activity.setOperation(OperationType.DELETE);
|
||||
entityProcessor.processEntity(activity, multiDBTransactionManager);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ActivityTaskDTO insertOrUpdateMemo(TaskMemoRequestDTO taskMemoRequest) throws Exception {
|
||||
StbActivity activity = TaskUtility.buildStbActivityFromActivityTask(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
taskMemoRequest.getActivityTaskDTO()
|
||||
).setAlarmTime(
|
||||
taskMemoRequest.getNotificationDate() == null ?
|
||||
EmsRestConstants.LOCAL_DATE_TIME_NULL : taskMemoRequest.getNotificationDate()
|
||||
);
|
||||
|
||||
activity.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(activity, multiDBTransactionManager);
|
||||
|
||||
crmService.createActivityNotification(activity);
|
||||
|
||||
return TaskUtility.buildActivityTaskFromStbActivity(activity);
|
||||
}
|
||||
}
|
||||
@@ -57,21 +57,54 @@ public class UserAbsenceService {
|
||||
@Autowired
|
||||
private RequestDataDTO requestDataDTO;
|
||||
|
||||
public List<AssenzaDTO> retrieveAssenze(LocalDate startDate, LocalDate endDate) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
"WHERE giustificativo IS NOT NULL\n" +
|
||||
" AND jtb_rlavt.data_lav BETWEEN %s AND %s",
|
||||
startDate, endDate
|
||||
);
|
||||
public List<AssenzaDTO> retrieveAssenze(String username, LocalDate startDate, LocalDate endDate) throws Exception {
|
||||
String sql;
|
||||
|
||||
if (startDate != null && endDate != null) {
|
||||
sql = Query.format(
|
||||
"SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
"WHERE giustificativo IS NOT NULL\n" +
|
||||
" AND jtb_rlavt.data_lav BETWEEN %s AND %s",
|
||||
startDate, endDate
|
||||
);
|
||||
} else {
|
||||
sql = "SELECT jrl_flav_users.user_name,\n" +
|
||||
" data_lav,\n" +
|
||||
" jtb_rlavt.giustificativo,\n" +
|
||||
" jtb_rlavt.note,\n" +
|
||||
" jtb_rlavt.ore_assenza,\n" +
|
||||
" jtb_rlavt.cod_jflav\n" +
|
||||
"FROM jtb_rlavt\n" +
|
||||
" LEFT OUTER JOIN jrl_flav_users\n" +
|
||||
" ON jrl_flav_users.cod_jflav = jtb_rlavt.cod_jflav AND jrl_flav_users.flag_jflav_default = 'S'\n" +
|
||||
" INNER JOIN jtb_giustifica ON jtb_rlavt.giustificativo = jtb_giustifica.giustificativo\n" +
|
||||
"WHERE jtb_rlavt.giustificativo IS NOT NULL\n" +
|
||||
" AND flag_recupero = 'N'\n";
|
||||
|
||||
if (startDate != null) {
|
||||
sql += Query.format(
|
||||
" AND jtb_rlavt.data_lav >= %s\n",
|
||||
startDate
|
||||
);
|
||||
} else if (endDate != null) {
|
||||
sql += Query.format(
|
||||
" AND jtb_rlavt.data_lav <= %s\n",
|
||||
endDate
|
||||
);
|
||||
}
|
||||
|
||||
if (username != null) {
|
||||
sql += Query.format(" AND user_name = %s\n", username);
|
||||
}
|
||||
}
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, AssenzaDTO.class);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package it.integry.ems.activity.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockHistoryDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockInRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursClockOutRequestDTO;
|
||||
import it.integry.ems.activity.dto.UserWorkHoursStatusDTO;
|
||||
import it.integry.ems.activity.dto.*;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.googleCloudApi.service.GeocodingService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.SystemService;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
@@ -21,6 +19,7 @@ import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.googleCloudApi.dto.IndirizzoDTO;
|
||||
import it.integry.firebase.dto.MessageDTO;
|
||||
import it.integry.firebase.dto.NotificationDTO;
|
||||
import it.integry.firebase.dto.android.AndroidConfigDTO;
|
||||
@@ -28,8 +27,6 @@ import it.integry.firebase.dto.android.AndroidNotificationDTO;
|
||||
import it.integry.firebase.dto.apns.ApnsConfigDTO;
|
||||
import it.integry.firebase.dto.apns.ApsDTO;
|
||||
import it.integry.firebase.service.NotificationService;
|
||||
import it.integry.googleCloudApi.dto.IndirizzoDTO;
|
||||
import it.integry.googleCloudApi.service.GeocodingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -72,11 +69,22 @@ public class UserWorkHoursService {
|
||||
private GeocodingService geocodingService;
|
||||
|
||||
public void clockIn(String username, UserWorkHoursClockInRequestDTO userWorkHoursClockInRequestDTO) throws Exception {
|
||||
if (!userWorkHoursClockInRequestDTO.isValidPosition())
|
||||
throw new Exception("Posizione di ingresso non valida");
|
||||
IndirizzoDTO positionFromCoords = new IndirizzoDTO();
|
||||
|
||||
if (userWorkHoursClockInRequestDTO.isValidPosition()) {
|
||||
positionFromCoords = geocodingService.getPositionFromCoords(
|
||||
multiDBTransactionManager,
|
||||
userWorkHoursClockInRequestDTO.getPositionLatitude(),
|
||||
userWorkHoursClockInRequestDTO.getPositionLongitude()
|
||||
);
|
||||
}
|
||||
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(codJflav, userWorkHoursClockInRequestDTO.getTimestamp() != null ? userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() : LocalDate.now());
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(
|
||||
codJflav,
|
||||
userWorkHoursClockInRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() : LocalDate.now()
|
||||
);
|
||||
|
||||
if (userWorkHoursStatusDTO != null && userWorkHoursStatusDTO.isUserInside()) {
|
||||
throw new Exception("E' già presente un ingresso effettuato il " +
|
||||
@@ -87,15 +95,12 @@ public class UserWorkHoursService {
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(userWorkHoursClockInRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() :LocalDate.now())
|
||||
userWorkHoursClockInRequestDTO.getTimestamp().toLocalDate() : LocalDate.now())
|
||||
.setInseritoDa(username)
|
||||
.setCodDiviCont(retrieveDefaultCodDiviCont());
|
||||
|
||||
jtbRLavt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
final IndirizzoDTO positionFromCoords =
|
||||
geocodingService.getPositionFromCoords(multiDBTransactionManager, userWorkHoursClockInRequestDTO.getPositionLatitude(), userWorkHoursClockInRequestDTO.getPositionLongitude());
|
||||
|
||||
JtbRLavr jtbRLavr = new JtbRLavr()
|
||||
.setDaOra(userWorkHoursClockInRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockInRequestDTO.getTimestamp() : LocalDateTime.now())
|
||||
@@ -111,17 +116,27 @@ public class UserWorkHoursService {
|
||||
|
||||
|
||||
public void clockOut(String username, UserWorkHoursClockOutRequestDTO userWorkHoursClockOutRequestDTO) throws Exception {
|
||||
if (!userWorkHoursClockOutRequestDTO.isValidPosition())
|
||||
throw new Exception("Posizione di uscita non valida");
|
||||
IndirizzoDTO positionFromCoords = new IndirizzoDTO();
|
||||
|
||||
if (userWorkHoursClockOutRequestDTO.isValidPosition()) {
|
||||
positionFromCoords = geocodingService.getPositionFromCoords(
|
||||
multiDBTransactionManager,
|
||||
userWorkHoursClockOutRequestDTO.getPositionLatitude(),
|
||||
userWorkHoursClockOutRequestDTO.getPositionLongitude()
|
||||
);
|
||||
}
|
||||
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(codJflav, userWorkHoursClockOutRequestDTO.getTimestamp() != null ? userWorkHoursClockOutRequestDTO.getTimestamp().toLocalDate() : LocalDate.now());
|
||||
UserWorkHoursStatusDTO userWorkHoursStatusDTO = retrieveUltimaTimbratura(
|
||||
codJflav,
|
||||
userWorkHoursClockOutRequestDTO.getTimestamp() != null ?
|
||||
userWorkHoursClockOutRequestDTO.getTimestamp().toLocalDate() : LocalDate.now()
|
||||
);
|
||||
|
||||
if (userWorkHoursStatusDTO == null || !userWorkHoursStatusDTO.isUserInside()) {
|
||||
throw new Exception("Nessun ingresso rilevato");
|
||||
}
|
||||
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(userWorkHoursClockOutRequestDTO.getTimestamp() != null ?
|
||||
@@ -137,9 +152,6 @@ public class UserWorkHoursService {
|
||||
if (userWorkHoursClockOutRequestDTO.isTrasfertaItalia())
|
||||
jtbRLavt.setFlagTrasferta("S");
|
||||
|
||||
final IndirizzoDTO positionFromCoords =
|
||||
geocodingService.getPositionFromCoords(multiDBTransactionManager, userWorkHoursClockOutRequestDTO.getPositionLatitude(), userWorkHoursClockOutRequestDTO.getPositionLongitude());
|
||||
|
||||
JtbRLavr jtbRLavr = new JtbRLavr()
|
||||
.setCodJcom(userWorkHoursClockOutRequestDTO.getCodJcom())
|
||||
.setCodJfas(userWorkHoursClockOutRequestDTO.getCodJfas())
|
||||
@@ -157,6 +169,61 @@ public class UserWorkHoursService {
|
||||
}
|
||||
|
||||
|
||||
public void updateWorkedHours(String username, UserWorkHoursUpdateDTO requestUpdate) throws Exception {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
|
||||
JtbRLavr jtbRLavr = retrieveRigaLavr(codJflav, requestUpdate.getOldTimestamp().toLocalDate(), requestUpdate.getOldTimestamp());
|
||||
|
||||
if (jtbRLavr == null) {
|
||||
throw new Exception("Timbratura non trovata");
|
||||
} else {
|
||||
jtbRLavr.setOperation(OperationType.UPDATE);
|
||||
|
||||
if (requestUpdate.isClockIn())
|
||||
jtbRLavr.setDaOra(requestUpdate.getTimestamp())
|
||||
.setModificatoDa(username);
|
||||
else
|
||||
jtbRLavr.setaOra(requestUpdate.getTimestamp())
|
||||
.setModificatoDa(username);
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(requestUpdate.getTimestamp() != null ?
|
||||
requestUpdate.getTimestamp().toLocalDate() : LocalDate.now())
|
||||
.setInseritoDa(username)
|
||||
.setCodDiviCont(retrieveDefaultCodDiviCont());
|
||||
|
||||
jtbRLavt.setOperation(OperationType.NO_OP);
|
||||
jtbRLavt.getJtbRlavr().add(jtbRLavr);
|
||||
|
||||
entityProcessor.processEntity(jtbRLavt, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteWorkedHours(String username, UserWorkHoursDeleteDTO requestDelete) throws Exception {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
|
||||
JtbRLavt jtbRLavt = new JtbRLavt()
|
||||
.setCodJflav(codJflav)
|
||||
.setDataLav(requestDelete.getTimestamp() != null ?
|
||||
requestDelete.getTimestamp().toLocalDate() : LocalDate.now())
|
||||
.setInseritoDa(username)
|
||||
.setCodDiviCont(retrieveDefaultCodDiviCont());
|
||||
|
||||
JtbRLavr jtbRLavr = retrieveRigaLavr(codJflav, requestDelete.getTimestamp().toLocalDate(), requestDelete.getTimestamp());
|
||||
|
||||
if (jtbRLavr == null) {
|
||||
throw new Exception("Timbratura non trovata");
|
||||
} else {
|
||||
jtbRLavr.setOperation(OperationType.DELETE);
|
||||
|
||||
jtbRLavt.setOperation(OperationType.NO_OP);
|
||||
jtbRLavt.getJtbRlavr().add(jtbRLavr);
|
||||
|
||||
entityProcessor.processEntity(jtbRLavt, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
|
||||
private String retrieveDefaultCodDiviCont() throws SQLException, IOException, PrimaryDatabaseNotPresentException {
|
||||
return setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "WINACCESS", "SETUP", "COD_DIVI_CONT");
|
||||
}
|
||||
@@ -176,6 +243,20 @@ public class UserWorkHoursService {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, UserWorkHoursStatusDTO.class);
|
||||
}
|
||||
|
||||
private JtbRLavr retrieveRigaLavr(String codJflav, LocalDate date, LocalDateTime timestamp) throws Exception {
|
||||
|
||||
String sql = Query.format(
|
||||
"SELECT *\n" +
|
||||
"FROM jtb_rlavr\n" +
|
||||
"WHERE data_lav = %s\n" +
|
||||
" AND cod_jflav = %s\n" +
|
||||
" AND ((da_ora IS NULL OR a_ora IS NULL) AND (da_ora = %s OR a_ora = %s))",
|
||||
date, codJflav, timestamp, timestamp
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, JtbRLavr.class);
|
||||
}
|
||||
|
||||
public List<UserWorkHoursClockHistoryDTO> clockStatus(String username, LocalDate startDate, LocalDate endDate) throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||
String codJflav = userService.retrieveCodJflav(username);
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package it.integry.ems.activity.utility;
|
||||
|
||||
import it.integry.ems.activity.dto.ActivityTaskDTO;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems_model.entity.StbActivity;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
public class TaskUtility {
|
||||
|
||||
public static StbActivity buildStbActivityFromActivityTask(Connection conn, ActivityTaskDTO activity) throws Exception {
|
||||
StbActivity stbActivity = new StbActivity();
|
||||
|
||||
stbActivity.setActivityId(activity.getActivityId())
|
||||
.setActivityDescription(activity.getActivityDescription())
|
||||
.setNote(activity.getNote())
|
||||
.setResultDescription(activity.getResultDescription())
|
||||
.setActivityTypeId(activity.getActivityTypeId())
|
||||
.setActivityResultId(activity.getActivityResultId())
|
||||
.setUserName(activity.getUserName())
|
||||
.setEffectiveTime(activity.getEffectiveTime())
|
||||
.setEffectiveEndtime(activity.getEffectiveEndtime())
|
||||
.setEstimatedTime(activity.getEstimatedTime())
|
||||
.setEstimatedEndtime(activity.getEstimatedEndtime())
|
||||
.setOreRapportino(activity.getOreLav())
|
||||
.setFlagTipologia("A")
|
||||
.setCodJfas(retrieveCodJfas(conn, activity.getActivityTypeId(), stbActivity.getFlagTipologia()));
|
||||
|
||||
return stbActivity;
|
||||
}
|
||||
|
||||
public static ActivityTaskDTO buildActivityTaskFromStbActivity(StbActivity stbActivity) throws Exception {
|
||||
ActivityTaskDTO activity = new ActivityTaskDTO();
|
||||
|
||||
activity.setActivityId(stbActivity.getActivityId())
|
||||
.setActivityDescription(stbActivity.getActivityDescription())
|
||||
.setNote(stbActivity.getNote())
|
||||
.setResultDescription(stbActivity.getResultDescription())
|
||||
.setActivityTypeId(stbActivity.getActivityTypeId())
|
||||
.setActivityResultId(stbActivity.getActivityResultId())
|
||||
.setUserName(stbActivity.getUserName())
|
||||
.setEffectiveTime(stbActivity.getEffectiveTime())
|
||||
.setEffectiveEndtime(stbActivity.getEffectiveEndtime())
|
||||
.setEstimatedTime(stbActivity.getEstimatedTime())
|
||||
.setEstimatedEndtime(stbActivity.getEstimatedEndtime())
|
||||
.setOreLav(stbActivity.getOreRapportino())
|
||||
.setAlarmTime(stbActivity.getAlarmTime());
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
||||
public static String retrieveCodJfas(Connection conn, String activityType, String flagTipologia) throws Exception {
|
||||
String sql = Query.format(
|
||||
"SELECT cod_jfas\n" +
|
||||
"FROM stb_activity_type\n" +
|
||||
"WHERE activity_type_id = %s\n" +
|
||||
" AND flag_tipologia = %s",
|
||||
activityType, flagTipologia
|
||||
);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user