From 1e91dc33009cfdc951b2642877f40280b51c3089 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期五, 28 二月 2025 15:17:01 +0800
Subject: [PATCH] zjh20250228

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSurveyTemplateController.java |  115 +++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 90 insertions(+), 25 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSurveyTemplateController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSurveyTemplateController.java
index fe19864..563b4c1 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSurveyTemplateController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSurveyTemplateController.java
@@ -10,12 +10,12 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ltkj.common.core.domain.TreeSelect;
 import com.ltkj.common.core.domain.entity.SysDept;
-import com.ltkj.hosp.domain.TjSurveyOptions;
-import com.ltkj.hosp.domain.TjSurveyQuestion;
-import com.ltkj.hosp.domain.TjSurveyTempQues;
+import com.ltkj.common.core.domain.entity.SysDictData;
+import com.ltkj.hosp.domain.*;
 import com.ltkj.hosp.service.ITjSurveyQuestionService;
 import com.ltkj.system.service.ISysConfigService;
 import com.ltkj.system.service.ISysDeptService;
+import com.ltkj.system.service.ISysDictDataService;
 import com.ltkj.tduck.domain.UserFormEntity;
 import com.ltkj.tduck.enums.FormSourceTypeEnum;
 import com.ltkj.tduck.enums.FormStatusEnum;
@@ -30,7 +30,6 @@
 import com.ltkj.common.core.controller.BaseController;
 import com.ltkj.common.core.domain.AjaxResult;
 import com.ltkj.common.enums.BusinessType;
-import com.ltkj.hosp.domain.TjSurveyTemplate;
 import com.ltkj.hosp.service.ITjSurveyTemplateService;
 import com.ltkj.common.utils.poi.ExcelUtil;
 import com.ltkj.common.core.page.TableDataInfo;
@@ -58,7 +57,6 @@
 
     @Autowired
     private ISysDeptService deptService;
-
     /**
      * 鍒ゆ柇鏄惁寮�鍚~楦〃鍗曡璁�
      */
@@ -75,11 +73,12 @@
     @ApiOperation(value = "鍒ゆ柇璇ユā鏉挎槸鍚﹀彲鍒犻櫎")
     @GetMapping(value = "/canDelete")
     public AjaxResult canDelete(Long id) {
+        TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(id);
 //        List<FwdPlanInfoVo> fwdPlanInfoVos = fwdSqlMapper.canDelete(id);
-//        if (fwdPlanInfoVos!=null && fwdPlanInfoVos.size()>0){
-//            return AjaxResult.success(false);
-//        }
-        return AjaxResult.success(false);
+        if (byId !=null && byId.getQybz().equals("0")){
+            return AjaxResult.success(false);
+        }
+        return AjaxResult.success(true);
     }
 
 
@@ -153,28 +152,40 @@
             wq1.eq(TjSurveyQuestion::getMid,byId.getMid());
             final List<TjSurveyQuestion> list1 = tjSurveyQuestionService.list(wq1);
             for (TjSurveyQuestion tjSurveyQuestion : list1) {
-                final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(tjSurveyQuestion.getQid());
+                final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(String.valueOf(tjSurveyQuestion.getQid()));
                 tjSurveyQuestion.setTjSurveyOptionsList(tjSurveyOptions);
             }
             return AjaxResult.success(list1);
 
         }
         return AjaxResult.success("鏆傛棤淇℃伅");
+    }
 
 
-//        List<TjSurveyQuestion> l11=new ArrayList<>();
-//        TjSurveyTemplate byId1 = tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid);
-//        List<TjSurveyTempQues> tjSurveyTempQuesList = byId1.getTjSurveyTempQuesList();
-//        if (tjSurveyTempQuesList!=null){
-//            for (TjSurveyTempQues tjSurveyTempQues : tjSurveyTempQuesList) {
-//                TjSurveyQuestion byId11 = tjSurveyQuestionService.selectTjSurveyQuestionByQid(tjSurveyTempQues.getQid());
-//                if (byId11!=null){
-//                    l11.add(byId11);
-//                }
-//            }
-//            return AjaxResult.success(l11);
-//        }
-//        return AjaxResult.success("鏆傛棤淇℃伅");
+    /**
+     * 鑾峰彇闂嵎妯℃澘
+     */
+    @GetMapping("/getQuesByMids")
+    @ApiOperation(value = "鑾峰彇闂嵎妯℃澘淇℃伅")
+    public AjaxResult getQuesByMids(@RequestParam Long mid) {
+
+        List<TjSurveyQuestion> l1 = new ArrayList<>();
+//        TjSurveyTemplate byId = tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid);
+        List<TjSurveyTempQues> tjSurveyTempQuesList = tjSurveyQuestionService.selectOptionsByMid(mid.toString());
+        if (tjSurveyTempQuesList != null && tjSurveyTempQuesList.size()>0) {
+            for (TjSurveyTempQues tjSurveyTempQues : tjSurveyTempQuesList) {
+                TjSurveyQuestion byId1 = tjSurveyQuestionService.selectTjSurveyQuestionByQid(tjSurveyTempQues.getQid());
+                if (byId1 != null) {
+                    l1.add(byId1);
+                }
+            }
+            return AjaxResult.success(l1);
+        }
+        List<TjSurveyQuestion> optionsByMid = tjSurveyQuestionService.getOptionsByMid(mid.toString());
+        if(null !=optionsByMid && optionsByMid.size()>0){
+            return AjaxResult.success(optionsByMid);
+        }
+        return AjaxResult.success("鏆傛棤淇℃伅");
     }
 
 
@@ -186,6 +197,10 @@
     @PostMapping
     public AjaxResult add(@RequestBody TjSurveyTemplate tjSurveyTemplate) {
 //        return toAjax(tjSurveyTemplateService.insertTjSurveyTemplate(tjSurveyTemplate));
+        TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByTjCategory(tjSurveyTemplate.getTempType());
+        if(null !=byId){
+            return AjaxResult.error("璇ョ被鍨嬫ā鏉垮凡瀛樺湪  涓嶅彲閲嶅鍒涘缓!!!");
+        }
         final String call = configService.selectConfigByKey("need_design");
         //鍒ゆ柇鏄惁寮�鍚~楦〃鍗曡璁�
         if ("true".equals(call)){
@@ -220,7 +235,6 @@
                                                  @RequestParam("pageNum") int pageNum,
                                                  @RequestParam("pageSize") int pageSize) {
         Map<String, Object> res = new HashMap<>();
-        System.out.println();
 //        List<TjSurveyQuestion> list = tjSurveyTemplateService.getQuestionsByMid(mid);
         LambdaQueryWrapper<TjSurveyQuestion> wq1=new LambdaQueryWrapper<>();
         wq1.eq(TjSurveyQuestion::getMid,mid);
@@ -240,7 +254,7 @@
         final TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(mid);
         for (TjSurveyQuestion tjSurveyQuestion : result) {
             tjSurveyQuestion.setTemplate(byId);
-            final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(tjSurveyQuestion.getQid());
+            final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(String.valueOf(tjSurveyQuestion.getQid()));
             tjSurveyQuestion.setTjSurveyOptionsList(tjSurveyOptions);
         }
         res.put("data", result);
@@ -261,12 +275,63 @@
 
 
     /**
+     * 鏌ヨ闂嵎妯℃澘鍒楄〃
+     */
+    @GetMapping("/listByDeptId1")
+    public AjaxResult listByDeptId1() {
+        SysDictData data=new SysDictData();
+        data.setDictType("question_template_type");
+        data.setStatus("0");
+        List<TreeTjSurveryTemplate> list = tjSurveyTemplateService.selectDictDataList(data);
+        if(null !=list && list.size()>0){
+            for (TreeTjSurveryTemplate dictData : list) {
+                List<TreeTjSurveryTemplate> templateList = tjSurveyTemplateService.getTreeTjSurveryTemplate(dictData.getVaule());
+                dictData.setChildren(templateList);
+            }
+        }
+        return AjaxResult.success(list);
+    }
+
+
+
+    @GetMapping("/getTjrWnJuanMoBan")
+    public AjaxResult getTjrWnJuanMoBan(String tjCategory) {
+        TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByTjCategory(tjCategory);
+//        TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(Long.valueOf(mid));
+        if(null !=byId){
+            if ("1".equals(byId.getQybz())){
+                return AjaxResult.success("璇ラ棶鍗锋ā鏉夸笉瀛樺湪鎴栧凡鍋滅敤");
+            }
+            //鍒ゆ柇鏄惁鏈夐棶棰�
+            if(byId.getDesignId()!=null){
+                return AjaxResult.success(byId.getDesignId());
+            }
+            LambdaQueryWrapper<TjSurveyQuestion> wq1=new LambdaQueryWrapper<>();
+            wq1.eq(TjSurveyQuestion::getMid,byId.getMid());
+            final List<TjSurveyQuestion> list1 = tjSurveyQuestionService.list(wq1);
+            for (TjSurveyQuestion tjSurveyQuestion : list1) {
+                final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(String.valueOf(tjSurveyQuestion.getQid()));
+                tjSurveyQuestion.setTjSurveyOptionsList(tjSurveyOptions);
+            }
+            return AjaxResult.success(list1);
+
+        }
+        return AjaxResult.success("鏆傛棤淇℃伅");
+    }
+
+
+
+    /**
      * 淇敼闂嵎妯℃澘
      */
     //@PreAuthorize("@ss.hasPermi('hosp:surveyTemplate:edit')")
     @Log(title = "闂嵎妯℃澘", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody TjSurveyTemplate tjSurveyTemplate) {
+        TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(tjSurveyTemplate.getMid());
+        if(null ==byId){
+            return AjaxResult.error("璇ユā鏉夸笉瀛樺湪!!!");
+        }
         return toAjax(tjSurveyTemplateService.updateTjSurveyTemplate(tjSurveyTemplate));
     }
 

--
Gitblit v1.8.0