+
+
+
+
\ No newline at end of file
Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/GodownEntryItem.java
===================================================================
diff -u -r13377 -r13500
--- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/GodownEntryItem.java (.../GodownEntryItem.java) (revision 13377)
+++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/assestmanagement/GodownEntryItem.java (.../GodownEntryItem.java) (revision 13500)
@@ -420,7 +420,7 @@
* @return
*/
public static String gradeOrDefault(String grade){
- if(!"一类".equals(grade) && !"二类".equals(grade) && !"三类".equals(grade)){
+ if(!DisposableGoods.GRADE_FIRST.equals(grade) && !DisposableGoods.GRADE_SECOND.equals(grade) && !DisposableGoods.GRADE_THIRD.equals(grade)){
return null;
}
return grade;
Index: ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java
===================================================================
diff -u -r13493 -r13500
--- ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 13493)
+++ ssts-reports/src/main/java/com/forgon/disinfectsystem/jasperreports/service/JasperReportManagerImpl.java (.../JasperReportManagerImpl.java) (revision 13500)
@@ -26,6 +26,7 @@
import java.util.Set;
import java.util.stream.Stream;
+import net.sf.ehcache.search.Results;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
@@ -113,6 +114,7 @@
import com.forgon.disinfectsystem.jasperreports.javabeansource.GodownEntryItemVo;
import com.forgon.disinfectsystem.jasperreports.javabeansource.GodownEntryStatistic_child;
import com.forgon.disinfectsystem.jasperreports.javabeansource.GodownEntryStatistic_main;
+import com.forgon.disinfectsystem.jasperreports.javabeansource.GoodsAmountSummaryByGrade;
import com.forgon.disinfectsystem.jasperreports.javabeansource.InvoiceAmountContrastBean;
import com.forgon.disinfectsystem.jasperreports.javabeansource.InvoiceQuery;
import com.forgon.disinfectsystem.jasperreports.javabeansource.InvoiceQueryItem;
@@ -7554,6 +7556,272 @@
return ret;
}
+
+ /**
+ * 根据物品、时间范围、类别等条件按物品分组统计采购计划数量、入库数量、出库数量
+ * @param timeStart
+ * @param timeEnd
+ * @param goodsName
+ * @param grade
+ * @param orgUnitCoding
+ * @return
+ */
+ public List getGoodsAmountSummaryByGrade(String timeStart, String timeEnd, String goodsName,String grade,String orgUnitName){
+ OrgUnit orgUnit = (OrgUnit)objectDao.getByProperty(OrgUnit.class.getSimpleName(), "name", orgUnitName);
+ String orgUnitCoding = orgUnit == null ? AcegiHelper.getCurrentOrgUnitCode() : orgUnit.getOrgUnitCoding();
+ List returnList = new ArrayList();
+ String timeCondition = "";//采购计划、入/退库时间条件
+ String sendTimeCondition = "";//发货时间条件
+ String returnTimeCondition = "";//退货时间条件
+ String goodsNameCondition = "";//物品条件
+ String gradeCondition = "";//类别条件
+
+ if(StringUtils.isNotBlank(grade)){
+ gradeCondition = " and po.grade = '" + grade + "'";
+ }
+
+ String goodsPlanSummarySql = "";
+ String inStorageSummarySql = "";
+ String moveInSummarySql = "";
+ String stockTaskInSummarySql = "";
+ String moveOutSummarySql = "";
+ String stockTaskOutSummarySql = "";
+ String outStorageSummarySql = "";
+ String invoiceSummarySql = "";
+ String returnSummarySql = "";
+ //按数据库类型分别处理
+ if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){
+ //sqlserver的处理逻辑
+ if(StringUtils.isNotBlank(timeStart) && StringUtils.isNotBlank(timeEnd)){
+ timeCondition = " and f.time between '"+timeStart+"' and '"+timeEnd+"'";
+ sendTimeCondition = " and f.sendTime between '"+timeStart+"' and '"+timeEnd+"'";
+ returnTimeCondition = " and f.returnTime between '"+timeStart+"' and '"+timeEnd+"'";
+ }
+ if(StringUtils.isNotBlank(goodsName)){
+ if(goodsName.contains("[") && goodsName.contains("]") && goodsName.lastIndexOf("]") > goodsName.indexOf("[")){
+ goodsNameCondition = " and po.name + '[' + po.specification + ']' = '" + goodsName + "'";
+ }else{
+ goodsNameCondition = " and po.name = '" + goodsName + "'";
+ }
+ }
+ //一次性物品信息及采购数量
+ goodsPlanSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, sum(gpi.scheduleAmout) amount from DisposableGoods po"
+ +" left join GoodPurchaseItem gpi on po.id=gpi.disposableGoodsId"
+ +" and gpi.goodPurchasePlan_id in (select id from GoodPurchasePlan f where 1=1 " + timeCondition
+ +" and f.orgUnit_id in (select id from OrgUnit where orgUnitCoding='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-购入入库(手工入库,同步入库,导入入库)
+ inStorageSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in "
+ +" (select id from GodownEntry f where f.type='"+GodownEntry.TYPE_IN+"' and f.subType in ('"+GodownEntry.SUBTYPE_MANUAL_IN+"','"+GodownEntry.SUBTYPE_SYNC_IN+"','"+GodownEntry.SUBTYPE_MOVE_IN+"') " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-调拨入库
+ moveInSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, sum(gei.amount) amount from DisposableGoods po"
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType='" + GodownEntry.SUBTYPE_MOVE_IN + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-盘盈入库
+ stockTaskInSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType='" + GodownEntry.SUBTYPE_STOCKTAKE_IN + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-调拨出库
+ moveOutSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, -1 * sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType='" + GodownEntry.SUBTYPE_MOVE_OUT + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-盘亏出库
+ stockTaskOutSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, -1 * sum(gei.amount) amount from DisposableGoods po"
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType = '" + GodownEntry.SUBTYPE_STOCKTAKE_OUT + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-退库单
+ outStorageSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, -1 * sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.type='" + GodownEntry.TYPE_OUT + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息出库数量查询-发货
+ invoiceSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, sum(ii.amount) amount from DisposableGoods po"
+ +" left join InvoiceItem ii on po.id=ii.disposableGoodsId"
+ +" and ii.invoice_id in (select id from Invoice f where 1=1 " + sendTimeCondition + " and f.orgUnitCoding='" + orgUnitCoding + "') where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息出库数量查询-退货
+ returnSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name + '['+ po.specification +']' end name, -1*sum(rgi.amount) amount from DisposableGoods po "
+ +" left join ReturnGoodsItem rgi on po.id=rgi.disposableGoodsId"
+ +" and rgi.returnGoodsRecord_ID in (select id from ReturnGoodsRecord f where 1=1 " + returnTimeCondition + " and f.handleDepartCode='" + orgUnitCoding + "') where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+ }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){
+ //oracle的处理逻辑
+ if(StringUtils.isNotBlank(timeStart) && StringUtils.isNotBlank(timeEnd)){
+ timeCondition = " and f.time between to_date('"+timeStart+"','yyyy-mm-dd hh24:mi:ss') and to_date('"+timeEnd+"','yyyy-mm-dd hh24:mi:ss')";
+ sendTimeCondition = " and f.sendTime between to_date('"+timeStart+"','yyyy-mm-dd hh24:mi:ss') and to_date('"+timeEnd+"','yyyy-mm-dd hh24:mi:ss')";
+ returnTimeCondition = " and f.returnTime between to_date('"+timeStart+"','yyyy-mm-dd hh24:mi:ss') and to_date('"+timeEnd+"','yyyy-mm-dd hh24:mi:ss')";
+ }
+ if(StringUtils.isNotBlank(goodsName)){
+ if(goodsName.contains("[") && goodsName.contains("]") && goodsName.lastIndexOf("]") > goodsName.indexOf("[")){
+ goodsNameCondition = " and po.name || '[' || po.specification || ']' = '" + goodsName + "'";
+ }else{
+ goodsNameCondition = " and po.name = '" + goodsName + "'";
+ }
+ }
+ //一次性物品信息及采购数量
+ goodsPlanSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, sum(gpi.scheduleAmout) amount from DisposableGoods po"
+ +" left join GoodPurchaseItem gpi on po.id=gpi.disposableGoodsId"
+ +" and gpi.goodPurchasePlan_id in (select id from GoodPurchasePlan f where 1=1 " + timeCondition
+ +" and f.orgUnit_id in (select id from OrgUnit where orgUnitCoding='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-购入入库(手工入库,同步入库,导入入库)
+ inStorageSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in "
+ +" (select id from GodownEntry f where f.type='"+GodownEntry.TYPE_IN+"' and f.subType in ('"+GodownEntry.SUBTYPE_MANUAL_IN+"','"+GodownEntry.SUBTYPE_SYNC_IN+"','"+GodownEntry.SUBTYPE_MOVE_IN+"') " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-调拨入库
+ moveInSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, sum(gei.amount) amount from DisposableGoods po"
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType='" + GodownEntry.SUBTYPE_MOVE_IN + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-盘盈入库
+ stockTaskInSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType='" + GodownEntry.SUBTYPE_STOCKTAKE_IN + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-调拨出库
+ moveOutSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, -1 * sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType='" + GodownEntry.SUBTYPE_MOVE_OUT + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-盘亏出库
+ stockTaskOutSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, -1 * sum(gei.amount) amount from DisposableGoods po"
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.subType = '" + GodownEntry.SUBTYPE_STOCKTAKE_OUT + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息入库数量-退库单
+ outStorageSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, -1 * sum(gei.amount) amount from DisposableGoods po "
+ +" left join GodownEntryItem gei on po.id=gei.disposableGoodsId"
+ +" and gei.godownEntry_id in (select id from GodownEntry f where f.type='" + GodownEntry.TYPE_OUT + "' " + timeCondition
+ +" and warehouseID in (select id from WareHouse where orgUnitCode='" + orgUnitCoding + "')) where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息出库数量查询-发货
+ invoiceSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, sum(ii.amount) amount from DisposableGoods po"
+ +" left join InvoiceItem ii on po.id=ii.disposableGoodsId"
+ +" and ii.invoice_id in (select id from Invoice f where 1=1 " + sendTimeCondition + " and f.orgUnitCoding='" + orgUnitCoding + "') where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+
+ //一次性物品信息出库数量查询-退货
+ returnSummarySql = "select po.externalCode, case when po.specification is null then po.name else po.name || '['|| po.specification ||']' end name, -1*sum(rgi.amount) amount from DisposableGoods po "
+ +" left join ReturnGoodsItem rgi on po.id=rgi.disposableGoodsId"
+ +" and rgi.returnGoodsRecord_ID in (select id from ReturnGoodsRecord f where 1=1 " + returnTimeCondition + " and f.handleDepartCode='" + orgUnitCoding + "') where 1=1 " + goodsNameCondition + gradeCondition
+ +" group by po.externalCode, po.name,po.specification order by po.externalCode";
+ }else{
+ //sqlserver与oracle以外的数据库处理
+ }
+
+ List