jiapeng %!s(int64=6) %!d(string=hace) años
padre
commit
18f368e9a5

+ 10 - 0
pom.xml

@ -65,6 +65,16 @@
65 65
            <artifactId>mail</artifactId>
66 66
            <version>1.4</version>
67 67
        </dependency>
68
        <dependency>
69
        	<groupId>com.ekexiu</groupId>
70
        	<artifactId>decamino_nonames</artifactId>
71
        	<version>0.0.1</version>
72
        </dependency>
73
                <dependency>
74
        	<groupId>com.ekexiu</groupId>
75
        	<artifactId>decamino_nonames_rt</artifactId>
76
        	<version>0.0.1</version>
77
        </dependency>
68 78
    </dependencies>
69 79
    <build>
70 80
        <plugins>

+ 13 - 0
src/main/java/com/ekexiu/project/log/SystemLogFactory.java

@ -0,0 +1,13 @@
1
package com.ekexiu.project.log;
2

3
import org.jfw.util.log.LogFactory;
4
import org.jfw.util.log.Logger;
5

6
public class SystemLogFactory extends LogFactory {
7
	private static SystemLogger log = new SystemLogger();
8

9
	@Override
10
	public Logger getLogger(Class<?> clazz) {
11
		return log;
12
	}
13
}

+ 93 - 0
src/main/java/com/ekexiu/project/log/SystemLogger.java

@ -0,0 +1,93 @@
1
package com.ekexiu.project.log;
2

3
import org.jfw.util.log.Logger;
4

5
public class SystemLogger implements Logger {
6
	@Override
7
	public boolean isEnableTrace() {
8
		return true;
9
	}
10

11
	@Override
12
	public void trace(String message) {
13
		System.out.println(message);
14
	}
15

16
	@Override
17
	public void trace(String message, Throwable t) {
18
		System.err.println(message);
19
		t.printStackTrace(System.err);
20
	}
21

22
	@Override
23
	public boolean isEnableDebug() {
24
		return true;
25
	}
26

27
	@Override
28
	public void debug(String message) {
29
		System.err.println(message);
30
	}
31

32
	@Override
33
	public void debug(String message, Throwable t) {
34
		System.err.println(message);
35
		t.printStackTrace(System.err);
36
	}
37

38
	@Override
39
	public boolean isEnableInfo() {
40
		return true;
41
	}
42

43
	@Override
44
	public void info(String message) {
45
		System.err.println(message);
46

47
	}
48

49
	@Override
50
	public void info(String message, Throwable t) {
51
		System.err.println(message);
52
		t.printStackTrace(System.err);
53
	}
54

55
	@Override
56
	public boolean isEnableWarn() {
57
		return true;
58
	}
59

60
	@Override
61
	public void warn(String message) {
62
		System.err.println(message);
63
	}
64

65
	@Override
66
	public void warn(String message, Throwable t) {
67
		System.err.println(message);
68
		t.printStackTrace(System.err);
69
	}
70

71
	@Override
72
	public void error(String message) {
73
		System.err.println(message);
74
	}
75

76
	@Override
77
	public void error(String message, Throwable t) {
78
		System.err.println(message);
79
		t.printStackTrace(System.err);
80
	}
81

82
	@Override
83
	public void fatal(String message) {
84
		System.err.println(message);
85
	}
86

87
	@Override
88
	public void fatal(String message, Throwable t) {
89
		System.err.println(message);
90
		t.printStackTrace(System.err);
91
	}
92

93
}

+ 26 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiCleanTask.java

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

3
import org.jfw.util.log.LogFactory;
4
import org.jfw.util.log.Logger;
5

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

19
	
20

21
	@Override
22
	public void run() {
23
		aiTaskService.updateTaskState(taskId, 399, null, new AiStrengthenTask(taskId, taskType, aiTaskService));
24
	}
25

26
}

+ 99 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiDiacrisisTask.java

@ -0,0 +1,99 @@
1
package com.ekexiu.project.storage.diacrisis;
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
import java.util.LinkedList;
9
import java.util.concurrent.TimeUnit;
10

11
import org.jfw.util.ConstData;
12
import org.jfw.util.context.JfwAppContext;
13
import org.jfw.util.io.IoUtil;
14
import org.jfw.util.log.LogFactory;
15
import org.jfw.util.log.Logger;
16

17
public class AiDiacrisisTask implements Runnable {
18

19
	private static Logger LOG = LogFactory.getLog(AiDiacrisisTask.class);
20

21
	private static int processing = 2;
22
	private String urlPrefix = "http://192.168.3.114:5000/test?pi=";
23

24
	private static LinkedList<AiDiacrisisTask> queue = new LinkedList<AiDiacrisisTask>();
25
	private String taskId;
26
	private int taskType;
27
	private AiTaskService aiTaskService;
28

29
	public AiDiacrisisTask(String taskId, int taskType, AiTaskService aiTaskService) {
30
		this.taskId = taskId;
31
		this.taskType = taskType;
32
		this.aiTaskService = aiTaskService;
33
	}
34

35
	@Override
36
	public void run() {
37
		synchronized (AiDiacrisisTask.class) {
38
			if (AiDiacrisisTask.processing > 0) {
39
				AiDiacrisisTask.processing--;
40
			} else {
41
				AiDiacrisisTask.queue.add(this);
42
				return;
43
			}
44
		}
45
		aiTaskService.updateTaskState(taskId, 600, null, null);
46
		this.doRun();
47
		synchronized (AiDiacrisisTask.class) {
48
			AiDiacrisisTask.processing++;
49
			if (AiDiacrisisTask.queue.size() > 0) {
50
				AiDiacrisisTask next = AiDiacrisisTask.queue.pollLast();
51
				JfwAppContext.getScheduledExecutorService().schedule(next, 50, TimeUnit.MILLISECONDS);
52
			}
53
		}
54
	}
55

56
	private void doRun() {
57
		int nextState = 650;
58
		String nextStateCode = "ERR0599";
59

60
		File file = new File(aiTaskService.getDstPath(), taskId);
61
		if (file.exists() && file.isDirectory()) {
62
			try {
63
				URL u = new URL(urlPrefix + file.getAbsolutePath());
64
				HttpURLConnection httpURLConnection = (HttpURLConnection) u.openConnection();
65
				if (httpURLConnection.getResponseCode() == 200) {
66
					InputStream in = httpURLConnection.getInputStream();
67
					try {
68
						ByteArrayOutputStream out = new ByteArrayOutputStream();
69
						byte[] buf = new byte[128];
70
						int len = 0;
71
						while ((len = in.read(buf)) != -1) {
72
							if (len > 0) {
73
								out.write(buf, 0, len);
74
							}
75
						}
76
						buf = out.toByteArray();
77
						if (buf.length > 0) {
78
							String ret = new String(buf, ConstData.UTF8);
79
							ret = ret.trim();
80
							if (ret.equals("1")) {
81
								nextState = 699;
82
								nextStateCode = null;
83
							}
84
						}
85

86
					} catch (Exception e) {
87
					} finally {
88
						IoUtil.close(in);
89
					}
90
				} else {
91
					nextStateCode = "ERR0502";
92
				}
93
			} catch (Exception ee) {
94
			}
95

96
		}
97
		aiTaskService.updateTaskState(taskId, nextState, nextStateCode, null);
98
	}
99
}

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

@ -0,0 +1,116 @@
1
package com.ekexiu.project.storage.diacrisis;
2

3
import java.awt.image.BufferedImage;
4
import java.io.File;
5
import java.io.IOException;
6

7
import javax.imageio.ImageIO;
8
import javax.imageio.ImageReader;
9
import javax.imageio.ImageWriter;
10
import javax.imageio.event.IIOReadWarningListener;
11
import javax.imageio.event.IIOWriteWarningListener;
12

13
import org.jfw.util.log.LogFactory;
14
import org.jfw.util.log.Logger;
15

16
import fr.apteryx.imageio.dicom.DicomReader;
17

18
public class AiFormatTask implements Runnable {
19
	private static Logger LOG = LogFactory.getLog(AiFormatTask.class);
20
	private String taskId;
21
	private int taskType;
22
	private AiTaskService aiTaskService;
23

24
	public AiFormatTask(String taskId, int taskType, AiTaskService aiTaskService) {
25
		this.taskId = taskId;
26
		this.taskType = taskType;
27
		this.aiTaskService = aiTaskService;
28
	}
29

30
	@Override
31
	public void run() {
32

33
		File file = new File(aiTaskService.getDstPath(), taskId);
34
		if (!file.exists()) {
35
			LOG.error("Path[" + file.getAbsolutePath() + "] not exists");
36
			aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
37
		} else {
38
			int begin, end;
39
			if (taskType == 1) {
40
				begin = 1;
41
				end = 7;
42
			} else if (taskType == 2) {
43
				begin = 7;
44
				end = 14;
45
			} else {
46
				LOG.error("err task type[" + taskType + "]");
47
				aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
48
				return;
49
			}
50
			for (int i = begin; i < end; ++i) {
51
				File src = new File(file, "IM_" + String.format("%04d.DICOM", i));
52
				if (!src.exists()) {
53
					LOG.error("Path[" + src.getAbsolutePath() + "] not exists");
54
					aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
55
					return;
56
				}
57
				File dst = new File(file, "ASD_" + String.format("%02d", i));
58
				if (dst.exists()) {
59
					LOG.error("Path[" + dst.getAbsolutePath() + "]  exists");
60
					aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
61
					return;
62
				}
63
				if (dst.mkdir()) {
64

65
					try {
66
						DicomReader reader = new DicomReader();
67
						reader.addIIOReadWarningListener(new WarningListener());
68
						reader.setInput(src);
69
						int nf = reader.getNumImages(true);
70
						if (nf <= 0) {
71
							LOG.error("file [" + src.getAbsolutePath() + "] invalid");
72
							aiTaskService.updateTaskState(taskId, 551, "ERR0402", null);
73
							return;
74
						}
75

76
						for (int k = 0; k < nf; ++k) {
77
							BufferedImage bi = reader.read(i);
78
							if (bi == null) {
79
								LOG.error("file [" + src.getAbsolutePath() + "] invalid");
80
								aiTaskService.updateTaskState(taskId, 551, "ERR0402", null);
81
								return;
82
							}
83

84
							File jpg = new File(dst, String.format("ASD_%02d_%03d.JPG", i, k));
85
							if (jpg.exists()) {
86
								LOG.error("file[" + jpg.getAbsolutePath() + "]  exists");
87
								aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
88
								return;
89
							}
90
							ImageIO.write(bi, "JPG", jpg);
91
						}
92
					} catch (Exception e) {
93
						aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
94
						return;
95
					}
96

97
				} else {
98
					LOG.error("makdir [" + dst.getAbsolutePath() + "] error");
99
					aiTaskService.updateTaskState(taskId, 552, "ERR0403", null);
100
					return;
101
				}
102
			}
103
		}
104
		aiTaskService.updateTaskState(taskId, 599, null, new AiDiacrisisTask(taskId, taskType, aiTaskService));
105
	}
106
}
107

108
class WarningListener implements IIOReadWarningListener, IIOWriteWarningListener {
109
	public void warningOccurred(ImageReader source, String warning) {
110
		System.err.println("READ WARNING: " + warning);
111
	}
112

113
	public void warningOccurred(ImageWriter source, int idx, String warning) {
114
		System.err.println("WRITE WARNING (image " + idx + "): " + warning);
115
	}
116
}

+ 26 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiStrengthenTask.java

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

3
import org.jfw.util.log.LogFactory;
4
import org.jfw.util.log.Logger;
5

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

19
	
20

21
	@Override
22
	public void run() {
23
		aiTaskService.updateTaskState(taskId, 499, null, new AiFormatTask(taskId, taskType, aiTaskService));
24
	}
25

26
}

+ 110 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiTask.java

@ -0,0 +1,110 @@
1
package com.ekexiu.project.storage.diacrisis;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7
import org.jfw.apt.orm.core.enums.DE;
8

9
import com.ekexiu.project.storage.base.po.CreateTimeSupported;
10

11
@PrimaryKey("id")
12
@Table
13
public class AiTask implements CreateTimeSupported {
14
	private String id;
15
	private String dataNum;
16
	private String createTime;
17
	private int  taskType;
18
	private int  state;
19
	private String stateCode;
20
	private String uid;
21
	private String modifyTime;
22
	
23
	@Column(DE.id_32)
24
	public String getId() {
25
		return id;
26
	}
27
	public void setId(String id) {
28
		this.id = id;
29
	}
30
	@Column(value=DE.text_de,renewable=false)
31
	public String getDataNum() {
32
		return dataNum;
33
	}
34
	public void setDataNum(String dataNum) {
35
		this.dataNum = dataNum;
36
	}
37
	public String getCreateTime() {
38
		return createTime;
39
	}
40
	public void setCreateTime(String createTime) {
41
		this.createTime = createTime;
42
	}
43
	@Column(value=DE.int_de,renewable=false)
44
	public int getTaskType() {
45
		return taskType;
46
	}
47
	public void setTaskType(int taskType) {
48
		this.taskType = taskType;
49
	}
50
	/**
51
	 *  100 submit  wait transfer queue
52
	 *  
53
	 *  200 transfering     
54
	 *  250 transfer error
55
	 *  299  transfer ok  wait 脱敏 queue
56
	 *  
57
	 *   300 脱敏ing
58
	 *   350  脱敏  error
59
	 *   399 脱敏ed    wait 增强 queue
60
	 *   
61
	 *   400 增强ing
62
	 *   450 增强 error
63
	 *   499 增强ed  wait 格式转换 queue
64
	 *   
65
	 *   500 格式转换ing
66
	 *   551 格式转换 error  with  invalid format
67
	 *   552 格式转换 error  with  IO
68
	 *   599 格式转换ed  wait 智能诊断  queue
69
	 *   
70
	 *   600  智能诊断ing
71
	 *   650   智能诊断 error
72
	 *   699   智能诊断ed
73
	 *  
74
	 *  
75
	 *  
76
	 *  
77
	 * @return
78
	 */
79
	@Column(value=DE.int_de)
80
	public int getState() {
81
		return state;
82
	}
83
	public void setState(int state) {
84
		this.state = state;
85
	}
86
	public String getStateCode() {
87
		return stateCode;
88
	}
89
	@Column(DE.Text_de)
90
	public void setStateCode(String stateCode) {
91
		this.stateCode = stateCode;
92
	}
93
	@Column(DE.refid_32)
94
	public String getUid() {
95
		return uid;
96
	}
97
	public void setUid(String uid) {
98
		this.uid = uid;
99
	}
100
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)",fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = true)
101
	public String getModifyTime() {
102
		return modifyTime;
103
	}
104
	public void setModifyTime(String modifyTime) {
105
		this.modifyTime = modifyTime;
106
	}
107
	
108
	
109
	
110
}

+ 47 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiTaskDao.java

@ -0,0 +1,47 @@
1
package com.ekexiu.project.storage.diacrisis;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Nullable;
7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.IncludeFixSet;
10
import org.jfw.apt.orm.annotation.dao.method.Or;
11
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
12
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
13
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
14
import org.jfw.apt.orm.annotation.dao.method.operator.PageSelect;
15
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
16
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
17
import org.jfw.apt.orm.annotation.dao.param.Set;
18
import org.jfw.util.PageQueryResult;
19

20
@DAO
21
public interface AiTaskDao {
22

23
	
24
	
25
	@Insert
26
	int insert(Connection con,AiTask task)throws SQLException;
27
	
28
	@IncludeFixSet
29
	@UpdateWith
30
	@SetSentence("STATE_CODE = NULL")
31
	@From(AiTask.class)
32
	int update(Connection con,String id,@Set int state) throws SQLException;
33
	
34
	@UpdateWith
35
	@From(AiTask.class)
36
	@IncludeFixSet
37
	int update(Connection con,String id,@Set int state,@Set String stateCode) throws SQLException;
38
	
39
	@PageSelect
40
	@OrderBy("ORDER BY CREATE_TIME DESC,ID DESC")
41
	PageQueryResult<AiTask> pageQuery(Connection con,String uid,@Nullable String dataNum,@Nullable Integer taskType,int pageSize,int pageNo)throws SQLException;
42
	
43
	@SelectOne
44
	@Nullable
45
	AiTask query(Connection con,String id)throws SQLException;
46
	
47
}

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

@ -0,0 +1,164 @@
1
package com.ekexiu.project.storage.diacrisis;
2

3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileOutputStream;
6
import java.io.InputStream;
7
import java.io.OutputStream;
8
import java.sql.Connection;
9
import java.sql.SQLException;
10
import java.util.concurrent.TimeUnit;
11

12
import org.jfw.apt.annotation.Autowrie;
13
import org.jfw.apt.annotation.Nullable;
14
import org.jfw.apt.web.annotation.LoginUser;
15
import org.jfw.apt.web.annotation.Path;
16
import org.jfw.apt.web.annotation.operate.Get;
17
import org.jfw.apt.web.annotation.operate.Post;
18
import org.jfw.apt.web.annotation.param.JdbcConn;
19
import org.jfw.apt.web.annotation.param.PathVar;
20
import org.jfw.util.PageQueryResult;
21
import org.jfw.util.StringUtil;
22
import org.jfw.util.context.JfwAppContext;
23
import org.jfw.util.io.IoUtil;
24
import org.jfw.util.jdbc.JdbcUtil;
25
import org.jfw.util.log.LogFactory;
26
import org.jfw.util.log.Logger;
27

28
import com.ekexiu.project.storage.system.SessionUser;
29

30
@Path("/task")
31
public class AiTaskService {
32

33
	private static Logger LOG = LogFactory.getLog(AiTaskService.class);
34

35
	private long delayTime = 2000;
36

37
	@Autowrie
38
	private AiTaskDao aiTaskDao;
39
	private File srcPath = new File("/ekexiu/storage_asd/src");
40
	private File dstPath = new File("/ekexiu/storage_asd/dst");
41

42
	public File getSrcPath() {
43
		return srcPath;
44
	}
45

46
	public void setSrcPath(File srcPath) {
47
		this.srcPath = srcPath;
48
	}
49

50
	public File getDstPath() {
51
		return dstPath;
52
	}
53

54
	public void setDstPath(File dstPath) {
55
		this.dstPath = dstPath;
56
	}
57

58
	public AiTaskDao getAiTaskDao() {
59
		return aiTaskDao;
60
	}
61

62
	public void setAiTaskDao(AiTaskDao aiTaskDao) {
63
		this.aiTaskDao = aiTaskDao;
64
	}
65

66
	public boolean copyFile(File src, File dst) {
67
		try {
68
			if (src.exists() && (!dst.exists())) {
69
				InputStream in = null;
70
				OutputStream out = null;
71
				try {
72
					in = new FileInputStream(src);
73
					out = new FileOutputStream(dst);
74
					byte[] buf = new byte[4096];
75
					IoUtil.copy(in, out, buf);
76
					out.flush();
77
				} finally {
78
					if (in != null) {
79
						IoUtil.close(in);
80
					}
81
					if (out != null) {
82
						IoUtil.close(out);
83
					}
84
				}
85
				return true;
86
			}
87
		} catch (Exception e) {
88
		}
89
		return false;
90
	}
91

92
	public void updateTaskState(String id, int state, String stateCode, final Runnable runnable) {
93
		Connection con;
94
		try {
95
			con = JfwAppContext.getDataSource().getConnection();
96
			try {
97
				if (stateCode != null) {
98
					aiTaskDao.update(con, id, state, stateCode);
99
				} else {
100
					aiTaskDao.update(con, id, state);
101
				}
102
				con.commit();
103
				if (runnable != null) {
104
					JfwAppContext.getScheduledExecutorService().schedule(runnable, this.delayTime, TimeUnit.MILLISECONDS);
105
				}
106
			} catch (Exception e) {
107
				JdbcUtil.rollback(con);
108
			} finally {
109
				con.close();
110
			}
111
		} catch (Exception e1) {
112

113
		}
114
	}
115
	
116

117
   @Path("/add")
118
   @Get
119
   @Post
120
	public String insert(@JdbcConn(true) Connection con, @LoginUser SessionUser user, final String dataNum, final int taskType) throws SQLException {
121
		final String id = StringUtil.buildUUID();
122
		AiTask task = new AiTask();
123

124
		task.setDataNum(dataNum);
125
		task.setTaskType(taskType);
126
		task.setState(100);
127
		task.setStateCode(null);
128
		task.setId(id);
129
		task.setUid(user.getId());
130
		aiTaskDao.insert(con, task);
131
		
132
		JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
133
			@Override
134
			public void run() {
135
				updateTaskState(id, 200, null, new AiTransferTask(id, taskType,AiTaskService.this));
136
			}
137
		},this.delayTime,TimeUnit.MILLISECONDS);
138
		return id;
139
	}
140
   
141
   private static final String EMPTY_STRING_ARRAY[] = new String[0];
142
   @Get
143
   @Path("/pq")
144
   public PageQueryResult<AiTask> pageQuery(@JdbcConn Connection con,@LoginUser SessionUser user,@Nullable String dataNum,@Nullable Integer taskType,int pageSize,int pageNo) throws SQLException{
145
	   return aiTaskDao.pageQuery(con, user.getId(), dataNum, taskType, pageSize, pageNo);
146
   }
147
   @Get
148
   @Path("/result/{taskid}")
149
   public String[] getResult(@PathVar String taskid){
150
	   File path = new File(dstPath,taskid);
151
	   if(path.exists() && path.isDirectory()){
152
		   path = new File(path,"ASD_RESULT");
153
		   if(path.exists() && path.isDirectory()){
154
			   return path.list();
155
		   }
156
	   }
157
	   return EMPTY_STRING_ARRAY;
158
   }
159
   @Get
160
   @Path("/qo")
161
   public AiTask query(@JdbcConn Connection con,String id)throws SQLException{
162
	   return aiTaskDao.query(con, id);
163
   }
164
}

+ 62 - 0
src/main/java/com/ekexiu/project/storage/diacrisis/AiTransferTask.java

@ -0,0 +1,62 @@
1
package com.ekexiu.project.storage.diacrisis;
2

3
import java.io.File;
4

5
import org.jfw.util.log.LogFactory;
6
import org.jfw.util.log.Logger;
7

8
public class AiTransferTask implements Runnable {
9
	private static Logger LOG = LogFactory.getLog(AiTransferTask.class);
10
	private String taskId;
11
	private int taskType;
12
	private AiTaskService aiTaskService;
13

14
	public AiTransferTask(String taskId, int taskType, AiTaskService aiTaskService) {
15
		this.taskId = taskId;
16
		this.taskType = taskType;
17
		this.aiTaskService = aiTaskService;
18
	}
19

20
	@Override
21
	public void run() {
22

23
		File file = new File(aiTaskService.getDstPath(), taskId);
24
		if (file.exists()) {
25
			LOG.error("Path[" + file.getAbsolutePath() + "] exists");
26
			aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
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;
37
						}
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;
47
						}
48
					}
49
				} else {
50
					LOG.error("err task type[" + taskType + "]");
51
					aiTaskService.updateTaskState(taskId, 250, "ERR0199", null);
52
					return;
53
				}
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
	}
61

62
}

+ 17 - 0
src/main/java/com/ekexiu/project/storage/servlet/StartupServlet.java

@ -0,0 +1,17 @@
1
package com.ekexiu.project.storage.servlet;
2

3
import javax.servlet.ServletException;
4
import javax.servlet.http.HttpServlet;
5

6
import fr.apteryx.imageio.dicom.Plugin;
7

8
public class StartupServlet extends HttpServlet {
9
	private static final long serialVersionUID = 1L;
10

11
	@Override
12
	public void init() throws ServletException {
13
		super.init();
14
		 System.loadLibrary("decamino");
15
		Plugin.setLicenseKey("1758D1W8YEYL81675OA9ABHD");
16
	}
17
}

+ 23 - 0
src/main/java/com/ekexiu/project/util/ScheduledExecutorServiceFactory.java

@ -0,0 +1,23 @@
1
package com.ekexiu.project.util;
2

3
import java.util.concurrent.Executors;
4
import java.util.concurrent.ScheduledExecutorService;
5

6
import org.jfw.apt.annotation.Bean;
7

8
@Bean
9
public class ScheduledExecutorServiceFactory {
10
	private int corePoolSize =10 ;
11

12
	public int getCorePoolSize() {
13
		return corePoolSize;
14
	}
15

16
	public void setCorePoolSize(int corePoolSize) {
17
		this.corePoolSize = corePoolSize;
18
	}
19
	
20
	public ScheduledExecutorService create(){
21
		return Executors.newScheduledThreadPool(this.corePoolSize);
22
	}
23
}

+ 1 - 0
src/main/resources/META-INF/services/org.jfw.util.log.LogFactory

@ -0,0 +1 @@
1
com.ekexiu.project.log.SystemLogFactory

+ 18 - 16
src/main/resources/project.properties

@ -1,33 +1,35 @@
1
scheduledExecutorService::factory=com_ekexiu_project_util_ScheduledExecutorServiceFactory
2
scheduledExecutorService.factory-method=create
1 3
dataSource=com.alibaba.druid.pool.DruidDataSource
2
#数据库连接地址、名称、密码
3
dataSource.url=jdbc:postgresql://192.168.3.233:5432/storage
4
#锟斤拷菘锟斤拷锟斤拷拥锟街凤拷锟斤拷锟狡★拷锟斤拷锟斤拷
5
dataSource.url=jdbc:postgresql://127.0.0.1:5432/storage
4 6
dataSource.username=postgres
5 7
dataSource.password=postgres
6
#连接池启动时的初始值(初始化连接)
8
#锟斤拷锟接筹拷锟斤拷锟斤拷时锟侥筹拷始值锟斤拷锟斤拷始锟斤拷锟斤拷锟接o拷
7 9
dataSource.initialSize::int=1
8
#最小空闲连接
10
#锟斤拷小锟斤拷锟斤拷锟斤拷锟斤拷
9 11
dataSource.minIdle::int=1 
10
#连接池的最大值(最大连接数量)
12
#锟斤拷锟接池碉拷锟斤拷锟街碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
11 13
dataSource.maxActive::int=1
12
#超时等待时间(maxWait代表当Connection用尽了,多久之后进行回收丢失连接)
14
#锟斤拷时锟饺达拷时锟戒(maxWait锟斤拷?Connection锟矫撅拷锟剿o拷锟斤拷锟街�拷锟斤拷锟叫伙拷锟秸讹拷失锟斤拷锟接o拷
13 15
dataSource.maxWait::long=60000
14
#连接超时任务的时间间隔
16
#���ӳ�ʱ�����ʱ����
15 17
dataSource.timeBetweenEvictionRunsMillis::long=60000
16
#连接的超时时间
18
#锟斤拷锟接的筹拷时时锟斤拷
17 19
dataSource.minEvictableIdleTimeMillis::long=300000  
18
#用来验证从连接池取出的连接
20
#锟斤拷锟斤拷锟斤拷证锟斤拷锟斤拷锟接筹拷取锟斤拷锟斤拷锟斤拷锟斤拷
19 21
dataSource.validationQuery=SELECT 1  
20
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败则连接将被从池中去除
22
#ָ�������Ƿ񱻿������ӻ�����(�����)���м���.�����ʧ�������ӽ����ӳ���ȥ��
21 23
dataSource.testWhileIdle::boolean=true
22
#在从池中取出连接前进行检验,如果检验失败则从池中去除连接并尝试取出另一个
24
#�ڴӳ���ȡ������ǰ���м���,������ʧ����ӳ���ȥ�����Ӳ�����ȡ����һ��
23 25
dataSource.testOnBorrow::boolean=true
24
#指明是否在归还到池中前进行检验
26
#指锟斤拷锟角凤拷锟节归还锟斤拷锟斤拷锟斤拷前锟斤拷锟叫硷拷锟斤拷
25 27
dataSource.testOnReturn::boolean=true   
26
#开启池的prepared statement 池功能
28
#锟斤拷锟斤拷锟截碉拷prepared statement 锟截癸拷锟斤拷
27 29
dataSource.poolPreparedStatements::boolean=true 
28
#statement池能够同时分配的打开的statements的最大数量
30
#statement���ܹ�ͬʱ����Ĵ򿪵�statements���������
29 31
dataSource.maxPoolPreparedStatementPerConnectionSize::int=20
30
#默认的SQL语句自动提交状态(开启或关闭)设置由连接池本身设置(false由连接池定)
32
#Ĭ�ϵ�SQL����Զ��ύ״̬(������ر�)���������ӳر�������(false�����ӳض�)
31 33
dataSource.defaultAutoCommit::boolean=false
32 34
33
com_ekexiu_project_storage_resource_service_StorageService.filePath::java.io.File=/kexiu/storage/data
35
com_ekexiu_project_storage_resource_service_StorageService.filePath::java.io.File=/ekexiu/storage/data

+ 28 - 26
src/main/webapp/WEB-INF/web.xml

@ -1,27 +1,29 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
4
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
5
         version="3.0" metadata-complete="true">
6
    <servlet>
7
        <servlet-name>ajax</servlet-name>
8
        <servlet-class>org.jfw.web.servlet.core.FilenameConfigServlet</servlet-class>
9
        <init-param>
10
            <param-name>prefixLen</param-name>
11
            <param-value>14</param-value>
12
        </init-param>
13
        <init-param>
14
            <param-name>viewType</param-name>
15
            <param-value>1</param-value>
16
        </init-param>
17
        <init-param>
18
            <param-name>configFileName</param-name>
19
            <param-value>beanConfig.properties,project.properties</param-value>
20
        </init-param>
21
        <load-on-startup>1</load-on-startup>
22
    </servlet>
23
    <servlet-mapping>
24
        <servlet-name>ajax</servlet-name>
25
        <url-pattern>/ajax/*</url-pattern>
26
    </servlet-mapping>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
3
  <servlet>
4
    <servlet-name>ajax</servlet-name>
5
    <servlet-class>org.jfw.web.servlet.core.FilenameConfigServlet</servlet-class>
6
    <init-param>
7
      <param-name>prefixLen</param-name>
8
      <param-value>14</param-value>
9
    </init-param>
10
    <init-param>
11
      <param-name>viewType</param-name>
12
      <param-value>1</param-value>
13
    </init-param>
14
    <init-param>
15
      <param-name>configFileName</param-name>
16
      <param-value>beanConfig.properties,project.properties</param-value>
17
    </init-param>
18
    <load-on-startup>1</load-on-startup>
19
  </servlet>
20
  <servlet>
21
  	<servlet-name>startupServlet</servlet-name>
22
  	<servlet-class>com.ekexiu.project.storage.servlet.StartupServlet</servlet-class>
23
  	<load-on-startup>2</load-on-startup>
24
  </servlet>
25
  <servlet-mapping>
26
    <servlet-name>ajax</servlet-name>
27
    <url-pattern>/ajax/*</url-pattern>
28
  </servlet-mapping>
27 29
</web-app>