apzl_leasing/calc/com/tenwa/reckon/executor/ManageSubsectionData.java
2021-07-20 16:18:15 +08:00

67 lines
1.9 KiB
Java

package com.tenwa.reckon.executor;
import java.util.List;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import jbo.app.tenwa.calc.LB_SUBSECTION_INFO_TEMP;
public class ManageSubsectionData {
private String subsectionNumber;
private String projectId;
private String flowunid;
public String getSubsectionNumber() {
return subsectionNumber;
}
public void setSubsectionNumber(String subsectionNumber) {
this.subsectionNumber = subsectionNumber;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getFlowunid() {
return flowunid;
}
public void setFlowunid(String flowunid) {
this.flowunid = flowunid;
}
public String saveSubsection(JBOTransaction tx) throws Exception {
Integer sn = new Integer(subsectionNumber);
BizObjectManager lsitManger = JBOFactory.getBizObjectManager(LB_SUBSECTION_INFO_TEMP.CLASS_NAME, tx);
List<BizObject> lsitList = lsitManger.createQuery(" flowunid=:flowunid ").setParameter("flowunid", flowunid).getResultList(false);
if( sn >= 0 ) {
if(lsitList.size()==0 || sn > lsitList.size()) {
int i = ( lsitList.size()+1 ) ;
for( ; i<=sn ; i++ ) {
BizObject lsit = lsitManger.newObject();
lsit.setAttributeValue("subsection_number", i);
lsit.setAttributeValue("projectid", projectId);
lsit.setAttributeValue("flowunid", flowunid);
lsitManger.saveObject(lsit);
}
}else if( sn < lsitList.size()){
int i = (sn +1);
for( ; i<= lsitList.size() ; i++ ) {
BizObject lsit = lsitManger.createQuery("flowunid =:flowunid and subsection_number =:subsectionNumber").setParameter("flowunid", flowunid).setParameter("subsectionNumber", i).getSingleResult(true);
if(lsit!=null ) {
lsitManger.deleteObject(lsit);
}
}
}
}
return "success";
}
}