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();
|
}
|
}
|
}
|