📄 changebusinessdaoimpl.java
字号:
package com.gs.component.change.dao;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import com.gs.component.change.util.ChangeUtil;
import com.gs.component.change.model.ChangeRecordModel;
import com.gs.util.*;
public class ChangeBusinessDAOImpl implements ChangeBusinessDAO{
SQLExecProxy sqlExecProxy = null;
public ChangeBusinessDAOImpl(){
sqlExecProxy = new SQLExecProxy();
}
/**
*方法名称:changeToReal
*功能描述:更新开业登记信息
*参数OLDSN:开业事务号
*参数updateItem:更新的字段
*参数updateValue:更新的值
*参数tableName:更新的表名
*创建人:冯瑞龙
*创建时间:2003-10-14
* 修改人:王杰飞
* 修改时间:2004-02-16
* 修改原因:子表新增数据没有正确的倒入in_sub_insdel表
*
* 修改人:...
* 修改时间:2004-03-23
* 修改位置:HashMap getChangeItemDetail(String SN,String BID,String INNERID,String PAGE)
* 修改原因:变更后的值可以为空,
* 修改说明:修改前是根据out_change表变更后的值不为空来判断,
* 修改为只要out_change表有相应的值无论是否为空都有效。
*/
public void changeToReal(String OLDSN,String updateItem,String updateValue,String tableName) throws Exception{
Connection conn = null;
Statement stmt = null;
String sql = null;
try{
conn = Common.getConnection();
// conn.setAutoCommit(false);
stmt = conn.createStatement();
if(updateValue == null || updateValue.equals("")){
sql = " update " + tableName + " set " + updateItem + "=null where field001='" + OLDSN + "'";
} else{
sql = " update " + tableName + " set " + updateItem + "='" + updateValue + "' where field001='" + OLDSN + "'";
}
stmt.executeUpdate(sql);
// conn.commit();
Debug.println("[ChangeBusinessDAOImpl-->>changeToReal()-->>sql]" + sql);
} catch(Exception e){
throw new AppException("[ChangeBusinessDAOImpl-->>changeToReal]: Exception " +
e.getMessage());
} finally{
try{
this.closeStatement(stmt);
} catch(Exception e){
}
try{
this.closeConnection(conn);
} catch(Exception e){
}
}
}
/**
*方法名称:moveFromOutToIn
*功能描述:把记录从外网拷贝到内网
*参数SN:事务号
*返回值:无
*创建人:冯瑞龙
*创建时间:2003-10-14
*/
public void moveFromOutToIn(String SN,String OLDSN) throws Exception{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
String SUB = null;
String OLDSUB = null;
ArrayList al = new ArrayList();
try{
conn = Common.getConnection();
// conn.setAutoCommit(false);
stmt = conn.createStatement();
sql = " insert into " + TableNameUtil.GSGSJIN_BASIS02 +
" (field001,field002,field046,field047,field052) select field001,field002,field046,field047,field052 from " +
TableNameUtil.GSGSJOUT_BASIS01 + " where field001 = '" + SN + "'";
//Debug.println("[OperateDAOImpl-->>moveFromOutToIn]sql:"+sql);
//stmt.executeUpdate(sql);
//导子表从01到02
//查找01表中需要更新的记录
sql = " select distinct field002 from " + TableNameUtil.GSGSJOUT_SUB01 + " where field001='" + SN + "'";
Debug.println("[ChangeBusinessDAOImpl-->>moveFromOutToIn()----sql1(查找01表中需要更新的记录)]" + sql);
rs = stmt.executeQuery(sql);
//先将记录取出
while(rs.next()){
al.add(rs.getString("field002"));
}
for(int i = 0;i < al.size();i++){
SUB = (String) al.get(i);
if(SUB.equals("sub01_08")){
continue;
}
Debug.println("IIIIIIIIIIII***********IIIIIIIIIIII<SUB>" + SUB);
OLDSUB = "sub02" + SUB.substring(5);
//删除02表中需要更新的记录
sql = " delete from " + TableNameUtil.GSGSJIN_SUB02 + " where field001='" + OLDSN + "' and field002='" + OLDSUB + "'";
Debug.println("[ChangeBusinessDAOImpl-->>moveFromOutToIn()---sql2(删除02表中需要更新的记录)]" + sql);
stmt.executeUpdate(sql);
//将01表中的记录导入02表中
sql = "insert into " + TableNameUtil.GSGSJIN_SUB02 + " select * from " + TableNameUtil.GSGSJOUT_SUB01 + " where field001='" + SN +
"' and field002='" + SUB + "' and (field250<>'del' or field250 is null)";
Debug.println("[ChangeBusinessDAOImpl-->>moveFromOutToIn()---sql3(将01表中的记录导入02表中)]" + sql);
stmt.executeUpdate(sql);
//更新02表中的字段
//modify (hgw 2004-03-12 16:03)
//更新02表中的字段field249,field250为"",让下次变更时导出数据到外网没有"add/del"等附加信息
//old
//sql = " update " + TableNameUtil.GSGSJIN_SUB02 + " set field001='" + OLDSN + "' , field002='" + OLDSUB + "' where field001='" + SN +
// "' and field002='" + SUB + "'";
//new
sql = " update " + TableNameUtil.GSGSJIN_SUB02 + " set field001='" + OLDSN +
"' , field002='" + OLDSUB +
"' , field249='' , field250='' where field001='" + SN +
"' and field002='" + SUB + "'";
Debug.println("[ChangeBusinessDAOImpl-->>moveFromOutToIn()---sql4(更新02表中的字段)]" + sql);
stmt.executeUpdate(sql);
}
// conn.commit();
} catch(Exception e){
throw new AppException("[ChangeBusinessDAOImpl-->>moveFromOutToIn]: Exception " +
e.getMessage());
} finally{
try{
this.closeResultSet(rs);
} catch(Exception e){
}
try{
this.closeStatement(stmt);
} catch(Exception e){
}
try{
this.closeConnection(conn);
} catch(Exception e){
}
}
}
//导入法定代表人、负责人数据
public void moveChairmanToIn(String SN,String OLDSN,String SUB) throws Exception{
String sql = null;
String OLDSUB = null;
String temp = null;
try{
OLDSUB = "sub02" + SUB.substring(5);
sqlExecProxy.openProxy();
sqlExecProxy.setAutoCommit(false);
//先判断外网子表中是否有记录
sql = " select field134 from " + TableNameUtil.GSGSJOUT_BASIS01 + " where field001='" + SN + "'";
Debug.println("[ChangeBusinessDAOImpl------moveChairmanToIn>>SQL]" + sql);
sqlExecProxy.executeQuery(sql);
temp = sqlExecProxy.getFieldString("field134");
if(temp != null && !temp.trim().equals("")){
//删除02表中需要更新的记录
sql = " delete from " + TableNameUtil.GSGSJIN_SUB02 + " where field001='" + OLDSN + "' and field002='" + OLDSUB + "'";
Debug.println("[ChangeBusinessDAOImpl------moveChairmanToIn>>SQL1]" + sql);
sqlExecProxy.executeUpdate(sql);
//将01表中的记录导入02表中
sql = "insert into " + TableNameUtil.GSGSJIN_SUB02 + " select * from " + TableNameUtil.GSGSJOUT_SUB01 + " where field001='" + SN +
"' and field002='" + SUB + "'";
Debug.println("[ChangeBusinessDAOImpl------moveChairmanToIn>>SQL2]" + sql);
sqlExecProxy.executeUpdate(sql);
//更新02表中的字段
sql = " update " + TableNameUtil.GSGSJIN_SUB02 + " set field001='" + OLDSN + "' , field002='" + OLDSUB + "' where field001='" + SN +
"' and field002='" + SUB + "'";
sqlExecProxy.executeUpdate(sql);
}
sqlExecProxy.commitProxy();
} catch(Exception e){
throw new AppException("[ChangeBusinessDAOImpl-->>moveChairmanToIn]: Exception " +
e.getMessage());
} finally{
try{
sqlExecProxy.closeProxy();
} catch(Exception e){
Debug.println("[ChangeBusinessDAOImpl-->>moveChairmanToIn]exception:" + e.toString());
}
}
}
/**
*方法名称:selectSubApply
*功能描述:读取子表记录
*参数SN:事务号
*参数SUB:子表名
*参数tableName:表名
*返回值:无
*创建人:冯瑞龙
*创建时间:2003-10-20
*/
public ArrayList selectSubApply(String SN,String SUB,String tableName) throws Exception{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
ArrayList al = new ArrayList();
try{
conn = Common.getConnection();
// conn.setAutoCommit(false);
stmt = conn.createStatement();
sql = " select * from " + tableName + " where field001='" + SN + "' and field002='" + SUB + "' order by field003";
Debug.println("[ChangeBusinessDAOImpl-->>11selectSubApply]sql=" + sql);
rs = stmt.executeQuery(sql);
//取得各字段的值,放入hashmap
ResultSetMetaData fieldMeta = rs.getMetaData();
int fieldCount = fieldMeta.getColumnCount();
int i = 0;
while(rs.next()){
HashMap hashmap = new HashMap();
for(int j = 1;j <= fieldCount;j++){
String fieldName = fieldMeta.getColumnName(j);
String fieldValue = rs.getString(fieldName);
hashmap.put(fieldName.trim().toLowerCase(),fieldValue);
}
al.add(hashmap);
hashmap = null;
Debug.println("[ChangeBusinessDAOImpl-->>selectSubApply]resultCout:" + i);
i++;
}
// conn.commit();
} catch(Exception e){
throw new AppException("[ChangeBusinessDAOImpl-->>selectSubApply]: Exception " +
e.getMessage());
} finally{
try{
this.closeResultSet(rs);
} catch(Exception e){
}
try{
this.closeStatement(stmt);
} catch(Exception e){
}
try{
this.closeConnection(conn);
} catch(Exception e){
}
return al;
}
}
/**
*方法名称:copyOutSubToLogDel
*功能描述:保存外网子表的增删除操作
*参数SN:事务号
*参数SUB:子表名
*参数OLDSN:开业的事务号
*返回值:无
*创建人:冯瑞龙
*创建时间:2003-10-20
*/
public void copyOutSubToLogDel(String SN,String OLDSN,String operateUser) throws Exception{
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = "";
String SUB = "";
String OLDSUB = "";
String currentDateTime = ChangeUtil.getCurrentTime();
try{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -