172 lines
5.5 KiB
Java
172 lines
5.5 KiB
Java
package com.tenwa.customer.controller.cert;
|
|
|
|
import java.util.List;
|
|
|
|
import jbo.app.tenwa.customer.CUSTOMER_CERT;
|
|
|
|
|
|
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 CustomerCertController {
|
|
private String status="";
|
|
private String certtype="";
|
|
private String certid="";
|
|
private String orgID="";
|
|
private String id="";
|
|
private String customerId="";
|
|
private String issuecountry="";
|
|
private String customerid;
|
|
private String ismaincert="";
|
|
public String getStatus() {
|
|
return status;
|
|
}
|
|
public void setStatus(String status) {
|
|
this.status = status;
|
|
}
|
|
public String getIsmaincert() {
|
|
return ismaincert;
|
|
}
|
|
public void setIsmaincert(String ismaincert) {
|
|
this.ismaincert = ismaincert;
|
|
}
|
|
public String getIssuecountry() {
|
|
return issuecountry;
|
|
}
|
|
public void setIssuecountry(String issuecountry) {
|
|
this.issuecountry = issuecountry;
|
|
}
|
|
public String getCustomerId() {
|
|
return customerId;
|
|
}
|
|
public void setCustomerId(String customerId) {
|
|
this.customerId = 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 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 getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
//修改只有一条有效不允许失效
|
|
public String checkStatus(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom=JBOFactory.getBizObjectManager(CUSTOMER_CERT.CLASS_NAME);
|
|
tx.join(bom);
|
|
//查询此客户所有有效的证件信息
|
|
List<BizObject> CUSTOMER_CERT = bom.createQuery("customerid=:customerid and status='valid'").setParameter("customerid",customerid).getResultList(false);
|
|
//此客户只有一条有效证件信息时不许做失效操作
|
|
if(CUSTOMER_CERT.size() == 1){
|
|
return "false";
|
|
}
|
|
BizObjectQuery boq = bom.createQuery("update O set status = 'invalid' where id=:id");
|
|
boq.setParameter("id",id);
|
|
int i = boq.executeUpdate();
|
|
String s = Integer.toString(i);
|
|
return s;
|
|
}
|
|
//做失效操作是主证件会自动为否
|
|
public String checkIsmaincert(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_CERT.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将其他同类证件设为无效
|
|
BizObjectQuery boq1 = bom.createQuery("update O set ismaincert = 'no' where id<>:id" );
|
|
boq1.setParameter("id", id);
|
|
//将此证件设为生效
|
|
int i = boq1.executeUpdate();
|
|
String s = Integer.toString(i);
|
|
return s;
|
|
}
|
|
//设置主证件
|
|
public String initismaincert(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_CERT.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将其他同类证件设为无效
|
|
BizObjectQuery boq1 = bom.createQuery("update O set ismaincert = 'no' where id<>:id" );
|
|
boq1.setParameter("id", id);
|
|
//将此证件设为生效
|
|
BizObjectQuery boq2 = bom.createQuery("update O set ismaincert = 'yes' where id=:id").setParameter("id", id);
|
|
int i = boq2.executeUpdate();
|
|
boq1.executeUpdate();
|
|
String s = Integer.toString(i);
|
|
return s;
|
|
}
|
|
|
|
//生效
|
|
public String initStatusYes(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_CERT.CLASS_NAME);
|
|
tx.join(bom);
|
|
//先将其他同类证件设为无效
|
|
BizObjectQuery boq1 = bom.createQuery("update O set status = 'invalid'where id<>:id and certtype=:certtype");
|
|
BizObjectQuery boq3 = bom.createQuery("update O set ismaincert = 'no' where id<>:id and certtype=:certtype");
|
|
boq1.setParameter("id", id).setParameter("certtype",certtype);
|
|
boq3.setParameter("id", id).setParameter("certtype",certtype);
|
|
//将此证件设为生效
|
|
BizObject CUSTOMER_CERT = bom.createQuery("customerid=:customerid and status='valid' and certtype=:certtype").setParameter("customerid",customerid).setParameter("certtype",certtype).getSingleResult(false);//是否查询单条不是false
|
|
BizObjectQuery boq2;
|
|
if(CUSTOMER_CERT == null){
|
|
String ismaincert = "";
|
|
boq2= bom.createQuery("update O set status = 'valid',ismaincert='no' where id =:id").setParameter("id", id);
|
|
}else{
|
|
ismaincert=CUSTOMER_CERT.getAttribute("ismaincert").toString();
|
|
if("no".equals(ismaincert)){
|
|
boq2= bom.createQuery("update O set status = 'valid' where id =:id").setParameter("id", id);
|
|
}else{
|
|
boq2= bom.createQuery("update O set status = 'valid',ismaincert='yes' where id =:id").setParameter("id", id);
|
|
}
|
|
}
|
|
int i = boq2.executeUpdate();
|
|
boq1.executeUpdate();
|
|
boq3.executeUpdate();
|
|
String s = Integer.toString(i);
|
|
return s;
|
|
}
|
|
|
|
//失效
|
|
public String initStatusNo(JBOTransaction tx)throws Exception {
|
|
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_CERT.CLASS_NAME);
|
|
tx.join(bom);
|
|
//查询此客户所有有效的证件信息
|
|
List<BizObject> CUSTOMER_CERT = bom.createQuery("customerid=:customerid and status='valid'").setParameter("customerid",customerid).getResultList(false);
|
|
//此客户只有一条有效证件信息时不许做失效操作
|
|
if(CUSTOMER_CERT.size() == 1){
|
|
return "no";
|
|
}
|
|
BizObjectQuery boq = bom.createQuery("update O set status = 'invalid' where id=:id");
|
|
boq.setParameter("id",id);
|
|
int i = boq.executeUpdate();
|
|
String s = Integer.toString(i);
|
|
return s;
|
|
}
|
|
|
|
}
|
|
|
|
|