提交 f23e3eac 编写于 作者: O o2null

Merge branch 'fix/attendance_0827' into 'wrdp'

考勤-服务端:修改预打卡计算方法

See merge request o2oa/o2oa!5218
package com.x.attendance.assemble.control;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.lang.reflect.Field;
public class CriteriaQueryTools {
public static Order setOrder(CriteriaBuilder cb, Root<?> root, Class<?> clazz_, String fieldName, String orderType) {
Boolean fieldExists = false;
Field[] fields = clazz_.getFields();
for (Field field : fields) {
if (StringUtils.equalsIgnoreCase(field.getName(), fieldName)) {
fieldName = field.getName(); // 忽略大小写之后,重置查询字段的名称
fieldExists = true;
}
}
if (!fieldExists) {
return null; // 如果查询字段根本和object 对不上,那么就返回null
}
if (StringUtils.equalsIgnoreCase(orderType, "asc")) {
return cb.asc(root.get(fieldName));
} else {
return cb.desc(root.get(fieldName));
}
}
public static Predicate predicate_or(CriteriaBuilder criteriaBuilder, Predicate predicate, Predicate predicate_target) {
if (predicate == null) {
return predicate_target;
} else {
if (predicate_target != null) {
return criteriaBuilder.or(predicate, predicate_target);
} else {
return predicate;
}
}
}
public static Predicate predicate_and(CriteriaBuilder criteriaBuilder, Predicate predicate, Predicate predicate_target) {
if (predicate == null) {
return predicate_target;
} else {
if (predicate_target != null) {
return criteriaBuilder.and(predicate, predicate_target);
} else {
return predicate;
}
}
}
}
......@@ -2,19 +2,18 @@ package com.x.attendance.assemble.control.factory;
import com.x.attendance.assemble.control.AbstractFactory;
import com.x.attendance.assemble.control.Business;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.assemble.control.jaxrs.selfholiday.ActionListNextWithFilter;
import com.x.attendance.assemble.control.jaxrs.selfholiday.WrapInFilter;
import com.x.attendance.entity.AttendanceSelfHoliday;
import com.x.attendance.entity.AttendanceSelfHoliday_;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.tools.ListTools;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -90,17 +89,6 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
cq.select(root.get(AttendanceSelfHoliday_.id));
return em.createQuery(cq.where(p)).getResultList();
}
//@MethodDescribe("根据流程的文档ID列示员工的AttendanceSelfHoliday信息列表")
// public List<String> getByWorkFlowDocId(String docId) throws Exception {
// EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
// CriteriaBuilder cb = em.getCriteriaBuilder();
// CriteriaQuery<String> cq = cb.createQuery(String.class);
// Root<AttendanceSelfHoliday> root = cq.from( AttendanceSelfHoliday.class);
// Predicate p = cb.equal(root.get(AttendanceSelfHoliday_.docId), docId);
// cq.select(root.get(AttendanceSelfHoliday_.id));
// return em.createQuery(cq.where(p)).getResultList();
// }
public List<String> listByStartDateAndEndDate(Date startDate, Date endDate) throws Exception {
EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class);
......@@ -112,7 +100,7 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
cq.select(root.get(AttendanceSelfHoliday_.id));
return em.createQuery(cq.where(p)).getResultList();
}
/**
* 查询下一页的信息数据
* @param id
......@@ -126,62 +114,46 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
public List<AttendanceSelfHoliday> listIdsNextWithFilter( String id, Integer count, Object sequence, ActionListNextWithFilter.WrapIn wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( AttendanceSelfHoliday.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<AttendanceSelfHoliday> cq = cb.createQuery(AttendanceSelfHoliday.class);
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
if( order == null || order.isEmpty() ){
order = "DESC";
}
Integer index = 1;
sql_stringBuffer.append( "SELECT o FROM "+AttendanceSelfHoliday.class.getCanonicalName()+" o where 1=1" );
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, AttendanceSelfHoliday_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(AttendanceSelfHoliday_.employeeName));
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getQ_empName()) && (!wrapIn.getQ_empName().isEmpty())) {
sql_stringBuffer.append(" and o.employeeName = ?" + (index));
vs.add( wrapIn.getQ_empName() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getQ_empName())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.employeeName),wrapIn.getQ_empName()));
}
if (null != wrapIn.getUnitNames() && wrapIn.getUnitNames().size()>0) {
sql_stringBuffer.append(" and o.unitOu in ( ?" + (index) + ")");
vs.add( wrapIn.getUnitNames() );
index++;
if(ListTools.isNotEmpty(wrapIn.getUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.unitOu),wrapIn.getUnitNames().get(0)));
}
if (null != wrapIn.getTopUnitNames() && wrapIn.getTopUnitNames().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitOu in ( ?" + (index) + ")");
vs.add( wrapIn.getTopUnitNames() );
index++;
if(ListTools.isNotEmpty(wrapIn.getTopUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.topUnitOu),wrapIn.getTopUnitNames().get(0)));
}
if (null != wrapIn.getStartdate() && null != wrapIn.getEnddate()) {
sql_stringBuffer.append(" and o.startTime >= ?" + (index) );
vs.add( wrapIn.getStartdate());
index++;
sql_stringBuffer.append(" and o.endTime <= ?" + (index));
vs.add( wrapIn.getEnddate());
index++;
}
if( StringUtils.isNotEmpty( wrapIn.getKey() )){
sql_stringBuffer.append(" order by o."+wrapIn.getKey()+" " + order );
}else{
sql_stringBuffer.append(" order by o.sequence " + order );
}
Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceSelfHoliday.class );
//System.out.println("query=" +query.toString());
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
p = cb.and(p,cb.greaterThanOrEqualTo(root.get(AttendanceSelfHoliday_.startTime),wrapIn.getStartdate()));
p = cb.and(p,cb.lessThanOrEqualTo(root.get(AttendanceSelfHoliday_.endTime),wrapIn.getEnddate()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
}
/**
* 查询上一页的文档信息数据
* @param id
......@@ -195,49 +167,39 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
public List<AttendanceSelfHoliday> listIdsPrevWithFilter( String id, Integer count, Object sequence, WrapInFilter wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( AttendanceSelfHoliday.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<AttendanceSelfHoliday> cq = cb.createQuery(AttendanceSelfHoliday.class);
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
if( order == null || order.isEmpty() ){
order = "DESC";
}
sql_stringBuffer.append( "SELECT o FROM "+AttendanceSelfHoliday.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
if ((null != wrapIn.getQ_empName()) && (!wrapIn.getQ_empName().isEmpty())) {
sql_stringBuffer.append(" and o.employeeName = ?" + (index));
vs.add( wrapIn.getQ_empName() );
index++;
Order _order = CriteriaQueryTools.setOrder(cb, root, AttendanceSelfHoliday_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(AttendanceSelfHoliday_.employeeName));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(AttendanceSelfHoliday_.sequence),sequence.toString()));
}
}
if (null != wrapIn.getUnitNames() && wrapIn.getUnitNames().size()>0) {
sql_stringBuffer.append(" and o.unitName in ( ?" + (index) + ")");
vs.add( wrapIn.getUnitNames() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getQ_empName())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.employeeName),wrapIn.getQ_empName()));
}
if (null != wrapIn.getTopUnitNames() && wrapIn.getTopUnitNames().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ( ?" + (index) + ")");
vs.add( wrapIn.getTopUnitNames() );
index++;
if(ListTools.isNotEmpty(wrapIn.getUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.unitOu),wrapIn.getUnitNames().get(0)));
}
if( StringUtils.isNotEmpty( wrapIn.getKey() )){
sql_stringBuffer.append(" order by o."+wrapIn.getKey()+" " + order );
}else{
sql_stringBuffer.append(" order by o.sequence " + order );
if(ListTools.isNotEmpty(wrapIn.getTopUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.topUnitOu),wrapIn.getTopUnitNames().get(0)));
}
Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceSelfHoliday.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(20).getResultList();
}
......@@ -250,34 +212,21 @@ public class AttendanceSelfHolidayFactory extends AbstractFactory {
public long getCountWithFilter( WrapInFilter wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( AttendanceSelfHoliday.class );
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer.append( "SELECT count(o.id) FROM "+AttendanceSelfHoliday.class.getCanonicalName()+" o where 1=1" );
if ((null != wrapIn.getQ_empName()) && (!wrapIn.getQ_empName().isEmpty())) {
sql_stringBuffer.append(" and o.employeeName = ?" + (index));
vs.add( wrapIn.getQ_empName() );
index++;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<AttendanceSelfHoliday> root = cq.from(AttendanceSelfHoliday.class);
Predicate p = cb.isNotNull(root.get(AttendanceSelfHoliday_.employeeName));
if(StringUtils.isNotEmpty(wrapIn.getQ_empName())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.employeeName),wrapIn.getQ_empName()));
}
if (null != wrapIn.getUnitNames() && wrapIn.getUnitNames().size()>0) {
sql_stringBuffer.append(" and o.unitName in ( ?" + (index) + ")");
vs.add( wrapIn.getUnitNames() );
index++;
if(ListTools.isNotEmpty(wrapIn.getUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.unitOu),wrapIn.getUnitNames().get(0)));
}
if (null != wrapIn.getTopUnitNames() && wrapIn.getTopUnitNames().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ( ?" + (index) + ")");
vs.add( wrapIn.getTopUnitNames() );
index++;
if(ListTools.isNotEmpty(wrapIn.getTopUnitNames())){
p = cb.and(p,cb.equal(root.get(AttendanceSelfHoliday_.topUnitOu),wrapIn.getTopUnitNames().get(0)));
}
Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceSelfHoliday.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return (Long) query.getSingleResult();
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public List<String> getByPersonName(String personName) throws Exception {
......
......@@ -6,11 +6,10 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.entity.*;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.AbstractFactory;
......@@ -18,9 +17,6 @@ import com.x.attendance.assemble.control.Business;
import com.x.attendance.assemble.control.jaxrs.attendancestatistic.WrapInFilterStatisticPersonForMonth;
import com.x.attendance.assemble.control.service.AttendanceEmployeeConfigServiceAdv;
import com.x.attendance.assemble.control.service.UserManagerService;
import com.x.attendance.entity.AttendanceEmployeeConfig;
import com.x.attendance.entity.StatisticPersonForMonth;
import com.x.attendance.entity.StatisticPersonForMonth_;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
......@@ -159,54 +155,45 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
public List<StatisticPersonForMonth> listIdsNextWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticPersonForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticPersonForMonth.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticPersonForMonth> cq = cb.createQuery(StatisticPersonForMonth.class);
Root<StatisticPersonForMonth> root = cq.from(StatisticPersonForMonth.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
if( order == null || order.isEmpty() ){
order = "DESC";
}
Integer index = 1;
sql_stringBuffer.append( "SELECT o FROM "+StatisticPersonForMonth.class.getCanonicalName()+" o where 1=1" );
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticPersonForMonth_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticPersonForMonth_.id));
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(StatisticPersonForMonth_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(StatisticPersonForMonth_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticPersonForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
p = cb.and(p,root.get(StatisticPersonForMonth_.employeeName).in(wrapIn.getEmployeeName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticPersonForMonth_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticPersonForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticPersonForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticPersonForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
......@@ -223,62 +210,50 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
public List<StatisticPersonForMonth> listIdsPrevWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticPersonForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticPersonForMonth.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticPersonForMonth> cq = cb.createQuery(StatisticPersonForMonth.class);
Root<StatisticPersonForMonth> root = cq.from(StatisticPersonForMonth.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
if( order == null || order.isEmpty() ){
order = "DESC";
}
sql_stringBuffer.append( "SELECT o FROM "+StatisticPersonForMonth.class.getCanonicalName()+" o where 1=1" );
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticPersonForMonth_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticPersonForMonth_.id));
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(StatisticPersonForMonth_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(StatisticPersonForMonth_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticPersonForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
p = cb.and(p,root.get(StatisticPersonForMonth_.employeeName).in(wrapIn.getEmployeeName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticPersonForMonth_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticPersonForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticPersonForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticPersonForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(20).getResultList();
}
/**
* 查询符合的文档信息总数
* @param id
* @param count
* @param sequence
* @param wrapIn
* @return
* @throws Exception
......@@ -286,43 +261,28 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
public long getCountWithFilter( WrapInFilterStatisticPersonForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticPersonForMonth.class );
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer.append( "SELECT count(o.id) FROM "+StatisticPersonForMonth.class.getCanonicalName()+" o where 1=1" );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<StatisticPersonForMonth> root = cq.from(StatisticPersonForMonth.class);
Predicate p = cb.isNotNull(root.get(StatisticPersonForMonth_.id));
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
}
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticPersonForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return (Long) query.getSingleResult();
p = cb.and(p,root.get(StatisticPersonForMonth_.employeeName).in(wrapIn.getEmployeeName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticPersonForMonth_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticPersonForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticPersonForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticPersonForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
public StatisticPersonForMonth get(String employeeName, String cycleYear, String cycleMonth) throws Exception {
......
......@@ -5,11 +5,11 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.entity.StatisticUnitForDay;
import com.x.attendance.entity.StatisticUnitForDay_;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.AbstractFactory;
......@@ -114,54 +114,45 @@ public class StatisticTopUnitForDayFactory extends AbstractFactory {
public List<StatisticTopUnitForDay> listIdsNextWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticTopUnitForDay wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticTopUnitForDay.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticTopUnitForDay> cq = cb.createQuery(StatisticTopUnitForDay.class);
Root<StatisticTopUnitForDay> root = cq.from(StatisticTopUnitForDay.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
if( order == null || order.isEmpty() ){
order = "DESC";
}
Integer index = 1;
sql_stringBuffer.append( "SELECT o FROM "+StatisticTopUnitForDay.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticTopUnitForDay_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticTopUnitForDay_.id));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(StatisticTopUnitForDay_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(StatisticTopUnitForDay_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
/*if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getEmployeeName()));
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForDay_.).in(wrapIn.getUnitName()));
}*/
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForDay_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForDay_.statisticYear),wrapIn.getStatisticYear()));
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticTopUnitForDay.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForDay_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
......@@ -178,61 +169,50 @@ public class StatisticTopUnitForDayFactory extends AbstractFactory {
public List<StatisticTopUnitForDay> listIdsPrevWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticTopUnitForDay wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticTopUnitForDay.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticTopUnitForDay> cq = cb.createQuery(StatisticTopUnitForDay.class);
Root<StatisticTopUnitForDay> root = cq.from(StatisticTopUnitForDay.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
if( order == null || order.isEmpty() ){
order = "DESC";
}
sql_stringBuffer.append( "SELECT o FROM "+StatisticTopUnitForDay.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticTopUnitForDay_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticTopUnitForDay_.id));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(StatisticTopUnitForDay_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(StatisticTopUnitForDay_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
/*if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getEmployeeName()));
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForDay_.).in(wrapIn.getUnitName()));
}*/
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForDay_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForDay_.statisticYear),wrapIn.getStatisticYear()));
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticTopUnitForDay.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForDay_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(20).getResultList();
}
/**
* 查询符合的文档信息总数
* @param id
* @param count
* @param sequence
* @param wrapIn
* @return
* @throws Exception
......@@ -240,42 +220,21 @@ public class StatisticTopUnitForDayFactory extends AbstractFactory {
public long getCountWithFilter( WrapInFilterStatisticTopUnitForDay wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticTopUnitForDay.class );
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer.append( "SELECT count(o.id) FROM "+StatisticTopUnitForDay.class.getCanonicalName()+" o where 1=1" );
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<StatisticTopUnitForDay> root = cq.from(StatisticTopUnitForDay.class);
Predicate p = cb.isNotNull(root.get(StatisticTopUnitForDay_.id));
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForDay_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForDay_.statisticYear),wrapIn.getStatisticYear()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForDay_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticTopUnitForDay.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return (Long) query.getSingleResult();
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
}
\ No newline at end of file
......@@ -5,11 +5,11 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.entity.StatisticTopUnitForDay;
import com.x.attendance.entity.StatisticTopUnitForDay_;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.AbstractFactory;
......@@ -94,54 +94,39 @@ public class StatisticTopUnitForMonthFactory extends AbstractFactory {
public List<StatisticTopUnitForMonth> listIdsNextWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticTopUnitForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticTopUnitForMonth.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticTopUnitForMonth> cq = cb.createQuery(StatisticTopUnitForMonth.class);
Root<StatisticTopUnitForMonth> root = cq.from(StatisticTopUnitForMonth.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
if( order == null || order.isEmpty() ){
order = "DESC";
}
Integer index = 1;
sql_stringBuffer.append( "SELECT o FROM "+StatisticTopUnitForMonth.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticTopUnitForMonth_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticTopUnitForMonth_.id));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(StatisticTopUnitForMonth_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(StatisticTopUnitForMonth_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticTopUnitForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
......@@ -158,61 +143,44 @@ public class StatisticTopUnitForMonthFactory extends AbstractFactory {
public List<StatisticTopUnitForMonth> listIdsPrevWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticTopUnitForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticTopUnitForMonth.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticTopUnitForMonth> cq = cb.createQuery(StatisticTopUnitForMonth.class);
Root<StatisticTopUnitForMonth> root = cq.from(StatisticTopUnitForMonth.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
if( order == null || order.isEmpty() ){
order = "DESC";
}
sql_stringBuffer.append( "SELECT o FROM "+StatisticTopUnitForMonth.class.getCanonicalName()+" o where 1=1" );
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticTopUnitForMonth_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticTopUnitForMonth_.id));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(StatisticTopUnitForMonth_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(StatisticTopUnitForMonth_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticTopUnitForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(20).getResultList();
}
/**
* 查询符合的文档信息总数
* @param id
* @param count
* @param sequence
* @param wrapIn
* @return
* @throws Exception
......@@ -220,44 +188,22 @@ public class StatisticTopUnitForMonthFactory extends AbstractFactory {
public long getCountWithFilter( WrapInFilterStatisticTopUnitForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticTopUnitForMonth.class );
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer.append( "SELECT count(o.id) FROM "+StatisticTopUnitForMonth.class.getCanonicalName()+" o where 1=1" );
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<StatisticTopUnitForMonth> root = cq.from(StatisticTopUnitForMonth.class);
Predicate p = cb.isNotNull(root.get(StatisticTopUnitForMonth_.id));
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticTopUnitForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticTopUnitForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticTopUnitForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return (Long) query.getSingleResult();
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
}
\ No newline at end of file
......@@ -6,18 +6,15 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.entity.*;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.AbstractFactory;
import com.x.attendance.assemble.control.Business;
import com.x.attendance.assemble.control.jaxrs.attendancestatistic.WrapInFilterStatisticUnitForDay;
import com.x.attendance.entity.StatisticUnitForDay;
import com.x.attendance.entity.StatisticUnitForDay_;
import com.x.base.core.project.exception.ExceptionWhen;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
......@@ -176,57 +173,46 @@ public class StatisticUnitForDayFactory extends AbstractFactory {
public List<StatisticUnitForDay> listIdsNextWithFilter(String id, Integer count, Object sequence,
WrapInFilterStatisticUnitForDay wrapIn) throws Exception {
// 先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get(StatisticUnitForDay.class);
String order = wrapIn.getOrder();// 排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
EntityManager em = this.entityManagerContainer().get( StatisticUnitForDay.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticUnitForDay> cq = cb.createQuery(StatisticUnitForDay.class);
Root<StatisticUnitForDay> root = cq.from(StatisticUnitForDay.class);
if (order == null || order.isEmpty()) {
String order = wrapIn.getOrder();//排序方式
if( order == null || order.isEmpty() ){
order = "DESC";
}
Integer index = 1;
sql_stringBuffer.append("SELECT o FROM " + StatisticUnitForDay.class.getCanonicalName() + " o where 1=1");
if ((null != sequence)) {
sql_stringBuffer.append(
" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add(wrapIn.getEmployeeName());
index++;
}
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticUnitForDay_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticUnitForDay_.id));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(StatisticUnitForDay_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(StatisticUnitForDay_.sequence),sequence.toString()));
}
}
/*if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getEmployeeName()));
}*/
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add(wrapIn.getUnitName());
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add(wrapIn.getTopUnitName());
index++;
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getStatisticYear()) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add(wrapIn.getStatisticYear());
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add(wrapIn.getStatisticMonth());
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForDay_.statisticYear),wrapIn.getStatisticYear()));
}
sql_stringBuffer.append(" order by o.sequence " + order);
Query query = em.createQuery(sql_stringBuffer.toString(), StatisticUnitForDay.class);
// 为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForDay_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
......@@ -244,110 +230,76 @@ public class StatisticUnitForDayFactory extends AbstractFactory {
public List<StatisticUnitForDay> listIdsPrevWithFilter(String id, Integer count, Object sequence,
WrapInFilterStatisticUnitForDay wrapIn) throws Exception {
// 先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get(StatisticUnitForDay.class);
String order = wrapIn.getOrder();// 排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
EntityManager em = this.entityManagerContainer().get( StatisticUnitForDay.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticUnitForDay> cq = cb.createQuery(StatisticUnitForDay.class);
Root<StatisticUnitForDay> root = cq.from(StatisticUnitForDay.class);
if (order == null || order.isEmpty()) {
String order = wrapIn.getOrder();//排序方式
if( order == null || order.isEmpty() ){
order = "DESC";
}
sql_stringBuffer.append("SELECT o FROM " + StatisticUnitForDay.class.getCanonicalName() + " o where 1=1");
if ((null != sequence)) {
sql_stringBuffer.append(
" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add(wrapIn.getEmployeeName());
index++;
}
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticUnitForDay_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticUnitForDay_.id));
if ((null != sequence) ) {
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(StatisticUnitForDay_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(StatisticUnitForDay_.sequence),sequence.toString()));
}
}
/*if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getEmployeeName()));
}*/
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add(wrapIn.getUnitName());
index++;
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add(wrapIn.getTopUnitName());
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticYear()) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add(wrapIn.getStatisticYear());
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForDay_.statisticYear),wrapIn.getStatisticYear()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add(wrapIn.getStatisticMonth());
index++;
}
sql_stringBuffer.append(" order by o.sequence " + order);
Query query = em.createQuery(sql_stringBuffer.toString(), StatisticUnitForDay.class);
// 为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForDay_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(20).getResultList();
}
/**
* 查询符合的文档信息总数
*
* @param id
* @param count
* @param sequence
* @param wrapIn
* @return
* @throws Exception
*/
public long getCountWithFilter(WrapInFilterStatisticUnitForDay wrapIn) throws Exception {
// 先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get(StatisticUnitForDay.class);
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer
.append("SELECT count(o.id) FROM " + StatisticUnitForDay.class.getCanonicalName() + " o where 1=1");
EntityManager em = this.entityManagerContainer().get( StatisticUnitForDay.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<StatisticUnitForDay> root = cq.from(StatisticUnitForDay.class);
Predicate p = cb.isNotNull(root.get(StatisticUnitForDay_.id));
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add(wrapIn.getEmployeeName());
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add(wrapIn.getUnitName());
index++;
p = cb.and(p,root.get(StatisticUnitForDay_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add(wrapIn.getTopUnitName());
index++;
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForDay_.topUnitName).in(wrapIn.getTopUnitName()));
}
if ((null != wrapIn.getStatisticYear()) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add(wrapIn.getStatisticYear());
index++;
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForDay_.statisticYear),wrapIn.getStatisticYear()));
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add(wrapIn.getStatisticMonth());
index++;
}
Query query = em.createQuery(sql_stringBuffer.toString(), StatisticUnitForDay.class);
// 为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForDay_.statisticMonth),wrapIn.getStatisticMonth()));
}
return (Long) query.getSingleResult();
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
}
\ No newline at end of file
......@@ -5,11 +5,11 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.*;
import com.x.attendance.assemble.control.CriteriaQueryTools;
import com.x.attendance.entity.StatisticUnitForDay;
import com.x.attendance.entity.StatisticUnitForDay_;
import org.apache.commons.lang3.StringUtils;
import com.x.attendance.assemble.control.AbstractFactory;
......@@ -121,54 +121,42 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
public List<StatisticUnitForMonth> listIdsNextWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticUnitForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticUnitForMonth.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticUnitForMonth> cq = cb.createQuery(StatisticUnitForMonth.class);
Root<StatisticUnitForMonth> root = cq.from(StatisticUnitForMonth.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
if( order == null || order.isEmpty() ){
order = "DESC";
}
Integer index = 1;
sql_stringBuffer.append( "SELECT o FROM "+StatisticUnitForMonth.class.getCanonicalName()+" o where 1=1" );
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticUnitForMonth_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticUnitForMonth_.id));
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? "<" : ">") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticUnitForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.lessThan(root.get(StatisticUnitForMonth_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.greaterThan(root.get(StatisticUnitForMonth_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForMonth_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(count).getResultList();
}
......@@ -185,62 +173,47 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
public List<StatisticUnitForMonth> listIdsPrevWithFilter( String id, Integer count, Object sequence, WrapInFilterStatisticUnitForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticUnitForMonth.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<StatisticUnitForMonth> cq = cb.createQuery(StatisticUnitForMonth.class);
Root<StatisticUnitForMonth> root = cq.from(StatisticUnitForMonth.class);
String order = wrapIn.getOrder();//排序方式
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
if( order == null || order.isEmpty() ){
order = "DESC";
}
sql_stringBuffer.append( "SELECT o FROM "+StatisticUnitForMonth.class.getCanonicalName()+" o where 1=1" );
String orderFieldName = "";
if(StringUtils.isNotEmpty( wrapIn.getKey())){
orderFieldName = wrapIn.getKey();
}else{
orderFieldName = "sequence";
}
Order _order = CriteriaQueryTools.setOrder(cb, root, StatisticUnitForMonth_.class, orderFieldName,order);
Predicate p = cb.isNotNull(root.get(StatisticUnitForMonth_.id));
if ((null != sequence) ) {
sql_stringBuffer.append(" and o.sequence " + (StringUtils.equalsIgnoreCase(order, "DESC") ? ">" : "<") + (" ?" + (index)));
vs.add(sequence);
index++;
}
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
}
sql_stringBuffer.append(" order by o.sequence " + order );
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticUnitForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
if(StringUtils.equalsIgnoreCase(order, "DESC")){
p = cb.and(p,cb.greaterThan(root.get(StatisticUnitForMonth_.sequence),sequence.toString()));
}else{
p = cb.and(p,cb.lessThan(root.get(StatisticUnitForMonth_.sequence),sequence.toString()));
}
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForMonth_.unitName).in(wrapIn.getUnitName()));
}
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
Query query = em.createQuery(cq.select(root).where(p).orderBy(_order) );
return query.setMaxResults(20).getResultList();
}
/**
* 查询符合的文档信息总数
* @param id
* @param count
* @param sequence
* @param wrapIn
* @return
* @throws Exception
......@@ -248,50 +221,29 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
public long getCountWithFilter( WrapInFilterStatisticUnitForMonth wrapIn ) throws Exception {
//先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
EntityManager em = this.entityManagerContainer().get( StatisticUnitForMonth.class );
List<Object> vs = new ArrayList<>();
StringBuffer sql_stringBuffer = new StringBuffer();
Integer index = 1;
sql_stringBuffer.append( "SELECT count(o.id) FROM "+StatisticUnitForMonth.class.getCanonicalName()+" o where 1=1" );
if ((null != wrapIn.getEmployeeName()) && wrapIn.getEmployeeName().size() > 0) {
sql_stringBuffer.append(" and o.employeeName in ?" + (index));
vs.add( wrapIn.getEmployeeName() );
index++;
}
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.unitName in ?" + (index));
vs.add( wrapIn.getUnitName() );
index++;
}
if ((null != wrapIn.getTopUnitName()) && wrapIn.getTopUnitName().size() > 0 ) {
sql_stringBuffer.append(" and o.topUnitName in ?" + (index));
vs.add( wrapIn.getTopUnitName() );
index++;
}
if ((null != wrapIn.getStatisticYear() ) && (!wrapIn.getStatisticYear().isEmpty())) {
sql_stringBuffer.append(" and o.statisticYear = ?" + (index));
vs.add( wrapIn.getStatisticYear() );
index++;
}
if ((null != wrapIn.getStatisticMonth()) && (!wrapIn.getStatisticMonth().isEmpty())) {
sql_stringBuffer.append(" and o.statisticMonth = ?" + (index));
vs.add( wrapIn.getStatisticMonth() );
index++;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<StatisticUnitForMonth> root = cq.from(StatisticUnitForMonth.class);
Predicate p = cb.isNotNull(root.get(StatisticUnitForMonth_.id));
if ((null != wrapIn.getUnitName()) && wrapIn.getUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForMonth_.unitName).in(wrapIn.getUnitName()));
}
Query query = em.createQuery( sql_stringBuffer.toString(), StatisticUnitForMonth.class );
//为查询设置所有的参数值
for (int i = 0; i < vs.size(); i++) {
query.setParameter(i + 1, vs.get(i));
}
return (Long) query.getSingleResult();
if ((null != wrapIn.getUnitName()) && wrapIn.getTopUnitName().size() > 0) {
p = cb.and(p,root.get(StatisticUnitForMonth_.topUnitName).in(wrapIn.getTopUnitName()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticYear())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForMonth_.statisticYear),wrapIn.getStatisticYear()));
}
if(StringUtils.isNotEmpty(wrapIn.getStatisticMonth())){
p = cb.and(p,cb.equal(root.get(StatisticUnitForMonth_.statisticMonth),wrapIn.getStatisticMonth()));
}
cq.select(cb.count(root)).where(p);
return em.createQuery(cq).getSingleResult();
}
/**
* 根据组织名称,统计年月,统计顶层组织所有人员迟到次数总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -322,8 +274,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员异常打卡次数总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -354,8 +304,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员工时不足人次总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -386,8 +334,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员早退人次总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -418,8 +364,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员签退人次总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -450,8 +394,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员签到人次总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -482,8 +424,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员出勤人天总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -515,8 +455,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员请假人次总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -548,8 +486,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据组织名称,统计年月,统计顶层组织所有人员缺勤人次总和
* @param unitName
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......@@ -581,9 +517,6 @@ public class StatisticUnitForMonthFactory extends AbstractFactory {
/**
* 根据顶层组织名称,统计年月,统计顶层组织所有人员数量
* @param topUnitNames
* @param cycleYear
* @param cycleMonth
* @return
* @throws Exception
*/
......
......@@ -66,7 +66,7 @@ public class ActionMobilePreview extends BaseAction {
}
}
//根据最后一次打卡信息,计算下一次打卡的信息
//根据当前时间和排班设置,计算当前预打卡信息
WoSign woSignFeature = null;
if (check) {
//打卡策略:1-两次打卡(上午上班,下午下班) 2-三次打卡(上午上班,下午下班加中午一次共三次) 3-四次打卡(上午下午都打上班下班卡)
......@@ -118,30 +118,23 @@ public class ActionMobilePreview extends BaseAction {
//排班设置中的下班时间
Date offDutyTime = dateOperation.getDateFromString( recordDateString+ " " + scheduleSetting.getOffDutyTime() );
if( ListTools.isEmpty( wraps )){
//一次都没有打过,不管几点,都是上班打卡
//根据当前时间和排班设置,判断当前时间是落在哪个区间
if(onDutyTime.after(now)){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
//判断如果此时打卡,是否是正常|迟到|缺勤|
if(onDutyTime != null && onDutyTime.after(now)){
woSignFeature.setSignSeq(1);
}else if( absenceStartTime != null && now.after( absenceStartTime )){
woSignFeature.setSignSeq(3);
}else if(lateStartTime != null && now.after( lateStartTime )){
woSignFeature.setSignSeq(2);
}
}else if(lateStartTime.after(now)){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}else if(lateStartTime.before(now) && absenceStartTime.after(now)){
woSignFeature.setSignSeq(2);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}else if(absenceStartTime.before(now) && leaveEarlyStartTime.after(now)){
//过了缺勤时间就算是第二次打卡-签退
woSignFeature.setSignSeq(4);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY);
}else{
//打了一次,就是下班打卡,打了两次,就没有了
if( wraps.size() == 1 ){
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
if(offDutyTime !=null && now.after( offDutyTime )){
woSignFeature.setSignSeq(1);
}else if(leaveEarlyStartTime != null && leaveEarlyStartTime.after(now)){
woSignFeature.setSignSeq(4);
}
}else{
woSignFeature.setSignSeq(5); //没有需要的打卡了
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
}
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY);
}
return woSignFeature;
}
......@@ -167,15 +160,19 @@ public class ActionMobilePreview extends BaseAction {
//计算,上班下班时间
if( StringUtils.isNotEmpty( scheduleSetting.getOnDutyTime())) {
//排班设置中的上班时间
onDutyTime = dateOperation.getDateFromString( todayDateStr + " " + scheduleSetting.getOnDutyTime() );
}
if( StringUtils.isNotEmpty( scheduleSetting.getOffDutyTime())) {
//排班设置中的下班时间
offDutyTime = dateOperation.getDateFromString( todayDateStr + " " + scheduleSetting.getOffDutyTime() );
}
if( StringUtils.isNotEmpty( scheduleSetting.getMiddayRestStartTime())) {
//排班设置中的午休开始时间
morningOffdutyTime = dateOperation.getDateFromString( todayDateStr + " " + scheduleSetting.getMiddayRestStartTime() );
}
if( StringUtils.isNotEmpty( scheduleSetting.getMiddayRestEndTime())) {
//排班设置中的午休结束时间
afternoonOndutyTime = dateOperation.getDateFromString( todayDateStr + " " + scheduleSetting.getMiddayRestEndTime() );
}
//排班设置中的迟到时间
......@@ -186,84 +183,38 @@ public class ActionMobilePreview extends BaseAction {
Date leaveEarlyStartTime = dateOperation.getDateFromString( todayDateStr + " " + scheduleSetting.getLeaveEarlyStartTime() );
signRecordStatus = getSignRecordStatus( wraps, onDutyTime, morningOffdutyTime, afternoonOndutyTime, offDutyTime );
if( ListTools.isEmpty( wraps )){
//一次都没有打过,只能打上班卡
//根据当前时间和排班设置,判断当前时间是落在哪个区间
if(onDutyTime.after(now)){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
//判断如果此时打卡,是否是正常|迟到|缺勤|
if(onDutyTime != null && onDutyTime.after(now)){
woSignFeature.setSignSeq(1);
}else if( absenceStartTime != null && now.after( absenceStartTime )){
woSignFeature.setSignSeq(3);
}else if(lateStartTime != null && now.after( lateStartTime )){
}else if(lateStartTime.after(now)){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}else if(lateStartTime.before(now) && morningOffdutyTime.after(now)){
if(absenceStartTime.after(now)){
woSignFeature.setSignSeq(2);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}else{
woSignFeature.setSignSeq(3);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}
}else{
//打了一次,之后,有可能是中午签到打卡,有可能是下午下班签退打卡
//woSignFeature.setSignSeq( wraps.size() + 1 );
//可能是午休或者下班卡了,上班打不可能打了
//看当前时间,有没有过中午签到时间
if( morningOffdutyTime !=null && morningOffdutyTime.before( now ) ){//现在已经是午休之后了
//看看下班没,如果下班了,就直接打下班卡了,否则,还可以打个午休卡
if( offDutyTime !=null && offDutyTime.before( now ) ){
//下班了,要么打下班卡
if( !signRecordStatus.getAlreadyOffDuty()){
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
if(offDutyTime !=null && now.after( offDutyTime )){
woSignFeature.setSignSeq(1);
}else if(leaveEarlyStartTime != null && leaveEarlyStartTime.after(now)){
woSignFeature.setSignSeq(4);
}
}else{
//下班卡打过了,不用再打卡了
woSignFeature.setSignSeq(5);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
}
}else{
//还没有下午,可以打午休卡,看看是否已经打过午休卡了
if( !signRecordStatus.getAlreadyAfternoon()){
//没有打过午休卡,那么可以打一下午休卡
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON );
woSignFeature.setSignSeq(1);
}else{
//午休卡打过了,看看下班卡打过没有,如果没有,可以打下班卡
if( !signRecordStatus.getAlreadyOffDuty() ){
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
if(offDutyTime !=null && now.after( offDutyTime )){
woSignFeature.setSignSeq(1);
}else if(leaveEarlyStartTime != null && leaveEarlyStartTime.after(now)){
woSignFeature.setSignSeq(4);
}
}else{
//下班卡打过了,不用再打卡了
woSignFeature.setSignSeq(5);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
}
}
}
}else if(morningOffdutyTime.before(now) && afternoonOndutyTime.after(now)){
//过了午休开始时间就算是第二次打卡-中午签到
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON);
}else if(afternoonOndutyTime.before(now) && leaveEarlyStartTime.after(now)){
//过了午休结束时间-可能是中午签到或下午下班签退
if(signRecordStatus.getAlreadyAfternoon()){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON);
}else{
//现在在午休之前,要么上班卡,要么午休卡,已经打过一次了,肯定不能再打上班卡了,看看是否已经打过了午休卡
if( !signRecordStatus.getAlreadyAfternoon() ){
//没有打过午休卡,那么可以打午休卡
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON );
woSignFeature.setSignSeq(1);
}else{
//午休卡打过了,看看下班卡打过没有,如果没有,可以打下班卡
if( !signRecordStatus.getAlreadyOffDuty()){
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
if(offDutyTime !=null && now.after( offDutyTime )){
woSignFeature.setSignSeq(1);
}else if(leaveEarlyStartTime != null && leaveEarlyStartTime.after(now)){
woSignFeature.setSignSeq(4);
}
}else{
//下班卡打过了,不用再打卡了
woSignFeature.setSignSeq(5);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
}
}
woSignFeature.setSignSeq(4);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY);
}
} else{
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY);
}
return woSignFeature;
}
......@@ -307,89 +258,61 @@ public class ActionMobilePreview extends BaseAction {
Date leaveEarlyStartTime = dateOperation.getDateFromString( todayDateStr + " " + scheduleSetting.getLeaveEarlyStartTime() );
signRecordStatus = getSignRecordStatus( wraps, onDutyTime, morningOffdutyTime, afternoonOndutyTime, offDutyTime );
if( ListTools.isEmpty( wraps )){
//一次都没有打过,看看当前时间是上班还是下午,如果是上午,就是上午签到,如果是下午,就是下午签到
if( now.after(afternoonOndutyTime)){
//在下午下班时间之后了,下午上班签到打卡
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON_ONDUTY );
if( absenceStartTime != null && now.after( absenceStartTime )){
woSignFeature.setSignSeq(3);
}else if(lateStartTimeAfternoon != null && now.after( lateStartTimeAfternoon )){
woSignFeature.setSignSeq(2);
}
//根据当前时间和排班设置,判断当前时间是落在哪个区间
if(onDutyTime.after(now)){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}else if(lateStartTime.after(now)){
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
}else if(lateStartTime.before(now) && leaveEarlyStartTimeMorning.after(now)) {
if(signRecordStatus.getAlreadyOnduty()){
//上午已打过上班卡,此时结果为上午早退
woSignFeature.setSignSeq(4);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY);
}else{
//上午没打过上班卡,即当前是第一次打卡,此时结果为上午迟到
woSignFeature.setSignSeq(2);
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY );
if(onDutyTime != null && onDutyTime.after(now)){
woSignFeature.setSignSeq(1);
}else if( absenceStartTime != null && now.after( absenceStartTime )){
if (absenceStartTime.after(now)) {
woSignFeature.setSignSeq(3);
}else if(lateStartTime != null && now.after( lateStartTime )){
woSignFeature.setSignSeq(2);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_ONDUTY);
}
}
}else{
//当前是什么区间
if( onDutyTime.after(now)){
//上午上班之前,无论几次,都只可能是上午的下班卡
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY );
if(leaveEarlyStartTimeMorning!=null && now.after(leaveEarlyStartTimeMorning)){
woSignFeature.setSignSeq(4);
}else{
woSignFeature.setSignSeq(1);
}
}else if( now.after(onDutyTime) && morningOffdutyTime.after(now)){
//上午上班时段: 上午签退
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY );
}else if(leaveEarlyStartTimeMorning.before(now) && morningOffdutyTime.after(now)){
//过了上午早退时间就算第二次打卡-上午下班打卡
if (absenceStartTime.after(now)) {
woSignFeature.setSignSeq(1);
}else if( now.after(morningOffdutyTime) && afternoonOndutyTime.after( now )){
//午休时段:前一次打卡有可能上午签到卡,可能下午签到卡
if( signRecordStatus.getAlreadyOnduty() ){ //已经上午签到过了,只有一次卡,应该就是签到
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY );
if(leaveEarlyStartTimeMorning!=null && now.after(leaveEarlyStartTimeMorning)){
woSignFeature.setSignSeq(4);
}else{
woSignFeature.setSignSeq(1);
}
}else if( signRecordStatus.getAlreadyAfternoonOnDuty()){
//如果上午没有签到,是下午的签到的话,第二次就应该是下午签退打卡了
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
if(leaveEarlyStartTime!=null && now.before(leaveEarlyStartTime)){
woSignFeature.setSignSeq(4);
}else{
woSignFeature.setSignSeq(1);
}
}
}else if( now.after(afternoonOndutyTime) && offDutyTime.after(now)){
//下午上班时段,如果前一次是下午签到,那么下一次就应该是下午签退了,否则,就是下午签到
if( signRecordStatus.getAlreadyAfternoonOnDuty()){
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
if(leaveEarlyStartTime != null && leaveEarlyStartTime.after(now)){
woSignFeature.setSignSeq(4);
}else{
woSignFeature.setSignSeq(1);
}
}else{
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON_ONDUTY );
if(lateStartTimeAfternoon!=null && now.after(lateStartTimeAfternoon)){
woSignFeature.setSignSeq(2);
}else{
woSignFeature.setSignSeq(1);
}
}
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY);
} else {
woSignFeature.setSignSeq(3);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY);
}
}else if(morningOffdutyTime.before(now) && afternoonOndutyTime.after(now)){
//此时打卡,可能是上午下班打卡,可能是下午上班打卡
woSignFeature.setSignSeq(1);
if(signRecordStatus.getAlreadyMorningOffDuty()){
//已经打卡上午下班卡,此时是下午上班卡
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON_ONDUTY);
}else{
//下午下班之后,只可能是下午的签到签退卡了
if( signRecordStatus.getAlreadyAfternoonOnDuty()){
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY );
woSignFeature.setSignSeq(1);
}else{
woSignFeature.setCheckinType( AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON_ONDUTY );
if(lateStartTimeAfternoon!=null && now.after(lateStartTimeAfternoon)){
woSignFeature.setSignSeq(2);
}else{
woSignFeature.setSignSeq(1);
}
}
//未打卡上午下班卡,此时是上午下班卡
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_MORNING_OFFDUTY);
}
}else if(afternoonOndutyTime.before(now) && leaveEarlyStartTime.after(now)){
//过了午休结束时间-下午上班签到或下午下班
if(signRecordStatus.getAlreadyAfternoonOnDuty()){
//已经打过下午上班卡-此时是下午下班卡
woSignFeature.setSignSeq(4);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY);
}else{
//未打过下午上班卡-此时是下午上班卡
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_AFTERNOON_ONDUTY);
}
} else{
woSignFeature.setSignSeq(1);
woSignFeature.setCheckinType(AttendanceDetailMobile.CHECKIN_TYPE_OFFDUTY);
}
return woSignFeature;
}
......
......@@ -78,6 +78,9 @@ public class ActionReciveAttendanceMobile extends BaseAction {
if( StringUtils.isNotEmpty(wrapIn.getWorkAddress()) ){
attendanceDetailMobile.setWorkAddress( wrapIn.getWorkAddress() );
}
if( StringUtils.isNotEmpty(wrapIn.getOptMachineType()) ){
attendanceDetailMobile.setOptMachineType( wrapIn.getOptMachineType() );
}
}
if( check ){
if( StringUtils.isNotEmpty(wrapIn.getLatitude())){
......@@ -251,7 +254,7 @@ public class ActionReciveAttendanceMobile extends BaseAction {
private String optSystemName = "其他";
@FieldDescribe( "工作地点描述, 可以为空." )
private String workAddress = "未知";
private String workAddress = "";
@FieldDescribe("是否范围外打卡")
private Boolean isExternal = false;
......
......@@ -116,20 +116,25 @@ class ComposeDetailWithMobileInSignProxy1 {
* @throws Exception
*/
private String getRecordAddress(List<AttendanceDetailMobile> mobileDetails) throws Exception {
String recordAddress = "";
String mobileAddress = "";
for( AttendanceDetailMobile detailMobile : mobileDetails ) {
String tmpRecordAddress = detailMobile.getWorkAddress();
if(StringUtils.isNotEmpty(tmpRecordAddress)){
if(StringUtils.isEmpty(recordAddress)){
recordAddress = tmpRecordAddress;
}else{
if(!StringUtils.contains(recordAddress,tmpRecordAddress)){
recordAddress = recordAddress+","+tmpRecordAddress;
}
String recordAddress = detailMobile.getRecordAddress();
String workAddress = detailMobile.getWorkAddress();
String oneAddress = "";
if(StringUtils.isNotEmpty(workAddress)){
oneAddress = workAddress;
}else{
oneAddress = recordAddress;
}
if(StringUtils.isEmpty(mobileAddress)){
mobileAddress = oneAddress;
}else{
if(StringUtils.isNotEmpty(oneAddress) && !StringUtils.contains(mobileAddress,oneAddress)){
mobileAddress = mobileAddress+","+oneAddress;
}
}
}
return recordAddress;
return mobileAddress;
}
/**
......
......@@ -162,20 +162,25 @@ class ComposeDetailWithMobileInSignProxy2 {
* @throws Exception
*/
private String getRecordAddress(List<AttendanceDetailMobile> mobileDetails) throws Exception {
String recordAddress = "";
String mobileAddress = "";
for( AttendanceDetailMobile detailMobile : mobileDetails ) {
String tmpRecordAddress = detailMobile.getWorkAddress();
if(StringUtils.isNotEmpty(tmpRecordAddress)){
if(StringUtils.isEmpty(recordAddress)){
recordAddress = tmpRecordAddress;
}else{
if(!StringUtils.contains(recordAddress,tmpRecordAddress)){
recordAddress = recordAddress+","+tmpRecordAddress;
}
String recordAddress = detailMobile.getRecordAddress();
String workAddress = detailMobile.getWorkAddress();
String oneAddress = "";
if(StringUtils.isNotEmpty(workAddress)){
oneAddress = workAddress;
}else{
oneAddress = recordAddress;
}
if(StringUtils.isEmpty(mobileAddress)){
mobileAddress = oneAddress;
}else{
if(StringUtils.isNotEmpty(oneAddress) && !StringUtils.contains(mobileAddress,oneAddress)){
mobileAddress = mobileAddress+","+oneAddress;
}
}
}
return recordAddress;
return mobileAddress;
}
/**
......
......@@ -207,20 +207,25 @@ class ComposeDetailWithMobileInSignProxy3 {
* @throws Exception
*/
private String getRecordAddress(List<AttendanceDetailMobile> mobileDetails) throws Exception {
String recordAddress = "";
String mobileAddress = "";
for( AttendanceDetailMobile detailMobile : mobileDetails ) {
String tmpRecordAddress = detailMobile.getWorkAddress();
if(StringUtils.isNotEmpty(tmpRecordAddress)){
if(StringUtils.isEmpty(recordAddress)){
recordAddress = tmpRecordAddress;
}else{
if(!StringUtils.contains(recordAddress,tmpRecordAddress)){
recordAddress = recordAddress+","+tmpRecordAddress;
}
String recordAddress = detailMobile.getRecordAddress();
String workAddress = detailMobile.getWorkAddress();
String oneAddress = "";
if(StringUtils.isNotEmpty(workAddress)){
oneAddress = workAddress;
}else{
oneAddress = recordAddress;
}
if(StringUtils.isEmpty(mobileAddress)){
mobileAddress = oneAddress;
}else{
if(StringUtils.isNotEmpty(oneAddress) && !StringUtils.contains(mobileAddress,oneAddress)){
mobileAddress = mobileAddress+","+oneAddress;
}
}
}
return recordAddress;
return mobileAddress;
}
/**
......
......@@ -514,17 +514,17 @@ MWF.xApplication.Attendance.MyDetail.SelfHoliday = new Class({
MWF.xApplication.Attendance.MyDetail.DetailStaticExplorer = new Class({
Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
load: function(){
/* load: function(){
//this.loadFilter();
this.loadContentNode();
this.setNodeScroll();
debugger;
var filterData = {
cycleYear : this.preMonthDate.getFullYear().toString(),
cycleMonth : this.preMonthDate.format(this.app.lp.dateFormatOnlyMonth)
};
this.loadView( filterData );
},
},*/
loadFilter : function(){
this.fileterNode = new Element("div.fileterNode", {
......@@ -539,15 +539,31 @@ MWF.xApplication.Attendance.MyDetail.DetailStaticExplorer = new Class({
}).inject( this.fileterNode );
table.setStyle("width","360px");
var tr = new Element("tr").inject(table);
this.createYearSelectTd( tr );
this.createMonthSelectTd( tr );
//this.createDateSelectTd( tr )
this.createActionTd( tr )
this.createActionTd( tr );
}.bind(this))
}.bind(this));
},
createYearSelectTd : function( tr ){
var _self = this;
var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.annuaal }).inject(tr);
var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
this.yearString = new MDomItem( td, {
"name" : "yearString",
"type" : "select",
"selectValue" : function(){
var years = [];
var year = new Date().getFullYear();
for(var i=0; i<6; i++ ){
years.push( year-- );
}
return years;
}
}, true, this.app, this.filterFormCss );
this.yearString.load();
},
createMonthSelectTd : function( tr ){
var _self = this;
var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : MWF.xApplication.Attendance.LP.months }).inject(tr);
......@@ -568,13 +584,21 @@ MWF.xApplication.Attendance.MyDetail.DetailStaticExplorer = new Class({
"text" : MWF.xApplication.Attendance.LP.query,
"styles" : this.app.css.filterButton
}).inject(td);
debugger;
input.addEvent("click", function(){
//var filterData = {
// cycleYear : this.cycleYear.getValue(),
// cycleMonth : this.cycleMonth.getValue()
//}
var year = this.preMonthDate.getFullYear().toString();
var month = (this.preMonthDate.getMonth()+1).toString();
var year = this.yearString.getValue("year");
var month = this.cycleMonth.getValue("month");
if(year && year!=""){
}else{
year = this.preMonthDate.getFullYear().toString();
}
if(month && month!=""){
}else{
month = (this.preMonthDate.getMonth()+1).toString();
}
/*var year = this.preMonthDate.getFullYear().toString();
var month = (this.preMonthDate.getMonth()+1).toString();*/
debugger;
if( month.length == 1 )month = "0"+month;
var filterData = {
cycleYear : year,
......@@ -695,10 +719,11 @@ MWF.xApplication.Attendance.MyDetail.DetailStaticView = new Class({
filter.key = this.sortField || this.sortFieldDefault || "";
filter.order = this.sortType || this.sortTypeDefault || "";
filter.q_empName = layout.desktop.session.user.distinguishedName;
//if( filter.cycleMonth == "" )filter.cycleMonth="(0)";
var month = (new Date().getMonth()+1).toString();
if( filter.cycleMonth == "" )filter.cycleMonth="(0)";
/*var month = (new Date().getMonth()+1).toString();
if( month.length == 1 )month = "0"+month;
filter.cycleMonth = month;
filter.cycleMonth = month;*/
debugger;
this.actions.listStaticMonthPerson( filter.q_empName, filter.cycleYear,filter.cycleMonth, function(json){
if( callback )callback(json);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册