| | |
| | | package com.zt.life.modules.project.service; |
| | | |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.core.context.User; |
| | | import com.zt.core.context.UserContext; |
| | | 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.contractReview.model.ContractReview; |
| | | import com.zt.life.modules.mainPart.utils.GetFilesPath; |
| | | 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 TestAgencyInfoService testAgencyInfoService; |
| | | |
| | | @Autowired |
| | | private SysOssService sysOssService; |
| | | |
| | | public SoftwareTestOrderDto getDto(Long environId, Long projectId) { |
| | | SoftwareTestOrderDto data = new SoftwareTestOrderDto(); |
| | | @Autowired |
| | | private GetFilesPath getFilesPath; |
| | | |
| | | @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)); |
| | |
| | | List<EnvironAnalysis> environAnalysesList = environAnalysisService.getList(environId); |
| | | data.setEnvironAnalysisList(environAnalysesList); |
| | | } else { |
| | | Environ environ =new Environ(); |
| | | Environ environ = new Environ(); |
| | | data.setEnviron(environ); |
| | | } |
| | | if (projectId != null) { |
| | |
| | | } |
| | | if (data.getTestAgencyInfo() == null) |
| | | data.setTestAgencyInfo(testAgencyInfoService.get(10000L)); |
| | | if (environId != null) { |
| | | OssDto ossDto1 = sysOssConfigService.getOssByBusiType(environId, "test_environ_diagram"); |
| | | OssDto ossDto2 = sysOssConfigService.getOssByBusiType(environId, "test_environ"); |
| | | if (ossDto1 != null ) { |
| | | data.setFiles(ossDto1); |
| | | } |
| | | if (ossDto2 != null){ |
| | | data.setFiles2(ossDto2); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public List<Environ> page(QueryFilter queryFilter) { |
| | | return baseDao.getList(queryFilter.getQueryParams()); |
| | | User user = UserContext.getUser(); |
| | | Integer secretClass = user.getSecretClass(); |
| | | queryFilter.getQueryParams().put("secretClass",secretClass); |
| | | List<Environ> list = baseDao.getList(queryFilter.getQueryParams()); |
| | | if (list.size() > 0) { |
| | | sysOssService.setListOsses(list, "test_environ"); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | super.deleteLogic(ids); |
| | | } |
| | | |
| | | public Boolean save(SoftwareTestOrderDto softwareTestOrderDto) { |
| | | Long environId = softwareTestOrderDto.getEnviron().getId(); |
| | | public Boolean save(EnvironDto environDto) { |
| | | Long environId = environDto.getEnviron().getId(); |
| | | if (environId != null) |
| | | baseDao.updateById(softwareTestOrderDto.getEnviron()); |
| | | baseDao.updateById(environDto.getEnviron()); |
| | | else { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
| | | String year = sdf.format(new Date()); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("funCode", "environ"); |
| | | map.put("year",year); |
| | | softwareTestOrderDto.getEnviron().setYear(year); |
| | | softwareTestOrderDto.getEnviron().setProjectId(softwareTestOrderDto.getProjectId()); |
| | | softwareTestOrderDto.getEnviron().setCode(sysCodeRuleService.getNewCode(map)); |
| | | baseDao.insert(softwareTestOrderDto.getEnviron()); |
| | | environId = softwareTestOrderDto.getEnviron().getId(); |
| | | map.put("projectId", environDto.getProjectId().toString()); |
| | | environDto.getEnviron().setYear(year); |
| | | environDto.getEnviron().setProjectId(environDto.getProjectId()); |
| | | environDto.getEnviron().setCode(sysCodeRuleService.getNewCode(map)); |
| | | baseDao.insert(environDto.getEnviron()); |
| | | environId = environDto.getEnviron().getId(); |
| | | } |
| | | |
| | | int i = 0; |
| | | for (EnvironSoftwareResources environSoftwareResources : softwareTestOrderDto.getSoftwareResourcesList()) { |
| | | for (EnvironSoftwareResources environSoftwareResources : environDto.getSoftwareResourcesList()) { |
| | | environSoftwareResources.setEnvironId(environId); |
| | | if (environSoftwareResources.getId() != null) { |
| | | environSoftwareResourcesService.update(environSoftwareResources); |
| | |
| | | } |
| | | } |
| | | i = 0; |
| | | for (EnvironHardwareResources environHardwareResources : softwareTestOrderDto.getHardwareResourcesList()) { |
| | | for (EnvironHardwareResources environHardwareResources : environDto.getHardwareResourcesList()) { |
| | | environHardwareResources.setEnvironId(environId); |
| | | if (environHardwareResources.getId() != null) { |
| | | environHardwareResourcesService.update(environHardwareResources); |
| | |
| | | } |
| | | |
| | | i = 0; |
| | | for (EnvironAnalysis environAnalysis : softwareTestOrderDto.getEnvironAnalysisList()) { |
| | | for (EnvironAnalysis environAnalysis : environDto.getEnvironAnalysisList()) { |
| | | environAnalysis.setEnvironId(environId); |
| | | if (environAnalysis.getId() != null) { |
| | | environAnalysisService.update(environAnalysis); |
| | |
| | | environAnalysisService.insert(environAnalysis); |
| | | } |
| | | } |
| | | if (softwareTestOrderDto.getTestAgencyInfo().getId() == 10000) { |
| | | softwareTestOrderDto.getTestAgencyInfo().setId(environId); |
| | | testAgencyInfoService.insert(softwareTestOrderDto.getTestAgencyInfo()); |
| | | if (environDto.getTestAgencyInfo().getId() == 10000) { |
| | | environDto.getTestAgencyInfo().setId(environId); |
| | | testAgencyInfoService.insert(environDto.getTestAgencyInfo()); |
| | | } else { |
| | | testAgencyInfoService.update(softwareTestOrderDto.getTestAgencyInfo()); |
| | | testAgencyInfoService.update(environDto.getTestAgencyInfo()); |
| | | } |
| | | sysOssConfigService.updateOss(softwareTestOrderDto.getEnviron().getId(), softwareTestOrderDto.getFiles());// 保存附件 |
| | | sysOssConfigService.updateOss(environDto.getEnviron().getId(), environDto.getFiles());// 保存附件 |
| | | sysOssConfigService.updateOss(environDto.getEnviron().getId(), environDto.getFiles2());// 保存附件 |
| | | return true; |
| | | } |
| | | |
| | | public void exportEnviron(Long id, HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | EnvironDto dataObj = this.getDto(id, null); |
| | | String imagePath = "文件图片:"+getFilesPath.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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |