“djh”
4 days ago 9abc6588d464269024d3e680b98cfd71e2acc84e
multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java
@@ -15,6 +15,7 @@
import com.gkhy.exam.system.domain.*;
import com.gkhy.exam.system.mapper.*;
import com.gkhy.exam.system.service.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -53,6 +54,8 @@
    @Autowired
    private ProclaimService proclaimService;
    @Autowired
    private SysCommonService service;
    @Override
    public CommonPage selectStandardizedTemplateList(StandardizedTemplate standardizedTemplate) {
@@ -80,6 +83,32 @@
    public CommonResult insertStandardizedTemplate(StandardizedTemplate standardizedTemplate) {
//        checkPer();
        LoginUserDetails loginUser = SecurityUtils.getLoginUser();
        if (standardizedTemplate.getScope() == 2 && SecurityUtils.adminUser()){
            if (standardizedTemplate.getTemplateType()==1
                || standardizedTemplate.getTemplateType()==2
                || standardizedTemplate.getTemplateType()==3
                || standardizedTemplate.getTemplateType()==10
                || standardizedTemplate.getTemplateType()==11){
                List<SysCompany> sysCompanies = sysCompanyService.selectCompanyLists();
                List<StandardizedTemplate> standardizedTemplates = new ArrayList<>();
                for (SysCompany sysCompany : sysCompanies) {
                    StandardizedTemplate standardizedTemplate1 = new StandardizedTemplate();
                    BeanUtils.copyProperties(standardizedTemplate,standardizedTemplate1);
                    standardizedTemplate1.setCompanyId(Math.toIntExact(sysCompany.getId()));
                    standardizedTemplate1.setCompanyName(sysCompany.getName());
                    standardizedTemplate1.setCreateBy(loginUser.getUsername());
                    standardizedTemplate1.setCreateTime(LocalDateTime.now());
                    standardizedTemplates.add(standardizedTemplate1);
                    standardizedTemplate1.setFilePath(service.copyFileWithCompanyId(standardizedTemplate.getFilePath(),sysCompany.getId()));
                }
                int update = standardizedTemplateMapper.insertBatch(standardizedTemplates);
                if (update > 0) {
                    return CommonResult.success();
                }
                return CommonResult.failed();
            }
        }
        SysCompany sysCompany = sysCompanyService.selectCompanyById(standardizedTemplate.getCompanyId().longValue());
        standardizedTemplate.setCompanyName(sysCompany.getName());