zhaoqiaobo
9 months ago
17 changed files with 1560 additions and 136 deletions
@ -0,0 +1,47 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package com.logpm.basicdata.vo; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.logpm.basicdata.entity.BasicdataPriceEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 基础价格表 实体类 |
||||
* |
||||
* @author zqb |
||||
* @since 2024-04-02 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "BasicdataPrice对象", description = "基础价格表") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class BasicdataPriceImportVO extends BasicdataPriceEntity { |
||||
|
||||
@ApiModelProperty(value = "客户名称") |
||||
private String clientName; |
||||
@ApiModelProperty(value = "客户编码") |
||||
private String clientCode; |
||||
@ApiModelProperty(value = "品牌名称") |
||||
private String brandName; |
||||
|
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.logpm.basicdata.constant; |
||||
|
||||
/** |
||||
* @author zhaoqiaobo |
||||
* @create 2024-04-24 |
||||
*/ |
||||
public abstract class BasicdataConstants { |
||||
|
||||
public interface Price { |
||||
String VEHICLE_TYPE = "price_vehicle_type"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,73 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package com.logpm.basicdata.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* 基础价格路径 数据传输对象实体类 |
||||
* |
||||
* @author zqb |
||||
* @since 2024-04-08 |
||||
*/ |
||||
@Data |
||||
public class BasicdataPriceRouteImportDTO implements Serializable { |
||||
|
||||
/** |
||||
* 客户编码 |
||||
*/ |
||||
private String clientCode; |
||||
/** |
||||
* 品牌 |
||||
*/ |
||||
private String brand; |
||||
/** |
||||
* 发货单位 |
||||
*/ |
||||
private String sendOrgCode; |
||||
/** |
||||
* 发站省 |
||||
*/ |
||||
private String startProvince; |
||||
/** |
||||
* 发站市 |
||||
*/ |
||||
private String startCity; |
||||
/** |
||||
* 发站区 |
||||
*/ |
||||
private String startArea; |
||||
/** |
||||
* 到站省 |
||||
*/ |
||||
private String endProvince; |
||||
/** |
||||
* 到站市 |
||||
*/ |
||||
private String endCity; |
||||
/** |
||||
* 到站区 |
||||
*/ |
||||
private String endArea; |
||||
/** |
||||
* 类型 提货,干线 |
||||
*/ |
||||
private String type; |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,81 @@
|
||||
package com.logpm.basicdata.util; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.excel.read.builder.ExcelReaderBuilder; |
||||
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder; |
||||
import com.alibaba.excel.read.listener.ReadListener; |
||||
import org.springblade.core.excel.listener.DataListener; |
||||
import org.springblade.core.excel.support.ExcelException; |
||||
import org.springframework.util.StringUtils; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.BufferedInputStream; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* easyexcel 读数据工具类 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-04-24 |
||||
*/ |
||||
public class EasyExcelUtil { |
||||
public static <T> List<T> read(MultipartFile excel, Class<T> clazz) { |
||||
DataListener<T> dataListener = new DataListener(); |
||||
ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz); |
||||
if (builder == null) { |
||||
return null; |
||||
} else { |
||||
builder.doReadAll(); |
||||
return dataListener.getDataList(); |
||||
} |
||||
} |
||||
|
||||
public static <T> List<T> read(MultipartFile excel, int sheetNo, Class<T> clazz) { |
||||
return read(excel, sheetNo, 1, clazz); |
||||
} |
||||
|
||||
public static <T> List<T> readTrim(MultipartFile excel, int sheetNo, Class<T> clazz) { |
||||
return readTrim(excel, sheetNo, 1, clazz); |
||||
} |
||||
|
||||
public static <T> List<T> read(MultipartFile excel, int sheetNo, int headRowNumber, Class<T> clazz) { |
||||
DataListener<T> dataListener = new DataListener(); |
||||
ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz); |
||||
if (builder == null) { |
||||
return null; |
||||
} else { |
||||
((ExcelReaderSheetBuilder) builder.sheet(sheetNo).headRowNumber(headRowNumber)).doRead(); |
||||
return dataListener.getDataList(); |
||||
} |
||||
} |
||||
public static <T> List<T> readTrim(MultipartFile excel, int sheetNo, int headRowNumber, Class<T> clazz) { |
||||
DataListener<T> dataListener = new DataListener(); |
||||
ExcelReaderBuilder builder = getReaderBuilder(excel, dataListener, clazz); |
||||
if (builder == null) { |
||||
return null; |
||||
} else { |
||||
((ExcelReaderSheetBuilder) builder.sheet(sheetNo).headRowNumber(headRowNumber)).registerConverter(new TrimConverter()).doRead(); |
||||
return dataListener.getDataList(); |
||||
} |
||||
} |
||||
|
||||
public static <T> ExcelReaderBuilder getReaderBuilder(MultipartFile excel, ReadListener<T> readListener, Class<T> clazz) { |
||||
String filename = excel.getOriginalFilename(); |
||||
if (StrUtil.isEmpty(filename)) { |
||||
throw new ExcelException("请上传文件!"); |
||||
} else if (!StringUtils.endsWithIgnoreCase(filename, ".xls") && !StringUtils.endsWithIgnoreCase(filename, ".xlsx")) { |
||||
throw new ExcelException("请上传正确的excel文件!"); |
||||
} else { |
||||
try { |
||||
InputStream inputStream = new BufferedInputStream(excel.getInputStream()); |
||||
return EasyExcel.read(inputStream, clazz, readListener); |
||||
} catch (IOException var6) { |
||||
var6.printStackTrace(); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.logpm.basicdata.util; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.excel.converters.Converter; |
||||
import com.alibaba.excel.enums.CellDataTypeEnum; |
||||
import com.alibaba.excel.metadata.CellData; |
||||
import com.alibaba.excel.metadata.GlobalConfiguration; |
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty; |
||||
|
||||
/** |
||||
* 自定义去除cell前后空格转换器 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-04-24 |
||||
*/ |
||||
public class TrimConverter implements Converter<String> { |
||||
@Override |
||||
public Class supportJavaTypeKey() { |
||||
return String.class; |
||||
} |
||||
|
||||
@Override |
||||
public CellDataTypeEnum supportExcelTypeKey() { |
||||
return CellDataTypeEnum.STRING; |
||||
} |
||||
|
||||
@Override |
||||
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
||||
String value = cellData.getStringValue(); |
||||
if (StrUtil.isNotEmpty(value)) { |
||||
return value.trim(); |
||||
} |
||||
return value; |
||||
} |
||||
|
||||
@Override |
||||
public CellData convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
||||
if (StrUtil.isEmpty(value)) { |
||||
return new CellData(value); |
||||
} |
||||
return new CellData(value.trim()); |
||||
} |
||||
} |
Loading…
Reference in new issue