heheng
5 days ago 3134991a6c9315421ff3d4b3b4f1bd76bb5dbdc9
multi-system/src/main/java/com/gkhy/exam/system/service/impl/StandardizedTemplateServiceImpl.java
@@ -2,7 +2,6 @@
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.api.CommonPage;
@@ -16,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;
@@ -51,6 +51,12 @@
    @Autowired
    private ProductServiceMapper productServiceMapper;
    @Autowired
    private ProclaimService proclaimService;
    @Autowired
    private SysCommonService service;
    @Override
    public CommonPage selectStandardizedTemplateList(StandardizedTemplate standardizedTemplate) {
        boolean admin = SecurityUtils.adminUser();
@@ -75,8 +81,34 @@
    @Override
    public CommonResult insertStandardizedTemplate(StandardizedTemplate standardizedTemplate) {
        checkPer();
//        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());
@@ -100,7 +132,7 @@
    @Override
    public CommonResult updateStandardizedTemplate(StandardizedTemplate standardizedTemplate) {
        checkPer();
//        checkPer();
        LoginUserDetails loginUser = SecurityUtils.getLoginUser();
        SysCompany sysCompany = sysCompanyService.selectCompanyById(standardizedTemplate.getCompanyId().longValue());
        standardizedTemplate.setCompanyName(sysCompany.getName());
@@ -115,7 +147,7 @@
    @Override
    public CommonResult deletedStandardizedTemplate(Integer standardizedTemplateId) {
        checkPer();
//        checkPer();
        StandardizedTemplate standardizedTemplate = new StandardizedTemplate();
        LoginUserDetails loginUser = SecurityUtils.getLoginUser();
        standardizedTemplate.setUpdateBy(loginUser.getUsername());
@@ -130,7 +162,7 @@
    }
    private void checkPer(){
        boolean admin = SecurityUtils.adminUser();
        boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
        if (!admin) {
            throw new ApiException("非管理员不可操作");
        }
@@ -209,11 +241,15 @@
        //部门
        SysDept sysDept = new SysDept();
        sysDept.setCompanyId(companyId.longValue());
        sysDept.setResponsType("1");
//        sysDept.setResponsType("1");
        List<TreeSelect> treeSelects = iSysDeptService.selectDeptTreeList(sysDept);
        //公司概况
        List<CompanySummary> companySummaries = companySummaryMapper.selectCompanySummaryList(companyId);
        List<Proclaim> proclaims = proclaimService.selectProclaimByCompanyId(companyId);
        map.put("proclaim",proclaims);
        //质量方针
        List<CompanyQualityPolicy> companyQualityPolicies = companyQualityPolicyMapper.selectCompanyQualityPolicyList(companyId);
@@ -248,4 +284,13 @@
        }
        return CommonResult.success(map);
    }
    @Override
    public CommonResult topStandardizedTemplate(Integer id) {
        StandardizedTemplate standardizedTemplate = new StandardizedTemplate();
        standardizedTemplate.setId(id);
        standardizedTemplate.setTopTime(LocalDateTime.now());
        standardizedTemplateMapper.updateById(standardizedTemplate);
        return CommonResult.success();
    }
}