jinlin
2024-01-12 f491d30b0a69148bd0991b3d5b1c4cf9f8216949
modules/mainPart/src/main/java/com/zt/life/modules/testReviewComment/service/TestReviewCommentService.java
@@ -2,6 +2,8 @@
import cn.hutool.core.convert.Convert;
import com.zt.common.service.BaseService;
import com.zt.core.context.User;
import com.zt.core.context.UserContext;
import com.zt.life.export.dto.WordFile;
import com.zt.life.export.service.WordFileService;
import com.zt.life.modules.baselineRelease.dto.BaselineDto;
@@ -9,16 +11,19 @@
import com.zt.life.modules.baselineRelease.model.BaselineReleaseRemark;
import com.zt.life.modules.baselineRelease.service.BaselineReleaseRemarkService;
import com.zt.life.modules.project.service.ProjectService;
import com.zt.life.modules.sysBaseInfo.service.TestAgencyInfoService;
import com.zt.life.modules.testReviewComment.dao.TestReviewCommentDao;
import com.zt.life.modules.testReviewComment.dto.ReviewCommentDto;
import com.zt.life.modules.testReviewComment.model.TestReviewComment;
import com.zt.life.sys.dto.OssDto;
import com.zt.life.sys.service.SysOssConfigService;
import com.zt.modules.coderule.service.SysCodeRuleService;
import com.zt.modules.oss.service.SysOssService;
import com.zt.modules.workflow.dto.FlowInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zt.common.db.query.QueryFilter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -27,16 +32,18 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * test_review_comment
 *
 * @author zt generator
 * @author zt generator
 * @since 1.0.0 2023-12-28
 */
@Service
public class TestReviewCommentService  extends BaseService<TestReviewCommentDao, TestReviewComment> {
public class TestReviewCommentService extends BaseService<TestReviewCommentDao, TestReviewComment> {
    @Autowired
    private SysOssService sysOssService;
@@ -45,10 +52,13 @@
    private ProjectService projectService;
    @Autowired
    private SysCodeRuleService sysCodeRuleService;
    private SysOssConfigService sysOssConfigService;
    @Autowired
    private WordFileService wordFileService;
    @Autowired
    private TestAgencyInfoService testAgencyInfoService;
    /**
     * 分页查询
@@ -57,9 +67,14 @@
     * @return
     */
    public List<TestReviewComment> page(QueryFilter queryFilter) {
        String pageCode = String.valueOf(queryFilter.getParams().get("pageCode"));
        pageCode=pageCode.replace("%","");
        User user = UserContext.getUser();
        Integer secretClass = user.getSecretClass();
        queryFilter.getQueryParams().put("secretClass",secretClass);
        List<TestReviewComment> list = baseDao.getList(queryFilter.getQueryParams());
        if (list.size() > 0) {
            sysOssService.setListOsses(list, "test_review_comment");
            sysOssService.setListOsses(list, "test_review_comment_" + pageCode);
        }
        return list;
    }
@@ -76,7 +91,6 @@
    public ReviewCommentDto getDto(Long commentId, Long projectId, String pageCode) {
        ReviewCommentDto data = new ReviewCommentDto();
        data.setPageCode(pageCode);
        if (commentId != null) {
            data.setId(commentId);
            TestReviewComment reviewComment = this.get(commentId);
@@ -95,29 +109,32 @@
        }
        return data;
    }
    public Long save(ReviewCommentDto reviewCommentDto) {
        Long commentId = reviewCommentDto.getReviewComment().getId();
        if (commentId != null)
            baseDao.updateById(reviewCommentDto.getReviewComment());
        else {
            Map<String, String> map = new HashMap<>();
            String pagecode = reviewCommentDto.getPageCode();
            map.put("funCode", "test_review_comment_" + pagecode);
            map.put("projectId", reviewCommentDto.getProjectId().toString());
            reviewCommentDto.getReviewComment().setProjectId(reviewCommentDto.getProjectId());
            reviewCommentDto.getReviewComment().setCode(sysCodeRuleService.getNewCode(map));
            baseDao.insert(reviewCommentDto.getReviewComment());
            commentId = reviewCommentDto.getReviewComment().getId();
        }
        sysOssConfigService.updateOss(reviewCommentDto.getId(), reviewCommentDto.getFiles());// 保存附件
        return commentId;
    }
    public void exportReviewComment(Long id, String pageCode, HttpServletRequest request, HttpServletResponse response) {
        try {
            ReviewCommentDto dataObj = this.getDto(id, null, pageCode);
            Map<String, String> map = new HashMap<>();
            map.put("plan", "计划");
            map.put("ready", "就绪");
            map.put("summary", "测试总结");
            String type = map.get(pageCode);
            dataObj.setPageCode(type);
            WordFile wordFile = new WordFile();
            wordFile.setModulePath("基线发布书.docx");
            wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_基线发布书.docx");
            wordFile.setModulePath("测试" + type + "评审意见.docx");
            wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_测试" + type + "评审意见.docx");
            wordFileService.exportWordFile(request, dataObj, wordFile, response);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();