Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r35954 -r35956 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 35954) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 35956) @@ -207,6 +207,7 @@ import com.forgon.disinfectsystem.jasperreports.util.MonthReportGroupBySterilizationModeHelper; import com.forgon.disinfectsystem.jasperreports.util.MonthReportHelper; import com.forgon.disinfectsystem.jasperreports.util.NurseWorkloadReportHelper; +import com.forgon.disinfectsystem.jasperreports.util.OperationReservationInvoiceHelper; import com.forgon.disinfectsystem.jasperreports.util.PackingReportHelper; import com.forgon.disinfectsystem.jasperreports.util.PackingUnqualifieReportHelper; import com.forgon.disinfectsystem.jasperreports.util.QualityControlOfClinicHelper; @@ -395,6 +396,8 @@ private ReportHelper1 reportHelper1; @Autowired private DisposableGoodsInventoryHelper disposableGoodsInventoryHelper; + @Autowired + private OperationReservationInvoiceHelper operationReservationInvoiceHelper; /** * 利用sql语句做数据源创建JasperPrint对象 * @param realPath 报表的jasper文件在服务器本地机子的全路径 @@ -1659,308 +1662,15 @@ @Override public List getOperationReservationDetailData(String startTime, String endTime, String operationRoomName, String tousseName) { - List list = new ArrayList(); - if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { - if(StringUtils.isNotBlank(startTime) && startTime.trim().length() == 16){ - startTime = startTime + ":00"; - } - if(StringUtils.isNotBlank(endTime) && endTime.trim().length() == 16){ - endTime = endTime + ":59"; - } - String betweenSql = "and " + dateQueryAdapter.dateAreaSql("ore.operationTime", startTime, endTime); - - String operatingRoomSql = ""; - if (StringTools.isNotBlank(operationRoomName)) { - operatingRoomSql = String.format("and ore.operatingRoom='%s'", operationRoomName); - } - - String tousseNameSql = ""; - if (StringTools.isNotBlank(tousseName)) { - tousseNameSql = String.format("and ti.tousseName='%s'", tousseName); - } - - String sql = String.format("select oro.id operationRoomId,oro.orgUnitName orgUnitName,oro.operationRoomName,ore.id operationReservationId,ore.operationTime,ore.consoleName,ti.tousseName,ti.amount " - + "from OperationReservation ore join TousseItem ti on ti.recyclingApplication_ID=ore.id " - + "join OperationRoom oro on oro.operationRoomName=ore.operatingRoom " - + "where oro.isInvoice='%s' %s %s %s order by ore.operationTime,ore.consoleName", - Constants.STR_YES, betweenSql, operatingRoomSql, tousseNameSql); - ResultSet result = objectDao.executeSql(sql); - - Map map1 = new LinkedHashMap(); - Map map2 = new LinkedHashMap(); - Map map3 = new LinkedHashMap(); - - String separator = ";;"; - try { - while(result.next()){ - String operationRoomId = result.getString("operationRoomId"); - String orgUnitName = StringTools.defaultString(result.getString("orgUnitName")); - String operatingRoomName = StringTools.defaultString(result.getString("operationRoomName")); - String operationReservationId = result.getString("operationReservationId"); - String operationTime = ForgonDateUtils.safelyFormatDate(result.getTimestamp("operationTime"), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMM, ""); - String operationTimeGroup = ""; - if (StringTools.isNotBlank(operationTime)) { - operationTimeGroup = operationTime.substring(0, 10) + "\r\n手术排班的物品"; - } - String consoleName = StringTools.defaultString(result.getString("consoleName")); - String goodsName = StringTools.defaultString(result.getString("tousseName")); - Integer amount = result.getInt("amount"); - - OperationReservationDetail_main child1 = map1.get(operationTimeGroup); - if (null == child1) { - child1 = new OperationReservationDetail_main(); - child1.setOperationTimeGroup(operationTimeGroup); - map1.put(operationTimeGroup, child1); - } - - String separator1 = operationTimeGroup + separator + operationRoomId; - OperationReservationDetail_child child2 = map2.get(separator1); - if (null == child2) { - child2 = new OperationReservationDetail_child(); - child2.setOrgUnitName(orgUnitName); - child2.setOperatingRoom(operatingRoomName); - map2.put(separator1, child2); - } - - String separator2 = separator1 + separator + operationReservationId; - OperationReservationDetail_child_child child3 = map3.get(separator2); - if (null == child3) { - child3 = new OperationReservationDetail_child_child(); - child3.setOperationTime(operationTime); - child3.setConsoleName(consoleName); - map3.put(separator2, child3); - } - - String goodsDetail = child3.getGoodsDetail(); - if (StringTools.isBlank(goodsDetail)) { - child3.setGoodsDetail(goodsName + "*" + amount); - } else { - child3.setGoodsDetail(goodsDetail + "、" + goodsName + "*" + amount); - } - } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(result); - } - - for (Entry entry1 : map1.entrySet()) { - String key1 = entry1.getKey(); - OperationReservationDetail_main value1 = entry1.getValue(); - - List child1 = new ArrayList(); - for (Entry entry2 : map2.entrySet()) { - String key2 = entry2.getKey(); - String key1Temp = key2.substring(0, key2.lastIndexOf(separator)); - if (key1Temp.equals(key1)) { - OperationReservationDetail_child value2 = entry2.getValue(); - - List child2 = new ArrayList(); - for (Entry entry3 : map3.entrySet()) { - String key3 = entry3.getKey(); - String key2Temp = key3.substring(0, key3.lastIndexOf(separator)); - if (key2Temp.equals(key2)) { - OperationReservationDetail_child_child value3 = entry3.getValue(); - child2.add(value3); - } - } - - value2.setChild(child2); - child1.add(value2); - } - } - value1.setChild(child1); - list.add(value1); - } - } - return list; + return operationReservationInvoiceHelper.getOperationReservationDetailData(startTime, endTime, operationRoomName, tousseName); } @Override public List getOperationReservationSumData(String startTime, String endTime, String tousseName) { - List list = new ArrayList(); - if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { - if(StringUtils.isNotBlank(startTime) && startTime.trim().length() == 16){ - startTime = startTime + ":00"; - } - if(StringUtils.isNotBlank(endTime) && endTime.trim().length() == 16){ - endTime = endTime + ":59"; - } - String betweenSql = "and " + dateQueryAdapter.dateAreaSql("ore.operationTime", startTime, endTime); - - String tousseNameSql = ""; - if (StringTools.isNotBlank(tousseName)) { - tousseNameSql = String.format("and ti.tousseName='%s'", tousseName); - } - - String sql = String.format("select oro.id operationRoomId,oro.orgUnitName,oro.operationRoomName,ore.id operationReservationId,ore.operationTime,ti.tousseName,sum(ti.amount) amount " - + "from OperationReservation ore join TousseItem ti on ti.recyclingApplication_ID=ore.id " - + "join OperationRoom oro on oro.operationRoomName=ore.operatingRoom " - + "where oro.isInvoice='%s' %s %s group by oro.id,oro.orgUnitName,oro.operationRoomName,ore.id,ore.operationTime,ti.tousseName order by ore.operationTime", - Constants.STR_YES, betweenSql, tousseNameSql); - ResultSet result = objectDao.executeSql(sql); - - Map map1 = new LinkedHashMap(); - Map map2 = new LinkedHashMap(); - Map map3 = new LinkedHashMap(); - - Map map4 = new HashMap(); - - String separator = ";;"; - try { - while(result.next()){ - String operationRoomId = result.getString("operationRoomId"); - String orgUnitName = StringTools.defaultString(result.getString("orgUnitName")); - String operatingRoomName = StringTools.defaultString(result.getString("operationRoomName")); - String operationReservationId = result.getString("operationReservationId"); - String operationTimeGroup = ForgonDateUtils.safelyFormatDate(result.getTimestamp("operationTime"), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDD, ""); - if (StringTools.isNotBlank(operationTimeGroup)) { - operationTimeGroup += "\r\n手术排班的物品"; - } - String goodsName = StringTools.defaultString(result.getString("tousseName")); - Integer amount = result.getInt("amount"); - - map4.put(goodsName, goodsName); - - OperationReservationSum_main child1 = map1.get(operationTimeGroup); - if (null == child1) { - child1 = new OperationReservationSum_main(); - child1.setOperationTimeGroup(operationTimeGroup); - map1.put(operationTimeGroup, child1); - } - - String separator1 = operationTimeGroup + separator + orgUnitName; - OperationReservationSum_child child2 = map2.get(separator1); - if (null == child2) { - child2 = new OperationReservationSum_child(); - child2.setOrgUnitName(orgUnitName); - map2.put(separator1, child2); - } - - String separator2 = separator1 + separator + goodsName; - OperationReservationSum_child_child child3 = map3.get(separator2); - if (null == child3) { - child3 = new OperationReservationSum_child_child(); - child3.setTousseName(goodsName); - map3.put(separator2, child3); - } - child3.setAmount(child3.getAmount() + amount); - } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(result); - } - - Set> tousseNameEntrySet = map4.entrySet(); - String[] TousseNameArr = new String[tousseNameEntrySet.size()]; - int i = 0; - for (Entry entry : tousseNameEntrySet) { - TousseNameArr[i ++] = entry.getKey(); - } - - Map map5 = new LinkedHashMap(); - if (TousseNameArr.length > 0) { - String sql2 = String.format("select 'decontaminationAreaAmount' amountType,td.name tousseName,sum(pt.amount) amount from PackingTask pt join TousseDefinition td on td.id=pt.tousseDefinition_id " - + "group by td.name having(1=1 %s) " - + "union all " - + "select 'packingAreaAmount' amountType,ti.tousseName,count(*) amount from TousseInstance ti where ti.status='%s' " - + "group by ti.tousseName having(1=1 %s) " - + "union all " - + "select 'invoiceAreaAmount' amountType,ti.tousseName,count(*) amount from TousseInstance ti where ti.status='%s' " - + "group by ti.tousseName having(1=1 %s) ", - SqlUtils.get_InSql("td.name", TousseNameArr), TousseInstance.STATUS_REVIEWED, SqlUtils.get_InSql("ti.tousseName", TousseNameArr), - TousseInstance.STATUS_STERILED, SqlUtils.get_InSql("ti.tousseName", TousseNameArr)); - - ResultSet result2 = objectDao.executeSql(sql2); - try { - while(result2.next()){ - String amountType = StringTools.defaultString(result2.getString("amountType")); - String goodsName = StringTools.defaultString(result2.getString("tousseName")); - int amount = result2.getInt("amount"); - - OperationReservationSum_child_child child = map5.get(goodsName); - if (null == child) { - child = new OperationReservationSum_child_child(); - map5.put(goodsName, child); - } - setAmountByAmountType(child, amountType, amount); - } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(result2); - } - } - - for (Entry entry1 : map1.entrySet()) { - String key1 = entry1.getKey(); - OperationReservationSum_main value1 = entry1.getValue(); - - List child1 = new ArrayList(); - for (Entry entry2 : map2.entrySet()) { - String key2 = entry2.getKey(); - String key1Temp = key2.substring(0, key2.lastIndexOf(separator)); - if (key1Temp.equals(key1)) { - OperationReservationSum_child value2 = entry2.getValue(); - - List child2 = new ArrayList(); - for (Entry entry3 : map3.entrySet()) { - String key3 = entry3.getKey(); - String key2Temp = key3.substring(0, key3.lastIndexOf(separator)); - if (key2Temp.equals(key2)) { - OperationReservationSum_child_child value3 = entry3.getValue(); - OperationReservationSum_child_child tempValue3 = map5.get(value3.getTousseName()); - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - - if (ForgonDateUtils.safelyParseDate(key1.substring(0, 10)).before(calendar.getTime())) { - value3.setDecontaminationAreaAmount(-1); - value3.setPackingAreaAmount(-1); - value3.setInvoiceAreaAmount(-1); - } else { - if (null != tempValue3) { - value3.setDecontaminationAreaAmount(tempValue3.getDecontaminationAreaAmount()); - value3.setPackingAreaAmount(tempValue3.getPackingAreaAmount()); - value3.setInvoiceAreaAmount(tempValue3.getInvoiceAreaAmount()); - } - } - child2.add(value3); - } - } - value2.setChild(child2); - child1.add(value2); - } - } - value1.setChild(child1); - list.add(value1); - } - } - return list; + return operationReservationInvoiceHelper.getOperationReservationSumData(startTime, endTime, tousseName); } - /** - * 根据类型,设置po的数量(此方法只使用与本类的getOperationReservationSumData方法) - * @param child 目标对象 - * @param amountType 数量类型 - * @param amount 数量 - */ - private void setAmountByAmountType( - OperationReservationSum_child_child child, String amountType, - int amount) { - if ("decontaminationAreaAmount".equals(amountType)) { - child.setDecontaminationAreaAmount(child.getDecontaminationAreaAmount() + amount); - } else if ("packingAreaAmount".equals(amountType)) { - child.setPackingAreaAmount(child.getPackingAreaAmount() + amount); - } else if ("invoiceAreaAmount".equals(amountType)) { - child.setInvoiceAreaAmount(child.getInvoiceAreaAmount() + amount); - } - } - @Override public List getUrgentNeedGoodsProcessingCycleData( String startTime, String endTime, String tousseName, String departCoding, String tousseTypes, String departs) { Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/OperationReservationInvoiceHelper.java =================================================================== diff -u --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/OperationReservationInvoiceHelper.java (revision 0) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/util/OperationReservationInvoiceHelper.java (revision 35956) @@ -0,0 +1,353 @@ +package com.forgon.disinfectsystem.jasperreports.util; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.forgon.Constants; +import com.forgon.databaseadapter.service.DateQueryAdapter; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance; +import com.forgon.disinfectsystem.jasperreports.javabeansource.OperationReservationDetail_child; +import com.forgon.disinfectsystem.jasperreports.javabeansource.OperationReservationDetail_child_child; +import com.forgon.disinfectsystem.jasperreports.javabeansource.OperationReservationDetail_main; +import com.forgon.disinfectsystem.jasperreports.javabeansource.OperationReservationSum_child; +import com.forgon.disinfectsystem.jasperreports.javabeansource.OperationReservationSum_child_child; +import com.forgon.disinfectsystem.jasperreports.javabeansource.OperationReservationSum_main; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.string.StringTools; +import com.forgon.tools.util.ForgonDateUtils; +import com.forgon.tools.util.SqlUtils; +/** + * 手术排班物品查询 + */ +@Component +public class OperationReservationInvoiceHelper { + @Autowired + private ObjectDao objectDao; + @Autowired + private DateQueryAdapter dateQueryAdapter; + /** + * 获取手术排班报表(明细)报表的数据 + * @param startTime 开始时间格式如:2017-01-01 00:00 + * @param endTime 结束时间格式如:2017-01-01 00:00 + * @param operationRoomName 指定想要查询的手术间名称,如果不指定则查询全部手术间 + * @param tousseName 指定想要查询的器械包名称,如果不指定则查询全部器械包 + * @return + */ + public List getOperationReservationDetailData(String startTime, + String endTime, String operationRoomName, String tousseName) { + List list = new ArrayList(); + if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { + if(StringUtils.isNotBlank(startTime) && startTime.trim().length() == 16){ + startTime = startTime + ":00"; + } + if(StringUtils.isNotBlank(endTime) && endTime.trim().length() == 16){ + endTime = endTime + ":59"; + } + String betweenSql = "and " + dateQueryAdapter.dateAreaSql("ore.operationTime", startTime, endTime); + + String operatingRoomSql = ""; + if (StringTools.isNotBlank(operationRoomName)) { + operatingRoomSql = String.format("and ore.operatingRoom='%s'", operationRoomName); + } + + String tousseNameSql = ""; + if (StringTools.isNotBlank(tousseName)) { + tousseNameSql = String.format("and ti.tousseName='%s'", tousseName); + } + + String sql = String.format("select oro.id operationRoomId,oro.orgUnitName orgUnitName,oro.operationRoomName,ore.id operationReservationId,ore.operationTime,ore.consoleName,ti.tousseName,ti.amount " + + "from OperationReservation ore join TousseItem ti on ti.recyclingApplication_ID=ore.id " + + "join OperationRoom oro on oro.operationRoomName=ore.operatingRoom " + + "where oro.isInvoice='%s' %s %s %s order by ore.operationTime,ore.consoleName", + Constants.STR_YES, betweenSql, operatingRoomSql, tousseNameSql); + ResultSet result = objectDao.executeSql(sql); + + Map map1 = new LinkedHashMap(); + Map map2 = new LinkedHashMap(); + Map map3 = new LinkedHashMap(); + + String separator = ";;"; + try { + while(result.next()){ + String operationRoomId = result.getString("operationRoomId"); + String orgUnitName = StringTools.defaultString(result.getString("orgUnitName")); + String operatingRoomName = StringTools.defaultString(result.getString("operationRoomName")); + String operationReservationId = result.getString("operationReservationId"); + String operationTime = ForgonDateUtils.safelyFormatDate(result.getTimestamp("operationTime"), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDDHHMM, ""); + String operationTimeGroup = ""; + if (StringTools.isNotBlank(operationTime)) { + operationTimeGroup = operationTime.substring(0, 10) + "\r\n手术排班的物品"; + } + String consoleName = StringTools.defaultString(result.getString("consoleName")); + String goodsName = StringTools.defaultString(result.getString("tousseName")); + Integer amount = result.getInt("amount"); + + OperationReservationDetail_main child1 = map1.get(operationTimeGroup); + if (null == child1) { + child1 = new OperationReservationDetail_main(); + child1.setOperationTimeGroup(operationTimeGroup); + map1.put(operationTimeGroup, child1); + } + + String separator1 = operationTimeGroup + separator + operationRoomId; + OperationReservationDetail_child child2 = map2.get(separator1); + if (null == child2) { + child2 = new OperationReservationDetail_child(); + child2.setOrgUnitName(orgUnitName); + child2.setOperatingRoom(operatingRoomName); + map2.put(separator1, child2); + } + + String separator2 = separator1 + separator + operationReservationId; + OperationReservationDetail_child_child child3 = map3.get(separator2); + if (null == child3) { + child3 = new OperationReservationDetail_child_child(); + child3.setOperationTime(operationTime); + child3.setConsoleName(consoleName); + map3.put(separator2, child3); + } + + String goodsDetail = child3.getGoodsDetail(); + if (StringTools.isBlank(goodsDetail)) { + child3.setGoodsDetail(goodsName + "*" + amount); + } else { + child3.setGoodsDetail(goodsDetail + "、" + goodsName + "*" + amount); + } + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(result); + } + + for (Entry entry1 : map1.entrySet()) { + String key1 = entry1.getKey(); + OperationReservationDetail_main value1 = entry1.getValue(); + + List child1 = new ArrayList(); + for (Entry entry2 : map2.entrySet()) { + String key2 = entry2.getKey(); + String key1Temp = key2.substring(0, key2.lastIndexOf(separator)); + if (key1Temp.equals(key1)) { + OperationReservationDetail_child value2 = entry2.getValue(); + + List child2 = new ArrayList(); + for (Entry entry3 : map3.entrySet()) { + String key3 = entry3.getKey(); + String key2Temp = key3.substring(0, key3.lastIndexOf(separator)); + if (key2Temp.equals(key2)) { + OperationReservationDetail_child_child value3 = entry3.getValue(); + child2.add(value3); + } + } + + value2.setChild(child2); + child1.add(value2); + } + } + value1.setChild(child1); + list.add(value1); + } + } + return list; + } + /** + * 获取手术排班报表(汇总)报表的数据 + * @param startTime 开始时间格式如:2017-01-01 00:00 + * @param endTime 结束时间格式如:2017-01-01 00:00 + * @param tousseName 指定想要查询的器械包名称,如果不指定则查询全部器械包 + * @return + */ + public List getOperationReservationSumData(String startTime, + String endTime, String tousseName) { + List list = new ArrayList(); + if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) { + if(StringUtils.isNotBlank(startTime) && startTime.trim().length() == 16){ + startTime = startTime + ":00"; + } + if(StringUtils.isNotBlank(endTime) && endTime.trim().length() == 16){ + endTime = endTime + ":59"; + } + String betweenSql = "and " + dateQueryAdapter.dateAreaSql("ore.operationTime", startTime, endTime); + + String tousseNameSql = ""; + if (StringTools.isNotBlank(tousseName)) { + tousseNameSql = String.format("and ti.tousseName='%s'", tousseName); + } + + String sql = String.format("select oro.orgUnitName,ore.operationTime,ti.tousseName,sum(ti.amount) amount " + + "from OperationReservation ore join TousseItem ti on ti.recyclingApplication_ID=ore.id " + + "join OperationRoom oro on oro.operationRoomName=ore.operatingRoom " + + "where oro.isInvoice='%s' %s %s group by oro.id,oro.orgUnitName,oro.operationRoomName,ore.id,ore.operationTime,ti.tousseName order by ore.operationTime", + Constants.STR_YES, betweenSql, tousseNameSql); + ResultSet result = objectDao.executeSql(sql); + + Map map1 = new LinkedHashMap(); + Map map2 = new LinkedHashMap(); + Map map3 = new LinkedHashMap(); + + Map map4 = new HashMap(); + + String separator = ";;"; + try { + while(result.next()){ + String orgUnitName = StringTools.defaultString(result.getString("orgUnitName")); + String operationTimeGroup = ForgonDateUtils.safelyFormatDate(result.getTimestamp("operationTime"), ForgonDateUtils.SIMPLEDATEFORMAT_YYYYMMDD, ""); + if (StringTools.isNotBlank(operationTimeGroup)) { + operationTimeGroup += "\r\n手术排班的物品"; + } + String goodsName = StringTools.defaultString(result.getString("tousseName")); + Integer amount = result.getInt("amount"); + + map4.put(goodsName, goodsName); + + OperationReservationSum_main child1 = map1.get(operationTimeGroup); + if (null == child1) { + child1 = new OperationReservationSum_main(); + child1.setOperationTimeGroup(operationTimeGroup); + map1.put(operationTimeGroup, child1); + } + + String separator1 = operationTimeGroup + separator + orgUnitName; + OperationReservationSum_child child2 = map2.get(separator1); + if (null == child2) { + child2 = new OperationReservationSum_child(); + child2.setOrgUnitName(orgUnitName); + map2.put(separator1, child2); + } + + String separator2 = separator1 + separator + goodsName; + OperationReservationSum_child_child child3 = map3.get(separator2); + if (null == child3) { + child3 = new OperationReservationSum_child_child(); + child3.setTousseName(goodsName); + map3.put(separator2, child3); + } + child3.setAmount(child3.getAmount() + amount); + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(result); + } + + Set> tousseNameEntrySet = map4.entrySet(); + String[] TousseNameArr = new String[tousseNameEntrySet.size()]; + int i = 0; + for (Entry entry : tousseNameEntrySet) { + TousseNameArr[i ++] = entry.getKey(); + } + + Map map5 = new LinkedHashMap(); + if (TousseNameArr.length > 0) { + String sql2 = String.format("select 'decontaminationAreaAmount' amountType,td.name tousseName,sum(pt.amount) amount from PackingTask pt join TousseDefinition td on td.id=pt.tousseDefinition_id " + + "group by td.name having(1=1 %s) " + + "union all " + + "select 'packingAreaAmount' amountType,ti.tousseName,count(*) amount from TousseInstance ti where ti.status='%s' " + + "group by ti.tousseName having(1=1 %s) " + + "union all " + + "select 'invoiceAreaAmount' amountType,ti.tousseName,count(*) amount from TousseInstance ti where ti.status='%s' " + + "group by ti.tousseName having(1=1 %s) ", + SqlUtils.get_InSql("td.name", TousseNameArr), TousseInstance.STATUS_REVIEWED, SqlUtils.get_InSql("ti.tousseName", TousseNameArr), + TousseInstance.STATUS_STERILED, SqlUtils.get_InSql("ti.tousseName", TousseNameArr)); + + ResultSet result2 = objectDao.executeSql(sql2); + try { + while(result2.next()){ + String amountType = StringTools.defaultString(result2.getString("amountType")); + String goodsName = StringTools.defaultString(result2.getString("tousseName")); + int amount = result2.getInt("amount"); + + OperationReservationSum_child_child child = map5.get(goodsName); + if (null == child) { + child = new OperationReservationSum_child_child(); + map5.put(goodsName, child); + } + setAmountByAmountType(child, amountType, amount); + } + } catch (SQLException e) { + e.printStackTrace(); + }finally { + DatabaseUtil.closeResultSetAndStatement(result2); + } + } + + for (Entry entry1 : map1.entrySet()) { + String key1 = entry1.getKey(); + OperationReservationSum_main value1 = entry1.getValue(); + + List child1 = new ArrayList(); + for (Entry entry2 : map2.entrySet()) { + String key2 = entry2.getKey(); + String key1Temp = key2.substring(0, key2.lastIndexOf(separator)); + if (key1Temp.equals(key1)) { + OperationReservationSum_child value2 = entry2.getValue(); + + List child2 = new ArrayList(); + for (Entry entry3 : map3.entrySet()) { + String key3 = entry3.getKey(); + String key2Temp = key3.substring(0, key3.lastIndexOf(separator)); + if (key2Temp.equals(key2)) { + OperationReservationSum_child_child value3 = entry3.getValue(); + OperationReservationSum_child_child tempValue3 = map5.get(value3.getTousseName()); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + if (ForgonDateUtils.safelyParseDate(key1.substring(0, 10)).before(calendar.getTime())) { + value3.setDecontaminationAreaAmount(-1); + value3.setPackingAreaAmount(-1); + value3.setInvoiceAreaAmount(-1); + } else { + if (null != tempValue3) { + value3.setDecontaminationAreaAmount(tempValue3.getDecontaminationAreaAmount()); + value3.setPackingAreaAmount(tempValue3.getPackingAreaAmount()); + value3.setInvoiceAreaAmount(tempValue3.getInvoiceAreaAmount()); + } + } + child2.add(value3); + } + } + value2.setChild(child2); + child1.add(value2); + } + } + value1.setChild(child1); + list.add(value1); + } + } + return list; + } + /** + * 根据类型,设置po的数量(此方法只使用与本类的getOperationReservationSumData方法) + * @param child 目标对象 + * @param amountType 数量类型 + * @param amount 数量 + */ + private void setAmountByAmountType( + OperationReservationSum_child_child child, String amountType, + int amount) { + if ("decontaminationAreaAmount".equals(amountType)) { + child.setDecontaminationAreaAmount(child.getDecontaminationAreaAmount() + amount); + } else if ("packingAreaAmount".equals(amountType)) { + child.setPackingAreaAmount(child.getPackingAreaAmount() + amount); + } else if ("invoiceAreaAmount".equals(amountType)) { + child.setInvoiceAreaAmount(child.getInvoiceAreaAmount() + amount); + } + } +}