From aebbf80faaa7184ee4eb6a4fe1d5b1c5edb3b82c Mon Sep 17 00:00:00 2001 From: flazx Date: Tue, 6 Mar 2018 09:10:59 +0800 Subject: [PATCH] =?UTF-8?q?-=20ComponentVO=E6=B7=BB=E5=8A=A0JSONObject?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=20-=20BaseUtils=E6=B7=BB=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96getUserGroupId=E6=96=B9=E6=B3=95=20-=20ExcelUtils?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=8E=A7=E4=BB=B6=E7=9A=84Format=20-=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9WF=E7=9A=84=E8=B7=AF=E5=BE=84=EF=BC=88?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=B8=8D=E5=AF=B9=EF=BC=89=20-=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E6=90=9C=E7=B4=A2=E7=BB=84=E4=BB=B6=EF=BC=88=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86api=E6=96=B9=E6=B3=95=E5=B8=A6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8=E7=9A=84bugs?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/vo/ComponentVO.java | 18 +++++- .../awcp/formdesigner/utils/BaseUtils.java | 14 ++++- .../awcp/formdesigner/utils/ExcelUtils.java | 59 ++++++++++++++++++- .../webapp/WF/Comm/Sys/SFDBSrcNewGuide.htm | 4 +- .../src/main/webapp/venson/js/addSearch.js | 2 +- 5 files changed, 90 insertions(+), 7 deletions(-) diff --git a/core/awcp-formdesigner/awcp-formdesigner-application/src/main/java/cn/org/awcp/formdesigner/application/vo/ComponentVO.java b/core/awcp-formdesigner/awcp-formdesigner-application/src/main/java/cn/org/awcp/formdesigner/application/vo/ComponentVO.java index 6f7f4a2d..6eed36ec 100644 --- a/core/awcp-formdesigner/awcp-formdesigner-application/src/main/java/cn/org/awcp/formdesigner/application/vo/ComponentVO.java +++ b/core/awcp-formdesigner/awcp-formdesigner-application/src/main/java/cn/org/awcp/formdesigner/application/vo/ComponentVO.java @@ -19,6 +19,7 @@ public class ComponentVO { private String defaultValueScript; //默认值的值脚本 private String formValidator; //校验 private String optionScript; //多选控件的text选项; + private JSONObject jsonObj; public static ComponentVO parseFromJson(String jsonStr){ ComponentVO result = new ComponentVO(); @@ -37,12 +38,18 @@ public class ComponentVO { result.setDataItemCode(o.getString("dataItemCode")); result.setValueType(o.getString("valueType")); result.setOptionScript(o.getString("optionScript")); + result.setJsonObj(o); return result; } public boolean isValueType(){ - int componentType = this.componentType; + Integer componentType = this.componentType; + + if(componentType == null){ + return false; + } + return componentType==1001 || componentType==1002 ||componentType==1003 ||componentType==1004 ||componentType==1005 || componentType==1006 ||componentType==1007||componentType==1012 || componentType==1010 @@ -225,5 +232,12 @@ public class ComponentVO { public void setOptionScript(String optionContent) { this.optionScript = optionContent; } - + + public JSONObject getJsonObj() { + return jsonObj; + } + + public void setJsonObj(JSONObject jsonObj) { + this.jsonObj = jsonObj; + } } diff --git a/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/BaseUtils.java b/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/BaseUtils.java index 83140f06..178221e9 100644 --- a/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/BaseUtils.java +++ b/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/BaseUtils.java @@ -64,7 +64,7 @@ public abstract class BaseUtils { protected PunPositionService punPositionService = Springfactory.getBean("punPositionServiceImpl"); // 注入组织服务 protected PunGroupService punGroupService = Springfactory.getBean("punGroupServiceImpl"); - // 注入SpringJdbc + // 注入SprfingJdbc protected JdbcTemplate jdbcTemplate = Springfactory.getBean("jdbcTemplate"); // 注入元数据模型服务 protected MetaModelService metaModelService = Springfactory.getBean("metaModelServiceImpl"); @@ -226,6 +226,18 @@ public abstract class BaseUtils { return ""; } + /** + * 获取用户的组织Id + */ + public Long getUserGroupId() { + List groups = getUserGroupById(getUser().getUserId() + ""); + for (PunGroupVO punGroupVO : groups) { + return punGroupVO.getGroupId(); + } + + return Long.MIN_VALUE; + } + /** * 获取当前用户的组织名称 * diff --git a/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/ExcelUtils.java b/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/ExcelUtils.java index 606e79dc..ce8c8f1c 100644 --- a/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/ExcelUtils.java +++ b/core/awcp-web/src/main/java/cn/org/awcp/formdesigner/utils/ExcelUtils.java @@ -1,5 +1,6 @@ package cn.org.awcp.formdesigner.utils; +import cn.org.awcp.core.utils.DateUtils; import cn.org.awcp.core.utils.Springfactory; import cn.org.awcp.formdesigner.application.service.FormdesignerService; import cn.org.awcp.formdesigner.application.service.StoreService; @@ -7,9 +8,11 @@ import cn.org.awcp.formdesigner.application.vo.ComponentVO; import cn.org.awcp.formdesigner.application.vo.DocumentVO; import cn.org.awcp.formdesigner.application.vo.DynamicPageVO; import cn.org.awcp.formdesigner.application.vo.StoreVO; +import cn.org.awcp.formdesigner.core.constants.FormDesignerGlobal; import cn.org.awcp.metadesigner.application.MetaModelOperateService; import cn.org.awcp.venson.service.FileService; import cn.org.awcp.venson.util.ExcelUtil; +import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -60,7 +63,6 @@ public class ExcelUtils { if (stores != null && stores.size() > 0) { for (StoreVO store : stores) { ComponentVO component = ComponentVO.parseFromJson(store.getContent()); - int componentType = component.getComponentType(); String dataItemCode = component.getDataItemCode(); String defaultValueScript = component.getDefaultValueScript(); @@ -154,6 +156,8 @@ public class ExcelUtils { } dataMap.put("ID", UUID.randomUUID().toString()); + + handleFormDataByComponents(pageFormId,modelCode, dataMap); boolean saveResult = metaModelOperateService.save(dataMap, modelCode); if(saveResult){ insertSize++; } } @@ -163,4 +167,57 @@ public class ExcelUtils { result.put("insertSize", insertSize); return result; } + + private static void handleFormDataByComponents(String pageFormId,String modelCode,Map map) { + StoreService storeService = Springfactory.getBean("storeServiceImpl"); + + PageList stores = storeService.findByDyanamicPageId(pageFormId); + if (stores != null && stores.size() > 0) { + for (StoreVO store : stores) { + ComponentVO component = ComponentVO.parseFromJson(store.getContent()); + + if(component.isValueType()){ + String code = component.getDataItemCode().replace(modelCode + ".", ""); + if (!map.containsKey(code)) { + continue; + } + + String value = map.get(code); + JSONObject comObj = component.getJsonObj(); + + if (component.isDateTimeType()) { + String dateType = comObj.getString("dateType"); + value = handleDateType(value, dateType); + + map.put(code, value); + } + if (component.getComponentType() == 1032) { + value = value.replaceAll(",", ""); + map.put(code, value); + } + } + } + } + } + + private static String handleDateType(String value, String dateType) { + if ("yyyy-mm-dd".equals(dateType)) { // yyyy-MM + value = DateUtils.format(DateUtils.parseDate(value, "yyyy-MM-dd")); + } else if ("dd/mm/yyyy".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "dd/MM/yyyy")); + } else if ("yyyy-mm-dd HH:ii".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "yyyy-MM-dd HH:mm")); + } else if ("dd/mm/yyyy HH:ii".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "dd/MM/yyyy HH:mm")); + } else if ("yyyy-mm-dd HH:ii:ss".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "yyyy-MM-dd HH:mm:ss")); + } else if ("yyyy-mm".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "yyyy-MM")); + } else if ("yyyy".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "yyyy")); + } else if ("HH:ii".equals(dateType)) { + value = DateUtils.format(DateUtils.parseDate(value, "HH:mm")); + } + return value; + } } diff --git a/core/awcp-web/src/main/webapp/WF/Comm/Sys/SFDBSrcNewGuide.htm b/core/awcp-web/src/main/webapp/WF/Comm/Sys/SFDBSrcNewGuide.htm index 6a1af0cc..067ab75f 100644 --- a/core/awcp-web/src/main/webapp/WF/Comm/Sys/SFDBSrcNewGuide.htm +++ b/core/awcp-web/src/main/webapp/WF/Comm/Sys/SFDBSrcNewGuide.htm @@ -8,8 +8,8 @@ - - + +