|
|
@@ -208,45 +208,42 @@ public class FileUtil {
|
|
|
public static Boolean fileUp(Connection connection,MultipartFile file,String sob){
|
|
|
boolean result = false;
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String path = saveFile(file, "ADMIN");
|
|
|
String filename = file.getOriginalFilename().replaceAll(",", ",");
|
|
|
int size = (int) file.getSize();
|
|
|
if(size>0) {
|
|
|
Statement statement = null;
|
|
|
try {
|
|
|
statement = connection.createStatement();
|
|
|
- String sql = "select " + sob + ".EMAILFILEPATH.nextval from dual";
|
|
|
- ResultSet resultSet = statement.executeQuery(sql);
|
|
|
- if (resultSet.next()) {
|
|
|
- int id = resultSet.getInt(1);
|
|
|
- String sql1 =
|
|
|
- "INSERT INTO " + sob + ".filepath(fp_id,fp_path,fp_size,fp_man,fp_date,fp_name) values(" + id + ",'" + path +
|
|
|
- "'," + size + ",'" + "管理员" + "'," + "to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "')";
|
|
|
- int i = statement.executeUpdate(sql1);
|
|
|
- if (i > 0) {
|
|
|
- String substring = null;
|
|
|
- if (filename.indexOf("-") != -1) {
|
|
|
- substring = filename.substring(0, filename.indexOf("-"));
|
|
|
- } else
|
|
|
- substring = filename.substring(0, filename.indexOf("."));
|
|
|
- //String sql2 = "select " + sob + ".FTPATTCHTEMP_SEQ.nextval from dual";
|
|
|
- //ResultSet resultSet2 = statement.executeQuery(sql2);
|
|
|
- String sql3 = "INSERT INTO " + sob + ".FTPATTCHTEMP(FT_ID,FT_ATTCH,FT_PIINOUTNO,FT_STATUS,FT_INSERTDATE,FT_FILENAME,FT_SOB)values(" + sob + ".FTPATTCHTEMP_SEQ.nextval,'" + id + ";','" + substring + "','GET',to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "','" + sob + "')";
|
|
|
- int i1 = statement.executeUpdate(sql3);
|
|
|
- if (i1 > 0) {
|
|
|
- result = true;
|
|
|
+ ResultSet set = statement.executeQuery("select count(1) from " + sob + ".FTPATTCHTEMP where FT_FILENAME='" + filename + "' and FT_SOB='"+sob+"'");
|
|
|
+ while (set.next()){
|
|
|
+ int count = set.getInt(1);
|
|
|
+ if (count==0){
|
|
|
+ String path = saveFile(file, "FTP");
|
|
|
+ ResultSet resultSet = statement.executeQuery("select " + sob + ".EMAILFILEPATH.nextval from dual");
|
|
|
+ if (resultSet.next()) {
|
|
|
+ int id = resultSet.getInt(1);
|
|
|
+ String sql1 =
|
|
|
+ "INSERT INTO " + sob + ".filepath(fp_id,fp_path,fp_size,fp_man,fp_date,fp_name) values(" + id + ",'" + path +
|
|
|
+ "'," + size + ",'" + "FTP" + "'," + "to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "')";
|
|
|
+ int i = statement.executeUpdate(sql1);
|
|
|
+ if (i > 0) {
|
|
|
+ String substring = null;
|
|
|
+ if (filename.indexOf("-") != -1) {
|
|
|
+ substring = filename.substring(0, filename.indexOf("-"));
|
|
|
+ } else {
|
|
|
+ substring = filename.substring(0, filename.indexOf("."));
|
|
|
+ }
|
|
|
+ String sql3 = "INSERT INTO " + sob + ".FTPATTCHTEMP(FT_ID,FT_ATTCH,FT_PIINOUTNO,FT_STATUS,FT_INSERTDATE,FT_FILENAME,FT_SOB)values(" + sob + ".FTPATTCHTEMP_SEQ.nextval,'" + id + ";','" + substring + "','GET',to_date('" + format.format(new Date()) + "','yyyy-mm-dd HH24:mi:ss')" + ",'" + filename + "','" + sob + "')";
|
|
|
+ int i1 = statement.executeUpdate(sql3);
|
|
|
+ if (i1 > 0) {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ statement.close();
|
|
|
}
|
|
|
-
|
|
|
- /*String sql2 =
|
|
|
- "update " + sob + ".prodinout set pi_attach = '" + id + ";' where pi_inoutno ='" + substring+"'";
|
|
|
- int i = statement.executeUpdate(sql2);
|
|
|
- if (i > 0) {
|
|
|
- result = true;
|
|
|
- }*/
|
|
|
}
|
|
|
- statement.close();
|
|
|
- return result;
|
|
|
+ result=true;
|
|
|
} catch (SQLException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|