Index: ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/DiposableGoodsTableManager.java =================================================================== diff -u -r31144 -r34197 --- ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/DiposableGoodsTableManager.java (.../DiposableGoodsTableManager.java) (revision 31144) +++ ssts-diposablegoods/src/main/java/com/forgon/disinfectsystem/diposablegoods/dwr/table/DiposableGoodsTableManager.java (.../DiposableGoodsTableManager.java) (revision 34197) @@ -5,9 +5,9 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -16,6 +16,7 @@ import net.sf.json.JSONObject; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang.StringUtils; import org.directwebremoting.util.Logger; @@ -36,14 +37,15 @@ import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoods; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsBatch; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsBatchStock; +import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsIdentification; import com.forgon.disinfectsystem.entity.assestmanagement.DisposableGoodsStock; import com.forgon.disinfectsystem.entity.assestmanagement.ExpensiveDisposablegoods; import com.forgon.disinfectsystem.entity.basedatamanager.datasynchronization.HisMaterialDefinition; import com.forgon.disinfectsystem.entity.basedatamanager.datasynchronization.HisMaterialType; -import com.forgon.disinfectsystem.entity.basedatamanager.supplier.Certificate; import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; import com.forgon.disinfectsystem.entity.basedatamanager.warehouse.WareHouse; import com.forgon.disinfectsystem.entity.systemwarning.SystemWarningItemVO; +import com.forgon.disinfectsystem.vo.PriceAmount; import com.forgon.systemsetting.model.HttpOption; import com.forgon.systemsetting.service.HttpOptionManager; import com.forgon.tools.SpringBeanManger; @@ -566,10 +568,83 @@ .getDisposableGoodsBatchStockByDisposableGoodsId(disposableGoodsId,warehouseId, selectAll); String batchs = "[]"; if(batchStocks != null){ + //batchs = JSONUtil.toJSONStringEx(batchStocks,true,DisposableGoodsBatchStock.filterProperties); + batchs = getDiposableGoodsPriceAmountInfoCanOutEntryByBatchID(batchStocks); + } + return batchs; + } + + /** + * 获取批次的价格及价格对应的库存数量,并按照价格分开显示 + * @param batchStocks + * @return + */ + private String getDiposableGoodsPriceAmountInfoCanOutEntryByBatchID(List batchStocks) { + String batchs = "[]"; + if(CollectionUtils.isNotEmpty(batchStocks)){ batchs = JSONUtil.toJSONStringEx(batchStocks,true,DisposableGoodsBatchStock.filterProperties); + + //获取批次库存不同价格对应的数量 + Map> batchStockPriceAmountMap = new HashMap>(); + for (DisposableGoodsBatchStock disposableGoodsBatchStock : batchStocks) { + List identifications = disposableGoodsBatchStock.getIdentifications(); + if(CollectionUtils.isNotEmpty(identifications) && disposableGoodsBatchStock.getStorage() > 0){ + Long batchStockId = disposableGoodsBatchStock.getId(); + Map tempPriceAmountMap = batchStockPriceAmountMap.get(batchStockId); + if(tempPriceAmountMap == null){ + tempPriceAmountMap = new HashMap(); + } + for (DisposableGoodsIdentification dgi : identifications) { + if (dgi.getAmount() == null || dgi.getAmount() <= 0) { + continue; + } + Double price = dgi.getPrice(); + PriceAmount priceAmount = tempPriceAmountMap.get(price); + if(priceAmount == null){ + priceAmount = new PriceAmount(); + priceAmount.setAmount(0l); + } + double fluctuationPrice = supplyRoomConfigManager + .getTousseFluctuationPrice(price); + priceAmount.setPrice(price); + priceAmount.setFluctuationPrice(fluctuationPrice); + priceAmount.setAmount(priceAmount.getAmount() + dgi.getAmount()); + tempPriceAmountMap.put(price, priceAmount); + } + batchStockPriceAmountMap.put(batchStockId, tempPriceAmountMap); + } + } + + //一个批次对应多个价格时,批次库存分开显示(其它属性一致,库存和价格不一样) + if(MapUtils.isNotEmpty(batchStockPriceAmountMap)){ + net.sf.json.JSONArray result = new net.sf.json.JSONArray(); + net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(batchs); + if(array != null && array.size() > 0){ + for(int i=0;i priceAmountMap = batchStockPriceAmountMap.get(batch_id); + if(priceAmountMap != null && CollectionUtils.isNotEmpty(priceAmountMap.values())){ + Collection priceAmountList = priceAmountMap.values(); + for (PriceAmount priceAmount : priceAmountList) { + net.sf.json.JSONObject tempJson = net.sf.json.JSONObject.fromObject(json); + tempJson.put("priceAmount", net.sf.json.JSONObject.fromObject(priceAmount)); + tempJson.put("storage", priceAmount.getAmount()); + tempJson.put("cost", priceAmount.getPrice()); + result.add(tempJson); + } + }else{ + result.add(json); + } + } + return result.toString(); + } + } + } return batchs; } + /** * 根据一次性物品定义的id获取批次 * @param id 一次性物品定义id