📄 gbs_mmifdetail_db.java
字号:
//print sql
System.out.println("[INFO] sql = " + sql.toString());
}
// end sql edit ================================
strSql = sql.toString();
pstmt = conn.prepareStatement(strSql);
bresult = pstmt.executeUpdate();
} catch (Exception exception) {
System.out.println("[Error Happen!]");
System.out.println("[Start Trace]");
exception.printStackTrace();
System.out.println("[End Trace]");
throw exception;
} finally {
//release db
try {
if (rset != null) {
rset.close();
}
if (pstmt != null) {
pstmt.close();
}
if (st != null) {
st.close();
}
} catch (SQLException se) {
throw se;
}
}
return bresult;
}
/**
* insert into MIF and MIF_DETAIL
* @return int
* @exception Exception Exception for information of other errors
* @since 2004/08/09
*/
public ReturnValue addMifDetail(GBS_MifEntryList_stBean MifIn, String seqNo, String fileStatus) throws Exception {
ReturnValue returnValue = new ReturnValue();
MessageList messageList = new MessageList();
returnValue.setMessageList(messageList);
StringBuffer sql = new StringBuffer();
StringBuffer sql1 = new StringBuffer();
// start sql edit ================================
sql1.append(" SELECT ");
sql1.append(" CUSTOMER_ID ");
sql1.append(" FROM ");
sql1.append(" M_MIF ");
sql1.append(" WHERE ");
sql1.append(" CUSTOMER_ID = '" + BaseCommonCheck.convertSql(MifIn.getCustomerId()) + "'");
sql1.append(" AND PRODUCT_CATEGORY = '" + BaseCommonCheck.convertSql(MifIn.getProductCategory()) + "'");
sql1.append(" AND SUBSIDIARY_CODE = '" + BaseCommonCheck.convertSql(MifIn.getSubsidiaryCode()) + "'");
sql1.append(" AND COUNTRY_CODE = '" + BaseCommonCheck.convertSql(MifIn.getCountryCode()) + "'");
System.out.println("[INFO] sql = " + sql1.toString());
sql.append(" INSERT INTO ");
sql.append(" M_MIF ( ");
sql.append(" CUSTOMER_ID, "); //屭媞ID
sql.append(" PRODUCT_CATEGORY, "); //惢昳暘椶
sql.append(" COUNTRY_CODE, "); //崙僐乕僪
sql.append(" SUBSIDIARY_CODE, "); //尰朄僐乕僪
sql.append(" REMARKS, "); //儕儅乕僋僗
sql.append(" ATCH_FILE_NAME, "); //揧晅僼傽僀儖柤
sql.append(" ATCH_FILE, "); //揧晅僼傽僀儖
sql.append(" CREATE_USER, "); //嶌惉儐乕僓乕
sql.append(" CREATE_DATE "); //嶌惉擔帪
sql.append(" ) ");
sql.append(" VALUES ( ");
sql.append(" '" + BaseCommonCheck.convertSql(MifIn.getCustomerId()) + "',");
sql.append(" '" + BaseCommonCheck.convertSql(MifIn.getProductCategory()) + "',");
sql.append(" '" + BaseCommonCheck.convertSql(MifIn.getCountryCode()) + "',");
sql.append(" '" + BaseCommonCheck.convertSql(MifIn.getSubsidiaryCode()) + "',");
sql.append(" '" + BaseCommonCheck.convertSql(MifIn.getRemarks()) + "',");
sql.append(" '', ");
sql.append(" null,");
sql.append(" '" + BaseCommonCheck.convertSql(MifIn.getUser()) + "',");
sql.append(" SYSDATE ");
sql.append(" ) ");
System.out.println("[INFO] sql = " + sql.toString());
// end sql edit ================================
ResultSet rset = null;
Connection conn = null;
Statement st = null;
PreparedStatement pstmt = null;
String strSql;
ArrayList lstDetail = new ArrayList();
int bresult = 0;
try {
//print sql
strSql = sql1.toString();
conn = this.datasource.getConnection();
st = conn.createStatement();
rset = st.executeQuery(strSql);
if (rset.next()) {
messageList.setMessage("", "", "10000002", Integer.MIN_VALUE);
returnValue.setBussinessError();
} else {
strSql = "";
strSql = sql.toString();
pstmt = conn.prepareStatement(strSql);
bresult = pstmt.executeUpdate();
if (bresult > 0) {
lstDetail = MifIn.getGBSMMifDetail_st();
for (int i = 0; lstDetail != null && i < lstDetail.size(); i++) {
GBS_MMifDetail_stBean detail_st = (GBS_MMifDetail_stBean) lstDetail.get(i);
//insert MIF徻嵶忣曬
returnValue = insertMifDetail(MifIn, detail_st, conn);
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
messageList.addAll(returnValue.getMessageList());
returnValue.setBussinessError();
break;
}
} else {
if (bresult <= 0) {
break;
}
}
}
}
//update attachmentFile
if (bresult > 0 && fileStatus.equals("update") && !seqNo.equals("")) {
returnValue = this.updateAttachmentFile(MifIn, seqNo, conn);
bresult = ((Integer) returnValue.getDataValue()).intValue();
}
if (bresult > 0) {
conn.commit();
} else {
conn.rollback();
}
}
} catch (Exception exception) {
System.out.println("[Error Happen!]");
System.out.println("[Start Trace]");
exception.printStackTrace();
System.out.println("[End Trace]");
throw exception;
} finally {
//release db
try {
if (rset != null) {
rset.close();
}
if (st != null) {
st.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException se) {
throw se;
}
}
returnValue.setDataValue(new Integer(bresult));
return returnValue;
}
/**
* insert into MIF_DETAIL
* @return int
* @exception Exception Exception for information of other errors
* @since 2004/08/09
*/
public ReturnValue insertMifDetail(GBS_MifEntryList_stBean MifIn, GBS_MMifDetail_stBean detail_st, Connection conn)
throws Exception {
//Add by Gxk 2004/09/10 Start
MifIn.setCountryCode(BaseCommonCheck.convertSql(MifIn.getCountryCode()));
MifIn.setCustomerId(BaseCommonCheck.convertSql(MifIn.getCustomerId()));
MifIn.setProductCategory(BaseCommonCheck.convertSql(MifIn.getProductCategory()));
MifIn.setRemarks(BaseCommonCheck.convertSql(MifIn.getRemarks()));
MifIn.setSubsidiaryCode(BaseCommonCheck.convertSql(MifIn.getSubsidiaryCode()));
MifIn.setUser(BaseCommonCheck.convertSql(MifIn.getUser()));
detail_st.setCpcPrice(BaseCommonCheck.convertSql(detail_st.getCpcPrice()));
detail_st.setCreateUser(BaseCommonCheck.convertSql(detail_st.getCreateUser()));
detail_st.setCurrency(BaseCommonCheck.convertSql(detail_st.getCurrency()));
detail_st.setHardPrice(BaseCommonCheck.convertSql(detail_st.getHardPrice()));
detail_st.setInstallDate(BaseCommonCheck.convertSql(detail_st.getInstallDate()));
detail_st.setMcv(BaseCommonCheck.convertSql(detail_st.getMcv()));
detail_st.setModel(BaseCommonCheck.convertSql(detail_st.getModel()));
detail_st.setModelOld(BaseCommonCheck.convertSql(detail_st.getModelOld()));
detail_st.setPerson(BaseCommonCheck.convertSql(detail_st.getPerson()));
detail_st.setQty(BaseCommonCheck.convertSql(detail_st.getQty()));
detail_st.setRfpDate(BaseCommonCheck.convertSql(detail_st.getRfpDate()));
detail_st.setUpdateUser(BaseCommonCheck.convertSql(detail_st.getUpdateUser()));
detail_st.setUserId(BaseCommonCheck.convertSql(detail_st.getUserId()));
detail_st.setUserName(BaseCommonCheck.convertSql(detail_st.getUserName()));
//Add by Gxk 2004/09/10 End
ReturnValue returnValue = new ReturnValue();
MessageList messageList = new MessageList();
returnValue.setMessageList(messageList);
StringBuffer sql = new StringBuffer();
StringBuffer sql1 = new StringBuffer();
// start sql edit ================================
sql1.append(" SELECT ");
sql1.append(" CUSTOMER_ID ");
sql1.append(" FROM ");
sql1.append(" M_MIF_DETAIL");
sql1.append(" WHERE ");
sql1.append(" CUSTOMER_ID = '" + MifIn.getCustomerId() + "'");
sql1.append(" AND PRODUCT_CATEGORY = '" + MifIn.getProductCategory() + "'");
sql1.append(" AND SUBSIDIARY_CODE = '" + MifIn.getSubsidiaryCode() + "'");
sql1.append(" AND COUNTRY_CODE = '" + MifIn.getCountryCode() + "'");
sql1.append(" AND MODEL = '" + detail_st.getModel() + "'");
System.out.println("[INFO] sql = " + sql1.toString());
sql.append(" INSERT INTO ");
sql.append(" M_MIF_DETAIL ");
sql.append(" ( ");
sql.append(" CUSTOMER_ID, "); //屭媞ID
sql.append(" PRODUCT_CATEGORY,"); //惢昳暘椶
sql.append(" COUNTRY_CODE,"); //崙僐乕僪
sql.append(" SUBSIDIARY_CODE,"); //尰朄僐乕僪
sql.append(" MODEL,"); //儌僨儖
sql.append(" QTY,"); //悢検
sql.append(" CURRENCY,"); //捠壿
sql.append(" HARD_PRICE,"); //僴乕僪僂僃傾壙奿
sql.append(" CPC_PRICE,"); //CPC壙奿
sql.append(" MCV,"); //MCV
sql.append(" INSTALLATION_DATE,"); //摫擖擔
sql.append(" RFP_RCV_DATE,"); //RFP庴庢擔
sql.append(" USER_ID,"); //搊榐幰
sql.append(" CREATE_USER,"); //嶌惉儐乕僓乕
sql.append(" CREATE_DATE"); //嶌惉擔帪
sql.append(" )");
sql.append(" VALUES ( ");
sql.append(" '" + MifIn.getCustomerId() + "',");
sql.append(" '" + MifIn.getProductCategory() + "',");
sql.append(" '" + MifIn.getCountryCode() + "',");
sql.append(" '" + MifIn.getSubsidiaryCode() + "',");
sql.append(" '" + detail_st.getModel() + "',");
sql.append(" '" + detail_st.getQty() + "',");
sql.append(" '" + detail_st.getCurrency() + "',");
sql.append(" '" + detail_st.getHardPrice() + "',");
sql.append(" '" + detail_st.getCpcPrice() + "',");
sql.append(" '" + detail_st.getMcv() + "',");
sql.append("to_date( '" + detail_st.getInstallDate() + "','yyyy/MM/dd'),");
sql.append("to_date( '" + detail_st.getRfpDate() + "','yyyy/MM/dd'),");
sql.append(" '" + MifIn.getUser() + "',");
sql.append(" '" + MifIn.getUser() + "',");
sql.append(" SYSDATE ) ");
// end sql edit ================================
//print sql
System.out.println("[INFO] sql = " + sql.toString());
ResultSet rset = null;
Statement st = null;
PreparedStatement pstmt = null;
String strSql;
ArrayList lstDetail = new ArrayList();
int bresult = 0;
try {
strSql = sql1.toString();
st = conn.createStatement();
rset = st.executeQuery(strSql);
if (rset.next()) {
messageList.setMessage("", "", "10000002", Integer.MIN_VALUE);
returnValue.setBussinessError();
} else {
strSql = sql.toString();
pstmt = conn.prepareStatement(strSql);
bresult = pstmt.executeUpdate();
}
} catch (Exception exception) {
System.out.println("[Error Happen!]");
System.out.println("[Start Trace]");
exception.printStackTrace();
System.out.println("[End Trace]");
throw exception;
} finally {
//release db
try {
if (rset != null) {
rset.close();
}
if (pstmt != null) {
pstmt.close();
}
if (st != null) {
st.close();
}
} catch (SQLException se) {
throw se;
}
}
returnValue.setDataValue(String.valueOf(bresult));
return returnValue;
}
/**
* update AttachmentFile
* @return boolean
* @exception Exception Exception for information of other errors
* @since 2004/08/09
*/
public ReturnValue updateAttachmentFile(GBS_MifEntryList_stBean in, String seqNo, Connection conn)
throws Exception {
//Add by Gxk 2004/09/10 Start
in.setCountryCode(BaseCommonCheck.convertSql(in.getCountryCode()));
in.setCustomerId(BaseCommonCheck.convertSql(in.getCustomerId()));
in.setProductCategory(BaseCommonCheck.convertSql(in.getProductCategory()));
in.setRemarks(BaseCommonCheck.convertSql(in.getRemarks()));
in.setSubsidiaryCode(BaseCommonCheck.convertSql(in.getSubsidiaryCode()));
in.setUser(BaseCommonCheck.convertSql(in.getUser()));
//Add by Gxk 2004/09/10 End
ReturnValue returnValue = new ReturnValue();
MessageList messageList = new MessageList();
returnValue.setMessageList(messageList);
StringBuffer sqlSel = new StringBuffer();
sqlSel.append(" SELECT");
sqlSel.append(" ATTACHMENT_FILE_NAME, ATTACHMENT_FILE");
sqlSel.append(" FROM ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -