线路客流,单站客流

main
王宇航 2026-08-28 15:22:16 +08:00
parent e0ce16d820
commit 95eb4ac9bd
15 changed files with 1481 additions and 7 deletions

View File

@ -0,0 +1,389 @@
package net.juntech.modules.ysdp.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.jeeplus.aop.logging.annotation.ApiLog;
import com.jeeplus.common.redis.RedisUtils;
import com.jeeplus.core.excel.EasyExcelUtils;
import com.jeeplus.core.excel.ExcelOptions;
import com.jeeplus.core.excel.annotation.ExportMode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import net.juntech.modules.ysdp.domain.MetroBigActivity;
import net.juntech.modules.ysdp.service.MetroBigActivityService;
import net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO;
import net.juntech.modules.ysdp.service.mapstruct.MetroBigActivityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* Controller
* @author claude
* @version 2026-08-27
*/
@Tag(name = "重大活动")
@RestController
@RequestMapping(value = "/ysdp/metroBigActivity")
public class MetroBigActivityController {
@Autowired
private MetroBigActivityService metroBigActivityService;
@Autowired
private MetroBigActivityWrapper metroBigActivityWrapper;
@Autowired
private RedisUtils redisUtils;
@Autowired
private net.juntech.modules.ysdp.service.YsYunyingService ysYunyingService;
/**
*
*/
@ApiLog("查询重大活动列表数据")
@Operation(summary = "查询重大活动列表数据")
@PreAuthorize("hasAuthority('ysdp:metroBigActivity:list')")
@GetMapping("list")
public ResponseEntity<IPage<MetroBigActivityDTO>> list(MetroBigActivityDTO dto,
Page<MetroBigActivity> page) throws Exception {
QueryWrapper<MetroBigActivityDTO> queryWrapper = new QueryWrapper<>();
// 逻辑删除过滤
queryWrapper.and(qw -> qw.isNull("del_flag").or().ne("del_flag", "1"));
if (dto.getActivityName() != null && !dto.getActivityName().trim().isEmpty()) {
queryWrapper.like("activity_name", dto.getActivityName());
}
if (dto.getMetroLine() != null && !dto.getMetroLine().trim().isEmpty()) {
queryWrapper.eq("metro_line", dto.getMetroLine());
}
if (dto.getMetroStation() != null && !dto.getMetroStation().trim().isEmpty()) {
queryWrapper.eq("metro_station", dto.getMetroStation());
}
// 活动月份筛选(跨月活动也能被匹配)
if (dto.getActivityMonth() != null && !dto.getActivityMonth().trim().isEmpty()) {
String month = dto.getActivityMonth();
queryWrapper.and(qw -> qw
.apply("DATE_FORMAT(start_date, '%Y-%m') = {0}", month)
.or().apply("DATE_FORMAT(end_date, '%Y-%m') = {0}", month)
.or().apply("(start_date <= LAST_DAY(STR_TO_DATE(CONCAT({0}, '-01'), '%Y-%m-%d')) " +
"AND end_date >= STR_TO_DATE(CONCAT({0}, '-01'), '%Y-%m-%d'))", month)
);
}
queryWrapper.orderByDesc("start_date");
IPage<MetroBigActivityDTO> result = metroBigActivityService.pageWithName(page, queryWrapper);
// 填充线路名/车站名/状态字段(跨库单独查 ysdp 数据源)
fillLineAndStationName(result.getRecords());
if (result.getRecords() != null) {
for (MetroBigActivityDTO record : result.getRecords()) {
record.setStatus(calcStatus(record.getStartDate(), record.getEndDate()));
}
}
return ResponseEntity.ok(result);
}
/**
* 线
* - metro_line ys_line.id YsYunyingService.getLinesByIds name metroLineName
* - metro_station ys_station.station_id getStationsByStationIds name metroStationName
*/
private void fillLineAndStationName(List<MetroBigActivityDTO> list) {
if (list == null || list.isEmpty()) {
return;
}
// 收集要查的 id
java.util.Set<String> lineIds = new java.util.HashSet<>();
java.util.Set<String> stationIds = new java.util.HashSet<>();
for (MetroBigActivityDTO d : list) {
if (d.getMetroLine() != null && !d.getMetroLine().isEmpty()) {
lineIds.add(d.getMetroLine());
}
if (d.getMetroStation() != null && !d.getMetroStation().isEmpty()) {
stationIds.add(d.getMetroStation());
}
}
// 批量查线路(复用 YsYunyingDTOstationId=ys_line.id, stationName=name
java.util.Map<String, String> lineNameMap = new java.util.HashMap<>();
if (!lineIds.isEmpty()) {
for (net.juntech.modules.ysdp.service.dto.YsYunyingDTO line : ysYunyingService.getLinesByIds(lineIds)) {
lineNameMap.put(line.getStationId(), line.getStationName());
}
}
// 批量查车站
java.util.Map<String, String> stationNameMap = new java.util.HashMap<>();
if (!stationIds.isEmpty()) {
for (net.juntech.modules.ysdp.service.dto.YsYunyingDTO st : ysYunyingService.getStationsByStationIds(stationIds)) {
stationNameMap.put(st.getStationId(), st.getStationName());
}
}
// 回填
for (MetroBigActivityDTO d : list) {
d.setMetroLineName(lineNameMap.get(d.getMetroLine()));
d.setMetroStationName(stationNameMap.get(d.getMetroStation()));
}
}
/**
* Id
*/
@ApiLog("根据Id获取重大活动数据")
@Operation(summary = "根据Id获取重大活动数据")
@PreAuthorize("hasAnyAuthority('ysdp:metroBigActivity:view','ysdp:metroBigActivity:add','ysdp:metroBigActivity:edit')")
@GetMapping("queryById")
public ResponseEntity<MetroBigActivityDTO> queryById(String id) {
return ResponseEntity.ok(metroBigActivityWrapper.toDTO(metroBigActivityService.getById(id)));
}
/**
*
*/
@ApiLog("保存重大活动")
@Operation(summary = "保存重大活动")
@PreAuthorize("hasAnyAuthority('ysdp:metroBigActivity:add','ysdp:metroBigActivity:edit')")
@PostMapping("save")
public ResponseEntity<String> save(@Valid @RequestBody MetroBigActivityDTO dto) {
// 校验:结束日期 >= 开始日期
if (dto.getEndDate() != null && dto.getStartDate() != null
&& dto.getEndDate().before(dto.getStartDate())) {
return ResponseEntity.badRequest().body("结束日期不能早于开始日期");
}
metroBigActivityService.saveOrUpdate(metroBigActivityWrapper.toEntity(dto));
return ResponseEntity.ok("保存重大活动成功");
}
/**
*
*/
@ApiLog("删除重大活动")
@Operation(summary = "删除重大活动")
@PreAuthorize("hasAuthority('ysdp:metroBigActivity:del')")
@DeleteMapping("delete")
public ResponseEntity<String> delete(String ids) {
String[] idArray = ids.split(",");
// 逻辑删除
metroBigActivityService.removeByIds(Lists.newArrayList(idArray));
return ResponseEntity.ok("删除重大活动成功");
}
/**
*
*/
@ApiLog("导出重大活动数据")
@Operation(summary = "导出重大活动数据")
@PreAuthorize("hasAnyAuthority('ysdp:metroBigActivity:export')")
@GetMapping("export")
public void exportFile(MetroBigActivityDTO dto, Page<MetroBigActivity> page,
ExcelOptions options, HttpServletResponse response) throws Exception {
String fileName = options.getFilename();
QueryWrapper<MetroBigActivity> queryWrapper = new QueryWrapper<>();
// 逻辑删除过滤
queryWrapper.and(qw -> qw.isNull("del_flag").or().ne("del_flag", "1"));
if (dto.getActivityName() != null && !dto.getActivityName().trim().isEmpty()) {
queryWrapper.like("activity_name", dto.getActivityName());
}
if (dto.getMetroLine() != null && !dto.getMetroLine().trim().isEmpty()) {
queryWrapper.eq("metro_line", dto.getMetroLine());
}
if (dto.getMetroStation() != null && !dto.getMetroStation().trim().isEmpty()) {
queryWrapper.eq("metro_station", dto.getMetroStation());
}
if (ExportMode.current.equals(options.getMode())) {
// 导出当前页
} else if (ExportMode.selected.equals(options.getMode())) {
queryWrapper.in("id", options.getSelectIds());
} else {
page.setSize(-1);
page.setCurrent(0);
}
List<MetroBigActivity> result = metroBigActivityService.page(page, queryWrapper).getRecords();
EasyExcelUtils.newInstance(metroBigActivityService, metroBigActivityWrapper)
.exportExcel(result, options.getSheetName(), MetroBigActivityDTO.class,
fileName, options.getExportFields(), response);
}
/**
* 线/
*/
@ApiLog("导入重大活动数据")
@Operation(summary = "导入重大活动数据")
@PreAuthorize("hasAnyAuthority('ysdp:metroBigActivity:import')")
@PostMapping("import")
public ResponseEntity importFile(MultipartFile file) throws Exception {
// 先用 EasyExcel 读取 Excel
List<MetroBigActivityDTO> list = com.alibaba.excel.EasyExcel.read(file.getInputStream())
.head(MetroBigActivityDTO.class)
.sheet()
.doReadSync();
if (list == null || list.isEmpty()) {
return ResponseEntity.ok("导入数据为空");
}
// 批量查询线路、车站的映射(名称 → id/station_id
List<net.juntech.modules.ysdp.service.dto.YsYunyingDTO> allLines = ysYunyingService.getLineList();
java.util.Map<String, String> lineNameToId = new java.util.HashMap<>();
for (net.juntech.modules.ysdp.service.dto.YsYunyingDTO line : allLines) {
// 支持 "7号线" 或 "7" 都能匹配
lineNameToId.put(line.getName(), line.getId());
if (line.getName() != null && line.getName().endsWith("号线")) {
lineNameToId.put(line.getName().replace("号线", ""), line.getId());
}
}
// 拿所有车站(跨线路)
java.util.Map<String, String> stationNameToStationId = new java.util.HashMap<>();
for (net.juntech.modules.ysdp.service.dto.YsYunyingDTO line : allLines) {
List<net.juntech.modules.ysdp.service.dto.YsYunyingDTO> stations =
ysYunyingService.getStationsByLineDbId(line.getId());
for (net.juntech.modules.ysdp.service.dto.YsYunyingDTO st : stations) {
stationNameToStationId.put(st.getStationName(), st.getStationId());
}
}
// 转换:名称 → id
int successCount = 0;
StringBuilder errors = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
MetroBigActivityDTO dto = list.get(i);
try {
// 线路名 → ys_line.id
String lineId = lineNameToId.get(dto.getMetroLine());
if (lineId == null) {
errors.append("第").append(i + 2).append("行:线路'").append(dto.getMetroLine()).append("'未找到<br>");
continue;
}
// 车站名 → ys_station.station_id
String stationId = stationNameToStationId.get(dto.getMetroStation());
if (stationId == null) {
errors.append("第").append(i + 2).append("行:车站'").append(dto.getMetroStation()).append("'未找到<br>");
continue;
}
dto.setMetroLine(lineId);
dto.setMetroStation(stationId);
// 保存
MetroBigActivity entity = metroBigActivityWrapper.toEntity(dto);
metroBigActivityService.saveOrUpdate(entity);
successCount++;
} catch (Exception ex) {
errors.append("第").append(i + 2).append("行:保存失败 - ").append(ex.getMessage()).append("<br>");
}
}
String msg = "成功导入 " + successCount + " 条数据";
if (errors.length() > 0) {
msg += "<br>失败信息:<br>" + errors.toString();
}
return ResponseEntity.ok(msg);
}
/**
*
*/
@ApiLog("下载导入重大活动数据模板")
@Operation(summary = "下载导入重大活动数据模板")
@PreAuthorize("hasAnyAuthority('ysdp:metroBigActivity:import')")
@GetMapping("import/template")
public void importFileTemplate(HttpServletResponse response) throws IOException {
String fileName = "重大活动数据导入模板.xlsx";
List<MetroBigActivityDTO> list = Lists.newArrayList();
// 添加示例数据(用户可以直接参考填写)
MetroBigActivityDTO example1 = new MetroBigActivityDTO();
example1.setActivityName("CBE中国美容博览会");
example1.setMetroLine("7号线");
example1.setMetroStation("花木路");
try {
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
example1.setStartDate(sdf.parse("2026-05-12"));
example1.setEndDate(sdf.parse("2026-05-14"));
} catch (Exception e) {
// ignore
}
example1.setVenue("新国际博览中心");
example1.setRemark("示例:大型展会");
MetroBigActivityDTO example2 = new MetroBigActivityDTO();
example2.setActivityName("上海国际车展");
example2.setMetroLine("2号线");
example2.setMetroStation("徐泾东");
try {
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
example2.setStartDate(sdf.parse("2026-04-21"));
example2.setEndDate(sdf.parse("2026-04-28"));
} catch (Exception e) {
// ignore
}
example2.setVenue("国家会展中心");
example2.setRemark("示例国际A级车展");
list.add(example1);
list.add(example2);
EasyExcelUtils.newInstance(metroBigActivityService, metroBigActivityWrapper)
.exportExcel(list, "重大活动数据", MetroBigActivityDTO.class, fileName, null, response);
}
/**
* 线
* juntech_ysdp@DS("ysdp")
* id=ys_line.id, lineId=ys_line.line_id, stationName=ys_line.name
*/
@ApiLog("获取所有线路")
@Operation(summary = "获取所有线路")
@GetMapping("lineOptions")
public ResponseEntity<List<net.juntech.modules.ysdp.service.dto.YsYunyingDTO>> lineOptions() {
return ResponseEntity.ok(ysYunyingService.getLineList());
}
/**
* 线 id
* juntech_ysdp@DS("ysdp")
* stationId=ys_station.station_idID, stationName=ys_station.name
*/
@ApiLog("根据线路获取车站")
@Operation(summary = "根据线路获取车站")
@GetMapping("stationOptions")
public ResponseEntity<List<net.juntech.modules.ysdp.service.dto.YsYunyingDTO>> stationOptions(String lineId) {
return ResponseEntity.ok(ysYunyingService.getStationsByLineDbId(lineId));
}
/**
* /
* @return / /
*/
private String calcStatus(Date startDate, Date endDate) {
if (startDate == null || endDate == null) {
return "";
}
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = sdf.format(new Date());
Date today = sdf.parse(todayStr);
String startStr = sdf.format(startDate);
String endStr = sdf.format(endDate);
Date start = sdf.parse(startStr);
Date end = sdf.parse(endStr);
if (today.before(start)) {
return "未开始";
}
if (today.after(end)) {
return "已结束";
}
return "进行中";
} catch (Exception e) {
return "";
}
}
}

View File

@ -42,6 +42,9 @@ public class TrafficApiController extends BaseApiController {
@Autowired
private YsYunyingMaxService ysYunyingMaxService;
@Autowired
private net.juntech.modules.ysdp.service.MetroBigActivityService metroBigActivityService;
/**
* 线
*/
@ -331,6 +334,129 @@ public class TrafficApiController extends BaseApiController {
return okJsonResponse(resultObj, cacheKey);
}
/**
* 线
* //
*/
@ApiLog("获取重大活动清单")
@Operation(summary = "获取重大活动清单")
@PostMapping("getBigActivityList/v1")
public ResponseEntity<JSONObject> getBigActivityList(
@RequestParam(value = "metroLine", required = false, defaultValue = "") String metroLine,
@RequestParam(value = "metroStation", required = false, defaultValue = "") String metroStation,
@RequestParam(value = "activityMonth", required = false, defaultValue = "") String activityMonth,
HttpServletRequest request) {
if (!checkRequest(request)) {
return checkResult;
}
String cacheKey = Constant.API_CACHE_NAME_TRAFFIC_BIG_ACTIVITY
+ metroLine + "_" + metroStation + "_" + activityMonth;
JSONArray resultArray = new JSONArray();
try {
if (useCache(cacheKey, request)) {
resultArray = redisUtils.getJSONArray(cacheKey);
} else {
List<net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO> list =
metroBigActivityService.queryActivityForScreen(metroLine, metroStation, activityMonth);
// 跨库注入线路名/车站名ys_line / ys_station 在 juntech_ysdp 库)
java.util.Set<String> lineIds = new java.util.HashSet<>();
java.util.Set<String> stationIds = new java.util.HashSet<>();
for (net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO d : list) {
if (d.getMetroLine() != null && !d.getMetroLine().isEmpty()) lineIds.add(d.getMetroLine());
if (d.getMetroStation() != null && !d.getMetroStation().isEmpty()) stationIds.add(d.getMetroStation());
}
java.util.Map<String, String> lineNameMap = new java.util.HashMap<>();
if (!lineIds.isEmpty()) {
for (YsYunyingDTO line : ysYunyingService.getLinesByIds(lineIds)) {
lineNameMap.put(line.getStationId(), line.getStationName());
}
}
java.util.Map<String, String> stationNameMap = new java.util.HashMap<>();
if (!stationIds.isEmpty()) {
for (YsYunyingDTO s : ysYunyingService.getStationsByStationIds(stationIds)) {
stationNameMap.put(s.getStationId(), s.getStationName());
}
}
for (net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO d : list) {
d.setMetroLineName(lineNameMap.get(d.getMetroLine()));
d.setMetroStationName(stationNameMap.get(d.getMetroStation()));
}
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date todayDate;
try {
todayDate = sdf.parse(sdf.format(new java.util.Date()));
} catch (Exception ex) {
todayDate = new java.util.Date();
}
// 先收集到 List计算状态并排序
java.util.List<JSONObject> tempList = new java.util.ArrayList<>();
for (net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO item : list) {
JSONObject obj = new JSONObject();
obj.put("id", item.getId());
obj.put("activityName", item.getActivityName());
obj.put("metroLine", item.getMetroLine());
obj.put("metroLineName", item.getMetroLineName());
obj.put("metroStation", item.getMetroStation());
obj.put("metroStationName", item.getMetroStationName());
obj.put("startDate", item.getStartDate() != null ? sdf.format(item.getStartDate()) : "");
obj.put("endDate", item.getEndDate() != null ? sdf.format(item.getEndDate()) : "");
obj.put("venue", item.getVenue() == null ? "" : item.getVenue());
obj.put("remark", item.getRemark() == null ? "" : item.getRemark());
// 状态:未开始 / 进行中 / 已结束
String status = "";
int statusOrder = 3; // 默认排序:已结束=3
if (item.getStartDate() != null && item.getEndDate() != null) {
java.util.Date start;
java.util.Date end;
try {
start = sdf.parse(sdf.format(item.getStartDate()));
end = sdf.parse(sdf.format(item.getEndDate()));
if (todayDate.before(start)) {
status = "未开始";
statusOrder = 2;
} else if (todayDate.after(end)) {
status = "已结束";
statusOrder = 3;
} else {
status = "进行中";
statusOrder = 1;
}
} catch (Exception ignore) {
}
}
obj.put("status", status);
obj.put("statusOrder", statusOrder); // 用于排序
tempList.add(obj);
}
// 按状态排序:进行中(1) → 未开始(2) → 已结束(3)
tempList.sort((a, b) -> {
int orderA = (Integer) a.get("statusOrder");
int orderB = (Integer) b.get("statusOrder");
if (orderA != orderB) {
return Integer.compare(orderA, orderB);
}
// 同状态按开始日期排序
String dateA = (String) a.get("startDate");
String dateB = (String) b.get("startDate");
return dateA.compareTo(dateB);
});
// 移除排序字段并加入结果
for (JSONObject obj : tempList) {
obj.remove("statusOrder");
resultArray.add(obj);
}
}
} catch (Exception ex) {
return badJsonResponse("获取重大活动清单异常", ex);
}
return okJsonResponse(resultArray, cacheKey);
}
/**
*
*/

View File

@ -0,0 +1,69 @@
package net.juntech.modules.ysdp.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jeeplus.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* Entity
* @author claude
* @version 2026-08-27
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_metro_big_activity")
public class MetroBigActivity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private String activityName;
/**
* 线 juntech_ysdp.ys_line.id UUID
*/
private String metroLine;
/**
* juntech_ysdp.ys_station.station_id ID0313
*/
private String metroStation;
/**
*
*/
private Date startDate;
/**
*
*/
private Date endDate;
/**
*
*/
private String venue;
/**
*
*/
private String remark;
/**
*
*/
@TableField("create_by_id")
private String createByIdId;
/**
*
*/
@TableField("update_by_id")
private String updateByIdId;
}

View File

@ -0,0 +1,38 @@
package net.juntech.modules.ysdp.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.juntech.modules.ysdp.domain.MetroBigActivity;
import net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* MAPPER
* @author claude
* @version 2026-08-27
*/
@InterceptorIgnore(tenantLine = "true")
public interface MetroBigActivityMapper extends BaseMapper<MetroBigActivity> {
/**
* 线线/
*
* @param metroLine 线 ID
* @param metroStation ID
* @param activityMonth yyyy-MM
* @return
*/
List<MetroBigActivityDTO> queryActivityForScreen(@Param("metroLine") String metroLine,
@Param("metroStation") String metroStation,
@Param("activityMonth") String activityMonth);
/**
* 线/
*/
com.baomidou.mybatisplus.core.metadata.IPage<MetroBigActivityDTO> selectPageWithName(
com.baomidou.mybatisplus.extension.plugins.pagination.Page<MetroBigActivity> page,
@Param(com.baomidou.mybatisplus.core.toolkit.Constants.WRAPPER) com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<MetroBigActivityDTO> queryWrapper);
}

View File

@ -68,12 +68,29 @@ public interface YsYunyingMapper extends BaseMapper<YsYunying> {
public List<YsYunyingDTO> getLineList();
/**
* 线
* @param lineId 线 "03"
* 线 ys_line.line_id ID
* @param lineId 线ys_line.line_id "03"
* @return 线
*/
public List<YsYunyingDTO> getStationsByLine(@Param("lineId") String lineId);
/**
* ys_line id 线
* @param id ys_line.id UUID
* @return
*/
public List<YsYunyingDTO> getStationsByLineDbId(@Param("id") String id);
/**
* ys_line.id 线
*/
public List<YsYunyingDTO> getLinesByIds(@Param("ids") java.util.Collection<String> ids);
/**
* ys_station.station_id
*/
public List<YsYunyingDTO> getStationsByStationIds(@Param("stationIds") java.util.Collection<String> stationIds);
/**
*
* @param stationId

View File

@ -0,0 +1,62 @@
<?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="net.juntech.modules.ysdp.mapper.MetroBigActivityMapper">
<!--
大屏查询:不 JOIN ys_line/ys_station跨库无法 JOIN
线路名 / 车站名由 Java 层通过 YsYunyingService(@DS("ysdp")) 单独批量注入
-->
<select id="queryActivityForScreen" resultType="net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO">
SELECT
id AS id,
activity_name AS activityName,
metro_line AS metroLine,
metro_station AS metroStation,
start_date AS startDate,
end_date AS endDate,
venue AS venue,
remark AS remark,
create_time AS createTime,
update_time AS updateTime
FROM t_metro_big_activity
WHERE (del_flag IS NULL OR del_flag != '1')
<if test="metroLine != null and metroLine != ''">
AND metro_line = #{metroLine}
</if>
<if test="metroStation != null and metroStation != ''">
AND metro_station = #{metroStation}
</if>
<if test="activityMonth != null and activityMonth != ''">
AND (
DATE_FORMAT(start_date, '%Y-%m') = #{activityMonth}
OR DATE_FORMAT(end_date, '%Y-%m') = #{activityMonth}
OR (start_date &lt;= LAST_DAY(STR_TO_DATE(CONCAT(#{activityMonth}, '-01'), '%Y-%m-%d'))
AND end_date &gt;= STR_TO_DATE(CONCAT(#{activityMonth}, '-01'), '%Y-%m-%d'))
)
</if>
ORDER BY start_date ASC, id ASC
</select>
<!--
后台分页查询:不 JOINJava 层单独查名称并回填
-->
<select id="selectPageWithName" resultType="net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO">
SELECT
id AS id,
activity_name AS activityName,
metro_line AS metroLine,
metro_station AS metroStation,
start_date AS startDate,
end_date AS endDate,
venue AS venue,
remark AS remark,
create_time AS createTime,
update_time AS updateTime,
create_by_id AS createById,
update_by_id AS updateById,
del_flag AS delFlag
FROM t_metro_big_activity
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -168,6 +168,7 @@
<!-- LIMIT 10-->
<!-- </select>-->
<!-- 常规页面接口:获取客流排名 TOP10按站点名合并线路统计所有线路不区分单/换乘站) -->
<select id="getStationMaxList" resultType="net.juntech.modules.ysdp.service.dto.YsYunyingDTO">
SELECT
lineId,
@ -175,11 +176,11 @@
stationName,
total
FROM (
-- 先按站点名称,把所有线路合并起来
<!-- &#45;&#45; 先按站点名称,把所有线路合并起来-->
SELECT
TRIM(b.`name`) AS stationName,
GROUP_CONCAT(DISTINCT a.line_id ORDER BY a.line_id SEPARATOR ',') AS lineId,
-- 用MIN只是为了拿一个站点ID不影响业务
<!-- &#45;&#45; 用MIN只是为了拿一个站点ID不影响业务-->
MIN(a.station_id) AS stationId
FROM ys_yunying a
LEFT JOIN ys_station b ON a.station_id = b.station_id
@ -191,7 +192,7 @@
GROUP BY TRIM(b.`name`)
) AS station_lines
JOIN (
-- 再单独统计客流,排除不需要的站点。单位:万人(保留 2 位小数)
<!-- 再单独统计客流,排除不需要的站点-->
SELECT
TRIM(b.`name`) AS stationName,
ROUND((SUM(a.pull_num) + SUM(a.departure_num)) / 100) AS total
@ -210,6 +211,7 @@
LIMIT 10
</select>
<!-- 客运页面接口获取进出站客流排名TOP10单线路站点统计所有线路 -->
<select id="getInOutStationMaxList" resultType="net.juntech.modules.ysdp.service.dto.YsYunyingDTO">
SELECT
lineId,
@ -318,6 +320,43 @@
ORDER BY sort ASC, station_id ASC
</select>
<select id="getStationsByLineDbId" resultType="net.juntech.modules.ysdp.service.dto.YsYunyingDTO">
SELECT
s.station_id AS stationId,
TRIM(s.`name`) AS stationName,
s.line_id AS lineId,
s.crosslines AS crosslines
FROM ys_station s
WHERE s.line_id = (
SELECT id FROM ys_line WHERE id = #{id} LIMIT 1
)
AND (s.del_flag IS NULL OR s.del_flag != '1')
AND (s.`enable` IS NULL OR s.`enable` = '1')
ORDER BY s.sort ASC, s.station_id ASC
</select>
<select id="getLinesByIds" resultType="net.juntech.modules.ysdp.service.dto.YsYunyingDTO">
SELECT
id AS stationId, <!-- 复用字段:这里放 ys_line.id -->
line_id AS lineId,
`name` AS stationName <!-- 复用字段:这里放线路名 -->
FROM ys_line
WHERE id IN
<foreach collection="ids" item="i" open="(" separator="," close=")">#{i}</foreach>
AND (del_flag IS NULL OR del_flag != '1')
</select>
<select id="getStationsByStationIds" resultType="net.juntech.modules.ysdp.service.dto.YsYunyingDTO">
SELECT
station_id AS stationId,
TRIM(`name`) AS stationName,
line_id AS lineId
FROM ys_station
WHERE station_id IN
<foreach collection="stationIds" item="s" open="(" separator="," close=")">#{s}</foreach>
AND (del_flag IS NULL OR del_flag != '1')
</select>
<select id="getStationInOutFlow" resultType="net.juntech.modules.ysdp.service.dto.YsYunyingMaxDTO">
SELECT
#{stationId} AS lineId,
@ -368,7 +407,7 @@
<select id="getStationCompareValue" resultType="String">
SELECT
CAST((SUM(a.pull_num) + SUM(a.departure_num)) / 10000 AS DECIMAL(10,2)) AS total
ROUND((SUM(a.pull_num) + SUM(a.departure_num)) / 100) AS total
FROM ys_yunying a
left join ys_station b on a.station_id = b.station_id
WHERE

View File

@ -0,0 +1,40 @@
package net.juntech.modules.ysdp.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.juntech.modules.ysdp.domain.MetroBigActivity;
import net.juntech.modules.ysdp.mapper.MetroBigActivityMapper;
import net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* Service
* @author claude
* @version 2026-08-27
*/
@Service
@Transactional
public class MetroBigActivityService extends ServiceImpl<MetroBigActivityMapper, MetroBigActivity> {
@Autowired
private MetroBigActivityMapper metroBigActivityMapper;
/**
*
*/
public List<MetroBigActivityDTO> queryActivityForScreen(String metroLine, String metroStation, String activityMonth) {
return metroBigActivityMapper.queryActivityForScreen(metroLine, metroStation, activityMonth);
}
/**
* 线/
*/
public com.baomidou.mybatisplus.core.metadata.IPage<MetroBigActivityDTO> pageWithName(
com.baomidou.mybatisplus.extension.plugins.pagination.Page<MetroBigActivity> page,
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<MetroBigActivityDTO> queryWrapper) {
return metroBigActivityMapper.selectPageWithName(page, queryWrapper);
}
}

View File

@ -92,12 +92,35 @@ public class YsYunyingService extends ServiceImpl<YsYunyingMapper, YsYunying> {
}
/**
* 线
* 线 ys_line.line_id ID
*/
public List<YsYunyingDTO> getStationsByLine(String lineId) {
return ysYunyingMapper.getStationsByLine(lineId);
}
/**
* ys_line id
*/
public List<YsYunyingDTO> getStationsByLineDbId(String id) {
return ysYunyingMapper.getStationsByLineDbId(id);
}
/**
* ys_line id 线 Java
*/
public List<YsYunyingDTO> getLinesByIds(java.util.Collection<String> ids) {
if (ids == null || ids.isEmpty()) return java.util.Collections.emptyList();
return ysYunyingMapper.getLinesByIds(ids);
}
/**
* ys_station.station_id Java
*/
public List<YsYunyingDTO> getStationsByStationIds(java.util.Collection<String> stationIds) {
if (stationIds == null || stationIds.isEmpty()) return java.util.Collections.emptyList();
return ysYunyingMapper.getStationsByStationIds(stationIds);
}
/**
*
*/

View File

@ -0,0 +1,109 @@
package net.juntech.modules.ysdp.service.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeeplus.core.query.Query;
import com.jeeplus.core.query.QueryType;
import com.jeeplus.core.service.dto.BaseDTO;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* DTO
* @author claude
* @version 2026-08-27
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class MetroBigActivityDTO extends BaseDTO {
private static final long serialVersionUID = 1L;
/**
*
*/
@NotEmpty(message = "活动名称不能为空")
@Query(type = QueryType.LIKE)
@ExcelProperty("活动名称")
private String activityName;
/**
* 线juntech_ysdp.ys_line.id UUID
*/
@NotEmpty(message = "地铁线路不能为空")
@Query(type = QueryType.EQ)
@ExcelProperty("地铁线路")
private String metroLine;
/**
* juntech_ysdp.ys_station.station_id ID
*/
@NotEmpty(message = "关联站点不能为空")
@Query(type = QueryType.EQ)
@ExcelProperty("关联站点")
private String metroStation;
/**
*
*/
@NotNull(message = "开始日期不能为空")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ExcelProperty("开始日期")
private Date startDate;
/**
*
*/
@NotNull(message = "结束日期不能为空")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ExcelProperty("结束日期")
private Date endDate;
/**
*
*/
@ExcelProperty("举办场馆")
private String venue;
/**
*
*/
@ExcelProperty("备注")
private String remark;
/**
* yyyy-MM
*/
private String activityMonth;
/**
* 线
*/
private String metroLineName;
/**
*
*/
private String metroStationName;
/**
* //
*/
private String status;
/**
*
*/
@ExcelProperty("创建者")
private String createById;
/**
*
*/
@ExcelProperty("更新者")
private String updateById;
}

View File

@ -0,0 +1,19 @@
package net.juntech.modules.ysdp.service.mapstruct;
import com.jeeplus.core.mapstruct.EntityWrapper;
import net.juntech.modules.ysdp.domain.MetroBigActivity;
import net.juntech.modules.ysdp.service.dto.MetroBigActivityDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
/**
* MetroBigActivityWrapper
* @author claude
* @version 2026-08-27
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = {})
public interface MetroBigActivityWrapper extends EntityWrapper<MetroBigActivityDTO, MetroBigActivity> {
MetroBigActivityWrapper INSTANCE = Mappers.getMapper(MetroBigActivityWrapper.class);
}

View File

@ -76,4 +76,9 @@ Constant {
*/
public static final String API_CACHE_NAME_TRAFFIC_LINE_LIST = "api_traffic_lineListV1_";
/**
* -
*/
public static final String API_CACHE_NAME_TRAFFIC_BIG_ACTIVITY = "api_traffic_bigActivityV1_";
}

View File

@ -0,0 +1,75 @@
import request from "@/utils/httpRequest";
export default {
save: function (inputForm) {
return request({
url: "/ysdp/metroBigActivity/save",
method: "post",
data: inputForm,
});
},
delete: function (ids) {
return request({
url: "/ysdp/metroBigActivity/delete",
method: "delete",
params: { ids: ids },
});
},
queryById: function (id) {
return request({
url: "/ysdp/metroBigActivity/queryById",
method: "get",
params: { id: id },
});
},
list: function (params) {
return request({
url: "/ysdp/metroBigActivity/list",
method: "get",
params: params,
});
},
lineOptions: function () {
return request({
url: "/ysdp/metroBigActivity/lineOptions",
method: "get",
});
},
stationOptions: function (lineId) {
return request({
url: "/ysdp/metroBigActivity/stationOptions",
method: "get",
params: { lineId: lineId },
});
},
exportTemplate: function () {
return request({
url: "/ysdp/metroBigActivity/import/template",
method: "get",
responseType: "blob",
});
},
exportExcel: function (params) {
return request({
url: "/ysdp/metroBigActivity/export",
method: "get",
params: params,
responseType: "blob",
});
},
importExcel: function (data) {
return request({
url: "/ysdp/metroBigActivity/import",
method: "post",
data: data,
});
},
};

View File

@ -0,0 +1,173 @@
<template>
<v-dialog
:title="title"
:close-on-click-modal="false"
v-model="visible">
<el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="method==='view'" label-width="120px">
<el-row :gutter="15">
<el-col :span="24">
<el-form-item label="活动名称" prop="activityName"
:rules="[
{required: true, message:'活动名称不能为空', trigger:'blur'},
{max: 500, message:'活动名称最多500字符', trigger:'blur'}
]">
<el-input v-model="inputForm.activityName" placeholder="请输入活动完整名称" maxlength="500" show-word-limit></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="地铁线路" prop="metroLine"
:rules="[{required: true, message:'请选择地铁线路', trigger:'change'}]">
<el-select v-model="inputForm.metroLine" placeholder="请选择地铁线路" @change="onLineChange" filterable style="width: 100%;">
<!-- value = ys_line.id (主键 UUID) -->
<el-option v-for="item in lineList" :key="item.id"
:label="item.name || (item.lineId + '号线')" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="关联站点" prop="metroStation"
:rules="[{required: true, message:'请选择关联站点', trigger:'change'}]">
<el-select v-model="inputForm.metroStation" placeholder="请先选择线路" filterable style="width: 100%;" :disabled="!inputForm.metroLine">
<!-- value = ys_station.station_id (业务ID) -->
<el-option v-for="item in stationList" :key="item.stationId"
:label="item.stationName" :value="item.stationId"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开始日期" prop="startDate"
:rules="[{required: true, message:'开始日期不能为空', trigger:'change'}]">
<el-date-picker v-model="inputForm.startDate" type="date" placeholder="选择开始日期"
value-format="YYYY-MM-DD" style="width: 100%;"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束日期" prop="endDate"
:rules="[
{required: true, message:'结束日期不能为空', trigger:'change'},
{validator: validateEndDate, trigger:'change'}
]">
<el-date-picker v-model="inputForm.endDate" type="date" placeholder="选择结束日期"
value-format="YYYY-MM-DD" style="width: 100%;"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="举办场馆" prop="venue">
<el-input v-model="inputForm.venue" placeholder="请输入举办场馆(选填)" maxlength="200"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="inputForm.remark" type="textarea" :rows="3" placeholder="请输入备注(选填)" maxlength="500" show-word-limit></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false" icon="circle-close">关闭</el-button>
<el-button type="primary" v-if="method != 'view'" @click="doSubmit()" icon="circle-check" v-noMoreClick></el-button>
</span>
</template>
</v-dialog>
</template>
<script>
import metroBigActivityService from '@/api/ysdp/metroBigActivityService'
export default {
data () {
return {
title: '',
method: '',
visible: false,
loading: false,
lineList: [],
stationList: [],
inputForm: {
id: '',
activityName: '',
metroLine: '',
metroStation: '',
startDate: '',
endDate: '',
venue: '',
remark: ''
}
}
},
methods: {
validateEndDate (rule, value, callback) {
if (value && this.inputForm.startDate && value < this.inputForm.startDate) {
callback(new Error('结束日期不能早于开始日期'))
} else {
callback()
}
},
init (method, id) {
this.method = method
this.inputForm.id = id
if (method === 'add') {
this.title = `新建重大活动`
} else if (method === 'edit') {
this.title = '修改重大活动'
} else if (method === 'view') {
this.title = '查看重大活动'
}
this.visible = true
this.loading = false
this.stationList = []
this.$nextTick(() => {
this.$refs.inputForm.resetFields()
// 线
metroBigActivityService.lineOptions().then((data) => {
this.lineList = data || []
})
if (method === 'edit' || method === 'view') {
this.loading = true
metroBigActivityService.queryById(this.inputForm.id).then((data) => {
this.inputForm = this.recover(this.inputForm, data)
//
if (this.inputForm.metroLine) {
metroBigActivityService.stationOptions(this.inputForm.metroLine).then((res) => {
this.stationList = res || []
})
}
this.loading = false
})
}
})
},
onLineChange (val) {
// 线
this.inputForm.metroStation = ''
this.stationList = []
if (val) {
metroBigActivityService.stationOptions(val).then((data) => {
this.stationList = data || []
})
}
},
doSubmit () {
this.$refs['inputForm'].validate((valid) => {
if (valid) {
this.loading = true
metroBigActivityService.save(this.inputForm).then((data) => {
this.visible = false
this.$message.success(data)
this.$emit('refreshDataList')
this.loading = false
}).catch(() => {
this.loading = false
})
}
})
}
}
}
</script>

View File

@ -0,0 +1,290 @@
<template>
<div class="page">
<el-form
:inline="true"
v-if="searchVisible"
class="query-form m-b-10"
ref="searchForm"
:model="searchForm"
@keyup.enter="refreshList()"
@submit.prevent
>
<el-form-item prop="activityName" label="活动名称:">
<el-input v-model="searchForm.activityName" placeholder="请输入活动名称" clearable></el-input>
</el-form-item>
<el-form-item prop="metroLine" label="地铁线路:">
<el-select v-model="searchForm.metroLine" placeholder="请选择线路" clearable @change="onSearchLineChange" filterable style="width: 160px;">
<!-- value = ys_line.id (主键 UUID) -->
<el-option v-for="item in lineList" :key="item.id"
:label="item.name || (item.lineId + '号线')" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="metroStation" label="关联站点:">
<el-select v-model="searchForm.metroStation" placeholder="请先选择线路" clearable filterable style="width: 160px;" :disabled="!searchForm.metroLine">
<!-- value = ys_station.station_id (业务ID) -->
<el-option v-for="item in searchStationList" :key="item.stationId"
:label="item.stationName" :value="item.stationId"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="activityMonth" label="举办月份:">
<el-date-picker v-model="searchForm.activityMonth" type="month" placeholder="选择月份"
value-format="YYYY-MM" style="width: 160px;"></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="refreshList()" icon="search">查询</el-button>
<el-button type="default" @click="resetSearch()" icon="refresh-right">重置</el-button>
<el-upload
v-if="hasPermission('ysdp:metroBigActivity:import')"
ref="uploadExcel"
:show-file-list="false"
:auto-upload="false"
:on-change="handleFileChange"
accept=".xlsx,.xls"
style="display: inline-block; margin-left: 10px;">
<el-button type="success" icon="upload" plain>导入数据</el-button>
</el-upload>
<el-button v-if="hasPermission('ysdp:metroBigActivity:import')" type="info" @click="downloadTpl()" icon="download" plain>下载模板</el-button>
</el-form-item>
</el-form>
<div class="jp-table">
<vxe-toolbar ref="metroBigActivityToolbar" :refresh="{query: refreshList}" import export print custom>
<template #buttons>
<el-button v-if="hasPermission('ysdp:metroBigActivity:add')" type="primary" icon="plus" @click="add()"></el-button>
<el-button v-if="hasPermission('ysdp:metroBigActivity:edit')" type="warning" icon="edit-filled" @click="edit()"
v-show="$refs.metroBigActivityTable && $refs.metroBigActivityTable.getCheckboxRecords().length === 1" plain>修改</el-button>
<el-button v-if="hasPermission('ysdp:metroBigActivity:del')" type="danger" icon="del-filled" @click="del()"
v-show="$refs.metroBigActivityTable && $refs.metroBigActivityTable.getCheckboxRecords().length > 0" plain>删除</el-button>
</template>
<template #tools>
<vxe-button type="text" :title="searchVisible ? '收起检索' : '展开检索'" icon="vxe-icon-search"
class="tool-btn" @click="searchVisible = !searchVisible"></vxe-button>
</template>
</vxe-toolbar>
<div class="jp-table-body">
<vxe-table
border="inner" auto-resize resizable height="auto" :loading="loading" size="small"
ref="metroBigActivityTable" show-header-overflow show-overflow highlight-hover-row
:menu-config="{}" :print-config="{}"
:export-config="{
remote: true,
filename: `重大活动数据${moment(new Date()).format('YYYY-MM-DD')}`,
sheetName: '重大活动数据',
exportMethod: exportMethod,
types: ['xlsx'],
modes: ['current', 'selected', 'all'],
}"
@sort-change="sortChangeHandle" :sort-config="{remote:true}"
:data="dataList" :checkbox-config="{}">
<vxe-column type="seq" width="40"></vxe-column>
<vxe-column type="checkbox" width="40px"></vxe-column>
<vxe-column field="activityName" sortable title="活动名称" min-width="260">
<template #default="{ row }">
<el-link type="primary" :underline="false" v-if="hasPermission('ysdp:metroBigActivity:edit')" @click="edit(row.id)">{{ row.activityName }}</el-link>
<el-link type="primary" :underline="false" v-else-if="hasPermission('ysdp:metroBigActivity:view')" @click="view(row.id)">{{ row.activityName }}</el-link>
<span v-else>{{ row.activityName }}</span>
</template>
</vxe-column>
<vxe-column field="metroLine" sortable title="地铁线路" width="110">
<template #default="{ row }">
<!-- 后端已通过 Java 注入 metroLineName -->
<span>{{ row.metroLineName || row.metroLine }}</span>
</template>
</vxe-column>
<vxe-column field="metroStation" sortable title="关联站点" width="130">
<template #default="{ row }">
<span>{{ row.metroStationName || row.metroStation }}</span>
</template>
</vxe-column>
<vxe-column field="startDate" sortable title="开始日期" width="120"></vxe-column>
<vxe-column field="endDate" sortable title="结束日期" width="120"></vxe-column>
<vxe-column field="venue" title="举办场馆" min-width="180"></vxe-column>
<vxe-column field="status" title="状态" width="90">
<template #default="{ row }">
<el-tag v-if="row.status === '进行中'" type="success" size="small"></el-tag>
<el-tag v-else-if="row.status === ''" type="info" size="small">未开始</el-tag>
<el-tag v-else-if="row.status === ''" type="warning" size="small">已结束</el-tag>
<span v-else>-</span>
</template>
</vxe-column>
<vxe-column field="createTime" sortable title="创建时间" width="160"></vxe-column>
<vxe-column fixed="right" align="center" width="200" title="操作">
<template #default="{ row }">
<el-button v-if="hasPermission('ysdp:metroBigActivity:view')" type="primary" text icon="view-filled" @click="view(row.id)"></el-button>
<el-button v-if="hasPermission('ysdp:metroBigActivity:edit')" type="primary" text icon="edit-filled" @click="edit(row.id)"></el-button>
<el-button v-if="hasPermission('ysdp:metroBigActivity:del')" type="danger" text icon="del-filled" @click="del(row.id)"></el-button>
</template>
</vxe-column>
</vxe-table>
<vxe-pager background size="small"
:current-page="tablePage.currentPage"
:page-size="tablePage.pageSize"
:total="tablePage.total"
:page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
:layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
@page-change="currentChangeHandle">
</vxe-pager>
</div>
</div>
<MetroBigActivityForm ref="metroBigActivityForm" @refreshDataList="refreshList"></MetroBigActivityForm>
</div>
</template>
<script>
import MetroBigActivityForm from './MetroBigActivityForm'
import metroBigActivityService from '@/api/ysdp/metroBigActivityService'
export default {
data () {
return {
searchVisible: true,
searchForm: {
activityName: '',
metroLine: '',
metroStation: '',
activityMonth: ''
},
lineList: [],
searchStationList: [],
dataList: [],
tablePage: {
total: 0,
currentPage: 1,
pageSize: 10,
orders: [{ column: 'start_date', asc: false }]
},
loading: false
}
},
components: { MetroBigActivityForm },
mounted () {
this.$nextTick(() => {
const $table = this.$refs.metroBigActivityTable
const $toolbar = this.$refs.metroBigActivityToolbar
$table.connect($toolbar)
})
// 线
metroBigActivityService.lineOptions().then((data) => {
this.lineList = data || []
})
},
activated () {
this.refreshList()
},
methods: {
onSearchLineChange (val) {
this.searchForm.metroStation = ''
this.searchStationList = []
if (val) {
metroBigActivityService.stationOptions(val).then((data) => {
this.searchStationList = data || []
})
}
},
refreshList () {
this.loading = true
metroBigActivityService.list({
current: this.tablePage.currentPage,
size: this.tablePage.pageSize,
orders: this.tablePage.orders,
...this.searchForm
}).then((data) => {
this.dataList = data.records
this.tablePage.total = data.total
this.loading = false
})
},
currentChangeHandle ({ currentPage, pageSize }) {
this.tablePage.currentPage = currentPage
this.tablePage.pageSize = pageSize
this.refreshList()
},
sortChangeHandle (obj) {
this.tablePage.orders = []
if (obj.order != null) {
this.tablePage.orders = [{ column: obj.column.sortBy || this.$utils.toLine(obj.property), asc: obj.order === 'asc' }]
} else {
this.tablePage.orders = [{ column: 'start_date', asc: false }]
}
this.refreshList()
},
add () {
this.$refs.metroBigActivityForm.init('add', '')
},
edit (id) {
id = id || this.$refs.metroBigActivityTable.getCheckboxRecords().map(item => item.id)[0]
this.$refs.metroBigActivityForm.init('edit', id)
},
view (id) {
this.$refs.metroBigActivityForm.init('view', id)
},
del (id) {
const ids = id || this.$refs.metroBigActivityTable.getCheckboxRecords().map(item => item.id).join(',')
this.$confirm(`确定删除所选项吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.loading = true
metroBigActivityService.delete(ids).then((data) => {
this.$message.success(data)
this.refreshList()
this.loading = false
})
})
},
downloadTpl () {
this.loading = true
metroBigActivityService.exportTemplate().then((data) => {
this.$utils.downloadExcel(data, '重大活动导入模板')
this.loading = false
}).catch((err) => {
this.loading = false
if (err.response) console.log(err.response)
})
},
handleFileChange (file) {
// el-upload on-change
const formData = new FormData()
formData.append('file', file.raw)
this.loading = true
metroBigActivityService.importExcel(formData).then((result) => {
this.$message.success({ dangerouslyUseHTMLString: true, message: result })
this.refreshList()
this.loading = false
}).catch((err) => {
this.loading = false
if (err.response) {
this.$message.error('导入失败:' + (err.response.data.msg || err.message))
}
})
},
exportMethod ({ options }) {
const params = {
current: this.tablePage.currentPage,
size: this.tablePage.pageSize,
orders: this.tablePage.orders,
...this.searchForm,
filename: options.filename,
sheetName: options.sheetName,
isHeader: options.isHeader,
original: options.original,
mode: options.mode,
selectIds: options.mode === 'selected' ? options.data.map((item) => item.id) : [],
exportFields: options.columns.map((column) => column.property && column.property.split('.')[0])
}
this.loading = true
return metroBigActivityService.exportExcel(params).then((data) => {
this.$utils.downloadExcel(data, options.filename)
this.loading = false
}).catch((err) => {
if (err.response) console.log(err.response)
})
},
resetSearch () {
this.$refs.searchForm.resetFields()
this.searchStationList = []
this.refreshList()
}
}
}
</script>