ClassGradeController.java 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  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. ClassGrade gradeGrade = iClassGradeService.getById(bo.getGradeId());
  177. if (StringUtils.isNotBlank(gradeGrade.getSevenCode())){
  178. bo.setSevenCode(gradeGrade.getSevenCode());
  179. }
  180. startPage();
  181. List<ClassGradeStudentVo> list = iClassGradeService.listGrade(bo);
  182. return getDataTable(list);
  183. }
  184. /**
  185. * 查询所有班级用户列表
  186. */
  187. @ApiOperation("查询所有班级用户列表")
  188. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  189. @GetMapping("/listGradeAll")
  190. public TableDataInfo<ClassGradeStudentVo> listGradeAll(ClassGradeUserQueryBo bo) {
  191. startPage();
  192. List<ClassGradeStudentVo> list = iClassGradeService.listGradeAll(bo);
  193. return getDataTable(list);
  194. }
  195. /**
  196. * 导出班级学员列表
  197. */
  198. @ApiOperation("导出班级学员列表")
  199. // @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  200. @GetMapping("/exportListGrade")
  201. public AjaxResult exportListGrade(ClassGradeUserQueryBo bo) {
  202. List<ClassGradeStudentVo> list = iClassGradeService.listGrade(bo);
  203. List<ClassStudentExportVo> exportVos = list.stream().map(item -> ClassStudentExportVo.initEntity(item)).collect(Collectors.toList());
  204. ExcelUtil<ClassStudentExportVo> util = new ExcelUtil<ClassStudentExportVo>(ClassStudentExportVo.class);
  205. return util.exportExcel(exportVos, "班级学员列表");
  206. }
  207. /**
  208. * 学员进入新的班级
  209. */
  210. @ApiOperation("学员进入新的班级")
  211. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  212. @Log(title = "班级", businessType = BusinessType.INSERT)
  213. @PostMapping("/addUserGrade")
  214. public AjaxResult<Void> editUserGrade(@RequestBody ClassGradeUserAddQueryBo bo) {
  215. return toAjax(iClassGradeService.editUserGrade(bo) ? 1 : 0);
  216. }
  217. /**
  218. * 查询学时学员记录列表
  219. */
  220. @ApiOperation("查询学员学时列表")
  221. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  222. @GetMapping("/listUserPeriod")
  223. public TableDataInfo<ClassPeriodStudentVo> listUserPeriod(ClassGradeUserQueryBo bo) {
  224. startPage();
  225. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriod(bo);
  226. return getDataTable(list);
  227. }
  228. /**
  229. * 查询学时学员记录列表
  230. */
  231. @ApiOperation("查询学员学时学习记录列表")
  232. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  233. @GetMapping("/listUserPeriodRecord")
  234. public TableDataInfo<ClassPeriodStudentVo> listUserPeriodRecord(ClassGradeUserQueryBo bo) {
  235. startPage();
  236. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriodRecord(bo);
  237. return getDataTable(list);
  238. }
  239. /**
  240. * 班级管理列表
  241. */
  242. @ApiOperation("班级管理列表")
  243. @GetMapping("/listUserPeriodRecord/new")
  244. public TableDataInfo<ClassPeriodStudentVo> listUserPeriodRecordNew(ClassGradeUserQueryBo bo) {
  245. startPage();
  246. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriodRecordNew(bo);
  247. return getDataTable(list);
  248. }
  249. @ApiOperation("按周查询学员学时学习记录列表")
  250. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  251. @GetMapping("/listUserPeriodWeekRecord")
  252. public TableDataInfo<ClassPeriodStudentVo> listUserPeriodWeekRecord(ClassGradeUserQueryBo bo) {
  253. startPage();
  254. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserPeriodWeekRecord(bo);
  255. return getDataTable(list);
  256. }
  257. @ApiOperation("查询学员视频学习记录列表")
  258. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  259. @GetMapping("/listUserVideoRecord")
  260. public TableDataInfo<ClassPeriodStudentVo> listUserVideoRecord(ClassGradeUserQueryBo bo) {
  261. startPage();
  262. List<ClassPeriodStudentVo> list = iClassGradeUserService.listUserVideoRecord(bo);
  263. return getDataTable(list);
  264. }
  265. /**
  266. * 查询学时学员记录列表
  267. */
  268. @ApiOperation("查询学员学习记录列表")
  269. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  270. @GetMapping("/listUserStudyRecord")
  271. public TableDataInfo<UserPeriodExportV2Vo> listUserStudyRecord(ClassGradeUserQueryBo bo) {
  272. startPage();
  273. List<UserPeriodExportV2Vo> list = iClassGradeUserService.listUserStudyRecordV2(bo);
  274. return getDataTable(list);
  275. }
  276. @ApiOperation("周查询学员学习记录列表")
  277. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  278. @GetMapping("/listUserStudyRecordV2Week")
  279. public TableDataInfo<UserPeriodExportV2Vo> listUserStudyRecordV2Week(ClassGradeUserQueryBo bo) {
  280. startPage();
  281. List<UserPeriodExportV2Vo> list = iClassGradeUserService.listUserStudyRecordV2Week(bo);
  282. return getDataTable(list);
  283. }
  284. /**
  285. * 查询学时学员记录列表
  286. *//*
  287. @ApiOperation("查询学员学习记录列表")
  288. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  289. @GetMapping("/listUserStudyRecord")
  290. public TableDataInfo<UserPeriodExportVo> listUserStudyRecord(ClassGradeUserQueryBo bo) {
  291. startPage();
  292. List<UserPeriodExportVo> list = iClassGradeUserService.listUserStudyRecord(bo);
  293. return getDataTable(list);
  294. }*/
  295. /**
  296. * 导出资料审核列表
  297. */
  298. @ApiOperation("导出学员学时列表")
  299. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  300. @Log(title = "导出学员学时列表", businessType = BusinessType.EXPORT)
  301. @GetMapping("/export")
  302. public AjaxResult<Map<String,Object>> export(ClassGradeUserQueryBo bo) {
  303. String fileName = "";
  304. if(Validator.isEmpty(bo.getStudyStatus())){
  305. bo.setStudyStatus(0);
  306. fileName="全部";
  307. }else{
  308. if(bo.getStudyStatus()==0){
  309. fileName="全部";
  310. }
  311. if(bo.getStudyStatus()==1){
  312. fileName="未完成学习";
  313. }
  314. if(bo.getStudyStatus()==2){
  315. fileName="完成学习";
  316. }
  317. }
  318. bo.setUserPhoto(1);
  319. Map<String,Object> map = iClassGradeUserService.exportPo(bo);
  320. List<ClassPeriodStudentExportAllVo> list = (List<ClassPeriodStudentExportAllVo>)map.get("list");
  321. ExcelUtil<ClassPeriodStudentExportAllVo> util = new ExcelUtil<ClassPeriodStudentExportAllVo>(ClassPeriodStudentExportAllVo.class);
  322. ExportParams deptExportParams = new ExportParams();
  323. // 设置sheet得名称
  324. deptExportParams.setSheetName("表1");
  325. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  326. Map<String, Object> deptExportMap = new HashMap<>();
  327. deptExportMap.put("title", deptExportParams);
  328. deptExportMap.put("entity", ClassPeriodStudentExportAllVo.class);
  329. // sheet中要填充得数据
  330. deptExportMap.put("data", list);
  331. List<Map<String, Object>> sheetsList = new ArrayList<>();
  332. sheetsList.add(deptExportMap);
  333. String businessName = Validator.isNotEmpty(bo.getBusinessName())?bo.getBusinessName():"";
  334. map.put("excel",util.exportEasyExcel(sheetsList, businessName+"-"+fileName+"-学员学习记录-"+timeStr));
  335. map.remove("list");
  336. return AjaxResult.success(map);
  337. }
  338. @ApiOperation("周导出学员学时列表")
  339. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  340. @Log(title = "周导出学员学时列表", businessType = BusinessType.EXPORT)
  341. @PostMapping("/exportWeek")
  342. public AjaxResult<Map<String,Object>> exportWeek(@RequestBody ClassGradeUserQueryBo bo) {
  343. String fileName = "";
  344. if(Validator.isEmpty(bo.getStudyStatus())){
  345. bo.setStudyStatus(0);
  346. fileName="全部";
  347. }else{
  348. if(bo.getStudyStatus()==0){
  349. fileName="全部";
  350. }
  351. if(bo.getStudyStatus()==1){
  352. fileName="未完成学习";
  353. }
  354. if(bo.getStudyStatus()==2){
  355. fileName="完成学习";
  356. }
  357. }
  358. bo.setUserPhoto(1);
  359. Map<String,Object> map = iClassGradeUserService.exportWeekPo(bo);
  360. List<ClassPeriodStudentExportWeekAllVo> list = (List<ClassPeriodStudentExportWeekAllVo>)map.get("list");
  361. ExcelUtil<ClassPeriodStudentExportWeekAllVo> util = new ExcelUtil<ClassPeriodStudentExportWeekAllVo>(ClassPeriodStudentExportWeekAllVo.class);
  362. ExportParams deptExportParams = new ExportParams();
  363. // 设置sheet得名称
  364. deptExportParams.setSheetName("表1");
  365. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  366. Map<String, Object> deptExportMap = new HashMap<>();
  367. deptExportMap.put("title", deptExportParams);
  368. deptExportMap.put("entity", ClassPeriodStudentExportWeekAllVo.class);
  369. // sheet中要填充得数据
  370. deptExportMap.put("data", list);
  371. List<Map<String, Object>> sheetsList = new ArrayList<>();
  372. sheetsList.add(deptExportMap);
  373. String businessName = Validator.isNotEmpty(bo.getBusinessName())?bo.getBusinessName():"";
  374. map.put("excel",util.exportEasyExcel(sheetsList, businessName+"-"+fileName+"-学员学习记录-"+timeStr));
  375. map.remove("list");
  376. return AjaxResult.success(map);
  377. }
  378. /**
  379. * 查询学员学时信息列表
  380. */
  381. @ApiOperation("查询学员学时信息列表")
  382. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  383. @GetMapping("/listPeriod")
  384. public TableDataInfo<ClassPeriodUserVo> listPeriod(ClassGradeUserQueryBo bo) {
  385. startPage();
  386. List<ClassPeriodUserVo> list = iClassGradeUserService.listPeriod(bo);
  387. return getDataTable(list);
  388. }
  389. /**
  390. * 学时审核
  391. */
  392. @ApiOperation("学时审核")
  393. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  394. @GetMapping("/listPeriodAudit")
  395. public TableDataInfo<ClassPeriodVo> listPeriodAudit(ClassGradeUserQueryBo bo) {
  396. startPage();
  397. List<ClassPeriodVo> list = iClassGradeUserService.listPeriodAudit(bo);
  398. return getDataTable(list);
  399. }
  400. /**
  401. * 查询学员记录列表
  402. */
  403. @ApiOperation("查询学员记录列表")
  404. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  405. @GetMapping("/listUser")
  406. public TableDataInfo<ClassGradeUserVo> list(ClassGradeUserQueryBo bo) {
  407. startPage();
  408. List<ClassGradeUserVo> list = iClassGradeUserService.queryList(bo);
  409. return getDataTable(list);
  410. }
  411. /**
  412. * 查询查询以往审核记录列表
  413. */
  414. @ApiOperation("查询以往审核记录")
  415. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  416. @GetMapping("/listPeriodStatus")
  417. public TableDataInfo<UserPeriodStatusVo> list(UserPeriodQueryBo bo) {
  418. startPage();
  419. List<UserPeriodStatusVo> list = userPeriodStatusService.selectPeriodStatus(bo);
  420. return getDataTable(list);
  421. }
  422. /**
  423. * 查询班主任记录列表
  424. */
  425. @ApiOperation("查询班主任记录列表")
  426. @PreAuthorize("@ss.hasPermi('grade:sys:list')")
  427. @GetMapping("/listSys")
  428. public TableDataInfo<ClassGradeSysVo> list(ClassGradeSysQueryBo bo) {
  429. startPage();
  430. List<ClassGradeSysVo> list = iClassGradeSysService.queryList(bo);
  431. return getDataTable(list);
  432. }
  433. /**
  434. * 查询班级列表
  435. */
  436. @ApiOperation("是否出现官方接口选择")
  437. @PreAuthorize("@ss.hasPermi('grade:grade:select')")
  438. @GetMapping("/select")
  439. public AjaxResult<Integer> select(ClassGradeAddBo bo) {
  440. //自己公司的TenantId出现选择官方接口
  441. // boolean tenantId = ServletUtils.getRequest().getHeader("TenantId").equals("867735392558919680");
  442. // return AjaxResult.success(tenantId ? 1 : 0);
  443. return AjaxResult.success(1);
  444. }
  445. /**
  446. * 查询官方接口
  447. */
  448. @ApiOperation("查询官方接口")
  449. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  450. @GetMapping("/listInterfaceVo")
  451. public TableDataInfo<ClassGradeInterfaceVo> list(ClassGradeInterfaceQueryBo bo) {
  452. startPage();
  453. List<ClassGradeInterfaceVo> list = iClassGradeInterfaceService.queryList(bo);
  454. return getDataTable(list);
  455. }
  456. /* *//**
  457. * 导出班级列表
  458. *//*
  459. @ApiOperation("导出班级列表")
  460. @PreAuthorize("@ss.hasPermi('modules.grade:grade:export')")
  461. @Log(title = "班级", businessType = BusinessType.EXPORT)
  462. @GetMapping("/export")
  463. public AjaxResult<ClassGradeVo> export(ClassGradeQueryBo bo) {
  464. List<ClassGradeVo> list = iClassGradeService.queryList(bo);
  465. ExcelUtil<ClassGradeVo> util = new ExcelUtil<ClassGradeVo>(ClassGradeVo.class);
  466. return util.exportExcel(list, "班级");
  467. }*/
  468. /**
  469. * 获取班级详细信息
  470. */
  471. @ApiOperation("获取班级详细信息")
  472. @PreAuthorize("@ss.hasPermi('grade:grade:query')")
  473. @GetMapping("/{classId}")
  474. public AjaxResult<ClassGradeVo> getInfo(@PathVariable("classId") Long classId) {
  475. return AjaxResult.success(iClassGradeService.queryById(classId));
  476. }
  477. /**
  478. * 新增班级
  479. */
  480. @ApiOperation("新增班级")
  481. @PreAuthorize("@ss.hasPermi('grade:grade:add')")
  482. @Log(title = "班级", businessType = BusinessType.INSERT)
  483. @PostMapping()
  484. public AjaxResult<Void> add(@RequestBody ClassGradeAddBo bo) {
  485. return toAjax(iClassGradeService.insertByAddBo(bo) ? 1 : 0);
  486. }
  487. /**
  488. * 修改班级
  489. */
  490. @ApiOperation("修改班级")
  491. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  492. @Log(title = "班级", businessType = BusinessType.UPDATE)
  493. @PostMapping("/edit")
  494. public AjaxResult<Void> edit(@RequestBody ClassGradeEditBo bo) {
  495. return toAjax(iClassGradeService.updateByEditBo(bo) ? 1 : 0);
  496. }
  497. /**
  498. * 修改【请填写功能名称】
  499. */
  500. @ApiOperation("更改审核状态")
  501. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  502. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  503. @PostMapping("/editPeriod")
  504. public AjaxResult<Void> edit(@RequestBody UserPeriodEditBo bo) {
  505. return toAjax(iUserPeriodService.updateByEditBo(bo) ? 1 : 0);
  506. }
  507. /**
  508. * 更改批量待审核状态
  509. */
  510. @ApiOperation("更改批量待审核状态")
  511. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  512. @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
  513. @PostMapping("/editPeriodAll")
  514. public AjaxResult<Void> editPeriodAll(@RequestBody UserPeriodEditBo bo) {
  515. return toAjax(iUserPeriodService.editPeriodAll(bo) ? 1 : 0);
  516. }
  517. /**
  518. * 学时通过确认
  519. */
  520. @ApiOperation("学时通过确认")
  521. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  522. @Log(title = "学时通过确认", businessType = BusinessType.UPDATE)
  523. @PostMapping("/confirmPeriod")
  524. public AjaxResult<Void> confirmPeriod(@RequestBody UserPeriodEditBo bo) {
  525. return toAjax(iUserPeriodService.confirmPeriod(bo) ? 1 : 0);
  526. }
  527. /**
  528. * 修改学员记录
  529. */
  530. @ApiOperation("修改学员记录")
  531. @PreAuthorize("@ss.hasPermi('system:user:edit')")
  532. @Log(title = "学员记录", businessType = BusinessType.UPDATE)
  533. @PostMapping("/editGradeUser")
  534. public AjaxResult<Void> edit(@RequestBody ClassGradeUserEditBo bo) {
  535. return toAjax(iClassGradeUserService.updateByEditBo(bo) ? 1 : 0);
  536. }
  537. /**
  538. * 学时审核獲得商品節下面的審核記錄
  539. */
  540. @ApiOperation("学时审核獲得商品節下面的審核記錄")
  541. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  542. @GetMapping("/listPeriodAuditStatus")
  543. public AjaxResult<ClassPeriodSectionVo> listPeriodAuditStatus(UserPeriodQueryBo bo) {
  544. startPage();
  545. ClassPeriodSectionVo list = iClassGradeUserService.listPeriodAuditStatus(bo);
  546. return AjaxResult.success(list);
  547. }
  548. /**
  549. * 新增订单
  550. */
  551. @ApiOperation("选新班")
  552. @PostMapping("/sysChangeGrade")
  553. public AjaxResult changeGrade(@RequestBody ClassGradeUserSysChangeBo bo) {
  554. return AjaxResult.success(iClassGradeUserService.sysChangeGrade(bo));
  555. }
  556. /**
  557. * 自由选新班
  558. */
  559. @ApiOperation("自由选新班")
  560. @PostMapping("/changeGradeFree")
  561. public AjaxResult changeGradeFree(@RequestBody ClassGradeUserChangeBo bo) {
  562. return AjaxResult.success(iClassGradeUserService.changeGradeFree(bo));
  563. }
  564. /**
  565. * 检查编辑数据是否有用户通过学时
  566. */
  567. @ApiOperation("检查编辑数据是否有用户通过学时")
  568. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  569. @GetMapping("/checkGoodsChange")
  570. public AjaxResult<Long> checkGoodsChange(UserPeriodQueryBo bo) {
  571. return AjaxResult.success(iUserPeriodService.checkGoodsChange(bo));
  572. }
  573. /**
  574. * 检查编辑数据是否有用户通过学时
  575. */
  576. @ApiOperation("检查编辑数据是否有用户在学习")
  577. @PreAuthorize("@ss.hasPermi('grade:user:list')")
  578. @GetMapping("/checkGoodsStudy")
  579. public AjaxResult<Long> checkGoodsStudy(UserPeriodQueryBo bo) {
  580. return AjaxResult.success(iUserPeriodService.checkGoodsStudy(bo));
  581. }
  582. /**
  583. * 查询班级信息推送数量
  584. */
  585. @ApiOperation("查询班级信息推送数量")
  586. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  587. @GetMapping("/officialInfoCount")
  588. public AjaxResult<Map<String,Object>> officialInfoCount(ClassGradeUserQueryBo bo) {
  589. return AjaxResult.success(iClassGradeUserService.selectOfficialInfoCount(bo));
  590. }
  591. /**
  592. * 查询班级学时推送数量
  593. */
  594. @ApiOperation("查询班级学时推送数量")
  595. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  596. @GetMapping("/officialPeriodCount")
  597. public AjaxResult<Long> officialPeriodCount(ClassGradeUserQueryBo bo) {
  598. return AjaxResult.success(iClassGradeUserService.selectOfficialPeriodCount(bo));
  599. }
  600. /**
  601. * 批量打回待审核状态
  602. */
  603. @ApiOperation("批量打回待审核状态")
  604. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  605. @Log(title = "批量打回待审核状态", businessType = BusinessType.UPDATE)
  606. @PostMapping("/rollbackPeriod")
  607. public AjaxResult<Void> rollbackPeriod(@RequestBody UserPeriodEditBo bo) {
  608. return toAjax(iUserPeriodService.rollbackPeriod(bo) ? 1 : 0);
  609. }
  610. /**
  611. * 锁定学时审核页面
  612. */
  613. @ApiOperation("锁定学时审核页面")
  614. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  615. @PostMapping("/lockPeriod")
  616. public AjaxResult<Void> lockPeriod(@RequestBody UserPeriodEditBo bo) {
  617. String key = "LockPeriod_"+bo.getGradeId()+"-"+bo.getUserId();
  618. redisCache.setCacheObject(key, SecurityUtils.getUsername(),15, TimeUnit.SECONDS);//15秒锁定
  619. return AjaxResult.success();
  620. }
  621. /**
  622. * 查看学时审核锁定状态
  623. */
  624. @ApiOperation("查看学时审核锁定状态")
  625. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  626. @Log(title = "查看学时审核锁定状态", businessType = BusinessType.UPDATE)
  627. @PostMapping("/lockPeriodStatus")
  628. public AjaxResult<Void> lockPeriodStatus(@RequestBody UserPeriodEditBo bo) {
  629. String key = "LockPeriod_"+bo.getGradeId()+"-"+bo.getUserId();
  630. String username = redisCache.getCacheObject(key);
  631. if(SecurityUtils.getUsername().equals(username)){
  632. username = null;//同个用户不返回
  633. }
  634. return AjaxResult.success(username);
  635. }
  636. /**
  637. * 查询学习账号标记列表
  638. */
  639. @ApiOperation("查询学习账号标记列表")
  640. @PreAuthorize("@ss.hasPermi('grade:grade:list')")
  641. @GetMapping("/listStudyAccountStatus")
  642. public TableDataInfo<StudyAccountStatusVo> listStudyAccountStatus(StudyAccountStatusQueryBo bo) {
  643. List<StudyAccountStatusVo> list = iClassGradeUserService.listStudyAccountStatus(bo);
  644. return getDataTable(getPageInfo(bo.getPageNum(), bo.getPageSize(), list).getList());
  645. }
  646. /**
  647. * 导出学习账号标记列表
  648. */
  649. @ApiOperation("导出学习账号标记列表")
  650. @PreAuthorize("@ss.hasPermi('system:profile:export')")
  651. @Log(title = "导出学员学时列表", businessType = BusinessType.EXPORT)
  652. @GetMapping("/exportStudyAccount")
  653. public AjaxResult<Map<String,Object>> exportStudyAccount(ClassGradeUserQueryBo bo) {
  654. bo.setUserPhoto(1);
  655. Map<String,Object> map = new HashMap<>();
  656. List<ClassGradeStudentVo> list = iClassGradeService.listGrade(bo);
  657. List<StudyAccountStatusExportVo> newList = new ArrayList<>();
  658. for (ClassGradeStudentVo classGradeStudent : list) {
  659. StudyAccountStatusExportVo studyAccountStatusExportVo = new StudyAccountStatusExportVo();
  660. BeanUtils.copyProperties(classGradeStudent, studyAccountStatusExportVo);
  661. newList.add(studyAccountStatusExportVo);
  662. }
  663. map.put("list", newList);
  664. ExcelUtil<StudyAccountStatusExportVo> util = new ExcelUtil<>(StudyAccountStatusExportVo.class);
  665. return util.exportExcel(newList,"学习账号标记");
  666. /*ExportParams deptExportParams = new ExportParams();
  667. // 设置sheet得名称
  668. deptExportParams.setSheetName("表1");
  669. String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  670. Map<String, Object> deptExportMap = new HashMap<>();
  671. deptExportMap.put("title", deptExportParams);
  672. deptExportMap.put("entity", StudyAccountStatusExportVo.class);
  673. // sheet中要填充得数据
  674. deptExportMap.put("data", list);
  675. List<Map<String, Object>> sheetsList = new ArrayList<>();
  676. sheetsList.add(deptExportMap);
  677. map.put("excel",util.exportEasyExcel(sheetsList, "学习账号标记"+timeStr));
  678. map.remove("list");
  679. return AjaxResult.success(map);*/
  680. }
  681. /**
  682. * 数据批量同步到官方系统
  683. */
  684. @ApiOperation("数据批量同步到官方系统")
  685. @PreAuthorize("@ss.hasPermi('grade:grade:edit')")
  686. @Log(title = "数据批量同步到官方系统", businessType = BusinessType.UPDATE)
  687. @PostMapping("/OpenQdyAccount")
  688. public AjaxResult<Void> OpenQdyAccount(@RequestBody OpenQdyAccountBo bo) {
  689. return toAjax(iClassGradeService.OpenQdyAccount(bo) ? 1 : 0);
  690. }
  691. /**
  692. * 发送验证码
  693. */
  694. @ApiOperation("发送验证码")
  695. @PostMapping("/sendCode")
  696. public AjaxResult<Void> OpenQdyAccount() {
  697. return toAjax(iClassGradeService.sendCode() ? 1 : 0);
  698. }
  699. @ApiOperation("二审打回重审")
  700. @PostMapping("/confirm/rollbackPeriod")
  701. public AjaxResult<Void> confirmRollbackPeriod(@RequestBody UserPeriodEditBo bo)
  702. {
  703. bo.setRollBackPlat(1);
  704. iUserPeriodService.confirmRollbackPeriod(bo);
  705. return AjaxResult.success();
  706. }
  707. @ApiOperation("获取官方班级人数")
  708. @Log(title = "获取官方班级人数", businessType = BusinessType.UPDATE)
  709. @GetMapping("/officialGradeCount")
  710. public AjaxResult<Integer> queryOfficialGradeCount(ClassGradeQueryBo bo) {
  711. return AjaxResult.success(iClassGradeService.queryOfficialGradeCount(bo));
  712. }
  713. @ApiOperation("导出商品的课程结构")
  714. @GetMapping("/exportGoodsMenuExcel")
  715. public AjaxResult<List<ClassNpUserInfoVo>> exportGoodsMenuExcel(UserPeriodEditBo bo) {
  716. GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
  717. List<SyncUserChapterExport> list = iUserPeriodService.exportGoodsMenuExcel(bo);
  718. List<SyncUserChapterExport> exportVos = list.stream().map(item -> BeanUtil.toBean(item,SyncUserChapterExport.class)).collect(Collectors.toList());
  719. ExcelUtil<SyncUserChapterExport> util = new ExcelUtil<SyncUserChapterExport>(SyncUserChapterExport.class);
  720. return util.exportExcel(exportVos, goodsVo.getGoodsName());
  721. }
  722. }