Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/dwr/table/InvoicePlanTableManager.java =================================================================== diff -u -r34123 -r35067 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/dwr/table/InvoicePlanTableManager.java (.../InvoicePlanTableManager.java) (revision 34123) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/dwr/table/InvoicePlanTableManager.java (.../InvoicePlanTableManager.java) (revision 35067) @@ -1,21 +1,16 @@ package com.forgon.disinfectsystem.invoicemanager.dwr.table; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; -import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.util.CycleDetectionStrategy; import net.sf.json.util.PropertyFilter; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import com.forgon.component.grid.GridManager; -import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.disinfectsystem.common.Constants; import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; @@ -25,7 +20,6 @@ import com.forgon.tools.SpringBeanManger; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JsonPropertyFilter; -import com.forgon.tools.util.SqlUtils; /** * @author WangYi @@ -107,7 +101,7 @@ } public int getUnfinishedInvoicePlanAmount() { - Set exclusionType = new HashSet(); + /*Set exclusionType = new HashSet(); exclusionType.add(InvoicePlan.TYPE_SECOND_SUPPLY_ROOM); exclusionType.add(InvoicePlan.TYPE_EXPENSIVEGOODS_FORM); String sql = " where handleDepartCoding='"+ AcegiHelper.getCurrentOrgUnitCode() @@ -117,13 +111,14 @@ + Constants.STATUS_PARTOFDELIVERING + "') and (" + SqlUtils.getStringFieldNotInCollectionsPredicate("po.type", exclusionType) + ")"; //return invoicePlanManager.getInvoicePlanAmount(sql); - /*return objectDao.countBySql(String.format("select count(0) from %s po %s", - InvoicePlan.class.getSimpleName(),sql));*/ + return objectDao.countBySql(String.format("select count(0) from %s po %s", + InvoicePlan.class.getSimpleName(),sql)); JSONArray invoicePlanVoArray = invoicePlanOptimizeManager.getInvoicePlansByOrgAndTousseType(null, null, null, null, null, null, null); int invoicePlanVoArraySize = CollectionUtils.size(invoicePlanVoArray); - return invoicePlanVoArraySize > 0 ? invoicePlanVoArraySize - 1 : 0; + return invoicePlanVoArraySize > 0 ? invoicePlanVoArraySize - 1 : 0;*/ + return invoicePlanOptimizeManager.getUnfinishedInvoicePlanAmount(); } /* Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java =================================================================== diff -u -r34563 -r35067 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 34563) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 35067) @@ -248,6 +248,12 @@ public List getInvoicePlanListByOrgUnitCodingsAndTousseType( Collection orgUnitCodings, String applyDate , String tousseType, String tousseGroupIds,String appFormType, boolean isSortedByUrgency,boolean needQueryTousseItem); + /** + * 查询未完成的申请单数量 + * @return + */ + public int getUnfinishedInvoicePlanAmount(); + public Collection getInvoicePlanListForExpressInvoiceWaitDeliverGoods( String orgUnitCoding, String applyDate, String tousseType,String tousseDefinitionId,String disposableGoodsId); Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r34883 -r35067 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 34883) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 35067) @@ -4404,6 +4404,24 @@ */ private String buildSqlForGetInvoicePlanByOrgUnitCodingsAndTousseType( Collection orgUnitCodings, String applyDate , String tousseType,String useCase, String tousseGroupIds , String appFormType) { + return buildSqlForGetInvoicePlanByOrgUnitCodingsAndTousseType(orgUnitCodings, applyDate, tousseType, useCase, tousseGroupIds, appFormType, false); + } + + /** + * 拼接查询SQL的WHERE部分 根据时间段和多个orgUnitCoding和器械包分组获取未发货的发货计划单 + * @param orgUnitCodings + * @param applyDate + * @param tousseType + * @param useCase + * @param tousseGroupIds + * @param appFormType 申请单类型 + * @param returnSql 是否返回sql语句:true返回sql语句;false返回hql + * @return String + * @author SYF + * @since 2015-09-22 + */ + private String buildSqlForGetInvoicePlanByOrgUnitCodingsAndTousseType( + Collection orgUnitCodings, String applyDate , String tousseType,String useCase, String tousseGroupIds , String appFormType, boolean returnSql) { String where1 = String.format( "(deliverStatus='%s' or deliverStatus='%s') and (endStatus is null or endStatus!='%s')", InvoicePlan.DELIVERSTATUS_AWAITDELIVER, @@ -4468,7 +4486,7 @@ //如果申请时间范围不为空时 if (StringUtils.isNotBlank(applyDate)) { try { - where7 = this.setTimeCondition(applyDate); + where7 = this.setTimeCondition(applyDate, returnSql); } catch (Exception e) { logger.error(e, e); @@ -4492,19 +4510,29 @@ if (StringUtils.isNotBlank(tousseType)) { Set tousseTypeSet = buildTousseTypeSet(tousseType); + String invoicePlanIdSql = " invoicePlan.id "; + if(returnSql){ + //returnSql=true,返回sql语句 + invoicePlanIdSql = " recyclingApplication_ID "; + } if(CollectionUtils.isNotEmpty(tousseTypeSet)){ // 新的传参方式 - where8 = String.format("po.id in (select invoicePlan.id from TousseItem where (isTerminated is null or isTerminated <> true) and %s)",SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", tousseTypeSet)); + where8 = String.format("po.id in (select %s from TousseItem where (isTerminated is null or isTerminated <> 1) and %s)", invoicePlanIdSql, SqlUtils.getStringFieldInLargeCollectionsPredicate("tousseType", tousseTypeSet)); }else if(TousseItem.DIPOSABLE_YES.equals(tousseType) || TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ - where8 = String.format("po.id in (select invoicePlan.id from TousseItem where (isTerminated is null or isTerminated <> true) and (amount - sendOutAmount > 0) and tousseType = '%s')",TousseItem.TYPE_DIPOSABLE_GOODS); + where8 = String.format("po.id in (select %s from TousseItem where (isTerminated is null or isTerminated <> 1) and (amount - sendOutAmount > 0) and tousseType = '%s')", invoicePlanIdSql, TousseItem.TYPE_DIPOSABLE_GOODS); }else if(TousseItem.DIPOSABLE_NO.equals(tousseType)){ - where8 = String.format("po.id in (select invoicePlan.id from TousseItem where (isTerminated is null or isTerminated <> true) and tousseType != '%s')",TousseItem.TYPE_DIPOSABLE_GOODS); + where8 = String.format("po.id in (select %s from TousseItem where (isTerminated is null or isTerminated <> 1) and tousseType != '%s')", invoicePlanIdSql, TousseItem.TYPE_DIPOSABLE_GOODS); }else{ //具体的器械包类型 - where8 = String.format("po.id in (select invoicePlan.id from TousseItem where (isTerminated is null or isTerminated <> true) and tousseType = '%s')",tousseType); + where8 = String.format("po.id in (select %s from TousseItem where (isTerminated is null or isTerminated <> 1) and tousseType = '%s')", invoicePlanIdSql, tousseType); } } if (StringUtils.isNotBlank(tousseGroupIds)) {//不查询所有器械包分组 + String invoicePlanIdSql = " invoicePlan.id "; + if(returnSql){ + //returnSql=true,返回sql语句 + invoicePlanIdSql = " recyclingApplication_ID "; + } StringBuffer tousseGroupSql = new StringBuffer(); if(tousseGroupIds.indexOf(",") != -1){//查询多个分组 String[] tousseGroupArray = tousseGroupIds.split(","); @@ -4515,24 +4543,37 @@ tousseGroupSql.append(",").append(tousseGroupArray[i]); } } - where9 = String.format(" po.id in (select invoicePlan.id from TousseItem ti where (isTerminated is null or isTerminated <> true) and ancestorID in ( select td.id from TousseDefinition td where td.tousseGroupID in (%s) ))",tousseGroupSql); + where9 = String.format(" po.id in (select %s from TousseItem ti where (isTerminated is null or isTerminated <> 1) and ancestorID in ( select td.id from TousseDefinition td where td.tousseGroupID in (%s) ))", invoicePlanIdSql, tousseGroupSql); }else if(StringUtils.isNumeric(tousseGroupIds)){ - where9 = String.format(" po.id in (select invoicePlan.id from TousseItem ti where (isTerminated is null or isTerminated <> true) and ancestorID in ( select td.id from TousseDefinition td where td.tousseGroupID = %s ))",tousseGroupIds); + where9 = String.format(" po.id in (select %s from TousseItem ti where (isTerminated is null or isTerminated <> 1) and ancestorID in ( select td.id from TousseDefinition td where td.tousseGroupID = %s ))", invoicePlanIdSql, tousseGroupIds); } } String sql = String .format(" WHERE (%s) and (%s) and (%s) and (%s) and (%s) and (%s) and (%s) and (%s) and (%s) and (%s)", where1, where2, where3, where4, where5, where6, where7, where8,second_supply_room_sql,where9); return sql; } + + @Override + public int getUnfinishedInvoicePlanAmount() { + int invoicePlanAmount = 0; + try { + String sql = buildSqlForGetInvoicePlanByOrgUnitCodingsAndTousseType(null, null, null, null, null, null, true); + sql = String.format("select count(*) from %s po %s", InvoicePlan.class.getSimpleName(), sql); + invoicePlanAmount = objectDao.countBySql(sql); + } catch (Exception e) { + e.printStackTrace(); + } + return invoicePlanAmount; + } /** * 设置时间的条件 * @param applyDate 要设定的时间 - * @param tableColumnAliasPre 字段的表别名前缀,包含. + * @param returnSql 是否返回sql语句:true返回sql语句;false返回hql * @return */ - protected String setTimeCondition(String applyDate){ + protected String setTimeCondition(String applyDate, boolean returnSql){ SimpleDateFormat sdf = new SimpleDateFormat(DateTools.COMMON_DATE_HMS); try { String[] applyDateArray = StringUtils.split(applyDate, Constants.IDS_SEPARATOR); @@ -4548,6 +4589,14 @@ dateQueryAdapter.dateAdapter(out_endTime), dateQueryAdapter.dateAdapter(out_beginTime), dateQueryAdapter.dateAdapter(out_endTime)); + if(returnSql){ + //返回sql语句 + where7 = String.format("(applicationTime between %s and %s or po.id in (select recyclingApplication_id from RecyclingRecord where recyclingTime between %s and %s))", + dateQueryAdapter.dateAdapter(out_beginTime), + dateQueryAdapter.dateAdapter(out_endTime), + dateQueryAdapter.dateAdapter(out_beginTime), + dateQueryAdapter.dateAdapter(out_endTime)); + } logger.info("where7:" + where7); return where7; }