Commit 111339e4 authored by 雍欢's avatar 雍欢

1、合并表单设计代码;2、如果存在多个 operationId,则取第一个operationId;

parent 3ad09e69
......@@ -4,6 +4,7 @@ import java.io.File;
import java.util.List;
import java.util.Map;
import com.huigou.uasp.util.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -29,43 +30,43 @@ public class BuildPageListFile implements BuildFilerInter {
String fileName=clsName; //首字母小写
clsName=Utils.toUpperCaseFirstOne(clsName); //首字母大写
sb.append("<%@ page language=\"java\" contentType=\"text/html; charset=utf-8\"%>\r\n");
sb.append("<%@taglib uri=\"/WEB-INF/taglib.tld\" prefix=\"x\"%>\r\n");
sb.append("<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\"%>\r\n");
sb.append("<html>\r\n");
sb.append("<head>\r\n");
sb.append("<%@ page language=\"java\" contentType=\"text/html; charset=utf-8\"%>").append(Constant.SYSMBOL_LINE);
sb.append("<%@taglib uri=\"/WEB-INF/taglib.tld\" prefix=\"x\"%>").append(Constant.SYSMBOL_LINE);
sb.append("<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\"%>").append(Constant.SYSMBOL_LINE);
sb.append("<html>").append(Constant.SYSMBOL_LINE);
sb.append("<head>").append(Constant.SYSMBOL_LINE);
sb.append("<x:base include=\"layout,dialog,grid,tree,dateTime,combox,attachment,commonTree,comboDialog\" />\r\n");
sb.append("<script src='<c:url value=\"/lib/jquery/jquery.comboDialog.js\"/>' type=\"text/javascript\"></script>\r\n");
sb.append("<script src='<c:url value=\"/lib/jquery/jquery.commonTree.js\"/>' type=\"text/javascript\"></script>\r\n");
sb.append("<script src='<c:url value=\"/lib/jquery/jquery.flexField.js\"/>' type=\"text/javascript\"></script>\r\n");
sb.append("<x:base include=\"layout,dialog,grid,tree,dateTime,combox,attachment,commonTree,comboDialog\" />").append(Constant.SYSMBOL_LINE);
sb.append("<script src='<c:url value=\"/lib/jquery/jquery.comboDialog.js\"/>' type=\"text/javascript\"></script>").append(Constant.SYSMBOL_LINE);
sb.append("<script src='<c:url value=\"/lib/jquery/jquery.commonTree.js\"/>' type=\"text/javascript\"></script>").append(Constant.SYSMBOL_LINE);
sb.append("<script src='<c:url value=\"/lib/jquery/jquery.flexField.js\"/>' type=\"text/javascript\"></script>").append(Constant.SYSMBOL_LINE);
String JsPath="";
if (paraForm.getIsform()==1){ //表单生成器 生成页面
JsPath=paraForm.getFormPath();
JsPath=JsPath.substring(JsPath.indexOf("customform"));
sb.append("<script src='<c:url value=\"/").append(JsPath).append("/").append(fileName).append("List.js\"/>' type=\"text/javascript\"></script>\r\n");
sb.append("<script src='<c:url value=\"/").append(JsPath).append("/").append(fileName).append("List.js\"/>' type=\"text/javascript\"></script>").append(Constant.SYSMBOL_LINE);
} else { //生成源码 的
sb.append("<script src='<c:url value=\"/biz/").append(paraForm.getFormPath()).append("/").append(fileName).append("List.js\"/>' type=\"text/javascript\"></script>\r\n");
sb.append("<script src='<c:url value=\"/biz/").append(paraForm.getFormPath()).append("/").append(fileName).append("List.js\"/>' type=\"text/javascript\"></script>").append(Constant.SYSMBOL_LINE);
}
sb.append("</head>\r\n");
sb.append(" <body>\r\n");
// sb.append(" <x:hidden name=\"id\" />\r\n");
sb.append("</head>").append(Constant.SYSMBOL_LINE);
sb.append(" <body>").append(Constant.SYSMBOL_LINE);
// sb.append(" <x:hidden name=\"id\" />").append(Constant.SYSMBOL_LINE);
sb.append(" <div class=\"container-fluid\">\r\n");
sb.append(" <div id=\"layout\">\r\n");
sb.append(" <div class=\"container-fluid\">").append(Constant.SYSMBOL_LINE);
sb.append(" <div id=\"layout\">").append(Constant.SYSMBOL_LINE);
//拼接标题
sb.append("<div position=\"center\" title=\"").append(paraForm.getFormName()).append("\">\r\n");
sb.append(" <x:title title=\"搜索\" hideTable=\"queryMainForm\" isHide=\"true\" />\r\n");
sb.append("<div position=\"center\" title=\"").append(paraForm.getFormName()).append("\">").append(Constant.SYSMBOL_LINE);
sb.append(" <x:title title=\"搜索\" hideTable=\"queryMainForm\" isHide=\"true\" />").append(Constant.SYSMBOL_LINE);
if (paraForm.getIsform()==1){ //表单生成器 生成页面
sb.append(" <x:hidden name=\"formNo\" />\r\n");
sb.append(" <x:hidden name=\"procId\" />\r\n");
sb.append(" <x:hidden name=\"formNo\" />").append(Constant.SYSMBOL_LINE);
sb.append(" <x:hidden name=\"procId\" />").append(Constant.SYSMBOL_LINE);
}
sb.append(" <form class=\"hg-form ui-hide\" method=\"post\" action=\"\" id=\"queryMainForm\">\r\n");
sb.append(" <form class=\"hg-form ui-hide\" method=\"post\" action=\"\" id=\"queryMainForm\">").append(Constant.SYSMBOL_LINE);
sb.append(" <div class=\"hg-form-row\">\r\n");
sb.append(" <div class=\"hg-form-row\">").append(Constant.SYSMBOL_LINE);
//拼接查询字段
// String searchField=pageMap.get("listdisplaySearchField").toString();
String []searchFields=paraForm.getSearchFields();
......@@ -94,29 +95,29 @@ public class BuildPageListFile implements BuildFilerInter {
}
if ("select".equals(tagType)){ //数据字典 dataSourceType=3
sb.append(" <x:selectC name=\"").append(searchField).append("\" label=\"")
.append(chName).append("\" dictionary=\"").append(dataSource).append("\" emptyOption=\"true\" labelCol=\"1\" />\r\n");
.append(chName).append("\" dictionary=\"").append(dataSource).append("\" emptyOption=\"true\" labelCol=\"1\" />").append(Constant.SYSMBOL_LINE);
}else if ("input".equals(tagType)){
sb.append(" <x:inputC name=\"").append(searchField)
.append("\" label=\"").append(chName).append("\" labelCol=\"1\" />\r\n");
.append("\" label=\"").append(chName).append("\" labelCol=\"1\" />").append(Constant.SYSMBOL_LINE);
}else if ("date".equals(tagType)){
sb.append(" <x:inputC name=\"start").append(Utils.toUpperCaseFirstOne(searchField)).append("\" wrapper=\"date\" label=\"").append(chName).append("从\" labelCol=\"1\"/>\r\n");
sb.append(" <x:inputC name=\"end").append(Utils.toUpperCaseFirstOne(searchField)).append("\" wrapper=\"date\" label=\"至\" labelCol=\"1\"/>\r\n");
sb.append(" <x:inputC name=\"start").append(Utils.toUpperCaseFirstOne(searchField)).append("\" wrapper=\"date\" label=\"").append(chName).append("从\" labelCol=\"1\"/>").append(Constant.SYSMBOL_LINE);
sb.append(" <x:inputC name=\"end").append(Utils.toUpperCaseFirstOne(searchField)).append("\" wrapper=\"date\" label=\"至\" labelCol=\"1\"/>").append(Constant.SYSMBOL_LINE);
// <x:inputL name="completeDate" label="竣工日期起" readonly="false" wrapper="date" />
// <x:inputL name="endcompleteDate" label="止" readonly="false" wrapper="date" />
}
} //searchFields[i]==1
}
sb.append(" <x:searchButtons />\r\n");
sb.append(" </div>\r\n");
sb.append(" </form>\r\n");
sb.append(" <div id=\"").append(fileName).append("Grid\" style=\"margin:2px;\"></div>\r\n");
sb.append(" </div>\r\n");
sb.append(" </div>\r\n");
sb.append(" </div>\r\n");
sb.append(" </body>\r\n");
sb.append(" <x:searchButtons />").append(Constant.SYSMBOL_LINE);
sb.append(" </div>").append(Constant.SYSMBOL_LINE);
sb.append(" </form>").append(Constant.SYSMBOL_LINE);
sb.append(" <div id=\"").append(fileName).append("Grid\" style=\"margin:2px;\"></div>").append(Constant.SYSMBOL_LINE);
sb.append(" </div>").append(Constant.SYSMBOL_LINE);
sb.append(" </div>").append(Constant.SYSMBOL_LINE);
sb.append(" </div>").append(Constant.SYSMBOL_LINE);
sb.append(" </body>").append(Constant.SYSMBOL_LINE);
sb.append("</html>\r\n");
sb.append("</html>").append(Constant.SYSMBOL_LINE);
String filePathName=paraForm.getUploadPath()+"/"+paraForm.getFormPath()+"/"+fileName+"List.jsp";
......
......@@ -7,6 +7,7 @@ import com.google.common.base.CaseFormat;
import com.huigou.uasp.builder.ButtonTypeInter;
import com.huigou.uasp.builder.vo.ButtonAttributeVO;
import com.huigou.uasp.builder.vo.SeleListCustomVO;
import com.huigou.uasp.form.domain.model.FormParameter;
import com.huigou.uasp.util.Utils;
import com.huigou.uasp.util.Constant;
......@@ -18,7 +19,7 @@ public class AddButtonResult implements ButtonTypeInter {
//如果是配置了流程 则通过Ifame打开,发起流程页面
sb.append(" function addHandler(){");
sb.append(" if ($('#procId').val()!=\"\") { ");
sb.append("UICtrl.addTabItem({ ");
sb.append(" tabid: 'add").append(btnAttr.getEntityName()).append("',");
sb.append(" text: \"新增"+btnAttr.getFormName()+"\",");
......@@ -54,174 +55,20 @@ public class AddButtonResult implements ButtonTypeInter {
sb.append(Constant.SYSMBOL_LINE);
sb.append("function initAdd").append(Utils.toUpperCaseFirstOne(btnAttr.getEntityName())).append("(){ ");
//如果存在自定义的 下拉选择框
boolean existCustomSelect=false;
for (int i=0;i<btnAttr.getDataSourceType().length;i++){
if (Constant.DATASOURCETYPE_SQL.equals(btnAttr.getDataSourceType()[i])){
existCustomSelect=true;
break;
}
}
//dataSouce: [searchName:;type:;id:;displayField:{};conditionField:{};ordeby:]
if (existCustomSelect){
//String dataSource="";
SeleListCustomVO selectCustom=null;
List <SeleListCustomVO> customLists= btnAttr.getSelectCustoms();
for (int i=0;i<btnAttr.getDataSourceType().length;i++){ //遍历所有的数据来源
if (Constant.DATASOURCETYPE_SQL.equals(btnAttr.getDataSourceType()[i])){ //是集合类型的 自定义检索SQL的 
String targetField=btnAttr.getFieldEns()[i];
selectCustom=null;
for (int u=0;u<customLists.size();u++){ //遍历所有的检索SQL
if (btnAttr.getIsForm()==1){ //是表单生成器 字段名称变成了field0、field1、field2....
if (i==customLists.get(u).getTargetNum()){
selectCustom=customLists.get(u);
break;
}
} else { //代码生成器
if (targetField.equals(customLists.get(u).getTargetField())){ //字段名称是真实字段名称
selectCustom=customLists.get(u);
break;
}
}
} //
if (selectCustom!=null){
sb.append(" $('#").append(targetField).append("').searchbox({ ");
sb.append(" type : '").append(selectCustom.getSearchboxType()).append("', ");
sb.append(" name : '").append(selectCustom.getSearchName()).append("', ");
if (btnAttr.getIsForm()==1){ //是表单生成器 增加参数frmType
sb.append(" frmType : '").append(selectCustom.getFormNo()).append("', ");
}
sb.append(" getParam : function() { ");
sb.append(" return { "); //参数字段
if (selectCustom.getCondiColumns()!=null&&!"".equals(selectCustom.getCondiColumns())){
String []condiCols=selectCustom.getCondiColumns().split(",");
for (int x=0;x<condiCols.length;x++){
sb.append(" ").append(condiCols[x]).append(":$('#")
.append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,condiCols[x]))
.append("').val()");
if (x<condiCols.length-1){
sb.append(",");
}
sb.append(" ");
}
}
//存在冒号开头的指定变量参数
if (selectCustom.getParamFields()!=null&&!"".equals(selectCustom.getParamFields())){
if (selectCustom.getCondiColumns()!=null&&!"".equals(selectCustom.getCondiColumns())){
sb.append(" ,");
}
String []paramFields=selectCustom.getParamFields().split(",");
String []paramSourceFields=new String[paramFields.length];
if (selectCustom.getParamSourceFields()!=null&&!"".equals(selectCustom.getParamSourceFields())){
paramSourceFields=selectCustom.getParamSourceFields().split(",");
}
String paramSourceField="";
for (int x=0;x<paramFields.length;x++){
sb.append(" ").append(paramFields[x]).append(":$('#");
if (btnAttr.getIsForm()==1){ //是表单生成器 字段名称变成了field0、field1、field2....
String []fields=selectCustom.getFieldEns();
paramSourceField=paramSourceFields[x]; //默认取来源字段 ,以免是隐藏字段没有找到值
for (int y=0;y<fields.length;y++){
if (fields[y].equals(paramSourceFields[x])){
paramSourceField="field"+y;
break;
}
}
} else {
paramSourceField=paramSourceFields[x];
}
if (paramSourceFields.length>x){
sb.append(paramSourceField);
} else {
sb.append(paramFields[x]);
}
sb.append("').val()");
if (x<paramFields.length-1){
sb.append(",");
}
sb.append(" ");
}
}
sb.append(" }; ");
sb.append(" }, ");
sb.append(" back : { ");
if (selectCustom.getFieldCodes()!=null&&!"".equals(selectCustom.getFieldCodes())){
String []fieldCodes=selectCustom.getFieldCodes().split(",");
String []backFields=selectCustom.getBackFields().split(",");
String []fieldEns=selectCustom.getFieldEns(); //隐藏字段如何处理?
for (int y=0;y<fieldCodes.length;y++){
if (backFields.length>=y+1&&!"".equals(backFields[y])){//有对应的返回字段
sb.append(" ").append(fieldCodes[y]).append(":'#");
if (btnAttr.getIsForm()==1){ //是表单生成器 字段名称变成了field0、field1、field2....
sb.append(getMappingFieldEn(fieldEns,backFields[y]));
// if (backFields[y].equals(getRealFieldEn(fieldEns,targetField))){ //返回给当前字段的值 需要加 _text
// sb.append("_text"); //不用 旧版本需要
// }
} else { //代码生成器
sb.append(backFields[y]);
// if (targetField.equals(backFields[y])){ //返回给当前字段的值 需要加 _text
// sb.append("_text");
// }
}
sb.append("'");
if (y<backFields.length-1) {
sb.append(",");
}
sb.append(" ");
}
}
}
//toServiceCode_text
sb.append(" }, ");
sb.append(" onChange : function() { ");
// sb.append(" $('#buildingName').val($('#buildingName_text').val()); ");
sb.append(" } ");
sb.append(" }); ");
// sb.append(" } ");
// sb.append(" } ");
}
}
}
}
/*
$('#buildingName').searchbox({
type : 'oa',
name : 'buildingInfo',
getParam : function() {
return {
villageId:$('#villageId').val() //sql语句 定义了 以:参数
};
},
back : {
id : '#buildingId',
buildingName : '#buildingName_text'
},
onChange : function() {
$('#buildingName').val($('#buildingName_text').val());
Utils.createEasySearch(sb,btnAttr);
if (btnAttr.getExistAttachment()==1) {
//sb.append(" var _attbizid=$(\"#attbizid\").val();");
//sb.append(" $('#").append(Utils.toLowerCaseFirstOne(btnAttr.getEntityName())).append("Attach').fileList({bizId:_attbizid}); ");
List<FormParameter> attachLists = btnAttr.getAttachmentLists();
for (FormParameter formParameter : attachLists) {
sb.append(" $('#").append(formParameter.getParmVals()).append("Attach').fileList({bizId:$(\"#attbizid\").val()});");
}
}
});
*/
if (btnAttr.getExistAttachment()==1){
sb.append(" var _attbizid=$(\"#attbizid\").val();");
sb.append(" $('#").append(Utils.toLowerCaseFirstOne(btnAttr.getEntityName())).append("List').fileList({bizId:_attbizid}); //�����ؼ���ʼ��");
}
//sb.append(" $("#projectName").attr("readonly",true);
sb.append(" } ");
sb.append(" } ");
sb.append(" ");
// sb.append(" //保存方法 ;");
......@@ -245,6 +92,8 @@ public class AddButtonResult implements ButtonTypeInter {
sb.append(" success: function (data) {");
sb.append(" $(\"#id\").val(data);");
sb.append(" if ($('#").append(btnAttr.getEntityName()).append("')) { $('#");
sb.append(btnAttr.getEntityName()).append("Attach').fileList({bizId:data}); } ");
sb.append(" if (grid&&grid!=\"\") {UICtrl.addGridRow(eval(grid),{id:data } );}");
sb.append(" reload").append(Utils.toUpperCaseFirstOne(btnAttr.getEntityName())).append("Grid();");
sb.append(" refreshFlag = true;");
......
......@@ -6,6 +6,7 @@ import java.util.List;
import com.google.common.base.CaseFormat;
import com.huigou.uasp.builder.ButtonTypeInter;
import com.huigou.uasp.builder.vo.ButtonAttributeVO;
import com.huigou.uasp.form.domain.model.FormParameter;
import com.huigou.uasp.util.Utils;
import com.huigou.uasp.util.Constant;
......@@ -72,7 +73,7 @@ public class SaveRowButtonResult implements ButtonTypeInter {
//sb.append(" $(\"#id\").val(data); ");
.append(" refreshFlag = true;")
//避免明细表修改后保存后提示 数据已经改变,关闭后数据丢失的提示
.append(" ").append(btnAttr.getEntityName()).append("GridManager.isDataChanged=false;")
//.append(" ").append(btnAttr.getEntityName()).append("GridManager.isDataChanged=false;")
.append(" if (data.result==\"success\") { ");
//.append(" reload").append(Utils.toUpperCaseFirstOne(btnAttr.getEntityName())).append("Grid();")
......@@ -117,7 +118,9 @@ public class SaveRowButtonResult implements ButtonTypeInter {
sb.append(" success: function (data) {");
sb.append(" $(\"#id\").val(data);");
sb.append(" if (grid&&grid!=\"\") {UICtrl.addGridRow(eval(grid),{id:''} );}");
sb.append(" if ($('#").append(btnAttr.getParentEntityName()).append("')) { $('#");
sb.append(btnAttr.getParentEntityName()).append("Attach').fileList({bizId:data}); } ");
sb.append(" if (grid&&grid!=\"\"&&grid!=1) {UICtrl.addGridRow(eval(grid),{id:''} );}");
//sb.append(" reload").append(Utils.toUpperCaseFirstOne(btnAttr.getEntityName())).append("Grid();");
//sb.append(" refreshFlag = true;");
//sb.append(" _self.close();");
......@@ -166,7 +169,17 @@ public class SaveRowButtonResult implements ButtonTypeInter {
sb.append(" var params=[];");
sb.append(btnAttr.getEntityName()).append("GridManager.options.url=web_app.name + '/dataManage/slicedQueryDataRecordDetail.ajax?id='+getId();");
//sb.append(btnAttr.getEntityName()).append("GridManager.isDataChanged=flase;"); //但是页面有提示?
sb.append("UICtrl.gridSearch(").append(btnAttr.getEntityName()).append("GridManager, params);");
//sb.append("UICtrl.gridSearch(").append(btnAttr.getEntityName()).append("GridManager, params);");
sb.append(btnAttr.getEntityName()).append("GridManager.loadData();");
if (btnAttr.getExistAttachment()==1) {
List<FormParameter> attachLists = btnAttr.getAttachmentLists();
for (FormParameter formParameter : attachLists) {
//sb.append(" if ($('#").append(btnAttr.getParentEntityName()).append("Attach')) { $('#")
// .append(btnAttr.getParentEntityName()).append("Attach').fileList({bizId:getId()}); }");
sb.append(" if ($('#").append(formParameter.getParmVals()).append("Attach')) { $('#")
.append(formParameter.getParmVals()).append("Attach').fileList({bizId:getId()}); }");
}
}
sb.append("}");
sb.append(Constant.SYSMBOL_LINE);
......
package com.huigou.uasp.builder.vo;
import com.huigou.uasp.bpm.managment.domain.model.ProcDefinition;
import com.huigou.uasp.form.domain.model.FormParameter;
import java.util.List;
......@@ -20,10 +21,12 @@ public class ButtonAttributeVO {
private String buttonMethoedName;
private int existAttachment;
private String []dataSourceType;
private String []dataSource;
private List <FormParameter> attachmentLists;
private String []dataSourceTypes;
private String []dataSources;
private String []fieldEns;
......@@ -87,20 +90,20 @@ public class ButtonAttributeVO {
this.existAttachment = existAttachment;
}
public String[] getDataSourceType() {
return dataSourceType;
public String[] getDataSourceTypes() {
return dataSourceTypes;
}
public void setDataSourceType(String[] dataSourceType) {
this.dataSourceType = dataSourceType;
public void setDataSourceTypes(String[] dataSourceTypes) {
this.dataSourceTypes = dataSourceTypes;
}
public String[] getDataSource() {
return dataSource;
public String[] getDataSources() {
return dataSources;
}
public void setDataSource(String[] dataSource) {
this.dataSource = dataSource;
public void setDataSources(String[] dataSources) {
this.dataSources = dataSources;
}
public String[] getFieldEns() {
......@@ -119,5 +122,11 @@ public class ButtonAttributeVO {
this.selectCustoms = selectCustoms;
}
public List<FormParameter> getAttachmentLists() {
return attachmentLists;
}
public void setAttachmentLists(List<FormParameter> attachmentLists) {
this.attachmentLists = attachmentLists;
}
}
package com.huigou.uasp.builder.vo;
import com.huigou.uasp.bpm.managment.domain.model.ProcDefinition;
import com.huigou.uasp.form.domain.model.FormParameter;
import java.util.List;
......@@ -50,13 +51,15 @@ public class ParamFormVO {
private int fieldCols;
private int textAreaRows;
private int existAttachment;
private List <FormParameter> attachmentLists;
//private ProcDefinition procDefinition;
private List <SeleListCustomVO> selectCustoms; //检索SQL对象参数
private List <ParamFormVO>details; //明细表对象参数
private EasySearchVO easySearchVO;
public int getIsform() {
return isform;
......@@ -288,4 +291,19 @@ public class ParamFormVO {
this.defaultOperation = defaultOperation;
}
public EasySearchVO getEasySearchVO() {
return easySearchVO;
}
public void setEasySearchVO(EasySearchVO easySearchVO) {
this.easySearchVO = easySearchVO;
}
public List<FormParameter> getAttachmentLists() {
return attachmentLists;
}
public void setAttachmentLists(List<FormParameter> attachmentLists) {
this.attachmentLists = attachmentLists;
}
}
......@@ -9,9 +9,17 @@ import com.huigou.context.Operator;
import com.huigou.context.OrgUnit;
import com.huigou.exception.ApplicationException;
import com.huigou.uasp.bmp.common.BizBillStatus;
import com.huigou.uasp.bpm.engine.application.WorkflowApplication;
import com.huigou.uasp.bpm.managment.domain.model.ProcDefinition;
import com.huigou.uasp.bpm.managment.repository.ProcDefinitionRespository;
import com.huigou.uasp.data.application.DataRecordByFlowApplication;
import com.huigou.util.ApplicationContextWrapper;
import net.sf.json.JSONObject;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -62,10 +70,15 @@ public class DataManageController extends CommonController {
@Autowired
private DataRecordApplication dataRecordApplication;
@Autowired
private WorkflowApplication workflowApplication;
@Autowired
private CommonUtilApplication commonUtilApplication;
@Autowired
private DataRecordByFlowApplication dataRecordByFlowApplication;
@Override
protected String getPagePath() {
return "/customform/";
......@@ -115,22 +128,53 @@ public class DataManageController extends CommonController {
@SuppressWarnings("unchecked")
public String addDataRecord() {
SDO sdo = this.getSDO();
// 优先取id作为业务主键
String id = sdo.getString("id");
if (StringUtils.isBlank(id)) {
// 否则取bizId作为业务主键
id = sdo.getBizId();
sdo.putProperty("id", id);
}
if (StringUtils.isNotBlank(sdo.getString("procId"))){
this.putAttribute("procId",sdo.getString("procId"));
String bizId = sdo.getString("bizId");
if (StringUtils.isNotBlank(bizId)) { //带流程 且在审批状态
ProcDefinition pd=dataRecordByFlowApplication.getFormNoByBizid(bizId);
Map map=new HashMap<>();
id = bizId;
map.put("formNo",pd.getFormNo());
map.put("procId",pd.getProcId());
map.put("id",bizId);
sdo.setProperties(map);
} else { //新增 修改中
if (StringUtils.isNotBlank(sdo.getString("procId"))) { //关联流程的
Operator operator = sdo.getOperator();
this.putAttribute("procId", sdo.getString("procId"));
this.putAttribute("createdByName",operator.getPersonMemberName());
this.putAttribute("createdDate",new Timestamp((new Date()).getTime()));
ProcessInstance pi = workflowApplication.getRunTimeService().createProcessInstanceQuery().processInstanceBusinessKey(id)
.singleResult();
if (pi != null && (StringUtils.isBlank(sdo.getString("taskId")))) {
workflowApplication.getTaskService().createTaskQuery()
.processInstanceId(pi.getProcessInstanceId())
.list()
.stream()
.filter(task -> task.getAssignee().equals(operator.getFullId()))
.findAny()
.ifPresent(task -> {
putAttribute("taskId", task.getId());
});
}
} else {
this.putAttribute("procId", "");
}
}
String formNo = sdo.getString("formNo");
DataRecordQueryRequest queryRequest =sdo.toQueryRequest(DataRecordQueryRequest.class);
List<SafFormslist> list = safFormslistRepository.findByFormNo(formNo);
SafFormslist safFormslist = list.get(0);
if (safFormslist.getExistAttachment()==1){ //存在附件
this.putAttribute("attbizid",id);
}
String tableName = commonUtilApplication.getTablesByFormId(safFormslist.getId(), 1);
tableName = tableName.split(",")[0]; //取第一个主表
......
......@@ -61,7 +61,7 @@ public interface SafFormslistApplication {
/*
* 是否生成页面文件
*/
String needGenerateFile(String formNo);
String produceGenerateFile(String formNo);
//查询单值的属性
// List<Map<String, Object>> queryDataRecordSingleFields(SafFormsQueryRequest queryRequest);
......
......@@ -7,17 +7,13 @@ import com.huigou.uasp.bmp.common.application.BaseApplication;
import com.huigou.uasp.bmp.configuration.repository.SysDictionaryRepository;
import com.huigou.uasp.form.application.CommonUtilApplication;
import com.huigou.uasp.form.application.FormsDesignApplication;
import com.huigou.uasp.form.domain.model.FormAttribute;
import com.huigou.uasp.form.domain.model.FormSearchSql;
import com.huigou.uasp.form.domain.model.SafFormslist;
import com.huigou.uasp.form.domain.model.*;
import com.huigou.uasp.form.domain.query.FormsAttributeQueryRequest;
import com.huigou.uasp.form.pojo.Options;
import com.huigou.uasp.form.pojo.PubProperty;
import com.huigou.uasp.form.pojo.Root;
import com.huigou.uasp.form.pojo.TableColumns;
import com.huigou.uasp.form.repository.FormAttributeRepository;
import com.huigou.uasp.form.repository.FormSearchSqlRepository;
import com.huigou.uasp.form.repository.SafFormslistRepository;
import com.huigou.uasp.form.repository.*;
import com.huigou.uasp.util.Constant;
import com.huigou.uasp.util.Utils;
import net.sf.ezmorph.bean.MorphDynaBean;
......@@ -48,6 +44,12 @@ public class FormsDesignApplicationImpl extends BaseApplication implements Forms
@Autowired
private FormAttributeRepository formAttributeRepository;
@Autowired
private FormTablesRepository formTablesRepository;
@Autowired
private FormParameterRepository formParameterRepository;
@Autowired
private FormSearchSqlRepository formSearchSqlRepository;
@Autowired
......@@ -62,7 +64,6 @@ public class FormsDesignApplicationImpl extends BaseApplication implements Forms
@Override
@Transactional
/* 旧的方法 old */
public Map <String,Object> saveFormAttribute(FormsAttributeQueryRequest queryRequest,SafFormslist form) {
Map <String, Object>map = new HashMap<String, Object>();
map.put("success", "1");
......@@ -80,11 +81,11 @@ public class FormsDesignApplicationImpl extends BaseApplication implements Forms
//获取主表所有字段元素
List<Map<String, Object>> mainFieldLists=commonUtilApplication.queryFormTableFields(queryRequest.getFormNo(),mainTableName);
List <String>displayNums=new ArrayList<String>();
//遍历表单属性列表
int sequence=0;
int sequence=0,nums=0;
for (Root root:rootList){
nums++;
root.setFormId(form.getId());
root.setFormNo(form.getFormNo());
......@@ -109,8 +110,36 @@ public class FormsDesignApplicationImpl extends BaseApplication implements Forms
if ("radio".equals(root.getType())){ // radios组件
}*/
if ("table".equals(root.getType())||"grid".equals(root.getType())){ //表格或表单
displayNums.add(root.getTableColumns().get(0).getTable()) ;//表名
}
// 文件附件
if ("fileupload".equals(root.getType())){
// root.getName(); //文件标题
FormParameter formParameter=new FormParameter();
formParameter.setParmType(5);
formParameter.setId(Utils.createUuid());
formParameter.setFormNo(form.getFormNo());
formParameter.setParmCode(root.getOptions().getBizCode());
formParameter.setParmName(root.getName());
formParameter.setParmVals(root.getOptions().getBizId());
formParameter.setDisplayNums(nums);
formParameter.setStatus(1);
this.formParameterRepository.saveAndFlush(formParameter);
}
}
//保存表单及明细表的顺序
List<FormTables> formTablesList=this.formTablesRepository.findByFormId(form.getId());
for (int u=0;u<displayNums.size();u++){
for (FormTables formTables:formTablesList){
if (formTables.getTableName().equals(displayNums.get(u))){
formTables.setDisplayNums(u+1);
this.formTablesRepository.saveAndFlush(formTables);
break;
}
}
}
} catch (Exception e) {
map.put("success", "0");
map.put("reason", e.getMessage());
......
......@@ -70,6 +70,9 @@ private FormSearchSqlRepository formSearchSqlRepository;
@Autowired
private SysFunctionApplicationProxy sysFunctionApplication;
@Autowired
private FormParameterRepository formParameterRepository;
@Autowired
private CommonUtilApplication commonUtilApplication;
......@@ -767,7 +770,7 @@ public void deleteSyfFormsByIds(List<String> ids) {
* 生成表单的页面文件
* queryRequest:需要参数formNo
*/
public String needGenerateFile(String formNo) {
public String produceGenerateFile(String formNo) {
String backStr="";
String webPath = this.getClass().getClassLoader().getResource("/").getPath();
webPath = webPath.substring(1, webPath.length() - 16);
......@@ -789,6 +792,7 @@ public void deleteSyfFormsByIds(List<String> ids) {
queryRequest.setId(safFormslist.getId());
queryRequest.setTableName(tableName.toUpperCase());
queryRequest.setFormNo(formNo);
queryRequest.setExistAttachment(safFormslist.getExistAttachment());
String pageName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,tableName); //转驼峰法
String filePathName = webPath + "/" + pageName + ".jsp";
......@@ -813,20 +817,18 @@ public void deleteSyfFormsByIds(List<String> ids) {
DbTablesQueryRequest dbqueryRequest=new DbTablesQueryRequest();
dbqueryRequest.setTableName(tableName.toUpperCase());
hiddenField=commonUtilApplication.queryTableHiddenFields(dbqueryRequest,1);
if (safFormslist.getExistAttachment()==1){
hiddenField.add("attbizid");
}
paraForm.setIsform(1);
paraForm.setTableName(tableName);//主表名称
paraForm.setFormPath(webPath);
paraForm.setUploadPath(""); //页面文件 直接生成在运行目录
paraForm.setSrcPath(pagePath);
/* if (paraForm.getHiddenFields()!=null&&paraForm.getHiddenFields().size()>0){
List <String>tmpHidden=paraForm.getHiddenFields();
tmpHidden.addAll(hiddenField);
paraForm.setHiddenFields(tmpHidden);
} else {
paraForm.setHiddenFields(hiddenField);
}
*/
paraForm.setHiddenFields(hiddenField);
paraForm.setFormName(safFormslist.getFormName());
......@@ -932,43 +934,17 @@ public void deleteSyfFormsByIds(List<String> ids) {
hiddenFields.addAll(Utils.getHiddenFields(customVO));
listCustoms.add(customVO);
}
paraForms.setSelectCustoms(listCustoms);
paraForms.setHiddenFields(hiddenFields);
paraForms.setFormPath(queryRequest.getFormNo());
//判断是否存在明细表
/* List<Map<String, Object>> multsList =new ArrayList<Map<String, Object>>();
String mainTableName=queryRequest.getTableName().toLowerCase();//获取主表
queryRequest.setTableType(2);
multsList=this.queryExistTables(queryRequest);
if (multsList != null && multsList.size() > 0) {//多值则产生明细表
ParamFormVO paramVO = new ParamFormVO();
List<String> hiddenField=new ArrayList<String>();
hiddenField.add("id");
hiddenField.add("parentId");
List<ParamFormVO> details = new ArrayList<ParamFormVO>();
// Map<String, Object> map =null;
List<Map<String, Object>> list=null;
for (int i = 0; i < multsList.size(); i++) {
map = (Map<String, Object>) multsList.get(i);
// queryRequest.setAttrId(map.get("id").toString()); 05.18.2020 lxh close
queryRequest.setTableName(map.get("tableName").toString());
list = this.commonUtilApplication.queryDataRecordMultsFields(queryRequest.getId(),map.get("tableName").toString());
paramVO = Utils.composeAttributes(list, map.get("tableName").toString(), map.get("name").toString(), hiddenField);
paramVO.setDisplayFieldnames(paramVO.getFieldChs());
paramVO.setDisplayFields(paramVO.getFieldEns());
paramVO.setDisplayFieldTypes(paramVO.getValidatorTypes());
paramVO.setSrcPath(pagePath);
paramVO.setSelectCustoms(listCustoms);
paramVO.setIsform(1); //是表单生成器
paramVO.setFormPath(queryRequest.getFormNo());
paramVO.setMainTableName(mainTableName);
details.add(paramVO);
}
paraForms.setDetails(details);
}
*/
return getDetailTables(queryRequest,paraForms);
//添加文件附件参数
List <FormParameter> attachlists=this.formParameterRepository.findByFormNoAndParmType(queryRequest.getFormNo(),5);
if (attachlists!=null&&attachlists.size()>0){
paraForms.setExistAttachment(queryRequest.getExistAttachment());
paraForms.setAttachmentLists(attachlists);
}
return getDetailTables(queryRequest,paraForms);
//return paraForms;
}
......@@ -1006,6 +982,8 @@ public void deleteSyfFormsByIds(List<String> ids) {
paramVO.setIsform(1); //是表单生成器
paramVO.setFormPath(queryRequest.getFormNo());
paramVO.setMainTableName(mainTableName);
paramVO.setExistAttachment(paraForms.getExistAttachment());
paramVO.setAttachmentLists(paraForms.getAttachmentLists());
details.add(paramVO);
}
paraForms.setDetails(details);
......@@ -1130,6 +1108,7 @@ public void deleteSyfFormsByIds(List<String> ids) {
sql+=" and a.table_type="+queryRequest.getTableType();
}
sql+=" and c.form_no='"+queryRequest.getFormNo()+"'";
sql+=" order by a.display_nums ";
queryModel.setSql(sql);
mapData = this.sqlExecutorDao.executeSlicedQuery(queryModel);
......
......@@ -911,14 +911,14 @@ public String queryTableProperty(){
SafFormsQueryRequest formQueryRequest=sdo.toQueryRequest(SafFormsQueryRequest.class);;
// String pageName=CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,tableName);
//formQueryRequest.setTableName(tableName);
backStr=safFormsApplication.needGenerateFile(formQueryRequest.getFormNo());
backStr=safFormsApplication.produceGenerateFile(formQueryRequest.getFormNo());
Map <String,Object>map=new HashMap<String,Object>();
map.put("result",backStr);
return toResult(map);
}
//代码生成器-->组装参数对象 旧的方法 作废
public ParamFormVO getParamFormVO(Map <String, Object>pageMap){
public ParamFormVO getParamFormVO_ss(Map <String, Object>pageMap){
ParamFormVO paraForm = new ParamFormVO();
try {
paraForm.setIsform(0);
......@@ -966,11 +966,7 @@ public String queryTableProperty(){
}
List <String> hiddenList=new ArrayList<String>();
hiddenList.add("id");
paraForm.setHiddenFields(hiddenList);
if ("1".equals(pageMap.get("existAttachment").toString())){
hiddenList.add("attbizid");
paraForm.setHiddenFields(hiddenList);
}
}catch (Exception ex){
ex.printStackTrace();
......
......@@ -65,14 +65,14 @@ public class FormAttribute extends AbstractEntity {
/**
* 效验DB函数及其参数
* 效验DB函数名称及其参数
* DB效验函数或过程(冒号后面是参数字段和返回字段,参数字段逗号分隔, 参数字段和返回字段中主表字段使用[]括起来)
*/
@Column(name = "check_function", length = 500)
private String checkFunction;
/**
* JS效验函数
* JS效验内容
* js中如果是获取主表字段的值 使用 "#[name]"格式
* 如果是明细表格中js中调用的明细表字段是以grid.record.开头获取 否则不予解析和转换
* 明细表中更新值的写法XXXGridManager.updateCell('name','',grid.record)
......@@ -92,6 +92,7 @@ public class FormAttribute extends AbstractEntity {
/**
* 下拉框的数据来源类型
* 1无 2 自定义检索SQL \3 数据字典 \4 固定JSON
*/
@Column(name = "data_source_type", length = 10)
private String dataSourceType;
......
......@@ -23,32 +23,36 @@ public class FormParameter extends AbstractEntity {
/**
* 参数类型
* 参数类型 参数类型:1、表单提示 2、检索SQL 3、校验函数 4、存储过程 5、文件附件
*/
@Column(name = "parm_type", length = 10)
private Integer parmType;
/**
* 参数Name
* 参数Name 参数说明/附件标题
*/
@Column(name = "parm_name", length = 100)
private String parmName;
/**
* 参数Code
* 参数Code 参数编码/函数名称/过程名称/附件CODE
*/
@Column(name = "parm_code", length = 100)
private String parmCode;
/**
* 参数Code
* 参数Code 参数值/附件ID
*/
@Column(name = "parm_vals", length = 3000)
private String parmVals;
//文件附件显示顺序
@Column(name="display_nums",length=10)
private Integer displayNums;
/**
* 状态1启用、停用0
*/
......@@ -118,8 +122,12 @@ public class FormParameter extends AbstractEntity {
public void setStatus(Integer status) {
this.status = status;
}
public Integer getDisplayNums() {
return displayNums;
}
public void setDisplayNums(Integer displayNums) {
this.displayNums = displayNums;
}
}
......@@ -48,6 +48,9 @@ public class FormTables extends AbstractEntity{
@Column(name="status",length=10)
private Integer status;
//排列顺序
@Column(name="display_nums",length=10)
private Integer displayNums;
/**
* 创建人信息
*/
......@@ -105,9 +108,12 @@ public Integer getTableType() {
public void setTableType(Integer tableType) {
this.tableType = tableType;
}
public Integer getDisplayNums() {
return displayNums;
}
public void setDisplayNums(Integer displayNums) {
this.displayNums = displayNums;
}
}
......@@ -14,7 +14,7 @@ public class FormsAttributeQueryRequest extends CodeAndNameQueryRequest {
private String formName;
private List<Root> rootList;
private String json;
public String getId() {
return id;
}
......@@ -63,5 +63,4 @@ public class FormsAttributeQueryRequest extends CodeAndNameQueryRequest {
this.json = json;
}
}
}
......@@ -10,6 +10,7 @@ public class SafFormsQueryRequest extends CodeAndNameQueryRequest {
private String formNo;
private String formName;
private int tableType;
private int existAttachment;
public String getId() {
return id;
......@@ -51,4 +52,11 @@ public class SafFormsQueryRequest extends CodeAndNameQueryRequest {
this.tableType = tableType;
}
public int getExistAttachment() {
return existAttachment;
}
public void setExistAttachment(int existAttachment) {
this.existAttachment = existAttachment;
}
}
......@@ -64,6 +64,9 @@ public class Options {
private int gutter;
private String justify;
private boolean responsive;
private String bizCode; //文件附件Code
private String bizId; //文件附件ID
public void setWidth(String width) {
this.width = width;
......@@ -357,9 +360,24 @@ public class Options {
public void setResponsive(boolean responsive) {
this.responsive = responsive;
}
//********************888
public String getBizCode() {
return bizCode;
}
public void setBizCode(String bizCode) {
this.bizCode = bizCode;
}
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
//********************888
}
\ No newline at end of file
package com.huigou.uasp.form.pojo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.huigou.uasp.form.model.ueform.field.FormField;
import com.huigou.uasp.util.Utils;
public class UeForm_old {
private Integer form_id ;// int primary key auto_increment ,
private String form_name;// varchar(255),
private String table_name;// varchar(255),
private String template;// text , 原始页面过来的编辑页面
private String html; //解析过可以review的html代码 跑
private String data ;//text ,
private String parse;// text , 解析过的 可以做为view的代码
private Integer fields;// int ,
//private String add_fields;// text
private Date crtime ;
private Date modify_time ;
public Integer getForm_id() {
return form_id;
}
public void setForm_id(Integer form_id) {
this.form_id = form_id;
}
public String getForm_name() {
return form_name;
}
public void setForm_name(String form_name) {
this.form_name = form_name;
}
public String getTable_name() {
return table_name;
}
public void setTable_name(String table_name) {
this.table_name = table_name;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public String getParse() {
return parse;
}
public void setParse(String parse) {
this.parse = parse;
}
public Integer getFields() {
return fields;
}
public void setFields(Integer fields) {
this.fields = fields;
}
public Date getCrtime() {
return crtime;
}
public void setCrtime(Date crtime) {
this.crtime = crtime;
}
public Date getModify_time() {
return modify_time;
}
public void setModify_time(Date modify_time) {
this.modify_time = modify_time;
}
public String getHtml() {
if(html.contains("{|-"))
html = html.replace("{|-", "").replace("-|}", "");
return html;
}
public void setHtml(String html) {
this.html = html;
}
public static UeForm_old praseTemplate(String template) {
UeForm_old form = new UeForm_old();
String preg = "(\\|-<span(((?!<span).)*leipiplugins=\"(radios|checkboxs|select)\".*?)>(.*?)<\\/span>-\\||<(img|input|textarea|select).*?(<\\/select>|<\\/textarea>|\\/>))";
String _html = template.replace("{|-", "").replace("-|}", "");
String _parse = _html ;
//template=template.replace("单选框","");
//template=template.replace("复选框","");
template=template.replace("<a class=\"btn btn-link\">","");
template=template.replace("</a>","");
List<FormField> fs = new ArrayList<>();
String[] ms = Utils.maches(template, preg);
for(String m : ms) {
FormField ff = FormField.parseText(m);
fs.add(ff);
if(ff.getLeipiplugins().equals("listctrl") || ff.getLeipiplugins().equals("select") || ff.getLeipiplugins().equals("datepicker")
|| ff.getLeipiplugins().equals("radios") || ff.getLeipiplugins().equals("checkboxs")) {
//要替换listctrl
String content = ff.getEdit(ff.getValue());
_html = _html.replace(ff.getContent(), content);
}
String _f_parse = ff.getView(ff.getValue());
if(_f_parse != null)
_parse = _parse.replace(ff.getContent(), _f_parse);
}
form.setForm_fields(fs);
form.setData(JSON.toJSONString(fs));
form.setFields(fs.size());
form.setParse(_parse);
form.setTemplate(template);
form.setHtml(_html);
return form ;
}
public String getEdit(String value) {
String _temp = getTemplate().replace("{|-", "").replace("-|}", "");
if(value == null) return _temp;
JSONObject jsonObjet = JSON.parseObject(value);
List<FormField> ffs = getForm_fields();
for(FormField ff : ffs) {
String ff_value = jsonObjet.getString(ff.getName());
String ff_view = ff.getEdit(ff_value);
_temp = _temp.replace(ff.getContent(), ff_view);
}
return _temp;
}
/**
* 视图页面展示
* @param value 后台保存的当前form的值 json
* @return 页面html代码
*/
public String getView(String value) {
if(value == null) return getParse();
String _temp = getTemplate().replace("{|-", "").replace("-|}", "");
JSONObject jsonObjet = JSON.parseObject(value);
List<FormField> ffs = getForm_fields() ;
for(FormField ff : ffs) {
String ff_value = jsonObjet.getString(ff.getName());
String ff_view = ff.getView(ff_value);
_temp = _temp.replace(ff.getContent(), ff_view);
}
return _temp;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
private List<FormField> form_fields ;
public void setForm_fields(List<FormField> form_fields) {
this.form_fields = form_fields;
}
public List<FormField> getForm_fields() {
if(data != null && (form_fields == null)) {
List<FormField> list = JSON.parseArray(data , FormField.class);
form_fields = new ArrayList<>();
for(FormField ff : list) {
ff = FormField.parseText(ff.getContent());
form_fields.add(ff);
}
}
return form_fields;
}
}
......@@ -159,11 +159,11 @@ public class PublicAnalysis {
DynaProperty[] tabdynaProperties = bean.getDynaClass().getDynaProperties();
for (int e = 0; e < tabdynaProperties.length; e++) {
attrName = tabdynaProperties[e].getName();// 属性名称
attrVal = bean.get(attrName);// 属性值
attrVal = bean.get(attrName);// 属性值
if (attrVal != null && !"null".equals(attrVal.toString().trim())) {
if (ReflectionUtil.getSetMethod(object.getClass(), attrName) != null) {
if ("defaultValue".equals(attrName)) { // 多个地方同属性 但类型不一致
System.out.println("========s");
System.out.println("PublicAnalysis========s");
} else {
ReflectionUtil.invokeSet(object, attrName, attrVal);
}
......
......@@ -11,7 +11,8 @@ import com.huigou.uasp.form.domain.model.FormParameter;
public interface FormParameterRepository extends JpaRepository<FormParameter, String>{
List<FormParameter> findByFormNo(String formNo,int parmType);
@Query("from FormParameter s where s.formNo=?1 and s.parmType=?2 ")
List<FormParameter> findByFormNoAndParmType(String formNo,int parmType);
@Modifying
@Query("delete from FormParameter u WHERE u.formNo=?1 and u.parmType=?2")
......
......@@ -148,7 +148,10 @@ public class OperatorUIElementPermissionBuilderImp implements OperatorUIElementP
.stream()
.map(formField -> {
Map<String, Object> permission = new HashMap<>();
permission.put("operationId", flowElementFieldPermission.getValue());
Arrays.stream(StringUtils.trimToEmpty((String) flowElementFieldPermission.getValue()).split(","))
// 如果存在多个 operationId,则取第一个operationId
.findFirst()
.ifPresent(operationId -> permission.put("operationId", operationId));
permission.put("code", flowElementFieldPermission.getKey());
permission.put("formFieldId", formField.getId());
return permission;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment