| | |
| | | Assert.listOnlyOne(oaWorkflowFormDtos, "未设置表单"); |
| | | //查询表是否存在 |
| | | |
| | | int count = oaWorkflowFormInnerServiceSMOImpl.hasTable(oaWorkflowFormDtos.get(0).getTableName()); |
| | | if (count > 0) { // 已经部署过不用再部署 |
| | | return; |
| | | } |
| | | |
| | | String formJson = oaWorkflowFormDtos.get(0).getFormJson(); |
| | | |
| | | Assert.isJsonObject(formJson, "表单设计出错,请重新设计"); |
| | |
| | | |
| | | JSONArray components = form.getJSONArray("components"); |
| | | JSONObject component = null; |
| | | StringBuffer sql = new StringBuffer("create table "); |
| | | StringBuffer sql = new StringBuffer("create table if not exists "); |
| | | sql.append(oaWorkflowFormDtos.get(0).getTableName()); |
| | | sql.append(" ("); |
| | | sql.append("id varchar(30) NOT NULL PRIMARY KEY COMMENT '主键ID',"); |
| | | boolean isVarchar = false; |
| | | JSONObject validate = null; |
| | | for (int componentIndex = 0; componentIndex < components.size(); componentIndex++) { |
| | |
| | | sql.append("("); |
| | | sql.append(validate.getIntValue("maxLength")); |
| | | sql.append(") "); |
| | | } else if (isVarchar) { |
| | | } |
| | | if (isVarchar && !validate.containsKey("maxLength")) { |
| | | sql.append("(64) "); |
| | | } |
| | | if (validate.containsKey("required") && validate.getBoolean("required")) { |
| | | sql.append(" not null "); |
| | | } |
| | | } |
| | | if (!component.containsKey("validate") && isVarchar) { |
| | | sql.append("(64) "); |
| | | } |
| | | |
| | | sql.append(" comment '"); |
| | | sql.append(component.getString("label")); |
| | | sql.append("'"); |
| | | |
| | | if (componentIndex != components.size() - 1) { |
| | | sql.append(","); |
| | | } |
| | | sql.append("',"); |
| | | } |
| | | sql.append(" )"); |
| | | sql.append("store_id varchar(30) not null COMMENT '商户ID',"); |
| | | sql.append("create_user_id varchar(30) not null COMMENT '创建人ID',"); |
| | | sql.append("create_user_name varchar(64) not null COMMENT '创建人',"); |
| | | sql.append("state varchar(12) not null COMMENT '状态 1001 申请 1002 待审核 1003 退回 1004 委托 1005 办结',"); |
| | | sql.append("create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',"); |
| | | sql.append("status_cd varchar(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效'"); |
| | | sql.append(")"); |
| | | logger.debug("部署表单sql" + sql.toString()); |
| | | count = oaWorkflowFormInnerServiceSMOImpl.createTable(sql.toString()); |
| | | if (count < 1) { // 已经部署过不用再部署 |
| | | throw new IllegalArgumentException("部署表单失败"); |
| | | } |
| | | oaWorkflowFormInnerServiceSMOImpl.createTable(sql.toString()); |
| | | |
| | | // int count = oaWorkflowFormInnerServiceSMOImpl.createTable(sqlStr); |
| | | // if (count < 1) { // 已经部署过不用再部署 |
| | | // throw new IllegalArgumentException("部署表单失败"); |
| | | // } |
| | | } |
| | | |
| | | @Override |