Commit d0ced848 by wangchunyang

导入修改

parent e76fdea5
......@@ -21,13 +21,15 @@ public class MaterialImp {
private Double unit_price;
@ExcelProperty(value = "存储位置", index = 6)
private String storage_location;
@ExcelProperty(value = "最低库存", index = 7)
@ExcelProperty(value = "供应商", index = 7)
private String supplier_name;
@ExcelProperty(value = "最低库存", index = 8)
private Double min_stock;
@ExcelProperty(value = "最高库存", index = 8)
@ExcelProperty(value = "最高库存", index = 9)
private Double max_stock;
@ExcelProperty(value = "可领用", index = 9)
private Integer can_borrow;
@ExcelProperty(value = "描述", index = 10)
@ExcelProperty(value = "可领用", index = 10)
private String can_borrow;
@ExcelProperty(value = "描述", index = 11)
private String material_desc;
}
......
......@@ -4,9 +4,7 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.scpyun.base.core.utils.StringUtils;
import com.scpyun.base.core.utils.UUIDUtil;
import com.scpyun.base.core.utils.validator.IdcardUtil;
import com.scpyun.base.db.service.CommonService;
import com.scpyun.platform.jilinsscgsdp.bean.entity.KeyPersonImp;
import com.scpyun.platform.jilinsscgsdp.bean.entity.MaterialImp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,27 +35,30 @@ public class MaterialFileListener extends AnalysisEventListener<MaterialImp> {
private Map<String, Map> catgoryMap = new HashMap<>();
private Map<String, Map> materialMap = new HashMap<>();
private int sortNo = 0;
private Map<String, Object> user = null;
public MaterialFileListener(CommonService commonService, String namespace, Map<String,Object> param) {
this.commonService = commonService;
this.namespace = namespace;
this.param = param;
user = (Map<String, Object>) param.get("_user");
//获取所有办公用品分类信息
List<Map<String, Object>> catgoryLisit = commonService.findList(catgoryNamespace + "findList", param);
catgoryLisit.forEach(item -> {
catgoryMap.put(String.valueOf(item.get("category_name")), item);
});
int tempsortNo = 0;
//获取所有办公用品信息,后续根据办公用品编码来判断更新或插入
List<Map<String, Object>> materialLisit = commonService.findList(materialNamespace + "findList", param);
materialLisit.forEach(item -> {
catgoryMap.put(String.valueOf(item.get("material_code")), item);
for (int i = 0; i < materialLisit.size(); i++) {
Map<String, Object> item = materialLisit.get(i);
materialMap.put(String.valueOf(item.get("material_code")), item);
Integer sort = (Integer)item.get("sort_no");
if (sort != null) {
if (sort != null && sortNo < sort.intValue()) {
sortNo = sort;
}
});
}
sortNo = sortNo + 1;
}
@Override
......@@ -99,16 +100,15 @@ public class MaterialFileListener extends AnalysisEventListener<MaterialImp> {
Map<String, Object> exists = materialMap.get(m.getMaterial_code());
if(StringUtils.isNotEmpty(m.getCategory_name())) {
Map<String, Object> catgory = catgoryMap.get(m.getCategory_code());
Map<String, Object> catgory = catgoryMap.get(m.getCategory_name());
if(catgory!=null) {
row.put("category_Code", String.valueOf(catgory.get("category_code")));
row.put("category_Name", m.getCategory_name());
row.put("category_id", String.valueOf(catgory.get("id")));
}
}
double min = 0L;
double max = 0L;
int can_borrow = 1;
int can_borrow = 0;
double unit_price = 0L;
if(m.getMin_stock()!=null) {
min = m.getMin_stock();
......@@ -116,8 +116,8 @@ public class MaterialFileListener extends AnalysisEventListener<MaterialImp> {
if(m.getMax_stock()!=null) {
max = m.getMax_stock();
}
if(!new Integer(1).equals(m.getCan_borrow())) {
can_borrow = 0;
if("是".equals(m.getCan_borrow())) {
can_borrow = 1;
}
if(m.getUnit_price()!=null) {
unit_price = m.getUnit_price();
......@@ -134,6 +134,9 @@ public class MaterialFileListener extends AnalysisEventListener<MaterialImp> {
row.put("can_borrow", can_borrow);
row.put("material_desc", m.getMaterial_desc());
row.put("order_no", sortNo++);
row.put("supplier_name", m.getSupplier_name());
row.put("status", 1);
row.put("_user", user);
if (exists == null) {
row.put("id", UUIDUtil.getUUID());
commonService.insert(namespace + "insert", row);
......
......@@ -57,7 +57,7 @@
create_time,
order_no
) VALUES (
#{#id},
#{id},
#{catgory_name},
#{remark},
1,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论