ClassGradeController.java 34 KB

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