129 lines
3.1 KiB
Java
129 lines
3.1 KiB
Java
package com.tenwa.customer.controller.person;
|
|
|
|
import jbo.app.tenwa.customer.CUSTOMER_ATTRIBUTION;
|
|
|
|
import com.amarsoft.are.jbo.BizObject;
|
|
import com.amarsoft.are.jbo.BizObjectManager;
|
|
import com.amarsoft.are.jbo.BizObjectQuery;
|
|
import com.amarsoft.are.jbo.JBOFactory;
|
|
import com.amarsoft.are.jbo.JBOTransaction;
|
|
|
|
public class CustomerPersonAttributionController {
|
|
|
|
private String userId;
|
|
private String customerId;
|
|
private String status;
|
|
private String id;
|
|
private String isMain;
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(String status) {
|
|
this.status = status;
|
|
}
|
|
public String getUserId() {
|
|
return userId;
|
|
}
|
|
|
|
public void setUserId(String userId) {
|
|
this.userId = userId;
|
|
}
|
|
|
|
public String getCustomerId() {
|
|
return customerId;
|
|
}
|
|
|
|
public void setCustomerId(String customerId) {
|
|
this.customerId = customerId;
|
|
}
|
|
|
|
public String getIsMain() {
|
|
return isMain;
|
|
}
|
|
|
|
public void setIsMain(String isMain) {
|
|
this.isMain = isMain;
|
|
}
|
|
|
|
/**
|
|
* 设置是否主归属人
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String setMainFlag(JBOTransaction tx) throws Exception{
|
|
String result = "true";
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ATTRIBUTION.CLASS_NAME);
|
|
tx.join(bom);
|
|
BizObject bo1 = bom.createQuery("id=:id").setParameter("id",id).getSingleResult(false);
|
|
//设置主归属人
|
|
if("yes".equals(isMain)){
|
|
if(bo1!=null){//检查是否已为主归属人
|
|
if(bo1.getAttribute("isMain").getString().equals("yes")){
|
|
return "false1";
|
|
}
|
|
}
|
|
}else{//取消主归属人
|
|
if(bo1!=null){//归属人是创建人员,不能取消
|
|
if(bo1.getAttribute("userid").getString().equals(bo1.getAttribute("inputuserid").getString())){
|
|
return "false3";
|
|
}else{//检查是否已不是主归属人
|
|
if(bo1.getAttribute("isMain").getString().equals("no")){
|
|
return "false2";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//更新主归属人
|
|
BizObjectQuery bq1 = bom.createQuery("update O set isMain=:isMain where id=:id ");
|
|
bq1.setParameter("id",id).setParameter("isMain",isMain);
|
|
bq1.executeUpdate();
|
|
return result;
|
|
}
|
|
/**
|
|
* 更新生效失效
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String updateStatus(JBOTransaction tx) throws Exception{
|
|
String result = "true";
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_ATTRIBUTION.CLASS_NAME);
|
|
tx.join(bom);
|
|
BizObject bo1 = bom.createQuery("id=:id ").setParameter("id", id).getSingleResult(false);
|
|
//设置为生效
|
|
if("yes".equals(status)){
|
|
if(bo1!=null){//检查是否已生效
|
|
if(bo1.getAttribute("status").equals("yes")){
|
|
return "false1";
|
|
}
|
|
}
|
|
}else{//设置失效
|
|
if(bo1!=null){//归属人是创建人员,不能取消
|
|
if(bo1.getAttribute("userid").getString().equals(bo1.getAttribute("inputuserid").getString())){
|
|
return "false3";
|
|
}else{//已失效
|
|
if(bo1.getAttribute("status").getString().equals("no")){
|
|
return "false2";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//更新状态
|
|
BizObjectQuery bq1 = bom.createQuery("update O set status=:status where id=:id ");
|
|
bq1.setParameter("id",id).setParameter("status", status);
|
|
bq1.executeUpdate();
|
|
return result;
|
|
}
|
|
}
|