src/main/java/com/product/face/config/ErrorCode.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/face/config/FaceConst.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/face/controller/FaceApplyController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/face/entity/TableColumn.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/face/service/FaceApplyService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/face/service/FaceDesignService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/product/face/config/ErrorCode.java
@@ -18,6 +18,10 @@ SAVE_EMPTY_FACE_FAIL("ä¿å表åå 容失败,表åå 容ä¸è½ä¸ºç©º", 2), DELETE_FACE_FAIL("å é¤è¡¨å失败", 3), GET_FACE_COLUMN_FAIL("è·åå表é 置失败", 4), GET_FACE_CONFIG_FAIL("è·å表åé 置信æ¯å¤±è´¥", 5), REQUEST_PARAM_ERROR("请æ±åæ°æè¯¯", 6), ; src/main/java/com/product/face/config/FaceConst.java
@@ -17,7 +17,10 @@ public static final String CHILDREN = "children"; public static final String FIELD_CONFIG = "__config__"; //æ§ä»¶ç»å®å段åç屿§åç§° public static final String FIELD_PROPERTY_CONFIG = "__config__"; public static final String FIELD_PROPERTY_VMODEL = "__vModel__"; public static final String FIELD_PROPERTY_LABEL = "label"; public static final String FIELD_MASTER = "master_uuid"; //æ§ä»¶è¡¨å±æ§ååæ®µ src/main/java/com/product/face/controller/FaceApplyController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,74 @@ package com.product.face.controller; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.face.config.ErrorCode; import com.product.face.config.FaceConst; import com.product.face.service.FaceApplyService; import com.product.module.sys.version.ApiVersion; import com.product.util.BaseUtil; import com.product.util.support.AbstractBaseController; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; /** * @Author cheng * @Date 2023/5/17 10:17 * @Desc 表ååºç¨æ§å¶å± */ @RestController @RequestMapping("/api/face/apply") public class FaceApplyController extends AbstractBaseController { @Resource private FaceApplyService faceApplyService; /** * è·åè¡¨æ ¼åé ç½® * * @param request * @return */ @PostMapping("/get-list-column/{version}") @ApiVersion(1) public String getListColumn(HttpServletRequest request) { try { FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); return success(faceApplyService.getFaceListConf(fse)); } catch (BaseException e) { e.printStackTrace(); return error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return error(ErrorCode.GET_FACE_COLUMN_FAIL, e); } } /** * å½å ¥è¡¨åè·åé ç½® * * @param request * @return */ @PostMapping("/get-form-conf/{version}") @ApiVersion(1) public String getFormConf(HttpServletRequest request) { try { FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, FaceConst.TABLE_FACE_CONFIG); return faceApplyService.getFaceFormConfig(fse); } catch (BaseException e) { e.printStackTrace(); return error(e); } catch (Exception e) { e.printStackTrace(); SpringMVCContextHolder.getSystemLogger().error(e); return error(ErrorCode.GET_FACE_CONFIG_FAIL, e); } } } src/main/java/com/product/face/entity/TableColumn.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,49 @@ package com.product.face.entity; import java.io.Serializable; /** * @Author cheng * @Date 2023/5/17 10:13 * @Desc è¡¨æ ¼å */ public class TableColumn implements Serializable { private static final long serialVersionUID = -2568367952209207590L; /** * åç»å®å段å */ private String field; /** * åæ é¢ */ private String title; /** * å宽度 */ private String columnWidth; public String getField() { return field; } public void setField(String field) { this.field = field; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getColumnWidth() { return columnWidth; } public void setColumnWidth(String columnWidth) { this.columnWidth = columnWidth; } } src/main/java/com/product/face/service/FaceApplyService.java
@@ -1,13 +1,25 @@ package com.product.face.service; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import com.product.admin.service.SystemFaceService; import com.product.common.lang.StringUtils; 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.TableColumn; 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; import java.util.stream.Collectors; /** * @Author cheng @@ -20,20 +32,80 @@ @Resource private SystemFaceService systemFaceService; @Resource private FaceDesignService designService; 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; //æ ¹æ®è¡¨åå·æ¥è¯¢ FieldSetEntity faceConf = getBaseDao().getFieldSetByFilter(FaceConst.TABLE_FACE_CONFIG, "face_number=?", new Object[]{faceNumber}, true); DataTableEntity fieldPropertyDt = faceConf.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY); if (DataTableEntity.isEmpty(fieldPropertyDt)) { throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL); } List<JSONObject> faceControlList = designService.getFaceControlList(fieldPropertyDt); JSONObject jsonObject = faceControlList.get(0); if (jsonObject == null || jsonObject.isEmpty()) { throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL); } //è¡¨æ ¼å JSONArray tableColumns = jsonObject.getJSONObject(FaceConst.FIELD_PROPERTY_CONFIG).getJSONArray(FaceConst.CHILDREN); if (tableColumns == null || tableColumns.isEmpty()) { throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL); } List<TableColumn> result = Lists.newArrayList(); for (int i = 0; i < tableColumns.size(); i++) { TableColumn tableColumn = new TableColumn(); JSONObject columnJson = tableColumns.getJSONObject(i); String fieldName = columnJson.getString(FaceConst.FIELD_PROPERTY_VMODEL); if (StringUtils.isEmpty(fieldName)) { continue; } JSONObject config = columnJson.getJSONObject(FaceConst.FIELD_PROPERTY_CONFIG); Object setWidth = config.get("setWidth"); if (!StringUtils.isEmpty(setWidth)) { tableColumn.setColumnWidth(setWidth + "%"); } tableColumn.setField(fieldName); tableColumn.setTitle(config.getString(FaceConst.FIELD_PROPERTY_LABEL)); result.add(tableColumn); } return result; } /** * å½å ¥è¡¨åè·å表åé ç½® * * @param fse * @return * @throws BaseException */ public String getFaceFormConfig(FieldSetEntity fse) throws BaseException { String faceNumber = fse.getString(FaceConst.FIELD_FACE_NUMBER); if (StringUtils.isEmpty(faceNumber)) { throw new BaseException(ErrorCode.REQUEST_PARAM_ERROR); } //æ ¹æ®è¡¨åå·æ¥è¯¢ FieldSetEntity faceConf = getBaseDao().getFieldSetByFilter(FaceConst.TABLE_FACE_CONFIG, "face_number=?", new Object[]{faceNumber}, true); DataTableEntity fieldPropertyDt = faceConf.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY); if (DataTableEntity.isEmpty(fieldPropertyDt)) { throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL); } List<JSONObject> faceControlList = designService.getFaceControlList(fieldPropertyDt); Map<String, Object> other = new HashMap<>(); other.put("drawingList", faceControlList); faceConf.getSubData().clear(); return BaseUtil.success(faceConf, other); } } src/main/java/com/product/face/service/FaceDesignService.java
@@ -39,7 +39,7 @@ @Resource private PublicService publicService; public PublicService publicService; /** * è·å表åé 置详æ @@ -53,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))) //æåº @@ -69,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) {