zhaowenxuan
7 天以前 0892d843cd394f383ff50f480f7f22f2ec3829bc
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);
            }
        }
    }