159 lines
4.7 KiB
Java
159 lines
4.7 KiB
Java
package com.tenwa.customer.controller.supplier;
|
|
|
|
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 com.tenwa.comm.util.date.DateAssistant;
|
|
|
|
public class NewSupplierController{
|
|
|
|
private String certType="";
|
|
private String certId="";
|
|
private String nationCode="";
|
|
private String customerType="";
|
|
private String customerName="";
|
|
private String userId="";
|
|
private String orgId="";
|
|
private String customerId="";
|
|
|
|
|
|
public String getCertType() {
|
|
return certType;
|
|
}
|
|
|
|
|
|
public void setCertType(String certType) {
|
|
this.certType = certType;
|
|
}
|
|
|
|
|
|
public String getCertId() {
|
|
return certId;
|
|
}
|
|
|
|
|
|
public void setCertId(String certId) {
|
|
this.certId = certId;
|
|
}
|
|
|
|
|
|
public String getNationCode() {
|
|
return nationCode;
|
|
}
|
|
|
|
|
|
public void setNationCode(String nationCode) {
|
|
this.nationCode = nationCode;
|
|
}
|
|
|
|
|
|
public String getCustomerType() {
|
|
return customerType;
|
|
}
|
|
|
|
|
|
public void setCustomerType(String customerType) {
|
|
this.customerType = customerType;
|
|
}
|
|
|
|
|
|
public String getCustomerName() {
|
|
return customerName;
|
|
}
|
|
|
|
|
|
public void setCustomerName(String customerName) {
|
|
this.customerName = customerName;
|
|
}
|
|
|
|
|
|
public String getUserId() {
|
|
return userId;
|
|
}
|
|
|
|
|
|
public void setUserId(String userId) {
|
|
this.userId = userId;
|
|
}
|
|
|
|
|
|
public String getOrgId() {
|
|
return orgId;
|
|
}
|
|
|
|
|
|
public void setOrgId(String orgId) {
|
|
this.orgId = orgId;
|
|
}
|
|
|
|
public String getCustomerId() {
|
|
return customerId;
|
|
}
|
|
|
|
|
|
public void setCustomerId(String customerId) {
|
|
this.customerId = customerId;
|
|
}
|
|
|
|
/**
|
|
* ÐÂÔö¿Í»§Ð£Ñé
|
|
* @param tx
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public String checkCustomer(JBOTransaction tx)throws Exception {
|
|
BizObjectManager custManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_INFO");
|
|
BizObjectManager attrManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_ATTRIBUTION");
|
|
BizObjectManager certManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_CERT");
|
|
tx.join(custManager);
|
|
tx.join(attrManager);
|
|
tx.join(certManager);
|
|
//²éѯ¿Í»§ÃûÊÇ·ñ´æÔÚ
|
|
BizObject cust1 = custManager.createQuery("customername=:customername").setParameter("customername",customerName).getSingleResult(false);
|
|
//²éѯ֤¼þºÅÊÇ·ñ´æÔÚ
|
|
BizObject cust2 = custManager.createQuery("certid=:certid and certtype=:certtype").setParameter("certid",certId).setParameter("certtype",certType).getSingleResult(false);
|
|
if(cust2!=null){//¿Í»§Ãû´æÔÚ
|
|
return "FAIl@¿Í»§Ö¤¼þºÅÂë\""+certId+"\"ÔÚϵͳÖÐÒÑ×¢²á£¬²»ÄÜÖØ¸´×¢²á£¡";
|
|
}else if(cust1!=null){//Ö¤¼þ´æÔÚ
|
|
return "FAIl@¿Í»§Ãû\""+customerName+"\"ÒÑ´æÔÚ£¡";
|
|
}else{
|
|
//ÐÂÔö¿Í»§
|
|
BizObject newCustomer = custManager.newObject();
|
|
newCustomer.setAttributeValue("nationcode", nationCode);
|
|
newCustomer.setAttributeValue("customername", customerName);
|
|
newCustomer.setAttributeValue("certtype", certType);
|
|
newCustomer.setAttributeValue("certid", certId);
|
|
newCustomer.setAttributeValue("customertype", customerType);
|
|
newCustomer.setAttributeValue("inputuserid", userId);
|
|
newCustomer.setAttributeValue("inputorgid", orgId);
|
|
newCustomer.setAttributeValue("inputtime", DateAssistant.getTodayNow());
|
|
custManager.saveObject(newCustomer);
|
|
//½«×¢²áÖ¤¼þÌí¼Óµ½Ö¤¼þ±íÖÐ
|
|
BizObject newCert = certManager.newObject();
|
|
newCert.setAttributeValue("customerid", newCustomer.getAttribute("customerid").getString());
|
|
newCert.setAttributeValue("issuecountry",newCustomer.getAttribute("nationcode").getString());
|
|
newCert.setAttributeValue("certtype",newCustomer.getAttribute("certtype").getString());
|
|
newCert.setAttributeValue("certid",newCustomer.getAttribute("certid").getString());
|
|
newCert.setAttributeValue("customername",newCustomer.getAttribute("customername").getString());
|
|
newCert.setAttributeValue("inputuserid", userId);
|
|
newCert.setAttributeValue("inputorgid", orgId);
|
|
newCert.setAttributeValue("inputtime", DateAssistant.getTodayNow());
|
|
certManager.saveObject(newCert);
|
|
//½«¿Í»§¹éÊô±í
|
|
BizObject newAttribution = attrManager.newObject();
|
|
newAttribution.setAttributeValue("customerid", newCustomer.getAttribute("customerid").getString());
|
|
newAttribution.setAttributeValue("userid",userId);
|
|
newAttribution.setAttributeValue("isMain","yes");
|
|
newAttribution.setAttributeValue("status","yes");
|
|
newAttribution.setAttributeValue("inputuserid", userId);
|
|
newAttribution.setAttributeValue("inputorgid", orgId);
|
|
newAttribution.setAttributeValue("inputtime", DateAssistant.getTodayNow());
|
|
attrManager.saveObject(newAttribution);
|
|
|
|
return "SUCCESS@¿Í»§\""+customerName+"\"ÐÂÔö³É¹¦@"+newCustomer.getAttribute("customerid").getString();
|
|
}
|
|
}
|
|
|
|
}
|