jinlin
2024-01-12 f491d30b0a69148bd0991b3d5b1c4cf9f8216949
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.zt.life.modules.testReviewComment.service;
 
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;
import com.zt.life.modules.baselineRelease.model.BaselineRelease;
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;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
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
 * @since 1.0.0 2023-12-28
 */
@Service
public class TestReviewCommentService extends BaseService<TestReviewCommentDao, TestReviewComment> {
 
    @Autowired
    private SysOssService sysOssService;
 
    @Autowired
    private ProjectService projectService;
 
    @Autowired
    private SysOssConfigService sysOssConfigService;
 
    @Autowired
    private WordFileService wordFileService;
 
    @Autowired
    private TestAgencyInfoService testAgencyInfoService;
 
    /**
     * 分页查询
     *
     * @param queryFilter
     * @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_" + pageCode);
        }
        return list;
    }
 
    /**
     * 删除
     *
     * @param ids
     */
    public void delete(Long[] ids) {
        super.deleteLogic(ids);
    }
 
 
    public ReviewCommentDto getDto(Long commentId, Long projectId, String pageCode) {
        ReviewCommentDto data = new ReviewCommentDto();
        if (commentId != null) {
            data.setId(commentId);
            TestReviewComment reviewComment = this.get(commentId);
            data.setReviewComment(reviewComment);
            if (reviewComment != null && projectId == null) {
                projectId = reviewComment.getProjectId();
            }
        } else {
            TestReviewComment reviewComment = new TestReviewComment();
            reviewComment.setPageCode(pageCode);
            data.setReviewComment(reviewComment);
        }
        if (projectId != null) {
            data.setProjectId(projectId);
            data.setProject(projectService.get(projectId));
        }
        return data;
    }
 
    public Long save(ReviewCommentDto reviewCommentDto) {
        Long commentId = reviewCommentDto.getReviewComment().getId();
        if (commentId != null)
            baseDao.updateById(reviewCommentDto.getReviewComment());
        else {
            reviewCommentDto.getReviewComment().setProjectId(reviewCommentDto.getProjectId());
            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("测试" + type + "评审意见.docx");
            wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_测试" + type + "评审意见.docx");
            wordFileService.exportWordFile(request, dataObj, wordFile, response);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}