fix: 年度计划导入BUG

This commit is contained in:
2024-01-08 17:06:20 +08:00
parent 0dd818017a
commit d106d3908d
5 changed files with 20 additions and 13 deletions
@@ -667,7 +667,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
String enNameCode = plan.getEnNameCode(); String enNameCode = plan.getEnNameCode();
String standardCategoryCode = plan.getStandardCategoryCode(); String standardCategoryCode = plan.getStandardCategoryCode();
// 检查企标编号是否有效 // 检查企标编号是否有效
if (StrUtil.isBlank(originEnStandardNo)) { if (StrUtil.isBlank(enStandardCode)) {
errMsg.append("'企业标准代号'不能为空。"); errMsg.append("'企业标准代号'不能为空。");
} else { } else {
// 检查企业标准代号 // 检查企业标准代号
@@ -675,7 +675,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
errMsg.append("'企业标准代号'无效。"); errMsg.append("'企业标准代号'无效。");
} }
} }
if (StrUtil.isBlank(originEnStandardNo)) { if (StrUtil.isBlank(enNameCode)) {
errMsg.append("'企业名称代号'不能为空。"); errMsg.append("'企业名称代号'不能为空。");
} else { } else {
// 检查企业标准代号 // 检查企业标准代号
@@ -683,7 +683,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
errMsg.append("'企业名称代号'无效。"); errMsg.append("'企业名称代号'无效。");
} }
} }
if (StrUtil.isBlank(originEnStandardNo)) { if (StrUtil.isBlank(standardCategoryCode)) {
errMsg.append("'标准类别代号'不能为空。"); errMsg.append("'标准类别代号'不能为空。");
} else { } else {
// 检查企业标准代号 // 检查企业标准代号
@@ -692,9 +692,7 @@ public class ProcessEsAnnualInitServiceImpl extends ServiceImpl<ProcessEsAnnualI
} }
} }
} }
if (newEnStandardName.length() > 50) { errMsg.append(excelUtils.validStandardName(newEnStandardName));
errMsg.append("'新企标名称'过长(最多50字)。");
}
return errMsg.toString(); return errMsg.toString();
} }
} }
@@ -503,7 +503,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
String enNameCode = plan.getEnNameCode(); String enNameCode = plan.getEnNameCode();
String standardCategoryCode = plan.getStandardCategoryCode(); String standardCategoryCode = plan.getStandardCategoryCode();
// 检查企标编号是否有效 // 检查企标编号是否有效
if (StrUtil.isBlank(originEnStandardNo)) { if (StrUtil.isBlank(enStandardCode)) {
errMsg.append("'企业标准代号'不能为空。"); errMsg.append("'企业标准代号'不能为空。");
} else { } else {
// 检查企业标准代号 // 检查企业标准代号
@@ -511,7 +511,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
errMsg.append("'企业标准代号'无效。"); errMsg.append("'企业标准代号'无效。");
} }
} }
if (StrUtil.isBlank(originEnStandardNo)) { if (StrUtil.isBlank(enNameCode)) {
errMsg.append("'企业名称代号'不能为空。"); errMsg.append("'企业名称代号'不能为空。");
} else { } else {
// 检查企业标准代号 // 检查企业标准代号
@@ -519,7 +519,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
errMsg.append("'企业名称代号'无效。"); errMsg.append("'企业名称代号'无效。");
} }
} }
if (StrUtil.isBlank(originEnStandardNo)) { if (StrUtil.isBlank(standardCategoryCode)) {
errMsg.append("'标准类别代号'不能为空。"); errMsg.append("'标准类别代号'不能为空。");
} else { } else {
// 检查企业标准代号 // 检查企业标准代号
@@ -528,9 +528,7 @@ public class ProcessEsAnnualReportServiceImpl extends ServiceImpl<ProcessEsAnnua
} }
} }
} }
if (newEnStandardName.length() > 50) { errMsg.append(excelUtils.validStandardName(newEnStandardName));
errMsg.append("'新企标名称'过长(最多50字)。");
}
return errMsg.toString(); return errMsg.toString();
} }
} }
@@ -10,6 +10,7 @@ import com.jero.modules.laws.common.util.ImportUtil;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard; import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService; import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.system.entity.SysDictItem; import com.jero.modules.system.entity.SysDictItem;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
@@ -77,7 +78,7 @@ public class ExcelUtils {
public static List<String> getHeaderFromExcel(InputStream is, Integer index) throws Exception { public static List<String> getHeaderFromExcel(InputStream is, Integer index) throws Exception {
List<String> headers = new ArrayList<>(); List<String> headers = new ArrayList<>();
Workbook workbook = new XSSFWorkbook(is); Workbook workbook = new HSSFWorkbook(is);
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
// HeadRow在index 1 // HeadRow在index 1
@@ -403,4 +404,14 @@ public class ExcelUtils {
} }
return ""; return "";
} }
public String validStandardName(String value) {
if (StrUtil.isBlank(value)) {
return "新企标名称不能为空";
}
if (value.length() > 50) {
return "'新企标名称'过长(最多50字)。";
}
return "";
}
} }