许鹏程
2023-05-19 cae784ab0232e3e3f8abfb0077fd9cf1e49ccb07
src/main/java/com/product/face/service/FaceDesignService.java
@@ -8,6 +8,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.drew.metadata.Face;
import com.product.admin.service.PublicService;
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.entity.DataTableEntity;
@@ -23,6 +24,7 @@
import org.apache.logging.log4j.core.Core;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
@@ -36,6 +38,9 @@
public class FaceDesignService extends AbstractBaseService implements IFaceDesignService {
   @Resource
   public PublicService publicService;
   /**
    * 获取表单配置详情
    *
@@ -48,10 +53,18 @@
      FieldSetEntity fse = getBaseDao().getFieldSetEntity(FaceConst.TABLE_FACE_CONFIG, uuid, true);
      DataTableEntity fieldPropertyDt = fse.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY);
      if (DataTableEntity.isEmpty(fieldPropertyDt)) {
         return null;
         throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL);
      }
      List<JSONObject> result = getFaceControlList(fieldPropertyDt);
      Map<String, Object> other = new HashMap<>();
      other.put("drawingList", result);
      fse.getSubData().clear();
      return BaseUtil.success(fse, other);
   }
   public List<JSONObject> getFaceControlList(DataTableEntity faceControlDt) {
      List<JSONObject> result = new ArrayList<>();
      List<FieldSetEntity> data = fieldPropertyDt.getData();
      List<FieldSetEntity> data = faceControlDt.getData();
      Map<String, List<FieldSetEntity>> collect = data.stream()
            .filter(item -> StringUtils.isEmpty(item.getString(FaceConst.FIELD_PARENT_UUID))) //过滤 取父级
//            .sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))) //排序
@@ -64,11 +77,7 @@
         result.add(getPropertyJson(propertyList, groupContainer));
      }
      result.sort(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE)));
      System.out.println(result);
      Map<String, Object> other = new HashMap<>();
      other.put("drawingList", result);
      fse.getSubData().clear();
      return BaseUtil.success(fse, other);
      return result;
   }
   private JSONObject getPropertyJson(List<FieldSetEntity> propertyList, Map<String, List<FieldSetEntity>> groupContainer) {
@@ -81,6 +90,15 @@
            String propertyType = fs.getString(FaceConst.FIELD_PROPERTY_TYPE);
            String propertyName = fs.getString(FaceConst.FIELD_PROPERTY_NAME);
            propertyValue = fs.getString(FaceConst.FIELD_PROPERTY_VALUE);
            if (StringUtils.equalsAny(propertyName, "renderKey", "formId")) {
               propertyValue = fs.getString("id");
            }
            if ("componentType".equals(propertyName) && "design".equals(propertyValue)) {
               continue;
            }
            if ("layout".equals(propertyName)) {
               property.put("defaultValue", null);
            }
            switch (propertyType) {
               case "1"://字符串
                  property.put(propertyName, propertyValue);
@@ -168,7 +186,7 @@
      BaseUtil.createCreatorAndCreationTime(fse);
      fields.setData(fieldSetEntityList);
      fse.addSubDataTable(fields);
      fse.setValue(FaceConst.FIELD_FACE_TYPE, 2);
//        fse.setValue(FaceConst.FIELD_FACE_TYPE, 2);
      if (!StringUtils.isEmpty(fse.getUUID())) {
         getBaseDao().delete(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY, "master_uuid=?", new Object[]{fse.getUUID()});
      }
@@ -281,4 +299,18 @@
      return fse;
   }
   /**
    * 删除表单设计
    *
    * @param fse
    * @throws BaseException
    */
   @Override
   @Transactional
   public void deleteFace(FieldSetEntity fse) throws BaseException {
      publicService.delete(fse);
   }
}