?? 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 + -