| | |
| | | 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.EntTestMember; |
| | | import com.ots.project.exam.domain.EntTestPackage; |
| | | import com.ots.project.exam.domain.SysUserExtend; |
| | | import com.ots.project.exam.service.IEntDemographyParamService; |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 测试包管理Controller |
| | | * |
| | | * @author ots |
| | | * @date 2019-11-27 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/exam/test_package") |
| | | public class EntTestPackageController extends BaseController { |
| | | private String prefix = "exam/test_package"; |
| | | |
| | | @Autowired |
| | | private IEntTestPackageService entTestPackageService; |
| | | |
| | | @Autowired |
| | | private IEntDemographyParamService entDemographyParamService; |
| | | |
| | | @Autowired |
| | | private ISysUserExtendService sysUserExtendService; |
| | | |
| | | @Autowired |
| | | private ITReportTemplateService reportTemplateService; |
| | | |
| | | @RequiresPermissions("exam:test_package:view") |
| | | @GetMapping() |
| | | public String test_package() { |
| | | return prefix + "/test_package"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询测试包管理列表 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:list") |
| | | @PostMapping("/list") |
| | | @ResponseBody |
| | |
| | | if (UserTypeEnum.ENT_USER.getUserType().equals(userType)) { |
| | | entTestPackage.setUserId(sysUser.getUserId()); |
| | | } |
| | | |
| | | //分销商可以看到分销商下的企业信息 |
| | | if (UserTypeEnum.DIS_USER.getUserType().equals(userType)) { |
| | | SysUserExtend sysUserExtend = new SysUserExtend(); |
| | | sysUserExtend.setParentUserId(sysUser.getUserId()); |
| | |
| | | } |
| | | return getDataTable(entTestPackageService.selectEntTestPackageList(entTestPackage)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询测试包管理列表 |
| | | */ |
| | | @PostMapping("/listTopTestPackage") |
| | | @ResponseBody |
| | | public TableDataInfo listTopTestPackage(EntTestPackage entTestPackage) { |
| | |
| | | if (!SYS_USER.getUserType().equals(sysUser.getUserType())) { |
| | | entTestPackage.setUserId(sysUser.getUserId()); |
| | | } |
| | | |
| | | return getDataTable(entTestPackageService.selectEntTestPackageList(entTestPackage)); |
| | | return getDataTable(entTestPackageService.selectEntTestPackageMainList(entTestPackage)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出测试包管理列表 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:export") |
| | | @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"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 回收人次(回收密码) |
| | | */ |
| | | @RequiresPermissions("exam:test_package:recover") |
| | | @PostMapping("/recover/{testId}") |
| | | @ResponseBody |
| | | public AjaxResult recover(@PathVariable Long testId) { |
| | | return toAjax(entTestPackageService.recover(testId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增测试包管理 |
| | | */ |
| | | @GetMapping("/add") |
| | | public String add(ModelMap mmap) { |
| | | |
| | | //多语言选择 |
| | | EntDemographyParam entDemographyParam = new EntDemographyParam(); |
| | | entDemographyParam.setParamStatus("1"); |
| | | List<EntDemographyParam> list = entDemographyParamService.selectEntDemographyParamList(entDemographyParam); |
| | | mmap.put("roles", list); |
| | | |
| | | |
| | | //报告模板编码 t_report_template |
| | | // mmap.put("templateList", reportTemplateService.getReportTemplates(ShiroUtils.getSysUser())); |
| | | mmap.put("template", getTemplate()); |
| | | SysUserExtend sysUserExtend = sysUserExtendService.selectSysUserExtendById(ShiroUtils.getUserId()); |
| | | String mailContent = sysUserExtend.getMailContent(); |
| | |
| | | mmap.put("hrTemplate", mailContent); |
| | | return prefix + "/add"; |
| | | } |
| | | |
| | | @NotNull |
| | | private String getHrTemplate() { |
| | | String template = "亲爱的{Company}人力资源部,\n" + |
| | |
| | | "ฝ่ายบริการลูกค้าสัมพันธ์บริษท TAI"; |
| | | return template; |
| | | } |
| | | |
| | | @NotNull |
| | | private String getTemplate() { |
| | | String template = "亲爱的{FullName},\n" + |
| | |
| | | "<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") |
| | |
| | | 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 -> { |
| | |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 存在数据则更新为true |
| | | */ |
| | | if (Objects.nonNull(paramCodes)) { |
| | | String[] split = paramCodes.split(","); |
| | | list.forEach(p -> { |
| | |
| | | }); |
| | | } |
| | | 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") |
| | |
| | | public AjaxResult editSave(EntTestPackage entTestPackage) { |
| | | return toAjax(entTestPackageService.updateEntTestPackage(entTestPackage)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除测试包管理 |
| | | */ |
| | | @RequiresPermissions("exam:test_package:remove") |
| | | @Log(title = "测试包管理", businessType = BusinessType.DELETE) |
| | | @PostMapping("/remove") |
| | |
| | | public AjaxResult remove(String ids) { |
| | | return toAjax(entTestPackageService.deleteEntTestPackageByIds(ids)); |
| | | } |
| | | |
| | | |
| | | } |