一、
public String next(){
getDeptPlan().setPlanVersion(Integer.toString(
DeptPlanBO.getMaxPlanVersion(getDeptPlan(), getBmYear())));
DeptPlanBO.saveDeptPlan(getDeptPlan(),getBmYear());
return SUCCESS;
}public static int getMaxPlanVersion(DeptPlan deptPlan, int year) {
if(deptPlan == null) {
printMsg("delete()","deptPlan is null");
return 0;
}
//如果不是新建的计划,则去数据库中最新的版本号加一返回
Session session = getSession(year);
String hql = "from DeptPlan where deptId = '"
+ CommonUtil.trim(deptPlan.getDeptId()) + "' and planYear ='"
+ CommonUtil.trim(deptPlan.getPlanYear()) + "' order by planVersion DESC";
List < DeptPlan > deptPlans = session.createQuery(hql).list();
if(HibernateUtil.notInTransaction(session)) session.close();
if(deptPlans.size() > 0) {
return CommonUtil.parseInt(deptPlans.get(0).getPlanVersion(),0) + 1;
}
return 0;
}二、
public String next(){
DeptPlan dept = DeptPlanBO.getMaxPlanVersion(getDeptPlan(), getBmYear())));
DeptPlanBO.saveDeptPlan(dept,getBmYear());
return SUCCESS;
}public static DeptPlan getMaxPlanVersion(DeptPlan deptPlan, int year) {
if(deptPlan == null) {
printMsg("delete()","deptPlan is null");
return 0;
}
//如果不是新建的计划,则去数据库中最新的版本号加一返回
Session session = getSession(year);
String hql = "from DeptPlan where deptId = '"
+ CommonUtil.trim(deptPlan.getDeptId()) + "' and planYear ='"
+ CommonUtil.trim(deptPlan.getPlanYear()) + "' order by planVersion DESC";
List < DeptPlan > deptPlans = session.createQuery(hql).list();
if(HibernateUtil.notInTransaction(session)) session.close();
if(deptPlans.size() > 0) {
deptPlan.setPlanVersion(CommonUtil.parseInt(deptPlans.get(0).getPlanVersion(),0) + 1);
}
return deptPlan;
}
public String next(){
getDeptPlan().setPlanVersion(Integer.toString(
DeptPlanBO.getMaxPlanVersion(getDeptPlan(), getBmYear())));
DeptPlanBO.saveDeptPlan(getDeptPlan(),getBmYear());
return SUCCESS;
}public static int getMaxPlanVersion(DeptPlan deptPlan, int year) {
if(deptPlan == null) {
printMsg("delete()","deptPlan is null");
return 0;
}
//如果不是新建的计划,则去数据库中最新的版本号加一返回
Session session = getSession(year);
String hql = "from DeptPlan where deptId = '"
+ CommonUtil.trim(deptPlan.getDeptId()) + "' and planYear ='"
+ CommonUtil.trim(deptPlan.getPlanYear()) + "' order by planVersion DESC";
List < DeptPlan > deptPlans = session.createQuery(hql).list();
if(HibernateUtil.notInTransaction(session)) session.close();
if(deptPlans.size() > 0) {
return CommonUtil.parseInt(deptPlans.get(0).getPlanVersion(),0) + 1;
}
return 0;
}二、
public String next(){
DeptPlan dept = DeptPlanBO.getMaxPlanVersion(getDeptPlan(), getBmYear())));
DeptPlanBO.saveDeptPlan(dept,getBmYear());
return SUCCESS;
}public static DeptPlan getMaxPlanVersion(DeptPlan deptPlan, int year) {
if(deptPlan == null) {
printMsg("delete()","deptPlan is null");
return 0;
}
//如果不是新建的计划,则去数据库中最新的版本号加一返回
Session session = getSession(year);
String hql = "from DeptPlan where deptId = '"
+ CommonUtil.trim(deptPlan.getDeptId()) + "' and planYear ='"
+ CommonUtil.trim(deptPlan.getPlanYear()) + "' order by planVersion DESC";
List < DeptPlan > deptPlans = session.createQuery(hql).list();
if(HibernateUtil.notInTransaction(session)) session.close();
if(deptPlans.size() > 0) {
deptPlan.setPlanVersion(CommonUtil.parseInt(deptPlans.get(0).getPlanVersion(),0) + 1);
}
return deptPlan;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货