📄 reportmgrimpl.java
字号:
package com.yuanchung.sales.service.resport.impl;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Hibernate;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projection;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import com.yuanchung.sales.dao.report.ReportCategoryDAO;
import com.yuanchung.sales.dao.report.ReportDAO;
import com.yuanchung.sales.model.customer.Customer;
import com.yuanchung.sales.model.report.Report;
import com.yuanchung.sales.model.report.ReportCategory;
import com.yuanchung.sales.service.resport.ReportMgr;
/**
* 报表的业务层实现类
* @author gzq
*
*/
public class ReportMgrImpl implements ReportMgr{
private static final Log log = LogFactory.getLog(ReportMgrImpl.class);
private ReportCategoryDAO reportCategoryDAO;
private ReportDAO reportDAO;
public void setReportCategoryDAO(ReportCategoryDAO reportCategoryDAO) {
this.reportCategoryDAO = reportCategoryDAO;
}
public void setReportDAO(ReportDAO reportDAO) {
this.reportDAO = reportDAO;
}
public List<ReportCategory> getReportCategory(){
return reportCategoryDAO.findAll();
}
/**
* 根据ID获得报表类别
* @param id 报表类别的ID
* @return
*/
public ReportCategory findReportCategoryById(Integer id){
ReportCategory rc = reportCategoryDAO.findById(id);
//强制装载
Hibernate.initialize(rc.getChildren());
return rc;
}
/**
* 获得报表类别包含的报表
* @param id 报表类别ID
* @return
*/
public List<Report> findReportByReportCategoryId(Integer id){
DetachedCriteria dc = DetachedCriteria.forClass(Report.class)
.add(Property.forName("reportCategory.id").eq(id));
return reportDAO.findByCriteria(dc);
}
/**
* 根据时间范围获得新增客户
* @param startDate 开始日期
* @param endDate 结束日期
* @return List(){familyName,customerName,inDate}
*/
public List getNewCreatedCustomer(String startDate,String endDate){
DetachedCriteria dc = DetachedCriteria.forClass(Customer.class);
dc.createAlias("user", "USER");
dc.setProjection(Projections.projectionList()
.add(Projections.property("USER.familyName").as("userFamilyName"))
.add(Projections.property("customerName"))
.add(Projections.property("inDate"))
);
dc.add(Restrictions.between("inDate", startDate, endDate));
return reportDAO.findByCriteria(dc);
}
/**
* 根据时间范围获得新增客户数
* @param startDate 开始日期
* @param endDate 结束日期
* @return List(){month,customerCount}
*/
public List getNewCreatedCustomerCount(String startDate,String endDate) {
return reportDAO.getNewCreatedCustomerCount(startDate, endDate);
}
/**
* 根据时间范围获得已忽视的客户数
* @param startDate 开始日期
* @param endDate 结束日期
* @return List(){month,customerCount}
*/
public List getIgnoredCustomerCount(String startDate,String endDate) {
return reportDAO.getIgnoredCustomerCount(startDate, endDate);
}
/**
* 根据时间范围获得最近联系的客户数
* @param startDate 开始日期
* @param endDate 结束日期
* @return List(){month,customerCount}
*/
public List getRecentlyContactCustomerCount(String startDate,String endDate) {
return reportDAO.getRecentlyContactCustomerCount(startDate, endDate);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -