添加web中APP流程配置功能

This commit is contained in:
yexuan 2018-06-20 15:07:08 +08:00
parent 92ab093abe
commit 4814b6b128
6 changed files with 567 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<%@ page contentType="text/html; charset=GBK"%><%@
include file="/Frame/resources/include/include_begin_list.jspf"%><%
ASObjectModel doTemp = new ASObjectModel("APP_FLOW_LIST");
doTemp.setLockCount(2); //锁定两列
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //设置为Grid风格
dwTemp.ReadOnly = "1";//编辑模式
dwTemp.setPageSize(10);
dwTemp.ConvertCode2Title = "1";
dwTemp.genHTMLObjectWindow("");
String sButtons[][] = {
{"true","","Button","导入新流程","导入新流程","importNewFlow()","","","","btn_icon_add"},
{"true","","Button","取消流程","取消流程","delFlow()","","","","btn_icon_delete"},
{"true","","Button","流程配置","流程配置","configureFlow()","","","","btn_icon_workflow"},
};
%>
<%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function importNewFlow() {
AsDialog.selectCatalogDialog("SelectFlow", "", "", function(sReturn) {
if (typeof (sReturn) == "undefined" || sReturn.length == 0)
return;
sReturn = sReturn.split("@");
var FlowNo = sReturn[0];
var sResult = AsControl.RunJavaMethodTrans("com.amarsoft.app.check.AppFlow","checkFlowByFlowNo","flowNo="+FlowNo);
alert(sResult);
reloadSelf();
});
}
function delFlow() {
var flowno = getItemValue(0, getRow(), "flowno");
if (typeof (flowno) == "undefined" || flowno.length == 0) {
alert("请选择一条流程记录");
return;
}
var sResult = AsControl.RunJavaMethodTrans("com.amarsoft.app.check.AppFlow",
"DelFlowByFlowNo","flowNo="+flowno);
alert(sResult);
reloadSelf();
}
function configureFlow() {
var flowno = getItemValue(0, getRow(), "flowno");
if (typeof (flowno) == "undefined" || flowno.length == 0) {
alert("请选择一条流程记录");
return;
}
var sUrl = "/AppConfig/AppFlow/CatalogList.jsp";
AsControl.OpenTab(sUrl,"flowNo="+flowno,{title:"手机流程阶段配置"});
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,50 @@
<%@ page contentType="text/html; charset=GBK"%><%@
include file="/Frame/resources/include/include_begin_info.jspf"%><%
//获得参数
String flowNo = CurPage.getParameter("flowNo");
String phaseNo = CurPage.getParameter("phaseNo");
if (flowNo == null) flowNo = "";
if (phaseNo == null) phaseNo = "";
String id = CurPage.getParameter("id");
if (id == null) id = "";
String sUserID = CurPage.getParameter("UserID");
if (sUserID == null) sUserID = "";
java.util.Date dateNow = new java.util.Date();
SimpleDateFormat sdfTemp = new SimpleDateFormat("yyyy/MM/dd");
String date = sdfTemp.format(dateNow);
ASObjectModel doTemp = new ASObjectModel("APP_PRD_CATALOG_INFO");
doTemp.setDefaultValue("FLOWNO", flowNo);
doTemp.setReadOnly("FLOWNO", true);
if (!"".equals(phaseNo)) {
doTemp.setReadOnly("PHASENO", true);
} else {
doTemp.setReadOnly("PHASENO", false);
}
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2"; //设置DW风格 1:Grid 2:Freeform
dwTemp.ReadOnly = "0"; //设置是否只读 1:只读 0:可写
dwTemp.genHTMLObjectWindow(id);
String sButtons[][] = {
{"true", "All", "Button", "保存","保存所有修改", "saveRecord()", "", "", "", "btn_icon_save"},
{"true", "All", "Button", "关闭","关闭", "goBack()", "", "", "", "btn_icon_close"},
};
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
function goBack(){
parent.AsDialog.ClosePage();
}
function saveRecord(sPostEvents) {
as_save("myiframe0", "goBack()");
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,63 @@
<%@ page contentType="text/html; charset=GBK"%><%@
include file="/Frame/resources/include/include_begin_list.jspf"%><%
String flowNo = CurPage.getParameter("flowNo");
if (null == flowNo) flowNo = "";
ASObjectModel doTemp = new ASObjectModel("APP_PRD_CATALOG_LIST");
doTemp.setLockCount(2); //锁定两列
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //设置为Grid风格
dwTemp.ReadOnly = "1";//编辑模式
dwTemp.setPageSize(10);
dwTemp.ConvertCode2Title = "1";
dwTemp.genHTMLObjectWindow(flowNo);
String sButtons[][] = {
{"true","","Button","新增阶段","新增阶段","newRecord()","","","","btn_icon_add"},
{"true","","Button","取消阶段","取消阶段",
"if(confirm('确实要删除吗?'))as_delete(0,'')","","","","btn_icon_delete"},
{"true","","Button","编辑阶段","编辑阶段","viewAndEdit()","","","","btn_icon_edit"},
{"true","","Button","页签配置","页签配置","middleConfig()","","","","btn_icon_workflow"},
};
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function newRecord() {
var flowNo = getItemValue(0, getRow(0), 'flowno');
var phaseNo = "";
var sUrl = "/AppConfig/AppFlow/CatalogInfo.jsp";
AsDialog.PopView(sUrl, "flowNo="+flowNo+"&phaseNo="+phaseNo, "dialogWidth=600px;dialogHeight=450px;",
function(message) {
reloadSelf();
}, "新增阶段");
}
function viewAndEdit() {
var sUrl = "/AppConfig/AppFlow/CatalogInfo.jsp";
var id = getItemValue(0, getRow(0), 'id');
if (id == "" || typeof(id) == "undefined") {
alert("请选择一条阶段!");
return false;
}
var flowNo = getItemValue(0, getRow(0), 'flowno');
var phaseNo = getItemValue(0, getRow(0), 'phaseno');
AsDialog.PopView(sUrl, "id=" + id + "&flowNo="+flowNo+"&phaseNo="+phaseNo,
"dialogWidth=600px;dialogHeight=450px;", function(message) {
reloadSelf();
}, "编辑阶段");
}
function middleConfig() {
var id = getItemValue(0, getRow(0), 'id');
if (id == "" || typeof(id) == "undefined") {
alert("请选择一条阶段!");
return false;
}
var flowNo = getItemValue(0, getRow(0), 'flowno');
var phaseNo = getItemValue(0, getRow(0), 'phaseno');
var sUrl = "/AppConfig/AppFlow/MiddleList.jsp";
AsControl.OpenTab(sUrl,"id="+id + "&flowNo="+flowNo+"&phaseNo="+phaseNo, {title:"流程页签配置"});
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,39 @@
<%@ page contentType="text/html; charset=GBK"%><%@
include file="/Frame/resources/include/include_begin_info.jspf"%><%
//获得参数
String catalogId = CurPage.getParameter("catalogId");
String libraryId = CurPage.getParameter("libraryId");
if (catalogId == null) catalogId = "";
if (libraryId == null) libraryId = "";
String sUserID = CurPage.getParameter("UserID");
if (sUserID == null) sUserID = "";
java.util.Date dateNow = new java.util.Date();
SimpleDateFormat sdfTemp = new SimpleDateFormat("yyyy/MM/dd");
String date = sdfTemp.format(dateNow);
ASObjectModel doTemp = new ASObjectModel("APP_MIDDLE_INFO");
if (!"".equals(catalogId)) doTemp.setDefaultValue("APP_NODE_CATALOG_ID", catalogId);
if (!"".equals(libraryId)) doTemp.setDefaultValue("APP_NODE_LIBRARY_ID", libraryId);
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2"; //设置DW风格 1:Grid 2:Freeform
dwTemp.ReadOnly = "0"; //设置是否只读 1:只读 0:可写
dwTemp.genHTMLObjectWindow(catalogId+","+libraryId);
String sButtons[][] = {
{"true", "All", "Button", "保存","保存所有修改", "saveRecord()", "", "", "", "btn_icon_save"}
};
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
function goBack(){
parent.AsDialog.ClosePage();
}
function saveRecord() {
as_save("myiframe0", "goBack()");
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,68 @@
<%@ page contentType="text/html; charset=GBK"%><%@
include file="/Frame/resources/include/include_begin_list.jspf"%><%
String id = CurPage.getParameter("id");
String flowNo = CurPage.getParameter("flowNo");
String phaseNo = CurPage.getParameter("phaseNo");
if (id == null) id = "";
if (null == flowNo) flowNo = "";
if (phaseNo == null) phaseNo = "";
String sUserID = CurPage.getParameter("UserID");
if (sUserID == null) sUserID = "";
ASObjectModel doTemp = new ASObjectModel("APP_MIDDLE_LIST");
doTemp.setLockCount(2); //锁定两列
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //设置为Grid风格
dwTemp.ReadOnly = "1";//编辑模式
dwTemp.setPageSize(10);
dwTemp.ConvertCode2Title = "1";
dwTemp.genHTMLObjectWindow(id);
String sButtons[][] = {
{"true","","Button","新增页签","新增页签","newRecord()","","","","btn_icon_add"},
{"true","","Button","取消页签","取消页签",
"if(confirm('确实要删除吗?'))as_delete(0,'')","","","","btn_icon_delete"},
{"true","","Button","编辑页签","编辑页签","viewAndEdit()","","","","btn_icon_edit"}
};
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function newRecord() {
var catalogId = "<%=id%>"
var libraryId = "";
AsDialog.selectCatalogDialog("AppPageLibraryList", "", "", function(sReturn) {
if (typeof (sReturn) == "undefined" || sReturn.length == 0)
return;
sReturn = sReturn.split("@");
libraryId = sReturn[0];
var sUrl = "/AppConfig/AppFlow/MiddleInfo.jsp";
AsDialog.PopView(sUrl, "catalogId="+catalogId + "&libraryId="+libraryId, "dialogWidth=600px;dialogHeight=450px;",
function(message) {
reloadSelf();
}, "新增页签");
});
}
function viewAndEdit() {
var sUrl = "/AppConfig/AppFlow/MiddleInfo.jsp";
var catalogId = "<%=id%>"
var libraryId = getItemValue(0, getRow(0), 'APP_NODE_LIBRARY_ID');
if (catalogId == "" || typeof (catalogId) == "undefined") {
alert("请选择一条页签!");
return false;
}
if (libraryId == "" || typeof (libraryId) == "undefined") {
alert("请选择一条页签!");
return false;
}
AsDialog.PopView(sUrl, "catalogId=" + catalogId + "&libraryId="
+ libraryId, "dialogWidth=600px;dialogHeight=450px;", function(
message) {
reloadSelf();
}, "编辑页签");
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -0,0 +1,291 @@
package com.amarsoft.app.check;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Random;
import jbo.app.APP_BUSINESS_GROUP;
import jbo.app.APP_BUSINESS_TEMPLATE;
import jbo.app.PRD_NODEINFO_CATALOG_APP;
import jbo.app.PRD_NODEINFO_MIDDLE_APP;
import jbo.awe.AWE_DO_CATALOG;
import jbo.sys.FLOW_MODEL;
import com.amarsoft.are.ARE;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.BizObjectQuery;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.reckon.util.UUIDUtil;
public class AppFlow {
private String groupCode;
private String groupName;
private String isList;
private String dono;
public String getGroupCode() {
return groupCode;
}
public void setGroupCode(String groupCode) {
this.groupCode = groupCode;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getIsList() {
return isList;
}
public void setIsList(String isList) {
this.isList = isList;
}
public String getDono() {
return dono;
}
public void setDono(String dono) {
this.dono = dono;
}
public String generateRandomNumber() {
java.util.Date dateNow = new java.util.Date();
SimpleDateFormat sdfTemp1 = new SimpleDateFormat("yyyy");
SimpleDateFormat sdfTemp2 = new SimpleDateFormat("MM");
SimpleDateFormat sdfTemp3 = new SimpleDateFormat("dd");
SimpleDateFormat sdfTemp4 = new SimpleDateFormat("HH");
SimpleDateFormat sdfTemp5 = new SimpleDateFormat("mm");
String date1 = sdfTemp1.format(dateNow);
String date2 = sdfTemp2.format(dateNow);
String date3 = sdfTemp3.format(dateNow);
String date4 = sdfTemp4.format(dateNow);
String date5 = sdfTemp5.format(dateNow);
Random r = new Random();
int i = r.nextInt(10000) + 1;
String str = String.valueOf(i);
str = date1 + "" + date2 + "" + date3 + "" + date4 + "" + date5 + ""
+ "R" + str;
ARE.getLog().debug(str);
return str;
}
public String delDonoGroup(JBOTransaction tx) throws Exception {
BizObjectManager groupManage = JBOFactory
.getBizObjectManager(APP_BUSINESS_GROUP.CLASS_NAME);
BizObjectManager templateManage = JBOFactory
.getBizObjectManager(APP_BUSINESS_TEMPLATE.CLASS_NAME);
tx.join(groupManage);
tx.join(templateManage);
BizObject groupBo = groupManage.createQuery("GROUP_CODE=:GROUP_CODE")
.setParameter("GROUP_CODE", this.groupCode)
.getSingleResult(true);
List<BizObject> templateBos = templateManage
.createQuery("GROUP_CODE=:GROUP_CODE")
.setParameter("GROUP_CODE", this.groupCode).getResultList(true);
if (null != groupBo) {
groupManage.deleteObject(groupBo);
tx.commit();
}
if (templateBos.size() > 0) {
for (BizObject templateBo : templateBos) {
templateManage.deleteObject(templateBo);
tx.commit();
}
}
return "操作成功!";
}
public String importDonoGroup(JBOTransaction tx) throws Exception {
BizObjectManager doManage = JBOFactory
.getBizObjectManager(AWE_DO_CATALOG.CLASS_NAME);
BizObject doBo = doManage.createQuery("dono=:dono")
.setParameter("dono", this.dono).getSingleResult(false);
if (null == doBo)
return "fail@" + this.dono + "模板号无效,请填写正确的模板号!";
String doName = doBo.getAttribute("doName") == null ? "" : doBo
.getAttribute("doName").toString();
this.groupCode = this.dono + "" + generateRandomNumber();
this.groupName = this.groupName == null ? doName : this.groupName;
BizObjectManager groupManage = JBOFactory
.getBizObjectManager(APP_BUSINESS_GROUP.CLASS_NAME);
BizObjectManager templateManage = JBOFactory
.getBizObjectManager(APP_BUSINESS_TEMPLATE.CLASS_NAME);
tx.join(groupManage);
tx.join(templateManage);
BizObject groupBo = groupManage.createQuery("GROUP_CODE=:GROUP_CODE")
.setParameter("GROUP_CODE", this.groupCode)
.getSingleResult(true);
List<BizObject> templateBos = templateManage
.createQuery("GROUP_CODE=:GROUP_CODE")
.setParameter("GROUP_CODE", this.groupCode).getResultList(true);
if (null != groupBo) {
groupManage.deleteObject(groupBo);
tx.commit();
}
if (templateBos.size() > 0) {
for (BizObject templateBo : templateBos) {
templateManage.deleteObject(templateBo);
tx.commit();
}
}
groupBo = groupManage.newObject();
groupBo.setAttributeValue("GROUP_CODE", this.groupCode);
groupBo.setAttributeValue("GROUP_NAME", this.groupName);
groupBo.setAttributeValue("ISLIST", this.isList);
groupBo.setAttributeValue("GROUP_POSITION", "400000");
groupBo.setAttributeValue("GROUP_ENABLE", "Y");
groupManage.saveObject(groupBo);
tx.commit();
BizObjectManager libraryManage = JBOFactory
.getBizObjectManager(jbo.app.AWE_DO_LIBRARY.CLASS_NAME);
List<BizObject> libraryBos = libraryManage.createQuery("dono=:dono")
.setParameter("dono", this.dono).getResultList(false);
for (BizObject libraryBo : libraryBos) {
BizObject templateBo = templateManage.newObject();
// 绑定参数
templateBo.setAttributeValue("DONO", this.dono);
templateBo.setAttributeValue("COLINDEX",
libraryBo.getAttribute("COLINDEX").getValue());
templateBo.setAttributeValue("SORTNO",
libraryBo.getAttribute("SORTNO").getValue());
templateBo.setAttributeValue("COLNAME",
libraryBo.getAttribute("COLNAME").getValue());
// 主键外键
templateBo.setAttributeValue("GROUP_CODE", this.groupCode);
templateBo.setAttributeValue("DATA_CODE",
libraryBo.getAttribute("COLNAME").getValue());
// 显示配置参数
templateBo.setAttributeValue("DATA_NAME",
libraryBo.getAttribute("COLHEADER").getValue());
templateBo.setAttributeValue("ISLIST", this.isList);
templateBo.setAttributeValue("ISSHOW", "Y");
templateBo.setAttributeValue("DATA_POSITION", libraryBo
.getAttribute("SORTNO").getInt());
templateManage.saveObject(templateBo);
tx.commit();
}
return "success@" + this.groupCode + "分组保存成功!";
}
private String flowNo;
public String getFlowNo() {
return flowNo;
}
public void setFlowNo(String flowNo) {
this.flowNo = flowNo;
}
public String checkFlowByFlowNo(JBOTransaction tx) throws Exception {
try {
BizObjectManager bom = JBOFactory
.getBizObjectManager(PRD_NODEINFO_CATALOG_APP.CLASS_NAME);
BizObjectQuery boq = bom.createQuery("FLOWNO=:FLOWNO")
.setParameter("FLOWNO", flowNo);
BizObject bo = boq.getSingleResult(false);
if (null != bo) {
return "流程已导入, 可进入流程详情进行编辑!";
} else {
BizObjectManager fmManage = JBOFactory
.getBizObjectManager(FLOW_MODEL.CLASS_NAME);
BizObjectManager pManage = JBOFactory
.getBizObjectManager(PRD_NODEINFO_CATALOG_APP.CLASS_NAME);
BizObjectQuery fmQuery = fmManage.createQuery("flowno=:flowno")
.setParameter("flowno", flowNo);
List<BizObject> fms = fmQuery.getResultList(false);
tx.join(pManage);
for (BizObject fm : fms) {
BizObject p = pManage.newObject();
String uuid = UUIDUtil.getUUID();
p.setAttributeValue("id", uuid);
p.setAttributeValue("flowno", flowNo);
p.setAttributeValue("phaseno", fm.getAttribute("phaseno"));
p.setAttributeValue("config_type", "Project");
p.setAttributeValue("config_display", "APP流程详情");
p.setAttributeValue("ENABLE_OPERATION", "N");
p.setAttributeValue("SORTNO", fm.getAttribute("phaseno"));
pManage.saveObject(p);
tx.commit();
}
return "流程导入成功!";
}
} catch (Exception e) {
ARE.getLog().error(e);
tx.rollback();
return "流程导入失败,请联系管理员:" + e;
}
}
public String DelFlowByFlowNo(JBOTransaction tx) throws Exception {
try {
BizObjectManager bom = JBOFactory
.getBizObjectManager(PRD_NODEINFO_CATALOG_APP.CLASS_NAME);
tx.join(bom);
BizObjectQuery boq = bom.createQuery("FLOWNO=:FLOWNO")
.setParameter("FLOWNO", flowNo);
List<BizObject> bos = boq.getResultList(true);
if (bos.size() == 0) {
return "请选择一条流程记录!";
} else {
String ids = "";
for (BizObject bo : bos) {
String id = bo.getAttribute("id") == null ? "" : bo
.getAttribute("id").toString();
ids += "'" + id + "',";
}
if (ids.length() > 1) {
ids = ids.substring(0, ids.length() - 1);
}
BizObjectManager middleManage = JBOFactory
.getBizObjectManager(PRD_NODEINFO_MIDDLE_APP.CLASS_NAME);
List<BizObject> middles = middleManage.createQuery(
"APP_NODE_CATALOG_ID in (" + ids + ")").getResultList(
false);
if (middles.size() > 0) {
return "此流程尚有页签未取消,无法删除!";
}
boq = bom.createQuery("DELETE FROM O WHERE FLOWNO=:FLOWNO")
.setParameter("FLOWNO", flowNo);
boq.executeUpdate();
tx.commit();
return "流程取消成功!";
}
} catch (Exception e) {
ARE.getLog().error(e);
tx.rollback();
return "流程取消失败,请联系管理员:" + e;
}
}
}