完善营销信息录入功能
This commit is contained in:
parent
2e70215836
commit
d407560620
@ -401,9 +401,9 @@ const {
|
||||
};
|
||||
|
||||
// 只有当checkType为'9'时才显示编辑按钮
|
||||
if (row.checkFlag !== '9') {
|
||||
return null;
|
||||
}
|
||||
// if (row.checkFlag !== '9') {
|
||||
// return null;
|
||||
// }
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
{editBtn()}
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.http.HttpStatus;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -15,7 +16,9 @@ import org.dromara.common.core.exception.base.BaseException;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@ -200,6 +203,27 @@ public class GlobalExceptionHandler {
|
||||
public R<Void> handleHttpMessageNotReadableException(HttpMessageNotReadableException e, HttpServletRequest request) {
|
||||
log.error("请求地址'{}', 参数解析失败: {}", request.getRequestURI(), e.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_BAD_REQUEST, "请求参数格式错误:" + e.getMostSpecificCause().getMessage());
|
||||
|
||||
}
|
||||
/**
|
||||
* HttpMessageNotWritableException处理,特别是处理Excel导出异常
|
||||
*/
|
||||
@ExceptionHandler(HttpMessageNotWritableException.class)
|
||||
public void handleHttpMessageNotWritableException(HttpMessageNotWritableException e, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}', 响应写入失败: {}", requestURI, e.getMessage());
|
||||
|
||||
// 特殊处理导出Excel时的异常,避免类型不匹配
|
||||
if (requestURI.contains("/export")) {
|
||||
response.reset();
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
R<Void> result = R.fail("导出Excel失败: " + e.getMessage());
|
||||
response.getWriter().print(JsonUtils.toJsonString(result));
|
||||
} else {
|
||||
// 其他情况按默认处理
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.mps.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
@ -8,6 +9,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.dromara.common.excel.core.ExcelResult;
|
||||
@ -59,8 +61,31 @@ public class MpsMarketController extends BaseController {
|
||||
@Log(title = "营销数据管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(MpsMarketBo bo, HttpServletResponse response) {
|
||||
List<MpsMarketVo> list = mpsMarketService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "营销数据管理", MpsMarketVo.class, response);
|
||||
try {
|
||||
List<MpsMarketVo> list = mpsMarketService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "营销数据管理", MpsMarketVo.class, response);
|
||||
} catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// log.error("导出Excel失败", e);
|
||||
e.printStackTrace();
|
||||
try {
|
||||
// 检查响应是否已经提交
|
||||
if (!response.isCommitted()) {
|
||||
response.reset();
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
R<Void> result = R.fail("导出Excel失败: " + e.getMessage());
|
||||
response.getWriter().print(JsonUtils.toJsonString(result));
|
||||
response.getWriter().flush();
|
||||
}
|
||||
} catch (IOException ioException) {
|
||||
//打印错误
|
||||
ioException.printStackTrace();
|
||||
// log.error("写入响应失败", ioException);
|
||||
}
|
||||
}
|
||||
// List<MpsMarketVo> list = mpsMarketService.queryList(bo);
|
||||
// ExcelUtil.exportExcel(list, "营销数据管理", MpsMarketVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,9 @@ package org.dromara.mps.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.format.DateTimeFormat;
|
||||
import cn.idev.excel.annotation.format.NumberFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.dromara.mps.domain.MpsMarket;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
@ -35,12 +38,14 @@ public class MpsMarketVo implements Serializable {
|
||||
* 主键
|
||||
*/
|
||||
@ExcelProperty(value = "主键")
|
||||
@NumberFormat("#")
|
||||
private Long dataId;
|
||||
|
||||
/**
|
||||
* 业务类型id
|
||||
*/
|
||||
@ExcelProperty(value = "业务类型id")
|
||||
@NumberFormat("#")
|
||||
private Long subcategoryId;
|
||||
|
||||
/**
|
||||
@ -78,6 +83,7 @@ public class MpsMarketVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "数据日期")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat("yyyy-MM-dd")
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
@ -96,13 +102,14 @@ public class MpsMarketVo implements Serializable {
|
||||
* 客户类型(1-个人,2-对公)
|
||||
*/
|
||||
@ExcelProperty(value = "客户类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "1-个人,2-对公")
|
||||
@ExcelDictFormat(readConverterExp = "1=个人,2=对公")
|
||||
private String custType;
|
||||
|
||||
/**
|
||||
* 客户身份证号
|
||||
*/
|
||||
@ExcelProperty(value = "客户身份证号")
|
||||
@NumberFormat("#")
|
||||
private String custId;
|
||||
|
||||
/**
|
||||
@ -131,6 +138,7 @@ public class MpsMarketVo implements Serializable {
|
||||
|
||||
|
||||
@ExcelProperty(value = "磁条卡更换登记记录")
|
||||
@ExcelIgnore
|
||||
private List<MpsMagneticcardVo> magneticCardList;
|
||||
|
||||
/**
|
||||
@ -158,6 +166,7 @@ public class MpsMarketVo implements Serializable {
|
||||
private Long trafficId;
|
||||
|
||||
@ExcelProperty(value = "交警处罚决定书列表")
|
||||
@ExcelIgnore
|
||||
private List<MpsTrafficVo> trafficList;
|
||||
|
||||
/**
|
||||
@ -188,22 +197,21 @@ public class MpsMarketVo implements Serializable {
|
||||
/**
|
||||
* 核对时间
|
||||
*/
|
||||
@ExcelProperty(value = "核对时间")
|
||||
private Date checkTime;
|
||||
// @ExcelProperty(value = "核对时间")
|
||||
// private Date checkTime;
|
||||
|
||||
/**
|
||||
* 核对人员(人工核对时)
|
||||
*/
|
||||
@ExcelProperty(value = "核对人员", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "人=工核对时")
|
||||
private String checkUser;
|
||||
// @ExcelProperty(value = "核对人员", converter = ExcelDictConvert.class)
|
||||
// private String checkUser;
|
||||
|
||||
/**
|
||||
* 核对方式(0系统 1人工 2其他1 3其他2 4其他3)
|
||||
*/
|
||||
@ExcelProperty(value = "核对方式", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=系统,1=人工,2=其他1,3=其他2,4=其他3")
|
||||
private String checkType;
|
||||
// @ExcelProperty(value = "核对方式", converter = ExcelDictConvert.class)
|
||||
// @ExcelDictFormat(readConverterExp = "0=系统,1=人工,2=其他1,3=其他2,4=其他3")
|
||||
// private String checkType;
|
||||
|
||||
/**
|
||||
* 核对结果
|
||||
|
@ -488,10 +488,44 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(List<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
// 先删除关联的磁条卡数据
|
||||
if (!ids.isEmpty()) {
|
||||
// 查询需要删除的营销数据,获取magneticCardId和trafficId
|
||||
List<MpsMarket> marketList = baseMapper.selectBatchIds(ids);
|
||||
|
||||
// 收集需要删除的magneticCardId和trafficId
|
||||
List<Long> magneticCardIds = new ArrayList<>();
|
||||
List<Long> trafficIds = new ArrayList<>();
|
||||
|
||||
for (MpsMarket market : marketList) {
|
||||
if (market.getMagneticCardId() != null) {
|
||||
magneticCardIds.add(market.getMagneticCardId());
|
||||
}
|
||||
if (market.getTrafficId() != null) {
|
||||
trafficIds.add(market.getTrafficId());
|
||||
}
|
||||
}
|
||||
|
||||
// 删除磁条卡数据
|
||||
if (!magneticCardIds.isEmpty()) {
|
||||
magneticcardMapper.delete(new LambdaQueryWrapper<MpsMagneticcard>()
|
||||
.in(MpsMagneticcard::getMagneticCardId, magneticCardIds));
|
||||
}
|
||||
|
||||
// 删除交通罚没款数据
|
||||
if (!trafficIds.isEmpty()) {
|
||||
TrafficMapper.delete(new LambdaQueryWrapper<MpsTraffic>()
|
||||
.in(MpsTraffic::getTrafficId, trafficIds));
|
||||
}
|
||||
}
|
||||
|
||||
// 最后删除主表数据
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user