新增礼品卡报表的功能

This commit is contained in:
季圣华
2017-07-17 00:32:17 +08:00
parent 883890eb00
commit fd0413c187
9 changed files with 439 additions and 29 deletions

View File

@@ -339,6 +339,50 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
}
}
/**
* 查找统计信息_根据礼品卡(报表)
* @return
*/
public void findGiftReport() {
try {
PageUtil<DepotHead> pageUtil_in = new PageUtil<DepotHead>();
pageUtil_in.setPageSize(0);
pageUtil_in.setCurPage(0);
pageUtil_in.setAdvSearch(getConditionHead_Gift_In());
depotHeadService.find(pageUtil_in);
List<DepotHead> dataList_in = pageUtil_in.getPageList();
JSONObject outer = new JSONObject();
String headId = "";
if(null != dataList_in) {
for(DepotHead depotHead:dataList_in) {
headId = headId + depotHead.getId() + ",";
}
PageUtil<DepotHead> pageUtil_out = new PageUtil<DepotHead>();
pageUtil_out.setPageSize(0);
pageUtil_out.setCurPage(0);
pageUtil_out.setAdvSearch(getConditionHead_Gift_Out());
depotHeadService.find(pageUtil_out);
List<DepotHead> dataList_out = pageUtil_out.getPageList();
if(null != dataList_out) {
for(DepotHead depotHead:dataList_out) {
headId = headId + depotHead.getId() + ",";
}
}
}
if(headId!="") {
headId = headId.substring(0, headId.lastIndexOf(","));
}
outer.put("HeadIds", headId);
toClient(outer.toString());
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
}
}
/**
* 查询单位的累计应收和累计应付,零售不能计入
@@ -442,6 +486,22 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
condition.put("OperTime_s_lteq",model.getMonthTime() + "-31 00:00:00");
return condition;
}
private Map<String,Object> getConditionHead_Gift_In() {
Map<String,Object> condition = new HashMap<String,Object>();
if(model.getProjectId()!=null) {
condition.put("AllocationProjectId_n_eq", model.getProjectId());
}
return condition;
}
private Map<String,Object> getConditionHead_Gift_Out() {
Map<String,Object> condition = new HashMap<String,Object>();
if(model.getProjectId()!=null) {
condition.put("ProjectId_n_eq", model.getProjectId());
}
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
public DepotHeadModel getModel()

View File

@@ -240,6 +240,53 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 查找礼品卡信息
* @return
*/
public void findGiftByAll() {
try {
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getConditionALL());
depotItemService.find(pageUtil);
List<DepotItem> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
Integer pid = model.getProjectId();
JSONArray dataArray = new JSONArray();
if(null != dataList) {
for(DepotItem depotItem:dataList){
JSONObject item = new JSONObject();
Integer InSum = sumNumberGift("礼品充值", pid, depotItem.getMaterialId().getId(), "in");
Integer OutSum = sumNumberGift("礼品销售", pid, depotItem.getMaterialId().getId(), "out");
item.put("Id", depotItem.getId());
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
item.put("MaterialName", depotItem.getMaterialId().getName());
item.put("MaterialModel", depotItem.getMaterialId().getModel());
item.put("MaterialStandard", depotItem.getMaterialId().getStandard());
item.put("MaterialColor", depotItem.getMaterialId().getColor());
item.put("MaterialUnit", depotItem.getMaterialId().getUnit());
item.put("thisSum", InSum - OutSum);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 进货统计
* @return
@@ -487,6 +534,37 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
return sumNumber;
}
/**
* 数量合计-礼品卡
* @param type
* @param MId
* @param MonthTime
* @param isPrev
* @return
*/
@SuppressWarnings("unchecked")
public Integer sumNumberGift(String subType,Integer ProjectId,Long MId,String type) {
Integer sumNumber = 0;
String allNumber = "";
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try {
depotItemService.findGiftByType(pageUtil, subType, ProjectId, MId,type);
allNumber = pageUtil.getPageList().toString();
allNumber = allNumber.substring(1,allNumber.length()-1);
if(allNumber.equals("null")){
allNumber = "0";
}
allNumber = allNumber.replace(".0", "");
} catch (JshException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sumNumber = Integer.parseInt(allNumber);
return sumNumber;
}
/**
* 价格合计
* @param type

View File

@@ -27,23 +27,23 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
String queryString;
if(isPrev) {
queryString = "select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'";
StringBuffer queryString = new StringBuffer();
if(isPrev) {
queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
if(ProjectId!=null) {
queryString += " and ProjectId='" + ProjectId +"'";
queryString.append(" and ProjectId='" + ProjectId +"'");
}
queryString += " and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' ";
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
else {
queryString = "select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'";
if(ProjectId!=null) {
queryString += " and ProjectId='" + ProjectId +"'";
}
queryString += " and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " ;
queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
}
else {
queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
if(ProjectId!=null) {
queryString.append(" and ProjectId='" + ProjectId +"'");
}
queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@@ -54,21 +54,20 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
String queryString;
if(isPrev) {
queryString = "select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'";
if(ProjectId!=null) {
queryString += " and ProjectId='" + ProjectId +"'";
StringBuffer queryString = new StringBuffer();
if (isPrev) {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'");
if (ProjectId != null) {
queryString.append(" and ProjectId='" + ProjectId + "'");
}
queryString += " and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' ";
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime <'" + MonthTime + "-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
else {
queryString = "select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'";
if(ProjectId!=null) {
queryString += " and ProjectId='" + ProjectId +"'";
} else {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'");
if (ProjectId != null) {
queryString.append(" and ProjectId='" + ProjectId + "'");
}
queryString += " and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' ";
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
@@ -90,6 +89,28 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
@Override
public void findGiftByType(PageUtil<DepotItem> pageUtil,String subType,Integer ProjectId,Long MId,String type) throws JshException
{
//多表联查,多表连查此处用到了createSQLQuery可以随便写sql语句很方便
Query query;
StringBuffer queryString = new StringBuffer();
queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and SubType='" + subType +"'");
if(ProjectId!=null) {
if(type.equals("in")){
queryString.append(" and AllocationProjectId='" + ProjectId +"'"); //礼品充值时
}
else if(type.equals("out")){
queryString.append(" and ProjectId='" + ProjectId +"'");
}
}
queryString.append(" and MaterialId ="+ MId);
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}

View File

@@ -12,5 +12,7 @@ public interface DepotItemIDAO extends BaseIDAO<DepotItem>
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException;
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId, String MonthTime, String sumType) throws JshException;
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId, String MonthTime, String sumType) throws JshException;
public void findGiftByType(PageUtil<DepotItem> pageUtil,String subType,Integer ProjectId,Long MId, String type) throws JshException;
}

View File

@@ -19,7 +19,9 @@ public interface DepotItemIService extends BaseIService<DepotItem>
void findPriceByType(PageUtil<DepotItem> depotItem, String type,Integer ProjectId, Long MId, String MonthTime,Boolean isPrev)throws JshException;
void buyOrSale(PageUtil<DepotItem> depotItem, String type, String subType, Long MId, String MonthTime, String sumType)throws JshException;
void findGiftByType(PageUtil<DepotItem> depotItem, String subType,Integer ProjectId, Long MId, String type)throws JshException;
/**
* 导出信息
* @return

View File

@@ -61,6 +61,12 @@ public class DepotItemService extends BaseService<DepotItem> implements DepotIte
{
depotItemDao.buyOrSale(pageUtil, type, subType, MId, MonthTime, sumType);
}
@Override
public void findGiftByType(PageUtil<DepotItem> pageUtil, String subType,Integer ProjectId,Long MId,String type) throws JshException
{
depotItemDao.findGiftByType(pageUtil, subType, ProjectId, MId, type);
}
/**
* 导出Excel表格