| | |
| | | package com.zt.life.modules.project.service; |
| | | |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.core.sys.dto.DictDto; |
| | | import com.zt.core.sys.dto.DictItemDto; |
| | | import com.zt.core.sys.dto.DictLeafDto; |
| | | import com.zt.life.export.dto.WordFile; |
| | | import com.zt.life.export.service.WordFileService; |
| | | import com.zt.life.modules.mainPart.utils.GetShowDictList; |
| | | import com.zt.life.modules.project.dao.EnvironDao; |
| | | import com.zt.life.modules.project.dto.EnvironDto; |
| | | import com.zt.life.modules.project.dto.SoftwareTestOrderDto; |
| | | import com.zt.life.modules.project.model.*; |
| | | import com.zt.life.modules.sysBaseInfo.model.TestAgencyInfo; |
| | | import com.zt.life.modules.sysBaseInfo.service.TestAgencyInfoService; |
| | | 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.cloud.LocalStorageService; |
| | | import com.zt.modules.oss.model.SysOss; |
| | | import com.zt.modules.oss.service.SysOssService; |
| | | import com.zt.modules.sys.service.SysDictTypeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | 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.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | private EnvironHardwareResourcesService environHardwareResourcesService; |
| | | |
| | | @Autowired |
| | | private SoftwareTestOrderService softwareTestOrderService; |
| | | private GetShowDictList getShowDictList; |
| | | |
| | | @Autowired |
| | | private WordFileService wordFileService; |
| | | |
| | | @Autowired |
| | | private SysCodeRuleService sysCodeRuleService; |
| | |
| | | @Autowired |
| | | private SysOssService sysOssService; |
| | | |
| | | @Autowired |
| | | private LocalStorageService localStorageService; |
| | | |
| | | @Value("${zt.oss.local-path}") |
| | | private String localPath; |
| | | |
| | | public EnvironDto getDto(Long environId, Long projectId) { |
| | | EnvironDto data = new EnvironDto(); |
| | | if (environId != null) { |
| | | data.setId(environId); |
| | | Environ environ = this.get(environId); |
| | | data.setEnviron(environ); |
| | | data.setTestAgencyInfo(testAgencyInfoService.get(environId)); |
| | |
| | | } |
| | | if (data.getTestAgencyInfo() == null) |
| | | data.setTestAgencyInfo(testAgencyInfoService.get(10000L)); |
| | | if (environId != null) { |
| | | OssDto ossDto = sysOssConfigService.getOssByBusiType(environId, "test_environt_diagram"); |
| | | if (ossDto != null) { |
| | | data.setFiles(ossDto); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | |
| | | sysOssConfigService.updateOss(environDto.getEnviron().getId(), environDto.getFiles());// 保存附件 |
| | | return true; |
| | | } |
| | | |
| | | public void exportEnviron(Long id, HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | EnvironDto dataObj = this.getDto(id, null); |
| | | String imagePath = "文件图片:"+getFirstImagePath(dataObj.getFiles()); |
| | | dataObj.getEnviron().setTestEnvirontDiagram(imagePath); |
| | | //通用字典列表字符串生成 |
| | | String isVirusScanStr = getShowDictList.getShowDictList(dataObj.getEnviron().getIsVirusScan(), "is_or_not", false); |
| | | dataObj.getEnviron().setIsVirusScanStr(isVirusScanStr); |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | public String getFirstImagePath(OssDto oss) { |
| | | String filePath = ""; |
| | | if (oss != null) { |
| | | if (oss.getGroups().size() > 0) { |
| | | OssDto.OssFieldGroupDto group = oss.getGroups().get(0); |
| | | if (group.getFields().size() > 0) { |
| | | OssDto.OssFieldDto field = group.getFields().get(0); |
| | | if (field.getFiles().size() > 0) { |
| | | com.zt.core.oss.dto.OssDto file = field.getFiles().get(0); |
| | | SysOss sysOss = sysOssService.get(file.getId()); |
| | | filePath = localPath+sysOss.getPath(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return filePath; |
| | | } |
| | | } |