multi-system/src/main/java/com/gkhy/exam/system/domain/StandardizedTemplate.java
@@ -100,4 +100,9 @@ @TableField("top_time") private LocalDateTime topTime; @ApiModelProperty(value = "范围1单个,2全部") @TableField(exist = false) private Integer scope; } multi-system/src/main/java/com/gkhy/exam/system/mapper/StandardizedTemplateMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.gkhy.exam.system.domain.StandardizedTemplate; import org.apache.ibatis.annotations.Param; import org.mapstruct.Mapper; import java.util.List; @@ -19,4 +20,7 @@ List<StandardizedTemplate> selectStandardizedTemplateListV2(StandardizedTemplate template); int updateStandardizedTemplateById(StandardizedTemplate template); int insertBatch(@Param("standardizedTemplates") List<StandardizedTemplate> standardizedTemplates); } 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()); multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysCommonServiceImpl.java
@@ -109,8 +109,15 @@ log.error("文件复制失败: {}", e.getMessage()); throw new ApiException("文件复制失败,请联系管理员"); } // 6. 返回新文件路径 return targetFilePath.replace("\\", "/"); String standardizedUploadPath = uploadPath.endsWith("/") || uploadPath.endsWith("\\") ? uploadPath.substring(0, uploadPath.length() - 1) : uploadPath; // 6.2 拼接相对路径(统一用/分隔,格式:uploadPath/dateStr/newFileName) String relativeFilePath = standardizedUploadPath + "/" + dateStr + "/" + newFileName; // 7. 返回相对路径(替换原来的绝对路径) return relativeFilePath; } multi-system/src/main/resources/mapper/system/StandardizedTemplateMapper.xml
@@ -1,6 +1,41 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.gkhy.exam.system.mapper.StandardizedTemplateMapper"> <insert id="insertBatch"> INSERT INTO `standardized_template` ( `company_id`, `company_name`, `create_by`, `create_time`, `template_name`, `template_type`, `file_path`, `format`, `classify`, `dept_id`, `industry_type_id`, `stage`, `department` ) VALUES <foreach collection="standardizedTemplates" item="item" separator=","> ( #{item.companyId}, #{item.companyName}, #{item.createBy}, #{item.createTime}, #{item.templateName}, #{item.templateType}, #{item.filePath}, #{item.format}, #{item.classify}, #{item.deptId}, #{item.industryTypeId}, #{item.stage}, #{item.department} ) </foreach> </insert> <update id="updateStandardizedTemplateById" parameterType="com.gkhy.exam.system.domain.StandardizedTemplate"> UPDATE standardized_template <set>