From 43a8037b60150b65651c03fd654621d37075d051 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 16 四月 2025 18:00:26 +0800
Subject: [PATCH] Merge branch 'devlop' of http://47.97.1.152:5880/r/wms-master into devlop
---
rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java | 132 +++++++++++++++++++++++++++-----------------
1 files changed, 81 insertions(+), 51 deletions(-)
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 7b53065..ad98507 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
@@ -7,6 +7,8 @@
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 org.apache.commons.lang3.StringUtils;
+import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@@ -24,7 +26,7 @@
* @author Ryan
* @description 閫氳繃瀛楁鍞竴鏍囪瘑鑾峰彇鍔ㄦ�佸瓧娈靛璞ey-value
* @param
- * @return
+ * @return 鎵╁睍瀛楁瀵硅薄
* @time 2025/3/12 12:50
*/
public static Map<String, String> getFields(String uuid) {
@@ -51,28 +53,42 @@
return fieldsMap;
}
- public static void mergeFields(Map<String, Object> fileds ,String uuid) {
+ /**
+ * @author Ryan
+ * @description 鑾峰彇闆嗗悎鎵╁睍瀛楁key-value鍊�
+ * @param
+ * @return 鍖呭惈鎵╁睍瀛楁鐨勯泦鍚堝璞�
+ * @time 2025/3/15 15:05
+ */
+ public static List<Map<String, Object>> getExtendFields(List<Map<String, Object>> params) {
FieldsService fieldsService = SpringUtils.getBean(FieldsService.class);
- List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getFlagEnable, 1).eq(Fields::getStatus, 1));
- if (fields.isEmpty()) {
- return;
- }
+ List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>()
+ .eq(Fields::getStatus, 1)
+ .eq(Fields::getFlagEnable, 1));
FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
- List<FieldsItem> fieldsItems = fieldsItemService.list(new LambdaQueryWrapper<FieldsItem>().eq(FieldsItem::getUuid, uuid));
- for (Fields field : fields ) {
- if (fieldsItems.isEmpty()) {
- fileds.put(field.getFields(), null);
+ List<Map<String, Object>> result = new ArrayList<>();
+ for (Map<String, Object> param : params) {
+ result.add(param);
+ if (Objects.isNull(param.get("fieldsIndex"))) {
continue;
}
- fieldsItems.forEach(fieldsItem -> {
- if (fieldsItem.getFieldsId().equals(field.getId())) {
- fileds.put(field.getFields(), fieldsItem.getValue());
+ List<FieldsItem> itemList = fieldsItemService
+ .list(new LambdaQueryWrapper<FieldsItem>()
+ .eq(FieldsItem::getUuid, param.get("fieldsIndex")));
+ if (itemList.isEmpty()) {
+ continue;
+ }
+ fields.forEach(fds -> {
+ for (FieldsItem fieldsItem : itemList) {
+ if (!Objects.isNull(fieldsItem.getFieldsId()) && fieldsItem.getFieldsId().equals(fds.getId())) {
+ param.put(fds.getFields(), fieldsItem.getValue());
+ }
}
});
}
-
+ return result;
}
-
+
/**
* @param template
* @return
@@ -80,25 +96,31 @@
* @description 鍔ㄦ�佸瓧娈祐alue淇濆瓨
* @time 2025/3/18 15:00
*/
- public static void saveFields(Map<String, ?> template, String uuid) {
+ @Transactional(rollbackFor = Exception.class)
+ public static boolean saveFields(Map<String, ?> template, String uuid) throws Exception{
List<Fields> fields = getFieldsSta();
FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
- if (fields.isEmpty()) {
- throw new CoolException("鎵╁睍瀛楁涓嶅瓨鍦紒锛�");
- }
List<FieldsItem> fieldsItems = new ArrayList<>();
- for (Fields field : fields) {
- if (!Objects.isNull(template.get(field.getFields()))) {
- FieldsItem item = new FieldsItem();
- item.setFieldsId(field.getId())
- .setUuid(uuid)
- .setValue(template.get(field.getFields()).toString());
- fieldsItems.add(item);
+ if (!fields.isEmpty()) {
+ for (Fields obj : fields) {
+ if (!Objects.isNull(template.get(obj.getFields())) && StringUtils.isNotBlank(template.get(obj.getFields()).toString())) {
+ FieldsItem item = new FieldsItem();
+ item.setUuid(uuid)
+ .setValue(template.get(obj.getFields()).toString())
+ .setMatnrId(!Objects.isNull(template.get("matnrId")) ? Long.parseLong(template.get("matnrId").toString()) : null)
+ .setFieldsId(obj.getId());
+ fieldsItems.add(item);
+ }
}
+ if (fieldsItems.isEmpty()) {
+ return false;
+ }
+ if (!fieldsItemService.saveBatch(fieldsItems)) {
+ throw new CoolException("鎵╁睍瀛楁淇濆瓨澶辫触锛侊紒");
+ }
+ return true;
}
- if (!fieldsItemService.saveBatch(fieldsItems)) {
- throw new CoolException("鍔ㄦ�佸瓧娈靛�间繚瀛樺け璐ワ紒锛�");
- }
+ return false;
}
/**
@@ -110,38 +132,46 @@
return fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getStatus, 1).eq(Fields::getFlagEnable, 1));
}
- public static void updateFieldsValue(Map<String, Object> params) {
+ /**
+ * @author Ryan
+ * @description 鍔ㄦ�佸瓧娈典慨鏀�
+ * @param
+ * @return
+ * @time 2025/4/7 15:28
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public static void updateFieldsValue(Map<String, Object> params) throws Exception {
List<Fields> fields = getFieldsSta();
if (fields.isEmpty()) { return; }
Object fieldsIndex = params.get("fieldsIndex");
- if (!Objects.isNull(fieldsIndex)) {
+ if (!Objects.isNull(fieldsIndex) && StringUtils.isNotBlank(fieldsIndex.toString())) {
String index = fieldsIndex.toString();
FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
for (Fields field : fields) {
- if (!Objects.isNull(params.get(field.getFields()))) {
- FieldsItem indexItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>()
- .eq(FieldsItem::getUuid, index)
- .eq(FieldsItem::getFieldsId, field.getId()));
- //濡傛灉瀛愯〃涓虹┖锛屾墽琛屾彃鍏ユ搷浣滐紝鍚﹀垯灏辨墽琛屼慨鏀规搷浣�
- if (Objects.isNull(indexItem)) {
- FieldsItem item = new FieldsItem();
- item.setUuid(index)
- .setFieldsId(field.getId())
- .setValue(params.get(field.getFields()).toString());
- if (fieldsItemService.save(item)) {
- throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
- }
- } else {
- indexItem.setValue(params.get(field.getFields()).toString());
- if (fieldsItemService.updateById(indexItem)) {
- throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
+ if (!Objects.isNull(params.get(field.getFields()))) {
+ FieldsItem indexItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>()
+ .eq(FieldsItem::getUuid, index)
+ .eq(FieldsItem::getFieldsId, field.getId()));
+ //濡傛灉瀛愯〃涓虹┖锛屾墽琛屾彃鍏ユ搷浣滐紝鍚﹀垯灏辨墽琛屼慨鏀规搷浣�
+ if (Objects.isNull(indexItem)) {
+ FieldsItem item = new FieldsItem();
+ item.setUuid(index)
+ .setFieldsId(field.getId())
+ .setMatnrId(!Objects.isNull(params.get("matnrId")) ? Long.parseLong(params.get("matnrId").toString()) : null)
+ .setValue(params.get(field.getFields()).toString());
+ if (!fieldsItemService.save(item)) {
+ throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
+ }
+ } else {
+ indexItem.setValue(params.get(field.getFields()).toString());
+ if (!fieldsItemService.updateById(indexItem)) {
+ throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
+ }
}
}
- }
}
} else {
- String uuid16 = CommonUtil.randomUUID16();
- saveFields(params, uuid16);
+ saveFields(params, params.get("index").toString());
}
}
}
--
Gitblit v1.9.1