| | |
| | | package com.ots.project.exam.controller; |
| | | |
| | | import com.ots.common.enums.UserTypeEnum; |
| | | import com.ots.common.utils.MessageUtils; |
| | | import com.ots.common.utils.StringUtils; |
| | |
| | | import com.ots.framework.web.domain.AjaxResult; |
| | | import com.ots.framework.web.page.TableDataInfo; |
| | | import com.ots.project.exam.domain.EntDemographyParam; |
| | | import com.ots.project.exam.domain.EntEmailTemplate; |
| | | import com.ots.project.exam.domain.EntTestMember; |
| | | import com.ots.project.exam.domain.EntTestPackage; |
| | | import com.ots.project.exam.domain.SysUserExtend; |
| | | import com.ots.project.exam.service.IEntDemographyParamService; |
| | | import com.ots.project.exam.service.IEntTestPackageService; |
| | | import com.ots.project.exam.service.ISysUserExtendService; |
| | | import com.ots.project.exam.service.ITReportTemplateService; |
| | | import com.ots.project.exam.service.*; |
| | | import com.ots.project.system.user.domain.User; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.jetbrains.annotations.NotNull; |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.ots.common.enums.UserTypeEnum.SYS_USER; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ITReportTemplateService reportTemplateService; |
| | | |
| | | @Autowired |
| | | private IEntEmailTemplateService entEmailTemplateService; |
| | | |
| | | @RequiresPermissions("exam:test_package:view") |
| | | @GetMapping() |
| | | public String test_package() { |
| | | return prefix + "/test_package"; |
| | | } |
| | | |
| | | @RequiresPermissions("exam:test_package:search") |
| | | @RequiresPermissions("exam:test_package:view") |
| | | @GetMapping("/searchTestPackage") |
| | | public String search(String testName, ModelMap mmap) { |
| | | if (Objects.nonNull(testName)) { |
| | |
| | | @PostMapping("/export") |
| | | @ResponseBody |
| | | public AjaxResult export(EntTestPackage entTestPackage) { |
| | | User sysUser = ShiroUtils.getSysUser(); |
| | | String userType = sysUser.getUserType(); |
| | | List<Long> userIds = new ArrayList<>(); |
| | | userIds.add(sysUser.getUserId()); |
| | | |
| | | if (UserTypeEnum.DIS_USER.getUserType().equals(userType)) { |
| | | SysUserExtend sysUserExtend = new SysUserExtend(); |
| | | sysUserExtend.setParentUserId(sysUser.getUserId()); |
| | | List<SysUserExtend> sysUserExtends = sysUserExtendService.selectSysUserExtendList(sysUserExtend); |
| | | for (int i = 0; i < sysUserExtends.size(); i++) { |
| | | SysUserExtend extend = sysUserExtends.get(i); |
| | | userIds.add(extend.getUserId()); |
| | | } |
| | | } |
| | | List<EntTestPackage> list = entTestPackageService.selectEntTestPackageList(entTestPackage); |
| | | if (!SYS_USER.getUserType().equals(userType)) { |
| | | |
| | | list = list.stream().filter(p -> userIds.contains(p.getUserId())).collect(Collectors.toList()); |
| | | } |
| | | ExcelUtil<EntTestPackage> util = new ExcelUtil<EntTestPackage>(EntTestPackage.class); |
| | | return util.exportExcel(list, "test_package"); |
| | | } |
| | |
| | | mmap.put("roles", list); |
| | | //报告模板编码 t_report_template |
| | | // mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser())); |
| | | mmap.put("template", getTemplate()); |
| | | // mmap.put("template", getTemplate()); |
| | | //默认邮件内容模板配置 |
| | | EntEmailTemplate eet = entEmailTemplateService.getOnly(); |
| | | mmap.put("eet", eet); |
| | | SysUserExtend sysUserExtend = sysUserExtendService.selectSysUserExtendById(ShiroUtils.getUserId()); |
| | | String mailContent = sysUserExtend.getMailContent(); |
| | | if (StringUtils.isBlank(mailContent)) { |
| | | mailContent = getHrTemplate(); |
| | | } |
| | | mmap.put("hrTemplate", mailContent); |
| | | mmap.put("hrTemplate",mailContent); |
| | | return prefix + "/add"; |
| | | } |
| | | |
| | | /** |
| | | * 根据产品包ID获取模板编码 |
| | | */ |
| | | @PostMapping("/prodTemplate") |
| | | @ResponseBody |
| | | public AjaxResult changeTemplate(Long prodId) { |
| | | return AjaxResult.success(MessageUtils.message("basis.successfulOperation"), reportTemplateService.getReportTemplates(ShiroUtils.getSysUser(), prodId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:add") |
| | | @Log(title = "测试包管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | @ResponseBody |
| | | public AjaxResult addSave(EntTestPackage entTestPackage) { |
| | | return toAjax(entTestPackageService.insertEntTestPackage(entTestPackage)); |
| | | } |
| | | |
| | | /** |
| | | * 修改测试包管理 |
| | | */ |
| | | @GetMapping("/edit/{id}") |
| | | public String edit(@PathVariable("id") Long id, ModelMap mmap) { |
| | | EntTestPackage entTestPackage = entTestPackageService.selectEntTestPackageById(id); |
| | | mmap.put("entTestPackage", entTestPackage); |
| | | EntDemographyParam entDemographyParam = new EntDemographyParam(); |
| | | List<EntDemographyParam> list = entDemographyParamService.selectEntDemographyParamList(entDemographyParam); |
| | | String paramCodes = entTestPackage.getParamCodes(); |
| | | /** |
| | | * 默认全部为false |
| | | */ |
| | | if (Objects.nonNull(paramCodes)) { |
| | | String[] split = paramCodes.split(","); |
| | | list.forEach(p -> { |
| | | Arrays.asList(split).forEach(t -> { |
| | | p.setFlag(false); |
| | | }); |
| | | }); |
| | | } |
| | | /** |
| | | * 存在数据则更新为true |
| | | */ |
| | | if (Objects.nonNull(paramCodes)) { |
| | | String[] split = paramCodes.split(","); |
| | | list.forEach(p -> { |
| | | Arrays.asList(split).forEach(t -> { |
| | | if (Objects.equals(String.valueOf(p.getParamId()), t)) { |
| | | p.setFlag(true); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | mmap.put("roles", list); |
| | | //默认邮件内容模板配置 |
| | | EntEmailTemplate eet = entEmailTemplateService.getOnly(); |
| | | mmap.put("eet", eet); |
| | | SysUserExtend sysUserExtend = sysUserExtendService.selectSysUserExtendById(ShiroUtils.getUserId()); |
| | | String mailContent = sysUserExtend.getMailContent(); |
| | | mmap.put("hrTemplate",mailContent); |
| | | |
| | | //报告模板编码 t_report_template |
| | | mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser(), entTestPackage.getProdId())); |
| | | return prefix + "/edit"; |
| | | } |
| | | |
| | | /** |
| | | * 修改保存测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:edit") |
| | | @Log(title = "测试包管理", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | @ResponseBody |
| | | public AjaxResult editSave(EntTestPackage entTestPackage) { |
| | | return toAjax(entTestPackageService.updateEntTestPackage(entTestPackage)); |
| | | } |
| | | |
| | | /** |
| | | * 删除测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:remove") |
| | | @Log(title = "测试包管理", businessType = BusinessType.DELETE) |
| | | @PostMapping("/remove") |
| | | @ResponseBody |
| | | public AjaxResult remove(String ids) { |
| | | return toAjax(entTestPackageService.deleteEntTestPackageByIds(ids)); |
| | | } |
| | | |
| | | @NotNull |
| | |
| | | "<br>"; |
| | | return template; |
| | | } |
| | | |
| | | /** |
| | | * 根据产品包ID获取模板编码 |
| | | */ |
| | | @PostMapping("/prodTemplate") |
| | | @ResponseBody |
| | | public AjaxResult changeTemplate(Long prodId) { |
| | | return AjaxResult.success(MessageUtils.message("basis.successfulOperation"), reportTemplateService.getReportTemplates(ShiroUtils.getSysUser(), prodId)); |
| | | } |
| | | |
| | | /** |
| | | * 新增保存测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:add") |
| | | @Log(title = "测试包管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | @ResponseBody |
| | | public AjaxResult addSave(EntTestPackage entTestPackage) { |
| | | return toAjax(entTestPackageService.insertEntTestPackage(entTestPackage)); |
| | | } |
| | | |
| | | /** |
| | | * 修改测试包管理 |
| | | */ |
| | | @GetMapping("/edit/{id}") |
| | | public String edit(@PathVariable("id") Long id, ModelMap mmap) { |
| | | EntTestPackage entTestPackage = entTestPackageService.selectEntTestPackageById(id); |
| | | mmap.put("entTestPackage", entTestPackage); |
| | | |
| | | EntDemographyParam entDemographyParam = new EntDemographyParam(); |
| | | List<EntDemographyParam> list = entDemographyParamService.selectEntDemographyParamList(entDemographyParam); |
| | | |
| | | String paramCodes = entTestPackage.getParamCodes(); |
| | | /** |
| | | * 默认全部为false |
| | | */ |
| | | if (Objects.nonNull(paramCodes)) { |
| | | String[] split = paramCodes.split(","); |
| | | list.forEach(p -> { |
| | | Arrays.asList(split).forEach(t -> { |
| | | p.setFlag(false); |
| | | }); |
| | | }); |
| | | } |
| | | /** |
| | | * 存在数据则更新为true |
| | | */ |
| | | if (Objects.nonNull(paramCodes)) { |
| | | String[] split = paramCodes.split(","); |
| | | list.forEach(p -> { |
| | | Arrays.asList(split).forEach(t -> { |
| | | if (Objects.equals(String.valueOf(p.getParamId()), t)) { |
| | | p.setFlag(true); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | mmap.put("roles", list); |
| | | |
| | | //报告模板编码 t_report_template |
| | | mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser(), entTestPackage.getProdId())); |
| | | return prefix + "/edit"; |
| | | } |
| | | |
| | | /** |
| | | * 修改保存测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:edit") |
| | | @Log(title = "测试包管理", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | @ResponseBody |
| | | public AjaxResult editSave(EntTestPackage entTestPackage) { |
| | | return toAjax(entTestPackageService.updateEntTestPackage(entTestPackage)); |
| | | } |
| | | |
| | | /** |
| | | * 删除测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:remove") |
| | | @Log(title = "测试包管理", businessType = BusinessType.DELETE) |
| | | @PostMapping("/remove") |
| | | @ResponseBody |
| | | public AjaxResult remove(String ids) { |
| | | return toAjax(entTestPackageService.deleteEntTestPackageByIds(ids)); |
| | | } |
| | | |
| | | |
| | | } |