|
|
@@ -10,6 +10,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
|
|
+import com.x.attendance.assemble.control.service.UserManagerService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import com.x.attendance.assemble.control.AbstractFactory;
|
|
|
@@ -311,8 +312,124 @@ public class AttendanceAppealInfoFactory extends AbstractFactory {
|
|
|
query.setParameter(i + 1, vs.get(i));
|
|
|
}
|
|
|
return query.setMaxResults(count).getResultList();
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询下一页的信息数据--只查询当前人有权限审批的
|
|
|
+ * @param id
|
|
|
+ * @param count
|
|
|
+ * @param sequence
|
|
|
+ * @param wrapIn
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public List<AttendanceAppealInfo> listIdsNextWithFilterWithCurrentProcessor( String id, Integer count, Object sequence, WrapInFilterAppeal wrapIn ,Boolean isManager) throws Exception {
|
|
|
+ //先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
|
|
|
+ EntityManager em = this.entityManagerContainer().get( AttendanceAppealInfo.class );
|
|
|
+ String order = wrapIn.getOrder();//排序方式
|
|
|
+ List<Object> vs = new ArrayList<>();
|
|
|
+ StringBuffer sql_stringBuffer = new StringBuffer();
|
|
|
+ UserManagerService userManagerService = new UserManagerService();
|
|
|
+ if( order == null || order.isEmpty() ){
|
|
|
+ order = "DESC";
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer index = 1;
|
|
|
+ sql_stringBuffer.append( "SELECT o FROM "+AttendanceAppealInfo.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.getDetailId()) && (!wrapIn.getDetailId().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.detailId = ?" + (index));
|
|
|
+ vs.add( wrapIn.getDetailId() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getEmpName()) && (!wrapIn.getEmpName().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.empName = ?" + (index));
|
|
|
+ vs.add( wrapIn.getEmpName() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getUnitName()) && (!wrapIn.getUnitName().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.unitName = ?" + (index));
|
|
|
+ vs.add( wrapIn.getUnitName() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getTopUnitName()) && (!wrapIn.getTopUnitName().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.topUnitName = ?" + (index));
|
|
|
+ vs.add( wrapIn.getTopUnitName() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getYearString() ) && (!wrapIn.getYearString().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.yearString = ?" + (index));
|
|
|
+ vs.add( wrapIn.getYearString() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getMonthString()) && (!wrapIn.getMonthString().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.monthString = ?" + (index));
|
|
|
+ vs.add( wrapIn.getMonthString() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if (wrapIn.getStatus()!=999) {
|
|
|
+ sql_stringBuffer.append(" and o.status = ?" + (index));
|
|
|
+ vs.add( wrapIn.getStatus() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getAppealReason()) && (!wrapIn.getAppealReason().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.appealReason = ?" + (index));
|
|
|
+ vs.add( wrapIn.getAppealReason() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if(!isManager){
|
|
|
+ if ((null != wrapIn.getProcessPerson1()) && (!wrapIn.getProcessPerson1().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.currentProcessor = ?" + (index));
|
|
|
+ vs.add( wrapIn.getProcessPerson1() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// if ((null != wrapIn.getProcessPerson2()) && (!wrapIn.getProcessPerson2().isEmpty())) {
|
|
|
+// sql_stringBuffer.append(" and o.processPerson2 = ?" + (index));
|
|
|
+// vs.add( wrapIn.getProcessPerson2() );
|
|
|
+// index++;
|
|
|
+// }
|
|
|
+
|
|
|
+ //添加OR条件
|
|
|
+ if (wrapIn.getOrAtrribute() != null && wrapIn.getOrAtrribute().size() > 0) {
|
|
|
+ sql_stringBuffer.append(" and (");
|
|
|
+ NameValueCountPair nameValueCountPair = null;
|
|
|
+ for (int p = 0; p < wrapIn.getOrAtrribute().size(); p++) {
|
|
|
+ nameValueCountPair = wrapIn.getOrAtrribute().get(p);
|
|
|
+ if (p == 0) {
|
|
|
+ sql_stringBuffer.append(" o." + nameValueCountPair.getName() + " = ?" + (index));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ sql_stringBuffer.append(" or o." + nameValueCountPair.getName() + " = ?" + (index));
|
|
|
+ }
|
|
|
+ vs.add(nameValueCountPair.getValue());
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ sql_stringBuffer.append(" )");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(), AttendanceAppealInfo.class );
|
|
|
+ //为查询设置所有的参数值
|
|
|
+ for (int i = 0; i < vs.size(); i++) {
|
|
|
+ query.setParameter(i + 1, vs.get(i));
|
|
|
+ }
|
|
|
+ System.out.println("listIdsNextWithFilterWithCurrentProcessor="+query);
|
|
|
+ return query.setMaxResults(count).getResultList();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询上一页的文档信息数据
|
|
|
* @param id
|
|
|
@@ -514,4 +631,97 @@ public class AttendanceAppealInfoFactory extends AbstractFactory {
|
|
|
}
|
|
|
return (Long) query.getSingleResult();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合的文档信息总数
|
|
|
+ * @param wrapIn
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public long getCountWithFilterWithCurrentProcessor( WrapInFilterAppeal wrapIn ,boolean isManager) throws Exception {
|
|
|
+ //先获取上一页最后一条的sequence值,如果有值的话,以此sequence值作为依据取后续的count条数据
|
|
|
+ EntityManager em = this.entityManagerContainer().get( AttendanceAppealInfo.class );
|
|
|
+ List<Object> vs = new ArrayList<>();
|
|
|
+ StringBuffer sql_stringBuffer = new StringBuffer();
|
|
|
+ Integer index = 1;
|
|
|
+
|
|
|
+ sql_stringBuffer.append( "SELECT count(o.id) FROM "+AttendanceAppealInfo.class.getCanonicalName()+" o where 1=1" );
|
|
|
+
|
|
|
+ if ((null != wrapIn.getDetailId()) && (!wrapIn.getDetailId().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.detailId = ?" + (index));
|
|
|
+ vs.add( wrapIn.getDetailId() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getEmpName()) && (!wrapIn.getEmpName().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.empName = ?" + (index));
|
|
|
+ vs.add( wrapIn.getEmpName() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getUnitName()) && (!wrapIn.getUnitName().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.unitName = ?" + (index));
|
|
|
+ vs.add( wrapIn.getUnitName() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getTopUnitName()) && (!wrapIn.getTopUnitName().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.topUnitName = ?" + (index));
|
|
|
+ vs.add( wrapIn.getTopUnitName() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getYearString() ) && (!wrapIn.getYearString().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.yearString = ?" + (index));
|
|
|
+ vs.add( wrapIn.getYearString() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getMonthString()) && (!wrapIn.getMonthString().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.monthString = ?" + (index));
|
|
|
+ vs.add( wrapIn.getMonthString() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if (wrapIn.getStatus()!=999) {
|
|
|
+ sql_stringBuffer.append(" and o.status = ?" + (index));
|
|
|
+ vs.add( wrapIn.getStatus() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if ((null != wrapIn.getAppealReason()) && (!wrapIn.getAppealReason().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.appealReason = ?" + (index));
|
|
|
+ vs.add( wrapIn.getAppealReason() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if(!isManager){
|
|
|
+ if ((null != wrapIn.getProcessPerson1()) && (!wrapIn.getProcessPerson1().isEmpty())) {
|
|
|
+ sql_stringBuffer.append(" and o.currentProcessor = ?" + (index));
|
|
|
+ vs.add( wrapIn.getProcessPerson1() );
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+// if ((null != wrapIn.getProcessPerson2()) && (!wrapIn.getProcessPerson2().isEmpty())) {
|
|
|
+// sql_stringBuffer.append(" and o.processPerson2 = ?" + (index));
|
|
|
+// vs.add( wrapIn.getProcessPerson2() );
|
|
|
+// index++;
|
|
|
+// }
|
|
|
+ //添加OR
|
|
|
+ if (wrapIn.getOrAtrribute() != null && wrapIn.getOrAtrribute().size() > 0) {
|
|
|
+ sql_stringBuffer.append(" and (");
|
|
|
+ NameValueCountPair nameValueCountPair = null;
|
|
|
+ for (int p = 0; p < wrapIn.getOrAtrribute().size(); p++) {
|
|
|
+ nameValueCountPair = wrapIn.getOrAtrribute().get(p);
|
|
|
+ if (p == 0) {
|
|
|
+ sql_stringBuffer.append(" o." + nameValueCountPair.getName() + " = ?" + (index));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ sql_stringBuffer.append(" or o." + nameValueCountPair.getName() + " = ?" + (index));
|
|
|
+ }
|
|
|
+ vs.add(nameValueCountPair.getValue());
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ sql_stringBuffer.append(" )");
|
|
|
+ }
|
|
|
+
|
|
|
+ Query query = em.createQuery( sql_stringBuffer.toString(), AttendanceAppealInfo.class );
|
|
|
+ //为查询设置所有的参数值
|
|
|
+ for (int i = 0; i < vs.size(); i++) {
|
|
|
+ query.setParameter(i + 1, vs.get(i));
|
|
|
+ }
|
|
|
+ return (Long) query.getSingleResult();
|
|
|
+ }
|
|
|
}
|