| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | public class FaceDesignService extends AbstractBaseService implements IFaceDesignService { |
| | | |
| | | |
| | | @Resource |
| | | public PublicService publicService; |
| | | |
| | | /** |
| | | * 获取表单配置详情 |
| | | * |
| | |
| | | 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))) //排序 |
| | |
| | | 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) { |
| | |
| | | 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); |
| | |
| | | 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()}); |
| | | } |
| | |
| | | return fse; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除表单设计 |
| | | * |
| | | * @param fse |
| | | * @throws BaseException |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void deleteFace(FieldSetEntity fse) throws BaseException { |
| | | publicService.delete(fse); |
| | | } |
| | | |
| | | |
| | | } |