许鹏程
2024-11-26 29f1a0a5d9bc184fa497a88ec11c37f10a45df92
src/main/java/com/product/face/service/FaceDesignService.java
@@ -6,6 +6,7 @@
import com.alibaba.fastjson.JSONObject;
import com.product.admin.service.PublicService;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.config.CoreConst;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
@@ -17,6 +18,8 @@
import com.product.face.service.ide.IFaceDesignService;
import com.product.face.util.FaceUtil;
import com.product.util.BaseUtil;
import org.apache.poi.hdgf.pointers.Pointer;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -65,6 +68,17 @@
      return BaseUtil.success(fse, other);
   }
   public class Pointer {
      int data = 0;
      public int getData() {
         return ++data;
      }
      public void setData(int data) {
         this.data = data;
      }
   }
   /**
    * 保存表单内容数据
@@ -81,6 +95,8 @@
         ErrorCode.SAVE_EMPTY_FACE_FAIL.throwException();
      }
      List<FieldSetEntity> fieldSetEntityList = new ArrayList<>();
      //声明一个带指针的int变量
      Pointer pointer = new Pointer();
      for (int i = 0; i < fields.getRows(); i++) {
         if (fields.getBoolean(i, "event_property")) {
            DataTableEntity subDataTable = fields.getFieldSetEntity(i).getSubDataTable("event_array");
@@ -89,7 +105,7 @@
            }
            fields.setFieldValue(i, "event_array", BaseUtil.dataTableEntityToJson(subDataTable));
         }
         fieldSetEntityList.addAll(controlTraverse(new JSONObject((Map) fields.getFieldSetEntity(i).getValues()), null, i));
         fieldSetEntityList.addAll(controlTraverse(new JSONObject((Map) fields.getFieldSetEntity(i).getValues()), null, i, pointer));
      }
      fse.removeSubData(FaceConst.FACE_FIELD);
      BaseUtil.createCreatorAndCreationTime(fse);
@@ -107,7 +123,7 @@
      return fse;
   }
   public List<FieldSetEntity> controlTraverse(Object o, String parentUuid, Integer sequence) {
   public List<FieldSetEntity> controlTraverse(Object o, String parentUuid, Integer sequence, Pointer pointer) {
      List<FieldSetEntity> fieldSetList = new ArrayList<>();
      try {
         if (o instanceof JSONArray) {
@@ -116,7 +132,7 @@
            try {
               for (int i = 0; i < jsonArray.size(); i++) {
                  Object obj = jsonArray.get(i);
                  fieldSetList.addAll(controlTraverse(obj, parentUuid, i));
                  fieldSetList.addAll(controlTraverse(obj, parentUuid, i, pointer));
               }
            } catch (Exception e) {
               e.printStackTrace();
@@ -133,7 +149,7 @@
                  int propertyType = fs.getInteger(FaceConst.FIELD_PROPERTY_TYPE).intValue();
                  if ((4 == propertyType || 3 == propertyType) && (entry.getValue() instanceof JSONArray || entry.getValue() instanceof JSONObject)) {
                     try {
                        fieldSetList.addAll(controlTraverse(entry.getValue(), fs.getUUID(), null));
                        fieldSetList.addAll(controlTraverse(entry.getValue(), fs.getUUID(), null, pointer));
                        fs.remove(FaceConst.FIELD_PROPERTY_VALUE);
                     } catch (Exception e) {
                        e.printStackTrace();
@@ -145,7 +161,7 @@
               }
            }
            if (sequence != null) {
               FieldSetEntity fs = getTemplateFieldSet(FaceConst.CONTROL_SEQUENCE, sequence, groupUuid);
               FieldSetEntity fs = getTemplateFieldSet(FaceConst.CONTROL_SEQUENCE, pointer.getData(), groupUuid);
               fs.setValue(FaceConst.FIELD_PARENT_UUID, parentUuid);
               fieldSetList.add(fs);
            }