许鹏程
2024-11-05 9824fc1a7b71cb4d617ea18cab36b8c179e6a37c
src/main/java/com/product/face/service/FaceApplyService.java
@@ -1,13 +1,33 @@
package com.product.face.service;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.aspose.slides.p2cbca448.and;
import com.google.common.collect.Lists;
import com.product.admin.service.SystemFaceService;
import com.product.common.lang.StringUtils;
import com.product.core.cache.util.RedisUtil;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.face.config.ErrorCode;
import com.product.face.config.FaceConst;
import com.product.face.entity.FaceEntity;
import com.product.face.entity.FaceListEntity;
import com.product.face.entity.TableColumn;
import com.product.face.util.FaceUtil;
import com.product.util.BaseUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Author cheng
@@ -20,20 +40,73 @@
   @Resource
   private SystemFaceService systemFaceService;
   @Resource
   private FaceCacheService faceCacheService;
   /**
    * 获取表单配置
    * @param fse
    * @return
    */
   public Object getFaceListConf(FieldSetEntity fse) {
      //TODO 使用变动安
      String faceUuid = fse.getString(FaceConst.FIELD_FACE_UUID);
      String faceNumber = fse.getString(FaceConst.FIELD_FACE_NUMBER);
      if (faceNumber == null && faceUuid == null) {
         return null;
      }
      if (StringUtils.isEmpty(faceNumber) && StringUtils.isEmpty(faceUuid)) {
         throw new BaseException(ErrorCode.REQUEST_PARAM_ERROR);
      if(StringUtils.isEmpty(faceUuid)){
      }
      if (!StringUtils.isEmpty(faceUuid) && StringUtils.isEmpty(faceNumber)) {
         return systemFaceService.getFaceFieldList(faceUuid);
      }
      //TODO 使用表单设计器设计的列表返回
      return null;
      FaceListEntity faceListCache = faceCacheService.getFaceListCache(faceNumber);
      if (faceListCache == null) {
         throw new BaseException(ErrorCode.GET_FACE_CONF_FAIL);
      }
      return faceListCache;
   }
   /**
    * 录入表单获取表单配置
    *
    * @param fse
    * @return
    * @throws BaseException
    */
   public String getFaceFormConfig(FieldSetEntity fse) throws BaseException {
      FaceEntity faceFormCache = faceCacheService.getFaceFormCache(fse.getString(FaceConst.FIELD_FACE_NUMBER));
      if (faceFormCache == null) {
         throw new BaseException(ErrorCode.GET_FACE_CONF_FAIL);
      }
      return BaseUtil.success(faceFormCache.getData(), MapUtil.builder("drawingList", (Object) faceFormCache.getDrawingList()).map());
   }
   public List<String> getFaceReference(FieldSetEntity fse) throws BaseException {
      String faceNumber = fse.getString("face_number");
      if (StringUtils.isEmpty(faceNumber)) {
         return null;
      }
      String[] faceNumberArr = faceNumber.split(",");
      StringBuilder sql = new StringBuilder();
      sql.append(" select case when c.property_value like '%prompt' then  a.property_value else concat('《',a.property_value,'》') end as  property_value from product_sys_face_control_property a ");
      sql.append(" join product_sys_face_control_property b on a.group_uuid=b.group_uuid and a.uuid!=b.uuid ");
      sql.append(" join product_sys_face_control_property c on b.uuid=c.parent_uuid ");
      sql.append(" where a.property_name='advanceName' and a.master_uuid in (SELECT uuid from product_sys_face where face_type=2 and ").append(BaseUtil.buildQuestionMarkFilter("face_number", faceNumberArr.length, true)).append(") ");
      sql.append(" and b.property_name='__config__' and c.property_name='tag'  GROUP BY 1 ");
      DataTableEntity dte = getBaseDao().listTable(sql.toString(), faceNumberArr);
      List<String> list = Lists.newArrayList();
      if (DataTableEntity.isEmpty(dte)) {
         return list;
      }
      for (int i = 0; i < dte.getRows(); i++) {
         FieldSetEntity fs = dte.getFieldSetEntity(i);
         list.add(fs.getString("property_value"));
      }
      return list;
   }
}