Commit 44b3f0a3 by zhouhaibao

[+]审批新增校验

1 parent 7e10a7d2
package cn.com.glsx.dj.oaapproval.dto.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class BatchStoreCombinedExcelDTO {
@ExcelProperty(value = "*门店名称", index = 0)
private String storeName;
@ExcelProperty(value = "*门店商户号", index = 1)
private String storeCode;
@ExcelProperty(value = "*业务模式", index = 2)
private String bizMode;
@ExcelProperty(value = "*签约主体(关联平台)", index = 3)
private String signingEntity;
@ExcelProperty(value = "*运营模式", index = 4)
private String opMode;
@ExcelProperty(value = "服务商2/F公司", index = 5)
private String fCompany;
@ExcelProperty(value = "*服务商", index = 6)
private String serviceProvider;
@ExcelProperty(value = "上级服务商", index = 7)
private String superiorProvider;
@ExcelProperty(value = "*园区店", index = 8)
private String parkingStore;
@ExcelProperty(value = "*类型", index = 9)
private String productType;
@ExcelProperty(value = "*销售品类", index = 10)
private String productCategory;
@ExcelProperty(value = "*流量结算模式", index = 11)
private String feeSettlementMode;
@ExcelProperty(value = "*渗透率", index = 12, converter = PercentStringConverter.class)
private BigDecimal penetrationRate;
@ExcelProperty(value = "*转化率", index = 13, converter = PercentStringConverter.class)
private BigDecimal conversionRate;
@ExcelProperty(value = "*单车采购产值", index = 14, converter = NumberStringConverter.class)
private BigDecimal revenuePerCar;
@ExcelProperty(value = "*门店单台利润额", index = 15, converter = NumberStringConverter.class)
private BigDecimal storeProfitPerCar;
@ExcelProperty(value = "*交付数", index = 16, converter = IntegerStringConverter.class)
private Integer deliveryCount;
@ExcelProperty(value = "*触客率", index = 17, converter = PercentStringConverter.class)
private BigDecimal customerTouchRate;
@ExcelProperty(value = "*转化率", index = 18, converter = PercentStringConverter.class)
private BigDecimal conversionRate2;
@ExcelProperty(value = "*升级客单价", index = 19, converter = NumberStringConverter.class)
private BigDecimal upgradePrice;
@ExcelProperty(value = "*产值", index = 20, converter = NumberStringConverter.class)
private BigDecimal revenue;
@ExcelProperty(value = "*流量费", index = 21, converter = NumberStringConverter.class)
private BigDecimal trafficFee;
@ExcelProperty(value = "*管理层市场费1", index = 22, converter = NumberStringConverter.class)
private BigDecimal marketFee1;
@ExcelProperty(value = "*管理层市场费2", index = 23, converter = NumberStringConverter.class)
private BigDecimal marketFee2;
@ExcelProperty(value = "*一线阳光激励1", index = 24, converter = NumberStringConverter.class)
private BigDecimal incentive1;
@ExcelProperty(value = "*一线阳光激励2", index = 25, converter = NumberStringConverter.class)
private BigDecimal incentive2;
@ExcelProperty(value = "*资源费", index = 26, converter = NumberStringConverter.class)
private BigDecimal resourceFee;
@ExcelProperty(value = "*产品成本", index = 27, converter = NumberStringConverter.class)
private BigDecimal productCost;
@ExcelProperty(value = "*人员成本", index = 28, converter = NumberStringConverter.class)
private BigDecimal personnelCost;
@ExcelProperty(value = "*房租", index = 29, converter = NumberStringConverter.class)
private BigDecimal rentCost;
@ExcelProperty(value = "*折旧与摊销", index = 30, converter = NumberStringConverter.class)
private BigDecimal depreciation;
@ExcelProperty(value = "*其他(水电、耗材等)", index = 31, converter = NumberStringConverter.class)
private BigDecimal otherCost;
@ExcelProperty(value = "*原厂膜回收", index = 32, converter = NumberStringConverter.class)
private BigDecimal recyclingFilm;
@ExcelProperty(value = "*区域运营", index = 33)
private String areaOp;
@ExcelProperty(value = "*线上运营", index = 34)
private String onlineOp;
@ExcelProperty(value = "*区域督导", index = 35)
private String regionSupervisor;
}
...@@ -35,24 +35,6 @@ public class BatchStoreExcelDTO { ...@@ -35,24 +35,6 @@ public class BatchStoreExcelDTO {
@ExcelProperty(value = "*园区店", index = 8) @ExcelProperty(value = "*园区店", index = 8)
private String parkingStore; private String parkingStore;
@ExcelProperty(value = "*类型", index = 9)
private String productType;
@ExcelProperty(value = "*销售品类", index = 10)
private String productCategory;
@ExcelProperty(value = "*流量结算模式", index = 11)
private String feeSettlementMode;
@ExcelProperty(value = "*渗透率", index = 12)
private BigDecimal penetrationRate;
@ExcelProperty(value = "*转化率", index = 13)
private BigDecimal conversionRate;
@ExcelProperty(value = "*单车采购产值", index = 14)
private BigDecimal revenuePerCar;
@ExcelProperty(value = "*门店单台利润额", index = 15) @ExcelProperty(value = "*门店单台利润额", index = 15)
private BigDecimal storeProfitPerCar; private BigDecimal storeProfitPerCar;
...@@ -62,33 +44,6 @@ public class BatchStoreExcelDTO { ...@@ -62,33 +44,6 @@ public class BatchStoreExcelDTO {
@ExcelProperty(value = "*触客率", index = 17) @ExcelProperty(value = "*触客率", index = 17)
private BigDecimal customerTouchRate; private BigDecimal customerTouchRate;
@ExcelProperty(value = "*转化率", index = 18)
private BigDecimal conversionRate2;
@ExcelProperty(value = "*升级客单价", index = 19)
private BigDecimal upgradePrice;
@ExcelProperty(value = "*产值", index = 20)
private BigDecimal revenue;
@ExcelProperty(value = "*流量费", index = 21)
private BigDecimal trafficFee;
@ExcelProperty(value = "*管理层市场费1", index = 22)
private BigDecimal marketFee1;
@ExcelProperty(value = "*管理层市场费2", index = 23)
private BigDecimal marketFee2;
@ExcelProperty(value = "*一线阳光激励1", index = 24)
private BigDecimal incentive1;
@ExcelProperty(value = "*一线阳光激励2", index = 25)
private BigDecimal incentive2;
@ExcelProperty(value = "*资源费", index = 26)
private BigDecimal resourceFee;
@ExcelProperty(value = "*产品成本", index = 27) @ExcelProperty(value = "*产品成本", index = 27)
private BigDecimal productCost; private BigDecimal productCost;
...@@ -104,8 +59,6 @@ public class BatchStoreExcelDTO { ...@@ -104,8 +59,6 @@ public class BatchStoreExcelDTO {
@ExcelProperty(value = "*其他(水电、耗材等)", index = 31) @ExcelProperty(value = "*其他(水电、耗材等)", index = 31)
private BigDecimal otherCost; private BigDecimal otherCost;
@ExcelProperty(value = "*原厂膜回收", index = 32)
private BigDecimal recyclingFilm;
@ExcelProperty(value = "*区域运营", index = 33) @ExcelProperty(value = "*区域运营", index = 33)
private String areaOp; private String areaOp;
......
package cn.com.glsx.dj.oaapproval.dto.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import java.math.BigDecimal;
import lombok.Data;
@Data
public class BatchStoreProductExcelDTO {
@ExcelProperty(value = "*类型", index = 9)
private String productType;
@ExcelProperty(value = "*销售品类", index = 10)
private String productCategory;
@ExcelProperty(value = "*流量结算模式", index = 11)
private String feeSettlementMode;
@ExcelProperty(value = "*渗透率", index = 12, converter = PercentStringConverter.class)
private BigDecimal penetrationRate;
@ExcelProperty(value = "*转化率", index = 13, converter = PercentStringConverter.class)
private BigDecimal conversionRate;
@ExcelProperty(value = "*单车采购产值", index = 14)
private BigDecimal revenuePerCar;
@ExcelProperty(value = "*转化率", index = 18, converter = PercentStringConverter.class)
private BigDecimal conversionRate2;
@ExcelProperty(value = "*升级客单价", index = 19)
private BigDecimal upgradePrice;
@ExcelProperty(value = "*产值", index = 20)
private BigDecimal revenue;
@ExcelProperty(value = "*流量费", index = 21)
private BigDecimal trafficFee;
@ExcelProperty(value = "*管理层市场费1", index = 22)
private BigDecimal marketFee1;
@ExcelProperty(value = "*管理层市场费2", index = 23)
private BigDecimal marketFee2;
@ExcelProperty(value = "*一线阳光激励1", index = 24)
private BigDecimal incentive1;
@ExcelProperty(value = "*一线阳光激励2", index = 25)
private BigDecimal incentive2;
@ExcelProperty(value = "*资源费", index = 26)
private BigDecimal resourceFee;
@ExcelProperty(value = "*原厂膜回收", index = 32)
private BigDecimal recyclingFilm;
}
package cn.com.glsx.dj.oaapproval.dto.excel;
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;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
public class IntegerStringConverter implements Converter<Integer> {
@Override
public Class<?> supportJavaTypeKey() {
return Integer.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return null;
}
@Override
public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception {
if (cellData == null) {
return null;
}
String stringValue = null;
if (cellData.getStringValue() != null) {
stringValue = cellData.getStringValue().trim();
} else if (cellData.getNumberValue() != null) {
return cellData.getNumberValue().intValue();
}
if (StringUtils.isEmpty(stringValue)) {
return null;
}
try {
BigDecimal decimal = new BigDecimal(stringValue);
return decimal.intValue();
} catch (NumberFormatException e) {
throw new NumberFormatException("Invalid number format: " + stringValue);
}
}
@Override
public CellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value == null) {
return new CellData<>("");
}
return new CellData<>(value.toString());
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.oaapproval.dto.excel;
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;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
public class NumberStringConverter implements Converter<BigDecimal> {
@Override
public Class<?> supportJavaTypeKey() {
return BigDecimal.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return null;
}
@Override
public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception {
if (cellData == null) {
return null;
}
String stringValue = null;
if (cellData.getStringValue() != null) {
stringValue = cellData.getStringValue().trim();
} else if (cellData.getNumberValue() != null) {
return cellData.getNumberValue();
}
if (StringUtils.isEmpty(stringValue)) {
return null;
}
try {
return new BigDecimal(stringValue);
} catch (NumberFormatException e) {
throw new NumberFormatException("Invalid number format: " + stringValue);
}
}
@Override
public CellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value == null) {
return new CellData<>("");
}
return new CellData<>(value.toString());
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.oaapproval.dto.excel;
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;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class PercentStringConverter implements Converter<BigDecimal> {
@Override
public Class<?> supportJavaTypeKey() {
return BigDecimal.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return null;
}
@Override
public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception {
if (cellData == null) {
return null;
}
String stringValue = null;
if (cellData.getStringValue() != null) {
stringValue = cellData.getStringValue().trim();
} else if (cellData.getNumberValue() != null) {
return cellData.getNumberValue();
}
if (StringUtils.isEmpty(stringValue)) {
return null;
}
if (stringValue.endsWith("%")) {
String numStr = stringValue.substring(0, stringValue.length() - 1).trim();
if (StringUtils.isEmpty(numStr)) {
return null;
}
try {
BigDecimal value = new BigDecimal(numStr);
return value.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
} catch (NumberFormatException e) {
return null;
}
}
try {
return new BigDecimal(stringValue);
} catch (NumberFormatException e) {
throw new NumberFormatException("Invalid number format: " + stringValue);
}
}
@Override
public CellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value == null) {
return new CellData<>("");
}
BigDecimal percentValue = value.multiply(new BigDecimal("100"));
return new CellData<>(percentValue.setScale(2, RoundingMode.HALF_UP) + "%");
}
}
...@@ -45,75 +45,75 @@ public class SingleStoreExcelDTO { ...@@ -45,75 +45,75 @@ public class SingleStoreExcelDTO {
@ExcelProperty(value = "*流量结算模式", index = 9) @ExcelProperty(value = "*流量结算模式", index = 9)
private String feeSettlementMode; private String feeSettlementMode;
@ExcelProperty(value = "*渗透率", index = 10) @ExcelProperty(value = "*渗透率", index = 10, converter = PercentStringConverter.class)
private BigDecimal penetrationRate; private BigDecimal penetrationRate;
@ExcelProperty(value = "*转化率", index = 11) @ExcelProperty(value = "*转化率", index = 11, converter = PercentStringConverter.class)
private BigDecimal conversionRate; private BigDecimal conversionRate;
@ExcelProperty(value = "*单车采购产值", index = 12) @ExcelProperty(value = "*单车采购产值", index = 12, converter = NumberStringConverter.class)
private BigDecimal revenuePerCar; private BigDecimal revenuePerCar;
@ExcelMergeRow(columIndex = 13) @ExcelMergeRow(columIndex = 13)
@ExcelProperty(value = "*门店单台利润额", index = 13) @ExcelProperty(value = "*门店单台利润额", index = 13, converter = NumberStringConverter.class)
private BigDecimal storeProfitPerCar; private BigDecimal storeProfitPerCar;
@ExcelMergeRow(columIndex = 14) @ExcelMergeRow(columIndex = 14)
@ExcelProperty(value = "*交付数", index = 14) @ExcelProperty(value = "*交付数", index = 14, converter = IntegerStringConverter.class)
private Integer deliveryCount; private Integer deliveryCount;
@ExcelMergeRow(columIndex = 15) @ExcelMergeRow(columIndex = 15)
@ExcelProperty(value = "*触客率", index = 15) @ExcelProperty(value = "*触客率", index = 15, converter = PercentStringConverter.class)
private BigDecimal customerTouchRate; private BigDecimal customerTouchRate;
@ExcelProperty(value = "*转化率", index = 16) @ExcelProperty(value = "*转化率", index = 16, converter = PercentStringConverter.class)
private BigDecimal conversionRate2; private BigDecimal conversionRate2;
@ExcelProperty(value = "*升级客单价", index = 17) @ExcelProperty(value = "*升级客单价", index = 17, converter = NumberStringConverter.class)
private BigDecimal upgradePrice; private BigDecimal upgradePrice;
@ExcelProperty(value = "*产值", index = 18) @ExcelProperty(value = "*产值", index = 18, converter = NumberStringConverter.class)
private BigDecimal revenue; private BigDecimal revenue;
@ExcelProperty(value = "*流量费", index = 19) @ExcelProperty(value = "*流量费", index = 19, converter = NumberStringConverter.class)
private BigDecimal trafficFee; private BigDecimal trafficFee;
@ExcelProperty(value = "*管理层市场费1", index = 20) @ExcelProperty(value = "*管理层市场费1", index = 20, converter = NumberStringConverter.class)
private BigDecimal marketFee1; private BigDecimal marketFee1;
@ExcelProperty(value = "*管理层市场费2", index = 21) @ExcelProperty(value = "*管理层市场费2", index = 21, converter = NumberStringConverter.class)
private BigDecimal marketFee2; private BigDecimal marketFee2;
@ExcelProperty(value = "*一线阳光激励1", index = 22) @ExcelProperty(value = "*一线阳光激励1", index = 22, converter = NumberStringConverter.class)
private BigDecimal incentive1; private BigDecimal incentive1;
@ExcelProperty(value = "*一线阳光激励2", index = 23) @ExcelProperty(value = "*一线阳光激励2", index = 23, converter = NumberStringConverter.class)
private BigDecimal incentive2; private BigDecimal incentive2;
@ExcelProperty(value = "*资源费", index = 24) @ExcelProperty(value = "*资源费", index = 24, converter = NumberStringConverter.class)
private BigDecimal resourceFee; private BigDecimal resourceFee;
@ExcelProperty(value = "*产品成本", index = 25) @ExcelProperty(value = "*产品成本", index = 25, converter = NumberStringConverter.class)
private BigDecimal productCost; private BigDecimal productCost;
@ExcelMergeRow(columIndex = 26) @ExcelMergeRow(columIndex = 26)
@ExcelProperty(value = "*人员成本", index = 26) @ExcelProperty(value = "*人员成本", index = 26, converter = NumberStringConverter.class)
private BigDecimal personnelCost; private BigDecimal personnelCost;
@ExcelMergeRow(columIndex = 27) @ExcelMergeRow(columIndex = 27)
@ExcelProperty(value = "*房租", index = 27) @ExcelProperty(value = "*房租", index = 27, converter = NumberStringConverter.class)
private BigDecimal rentCost; private BigDecimal rentCost;
@ExcelMergeRow(columIndex = 28) @ExcelMergeRow(columIndex = 28)
@ExcelProperty(value = "*折旧与摊销", index = 28) @ExcelProperty(value = "*折旧与摊销", index = 28, converter = NumberStringConverter.class)
private BigDecimal depreciation; private BigDecimal depreciation;
@ExcelMergeRow(columIndex = 29) @ExcelMergeRow(columIndex = 29)
@ExcelProperty(value = "*其他(水电、耗材等)", index = 29) @ExcelProperty(value = "*其他(水电、耗材等)", index = 29, converter = NumberStringConverter.class)
private BigDecimal otherCost; private BigDecimal otherCost;
@ExcelMergeRow(columIndex = 30) @ExcelMergeRow(columIndex = 30)
@ExcelProperty(value = "*原厂膜回收", index = 30) @ExcelProperty(value = "*原厂膜回收", index = 30, converter = NumberStringConverter.class)
private BigDecimal recyclingFilm; private BigDecimal recyclingFilm;
@ExcelMergeRow(columIndex = 31) @ExcelMergeRow(columIndex = 31)
......
package cn.com.glsx.dj.oaapproval.listener;
import java.util.Arrays;
import java.util.List;
public class ExcelHeaderConstants {
public static final List<String> SINGLE_STORE_FIRST_ROW_HEADERS = Arrays.asList(
"流量方信息",
"销售范围",
"兜底要求",
"预估经营数据",
"商务政策",
"预估运营成本",
"人员信息"
);
public static final List<String> BATCH_STORE_FIRST_ROW_HEADERS = Arrays.asList(
"流量方信息",
"销售范围",
"兜底要求",
"预估经营数据",
"商务政策",
"预估运营成本",
"人员信息"
);
public static final List<String> SINGLE_STORE_HEADERS = Arrays.asList(
"*业务模式",
"*签约主体\n(关联平台)",
"*运营模式",
"服务商2/F公司",
"*服务商",
"上级服务商",
"*园区店",
"*类型",
"*销售品类",
"*流量结算模式",
"*渗透率",
"*转化率",
"*单车采购产值",
"*门店单台利润额",
"*交付数",
"*触客率",
"*转化率",
"*升级客单价",
"*产值",
"*流量费",
"*管理层市场费1",
"*管理层市场费2",
"*一线阳光激励1",
"*一线阳光激励2",
"*资源费",
"*产品成本",
"*人员成本",
"*房租",
"*折旧与摊销",
"*其他(水电、耗材等)",
"*原厂膜回收",
"*区域运营",
"*线上运营",
"*区域督导"
);
public static final List<String> BATCH_STORE_HEADERS = Arrays.asList(
"*门店名称",
"*门店商户号",
"*业务模式",
"*签约主体\n(关联平台)",
"*运营模式",
"服务商2/F公司",
"*服务商",
"上级服务商",
"*园区店",
"*类型",
"*销售品类",
"*流量结算模式",
"*渗透率",
"*转化率",
"*单车采购产值",
"*门店单台利润额",
"*交付数",
"*触客率",
"*转化率",
"*升级客单价",
"*产值",
"*流量费",
"*管理层市场费1",
"*管理层市场费2",
"*一线阳光激励1",
"*一线阳光激励2",
"*资源费",
"*产品成本",
"*人员成本",
"*房租",
"*折旧与摊销",
"*其他(水电、耗材等)",
"*原厂膜回收",
"*区域运营",
"*线上运营",
"*区域督导"
);
}
package cn.com.glsx.dj.oaapproval.listener;
public class ExcelHeaderMismatchException extends RuntimeException {
public ExcelHeaderMismatchException(String message) {
super(message);
}
public ExcelHeaderMismatchException(String message, Throwable cause) {
super(message, cause);
}
}
package cn.com.glsx.dj.oaapproval.service; package cn.com.glsx.dj.oaapproval.service;
import cn.com.glsx.dj.oaapproval.dto.excel.BatchStoreExcelDTO; import cn.com.glsx.dj.oaapproval.dto.excel.BatchStoreCombinedExcelDTO;
import cn.com.glsx.dj.oaapproval.dto.excel.SingleStoreExcelDTO; import cn.com.glsx.dj.oaapproval.dto.excel.SingleStoreExcelDTO;
import cn.com.glsx.dj.oaapproval.dto.store.ExcelImportResult; import cn.com.glsx.dj.oaapproval.dto.store.ExcelImportResult;
import cn.com.glsx.dj.oaapproval.dto.store.StoreApproveDTO; import cn.com.glsx.dj.oaapproval.dto.store.StoreApproveDTO;
...@@ -8,6 +8,7 @@ import cn.com.glsx.dj.oaapproval.dto.store.StoreWithProductsDTO; ...@@ -8,6 +8,7 @@ import cn.com.glsx.dj.oaapproval.dto.store.StoreWithProductsDTO;
import cn.com.glsx.dj.oaapproval.dto.store.UpdateStoreApproveDTO; import cn.com.glsx.dj.oaapproval.dto.store.UpdateStoreApproveDTO;
import cn.com.glsx.dj.oaapproval.enums.store.ShelfTypeEnum; import cn.com.glsx.dj.oaapproval.enums.store.ShelfTypeEnum;
import cn.com.glsx.dj.oaapproval.listener.CreateBusinessApproveExcelListener; import cn.com.glsx.dj.oaapproval.listener.CreateBusinessApproveExcelListener;
import cn.com.glsx.dj.oaapproval.listener.ExcelHeaderMismatchException;
import cn.com.glsx.dj.oaapproval.remote.StoreCreateBusinessApproveRemote; import cn.com.glsx.dj.oaapproval.remote.StoreCreateBusinessApproveRemote;
import cn.com.glsx.dj.oaapproval.request.stroreapp.StoreApproveDTORequest; import cn.com.glsx.dj.oaapproval.request.stroreapp.StoreApproveDTORequest;
import cn.com.glsx.dj.oaapproval.request.stroreapp.StoreApproveUpdateDTORequest; import cn.com.glsx.dj.oaapproval.request.stroreapp.StoreApproveUpdateDTORequest;
...@@ -22,7 +23,6 @@ import cn.com.glsx.framework.core.beans.rpc.RpcResponse; ...@@ -22,7 +23,6 @@ import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse; import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.remote.MerchantRemote;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.rop.request.UploadFile; import com.rop.request.UploadFile;
...@@ -35,18 +35,9 @@ import java.util.Objects; ...@@ -35,18 +35,9 @@ import java.util.Objects;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/**
* @author 11$
* @version V1.0
* @Title StoreApproveService
* @Description:
* @date 2026/4/24 17:43
* @Company:didihu.com.cn
*/
@Service @Service
@Slf4j @Slf4j
public class StoreApproveService { public class StoreApproveService {
...@@ -90,9 +81,11 @@ public class StoreApproveService { ...@@ -90,9 +81,11 @@ public class StoreApproveService {
importExcel(request.getFile(), createBusinessApproveDTO); importExcel(request.getFile(), createBusinessApproveDTO);
log.info("创建单店模式表单:{}", JSONObject.toJSONString(createBusinessApproveDTO)); log.info("创建单店模式表单:{}", JSONObject.toJSONString(createBusinessApproveDTO));
return storeCreateBusinessApproveRemote.createDraft(createBusinessApproveDTO); return storeCreateBusinessApproveRemote.createDraft(createBusinessApproveDTO);
} catch (ExcelHeaderMismatchException e) {
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
return RpcResponse.error(e); return RpcResponse.error(e);
} catch (Exception e) { } catch (Exception e) {
log.error("嘀加上架表导入失败:{}", e.getMessage(), e); log.error("嘀加上架表导入失败:{}", e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage()); throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
} }
...@@ -101,21 +94,16 @@ public class StoreApproveService { ...@@ -101,21 +94,16 @@ public class StoreApproveService {
private void importExcel(UploadFile file, StoreApproveDTO storeApproveDTO) { private void importExcel(UploadFile file, StoreApproveDTO storeApproveDTO) {
validate(file); validate(file);
CreateBusinessApproveImportExcelContext globalContext = readExcel(file, storeApproveDTO); CreateBusinessApproveImportExcelContext globalContext = readExcel(file, storeApproveDTO);
List<StoreWithProductsDTO> storeWithProductsList = globalContext.getStoreWithProductsDTOS(); List<StoreWithProductsDTO> storeWithProductsList = globalContext.getStoreWithProductsDTOS();
if (CollectionUtils.isEmpty(storeWithProductsList)) { if (CollectionUtils.isEmpty(storeWithProductsList)) {
throw new RpcServiceException("Excel 解析无数据"); throw new RpcServiceException("Excel 解析无数据");
} }
storeApproveDTO.setStoreWithProductsDTOS(storeWithProductsList); storeApproveDTO.setStoreWithProductsDTOS(storeWithProductsList);
storeApproveDTO.setErrorMessages(globalContext.getErrorMessages());
if (CollectionUtils.isNotEmpty(globalContext.getErrorMessages())) {
String errors = String.join("; ", globalContext.getErrorMessages());
log.warn("Excel 解析存在错误: {}", errors);
}
String excelUrl = uploadExcel(file, "产品上架表"); String excelUrl = uploadExcel(file, "产品上架表");
if (StringUtils.isBlank(excelUrl)) { if (StringUtils.isBlank(excelUrl)) {
throw new RpcServiceException("EXCEL_UPLOAD_FILE_FAIL"); throw new RpcServiceException("EXCEL_UPLOAD_FILE_FAIL");
} }
storeApproveDTO.setGoodsCreateExcel(excelUrl); storeApproveDTO.setGoodsCreateExcel(excelUrl);
} }
...@@ -136,7 +124,7 @@ public class StoreApproveService { ...@@ -136,7 +124,7 @@ public class StoreApproveService {
.doRead(); .doRead();
} else { } else {
listener = new CreateBusinessApproveExcelListener(context, isSingleStoreMode); listener = new CreateBusinessApproveExcelListener(context, isSingleStoreMode);
EasyExcel.read(inputStream, BatchStoreExcelDTO.class, listener) EasyExcel.read(inputStream, BatchStoreCombinedExcelDTO.class, listener)
.sheet() .sheet()
.headRowNumber(2) .headRowNumber(2)
.doRead(); .doRead();
...@@ -147,11 +135,25 @@ public class StoreApproveService { ...@@ -147,11 +135,25 @@ public class StoreApproveService {
return context; return context;
} catch (Exception e) { } catch (Exception e) {
if (isExcelHeaderMismatchException(e)) {
log.error("Excel表头校验失败");
throw new ExcelHeaderMismatchException("请上传正确的门店上架表");
}
log.error("读取 Excel 文件失败: {}", e.getMessage(), e); log.error("读取 Excel 文件失败: {}", e.getMessage(), e);
throw new RpcServiceException("读取 Excel 文件失败: " + e.getMessage()); throw new RpcServiceException("读取 Excel 文件失败: " + e.getMessage());
} }
} }
private boolean isExcelHeaderMismatchException(Throwable e) {
if (e == null) {
return false;
}
if (e instanceof ExcelHeaderMismatchException) {
return true;
}
return isExcelHeaderMismatchException(e.getCause());
}
public void validate(UploadFile file) { public void validate(UploadFile file) {
RopResponse<?> validateResp = uploadFileService.validate(file, "excel"); RopResponse<?> validateResp = uploadFileService.validate(file, "excel");
if (validateResp.getData() == null) { if (validateResp.getData() == null) {
......
package cn.com.glsx.dj.oaapproval.utils;
import java.math.BigDecimal;
public class NumberValidationUtil {
private static final BigDecimal ZERO = BigDecimal.ZERO;
private static final BigDecimal ONE = BigDecimal.ONE;
public static String validateBigDecimalNotNull(BigDecimal value, String fieldName) {
if (value == null) {
return fieldName + "不能为空";
}
return null;
}
public static String validateBigDecimalNotNegative(BigDecimal value, String fieldName) {
if (value == null) {
return fieldName + "不能为空";
}
if (value.compareTo(ZERO) < 0) {
return fieldName + "不能为负数";
}
return null;
}
public static String validateBigDecimalPercentage(BigDecimal value, String fieldName) {
if (value == null) {
return fieldName + "不能为空或者异常";
}
if (value.compareTo(ZERO) < 0 || value.compareTo(ONE) > 0) {
return fieldName + "必须在0到1之间";
}
return null;
}
public static String validateIntegerNotNull(Integer value, String fieldName) {
if (value == null) {
return fieldName + "不能为空";
}
return null;
}
public static String validateIntegerNotNegative(Integer value, String fieldName) {
if (value == null) {
return fieldName + "不能为空";
}
if (value < 0) {
return fieldName + "不能为负数";
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.oaapproval.vo; package cn.com.glsx.dj.oaapproval.vo;
import cn.com.glsx.dj.oaapproval.dto.store.BatchStoreImportDTO; import cn.com.glsx.dj.oaapproval.dto.store.ImportErrorInfo;
import cn.com.glsx.dj.oaapproval.dto.store.SingleStoreImportDTO;
import cn.com.glsx.dj.oaapproval.dto.store.StoreWithProductsDTO; import cn.com.glsx.dj.oaapproval.dto.store.StoreWithProductsDTO;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Data;
@Data @Data
public class CreateBusinessApproveImportExcelContext implements Serializable { public class CreateBusinessApproveImportExcelContext implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List<SingleStoreImportDTO> singleStoreImportDTOS = new ArrayList<>();
private List<BatchStoreImportDTO> batchStoreImportDTOS = new ArrayList<>();
private List<StoreWithProductsDTO> storeWithProductsDTOS = new ArrayList<>(); private List<StoreWithProductsDTO> storeWithProductsDTOS = new ArrayList<>();
private List<String> errorMessages = new ArrayList<>(); private List<ImportErrorInfo> errorMessages = new ArrayList<>();
private Integer totalRows = 0; private Integer totalRows = 0;
...@@ -28,7 +22,11 @@ public class CreateBusinessApproveImportExcelContext implements Serializable { ...@@ -28,7 +22,11 @@ public class CreateBusinessApproveImportExcelContext implements Serializable {
private Integer failRows = 0; private Integer failRows = 0;
public void addErrorMessage(String message) { public void addErrorMessage(String message) {
this.errorMessages.add(message); this.errorMessages.add(new ImportErrorInfo(null, message, null));
}
public void addErrorInfo(ImportErrorInfo errorInfo) {
this.errorMessages.add(errorInfo);
} }
public void incrementSuccessRows() { public void incrementSuccessRows() {
......
...@@ -54,7 +54,7 @@ public class CreateBussinessApproveControllerTest extends BaseControllerTest { ...@@ -54,7 +54,7 @@ public class CreateBussinessApproveControllerTest extends BaseControllerTest {
@Test @Test
public void testCreateDraft() throws Exception { public void testCreateDraft() throws Exception {
UploadFile uploadFile = new UploadFile(new File("F:\\360MoveData\\Users\\11\\Desktop\\企微SAAS\\门店上架模版-单店模式 (2).xlsx")); UploadFile uploadFile = new UploadFile(new File("C:\\Users\\11\\Downloads\\门店上架模版-项目制批量上架 (1).xlsx"));
String file = "xlsx@" + Base64.encodeBase64String(uploadFile.getContent()); String file = "xlsx@" + Base64.encodeBase64String(uploadFile.getContent());
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(10); MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(10);
params.add("v", "1.0.0"); params.add("v", "1.0.0");
...@@ -62,12 +62,10 @@ public class CreateBussinessApproveControllerTest extends BaseControllerTest { ...@@ -62,12 +62,10 @@ public class CreateBussinessApproveControllerTest extends BaseControllerTest {
params.add("file", file); params.add("file", file);
params.add("basicApproveInfo", "{\"storeCode\":\"10001\",\"storeName\":\"测试门店\",\"merchantId\":1,\"merchantName\":\"测试商户\"}"); params.add("basicApproveInfo", "{\"storeCode\":\"10001\",\"storeName\":\"测试门店\",\"merchantId\":1,\"merchantName\":\"测试商户\"}");
params.add("approveType", "1"); params.add("approveType", "1");
params.add("merchantId", "442107956"); params.add("shelfType", "2");
params.add("merchantName", "测试商户");
params.add("shelfType", "1");
params.add("sceneType", "1"); params.add("sceneType", "1");
params.add("baseSceneCode", "110101"); params.add("baseSceneCode", "110101");
params.add("sessionId", "964e6dd9-0d8a-4e1f-bcaa-e09da7e55da5"); params.add("sessionId", "bb9c2a78-05de-41bc-a72a-9790e1b03088");
params.add("submitFlag", "0"); params.add("submitFlag", "0");
System.out.println(post(params)); System.out.println(post(params));
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!