first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
350
rus/WEB-INF/lib/ablia_src/com/ablia/pre/Presenza.java
Normal file
350
rus/WEB-INF/lib/ablia_src/com/ablia/pre/Presenza.java
Normal file
|
|
@ -0,0 +1,350 @@
|
|||
package com.ablia.pre;
|
||||
|
||||
import com.ablia.common.Users;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.db.WcString;
|
||||
import com.ablia.util.Vectumerator;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
|
||||
public class Presenza extends DBAdapter implements Serializable {
|
||||
private long id_presenza;
|
||||
|
||||
private Date dataPresenza = getToday();
|
||||
|
||||
private Time ora;
|
||||
|
||||
private long id_users;
|
||||
|
||||
public static final long MOV_INGRESSO = 1L;
|
||||
|
||||
public static final long MOV_USCITA = 2L;
|
||||
|
||||
private long flgIngressoUscita;
|
||||
|
||||
private Users users;
|
||||
|
||||
public Presenza(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public Presenza() {}
|
||||
|
||||
public void setId_presenza(long newId_presenza) {
|
||||
this.id_presenza = newId_presenza;
|
||||
}
|
||||
|
||||
public void setDataPresenza(Date newDataPresenza) {
|
||||
this.dataPresenza = newDataPresenza;
|
||||
}
|
||||
|
||||
public void setOra(Time newOraIngresso) {
|
||||
this.ora = newOraIngresso;
|
||||
}
|
||||
|
||||
public void setId_users(long newId_users) {
|
||||
this.id_users = newId_users;
|
||||
setUsers(null);
|
||||
}
|
||||
|
||||
public void setFlgIngressoUscita(long newFlgIngressoUscita) {
|
||||
this.flgIngressoUscita = newFlgIngressoUscita;
|
||||
}
|
||||
|
||||
public long getId_presenza() {
|
||||
return this.id_presenza;
|
||||
}
|
||||
|
||||
public Date getDataPresenza() {
|
||||
return this.dataPresenza;
|
||||
}
|
||||
|
||||
public Time getOra() {
|
||||
return this.ora;
|
||||
}
|
||||
|
||||
public long getId_users() {
|
||||
return this.id_users;
|
||||
}
|
||||
|
||||
private long getTotSecByUserDay(long l_id_users, Date l_data) {
|
||||
if (l_id_users == 0L || l_data == null)
|
||||
return 0L;
|
||||
Time in = null;
|
||||
Time out = null;
|
||||
long secDiff = 0L;
|
||||
long secTot = 0L;
|
||||
Vectumerator<Presenza> vec = findByUsersData(l_id_users, l_data);
|
||||
while (vec.hasMoreElements()) {
|
||||
Presenza row = vec.nextElement();
|
||||
if (row.getFlgIngressoUscita() == 1L) {
|
||||
in = row.getOra();
|
||||
} else {
|
||||
out = row.getOra();
|
||||
}
|
||||
if (in != null && out != null) {
|
||||
secDiff = getTimeDiff(in, out);
|
||||
if (secDiff > 0L)
|
||||
secTot += secDiff;
|
||||
in = null;
|
||||
out = null;
|
||||
}
|
||||
}
|
||||
return secTot;
|
||||
}
|
||||
|
||||
public Time getTotOre() {
|
||||
return new Time(getTotSec() * 1000L - 3600000L);
|
||||
}
|
||||
|
||||
public long getTotSec() {
|
||||
return getTotSecByUserDay(getId_users(), getDataPresenza());
|
||||
}
|
||||
|
||||
public long getMovValido() {
|
||||
Presenza bean = getUltimoMovimento();
|
||||
if (bean.getDBState() == 0)
|
||||
return 0L;
|
||||
if (bean.getFlgIngressoUscita() == 1L)
|
||||
return 2L;
|
||||
return 1L;
|
||||
}
|
||||
|
||||
public Presenza getUltimoMovimento() {
|
||||
return getUltimoMovimentoByUsersData(getId_users(), getDataPresenza());
|
||||
}
|
||||
|
||||
public boolean isMovValido() {
|
||||
if (getId_users() == 0L || getDataPresenza() == null || getOra() == null)
|
||||
return true;
|
||||
Vectumerator<Presenza> vec = findByUsersDataOra(getId_users(),
|
||||
getDataPresenza(), getOra());
|
||||
if (vec.hasMoreElements()) {
|
||||
Presenza row = vec.nextElement();
|
||||
if (row.getFlgIngressoUscita() == getFlgIngressoUscita())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public long getFlgIngressoUscita() {
|
||||
return this.flgIngressoUscita;
|
||||
}
|
||||
|
||||
public static final String getIngressoUscita(long l_flgIngressoUscita) {
|
||||
if (l_flgIngressoUscita == 1L)
|
||||
return "Ingresso";
|
||||
if (l_flgIngressoUscita == 2L)
|
||||
return "Uscita";
|
||||
return "??";
|
||||
}
|
||||
|
||||
public String getIngressoUscita() {
|
||||
return getIngressoUscita(getFlgIngressoUscita());
|
||||
}
|
||||
|
||||
public void setUsers(Users newUsers) {
|
||||
this.users = newUsers;
|
||||
}
|
||||
|
||||
public Users getUsers() {
|
||||
this.users = (Users)getSecondaryObject((DBAdapter)this.users, Users.class, getId_users());
|
||||
return this.users;
|
||||
}
|
||||
|
||||
public String getDescrizioneMovimento() {
|
||||
if (getId_presenza() == 0L)
|
||||
return "";
|
||||
String temp = String.valueOf(getId_presenza()) + " - " +
|
||||
getUsers().getCognomeNome() + " " + getIngressoUscita() +
|
||||
" il " + getDataFormat().format(getDataPresenza()) +
|
||||
" alle " + getDataFormat().format(getOra());
|
||||
return temp;
|
||||
}
|
||||
|
||||
protected ResParm checkDeleteCascade() {
|
||||
return new ResParm(true);
|
||||
}
|
||||
|
||||
protected void deleteCascade() {}
|
||||
|
||||
public Vectumerator findByCR(PresenzaCR CR, int pageNumber, int pageRows) {
|
||||
if (pageNumber == 0 && pageRows == 0)
|
||||
return findReportByCR(CR);
|
||||
String s_Sql_Find = "select DISTINCT A.* from PRESENZA AS A";
|
||||
String s_Sql_Order = " ORDER BY A.dataPresenza, A.ora";
|
||||
WcString wc = new WcString();
|
||||
if (CR.getId_users() != 0L)
|
||||
wc.addWc("A.id_users=" + CR.getId_users());
|
||||
if (CR.getDataPresenza() != null)
|
||||
wc.addWc("A.dataPresenza=?");
|
||||
if (CR.getDataPresenzaDa() != null)
|
||||
wc.addWc("A.dataPresenza>=?");
|
||||
if (CR.getDataPresenzaA() != null)
|
||||
wc.addWc("A.dataPresenza<=? ");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
int dataCount = 1;
|
||||
if (CR.getDataPresenza() != null) {
|
||||
stmt.setDate(dataCount, CR.getDataPresenza());
|
||||
dataCount++;
|
||||
}
|
||||
if (CR.getDataPresenzaDa() != null) {
|
||||
stmt.setDate(dataCount, CR.getDataPresenzaDa());
|
||||
dataCount++;
|
||||
}
|
||||
if (CR.getDataPresenzaA() != null) {
|
||||
stmt.setDate(dataCount, CR.getDataPresenzaA());
|
||||
dataCount++;
|
||||
}
|
||||
return findRows(stmt, pageNumber, pageRows);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public Vectumerator findReportByCR(PresenzaCR CR) {
|
||||
String s_Sql_Find = "SELECT A.dataPresenza, A.id_users FROM PRESENZA as A GROUP BY A.dataPresenza, A.id_users";
|
||||
String s_Sql_Order = " ORDER BY A.dataPresenza, A.id_users";
|
||||
WcString wc = new WcString();
|
||||
if (CR.getId_users() != 0L)
|
||||
wc.addHavingWc("A.id_users=" + CR.getId_users());
|
||||
if (CR.getDataPresenza() != null)
|
||||
wc.addWc("A.dataPresenza=?");
|
||||
if (CR.getDataPresenzaDa() != null)
|
||||
wc.addHavingWc("A.dataPresenza>=?");
|
||||
if (CR.getDataPresenzaA() != null)
|
||||
wc.addHavingWc("A.dataPresenza<=? ");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
int dataCount = 1;
|
||||
if (CR.getDataPresenza() != null) {
|
||||
stmt.setDate(dataCount, CR.getDataPresenza());
|
||||
dataCount++;
|
||||
}
|
||||
if (CR.getDataPresenzaDa() != null) {
|
||||
stmt.setDate(dataCount, CR.getDataPresenzaDa());
|
||||
dataCount++;
|
||||
}
|
||||
if (CR.getDataPresenzaA() != null) {
|
||||
stmt.setDate(dataCount, CR.getDataPresenzaA());
|
||||
dataCount++;
|
||||
}
|
||||
return findRows(stmt);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public Vectumerator findByUsersData(long l_id_users, Date l_data) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from PRESENZA AS A";
|
||||
String s_Sql_Order = " order by A.dataPresenza, A.ora";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_users=" + l_id_users);
|
||||
wc.addWc("A.dataPresenza=?");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
stmt.setDate(1, l_data);
|
||||
return findRows(stmt);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public Vectumerator findByUsersDataOra(long l_id_users, Date l_data, Time l_ora) {
|
||||
String s_Sql_Find = "select DISTINCT A.* from PRESENZA AS A";
|
||||
String s_Sql_Order = " order by A.dataPresenza, A.ora DESC";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_users=" + l_id_users);
|
||||
wc.addWc("A.id_presenza!=" + getId_presenza());
|
||||
wc.addWc("A.dataPresenza=?");
|
||||
wc.addWc("A.ora<=?");
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
stmt.setDate(1, l_data);
|
||||
stmt.setTime(2, l_ora);
|
||||
return findRows(stmt);
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return AB_EMPTY_VECTUMERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public Presenza getUltimoMovimentoByUsersData(long l_id_users, Date l_data) {
|
||||
if (getApFull() == null || l_id_users == 0L || l_data == null)
|
||||
return new Presenza(getApFull());
|
||||
String s_Sql_Find = "select DISTINCT A.* from PRESENZA AS A";
|
||||
String s_Sql_Order = " order by A.dataPresenza desc, A.ora desc";
|
||||
WcString wc = new WcString();
|
||||
wc.addWc("A.id_users=" + l_id_users);
|
||||
wc.addWc("A.dataPresenza<=?");
|
||||
if (getId_presenza() != 0L)
|
||||
wc.addWc("A.id_presenza!=" + getId_presenza());
|
||||
try {
|
||||
PreparedStatement stmt = getConn().prepareStatement(
|
||||
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
|
||||
stmt.setDate(1, l_data);
|
||||
Presenza bean = (Presenza)getFirstRecord(stmt);
|
||||
return (bean == null) ? new Presenza(getApFull()) : bean;
|
||||
} catch (SQLException e) {
|
||||
handleDebug(e);
|
||||
return new Presenza(getApFull());
|
||||
}
|
||||
}
|
||||
|
||||
public ResParm save() {
|
||||
if (getDataPresenza() == null)
|
||||
setDataPresenza(getToday());
|
||||
if (getOra() == null)
|
||||
setOra(new Time(System.currentTimeMillis()));
|
||||
return super.save();
|
||||
}
|
||||
|
||||
public String getPresenze() {
|
||||
return getPresenzeByUserDay(getId_users(), getDataPresenza());
|
||||
}
|
||||
|
||||
private String getPresenzeByUserDay(long l_id_users, Date l_data) {
|
||||
if (l_id_users == 0L || l_data == null)
|
||||
return "";
|
||||
Time in = null;
|
||||
Time out = null;
|
||||
StringBuffer temp = new StringBuffer();
|
||||
Vectumerator<Presenza> vec = findByUsersData(l_id_users, l_data);
|
||||
while (vec.hasMoreElements()) {
|
||||
Presenza row = vec.nextElement();
|
||||
if (row.getFlgIngressoUscita() == 1L) {
|
||||
in = row.getOra();
|
||||
} else {
|
||||
out = row.getOra();
|
||||
}
|
||||
if (in != null && out != null) {
|
||||
if (getTimeDiff(in, getMidDay()) > 0L &&
|
||||
getTimeDiff(out, getMidDay()) > 0L) {
|
||||
temp.append("Mattino - ");
|
||||
} else if (getTimeDiff(in, getMidDay()) <= 0L &&
|
||||
getTimeDiff(out, getMidDay()) <= 0L) {
|
||||
temp.append("Pomeriggio - ");
|
||||
}
|
||||
if (getTimeDiff(in, getMidDay()) > 0L &&
|
||||
getTimeDiff(out, getMidDay()) <= 0L)
|
||||
temp.append("Mattino - Pomeriggio -");
|
||||
in = null;
|
||||
out = null;
|
||||
}
|
||||
}
|
||||
return temp.toString();
|
||||
}
|
||||
}
|
||||
104
rus/WEB-INF/lib/ablia_src/com/ablia/pre/PresenzaCR.java
Normal file
104
rus/WEB-INF/lib/ablia_src/com/ablia/pre/PresenzaCR.java
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
package com.ablia.pre;
|
||||
|
||||
import com.ablia.common.Users;
|
||||
import com.ablia.db.ApplParmFull;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
|
||||
public class PresenzaCR extends CRAdapter {
|
||||
private long id_presenza;
|
||||
|
||||
private Date dataPresenza;
|
||||
|
||||
private Date dataPresenzaDa = DBAdapter.getToday();
|
||||
|
||||
private Date dataPresenzaA;
|
||||
|
||||
private Time ora;
|
||||
|
||||
private long id_users;
|
||||
|
||||
private long flgIngressoUscita;
|
||||
|
||||
private Users users;
|
||||
|
||||
public PresenzaCR(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public PresenzaCR() {}
|
||||
|
||||
public void setId_presenza(long newId_presenza) {
|
||||
this.id_presenza = newId_presenza;
|
||||
}
|
||||
|
||||
public void setDataPresenza(Date newDataPresenza) {
|
||||
this.dataPresenza = newDataPresenza;
|
||||
}
|
||||
|
||||
public void setOra(Time newOraIngresso) {
|
||||
this.ora = newOraIngresso;
|
||||
}
|
||||
|
||||
public void setId_users(long newId_users) {
|
||||
this.id_users = newId_users;
|
||||
setUsers(null);
|
||||
}
|
||||
|
||||
public void setFlgIngressoUscita(long newFlgIngressoUscita) {
|
||||
this.flgIngressoUscita = newFlgIngressoUscita;
|
||||
}
|
||||
|
||||
public long getId_presenza() {
|
||||
return this.id_presenza;
|
||||
}
|
||||
|
||||
public Date getDataPresenza() {
|
||||
return this.dataPresenza;
|
||||
}
|
||||
|
||||
public Time getOra() {
|
||||
return this.ora;
|
||||
}
|
||||
|
||||
public long getId_users() {
|
||||
return this.id_users;
|
||||
}
|
||||
|
||||
public long getFlgIngressoUscita() {
|
||||
return this.flgIngressoUscita;
|
||||
}
|
||||
|
||||
public void setUsers(Users newUsers) {
|
||||
this.users = newUsers;
|
||||
}
|
||||
|
||||
public Users getUsers() {
|
||||
this.users = (Users)getSecondaryObject(
|
||||
(DBAdapter)this.users,
|
||||
Users.class, getId_users());
|
||||
return this.users;
|
||||
}
|
||||
|
||||
public String getIngressoUscita() {
|
||||
return Presenza.getIngressoUscita(getFlgIngressoUscita());
|
||||
}
|
||||
|
||||
public Date getDataPresenzaDa() {
|
||||
return this.dataPresenzaDa;
|
||||
}
|
||||
|
||||
public void setDataPresenzaDa(Date dataPresenzaDa) {
|
||||
this.dataPresenzaDa = dataPresenzaDa;
|
||||
}
|
||||
|
||||
public Date getDataPresenzaA() {
|
||||
return this.dataPresenzaA;
|
||||
}
|
||||
|
||||
public void setDataPresenzaA(Date dataPresenzaA) {
|
||||
this.dataPresenzaA = dataPresenzaA;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.ablia.pre.servlet;
|
||||
|
||||
import com.ablia.common.Users;
|
||||
import com.ablia.db.CRAdapter;
|
||||
import com.ablia.db.DBAdapter;
|
||||
import com.ablia.db.ResParm;
|
||||
import com.ablia.pre.Presenza;
|
||||
import com.ablia.pre.PresenzaCR;
|
||||
import com.ablia.servlet.AblServletSvlt;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class PresenzaSvlt extends AblServletSvlt {
|
||||
protected void fillComboAfterDetail(DBAdapter beanA, HttpServletRequest req, HttpServletResponse res) {
|
||||
Presenza bean = (Presenza)beanA;
|
||||
req.setAttribute("listaUsers", new Users(getApFull(req)).findUsersPresenze());
|
||||
}
|
||||
|
||||
protected void fillComboAfterSearch(CRAdapter CR, HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("listaUsers", new Users(getApFull(req)).findUsersPresenze());
|
||||
}
|
||||
|
||||
protected DBAdapter getBean(HttpServletRequest req) {
|
||||
return new Presenza(getApFull(req));
|
||||
}
|
||||
|
||||
protected CRAdapter getBeanCR(HttpServletRequest req) {
|
||||
return new PresenzaCR(getApFull(req));
|
||||
}
|
||||
|
||||
protected void prepareNewRecord(HttpServletRequest req, HttpServletResponse res) {
|
||||
req.setAttribute("listaUsers", new Users(getApFull(req)).findUsersPresenze());
|
||||
Presenza bean = new Presenza(getApFull(req));
|
||||
}
|
||||
|
||||
protected void addRows(HttpServletRequest req, HttpServletResponse res) {}
|
||||
|
||||
protected ResParm beforeSearch(HttpServletRequest req, HttpServletResponse res) {
|
||||
return super.beforeSearch(req, res);
|
||||
}
|
||||
|
||||
protected void otherCommands(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getCmd(req).equals("in") || getCmd(req).equals("out")) {
|
||||
Presenza bean = new Presenza(getApFull(req));
|
||||
bean.setId_users(getLoginUserId(req).longValue());
|
||||
if (getCmd(req).equals("in")) {
|
||||
bean.setFlgIngressoUscita(1L);
|
||||
} else {
|
||||
bean.setFlgIngressoUscita(2L);
|
||||
}
|
||||
ResParm rp = bean.save();
|
||||
sendMessage(req, rp.getMsg());
|
||||
setJspPageRelative("menu.jsp", req);
|
||||
callJsp(req, res);
|
||||
} else {
|
||||
search(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
protected void print(HttpServletRequest req, HttpServletResponse res) {
|
||||
boolean flgPrint = false;
|
||||
try {
|
||||
long l_id = 0L;
|
||||
int l_flgTipo = (int)getRequestLongParameter(req, "flgTipoReport");
|
||||
Presenza bean = new Presenza(getApFull(req));
|
||||
PresenzaCR CR = new PresenzaCR(getApFull(req));
|
||||
fillObject(req, CR);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void showBean(HttpServletRequest req, HttpServletResponse res) {
|
||||
if (getAct(req).equals("refresh")) {
|
||||
long l_id = getRequestLongParameter(req, "id_presenza");
|
||||
Presenza bean = new Presenza(getApFull(req));
|
||||
bean.findByPrimaryKey(l_id);
|
||||
fillObject(req, bean);
|
||||
req.setAttribute("flgIngressoUscita",
|
||||
String.valueOf(bean.getMovValido()));
|
||||
}
|
||||
super.showBean(req, res);
|
||||
}
|
||||
|
||||
protected void view(HttpServletRequest req, HttpServletResponse res) {
|
||||
PresenzaCR CR = new PresenzaCR(getApFull(req));
|
||||
CR.setId_users(getLoginUserId(req).longValue());
|
||||
CR.setDataPresenza(DBAdapter.getToday());
|
||||
Presenza bean = new Presenza(getApFull(req));
|
||||
req.setAttribute("list", bean.findByCR(CR, 1, 40));
|
||||
req.setAttribute("CR", CR);
|
||||
forceJspPageRelative("/presenzaView.jsp", req);
|
||||
callJsp(req, res);
|
||||
}
|
||||
}
|
||||
3
rus/WEB-INF/lib/ablia_src/com/ablia/pre/versionLog.txt
Normal file
3
rus/WEB-INF/lib/ablia_src/com/ablia/pre/versionLog.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Pre 0_02_280508
|
||||
|
||||
02-05-2014 Allineamento a nuovo versionamento.
|
||||
Loading…
Add table
Add a link
Reference in a new issue