宋悦 7 жил өмнө
parent
commit
33953d2050

+ 6 - 7
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/CourseApi.java

@@ -26,13 +26,12 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
 import cn.com.qmth.examcloud.common.util.excel.ExcelError;
 import cn.com.qmth.examcloud.service.core.assemble.CourseAssembler;
-import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
+import cn.com.qmth.examcloud.service.core.dto.CourseDto;
 import cn.com.qmth.examcloud.service.core.entity.Course;
 import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
 import cn.com.qmth.examcloud.service.core.service.CourseService;
@@ -173,19 +172,19 @@ public class CourseApi {
     @ApiOperation(value="下载导入模板",notes = "下载导入模板")
     @GetMapping("/download")
     public void importFileTemplate(HttpServletResponse response){
-        List<CourseDTO> list= new ArrayList<CourseDTO>();
-        list.add(new CourseDTO("大学英语", "000001", "0"));
-        ExportUtils.exportEXCEL("课程导入模板", CourseDTO.class, list, response);
+        List<CourseDto> list= new ArrayList<CourseDto>();
+        list.add(new CourseDto("大学英语", "000001", "0"));
+        ExportUtils.exportEXCEL("课程导入模板", CourseDto.class, list, response);
     }
     
     @ApiOperation(value="导出课程",notes = "导出")
     @GetMapping("/export")
     public void exportCourse(@ModelAttribute Course orgCriteria,HttpServletResponse response){
-    	List<CourseDTO> list = new ArrayList<CourseDTO>();
+    	List<CourseDto> list = new ArrayList<CourseDto>();
     	courseService.findAll(orgCriteria).forEach(c -> {
     		list.add(courseAssembler.toDTO(c));
         });
-    	ExportUtils.exportEXCEL("课程列表", CourseDTO.class, list, response);
+    	ExportUtils.exportEXCEL("课程列表", CourseDto.class, list, response);
     }
     
     @ApiOperation(value="禁用课程",notes="禁用")

+ 3 - 6
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java

@@ -1,7 +1,7 @@
 package cn.com.qmth.examcloud.service.core.api;
 
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
+import cn.com.qmth.examcloud.service.core.dto.OrgDto;
 import cn.com.qmth.examcloud.service.core.util.ExportUtils;
 import io.swagger.annotations.ApiOperation;
 
@@ -13,7 +13,6 @@ import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import io.swagger.models.Response;
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
 import cn.com.qmth.examcloud.common.util.excel.ExcelError;
@@ -197,9 +195,8 @@ public class OrgApi {
     @ApiOperation(value="下载导入模板",notes = "下载导入模板")
     @GetMapping("/download")
     public void importFileTemplate(HttpServletResponse response){
-        List<Org> list= new ArrayList<Org>();
-        list.add(new Org("学习中心", "000001", "张三","13687653477"));
-        ExportUtils.exportEXCEL("学习中心导入模板", Org.class, list, response);
+        List<OrgDto> list= new ArrayList<OrgDto>();
+        ExportUtils.exportEXCEL("学习中心导入模板", OrgDto.class, list, response);
     }
 
     @ApiOperation(value = "启用机构", notes = "启用")

+ 6 - 11
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/SpecialtyApi.java

@@ -4,17 +4,12 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.function.Consumer;
-
-
-
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.com.qmth.examcloud.common.util.excel.ExcelError;
-import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
 import io.swagger.annotations.ApiOperation;
 
 
@@ -29,7 +24,7 @@ import org.springframework.web.bind.annotation.*;
 
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
-import cn.com.qmth.examcloud.service.core.dto.SpecialtyDTO;
+import cn.com.qmth.examcloud.service.core.dto.SpecialtyDto;
 import cn.com.qmth.examcloud.service.core.entity.Specialty;
 import cn.com.qmth.examcloud.service.core.repo.SpecialtyRepo;
 import cn.com.qmth.examcloud.service.core.service.SpecialtyService;
@@ -176,8 +171,8 @@ public class SpecialtyApi {
 	@ApiOperation(value="下载导入模板",notes = "下载导入模板")
 	@GetMapping("/download")
 	public void importFileTemplate(HttpServletResponse response){
-		List<SpecialtyDTO> list= new ArrayList<SpecialtyDTO>();
-		ExportUtils.exportEXCEL("专业导入模板", SpecialtyDTO.class, list, response);
+		List<SpecialtyDto> list= new ArrayList<SpecialtyDto>();
+		ExportUtils.exportEXCEL("专业导入模板", SpecialtyDto.class, list, response);
 	}
 
 	@ApiOperation(value="导入",notes = "导入")
@@ -208,10 +203,10 @@ public class SpecialtyApi {
 	@ApiOperation(value="导出专业", notes="导出专业")
 	@GetMapping("/export")
 	public void exportSpecialty(@ModelAttribute Specialty specialty,HttpServletResponse response){
-		List<SpecialtyDTO> list = new ArrayList<SpecialtyDTO>();
+		List<SpecialtyDto> list = new ArrayList<SpecialtyDto>();
 		specialtyService.findAll(specialty).forEach(c -> {
-			list.add(new SpecialtyDTO(c));
+			list.add(new SpecialtyDto(c));
 		});
-		ExportUtils.exportEXCEL("专业列表", SpecialtyDTO.class, list, response);
+		ExportUtils.exportEXCEL("专业列表", SpecialtyDto.class, list, response);
 	}
 }

+ 12 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserRoleApi.java

@@ -34,6 +34,18 @@ public class UserRoleApi {
         return new ResponseEntity(userRoleService.findAllRoles(), HttpStatus.OK);
     }
 
+    @ApiOperation(value="获取评卷角色",notes="获取评卷角色")
+    @GetMapping("/marker")
+    public ResponseEntity getMarkerRoles(){
+        return new ResponseEntity(userRoleService.findMarkerRoles(), HttpStatus.OK);
+    }
+
+    @ApiOperation(value="获取非评卷角色",notes="获取非评卷角色")
+    @GetMapping("/nonMarker")
+    public ResponseEntity getNonMarkerRoles(){
+        return new ResponseEntity(userRoleService.findNonMarkerRoles(), HttpStatus.OK);
+    }
+
     @ApiOperation(value="新增用户角色",notes="新增角色")
     @PostMapping
     public ResponseEntity addUserRole(@RequestBody UserRole userRole){

+ 3 - 3
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/CourseService.java

@@ -23,7 +23,7 @@ import cn.com.qmth.examcloud.common.dto.core.enums.CourseLevel;
 import cn.com.qmth.examcloud.common.util.excel.ExcelError;
 import cn.com.qmth.examcloud.common.util.excel.ExcelReader;
 import cn.com.qmth.examcloud.common.util.excel.ExcelReaderHandle;
-import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
+import cn.com.qmth.examcloud.service.core.dto.CourseDto;
 import cn.com.qmth.examcloud.service.core.entity.Course;
 import cn.com.qmth.examcloud.service.core.entity.CourseSpeciatly;
 import cn.com.qmth.examcloud.service.core.repo.CourseRepo;
@@ -41,11 +41,11 @@ public class CourseService {
     @Transactional
 	public List<ExcelError> importCourse(Long orgId,InputStream inputStream) {
 		List<Course> list = new ArrayList<Course>();
-		ExcelReader excelReader = new ExcelReader(CourseDTO.class);
+		ExcelReader excelReader = new ExcelReader(CourseDto.class);
         List<ExcelError> excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
             @Override
             public ExcelError handle(Object obj) {
-            	CourseDTO dto = (CourseDTO) obj;
+            	CourseDto dto = (CourseDto) obj;
             	Course course = new Course(dto.getName(),dto.getCode());
             	course.setOrgId(orgId);
             	course.setCreateTime(new Date());

+ 74 - 18
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/OrgService.java

@@ -6,6 +6,9 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import cn.com.qmth.examcloud.service.core.dto.OrgDto;
+import cn.com.qmth.examcloud.service.core.entity.ExamSite;
+import cn.com.qmth.examcloud.service.core.repo.ExamSiteRepo;
 import cn.com.qmth.examcloud.service.core.service.sync.DataSendService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,40 +36,97 @@ public class OrgService {
     @Autowired
     UserRepo userRepo;
 
+	@Autowired
+	ExamSiteRepo examSiteRepo;
+
 	@Autowired
 	DataSendService dataSendService;
     
     @Transactional
 	public List<ExcelError> importLearnCenter(Long orgId, InputStream inputStream) {
-		List<Org> list = new ArrayList<Org>();
-		Org parentOrg = orgRepo.findOne(orgId);
-		ExcelReader excelReader = new ExcelReader(Org.class);
+		ExcelReader excelReader = new ExcelReader(OrgDto.class);
         List<ExcelError> excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
             @Override
             public ExcelError handle(Object obj) {
-            	Org dto = (Org) obj;
-                dto.setRootId(orgId);
-                dto.setParentId(orgId);
-                dto.setApps(parentOrg.getApps());
-                dto.setCreateTime(new Date());
-                dto.setEnable(true);
+				OrgDto dto = (OrgDto) obj;
+				dto.setParentId(orgId);
+				dto.setRootId(orgId);
                 ExcelError error = importCheck(dto);
                 if (error == null) {
-                	list.add(dto);
+                	saveOrgAndExamSite(dto);
                 }
                 return error;
             }
         });
-        orgRepo.save(list);
 		return excelErrors;
 	}
 
-	private ExcelError importCheck(Org dto) {
+	private void saveOrgAndExamSite(OrgDto orgDto){
+		Org org = orgRepo.findFirstByParentIdAndCode(orgDto.getParentId(),orgDto.getCode());
+		if(org == null){
+
+			Org tempOrg = orgRepo.save(orgAssembler(orgDto));
+			orgDto.setId(tempOrg.getId());
+			examSiteRepo.save(examSiteAssembler(orgDto));
+
+		}else{
+
+			org.setName(orgDto.getName());
+			org.setContacts(orgDto.getContacts());
+			org.setTelphone(orgDto.getTelphone());
+			orgRepo.save(org);
+
+			orgDto.setId(org.getId());
+			ExamSite examSite = examSiteRepo.findFirstByOrgIdAndCode(org.getId(),orgDto.getExamSiteCode());
+			if(examSite == null){
+				examSiteRepo.save(examSiteAssembler(orgDto));
+			}else{
+				examSite.setName(orgDto.getExamSiteName());
+				examSite.setContacts(orgDto.getContacts());
+				examSite.setTelphone(orgDto.getTelphone());
+				examSiteRepo.save(examSite);
+			}
+		}
+
+	}
+
+	private Org orgAssembler(OrgDto orgDto){
+		Org org = new Org();
+		org.setRootId(orgDto.getRootId());
+		org.setParentId(orgDto.getParentId());
+		org.setCode(orgDto.getCode());
+		org.setName(orgDto.getName());
+		org.setContacts(orgDto.getContacts());
+		org.setTelphone(orgDto.getTelphone());
+		org.setCreateTime(new Date());
+		org.setEnable(true);
+		return org;
+	}
+
+	private ExamSite examSiteAssembler(OrgDto orgDto){
+		ExamSite examSite = new ExamSite();
+		examSite.setCode(orgDto.getExamSiteCode());
+		examSite.setName(orgDto.getExamSiteName());
+		examSite.setOrgId(orgDto.getId());
+		examSite.setContacts(orgDto.getContacts());
+		examSite.setTelphone(orgDto.getTelphone());
+		examSite.setCreateTime(new Date());
+		examSite.setEnable(true);
+		return examSite;
+	}
+
+	private ExcelError importCheck(OrgDto dto) {
 		if(StringUtils.isEmpty(dto.getCode())){
-			return new ExcelError("代码不能为空");
+			return new ExcelError("中心代码不能为空");
 		}
 		if(StringUtils.isEmpty(dto.getName())){
-			return new ExcelError("名称不能为空");
+			return new ExcelError("中心名称不能为空");
+		}
+		if(StringUtils.isEmpty(dto.getExamSiteCode())){
+			return new ExcelError("考点代码不能为空");
+		}
+		if(StringUtils.isEmpty(dto.getExamSiteName())){
+			return new ExcelError("考点名称不能为空");
 		}
 		if(StringUtils.isEmpty(dto.getContacts())){
 			return new ExcelError("联系人不能为空");
@@ -74,10 +134,6 @@ public class OrgService {
 		if(StringUtils.isEmpty(dto.getTelphone())){
 			return new ExcelError("联系电话不能为空");
 		}
-		Org org = orgRepo.findFirstByParentIdAndCode(dto.getParentId(),dto.getCode());
-		if(org!=null){
-			return new ExcelError("代码已存在");
-		}
 		return null;
 	}
 

+ 3 - 3
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/SpecialtyService.java

@@ -22,7 +22,7 @@ import org.springframework.util.StringUtils;
 import cn.com.qmth.examcloud.common.util.excel.ExcelError;
 import cn.com.qmth.examcloud.common.util.excel.ExcelReader;
 import cn.com.qmth.examcloud.common.util.excel.ExcelReaderHandle;
-import cn.com.qmth.examcloud.service.core.dto.SpecialtyDTO;
+import cn.com.qmth.examcloud.service.core.dto.SpecialtyDto;
 import cn.com.qmth.examcloud.service.core.entity.CourseSpeciatly;
 import cn.com.qmth.examcloud.service.core.entity.Specialty;
 import cn.com.qmth.examcloud.service.core.repo.SpecialtyRepo;
@@ -40,11 +40,11 @@ public class SpecialtyService {
 	@Transactional
 	public List<ExcelError> importSpecialty(Long orgId, InputStream inputStream) {
 		List<Specialty> list = new ArrayList<Specialty>();
-		ExcelReader excelReader = new ExcelReader(SpecialtyDTO.class);
+		ExcelReader excelReader = new ExcelReader(SpecialtyDto.class);
 		List<ExcelError> excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
 			@Override
 			public ExcelError handle(Object obj) {
-				SpecialtyDTO dto = (SpecialtyDTO) obj;
+				SpecialtyDto dto = (SpecialtyDto) obj;
 				Specialty specialty = new Specialty(dto.getCode(),dto.getName());
 				specialty.setOrgId(orgId);
 				specialty.setCreateTime(new Date());

+ 19 - 0
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserRoleService.java

@@ -2,11 +2,14 @@ package cn.com.qmth.examcloud.service.core.service;
 
 import cn.com.qmth.examcloud.common.uac.entity.Role;
 import cn.com.qmth.examcloud.common.uac.entity.RolesService;
+import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
 import cn.com.qmth.examcloud.service.core.repo.UserRoleRepo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 用户角色服务类
@@ -27,5 +30,21 @@ public class UserRoleService{
         return RolesService.ROLE_LIST;
     }
 
+    public List<Role> findMarkerRoles(){
+        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> role.getCode().equals(RoleMeta.MARKER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+
+    public List<Role> findNonMarkerRoles(){
+        List<Role> tempRoles = new ArrayList<>(RolesService.ROLE_LIST);
+        tempRoles = tempRoles.stream()
+                .filter(role -> !role.getCode().equals(RoleMeta.MARKER.name()))
+                .collect(Collectors.toList());
+        return tempRoles;
+    }
+
 
 }

+ 4 - 4
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/assemble/CourseAssembler.java

@@ -2,16 +2,16 @@ package cn.com.qmth.examcloud.service.core.assemble;
 
 import org.springframework.stereotype.Component;
 
-import cn.com.qmth.examcloud.service.core.dto.CourseDTO;
+import cn.com.qmth.examcloud.service.core.dto.CourseDto;
 import cn.com.qmth.examcloud.service.core.entity.Course;
 
 @Component
 public class CourseAssembler {
 	
-	public CourseDTO toDTO(Course course){
-		CourseDTO dto = null;
+	public CourseDto toDTO(Course course){
+		CourseDto dto = null;
 		if(dto == null){
-			dto = new CourseDTO();
+			dto = new CourseDto();
 			dto.setName(course.getName());
 			dto.setCode(course.getCode());
 			dto.setLevel(course.getLevel().getName());

+ 3 - 3
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/CourseDTO.java → core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/CourseDto.java

@@ -8,7 +8,7 @@ import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
  * @author ting.yin
  * @date 2017年1月5日
  */
-public class CourseDTO{
+public class CourseDto {
 
 
     @ExcelProperty(index = 1,name = "课程代码")
@@ -65,12 +65,12 @@ public class CourseDTO{
 		this.enable = enable;
 	}
 
-	public CourseDTO(String name,String code,String level) {
+	public CourseDto(String name, String code, String level) {
 		this.name = name;
 		this.code = code;
 		this.level = level;
 	}
 
-	public CourseDTO() {
+	public CourseDto() {
 	}
 }

+ 141 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/OrgDto.java

@@ -0,0 +1,141 @@
+package cn.com.qmth.examcloud.service.core.dto;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
+
+import java.io.Serializable;
+
+/**
+ * Created by songyue on 17/1/13.
+ */
+public class OrgDto implements Serializable{
+
+    private static final long serialVersionUID = -592353272256492483L;
+
+    private Long id;
+    /**
+     * 顶级机构id,无上级时为0;eg.学校即是顶级
+     */
+    private Long rootId;
+    /**
+     * 父级机构id,无上级时为0;eg.学习中心的父级为学校
+     */
+    private Long parentId;
+
+    @ExcelProperty(name = "机构名称",index = 0)
+    private String name;
+
+    /**
+     * 学习中心代码
+     */
+    @ExcelProperty(name = "机构代码",index = 1)
+    private String code;
+
+    /**
+     * 考点名称
+     */
+    @ExcelProperty(name = "考点名称",index = 2)
+    private String examSiteName;
+
+    /**
+     * 考点代码
+     */
+    @ExcelProperty(name = "考点代码",index = 3)
+    private String examSiteCode;
+
+    /**
+     * 联系人
+     */
+    @ExcelProperty(name = "联系人",index = 4)
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    @ExcelProperty(name = "联系电话",index = 5)
+    private String telphone;
+
+    private Boolean enable;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getRootId() {
+        return rootId;
+    }
+
+    public void setRootId(Long rootId) {
+        this.rootId = rootId;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getExamSiteName() {
+        return examSiteName;
+    }
+
+    public void setExamSiteName(String examSiteName) {
+        this.examSiteName = examSiteName;
+    }
+
+    public String getExamSiteCode() {
+        return examSiteCode;
+    }
+
+    public void setExamSiteCode(String examSiteCode) {
+        this.examSiteCode = examSiteCode;
+    }
+
+    public String getContacts() {
+        return contacts;
+    }
+
+    public void setContacts(String contacts) {
+        this.contacts = contacts;
+    }
+
+    public String getTelphone() {
+        return telphone;
+    }
+
+    public void setTelphone(String telphone) {
+        this.telphone = telphone;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public OrgDto() {
+    }
+}

+ 3 - 3
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/SpecialtyDTO.java → core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/SpecialtyDto.java

@@ -8,7 +8,7 @@ import cn.com.qmth.examcloud.service.core.entity.Specialty;
  * @author weiwenhai
  * @date 2017年8月7号
  */
-public class SpecialtyDTO {
+public class SpecialtyDto {
 
 	@ExcelProperty(index = 1,name = "专业代码")
 	private String code;
@@ -20,9 +20,9 @@ public class SpecialtyDTO {
 	
 	private String enable;
 	
-	public SpecialtyDTO(){}
+	public SpecialtyDto(){}
 	
-	public SpecialtyDTO(Specialty specialty){
+	public SpecialtyDto(Specialty specialty){
 		this.code = specialty.getCode();
 		this.name = specialty.getName();
 	}