fix(自定义对比): 保存问题修复
This commit is contained in:
+2
-2
@@ -154,8 +154,8 @@ public class LawsCustomCompareInfoController {
|
||||
*/
|
||||
@AutoLog(value = "自定义对比-标准检索保存")
|
||||
@ApiOperation(value="自定义对比-标准检索保存", notes="自定义对比-标准检索保存")
|
||||
@GetMapping(value = "/saveStandard")
|
||||
public Result<IPage<StandardVO>> saveStandard(StandardSaveVO standardSaveVO) {
|
||||
@PostMapping(value = "/saveStandard")
|
||||
public Result<IPage<StandardVO>> saveStandard(@RequestBody StandardSaveVO standardSaveVO) {
|
||||
lawsCustomCompareInfoService.saveStandard(standardSaveVO);
|
||||
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public interface LawsCustomCompareInfoMapper extends BaseMapper<LawsCustomCompar
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
List<StandardVO> queryStandardList(QueryWrapper<StandardVO> queryWrapper);
|
||||
List<StandardVO> queryStandardList(@Param(Constants.WRAPPER) QueryWrapper<StandardVO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 自定义对比-自定义对比-通过id查询
|
||||
|
||||
+66
-44
@@ -9,10 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.BeanCopyUtils;
|
||||
import com.jero.common.util.FileUtils;
|
||||
import com.jero.common.util.SnowflakeUtils;
|
||||
import com.jero.common.util.ZipUtil;
|
||||
import com.jero.common.util.*;
|
||||
import com.jero.modules.laws.customcompare.common.LawsCustomCompareCommon;
|
||||
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareCell;
|
||||
import com.jero.modules.laws.customcompare.entity.LawsCustomCompareInfo;
|
||||
@@ -33,6 +30,8 @@ import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
|
||||
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
||||
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
||||
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.system.entity.SysDict;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
@@ -53,6 +52,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -75,6 +75,7 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
private final ILawsEnterpriseStandardService lawsEnterpriseStandardService;
|
||||
private final ISysDictService sysDictService;
|
||||
private final ISysDictItemService sysDictItemService;
|
||||
private final IOSSFileService iossFileService;
|
||||
public static final String STANDARD_NUMBER = "standard_number";
|
||||
|
||||
public LawsCustomCompareInfoServiceImpl(LawsCustomCompareInfoMapper lawsCustomCompareInfoMapper,
|
||||
@@ -85,7 +86,7 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
ILawsOverseasStandardService lawsOverseasStandardService,
|
||||
ILawsEnterpriseStandardService lawsEnterpriseStandardService,
|
||||
ISysDictService sysDictService,
|
||||
ISysDictItemService sysDictItemService) {
|
||||
ISysDictItemService sysDictItemService, IOSSFileService iossFileService) {
|
||||
this.lawsCustomCompareInfoMapper = lawsCustomCompareInfoMapper;
|
||||
this.lawsCustomCompareInfoStandardService = lawsCustomCompareInfoStandardService;
|
||||
this.lawsCustomCompareInventoryService = lawsCustomCompareInventoryService;
|
||||
@@ -95,6 +96,7 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
this.lawsEnterpriseStandardService = lawsEnterpriseStandardService;
|
||||
this.sysDictService = sysDictService;
|
||||
this.sysDictItemService = sysDictItemService;
|
||||
this.iossFileService = iossFileService;
|
||||
}
|
||||
|
||||
@Value("${jero.path.exportExcelTempPath}")
|
||||
@@ -144,7 +146,7 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
queryWrapper.in("id", list);
|
||||
}
|
||||
if(StringUtils.isNotBlank(standardVO.getStandardNumbers())){
|
||||
List<String> list = Arrays.asList(standardVO.getStandardNumber().split(","));
|
||||
List<String> list = Arrays.asList(standardVO.getStandardNumbers().split(","));
|
||||
queryWrapper.in(STANDARD_NUMBER, list);
|
||||
}
|
||||
queryWrapper.eq(StringUtils.isNotBlank(standardVO.getStandardNumber()), STANDARD_NUMBER, standardVO.getStandardNumber());
|
||||
@@ -182,45 +184,40 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
saveOrUpdate(lawsCustomCompareInfo);
|
||||
|
||||
// 处理自定义对比_标准 关联表
|
||||
if (StringUtils.isBlank(standardSaveVO.getStandardNumber())){
|
||||
// 删除数据
|
||||
lawsCustomCompareInfoStandardService.remove(
|
||||
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
|
||||
.eq(LawsCustomCompareInfoStandard::getInfoId, lawsCustomCompareInfo.getId()));
|
||||
// 自定义对比单元格数据 删除
|
||||
lawsCustomCompareCellService.remove(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId()));
|
||||
}else {
|
||||
// 更新数据
|
||||
StandardVO standardVO = new StandardVO();
|
||||
standardVO.setStandardNumbers(standardSaveVO.getStandardNumber());
|
||||
List<StandardVO> standardVOS = queryStandardList(standardVO);
|
||||
List<LawsCustomCompareInfoStandard> lawsCustomCompareInfoStandards = BeanCopyUtils.copyBeanList(standardVOS, LawsCustomCompareInfoStandard.class);
|
||||
for (LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard : lawsCustomCompareInfoStandards) {
|
||||
String snowflakeId = String.valueOf(SnowflakeUtils.snowflake());
|
||||
// 自定义对比单元格数据更新
|
||||
lawsCustomCompareCellService.update(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId())
|
||||
.eq(LawsCustomCompareCell::getStandardId, lawsCustomCompareInfoStandard.getId())
|
||||
.set(LawsCustomCompareCell::getStandardId, snowflakeId));
|
||||
|
||||
lawsCustomCompareInfoStandard.setId(snowflakeId);
|
||||
lawsCustomCompareInfoStandard.setCreateBy("");
|
||||
lawsCustomCompareInfoStandard.setCreateTime(null);
|
||||
lawsCustomCompareInfoStandard.setUpdateBy("");
|
||||
lawsCustomCompareInfoStandard.setUpdateTime(null);
|
||||
lawsCustomCompareInfoStandardService.save(lawsCustomCompareInfoStandard);
|
||||
}
|
||||
|
||||
// 自定义对比单元格 删除
|
||||
String ids = standardVOS.stream().map(StandardVO::getId).collect(Collectors.joining(","));
|
||||
lawsCustomCompareCellService.remove(
|
||||
// 删除数据
|
||||
lawsCustomCompareInfoStandardService.remove(
|
||||
new LambdaQueryWrapper<LawsCustomCompareInfoStandard>()
|
||||
.eq(LawsCustomCompareInfoStandard::getInfoId, lawsCustomCompareInfo.getId()));
|
||||
// 更新数据
|
||||
StandardVO standardVO = new StandardVO();
|
||||
standardVO.setStandardNumbers(standardSaveVO.getStandardNumber());
|
||||
List<StandardVO> standardVOS = queryStandardList(standardVO);
|
||||
List<LawsCustomCompareInfoStandard> lawsCustomCompareInfoStandards = BeanCopyUtils.copyBeanList(standardVOS, LawsCustomCompareInfoStandard.class);
|
||||
for (LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard : lawsCustomCompareInfoStandards) {
|
||||
String snowflakeId = String.valueOf(SnowflakeUtils.snowflake());
|
||||
// 自定义对比单元格数据更新
|
||||
lawsCustomCompareCellService.update(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId())
|
||||
.notIn(LawsCustomCompareCell::getStandardId, ids));
|
||||
.eq(LawsCustomCompareCell::getStandardId, lawsCustomCompareInfoStandard.getId())
|
||||
.set(LawsCustomCompareCell::getStandardId, snowflakeId));
|
||||
|
||||
lawsCustomCompareInfoStandard.setId(snowflakeId);
|
||||
lawsCustomCompareInfoStandard.setInfoId(lawsCustomCompareInfo.getId());
|
||||
lawsCustomCompareInfoStandard.setStandardId(lawsCustomCompareInfoStandard.getId());
|
||||
lawsCustomCompareInfoStandard.setCreateBy("");
|
||||
lawsCustomCompareInfoStandard.setCreateTime(null);
|
||||
lawsCustomCompareInfoStandard.setUpdateBy("");
|
||||
lawsCustomCompareInfoStandard.setUpdateTime(null);
|
||||
lawsCustomCompareInfoStandardService.save(lawsCustomCompareInfoStandard);
|
||||
}
|
||||
|
||||
// 自定义对比单元格 删除
|
||||
String ids = standardVOS.stream().map(StandardVO::getId).collect(Collectors.joining(","));
|
||||
lawsCustomCompareCellService.remove(
|
||||
new LambdaUpdateWrapper<LawsCustomCompareCell>()
|
||||
.eq(LawsCustomCompareCell::getInfoId, lawsCustomCompareInfo.getId())
|
||||
.notIn(LawsCustomCompareCell::getStandardId, ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -351,7 +348,6 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
|
||||
// 创建表头内容
|
||||
createTableHeader(sheet, countryMap, featureList, cellStyle);
|
||||
// 创建第二行内容
|
||||
@@ -452,13 +448,39 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
|
||||
&& Objects.equals(standardVO.getId(), v.getStandardId())
|
||||
&& Objects.equals(compareList.get(finalI - 3).getId(), v.getCompareItemId()))
|
||||
.findFirst();
|
||||
cellOptional.ifPresent(v -> cell.setCellValue(v.getContent()));
|
||||
cellOptional.ifPresent(v -> {
|
||||
cell.setCellValue(v.getContent());
|
||||
// 处理文件
|
||||
writeFile(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFile(LawsCustomCompareCell v) {
|
||||
if (StringUtils.isNotBlank(v.getFileId())){
|
||||
OSSFile ossFile = iossFileService.getById(v.getFileId());
|
||||
InputStream download = MinioUtil.download(ossFile.getUrl());
|
||||
inputStreamToFile(download, exportExcelTempPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void inputStreamToFile (InputStream inputStream, String filePath) {
|
||||
File file = new File(filePath);
|
||||
try (FileOutputStream outputStream = new FileOutputStream(file)){
|
||||
int bytesRead;
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JeroBootException("生成文件失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* private static void createOrdinaryColumn(List<StandardVO> standardVOS, List<LawsCustomCompareInventory> featureList, List<LawsCustomCompareInventory> compareList, List<LawsCustomCompareCell> list, int i, Row indexRow, Cell indexCell) {
|
||||
|
||||
Reference in New Issue
Block a user