Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java =================================================================== diff -u -r28369 -r29100 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 28369) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 29100) @@ -654,6 +654,16 @@ JSONArray materialItemsJson, Long invoicePlanId); /** + * 创建自定义器械包定义. + * @param ancestorTD + * @param materialItemsJson + * @param invoicePlanId + * @return + */ + public TousseDefinition newCustomTousseDefinition(TousseDefinition ancestorTD, + JSONArray materialItemsJson, Long invoicePlanId); + + /** * 创建消毒物品定义,该定义invoicePlanId为null, * 1.用于自定义装配. * 2.用于退货重发. Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java =================================================================== diff -u -r29030 -r29100 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 29030) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 29100) @@ -1343,16 +1343,22 @@ /** * 根据申请的器械包自动生成自定义器械申请记录 * - * @param tousseNameAndAmount - * 器械包名key-value,不能包含一次性物品 + * @param applyCustomTousseMap + * 自定义器械包map(key为包定义id,value为数量) * @return List */ @Override public List createRecyclingApplicationByCustomTousse( - Map tousseNameAndAmount, String applicant, + Map applyCustomTousseMap, String applicant, String depart, String departCoding, String remark,Date applicationCreateDate,Map urgentIdAndAmount,Long useRecordId) { List list = new ArrayList(); - for (Entry entry : tousseNameAndAmount.entrySet()) { + for (Entry entry : applyCustomTousseMap.entrySet()) { + Long tdId = entry.getKey(); + TousseDefinition sourceTD = tousseDefinitionManager.get(tdId); + if(sourceTD == null){ + throw new RuntimeException("ID="+ tdId+"的器械包已经不存在!"); + } + Integer amount = entry.getValue(); RecyclingApplication recyclingApplication = new RecyclingApplication(); recyclingApplication .setType(RecyclingApplication.TYPE_CUSTOM_TOUSSE_APPLIACTION_FORM); @@ -1361,10 +1367,6 @@ recyclingApplication.setDepartCoding(departCoding); recyclingApplication.setSettleAccountsDepart(depart); recyclingApplication.setSettleAccountsDepartCoding(departCoding); - recyclingApplication.setIncludeRecyclingItems(InvoicePlan.SIGNED_TRUE); - recyclingApplication - .setRecyclingStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE); - recyclingApplication.setOrderByFiled(InvoicePlan.RECYCLING_AWAITRECYCLE); recyclingApplication.setReaders(";ORGUNIT_" + recyclingApplication.getDepartCoding() + ";"); recyclingApplication.setSerialNumber(serialNumManager @@ -1388,12 +1390,6 @@ if (remark != null) { recyclingApplication.setRemark(remark); } - //TODO 待重构 - objectDao.saveOrUpdate(recyclingApplication); - TousseDefinition sourceTD = tousseDefinitionManager.get(entry.getKey()); - if(sourceTD == null){ - throw new RuntimeException("ID="+ entry.getKey()+"的器械包已经不存在!"); - } JSONArray array = new JSONArray(); for (MaterialInstance ms : sourceTD.getMaterialInstances()) { if(ms.getMaterialDefinition() != null){ @@ -1404,15 +1400,36 @@ array.add(obj); } } - TousseDefinition ancestorTD = tousseDefinitionManager.get(entry.getKey()); - TousseDefinition newToussedefinition = tousseDefinitionManager.newDisinfectGoodsDefinition(ancestorTD, array, recyclingApplication.getId()); + TousseDefinition ancestorTD = null; + if(DatabaseUtil.isPoIdValid(sourceTD.getAncestorID())){ + ancestorTD = tousseDefinitionManager.get(sourceTD.getAncestorID()); + if(ancestorTD == null){ + ancestorTD = sourceTD; + } + }else{ + ancestorTD = sourceTD; + } + if(ancestorTD.recycling()){ + recyclingApplication.setIncludeRecyclingItems(InvoicePlan.SIGNED_TRUE); + recyclingApplication + .setRecyclingStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE); + recyclingApplication.setOrderByFiled(InvoicePlan.RECYCLING_AWAITRECYCLE); + }else{ + recyclingApplication.setIncludeRecyclingItems(InvoicePlan.SIGNED_FALSE); + recyclingApplication + .setRecyclingStatus(null); + recyclingApplication.setOrderByFiled(InvoicePlan.DELIVER_AWAITDELIVER); + } + //TODO 待重构 + objectDao.saveOrUpdate(recyclingApplication); + TousseDefinition newToussedefinition = tousseDefinitionManager.newCustomTousseDefinition(ancestorTD, array, recyclingApplication.getId()); List applicationItems = new ArrayList(); TousseItem tousseItem = new TousseItem(); String tousseName = newToussedefinition.getName(); tousseItem.setTousseName(tousseName); tousseItem.setAmount(0); - tousseItem.setEditAmount(entry.getValue()); + tousseItem.setEditAmount(amount); tousseItem.setInvoicePlan(recyclingApplication); tousseItem.setDiposable(TousseItem.DIPOSABLE_NO); tousseItem.setTousseType(newToussedefinition.getTousseType()); @@ -1430,7 +1447,7 @@ tousseItem.setIsApplyEntireTousse(newToussedefinition.getIsApplyEntireTousse()); boolean isThereIDCard = tousseDefinitionManager.isThereIDCard(newToussedefinition); tousseItem.setIsThereIdentificationCard(isThereIDCard?"是":"否"); - Integer urgentAmount = urgentIdAndAmount.get(entry.getKey()); + Integer urgentAmount = urgentIdAndAmount.get(tdId); tousseItem.setUrgentAmount(urgentAmount); if(urgentAmount != null && urgentAmount > 0){ tousseItem.setUrgent(com.forgon.Constants.STR_YES); Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java =================================================================== diff -u -r28928 -r29100 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java (.../RecyclingApplicationManager.java) (revision 28928) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManager.java (.../RecyclingApplicationManager.java) (revision 29100) @@ -153,7 +153,7 @@ ,String applicant,String orgCoding,String orgUnitName,Date applicationDate,boolean useOrginalInvoiceplanOfForeignTousse); public List createRecyclingApplicationByCustomTousse( - Map tousseNameAndAmount, String applicant, + Map applyCustomTousseMap, String applicant, String depart, String departCoding, String remark,Date applicationCreateDate,Map urgentNameAmount,Long useRecordId); public void getPrintObjectOfDept(JSONObject printScope, Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java =================================================================== diff -u -r29057 -r29100 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 29057) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 29100) @@ -3107,6 +3107,7 @@ } return materialArry; } + private void setTousseDefinitionProperty(TousseDefinition ancestorTD, JSONArray materialItemsJson, TousseDefinition td) { td.setParentID(ancestorTD.getId());// 父亲id,页面选择的那个包定义 @@ -3172,6 +3173,56 @@ } @Override + public TousseDefinition newCustomTousseDefinition( + TousseDefinition ancestorTD, JSONArray materialItemsJson, + Long invoicePlanId) { + TousseDefinition td = new TousseDefinition(); + setCustomTousseDefinitionProperty(ancestorTD, materialItemsJson, td); + td.setInvoicePlanID(invoicePlanId); + return td; + } + + private void setCustomTousseDefinitionProperty(TousseDefinition ancestorTD, + JSONArray materialItemsJson, TousseDefinition td) { + td.setAncestorID(ancestorTD.getId());// 祖先id,器械包定义管理那里看到的 + td.setForDisplay(false); + td.setName(ancestorTD.getName()); + td.setIsRecycling(ancestorTD.getIsRecycling()); + td.setSpelling(ancestorTD.getSpelling()); + td.setWbCode(ancestorTD.getWbCode()); + td.setPrice(ancestorTD.getPrice()); + td.setTaskGroup(ancestorTD.getTaskGroup()); + td.setSterilingMethod(ancestorTD.getSterilingMethod()); + // 默认的包装类型 + td.setPackageType(ancestorTD.getPackageType()); + td.setBarcodePaperType(ancestorTD.getBarcodePaperType()); + td.setIsCleanedEntirely(ancestorTD.getIsCleanedEntirely()); + td.setPrintOrgSource(ancestorTD.getPrintOrgSource()); + td.setIsReview(ancestorTD.getIsReview()); + td.setRegistUseRecordAfterSigned(ancestorTD.getRegistUseRecordAfterSigned()); + + td.setIsSterile(ancestorTD.getIsSterile()); + td.setIsInvoice(ancestorTD.getIsInvoice()); + td.setTousseType(ancestorTD.getTousseType()); + td.setWorkLoadStatisticalMethod(ancestorTD + .getWorkLoadStatisticalMethod()); + td.setIsApplyEntireTousse(ancestorTD.getIsApplyEntireTousse()); + td.setInvoiceAmountMode(ancestorTD.getInvoiceAmountMode()); + List diposableGoodsItems = new ArrayList(); + for (DiposableGoodsInstance item : ancestorTD + .getDiposableGoodsItems()) { + DiposableGoodsInstance newItem = new DiposableGoodsInstance(); + newItem.setDiposableGoods(item.getDiposableGoods()); + newItem.setAmount(item.getAmount()); + newItem.setTousse(td); + diposableGoodsItems.add(newItem); + } + td.setDiposableGoodsItems(diposableGoodsItems); + + saveTousseDefinition(td,materialItemsJson.toString(),ancestorTD.getId()); + } + + @Override public JSONArray loadAllComboTousseDefinition(String spell,String comboTousseOrgUnitCoding,Map> idToUnitCodeSetMap) { String spellSql = ""; String comboTousseOrgUnitCodingSql = ""; Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recyclingapplication/RecyclingApplication.java =================================================================== diff -u -r28928 -r29100 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recyclingapplication/RecyclingApplication.java (.../RecyclingApplication.java) (revision 28928) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recyclingapplication/RecyclingApplication.java (.../RecyclingApplication.java) (revision 29100) @@ -291,19 +291,19 @@ List tousseTransitionPlanItemList = new ArrayList(); //循环要转换申请单的包实例 for(TousseInstance tousseInstance : tousseInstanceWillBeConvertedTousseItemList){ - TousseDefinition td = tousseInstance.getTousseDefinition(); - if(td == null){ + TousseDefinition tdOfTousseInstance = tousseInstance.getTousseDefinition(); + if(tdOfTousseInstance == null){ throw new RuntimeException("未找到" + tousseInstance.getTousseName() + "的包定义数据!"); } //如果申请单的单类型是自定义器械包申请单、但包实例的包定义类型不是自定义器械包时,continue if(StringUtils.equals(InvoicePlan.TYPE_CUSTOM_TOUSSE_APPLIACTION_FORM, getType())){ - if(!td.isCustomTousse()){ + if(!tdOfTousseInstance.isCustomTousse()){ continue; } }else{ //或者申请单的单类型不是自定义器械包申请单、但包实例的包定义类型又是自定义器械包时,continue - if(td.isCustomTousse()){ + if(tdOfTousseInstance.isCustomTousse()){ continue; } } @@ -315,14 +315,21 @@ //包实例录使用记录时所选的加急级别 UrgentLevel urgentLevelOfTousseInstance = tousseInstance.getUrgentLevelForUseRecord(); //包实例所属的包定义id - Long tdId = td.getId(); + Long tdId = tdOfTousseInstance.getId(); TousseItem currentTousseItem = null; if(CollectionUtils.isNotEmpty(tousseItemList)){ - boolean foundTousseItem = false; + boolean existsTousseItem = false; //循环之前的每个申请项 for (TousseItem tousseItem : tousseItemList) { Long tousseItemTousseDefinitionId = tousseItem.getTousseDefinitionId(); TousseDefinition tousseItemCutomerTd = (TousseDefinition)objectDao.getBySql(TousseDefinition.class.getSimpleName(), " where id=" + tousseItemTousseDefinitionId); + //如果是录入到使用记录的包实例及申请项的类型自定义器械包,且名称相同,又不是合并申请单时 + if(tousseItemCutomerTd.isCustomTousse() && tdOfTousseInstance.isCustomTousse() + && StringUtils.equals(tousseItemCutomerTd.getName(), tdOfTousseInstance.getName()) && !otherUseRecord){ + currentTousseItem = tousseItem; + existsTousseItem = true; + break; + } //自定义器械包只能用祖先id进行比较(申请项的包定义id为根据申请单创建的包定义id,而包实例的) if(tousseItemCutomerTd.getAncestorID() != null && (tdId.longValue() == tousseItemCutomerTd.getAncestorID().longValue())){ //是否为第二个或第二个以后的使用记录转换合并到本申请单 @@ -359,12 +366,12 @@ tousseItem.setPrice(tousseInstance.getTousseDefinition().getPrice()); objectDao.saveOrUpdate(tousseItem); currentTousseItem = tousseItem; - foundTousseItem = true; + existsTousseItem = true; break; } } - if(foundTousseItem == false){ + if(existsTousseItem == false){ currentTousseItem = new TousseItem(); currentTousseItem.setDiposable(TousseItem.DIPOSABLE_NO); currentTousseItem.setInvoicePlan(this); @@ -374,24 +381,24 @@ if(Constants.STR_YES.equals(tousseInstance.getIsUrgentForUseRecord())){ if(needAddUrgentAmountFromTousseInstance){ currentTousseItem.setUrgentAmount(currentTousseItem.getUrgentAmount() + 1); - currentTousseItem.setRowPrice(MathTools.mul(td.getPrice() , 1).doubleValue()); + currentTousseItem.setRowPrice(MathTools.mul(tdOfTousseInstance.getPrice() , 1).doubleValue()); } } - currentTousseItem.setUnit(td.getUnit()); - currentTousseItem.setIsTraceable(td.getIsTraceable()); - currentTousseItem.setPrice(td.getPrice()); - currentTousseItem.setTousseType(td.getTousseType()); - currentTousseItem.setTousseDefinitionId(td.getId()); - currentTousseItem.setMaterialAmount(td.getMaterialAmount()); - currentTousseItem.setAncestorID(td.getAncestorID()); + currentTousseItem.setUnit(tdOfTousseInstance.getUnit()); + currentTousseItem.setIsTraceable(tdOfTousseInstance.getIsTraceable()); + currentTousseItem.setPrice(tdOfTousseInstance.getPrice()); + currentTousseItem.setTousseType(tdOfTousseInstance.getTousseType()); + currentTousseItem.setTousseDefinitionId(tdOfTousseInstance.getId()); + currentTousseItem.setMaterialAmount(tdOfTousseInstance.getMaterialAmount()); + currentTousseItem.setAncestorID(tdOfTousseInstance.getAncestorID()); //设置发货数量依据(取包定义的发货数量依据) - currentTousseItem.setInvoiceAmountMode(td.getInvoiceAmountMode()); - currentTousseItem.setIsInvoice(td.getIsInvoice()); - currentTousseItem.setIsCleanedEntirely(td.getIsCleanedEntirely()); - currentTousseItem.setExpressRecycling(td.getExpressRecycling()); - currentTousseItem.setIsRecycling(td.getIsRecycling()); - currentTousseItem.setIsApplyEntireTousse(td.getIsApplyEntireTousse()); - if(td.isIDCardDisabled() || StringUtils.isBlank(td.getIsDisableIDCard())){ + currentTousseItem.setInvoiceAmountMode(tdOfTousseInstance.getInvoiceAmountMode()); + currentTousseItem.setIsInvoice(tdOfTousseInstance.getIsInvoice()); + currentTousseItem.setIsCleanedEntirely(tdOfTousseInstance.getIsCleanedEntirely()); + currentTousseItem.setExpressRecycling(tdOfTousseInstance.getExpressRecycling()); + currentTousseItem.setIsRecycling(tdOfTousseInstance.getIsRecycling()); + currentTousseItem.setIsApplyEntireTousse(tdOfTousseInstance.getIsApplyEntireTousse()); + if(tdOfTousseInstance.isIDCardDisabled() || StringUtils.isBlank(tdOfTousseInstance.getIsDisableIDCard())){ currentTousseItem.setIsThereIdentificationCard(Constants.STR_NO); }else{ currentTousseItem.setIsThereIdentificationCard(Constants.STR_YES); @@ -412,22 +419,22 @@ if(Constants.STR_YES.equals(tousseInstance.getIsUrgentForUseRecord())){ currentTousseItem.setUrgentAmount(currentTousseItem.getUrgentAmount() + 1); } - currentTousseItem.setUnit(td.getUnit()); - currentTousseItem.setIsTraceable(td.getIsTraceable()); - currentTousseItem.setPrice(td.getPrice()); - currentTousseItem.setRowPrice(MathTools.mul(td.getPrice() , 1).doubleValue()); - currentTousseItem.setTousseType(td.getTousseType()); - currentTousseItem.setTousseDefinitionId(td.getId()); - currentTousseItem.setMaterialAmount(td.getMaterialAmount()); - currentTousseItem.setAncestorID(td.getAncestorID()); + currentTousseItem.setUnit(tdOfTousseInstance.getUnit()); + currentTousseItem.setIsTraceable(tdOfTousseInstance.getIsTraceable()); + currentTousseItem.setPrice(tdOfTousseInstance.getPrice()); + currentTousseItem.setRowPrice(MathTools.mul(tdOfTousseInstance.getPrice() , 1).doubleValue()); + currentTousseItem.setTousseType(tdOfTousseInstance.getTousseType()); + currentTousseItem.setTousseDefinitionId(tdOfTousseInstance.getId()); + currentTousseItem.setMaterialAmount(tdOfTousseInstance.getMaterialAmount()); + currentTousseItem.setAncestorID(tdOfTousseInstance.getAncestorID()); //设置发货数量依据(取包定义的发货数量依据) - currentTousseItem.setInvoiceAmountMode(td.getInvoiceAmountMode()); - currentTousseItem.setIsInvoice(td.getIsInvoice()); - currentTousseItem.setIsCleanedEntirely(td.getIsCleanedEntirely()); - currentTousseItem.setExpressRecycling(td.getExpressRecycling()); - currentTousseItem.setIsRecycling(td.getIsRecycling()); - currentTousseItem.setIsApplyEntireTousse(td.getIsApplyEntireTousse()); - if(td.isIDCardDisabled() || StringUtils.isBlank(td.getIsDisableIDCard())){ + currentTousseItem.setInvoiceAmountMode(tdOfTousseInstance.getInvoiceAmountMode()); + currentTousseItem.setIsInvoice(tdOfTousseInstance.getIsInvoice()); + currentTousseItem.setIsCleanedEntirely(tdOfTousseInstance.getIsCleanedEntirely()); + currentTousseItem.setExpressRecycling(tdOfTousseInstance.getExpressRecycling()); + currentTousseItem.setIsRecycling(tdOfTousseInstance.getIsRecycling()); + currentTousseItem.setIsApplyEntireTousse(tdOfTousseInstance.getIsApplyEntireTousse()); + if(tdOfTousseInstance.isIDCardDisabled() || StringUtils.isBlank(tdOfTousseInstance.getIsDisableIDCard())){ currentTousseItem.setIsThereIdentificationCard(Constants.STR_NO); }else{ currentTousseItem.setIsThereIdentificationCard(Constants.STR_YES); @@ -440,7 +447,7 @@ } //如果包定义为要回收且器械包类型为器械包时又或者包类型为自定义器械包时,构造预回收计划单明细 - if(td.isCustomTousse() || (td.isInsideTousse() && Constants.STR_YES.equals(td.getIsConvertApplyGoods()))){ + if(tdOfTousseInstance.isCustomTousse() || (tdOfTousseInstance.isInsideTousse() && Constants.STR_YES.equals(tdOfTousseInstance.getIsConvertApplyGoods()))){ TousseTransitionPlanItem tousseTransitionPlanItem = null; if(CollectionUtils.isNotEmpty(tousseTransitionPlanItemList)){ boolean foundTousseTransitionPlanItemInList = false;