apzl_leasing/src_tenwa/com/tenwa/apzl/comm/PartdeptDistribute.java
2019-01-15 15:34:16 +08:00

162 lines
4.7 KiB
Java

package com.tenwa.apzl.comm;
import java.util.ArrayList;
import java.util.List;
import jbo.app.tenwa.customer.DISTRIBUTOR_ACCOUNT;
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
import jbo.sys.OVERDUE_DUNNING_INFO;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
public class PartdeptDistribute {
private String userid;
private String contract_number;
private String ids;
private String distributorNo;
private String accountId;
private String isMain;
public String getIsMain() {
return isMain;
}
public void setIsMain(String isMain) {
this.isMain = isMain;
}
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public String getDistributorNo() {
return distributorNo;
}
public void setDistributorNo(String distributorNo) {
this.distributorNo = distributorNo;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getContract_number() {
return contract_number;
}
public void setContract_number(String contract_number) {
this.contract_number = contract_number;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
/*
* Ñ¡Ôñ´ß¿îÔ±
*/
public String selectPartdept(JBOTransaction tx){
String userid = this.getUserid();
String contractNumber = this.getContract_number();
try {
BizObject contractInfo = JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO.CLASS_NAME, "contract_no=:contract_number").setParameter("contract_number", contractNumber).getSingleResult(false);
String contractId = contractInfo.getAttribute("id").toString();
BizObjectManager overdueManager = JBOFactory.getBizObjectManager(OVERDUE_DUNNING_INFO.CLASS_NAME, tx);
BizObject overdue = overdueManager.createQuery("contract_id=:contract_id").setParameter("contract_id", contractId).getSingleResult(false);
if(overdue == null){
BizObject overdue2 = overdueManager.newObject();
overdue2.setAttributeValue("contract_id", contractId);
overdue2.setAttributeValue("part_dept", userid);
overdueManager.saveObject(overdue2);
}else{
overdueManager.createQuery("update O set part_dept=:part_dept where contract_id=:contract_id")
.setParameter("contract_id", contractId).setParameter("part_dept", userid).executeUpdate();
}
} catch (JBOException e) {
e.printStackTrace();
}
return "";
}
/**
* ÅúÁ¿Ð޸Ĵ߿îÔ±
*/
public String selectPartdepts(JBOTransaction tx){
String userid = this.getUserid();
String[] arrIds = ids.split("@");
BizObjectManager overdueManager;
try {
overdueManager = JBOFactory.getBizObjectManager(OVERDUE_DUNNING_INFO.CLASS_NAME, tx);
for (int i = 0; i < arrIds.length; i++) {
String contractId = arrIds[i];
BizObject overdue = overdueManager.createQuery("contract_id=:contract_id").setParameter("contract_id", contractId).getSingleResult(false);
if(overdue == null){
BizObject overdue2 = overdueManager.newObject();
overdue2.setAttributeValue("contract_id", contractId);
overdue2.setAttributeValue("part_dept", userid);
overdueManager.saveObject(overdue2);
}else{
overdueManager.createQuery("update O set part_dept=:part_dept where contract_id=:contract_id")
.setParameter("contract_id", contractId).setParameter("part_dept", userid).executeUpdate();
}
}
} catch (JBOException e) {
e.printStackTrace();
}
return "";
}
/**
* ÅжϾ­ÏúÉÌÕË»§Ö÷ÕË»§£¬Ö»ÄÜ´æÔÚÒ»¸öÖ÷ÕË»§
*/
public String isMainAccount(JBOTransaction tx){
String msg = "";
try {
if("Y".equals(isMain)){
List<String> list = new ArrayList<String>();
String main = "";
@SuppressWarnings("unchecked")
List<BizObject> resultList = JBOFactory.createBizObjectQuery(DISTRIBUTOR_ACCOUNT.CLASS_NAME, "distributor_id=:distributor_id")
.setParameter("distributor_id", this.distributorNo).getResultList(false);
for (BizObject bo : resultList) {
main=bo.getAttribute("is_main")==null?"":bo.getAttribute("is_main").toString();
String accid = bo.getAttribute("ID").toString();
//Èç¹û´ËÕË»§ÊÇÖ÷ÕË»§Ôò²»²ÎÓëÅжÏ
if(!(accid.equals(accountId) && main.equals("Y"))){
list.add(main);
}
}
if(list.contains("Y")==true){
msg = "Ò»¸ö¾­ÏúÉÌÖ»ÄÜÓÐÒ»¸öÖ÷ÕË»§";
}
}
return msg;
} catch (JBOException e) {
e.printStackTrace();
}
return msg;
}
}