|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return  fieldsMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void mergeFields(Map<String, Object> fileds ,String uuid) { | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | fieldsItems.forEach(fieldsItem -> { | 
|---|
|  |  |  | if (fieldsItem.getFieldsId().equals(field.getId())) { | 
|---|
|  |  |  | fileds.put(field.getFields(), fieldsItem.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @param template | 
|---|
|  |  |  | 
|---|
|  |  |  | * @description 动态字段value保存 | 
|---|
|  |  |  | * @time 2025/3/18 15:00 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void saveFields(Map<String, ?> template, String uuid) { | 
|---|
|  |  |  | public static void saveFields(Map<String, ?> template, String uuid) throws Exception{ | 
|---|
|  |  |  | List<Fields> fields = getFieldsSta(); | 
|---|
|  |  |  | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); | 
|---|
|  |  |  | if (fields.isEmpty()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | FieldsService fieldsService = SpringUtils.getBean(FieldsService.class); | 
|---|
|  |  |  | return fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getStatus, 1).eq(Fields::getFlagEnable, 1)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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)) { | 
|---|
|  |  |  | 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("扩展字段修改失败!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | saveFields(params, params.get("index").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|