From 5c1e5f8ce5e53c187f100f5d786a77991198960a Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期二, 18 三月 2025 15:23:44 +0800
Subject: [PATCH] 修改 # 物料导入导出添加动态扩展字段
---
rsf-server/pom.xml | 23 +--
rsf-server/src/main/java/com/vincent/rsf/server/common/utils/ExcelUtil.java | 65 ---------
rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java | 43 +++++
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java | 143 +++++++++++--------
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java | 61 +++++---
rsf-server/src/main/resources/mapper/test/LocMapper.xml | 5
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/AsnOrderTemplate.java | 27 ---
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/MatnrsTemplate.java | 15 +
rsf-server/src/main/resources/application.yml | 2
rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java | 4
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Matnr.java | 6
11 files changed, 191 insertions(+), 203 deletions(-)
diff --git a/rsf-server/pom.xml b/rsf-server/pom.xml
index 1d061c1..2c67954 100644
--- a/rsf-server/pom.xml
+++ b/rsf-server/pom.xml
@@ -73,11 +73,17 @@
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
- <version>4.1.2</version>
+ <version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
@@ -140,21 +146,6 @@
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.6</version>
</dependency>
- <dependency>
- <groupId>cn.afterturn</groupId>
- <artifactId>easypoi-annotation</artifactId>
- <version>4.2.0</version>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>easyexcel</artifactId>
- <version>2.2.6</version>
- </dependency>
-<!-- <dependency>-->
-<!-- <groupId>cn.afterturn</groupId>-->
-<!-- <artifactId>easypoi-base</artifactId>-->
-<!-- <version>4.2.0</version>-->
-<!-- </dependency>-->
</dependencies>
<build>
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java
index 39d11cc..4fc83d3 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/CodeBuilder.java
@@ -22,9 +22,9 @@
// generator.username="sa";
// generator.password="Zoneyung@zy56$";
- generator.table="man_qly_ispt_item";
+ generator.table="man_loc";
generator.tableDesc="璐ㄦ淇℃伅";
- generator.packagePath="com.vincent.rsf.server.manager";
+ generator.packagePath="com.vincent.rsf.server.test";
generator.build();
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/ExcelUtil.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/ExcelUtil.java
index aefafe3..43131e0 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/ExcelUtil.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/ExcelUtil.java
@@ -2,12 +2,9 @@
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.entity.ImportParams;
-import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.SpringUtils;
-import com.vincent.rsf.framework.exception.CoolException;
-import com.vincent.rsf.server.manager.entity.Matnr;
import com.vincent.rsf.server.manager.entity.excel.MatnrsTemplate;
import com.vincent.rsf.server.manager.entity.excel.annotation.ExcelComment;
import com.vincent.rsf.server.system.entity.Fields;
@@ -16,7 +13,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.*;
import javax.servlet.http.HttpServletResponse;
@@ -143,69 +139,10 @@
public static ImportParams getDefaultImportParams() {
ImportParams importParams = new ImportParams();
importParams.setTitleRows(0);
+// importParams.setNeedVerify(true);
importParams.setHeadRows(1);
importParams.setSheetNum(1);
return importParams;
- }
-
- /**
- * @author Ryan
- * @description Excel瀵煎嚭Map鏍煎紡琛ㄦ牸
- * @param
- * @return
- * @time 2025/3/18 09:30
- */
- public static void exportForMap(HttpServletResponse response, Class cls, String fileName, List<List<Object>> data) {
- try {
- response.setContentType("application/octet-stream; charset=utf-8");
- response.setCharacterEncoding("utf-8");
- String name = URLEncoder.encode(fileName, "UTF-8");
- response.setHeader("Content-disposition", "attachment;filename=" + name + ".xlsx");
- EasyExcel.write(response.getOutputStream()).head(getHeader(cls)).sheet().doWrite(null);
- } catch (IOException exception) {
- exception.printStackTrace();
- }
- }
-
- /**
- * @author Ryan
- * @description excel瀵煎嚭map妯″紡
- * @param Class<T> 妯℃澘绫诲瀷
- * @return List<List<String>> 琛ㄥご淇℃伅
- * @time 2025/3/18 09:26
- */
- public static List<List<String>> getHeader(Class<T> t) {
- List<List<String>> headList = new ArrayList<List<String>>();
- if (t.getSuperclass().isInstance(MatnrsTemplate.class)) {
- Field[] allFields = Cools.getAllFields(t);
- if (Objects.isNull(allFields) || allFields.length < 1) {
- throw new CoolException("妯℃澘鍒椾笉鑳戒负绌猴紒锛�");
- }
- for (Field field : allFields) {
- List<String> list = new ArrayList<String>();
- String fieldName = "";
- if (field.isAnnotationPresent(Excel.class)){
- fieldName = field.getAnnotation(Excel.class).name();
- }
-
- list.add(field.getName());
- headList.add(list);
- }
-
- FieldsService itemService = SpringUtils.getBean(FieldsService.class);
- List<Fields> sysFields = itemService.list(new LambdaQueryWrapper<Fields>()
- .eq(Fields::getStatus, 1)
- .eq(Fields::getFlagEnable, 1));
- //娣诲姞鎵╁睍瀛楁鍒悕
- if (!sysFields.isEmpty()) {
- sysFields.forEach(fields1 -> {
- List<String> list = new ArrayList<String>();
- list.add(fields1.getFieldsAlise());
- headList.add(list);
- });
- }
- }
- return headList;
}
/**
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
index 2496618..d71068e 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
@@ -2,14 +2,13 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.common.SpringUtils;
+import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.system.entity.Fields;
import com.vincent.rsf.server.system.entity.FieldsItem;
import com.vincent.rsf.server.system.service.FieldsItemService;
import com.vincent.rsf.server.system.service.FieldsService;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @author Ryan
@@ -23,7 +22,7 @@
/**
* @author Ryan
- * @description 閫氳繃瀛楁鍞竴鏍囪瘑鑾峰彇鍔ㄦ�佸瓧娈礛ap
+ * @description 閫氳繃瀛楁鍞竴鏍囪瘑鑾峰彇鍔ㄦ�佸瓧娈靛璞ey-value
* @param
* @return
* @time 2025/3/12 12:50
@@ -51,5 +50,41 @@
return fieldsMap;
}
+
+ /**
+ * @param template
+ * @return
+ * @author Ryan
+ * @description 鍔ㄦ�佸瓧娈祐alue淇濆瓨
+ * @time 2025/3/18 15:00
+ */
+ public static void saveFields(Map<String, String> template, String uuid) {
+ List<Fields> fields = getFieldsSta();
+ FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
+ if (fields.isEmpty()) {
+ throw new CoolException("鎵╁睍瀛楁涓嶅瓨鍦紒锛�");
+ }
+ List<FieldsItem> fieldsItems = new ArrayList<>();
+ fields.forEach(fields1 -> {
+ if (!Objects.isNull(template.get(fields1.getFields()))) {
+ FieldsItem item = new FieldsItem();
+ item.setFieldsId(fields1.getId())
+ .setUuid(uuid)
+ .setValue(template.get(fields1.getFields()));
+ fieldsItems.add(item);
+ }
+ });
+ if (!fieldsItemService.saveBatch(fieldsItems)) {
+ throw new CoolException("鍔ㄦ�佸瓧娈靛�间繚瀛樺け璐ワ紒锛�");
+ }
+ }
+ /**
+ * 鑾峰彇鎵�鏈夊紑鍚姩鎬佹墿灞曞瓧娈�
+ * @return
+ */
+ public static List<Fields> getFieldsSta() {
+ FieldsService fieldsService = SpringUtils.getBean(FieldsService.class);
+ return fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getStatus, 1).eq(Fields::getFlagEnable, 1));
+ }
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
index 24a47ed..8781760 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Loc.java
@@ -1,24 +1,22 @@
package com.vincent.rsf.server.manager.entity;
import com.baomidou.mybatisplus.annotation.*;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import com.vincent.rsf.server.manager.service.WarehouseAreasService;
-import com.vincent.rsf.server.manager.service.WarehouseService;
-import lombok.experimental.Accessors;
-import org.springframework.format.annotation.DateTimeFormat;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.SpringUtils;
-import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
+import com.vincent.rsf.server.system.service.UserService;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
import java.io.Serializable;
+import java.text.SimpleDateFormat;
+import java.util.Date;
@Data
-@TableName("man_loc")
@Accessors(chain = true)
+@TableName("man_loc")
public class Loc implements Serializable {
private static final long serialVersionUID = 1L;
@@ -31,28 +29,29 @@
private Long id;
/**
- * 浠撳簱鏍囪瘑
- */
- @ApiModelProperty(value = "浠撳簱鏍囪瘑")
- private Long warehouseId;
- /**
* 搴撳尯鏍囪瘑
*/
@ApiModelProperty(value= "搴撳尯鏍囪瘑")
private Long areaId;
/**
- * 缂栧彿
+ * 搴撲綅鍙�
*/
- @ApiModelProperty(value= "缂栧彿")
+ @ApiModelProperty(value= "搴撲綅鍙�")
private String code;
/**
- * 搴撲綅绫诲瀷
+ * 浠撳簱鏍囪瘑
*/
- @ApiModelProperty(value= "搴撲綅绫诲瀷")
- private String type;
+ @ApiModelProperty(value= "浠撳簱鏍囪瘑")
+ private Long warehouseId;
+ /**
+ * 搴撲綅绫诲瀷(*) H: 楂樺簱浣� M: 涓簱浣� L: 浣庡簱浣�
+ */
+ @ApiModelProperty(value= "搴撲綅绫诲瀷(*) H: 楂樺簱浣� M: 涓簱浣� L: 浣庡簱浣� ")
+ @TableField("`type`")
+ private String type;
/**
* 铏氭嫙搴撲綅
@@ -79,24 +78,23 @@
private String unit;
/**
- * 闀�/瀹�/楂�
+ * 闀�
*/
- @ApiModelProperty(value= "闀�/瀹�/楂�")
+ @ApiModelProperty(value= "闀�")
@TableField("`length`")
private Double length;
/**
- * 瀹�
- */
- @ApiModelProperty("瀹�")
- @TableField("`width`")
- private Double width;
-
- /**
* 楂�
*/
- @ApiModelProperty("楂�")
+ @ApiModelProperty(value= "楂�")
private Double height;
+
+ /**
+ * 瀹�
+ */
+ @ApiModelProperty(value= "瀹�")
+ private Double width;
/**
* 鎺�
@@ -118,15 +116,11 @@
private Integer lev;
/**
- * 閫氶亾
+ * 宸烽亾
*/
@ApiModelProperty(value= "宸烽亾")
+ @TableField("`channel`")
private Integer channel;
-
- /**
- * 搴撲綅浣跨敤鐘舵��
- */
- private String useStatus;
/**
* 鏈�澶ч浂浠舵暟
@@ -139,6 +133,12 @@
*/
@ApiModelProperty(value= "鏈�澶у寘瑁呮暟")
private Integer maxPack;
+
+ /**
+ * 搴撲綅浣跨敤鐘舵�� O: 绌哄簱 D: 绌烘澘 R: 棰勭害鍑哄簱 S: 棰勭害鍏ュ簱 X: 绂佺敤 聽 F: 鍦ㄥ簱
+ */
+ @ApiModelProperty(value= "搴撲綅浣跨敤鐘舵�� O: 绌哄簱 D: 绌烘澘 R: 棰勭害鍑哄簱 S: 棰勭害鍏ュ簱 X: 绂佺敤 聽 F: 鍦ㄥ簱 ")
+ private String useStatus;
/**
* 鏄惁鏍囩绠$悊
@@ -156,6 +156,7 @@
* 鐘舵�� 1: 姝e父 0: 鍐荤粨
*/
@ApiModelProperty(value= "鐘舵�� 1: 姝e父 0: 鍐荤粨 ")
+ @TableField("`status`")
private Integer status;
/**
@@ -205,24 +206,25 @@
public Loc() {}
- public Loc(Long areaId, Long warehouseId, String code,String type,Short flagLogic,String fucAtrrs,String barcode,String unit,Double size, Double width, Double height,Integer lrow,Integer col,Integer lev,Integer channel,Integer maxParts,Integer maxPack,Short flagLabelMange,String locAttrs,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
- this.warehouseId = warehouseId;
+ public Loc(Long areaId, String code, Long warehouseId, String type, Short flagLogic, String fucAtrrs, String barcode, String unit, Double length, Double height, Double width, Integer row, Integer col, Integer lev, Integer channel, Integer maxParts, Integer maxPack, String useStatus, Short flagLabelMange, String locAttrs, Integer status, Integer deleted, Integer tenantId, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo) {
this.areaId = areaId;
this.code = code;
+ this.warehouseId = warehouseId;
this.type = type;
- this.width = width;
- this.height = height;
this.flagLogic = flagLogic;
this.fucAtrrs = fucAtrrs;
this.barcode = barcode;
this.unit = unit;
- this.length = size;
- this.row = lrow;
+ this.length = length;
+ this.height = height;
+ this.width = width;
+ this.row = row;
this.col = col;
this.lev = lev;
this.channel = channel;
this.maxParts = maxParts;
this.maxPack = maxPack;
+ this.useStatus = useStatus;
this.flagLabelMange = flagLabelMange;
this.locAttrs = locAttrs;
this.status = status;
@@ -237,22 +239,25 @@
// Loc loc = new Loc(
// null, // 搴撳尯鏍囪瘑[闈炵┖]
-// null, // 缂栧彿[闈炵┖]
-// null, // 搴撲綅绫诲瀷[闈炵┖]
-// null, // 鍚嶇О
+// null, // 搴撲綅鍙�
+// null, // 浠撳簱鏍囪瘑[闈炵┖]
+// null, // 搴撲綅绫诲瀷(*)[闈炵┖]
// null, // 铏氭嫙搴撲綅
// null, // 鍔熻兘灞炴��
// null, // 瀹瑰櫒缂栫爜
// null, // 瀛樻斁鍗曚綅
-// null, // 闀�/瀹�/楂�
+// null, // 闀�
+// null, // 楂�
+// null, // 瀹�
// null, // 鎺抂闈炵┖]
// null, // 鍒梉闈炵┖]
// null, // 灞俒闈炵┖]
-// null, // 閫氶亾[闈炵┖]
+// null, // 宸烽亾
// null, // 鏈�澶ч浂浠舵暟
// null, // 鏈�澶у寘瑁呮暟
+// null, // 搴撲綅浣跨敤鐘舵�乕闈炵┖]
// null, // 鏄惁鏍囩绠$悊
-// null, // 灞炴�闈炵┖]
+// null, // 灞炴��
// null, // 鐘舵�乕闈炵┖]
// null, // 鏄惁鍒犻櫎[闈炵┖]
// null, // 绉熸埛
@@ -263,22 +268,38 @@
// null // 澶囨敞
// );
- public String getWarehouseId$() {
- WarehouseService service = SpringUtils.getBean(WarehouseService.class);
- Warehouse warehouse = service.getById(this.warehouseId);
- if (!Cools.isEmpty(warehouse)) {
- return String.valueOf(warehouse.getName());
+ public String getType$(){
+ if (null == this.type){ return null; }
+ switch (this.type){
+ case "H":
+ return " 楂樺簱浣�";
+ case "M":
+ return " 涓簱浣�";
+ case "L":
+ return " 浣庡簱浣�";
+ default:
+ return String.valueOf(this.type);
}
- return null;
}
- public String gerAreaId$() {
- WarehouseAreasService service = SpringUtils.getBean(WarehouseAreasService.class);
- WarehouseAreas areas = service.getById(this.areaId);
- if (!Cools.isEmpty(areas)) {
- return String.valueOf(areas.getName());
+ public String getUseStatus$(){
+ if (null == this.useStatus){ return null; }
+ switch (this.useStatus){
+ case "O":
+ return " 绌哄簱";
+ case "D":
+ return " 绌烘澘";
+ case "R":
+ return " 棰勭害鍑哄簱";
+ case "S":
+ return " 棰勭害鍏ュ簱";
+ case "X":
+ return " 绂佺敤";
+ case "F":
+ return " 鍦ㄥ簱";
+ default:
+ return String.valueOf(this.useStatus);
}
- return null;
}
public String getStatus$(){
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Matnr.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Matnr.java
index d127f14..4bb88cb 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Matnr.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/Matnr.java
@@ -69,6 +69,12 @@
private Long groupId;
/**
+ * 瀛楁鏍囪瘑
+ */
+ @ApiModelProperty(value = "瀛楁鏍囪瘑")
+ private String fieldsIndex;
+
+ /**
* 鍒嗙粍鍔╄鐮�
*/
@ApiModelProperty(value = "鍒嗙粍鍔╄鐮�")
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/AsnOrderTemplate.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/AsnOrderTemplate.java
index c3c09a5..1efaedb 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/AsnOrderTemplate.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/AsnOrderTemplate.java
@@ -6,8 +6,6 @@
import com.vincent.rsf.server.manager.entity.excel.annotation.ExcelAutoColumnSize;
import com.vincent.rsf.server.manager.entity.excel.annotation.ExcelComment;
import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.ToString;
import lombok.experimental.Accessors;
import java.io.Serializable;
@@ -24,7 +22,7 @@
@Accessors(chain = true)
//@ToString(callSuper = true)
//@EqualsAndHashCode(callSuper = false)
-public class AsnOrderTemplate implements IExcelModel, IExcelDataModel, Serializable {
+public class AsnOrderTemplate implements Serializable {
@Excel(name = "琛屽彿")
@ExcelComment(value = "platItemId", example = "1357564255478")
@@ -82,27 +80,4 @@
@ExcelComment(value = "memo",example = "娉細鏄撶鍝侊紝杞绘嬁鏀�")
private String memo;
- private Integer rowNum;
-
- private String errorMsg;
-
- @Override
- public Integer getRowNum() {
- return this.rowNum;
- }
-
- @Override
- public void setRowNum(Integer rowNum) {
- this.rowNum = rowNum;
- }
-
- @Override
- public String getErrorMsg() {
- return this.errorMsg;
- }
-
- @Override
- public void setErrorMsg(String errorMsg) {
- this.errorMsg = errorMsg;
- }
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/MatnrsTemplate.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/MatnrsTemplate.java
index 688ab4d..9904ef6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/MatnrsTemplate.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/excel/MatnrsTemplate.java
@@ -8,6 +8,7 @@
import lombok.ToString;
import lombok.experimental.Accessors;
+import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
@@ -18,32 +19,34 @@
* @create 2025/3/3 08:40
*/
@Data
-@ExcelAutoColumnSize
-@Accessors(chain = true)
-@ToString(callSuper = true)
-@EqualsAndHashCode(callSuper = false)
-public class MatnrsTemplate implements Serializable {
+public class MatnrsTemplate {
+ @NotNull
@Excel(name = "鐗╂枡鍚嶇О")
@ExcelComment(example = "鍗庝负鎵嬫満")
private String name;
+ @NotNull
@Excel(name = "鍒嗙被鍔╄鐮�")
@ExcelComment(example = "256874556")
private String groupCode;
+ @NotNull
@Excel(name = "鍒嗙被鍚嶇О")
@ExcelComment(example = "绉诲姩璁惧")
private String groupName;
+ @NotNull
@Excel(name = "鐗╂枡鍔╄鐮�")
@ExcelComment(example = "P3528461569")
private String erpCode;
+ @NotNull
@Excel(name = "瑙勬牸")
@ExcelComment(example = "HW-148*68*10")
private String spec;
+ @NotNull
@Excel(name = "鍨嬪彿")
@ExcelComment(example = "鍗庝负涓夋姌鍙�")
private String model;
@@ -68,6 +71,7 @@
@ExcelComment(notNull = false, example = "鏂颁笂甯備笁鎶樺彔")
private String nromNum;
+ @NotNull
@Excel(name = "涓诲崟浣�")
@ExcelComment(example = "閮�")
private String unit;
@@ -88,6 +92,7 @@
@ExcelComment(notNull = false, example = "10")
private String minQty;
+ @NotNull
@Excel(name = "鏈�澶у簱瀛橀噺")
@ExcelComment(notNull = false, example = "150")
private String maxQty;
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
index ccfd8ca..ef2b8ce 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
@@ -4,8 +4,11 @@
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.framework.common.SpringUtils;
import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.common.utils.CommonUtil;
import com.vincent.rsf.server.common.utils.ExcelUtil;
+import com.vincent.rsf.server.common.utils.FieldsUtils;
import com.vincent.rsf.server.manager.entity.MatnrGroup;
import com.vincent.rsf.server.manager.entity.excel.MatnrsTemplate;
import com.vincent.rsf.server.manager.mapper.MatnrMapper;
@@ -13,6 +16,8 @@
import com.vincent.rsf.server.manager.service.MatnrGroupService;
import com.vincent.rsf.server.manager.service.MatnrService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.vincent.rsf.server.system.entity.Fields;
+import com.vincent.rsf.server.system.service.FieldsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -20,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
@Service("matnrService")
@@ -39,38 +45,45 @@
@Transactional(rollbackFor = Exception.class)
public R importExcels(MultipartFile file) throws Exception {
//璇诲彇涓婁紶鏂囦欢鍐呭
- ExcelImportResult<MatnrsTemplate> result = ExcelImportUtil.importExcelMore(file.getInputStream(), MatnrsTemplate.class, ExcelUtil.getDefaultImportParams());
+ ExcelImportResult result = ExcelImportUtil.importExcelMore(file.getInputStream(), MatnrsTemplate.class, ExcelUtil.getDefaultImportParams());
if (result.getList().isEmpty()) {
throw new CoolException("鐗╂枡瀵煎叆澶辫触锛侊紒");
}
List<Matnr> matnrs = new ArrayList<>();
- result.getList().forEach(template -> {
+ List<Map<String, String>> list = result.getList();
+ list.forEach(template -> {
Matnr matnr = new Matnr();
- matnr.setBarcode(template.getBarcode())
- .setCode(template.getErpCode())
- .setDescrible(template.getDescrible())
- .setColor(template.getColor())
- .setFlagCheck(Short.parseShort(template.getFlagCheck()))
- .setWeight(Double.parseDouble(template.getWeight()))
- .setValidWarn(Integer.parseInt(template.getValidWarn()))
- .setValid(Integer.parseInt(template.getValid()))
- .setUnit(template.getUnit())
- .setStockUnit(template.getPurUnit())
- .setSpec(template.getSpec())
- .setStagn(Integer.parseInt(template.getStagn()))
- .setModel(template.getModel())
- .setGroupCode(template.getGroupCode())
- .setPurUnit(template.getPurUnit())
- .setStockLevel(Short.parseShort(template.getStockLevel()))
- .setSafeQty(Double.parseDouble(template.getSafeQty()))
- .setMinQty(Double.parseDouble(template.getMinQty()));
- if (Objects.isNull(template.getGroupCode()) && Objects.isNull(template.getGroupName())) {
+ matnr.setBarcode(template.get("barcode"))
+ .setCode(template.get("code"))
+ .setDescrible(template.get("describle"))
+ .setColor(template.get("color"))
+ .setFlagCheck(!Objects.isNull(template.get("flagCheck")) ? Short.parseShort(template.get("flagCheck")) : 0)
+ .setWeight(!Objects.isNull(template.get("weight")) ? Double.parseDouble(template.get("weight")) : 0.0)
+ .setValidWarn(!Objects.isNull(template.get("validWarn")) ? Integer.parseInt(template.get("validWarn")): 0)
+ .setValid(!Objects.isNull(template.get("valid")) ? Integer.parseInt( template.get("valid")) : 0)
+ .setUnit(template.get("unit"))
+ .setStockUnit(template.get("purUnit"))
+ .setSpec(template.get("spec"))
+ .setStagn(!Objects.isNull(template.get("stagn")) ? Integer.parseInt(template.get("stagn")) : 0)
+ .setModel(template.get("model"))
+ .setGroupCode(template.get("groupCode"))
+ .setPurUnit(template.get("purUnit"))
+ .setStockLevel(!Objects.isNull(template.get("stockLevel")) ? Short.parseShort(template.get("stockLevel")) : 0)
+ .setSafeQty(!Objects.isNull(template.get("safeQty")) ? Double.parseDouble(template.get("safeQty")) : 0)
+ .setMinQty(!Objects.isNull(template.get("safeQty")) ? Double.parseDouble(template.get("minQty")) : 0);
+ if (Objects.isNull(template.get("groupCode")) && Objects.isNull(template.get("groupName"))) {
MatnrGroup matnrGroups = matnrGroupService.getOne(new LambdaQueryWrapper<MatnrGroup>()
- .eq(!Objects.isNull(template.getGroupCode()), MatnrGroup::getCode, template.getGroupCode())
- .eq(!Objects.isNull(template.getGroupName()),MatnrGroup::getName, template.getName()));
+ .eq(!Objects.isNull(template.get("groupCode")), MatnrGroup::getCode, template.get("groupCode"))
+ .eq(!Objects.isNull(template.get("groupName")),MatnrGroup::getName, template.get("groupName")));
matnr.setGroupId(matnrGroups.getId());
}
-
+ //鑾峰彇鍔ㄦ�佸瓧娈碉紝骞朵繚瀛樻槑缁嗗唴瀹�
+ if (!FieldsUtils.getFieldsSta().isEmpty()) {
+ String uuid = CommonUtil.randomUUID16();
+ matnr.setFieldsIndex(uuid);
+ //淇濆瓨鐗╂枡鎵╁睍灞炴�у��
+ FieldsUtils.saveFields(template, uuid);
+ }
matnrs.add(matnr);
});
diff --git a/rsf-server/src/main/resources/application.yml b/rsf-server/src/main/resources/application.yml
index 94a4edf..8d4d8f5 100644
--- a/rsf-server/src/main/resources/application.yml
+++ b/rsf-server/src/main/resources/application.yml
@@ -23,7 +23,7 @@
# global-config:
# field-strategy: 0
configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
cache-enabled: true
global-config:
diff --git a/rsf-server/src/main/resources/mapper/test/LocMapper.xml b/rsf-server/src/main/resources/mapper/test/LocMapper.xml
new file mode 100644
index 0000000..638ae43
--- /dev/null
+++ b/rsf-server/src/main/resources/mapper/test/LocMapper.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.vincent.rsf.server.test.mapper.LocMapper">
+
+</mapper>
--
Gitblit v1.9.1