367 lines
13 KiB
Java
367 lines
13 KiB
Java
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 = "";
|
||
|
||
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;
|
||
}
|
||
|
||
/**
|
||
* <20><><EFBFBD><EFBFBD>
|
||
* @param tx
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String del(JBOTransaction tx)throws Exception{
|
||
BizObjectManager bom = JBOFactory.getBizObjectManager(CUSTOMER_GROUP_COMPANY.CLASS_NAME);
|
||
tx.join(bom);
|
||
//<2F><><EFBFBD>˼<EFBFBD><CBBC><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬
|
||
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);
|
||
//<2F><><EFBFBD>˼<EFBFBD><CBBC><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬
|
||
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);
|
||
//<2F><><EFBFBD>˼<EFBFBD><CBBC><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬
|
||
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";
|
||
}
|
||
|
||
/**
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD>ظ<EFBFBD>
|
||
* @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);
|
||
//<2F><>ѯ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
|
||
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);
|
||
//<2F><>ѯ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
|
||
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);
|
||
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
|
||
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";
|
||
}
|
||
}
|
||
//<2F>жϾ<D0B6><CFBE><EFBFBD><EFBFBD>̱<EFBFBD><CCB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>ǰҳ<C7B0><D2B3>
|
||
/*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;
|
||
}
|
||
|
||
|
||
|
||
//У<><D0A3><EFBFBD>ļ<EFBFBD><C4BC>嵥<EFBFBD><E5B5A5><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ψһ
|
||
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";
|
||
}
|
||
}
|
||
|
||
|
||
//У<>龭<EFBFBD><E9BEAD><EFBFBD>̶<EFBFBD><CCB6><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
|
||
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<Map<String, String>> 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 "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD>㣡";
|
||
}
|
||
return "true";
|
||
|
||
}
|
||
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥
|
||
public String copyOneFile(JBOTransaction tx) throws Exception{
|
||
if(OLDITEMNO.length()<4){
|
||
Map<String,String> fromCondtion=new HashMap<String, String>();
|
||
fromCondtion.put("CodeNo", "DocList");
|
||
fromCondtion.put("IsInUse", "1");
|
||
fromCondtion.put("itemno", OLDITEMNO);
|
||
Map<String,String> otherProperty=new HashMap<String, String>();
|
||
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<BizObject> 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<String,String> fromCondtion=new HashMap<String, String>();
|
||
fromCondtion.put("CodeNo", "DocList");
|
||
fromCondtion.put("IsInUse", "1");
|
||
fromCondtion.put("itemno", oldnumber);
|
||
Map<String,String> otherProperty=new HashMap<String, String>();
|
||
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<String,String> fromCondtion=new HashMap<String, String>();
|
||
fromCondtion.put("DOC_CLASS_ITEMNO", oldnumber);
|
||
Map<String,String> otherProperty=new HashMap<String, String>();
|
||
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);
|
||
}
|
||
|
||
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
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<Map<String, String>> dataList = conn.executeQuery(selectSql, ITEMNO+"%");
|
||
for (Map<String, String> 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";
|
||
}
|
||
} |