Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/vo/TousseActualRecyclingAmount.java =================================================================== diff -u --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/vo/TousseActualRecyclingAmount.java (revision 0) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/vo/TousseActualRecyclingAmount.java (revision 16078) @@ -0,0 +1,155 @@ +package com.forgon.disinfectsystem.invoicemanager.vo; + +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.tools.MathTools; +import com.forgon.tools.string.StringTools; + +/** + * 器械包所谓的"实收数量"的数据结构 + * @author kzh + * + */ +public class TousseActualRecyclingAmount { + /** + * 器械包祖先id + */ + private Long ancestorID; + /** + * 回收数量 + */ + private Integer recyclingAmount; + /** + * 申请数量 + */ + private Integer amount; + /** + * 器械包类型 + */ + private String tousseType; + /** + * 包定义中是否回收属性 + */ + private String isRecycling; + /** + * 申请单类型 + */ + private String invoicePlanType; + + public Long getAncestorID() { + return ancestorID; + } + public void setAncestorID(Long ancestorID) { + this.ancestorID = ancestorID; + } + public Integer getRecyclingAmount() { + return recyclingAmount; + } + public void setRecyclingAmount(Integer recyclingAmount) { + this.recyclingAmount = recyclingAmount; + } + public Integer getAmount() { + return amount; + } + public void setAmount(Integer amount) { + this.amount = amount; + } + public String getTousseType() { + return tousseType; + } + public void setTousseType(String tousseType) { + this.tousseType = tousseType; + } + public String getIsRecycling() { + return isRecycling; + } + public void setIsRecycling(String isRecycling) { + this.isRecycling = isRecycling; + } + public String getInvoicePlanType() { + return invoicePlanType; + } + public void setInvoicePlanType(String invoicePlanType) { + this.invoicePlanType = invoicePlanType; + } + + /** + * 获取实收数量 + * @return + */ + public Integer getActualRecyclingAmount(){ + if(isBorrowing()){ + //借物单数量为0 + return 0; + } + if(StringTools.equals(tousseType, TousseDefinition.PACKAGE_TYPE_SPLIT) + || StringTools.equals(invoicePlanType, InvoicePlan.TYPE_FOREIGNPROXYDISINFECTION)){ + //外来器械拆分小包,或者外部代理灭菌申请单,数量为发货数量。返回-1由调用者重新设置 + return -1; + } + + if(isDressingOrNoRecycling()){ + //敷料表和不回收的器械包,为申请数量 + return amount; + } + + return recyclingAmount; + } + /** + * 是否借物单 + * @return + */ + private boolean isBorrowing(){ + return StringTools.equals(invoicePlanType, InvoicePlan.TYPE_BORROWINGSINGLE); + } + /** + * 敷料包或者是不回收的器械包 + * @return + */ + private boolean isDressingOrNoRecycling(){ + if(TousseDefinition.PACKAGE_TYPE_DRESSING.equals(tousseType) + || TousseDefinition.STR_NO.equals(isRecycling)){ + return true; + } + return false; + } + /** + * 将另一个实例的数据合并到本实例影响最终的实际数量.。前提是两个的包定义id必须一致。 + * 如果当前实例的单类型为借物单,而传入的参数不是借物单,并且修改了数量,则修改单类型为传入的参数 + * @param tara + */ + public void merge(TousseActualRecyclingAmount tara){ + if(tara == null){ + return; + } + Integer amnt = tara.getActualRecyclingAmount(); + Integer curAmnt = getActualRecyclingAmount(); + if(amnt > 0){ + if(tara.isDressingOrNoRecycling()){ + //敷料包或者是不回收的器械包,为申请数量,因为是包定义判断的,所以与当前实例是一致的 + if(isBorrowing()){ + invoicePlanType = tara.getInvoicePlanType(); + amount = tara.getAmount(); + recyclingAmount = tara.getRecyclingAmount(); + }else{ + amount = MathTools.add(amount, amnt).intValue(); + } + }else{ + //当前实例也不是敷料包或者是不回收的器械包 + if(curAmnt > 0){ + recyclingAmount = MathTools.add(recyclingAmount, amnt).intValue(); + }else{ + //当前实例是借物单。因为由传入的参数大于0,传入的就不会是外来器械拆分小包,或者外部代理灭菌申请单, + //因为这两个是包定义的类型确定的 + //把申请数量和回收数量都用传入的参数中的值,并修改单类型 + invoicePlanType = tara.getInvoicePlanType(); + amount = tara.getAmount(); + recyclingAmount = tara.getRecyclingAmount(); + } + } + }else{ + //此时传入的如果是外来器械拆分小包,或者外部代理灭菌申请单,则当前实例也是,最终返回数量为-1,不用干活 + //而如果是借物单,那对最终的结果就没有影响,也不用干活 + } + } +} Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java =================================================================== diff -u -r16053 -r16078 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 16053) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceManagerImpl.java (.../InvoiceManagerImpl.java) (revision 16078) @@ -99,6 +99,7 @@ import com.forgon.disinfectsystem.invoicemanager.vo.BatchPrintInvoiceVo; import com.forgon.disinfectsystem.invoicemanager.vo.InvoicePrintVo; import com.forgon.disinfectsystem.invoicemanager.vo.InvoiceStaticsVo; +import com.forgon.disinfectsystem.invoicemanager.vo.TousseActualRecyclingAmount; import com.forgon.disinfectsystem.invoicemanager.vo.WaitSignGoodsSummary; import com.forgon.disinfectsystem.printinvoiceconfig.service.PrintInvoiceConfigManager; import com.forgon.disinfectsystem.project.service.ProjectManager; @@ -6269,7 +6270,7 @@ mergeTousseRuleForInvoiceBatchPrint = supplyRoomConfig.getMergeTousseRuleForInvoiceBatchPrint(); } - Map recycleAmountMap = getTousseRecyclingAmount(invoices); + List recycleAmountInfo = getTousseRecyclingAmount(invoices); for (Invoice invoice : invoices) { List tousseList = invoiceTousseInstances.get(invoice.getId());//invoice.getTousseInstances(objectDao); @@ -6325,7 +6326,7 @@ tempVo = new InvoicePrintVo(); tempVo.setAmount(1); - tempVo.setRecyclingAmount(recycleAmountMap.get(tousseDefinition.getAncestorID())); + tempVo.setRecyclingAmount(getTousseActualRecycleAmount(recycleAmountInfo, tousseDefinition.getAncestorID())); tempVo.setSendDate(invoice.getSendTime()); tempVo.setFrequency(frequency); tempVo.setName(tousseInstance.getTousseName()); @@ -6351,17 +6352,19 @@ * @param invoices * @return */ - private Map getTousseRecyclingAmount(Collection invoices){ - Map map = new HashMap(); + private List getTousseRecyclingAmount(Collection invoices){ + List temp = new ArrayList(); if(CollectionUtils.isNotEmpty(invoices)){ List invoiceIds = invoices.stream().map(i->i.getId()).collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(invoiceIds)){ String idpredicate = SqlUtils.getNonStringFieldInCollectionsPredicate("i.id", invoiceIds); - String sql = "select m.ancestorID,m.isRecycling,m.tousseType,sum(m.recyclingAmount) as recyclingAmount,sum(m.amount) as amount from ( " + - " select td.ancestorID,td.isRecycling,td.tousseType,ti.recyclingAmount,ti.amount,ti.recyclingApplication_ID from " + TousseItem.class.getSimpleName() + String sql = "select m.ancestorID,m.isRecycling,m.tousseType,m.type,sum(m.recyclingAmount) as recyclingAmount,sum(m.amount) as amount from ( " + + " select td.ancestorID,td.isRecycling,td.tousseType,ti.recyclingAmount,ti.amount,ti.recyclingApplication_ID,ip.type from " + TousseItem.class.getSimpleName() + " ti inner join " + TousseDefinition.class.getSimpleName() + " td on td.id = ti.tousseDefinitionId" + + " inner join " + InvoicePlan.class.getSimpleName() + " ip on ip.id = ti.recyclingApplication_ID" + " ) m where m.recyclingApplication_ID in (select i.invoicePlan_ID from " + Invoice.class.getSimpleName() - + " i where "+idpredicate+") group by m.ancestorID,m.isRecycling,m.tousseType"; + + " i where "+idpredicate+") group by m.ancestorID,m.isRecycling,m.tousseType,m.type"; + logger.debug("实收数量sql:" + sql); ResultSet rs = objectDao.executeSql(sql); if(rs != null){ try { @@ -6371,12 +6374,16 @@ int amount = rs.getInt("amount"); String tousseType = rs.getString("tousseType"); String isRecycling = rs.getString("isRecycling"); - if(TousseDefinition.PACKAGE_TYPE_DRESSING.equals(tousseType) - || TousseDefinition.STR_NO.equals(isRecycling)){ - //敷料包或者是不回收的器械包,回收数量为申请数量 - recyclingAmount = amount; - } - map.put(tousseDefinitionId, MathTools.add(map.get(tousseDefinitionId), recyclingAmount).intValue()); + String invoicePlanType = rs.getString("type"); + + TousseActualRecyclingAmount tara = new TousseActualRecyclingAmount(); + tara.setAmount(amount); + tara.setAncestorID(tousseDefinitionId); + tara.setRecyclingAmount(recyclingAmount); + tara.setTousseType(tousseType); + tara.setIsRecycling(isRecycling); + tara.setInvoicePlanType(invoicePlanType); + temp.add(tara); } } catch (SQLException e) { e.printStackTrace(); @@ -6386,7 +6393,26 @@ } } } - return map; + //因为有可能一次打印中有多张类型的单,需要把不同类型的单的数量合并,最终为根据包定义id获取实际数量 + List mergeAmount = new ArrayList(); + for(TousseActualRecyclingAmount tara : temp){ + TousseActualRecyclingAmount find = CollectionUtils.find(mergeAmount, new Predicate(){ + @Override + public boolean evaluate(TousseActualRecyclingAmount object) { + if(tara.getAncestorID()!=null && object.getAncestorID()!=null + && tara.getAncestorID().longValue() == object.getAncestorID().longValue()){ + return true; + } + return false; + } + }); + if(find == null){ + mergeAmount.add(tara); + }else{ + find.merge(tara); + } + } + return mergeAmount; } /** @@ -6444,7 +6470,7 @@ if(supplyRoomConfig != null){ mergeTousseRuleForInvoiceBatchPrint = supplyRoomConfig.getMergeTousseRuleForInvoiceBatchPrint(); } - Map recycleAmountMap = getTousseRecyclingAmount(invoices); + List recycleAmountInfo = getTousseRecyclingAmount(invoices); List voList = new ArrayList(); for (Invoice invoice : invoices) { List tousseList = invoice.getTousseInstances(objectDao); @@ -6458,7 +6484,7 @@ String frequency = tousseInstance.getSterileFrequency();// 炉次 String tousseName = tousseInstance.getTousseName(); - InvoicePrintVo tempVo = findInvoicePrintVoForTousseMerge(voList, tousseInstance, mergeTousseRuleForInvoiceBatchPrint); + InvoicePrintVo tempVo = findInvoicePrintVoForTousseMerge(voList, tousseInstance, 1); if (tempVo != null) { tempVo.setAmount(tempVo.getAmount() + 1); @@ -6470,7 +6496,7 @@ tempVo = new InvoicePrintVo(); tempVo.setAmount(1); - tempVo.setRecyclingAmount(recycleAmountMap.get(tousseDefinition.getAncestorID())); + tempVo.setRecyclingAmount(getTousseActualRecycleAmount(recycleAmountInfo, tousseDefinition.getAncestorID())); tempVo.setSendDate(invoice.getSendTime()); tempVo.setFrequency(frequency); tempVo.setName(tousseInstance.getTousseName()); @@ -6587,6 +6613,35 @@ return loadToussePrintData(list); } + private TousseActualRecyclingAmount find(List recycleAmountInfo, + Long ancestorID){ + if(CollectionUtils.isNotEmpty(recycleAmountInfo) && ancestorID != null){ + for(TousseActualRecyclingAmount tara : recycleAmountInfo){ + if(tara != null){ + if(tara.getAncestorID().longValue() == ancestorID.longValue()){ + return tara; + } + } + } + } + return null; + } + private Integer getTousseActualRecycleAmount(List recycleAmountInfo, + Long ancestorID){ + if(CollectionUtils.isNotEmpty(recycleAmountInfo) && ancestorID != null){ + for(TousseActualRecyclingAmount tara : recycleAmountInfo){ + if(tara != null){ + if(tara.getAncestorID().longValue() == ancestorID.longValue()){ + return tara.getActualRecyclingAmount(); + } + } + } + } + /** + * 返回-1,最终会由调用方设置为发货数量 + */ + return -1; + } /** * 消毒物品发货单打印数据 * @param invoices 发货单,只能是同一个科室的 @@ -6598,7 +6653,7 @@ if(CollectionUtils.isEmpty(invoices) || invoiceTousseInstances == null || invoiceTousseInstances.size() <=0) return CollectionUtils.emptyCollection(); - Map recycleAmountMap = getTousseRecyclingAmount(invoices); + List recycleAmountInfo = getTousseRecyclingAmount(invoices); Map map = new HashMap(); for (Invoice invoice : invoices) { List tousseList = invoiceTousseInstances.get(invoice.getId()); @@ -6651,12 +6706,11 @@ invoicePrintVo.setSterilizerName(tousseInstance.getSterilizerName()); invoicePrintVo.setFrequency(tousseInstance.getSterileFrequency()); - if(tousseDefinition.applyEntireTousse()){ - invoicePrintVo.setRecyclingAmount(recycleAmountMap.get(tousseDefinition.getAncestorID())); - }else{ - int recyclingAmount = MathTools.mul(materialJson.getInt("totalAmout"), recycleAmountMap.get(tousseDefinition.getAncestorID())).intValue(); - invoicePrintVo.setRecyclingAmount(recyclingAmount); + Integer recyclingAmount = getTousseActualRecycleAmount(recycleAmountInfo,tousseDefinition.getAncestorID()); + if(!tousseDefinition.applyEntireTousse()){ + recyclingAmount = MathTools.mul(materialJson.getInt("totalAmout"), recyclingAmount).intValue(); } + invoicePrintVo.setRecyclingAmount(recyclingAmount); invoicePrintVo.setSendDate(invoice.getSendTime()); if(tousseDefinition.applyEntireTousse()){ Index: ssts-web/src/main/webapp/disinfectsystem/config/dgszyy/print/printConfig.js =================================================================== diff -u -r16074 -r16078 --- ssts-web/src/main/webapp/disinfectsystem/config/dgszyy/print/printConfig.js (.../printConfig.js) (revision 16074) +++ ssts-web/src/main/webapp/disinfectsystem/config/dgszyy/print/printConfig.js (.../printConfig.js) (revision 16078) @@ -289,8 +289,8 @@ // {header : "包装规格", dataIndex : 'packageSpec', width : '15%', align : 'center', fontSize : 11}, // {header : "单位", dataIndex : 'unit', width : 80, align : 'center', fontSize : 9}, {header : "单价", dataIndex : 'price', width : 100, align : 'right', fontSize : 9}, -// {header : "实收数", dataIndex : 'recyclingAmount', width : 100, align : 'right', fontSize : 9}, - {header : "实发数", dataIndex : 'amount', width : 200, align : 'right', fontSize : 9}, + {header : "实收数", dataIndex : 'recyclingAmount', width : 100, align : 'right', fontSize : 9}, + {header : "实发数", dataIndex : 'amount', width : 100, align : 'right', fontSize : 9}, {header : "金额", dataIndex : 'totalPrice', width : 100, align : 'right', fontSize : 9}, {header : "发货日期", dataIndex : 'sendDate', width : 110, align : 'center', fontSize : 9}, {header : "有效期", dataIndex : 'expireDate', width : 110, align : 'center', fontSize : 9}, Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/vo/InvoicePrintVo.java =================================================================== diff -u -r16031 -r16078 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/vo/InvoicePrintVo.java (.../InvoicePrintVo.java) (revision 16031) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/vo/InvoicePrintVo.java (.../InvoicePrintVo.java) (revision 16078) @@ -16,6 +16,10 @@ */ public class InvoicePrintVo { + /** + * 器械包类型。值为tousseDefinition中的tousseType或者是一次性物品 + */ + private String tousseType; private String name = ""; private int serialNumber = 1; private Integer amount; @@ -56,6 +60,14 @@ private String supplierName = ""; + public String getTousseType() { + return tousseType; + } + + public void setTousseType(String tousseType) { + this.tousseType = tousseType; + } + public String getName() { return name; } @@ -273,11 +285,17 @@ } public Integer getRecyclingAmount() { - return recyclingAmount == null?0:recyclingAmount; + if(recyclingAmount == null){ + recyclingAmount = -1; + } + if(recyclingAmount.intValue() == -1){ + return amount; + } + return recyclingAmount; } public void setRecyclingAmount(Integer recyclingAmount) { - this.recyclingAmount = recyclingAmount==null?0:recyclingAmount; + this.recyclingAmount = recyclingAmount; } public String getSendDate() { Index: ssts-web/src/main/webapp/disinfectsystem/print/print.js =================================================================== diff -u -r15772 -r16078 --- ssts-web/src/main/webapp/disinfectsystem/print/print.js (.../print.js) (revision 15772) +++ ssts-web/src/main/webapp/disinfectsystem/print/print.js (.../print.js) (revision 16078) @@ -415,7 +415,11 @@ value = formatMoney(value); } if(isUndefinedOrNullOrEmpty(value)){ - value = ''; + if(value === 0){ + //类型和值都相等,不处理,直接打印0 + }else{ + value = ''; + } } var style = getTableTdStyle(myObj.goodsTable,i); tableHtml += "" + value + " ";