parent
f89fc18d39
commit
855a58b58b
@ -0,0 +1,27 @@
|
|||||||
|
package com.dsic.gj_erp.bean.zyjh;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PwExcel {
|
||||||
|
|
||||||
|
@ExcelProperty(value = "船号")
|
||||||
|
public String dcCh;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "批量")
|
||||||
|
public String dcPl;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "分段")
|
||||||
|
public String dcFd;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "套料图")
|
||||||
|
public String tlth;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "备注")
|
||||||
|
public String bz;
|
||||||
|
|
||||||
|
public int dataOrder;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.dsic.gj_erp.controller.zyjh.dto;
|
||||||
|
|
||||||
|
import com.dsic.gj_erp.bean.zyjh.YcldwInfo;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class PwpgDto {
|
||||||
|
|
||||||
|
private String worker;
|
||||||
|
private List<YcldwInfo> list;
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.dsic.gj_erp.listeners;
|
||||||
|
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.dsic.gj_erp.bean.zyjh.PwExcel;
|
||||||
|
import com.dsic.gj_erp.util.ObjConvertUtils;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel通用监听器
|
||||||
|
*/
|
||||||
|
public class ExcelPwListener extends AnalysisEventListener<PwExcel> {
|
||||||
|
|
||||||
|
private static final int BATCH_COUNT = 500;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
List<PwExcel> objectList = new ArrayList<>();
|
||||||
|
List<Object> headList = new ArrayList<>();
|
||||||
|
|
||||||
|
List<PwExcel> datas = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(PwExcel excelDemo, AnalysisContext analysisContext) {
|
||||||
|
boolean b = ObjConvertUtils.checkObjAllFieldsIsNull(excelDemo);
|
||||||
|
if(!b){
|
||||||
|
datas.add(excelDemo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datas.size() >= BATCH_COUNT) {
|
||||||
|
saveData();
|
||||||
|
datas.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||||
|
saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取表头
|
||||||
|
@Override
|
||||||
|
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
|
||||||
|
headList.add(headMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库
|
||||||
|
*/
|
||||||
|
private void saveData() {
|
||||||
|
objectList.addAll(datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue