| | |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.exception.BaseException; |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.face.entity.FaceListEntity; |
| | | import com.product.face.service.FaceApplyService; |
| | | import com.product.face.util.FaceUtil; |
| | | import com.product.mobile.core.config.MobileCoreCode; |
| | | import com.product.mobile.core.entity.FaceFieldEntity; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Author cheng |
| | |
| | | |
| | | @Autowired |
| | | public BaseDao baseDao; |
| | | @Autowired |
| | | private FaceApplyService faceApplyService; |
| | | |
| | | ///获取表单总入口 |
| | | /** |
| | |
| | | * @param fse传入表名,或 表UUID |
| | | * @return |
| | | */ |
| | | public List<FaceFieldEntity> getFaceConfig(FieldSetEntity fse) { |
| | | public Object getFaceConfig(FieldSetEntity fse) { |
| | | |
| | | String tableUuid = fse.getString("table_uuid"); |
| | | String tableUuid = fse.getString("table_uuid"); |
| | | if (tableUuid == null && StringUtils.isNotEmpty(fse.getString("uuid")) |
| | | && StringUtils.isEmpty(fse.getString("table_name"))) { |
| | | //通过业务表信息查表单信息 |
| | |
| | | } |
| | | } |
| | | |
| | | List<FaceFieldEntity> ls = getFaceFieldByTable(fse); |
| | | Object o = getFaceFieldByTable(fse); |
| | | if (o instanceof FaceListEntity) { |
| | | FaceListEntity faceListEntity = (FaceListEntity) o; |
| | | List<FaceListEntity.FaceField> faceFieldList = faceListEntity.getFaceFields(); |
| | | List<JSONObject> objList = faceFieldList.stream().map(faceField -> { |
| | | JSONObject obj = JSONObject.parseObject(com.alibaba.fastjson.JSONObject.toJSONString(faceField)); |
| | | obj.put("name", obj.getString("columnName")); |
| | | obj.put("field", obj.getString("fieldName")); |
| | | return obj; |
| | | }).collect(Collectors.toList()); |
| | | return objList; |
| | | } |
| | | List<FaceFieldEntity> ls = (List<FaceFieldEntity>) o; |
| | | if (ls == null) ls = new ArrayList<FaceFieldEntity>(); |
| | | //递归把主表和子表的字段属性添加进去,如果没有配表单,则取表数据结构进行展示 |
| | | addproperty(tableUuid, fse.getString("table_name"), ls); |
| | | //所有表单uuid自动添加,并为hidden |
| | | |
| | | // 移动端若是没有配置表单信息,那么就最多显示10个字段,且需要剔除到部分字段 |
| | | String clientType = fse.getString("client_type"); |
| | | if ("app".equals(clientType)) { |
| | | List<String> exceptList = Arrays.asList("uuid", "org_level_uuid", "created_by", "created_utc_datetime"); |
| | | ls = ls.stream().filter(obj -> !exceptList.contains(obj.getField())).collect(Collectors.toList()); |
| | | if (ls.size() > 10) { |
| | | ls = ls.subList(0, 10); |
| | | } |
| | | } |
| | | return ls; |
| | | |
| | | } |
| | |
| | | FaceFieldEntity uuid = new FaceFieldEntity(); |
| | | FieldSetEntity f = dte.getFieldSetEntity(j); |
| | | if ("pk".equals(f.getString("field_type")) |
| | | // || "created_by".equals(f.getString("field_name")) |
| | | // || "created_utc_datetime".equals(f.getString("field_name")) |
| | | || "updated_by".equals(f.getString("field_name")) |
| | | || "updated_utc_datetime".equals(f.getString("field_name")) |
| | | || "flowsign".equals(f.getString("field_type")) |
| | |
| | | uuid.setMultiple("1"); |
| | | } else { |
| | | uuid.setMultiple("0"); |
| | | } |
| | | |
| | | if ("userids".equals(f.getString("field_type")) || "userid".equals(f.getString("field_type"))) { |
| | | uuid.setOrganizationType("5"); |
| | | } else if ("orgUuids".equals(f.getString("field_type")) || "orgUuid".equals(f.getString("field_type"))) { |
| | | uuid.setOrganizationType("2"); |
| | | } |
| | | |
| | | uuid.setComponentType(""); |
| | |
| | | } |
| | | } |
| | | |
| | | public List<FaceFieldEntity> getFaceFieldByTable(FieldSetEntity fse) { |
| | | public Object getFaceFieldByTable(FieldSetEntity fse) { |
| | | String tableUuid = fse.getString("table_uuid"); |
| | | String tableName = fse.getString("table_name"); |
| | | if (StringUtils.isEmpty(tableUuid) && !StringUtils.isEmpty(tableName)) { |
| | |
| | | if (StringUtils.isEmpty(tableUuid)) { |
| | | throw new BaseException(MobileCoreCode.SYSTEM_FORM_COUNT); |
| | | } |
| | | FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", "table_uuid=? and face_type=2", new Object[]{tableUuid}, true); |
| | | String faceType = BaseUtil.ifNull(fse.getString("face_type"), "2"); |
| | | String faceNumber = fse.getString("face_number"); |
| | | String filter = "table_uuid=? and face_type=? AND LENGTH(IFNULL(face_number,''))>0"; |
| | | Object[] paramArr = new Object[]{tableUuid, faceType}; |
| | | if (!StringUtils.isEmpty(faceNumber)) { |
| | | filter = "face_number=?"; |
| | | paramArr = new Object[]{faceNumber}; |
| | | } |
| | | FieldSetEntity faceFse = getBaseDao().getFieldSetByFilter("product_sys_face", filter, paramArr, true); |
| | | faceFse.setTableName(tableName); |
| | | //列表,且找到了配置表单,只有列表单 |
| | | if ("1".equals(faceType) && !FieldSetEntity.isEmpty(faceFse)) { |
| | | return faceApplyService.getFaceListConf(faceFse); |
| | | } |
| | | return getFaceField(faceFse); |
| | | } |
| | | |
| | |
| | | faceFieldEntity.setAllowDelete(setEntity.getBoolean("property_value")); |
| | | } else if ("control_sequence".equals(propertyName)) { |
| | | faceFieldEntity.putOtherParam("controlSequence", setEntity.getInteger("property_value")); |
| | | } else if ("__config__".equals(propertyName)) { |
| | | |
| | | String __config__ = setEntity.getUUID(); |
| | | List<FieldSetEntity> fieldSetEntities2 = parentMap.get(__config__); |
| | | if (!CollectionUtil.isEmpty(fieldSetEntities2)) { |
| | | for (FieldSetEntity fieldSetEntity4 : fieldSetEntities2) { |
| | | if ("label".equals(fieldSetEntity4.getString("property_name"))) { |
| | | faceFieldEntity.setName(fieldSetEntity4.getString("property_value")); |
| | | } else if ("required".equals(fieldSetEntity4.getString("property_name"))) { |
| | | faceFieldEntity.setRequired(fieldSetEntity4.getBoolean("property_value") ? "1" : "0"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | List<FaceFieldEntity> subFieldList = faceFieldEntity.getSubField(); |