CfAspectOptrControl.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package cn.hmsoft.mr.control.cf;
  2. import java.io.IOException;
  3. import java.util.List;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import org.springframework.web.multipart.MultipartFile;
  8. import cn.hmsoft.application.web.Ajax;
  9. import cn.hmsoft.frame.constants.FrameThreadCallbackType;
  10. import cn.hmsoft.frame.constants.FrameThreadStatus;
  11. import cn.hmsoft.frame.control.FrameControl;
  12. import cn.hmsoft.frame.data.model.FrameDept;
  13. import cn.hmsoft.frame.data.model.FrameOptr;
  14. import cn.hmsoft.frame.data.model.FrameThread;
  15. import cn.hmsoft.frame.thread.FrameThreadHelper;
  16. import cn.hmsoft.helper.excel.ExcelReaderHelper;
  17. import cn.hmsoft.mr.constants.FrameResIdConst;
  18. import cn.hmsoft.mr.constants.MRConst;
  19. import cn.hmsoft.mr.data.dao.cf.CfAspectOptrDao;
  20. import cn.hmsoft.mr.service.cf.CfAspectOptrService;
  21. /**
  22. * 评审专业老师
  23. * @author zq
  24. *
  25. */
  26. @RestController
  27. public class CfAspectOptrControl extends FrameControl {
  28. @Autowired
  29. private CfAspectOptrService service;
  30. @Autowired
  31. private CfAspectOptrDao dao;
  32. /**
  33. * 专业评审老师
  34. * @param query : 查询条件
  35. * @param school_id: 学校ID
  36. */
  37. @RequestMapping("cf/aspect/optr/page.htm")
  38. public Ajax pageAspectOptr(String query, Integer start, Integer limit, String order, String type,
  39. Integer school_id, Integer batch_id, Integer aspect_id) {
  40. return new Ajax(this.dao.pageAspectOptr(start, limit, query, getQueryOrder(order, type),
  41. school_id, batch_id, aspect_id));
  42. }
  43. /**
  44. * 专业评审老师账号信息
  45. * @param query : 查询条件
  46. * @param school_id: 学校ID
  47. */
  48. @RequestMapping("cf/school/optr/page")
  49. public Ajax pageSchoolOptr(String query, Integer start, Integer limit, String order, String type,
  50. Integer school_id) {
  51. FrameDept org = this.dao.find(FrameDept.class, this.getFrameOptr().getOptr_dept());
  52. Integer dept_id = null;
  53. if (!org.getDept_type().equals(MRConst.OrgType.Admin.toString())) {
  54. dept_id = org.getDept_id();
  55. } else {
  56. return new Ajax();
  57. }
  58. return new Ajax(this.dao.pageSchoolOptr(start, limit, query, getQueryOrder(order, type),
  59. dept_id));
  60. }
  61. /**
  62. * @param ids
  63. * @param aspect_id
  64. */
  65. @RequestMapping("cf/aspect/optr/set.htm")
  66. public Ajax setAspectOptr(Integer[] ids, Integer school_id, Integer batch_id, Integer aspect_id) {
  67. this.authOptrRole(FrameResIdConst.RES_ASPECT_OPTR_SET);
  68. this.service.setAspectOptr(ids, school_id, batch_id, aspect_id, this.getFrameOptr());
  69. return new Ajax();
  70. }
  71. /**
  72. * @param file
  73. * @param batch_id
  74. * @throws IOException
  75. */
  76. @RequestMapping("cf/aspect/optr/upload.htm")
  77. public Ajax uploadAspectOptr(MultipartFile file, Integer school_id, Integer batch_id, String error_flag, String thread_flag) throws IOException {
  78. //this.authOptrRole(FrameResIdConst.RES_ASPECT_OPTR_UPLOAD);
  79. final FrameOptr optr = this.getFrameOptr();
  80. List<List<String>> array = ExcelReaderHelper.readSheet(file.getOriginalFilename(), file.getInputStream());
  81. FrameThread thread = FrameThreadHelper.createThread("考生导入线程", "数据需要进行处理", FrameThreadCallbackType.Swal,
  82. "数据处理完成", this.getFrameOptr());
  83. try {
  84. new Thread(() -> {
  85. this.service.uploadProcess(thread, school_id, batch_id, error_flag, array, file, optr);
  86. }).start();
  87. } catch (Exception e) {
  88. FrameThreadHelper.completeThread(thread, "出现错误:" + e.getMessage(), FrameThreadStatus.Error);
  89. }
  90. return new Ajax(thread);
  91. }
  92. }