调通了结构化数据增删改查。

This commit is contained in:
chenxudong 2025-06-11 14:56:24 +08:00
parent 647f68c2bb
commit 73c5427155
9 changed files with 324 additions and 24 deletions

View File

@ -7,7 +7,6 @@ import com.electromagnetic.industry.software.manage.pojo.req.AddImportTableDataD
import com.electromagnetic.industry.software.manage.pojo.req.UpdateImportTableDataDTO;
import com.electromagnetic.industry.software.manage.service.ImportTableService;
import jakarta.annotation.Resource;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.web.bind.annotation.*;
import java.util.Optional;

View File

@ -2,7 +2,8 @@ package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableData;
import org.mapstruct.Mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ImportTableDataMapper extends BaseMapper<ImportTableData> {

View File

@ -2,7 +2,7 @@ package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
import org.mapstruct.Mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ImportTableInfoMapper extends BaseMapper<ImportTableInfo> {

View File

@ -8,5 +8,5 @@ import java.util.Map;
public class AddImportTableDataDTO {
private String tableInfoId;
private Map<Integer, Object> tableData;
private String tableData;
}

View File

@ -7,5 +7,5 @@ import java.util.Map;
@Data
public class UpdateImportTableDataDTO {
private String id;
private Map<Integer, Object> tableData;
private String tableData;
}

View File

@ -19,11 +19,11 @@ public interface ImportTableService {
ElectromagneticResult<?> selectTableInfoByRelatedId(String relatedId);
ElectromagneticResult<?> addTableData(String tableInfoId, Map<Integer, Object> tableData);
ElectromagneticResult<?> addTableData(String tableInfoId, String tableData);
ElectromagneticResult<?> removeTableDataById(String id);
ElectromagneticResult<?> updateTableData(String id, Map<Integer, Object> tableHeader);
ElectromagneticResult<?> updateTableData(String id, String tableHeader);
ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId);

View File

@ -95,9 +95,9 @@ public class ImportTableServiceImpl implements ImportTableService {
}
@Override
public ElectromagneticResult<?> addTableData(String tableInfoId, Map<Integer, Object> tableData) {
public ElectromagneticResult<?> addTableData(String tableInfoId, String tableData) {
String id = IdWorker.getSnowFlakeIdString();
ImportTableData importTableData = new ImportTableData().setId(id).setTableInfoId(tableInfoId).setData(JSONUtil.toJsonStr(tableData));
ImportTableData importTableData = new ImportTableData().setId(id).setTableInfoId(tableInfoId).setData(tableData);
importTableDataMapper.insert(importTableData);
return ElectromagneticResultUtil.success(id);
}
@ -112,10 +112,10 @@ public class ImportTableServiceImpl implements ImportTableService {
}
@Override
public ElectromagneticResult<?> updateTableData(String id, Map<Integer, Object> tableHeader) {
public ElectromagneticResult<?> updateTableData(String id, String tableHeader) {
importTableDataMapper.update(new ImportTableData(), Wrappers.<ImportTableData>lambdaUpdate()
.eq(ImportTableData::getId, id)
.set(ImportTableData::getData, JSONUtil.toJsonStr(tableHeader)));
.set(ImportTableData::getData, tableHeader));
return ElectromagneticResultUtil.success(true);
}
@ -123,7 +123,8 @@ public class ImportTableServiceImpl implements ImportTableService {
public ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId) {
Page<ImportTableData> importTableData = importTableDataMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.lambdaQuery(ImportTableData.class)
.eq(ImportTableData::getTableInfoId, tableInfoId)
.eq(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code));
.eq(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code)
.orderByAsc(ImportTableData::getCreatedTime));
long total = importTableData.getTotal();
if (0 == total) {
return ElectromagneticResultUtil.success(new RespPageVO<>(total, List.of()));

View File

@ -0,0 +1,311 @@
//import cn.hutool.json.JSONUtil;
//import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
//import com.electromagnetic.industry.software.manage.Application;
//import com.electromagnetic.industry.software.manage.service.ImportTableService;
//import jakarta.annotation.Resource;
//import org.junit.jupiter.api.Test;
//import org.springframework.boot.test.context.SpringBootTest;
//
//import java.util.LinkedHashMap;
//import java.util.Map;
//
//@SpringBootTest(classes = Application.class)
//public class ImportTableTest {
//
// @Resource
// private ImportTableService importTableService;
//
// @Test
// public void test1() {
//
//// int[] ids1 = {100423, 100431, 100432, 100433, 100434, 100435};
//// int[] ids2 = {100424, 100436, 100437, 100438, 100439, 100440};
//// int[] ids3 = {100425, 100441, 100442, 100443, 100444, 100445};
////
//// Map<Integer, Object> map1 = new LinkedHashMap<>();
//// map1.put(1, "起始频率");
//// map1.put(2, "终止频率");
//// map1.put(3, "M等级");
//// map1.put(4, "O等级");
//// map1.put(5, "R等级");
//// map1.put(6, "S等级");
//// map1.put(7, "T等级");
//// map1.put(8, "W等级");
//// map1.put(9, "Y等级");
//// map1.put(10, "版本号");
////
//// Map<Integer, Object> map2 = new LinkedHashMap<>();
//// map2.put(1, "起始频率");
//// map2.put(2, "终止频率");
//// map2.put(3, "B等级");
//// map2.put(4, "D等级");
//// map2.put(5, "F等级");
//// map2.put(6, "G等级");
//// map2.put(7, "L等级");
//// map2.put(8, "R等级");
//// map2.put(9, "S等级");
//// map2.put(10, "T等级");
//// map2.put(11, "W等级");
//// map2.put(12, "Y等级");
//// map2.put(13, "版本号");
////
//// Map<Integer, Object> map3 = new LinkedHashMap<>();
//// map3.put(1, "起始频率");
//// map3.put(2, "终止频率");
//// map3.put(3, "B等级");
//// map3.put(4, "F等级");
//// map3.put(5, "S等级");
//// map3.put(6, "G等级");
//// map3.put(7, "L等级");
//// map3.put(8, "R等级");
//// map3.put(9, "版本号");
////
//// for (Integer id : ids1) {
//// importTableService.addTableInfo(id + "", map1);
//// }
////
//// for (Integer id : ids2) {
//// importTableService.addTableInfo(id + "", map2);
//// }
////
//// for (Integer id : ids3) {
//// importTableService.addTableInfo(id + "", map3);
//// }
//
// }
//
// @Test
// public void test2() {
// String[] arr1 = {"1932333966414524416", "1932333966867509248","1932333966922035200","1932333966993338368","1932333967026892800","1932333967060447232"};
// Map<Integer, Object> map1 = new LinkedHashMap<>();
// map1.put(1, 0.01);
// map1.put(2, 0.5);
// map1.put(3, 0.6);
// map1.put(4, 3);
// map1.put(5, 0.6);
// map1.put(6, 0.03);
// map1.put(7, 0.15);
// map1.put(8, 3);
// map1.put(9, 6);
// map1.put(10, 1);
//
// Map<Integer, Object> map2 = new LinkedHashMap<>();
// map2.put(1, 0.5);
// map2.put(2, 1);
// map2.put(3, 30);
// map2.put(4, 150);
// map2.put(5, 30);
// map2.put(6, 1.5);
// map2.put(7, 7.5);
// map2.put(8, 150);
// map2.put(9, 300);
// map2.put(10, 1);
//
// Map<Integer, Object> map3 = new LinkedHashMap<>();
// map3.put(1, 1);
// map3.put(2, 30);
// map3.put(3, 70);
// map3.put(4, 250);
// map3.put(5, 30);
// map3.put(6, 1.5);
// map3.put(7, 7.5);
// map3.put(8, 150);
// map3.put(9, 300);
// map3.put(10, 1);
//
// Map<Integer, Object> map4 = new LinkedHashMap<>();
// map4.put(1, 30);
// map4.put(2, 40);
// map4.put(3, 70);
// map4.put(4, 250);
// map4.put(5, 30);
// map4.put(6, 1.5);
// map4.put(7, 7.5);
// map4.put(8, 150);
// map4.put(9, 300);
// map4.put(10, 1);
//
// Map<Integer, Object> map5 = new LinkedHashMap<>();
// map5.put(1, 40);
// map5.put(2, 100);
// map5.put(3, 32);
// map5.put(4, 50);
// map5.put(5, 30);
// map5.put(6, 1.5);
// map5.put(7, 7.55);
// map5.put(8, 150);
// map5.put(9, 300);
// map5.put(10, 1);
//
// for (String id : arr1) {
// importTableService.addTableData(id, map1);
// importTableService.addTableData(id, map2);
// importTableService.addTableData(id, map3);
// importTableService.addTableData(id, map4);
// importTableService.addTableData(id, map5);
// }
//
// }
//
// @Test
// public void test3() {
// String[] arr1 = {"1932333967098195968", "1932333967177887744", "1932333967236608000", "1932333967274356736", "1932333967307911168", "1932333967341465600"};
//
// Map<Integer, Object> map1 = new LinkedHashMap<>();
// map1.put(1, 100);
// map1.put(2, 200);
// map1.put(3, 20);
// map1.put(4, 25);
// map1.put(5, 50);
// map1.put(6, 100);
// map1.put(7, 200);
// map1.put(8, 20);
// map1.put(9, 1);
// map1.put(10, 5);
// map1.put(11, 100);
// map1.put(12, 200);
// map1.put(13, 1);
//
// Map<Integer, Object> map2 = new LinkedHashMap<>();
// map2.put(1, 200);
// map2.put(2, 400);
// map2.put(3, 20);
// map2.put(4, 25);
// map2.put(5, 50);
// map2.put(6, 100);
// map2.put(7, 200);
// map2.put(8, 20);
// map2.put(9, 1);
// map2.put(10, 5);
// map2.put(11, 100);
// map2.put(12, 200);
// map2.put(13, 1);
//
// Map<Integer, Object> map3 = new LinkedHashMap<>();
// map3.put(1, 400);
// map3.put(2, 700);
// map3.put(3, 20);
// map3.put(4, 20);
// map3.put(5, 25);
// map3.put(6, 50);
// map3.put(7, 200);
// map3.put(8, 20);
// map3.put(9, 1);
// map3.put(10, 5);
// map3.put(11, 100);
// map3.put(12, 200);
// map3.put(13, 1);
//
// Map<Integer, Object> map4 = new LinkedHashMap<>();
// map4.put(1, 700);
// map4.put(2, 1000);
// map4.put(3, 20);
// map4.put(4, 25);
// map4.put(5, 50);
// map4.put(6, 100);
// map4.put(7, 240);
// map4.put(8, 20);
// map4.put(9, 1);
// map4.put(10, 5);
// map4.put(11, 100);
// map4.put(12, 200);
// map4.put(13, 1);
//
// Map<Integer, Object> map5 = new LinkedHashMap<>();
// map5.put(1, 100);
// map5.put(2, 2000);
// map5.put(3, 25);
// map5.put(4, 50);
// map5.put(5, 100);
// map5.put(6, 200);
// map5.put(7, 250);
// map5.put(8, 20);
// map5.put(9, 1);
// map5.put(10, 5);
// map5.put(11, 100);
// map5.put(12, 200);
// map5.put(13, 1);
//
// for (String id : arr1) {
// importTableService.addTableData(id, map1);
// importTableService.addTableData(id, map2);
// importTableService.addTableData(id, map3);
// importTableService.addTableData(id, map4);
// importTableService.addTableData(id, map5);
// }
// }
//
// @Test
// public void test4() {
// String[] arr1 = {"1932333967379214336", "1932333967412768768", "1932333967492460544", "1932333967555375104", "1932333967593123840", "1932333967626678272"};
//
// Map<Integer, Object> map1 = new LinkedHashMap<>();
// map1.put(1, 400);
// map1.put(2, 700);
// map1.put(3, 150);
// map1.put(4, 175);
// map1.put(5, 350);
// map1.put(6, 700);
// map1.put(7, 730);
// map1.put(8, 150);
// map1.put(9, 1);
//
// Map<Integer, Object> map2 = new LinkedHashMap<>();
// map2.put(1, 700);
// map2.put(2, 1000);
// map2.put(3, 150);
// map2.put(4, 175);
// map2.put(5, 350);
// map2.put(6, 700);
// map2.put(7, 1400);
// map2.put(8, 150);
// map2.put(9, 1);
//
// Map<Integer, Object> map3 = new LinkedHashMap<>();
// map3.put(1, 1000);
// map3.put(2, 2000);
// map3.put(3, 250);
// map3.put(4, 500);
// map3.put(5, 1000);
// map3.put(6, 2000);
// map3.put(7, 5000);
// map3.put(8, 150);
// map3.put(9, 1);
//
// Map<Integer, Object> map4 = new LinkedHashMap<>();
// map4.put(1, 2000);
// map4.put(2, 4000);
// map4.put(3, 375);
// map4.put(4, 750);
// map4.put(5, 1500);
// map4.put(6, 3000);
// map4.put(7, 6000);
// map4.put(8, 150);
// map4.put(9, 1);
//
// Map<Integer, Object> map5 = new LinkedHashMap<>();
// map5.put(1, 4000);
// map5.put(2, 6000);
// map5.put(3, 375);
// map5.put(4, 750);
// map5.put(5, 1500);
// map5.put(6, 3000);
// map5.put(7, 7200);
// map5.put(8, 150);
// map5.put(9, 1);
//
// for (String id : arr1) {
// importTableService.addTableData(id, map1);
// importTableService.addTableData(id, map2);
// importTableService.addTableData(id, map3);
// importTableService.addTableData(id, map4);
// importTableService.addTableData(id, map5);
// }
// }
//
// @Test
// public void test5() {
// ElectromagneticResult<?> electromagneticResult = importTableService.selectTableDataByTableInfoId(1, 10, "1932333966867509248");
// System.out.println(JSONUtil.toJsonStr(electromagneticResult));
// }
//}

View File

@ -1,12 +0,0 @@
import com.electromagnetic.industry.software.manage.Application;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(classes = Application.class)
public class Test1 {
// @Test
// public void test() throws MalformedURLException {
//
// }
}