ClassGradeController.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. package com.zhongzheng.controller.grade;
  2. import java.io.FileOutputStream;
  3. import java.time.LocalDateTime;
  4. import java.time.format.DateTimeFormatter;
  5. import java.util.*;
  6. import java.util.concurrent.TimeUnit;
  7. import java.util.stream.Collectors;
  8. import cn.afterturn.easypoi.excel.ExcelExportUtil;
  9. import cn.afterturn.easypoi.excel.entity.ExportParams;
  10. import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
  11. import cn.hutool.core.bean.BeanUtil;
  12. import cn.hutool.core.lang.Validator;
  13. import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
  14. import com.baomidou.mybatisplus.core.toolkit.StringUtils;
  15. import com.github.pagehelper.PageInfo;
  16. import com.zhongzheng.common.core.domain.entity.SysRole;
  17. import com.zhongzheng.common.core.redis.RedisCache;
  18. import com.zhongzheng.common.utils.SecurityUtils;
  19. import com.zhongzheng.common.utils.ServletUtils;
  20. import com.zhongzheng.common.utils.ToolsUtils;
  21. import com.zhongzheng.modules.base.bo.UserProfileQueryBo;
  22. import com.zhongzheng.modules.base.vo.UserProfileExportGaiVo;
  23. import com.zhongzheng.modules.goods.service.IGoodsService;
  24. import com.zhongzheng.modules.goods.vo.GoodsVo;
  25. import com.zhongzheng.modules.grade.bo.*;
  26. import com.zhongzheng.modules.grade.domain.ClassGrade;
  27. import com.zhongzheng.modules.grade.service.*;
  28. import com.zhongzheng.modules.grade.vo.*;
  29. import com.zhongzheng.modules.user.entity.ClientLoginUser;
  30. import io.swagger.models.auth.In;
  31. import lombok.RequiredArgsConstructor;
  32. import org.springframework.beans.BeanUtils;
  33. import org.springframework.boot.SpringBootVersion;
  34. import org.springframework.security.access.prepost.PreAuthorize;
  35. import org.springframework.beans.factory.annotation.Autowired;
  36. import org.springframework.web.bind.annotation.GetMapping;
  37. import org.springframework.web.bind.annotation.PostMapping;
  38. import org.springframework.web.bind.annotation.PutMapping;
  39. import org.springframework.web.bind.annotation.DeleteMapping;
  40. import org.springframework.web.bind.annotation.PathVariable;
  41. import org.springframework.web.bind.annotation.RequestBody;
  42. import org.springframework.web.bind.annotation.RequestMapping;
  43. import org.springframework.web.bind.annotation.RestController;
  44. import com.zhongzheng.common.annotation.Log;
  45. import com.zhongzheng.common.core.controller.BaseController;
  46. import com.zhongzheng.common.core.domain.AjaxResult;
  47. import com.zhongzheng.common.enums.BusinessType;
  48. import com.zhongzheng.common.utils.poi.ExcelUtil;
  49. import com.zhongzheng.common.core.page.TableDataInfo;
  50. import io.swagger.annotations.Api;
  51. import io.swagger.annotations.ApiOperation;
  52. import javax.servlet.ServletOutputStream;
  53. /**
  54. * 班级Controller
  55. *
  56. * @author ruoyi
  57. * @date 2021-11-10
  58. */
  59. @Api(value = "班级控制器", tags = {"班级管理"})
  60. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  61. @RestController
  62. @RequestMapping("/grade/grade")
  63. public class ClassGradeController extends BaseController {
  64. private final IClassGradeService iClassGradeService;
  65. private final IClassGradeInterfaceService iClassGradeInterfaceService;
  66. private final IClassGradeSysService iClassGradeSysService;
  67. private final IClassGradeUserService iClassGradeUserService;
  68. private final IUserPeriodService iUserPeriodService;
  69. private final IUserPeriodStatusService userPeriodStatusService;
  70. private final RedisCache redisCache;
  71. private final IGoodsService iGoodsService;
  72. /**
  73. * 查询班级列表
  74. */
  75. @ApiOperation("批量查询商品班级列表")
  76. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  77. @GetMapping("/listGoodsBatch/{ids}")
  78. public TableDataInfo<ClassGradeGoodsVo> listGoodsBatch(@PathVariable Long[] ids) {
  79. startPage();
  80. ClassGradeQueryBo bo = new ClassGradeQueryBo();
  81. bo.setGoodsIds(Arrays.asList(ids));
  82. List<ClassGradeGoodsVo> list = iClassGradeService.listGoodsBatch(bo);
  83. return getDataTable(list);
  84. }
  85. /**
  86. * 查询班级列表
  87. */
  88. @ApiOperation("查询商品班级列表")
  89. @GetMapping("/listGoods")
  90. public TableDataInfo<ClassGradeVo> listGoods(ClassGradeQueryBo bo) {
  91. startPage();
  92. bo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
  93. bo.setPastDue(1L);
  94. bo.setAtFull(1L);
  95. List<ClassGradeVo> list = iClassGradeService.queryList(bo);
  96. return getDataTable(list);
  97. }
  98. /**
  99. * 查询班级列表
  100. */
  101. @ApiOperation("查询班级列表")
  102. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  103. @GetMapping("/list")
  104. public TableDataInfo<ClassGradeVo> list(ClassGradeQueryBo bo) {
  105. startPage();
  106. List<ClassGradeVo> list = iClassGradeService.queryList(bo);
  107. return getDataTable(list);
  108. }
  109. /**
  110. * 查询班级列表(新)
  111. */
  112. @ApiOperation("查询班级列表(新)")
  113. @GetMapping("/search/list")
  114. public TableDataInfo<ClassGradeVo> searchGradeList(ClassGradeQueryBo bo) {
  115. startPage();
  116. List<ClassGradeVo> list = iClassGradeService.searchGradeList(bo);
  117. return getDataTable(list);
  118. }
  119. /**
  120. * 查询其他平台班级详情
  121. */
  122. @ApiOperation("查询其他平台班级学员列表")
  123. @GetMapping("/other/Class/user")
  124. public AjaxResult<List<ClassNpUserInfoVo>> otherClassUserList(ClassNpUserInfoBo bo) {
  125. return AjaxResult.success(iClassGradeService.otherClassUserList(bo));
  126. }
  127. /**
  128. * 导出查询其他平台班级详情
  129. */
  130. @ApiOperation("查询其他平台班级学员列表")
  131. @GetMapping("/other/Class/user/export")
  132. public AjaxResult<List<ClassNpUserInfoVo>> otherClassUserListExport(ClassNpUserInfoBo bo) {
  133. List<ClassNpUserInfoVo> list = iClassGradeService.otherClassUserList(bo);
  134. List<ClassNpUserInfoExportVo> exportVos = list.stream().map(item -> BeanUtil.toBean(item,ClassNpUserInfoExportVo.class)).collect(Collectors.toList());
  135. ExcelUtil<ClassNpUserInfoExportVo> util = new ExcelUtil<ClassNpUserInfoExportVo>(ClassNpUserInfoExportVo.class);
  136. return util.exportExcel(exportVos, "班级学员列表");
  137. }
  138. /**
  139. * 查询班级列表
  140. */
  141. @ApiOperation("是否出现官方按钮选择 1官方信息推送 2官方学时推送 3账号开通 1,2,3 班级出现全部 学时审核出现学时推送 ")
  142. @PreAuthorize("@ss.hasPermi('grade:grade:select')")
  143. @GetMapping("/selectButton")
  144. public AjaxResult<Integer[]> selectButton(ClassGradeQueryBo bo) {
  145. ClassGradeVo classGradeVo = iClassGradeService.queryList(bo).get(0);
  146. List<Integer> integers = new ArrayList<>();
  147. Integer status =1;
  148. //判断字段是否填写,填写出现按钮
  149. if (classGradeVo.getInterfacePushId() != null ){
  150. integers.add(1);
  151. }
  152. if (classGradeVo.getInterfacePeriodId()!=null){
  153. integers.add(2);
  154. }
  155. if (classGradeVo.getInterfaceAccountId() != null ){
  156. integers.add(3);
  157. }
  158. if (classGradeVo.getNoInterfaceAccountId() != null ){
  159. integers.add(4);
  160. }
  161. //初始化需要得到的数组
  162. Integer[] array = new Integer[integers.size()];
  163. //使用for循环得到数组
  164. for(int i = 0; i < integers.size();i++){
  165. array[i] = integers.get(i);
  166. }
  167. return AjaxResult.success(array);
  168. }
  169. /**
  170. * 查询班级列表
  171. */
  172. @ApiOperation("查询班级学员列表")
  173. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  174. @GetMapping("/listGrade")
  175. public TableDataInfo<ClassGradeStudentVo> listGrade(ClassGradeUserQueryBo bo) {
  176. if (ObjectUtils.isNotNull(bo.getSevenCodeSign()) && bo.getSevenCodeSign() == 1
  177. && ObjectUtils.isNotNull(bo.getGradeId())){
  178. ClassGrade gradeGrade = iClassGradeService.getById(bo.getGradeId());
  179. if (StringUtils.isNotBlank(gradeGrade.getSevenCode())){
  180. bo.setSevenCode(gradeGrade.getSevenCode());
  181. }
  182. }
  183. startPage();
  184. List<ClassGradeStudentVo> list = iClassGradeService.listGrade(bo);
  185. return getDataTable(list);
  186. }
  187. /**
  188. * 导出班级学员列表
  189. */
  190. @ApiOperation("导出班级学员列表")
  191. // @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  192. @GetMapping("/exportListGrade")
  193. public AjaxResult exportListGrade(ClassGradeUserQueryBo bo) {
  194. List<ClassGradeStudentVo> list = iClassGradeService.listGrade(bo);
  195. List<ClassStudentExportVo> exportVos = list.stream().map(item -> ClassStudentExportVo.initEntity(item)).collect(Collectors.toList());
  196. ExcelUtil<ClassStudentExportVo> util = new ExcelUtil<ClassStudentExportVo>(ClassStudentExportVo.class);
  197. return util.exportExcel(exportVos, "班级学员列表");
  198. }
  199. /**
  200. * 学员进入新的班级
  201. */
  202. @ApiOperation("学员进入新的班级")
  203. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  204. @Log(title = "班级", businessType = BusinessType.INSERT)
  205. @PostMapping("/addUserGrade")
  206. public AjaxResult<Void> editUserGrade(@RequestBody ClassGradeUserAddQueryBo bo) {
  207. return toAjax(iClassGradeService.editUserGrade(bo) ? 1 : 0);
  208. }
  209. /**
  210. * 查询学时学员记录列表
  211. */
  212. @ApiOperation("查询学员学时列表")
  213. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  214. @GetMapping("/listUserPeriod")
  215. public TableDataInfo<ClassPeriodStudentVo> listUserPeriod(ClassGradeUserQueryBo bo) {
  216. startPage();
  217. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriod(bo);
  218. return getDataTable(list);
  219. }
  220. /**
  221. * 查询学时学员记录列表
  222. */
  223. @ApiOperation("查询学员学时学习记录列表")
  224. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  225. @GetMapping("/listUserPeriodRecord")
  226. public TableDataInfo<ClassPeriodStudentVo> listUserPeriodRecord(ClassGradeUserQueryBo bo) {
  227. startPage();
  228. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriodRecord(bo);
  229. return getDataTable(list);
  230. }
  231. @ApiOperation("按周查询学员学时学习记录列表")
  232. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  233. @GetMapping("/listUserPeriodWeekRecord")
  234. public TableDataInfo<ClassPeriodStudentVo> listUserPeriodWeekRecord(ClassGradeUserQueryBo bo) {
  235. startPage();
  236. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriodWeekRecord(bo);
  237. return getDataTable(list);
  238. }
  239. @ApiOperation("查询学员视频学习记录列表")
  240. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  241. @GetMapping("/listUserVideoRecord")
  242. public TableDataInfo<ClassPeriodStudentVo> listUserVideoRecord(ClassGradeUserQueryBo bo) {
  243. startPage();
  244. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserVideoRecord(bo);
  245. return getDataTable(list);
  246. }
  247. /**
  248. * 查询学时学员记录列表
  249. */
  250. @ApiOperation("查询学员学习记录列表")
  251. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  252. @GetMapping("/listUserStudyRecord")
  253. public TableDataInfo<UserPeriodExportV2Vo> listUserStudyRecord(ClassGradeUserQueryBo bo) {
  254. startPage();
  255. List<UserPeriodExportV2Vo> list = iClassGradeUserService.listUserStudyRecordV2(bo);
  256. return getDataTable(list);
  257. }
  258. @ApiOperation("周查询学员学习记录列表")
  259. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  260. @GetMapping("/listUserStudyRecordV2Week")
  261. public TableDataInfo<UserPeriodExportV2Vo> listUserStudyRecordV2Week(ClassGradeUserQueryBo bo) {
  262. startPage();
  263. List<UserPeriodExportV2Vo> list = iClassGradeUserService.listUserStudyRecordV2Week(bo);
  264. return getDataTable(list);
  265. }
  266. /**
  267. * 查询学时学员记录列表
  268. *//*
  269. @ApiOperation("查询学员学习记录列表")
  270. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  271. @GetMapping("/listUserStudyRecord")
  272. public TableDataInfo<UserPeriodExportVo> listUserStudyRecord(ClassGradeUserQueryBo bo) {
  273. startPage();
  274. List<UserPeriodExportVo> list = iClassGradeUserService.listUserStudyRecord(bo);
  275. return getDataTable(list);
  276. }*/
  277. /**
  278. * 导出资料审核列表
  279. */
  280. @ApiOperation("导出学员学时列表")
  281. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  282. @Log(title = "导出学员学时列表", businessType = BusinessType.EXPORT)
  283. @GetMapping("/export")
  284. public AjaxResult<Map<String,Object>> export(ClassGradeUserQueryBo bo) {
  285. String fileName = "";
  286. if(Validator.isEmpty(bo.getStudyStatus())){
  287. bo.setStudyStatus(0);
  288. fileName="全部";
  289. }else{
  290. if(bo.getStudyStatus()==0){
  291. fileName="全部";
  292. }
  293. if(bo.getStudyStatus()==1){
  294. fileName="未完成学习";
  295. }
  296. if(bo.getStudyStatus()==2){
  297. fileName="完成学习";
  298. }
  299. }
  300. bo.setUserPhoto(1);
  301. Map<String,Object> map = iClassGradeUserService.exportPo(bo);
  302. List<ClassPeriodStudentExportAllVo> list = (List<ClassPeriodStudentExportAllVo>)map.get("list");
  303. ExcelUtil<ClassPeriodStudentExportAllVo> util = new ExcelUtil<ClassPeriodStudentExportAllVo>(ClassPeriodStudentExportAllVo.class);
  304. ExportParams deptExportParams = new ExportParams();
  305. // 设置sheet得名称
  306. deptExportParams.setSheetName("表1");
  307. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  308. Map<String, Object> deptExportMap = new HashMap<>();
  309. deptExportMap.put("title", deptExportParams);
  310. deptExportMap.put("entity", ClassPeriodStudentExportAllVo.class);
  311. // sheet中要填充得数据
  312. deptExportMap.put("data", list);
  313. List<Map<String, Object>> sheetsList = new ArrayList<>();
  314. sheetsList.add(deptExportMap);
  315. String businessName = Validator.isNotEmpty(bo.getBusinessName())?bo.getBusinessName():"";
  316. map.put("excel",util.exportEasyExcel(sheetsList, businessName+"-"+fileName+"-学员学习记录-"+timeStr));
  317. map.remove("list");
  318. return AjaxResult.success(map);
  319. }
  320. @ApiOperation("周导出学员学时列表")
  321. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  322. @Log(title = "周导出学员学时列表", businessType = BusinessType.EXPORT)
  323. @PostMapping("/exportWeek")
  324. public AjaxResult<Map<String,Object>> exportWeek(@RequestBody ClassGradeUserQueryBo bo) {
  325. String fileName = "";
  326. if(Validator.isEmpty(bo.getStudyStatus())){
  327. bo.setStudyStatus(0);
  328. fileName="全部";
  329. }else{
  330. if(bo.getStudyStatus()==0){
  331. fileName="全部";
  332. }
  333. if(bo.getStudyStatus()==1){
  334. fileName="未完成学习";
  335. }
  336. if(bo.getStudyStatus()==2){
  337. fileName="完成学习";
  338. }
  339. }
  340. bo.setUserPhoto(1);
  341. Map<String,Object> map = iClassGradeUserService.exportWeekPo(bo);
  342. List<ClassPeriodStudentExportWeekAllVo> list = (List<ClassPeriodStudentExportWeekAllVo>)map.get("list");
  343. ExcelUtil<ClassPeriodStudentExportWeekAllVo> util = new ExcelUtil<ClassPeriodStudentExportWeekAllVo>(ClassPeriodStudentExportWeekAllVo.class);
  344. ExportParams deptExportParams = new ExportParams();
  345. // 设置sheet得名称
  346. deptExportParams.setSheetName("表1");
  347. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  348. Map<String, Object> deptExportMap = new HashMap<>();
  349. deptExportMap.put("title", deptExportParams);
  350. deptExportMap.put("entity", ClassPeriodStudentExportWeekAllVo.class);
  351. // sheet中要填充得数据
  352. deptExportMap.put("data", list);
  353. List<Map<String, Object>> sheetsList = new ArrayList<>();
  354. sheetsList.add(deptExportMap);
  355. String businessName = Validator.isNotEmpty(bo.getBusinessName())?bo.getBusinessName():"";
  356. map.put("excel",util.exportEasyExcel(sheetsList, businessName+"-"+fileName+"-学员学习记录-"+timeStr));
  357. map.remove("list");
  358. return AjaxResult.success(map);
  359. }
  360. /**
  361. * 查询学员学时信息列表
  362. */
  363. @ApiOperation("查询学员学时信息列表")
  364. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  365. @GetMapping("/listPeriod")
  366. public TableDataInfo<ClassPeriodUserVo> listPeriod(ClassGradeUserQueryBo bo) {
  367. startPage();
  368. List<ClassPeriodUserVo> list = iClassGradeUserService.listPeriod(bo);
  369. return getDataTable(list);
  370. }
  371. /**
  372. * 学时审核
  373. */
  374. @ApiOperation("学时审核")
  375. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  376. @GetMapping("/listPeriodAudit")
  377. public TableDataInfo<ClassPeriodVo> listPeriodAudit(ClassGradeUserQueryBo bo) {
  378. startPage();
  379. List<ClassPeriodVo> list = iClassGradeUserService.listPeriodAudit(bo);
  380. return getDataTable(list);
  381. }
  382. /**
  383. * 查询学员记录列表
  384. */
  385. @ApiOperation("查询学员记录列表")
  386. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  387. @GetMapping("/listUser")
  388. public TableDataInfo<ClassGradeUserVo> list(ClassGradeUserQueryBo bo) {
  389. startPage();
  390. List<ClassGradeUserVo> list = iClassGradeUserService.queryList(bo);
  391. return getDataTable(list);
  392. }
  393. /**
  394. * 查询查询以往审核记录列表
  395. */
  396. @ApiOperation("查询以往审核记录")
  397. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  398. @GetMapping("/listPeriodStatus")
  399. public TableDataInfo<UserPeriodStatusVo> list(UserPeriodQueryBo bo) {
  400. startPage();
  401. List<UserPeriodStatusVo> list = userPeriodStatusService.selectPeriodStatus(bo);
  402. return getDataTable(list);
  403. }
  404. /**
  405. * 查询班主任记录列表
  406. */
  407. @ApiOperation("查询班主任记录列表")
  408. @PreAuthorize("@ss.hasPermi('grade:sys:list')")
  409. @GetMapping("/listSys")
  410. public TableDataInfo<ClassGradeSysVo> list(ClassGradeSysQueryBo bo) {
  411. startPage();
  412. List<ClassGradeSysVo> list = iClassGradeSysService.queryList(bo);
  413. return getDataTable(list);
  414. }
  415. /**
  416. * 查询班级列表
  417. */
  418. @ApiOperation("是否出现官方接口选择")
  419. @PreAuthorize("@ss.hasPermi('grade:grade:select')")
  420. @GetMapping("/select")
  421. public AjaxResult<Integer> select(ClassGradeAddBo bo) {
  422. //自己公司的TenantId出现选择官方接口
  423. // boolean tenantId = ServletUtils.getRequest().getHeader("TenantId").equals("867735392558919680");
  424. // return AjaxResult.success(tenantId ? 1 : 0);
  425. return AjaxResult.success(1);
  426. }
  427. /**
  428. * 查询官方接口
  429. */
  430. @ApiOperation("查询官方接口")
  431. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  432. @GetMapping("/listInterfaceVo")
  433. public TableDataInfo<ClassGradeInterfaceVo> list(ClassGradeInterfaceQueryBo bo) {
  434. startPage();
  435. List<ClassGradeInterfaceVo> list = iClassGradeInterfaceService.queryList(bo);
  436. return getDataTable(list);
  437. }
  438. /* *//**
  439. * 导出班级列表
  440. *//*
  441. @ApiOperation("导出班级列表")
  442. @PreAuthorize("@ss.hasPermi('modules.grade:grade:export')")
  443. @Log(title = "班级", businessType = BusinessType.EXPORT)
  444. @GetMapping("/export")
  445. public AjaxResult<ClassGradeVo> export(ClassGradeQueryBo bo) {
  446. List<ClassGradeVo> list = iClassGradeService.queryList(bo);
  447. ExcelUtil<ClassGradeVo> util = new ExcelUtil<ClassGradeVo>(ClassGradeVo.class);
  448. return util.exportExcel(list, "班级");
  449. }*/
  450. /**
  451. * 获取班级详细信息
  452. */
  453. @ApiOperation("获取班级详细信息")
  454. @PreAuthorize("@ss.hasPermi('grade:grade:query')")
  455. @GetMapping("/{classId}")
  456. public AjaxResult<ClassGradeVo> getInfo(@PathVariable("classId") Long classId) {
  457. return AjaxResult.success(iClassGradeService.queryById(classId));
  458. }
  459. /**
  460. * 新增班级
  461. */
  462. @ApiOperation("新增班级")
  463. @PreAuthorize("@ss.hasPermi('grade:grade:add')")
  464. @Log(title = "班级", businessType = BusinessType.INSERT)
  465. @PostMapping()
  466. public AjaxResult<Void> add(@RequestBody ClassGradeAddBo bo) {
  467. return toAjax(iClassGradeService.insertByAddBo(bo) ? 1 : 0);
  468. }
  469. /**
  470. * 修改班级
  471. */
  472. @ApiOperation("修改班级")
  473. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  474. @Log(title = "班级", businessType = BusinessType.UPDATE)
  475. @PostMapping("/edit")
  476. public AjaxResult<Void> edit(@RequestBody ClassGradeEditBo bo) {
  477. return toAjax(iClassGradeService.updateByEditBo(bo) ? 1 : 0);
  478. }
  479. /**
  480. * 修改【请填写功能名称】
  481. */
  482. @ApiOperation("更改审核状态")
  483. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  484. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  485. @PostMapping("/editPeriod")
  486. public AjaxResult<Void> edit(@RequestBody UserPeriodEditBo bo) {
  487. return toAjax(iUserPeriodService.updateByEditBo(bo) ? 1 : 0);
  488. }
  489. /**
  490. * 更改批量待审核状态
  491. */
  492. @ApiOperation("更改批量待审核状态")
  493. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  494. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  495. @PostMapping("/editPeriodAll")
  496. public AjaxResult<Void> editPeriodAll(@RequestBody UserPeriodEditBo bo) {
  497. return toAjax(iUserPeriodService.editPeriodAll(bo) ? 1 : 0);
  498. }
  499. /**
  500. * 学时通过确认
  501. */
  502. @ApiOperation("学时通过确认")
  503. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  504. @Log(title = "学时通过确认", businessType = BusinessType.UPDATE)
  505. @PostMapping("/confirmPeriod")
  506. public AjaxResult<Void> confirmPeriod(@RequestBody UserPeriodEditBo bo) {
  507. return toAjax(iUserPeriodService.confirmPeriod(bo) ? 1 : 0);
  508. }
  509. /**
  510. * 修改学员记录
  511. */
  512. @ApiOperation("修改学员记录")
  513. @PreAuthorize("@ss.hasPermi('system:user:edit')")
  514. @Log(title = "学员记录", businessType = BusinessType.UPDATE)
  515. @PostMapping("/editGradeUser")
  516. public AjaxResult<Void> edit(@RequestBody ClassGradeUserEditBo bo) {
  517. return toAjax(iClassGradeUserService.updateByEditBo(bo) ? 1 : 0);
  518. }
  519. /**
  520. * 学时审核獲得商品節下面的審核記錄
  521. */
  522. @ApiOperation("学时审核獲得商品節下面的審核記錄")
  523. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  524. @GetMapping("/listPeriodAuditStatus")
  525. public AjaxResult<ClassPeriodSectionVo> listPeriodAuditStatus(UserPeriodQueryBo bo) {
  526. startPage();
  527. ClassPeriodSectionVo list = iClassGradeUserService.listPeriodAuditStatus(bo);
  528. return AjaxResult.success(list);
  529. }
  530. /**
  531. * 新增订单
  532. */
  533. @ApiOperation("选新班")
  534. @PostMapping("/sysChangeGrade")
  535. public AjaxResult changeGrade(@RequestBody ClassGradeUserSysChangeBo bo) {
  536. return AjaxResult.success(iClassGradeUserService.sysChangeGrade(bo));
  537. }
  538. /**
  539. * 自由选新班
  540. */
  541. @ApiOperation("自由选新班")
  542. @PostMapping("/changeGradeFree")
  543. public AjaxResult changeGradeFree(@RequestBody ClassGradeUserChangeBo bo) {
  544. return AjaxResult.success(iClassGradeUserService.changeGradeFree(bo));
  545. }
  546. /**
  547. * 检查编辑数据是否有用户通过学时
  548. */
  549. @ApiOperation("检查编辑数据是否有用户通过学时")
  550. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  551. @GetMapping("/checkGoodsChange")
  552. public AjaxResult<Long> checkGoodsChange(UserPeriodQueryBo bo) {
  553. return AjaxResult.success(iUserPeriodService.checkGoodsChange(bo));
  554. }
  555. /**
  556. * 检查编辑数据是否有用户通过学时
  557. */
  558. @ApiOperation("检查编辑数据是否有用户在学习")
  559. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  560. @GetMapping("/checkGoodsStudy")
  561. public AjaxResult<Long> checkGoodsStudy(UserPeriodQueryBo bo) {
  562. return AjaxResult.success(iUserPeriodService.checkGoodsStudy(bo));
  563. }
  564. /**
  565. * 查询班级信息推送数量
  566. */
  567. @ApiOperation("查询班级信息推送数量")
  568. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  569. @GetMapping("/officialInfoCount")
  570. public AjaxResult<Map<String,Object>> officialInfoCount(ClassGradeUserQueryBo bo) {
  571. return AjaxResult.success(iClassGradeUserService.selectOfficialInfoCount(bo));
  572. }
  573. /**
  574. * 查询班级学时推送数量
  575. */
  576. @ApiOperation("查询班级学时推送数量")
  577. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  578. @GetMapping("/officialPeriodCount")
  579. public AjaxResult<Long> officialPeriodCount(ClassGradeUserQueryBo bo) {
  580. return AjaxResult.success(iClassGradeUserService.selectOfficialPeriodCount(bo));
  581. }
  582. /**
  583. * 批量打回待审核状态
  584. */
  585. @ApiOperation("批量打回待审核状态")
  586. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  587. @Log(title = "批量打回待审核状态", businessType = BusinessType.UPDATE)
  588. @PostMapping("/rollbackPeriod")
  589. public AjaxResult<Void> rollbackPeriod(@RequestBody UserPeriodEditBo bo) {
  590. return toAjax(iUserPeriodService.rollbackPeriod(bo) ? 1 : 0);
  591. }
  592. /**
  593. * 锁定学时审核页面
  594. */
  595. @ApiOperation("锁定学时审核页面")
  596. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  597. @PostMapping("/lockPeriod")
  598. public AjaxResult<Void> lockPeriod(@RequestBody UserPeriodEditBo bo) {
  599. String key = "LockPeriod_"+bo.getGradeId()+"-"+bo.getUserId();
  600. redisCache.setCacheObject(key, SecurityUtils.getUsername(),15, TimeUnit.SECONDS);//15秒锁定
  601. return AjaxResult.success();
  602. }
  603. /**
  604. * 查看学时审核锁定状态
  605. */
  606. @ApiOperation("查看学时审核锁定状态")
  607. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  608. @Log(title = "查看学时审核锁定状态", businessType = BusinessType.UPDATE)
  609. @PostMapping("/lockPeriodStatus")
  610. public AjaxResult<Void> lockPeriodStatus(@RequestBody UserPeriodEditBo bo) {
  611. String key = "LockPeriod_"+bo.getGradeId()+"-"+bo.getUserId();
  612. String username = redisCache.getCacheObject(key);
  613. if(SecurityUtils.getUsername().equals(username)){
  614. username = null;//同个用户不返回
  615. }
  616. return AjaxResult.success(username);
  617. }
  618. /**
  619. * 查询学习账号标记列表
  620. */
  621. @ApiOperation("查询学习账号标记列表")
  622. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  623. @GetMapping("/listStudyAccountStatus")
  624. public TableDataInfo<StudyAccountStatusVo> listStudyAccountStatus(StudyAccountStatusQueryBo bo) {
  625. List<StudyAccountStatusVo> list = iClassGradeUserService.listStudyAccountStatus(bo);
  626. return getDataTable(getPageInfo(bo.getPageNum(), bo.getPageSize(), list).getList());
  627. }
  628. /**
  629. * 导出学习账号标记列表
  630. */
  631. @ApiOperation("导出学习账号标记列表")
  632. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  633. @Log(title = "导出学员学时列表", businessType = BusinessType.EXPORT)
  634. @GetMapping("/exportStudyAccount")
  635. public AjaxResult<Map<String,Object>> exportStudyAccount(ClassGradeUserQueryBo bo) {
  636. bo.setUserPhoto(1);
  637. Map<String,Object> map = new HashMap<>();
  638. List<ClassGradeStudentVo> list = iClassGradeService.listGrade(bo);
  639. List<StudyAccountStatusExportVo> newList = new ArrayList<>();
  640. for (ClassGradeStudentVo classGradeStudent : list) {
  641. StudyAccountStatusExportVo studyAccountStatusExportVo = new StudyAccountStatusExportVo();
  642. BeanUtils.copyProperties(classGradeStudent, studyAccountStatusExportVo);
  643. newList.add(studyAccountStatusExportVo);
  644. }
  645. map.put("list", newList);
  646. ExcelUtil<StudyAccountStatusExportVo> util = new ExcelUtil<>(StudyAccountStatusExportVo.class);
  647. return util.exportExcel(newList,"学习账号标记");
  648. /*ExportParams deptExportParams = new ExportParams();
  649. // 设置sheet得名称
  650. deptExportParams.setSheetName("表1");
  651. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  652. Map<String, Object> deptExportMap = new HashMap<>();
  653. deptExportMap.put("title", deptExportParams);
  654. deptExportMap.put("entity", StudyAccountStatusExportVo.class);
  655. // sheet中要填充得数据
  656. deptExportMap.put("data", list);
  657. List<Map<String, Object>> sheetsList = new ArrayList<>();
  658. sheetsList.add(deptExportMap);
  659. map.put("excel",util.exportEasyExcel(sheetsList, "学习账号标记"+timeStr));
  660. map.remove("list");
  661. return AjaxResult.success(map);*/
  662. }
  663. /**
  664. * 数据批量同步到官方系统
  665. */
  666. @ApiOperation("数据批量同步到官方系统")
  667. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  668. @Log(title = "数据批量同步到官方系统", businessType = BusinessType.UPDATE)
  669. @PostMapping("/OpenQdyAccount")
  670. public AjaxResult<Void> OpenQdyAccount(@RequestBody OpenQdyAccountBo bo) {
  671. return toAjax(iClassGradeService.OpenQdyAccount(bo) ? 1 : 0);
  672. }
  673. /**
  674. * 发送验证码
  675. */
  676. @ApiOperation("发送验证码")
  677. @PostMapping("/sendCode")
  678. public AjaxResult<Void> OpenQdyAccount() {
  679. return toAjax(iClassGradeService.sendCode() ? 1 : 0);
  680. }
  681. @ApiOperation("二审打回重审")
  682. @PostMapping("/confirm/rollbackPeriod")
  683. public AjaxResult<Void> confirmRollbackPeriod(@RequestBody UserPeriodEditBo bo)
  684. {
  685. bo.setRollBackPlat(1);
  686. iUserPeriodService.confirmRollbackPeriod(bo);
  687. return AjaxResult.success();
  688. }
  689. @ApiOperation("获取官方班级人数")
  690. @Log(title = "获取官方班级人数", businessType = BusinessType.UPDATE)
  691. @GetMapping("/officialGradeCount")
  692. public AjaxResult<Integer> queryOfficialGradeCount(ClassGradeQueryBo bo) {
  693. return AjaxResult.success(iClassGradeService.queryOfficialGradeCount(bo));
  694. }
  695. @ApiOperation("导出商品的课程结构")
  696. @GetMapping("/exportGoodsMenuExcel")
  697. public AjaxResult<List<ClassNpUserInfoVo>> exportGoodsMenuExcel(UserPeriodEditBo bo) {
  698. GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
  699. List<SyncUserChapterExport> list = iUserPeriodService.exportGoodsMenuExcel(bo);
  700. List<SyncUserChapterExport> exportVos = list.stream().map(item -> BeanUtil.toBean(item,SyncUserChapterExport.class)).collect(Collectors.toList());
  701. ExcelUtil<SyncUserChapterExport> util = new ExcelUtil<SyncUserChapterExport>(SyncUserChapterExport.class);
  702. return util.exportExcel(exportVos, goodsVo.getGoodsName());
  703. }
  704. }