feat: 增加大汉,安徽卡的导入

dev
huangfeng 4 months ago
parent d010a3a792
commit 58691e83a8

@ -1,10 +1,13 @@
package com.shxy.xymanager_admin.controller; package com.shxy.xymanager_admin.controller;
import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.annotation.Log; import com.shxy.xymanager_common.annotation.Log;
import com.shxy.xymanager_common.base.BaseController; import com.shxy.xymanager_common.base.BaseController;
import com.shxy.xymanager_common.base.ResponseReult; import com.shxy.xymanager_common.base.ResponseReult;
import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.entity.SimInfo; import com.shxy.xymanager_common.entity.SimInfo;
import com.shxy.xymanager_service.excel.*;
import com.shxy.xymanager_service.service.SimService; import com.shxy.xymanager_service.service.SimService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -28,6 +31,17 @@ public class SimController extends BaseController {
public ResponseReult<String> importSim(@RequestParam("file") MultipartFile file, public ResponseReult<String> importSim(@RequestParam("file") MultipartFile file,
@RequestParam(value = "type", required = true) Integer type) throws Exception { @RequestParam(value = "type", required = true) Integer type) throws Exception {
if (file != null && file.getInputStream() != null) { if (file != null && file.getInputStream() != null) {
if (type == Constants.NetType_Dahan) {
DahanExcelListener listener = new DahanExcelListener(service);
EasyExcel.read(file.getInputStream(), DahanLine.class, listener)
.sheet(0)
.doRead();
} else if (type == Constants.NetType_LWWLKJ) {
LwwlkjExcelListener listener = new LwwlkjExcelListener(service);
EasyExcel.read(file.getInputStream(), LwwlkjLine.class, listener)
.sheet(0)
.doRead();
}
return ResponseReult.success("OK"); return ResponseReult.success("OK");
} else { } else {

@ -0,0 +1,41 @@
package com.shxy.xymanager_service.excel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.entity.SimInfo;
import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_service.service.SimService;
public class DahanExcelListener extends AnalysisEventListener<DahanLine> {
SimService service;
public DahanExcelListener(SimService service) {
this.service = service;
}
@Override
public void invoke(DahanLine line, AnalysisContext analysisContext) {
int rowidx = analysisContext.readRowHolder().getRowIndex();
if (rowidx > 0) {
processLine(line);
}
}
private void processLine(DahanLine line) {
if (StringUtils.isNotEmpty(line.getIccid()) && StringUtils.isNotEmpty(line.getMsisdn())) {
SimInfo sim = new SimInfo();
sim.setIccid(line.getIccid());
sim.setMsisdn(line.getMsisdn());
sim.setImsi(line.getImsi());
sim.setType(Constants.NetType_Dahan);
service.addOrUpdate(sim);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}

@ -0,0 +1,18 @@
package com.shxy.xymanager_service.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class DahanLine {
@ExcelProperty("ICCID")
private String iccid;
@ExcelProperty("MSISDN")
private String msisdn;
@ExcelProperty("IMSI")
private String imsi;
}

@ -0,0 +1,40 @@
package com.shxy.xymanager_service.excel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.entity.SimInfo;
import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_service.service.SimService;
public class LwwlkjExcelListener extends AnalysisEventListener<LwwlkjLine> {
SimService service;
public LwwlkjExcelListener(SimService service) {
this.service = service;
}
@Override
public void invoke(LwwlkjLine line, AnalysisContext analysisContext) {
int rowidx = analysisContext.readRowHolder().getRowIndex();
if (rowidx > 0) {
processLine(line);
}
}
private void processLine(LwwlkjLine line) {
if (StringUtils.isNotEmpty(line.getIccid()) && StringUtils.isNotEmpty(line.getMsisdn())) {
SimInfo sim = new SimInfo();
sim.setIccid(line.getIccid());
sim.setMsisdn(line.getMsisdn());
sim.setType(Constants.NetType_LWWLKJ);
service.addOrUpdate(sim);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}

@ -0,0 +1,18 @@
package com.shxy.xymanager_service.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class LwwlkjLine {
@ExcelProperty("运营商")
private String provider;
@ExcelProperty("物联卡号")
private String msisdn;
@ExcelProperty("ICCID")
private String iccid;
}
Loading…
Cancel
Save