[CARELLI - CalendarioPV]
- nuove entity e servizi
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20250327144500 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
executeStatement("CREATE TABLE dbo.stb_activity_plan\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY\n" +
|
||||||
|
" CONSTRAINT pk_stb_activity_plan\n" +
|
||||||
|
" PRIMARY KEY,\n" +
|
||||||
|
" activity_type_id VARCHAR(40) NOT NULL,\n" +
|
||||||
|
" start_time TIME NOT NULL,\n" +
|
||||||
|
" end_time TIME NOT NULL,\n" +
|
||||||
|
" first_occurrence DATE NOT NULL,\n" +
|
||||||
|
" last_occurrence DATE,\n" +
|
||||||
|
" is_active BIT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" is_repeatable BIT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" is_all_day BIT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" periodicity_type TINYINT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" periodicity_frequency INT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" recurrence_rule VARCHAR(255),\n" +
|
||||||
|
" max_repetitions INT DEFAULT 0 NOT NULL\n" +
|
||||||
|
")");
|
||||||
|
|
||||||
|
executeStatement("create table dbo.srl_activity_plan_user\n" +
|
||||||
|
"(\n" +
|
||||||
|
" plan_id BIGINT not null\n" +
|
||||||
|
" constraint fk_srl_activity_plan_use_stb_activity_plan\n" +
|
||||||
|
" references dbo.stb_activity_plan (id),\n" +
|
||||||
|
" username VARCHAR(40)\n" +
|
||||||
|
" constraint fk_srl_activity_plan_use_stb_user\n" +
|
||||||
|
" references dbo.stb_user,\n" +
|
||||||
|
" constraint pk_srl_activity_plan_user\n" +
|
||||||
|
" primary key (plan_id, username)\n" +
|
||||||
|
")");
|
||||||
|
executeStatement("alter table dbo.stb_activity\n" +
|
||||||
|
" add plan_id bigint\n" +
|
||||||
|
" constraint fk_stb_activity_stb_activity_plan\n" +
|
||||||
|
" references dbo.stb_activity_plan (id)");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -301,6 +301,9 @@ public class EmsRestConstants {
|
|||||||
public static final String PATH_GET_OLD_UPDATE = PATH + "activity/oldUpdate";
|
public static final String PATH_GET_OLD_UPDATE = PATH + "activity/oldUpdate";
|
||||||
public static final String PATH_SEARCH_ACTIVITY = PATH + "activity/searchActivity";
|
public static final String PATH_SEARCH_ACTIVITY = PATH + "activity/searchActivity";
|
||||||
public static final String PATH_SUGGEST_ACTIVITY_DESCRIPTION = PATH + "activity/suggestActivityDescription";
|
public static final String PATH_SUGGEST_ACTIVITY_DESCRIPTION = PATH + "activity/suggestActivityDescription";
|
||||||
|
public static final String PATH_POST_ACTIVITY_PLAN = "activity/plan/{id}";
|
||||||
|
public static final String PATH_GET_SCHEDULED_ACTIVITIES = "activity/schduledActivities";
|
||||||
|
|
||||||
//SteUP
|
//SteUP
|
||||||
public static final String PATH_LOGIN_STEUP = PATH + "login";
|
public static final String PATH_LOGIN_STEUP = PATH + "login";
|
||||||
public static final String PATH_LOGINAZIENDA_STEUP = PATH + "loginAzienda";
|
public static final String PATH_LOGINAZIENDA_STEUP = PATH + "loginAzienda";
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package it.integry.ems_model.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import it.integry.ems_model.annotation.Master;
|
||||||
|
import it.integry.ems_model.annotation.PK;
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.annotation.Table;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
|
@Master
|
||||||
|
@PropertyReactive
|
||||||
|
@Table(SrlActivityPlanUser.ENTITY)
|
||||||
|
@JsonTypeName(SrlActivityPlanUser.ENTITY)
|
||||||
|
public class SrlActivityPlanUser extends EntityBase {
|
||||||
|
|
||||||
|
private final static Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
public static final String ENTITY = "srl_activity_plan_user";
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@PK
|
||||||
|
@SqlField(value = "plan_id", maxLength = 40, nullable = false)
|
||||||
|
private Long planId;
|
||||||
|
|
||||||
|
|
||||||
|
@PK
|
||||||
|
@SqlField(value = "username", maxLength = 40, nullable = false)
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
public SrlActivityPlanUser() {
|
||||||
|
super(logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPlanId() {
|
||||||
|
return planId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SrlActivityPlanUser setPlanId(Long planId) {
|
||||||
|
this.planId = planId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SrlActivityPlanUser setUserName(String username) {
|
||||||
|
this.userName = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -191,6 +191,10 @@ public class StbActivity extends EntityBase {
|
|||||||
@SqlField(value = "cod_mgrp", maxLength = 5)
|
@SqlField(value = "cod_mgrp", maxLength = 5)
|
||||||
private String codMgrp;
|
private String codMgrp;
|
||||||
|
|
||||||
|
@ImportFromParent(value = "id")
|
||||||
|
@SqlField(value = "plan_id", maxLength = 15)
|
||||||
|
private String planId;
|
||||||
|
|
||||||
@EntityChild
|
@EntityChild
|
||||||
private List<StbActivityCosts> stbActivityCosts = new ArrayList<>();
|
private List<StbActivityCosts> stbActivityCosts = new ArrayList<>();
|
||||||
|
|
||||||
@@ -730,6 +734,15 @@ public class StbActivity extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPlanId() {
|
||||||
|
return planId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivity setPlanId(String planId) {
|
||||||
|
this.planId = planId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<StbActivityCosts> getStbActivityCosts() {
|
public List<StbActivityCosts> getStbActivityCosts() {
|
||||||
return stbActivityCosts;
|
return stbActivityCosts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,231 @@
|
|||||||
|
package it.integry.ems_model.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import it.integry.ems_model.annotation.*;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.kie.api.definition.type.PropertyReactive;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
|
||||||
|
@Master
|
||||||
|
@PropertyReactive
|
||||||
|
@Table(StbActivityPlan.ENTITY)
|
||||||
|
@JsonTypeName(StbActivityPlan.ENTITY)
|
||||||
|
public class StbActivityPlan extends EntityBase {
|
||||||
|
public static final String ENTITY = "stb_activity_plan";
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@PK()
|
||||||
|
@Identity()
|
||||||
|
@SqlField(value = "id", nullable = false)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@SqlField("activity_type_id")
|
||||||
|
private String activityTypeId;
|
||||||
|
|
||||||
|
@SqlField("first_occurrence")
|
||||||
|
private LocalDate firstOccurrence;
|
||||||
|
|
||||||
|
@SqlField("last_occurrence")
|
||||||
|
private LocalDate lastOccurrence;
|
||||||
|
|
||||||
|
@SqlField("start_time")
|
||||||
|
private LocalTime startTime;
|
||||||
|
|
||||||
|
@SqlField("end_time")
|
||||||
|
private LocalTime endTime;
|
||||||
|
|
||||||
|
@SqlField("is_repeatable")
|
||||||
|
private Boolean isRepeatable;
|
||||||
|
|
||||||
|
@SqlField("is_active")
|
||||||
|
private Boolean isActive;
|
||||||
|
|
||||||
|
@SqlField("is_all_day")
|
||||||
|
private Boolean isAllDay;
|
||||||
|
|
||||||
|
@SqlField("periodicity_type")
|
||||||
|
private Periodicity periodicityType;
|
||||||
|
|
||||||
|
@SqlField("periodicity_frequency")
|
||||||
|
private Integer periodicityFrequency;
|
||||||
|
|
||||||
|
@SqlField("max_repetitions")
|
||||||
|
private Integer maxRepetitions;
|
||||||
|
|
||||||
|
@SqlField("recurrence_rule")
|
||||||
|
private String recurrenceRule;
|
||||||
|
|
||||||
|
|
||||||
|
public StbActivityPlan() {
|
||||||
|
super(logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityTypeId() {
|
||||||
|
return activityTypeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setActivityTypeId(String activityTypeId) {
|
||||||
|
this.activityTypeId = activityTypeId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getFirstOccurrence() {
|
||||||
|
return firstOccurrence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setFirstOccurrence(LocalDate firstOccurrence) {
|
||||||
|
this.firstOccurrence = firstOccurrence;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getLastOccurrence() {
|
||||||
|
return lastOccurrence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setLastOccurrence(LocalDate lastOccurrence) {
|
||||||
|
this.lastOccurrence = lastOccurrence;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setStartTime(LocalTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setEndTime(LocalTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRepeatable() {
|
||||||
|
return isRepeatable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setRepeatable(Boolean repeatable) {
|
||||||
|
isRepeatable = repeatable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setActive(Boolean active) {
|
||||||
|
isActive = active;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAllDay() {
|
||||||
|
return isAllDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setAllDay(Boolean allDay) {
|
||||||
|
isAllDay = allDay;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Periodicity getPeriodicityType() {
|
||||||
|
return periodicityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setPeriodicityType(Periodicity periodicityType) {
|
||||||
|
this.periodicityType = periodicityType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPeriodicityFrequency() {
|
||||||
|
return periodicityFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setPeriodicityFrequency(Integer periodicityFrequency) {
|
||||||
|
this.periodicityFrequency = periodicityFrequency;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMaxRepetitions() {
|
||||||
|
return maxRepetitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setMaxRepetitions(Integer maxRepetitions) {
|
||||||
|
this.maxRepetitions = maxRepetitions;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRecurrenceRule() {
|
||||||
|
return recurrenceRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan setRecurrenceRule(String recurrenceRule) {
|
||||||
|
this.recurrenceRule = recurrenceRule;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Periodicity implements IBaseEnum<Periodicity> {
|
||||||
|
|
||||||
|
NEVER((short) 0),
|
||||||
|
DAILY((short) 1),
|
||||||
|
WEEKLY((short) 2),
|
||||||
|
MONTHLY((short) 3),
|
||||||
|
YEARLY((short) 4);
|
||||||
|
|
||||||
|
private final short value;
|
||||||
|
|
||||||
|
Periodicity(final short value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Periodicity from(Object value) {
|
||||||
|
short castValue = (short) value;
|
||||||
|
for (Periodicity b : Periodicity.values()) {
|
||||||
|
if (b.value == castValue)
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public short getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Periodicity fromInternal(Object val) {
|
||||||
|
return from(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ import it.integry.ems.response.StatusResponse;
|
|||||||
import it.integry.ems.status.ServiceChecker;
|
import it.integry.ems.status.ServiceChecker;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.entity.StbActivity;
|
import it.integry.ems_model.entity.StbActivity;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -19,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -351,4 +354,26 @@ public class ActivityController {
|
|||||||
|
|
||||||
return ServiceRestResponse.createPositiveResponse(activityService.searchActivity(searchActivityDTO));
|
return ServiceRestResponse.createPositiveResponse(activityService.searchActivity(searchActivityDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = EmsRestConstants.PATH_POST_ACTIVITY_PLAN, method = RequestMethod.POST)
|
||||||
|
public ServiceRestResponse postActivityPlan(
|
||||||
|
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
|
@RequestBody ActivityPlanDTO planDto
|
||||||
|
) throws Exception{
|
||||||
|
return ServiceRestResponse.createPositiveResponse(activityService.createActivityPlan(planDto));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = EmsRestConstants.PATH_GET_SCHEDULED_ACTIVITIES, method = RequestMethod.GET)
|
||||||
|
public ServiceRestResponse getScheduledActivities(
|
||||||
|
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
|
@RequestParam String username,
|
||||||
|
@RequestParam String startDate,
|
||||||
|
@RequestParam String endDate
|
||||||
|
) throws Exception{
|
||||||
|
return ServiceRestResponse.createPositiveResponse(activityService.getScheduledActivities(username, UtilityString.parseLocalDateTime(startDate),UtilityString.parseLocalDateTime(endDate)));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package it.integry.ems.activity.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.entity.StbActivityPlan;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ActivityPlanDTO {
|
||||||
|
private Long id;
|
||||||
|
private String activityTypeId;
|
||||||
|
private LocalDate firstOccurrence;
|
||||||
|
private LocalDate lastOccurrence;
|
||||||
|
private LocalTime startTime;
|
||||||
|
private LocalTime endTime;
|
||||||
|
private Boolean isRepeatable;
|
||||||
|
private Boolean isActive;
|
||||||
|
private Boolean isAllDay;
|
||||||
|
private StbActivityPlan.Periodicity periodicityType;
|
||||||
|
private Integer periodicityFrequency;
|
||||||
|
private Integer maxRepetitions;
|
||||||
|
private String recurrenceRule;
|
||||||
|
private List<String> users = new ArrayList<>();
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityTypeId() {
|
||||||
|
return activityTypeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setActivityTypeId(String activityTypeId) {
|
||||||
|
this.activityTypeId = activityTypeId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getFirstOccurrence() {
|
||||||
|
return firstOccurrence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setFirstOccurrence(LocalDate firstOccurrence) {
|
||||||
|
this.firstOccurrence = firstOccurrence;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getLastOccurrence() {
|
||||||
|
return lastOccurrence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setLastOccurrence(LocalDate lastOccurrence) {
|
||||||
|
this.lastOccurrence = lastOccurrence;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setStartTime(LocalTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setEndTime(LocalTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRepeatable() {
|
||||||
|
return isRepeatable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setRepeatable(Boolean repeatable) {
|
||||||
|
isRepeatable = repeatable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setActive(Boolean active) {
|
||||||
|
isActive = active;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAllDay() {
|
||||||
|
return isAllDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setAllDay(Boolean allDay) {
|
||||||
|
isAllDay = allDay;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityPlan.Periodicity getPeriodicityType() {
|
||||||
|
return periodicityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setPeriodicityType(StbActivityPlan.Periodicity periodicityType) {
|
||||||
|
this.periodicityType = periodicityType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPeriodicityFrequency() {
|
||||||
|
return periodicityFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setPeriodicityFrequency(Integer periodicityFrequency) {
|
||||||
|
this.periodicityFrequency = periodicityFrequency;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMaxRepetitions() {
|
||||||
|
return maxRepetitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setMaxRepetitions(Integer maxRepetitions) {
|
||||||
|
this.maxRepetitions = maxRepetitions;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRecurrenceRule() {
|
||||||
|
return recurrenceRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setRecurrenceRule(String recurrenceRule) {
|
||||||
|
this.recurrenceRule = recurrenceRule;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityPlanDTO setUsers(List<String> users) {
|
||||||
|
this.users = users;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -1754,4 +1755,42 @@ public class ActivityService {
|
|||||||
|
|
||||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql.toString(), ActivityDTO.class);
|
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql.toString(), ActivityDTO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StbActivityPlan createActivityPlan(ActivityPlanDTO dto) throws Exception{
|
||||||
|
|
||||||
|
StbActivityPlan plan = new StbActivityPlan();
|
||||||
|
plan
|
||||||
|
.setId(dto.getId())
|
||||||
|
.setActivityTypeId(dto.getActivityTypeId())
|
||||||
|
.setFirstOccurrence(dto.getFirstOccurrence())
|
||||||
|
.setLastOccurrence(dto.getLastOccurrence())
|
||||||
|
.setStartTime(dto.getStartTime())
|
||||||
|
.setEndTime(dto.getEndTime())
|
||||||
|
.setRepeatable(dto.getRepeatable())
|
||||||
|
.setActive(dto.getActive())
|
||||||
|
.setAllDay(dto.getAllDay())
|
||||||
|
.setPeriodicityType(dto.getPeriodicityType())
|
||||||
|
.setPeriodicityFrequency(dto.getPeriodicityFrequency())
|
||||||
|
.setMaxRepetitions(dto.getMaxRepetitions())
|
||||||
|
.setRecurrenceRule(dto.getRecurrenceRule());
|
||||||
|
|
||||||
|
plan.setOperation(dto.getId() == null ? OperationType.INSERT : OperationType.UPDATE);
|
||||||
|
entityProcessor.processEntity(plan,true,multiDBTransactionManager);
|
||||||
|
|
||||||
|
return plan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ActivityPlanDTO> getScheduledActivities(String username, LocalDateTime startDate,LocalDateTime endDate) throws Exception{
|
||||||
|
|
||||||
|
String sql = Query.format("Select stb_activity_plan.* from stb_activity_plan \n\r" +
|
||||||
|
"inner join srl_activity_plan_user on stb_activity_plan.id = srl_activity_plan_user.plan_id \n\r" +
|
||||||
|
"where stb_activity_plan.is_active = 1 \n\r " +
|
||||||
|
"AND srl_activity_plan_user.username = {} \n\r " +
|
||||||
|
"AND ({} IS NULL OR stb_activity_plan.first_occurrence >= {}) \n\r" +
|
||||||
|
"AND ({} IS NULL OR stb_activity_plan.last_occurrence <= {} )"
|
||||||
|
,username,startDate,startDate,endDate,endDate);
|
||||||
|
List<ActivityPlanDTO> activities = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),sql,ActivityPlanDTO.class);
|
||||||
|
return activities;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user