Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java =================================================================== diff -u -r16645 -r16717 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 16645) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 16717) @@ -633,7 +633,7 @@ if(td.getAncestorID() != null && td.getAncestorID().longValue() != td.getId().longValue()){ ancestorTD = tousseDefinitionManager.getTousseDefinitionById(td.getAncestorID()); } - td = newDisinfectGoodsDefinition(ancestorTD,materialArry,application.getId()); + td = tousseDefinitionManager.newDisinfectGoodsDefinition(ancestorTD,materialArry,application.getId()); item.setTousseDefinitionId(td.getId()); } } @@ -1087,7 +1087,7 @@ } } TousseDefinition ancestorTD = tousseDefinitionManager.getTousseDefinitionById(entry.getKey()); - TousseDefinition newToussedefinition = newDisinfectGoodsDefinition(ancestorTD, array, recyclingApplication.getId()); + TousseDefinition newToussedefinition = tousseDefinitionManager.newDisinfectGoodsDefinition(ancestorTD, array, recyclingApplication.getId()); List applicationItems = new ArrayList(); TousseItem tousseItem = new TousseItem(); @@ -3815,66 +3815,6 @@ return resultJsonArray; } - public TousseDefinition newDisinfectGoodsDefinition(TousseDefinition ancestorTD,JSONArray materialItemsJson, Long invoicePlanId) { - if(invoicePlanId == null){ - throw new RuntimeException("申请单ID不能为空"); - } - // 此处找出来的父包定义,并不是在页面上选择的,而是包定义管理那里的 - if(ancestorTD == null){ - throw new RuntimeException("器械包定义已不存在!"); - } - TousseDefinition td = tousseDefinitionManager.getTousseDefinitionByNameTypeAndAPPID(ancestorTD.getName(), TousseDefinition.PACKAGE_TYPE_DISINFECTION, invoicePlanId.toString()); - if (td == null) { - td = new TousseDefinition(); - td.setInvoicePlanID(invoicePlanId); - } - td.setParentID(ancestorTD.getId());// 父亲id,页面选择的那个包定义 - td.setAncestorID(ancestorTD.getId());// 祖先id,器械包定义管理那里看到的 - td.setHandlerDepartCode(ancestorTD.getHandlerDepartCode()); - td.setHandlerDepartName(ancestorTD.getHandlerDepartName()); - td.setForDisplay(false); - td.setName(ancestorTD.getName()); - td.setIsRecycling(ancestorTD.getIsRecycling()); - td.setIsPacking(ancestorTD.getIsPacking()); - td.setIsPrint(ancestorTD.getIsPrint()); - td.setIsTraceable(ancestorTD.getIsTraceable()); - td.setIsReview(ancestorTD.getIsReview()); - td.setIsSterile(ancestorTD.getIsSterile()); - td.setTousseType(ancestorTD.getTousseType()); - td.setBarcodePaperType(ancestorTD.getBarcodePaperType()); - td.setWorkLoadStatisticalMethod(ancestorTD - .getWorkLoadStatisticalMethod()); - td.setIsTraceable(ancestorTD.getIsTraceable()); - td.setExpressRecycling(ancestorTD.getExpressRecycling()); - td.setIsCleanedEntirely(ancestorTD.getIsCleanedEntirely());// 默认为拆包清洗 - td.setIsApplyEntireTousse(ancestorTD.getIsApplyEntireTousse()); - // 消毒物品物包定义的包装以及灭菌程序分别为胶袋和无 - td.setPackageType(ancestorTD.getPackageType());// 默认的包装类型 - td.setSterilingMethod(ancestorTD.getSterilingMethod());// 默认的灭菌程序 - td.setTaskGroup(ancestorTD.getTaskGroup()); - //是否打印科室属性设置 - td.setIsPrintOrg(ancestorTD.getIsPrintOrg()); - //动态创建的消毒物品包定义的价格默认设置为祖先包的价格 - //td.setPrice(ancestorTD.getPrice()); - //是否打印材料属性设置 - td.setIsPrintMaterialForPacking(ancestorTD.getIsPrintMaterialForPacking()); - //装配是否扣减库存 - td.setAutoOutStockForPacking(ancestorTD.getAutoOutStockForPacking()); - List diposableGoodsItems = new ArrayList(); - for (DiposableGoodsInstance item : ancestorTD - .getDiposableGoodsItems()) { - DiposableGoodsInstance newItem = new DiposableGoodsInstance(); - newItem.setDiposableGoods(item.getDiposableGoods()); - newItem.setAmount(item.getAmount()); - diposableGoodsItems.add(newItem); - } - td.setDiposableGoodsItems(diposableGoodsItems); - - tousseDefinitionManager.saveTousseDefinition(td, null, - materialItemsJson.toString(),ancestorTD.getId()); - - return td; - } @Override public void newUnPackingTousseInstance(TousseDefinition td,TousseItem tousseItem,RecyclingApplication application , RecyclingRecord recyclingRecord){ if(application == null){ @@ -4633,7 +4573,7 @@ if(td.getAncestorID() != null && td.getAncestorID().longValue() != td.getId().longValue()){ ancestorTD = tousseDefinitionManager.getTousseDefinitionById(td.getAncestorID()); } - TousseDefinition newTousseDefinition = newDisinfectGoodsDefinition(ancestorTD,materialArry,plan.getId()); + TousseDefinition newTousseDefinition = tousseDefinitionManager.newDisinfectGoodsDefinition(ancestorTD,materialArry,plan.getId()); item.setTousseDefinitionId(newTousseDefinition.getId()); //是否生成包实例 if (TousseDefinition.STR_NO.equals(td.getIsPacking()) Index: ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java =================================================================== diff -u -r16708 -r16717 --- ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java (.../PackingManagerImpl.java) (revision 16708) +++ ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java (.../PackingManagerImpl.java) (revision 16717) @@ -5253,19 +5253,17 @@ // 传参方式待重构 // 自定义装配 - public void packingWithoutTask(JSONObject retObj, - HttpServletRequest request) { - SupplyRoomConfig supplyRoomConfigParams = supplyRoomConfigManager.getSystemParamsObj(); + public void packingWithoutTask(JSONObject retObj,HttpServletRequest request) { String inspector = request.getParameter("inspector");// 检查人 - String inspectorCode = request.getParameter("inspectorCode"); +// String inspectorCode = request.getParameter("inspectorCode"); String operator = request.getParameter("operator");// 配包者 String operatorCode = request.getParameter("operatorCode");// 配包者 String reviewer = request.getParameter("reviewer");// 审核者 String reviewerCode = request.getParameter("reviewerCode");// 审核者 String sterileUser = request.getParameter("sterileUser");// 灭菌员 String sterileCode = request.getParameter("sterileCode");// 灭菌员条码 String wrapper = request.getParameter("wrapper");// 配包者 - String wrapperCode = request.getParameter("wrapperCode");// 配包者 +// String wrapperCode = request.getParameter("wrapperCode");// 配包者 String packageType = request.getParameter("packageType");// 包装类型 String sterilingType = request.getParameter("sterilingType");// 灭菌程序 String sterilizer = request.getParameter("sterilizer");// 灭菌炉名称 @@ -5309,7 +5307,6 @@ String barcodes = "";// 待打印的条码标签 String virtualSeqNums = ""; - JSONArray toussesArray = new JSONArray(); boolean isDisinfection = false;// 是否为消毒物品 JSONArray materials = new JSONArray(); boolean isPrint = true; @@ -5319,16 +5316,24 @@ // 修改装配数量 barcodes += tousseName + ":"; Integer packAmount = Integer.parseInt(packAmountStr); - TousseDefinition td = tousseDefinitionManager - .getTousseDefinitionBySql(" where po.name = '" + tousseName - + "' and po.tousseType = '" + tousseType + "'"); + + String sql = String.format("where po.name = '%s' and po.tousseType = '%s'", tousseName,tousseType); + if(TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(tousseType)){ + sql += " and po.forDisplay = 1"; + } + TousseDefinition td = tousseDefinitionManager.getTousseDefinitionBySql(sql); if (td == null) { throw new RuntimeException(String.format("装配失败,未找到[%s]的包定义!", tousseName)); } if (td.isDisinfection()) { - throw new RuntimeException(String.format("装配失败,消毒物品不能自定义装配!", - tousseName)); + //非整包申请消毒物品不能自定义装配 + if(!td.applyEntireTousse()){ + throw new RuntimeException(String.format("装配失败,非整包申请的消毒物品不能自定义装配!", + tousseName)); + } + //创建消毒物品新定义 + td = buildDisinfectGoodsDefinition(td); } if (TousseDefinition.STR_NO.equals(td.getIsPrint())) { @@ -5340,45 +5345,30 @@ } } - if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(td - .getTousseType())) { + if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(td.getTousseType())) { isDisinfection = true; JSONObject material = new JSONObject(); - // 是否为消毒物品-->打印物品明细 - List materialInstanceList = td - .getMaterialInstances(); - if (materialInstanceList != null) { + // 是否为消毒物品-->打印物品明细s + List materialInstanceList = td.getMaterialInstances(); + if (CollectionUtils.isNotEmpty(materialInstanceList)) { for (MaterialInstance instance : materialInstanceList) { - - String name = instance.getMaterialDefinition().getName(); - if (StringUtils.isNotBlank(instance.getMaterialDefinition() - .getSpecification())) { - name += ("[" - + instance.getMaterialDefinition() - .getSpecification() + "]"); - } + MaterialDefinition md = instance.getMaterialDefinition(); + String name = CssdUtils.getMaterialName(md); material.put("name", name); material.put("count", instance.getCount()); material.put("isDiposable", "否"); materials.add(material); } } - List diposableGoodsInstanceList = td - .getDiposableGoodsItems(); - if (diposableGoodsInstanceList != null) { - for (DiposableGoodsInstance instance : diposableGoodsInstanceList) { - DisposableGoods disposableGoods = instance - .getDiposableGoods(); + List dgInstanceList = td.getDiposableGoodsItems(); + if (CollectionUtils.isNotEmpty(dgInstanceList)) { + for (DiposableGoodsInstance instance : dgInstanceList) { + DisposableGoods disposableGoods = instance.getDiposableGoods(); if (disposableGoods != null) { // 如果配置为打印,才打印一次性物品 if (disposableGoods.printInLabel()) { - String name = disposableGoods.getName(); - if (StringUtils.isNotBlank(disposableGoods - .getSpecification())) { - name += ("[" - + disposableGoods.getSpecification() + "]"); - } + String name = CssdUtils.getDiposableGoodsName(disposableGoods); material.put("name", name); material.put("amount", instance.getAmount()); material.put("isDiposable", "是"); @@ -5407,7 +5397,8 @@ packingRecord.setFrequency(frequency); packingRecord.setTaskGroup((taskGroup == null || taskGroup.trim() .length() == 0) ? td.getTaskGroup() : taskGroup); - packingRecord.setOrgUnitCoding(AcegiHelper.getLoginUser() + LoginUserData loginUser = AcegiHelper.getLoginUser(); + packingRecord.setOrgUnitCoding(loginUser .getOrgUnitCodingFromSupplyRoomConfig()); packingRecord.setDepart(depart); packingRecord.setDepartCoding(departCoding); @@ -5474,11 +5465,11 @@ tousseInstance.setPrice(price); tousseInstance.setFluctuationPrice(fPrice); - if (i == 0) { - barcodes += tousseInstance.getBarcode(); - } else { - barcodes += "," + tousseInstance.getBarcode(); + if (i != 0) { + barcodes += ","; } + barcodes += tousseInstance.getBarcode(); + tousseInstance.setReviewer(reviewer); tousseInstance.setType(BarcodeDevice.BARCODE_TYPE_PACKAGE); tousseInstance.setPackageType(packageType); @@ -5501,9 +5492,10 @@ tousseInstance.setValidUntil(validUntil); tousseInstance.setWarningUntil(warningUntil); - tousseInstance.setOrgUnitCoding(AcegiHelper.getLoginUser() + tousseInstance.setOrgUnitCoding(loginUser .getOrgUnitCodingFromSupplyRoomConfig()); - tousseInstance.setOrgUnitName(AcegiHelper.getLoginUser() + tousseInstance.setUnTraceableTousse(Constants.STR_YES.equals(td.getIsTraceable()) ? false : true); + tousseInstance.setOrgUnitName(loginUser .getOrgUnitNameCodingFromSupplyRoomConfig()); // 设置虚拟篮筐 if (packingAmountPerVirtualBasket != null @@ -5521,39 +5513,14 @@ e.printStackTrace(); } } - if (i == 0) { - virtualSeqNums += StringUtils.defaultIfEmpty(tousseInstance.getVirtualBasketSeqNum(), ""); - } else { - virtualSeqNums += "," + StringUtils.defaultIfEmpty(tousseInstance.getVirtualBasketSeqNum(), ""); + if (i != 0) { + virtualSeqNums += ","; } + virtualSeqNums += StringUtils.defaultIfEmpty(tousseInstance.getVirtualBasketSeqNum(), ""); + tousseInstanceManager.saveOrUpdate(tousseInstance); tousseInstanceList.add(tousseInstance); -// JSONArray subBarcodeArray = new JSONArray(); -// JSONArray subVirtualSeqNumArray = new JSONArray(); -// subBarcodeArray.add(tousseInstance.getBarcode()); -// subVirtualSeqNumArray.add(tousseInstance.getVirtualBasketSeqNum()); - -// JSONObject obj = CssdUtils.getTousseObjForPrint( -// td.getName(), getTousseDefinitionJson(td), subBarcodeArray, subVirtualSeqNumArray, tousseType, -// packageType,packageTypeAbbreviation, sterilingType, -// sterilizer, frequency, -// supplyRoomConfigParams.isPrintUserFullName(), -// operator, operatorCode, reviewer, reviewerCode,sterileUser,sterileCode, -// validUntilDateToPrint, -// sterileDateToPrint, -// markTousse, -// packingDate, -// false, -// isDisinfectionGoodsPrintExpirationDate, -// isPrint, isReview, isTraceable, isBigPackage, -// fixedBarcode, materialsJsonArray, -// null,supplierName, -// 0, -// 0,department, -// isPrintOrg,idCardDefinitionUseAmount,objectDao,td.getBarcodePaperType(),tousseInstance.getWashOperator(),tousseInstance.getWashOperatorCode(), -// tousseInstance.getWeight(),td.getPrintAmount()); -// toussesArray.add(obj); // 器械包标志牌处理 // 如果找到对应的器械包标识牌实例,则该器械包实例与标识牌实例关联,并退出循环,因为这里是1对1的关系 if (StringUtils.isNotBlank(idCardInstanceId)) { @@ -5563,7 +5530,6 @@ if (useAmount != null) { idCardDefinitionUseAmount = useAmount.toString(); } - break; } } @@ -5578,7 +5544,6 @@ if (StringUtils.isNotBlank(barcodes)) { String fixedBarcode = ""; if (!isTraceable) { - String tName = td.getName(); fixedBarcode = tousseInstanceManager .getTousseDefinitionFixedBarcode(td.getId()); } @@ -5598,6 +5563,26 @@ updatePackingConfigSession(request); } + + private TousseDefinition buildDisinfectGoodsDefinition(TousseDefinition td) { + JSONArray materialArry = new JSONArray(); + List mis = td.getMaterialInstances(); + if(mis != null){ + for (int i = 0; i < mis.size(); i++) { + MaterialInstance ms = mis.get(i); + //跟申请单那里统一,不然相同名称的包定义md5不一致 + if(ms.getCount() <= 0){ + continue; + } + JSONObject obj = new JSONObject(); + obj.put("name",CssdUtils.getMaterialName(ms.getMaterialDefinition())); + obj.put("count", ms.getCount()); + obj.put("tousseType", "器械"); + materialArry.add(obj); + } + } + return tousseDefinitionManager.newDisinfectGoodsDefinitionWithoutInvoicePlanId(td, materialArry); + } /** * 将用户打包时常用的字段记录到session中,传参方式待重构 Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r16592 -r16717 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 16592) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 16717) @@ -5938,7 +5938,7 @@ //器械包(含消毒物品、敷料包等)发货数量统计 if(StringUtils.isBlank(tousseType) || (!"器械材料".equals(tousseType) && !TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType) && !TYPE_AUTO_DEDUCTION.equals(tousseType))){ String invoiceAmountSql = "select '' as coding,i.settleAccountsDepart " - + "as depart,ii.amount,ii.tousseType,ii.tousseName,ii.invoicePlanID from Invoice i,InvoiceItem ii where i.id = ii.invoice_id " + + "as depart,ii.amount,ii.tousseType,ii.tousseName,ii.invoicePlanID,ii.tousseDefinitionId from Invoice i,InvoiceItem ii where i.id = ii.invoice_id " + " and " + getHandleDeptCodeSql("i.orgUnitCoding") + " " + " and (ii.amount is not null and ii.amount>0) "// 限制为只查包含器械包(含消毒物品、敷料包等)数量的 + " and " + SqlUtils.getStringFieldInCollectionsPredicate("ii.tousseType", allTousseType) @@ -5953,18 +5953,15 @@ String tousseTypeName = rs2.getString(4); String tousseName = rs2.getString(5); Long invoicePlanId = rs2.getLong(6); + Long tousseDefinitionId = rs2.getLong(7); // 如果是消毒物品,用统计数量替换包数量 if ("消毒物品".equals(tousseTypeName)) { - if (StringUtils.isNotBlank(tousseName) - && DatabaseUtil.isPoIdValid(invoicePlanId)) { - int disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount( - tousseName, invoicePlanId.toString()); - if (disinfectGoodsStatisticAmount > 0) { - tousseAmount = (tousseAmount * disinfectGoodsStatisticAmount); - } + int disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount(tousseDefinitionId); + if (disinfectGoodsStatisticAmount > 0) { + tousseAmount = (tousseAmount * disinfectGoodsStatisticAmount); } }else if(TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(tousseTypeName)&& !showCustonTousseAmount){ - tousseAmount = tousseAmount*getDisinfectGoodsStatisticAmount(tousseName,"" + invoicePlanId); + tousseAmount = tousseAmount*getDisinfectGoodsStatisticAmount(tousseDefinitionId); } if(tousseAmount > 0){ newMonthReport(code, dept,"2","数量统计", "器械包数量",tousseAmount,list); @@ -6398,22 +6395,17 @@ outEntryFilterSql += " and dgb.batchNumber = '"+batch+"'"; } - String caseSql = " CASE ii.tousseType WHEN '消毒物品' THEN (ii.tousseName + '_' + cast(ii.invoicePlanID as varchar)) WHEN '自定义器械包' THEN (ii.tousseName + '_' + cast(ii.invoicePlanID as varchar)) ELSE ii.tousseName END "; String returnGoodsTousseType = " CASE rr.type WHEN '一次性物品' THEN (rr.type) WHEN '器械包' THEN (td.toussetype) ELSE rr.type END "; - String dbName = dbConnection.getDatabase(); - if (dbConnection.isOracle()) { - caseSql = " CASE ii.tousseType WHEN '消毒物品' THEN (ii.tousseName || '_' || ii.invoicePlanID) WHEN '自定义器械包' THEN (ii.tousseName || '_' || ii.invoicePlanID) ELSE ii.tousseName END "; - } - String tousseSql = " (select i.settleAccountsDepart," + caseSql + " as name,sum(ii.amount) as amount,sum(ii.settlementPrice) as settlementprice,ii.tousseType as type" - + ",'' as batchNumber,null as expDate from invoice i,InvoiceItem ii " + String tousseSql = " (select i.settleAccountsDepart,ii.tousseName as name,sum(ii.amount) as amount,sum(ii.settlementPrice) as settlementprice,ii.tousseType as type" + + ",'' as batchNumber,null as expDate,ii.tousseDefinitionId as tousseDefinitionId from invoice i,InvoiceItem ii " + " where i.id = ii.invoice_id " + " and ii.diposable = '否' and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " + monthFilterSql + departFilterSql + typeFilterSql + goodsNameFilterSql - + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,ii.tousseType," + caseSql+")"; + + " and i.settleaccountsdepart is not null group by i.settleAccountsDepart,ii.tousseType,ii.tousseName,ii.tousseDefinitionId)"; String diposableGoodsSql = " "; String diposableGoodsTousseTypeSql = ""; @@ -6422,7 +6414,7 @@ } if(StringUtils.isBlank(typeSearch) || "一次性物品".equals(typeSearch) || "高值耗材".equals(typeSearch) || TYPE_AUTO_DEDUCTION.equals(typeSearch)){ diposableGoodsSql = " union all (select i.settleaccountsdepart,d.name as name,sum(d.amount) as amount,sum(d.fluctuationPrice*d.amount) as settlementprice,'一次性物品' as type" - + ",d.batch as batchNumber,dgbs.expDate from invoice i,DiposableGoodsItem d," + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs " + + ",d.batch as batchNumber,dgbs.expDate,0 as tousseDefinitionId from invoice i,DiposableGoodsItem d," + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs " + " where i.id = d.invoice_id and d.disposableGoodsBatchStockID=dgbs.id and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " +" and "+diposableGoodsItemPredicate +diposableGoodsTousseTypeSql @@ -6436,7 +6428,7 @@ { if(StringUtils.isBlank(typeSearch) || "一次性物品".equals(typeSearch)){ packingDisposableGoodsSql = " union all (select pr.orgUnitName,dgi.name as name,sum(dgi.amount) as amount,sum(dgi.fluctuationPrice*dgi.amount) as settlementprice,'一次性物品' as type" - + ",dgi.batch as batchNumber,dgbs.expDate from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId " + + ",dgi.batch as batchNumber,dgbs.expDate,0 as tousseDefinitionId from PackingRecord pr inner join DiposableGoodsItem dgi on pr.id = dgi.packingRecordId " + " inner join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on dgi.disposableGoodsBatchStockID=dgbs.id" + " where "+getHandleDeptCodeSql("pr.orgUnitCoding")+" " +" and "+packingDisposableGoodsTypeSql @@ -6451,7 +6443,7 @@ String materialInvoiceSql = " "; if (StringUtils.isBlank(typeSearch) || "器械材料".equals(typeSearch) || "高值耗材".equals(typeSearch)) { // 材料发货 - materialInvoiceSql = " union all (select i.settleAccountsDepart,ii.materialName,sum(ii.amount),sum(ii.settlementPrice),'材料' as type,'' as batchNumber,null as expDate " + materialInvoiceSql = " union all (select i.settleAccountsDepart,ii.materialName,sum(ii.amount),sum(ii.settlementPrice),'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " + " from MaterialInvoice i," + "MaterialInvoiceItem ii,materialDefinition d where i.id = ii.materialInvoice_id " + " and ii.materialDefinitionId = d.id and "+getHandleDeptCodeSql("i.orgUnitCoding")+" " @@ -6462,7 +6454,7 @@ + " group by i.settleaccountsdepart,ii.materialName) "; } // 材料退货 - String materialReturnSql = " union all (select rr.depart as settleaccountsdepart,ii.materialName,-sum(ii.amount),-sum(ii.settlementPrice),'材料' as type,'' as batchNumber,null as expDate " + String materialReturnSql = " union all (select rr.depart as settleaccountsdepart,ii.materialName,-sum(ii.amount),-sum(ii.settlementPrice),'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " + " from ReturnMaterialRecord rr,materialDefinition d," + "ReturnMaterialItem ii where rr.id = ii.returnMaterialRecord_ID " + " and ii.materialDefinitionId = d.id and "+getHandleDeptCodeSql("rr.handleDepartCode")+" " @@ -6475,7 +6467,7 @@ //退货 String returnGoodsSql = " union all (select rr.depart as settleaccountsdepart,ri.toussename as name," + "-sum(ri.amount) as amount,-sum(ri.settlementPrice) as settlementprice,"+returnGoodsTousseType+" as type" - + ",ri.batchNumber as batchNumber,dgbs.expDate from " + ReturnGoodsRecord.class.getSimpleName() + " rr inner join " + + ",ri.batchNumber as batchNumber,dgbs.expDate,0 as tousseDefinitionId from " + ReturnGoodsRecord.class.getSimpleName() + " rr inner join " + ReturnGoodsItem.class.getSimpleName()+ " ri on rr.id = ri.returngoodsrecord_id " + " left join " + TousseDefinition.class.getSimpleName() + " td on td.id = ri.tousseDefinition_id" + " left join " + DisposableGoodsBatchStock.class.getSimpleName() + " dgbs on ri.disposableGoodsBatchStockID=dgbs.id" @@ -6484,11 +6476,11 @@ +" and "+returnGoodsItemPredicate + " group by rr.depart,ri.toussename,"+returnGoodsTousseType+",ri.batchNumber,dgbs.expDate) "; - String lostMaterial = " union all (select r.depart,r.materialName,sum(r.additionalAmount),sum(r.additionalAmount * r.materialCost),'材料' as type,'' as batchNumber,null as expDate " + String lostMaterial = " union all (select r.depart,r.materialName,sum(r.additionalAmount),sum(r.additionalAmount * r.materialCost),'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " + " from RecyclingError r,materialDefinition m where r.materialDefinitionId = m.id and r.errorType = '缺失' and r.materialName != '器械包标识牌' and r.additionalAmount > 0 and "+getHandleDeptCodeSql("r.handleDepartCode")+" " + lostMaterialFilterSql + "group by r.depart,r.materialName ) "; - String damageMaterial = " union all (select i.depart,i.materialName,sum(i.additionalAmount),sum(i.materialCost*i.additionalAmount),'材料' as type,'' as batchNumber,null as expDate " + String damageMaterial = " union all (select i.depart,i.materialName,sum(i.additionalAmount),sum(i.materialCost*i.additionalAmount),'材料' as type,'' as batchNumber,null as expDate,0 as tousseDefinitionId " + "from RecyclingDamageItem i,MaterialDefinition m where i.materialDefinitionId = m.id " + "and i.additionalAmount > 0 and "+getHandleDeptCodeSql("i.handleDepartCode")+" " + damageFilterSql + " group by i.departCoding,i.depart,i.materialName ) "; @@ -6497,22 +6489,22 @@ if(TYPE_AUTO_DEDUCTION.equals(typeSearch)){ supplyRoomTousseTypeSql = String.format(" and rr.type='%s' ", InvoiceItem.TYPE_AUTO_DEDUCTION); } - String supplyRoomDiposableGoodsSql = " union all (select rr.depart as settleaccountsdepart,rri.goodsName,sum(rri.amount),sum(rri.price*rri.amount) as settlementprice,rri.type as type,dbs.batchNumber as batchNumber,dbs.expDate " + String supplyRoomDiposableGoodsSql = " union all (select rr.depart as settleaccountsdepart,rri.goodsName,sum(rri.amount),sum(rri.price*rri.amount) as settlementprice,rri.type as type,dbs.batchNumber as batchNumber,dbs.expDate,0 as tousseDefinitionId " +" from ReceiveRecord rr,ReceiveRecordItem rri left join " + DisposableGoodsBatchStock.class.getSimpleName() + " dbs " +" on rri.diposableGoodBatchStock_id = dbs.id left join DisposableGoods d on d.id = rri.disposableGoodsId where rr.id = rri.receiveRecord_id and "+getHandleDeptCodeSql("rr.departCoding")+" " +supplyRoomDiposableGoodsFilterSql +supplyRoomTousseTypeSql +" and "+receiveRecordItemPredicate + " group by rr.depart,rri.goodsName,rri.amount,rri.type,dbs.batchNumber,dbs.expDate) "; // 调拨出库 - String appropriateOutDiposableGoodsSql = " union all (select oge.targetOrgUnitName as settleaccountsdepart,ged.goodsName,sum(ged.amount),sum(ged.price*ged.amount) as settlementprice,'一次性物品' as type,dgb.batchNumber as batchNumber,dgb.expDate " + String appropriateOutDiposableGoodsSql = " union all (select oge.targetOrgUnitName as settleaccountsdepart,ged.goodsName,sum(ged.amount),sum(ged.price*ged.amount) as settlementprice,'一次性物品' as type,dgb.batchNumber as batchNumber,dgb.expDate,0 as tousseDefinitionId " +" from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID inner join DisposableGoodsBatch dgb on ged.disposableGoodsBatchID=dgb.id inner join DisposableGoods dg on dgb.diposablegoods_id = dg.id " +" where oge.type ='退库单' and oge.subType='调拨出库' and "+getHandleDeptCodeSql("oge.orgUnitCode")+" " +outEntryFilterSql +" and "+outEntryPredicate + " group by oge.targetOrgUnitName, ged.goodsName,dgb.batchNumber,dgb.expDate) "; // 盘亏出库 - String stocktakeOutDiposableGoodsSql = " union all (select oge.orgUnitName as settleaccountsdepart,ged.goodsName,sum(ged.amount),sum(ged.price*ged.amount) as settlementprice,'一次性物品' as type,dgb.batchNumber as batchNumber,dgb.expDate " + String stocktakeOutDiposableGoodsSql = " union all (select oge.orgUnitName as settleaccountsdepart,ged.goodsName,sum(ged.amount),sum(ged.price*ged.amount) as settlementprice,'一次性物品' as type,dgb.batchNumber as batchNumber,dgb.expDate,0 as tousseDefinitionId " +" from GodownEntry oge inner join GodownEntryDiposableGoodsItem ged on oge.id = ged.godownEntryID inner join DisposableGoodsBatch dgb on ged.disposableGoodsBatchID=dgb.id inner join DisposableGoods dg on dgb.diposablegoods_id = dg.id " +" where oge.type ='退库单' and oge.subType='盘亏出库' and "+getHandleDeptCodeSql("oge.orgUnitCode")+" " +outEntryFilterSql @@ -6569,21 +6561,16 @@ double settlementPrice = rs.getDouble("settlementprice"); int amount = rs.getInt("amount"); Date expDate = rs.getTimestamp("expDate"); + int disinfectGoodsStatisticAmount = 0; int totalAmount = amount; DepartmentMonthDetailItem mdi = new DepartmentMonthDetailItem(); if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(type) || (TousseDefinition.PACKAGE_TYPE_CUSTOM.equals(type) && !showCustonTousseAmount)) { - Integer _index = goodsName.lastIndexOf("_"); - if (_index > 0) { - String name = goodsName.substring(0, _index); - String invoiceplan_id = goodsName.substring( - _index + 1, goodsName.length()); - if (DatabaseUtil.isPoIdValid(invoiceplan_id)) { - disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount( - name, invoiceplan_id); + String toussedefinitionId = rs.getString("tousseDefinitionId"); + if (DatabaseUtil.isPoIdValid(toussedefinitionId)) { + disinfectGoodsStatisticAmount = getDisinfectGoodsStatisticAmount(Long.valueOf(toussedefinitionId)); } - } } if (disinfectGoodsStatisticAmount > 0){ totalAmount = (amount * disinfectGoodsStatisticAmount); @@ -6671,17 +6658,19 @@ return datas; } - private int getDisinfectGoodsStatisticAmount(String disinfectGoodsName,String invoicePlanID) { + /** + * 获取消毒物品材料数量,没有申请单的可能是自定义装配生成的 + * @param disinfectGoodsName + * @param invoicePlanID + * @return + */ + private int getDisinfectGoodsStatisticAmount(Long toussedefinitionId) { int statisticsAmount = 0; - if(StringUtils.isBlank(invoicePlanID)){ + if(toussedefinitionId == null){ return statisticsAmount; } String sql = "select sum(i.count) from Toussedefinition t,MaterialInstance i " - + "where t.id = i.tousse_id and t.name = '" + disinfectGoodsName - + "'"; - - sql += " and t.invoicePlanID = " + invoicePlanID; - + + "where t.id = i.tousse_id and t.id = " + toussedefinitionId; ResultSet rs = objectDao.executeSql(sql); if(rs != null){ try { Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java =================================================================== diff -u -r16316 -r16717 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java (.../RecyclingApplicationManager.java) (revision 16316) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java (.../RecyclingApplicationManager.java) (revision 16717) @@ -168,8 +168,6 @@ public void interfereInvoicePlan(String result); - public TousseDefinition newDisinfectGoodsDefinition(TousseDefinition ancestorTD, - JSONArray materialItemsJson, Long invoicePlanId); /** * 质量监测不合格器械包回收 * @param tousseInstanceId 器械包id Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java =================================================================== diff -u -r16592 -r16717 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 16592) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/action/JasperreportsAction.java (.../JasperreportsAction.java) (revision 16717) @@ -66,7 +66,6 @@ import com.forgon.disinfectsystem.entity.stocktakerecordmanager.StockTakeRecord; import com.forgon.disinfectsystem.entity.useRecord.UseDiposableGoodsItem; import com.forgon.disinfectsystem.entity.useRecord.UseRecord; -import com.forgon.disinfectsystem.jasperreports.javabeansource.DamageErrorMontBean; import com.forgon.disinfectsystem.jasperreports.javabeansource.EighteenQuotaBean; import com.forgon.disinfectsystem.jasperreports.javabeansource.ForeignTousseAfterUseDeliveryVO; import com.forgon.disinfectsystem.jasperreports.javabeansource.ForeignTousseSterilizationMonitorAndDeliveryVO; Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java =================================================================== diff -u -r16632 -r16717 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 16632) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 16717) @@ -793,6 +793,10 @@ String displayName = tousseDefinition.getName(); boolean isDisplayNameExist = false; for (Map map : mapList) { + //某某医院发现包名称为null的情况 + if(map.get("displayName") == null){ + continue; + } if (StringUtils.equals(map.get("displayName").toString(), displayName)) { isDisplayNameExist = true; @@ -2469,5 +2473,91 @@ return JSONUtil.buildJsonObject(false, "已存在:" + tousseItemVo.getTousseName() + ",请不要重复添加!"); } } + + /** + * 创建消毒物品定义,该定义invoicePlanId为null,用于自定义装配 + * @return + */ + public TousseDefinition newDisinfectGoodsDefinitionWithoutInvoicePlanId(TousseDefinition ancestorTD,JSONArray materialItemsJson){ + if(ancestorTD == null){ + throw new RuntimeException("器械包定义不存在!"); + } + String sql = String.format("where po.name = '%s' and po.forDisplay = 0 and po.materialsMD5 = '%s' " + + "and po.ancestorID = %s and po.invoicePlanID is null and po.tousseType = '%s'", + ancestorTD.getName(),ancestorTD.getMaterialsMD5(),ancestorTD.getId(), + TousseDefinition.PACKAGE_TYPE_DISINFECTION); + TousseDefinition td = (TousseDefinition)objectDao.getBySql(TousseDefinition.class.getSimpleName(), sql); + if(td == null){ + td = new TousseDefinition(); + setTousseDefinitionProperty(ancestorTD, materialItemsJson, td); + } + return td; + } + + + public TousseDefinition newDisinfectGoodsDefinition(TousseDefinition ancestorTD,JSONArray materialItemsJson, Long invoicePlanId) { + if(invoicePlanId == null){ + throw new RuntimeException("申请单ID不能为空"); + } + // 此处找出来的父包定义,并不是在页面上选择的,而是包定义管理那里的 + if(ancestorTD == null){ + throw new RuntimeException("器械包定义已不存在!"); + } + TousseDefinition td = getTousseDefinitionByNameTypeAndAPPID(ancestorTD.getName(), TousseDefinition.PACKAGE_TYPE_DISINFECTION, invoicePlanId.toString()); + if (td == null) { + td = new TousseDefinition(); + td.setInvoicePlanID(invoicePlanId); + } + setTousseDefinitionProperty(ancestorTD, materialItemsJson, td); + return td; + } + private void setTousseDefinitionProperty(TousseDefinition ancestorTD, + JSONArray materialItemsJson, TousseDefinition td) { + td.setParentID(ancestorTD.getId());// 父亲id,页面选择的那个包定义 + td.setAncestorID(ancestorTD.getId());// 祖先id,器械包定义管理那里看到的 + td.setHandlerDepartCode(ancestorTD.getHandlerDepartCode()); + td.setHandlerDepartName(ancestorTD.getHandlerDepartName()); + td.setForDisplay(false); + td.setName(ancestorTD.getName()); + td.setIsRecycling(ancestorTD.getIsRecycling()); + td.setIsPacking(ancestorTD.getIsPacking()); + td.setIsPrint(ancestorTD.getIsPrint()); + td.setIsTraceable(ancestorTD.getIsTraceable()); + td.setIsReview(ancestorTD.getIsReview()); + td.setIsSterile(ancestorTD.getIsSterile()); + td.setTousseType(ancestorTD.getTousseType()); + td.setBarcodePaperType(ancestorTD.getBarcodePaperType()); + td.setWorkLoadStatisticalMethod(ancestorTD + .getWorkLoadStatisticalMethod()); + td.setIsTraceable(ancestorTD.getIsTraceable()); + td.setExpressRecycling(ancestorTD.getExpressRecycling()); + td.setIsCleanedEntirely(ancestorTD.getIsCleanedEntirely());// 默认为拆包清洗 + td.setIsApplyEntireTousse(ancestorTD.getIsApplyEntireTousse()); + // 消毒物品物包定义的包装以及灭菌程序分别为胶袋和无 + td.setPackageType(ancestorTD.getPackageType());// 默认的包装类型 + td.setSterilingMethod(ancestorTD.getSterilingMethod());// 默认的灭菌程序 + td.setTaskGroup(ancestorTD.getTaskGroup()); + //是否打印科室属性设置 + td.setIsPrintOrg(ancestorTD.getIsPrintOrg()); + //动态创建的消毒物品包定义的价格默认设置为祖先包的价格 + //td.setPrice(ancestorTD.getPrice()); + //是否打印材料属性设置 + td.setIsPrintMaterialForPacking(ancestorTD.getIsPrintMaterialForPacking()); + //装配是否扣减库存 + td.setAutoOutStockForPacking(ancestorTD.getAutoOutStockForPacking()); + List diposableGoodsItems = new ArrayList(); + for (DiposableGoodsInstance item : ancestorTD + .getDiposableGoodsItems()) { + DiposableGoodsInstance newItem = new DiposableGoodsInstance(); + newItem.setDiposableGoods(item.getDiposableGoods()); + newItem.setAmount(item.getAmount()); + diposableGoodsItems.add(newItem); + } + td.setDiposableGoodsItems(diposableGoodsItems); + + saveTousseDefinition(td, null, + materialItemsJson.toString(),ancestorTD.getId()); + } + } Index: ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java =================================================================== diff -u -r16668 -r16717 --- ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 16668) +++ ssts-recyclingrecord/src/main/java/com/forgon/disinfectsystem/recyclingrecord/service/RecyclingRecordManagerImpl.java (.../RecyclingRecordManagerImpl.java) (revision 16717) @@ -1689,7 +1689,7 @@ obj.put("count", mi.getCount()); materialArray.add(obj); } - createInstanceTD = recyclingApplicationManager.newDisinfectGoodsDefinition(td, + createInstanceTD = tousseDefinitionManager.newDisinfectGoodsDefinition(td, materialArray, application.getId()); appItem.setTousseDefinitionId(createInstanceTD.getId()); Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java =================================================================== diff -u -r16329 -r16717 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 16329) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 16717) @@ -326,4 +326,21 @@ * @return */ JSONObject validateRepeatedTd(Map> checkList, TousseItemVo tousseItemVo); + + + /** + * 创建消毒物品包定义 + * @param ancestorTD + * @param materialItemsJson + * @param invoicePlanId + * @return + */ + public TousseDefinition newDisinfectGoodsDefinition(TousseDefinition ancestorTD, + JSONArray materialItemsJson, Long invoicePlanId); + + /** + * 创建消毒物品定义,该定义invoicePlanId为null,用于自定义装配 + * @return + */ + public TousseDefinition newDisinfectGoodsDefinitionWithoutInvoicePlanId(TousseDefinition ancestorTD,JSONArray materialItemsJson); } Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/tousse/tousseForm.js =================================================================== diff -u -r16646 -r16717 --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/tousse/tousseForm.js (.../tousseForm.js) (revision 16646) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/tousse/tousseForm.js (.../tousseForm.js) (revision 16717) @@ -1135,6 +1135,7 @@ },{ columnWidth : .25, layout : 'form', + labelWidth : 120, items:[{ xtype : 'combo', fieldLabel : '自定义装配打印标签',