From 3a8e1524dcf0eeb610d38123d5f0a3ef838379cd Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期一, 12 四月 2021 15:44:53 +0800
Subject: [PATCH] Merge branch '20210406-maqv2' into 20210412-youhua

---
 src/main/java/com/ots/project/exam/controller/EntTestPackageController.java |  226 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 128 insertions(+), 98 deletions(-)

diff --git a/src/main/java/com/ots/project/exam/controller/EntTestPackageController.java b/src/main/java/com/ots/project/exam/controller/EntTestPackageController.java
index b8b107b..cd3da43 100644
--- a/src/main/java/com/ots/project/exam/controller/EntTestPackageController.java
+++ b/src/main/java/com/ots/project/exam/controller/EntTestPackageController.java
@@ -1,5 +1,4 @@
 package com.ots.project.exam.controller;
-
 import com.ots.common.enums.UserTypeEnum;
 import com.ots.common.utils.MessageUtils;
 import com.ots.common.utils.StringUtils;
@@ -11,12 +10,11 @@
 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;
@@ -28,12 +26,11 @@
 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;
 
 /**
@@ -59,9 +56,21 @@
     @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:view")
+    @GetMapping("/searchTestPackage")
+    public String search(String testName, ModelMap mmap) {
+        if (Objects.nonNull(testName)) {
+            mmap.put("testName", testName);
+        }
         return prefix + "/test_package";
     }
 
@@ -114,7 +123,25 @@
     @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");
     }
@@ -141,14 +168,103 @@
         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";
+    }
+
+    /**
+     * 鏍规嵁浜у搧鍖匢D鑾峰彇妯℃澘缂栫爜
+     */
+    @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();
+        /**
+         * 榛樿鍏ㄩ儴涓篺alse
+         */
+        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
@@ -203,91 +319,5 @@
                 "<br>";
         return template;
     }
-
-    /**
-     * 鏍规嵁浜у搧鍖匢D鑾峰彇妯℃澘缂栫爜
-     */
-    @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();
-        /**
-         * 榛樿鍏ㄩ儴涓篺alse
-         */
-        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));
-    }
-
 
 }

--
Gitblit v1.9.1