Browse Source

央美本科

haogh 7 months ago
parent
commit
a1fd466a61

+ 14 - 0
sql/update.sql

@@ -71,3 +71,17 @@ CREATE TABLE `ly_std_ticket_result`
   ROW_FORMAT = Dynamic;
 
 INSERT INTO `frame_res`(`RES_ID`, `RES_NAME`, `RES_ALIAS`, `RES_URL`, `RES_PID`, `RES_LEVEL`, `RES_TYPE`, `RES_CSS`, `RES_STATUS`, `RES_ORDER`, `RES_DESC`) VALUES (304060, '准考证查询', '准考证查询', '/art/layout/material/ticketResult', 304000, 4, 'Page', 'fas fa-cart-plus text-danger', 'Active', 304060, NULL);
+
+
+CREATE TABLE `ly_room_model_photo`
+(
+    `id`          int(0)                                                  NOT NULL COMMENT '主键',
+    `room_id`     int(0)                                                  NOT NULL COMMENT '考场ID',
+    `seq`         int(0)                                                  NULL DEFAULT NULL COMMENT '序号',
+    `photo_path`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片路径',
+    `create_time` datetime(0)                                             NULL DEFAULT NULL COMMENT '创建时间',
+    PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB
+  CHARACTER SET = utf8
+  COLLATE = utf8_general_ci COMMENT = '模特拍照表'
+  ROW_FORMAT = Dynamic;

+ 43 - 34
src/cn/hmsoft/art/control/ex/pad/PadAppControl.java

@@ -8,6 +8,7 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import cn.hmsoft.art.data.dao.cf.CfAgentDao;
+import cn.hmsoft.art.helper.ArtParamHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -33,30 +34,32 @@ import cn.hmsoft.helper.StringHelper;
 public class PadAppControl {
 	
 	public static String AgentDownloadWriteStdPass = "hm2021";
-	
+
 	@Autowired
 	private StdRegDao daoStd;
+
 	@Autowired
 	private LyAgentDao daoAgent;
+
 	@Autowired
 	private CfAgentDao daoCfAgent;
+
 	@Autowired
 	private PadAppService sPadApp;
 	
 	/**
 	 * 拍模特.
-	 * @param password
-	 * @param room_id
-	 * @param room_image_type
-	 * @param request
-	 * @return
+	 * @param password 验证密码
+	 * @param room_id 考场ID
+	 * @param room_image_type 1\2\3
+	 * @param request 请求体
+	 * @return ajax
 	 */
 	@RequestMapping("pad/photo/mote/upload")
 	public Ajax uploadMoteImage(String password, int room_id, int room_image_type,
 			HttpServletRequest request) {
 		FrameAssertUtil.isEqual(password, AgentDownloadWriteStdPass, "密码错误,请重试");
-		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
-				request.getSession().getServletContext());
+		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
 		if (multipartResolver.isMultipart(request)) {
 			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
 			Iterator<String> iter = multiRequest.getFileNames();
@@ -75,32 +78,29 @@ public class PadAppControl {
 	
 	/**
 	 * 笔试拍照.
-	 * @param password
-	 * @param std_id
-	 * @param cert_id
-	 * @param agent_id
-	 * @param room_id
-	 * @param subject_id
-	 * @param photo_time
-	 * @param request
-	 * @return
+	 * @param password 密码
+	 * @param std_id 考生ID
+	 * @param cert_id 考生证件号码
+	 * @param agent_id 考点ID
+	 * @param room_id 笔试考场ID
+	 * @param subject_id 科目ID
+	 * @param photo_time 拍摄时间
+	 * @param request 请求体
+	 * @return ajax
 	 */
 	@RequestMapping("pad/photo/upload")
-	public Ajax uploadImage(String password, Integer std_id, String cert_id,
-			Integer agent_id, Integer room_id, Integer subject_id, String photo_time,
+	public Ajax uploadImage(String password, Integer std_id, String cert_id, Integer agent_id, Integer room_id, Integer subject_id, String photo_time,
 			HttpServletRequest request) {
 		FrameAssertUtil.isEqual(password, AgentDownloadWriteStdPass, "密码错误,请重试");
-		if (StringHelper.isEmpty(cert_id) || agent_id == null
-				|| StringHelper.isEmpty(subject_id))
+		if (StringHelper.isEmpty(cert_id) || agent_id == null || StringHelper.isEmpty(subject_id))
 			throw new BusinessException("查询考生出现错误:缺少必要的参数信息");
 
+		// 考生判断
 		StdReg std = daoStd.find("cert_id", cert_id);
-
 		FrameAssertUtil.isNotNull(std, "找不到证件号码匹配的考生信息");
 		FrameAssertUtil.isEqual(std.getStd_id(), std_id, "考生编号与数据库不一致");
 
-		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(
-				request.getSession().getServletContext());
+		CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
 		if (multipartResolver.isMultipart(request)) {
 			MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
 			Iterator<String> iter = multiRequest.getFileNames();
@@ -119,37 +119,46 @@ public class PadAppControl {
 	
 	/**
 	 * 笔试拍照考生列表.
-	 * @param password
-	 * @param agent_id
-	 * @return
+	 * @param password 验证密码
+	 * @param agent_id 考点Id
+	 * @return ajax
 	 */
 	@RequestMapping("pad/photo/std/list")
-	private Ajax downloadInfo(String password, String agent_id) {
-		Map<String, Object> map = new HashMap<String, Object>();
+	public Ajax downloadInfo(String password, String agent_id) {
+		Map<String, Object> map = new HashMap<>();
 		FrameAssertUtil.isEqual(password, AgentDownloadWriteStdPass, "密码错误,请重试");
 		// 科目
 		//String sql = "select ly_agent_id agent_id,ly_group_id group_id,subject_id,subject_name,subject_name subject_alias,group_order,exam_start_time,exam_end_time from ly_subject sb where ly_agent_id=? and subject_type='Written' order by exam_start_time";
 		String sql="SELECT sb.ly_agent_id agent_id,sb.ly_group_id group_id,sb.subject_id,sb.subject_name,CONCAT(sb.subject_name,'(',a.ASPECT_NAME,')') subject_alias,sb.group_order,sb.exam_start_time,sb.exam_end_time FROM ly_subject sb LEFT JOIN cf_aspect_subject cas ON cas.SUBJECT_ID=sb.SUBJECT_ID LEFT JOIN cf_aspect a ON a.ASPECT_ID=cas.ASPECT_ID WHERE ly_agent_id=? AND subject_type='Written' ORDER BY exam_start_time";
 		map.put("SubjectArray", this.daoAgent.listMapBySql(sql, agent_id));
+
 		// 考场
-		sql = "select ly_agent_id agent_id,ly_group_id group_id,ly_room_id room_id,room_name,room_seq,room_addr,room_capacity,room_status from ly_room_written where ly_agent_id=? and room_province='1' order by ly_group_id,room_seq";
+		//and room_province='1'
+		sql = "select ly_agent_id agent_id,ly_group_id group_id,ly_room_id room_id,room_name,room_seq,room_addr,room_capacity,room_status from ly_room_written where ly_agent_id=?  order by ly_group_id,room_seq";
+		// 央美-只有中国画和造型艺术需要拍照
+		if(ArtParamHelper.SchoolCode.equals("10047")) {
+			sql = "select ly_aget_id agent_id,ly_group_id group_id,ly_room_id room_id,room_name,room_seq,room_addr,room_capacity,room_status from ly_room_written where ly_agent_id=? and (room_name like '%中国画%' or room_name like '%造型艺术%') or order by ly_group_id,room_seq ";
+		}
 		map.put("RoomArray", this.daoAgent.listMapBySql(sql, agent_id));
+
 		// 考生列表
 		sql = "select std.std_id,std.cert_id,std.std_name,std.std_mobile std_mobile1,std.std_sex,t.ticket_no ticket_num,sb.subject_id,sb.ly_group_id group_id,sb.subject_name,sb.group_name,sb.ly_room_id room_id,sb.real_exam_seq exam_seq,sb.ly_room_addr room_addr,sb.ly_room_seq std_seatnumber  from ly_std_subject sb,ly_std_ticket t,std_reg std where sb.std_id=t.std_id and t.std_id=std.std_id and t.ly_agent_id=sb.ly_agent_id and sb.subject_type='Written' and t.category_id=sb.category_id and sb.ly_agent_id=? order by sb.subject_id,sb.ly_room_id,sb.real_exam_seq";
 		map.put("StdArray", this.daoAgent.listMapBySql(sql, agent_id));
+
 		return new Ajax(map);
 	}
 	
 	/**
 	 * 考点列表
-	 * @param password
-	 * @return
+	 * @param password 密码
+	 * @return ajax
 	 */
 	@RequestMapping("pad/photo/agent/list")
-	private Ajax getAgents(String password) {
-
+	public Ajax getAgents(String password) {
 		FrameAssertUtil.isEqual(password, AgentDownloadWriteStdPass, "密码错误,请重试");
 		String sql = "select agent_id,agent_name,agent_addr from cf_agent where agent_id in (select distinct ly_agent_id from ly_group) order by enrol_start_time";
 		return new Ajax(daoCfAgent.listBySql(sql));
 	}
+
+
 }

+ 12 - 0
src/cn/hmsoft/art/data/dao/ly/LyRoomModelPhotoDao.java

@@ -0,0 +1,12 @@
+package cn.hmsoft.art.data.dao.ly;
+
+import cn.hmsoft.art.data.model.ly.LyRoomModelPhoto;
+import cn.hmsoft.jdbc.core.PlatformDaoSupport;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class LyRoomModelPhotoDao extends PlatformDaoSupport<LyRoomModelPhoto> {
+
+
+
+}

+ 70 - 0
src/cn/hmsoft/art/data/model/ly/LyRoomModelPhoto.java

@@ -0,0 +1,70 @@
+package cn.hmsoft.art.data.model.ly;
+
+import cn.hmsoft.jdbc.entity.Table;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 模特拍照
+ */
+@Table(tableName = "ly_room_model_photo", keyColumn = "ID", sequenceName = "")
+public class LyRoomModelPhoto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    //ID
+    private Integer id;
+
+    //考场ID
+    private Integer room_id;
+
+    //序号
+    private Integer seq;
+
+    //图片路径
+    private String photo_path;
+
+    //创建时间
+    private LocalDateTime create_time;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getRoom_id() {
+        return room_id;
+    }
+
+    public void setRoom_id(Integer room_id) {
+        this.room_id = room_id;
+    }
+
+    public Integer getSeq() {
+        return seq;
+    }
+
+    public void setSeq(Integer seq) {
+        this.seq = seq;
+    }
+
+    public String getPhoto_path() {
+        return photo_path;
+    }
+
+    public void setPhoto_path(String photo_path) {
+        this.photo_path = photo_path;
+    }
+
+    public LocalDateTime getCreate_time() {
+        return create_time;
+    }
+
+    public void setCreate_time(LocalDateTime create_time) {
+        this.create_time = create_time;
+    }
+}

+ 82 - 34
src/cn/hmsoft/art/service/ex/pad/PadAppService.java

@@ -1,18 +1,12 @@
 package cn.hmsoft.art.service.ex.pad;
 
-import java.io.File;
-import java.time.LocalDateTime;
-import java.util.Date;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-
 import cn.hmsoft.art.constants.ExamStdLogType;
 import cn.hmsoft.art.constants.StdImageType;
 import cn.hmsoft.art.data.dao.ex.ExStdLogDao;
+import cn.hmsoft.art.data.dao.ly.LyRoomModelPhotoDao;
 import cn.hmsoft.art.data.dao.ly.LyStdSubjectDao;
 import cn.hmsoft.art.data.dao.std.StdRegDao;
+import cn.hmsoft.art.data.model.ly.LyRoomModelPhoto;
 import cn.hmsoft.art.data.model.ly.LyRoomWritten;
 import cn.hmsoft.art.data.model.std.StdReg;
 import cn.hmsoft.art.helper.ArtParamHelper;
@@ -21,60 +15,99 @@ import cn.hmsoft.frame.exception.BusinessException;
 import cn.hmsoft.frame.util.FrameAssertUtil;
 import cn.hmsoft.helper.FileHelper;
 import cn.hmsoft.helper.RandomHelper;
+import cn.hmsoft.log.LogHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.time.LocalDateTime;
+import java.util.Objects;
 
 @Service
 public class PadAppService extends ArtService {
+
 	@Autowired
 	private LyStdSubjectDao daoSubject;
+
 	@Autowired
 	private StdRegDao daoStd;
+
 	@Autowired
 	private ExStdLogDao daoLog;
+
+	@Autowired
+	private LyRoomModelPhotoDao roomModelPhotoDao;
 	
 	//模特照片上传
 	public void uploadMoteImage(int room_id, int room_image_type, MultipartFile file) {
 		String suffix = FileHelper.getFileSuffix(file);
 		FrameAssertUtil.isNotEmpty(suffix, "必须带有图片格式的后缀名");
-		String filename= file.getOriginalFilename().indexOf(".") > 0 ? file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf(".")) : null;
-		File newFile = this.makeMoteImageFile("mote_"+filename, room_id, room_image_type, suffix);
-		if (!this.upload(file, newFile))
+		if (!suffix.equalsIgnoreCase("png") && !suffix.equalsIgnoreCase("jpg") && !suffix.equalsIgnoreCase("jpeg")) {
+			throw new BusinessException("请上传后缀为png、jpg、jpeg格式的图片文件");
+		}
+
+		//文件名称
+		String filename = Objects.requireNonNull(file.getOriginalFilename()).indexOf(".") > 0 ?
+				file.getOriginalFilename().substring(0, file.getOriginalFilename().lastIndexOf(".")) :
+				null;
+		LyRoomWritten rw = daoSubject.find(LyRoomWritten.class, room_id);
+		if (rw == null) {
+			throw new BusinessException("考场不存在,请确认考场是否正确");
+		}
+		File newFile = this.makeMoteImageFile(rw, "mote_" + filename, room_id, room_image_type, suffix);
+		if (!this.upload(file, newFile)) {
 			throw new BusinessException("服务器保存照片失败,请重试");
+		}
+
+		// 关联考场
+		String photoPath = "mote" + File.separator + rw.getRoom_name() + "(" + rw.getRoom_addr() + ")" + File.separator + newFile.getName();
+		LyRoomModelPhoto photo = new LyRoomModelPhoto();
+		photo.setRoom_id(room_id);
+		photo.setPhoto_path(photoPath);
+		photo.setSeq(room_image_type);
+		photo.setCreate_time(LocalDateTime.now());
+		roomModelPhotoDao.insert(photo);
 	}
-	
-	public void uploadImage(int std_id, int agent_id, int room_id, int subject_id,
-			String img_time, MultipartFile file) {
+
+	public void uploadImage(int std_id, int agent_id, int room_id, int subject_id, String img_time, MultipartFile file) {
+		// 图片格式判断
 		String suffix = FileHelper.getFileSuffix(file);
 		FrameAssertUtil.isNotEmpty(suffix, "必须带有图片格式的后缀名");
+		if (!suffix.equalsIgnoreCase("png") && !suffix.equalsIgnoreCase("jpg") && !suffix.equalsIgnoreCase("jpeg")) {
+			throw new BusinessException("请上传后缀为png、jpg、jpeg格式的图片文件");
+		}
+
 		StdReg std = this.daoStd.find(std_id);
-		String file_name = "";
-		File newFile = this.makeStdImageFile(StdImageType.StdWrite, agent_id,
-				subject_id, std.getCert_id(), suffix);
-		if (!this.upload(file, newFile))
+
+		// 上传图片到服务器
+		String file_name;
+		File newFile = this.makeStdImageFile(StdImageType.StdWrite, agent_id, subject_id, std.getCert_id(), suffix);
+		if (!this.upload(file, newFile)) {
 			throw new BusinessException("服务器保存照片失败,请重试");
+		}
 		// 保存图片
 		file_name = newFile.getName();
-		this.daoLog.log(std_id, agent_id, subject_id, room_id,
-				ExamStdLogType.ExamPhoto, LocalDateTime.now(), null);
-		this.daoSubject.updateStdWrittenPhoto(room_id, std_id, subject_id, file_name +'.' + suffix);
+		//更新数据库中的图片字段
+		this.daoSubject.updateStdWrittenPhoto(room_id, std_id, subject_id, file_name + '.' + suffix);
+
+		this.daoLog.log(std_id, agent_id, subject_id, room_id, ExamStdLogType.ExamPhoto, LocalDateTime.now(), null);
+
 	}
-	
-	private File makeMoteImageFile(String image_type, int room_id,
-			int room_image_type, String dot) {
-		LyRoomWritten rw = daoSubject.find(LyRoomWritten.class, room_id);
+
+	private File makeMoteImageFile(LyRoomWritten rw, String image_type, int room_id, int room_image_type, String dot) {
+		//		LyRoomWritten rw = daoSubject.find(LyRoomWritten.class, room_id);
 		File file = new File(ArtParamHelper.EnrolMaterialLocalPath
-				+ File.separator + "mote" + File.separator + rw.getRoom_name()+"(" + rw.getRoom_addr()+")" + File.separator + image_type
+				+ File.separator + "mote" + File.separator + rw.getRoom_name() + "(" + rw.getRoom_addr() + ")" + File.separator + image_type
 				+ "_" + room_id + "_" + room_image_type + "_"
 				+ RandomHelper.getRandomValue(8) + "." + dot);
 		file.getParentFile().mkdirs();
 		return file;
 	}
-	
-	private File makeStdImageFile(String image_type, int agent_id,
-			int subject_id, String cert_id, String dot) {
-		File file = new File(ArtParamHelper.EnrolMaterialLocalPath
-				+ File.separator + image_type + File.separator + image_type
-				+ "_" + agent_id + "_" + subject_id + "_" + cert_id + "_"
-				+ RandomHelper.getRandomValue(8) + "." + dot);
+
+	private File makeStdImageFile(String image_type, int agent_id, int subject_id, String cert_id, String dot) {
+		File file = new File(ArtParamHelper.EnrolMaterialLocalPath + File.separator + image_type + File.separator + image_type
+				+ "_" + agent_id + "_" + subject_id + "_" + cert_id + "_" + RandomHelper.getRandomValue(8) + "." + dot);
 		file.getParentFile().mkdirs();
 		return file;
 	}
@@ -86,9 +119,24 @@ public class PadAppService extends ArtService {
 		try {
 			source.transferTo(target);
 		} catch (Exception e) {
-			e.printStackTrace();
+			LogHelper.error(e);
 			return false;
 		}
 		return true;
 	}
+
+	public static void main(String[] args) {
+		LyRoomWritten rw = new LyRoomWritten();
+		rw.setRoom_name("第1考场");
+		rw.setRoom_addr("附中教学楼1208");
+		String image_type = "mote_测试";
+		int room_id = 88;
+		int room_image_type = 1;
+		String dot = "jpg";
+		File file = new File(ArtParamHelper.EnrolMaterialLocalPath
+				+ File.separator + "mote" + File.separator + rw.getRoom_name() + "(" + rw.getRoom_addr() + ")" + File.separator + image_type
+				+ "_" + room_id + "_" + room_image_type + "_"
+				+ RandomHelper.getRandomValue(8) + "." + dot);
+		System.out.println(file.getName());
+	}
 }