ClassGradeController.java 26 KB

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