feat: 三维漫游数据主表控制器
This commit is contained in:
parent
855fd754b0
commit
59890a5659
@ -65,6 +65,7 @@ public class SecurityConfig {
|
||||
.requestMatchers("/eq/**").permitAll()
|
||||
.requestMatchers("/env/**").permitAll()
|
||||
.requestMatchers("/warn/**").permitAll()
|
||||
.requestMatchers("/threedroamb/**").permitAll()
|
||||
.requestMatchers("/overview/**").permitAll()
|
||||
.requestMatchers("/wt/**").permitAll()
|
||||
.requestMatchers("/fb/**").permitAll()
|
||||
|
||||
@ -249,6 +249,15 @@ public class SwaggerConfig {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi groupThreedRoamApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("5.3 三维漫游")
|
||||
.packagesToScan("com.yfd.platform.qgc_sys.threedRoam.controller")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi groupLygkApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.common.exception.BizException;
|
||||
import com.yfd.platform.config.ResponseResult;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamMEntity;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.dto.MsThreedRoamBVO;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.dto.MsThreedRoamMVO;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.service.IMsThreedRoamMService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 三维漫游数据主表控制器
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/threedroamb")
|
||||
@Tag(name = "三维漫游数据主表控制器")
|
||||
public class MsThreedRoamMController {
|
||||
|
||||
@Resource
|
||||
private IMsThreedRoamMService msThreedRoamMService;
|
||||
|
||||
@PostMapping("/GetKendoListCust")
|
||||
@Operation(summary = "条件过滤数据列表")
|
||||
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<MsThreedRoamMEntity> result = msThreedRoamMService.getKendoListCustReturn(dataSourceRequest);
|
||||
return ResponseResult.successData(result);
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@Operation(summary = "保存三维漫游数据")
|
||||
public ResponseResult save(@RequestBody MsThreedRoamMVO vo) {
|
||||
if (msThreedRoamMService.save(vo)) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error("三维漫游数据保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getThreedRoamDetails")
|
||||
@Operation(summary = "获取三维漫游数据详情")
|
||||
public ResponseResult getThreedRoamDetails(@RequestParam("id") String id) {
|
||||
return ResponseResult.successData(msThreedRoamMService.getThreedRoamDetails(id));
|
||||
}
|
||||
|
||||
@GetMapping("/delete")
|
||||
@Operation(summary = "删除三维漫游数据")
|
||||
public ResponseResult delete(@RequestParam("id") String id) {
|
||||
if (msThreedRoamMService.delete(id)) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error("三维漫游数据删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/getThreedRoamData")
|
||||
@Operation(summary = "三维漫游数据")
|
||||
public MsThreedRoamBVO getThreedRoamData(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return msThreedRoamMService.getThreedRoamData(dataSourceRequest);
|
||||
}
|
||||
|
||||
@PostMapping("/export")
|
||||
@Operation(summary = "导出三维漫游数据模板")
|
||||
public void export(HttpServletResponse response) {
|
||||
try {
|
||||
String fileName = "三维漫游数据模板";
|
||||
|
||||
XSSFWorkbook workBook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workBook.createSheet();
|
||||
workBook.setSheetName(0, "三维漫游数据模板");
|
||||
|
||||
XSSFRow row = sheet.createRow(0);
|
||||
row.createCell(0).setCellValue("飞行路径Code");
|
||||
row.createCell(1).setCellValue("飞行路径名称");
|
||||
row.createCell(2).setCellValue("经度\u00B0(0-180\u00B0)");
|
||||
row.createCell(3).setCellValue("纬度\u00B0(0-90\u00B0)");
|
||||
row.createCell(4).setCellValue("高程(m)(小于10000m)");
|
||||
row.createCell(5).setCellValue("时间(s)(小于100s)");
|
||||
row.createCell(6).setCellValue("序号");
|
||||
row.createCell(7).setCellValue("里程碑节点编码(电站编码)");
|
||||
row.createCell(8).setCellValue("里程碑节点名称(电站名称)");
|
||||
|
||||
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(fileName, "utf-8") + ".xlsx");
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
workBook.write(outputStream);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入三维漫游数据")
|
||||
public ResponseResult importExcel(MultipartFile file) {
|
||||
if (msThreedRoamMService.importData(file)) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error("导入三维漫游数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 三维漫游数据表实体(子表)
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Data
|
||||
@TableName("MS_THREEDROAM_B")
|
||||
public class MsThreedRoamEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@TableField("ID")
|
||||
private String id;
|
||||
|
||||
@TableField("ROAM_ID")
|
||||
private String roamId;
|
||||
|
||||
@TableField("CODE")
|
||||
private String code;
|
||||
|
||||
@TableField("NAME")
|
||||
private String name;
|
||||
|
||||
@TableField("LGTD")
|
||||
private BigDecimal lgtd;
|
||||
|
||||
@TableField("LTTD")
|
||||
private BigDecimal lttd;
|
||||
|
||||
@TableField("DTMEL")
|
||||
private BigDecimal dtmel;
|
||||
|
||||
@TableField("TIME")
|
||||
private BigDecimal time;
|
||||
|
||||
@TableField("ORDER_INDEX")
|
||||
private Integer orderIndex;
|
||||
|
||||
@TableField("STCD")
|
||||
private String stcd;
|
||||
|
||||
@TableField("STNM")
|
||||
private String stnm;
|
||||
|
||||
@TableField("RECORD_USER")
|
||||
private String recordUser;
|
||||
|
||||
@TableField("RECORD_TIME")
|
||||
private Date recordTime;
|
||||
|
||||
@TableField("MODIFY_USER")
|
||||
private String modifyUser;
|
||||
|
||||
@TableField("MODIFY_TIME")
|
||||
private Date modifyTime;
|
||||
|
||||
@TableField("IS_DELETED")
|
||||
private Integer isDeleted;
|
||||
|
||||
@TableField("DELETE_USER")
|
||||
private String deleteUser;
|
||||
|
||||
@TableField("DELETE_TIME")
|
||||
private Date deleteTime;
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 三维漫游数据主表实体
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Data
|
||||
@TableName("MS_THREEDROAMM_B")
|
||||
public class MsThreedRoamMEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@TableField("ID")
|
||||
private String id;
|
||||
|
||||
@TableField("CODE")
|
||||
private String code;
|
||||
|
||||
@TableField("NAME")
|
||||
private String name;
|
||||
|
||||
@TableField("RVCD")
|
||||
private String rvcd;
|
||||
|
||||
@TableField("REMARK")
|
||||
private String remark;
|
||||
|
||||
@TableField("RECORD_USER")
|
||||
private String recordUser;
|
||||
|
||||
@TableField("RECORD_TIME")
|
||||
private Date recordTime;
|
||||
|
||||
@TableField("MODIFY_USER")
|
||||
private String modifyUser;
|
||||
|
||||
@TableField("MODIFY_TIME")
|
||||
private Date modifyTime;
|
||||
|
||||
@TableField("IS_DELETED")
|
||||
private Integer isDeleted;
|
||||
|
||||
@TableField("DELETE_USER")
|
||||
private String deleteUser;
|
||||
|
||||
@TableField("DELETE_TIME")
|
||||
private Date deleteTime;
|
||||
|
||||
@TableField("BASE_ID")
|
||||
private String baseId;
|
||||
|
||||
/** 河段名称(非表字段,查询时填充) */
|
||||
@TableField(exist = false)
|
||||
private String rvcdName;
|
||||
|
||||
/** 基地编码(非表字段,查询时填充) */
|
||||
@TableField(exist = false)
|
||||
private String bscd;
|
||||
|
||||
/** 基地名称(非表字段,查询时填充) */
|
||||
@TableField(exist = false)
|
||||
private String bsnm;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三维漫游飞行路径数据查询结果 VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "三维漫游飞行路径数据")
|
||||
public class MsThreedRoamBVO {
|
||||
|
||||
@Schema(description = "数据集合 (坐标序列: totalTime, lgtd, lttd, dtmel, ...)")
|
||||
private List<Object> list;
|
||||
|
||||
@Schema(description = "里程碑集合")
|
||||
private List<String[]> milestoneList;
|
||||
|
||||
@Schema(description = "流域/编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "总时间")
|
||||
private BigDecimal totalTime;
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.dto;
|
||||
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三维漫游数据保存/查询 VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "三维漫游数据")
|
||||
public class MsThreedRoamMVO {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "河段")
|
||||
private String rvcd;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "漫游数据集合")
|
||||
private List<MsThreedRoamEntity> list;
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 三维漫游列表 VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "三维漫游列表")
|
||||
public class MsThreedRoamVO {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String recordUser;
|
||||
|
||||
@Schema(description = "更新人")
|
||||
private String modifyUser;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date recordTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date modifyTime;
|
||||
|
||||
@Schema(description = "河段编码")
|
||||
private String rvcd;
|
||||
|
||||
@Schema(description = "河段名称")
|
||||
private String rvcdName;
|
||||
|
||||
@Schema(description = "基地编码")
|
||||
private String bscd;
|
||||
|
||||
@Schema(description = "基地名称")
|
||||
private String bsnm;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamMEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 三维漫游数据主表 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsThreedRoamMMapper extends BaseMapper<MsThreedRoamMEntity> {
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三维漫游数据子表 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsThreedRoamMapper extends BaseMapper<MsThreedRoamEntity> {
|
||||
|
||||
/**
|
||||
* 批量插入漫游详细数据
|
||||
*/
|
||||
int batchInsertList(@Param("list") List<MsThreedRoamEntity> list);
|
||||
|
||||
/**
|
||||
* 根据漫游ID删除详细数据
|
||||
*/
|
||||
void deleteTheedRoam(@Param("roamId") String roamId);
|
||||
|
||||
/**
|
||||
* 查询电站编码和名称(校验里程碑节点是否存在)
|
||||
*/
|
||||
MsThreedRoamEntity selectStcd(@Param("stcd") String stcd);
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.service;
|
||||
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamMEntity;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.dto.MsThreedRoamBVO;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.dto.MsThreedRoamMVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 三维漫游数据主表 Service 接口
|
||||
*/
|
||||
public interface IMsThreedRoamMService {
|
||||
|
||||
/**
|
||||
* 条件过滤数据列表(GetKendoListCust)
|
||||
*/
|
||||
DataSourceResult<MsThreedRoamMEntity> getKendoListCustReturn(DataSourceRequest dataSourceRequest);
|
||||
|
||||
/**
|
||||
* 保存三维漫游数据
|
||||
*/
|
||||
Boolean save(MsThreedRoamMVO vo);
|
||||
|
||||
/**
|
||||
* 获取三维漫游数据详情
|
||||
*/
|
||||
MsThreedRoamMVO getThreedRoamDetails(String id);
|
||||
|
||||
/**
|
||||
* 删除三维漫游数据
|
||||
*/
|
||||
Boolean delete(String id);
|
||||
|
||||
/**
|
||||
* 获取三维漫游飞行路径数据
|
||||
*/
|
||||
MsThreedRoamBVO getThreedRoamData(DataSourceRequest dataSourceRequest);
|
||||
|
||||
/**
|
||||
* 导入三维漫游数据
|
||||
*/
|
||||
Boolean importData(MultipartFile file);
|
||||
}
|
||||
@ -0,0 +1,418 @@
|
||||
package com.yfd.platform.qgc_sys.threedRoam.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||
import com.yfd.platform.common.exception.BizException;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamEntity;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamMEntity;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.dto.MsThreedRoamBVO;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.dto.MsThreedRoamMVO;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.mapper.MsThreedRoamMMapper;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.mapper.MsThreedRoamMapper;
|
||||
import com.yfd.platform.qgc_sys.threedRoam.service.IMsThreedRoamMService;
|
||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 三维漫游数据主表 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class MsThreedRoamMServiceImpl extends ServiceImpl<MsThreedRoamMMapper, MsThreedRoamMEntity> implements IMsThreedRoamMService {
|
||||
|
||||
@Resource
|
||||
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
|
||||
|
||||
@Resource
|
||||
private MsThreedRoamMapper msThreedRoamMapper;
|
||||
|
||||
@Resource
|
||||
private MsThreedRoamMMapper msThreedRoamMMapper;
|
||||
|
||||
@Override
|
||||
public DataSourceResult<MsThreedRoamMEntity> getKendoListCustReturn(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT a.ID, a.CODE, a.NAME, a.RVCD, b.HBRVNM AS rvcdName, a.REMARK, ")
|
||||
.append("a.RECORD_USER, a.RECORD_TIME, a.MODIFY_USER, a.MODIFY_TIME, ")
|
||||
.append("c.BASEID AS bscd, c.BASENAME AS bsnm ")
|
||||
.append("FROM MS_THREEDROAMM_B a ")
|
||||
.append("LEFT JOIN SD_HBRV_DIC b ON a.RVCD = b.HBRVCD AND b.IS_DELETED = 0 ")
|
||||
.append("LEFT JOIN SD_HYDROBASE c ON b.BASEID = c.BASEID AND c.IS_DELETED = 0 ")
|
||||
.append("WHERE a.IS_DELETED = 0");
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String filterSql = buildFilterSql(dataSourceRequest == null ? null : dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql);
|
||||
}
|
||||
|
||||
// 排序
|
||||
sql.append(" ORDER BY a.CODE ASC");
|
||||
|
||||
Page<?> page = loadOptions == null ? null
|
||||
: QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<MsThreedRoamMEntity> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page, sql.toString(), paramMap, MsThreedRoamMEntity.class
|
||||
);
|
||||
|
||||
DataSourceResult<MsThreedRoamMEntity> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page == null ? list.size() : page.getTotal());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建过滤 SQL
|
||||
*/
|
||||
private String buildFilterSql(com.yfd.platform.common.DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap, int[] indexHolder) {
|
||||
if (filter == null) return "";
|
||||
|
||||
List<com.yfd.platform.common.DataSourceRequest.FilterDescriptor> childFilters = filter.getFilters();
|
||||
if (CollUtil.isNotEmpty(childFilters)) {
|
||||
List<String> childConditions = new ArrayList<>();
|
||||
for (com.yfd.platform.common.DataSourceRequest.FilterDescriptor child : childFilters) {
|
||||
String childSql = buildFilterSql(child, paramMap, indexHolder);
|
||||
if (StrUtil.isNotBlank(childSql)) {
|
||||
childConditions.add(childSql);
|
||||
}
|
||||
}
|
||||
if (childConditions.isEmpty()) return "";
|
||||
String logic = StrUtil.isNotBlank(filter.getLogic()) ? filter.getLogic() : "and";
|
||||
String connector = "and".equalsIgnoreCase(logic) ? " AND " : " OR ";
|
||||
return "(" + String.join(connector, childConditions) + ")";
|
||||
}
|
||||
|
||||
String field = filter.getField();
|
||||
Object value = filter.getValue();
|
||||
String operator = filter.getOperator();
|
||||
|
||||
if (StrUtil.isBlank(field)) return "";
|
||||
|
||||
String column = mapToListColumn(field);
|
||||
if (StrUtil.isBlank(column)) return "";
|
||||
|
||||
if ("isnull".equalsIgnoreCase(operator)) return column + " IS NULL";
|
||||
if ("isnotnull".equalsIgnoreCase(operator)) return column + " IS NOT NULL";
|
||||
if (value == null) return "";
|
||||
|
||||
String paramKey = "t" + indexHolder[0]++;
|
||||
paramMap.put(paramKey, value);
|
||||
|
||||
if ("eq".equalsIgnoreCase(operator)) {
|
||||
return column + " = #{map." + paramKey + "}";
|
||||
} else if ("neq".equalsIgnoreCase(operator)) {
|
||||
return column + " != #{map." + paramKey + "}";
|
||||
} else if ("contains".equalsIgnoreCase(operator)) {
|
||||
return column + " LIKE '%' || #{map." + paramKey + "} || '%'";
|
||||
} else if ("startswith".equalsIgnoreCase(operator)) {
|
||||
return column + " LIKE #{map." + paramKey + "} || '%'";
|
||||
} else if ("endswith".equalsIgnoreCase(operator)) {
|
||||
return column + " LIKE '%' || #{map." + paramKey + "}";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String mapToListColumn(String field) {
|
||||
if (StrUtil.isBlank(field)) return null;
|
||||
return switch (field) {
|
||||
case "code" -> "a.CODE";
|
||||
case "name" -> "a.NAME";
|
||||
case "rvcd" -> "a.RVCD";
|
||||
case "remark" -> "a.REMARK";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean save(MsThreedRoamMVO vo) {
|
||||
MsThreedRoamMEntity entity = new MsThreedRoamMEntity();
|
||||
BeanUtils.copyProperties(vo, entity);
|
||||
|
||||
// 校验编码是否存在
|
||||
if (!checkCodeExist(entity)) {
|
||||
throw new BizException("该编码已存在");
|
||||
}
|
||||
|
||||
boolean result;
|
||||
if (StrUtil.isNotBlank(entity.getId())) {
|
||||
result = this.updateById(entity);
|
||||
} else {
|
||||
result = this.save(entity);
|
||||
}
|
||||
|
||||
if (result && CollUtil.isNotEmpty(vo.getList())) {
|
||||
// 删除旧数据
|
||||
msThreedRoamMapper.deleteTheedRoam(entity.getId());
|
||||
|
||||
// 批量插入新数据
|
||||
List<MsThreedRoamEntity> batchList = new ArrayList<>();
|
||||
List<MsThreedRoamEntity> detailList = vo.getList();
|
||||
for (int i = 0; i < detailList.size(); i++) {
|
||||
MsThreedRoamEntity detail = detailList.get(i);
|
||||
if (StrUtil.isBlank(detail.getStcd())) {
|
||||
detail.setStcd("");
|
||||
}
|
||||
if (StrUtil.isBlank(detail.getStnm())) {
|
||||
detail.setStnm("");
|
||||
}
|
||||
detail.setRoamId(entity.getId());
|
||||
detail.setCode(vo.getCode());
|
||||
detail.setName(vo.getName());
|
||||
batchList.add(detail);
|
||||
|
||||
if (batchList.size() == 2000 || i == detailList.size() - 1) {
|
||||
int fruit = msThreedRoamMapper.batchInsertList(batchList);
|
||||
if (fruit < 1) {
|
||||
throw new BizException("保存三维漫游数据失败");
|
||||
}
|
||||
batchList = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验编码是否存在(修改时排除自身)
|
||||
*/
|
||||
private boolean checkCodeExist(MsThreedRoamMEntity entity) {
|
||||
QueryWrapper<MsThreedRoamMEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("CODE", entity.getCode());
|
||||
MsThreedRoamMEntity exist = msThreedRoamMMapper.selectOne(wrapper);
|
||||
if (exist != null && !exist.getId().equals(entity.getId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MsThreedRoamMVO getThreedRoamDetails(String id) {
|
||||
MsThreedRoamMVO vo = new MsThreedRoamMVO();
|
||||
MsThreedRoamMEntity entity = msThreedRoamMMapper.selectById(id);
|
||||
if (entity != null) {
|
||||
BeanUtils.copyProperties(entity, vo);
|
||||
|
||||
QueryWrapper<MsThreedRoamEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("ROAM_ID", id);
|
||||
wrapper.orderByAsc("ORDER_INDEX");
|
||||
List<MsThreedRoamEntity> list = msThreedRoamMapper.selectList(wrapper);
|
||||
vo.setList(list);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean delete(String id) {
|
||||
// 删除子表数据
|
||||
QueryWrapper<MsThreedRoamEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("ROAM_ID", id);
|
||||
List<MsThreedRoamEntity> list = msThreedRoamMapper.selectList(wrapper);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
msThreedRoamMapper.delete(wrapper);
|
||||
}
|
||||
// 删除主表数据
|
||||
int result = msThreedRoamMMapper.deleteById(id);
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MsThreedRoamBVO getThreedRoamData(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||
String code = QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "code");
|
||||
|
||||
MsThreedRoamMEntity entity = msThreedRoamMMapper.selectOne(
|
||||
new QueryWrapper<MsThreedRoamMEntity>().eq("CODE", code));
|
||||
if (entity == null) {
|
||||
throw new BizException("该流域没有三维漫游数据");
|
||||
}
|
||||
|
||||
QueryWrapper<MsThreedRoamEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("ROAM_ID", entity.getId());
|
||||
wrapper.orderByAsc("ORDER_INDEX");
|
||||
List<MsThreedRoamEntity> threedRoamList = msThreedRoamMapper.selectList(wrapper);
|
||||
|
||||
BigDecimal totalTime = BigDecimal.ZERO;
|
||||
List<Object> lists = new ArrayList<>();
|
||||
String baseCode = "";
|
||||
List<String[]> milestoneList = new ArrayList<>();
|
||||
List<String> stcdList = new ArrayList<>();
|
||||
|
||||
for (MsThreedRoamEntity detail : threedRoamList) {
|
||||
totalTime = totalTime.add(detail.getTime().multiply(new BigDecimal("0.2")));
|
||||
lists.add(totalTime);
|
||||
lists.add(detail.getLgtd());
|
||||
lists.add(detail.getLttd());
|
||||
lists.add(detail.getDtmel());
|
||||
baseCode = detail.getCode();
|
||||
|
||||
if (StrUtil.isNotBlank(detail.getStcd()) && !stcdList.contains(detail.getStnm())) {
|
||||
stcdList.add(detail.getStnm());
|
||||
milestoneList.add(new String[]{detail.getStnm(), totalTime.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
MsThreedRoamBVO vo = new MsThreedRoamBVO();
|
||||
vo.setList(lists);
|
||||
vo.setTotalTime(totalTime);
|
||||
vo.setCode(baseCode);
|
||||
vo.setMilestoneList(milestoneList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean importData(MultipartFile file) {
|
||||
if (file == null) {
|
||||
throw new BizException("请上传文件");
|
||||
}
|
||||
|
||||
List<MsThreedRoamEntity> list = new ArrayList<>();
|
||||
try {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(file.getInputStream());
|
||||
int sheets = workbook.getNumberOfSheets();
|
||||
for (int i = 0; i < sheets; i++) {
|
||||
XSSFSheet sheet = workbook.getSheetAt(i);
|
||||
int rows = sheet.getPhysicalNumberOfRows();
|
||||
for (int j = 1; j < rows; j++) {
|
||||
MsThreedRoamEntity detail = new MsThreedRoamEntity();
|
||||
XSSFRow row = sheet.getRow(j);
|
||||
|
||||
detail.setCode(row.getCell(0).toString());
|
||||
detail.setName(row.getCell(1).toString());
|
||||
|
||||
double lgtd = Double.parseDouble(row.getCell(2).toString());
|
||||
if (lgtd > 180 || lgtd < 0) {
|
||||
throw new BizException("经度必须在0-180\u00B0之间");
|
||||
}
|
||||
detail.setLgtd(new BigDecimal(row.getCell(2).toString()));
|
||||
|
||||
double lttd = Double.parseDouble(row.getCell(3).toString());
|
||||
if (lttd > 90 || lttd < 0) {
|
||||
throw new BizException("纬度必须在0-90\u00B0之间");
|
||||
}
|
||||
detail.setLttd(new BigDecimal(row.getCell(3).toString()));
|
||||
|
||||
double dtmel = Double.parseDouble(row.getCell(4).toString());
|
||||
if (dtmel >= 10000 || dtmel < 0) {
|
||||
throw new BizException("高程小于10000米");
|
||||
}
|
||||
detail.setDtmel(new BigDecimal(row.getCell(4).toString()).setScale(3, BigDecimal.ROUND_HALF_UP));
|
||||
|
||||
double time = Double.parseDouble(row.getCell(5).toString());
|
||||
if (time >= 100 || time < 0) {
|
||||
throw new BizException("时间小于100秒");
|
||||
}
|
||||
detail.setTime(new BigDecimal(row.getCell(5).toString()).setScale(1, BigDecimal.ROUND_HALF_UP));
|
||||
|
||||
int px = (int) Double.parseDouble(row.getCell(6).toString());
|
||||
detail.setOrderIndex(px);
|
||||
|
||||
if (row.getCell(7) != null && StrUtil.isNotBlank(row.getCell(7).toString())) {
|
||||
detail.setStcd(row.getCell(7).toString());
|
||||
} else {
|
||||
detail.setStcd("");
|
||||
}
|
||||
if (row.getCell(8) != null && StrUtil.isNotBlank(row.getCell(8).toString())) {
|
||||
detail.setStnm(row.getCell(8).toString());
|
||||
} else {
|
||||
detail.setStnm("");
|
||||
}
|
||||
|
||||
list.add(detail);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new BizException("导入文档解析错误");
|
||||
}
|
||||
|
||||
return saveImportData(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存导入数据
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean saveImportData(List<MsThreedRoamEntity> list) {
|
||||
Map<String, List<MsThreedRoamEntity>> collect = list.stream()
|
||||
.collect(Collectors.groupingBy(MsThreedRoamEntity::getCode));
|
||||
|
||||
collect.forEach((code, roamList) -> {
|
||||
MsThreedRoamMEntity entity = msThreedRoamMMapper.selectOne(
|
||||
new QueryWrapper<MsThreedRoamMEntity>().eq("CODE", code));
|
||||
if (entity == null) {
|
||||
entity = new MsThreedRoamMEntity();
|
||||
entity.setCode(code);
|
||||
}
|
||||
entity.setName(roamList.get(0).getName());
|
||||
|
||||
boolean result;
|
||||
if (StrUtil.isNotBlank(entity.getId())) {
|
||||
result = this.updateById(entity);
|
||||
} else {
|
||||
result = this.save(entity);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
msThreedRoamMapper.deleteTheedRoam(entity.getId());
|
||||
|
||||
List<MsThreedRoamEntity> batchList = new ArrayList<>();
|
||||
List<String> stcdExistList = new ArrayList<>();
|
||||
List<String> newStcdList = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < roamList.size(); i++) {
|
||||
MsThreedRoamEntity detail = roamList.get(i);
|
||||
detail.setRoamId(entity.getId());
|
||||
|
||||
if (StrUtil.isNotBlank(detail.getStcd())) {
|
||||
if (!stcdExistList.contains(detail.getStcd()) && !newStcdList.contains(detail.getStcd())) {
|
||||
MsThreedRoamEntity stcdEntity = msThreedRoamMapper.selectStcd(detail.getStcd());
|
||||
if (stcdEntity != null) {
|
||||
stcdExistList.add(detail.getStcd());
|
||||
} else {
|
||||
newStcdList.add(detail.getStcd());
|
||||
detail.setStcd("");
|
||||
detail.setStnm("");
|
||||
}
|
||||
} else if (newStcdList.contains(detail.getStcd())) {
|
||||
detail.setStcd("");
|
||||
detail.setStnm("");
|
||||
}
|
||||
}
|
||||
|
||||
batchList.add(detail);
|
||||
if (batchList.size() == 2000 || i == roamList.size() - 1) {
|
||||
int fruit = msThreedRoamMapper.batchInsertList(batchList);
|
||||
if (fruit < 1) {
|
||||
throw new BizException("导入三维漫游数据失败");
|
||||
}
|
||||
batchList = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yfd.platform.qgc_sys.threedRoam.mapper.MsThreedRoamMapper">
|
||||
|
||||
<insert id="batchInsertList" parameterType="List">
|
||||
INSERT INTO MS_THREEDROAM_B(ROAM_ID, CODE, NAME, LGTD, LTTD, DTMEL, TIME, ORDER_INDEX, STCD, STNM)
|
||||
SELECT *
|
||||
FROM (
|
||||
<foreach collection="list" item="item" separator="union all">
|
||||
SELECT
|
||||
#{item.roamId} AS roamId,
|
||||
#{item.code} AS code,
|
||||
#{item.name} AS name,
|
||||
#{item.lgtd} AS lgtd,
|
||||
#{item.lttd} AS lttd,
|
||||
#{item.dtmel} AS dtmel,
|
||||
#{item.time} AS time,
|
||||
#{item.orderIndex} AS orderIndex,
|
||||
#{item.stcd} AS stcd,
|
||||
#{item.stnm} AS stnm
|
||||
FROM DUAL
|
||||
</foreach>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteTheedRoam" parameterType="java.lang.String">
|
||||
DELETE FROM MS_THREEDROAM_B
|
||||
<where>
|
||||
<if test="roamId != null and roamId != ''">
|
||||
AND ROAM_ID = #{roamId}
|
||||
</if>
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<select id="selectStcd" resultType="com.yfd.platform.qgc_sys.threedRoam.domain.MsThreedRoamEntity">
|
||||
SELECT STCD, STNM FROM V_MS_STBPRP_T
|
||||
WHERE STTP_CODE = 'ENG'
|
||||
<if test="stcd != null and stcd != ''">
|
||||
AND STCD = #{stcd}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user