📄 chancebiz.java
字号:
package org.jb.y272.team0.biz;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.hibernate.Hibernate;
import org.jb.common.biz.BaseBiz;
import org.jb.common.util.PageResult;
import org.jb.y272.team0.entity.CstCustomer;
import org.jb.y272.team0.entity.CstLinkman;
import org.jb.y272.team0.entity.SalChance;
/**
* 管理业务逻辑类
* @author hailong.liu
*/
public class ChanceBiz extends BaseBiz {
/* 复杂业务方法 */
/* 简单业务方法 */
/**
* 加载
*/
public SalChance get(Serializable id){
SalChance ret = (SalChance)this.getCommonDAO().get(SalChance.class, id);
return ret;
}
/**
* 添加
*/
public boolean add(SalChance item){
item.setChcCreateDate(new java.sql.Date(new java.util.Date().getTime()));
this.getCommonDAO().add(item);
return true;
}
/**
* 删除
*/
public boolean del(Serializable id){
this.getCommonDAO().del(SalChance.class, id);
return true;
}
/**
* 修改
*/
public boolean update(SalChance item){
this.getCommonDAO().update(item);
return true;
}
/**
* 查询
*/
public void search(SalChance condition, PageResult pageResult) {
String hql = "select o from SalChance o where 1=1 ";
if (null!=condition){
if (isNotNullOrEmpty(condition.getChcSource())){
hql += "and o.chcSource like '%"
+condition.getChcSource()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcCustName())){
hql += "and o.chcCustName like '%"
+condition.getChcCustName()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcTitle())){
hql += "and o.chcTitle like '%"
+condition.getChcTitle()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcLinkman())){
hql += "and o.chcLinkman like '%"
+condition.getChcLinkman()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcTel())){
hql += "and o.chcTel like '%"
+condition.getChcTel()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcDesc())){
hql += "and o.chcDesc like '%"
+condition.getChcDesc()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcCreateBy())){
hql += "and o.chcCreateBy like '%"
+condition.getChcCreateBy()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcDueTo())){
hql += "and o.chcDueTo like '%"
+condition.getChcDueTo()+"%' ";
}
if (isNotNullOrEmpty(condition.getChcStatus())){
// hql += "and o.chcStatus like '%"
// +condition.getChcStatus()+"%' ";
if ("未指派".equals(condition.getChcStatus())){
hql += "and o.chcStatus = 1 ";
}else if ("非新建".equals(condition.getChcStatus())){
hql += "and o.chcStatus <> 1 ";
}
}
}
if (isNotNullOrEmpty(pageResult.getOrderBy())){
String sort = pageResult.getSort();
hql += "order by " + pageResult.getOrderBy() + " " +sort;
if ("asc".equals(sort)){
pageResult.setSort("desc");
}else{
pageResult.setSort("asc");
}
}else{
hql += "order by o.chcId desc";
}
this.getCommonDAO().listByPage(hql,pageResult);
}
public void dispatch(SalChance chc) {
Long id = chc.getChcId();
SalChance item = this.get(id);
item.setChcDueDate(new java.sql.Date(new java.util.Date().getTime()));
item.setChcDueTo(chc.getChcDueTo());
item.setChcDueId(chc.getChcDueId());
item.setChcStatus("2");
this.update(item);
}
public SalChance getWithPlans(long l) {
SalChance ret = this.get(l);
Hibernate.initialize(ret.getSalPlans());
return ret;
}
public void succes(long l) {
SalChance item = this.get(l);
item.setChcStatus("3");
this.update(item);
CstCustomer cst = new CstCustomer();
DateFormat df = new SimpleDateFormat("yyMMddHHmmssS");
String cno = df.format(new java.util.Date());
cst.setCustName(item.getChcCustName());
cst.setCustNo("KH" + cno);
cst.setCustStatus("1");
this.getCommonDAO().add(cst);
if (null!=item.getChcLinkman() && !"".equals(item.getChcLinkman().trim())){
CstLinkman lk = new CstLinkman();
lk.setCstCustomer(cst);
lk.setLkmCustName(item.getChcCustName());
lk.setLkmName(item.getChcLinkman());
lk.setLkmTel(item.getChcTel());
this.getCommonDAO().add(lk);
}
}
public void fail(long l) {
SalChance item = this.get(l);
item.setChcStatus("4");
this.update(item);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -