package com.tenwa.customer.controller.group; import java.util.HashMap; import java.util.List; import java.util.Map; 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; import com.amarsoft.are.lang.DataElement; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.quartz.DateUtil; import com.tenwa.reckon.util.Conn; import jbo.app.tenwa.customer.CUSTOMER_GROUP_COMPANY; import jbo.app.tenwa.customer.DISTRIBUTOR_GROUP_COMPANY; import jbo.app.tenwa.customer.DISTRIBUTOR_GROUP_RELATION; import jbo.app.tenwa.customer.DISTRIBUTOR_INFO; import jbo.app.tenwa.doc.LB_DOCCONFIG; import jbo.com.tenwa.entity.comm.own.COUNTRY_DISTRICT_INFO; import jbo.sys.CODE_LIBRARY; public class CustomerGroupCompanyController { private String id = ""; private String group_name = ""; private String group_no = ""; private String DISTRIBUTOR_CODING = ""; private String flowunid; private String ITEMNO = ""; private String SORTNO = ""; private String contractId; private String ITEMNAME = ""; private String OLDITEMNO = ""; private String inputUserId = ""; private String inputOrgId = ""; private String businessLicenseNo = ""; public String getITEMNO() { return ITEMNO; } public void setITEMNO(String iTEMNO) { ITEMNO = iTEMNO; } public String getSORTNO() { return SORTNO; } public void setSORTNO(String sORTNO) { SORTNO = sORTNO; } public String getFlowunid() { return flowunid; } public void setFlowunid(String flowunid) { this.flowunid = flowunid; } public String getDISTRIBUTOR_CODING() { return DISTRIBUTOR_CODING; } public void setDISTRIBUTOR_CODING(String dISTRIBUTOR_CODING) { DISTRIBUTOR_CODING = dISTRIBUTOR_CODING; } public String getGroup_name() { return group_name; } public void setGroup_name(String group_name) { this.group_name = group_name; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getGroup_no() { return group_no; } public void setGroup_no(String group_no) { this.group_no = group_no; } public String getContractId() { return contractId; } public void setContractId(String contractId) { this.contractId = contractId; } public String getITEMNAME() { return ITEMNAME; } public void setITEMNAME(String iTEMNAME) { ITEMNAME = iTEMNAME; } public String getOLDITEMNO() { return OLDITEMNO; } public void setOLDITEMNO(String oLDITEMNO) { OLDITEMNO = oLDITEMNO; } public String getInputUserId() { return inputUserId; } public void setInputUserId(String inputUserId) { this.inputUserId = inputUserId; } public String getInputOrgId() { return inputOrgId; } public void setInputOrgId(String inputOrgId) { this.inputOrgId = inputOrgId; } public String getBusinessLicenseNo() { return businessLicenseNo; } public void setBusinessLicenseNo(String businessLicenseNo) { this.businessLicenseNo = businessLicenseNo; } /** * ���� * @param tx * @return * @throws Exception */ public String del(JBOTransaction tx)throws Exception{ BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_GROUP_COMPANY.CLASS_NAME); tx.join(bom); //���˼�����Ϣ����Ϊ����״̬ BizObjectQuery boq = bom.createQuery("update O set status = 'status03' where id=:id "); boq.setParameter("id",id); int i = boq.executeUpdate(); if(i == 1){ return "true"; } return "false"; } public String dis_del(JBOTransaction tx)throws Exception{ BizObjectManager bom = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_COMPANY.CLASS_NAME); tx.join(bom); //���˼�����Ϣ����Ϊ����״̬ BizObjectQuery boq = bom.createQuery("update O set status = 'status03' where id=:id "); boq.setParameter("id",id); int i = boq.executeUpdate(); if(i == 1){ return "true"; } return "false"; } public String deleterelation(JBOTransaction tx)throws Exception{ BizObjectManager bom = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_RELATION.CLASS_NAME); tx.join(bom); //���˼�����Ϣ����Ϊ����״̬ BizObjectQuery boq = bom.createQuery("delete from O where id=:id "); boq.setParameter("id",id); int i = boq.executeUpdate(); if(i == 1){ return "true"; } return "false"; } /** * �������Ʋ����ظ� * @param tx * @return * @throws Exception */ public String group_name(JBOTransaction tx)throws Exception{ BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_GROUP_COMPANY.CLASS_NAME); tx.join(bom); //��ѯ�ü��������Ƿ��Ѵ��� BizObject CUSTOMER_GROUP_COMPANY = bom.createQuery("group_name=:group_name").setParameter("group_name",group_name).getSingleResult(false); if(CUSTOMER_GROUP_COMPANY != null){ return CUSTOMER_GROUP_COMPANY.getAttribute("status").toString(); }else{ return "false"; } } public String distributor_group_name(JBOTransaction tx)throws Exception{ BizObjectManager bom = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_COMPANY.CLASS_NAME); tx.join(bom); //��ѯ�ü��������Ƿ��Ѵ��� BizObject CUSTOMER_GROUP_COMPANY = bom.createQuery("group_name=:group_name").setParameter("group_name",group_name).getSingleResult(false); if(CUSTOMER_GROUP_COMPANY != null){ return CUSTOMER_GROUP_COMPANY.getAttribute("status").toString(); }else{ return "false"; } } public String checkCode(JBOTransaction tx)throws Exception{ BizObjectManager bom = JBOFactory.getBizObjectManager(COUNTRY_DISTRICT_INFO.CLASS_NAME); tx.join(bom); //��ѯ���������Ƿ��Ѵ��� BizObject CUSTOMER_GROUP_COMPANY = bom.createQuery("district_code=:district_code").setParameter("district_code",group_name).getSingleResult(false); if(CUSTOMER_GROUP_COMPANY != null){ return "false"; }else{ return "success"; } } public String distributor_group_no(JBOTransaction tx) throws Exception{ BizObjectManager dgcm = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_COMPANY.CLASS_NAME); BizObject dgc = dgcm.createQuery("group_no=:group_no").setParameter("group_no", group_no).getSingleResult(false); if(dgc == null){ return "true"; }else{ return "false"; } } public String distributor_basic(JBOTransaction tx) throws Exception{ BizObjectManager dgcm = JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO.CLASS_NAME); BizObject dgc = dgcm.createQuery("DISTRIBUTOR_CODING=:DISTRIBUTOR_CODING").setParameter("DISTRIBUTOR_CODING", DISTRIBUTOR_CODING).getSingleResult(false); if(dgc == null){ return "true"; }else{ return "false"; } } //�жϾ����̱����Ƿ��ǵ�ǰҳ�� /*public String distributor_basicS(JBOTransaction tx) throws Exception{ BizObjectManager dgcm = JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO_TEMP.CLASS_NAME); BizObject dgc = dgcm.createQuery("flowunid=:flowunid").setParameter("flowunid", this.flowunid).getSingleResult(true); String distributor_coding = dgc.getAttribute("DISTRIBUTOR_CODING").toString(); return distributor_coding; }*/ public String getNewId(JBOTransaction tx) throws Exception{ String id=""; BizObjectManager dgcm = JBOFactory.getBizObjectManager(DISTRIBUTOR_GROUP_COMPANY.CLASS_NAME); BizObject dgc = dgcm.createQuery("group_no=:group_no").setParameter("group_no", group_no).getSingleResult(false); if(dgc != null){ id= dgc.getAttribute("ID").getString(); } return id; } //У���ļ��嵥���ô��������Ƿ�Ψһ public String file_repeat(JBOTransaction tx) throws Exception{ BizObjectManager filedc = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME); BizObject dgfc = filedc.createQuery("ITEMNO=:ITEMNO and codeno='DocList'").setParameter("ITEMNO", ITEMNO).getSingleResult(false); if(dgfc == null){ return "true"; }else{ return "false"; } } //УÑé¾­ÏúÉ̶î¶ÈÊÇ·ñ×ã¹» public String checkTotal(JBOTransaction tx) throws Exception{ Conn conn = new Conn(tx); String sql = "SELECT IFNULL(convert(di.relines using gbk),dti.Total)-IFNULL(lcc.CLEAN_LEASE_MONEY,0) total,dti.channeltype FROM lb_contract_info lci LEFT JOIN vi_distributor_lines di ON di.distributor_no=lci.distributor_id LEFT JOIN LC_CALC_CONDITION lcc ON lcc.contract_id=lci.id left join distributor_info dti on dti.distributor_no=lci.distributor_id WHERE lci.id=? "; List> results = conn.executeQuery(sql, this.contractId); String istotal = results.get(0).get("total"); String channeltype = results.get(0).get("channeltype"); if("01".equals(channeltype) && new Double(istotal) < 0){ return "¾­ÏúÉ̶î¶È²»×㣡"; } return "true"; } //¸´ÖÆ×ÊÁÏÇåµ¥ public String copyOneFile(JBOTransaction tx) throws Exception{ if(OLDITEMNO.length()<4){ Map fromCondtion=new HashMap(); fromCondtion.put("CodeNo", "DocList"); fromCondtion.put("IsInUse", "1"); fromCondtion.put("itemno", OLDITEMNO); Map otherProperty=new HashMap(); otherProperty.put("itemno", ITEMNO); otherProperty.put("itemname", ITEMNAME); otherProperty.put("sortno", ITEMNO); otherProperty.put("CodeNo", "DocList"); otherProperty.put("INPUTUSER", inputUserId); otherProperty.put("INPUTORG", inputOrgId); otherProperty.put("INPUTTIME", DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")); otherProperty.put("UPDATEUSER", inputUserId); otherProperty.put("UPDATETIME", DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")); DataOperatorUtil.copySingleJBO(CODE_LIBRARY.CLASS_NAME, fromCondtion, CODE_LIBRARY.CLASS_NAME, null, otherProperty, tx); BizObjectManager clManage = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME); List clList = clManage.createQuery(" v.LEFT(itemno,3)=:ITEMNO and codeno='DocList' and IsInUse='1' and v.LENGTH(itemno)>4").setParameter("ITEMNO", OLDITEMNO).getResultList(false); if(clList!=null && clList.size()>0){ for (BizObject cl : clList) { String oldnumber = cl.getAttribute("ITEMNO").getString(); String newnumber = ITEMNO+oldnumber.substring(3, oldnumber.length()); this.copyTwoFile(tx, oldnumber, newnumber, cl.getAttribute("ITEMNAME").getString()); } } }else{ this.copyTwoFile(tx, OLDITEMNO, ITEMNO, ITEMNAME); } return "true"; } public void copyTwoFile(JBOTransaction tx,String oldnumber,String newnumber,String newName) throws Exception{ Map fromCondtion=new HashMap(); fromCondtion.put("CodeNo", "DocList"); fromCondtion.put("IsInUse", "1"); fromCondtion.put("itemno", oldnumber); Map otherProperty=new HashMap(); otherProperty.put("itemno", newnumber); otherProperty.put("itemname", newName); otherProperty.put("sortno", newnumber); otherProperty.put("CodeNo", "DocList"); otherProperty.put("INPUTUSER", inputUserId); otherProperty.put("INPUTORG", inputOrgId); otherProperty.put("INPUTTIME", DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")); otherProperty.put("UPDATEUSER", inputUserId); otherProperty.put("UPDATETIME", DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")); DataOperatorUtil.copySingleJBO(CODE_LIBRARY.CLASS_NAME, fromCondtion, CODE_LIBRARY.CLASS_NAME, null, otherProperty, tx); this.copySonFile(tx, oldnumber, newnumber); } public void copySonFile(JBOTransaction tx,String oldnumber,String newnumber) throws Exception{ Map fromCondtion=new HashMap(); fromCondtion.put("DOC_CLASS_ITEMNO", oldnumber); Map otherProperty=new HashMap(); otherProperty.put("DOC_CLASS_ITEMNO", newnumber); otherProperty.put("INPUTUSERID", inputUserId); otherProperty.put("INPUTORGID", inputOrgId); otherProperty.put("INPUTTIME", DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")); DataOperatorUtil.copyJBOSet(LB_DOCCONFIG.CLASS_NAME, fromCondtion, LB_DOCCONFIG.CLASS_NAME, null, otherProperty,null, tx); } //ɾ³ý¹ØÁªÊý¾Ý public String deleteCorrelationFile(JBOTransaction tx) throws Exception{ Conn conn = new Conn(tx); if(ITEMNO != null && ITEMNO.length()>4){ String deleteSql = "DELETE FROM LB_DOCCONFIG WHERE DOC_CLASS_ITEMNO=?"; conn.executeUpdate(deleteSql,ITEMNO); }else{ String selectSql = "SELECT itemno FROM CODE_LIBRARY WHERE CodeNo='DocList' AND IsInUse='1' AND itemno LIKE ? AND LENGTH(itemno)>4"; List> dataList = conn.executeQuery(selectSql, ITEMNO+"%"); for (Map map : dataList) { String inemno = map.get("itemno"); String deleteSql = "DELETE FROM LB_DOCCONFIG WHERE DOC_CLASS_ITEMNO=?"; conn.executeUpdate(deleteSql,inemno); String codeSql = "DELETE FROM CODE_LIBRARY WHERE CodeNo='DocList' AND IsInUse='1' AND itemno=?"; conn.executeUpdate(codeSql,inemno); } } return "success"; } //УÑé¾­ÏúÉÌÉóºËÉç»áͳһÐÅÓôúÂëÊÇ·ñÒѾ­´æÔÚ public String checkBusinessLicenseNo(JBOTransaction tx) throws Exception{ List> dataBySql = DataOperatorUtil.getDataBySql("select id from distributor_info_temp where id<>'"+id+"' and BUSINESS_LICENSE_NO='"+businessLicenseNo+"' "); if(dataBySql!=null && dataBySql.size() > 0) { return "false"; } dataBySql = DataOperatorUtil.getDataBySql("select id from distributor_info where BUSINESS_LICENSE_NO='"+businessLicenseNo+"' "); if(dataBySql!=null && dataBySql.size() > 0) { return "false"; } return "true"; } }