刘韬 2 gadi atpakaļ
vecāks
revīzija
3df7f16025
1 mainītis faili ar 56 papildinājumiem un 38 dzēšanām
  1. 56 38
      DataFusion/src/com/zskk/control/ViewController.java

+ 56 - 38
DataFusion/src/com/zskk/control/ViewController.java

@@ -234,53 +234,71 @@ public class ViewController extends Controller {
 	}
 	
 	public void dld() {
-		try {
-			Map<String, String> annex_params = new HashMap<>();
-			annex_params.put("institution_id", PropKit.get("institution_id"));
-			annex_params.put("type", "4");
-			annex_params.put("code", "1.2.8.20200820.1245.20220704114231427");
-			//附件类型1.mp4 2.pdf 3.jpeg
-			annex_params.put("annex_class_code", "3");
-			String filePath="http://200.200.200.59/bgdata/DJ202207A/DJ20220704A1142/BG2022070400422.jpg";
-			
-			OSS OSS_CLIENT = new OSSClientBuilder().build(PropKit.get("oss_endpoint"), PropKit.get("oss_accessKey"), PropKit.get("oss_secretKey"));
-
-			String fileNameStr[] = filePath.split("/");
-			String fileName = fileNameStr[fileNameStr.length - 1];
-			String fileStorePath = getFileWithUrl(filePath, fileName);
-			File file = new File(fileStorePath);
-			String key = PropKit.get("institution_id") + "/" + fileName;
-	        InputStream inputStream = null;
+		DataService dService = ServiceFactory.getService(DataService.class);
+		List<Record> records = Db.use("print").find("select * from IMAGEVIEW where ADDTIME >? order by ADDTIME desc",this.getPara("time"));
+		for (Record record : records) {
 			try {
-				inputStream = new FileInputStream(fileStorePath);
-			} catch (FileNotFoundException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-				renderText(e.toString());
-
-			}            
-			Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
-			if (!eBoolean) {
-				OSS_CLIENT.putObject(PropKit.get("oss_bucketName"), key, inputStream);
-				Boolean bBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
-				if (bBoolean) {
-					file.delete();
+				if (record == null) {
+					continue;
 				}
+				Map<String, String> annex_params = new HashMap<>();
+				annex_params.put("institution_id", PropKit.get("institution_id"));
+				annex_params.put("type", "2");
+				annex_params.put("code", record.getStr("CHECKID"));
+				//附件类型1.mp4 2.pdf 3.jpeg 4.png
+				annex_params.put("annex_class_code", "4");
+				annex_params.put("exam_datetime", parseStringToDate2(record.getStr("ADDTIME")));
+	      		dService.saveAnnex(annex_params, record.getStr("IMGURL"));
+			} catch (Exception e) {
+				// TODO: handle exception
+				continue;
 			}
-			renderText("succ");
-
-		} catch (Exception e) {
-			// TODO: handle exception
-			renderText(e.toString());
 
-		}	
+		}
 	}
 	
-	public void saveAnnex(Map<String, String> map, String filePath) {
-	    
+	/**
+	 * 日期字符串格式转换
+	 * 
+	 * @param dateStr
+	 * @return
+	 */
+	private String parseStringToDate1() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Date date = new Date();
+		String timeString = null;
+		Long i = date.getTime();
+		Long j = i - 43200;
+		Date newdate = new Date(j);
+		timeString = sdf.format(newdate);
+		return timeString;
+	}
+	
+	/**
+	 * 日期字符串格式转换
+	 * @param dateStr
+	 * @return
+	 */
+	private String parseStringToDate2(String dateStr) {
+		if (dateStr == null) {
+			return "";
+		}
+		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	    Date date = null;
+	    String timeString = null;
+		try {
+			date = sdf.parse(dateStr);
+			SimpleDateFormat sdf2= new SimpleDateFormat("yyyyMMdd");
 
+			timeString = sdf2.format(date);
+		} catch (ParseException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+        return timeString;
 	}
 	
+	
 	public static String getFileWithUrl(String url, String filename) {
 
 		Request request = new Request.Builder().url(url).build();