|
@@ -69,7 +69,11 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public R importExcel(MultipartFile file,String binSection) {
|
|
|
+ public R importExcel(MultipartFile file, String binSection, String year) {
|
|
|
+ String binName = null;
|
|
|
+ List<BinSection> binSec = CacheContext.bsnList.stream().filter(bin -> binSection.equals(bin.getSectionCode())).collect(Collectors.toList());
|
|
|
+ binName = binSec.get(0).getSectionName();
|
|
|
+
|
|
|
if (file.isEmpty()) {
|
|
|
return R.error("上传文件为空!");
|
|
|
}
|
|
@@ -85,16 +89,19 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
List<OrganizationRating> orgList = new ArrayList<>();
|
|
|
//Excel导入导出的单元类
|
|
|
List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
|
|
|
- List<String> ids = strings.stream().map(row -> row[row.length - 1]).collect(Collectors.toList());
|
|
|
- List<OrganizationRating> organizationRatings = baseMapper.selectBatchIds(ids);
|
|
|
- savePortal(organizationRatings);
|
|
|
- if (!binSection.equals(organizationRatings.get(0).getBinSection())) {
|
|
|
- return R.error("请导入" + binSection + "的数据");
|
|
|
- }
|
|
|
+ Page<OrganizationRating> page = new Page<>(1, 10000);
|
|
|
+ IPage<OrganizationRating> organizationRatingIPage = baseMapper.selectList(page, null, null, binSection, null, null, null, null, null, null, null, null, null, null, null);
|
|
|
+ List<OrganizationRating> orgRatings = organizationRatingIPage.getRecords().stream().filter(org -> binSection.equals(org.getBinSection()) && year.equals(org.getYear())).collect(Collectors.toList());
|
|
|
//遍历Excel表每一行的数据
|
|
|
for (String[] str : strings) {
|
|
|
- for (OrganizationRating or : organizationRatings) {
|
|
|
- if (str[0].equals(or.getOrganizationShortName())&&str[2].equals(or.getYear())) {
|
|
|
+ if (!str[1].equals(binName)) {
|
|
|
+ return R.error("请导入" + binSection + "的数据");
|
|
|
+ }
|
|
|
+ if (!str[2].equals(orgRatings.get(0).getYear())) {
|
|
|
+ return R.error("请导入" + year + "年的数据");
|
|
|
+ }
|
|
|
+ for (OrganizationRating or : orgRatings) {
|
|
|
+ if (str[0].equals(or.getOrganizationShortName()) && str[2].equals(or.getYear())) {
|
|
|
or.setSafetyEnvProtection(str[3]);
|
|
|
or.setVeto(str[4]);
|
|
|
or.setNetProfit(str[5]);
|