Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java =================================================================== diff -u -r15377 -r15402 --- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 15377) +++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 15402) @@ -10837,7 +10837,7 @@ return totalPrice; } public List createGoodsSummary(StockTakeRecord currentRecord,StockTakeRecord lastMonthRecord,String type){ - List list = createGoodsSummary1(currentRecord,lastMonthRecord,type); + List list = createGoodsDetail(currentRecord,lastMonthRecord,type); MonthGoodsDetailVo vo = new MonthGoodsDetailVo(); for(MonthGoodsDetailVo item : list){ vo.setStartStockPrice(MathTools.add(vo.getStartStockPrice(), item.getStartStockPrice()).doubleValue()); @@ -10859,7 +10859,7 @@ retList.add(vo); return retList; } - public List createGoodsSummary1(StockTakeRecord currentRecord,StockTakeRecord lastMonthRecord,String type){ + public List createGoodsDetail(StockTakeRecord currentRecord,StockTakeRecord lastMonthRecord,String type){ //List voList = new ArrayList(); MonthGoodsDetailSummaryService service = new MonthGoodsDetailSummaryService(); if(currentRecord != null){ @@ -11039,178 +11039,178 @@ DatabaseUtil.closeResultSetAndStatement(rs); } } - /** - * @param currentRecord - * @param lastMonthRecord - * @param ops - * @return - */ - public List createGoodsDetail(StockTakeRecord currentRecord,StockTakeRecord lastMonthRecord,String type){ - if(currentRecord != null){ - - String projectName = CssdUtils.getConfigProperty("project"); - - String typesql = ""; - if(StringUtils.isNotBlank(type)){ - typesql = " and po.type = '" + type + "' "; - } - //按物品类型、外部编码排序 - String orderBySql = " where po.stockTakeRecord.id = " - + currentRecord.getId() + typesql + " order by po.typeSequence,po.externalCode asc"; - @SuppressWarnings("unchecked") - List goodsList = objectDao.findBySql(StockDiposableGoods.class.getSimpleName(), orderBySql); - List voList = new ArrayList(); - - - //本期入库 - String startDate = ""; - if(lastMonthRecord == null){ - startDate = ""; - }else{ - startDate = dateQueryAdapter.dateAdapter(lastMonthRecord.getStockTakeDate()); - } - String endDate = dateQueryAdapter.dateAdapter(currentRecord.getStockTakeDate()); - - String basesql = "select d.name,d.specification,i.amount,i.cost from GodownEntry r,GodownEntryItem i,DisposableGoodsStock d " - + "where r.id = i.godownEntry_id and i.diposableGoods_id = d.id "; - //入库sql - String insql = basesql + " and r.type ='"+GodownEntry.TYPE_IN+"' and r.warehouseID = " - + currentRecord.getWarehouseId(); - if(StringUtils.isBlank(startDate)){ - insql += " and r.time < " + endDate + ""; - }else{ - insql += " and r.time between " + startDate + " and " + endDate + " "; - } - - //中医药附三区分手工入库、同步入库 - Map> inAutoMap = null; - if("gzzyyfs".equals(projectName)){ - String inAutosql = insql + " and r.remark = '同步一次性物品入库单' "; - insql += " and (r.remark != '同步一次性物品入库单' or r.remark is null) "; - inAutoMap = getGodownEntryItemBySql(inAutosql); - } - - Map> inMap = getGodownEntryItemBySql(insql); - - - //退库sql - String outsql = basesql + " and r.type ='"+GodownEntry.TYPE_OUT+"' and subType not in ('"+GodownEntry.SUBTYPE_MOVE_OUT+"','"+GodownEntry.SUBTYPE_STOCKTAKE_OUT+"') and r.warehouseID = " - + currentRecord.getWarehouseId(); - if(StringUtils.isBlank(startDate)){ - outsql += " and r.time < " + endDate + ""; - }else{ - outsql += " and r.time between " + startDate + " and " + endDate + " "; - } - Map> outMap = getGodownEntryItemBySql(outsql); - - for (StockDiposableGoods goods : goodsList) { - MonthGoodsDetailVo vo = new MonthGoodsDetailVo(); - vo.setExternalCode(goods.getExternalCode()); - vo.setName(goods.getName()); - vo.setUnit(goods.getUnit()); - vo.setType(goods.getType()); - vo.setSpecification(goods.getSpecification()); - //期末余数 - Long startAmount = goods.getAmount(); - Double startPrice = 0.00; - //总价为标识号之和 - List batchList = goods.getGoodsBatchs(); - for (StockDiposableGoodBatch stockDiposableGoodBatch : batchList) { - for (StockIdentificationOfGoods stockIdentification : stockDiposableGoodBatch.getStockIdentifications()) { - double tempPrice = MathTools.mul(stockIdentification.getAmount(), stockIdentification.getPrice()).doubleValue(); - startPrice = MathTools.add(startPrice, tempPrice).doubleValue(); - } - } - - vo.setEndStockAmount(startAmount); - vo.setEndStockPrice(startPrice); - if(lastMonthRecord == null){ - vo.setStartStockAmount(0L); - vo.setStartStockPrice(0.00); - }else{ - //期初库存 - String sql = ""; - if(StringUtils.isBlank(goods.getSpecification())){ - sql = " where po.name = '"+goods.getName()+"' and po.specification is null and po.stockTakeRecord.id = " + lastMonthRecord.getId(); - }else{ - sql = " where po.name = '"+goods.getName()+"' and po.specification = '" - + goods.getSpecification() +"' and po.stockTakeRecord.id = " + lastMonthRecord.getId(); - } - List dipGoodsList = getGoodsBySql(sql); - if(dipGoodsList != null && dipGoodsList.size() > 0 ){ - StockDiposableGoods diposableGoods = dipGoodsList.get(0); - Double tempPrice2 = 0.00; - List startBatchList = diposableGoods.getGoodsBatchs(); - for (StockDiposableGoodBatch stockDiposableGoodBatch : startBatchList) { - for (StockIdentificationOfGoods stockIdentification : stockDiposableGoodBatch.getStockIdentifications()) { - double tempPrice = MathTools.mul(stockIdentification.getAmount(), stockIdentification.getPrice()).doubleValue(); - tempPrice2 = new BigDecimal(tempPrice2).add(new BigDecimal(tempPrice)).doubleValue(); - } - } - Long amount = diposableGoods.getAmount(); - vo.setStartStockAmount(amount); - vo.setStartStockPrice(tempPrice2); - } - } - - String key = goods.getName(); - if(StringUtils.isNotBlank(goods.getSpecification())){ - key += "[" + goods.getSpecification() + "]"; - } - //手工入库 - List entryItems = inMap.get(key); - Long amount = 0L; - double totalPrice = 0.00; - if(entryItems != null){ - for (GodownEntryItem godownEntryItem : entryItems) { - Long tempAmount = godownEntryItem.getAmount(); - double itemTotalPrice = MathTools.mul(tempAmount, godownEntryItem.getCost()).doubleValue(); - totalPrice += itemTotalPrice; - amount = MathTools.add(amount, tempAmount).longValue(); - } - } - - //供应室退库到物资仓库 - List entryOutItems = outMap.get(key); - if(entryOutItems != null){ - for (GodownEntryItem godownEntryItem : entryOutItems) { - Long tempAmount = godownEntryItem.getAmount(); - double cost = godownEntryItem.getCost(); - double itemTotalPrice = MathTools.mul(tempAmount, cost).doubleValue(); - totalPrice = MathTools.sub(totalPrice, itemTotalPrice).doubleValue(); - amount = MathTools.sub(amount, tempAmount).longValue(); - } - } - vo.setInStorageAmount(amount); - vo.setInStoragePrice(totalPrice); - - //同步入库 - if(inAutoMap != null){ - List autoEntryItems = inAutoMap.get(key); - Long autoAmount = 0L; - double autoTotalPrice = 0.00; - if(autoEntryItems != null){ - for (GodownEntryItem godownEntryItem : autoEntryItems) { - Long tempAmount = godownEntryItem.getAmount(); - double itemTotalPrice = MathTools.mul(tempAmount, godownEntryItem.getCost()).doubleValue(); - autoTotalPrice += itemTotalPrice; - autoAmount = MathTools.add(autoAmount, tempAmount).longValue(); - } - } - vo.setInAutoStorageAmount(autoAmount); - vo.setInAutoStoragePrice(autoTotalPrice); - } - //本期出库数量 - Long outStoageAmount = vo.getStartStockAmount()+vo.getInStorageAmount()-vo.getEndStockAmount(); - Double outStoragePrice = vo.getStartStockPrice()+vo.getInStoragePrice()-vo.getEndStockPrice(); - vo.setOutStorageAmount(outStoageAmount); - vo.setOutStoragePrice(outStoragePrice); - voList.add(vo); - } - return voList; - } - return null; - } +// /** +// * @param currentRecord +// * @param lastMonthRecord +// * @param ops +// * @return +// */ +// public List createGoodsDetail(StockTakeRecord currentRecord,StockTakeRecord lastMonthRecord,String type){ +// if(currentRecord != null){ +// +// String projectName = CssdUtils.getConfigProperty("project"); +// +// String typesql = ""; +// if(StringUtils.isNotBlank(type)){ +// typesql = " and po.type = '" + type + "' "; +// } +// //按物品类型、外部编码排序 +// String orderBySql = " where po.stockTakeRecord.id = " +// + currentRecord.getId() + typesql + " order by po.typeSequence,po.externalCode asc"; +// @SuppressWarnings("unchecked") +// List goodsList = objectDao.findBySql(StockDiposableGoods.class.getSimpleName(), orderBySql); +// List voList = new ArrayList(); +// +// +// //本期入库 +// String startDate = ""; +// if(lastMonthRecord == null){ +// startDate = ""; +// }else{ +// startDate = dateQueryAdapter.dateAdapter(lastMonthRecord.getStockTakeDate()); +// } +// String endDate = dateQueryAdapter.dateAdapter(currentRecord.getStockTakeDate()); +// +// String basesql = "select d.name,d.specification,i.amount,i.cost from GodownEntry r,GodownEntryItem i,DisposableGoodsStock d " +// + "where r.id = i.godownEntry_id and i.diposableGoods_id = d.id "; +// //入库sql +// String insql = basesql + " and r.type ='"+GodownEntry.TYPE_IN+"' and r.warehouseID = " +// + currentRecord.getWarehouseId(); +// if(StringUtils.isBlank(startDate)){ +// insql += " and r.time < " + endDate + ""; +// }else{ +// insql += " and r.time between " + startDate + " and " + endDate + " "; +// } +// +// //中医药附三区分手工入库、同步入库 +// Map> inAutoMap = null; +// if("gzzyyfs".equals(projectName)){ +// String inAutosql = insql + " and r.remark = '同步一次性物品入库单' "; +// insql += " and (r.remark != '同步一次性物品入库单' or r.remark is null) "; +// inAutoMap = getGodownEntryItemBySql(inAutosql); +// } +// +// Map> inMap = getGodownEntryItemBySql(insql); +// +// +// //退库sql +// String outsql = basesql + " and r.type ='"+GodownEntry.TYPE_OUT+"' and subType not in ('"+GodownEntry.SUBTYPE_MOVE_OUT+"','"+GodownEntry.SUBTYPE_STOCKTAKE_OUT+"') and r.warehouseID = " +// + currentRecord.getWarehouseId(); +// if(StringUtils.isBlank(startDate)){ +// outsql += " and r.time < " + endDate + ""; +// }else{ +// outsql += " and r.time between " + startDate + " and " + endDate + " "; +// } +// Map> outMap = getGodownEntryItemBySql(outsql); +// +// for (StockDiposableGoods goods : goodsList) { +// MonthGoodsDetailVo vo = new MonthGoodsDetailVo(); +// vo.setExternalCode(goods.getExternalCode()); +// vo.setName(goods.getName()); +// vo.setUnit(goods.getUnit()); +// vo.setType(goods.getType()); +// vo.setSpecification(goods.getSpecification()); +// //期末余数 +// Long startAmount = goods.getAmount(); +// Double startPrice = 0.00; +// //总价为标识号之和 +// List batchList = goods.getGoodsBatchs(); +// for (StockDiposableGoodBatch stockDiposableGoodBatch : batchList) { +// for (StockIdentificationOfGoods stockIdentification : stockDiposableGoodBatch.getStockIdentifications()) { +// double tempPrice = MathTools.mul(stockIdentification.getAmount(), stockIdentification.getPrice()).doubleValue(); +// startPrice = MathTools.add(startPrice, tempPrice).doubleValue(); +// } +// } +// +// vo.setEndStockAmount(startAmount); +// vo.setEndStockPrice(startPrice); +// if(lastMonthRecord == null){ +// vo.setStartStockAmount(0L); +// vo.setStartStockPrice(0.00); +// }else{ +// //期初库存 +// String sql = ""; +// if(StringUtils.isBlank(goods.getSpecification())){ +// sql = " where po.name = '"+goods.getName()+"' and po.specification is null and po.stockTakeRecord.id = " + lastMonthRecord.getId(); +// }else{ +// sql = " where po.name = '"+goods.getName()+"' and po.specification = '" +// + goods.getSpecification() +"' and po.stockTakeRecord.id = " + lastMonthRecord.getId(); +// } +// List dipGoodsList = getGoodsBySql(sql); +// if(dipGoodsList != null && dipGoodsList.size() > 0 ){ +// StockDiposableGoods diposableGoods = dipGoodsList.get(0); +// Double tempPrice2 = 0.00; +// List startBatchList = diposableGoods.getGoodsBatchs(); +// for (StockDiposableGoodBatch stockDiposableGoodBatch : startBatchList) { +// for (StockIdentificationOfGoods stockIdentification : stockDiposableGoodBatch.getStockIdentifications()) { +// double tempPrice = MathTools.mul(stockIdentification.getAmount(), stockIdentification.getPrice()).doubleValue(); +// tempPrice2 = new BigDecimal(tempPrice2).add(new BigDecimal(tempPrice)).doubleValue(); +// } +// } +// Long amount = diposableGoods.getAmount(); +// vo.setStartStockAmount(amount); +// vo.setStartStockPrice(tempPrice2); +// } +// } +// +// String key = goods.getName(); +// if(StringUtils.isNotBlank(goods.getSpecification())){ +// key += "[" + goods.getSpecification() + "]"; +// } +// //手工入库 +// List entryItems = inMap.get(key); +// Long amount = 0L; +// double totalPrice = 0.00; +// if(entryItems != null){ +// for (GodownEntryItem godownEntryItem : entryItems) { +// Long tempAmount = godownEntryItem.getAmount(); +// double itemTotalPrice = MathTools.mul(tempAmount, godownEntryItem.getCost()).doubleValue(); +// totalPrice += itemTotalPrice; +// amount = MathTools.add(amount, tempAmount).longValue(); +// } +// } +// +// //供应室退库到物资仓库 +// List entryOutItems = outMap.get(key); +// if(entryOutItems != null){ +// for (GodownEntryItem godownEntryItem : entryOutItems) { +// Long tempAmount = godownEntryItem.getAmount(); +// double cost = godownEntryItem.getCost(); +// double itemTotalPrice = MathTools.mul(tempAmount, cost).doubleValue(); +// totalPrice = MathTools.sub(totalPrice, itemTotalPrice).doubleValue(); +// amount = MathTools.sub(amount, tempAmount).longValue(); +// } +// } +// vo.setInStorageAmount(amount); +// vo.setInStoragePrice(totalPrice); +// +// //同步入库 +// if(inAutoMap != null){ +// List autoEntryItems = inAutoMap.get(key); +// Long autoAmount = 0L; +// double autoTotalPrice = 0.00; +// if(autoEntryItems != null){ +// for (GodownEntryItem godownEntryItem : autoEntryItems) { +// Long tempAmount = godownEntryItem.getAmount(); +// double itemTotalPrice = MathTools.mul(tempAmount, godownEntryItem.getCost()).doubleValue(); +// autoTotalPrice += itemTotalPrice; +// autoAmount = MathTools.add(autoAmount, tempAmount).longValue(); +// } +// } +// vo.setInAutoStorageAmount(autoAmount); +// vo.setInAutoStoragePrice(autoTotalPrice); +// } +// //本期出库数量 +// Long outStoageAmount = vo.getStartStockAmount()+vo.getInStorageAmount()-vo.getEndStockAmount(); +// Double outStoragePrice = vo.getStartStockPrice()+vo.getInStoragePrice()-vo.getEndStockPrice(); +// vo.setOutStorageAmount(outStoageAmount); +// vo.setOutStoragePrice(outStoragePrice); +// voList.add(vo); +// } +// return voList; +// } +// return null; +// } @SuppressWarnings("unchecked") public Map> getGodownEntryItemBySql(String sql){