251 lines
8.2 KiB
Java
251 lines
8.2 KiB
Java
package com.tenwa.customer.controller.company;
|
||
|
||
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;
|
||
import com.tenwa.flow.util.FlowUtil;
|
||
|
||
public class NewCustomerCompanyController{
|
||
|
||
private String certType="";
|
||
private String certId="";
|
||
private String nationCode="";
|
||
private String customerType="";
|
||
private String customerName="";
|
||
private String userId="";
|
||
private String orgId="";
|
||
private String customerId="";
|
||
private String status="";
|
||
private String customernum;
|
||
|
||
public String getStatus() {
|
||
return status;
|
||
}
|
||
|
||
|
||
public void setStatus(String status) {
|
||
this.status = status;
|
||
}
|
||
|
||
|
||
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;
|
||
}
|
||
|
||
public String getCustomernum() {
|
||
return customernum;
|
||
}
|
||
|
||
|
||
public void setCustomernum(String customernum) {
|
||
this.customernum = customernum;
|
||
}
|
||
|
||
|
||
/**
|
||
* ÐÂÔö¿Í»§Ð£Ñé
|
||
* @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");
|
||
BizObjectManager typeManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_TYPE");
|
||
BizObjectManager financeManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_FINANCE");
|
||
tx.join(custManager);
|
||
tx.join(attrManager);
|
||
tx.join(certManager);
|
||
tx.join(typeManager);
|
||
BizObject cert=null;
|
||
//²éѯ֤¼þºÅÊÇ·ñ´æÔÚ
|
||
if(!((certType==null||"".equals(certType))||((certId==null||"".equals(certId))))){
|
||
cert = certManager.createQuery("certid=:certid ").setParameter("certid",certId).getSingleResult(false);
|
||
}
|
||
String certfrom="ϵͳ";
|
||
String scustomerid="";
|
||
if(cert!=null){//Ö¤¼þ´æÔÚ
|
||
scustomerid=cert.getAttribute("customerid").toString();
|
||
certfrom=typeManager.createQuery("customerid=:customerid and isoriginal='yes'").setParameter("customerid", scustomerid)
|
||
.getSingleResult(false).getAttribute("custtype").toString();
|
||
if("cust_type.cust".equals(certfrom)){
|
||
certfrom="³Ð×âÈË";
|
||
}else if("cust_type.assuror".equals(certfrom)){
|
||
certfrom="µ£±£ÈË";
|
||
}else if("cust_type.manufacturer".equals(certfrom)){
|
||
certfrom="ÖÆÔìÉÌ";
|
||
}else if("cust_type.vndr".equals(certfrom)){
|
||
certfrom="¹©Ó¦ÉÌ";
|
||
}else if("cust_type.othertype".equals(certfrom)){
|
||
certfrom="ÆäËûºÏ×÷·½";
|
||
}
|
||
|
||
return "FAIl@¿Í»§Ö¤¼þºÅÂë\""+certId+"\"ÔÚ"+certfrom+"ÖÐÒÑ×¢²á£¬²»ÄÜÖØ¸´×¢²á£¡";
|
||
|
||
}else{
|
||
|
||
//ÐÂÔö¿Í»§
|
||
BizObject newCustomer = custManager.newObject();
|
||
// newCustomer.setAttributeValue("customerid", "APZLC"+serin+serinum);
|
||
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);
|
||
if(customernum!="" && customernum!=null && customernum.length()>0){
|
||
newCustomer.setAttributeValue("customer_num", customernum);
|
||
}else{
|
||
newCustomer.setAttributeValue("customer_num", FlowUtil.getCustomer_Number(true,"C"));
|
||
}
|
||
newCustomer.setAttributeValue("inputtime", DateAssistant.getTodayNow());
|
||
custManager.saveObject(newCustomer);
|
||
if(!((certType==null||"".equals(certType))||((certId==null||"".equals(certId))))){
|
||
//½«×¢²áÖ¤¼þÌí¼Óµ½Ö¤¼þ±íÖÐ
|
||
BizObject newCert = certManager.newObject();
|
||
newCert.setAttributeValue("customerid", newCustomer.getAttribute("customerid").getString());
|
||
newCert.setAttributeValue("issuecountry",nationCode);
|
||
newCert.setAttributeValue("certtype",certType);
|
||
newCert.setAttributeValue("certid",certId);
|
||
newCert.setAttributeValue("status","valid");
|
||
newCert.setAttributeValue("customername",customerName);
|
||
newCert.setAttributeValue("inputuserid", userId);
|
||
newCert.setAttributeValue("inputorgid", orgId);
|
||
newCert.setAttributeValue("inputtime", DateAssistant.getTodayNow());
|
||
certManager.saveObject(newCert);
|
||
}
|
||
//½«¿Í»§¿Í»§Àà±ð´æÈëcustomer_type
|
||
BizObject newCustomerType = typeManager.newObject();
|
||
newCustomerType.setAttributeValue("customerid",newCustomer.getAttribute("customerid").getString());
|
||
newCustomerType.setAttributeValue("custtype","cust_type.cust");
|
||
/*if("status01".equals(status)){
|
||
newCustomerType.setAttributeValue("custstatus", "status01");//DZÔÚ
|
||
}else if("status02".equals(status)){
|
||
newCustomerType.setAttributeValue("custstatus", "status02");//Õýʽ
|
||
}else{
|
||
newCustomerType.setAttributeValue("custstatus", "status04");//ÆäËûĬÈϲݸå
|
||
}*/
|
||
if("status02".equals(status)){
|
||
newCustomerType.setAttributeValue("custstatus", "status02");//Õýʽ
|
||
}else{
|
||
newCustomerType.setAttributeValue("custstatus", "status04");//ÆäËûĬÈÏÕýʽ
|
||
}
|
||
newCustomerType.setAttributeValue("status","valid");
|
||
newCustomerType.setAttributeValue("isoriginal","yes");
|
||
newCustomerType.setAttributeValue("inputuserid", userId);
|
||
newCustomerType.setAttributeValue("inputorgid", orgId);
|
||
newCustomerType.setAttributeValue("inputtime", DateAssistant.getTodayNow());
|
||
typeManager.saveObject(newCustomerType);
|
||
|
||
//½«¿Í»§¹éÊô±í
|
||
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);
|
||
//½«¿Í»§´æ¿Í»§²ÆÎñ±àÂëά»¤
|
||
BizObject newFinance = financeManager.newObject();
|
||
newFinance.setAttributeValue("customerid", newCustomer.getAttribute("customerid").getString());
|
||
newFinance.setAttributeValue("customername", newCustomer.getAttribute("customername").getString());
|
||
financeManager.saveObject(newFinance);
|
||
return "SUCCESS@¿Í»§\""+customerName+"\"ÐÂÔö³É¹¦@"+newCustomer.getAttribute("customerid").getString();
|
||
}
|
||
}
|
||
public String checkCustomerNum(JBOTransaction tx)throws Exception {
|
||
BizObjectManager custManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_INFO");
|
||
BizObjectManager cltManager =JBOFactory.getFactory().getManager("jbo.app.tenwa.customer.CUSTOMER_LIST");
|
||
BizObject cus = custManager.createQuery("customername=:customername").setParameter("customername", customerName).getSingleResult(false);
|
||
if(cus!=null){
|
||
return "¿Í»§Ãû³ÆÒÑ´æÔÚ£¬ÇëÖØÐÂÑ¡Ôñ»òÌîд£¡£¡£¡";
|
||
}else{
|
||
BizObject cl = cltManager.createQuery("cust_name=:custname").setParameter("custname", customerName).getSingleResult(false);
|
||
if(cl!=null){
|
||
return "customernum@"+cl.getAttribute("cust_id").getString();
|
||
}
|
||
}
|
||
return "SUCCESS";
|
||
}
|
||
}
|