Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java =================================================================== diff -u -r41660 -r41665 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 41660) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/RecyclingApplicationManagerImpl.java (.../RecyclingApplicationManagerImpl.java) (revision 41665) @@ -5390,26 +5390,12 @@ : "保存成功"; try{ //省医需求:如果是借物单,则将申请物品明细转换至物品简要属性 - if(InvoicePlan.TYPE_BORROWINGSINGLE.equals(application.getType())){ + if(application.isBorrowingSingle()){ + // 下面这两句功能是一样的,application中的方法是使用applicationItems构建的 + // 并且如果newTousseItemVoList非空,则application调用的方法设置的值会被后面的覆盖 + // todo 这里的逻辑到底是怎么样,有待确认 application.tousseItemList2LendGoodsBrief(); - if(CollectionUtils.isNotEmpty(newTousseItemVoList)){ - List lendGoodsBriefList = new ArrayList(); - String[] lendGoodsBriefArray = null; - Map map = new HashMap(); - for(TousseItemVo ti : newTousseItemVoList){ - if(map.get(ti.getTousseName()) == null){ - map.put(ti.getTousseName() , ti.getAmount()); - }else{ - map.put(ti.getTousseName() , map.get(ti.getTousseName()) + ti.getAmount()); - } - } - for(String key : map.keySet()){ - lendGoodsBriefList.add(key + "x" + map.get(key)); - } - lendGoodsBriefArray = new String[lendGoodsBriefList.size()]; - lendGoodsBriefList.toArray(lendGoodsBriefArray); - application.setLendGoodsBrief(StringUtils.join(lendGoodsBriefArray, ",")); - } + generatorLendGoodsBriefWithNewTousseItemVo(application, newTousseItemVoList); } String msg = saveRecyclingApplication(application, newTousseItemVoList, @@ -5431,6 +5417,8 @@ } catch(RecyclingRecordException e){ message = e.getMessage(); + // 这里必须抛出异常,否则事务不会回滚。todo 更好的做法应该是取消这个try-catch + throw e; } return JSONUtil.buildJsonObject(true, message); } catch (Exception e) { @@ -5439,6 +5427,27 @@ } } + private void generatorLendGoodsBriefWithNewTousseItemVo(RecyclingApplication application, Collection newTousseItemVoList) { + if(CollectionUtils.isNotEmpty(newTousseItemVoList)){ + List lendGoodsBriefList = new ArrayList(); + String[] lendGoodsBriefArray = null; + Map map = new HashMap(); + for(TousseItemVo ti : newTousseItemVoList){ + if(map.get(ti.getTousseName()) == null){ + map.put(ti.getTousseName() , ti.getAmount()); + }else{ + map.put(ti.getTousseName() , map.get(ti.getTousseName()) + ti.getAmount()); + } + } + for(String key : map.keySet()){ + lendGoodsBriefList.add(key + "x" + map.get(key)); + } + lendGoodsBriefArray = new String[lendGoodsBriefList.size()]; + lendGoodsBriefList.toArray(lendGoodsBriefArray); + application.setLendGoodsBrief(StringUtils.join(lendGoodsBriefArray, ",")); + } + } + /** * 写入占用表数据(科研项目申请一次性物品后调用)时,计算申请的一次性物品总金额 * @param modifyTousseItemVoList