优化代码
This commit is contained in:
parent
d063bedba4
commit
049ebd0d6f
|
|
@ -3,6 +3,7 @@ package com.electromagnetic.industry.software.manage.controller;
|
||||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.AddImportTableDataDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.AddImportTableDataDTO;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateImportTableDataDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.UpdateImportTableDataDTO;
|
||||||
import com.electromagnetic.industry.software.manage.service.ImportTableService;
|
import com.electromagnetic.industry.software.manage.service.ImportTableService;
|
||||||
|
|
@ -23,13 +24,14 @@ public class ImportTableController {
|
||||||
public ElectromagneticResult<?> query(@RequestParam String tableInfoId, @RequestParam Integer pageSize, @RequestParam Integer pageNum) {
|
public ElectromagneticResult<?> query(@RequestParam String tableInfoId, @RequestParam Integer pageSize, @RequestParam Integer pageNum) {
|
||||||
pageNum = Optional.ofNullable(pageNum).orElse(1);
|
pageNum = Optional.ofNullable(pageNum).orElse(1);
|
||||||
pageSize = Optional.ofNullable(pageSize).orElse(10);
|
pageSize = Optional.ofNullable(pageSize).orElse(10);
|
||||||
return importTableService.selectTableDataByTableInfoId(pageNum, pageSize, tableInfoId);
|
return ElectromagneticResultUtil.success(importTableService.selectTableDataByTableInfoId(pageNum, pageSize, tableInfoId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@UserOperation(value = "新增结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
@UserOperation(value = "新增结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
||||||
public ElectromagneticResult<?> add(@RequestBody AddImportTableDataDTO addImportTableDataDTO) {
|
public ElectromagneticResult<?> add(@RequestBody AddImportTableDataDTO addImportTableDataDTO) {
|
||||||
return importTableService.addTableData(addImportTableDataDTO.getTableInfoId(), addImportTableDataDTO.getTableData());
|
return ElectromagneticResultUtil.success(importTableService.addTableData(addImportTableDataDTO.getTableInfoId(), addImportTableDataDTO.getTableData()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/remove")
|
@GetMapping("/remove")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.electromagnetic.industry.software.manage.service;
|
package com.electromagnetic.industry.software.manage.service;
|
||||||
|
|
||||||
|
import com.electromagnetic.industry.software.common.pojo.RespPageVO;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
|
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
|
||||||
|
|
||||||
|
|
@ -7,7 +8,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public interface ImportTableService {
|
public interface ImportTableService {
|
||||||
|
|
||||||
ElectromagneticResult<?> addTableInfo(String relatedId, Map<Integer, Object> tableHeader);
|
String addTableInfo(String relatedId, Map<Integer, Object> tableHeader);
|
||||||
|
|
||||||
ElectromagneticResult<?> removeTableInfoByRelatedId(String relatedId);
|
ElectromagneticResult<?> removeTableInfoByRelatedId(String relatedId);
|
||||||
|
|
||||||
|
|
@ -19,13 +20,13 @@ public interface ImportTableService {
|
||||||
|
|
||||||
ElectromagneticResult<?> selectTableInfoByRelatedId(String relatedId);
|
ElectromagneticResult<?> selectTableInfoByRelatedId(String relatedId);
|
||||||
|
|
||||||
ElectromagneticResult<?> addTableData(String tableInfoId, String tableData);
|
String addTableData(String tableInfoId, String tableData);
|
||||||
|
|
||||||
ElectromagneticResult<?> removeTableDataById(String id);
|
ElectromagneticResult<?> removeTableDataById(String id);
|
||||||
|
|
||||||
ElectromagneticResult<?> updateTableData(String id, String tableHeader);
|
ElectromagneticResult<?> updateTableData(String id, String tableHeader);
|
||||||
|
|
||||||
ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId);
|
RespPageVO selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1525,14 +1525,25 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElectromagneticResult<?> importPrj(MultipartFile file, String templateCode) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入工程
|
* 导入工程
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file
|
||||||
*/
|
*/
|
||||||
@Override
|
// @Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ElectromagneticResult<?> importPrj(MultipartFile file, String templateCode) {
|
public ElectromagneticResult<?> importPrj1(MultipartFile file, String templateCode) {
|
||||||
try {
|
try {
|
||||||
// 创建工程
|
// 创建工程
|
||||||
String prjId = updateImportPrj2Db(file);
|
String prjId = updateImportPrj2Db(file);
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@ public class ImportTableServiceImpl implements ImportTableService {
|
||||||
private ImportTableInfoMapper importTableInfoMapper;
|
private ImportTableInfoMapper importTableInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> addTableInfo(String relatedId, Map<Integer, Object> tableHeader) {
|
public String addTableInfo(String relatedId, Map<Integer, Object> tableHeader) {
|
||||||
String id = IdWorker.getSnowFlakeIdString();
|
String id = IdWorker.getSnowFlakeIdString();
|
||||||
ImportTableInfo importTableInfo = new ImportTableInfo()
|
ImportTableInfo importTableInfo = new ImportTableInfo()
|
||||||
.setId(id)
|
.setId(id)
|
||||||
.setTableHeader(JSONUtil.toJsonStr(tableHeader))
|
.setTableHeader(JSONUtil.toJsonStr(tableHeader))
|
||||||
.setRelatedId(relatedId);
|
.setRelatedId(relatedId);
|
||||||
importTableInfoMapper.insert(importTableInfo);
|
importTableInfoMapper.insert(importTableInfo);
|
||||||
return ElectromagneticResultUtil.success(id);
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -95,11 +95,11 @@ public class ImportTableServiceImpl implements ImportTableService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> addTableData(String tableInfoId, String tableData) {
|
public String addTableData(String tableInfoId, String tableData) {
|
||||||
String id = IdWorker.getSnowFlakeIdString();
|
String id = IdWorker.getSnowFlakeIdString();
|
||||||
ImportTableData importTableData = new ImportTableData().setId(id).setTableInfoId(tableInfoId).setData(tableData);
|
ImportTableData importTableData = new ImportTableData().setId(id).setTableInfoId(tableInfoId).setData(tableData);
|
||||||
importTableDataMapper.insert(importTableData);
|
importTableDataMapper.insert(importTableData);
|
||||||
return ElectromagneticResultUtil.success(id);
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -120,17 +120,17 @@ public class ImportTableServiceImpl implements ImportTableService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId) {
|
public RespPageVO selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId) {
|
||||||
Page<ImportTableData> importTableData = importTableDataMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.lambdaQuery(ImportTableData.class)
|
Page<ImportTableData> importTableData = importTableDataMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.lambdaQuery(ImportTableData.class)
|
||||||
.eq(ImportTableData::getTableInfoId, tableInfoId)
|
.eq(ImportTableData::getTableInfoId, tableInfoId)
|
||||||
.eq(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.orderByAsc(ImportTableData::getCreatedTime));
|
.orderByAsc(ImportTableData::getCreatedTime));
|
||||||
long total = importTableData.getTotal();
|
long total = importTableData.getTotal();
|
||||||
if (0 == total) {
|
if (0 == total) {
|
||||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, List.of()));
|
return new RespPageVO<>(total, List.of());
|
||||||
}
|
}
|
||||||
List<ImportTablePageDataVO> pageVo = BeanUtil.copyToList(importTableData.getRecords(), ImportTablePageDataVO.class);
|
List<ImportTablePageDataVO> pageVo = BeanUtil.copyToList(importTableData.getRecords(), ImportTablePageDataVO.class);
|
||||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, pageVo));
|
return new RespPageVO<>(total, pageVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue