From 73a816fd2b1e29c25d615c85ce34b12b55c16ccf Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期一, 20 一月 2025 13:41:45 +0800
Subject: [PATCH] zjh20250120

---
 ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjSurveyQuestionServiceImpl.java |   63 +++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjSurveyQuestionServiceImpl.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjSurveyQuestionServiceImpl.java
index c00d7ff..85c696e 100644
--- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjSurveyQuestionServiceImpl.java
+++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjSurveyQuestionServiceImpl.java
@@ -1,22 +1,20 @@
 package com.ltkj.hosp.service.impl;
 
-import java.util.List;
-
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ltkj.common.utils.DateUtils;
-import com.ltkj.hosp.domain.TjTeamSelectRecord;
-import com.ltkj.hosp.mapper.TjTeamSelectRecordMapper;
+import com.ltkj.common.utils.SecurityUtils;
+import com.ltkj.common.utils.StringUtils;
+import com.ltkj.hosp.domain.TjSurveyOptions;
+import com.ltkj.hosp.domain.TjSurveyQuestion;
+import com.ltkj.hosp.domain.TjSurveyTempQues;
+import com.ltkj.hosp.mapper.TjSurveyQuestionMapper;
+import com.ltkj.hosp.service.ITjSurveyQuestionService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
-
-import com.ltkj.common.utils.StringUtils;
-import org.springframework.transaction.annotation.Transactional;
-import com.ltkj.hosp.domain.TjSurveyOptions;
-import com.ltkj.hosp.mapper.TjSurveyQuestionMapper;
-import com.ltkj.hosp.domain.TjSurveyQuestion;
-import com.ltkj.hosp.service.ITjSurveyQuestionService;
+import java.util.List;
 
 /**
  * 闂嵎闂Service涓氬姟灞傚鐞�
@@ -29,6 +27,9 @@
     @Autowired
     private TjSurveyQuestionMapper tjSurveyQuestionMapper;
 
+    @Autowired
+    private ITjSurveyQuestionService tjSurveyQuestionService;
+
     /**
      * 鏌ヨ闂嵎闂
      *
@@ -36,8 +37,13 @@
      * @return 闂嵎闂
      */
     @Override
-    public TjSurveyQuestion selectTjSurveyQuestionByQid(Long qid) {
+    public TjSurveyQuestion selectTjSurveyQuestionByQid(String qid) {
         return tjSurveyQuestionMapper.selectTjSurveyQuestionByQid(qid);
+    }
+
+    @Override
+    public List<TjSurveyOptions> selectOptionsByQid(String qid) {
+        return tjSurveyQuestionMapper.selectOptionsByQid(qid);
     }
 
     /**
@@ -57,13 +63,17 @@
      * @param tjSurveyQuestion 闂嵎闂
      * @return 缁撴灉
      */
-    @Transactional
+//    @Transactional
     @Override
     public int insertTjSurveyQuestion(TjSurveyQuestion tjSurveyQuestion) {
         tjSurveyQuestion.setCreateTime(DateUtils.getNowDate());
-        int rows = tjSurveyQuestionMapper.insertTjSurveyQuestion(tjSurveyQuestion);
-        insertTjSurveyOptions(tjSurveyQuestion);
-        return rows;
+        tjSurveyQuestion.setCreateBy(SecurityUtils.getLoginUser().getUsername());
+//        int rows = tjSurveyQuestionMapper.insertTjSurveyQuestion(tjSurveyQuestion);
+        if (tjSurveyQuestionService.save(tjSurveyQuestion)) {
+            insertTjSurveyOptions(tjSurveyQuestion);
+            return 1;
+        }
+        return 0;
     }
 
     /**
@@ -76,8 +86,7 @@
     @Override
     public int updateTjSurveyQuestion(TjSurveyQuestion tjSurveyQuestion) {
         tjSurveyQuestion.setUpdateTime(DateUtils.getNowDate());
-        tjSurveyQuestionMapper.deleteTjSurveyOptionsByQid(tjSurveyQuestion.getQid())
-        ;
+        tjSurveyQuestionMapper.deleteTjSurveyOptionsByQid(tjSurveyQuestion.getQid());
         insertTjSurveyOptions(tjSurveyQuestion);
         return tjSurveyQuestionMapper.updateTjSurveyQuestion(tjSurveyQuestion);
     }
@@ -90,7 +99,7 @@
      */
     @Transactional
     @Override
-    public int deleteTjSurveyQuestionByQids(Long[] qids) {
+    public int deleteTjSurveyQuestionByQids(String[] qids) {
         tjSurveyQuestionMapper.deleteTjSurveyOptionsByQids(qids);
         return tjSurveyQuestionMapper.deleteTjSurveyQuestionByQids(qids);
     }
@@ -108,6 +117,16 @@
         return tjSurveyQuestionMapper.deleteTjSurveyQuestionByQid(qid);
     }
 
+    @Override
+    public List<TjSurveyTempQues> selectOptionsByMid(String mid) {
+        return tjSurveyQuestionMapper.selectOptionsByMid(mid);
+    }
+
+    @Override
+    public List<TjSurveyQuestion> getOptionsByMid(String mid) {
+        return tjSurveyQuestionMapper.getOptionsByMid(mid);
+    }
+
     /**
      * 鏂板闂嵎閫夐」淇℃伅
      *
@@ -119,15 +138,17 @@
         if (StringUtils.isNotNull(tjSurveyOptionsList)) {
             List<TjSurveyOptions> list = new ArrayList<TjSurveyOptions>();
             for (TjSurveyOptions tjSurveyOptions : tjSurveyOptionsList) {
-                tjSurveyOptions.setQid(qid);
+                tjSurveyOptions.setQid(qid.toString());
                 tjSurveyOptions.setDeleted(0);
+                tjSurveyOptions.setCreateBy(SecurityUtils.getLoginUser().getUsername());
+                tjSurveyOptions.setCreateTime(DateUtils.getNowDate());
                 list.add(tjSurveyOptions);
             }
             if (list.size() > 0) {
                 for (TjSurveyOptions tjSurveyOptions : list) {
                     tjSurveyOptions.setDeleted(0);
+                    tjSurveyQuestionMapper.insertTjSurveyOptions(tjSurveyOptions);
                 }
-                tjSurveyQuestionMapper.batchTjSurveyOptions(list);
             }
         }
     }

--
Gitblit v1.8.0