6
jinlin
2023-11-29 d89ef43c4713adf26f74b796653d1dd15ff1f81a
modules/mainPart/src/main/java/com/zt/life/modules/project/service/EnvironService.java
@@ -2,12 +2,13 @@
import com.zt.common.service.BaseService;
import com.zt.life.modules.project.dao.EnvironDao;
import com.zt.life.modules.project.dto.SoftwareTestOrderDto;
import com.zt.life.modules.project.dto.EnvironDto;
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.service.SysOssConfigService;
import com.zt.modules.coderule.service.SysCodeRuleService;
import com.zt.modules.oss.service.SysOssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zt.common.db.query.QueryFilter;
@@ -50,9 +51,12 @@
    @Autowired
    private TestAgencyInfoService testAgencyInfoService;
    @Autowired
    private SysOssService sysOssService;
    public SoftwareTestOrderDto getDto(Long environId, Long projectId) {
        SoftwareTestOrderDto data = new SoftwareTestOrderDto();
    public EnvironDto getDto(Long environId, Long projectId) {
        EnvironDto data = new EnvironDto();
        if (environId != null) {
            Environ environ = this.get(environId);
            data.setEnviron(environ);
@@ -100,25 +104,25 @@
        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);
@@ -130,7 +134,7 @@
            }
        }
        i = 0;
        for (EnvironHardwareResources environHardwareResources : softwareTestOrderDto.getHardwareResourcesList()) {
        for (EnvironHardwareResources environHardwareResources : environDto.getHardwareResourcesList()) {
            environHardwareResources.setEnvironId(environId);
            if (environHardwareResources.getId() != null) {
                environHardwareResourcesService.update(environHardwareResources);
@@ -143,7 +147,7 @@
        }
        i = 0;
        for (EnvironAnalysis environAnalysis : softwareTestOrderDto.getEnvironAnalysisList()) {
        for (EnvironAnalysis environAnalysis : environDto.getEnvironAnalysisList()) {
            environAnalysis.setEnvironId(environId);
            if (environAnalysis.getId() != null) {
                environAnalysisService.update(environAnalysis);
@@ -154,13 +158,13 @@
                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());// 保存附件
        return true;
    }
}