xiatian 1 рік тому
батько
коміт
554b841b53

+ 10 - 9
db/am_db.sql

@@ -1,8 +1,8 @@
 DROP TABLE IF EXISTS `am_question`;
 CREATE TABLE `am_question` (
   `id` bigint NOT NULL AUTO_INCREMENT,
-  `create_time` datetime(6) DEFAULT NULL,
-  `update_time` datetime(6) DEFAULT NULL,
+  `create_time` datetime DEFAULT NULL,
+  `update_time` datetime DEFAULT NULL,
   `answer` longtext COLLATE utf8mb4_bin NOT NULL,
   `content` longtext COLLATE utf8mb4_bin NOT NULL,
   `exam_id` bigint NOT NULL,
@@ -11,6 +11,7 @@ CREATE TABLE `am_question` (
   `main_number` int NOT NULL,
   `sub_number` int NOT NULL,
   `subject_code` varchar(255) COLLATE utf8mb4_bin NOT NULL,
+  `subject_name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `IDX_QUESTION_01` (`exam_id`, `subject_code`, `main_number`, `sub_number`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
@@ -18,8 +19,8 @@ CREATE TABLE `am_question` (
 DROP TABLE IF EXISTS `am_student`;
 CREATE TABLE `am_student` (
   `id` bigint NOT NULL AUTO_INCREMENT,
-  `create_time` datetime(6) DEFAULT NULL,
-  `update_time` datetime(6) DEFAULT NULL,
+  `create_time` datetime DEFAULT NULL,
+  `update_time` datetime DEFAULT NULL,
   `data_status` varchar(255) NOT NULL,
   `exam_id` bigint NOT NULL,
   `student_code` varchar(255) COLLATE utf8mb4_bin NOT NULL,
@@ -32,11 +33,11 @@ CREATE TABLE `am_student` (
 DROP TABLE IF EXISTS `am_student_score`;
 CREATE TABLE `am_student_score` (
   `id` bigint NOT NULL AUTO_INCREMENT,
-  `create_time` datetime(6) DEFAULT NULL,
-  `update_time` datetime(6) DEFAULT NULL,
+  `create_time` datetime DEFAULT NULL,
+  `update_time` datetime DEFAULT NULL,
   `ai_score` double DEFAULT NULL,
-  `answer_status` varchar(255) int NOT NULL,
-  `score_status` varchar(255) int NOT NULL,
+  `answer_status` varchar(255) NOT NULL,
+  `score_status` varchar(255) NOT NULL,
   `answer` longtext COLLATE utf8mb4_bin DEFAULT NULL,
   `err_msg` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL,
   `main_number` int NOT NULL,
@@ -47,7 +48,7 @@ CREATE TABLE `am_student_score` (
   `exam_id` bigint NOT NULL,
   `student_code` varchar(255) COLLATE utf8mb4_bin NOT NULL,
   `subject_code` varchar(255) COLLATE utf8mb4_bin NOT NULL,
-  `sub_number` int NOT NULL,
+  `sub_number` 	 varchar(255) NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `IDX_STUDENT_SCORE_01` (`student_id`, `question_id`),
   UNIQUE KEY `IDX_STUDENT_SCORE_02` (`exam_id`, `subject_code`, `student_code`,`main_number`, `sub_number`)

+ 12 - 23
src/main/java/cn/com/qmth/am/bean/ImageSlice.java

@@ -1,33 +1,33 @@
 package cn.com.qmth.am.bean;
 
 public class ImageSlice {
-	private Double x;
-	private Double y;
-	private Double w;
-	private Double h;
+	private Integer x;
+	private Integer y;
+	private Integer w;
+	private Integer h;
 	private Integer i;
-	public Double getX() {
+	public Integer getX() {
 		return x;
 	}
-	public void setX(Double x) {
+	public void setX(Integer x) {
 		this.x = x;
 	}
-	public Double getY() {
+	public Integer getY() {
 		return y;
 	}
-	public void setY(Double y) {
+	public void setY(Integer y) {
 		this.y = y;
 	}
-	public Double getW() {
+	public Integer getW() {
 		return w;
 	}
-	public void setW(Double w) {
+	public void setW(Integer w) {
 		this.w = w;
 	}
-	public Double getH() {
+	public Integer getH() {
 		return h;
 	}
-	public void setH(Double h) {
+	public void setH(Integer h) {
 		this.h = h;
 	}
 	public Integer getI() {
@@ -36,16 +36,5 @@ public class ImageSlice {
 	public void setI(Integer i) {
 		this.i = i;
 	}
-	public ImageSlice() {
-		super();
-	}
-	public ImageSlice(Double x, Double y, Double w, Double h, Integer i) {
-		super();
-		this.x = x;
-		this.y = y;
-		this.w = w;
-		this.h = h;
-		this.i = i;
-	}
 	
 }

+ 22 - 3
src/main/java/cn/com/qmth/am/config/InitData.java

@@ -1,19 +1,38 @@
 package cn.com.qmth.am.config;
 
 import java.io.File;
+import java.util.List;
 
+import org.apache.commons.collections4.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
 
+import com.qmth.boot.core.solar.model.OrgInfo;
+import com.qmth.boot.core.solar.service.SolarService;
+
 @Component
 public class InitData implements CommandLineRunner {
-
+	private static final Logger log = LoggerFactory.getLogger(InitData.class);
 	@Autowired
 	private SysProperty sysProperty;
-
+	@Autowired
+	private SolarService solarService;
 	@Override
 	public void run(String... args) throws Exception {
+		List<OrgInfo> orgs = null;
+		try {
+			orgs = solarService.getOrgList();
+		} catch (Exception e) {
+			log.error("激活授权失败");
+			System.exit(1);
+		}
+		if(CollectionUtils.isEmpty(orgs)) {
+			log.error("授权信息有误");
+			System.exit(1);
+		}
 		File dataDir=new File(sysProperty.getDataDir());
 		if(!dataDir.exists()) {
 			dataDir.mkdir();
@@ -26,7 +45,7 @@ public class InitData implements CommandLineRunner {
 		if(!quesImpDir.exists()) {
 			quesImpDir.mkdir();
 		}
-		File mscoreImpDir=new File(sysProperty.getDataDir()+"/marking-score-import");
+		File mscoreImpDir=new File(sysProperty.getDataDir()+"/score-import");
 		if(!mscoreImpDir.exists()) {
 			mscoreImpDir.mkdir();
 		}

+ 6 - 5
src/main/java/cn/com/qmth/am/entity/base/BaseEntity.java

@@ -23,7 +23,7 @@ public abstract class BaseEntity implements Serializable {
 	 * 创建时间
 	 */
     @TableField(fill = FieldFill.INSERT)
-	private Date creationTime;
+	private Date createTime;
 
 	public Date getUpdateTime() {
 		return updateTime;
@@ -33,12 +33,13 @@ public abstract class BaseEntity implements Serializable {
 		this.updateTime = updateTime;
 	}
 
-	public Date getCreationTime() {
-		return creationTime;
+	public Date getCreateTime() {
+		return createTime;
 	}
 
-	public void setCreationTime(Date creationTime) {
-		this.creationTime = creationTime;
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
 	}
 
+
 }

+ 26 - 5
src/main/java/cn/com/qmth/am/service/impl/QuestionServiceImpl.java

@@ -19,8 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.core.exception.StatusException;
 import com.qmth.boot.tools.excel.ExcelReader;
@@ -274,20 +272,43 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
 	}
 
 	private List<ImageSlice> getImageSlice(String s) {
+		if (StringUtils.isBlank(s)) {
+			return null;
+		}
+		s=s.trim();
 		if (StringUtils.isBlank(s)) {
 			return null;
 		}
 		try {
 			List<ImageSlice> list=new ArrayList<>();
-			JSONArray ja=JSONArray.parseArray(s);
-			for(int i=0;i<ja.size();i++) {
-				ImageSlice ret = JSONObject.parseObject(ja.getString(i), ImageSlice.class);
+			String[] items=s.split(",");
+			for(int i=0;i<items.length;i++) {
+				String item=items[i];
+				item=item.trim();
+				String[] config=item.split(":");
+				if(config.length!=5) {
+					return null;
+				}
+				int iVal=Integer.valueOf(config[0]);
+				int x=Integer.valueOf(config[1]);
+				int y=Integer.valueOf(config[2]);
+				int w=Integer.valueOf(config[3]);
+				int h=Integer.valueOf(config[4]);
+				ImageSlice ret = new ImageSlice();
+				ret.setH(h);
+				ret.setI(iVal);
+				ret.setW(w);
+				ret.setX(x);
+				ret.setY(y);
 				if (ret.getH() == null || ret.getI() == null || ret.getW() == null || ret.getX() == null
 						|| ret.getY() == null||ret.getI()<0) {
 					return null;
 				}
 				list.add(ret);
 			}
+			if(list.size()==0) {
+				return null;
+			}
 			list.sort(new Comparator<ImageSlice>() {
 				@Override
 				public int compare(ImageSlice o1, ImageSlice o2) {

+ 11 - 3
src/main/java/cn/com/qmth/am/service/impl/StudentScoreServiceImpl.java

@@ -85,7 +85,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 
 	@Override
 	public void importScore() {
-		File dir = new File(sysProperty.getDataDir() + "/marking-score-import");
+		File dir = new File(sysProperty.getDataDir() + "/score-import");
 		File[] fs = dir.listFiles();
 		if (fs == null || fs.length == 0) {
 			return;
@@ -357,7 +357,11 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 		dto.setStudentId(score.getStudentId());
 		dto.setStudentScoreId(score.getId());
 		dto.setImage(getSlice(score, q, answerImages));
-		queue.offer(dto);
+		try {
+			queue.put(dto);
+		} catch (InterruptedException e) {
+			throw new RuntimeException(e);
+		}
 	}
 
 	private byte[] getSlice(StudentScoreEntity score, QuestionEntity q, Map<Integer, AnswerImageDto> answerImages) {
@@ -430,7 +434,11 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
 
 	@Override
 	public StudentScoreImageDto pollStudentScoreImage() {
-		return queue.poll();
+		try {
+			return queue.take();
+		} catch (InterruptedException e) {
+			throw new RuntimeException(e);
+		}
 	}
 
 	@Transactional

+ 8 - 6
src/main/resources/application.properties

@@ -13,7 +13,7 @@ com.qmth.mybatis.block-attack=false
 #
 db.host=localhost
 db.port=3306
-db.database=ai-marking
+db.database=ai_marking
 com.qmth.datasource.username=root
 com.qmth.datasource.password=123456
 com.qmth.datasource.url=jdbc:mysql://${db.host}:${db.port}/${db.database}?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2b8&rewriteBatchedStatements=true
@@ -28,11 +28,13 @@ com.qmth.logging.file-path=/home/admin/project/ai-marking/log/ai-marking.log
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8
 
-
 com.qmth.solar.app-version=@project.version@
-com.qmth.solar.access-key=
-com.qmth.solar.access-secret=
 
-am.image-server=
+##################################setting##########################################
+com.qmth.solar.access-key=7bbdc11570bc474dbf50e0d4a5dff328
+com.qmth.solar.access-secret=IOodRvbp2LspJTHOScgB7Yx8MRloMpyl
+
+am.image-server=https://file.markingcloud.com/
 am.data-type=MARKING_CLOUD
-am.data-dir=../data
+am.data-dir=../data
+##################################setting##########################################

BIN
template/question-import.xlsx


BIN
template/score-import.xlsx


BIN
template/struct-import.xlsx


BIN
template/student-import.xlsx