2018-08-04 15:51:40 +08:00

68 lines
2.5 KiB
Java

package com.tenwa.flow.adjustinterest.action;
import java.util.List;
import jbo.app.tenwa.calc.LC_ADJUST_CONTRACT_TEMP;
import jbo.app.tenwa.doc.LB_DOCATTRIBUTE;
import jbo.app.tenwa.doc.LB_DOCLIBRARY;
import jbo.app.tenwa.doc.LB_DOCRELATIVE;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.doc.action.DocListAction;
public class AdjustInterestAction {
public String flowunid;
public String plan_number;
@SuppressWarnings("unchecked")
public void deleteFile(JBOTransaction tx) throws Exception{
List<BizObject> list=JBOFactory.createBizObjectQuery(LB_DOCRELATIVE.CLASS_NAME,"flow_unid=:flowunid and OBJECTTYPE='AdjustInterst' and plan_number=:plannumber").setParameter("flowunid", this.flowunid).setParameter("plannumber", plan_number) .getResultList(false);
DocListAction doc=new DocListAction();
for(BizObject bo:list){
doc.setRelativeId(bo.getAttribute("id").getString());
doc.deleteRelative(tx);
}
}
public static String getFile(String id) throws JBOException{
BizObject bo=JBOFactory.createBizObjectQuery(LC_ADJUST_CONTRACT_TEMP.CLASS_NAME,"id=:id").setParameter("id", id).getSingleResult(false);
BizObject rela=JBOFactory.createBizObjectQuery(LB_DOCRELATIVE.CLASS_NAME,"flow_unid=:flowunid and plan_number=:paymentnumber and OBJECTTYPE='AdjustInterst'")
.setParameter("flowunid", bo.getAttribute("flowunid").getString())
.setParameter("paymentnumber", bo.getAttribute("payment_number").getString())
.getSingleResult(false);
StringBuffer sb=new StringBuffer();
sb.append("{");
if(rela==null){
sb.append("}");
}else{
BizObject lib=JBOFactory.createBizObjectQuery(LB_DOCLIBRARY.CLASS_NAME,"relative_id=:relaid").setParameter("relaid", rela.getAttribute("id").getString()).getSingleResult(false);
BizObject attr=JBOFactory.createBizObjectQuery(LB_DOCATTRIBUTE.CLASS_NAME,"library_id=:libid").setParameter("libid", lib.getAttribute("id").getString()).getSingleResult(false);
sb.append("\"id\":\""+attr.getAttribute("id").getString()+"\",");
sb.append("\"filename\":\""+attr.getAttribute("FileName").getString()+"\"}");
}
return sb.toString();
}
public String getFlowunid() {
return flowunid;
}
public void setFlowunid(String flowunid) {
this.flowunid = flowunid;
}
public String getPlan_number() {
return plan_number;
}
public void setPlan_number(String plan_number) {
this.plan_number = plan_number;
}
}