jiapeng 6 ans auparavant
Parent
commit
a24386ab21

+ 46 - 1
src/main/java/com/ekexiu/project/storage/diacrisis/AiCleanTask.java

@ -1,5 +1,13 @@
1 1
package com.ekexiu.project.storage.diacrisis;
2 2

3
import java.io.ByteArrayOutputStream;
4
import java.io.File;
5
import java.io.InputStream;
6
import java.net.HttpURLConnection;
7
import java.net.URL;
8

9
import org.jfw.util.ConstData;
10
import org.jfw.util.io.IoUtil;
3 11
import org.jfw.util.log.LogFactory;
4 12
import org.jfw.util.log.Logger;
5 13

@ -20,7 +28,44 @@ public class AiCleanTask implements Runnable{
20 28

21 29
	@Override
22 30
	public void run() {
23
		aiTaskService.updateTaskState(taskId, 399, null, new AiStrengthenTask(taskId, taskType, aiTaskService));
31
		String errCode="ERR0209";//调用异常
32
		File file = new File(aiTaskService.getDstPath(), taskId);
33
		file = new File(file,"data");
34
			try {
35
				URL u = new URL("http://127.0.0.1:5001//desensitize?pi=" + file.getAbsolutePath());
36
				HttpURLConnection httpURLConnection = (HttpURLConnection) u.openConnection();
37
				if (httpURLConnection.getResponseCode() == 200) {
38
					InputStream in = httpURLConnection.getInputStream();
39
					try {
40
						ByteArrayOutputStream out = new ByteArrayOutputStream();
41
						byte[] buf = new byte[128];
42
						int len = 0;
43
						while ((len = in.read(buf)) != -1) {
44
							if (len > 0) {
45
								out.write(buf, 0, len);
46
							}
47
						}
48
						buf = out.toByteArray();
49
						if (buf.length > 0) {
50
							String ret = new String(buf, ConstData.UTF8);
51
							ret = ret.trim();
52
							if (ret.equals("1")) {
53
								aiTaskService.updateTaskState(taskId, 399, null, new AiStrengthenTask(taskId, taskType, aiTaskService));
54
								return;
55
							}
56
						}
57
						errCode="ERR0207";//调用协议返回错误 
58
					} catch (Exception e) {
59
						errCode="ERR0207";//调用协议传输异常 
60
					} finally {
61
						IoUtil.close(in);
62
					}
63
				}else{
64
					errCode="ERR0208";//调用协议状态异常  http status != 200
65
				} 
66
			} catch (Exception ee) {
67
			}
68
		aiTaskService.updateTaskState(taskId, 350,errCode, null);
24 69
	}
25 70

26 71
}

+ 1 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiFormatTask.java

@ -31,6 +31,7 @@ public class AiFormatTask implements Runnable {
31 31
	public void run() {
32 32

33 33
		File file = new File(aiTaskService.getDstPath(), taskId);
34
		file = new File(file,"data_enhance");
34 35
		if (!file.exists()) {
35 36
			LOG.error("Path[" + file.getAbsolutePath() + "] not exists");
36 37
			aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);

+ 49 - 8
src/main/java/com/ekexiu/project/storage/diacrisis/AiStrengthenTask.java

@ -1,26 +1,67 @@
1 1
package com.ekexiu.project.storage.diacrisis;
2 2

3
import java.io.ByteArrayOutputStream;
4
import java.io.File;
5
import java.io.InputStream;
6
import java.net.HttpURLConnection;
7
import java.net.URL;
8

9
import org.jfw.util.ConstData;
10
import org.jfw.util.io.IoUtil;
3 11
import org.jfw.util.log.LogFactory;
4 12
import org.jfw.util.log.Logger;
5 13

6
public class AiStrengthenTask implements Runnable{
14
public class AiStrengthenTask implements Runnable {
7 15
	private static Logger LOG = LogFactory.getLog(AiStrengthenTask.class);
8 16
	private String taskId;
9 17
	private int taskType;
10 18
	private AiTaskService aiTaskService;
11
	
12
	
13
	public AiStrengthenTask(String taskId,int taskType,AiTaskService aiTaskService){
19

20
	public AiStrengthenTask(String taskId, int taskType, AiTaskService aiTaskService) {
14 21
		this.taskId = taskId;
15 22
		this.taskType = taskType;
16 23
		this.aiTaskService = aiTaskService;
17 24
	}
18 25

19
	
20

21 26
	@Override
22 27
	public void run() {
23
		aiTaskService.updateTaskState(taskId, 499, null, new AiFormatTask(taskId, taskType, aiTaskService));
28
		String errCode = "ERR0309";// 调用异常
29
		File file = new File(aiTaskService.getDstPath(), taskId);
30
		file = new File(file, "data_desen");
31
		try {
32
			URL u = new URL("http://127.0.0.1:5003/enhance?pi=" + file.getAbsolutePath());
33
			HttpURLConnection httpURLConnection = (HttpURLConnection) u.openConnection();
34
			if (httpURLConnection.getResponseCode() == 200) {
35
				InputStream in = httpURLConnection.getInputStream();
36
				try {
37
					ByteArrayOutputStream out = new ByteArrayOutputStream();
38
					byte[] buf = new byte[128];
39
					int len = 0;
40
					while ((len = in.read(buf)) != -1) {
41
						if (len > 0) {
42
							out.write(buf, 0, len);
43
						}
44
					}
45
					buf = out.toByteArray();
46
					if (buf.length > 0) {
47
						String ret = new String(buf, ConstData.UTF8);
48
						ret = ret.trim();
49
						if (ret.equals("1")) {
50
							aiTaskService.updateTaskState(taskId, 499, null, new AiFormatTask(taskId, taskType, aiTaskService));
51
							return;
52
						}
53
					}
54
					errCode = "ERR0307";// 调用协议返回错误
55
				} catch (Exception e) {
56
					errCode = "ERR0307";// 调用协议传输异常
57
				} finally {
58
					IoUtil.close(in);
59
				}
60
			} else {
61
				errCode = "ERR0308";// 调用协议状态异常 http status != 200
62
			}
63
		} catch (Exception ee) {
64
		}
65
		aiTaskService.updateTaskState(taskId, 450, errCode, null);
24 66
	}
25

26 67
}

+ 0 - 1
src/main/java/com/ekexiu/project/storage/diacrisis/AiTaskService.java

@ -109,7 +109,6 @@ public class AiTaskService {
109 109
				con.close();
110 110
			}
111 111
		} catch (Exception e1) {
112

113 112
		}
114 113
	}
115 114
	

+ 26 - 25
src/main/java/com/ekexiu/project/storage/diacrisis/AiTransferTask.java

@ -25,37 +25,38 @@ public class AiTransferTask implements Runnable {
25 25
			LOG.error("Path[" + file.getAbsolutePath() + "] exists");
26 26
			aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
27 27
		} else {
28
			if (file.mkdir()) {
29
				if (taskType == 1) {
30
					for (int i = 1; i < 7; ++i) {
31
						File src = new File(aiTaskService.getSrcPath(), "IM_" + String.format("%04d.DICOM", i));
32
						File dst = new File(file, "IM_" + String.format("%04d.DICOM", i));
33
						if (!aiTaskService.copyFile(src, dst)) {
34
							LOG.error("copy File[" + src.getAbsolutePath() + "] error");
35
							aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
36
							return;
28
				file = new File(file,"data");
29
				if (file.mkdirs()) {
30
					if (taskType == 1) {
31
						for (int i = 1; i < 7; ++i) {
32
							File src = new File(aiTaskService.getSrcPath(), "IM_" + String.format("%04d.DICOM", i));
33
							File dst = new File(file, "IM_" + String.format("%04d.DICOM", i));
34
							if (!aiTaskService.copyFile(src, dst)) {
35
								LOG.error("copy File[" + src.getAbsolutePath() + "] error");
36
								aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
37
								return;
38
							}
37 39
						}
38
					}
39
				} else if (taskType == 2) {
40
					for (int i = 7; i < 14; ++i) {
41
						File src = new File(aiTaskService.getSrcPath(), "IM_" + String.format("%04d.DICOM", i));
42
						File dst = new File(file, "IM_" + String.format("%04d.DICOM", i));
43
						if (!!aiTaskService.copyFile(src, dst)) {
44
							LOG.error("copy File[" + src.getAbsolutePath() + "] error");
45
							aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
46
							return;
40
					} else if (taskType == 2) {
41
						for (int i = 7; i < 14; ++i) {
42
							File src = new File(aiTaskService.getSrcPath(), "IM_" + String.format("%04d.DICOM", i));
43
							File dst = new File(file, "IM_" + String.format("%04d.DICOM", i));
44
							if (!aiTaskService.copyFile(src, dst)) {
45
								LOG.error("copy File[" + src.getAbsolutePath() + "] error");
46
								aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
47
								return;
48
							}
47 49
						}
50
					} else {
51
						LOG.error("err task type[" + taskType + "]");
52
						aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
53
						return;
48 54
					}
55
					aiTaskService.updateTaskState(taskId, 299, null, new AiCleanTask(taskId, taskType, aiTaskService));
49 56
				} else {
50
					LOG.error("err task type[" + taskType + "]");
57
					LOG.error("mkdir File[" + file.getAbsolutePath() + "] error");
51 58
					aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
52
					return;
53 59
				}
54
				aiTaskService.updateTaskState(taskId, 299, null, new AiCleanTask(taskId, taskType, aiTaskService));
55
			} else {
56
				LOG.error("mkdir File[" + file.getAbsolutePath() + "] error");
57
				aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
58
			}
59 60
		}
60 61
	}
61 62