From 4814b6b128034eb5b30f8a55973297747839232a Mon Sep 17 00:00:00 2001 From: yexuan Date: Wed, 20 Jun 2018 15:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0web=E4=B8=ADAPP=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppConfig/AppFlow/AppFlowCatalogList.jsp | 56 ++++ WebContent/AppConfig/AppFlow/CatalogInfo.jsp | 50 +++ WebContent/AppConfig/AppFlow/CatalogList.jsp | 63 ++++ WebContent/AppConfig/AppFlow/MiddleInfo.jsp | 39 +++ WebContent/AppConfig/AppFlow/MiddleList.jsp | 68 ++++ src/com/amarsoft/app/check/AppFlow.java | 291 ++++++++++++++++++ 6 files changed, 567 insertions(+) create mode 100644 WebContent/AppConfig/AppFlow/AppFlowCatalogList.jsp create mode 100644 WebContent/AppConfig/AppFlow/CatalogInfo.jsp create mode 100644 WebContent/AppConfig/AppFlow/CatalogList.jsp create mode 100644 WebContent/AppConfig/AppFlow/MiddleInfo.jsp create mode 100644 WebContent/AppConfig/AppFlow/MiddleList.jsp create mode 100644 src/com/amarsoft/app/check/AppFlow.java diff --git a/WebContent/AppConfig/AppFlow/AppFlowCatalogList.jsp b/WebContent/AppConfig/AppFlow/AppFlowCatalogList.jsp new file mode 100644 index 000000000..04bcae831 --- /dev/null +++ b/WebContent/AppConfig/AppFlow/AppFlowCatalogList.jsp @@ -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"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/AppConfig/AppFlow/CatalogInfo.jsp b/WebContent/AppConfig/AppFlow/CatalogInfo.jsp new file mode 100644 index 000000000..46759e044 --- /dev/null +++ b/WebContent/AppConfig/AppFlow/CatalogInfo.jsp @@ -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"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/AppConfig/AppFlow/CatalogList.jsp b/WebContent/AppConfig/AppFlow/CatalogList.jsp new file mode 100644 index 000000000..9b81e6d41 --- /dev/null +++ b/WebContent/AppConfig/AppFlow/CatalogList.jsp @@ -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"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/AppConfig/AppFlow/MiddleInfo.jsp b/WebContent/AppConfig/AppFlow/MiddleInfo.jsp new file mode 100644 index 000000000..a73af8036 --- /dev/null +++ b/WebContent/AppConfig/AppFlow/MiddleInfo.jsp @@ -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"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> diff --git a/WebContent/AppConfig/AppFlow/MiddleList.jsp b/WebContent/AppConfig/AppFlow/MiddleList.jsp new file mode 100644 index 000000000..607aa6e06 --- /dev/null +++ b/WebContent/AppConfig/AppFlow/MiddleList.jsp @@ -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"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/src/com/amarsoft/app/check/AppFlow.java b/src/com/amarsoft/app/check/AppFlow.java new file mode 100644 index 000000000..5a4ef8b9a --- /dev/null +++ b/src/com/amarsoft/app/check/AppFlow.java @@ -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 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 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 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 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 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 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; + } + } +}