jinlin
2023-12-28 954ad75b793d1c74cd2912ed8eef923bc588674a
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
package com.zt.life.modules.testReviewComment.service;
 
import cn.hutool.core.convert.Convert;
import com.zt.common.service.BaseService;
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.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.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;
 
 
/**
 * 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 SysCodeRuleService sysCodeRuleService;
 
    @Autowired
    private WordFileService wordFileService;
 
    /**
     * 分页查询
     *
     * @param queryFilter
     * @return
     */
    public List<TestReviewComment> page(QueryFilter queryFilter) {
        List<TestReviewComment> list = baseDao.getList(queryFilter.getQueryParams());
        if (list.size() > 0) {
            sysOssService.setListOsses(list, "test_review_comment");
        }
        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();
        data.setPageCode(pageCode);
        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 {
            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();
        }
        return commentId;
    }
 
    public void exportReviewComment(Long id, String pageCode, HttpServletRequest request, HttpServletResponse response) {
        try {
            ReviewCommentDto dataObj = this.getDto(id, null, pageCode);
            WordFile wordFile = new WordFile();
            wordFile.setModulePath("基线发布书.docx");
            wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_基线发布书.docx");
            wordFileService.exportWordFile(request, dataObj, wordFile, response);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}