jinlin
2024-01-15 1a7af6fff5185bb257c16b0445140c93263a3331
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package com.zt.life.modules.qaAuditReport.service;
 
import cn.hutool.core.convert.Convert;
import com.zt.common.service.BaseService;
import com.zt.common.utils.CommonUtils;
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.configAuditReport.dto.ConfigAuditDto;
import com.zt.life.modules.configAuditReport.model.ConfigAuditReport;
import com.zt.life.modules.configAuditReport.model.ConfigAuditReportContent;
import com.zt.life.modules.configAuditReport.model.ConfigAuditReportProblem;
import com.zt.life.modules.configAuditReport.service.ConfigAuditReportContentService;
import com.zt.life.modules.configAuditReport.service.ConfigAuditReportProblemService;
import com.zt.life.modules.mainPart.utils.GetFilesPath;
import com.zt.life.modules.mainPart.utils.GetShowDictList;
import com.zt.life.modules.project.service.ProjectService;
import com.zt.life.modules.qaAuditReport.dao.QaAuditReportDao;
import com.zt.life.modules.qaAuditReport.dto.QaAuditReportDto;
import com.zt.life.modules.qaAuditReport.model.QaAuditReport;
import com.zt.life.modules.qaAuditReport.model.QaAuditReportIncongruent;
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.sys.service.SysUserService;
import com.zt.modules.workflow.dto.FlowInfoDto;
import com.zt.modules.workflow.service.WorkflowService;
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;
 
 
/**
 * qa_audit_report
 *
 * @author zt generator 
 * @since 1.0.0 2023-12-29
 */
@Service
public class QaAuditReportService  extends BaseService<QaAuditReportDao, QaAuditReport> {
    @Autowired
    private SysOssConfigService sysOssConfigService;
 
    @Autowired
    private SysOssService sysOssService;
 
    @Autowired
    private SysCodeRuleService sysCodeRuleService;
 
    @Autowired
    private ProjectService projectService;
 
    @Autowired
    private GetShowDictList getShowDictList;
 
    @Autowired
    private WordFileService wordFileService;
 
    @Autowired
    private GetFilesPath getFilesPath;
 
    @Autowired
    private  QaAuditReportIncongruentService incongruentService;
 
    @Autowired
    private WorkflowService workflowService;
 
    @Autowired
    private SysUserService sysUserService;
    /**
     * 分页查询
     *
     * @param queryFilter
     * @return
     */
    public List<QaAuditReport> page(QueryFilter queryFilter) {
        User user = UserContext.getUser();
        Integer secretClass = user.getSecretClass();
        queryFilter.getQueryParams().put("secretClass",secretClass);
        List<QaAuditReport> list = baseDao.getList(queryFilter.getQueryParams());
        if (list != null && list.size() > 0) {
            workflowService.getRunFlow(list, "qashbg");
            sysOssService.setListOsses(list, "qa_audit_report");
        }
        return list;
    }
 
    /**
     * 删除
     *
     * @param ids
     */
    public void delete(Long[] ids) {
        super.deleteLogic(ids);
    }
 
    public QaAuditReportDto getDto(Long projectId, Long reportId) {
        QaAuditReportDto data = new QaAuditReportDto();
        Map<String, String> map = new HashMap<>();
        map.put("contract", "合同评审阶段");
        map.put("require", "测试需求分析与策划阶段");
        map.put("execute", "测试设计、实现与执行阶段");
        map.put("summary", "测试总结阶段");
        if (reportId != null) {
            data.setId(reportId);
            QaAuditReport auditReport = this.get(reportId);
            data.setAuditReport(auditReport);
            if (auditReport != null && projectId == null) {
                projectId = auditReport.getProjectId();
            }
            List<QaAuditReportIncongruent> incongruentList = incongruentService.getList(reportId);
            data.setIncongruentList(incongruentList);
        } else {
            QaAuditReport auditReport = new QaAuditReport();
            data.setAuditReport(auditReport);
            List<QaAuditReportIncongruent> incongruentList = incongruentService.createList(projectId);
            data.setIncongruentList(incongruentList);
        }
        for (QaAuditReportIncongruent incongruent : data.getIncongruentList()) {
            String type = map.get(incongruent.getDiscoveryPhase());
            incongruent.setDiscoveryPhase(type);
        }
        if (projectId != null) {
            data.setProjectId(projectId);
            data.setProject(projectService.get(projectId));
        }
        return data;
    }
 
    public Boolean save(QaAuditReportDto qaAuditReportDto) {
        Long reportId = qaAuditReportDto.getAuditReport().getId();
        if (reportId != null)
            baseDao.updateById(qaAuditReportDto.getAuditReport());
        else {
            Map<String, String> map = new HashMap<>();
            map.put("funCode", "qa_audit_report");
            map.put("projectId", qaAuditReportDto.getProjectId().toString());
            qaAuditReportDto.getAuditReport().setProjectId(qaAuditReportDto.getProjectId());
            qaAuditReportDto.getAuditReport().setCode(sysCodeRuleService.getNewCode(map));
            baseDao.insert(qaAuditReportDto.getAuditReport());
            reportId = qaAuditReportDto.getAuditReport().getId();
        }
 
        for (QaAuditReportIncongruent incongruent : qaAuditReportDto.getIncongruentList()) {
            incongruent.setReportId(reportId);
            if (incongruent.getId() != null) {
                QaAuditReportIncongruent incongruent2 = incongruentService.get(incongruent.getId());
                if (CommonUtils.isActureChangeData(incongruent,incongruent2)) {
                    incongruentService.update(incongruent);
                }
            } else {
                incongruent.setProjectId(qaAuditReportDto.getAuditReport().getProjectId());
                incongruentService.insert(incongruent);
            }
        }
 
        sysOssConfigService.updateOss(qaAuditReportDto.getId(), qaAuditReportDto.getFiles());// 保存附件
        Long bizId = qaAuditReportDto.getAuditReport().getId();
        FlowInfoDto flowInfoDto = qaAuditReportDto.getFlowInfoDto();
 
        if (flowInfoDto != null && flowInfoDto.getSubmitType() != null && "tj,bl".contains(flowInfoDto.getSubmitType())) {
            if ("tj".equals(flowInfoDto.getSubmitType())) {
                workflowService.startFlow(flowInfoDto.getFlowCode(), bizId);
            }
            workflowService.approvePass(flowInfoDto.getFlowCode(), bizId, flowInfoDto.getStepIdMark());
        }
        return true;
    }
 
    public void exportQaReport(Long id, HttpServletRequest request, HttpServletResponse response) {
        try {
            QaAuditReportDto dataObj = this.getDto(null, id);
 
            String projectLeaderId=dataObj.getProject().getProjectLeader();
            String projectConfigerId=dataObj.getProject().getProjectTesters();
            String projectTestersId=dataObj.getProject().getProjectConfiger();
            dataObj.getProject().setProjectLeader(sysUserService.getNames(projectLeaderId));
            dataObj.getProject().setProjectTesters(sysUserService.getNames(projectTestersId));
            dataObj.getProject().setProjectConfiger(sysUserService.getNames(projectConfigerId));
            String CheckerPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getAuditReport().getCheckerId()));
            dataObj.getAuditReport().setChecker(CheckerPath);
            String SupervisorPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getAuditReport().getSupervisorId()));
            dataObj.getAuditReport().setSupervisorSign(SupervisorPath);
 
            WordFile wordFile = new WordFile();
            wordFile.setModulePath("QA审核报告.docx");
            wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_QA审核报告.docx");
            wordFileService.exportWordFile(request, dataObj, wordFile, response);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}