📄 orderserviceimpl.java
字号:
package com.iplan.portal.order.service;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import com.iplan.portal.framework.base.BaseService;
import com.iplan.portal.order.pojo.OrderInfo;
/**
* http://www.hao-se.cn
*
* @author ws
*/
public class OrderServiceImpl extends BaseService implements IOrderService {
/**
* 根据id获得pojo
*
* @param id
* id
* @return
*/
public OrderInfo getOrderInfoById(String id) {
return (OrderInfo) this.getCommonDAO().get(OrderInfo.class, id);
}
/**
* 根据orderNo获得pojo
*
* @param orderNo
* @return
*/
public OrderInfo getOrderInfoByOrderNo(String areaId, String userId,
String orderNo) {
DetachedCriteria dc = DetachedCriteria.forClass(OrderInfo.class);
dc.add(Restrictions.eq("areaid", areaId));
dc.add(Restrictions.eq("userId", userId));
dc.add(Restrictions.eq("orderNo", orderNo));
List list = this.getCommonDAO().findByCriteria(dc);
if (list != null && !list.isEmpty()) {
return (OrderInfo) list.get(0);
}
return null;
}
/**
* 获得pojo的list
*
* @param areaId
* @param userId
* @return
*/
public List getOrderInfoList(String areaId, String userId) {
StringBuffer sql = new StringBuffer();
sql
.append("select * from ORDERINFO where areaid = ? and userid = ? order by ORDERNO DESC");
List list = this.getCommonDAO().findBySQL(sql.toString(),
new Object[] { areaId, userId }).getRows();
return list;
}
/**
* 获得pojo的list
*
* @param areaId
* @param userId
* @param orderNo
* @param orderDateStr
* @param orderDateStr2
* @param customerName
* @param printingDateStr
* @param printingDateStr2
* @param month
* @param ok
* @return
*/
public List getOrderInfoList(String areaId, String userId, String orderNo,
String orderDateStr, String orderDateStr2, String customerName,
String printingDateStr, String printingDateStr2, String month,
String ok) {
StringBuffer sql = new StringBuffer();
sql.append("select * from ORDERINFO where areaid ='" + areaId
+ "' and userid ='" + userId + "' ");
if (orderNo != null && !"".equals(orderNo)) {
sql.append("and orderno like '%" + orderNo + "%' ");
}
if (orderDateStr != null && !"".equals(orderDateStr)) {
sql.append("and SUBSTRING(CONVERT(orderdate,VARCHAR),1,10) >= '"
+ convert(orderDateStr) + "' ");
}
if (orderDateStr2 != null && !"".equals(orderDateStr2)) {
sql.append("and SUBSTRING(CONVERT(orderdate,VARCHAR),1,10) <= '"
+ convert(orderDateStr2) + "' ");
}
if (customerName != null && !"".equals(customerName)) {
sql.append("and customername like '%" + customerName + "%' ");
}
if (printingDateStr != null && !"".equals(printingDateStr)) {
sql.append("and SUBSTRING(CONVERT(printingdate,VARCHAR),1,10) >= '"
+ convert(printingDateStr) + "' ");
}
if (printingDateStr2 != null && !"".equals(printingDateStr2)) {
sql.append("and SUBSTRING(CONVERT(printingdate,VARCHAR),1,10) <= '"
+ convert(printingDateStr2) + "' ");
}
if (month != null && !"".equals(month)) {
sql.append("and SUBSTRING(CONVERT(orderdate,VARCHAR),1,7) = '"
+ convert(month) + "' ");
}
if (ok != null && !"".equals(ok)) {
sql.append("and ok ='" + ok + "' ");
}
sql.append("order by ORDERNO DESC");
List list = this.getCommonDAO().findBySQL(sql.toString()).getRows();
return list;
}
private String convert(String date) {
String str = "";
str = date.replaceAll("/", "-");
return str;
}
/**
* 获得Excle数据的list
*
* @param areaId
* @param userId
* @param orderNo
* @param orderDateStr
* @param orderDateStr2
* @param customerName
* @param printingDateStr
* @param printingDateStr2
* @param month
* @param ok
* @return
*/
public List getExcleInfoList(String areaId, String userId, String orderNo,
String orderDateStr, String orderDateStr2, String customerName,
String printingDateStr, String printingDateStr2, String month,
String ok) {
StringBuffer sql = new StringBuffer();
sql.append("select * from ORDERINFO where areaid ='" + areaId
+ "' and userid ='" + userId + "' ");
if (orderNo != null && !"".equals(orderNo)) {
sql.append("and orderno like '%" + orderNo + "%' ");
}
if (orderDateStr != null && !"".equals(orderDateStr)) {
sql.append("and SUBSTRING(CONVERT(orderdate,VARCHAR),1,10) >= '"
+ convert(orderDateStr) + "' ");
}
if (orderDateStr2 != null && !"".equals(orderDateStr2)) {
sql.append("and SUBSTRING(CONVERT(orderdate,VARCHAR),1,10) <= '"
+ convert(orderDateStr2) + "' ");
}
if (customerName != null && !"".equals(customerName)) {
sql.append("and customername like '%" + customerName + "%' ");
}
if (printingDateStr != null && !"".equals(printingDateStr)) {
sql.append("and SUBSTRING(CONVERT(printingdate,VARCHAR),1,10) >= '"
+ convert(printingDateStr) + "' ");
}
if (printingDateStr2 != null && !"".equals(printingDateStr2)) {
sql.append("and SUBSTRING(CONVERT(printingdate,VARCHAR),1,10) <= '"
+ convert(printingDateStr2) + "' ");
}
if (month != null && !"".equals(month)) {
sql.append("and SUBSTRING(CONVERT(orderdate,VARCHAR),1,7) = '"
+ convert(month) + "' ");
}
if (ok != null && !"".equals(ok)) {
sql.append("and ok ='" + ok + "' ");
}
sql.append("order by ORDERNO");
List list = this.getCommonDAO().findBySQL(sql.toString()).getRows();
return list;
}
/**
* 保存pojo
*
* @param orderInfo
*/
public void saveOrderInfo(OrderInfo orderInfo) {
this.getCommonDAO().save(orderInfo);
}
/**
* 修改pojo
*
* @param orderInfo
*/
public void updateOrderInfo(OrderInfo orderInfo) {
this.getCommonDAO().update(orderInfo);
}
/**
* 删除pojo
*
* @param orderInfo
*/
public void deleteOrderInfo(OrderInfo orderInfo) {
this.getCommonDAO().delete(orderInfo);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -