📄 bookdaoimpl.java
字号:
a.setDeliplace(obj[5].toString());
a.setReceplace(obj[6].toString());
list1.add(a);
}
session.close();
return list1;
}
/**
* 根据ID和STATE查询BOOK表中的符合条件的数据
*/
public List findByWTGLCon(String id, String state) {
// TODO Auto-generated method stub
StringBuffer sql = new StringBuffer();
sql.append("select id,sendperon,receperson,type,weight,receplace,deliplace from book where delstate='1'");
if (null != id && id.trim().length() > 0) {
sql.append("and id =");
sql.append(id);
}
if (null != state && state.trim().length() > 0) {
sql.append(" AND state = '");
sql.append(state);
sql.append("'");
}
//System.out.print(sql);
session = getHibernateTemplate().getSessionFactory()
.openSession();
query = session.createSQLQuery(sql.toString());
List<Object> list = query.list();
List list1 = new ArrayList();
for (int i = 0; i < list.size(); i++) {
Object[] obj = (Object[]) list.get(i);
WT1301ViewEntity1 a = new WT1301ViewEntity1();
a.setId((Integer) obj[0]);
a.setSendperon(obj[1].toString());
a.setReceperson(obj[2].toString());
a.setType(obj[3].toString());
a.setWeight(obj[4].toString());
a.setDeliplace(obj[5].toString());
a.setReceplace(obj[6].toString());
list1.add(a);
}
session.close();
return list1;
}
/**
* 根据ID修改一条BOOK表中记录的delstate的值,即删除一条记录
*/
public boolean delete(String id) {
// TODO Auto-generated method stub
boolean bln = false;
try {
Book book = findById(id);
book.setDelstate(ComTool.DEL);
getHibernateTemplate().saveOrUpdate(book);
Log.insert("book", "delete");
bln = true;
} catch (Exception e) {
// TODO Auto-generated catch block
}
// session.close();
return bln;
}
/**
* 根据ID查询一条BOOK记录的所有字段
*/
public Book findById(String id) {
List list = getHibernateTemplate().find("from Book where id=" + id);
Book book = (Book) list.get(0);
//System.out.println(book.getCompany());
return book;
}
/**
* 向book表中插入由WT1201页面中的一条记录
*/
public boolean insert(Book book) {
boolean bln = false;
try {
getHibernateTemplate().save(book);
Log.insert("book", "insert");
bln = true;
} catch (Exception e) {
e.printStackTrace();
}
return bln;
}
/**
* 修改一条BOOK表中的记录
*/
public boolean updateWTGL(Book book) {
// TODO Auto-generated method stub
boolean bln = false;
try {
Book b=findById(book.getId().toString());
//b.setId(book.getId());
b.setReceperson(book.getReceperson());
b.setNotifyperson(book.getNotifyperson());
b.setType(book.getType());
b.setSize(book.getSize());
b.setWeight(book.getWeight());
b.setReceplace(book.getReceplace());
b.setDeliplace(book.getDeliplace());
b.setTrafree(book.getTrafree());
b.setDealcost(book.getDealcost());
b.setTransway(book.getTransway());
b.setCompany(book.getCompany());
getHibernateTemplate().saveOrUpdate(b);
Log.insert("book", "modifyWTGL");
bln = true;
} catch (Exception e) {
// TODO Auto-generated catch block
}
return bln;
}
/**
* 根据编号查询客户委托书
* @param id -客户委托书编号
* @return
*/
/**
* 查询一条记录的详细信息
* @param id-点击的该条记录的id
* @return
*/
public Book findSCDCById(String id) {
List list = getHibernateTemplate().find("from Book where id="+id);
Book book = (Book)list.get(0);
return book;
}
//---------------------------------------------------------- 商务 A3 -----------------------------------------------------------------
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#findSWGLAll()
*/
public List<SW4101ViewEntity1List> findSWGLAll() {
String temp = null;
String sql = "select b.id, b.sendperon, b.shipcname, b.weight, b.payrate, b.dealcost from book as b where b.delstate="
+ ComTool.UDL +" and b.State=" + "'"+ComTool.DJH+"'" ;
session = getHibernateTemplate().getSessionFactory().openSession();
query = session.createSQLQuery(sql);
List<Object> list1 = query.list();
List<SW4101ViewEntity1List> list = new ArrayList<SW4101ViewEntity1List>();
for (int i = 0; i < list1.size(); i++) {
Object[] obj = (Object[]) list1.get(i);
SW4101ViewEntity1List a = new SW4101ViewEntity1List();
a.setId((Integer) obj[0]);
a.setSendPeron(obj[1].toString());
a.setShipCName(obj[2].toString());
temp = obj[3].toString();
a.setWeight(Double.parseDouble(temp));
temp = obj[4].toString();
a.setPayRate(Double.parseDouble(temp));
temp = obj[5].toString();
a.setDealCost(Double.parseDouble(temp));
a.setGain(a.getDealCost() - a.getPayRate());
list.add(a);
}
session.close();
return list;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#findSFGLAll()
*/
public List<SW4201ViewEntity1List> findSFGLAll() {
String temp = null;
String sql = "Select b.id,b.sendperon,b.receperson,b.size,b.weight,b.trafree,b.dealcost FROM book as b WHERE b.delstate="
+ ComTool.UDL +" and b.state=" + "'"+ComTool.WJF+"'" ;
session = getHibernateTemplate().getSessionFactory().openSession();
query = session.createSQLQuery(sql);
List<Object> list1 = query.list();
List<SW4201ViewEntity1List> list = new ArrayList<SW4201ViewEntity1List>();
for (int i = 0; i < list1.size(); i++) {
Object[] obj = (Object[]) list1.get(i);
SW4201ViewEntity1List a = new SW4201ViewEntity1List();
a.setId((Integer) obj[0]);
a.setSendPeron(obj[1].toString());
a.setRecePerson(obj[2].toString());
temp = obj[3].toString();
a.setSize(Double.parseDouble(temp));
temp = obj[4].toString();
a.setWeight(Double.parseDouble(temp));
temp = obj[5].toString();
a.setTraFree(Double.parseDouble(temp));
temp = obj[6].toString();
a.setDealCost(Double.parseDouble(temp));
list.add(a);
}
session.close();
return list;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#findSWGLByCon(java.lang.String)
*/
public List<SW4101ViewEntity1List> findSWGLByCon(String id) {
String temp = null;
String sql = "select b.id, b.sendperon, b.shipcname, b.weight, b.payrate, b.dealcost from book as b where b.delstate="
+ ComTool.UDL+" and b.State=" + "'"+ComTool.DJH+"'";
if (null != id) {
sql = sql + " and b.id=" + id;
}
session = getHibernateTemplate().getSessionFactory()
.openSession();
query = session.createSQLQuery(sql);
List<Object> list1 = query.list();
List<SW4101ViewEntity1List> list = new ArrayList<SW4101ViewEntity1List>();
for (int i = 0; i < list1.size(); i++) {
Object[] obj = (Object[]) list1.get(i);
SW4101ViewEntity1List a = new SW4101ViewEntity1List();
a.setId((Integer) obj[0]);
a.setSendPeron(obj[1].toString());
a.setShipCName(obj[2].toString());
temp = obj[3].toString();
a.setWeight(Double.parseDouble(temp));
temp = obj[4].toString();
a.setPayRate(Double.parseDouble(temp));
temp = obj[5].toString();
a.setDealCost(Double.parseDouble(temp));
a.setGain(a.getDealCost() - a.getPayRate());
list.add(a);
}
session.close();
return list;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#findSFGLByCon(java.lang.String)
*/
public List<SW4201ViewEntity1List> findSFGLByCon(String id) {
String temp = null;
String sql = "Select b.id,b.sendperon,b.receperson,b.size,b.weight,b.trafree,b.dealcost FROM book as b WHERE b.delstate="
+ ComTool.UDL +" and b.state=" + "'"+ComTool.WJF+"'";
if (null != id) {
sql = sql + " and b.id=" + id;
}
session = getHibernateTemplate().getSessionFactory()
.openSession();
query = session.createSQLQuery(sql);
List<Object> list1 = query.list();
List<SW4201ViewEntity1List> list = new ArrayList<SW4201ViewEntity1List>();
for (int i = 0; i < list1.size(); i++) {
Object[] obj = (Object[]) list1.get(i);
SW4201ViewEntity1List a = new SW4201ViewEntity1List();
a.setId((Integer) obj[0]);
a.setSendPeron(obj[1].toString());
a.setRecePerson(obj[2].toString());
temp = obj[3].toString();
a.setSize(Double.parseDouble(temp));
temp = obj[4].toString();
a.setWeight(Double.parseDouble(temp));
temp = obj[5].toString();
a.setTraFree(Double.parseDouble(temp));
temp = obj[6].toString();
a.setDealCost(Double.parseDouble(temp));
list.add(a);
}
session.close();
return list;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#findSWGLById(java.lang.String)
*/
public Book findSWGLById(String id) {
List list = getHibernateTemplate().find("from Book where id=" + id);
Book book = (Book) list.get(0);
return book;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#updateSWJH(java.lang.String, java.lang.String, java.lang.String)
*/
public boolean updateSWJH(String id, String state, String remark) {
boolean bln = false;
Book book = this.findSWGLById(id);
book.setState(state);
book.setRemark(remark);
try {
getHibernateTemplate().update(book);
Log.insert("book", "modifySWJH");
bln = true;
} catch (Exception e) {
// TODO: 请补充异常捕获@SW4102E1S
// EMSG: " [内部错误]: 数据更新失败@SW4102E1S「牵涉字段 1.业务状态 state 2.备注 remark」"
// MSG: "数据取存失败"
}
return bln;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#updateSFGL(java.lang.String)
*/
public boolean updateSFGL(String id) {
boolean bln = false;
Book book = this.findSWGLById(id);
book.setState(ComTool.WSQ);
try {
getHibernateTemplate().update(book);
Log.insert("book", "modifySFGL");
bln = true;
} catch (Exception e) {
// TODO: 请补充异常捕获@SW4201E2S
// EMSG: " [内部错误]: 数据更新失败@SW4201E2S「牵涉字段 业务状态 state」"
// MSG: "数据取存失败"
}
return bln;
}
/* (non-Javadoc)
* @see jp.com.cost.dao.BookDao#updateSWJH(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public boolean updateSWJH(String id, String state, String remark,
String wtg)
{
boolean bln = false;
Book book = this.findSWGLById(id);
book.setState(wtg);
try {
getHibernateTemplate().update(book);
Log.insert("book", "modifySWJH");
bln = true;
} catch (Exception e) {
// TODO: 请补充异常捕获@SW4201E2S
// EMSG: " [内部错误]: 数据更新失败@SW4201E2S「牵涉字段 业务状态 state」"
// MSG: "数据取存失败"
}
return bln;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -