|
|
@@ -2,25 +2,24 @@ package com.uas.eis.serviceImpl;
|
|
|
|
|
|
import com.uas.eis.core.config.SpObserver;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
-import com.uas.eis.dto.DataCenter;
|
|
|
import com.uas.eis.entity.ErrorMessage;
|
|
|
import com.uas.eis.exception.ApiSystemException;
|
|
|
import com.uas.eis.sdk.entity.ApiResult;
|
|
|
+import com.uas.eis.sdk.resp.ApiResponse;
|
|
|
import com.uas.eis.service.MESDataService;
|
|
|
-import com.uas.eis.utils.BaseUtil;
|
|
|
-import com.uas.eis.utils.Constant;
|
|
|
-import com.uas.eis.utils.DateUtil;
|
|
|
-import com.uas.eis.utils.SqlUtil;
|
|
|
+import com.uas.eis.utils.*;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.sql.Timestamp;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class MESDataServiceImpl implements MESDataService {
|
|
|
@@ -243,6 +242,49 @@ public class MESDataServiceImpl implements MESDataService {
|
|
|
return relist;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public int saveFilePath(String accessKey, String requestId,String path, int size, String filename,String sncode) throws Exception {
|
|
|
+ String AE_MASTER = checkAccessKey(accessKey, requestId);
|
|
|
+ SpObserver.putSp(AE_MASTER);
|
|
|
+ int id = baseDao.getSeqId("filepath_seq");
|
|
|
+ /**
|
|
|
+ * 文件名含单引号无法下载*/
|
|
|
+ filename=filename.replaceAll(",", ",");
|
|
|
+ baseDao.execute("INSERT INTO filepath(fp_id,fp_path,fp_size,fp_man,fp_date,fp_name) values(" + id + ",'" + path + "'," + size
|
|
|
+ + ",'" + accessKey+ "'," + DateUtil.parseDateToOracleString(Constant.YMD_HMS, new Date()) + ",'" + filename
|
|
|
+ + "')");
|
|
|
+ baseDao.execute("insert into DCRFILEDATA (DF_ID ,DF_DATE,DF_INMAN,DF_ATTACH,DF_FILENAME,DF_RESULT)" +
|
|
|
+ " select DCRFILEDATA_seq.nextval,sysdate,?,?,?,? from dual ",accessKey,id,filename,sncode);
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResult<String> uploadDCRFile(String accessKey, String requestId, MultipartFile file, String sncode) throws IOException {
|
|
|
+ try {
|
|
|
+ String filename = file.getOriginalFilename();
|
|
|
+ String path = saveFile(file);
|
|
|
+ int id = saveFilePath(accessKey, requestId,path, (int) file.getSize(), filename,sncode);
|
|
|
+ return ApiResponse.successRsp("0", "Success", requestId, "");
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return ApiResponse.failRsp( "10011","上传失败"+(e.getMessage().length()>400 ? e.getMessage().substring(0,400):e.getMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String saveFile(MultipartFile file) throws IOException {
|
|
|
+ String path = "/dcr";
|
|
|
+ File filep = new File(path);
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ if (!filep.isDirectory()) {
|
|
|
+ filep.mkdir();
|
|
|
+ }
|
|
|
+ path = path+File.separator +fileName;
|
|
|
+ FileUtils.copyInputStreamToFile(file.getInputStream(),new File(path));
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private String checkAccessKey(String accessKey,String requestId){
|
|
|
Object accessSecret_O = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_SECRET", "AE_KEY='" + accessKey + "'");
|
|
|
Object AE_MASTER = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_MASTER", "AE_KEY='" + accessKey + "'");
|