1、新增维修记录

2、新增保养记录
3、新增港口码头主数据
4、新增铁路车站主数据
5、新增空港机场主数据
6、测试版nacos配置
7、测试版Harbor配置
8、其他配置修改
This commit is contained in:
2026-07-10 22:08:46 +08:00
parent f1e6599892
commit d9df98b5b1
85 changed files with 11436 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
FROM bladex/alpine-java:openjdk17_cn_slim
FROM ${docker.base.image}
LABEL maintainer="bladejava@qq.com"
@@ -12,4 +12,4 @@ COPY ./target/blade-system.jar ./app.jar
ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
CMD ["--spring.profiles.active=test"]
CMD ["--spring.profiles.active=prod"]

View File

@@ -0,0 +1,171 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.AirportMasterExcel;
import org.springblade.system.excel.AirportMasterImporter;
import org.springblade.system.pojo.entity.AirportMaster;
import org.springblade.system.pojo.vo.AirportMasterVO;
import org.springblade.system.service.IAirportMasterService;
import org.springblade.system.wrapper.AirportMasterWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 空港机场主数据 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "airport_master")
@RequestMapping("/airport-master")
@Tag(name = "空港机场主数据", description = "空港机场主数据")
public class AirportMasterController extends BladeController {
private final IAirportMasterService airportMasterService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入airportMaster")
public R<AirportMasterVO> detail(AirportMaster airportMaster) {
AirportMaster detail = airportMasterService.getOne(Condition.getQueryWrapper(airportMaster));
return R.data(AirportMasterWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入airportMaster")
public R<IPage<AirportMasterVO>> list(AirportMasterVO airportMaster, Query query) {
IPage<AirportMasterVO> pages = airportMasterService.selectAirportMasterPage(Condition.getPage(query), airportMaster);
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入airportMaster")
public R submit(@Valid @RequestBody AirportMaster airportMaster) {
return R.status(airportMasterService.submit(airportMaster));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(airportMasterService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(airportMasterService.changeStatus(id, status));
}
/**
* 导入空港机场主数据
*/
@PostMapping("/import-airport-master")
@ApiOperationSupport(order = 6)
@Operation(summary = "导入空港机场主数据", description = "传入excel")
public R importAirportMaster(MultipartFile file) {
AirportMasterImporter airportMasterImporter = new AirportMasterImporter(airportMasterService);
ExcelUtil.save(file, airportMasterImporter, AirportMasterExcel.class);
return R.success("操作成功");
}
/**
* 导出空港机场主数据
*/
@GetMapping("/export-airport-master")
@ApiOperationSupport(order = 7)
@Operation(summary = "导出空港机场主数据")
public void exportAirportMaster(@Parameter(hidden = true) @RequestParam Map<String, Object> airportMaster, HttpServletResponse response) {
Object ids = airportMaster.remove("ids");
QueryWrapper<AirportMaster> queryWrapper = Condition.getQueryWrapper(airportMaster, AirportMaster.class);
if (Func.isNotEmpty(ids)) {
queryWrapper.lambda().in(AirportMaster::getId, Func.toLongList(ids.toString()));
}
List<AirportMasterExcel> list = airportMasterService.exportAirportMaster(queryWrapper);
ExcelUtil.export(response, "空港机场主数据" + DateUtil.time(), "空港机场主数据表", list, AirportMasterExcel.class);
}
/**
* 导出模板
*/
@GetMapping("/export-template")
@ApiOperationSupport(order = 8)
@Operation(summary = "导出模板")
public void exportTemplate(HttpServletResponse response) {
List<AirportMasterExcel> list = new ArrayList<>();
ExcelUtil.export(response, "空港机场主数据模板", "空港机场主数据表", list, AirportMasterExcel.class);
}
}

View File

@@ -0,0 +1,181 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.PortTerminalExcel;
import org.springblade.system.excel.PortTerminalImporter;
import org.springblade.system.pojo.entity.PortTerminal;
import org.springblade.system.pojo.vo.PortTerminalVO;
import org.springblade.system.service.IPortTerminalService;
import org.springblade.system.wrapper.PortTerminalWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 港口码头主数据 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "port_terminal")
@RequestMapping("/port-terminal")
@Tag(name = "港口码头主数据", description = "港口码头主数据")
public class PortTerminalController extends BladeController {
private final IPortTerminalService portTerminalService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入portTerminal")
public R<PortTerminalVO> detail(PortTerminal portTerminal) {
PortTerminal detail = portTerminalService.getOne(Condition.getQueryWrapper(portTerminal));
return R.data(PortTerminalWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入portTerminal")
public R<IPage<PortTerminalVO>> list(PortTerminalVO portTerminal, Query query) {
IPage<PortTerminalVO> pages = portTerminalService.selectPortTerminalPage(Condition.getPage(query), portTerminal);
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入portTerminal")
public R submit(@Valid @RequestBody PortTerminal portTerminal) {
return R.status(portTerminalService.submit(portTerminal));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(portTerminalService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(portTerminalService.changeStatus(id, status));
}
/**
* 上级港口下拉数据源
*/
@GetMapping("/port-select")
@ApiOperationSupport(order = 6)
@Operation(summary = "上级港口下拉数据源")
public R<List<PortTerminal>> portSelect() {
return R.data(portTerminalService.selectEnabledPorts());
}
/**
* 导入港口码头主数据
*/
@PostMapping("/import-port-terminal")
@ApiOperationSupport(order = 7)
@Operation(summary = "导入港口码头主数据", description = "传入excel")
public R importPortTerminal(MultipartFile file) {
PortTerminalImporter portTerminalImporter = new PortTerminalImporter(portTerminalService);
ExcelUtil.save(file, portTerminalImporter, PortTerminalExcel.class);
return R.success("操作成功");
}
/**
* 导出港口码头主数据
*/
@GetMapping("/export-port-terminal")
@ApiOperationSupport(order = 8)
@Operation(summary = "导出港口码头主数据")
public void exportPortTerminal(@Parameter(hidden = true) @RequestParam Map<String, Object> portTerminal, HttpServletResponse response) {
Object ids = portTerminal.remove("ids");
QueryWrapper<PortTerminal> queryWrapper = Condition.getQueryWrapper(portTerminal, PortTerminal.class);
if (Func.isNotEmpty(ids)) {
queryWrapper.lambda().in(PortTerminal::getId, Func.toLongList(ids.toString()));
}
List<PortTerminalExcel> list = portTerminalService.exportPortTerminal(queryWrapper);
ExcelUtil.export(response, "港口码头主数据" + DateUtil.time(), "港口码头主数据表", list, PortTerminalExcel.class);
}
/**
* 导出模板
*/
@GetMapping("/export-template")
@ApiOperationSupport(order = 9)
@Operation(summary = "导出模板")
public void exportTemplate(HttpServletResponse response) {
List<PortTerminalExcel> list = new ArrayList<>();
ExcelUtil.export(response, "港口码头主数据模板", "港口码头主数据表", list, PortTerminalExcel.class);
}
}

View File

@@ -0,0 +1,171 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.RailwayStationExcel;
import org.springblade.system.excel.RailwayStationImporter;
import org.springblade.system.pojo.entity.RailwayStation;
import org.springblade.system.pojo.vo.RailwayStationVO;
import org.springblade.system.service.IRailwayStationService;
import org.springblade.system.wrapper.RailwayStationWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 铁路车站主数据 控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "railway_station")
@RequestMapping("/railway-station")
@Tag(name = "铁路车站主数据", description = "铁路车站主数据")
public class RailwayStationController extends BladeController {
private final IRailwayStationService railwayStationService;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入railwayStation")
public R<RailwayStationVO> detail(RailwayStation railwayStation) {
RailwayStation detail = railwayStationService.getOne(Condition.getQueryWrapper(railwayStation));
return R.data(RailwayStationWrapper.build().entityVO(detail));
}
/**
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入railwayStation")
public R<IPage<RailwayStationVO>> list(RailwayStationVO railwayStation, Query query) {
IPage<RailwayStationVO> pages = railwayStationService.selectRailwayStationPage(Condition.getPage(query), railwayStation);
return R.data(pages);
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入railwayStation")
public R submit(@Valid @RequestBody RailwayStation railwayStation) {
return R.status(railwayStationService.submit(railwayStation));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(railwayStationService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(railwayStationService.changeStatus(id, status));
}
/**
* 导入铁路车站主数据
*/
@PostMapping("/import-railway-station")
@ApiOperationSupport(order = 6)
@Operation(summary = "导入铁路车站主数据", description = "传入excel")
public R importRailwayStation(MultipartFile file) {
RailwayStationImporter railwayStationImporter = new RailwayStationImporter(railwayStationService);
ExcelUtil.save(file, railwayStationImporter, RailwayStationExcel.class);
return R.success("操作成功");
}
/**
* 导出铁路车站主数据
*/
@GetMapping("/export-railway-station")
@ApiOperationSupport(order = 7)
@Operation(summary = "导出铁路车站主数据")
public void exportRailwayStation(@Parameter(hidden = true) @RequestParam Map<String, Object> railwayStation, HttpServletResponse response) {
Object ids = railwayStation.remove("ids");
QueryWrapper<RailwayStation> queryWrapper = Condition.getQueryWrapper(railwayStation, RailwayStation.class);
if (Func.isNotEmpty(ids)) {
queryWrapper.lambda().in(RailwayStation::getId, Func.toLongList(ids.toString()));
}
List<RailwayStationExcel> list = railwayStationService.exportRailwayStation(queryWrapper);
ExcelUtil.export(response, "铁路车站主数据" + DateUtil.time(), "铁路车站主数据表", list, RailwayStationExcel.class);
}
/**
* 导出模板
*/
@GetMapping("/export-template")
@ApiOperationSupport(order = 8)
@Operation(summary = "导出模板")
public void exportTemplate(HttpServletResponse response) {
List<RailwayStationExcel> list = new ArrayList<>();
ExcelUtil.export(response, "铁路车站主数据模板", "铁路车站主数据表", list, RailwayStationExcel.class);
}
}

View File

@@ -0,0 +1,94 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
import cn.idev.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 空港机场主数据 Excel
*
* @author Chill
*/
@Data
@ColumnWidth(18)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class AirportMasterExcel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelIgnore
private Long id;
@ExcelProperty("编码")
private String code;
@ExcelProperty("IATA编码")
private String iataCode;
@ExcelProperty("ICAO代码")
private String icaoCode;
@ExcelProperty("机场标准名称")
private String name;
@ExcelProperty("机场简称")
private String shortName;
@ExcelProperty("所属省份")
private String provinceName;
@ExcelProperty("所属城市")
private String cityName;
@ExcelProperty("经度")
private BigDecimal longitude;
@ExcelProperty("纬度")
private BigDecimal latitude;
@ExcelProperty("数据来源")
private String dataSource;
@ExcelProperty("状态")
private String statusName;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
private String errorMessage;
}

View File

@@ -0,0 +1,49 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.system.service.IAirportMasterService;
import java.util.List;
/**
* 空港机场主数据导入类
*
* @author Chill
*/
@RequiredArgsConstructor
public class AirportMasterImporter implements ExcelImporter<AirportMasterExcel> {
private final IAirportMasterService service;
@Override
public void save(List<AirportMasterExcel> data) {
service.importAirportMaster(data);
}
}

View File

@@ -0,0 +1,94 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
import cn.idev.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 港口码头主数据 Excel
*
* @author Chill
*/
@Data
@ColumnWidth(18)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class PortTerminalExcel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelIgnore
private Long id;
@ExcelProperty("编码")
private String code;
@ExcelProperty("港口/码头名称")
private String name;
@ExcelProperty("类型")
private String category;
@ExcelProperty("上级港口")
private String parentName;
@ExcelProperty("上级港口编码")
private String parentCode;
@ExcelProperty("国家")
private String country;
@ExcelProperty("城市")
private String city;
@ExcelProperty("经度")
private BigDecimal longitude;
@ExcelProperty("纬度")
private BigDecimal latitude;
@ExcelProperty("数据来源")
private String dataSource;
@ExcelProperty("状态")
private String statusName;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
private String errorMessage;
}

View File

@@ -0,0 +1,49 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.system.service.IPortTerminalService;
import java.util.List;
/**
* 港口码头主数据导入类
*
* @author Chill
*/
@RequiredArgsConstructor
public class PortTerminalImporter implements ExcelImporter<PortTerminalExcel> {
private final IPortTerminalService service;
@Override
public void save(List<PortTerminalExcel> data) {
service.importPortTerminal(data);
}
}

View File

@@ -0,0 +1,94 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
import cn.idev.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 铁路车站主数据 Excel
*
* @author Chill
*/
@Data
@ColumnWidth(18)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class RailwayStationExcel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ExcelIgnore
private Long id;
@ExcelProperty("编码")
private String code;
@ExcelProperty("TMIS国标编码")
private String tmisCode;
@ExcelProperty("电报码")
private String telegraphCode;
@ExcelProperty("车站名称")
private String name;
@ExcelProperty("所属铁路线路")
private String railwayLine;
@ExcelProperty("所属省份")
private String provinceName;
@ExcelProperty("所属城市")
private String cityName;
@ExcelProperty("经度")
private BigDecimal longitude;
@ExcelProperty("纬度")
private BigDecimal latitude;
@ExcelProperty("数据来源")
private String dataSource;
@ExcelProperty("状态")
private String statusName;
@ExcelProperty("备注")
private String remark;
@ExcelProperty("报错文案")
private String errorMessage;
}

View File

@@ -0,0 +1,49 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.system.service.IRailwayStationService;
import java.util.List;
/**
* 铁路车站主数据导入类
*
* @author Chill
*/
@RequiredArgsConstructor
public class RailwayStationImporter implements ExcelImporter<RailwayStationExcel> {
private final IRailwayStationService service;
@Override
public void save(List<RailwayStationExcel> data) {
service.importRailwayStation(data);
}
}

View File

@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.AirportMaster;
import org.springblade.system.pojo.vo.AirportMasterVO;
import java.util.List;
/**
* 空港机场主数据 Mapper 接口
*
* @author Chill
*/
public interface AirportMasterMapper extends BaseMapper<AirportMaster> {
/**
* 自定义分页
*
* @param page 分页参数
* @param airportMaster 查询参数
* @return 空港机场分页
*/
List<AirportMasterVO> selectAirportMasterPage(IPage<AirportMasterVO> page, @Param("airportMaster") AirportMasterVO airportMaster);
}

View File

@@ -0,0 +1,53 @@
<?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="org.springblade.system.mapper.AirportMasterMapper">
<resultMap id="airportMasterResultMap" type="org.springblade.system.pojo.vo.AirportMasterVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="code" property="code"/>
<result column="iata_code" property="iataCode"/>
<result column="icao_code" property="icaoCode"/>
<result column="name" property="name"/>
<result column="short_name" property="shortName"/>
<result column="province_code" property="provinceCode"/>
<result column="province_name" property="provinceName"/>
<result column="city_code" property="cityCode"/>
<result column="city_name" property="cityName"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="data_source" property="dataSource"/>
<result column="remark" property="remark"/>
</resultMap>
<select id="selectAirportMasterPage" resultMap="airportMasterResultMap">
SELECT
*
FROM
blade_airport_master
WHERE
is_deleted = 0
<if test="airportMaster.code != null and airportMaster.code != ''">
<bind name="codeLike" value="'%' + airportMaster.code + '%'"/>
AND code LIKE #{codeLike}
</if>
<if test="airportMaster.name != null and airportMaster.name != ''">
<bind name="nameLike" value="'%' + airportMaster.name + '%'"/>
AND name LIKE #{nameLike}
</if>
<if test="airportMaster.dataSource != null and airportMaster.dataSource != ''">
AND data_source = #{airportMaster.dataSource}
</if>
<if test="airportMaster.status != null">
AND status = #{airportMaster.status}
</if>
ORDER BY update_time DESC, create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.system.pojo.entity.PortTerminal;
import org.springblade.system.pojo.vo.PortTerminalVO;
import java.util.List;
/**
* 港口码头主数据 Mapper 接口
*
* @author Chill
*/
public interface PortTerminalMapper extends BaseMapper<PortTerminal> {
/**
* 自定义分页
*
* @param page 分页参数
* @param portTerminal 查询参数
* @return 港口码头列表
*/
List<PortTerminalVO> selectPortTerminalPage(IPage<PortTerminalVO> page, PortTerminalVO portTerminal);
}

View File

@@ -0,0 +1,61 @@
<?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="org.springblade.system.mapper.PortTerminalMapper">
<resultMap id="portTerminalResultMap" type="org.springblade.system.pojo.vo.PortTerminalVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="code" property="code"/>
<result column="name" property="name"/>
<result column="category" property="category"/>
<result column="parent_id" property="parentId"/>
<result column="parent_code" property="parentCode"/>
<result column="parent_name" property="parentName"/>
<result column="country" property="country"/>
<result column="city" property="city"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="data_source" property="dataSource"/>
<result column="remark" property="remark"/>
</resultMap>
<select id="selectPortTerminalPage" resultMap="portTerminalResultMap">
SELECT
*
FROM
blade_port_terminal
WHERE
is_deleted = 0
<if test="portTerminal.code != null and portTerminal.code != ''">
<bind name="codeLike" value="'%' + portTerminal.code + '%'"/>
AND code LIKE #{codeLike}
</if>
<if test="portTerminal.name != null and portTerminal.name != ''">
<bind name="nameLike" value="'%' + portTerminal.name + '%'"/>
AND name LIKE #{nameLike}
</if>
<if test="portTerminal.category != null and portTerminal.category != ''">
AND category = #{portTerminal.category}
</if>
<if test="portTerminal.dataSource != null and portTerminal.dataSource != ''">
AND data_source = #{portTerminal.dataSource}
</if>
<if test="portTerminal.city != null and portTerminal.city != ''">
AND city = #{portTerminal.city}
</if>
<if test="portTerminal.country != null and portTerminal.country != ''">
AND country = #{portTerminal.country}
</if>
<if test="portTerminal.status != null">
AND status = #{portTerminal.status}
</if>
ORDER BY update_time DESC, create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.RailwayStation;
import org.springblade.system.pojo.vo.RailwayStationVO;
import java.util.List;
/**
* 铁路车站主数据 Mapper 接口
*
* @author Chill
*/
public interface RailwayStationMapper extends BaseMapper<RailwayStation> {
/**
* 自定义分页
*
* @param page 分页参数
* @param railwayStation 查询参数
* @return 铁路车站分页
*/
List<RailwayStationVO> selectRailwayStationPage(IPage<RailwayStationVO> page, @Param("railwayStation") RailwayStationVO railwayStation);
}

View File

@@ -0,0 +1,53 @@
<?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="org.springblade.system.mapper.RailwayStationMapper">
<resultMap id="railwayStationResultMap" type="org.springblade.system.pojo.vo.RailwayStationVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="code" property="code"/>
<result column="tmis_code" property="tmisCode"/>
<result column="telegraph_code" property="telegraphCode"/>
<result column="name" property="name"/>
<result column="railway_line" property="railwayLine"/>
<result column="province_code" property="provinceCode"/>
<result column="province_name" property="provinceName"/>
<result column="city_code" property="cityCode"/>
<result column="city_name" property="cityName"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="data_source" property="dataSource"/>
<result column="remark" property="remark"/>
</resultMap>
<select id="selectRailwayStationPage" resultMap="railwayStationResultMap">
SELECT
*
FROM
blade_railway_station
WHERE
is_deleted = 0
<if test="railwayStation.code != null and railwayStation.code != ''">
<bind name="codeLike" value="'%' + railwayStation.code + '%'"/>
AND code LIKE #{codeLike}
</if>
<if test="railwayStation.name != null and railwayStation.name != ''">
<bind name="nameLike" value="'%' + railwayStation.name + '%'"/>
AND name LIKE #{nameLike}
</if>
<if test="railwayStation.dataSource != null and railwayStation.dataSource != ''">
AND data_source = #{railwayStation.dataSource}
</if>
<if test="railwayStation.status != null">
AND status = #{railwayStation.status}
</if>
ORDER BY update_time DESC, create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,85 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.excel.AirportMasterExcel;
import org.springblade.system.pojo.entity.AirportMaster;
import org.springblade.system.pojo.vo.AirportMasterVO;
import java.util.List;
/**
* 空港机场主数据 服务类
*
* @author Chill
*/
public interface IAirportMasterService extends BaseService<AirportMaster> {
/**
* 自定义分页
*
* @param page 分页参数
* @param airportMaster 查询参数
* @return 空港机场分页
*/
IPage<AirportMasterVO> selectAirportMasterPage(IPage<AirportMasterVO> page, AirportMasterVO airportMaster);
/**
* 新增或修改空港机场
*
* @param airportMaster 空港机场
* @return 是否成功
*/
boolean submit(AirportMaster airportMaster);
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
/**
* 导入空港机场
*
* @param data 导入数据
*/
void importAirportMaster(List<AirportMasterExcel> data);
/**
* 导出空港机场
*
* @param queryWrapper 查询条件
* @return 导出数据
*/
List<AirportMasterExcel> exportAirportMaster(Wrapper<AirportMaster> queryWrapper);
}

View File

@@ -0,0 +1,92 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.excel.PortTerminalExcel;
import org.springblade.system.pojo.entity.PortTerminal;
import org.springblade.system.pojo.vo.PortTerminalVO;
import java.util.List;
/**
* 港口码头主数据 服务类
*
* @author Chill
*/
public interface IPortTerminalService extends BaseService<PortTerminal> {
/**
* 自定义分页
*
* @param page 分页参数
* @param portTerminal 查询参数
* @return 港口码头分页
*/
IPage<PortTerminalVO> selectPortTerminalPage(IPage<PortTerminalVO> page, PortTerminalVO portTerminal);
/**
* 新增或修改港口码头
*
* @param portTerminal 港口码头
* @return 是否成功
*/
boolean submit(PortTerminal portTerminal);
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
/**
* 启用港口下拉数据源
*
* @return 港口列表
*/
List<PortTerminal> selectEnabledPorts();
/**
* 导入港口码头
*
* @param data 导入数据
*/
void importPortTerminal(List<PortTerminalExcel> data);
/**
* 导出港口码头
*
* @param queryWrapper 查询条件
* @return 导出数据
*/
List<PortTerminalExcel> exportPortTerminal(Wrapper<PortTerminal> queryWrapper);
}

View File

@@ -0,0 +1,85 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.excel.RailwayStationExcel;
import org.springblade.system.pojo.entity.RailwayStation;
import org.springblade.system.pojo.vo.RailwayStationVO;
import java.util.List;
/**
* 铁路车站主数据 服务类
*
* @author Chill
*/
public interface IRailwayStationService extends BaseService<RailwayStation> {
/**
* 自定义分页
*
* @param page 分页参数
* @param railwayStation 查询参数
* @return 铁路车站分页
*/
IPage<RailwayStationVO> selectRailwayStationPage(IPage<RailwayStationVO> page, RailwayStationVO railwayStation);
/**
* 新增或修改铁路车站
*
* @param railwayStation 铁路车站
* @return 是否成功
*/
boolean submit(RailwayStation railwayStation);
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
/**
* 导入铁路车站
*
* @param data 导入数据
*/
void importRailwayStation(List<RailwayStationExcel> data);
/**
* 导出铁路车站
*
* @param queryWrapper 查询条件
* @return 导出数据
*/
List<RailwayStationExcel> exportRailwayStation(Wrapper<RailwayStation> queryWrapper);
}

View File

@@ -0,0 +1,255 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.AirportMasterExcel;
import org.springblade.system.mapper.AirportMasterMapper;
import org.springblade.system.pojo.entity.AirportMaster;
import org.springblade.system.pojo.entity.Region;
import org.springblade.system.pojo.vo.AirportMasterVO;
import org.springblade.system.service.IAirportMasterService;
import org.springblade.system.service.IRegionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* 空港机场主数据 服务实现类
*
* @author Chill
*/
@Service
@AllArgsConstructor
public class AirportMasterServiceImpl extends BaseServiceImpl<AirportMasterMapper, AirportMaster> implements IAirportMasterService {
private static final String CODE_PREFIX = "JC-";
private static final String SOURCE_BATCH = "批量导入";
private static final String SOURCE_MANUAL = "手工导入";
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final int REMARK_MAX_LENGTH = 200;
private static final Pattern IATA_CODE_PATTERN = Pattern.compile("^[A-Z]{3}$");
private static final Pattern ICAO_CODE_PATTERN = Pattern.compile("^[A-Z]{4}$");
private static final BigDecimal MIN_LONGITUDE = BigDecimal.valueOf(-180);
private static final BigDecimal MAX_LONGITUDE = BigDecimal.valueOf(180);
private static final BigDecimal MIN_LATITUDE = BigDecimal.valueOf(-90);
private static final BigDecimal MAX_LATITUDE = BigDecimal.valueOf(90);
private final IRegionService regionService;
@Override
public IPage<AirportMasterVO> selectAirportMasterPage(IPage<AirportMasterVO> page, AirportMasterVO airportMaster) {
return page.setRecords(baseMapper.selectAirportMasterPage(page, airportMaster));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(AirportMaster airportMaster) {
prepare(airportMaster, SOURCE_MANUAL);
validate(airportMaster);
return saveOrUpdate(airportMaster);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
AirportMaster airportMaster = getById(id);
if (Func.isEmpty(airportMaster)) {
throw new ServiceException("空港机场不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
AirportMaster update = new AirportMaster();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importAirportMaster(List<AirportMasterExcel> data) {
List<String> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
AirportMasterExcel excel = data.get(index);
try {
AirportMaster airportMaster = Objects.requireNonNull(BeanUtil.copyProperties(excel, AirportMaster.class));
airportMaster.setDataSource(SOURCE_BATCH);
airportMaster.setStatus(STATUS_ENABLED);
prepare(airportMaster, SOURCE_BATCH);
validate(airportMaster);
save(airportMaster);
} catch (Exception exception) {
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
errorList.add("" + (index + 2) + "行:" + message);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
}
@Override
public List<AirportMasterExcel> exportAirportMaster(Wrapper<AirportMaster> queryWrapper) {
List<AirportMaster> airportMasterList = list(queryWrapper);
return airportMasterList.stream().map(airportMaster -> {
AirportMasterExcel excel = Objects.requireNonNull(BeanUtil.copyProperties(airportMaster, AirportMasterExcel.class));
excel.setStatusName(Objects.equals(airportMaster.getStatus(), STATUS_ENABLED) ? "启用" : "停用");
return excel;
}).toList();
}
private void prepare(AirportMaster airportMaster, String defaultDataSource) {
airportMaster.setIataCode(trimToEmpty(airportMaster.getIataCode()).toUpperCase(Locale.ROOT));
airportMaster.setCode(CODE_PREFIX + airportMaster.getIataCode());
airportMaster.setIcaoCode(trimToEmpty(airportMaster.getIcaoCode()).toUpperCase(Locale.ROOT));
airportMaster.setName(trimToEmpty(airportMaster.getName()));
airportMaster.setShortName(trimToNull(airportMaster.getShortName()));
airportMaster.setProvinceCode(trimToNull(airportMaster.getProvinceCode()));
airportMaster.setProvinceName(trimToNull(airportMaster.getProvinceName()));
airportMaster.setCityCode(trimToNull(airportMaster.getCityCode()));
airportMaster.setCityName(trimToNull(airportMaster.getCityName()));
airportMaster.setRemark(trimToNull(airportMaster.getRemark()));
airportMaster.setDataSource(Func.toStrWithEmpty(airportMaster.getDataSource(), defaultDataSource));
if (Func.isEmpty(airportMaster.getStatus())) {
airportMaster.setStatus(STATUS_ENABLED);
}
fillRegion(airportMaster);
}
private void validate(AirportMaster airportMaster) {
if (Func.isEmpty(airportMaster.getIataCode())) {
throw new ServiceException("IATA编码不能为空");
}
if (!IATA_CODE_PATTERN.matcher(airportMaster.getIataCode()).matches()) {
throw new ServiceException("IATA编码为3位大写字母");
}
if (Func.isEmpty(airportMaster.getIcaoCode())) {
throw new ServiceException("ICAO代码不能为空");
}
if (!ICAO_CODE_PATTERN.matcher(airportMaster.getIcaoCode()).matches()) {
throw new ServiceException("ICAO代码为4位大写字母");
}
if (Func.isEmpty(airportMaster.getName())) {
throw new ServiceException("机场标准名称不能为空");
}
if (Func.isEmpty(airportMaster.getProvinceCode()) || Func.isEmpty(airportMaster.getCityCode())) {
throw new ServiceException("请选择省份和城市");
}
validateCoordinate(airportMaster.getLongitude(), MIN_LONGITUDE, MAX_LONGITUDE, "经度");
validateCoordinate(airportMaster.getLatitude(), MIN_LATITUDE, MAX_LATITUDE, "纬度");
if (Func.isNotEmpty(airportMaster.getRemark()) && airportMaster.getRemark().length() > REMARK_MAX_LENGTH) {
throw new ServiceException("备注不能超过200字");
}
validateUnique(airportMaster, AirportMaster::getIataCode, airportMaster.getIataCode(), "该IATA编码已存在");
validateUnique(airportMaster, AirportMaster::getIcaoCode, airportMaster.getIcaoCode(), "该ICAO代码已存在");
validateUnique(airportMaster, AirportMaster::getCode, airportMaster.getCode(), "该编码已存在");
}
private void fillRegion(AirportMaster airportMaster) {
Region province = null;
if (Func.isNotEmpty(airportMaster.getProvinceCode())) {
province = regionService.getById(airportMaster.getProvinceCode());
}
if (Func.isEmpty(province) && Func.isNotEmpty(airportMaster.getProvinceName())) {
province = regionService.getOne(Wrappers.<Region>lambdaQuery()
.eq(Region::getParentCode, "00")
.eq(Region::getName, airportMaster.getProvinceName()), false);
}
if (Func.isEmpty(province)) {
throw new ServiceException("请选择省份");
}
Region city = null;
if (Func.isNotEmpty(airportMaster.getCityCode())) {
city = regionService.getById(airportMaster.getCityCode());
}
if (Func.isEmpty(city) && Func.isNotEmpty(airportMaster.getCityName())) {
city = regionService.getOne(Wrappers.<Region>lambdaQuery()
.eq(Region::getParentCode, province.getCode())
.eq(Region::getName, airportMaster.getCityName()), false);
}
if (Func.isEmpty(city)) {
throw new ServiceException("请选择城市");
}
if (!Objects.equals(city.getParentCode(), province.getCode())) {
throw new ServiceException("所属城市与所属省份不匹配");
}
airportMaster.setProvinceCode(province.getCode());
airportMaster.setProvinceName(province.getName());
airportMaster.setCityCode(city.getCode());
airportMaster.setCityName(city.getName());
}
private void validateCoordinate(BigDecimal value, BigDecimal min, BigDecimal max, String name) {
if (value == null) {
return;
}
if (value.compareTo(min) < 0 || value.compareTo(max) > 0) {
throw new ServiceException(name + "范围不正确");
}
}
private void validateUnique(AirportMaster airportMaster, com.baomidou.mybatisplus.core.toolkit.support.SFunction<AirportMaster, ?> column, String value, String message) {
LambdaQueryWrapper<AirportMaster> queryWrapper = Wrappers.<AirportMaster>lambdaQuery()
.eq(column, value)
.eq(AirportMaster::getIsDeleted, 0);
if (Func.isNotEmpty(airportMaster.getId())) {
queryWrapper.ne(AirportMaster::getId, airportMaster.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException(message);
}
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
private String trimToNull(String value) {
String trimValue = trimToEmpty(value);
return trimValue.isEmpty() ? null : trimValue;
}
}

View File

@@ -0,0 +1,237 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.PortTerminalExcel;
import org.springblade.system.mapper.PortTerminalMapper;
import org.springblade.system.pojo.entity.PortTerminal;
import org.springblade.system.pojo.vo.PortTerminalVO;
import org.springblade.system.service.IPortTerminalService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* 港口码头主数据 服务实现类
*
* @author Chill
*/
@Service
public class PortTerminalServiceImpl extends BaseServiceImpl<PortTerminalMapper, PortTerminal> implements IPortTerminalService {
private static final String CATEGORY_PORT = "港口";
private static final String CATEGORY_TERMINAL = "码头";
private static final String SOURCE_INITIAL = "初始导入";
private static final String SOURCE_BATCH = "批量导入";
private static final String SOURCE_MANUAL = "手工导入";
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final Pattern PORT_CODE_PATTERN = Pattern.compile("^[A-Z]{5}$");
private static final Pattern TERMINAL_CODE_PATTERN = Pattern.compile("^[A-Z]{5}-[A-Z0-9]+$");
@Override
public IPage<PortTerminalVO> selectPortTerminalPage(IPage<PortTerminalVO> page, PortTerminalVO portTerminal) {
return page.setRecords(baseMapper.selectPortTerminalPage(page, portTerminal));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(PortTerminal portTerminal) {
prepare(portTerminal, SOURCE_MANUAL);
validate(portTerminal);
return saveOrUpdate(portTerminal);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
PortTerminal portTerminal = getById(id);
if (Func.isEmpty(portTerminal)) {
throw new ServiceException("港口码头不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
if (Objects.equals(status, STATUS_DISABLED) && CATEGORY_PORT.equals(portTerminal.getCategory())) {
validateEnabledTerminal(portTerminal.getId());
}
PortTerminal update = new PortTerminal();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
@Override
public List<PortTerminal> selectEnabledPorts() {
return list(Wrappers.<PortTerminal>lambdaQuery()
.eq(PortTerminal::getCategory, CATEGORY_PORT)
.eq(PortTerminal::getStatus, STATUS_ENABLED)
.orderByAsc(PortTerminal::getCode));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importPortTerminal(List<PortTerminalExcel> data) {
List<String> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
PortTerminalExcel excel = data.get(index);
try {
PortTerminal portTerminal = Objects.requireNonNull(BeanUtil.copyProperties(excel, PortTerminal.class));
portTerminal.setDataSource(SOURCE_BATCH);
portTerminal.setStatus(STATUS_ENABLED);
prepare(portTerminal, SOURCE_BATCH);
validate(portTerminal);
save(portTerminal);
} catch (Exception exception) {
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
errorList.add("" + (index + 2) + "行:" + message);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
}
@Override
public List<PortTerminalExcel> exportPortTerminal(Wrapper<PortTerminal> queryWrapper) {
List<PortTerminal> portTerminalList = list(queryWrapper);
return portTerminalList.stream().map(portTerminal -> {
PortTerminalExcel excel = Objects.requireNonNull(BeanUtil.copyProperties(portTerminal, PortTerminalExcel.class));
excel.setStatusName(Objects.equals(portTerminal.getStatus(), STATUS_ENABLED) ? "启用" : "停用");
return excel;
}).toList();
}
private void prepare(PortTerminal portTerminal, String defaultDataSource) {
portTerminal.setCode(trimToEmpty(portTerminal.getCode()).toUpperCase(Locale.ROOT));
portTerminal.setCategory(trimToEmpty(portTerminal.getCategory()));
portTerminal.setName(trimToEmpty(portTerminal.getName()));
portTerminal.setDataSource(Func.toStrWithEmpty(portTerminal.getDataSource(), defaultDataSource));
if (Func.isEmpty(portTerminal.getStatus())) {
portTerminal.setStatus(STATUS_ENABLED);
}
if (CATEGORY_PORT.equals(portTerminal.getCategory())) {
portTerminal.setParentId(null);
portTerminal.setParentCode(null);
portTerminal.setParentName(null);
return;
}
fillParentPort(portTerminal);
}
private void fillParentPort(PortTerminal portTerminal) {
PortTerminal parent = null;
if (Func.isNotEmpty(portTerminal.getParentId())) {
parent = getById(portTerminal.getParentId());
}
if (Func.isEmpty(parent) && Func.isNotEmpty(portTerminal.getParentCode())) {
parent = getOne(Wrappers.<PortTerminal>lambdaQuery()
.eq(PortTerminal::getCode, trimToEmpty(portTerminal.getParentCode()).toUpperCase(Locale.ROOT))
.eq(PortTerminal::getCategory, CATEGORY_PORT)
.eq(PortTerminal::getIsDeleted, 0));
}
if (Func.isEmpty(parent)) {
throw new ServiceException("码头必须选择上级港口");
}
if (!CATEGORY_PORT.equals(parent.getCategory())) {
throw new ServiceException("上级港口类型不正确");
}
portTerminal.setParentId(parent.getId());
portTerminal.setParentCode(parent.getCode());
portTerminal.setParentName(parent.getName());
portTerminal.setCountry(parent.getCountry());
portTerminal.setCity(parent.getCity());
}
private void validate(PortTerminal portTerminal) {
if (!CATEGORY_PORT.equals(portTerminal.getCategory()) && !CATEGORY_TERMINAL.equals(portTerminal.getCategory())) {
throw new ServiceException("类型只能为港口或码头");
}
if (Func.isEmpty(portTerminal.getCode())) {
throw new ServiceException("编码不能为空");
}
if (CATEGORY_PORT.equals(portTerminal.getCategory()) && !PORT_CODE_PATTERN.matcher(portTerminal.getCode()).matches()) {
throw new ServiceException("港口编码为5位大写字母");
}
if (CATEGORY_TERMINAL.equals(portTerminal.getCategory()) && !TERMINAL_CODE_PATTERN.matcher(portTerminal.getCode()).matches()) {
throw new ServiceException("码头编码格式为港口编码-码头标识");
}
if (CATEGORY_TERMINAL.equals(portTerminal.getCategory()) && !portTerminal.getCode().startsWith(portTerminal.getParentCode() + "-")) {
throw new ServiceException("码头编码必须以所属港口编码开头");
}
validateUniqueCode(portTerminal);
if (Objects.equals(portTerminal.getStatus(), STATUS_DISABLED) && CATEGORY_PORT.equals(portTerminal.getCategory())) {
validateEnabledTerminal(portTerminal.getId());
}
}
private void validateUniqueCode(PortTerminal portTerminal) {
LambdaQueryWrapper<PortTerminal> queryWrapper = Wrappers.<PortTerminal>lambdaQuery()
.eq(PortTerminal::getCode, portTerminal.getCode())
.eq(PortTerminal::getIsDeleted, 0);
if (Func.isNotEmpty(portTerminal.getId())) {
queryWrapper.ne(PortTerminal::getId, portTerminal.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException("该编码已存在");
}
}
private void validateEnabledTerminal(Long parentId) {
if (Func.isEmpty(parentId)) {
return;
}
long count = count(Wrappers.<PortTerminal>lambdaQuery()
.eq(PortTerminal::getParentId, parentId)
.eq(PortTerminal::getCategory, CATEGORY_TERMINAL)
.eq(PortTerminal::getStatus, STATUS_ENABLED)
.eq(PortTerminal::getIsDeleted, 0));
if (count > 0L) {
throw new ServiceException("该港口下存在已启用码头,请先停用码头");
}
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
}

View File

@@ -0,0 +1,255 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.excel.RailwayStationExcel;
import org.springblade.system.mapper.RailwayStationMapper;
import org.springblade.system.pojo.entity.RailwayStation;
import org.springblade.system.pojo.entity.Region;
import org.springblade.system.pojo.vo.RailwayStationVO;
import org.springblade.system.service.IRailwayStationService;
import org.springblade.system.service.IRegionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* 铁路车站主数据 服务实现类
*
* @author Chill
*/
@Service
@AllArgsConstructor
public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMapper, RailwayStation> implements IRailwayStationService {
private static final String CODE_PREFIX = "TL";
private static final String SOURCE_BATCH = "批量导入";
private static final String SOURCE_MANUAL = "手工导入";
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final int REMARK_MAX_LENGTH = 200;
private static final Pattern TMIS_CODE_PATTERN = Pattern.compile("^\\d{5}$");
private static final Pattern TELEGRAPH_CODE_PATTERN = Pattern.compile("^[A-Z]{3}$");
private static final BigDecimal MIN_LONGITUDE = BigDecimal.valueOf(-180);
private static final BigDecimal MAX_LONGITUDE = BigDecimal.valueOf(180);
private static final BigDecimal MIN_LATITUDE = BigDecimal.valueOf(-90);
private static final BigDecimal MAX_LATITUDE = BigDecimal.valueOf(90);
private final IRegionService regionService;
@Override
public IPage<RailwayStationVO> selectRailwayStationPage(IPage<RailwayStationVO> page, RailwayStationVO railwayStation) {
return page.setRecords(baseMapper.selectRailwayStationPage(page, railwayStation));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(RailwayStation railwayStation) {
prepare(railwayStation, SOURCE_MANUAL);
validate(railwayStation);
return saveOrUpdate(railwayStation);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
RailwayStation railwayStation = getById(id);
if (Func.isEmpty(railwayStation)) {
throw new ServiceException("铁路车站不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
RailwayStation update = new RailwayStation();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void importRailwayStation(List<RailwayStationExcel> data) {
List<String> errorList = new ArrayList<>();
for (int index = 0; index < data.size(); index++) {
RailwayStationExcel excel = data.get(index);
try {
RailwayStation railwayStation = Objects.requireNonNull(BeanUtil.copyProperties(excel, RailwayStation.class));
railwayStation.setDataSource(SOURCE_BATCH);
railwayStation.setStatus(STATUS_ENABLED);
prepare(railwayStation, SOURCE_BATCH);
validate(railwayStation);
save(railwayStation);
} catch (Exception exception) {
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
errorList.add("" + (index + 2) + "行:" + message);
}
}
if (Func.isNotEmpty(errorList)) {
throw new ServiceException(String.join("", errorList));
}
}
@Override
public List<RailwayStationExcel> exportRailwayStation(Wrapper<RailwayStation> queryWrapper) {
List<RailwayStation> railwayStationList = list(queryWrapper);
return railwayStationList.stream().map(railwayStation -> {
RailwayStationExcel excel = Objects.requireNonNull(BeanUtil.copyProperties(railwayStation, RailwayStationExcel.class));
excel.setStatusName(Objects.equals(railwayStation.getStatus(), STATUS_ENABLED) ? "启用" : "停用");
return excel;
}).toList();
}
private void prepare(RailwayStation railwayStation, String defaultDataSource) {
railwayStation.setTmisCode(trimToEmpty(railwayStation.getTmisCode()));
railwayStation.setCode(CODE_PREFIX + railwayStation.getTmisCode());
railwayStation.setTelegraphCode(trimToEmpty(railwayStation.getTelegraphCode()).toUpperCase(Locale.ROOT));
railwayStation.setName(trimToEmpty(railwayStation.getName()));
railwayStation.setRailwayLine(trimToNull(railwayStation.getRailwayLine()));
railwayStation.setProvinceCode(trimToNull(railwayStation.getProvinceCode()));
railwayStation.setProvinceName(trimToNull(railwayStation.getProvinceName()));
railwayStation.setCityCode(trimToNull(railwayStation.getCityCode()));
railwayStation.setCityName(trimToNull(railwayStation.getCityName()));
railwayStation.setRemark(trimToNull(railwayStation.getRemark()));
railwayStation.setDataSource(Func.toStrWithEmpty(railwayStation.getDataSource(), defaultDataSource));
if (Func.isEmpty(railwayStation.getStatus())) {
railwayStation.setStatus(STATUS_ENABLED);
}
fillRegion(railwayStation);
}
private void validate(RailwayStation railwayStation) {
if (Func.isEmpty(railwayStation.getTmisCode())) {
throw new ServiceException("TMIS国标编码不能为空");
}
if (!TMIS_CODE_PATTERN.matcher(railwayStation.getTmisCode()).matches()) {
throw new ServiceException("TMIS国标编码为5位数字");
}
if (Func.isEmpty(railwayStation.getTelegraphCode())) {
throw new ServiceException("电报码不能为空");
}
if (!TELEGRAPH_CODE_PATTERN.matcher(railwayStation.getTelegraphCode()).matches()) {
throw new ServiceException("电报码为3位大写字母");
}
if (Func.isEmpty(railwayStation.getName())) {
throw new ServiceException("车站名称不能为空");
}
if (Func.isEmpty(railwayStation.getProvinceCode()) || Func.isEmpty(railwayStation.getCityCode())) {
throw new ServiceException("请选择省份和城市");
}
validateCoordinate(railwayStation.getLongitude(), MIN_LONGITUDE, MAX_LONGITUDE, "经度");
validateCoordinate(railwayStation.getLatitude(), MIN_LATITUDE, MAX_LATITUDE, "纬度");
if (Func.isNotEmpty(railwayStation.getRemark()) && railwayStation.getRemark().length() > REMARK_MAX_LENGTH) {
throw new ServiceException("备注不能超过200字");
}
validateUnique(railwayStation, RailwayStation::getTmisCode, railwayStation.getTmisCode(), "该TMIS编码已存在");
validateUnique(railwayStation, RailwayStation::getTelegraphCode, railwayStation.getTelegraphCode(), "该电报码已存在");
validateUnique(railwayStation, RailwayStation::getCode, railwayStation.getCode(), "该编码已存在");
}
private void fillRegion(RailwayStation railwayStation) {
Region province = null;
if (Func.isNotEmpty(railwayStation.getProvinceCode())) {
province = regionService.getById(railwayStation.getProvinceCode());
}
if (Func.isEmpty(province) && Func.isNotEmpty(railwayStation.getProvinceName())) {
province = regionService.getOne(Wrappers.<Region>lambdaQuery()
.eq(Region::getParentCode, "00")
.eq(Region::getName, railwayStation.getProvinceName()), false);
}
if (Func.isEmpty(province)) {
throw new ServiceException("请选择省份");
}
Region city = null;
if (Func.isNotEmpty(railwayStation.getCityCode())) {
city = regionService.getById(railwayStation.getCityCode());
}
if (Func.isEmpty(city) && Func.isNotEmpty(railwayStation.getCityName())) {
city = regionService.getOne(Wrappers.<Region>lambdaQuery()
.eq(Region::getParentCode, province.getCode())
.eq(Region::getName, railwayStation.getCityName()), false);
}
if (Func.isEmpty(city)) {
throw new ServiceException("请选择城市");
}
if (!Objects.equals(city.getParentCode(), province.getCode())) {
throw new ServiceException("所属城市与所属省份不匹配");
}
railwayStation.setProvinceCode(province.getCode());
railwayStation.setProvinceName(province.getName());
railwayStation.setCityCode(city.getCode());
railwayStation.setCityName(city.getName());
}
private void validateCoordinate(BigDecimal value, BigDecimal min, BigDecimal max, String name) {
if (value == null) {
return;
}
if (value.compareTo(min) < 0 || value.compareTo(max) > 0) {
throw new ServiceException(name + "范围不正确");
}
}
private void validateUnique(RailwayStation railwayStation, com.baomidou.mybatisplus.core.toolkit.support.SFunction<RailwayStation, ?> column, String value, String message) {
LambdaQueryWrapper<RailwayStation> queryWrapper = Wrappers.<RailwayStation>lambdaQuery()
.eq(column, value)
.eq(RailwayStation::getIsDeleted, 0);
if (Func.isNotEmpty(railwayStation.getId())) {
queryWrapper.ne(RailwayStation::getId, railwayStation.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException(message);
}
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
private String trimToNull(String value) {
String trimValue = trimToEmpty(value);
return trimValue.isEmpty() ? null : trimValue;
}
}

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.pojo.entity.AirportMaster;
import org.springblade.system.pojo.vo.AirportMasterVO;
import java.util.Objects;
/**
* 空港机场主数据包装类
*
* @author Chill
*/
public class AirportMasterWrapper extends BaseEntityWrapper<AirportMaster, AirportMasterVO> {
public static AirportMasterWrapper build() {
return new AirportMasterWrapper();
}
@Override
public AirportMasterVO entityVO(AirportMaster airportMaster) {
return Objects.requireNonNull(BeanUtil.copyProperties(airportMaster, AirportMasterVO.class));
}
}

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.pojo.entity.PortTerminal;
import org.springblade.system.pojo.vo.PortTerminalVO;
import java.util.Objects;
/**
* 港口码头主数据包装类
*
* @author Chill
*/
public class PortTerminalWrapper extends BaseEntityWrapper<PortTerminal, PortTerminalVO> {
public static PortTerminalWrapper build() {
return new PortTerminalWrapper();
}
@Override
public PortTerminalVO entityVO(PortTerminal portTerminal) {
return Objects.requireNonNull(BeanUtil.copyProperties(portTerminal, PortTerminalVO.class));
}
}

View File

@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.pojo.entity.RailwayStation;
import org.springblade.system.pojo.vo.RailwayStationVO;
import java.util.Objects;
/**
* 铁路车站主数据包装类
*
* @author Chill
*/
public class RailwayStationWrapper extends BaseEntityWrapper<RailwayStation, RailwayStationVO> {
public static RailwayStationWrapper build() {
return new RailwayStationWrapper();
}
@Override
public RailwayStationVO entityVO(RailwayStation railwayStation) {
return Objects.requireNonNull(BeanUtil.copyProperties(railwayStation, RailwayStationVO.class));
}
}