- Conexión para el ws de SISVECOM

- Corrección de error en la fecha al guardar gastos
This commit is contained in:
Brayan.Gonzalez 2025-02-12 09:54:24 -07:00
parent c269ac5570
commit d44659160b
5 changed files with 237 additions and 178 deletions

View File

@ -36,6 +36,26 @@
</dependency> </dependency>
</dependencies> </dependencies>
<profiles> <profiles>
<profile>
<id>AWS-EC2-2</id>
<properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=UTC</hibernate.connection.url>
<hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>root</hibernate.connection.password>
<hibernate.connection.min_size>10</hibernate.connection.min_size>
<hibernate.connection.max_size>40</hibernate.connection.max_size>
<hibernate.connection.timeout>1800</hibernate.connection.timeout>
<hibernate.connection.max_statements>300</hibernate.connection.max_statements>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
<profile> <profile>
<id>AWS-EC2</id> <id>AWS-EC2</id>
<properties> <properties>

View File

@ -13,6 +13,7 @@ import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -39,218 +40,222 @@ import org.hibernate.annotations.GenericGenerator;
@Entity @Entity
public class OtherExpense implements Serializable { public class OtherExpense implements Serializable {
private static final long serialVersionUID = 6233701552847217683L; private static final long serialVersionUID = 6233701552847217683L;
@Id @Id
@GeneratedValue(generator = "uuid") @GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2") @GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "id", length = 36) @Column(name = "id", length = 36)
private String id; private String id;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn( @JoinColumn(
name = "id_user", name = "id_user",
referencedColumnName = "id", referencedColumnName = "id",
nullable = false nullable = false
) )
private User user; private User user;
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn( @JoinColumn(
name = "id_office", name = "id_office",
referencedColumnName = "id", referencedColumnName = "id",
nullable = false nullable = false
) )
private Office office; private Office office;
@Column(name = "expense", nullable = false) @Column(name = "expense", nullable = false)
private BigDecimal expense; private BigDecimal expense;
@Column(name = "description", length = 200, nullable = false) @Column(name = "description", length = 200, nullable = false)
private String description; private String description;
@Column(name = "created_by", nullable = false, length = 36) @Column(name = "created_by", nullable = false, length = 36)
private String createdBy; private String createdBy;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn( @JoinColumn(
name = "created_by", name = "created_by",
referencedColumnName = "id", referencedColumnName = "id",
nullable = false, nullable = false,
insertable = false, insertable = false,
updatable = false updatable = false
)
private User userCreatedBy;
) @Temporal(TemporalType.TIMESTAMP)
private User userCreatedBy; @Column(name = "created_on", length = 19)
private Date createdOn;
@Temporal(TemporalType.TIMESTAMP) @Column(name = "last_updated_by", length = 36)
@Column(name = "created_on", length = 19) private String lastUpdatedBy;
private Date createdOn;
@Column(name = "last_updated_by", length = 36) @Temporal(TemporalType.TIMESTAMP)
private String lastUpdatedBy; @Column(name = "last_updated_on", length = 19)
private Date lastUpdatedOn;
@Temporal(TemporalType.TIMESTAMP) public OtherExpense() {
@Column(name = "last_updated_on", length = 19) }
private Date lastUpdatedOn;
public OtherExpense() { /**
} *
* @param officeId
* @param userId
* @param expense
* @param description
*/
public OtherExpense(String officeId, String userId, BigDecimal expense, String description) {
this.office = new Office(officeId);
this.user = new User(userId);
this.expense = expense;
this.description = description;
this.createdBy = userId;
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, -1);
date = calendar.getTime();
this.createdOn = date;
}
/** public String getId() {
* return id;
* @param officeId }
* @param userId
* @param expense
* @param description
*/
public OtherExpense(String officeId, String userId, BigDecimal expense, String description) {
this.office = new Office(officeId);
this.user = new User(userId);
this.expense = expense;
this.description = description;
this.createdBy = userId;
this.createdOn = new Date();
}
public String getId() { public void setId(String id) {
return id; this.id = id;
} }
public void setId(String id) { public User getUser() {
this.id = id; return user;
} }
public User getUser() { public void setUser(User user) {
return user; this.user = user;
} }
public void setUser(User user) { public Office getOffice() {
this.user = user; return office;
} }
public Office getOffice() { public void setOffice(Office office) {
return office; this.office = office;
} }
public void setOffice(Office office) { public BigDecimal getExpense() {
this.office = office; return expense;
} }
public BigDecimal getExpense() { public void setExpense(BigDecimal expense) {
return expense; this.expense = expense;
} }
public void setExpense(BigDecimal expense) { public String getDescription() {
this.expense = expense; return description;
} }
public String getDescription() { public void setDescription(String description) {
return description; this.description = description;
} }
public void setDescription(String description) { public String getCreatedBy() {
this.description = description; return createdBy;
} }
public String getCreatedBy() { public void setCreatedBy(String createdBy) {
return createdBy; this.createdBy = createdBy;
} }
public void setCreatedBy(String createdBy) { public Date getCreatedOn() {
this.createdBy = createdBy; return createdOn;
} }
public Date getCreatedOn() { public void setCreatedOn(Date createdOn) {
return createdOn; this.createdOn = createdOn;
} }
public void setCreatedOn(Date createdOn) { public String getLastUpdatedBy() {
this.createdOn = createdOn; return lastUpdatedBy;
} }
public String getLastUpdatedBy() { public void setLastUpdatedBy(String lastUpdatedBy) {
return lastUpdatedBy; this.lastUpdatedBy = lastUpdatedBy;
} }
public void setLastUpdatedBy(String lastUpdatedBy) { public Date getLastUpdatedOn() {
this.lastUpdatedBy = lastUpdatedBy; return lastUpdatedOn;
} }
public Date getLastUpdatedOn() { public void setLastUpdatedOn(Date lastUpdatedOn) {
return lastUpdatedOn; this.lastUpdatedOn = lastUpdatedOn;
} }
public void setLastUpdatedOn(Date lastUpdatedOn) { public String getUserRoutes() {
this.lastUpdatedOn = lastUpdatedOn; String routes = "";
} routes = user.getHumanResource().getHumanResourceHasRoutes().stream().map((py) -> py.getRouteCtlg().getRoute()).collect(Collectors.joining(", "));
public String getUserRoutes() { return routes;
String routes = ""; }
routes = user.getHumanResource().getHumanResourceHasRoutes().stream().map((py) -> py.getRouteCtlg().getRoute()).collect(Collectors.joining(", "));
return routes; public User getUserCreatedBy() {
} return userCreatedBy;
}
public User getUserCreatedBy() { public void setUserCreatedBy(User userCreatedBy) {
return userCreatedBy; this.userCreatedBy = userCreatedBy;
} }
public void setUserCreatedBy(User userCreatedBy) { public String getCreatedByName() {
this.userCreatedBy = userCreatedBy; String name = getUserCreatedBy().getHumanResource().getFirstName() + " " + getUserCreatedBy().getHumanResource().getLastName();
}
public String getCreatedByName() { return name;
String name = getUserCreatedBy().getHumanResource().getFirstName() + " " + getUserCreatedBy().getHumanResource().getLastName(); }
return name; public boolean getAction(Date lastStableSmallBox, List<ClosingDay> closingDayToday) {
} Date date = createdOn;
String closingDayUser = null;
boolean action = true;
try {
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
public boolean getAction(Date lastStableSmallBox, List<ClosingDay> closingDayToday) { String dateStr = dt1.format(date);
Date date = createdOn; date = dt1.parse(dateStr);
String closingDayUser = null;
boolean action = true;
try {
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
String dateStr = dt1.format(date); action = date.after(lastStableSmallBox);
date = dt1.parse(dateStr);
action = date.after(lastStableSmallBox); // Busca el corte del día de este usuario
if (closingDayToday != null) {
Optional<ClosingDay> optUser = closingDayToday.stream().filter(p -> p.getUser().getId().equalsIgnoreCase(user.getId())
&& p.getCreatedOn().equals(createdOn)).findFirst();
closingDayUser = optUser.isPresent() ? optUser.get().getId() : null;
// Busca el corte del día de este usuario String dateStrCD;
if (closingDayToday != null) { Date dateCD;
Optional<ClosingDay> optUser = closingDayToday.stream().filter(p -> p.getUser().getId().equalsIgnoreCase(user.getId()) for (ClosingDay dato : closingDayToday) {
&& p.getCreatedOn().equals(createdOn)).findFirst(); dateStrCD = dt1.format(dato.getCreatedOn());
closingDayUser = optUser.isPresent() ? optUser.get().getId(): null; dateCD = dt1.parse(dateStrCD);
String dateStrCD; if (dato.getUser().getId().equalsIgnoreCase(getUser().getId()) && dateCD.equals(date)) {
Date dateCD; closingDayUser = dato.getUser().getId();
for(ClosingDay dato : closingDayToday){ }
dateStrCD = dt1.format(dato.getCreatedOn());
dateCD = dt1.parse(dateStrCD);
if(dato.getUser().getId().equalsIgnoreCase(getUser().getId()) && dateCD.equals(date)){
closingDayUser = dato.getUser().getId();
}
}
} }
}
if(action){ if (action) {
if(closingDayUser != null){ if (closingDayUser != null) {
action = false; action = false;
}
} }
}
} catch (ParseException ex) { } catch (ParseException ex) {
Logger.getLogger(ExpenseCompany.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ExpenseCompany.class.getName()).log(Level.SEVERE, null, ex);
} }
return action; return action;
} }
@Override @Override
public String toString() { public String toString() {
return "OtherExpense{" + "description=" + description + ", createdOn=" + createdOn + '}'; return "OtherExpense{" + "description=" + description + ", createdOn=" + createdOn + '}';
} }
} }

View File

@ -116,6 +116,16 @@
</dependencies> </dependencies>
<profiles> <profiles>
<profile>
<id>AWS-EC2-2</id>
<properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=UTC</hibernate.connection.url>
<hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>root</hibernate.connection.password>
<hibernate.connection.useSSL>false</hibernate.connection.useSSL>
<log4j2.path>/var/log/tomcat/cardriver.log</log4j2.path>
</properties>
</profile>
<profile> <profile>
<id>AWS-EC2</id> <id>AWS-EC2</id>
<properties> <properties>

View File

@ -189,6 +189,14 @@
</dependencies> </dependencies>
<profiles> <profiles>
<profile>
<id>AWS-EC2-2</id>
<properties>
<hibernate.connection.url>jdbc:mysql://localhost:3306/apo_pro_com_april_ten?serverTimezone=UTC</hibernate.connection.url>
<hibernate.connection.username>root</hibernate.connection.username>
<hibernate.connection.password>root</hibernate.connection.password>
</properties>
</profile>
<profile> <profile>
<id>AWS-EC2</id> <id>AWS-EC2</id>
<properties> <properties>

View File

@ -11,6 +11,22 @@
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<profiles> <profiles>
<profile>
<id>AWS-EC2-2</id>
<activation>
<property>
<name>AWS-EC2</name>
<value>true</value>
</property>
</activation>
<modules>
<module>../ace-security</module>
<module>../ace-layout</module>
<module>../ace-model</module>
<module>../ace-controller</module>
<module>../ace-web</module>
</modules>
</profile>
<profile> <profile>
<id>AWS-EC2</id> <id>AWS-EC2</id>
<activation> <activation>