From 64792581d0724f58ecdaecc6b8b8c671be6472b0 Mon Sep 17 00:00:00 2001 From: wangpf <1305001440@qq.com> Date: Wed, 14 Jun 2023 18:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E6=A8=A1=E5=AF=BC=E5=BC=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../96e935b1-0c70-47a3-8dbf-b3745569da1a.xml | 192 + .../obj_c98aadf656124adb895fbde7831db455.xml | 67 + .../8b4d5d27-f539-4c5b-a62c-4a342974fae6.xml | 45 + .../obj_c4b68176b3084b63a57461d17f3d76b6.bpmn | 54 + .../obj_c4b68176b3084b63a57461d17f3d76b6.draw | 1 + ...c4b68176b3084b63a57461d17f3d76b6_small.png | Bin 0 -> 1612 bytes .../template/form/发布流程-建模导引配置.htm | 74 + .../template/form/发布流程-建模导引配置_m.htm | 55 + .../apps/coe/pal/CoEPALController.java | 39 + .../web/DesignerRelationShapeWeb.java | 7476 +++++++++-------- .../template/page/carousel.map.html | 298 + .../page/pal.pl.repository.designer.htm | 182 +- .../js/coe.team.pal.designer.js | 9 +- .../designer/extend/css/designer.extend.css | 6 + .../lib/designer/extend/css/driver.min.css | 224 + .../lib/designer/extend/images/guide.png | Bin 0 -> 553 bytes .../lib/designer/extend/js/driver.min.js | 2 + 17 files changed, 5050 insertions(+), 3674 deletions(-) create mode 100644 com.actionsoft.apps.coe.pal.publisher/repository/bo/_96e935b1-0c70-47a3-8dbf-b3745569da1a/96e935b1-0c70-47a3-8dbf-b3745569da1a.xml create mode 100644 com.actionsoft.apps.coe.pal.publisher/repository/dw/_obj_c98aadf656124adb895fbde7831db455/obj_c98aadf656124adb895fbde7831db455.xml create mode 100644 com.actionsoft.apps.coe.pal.publisher/repository/form/_8b4d5d27-f539-4c5b-a62c-4a342974fae6/8b4d5d27-f539-4c5b-a62c-4a342974fae6.xml create mode 100644 com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.bpmn create mode 100644 com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.draw create mode 100644 com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6_small.png create mode 100644 com.actionsoft.apps.coe.pal.publisher/template/form/发布流程-建模导引配置.htm create mode 100644 com.actionsoft.apps.coe.pal.publisher/template/form/发布流程-建模导引配置_m.htm create mode 100644 com.actionsoft.apps.coe.pal/template/page/carousel.map.html create mode 100644 com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/css/driver.min.css create mode 100644 com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/images/guide.png create mode 100644 com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/driver.min.js diff --git a/com.actionsoft.apps.coe.pal.publisher/repository/bo/_96e935b1-0c70-47a3-8dbf-b3745569da1a/96e935b1-0c70-47a3-8dbf-b3745569da1a.xml b/com.actionsoft.apps.coe.pal.publisher/repository/bo/_96e935b1-0c70-47a3-8dbf-b3745569da1a/96e935b1-0c70-47a3-8dbf-b3745569da1a.xml new file mode 100644 index 00000000..a83bf72a --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/repository/bo/_96e935b1-0c70-47a3-8dbf-b3745569da1a/96e935b1-0c70-47a3-8dbf-b3745569da1a.xml @@ -0,0 +1,192 @@ + + + 96e935b1-0c70-47a3-8dbf-b3745569da1a + admin + 2023-06-09 18:34:25 + admin + 2023-06-14 17:22:15 + tGOmxiTgjT/77UoYpSlq8Vc+hHPRoJWHdZexXc7zEpYuMNdhvSICeJnlc/RzRHGrrMQnexzcl6CxfJE6ovERtQKwZhm7WRQ+MjFcOQROC/JnMGBoVrNr/nfsXV1uTYPG + false + 建模导引配置 + BO_ACT_PAL_MODELING_GUIDANCE + false + false + false + 发布流程 + admin + TABLE + + + 0 + _local + + + + f12c09be-4789-4bb8-991f-3b26a41ad958 + STEP + 步骤 + TEXT + 64 + false + + 100 + AWSUI.ComboBox + {"placeholder":"","boItemId":"96e935b1-0c70-47a3-8dbf-b3745569da1a","isAdvance":false,"dataType":"sampleText","data":"0:第1步|1:第2步|2:第3步|3:第4步|4:第5步|5:第6步|6:第7步","mode":"common","exportDataValidity":true,"setunival":true,"boUrlFormData":{"hrefSelVal":"nothing"}} + true + false + true + + ENTITY + + + + 0 + + false + + + {} + + + 7606a3c9-06be-4624-815d-af53947e9ef1 + MODELTYPE + 模型类型 + TEXT + 64 + false + + 60 + AWSUI.ComboBox + {"placeholder":"","boItemId":"96e935b1-0c70-47a3-8dbf-b3745569da1a","isAdvance":false,"dataType":"sampleText","data":"process.epc:EPC|process.flowchart:泳道图|control.policy:制度图|data.form:表单图|","mode":"common","exportDataValidity":true,"setunival":true,"boUrlFormData":{"hrefSelVal":"nothing"}} + true + false + true + + ENTITY + + + + 0 + + false + + + {} + + + 6dd4ce3c-742d-4629-9975-f945ebfd28ad + CONTENT + 导引内容 + BIGTEXT + 2000 + false + + 100 + AWSUI.File + {"isEncrypt":true,"manualSort":false,"fileCount":"0","fileClassificationList":"","fileWatermark":"","fileWatermarkFont":"","fileWatermarkFontColor":"","sortField":"CREATEDATE","sortType":"asc","compressFlag":"","waterMarkFlag":"","waterMarkPosition":"","waterMarkFontColor":"","waterMarkFontSize":30,"fileMaxSize":"199","uploadField":"上传人|CREATEUSER||false,上传时间|CREATEDATE||false,大小|FILESIZE||false,授权|AUTHORIZATION||false,预览|PREVIEW||false","anyFile":true,"uiSetting":{"anyFileExtList":""},"canPreviewOfficeFlag":"0"} + true + false + true + + ENTITY + + + + 0 + 1.视频支持mp4格式 +2.图片支持png,gif,jpg格式 + false + + + {} + + + 353c50c6-9996-443d-9cc0-75f676147b81 + TITLE + 标题 + TEXT + 64 + false + + 60 + AWSUI.Text + {"search":"0"} + true + false + true + + ENTITY + + + + 0 + + false + + + {} + + + 082b0dde-e7cb-4d6a-8f3f-f8fc61f73d72 + POSITION + 位置 + TEXT + 32 + false + + 60 + AWSUI.ComboBox + {"placeholder":"","boItemId":"96e935b1-0c70-47a3-8dbf-b3745569da1a","isAdvance":false,"dataType":"sampleText","data":"left:左|right:右|top:上|bottom:下","mode":"common","exportDataValidity":true,"setunival":true,"boUrlFormData":{"hrefSelVal":"nothing"}} + true + false + true + + ENTITY + + + + 0 + + false + + + {} + + + 20e03d57-7919-4d1b-8c55-326be89637d5 + GUIDETARGET + 导引作用对象 + TEXT + 32 + false + + 60 + AWSUI.Text + {"search":"0"} + true + false + true + + ENTITY + + + + 0 + + false + + + {} + + + + + 2b872c94-7725-4211-81a7-a6f29d9d2424 + AWS_IN_40A3C81D6927 + INDEX + BINDID + + + + + diff --git a/com.actionsoft.apps.coe.pal.publisher/repository/dw/_obj_c98aadf656124adb895fbde7831db455/obj_c98aadf656124adb895fbde7831db455.xml b/com.actionsoft.apps.coe.pal.publisher/repository/dw/_obj_c98aadf656124adb895fbde7831db455/obj_c98aadf656124adb895fbde7831db455.xml new file mode 100644 index 00000000..c8ee98ad --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/repository/dw/_obj_c98aadf656124adb895fbde7831db455/obj_c98aadf656124adb895fbde7831db455.xml @@ -0,0 +1,67 @@ + + + obj_c98aadf656124adb895fbde7831db455 + admin + 2023-06-09 18:52:09 + admin + 2023-06-14 17:21:43 + tGOmxiTgjT/77UoYpSlq8Vc+hHPRoJWHdZexXc7zEpYuMNdhvSICeJnlc/RzRHGr0hHBVIqN8dYTSvqefQg5v1yTv9SYZtHkvK6cZTaJ+UTpIOHlBvl4rTHI3yz7JQzr + false + 1.0 + obj_c98aadf656124adb895fbde7831db455 + + 发布流程 + 1 + admin + + <dataView id="obj_2796db900d084e52b4cbff8b491b0cbc" label="首页" showType="link" orderIndex="0" dwReportType="-1" isDefault="false" category="普通视图" implClassName="com.actionsoft.bpms.dw.design.dataview.CommonDataView" security="" event="" url="" userExtendJs="" show="true"> + <showHighSecurity>false</showHighSecurity> + <dataParams></dataParams> + <layoutECategoryType></layoutECategoryType> + <layoutECategoryTypeLast></layoutECategoryTypeLast> + <afterLoadEventCall></afterLoadEventCall> + <afterLoadEventScript></afterLoadEventScript> + <toolbar id="obj_eb542e28119342c1bf885356ad910293" isshow="true" extendcode="" event=""> + <button id="obj_d0cce9c8ebc344eb91436f89c54f0f1e" refbuttonid="save" cls="" fontColor="" bgColor="" security="" isshow="true" orderindex="0" mobileShow="false" event="" selectShow="false"/> + <button id="obj_0d8e1c4436e34fcb81f34111527a2cbd" refbuttonid="new" cls="" fontColor="" bgColor="" security="" isshow="true" orderindex="1" mobileShow="false" event="" selectShow="false"/> + <button id="obj_0d88916af4704adcaa9af5b66cb94a00" refbuttonid="delete" cls="" fontColor="" bgColor="" security="" isshow="false" orderindex="2" mobileShow="false" event="" selectShow="true"/> + <button id="obj_d138b8dd4827477d8bf39bcabfe1f658" refbuttonid="print" cls="" fontColor="" bgColor="" security="" isshow="true" orderindex="3" mobileShow="false" event="" selectShow="false"/> + <button id="obj_5239a445698044f68f3bd47c12b8df0c" refbuttonid="refresh" cls="" fontColor="" bgColor="" security="" isshow="true" orderindex="4" mobileShow="false" event="" selectShow="false"/> + <button id="obj_cebcaabdeb3c4e85a2ba5643b231ca21" refbuttonid="exportDWData" cls="" fontColor="" bgColor="" security="" isshow="true" orderindex="5" mobileShow="false" event="" selectShow="false"/> + <button id="obj_b5483fdb06a645448f3a5f8b47bdfa90" refbuttonid="importDWData" cls="" fontColor="" bgColor="" security="" isshow="true" orderindex="6" config="[{"btnName":"","formDefId":"obj_c4b68176b3084b63a57461d17f3d76b6|8b4d5d27-f539-4c5b-a62c-4a342974fae6","formName":"建模导引配置","formExcelShowName":"建模导引配置","maxRow":"20000","javaEvents":[],"enableAddImport":true,"enableupdateimport":false,"requiredImport":false,"importStrategy":{"addImport":{"strategybase":"maintainable","boModels":[{"boDefName":"BO_ACT_PAL_MODELING_GUIDANCE","boItems":[{"name":"STEP","title":"步骤"},{"name":"MODELTYPE","title":"模型类型"},{"name":"TITLE","title":"标题"},{"name":"POSITION","title":"位置"},{"name":"GUIDETARGET","title":"导引作用对象"}]}]}}}]" mobileShow="false" event="" selectShow="false"/> + </toolbar> + <searcher id="obj_9f926ae4867f41cbbee58eaf9db46c87" isshow="true" layoutType="tile" tdGroup="4" tileLayout="y" textCls="" dwLeftCls="" dwRightCls="" extendcode="" event="" xconditionEvent="" tileOpen="false"/> + <navTree id="obj_ffc4fc43ad9a44acb6dc3cfd3ed63262" isshow="false" type="" rootcls="" leafcls="" ismultiple="false" isexpanded="true" orderindex="" event=""/> + <layout id="obj_ebaa922389c04e9cb09942d3320ce30f" label="" classname="com.actionsoft.bpms.dw.exec.layout.LayoutA" event=""/> + <datagrid id="obj_e1862a1c5f52428ca1d8cef938bc4857" isshow="true" autoSearch="true" customSet="true" select="false" datasource="bo:BO_ACT_PAL_MODELING_GUIDANCE" countSql="" pagesize="15" event="" rowDefHeight="25" showCheckBox="true" ismultiple="true" isshownumbercol="true" numberCellTotal="false" shownumbercolwidth="40px" freezeCols="0" wrap="false" nowrapTitle="false" refbehaviorid="|_title{}title_||||" behaviortarget="" behaviorConfig="%7B%22behavior%22%3A%22%22%2C%22behaviorMobile%22%3A%22%22%2C%22h%22%3A%22%22%2C%22hUnit%22%3A%22px%22%2C%22ih%22%3A%22%22%2C%22ihUnit%22%3A%22px%22%2C%22isMask%22%3A0%2C%22sw%22%3A%22%22%2C%22swUnit%22%3A%22px%22%2C%22target%22%3A%22%22%2C%22title%22%3A%22%22%2C%22wUnit%22%3A%22px%22%2C%22w%22%3A%22%22%7D" extendsql="" identifier="_ID" extend1="" multiHeader=""> + <dataBaseConn></dataBaseConn> + <freezeField></freezeField> + <column id="obj_070dd64b65654cacad98c6d8bf9bd67d" sort="asc" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="162" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="64" required="0" align="left" showrule="{"type":"NORMAL","cons":"0:第1步|1:第2步|2:第3步|3:第4步|4:第5步|5:第6步|6:第7步","showAdv":true}" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="STEP" label="步骤" orderindex="0" colbehaviortarget="tab" ishidden="false" export="true" backHide="false" isusedvalue="false" tableheadsort="true" colrefbehaviorid="openmodifyform" columnAction="" datatype="TEXT" handleType="0" boType="AWSUI.ComboBox" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="ca1c9366-f64d-43f7-8e4d-6219187ac555" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="155" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="16" required="1" align="left" showrule="{"type":"NORMAL","cons":"process.epc:EPC|process.flowchart:泳道图|control.policy:制度图|data.form:表单图","showAdv":true}" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="MODELTYPE" label="模型类型" orderindex="1" colbehaviortarget="" ishidden="false" export="true" backHide="false" isusedvalue="false" tableheadsort="true" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="0" boType="AWSUI.ComboBox" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="75346837-90c1-4177-af82-5ddb7f372c24" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="113" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="32" required="1" align="left" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="TITLE" label="标题" orderindex="2" colbehaviortarget="" ishidden="false" export="true" backHide="false" isusedvalue="false" tableheadsort="true" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="0" boType="AWSUI.Text" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="7a7a9d03-15fa-47b4-95cc-07b205036a9e" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="150" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="16" required="1" align="left" showrule="{"type":"NORMAL","cons":"left:左|right:右|top:上|bottom:下","showAdv":true}" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="POSITION" label="位置" orderindex="3" colbehaviortarget="" ishidden="false" export="true" backHide="false" isusedvalue="false" tableheadsort="true" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="0" boType="AWSUI.ComboBox" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="f2daa8f5-551f-4286-80b3-89ed95c26e98" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="150" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="32" required="1" align="left" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="GUIDETARGET" label="导引作用对象" orderindex="4" colbehaviortarget="" ishidden="false" export="true" backHide="false" isusedvalue="false" tableheadsort="true" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="0" boType="AWSUI.Text" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_958273b27be5443aa924289d6c75d1d2" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="197" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="2000" required="0" align="left" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="CONTENT" label="导引内容" orderindex="5" colbehaviortarget="" ishidden="false" export="true" backHide="false" isusedvalue="false" tableheadsort="true" colrefbehaviorid="" columnAction="" datatype="BIGTEXT" handleType="0" boType="AWSUI.File" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_cebe4ce3ea324f60821ec0e8d707e3be" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="120px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="36" required="0" align="left" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_ID" label="业务表ID" orderindex="6" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_61ca793ccbeb4eaa85ba802e0845788d" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="120px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="36" required="0" align="left" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_ORGID" label="单位ID" orderindex="7" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_4cfdb05a3366467bbfe926f12bb17012" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="120px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="36" required="0" align="left" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_BINDID" label="流程实例ID" orderindex="8" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_d481ab0a8fdc45d382872a556f0a4e95" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="135px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="19" required="0" align="center" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_CREATEDATE" label="创建日期" orderindex="9" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="DATE" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_c1338643212240969d27977a352dbfaa" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="120px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="36" required="0" align="left" showrule="{"type": "org","orgtype": "user"}" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_CREATEUSER" label="创建人" orderindex="10" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_fae0ce75da5641dd87beef1e4463ec3f" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="135px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="19" required="0" align="center" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_UPDATEDATE" label="更新日期" orderindex="11" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="DATE" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_3e3ff15d69284101acee46330cf048c8" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="120px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="36" required="0" align="left" showrule="{"type": "org","orgtype": "user"}" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_UPDATEUSER" label="更新人" orderindex="12" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="TEXT" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <column id="obj_36db752c35904905be20d7a7a5be3684" sort="" isfilter="false" bgcolor="" fontcolor="" fontsize="12px" width="120px" colALias="" colTableAlias="" colTable="BO_ACT_PAL_MODELING_GUIDANCE" length="1" required="0" align="right" showrule="" upshowrule="" upDataClassName="" extend1="" extend2="" security="" securityLevel="0" event="" field="_ISEND" label="流程是否结束" orderindex="13" colbehaviortarget="" ishidden="true" export="false" backHide="true" isusedvalue="true" tableheadsort="false" colrefbehaviorid="" columnAction="" datatype="NUMBER" handleType="1" boType="" count="false" countType="" colorFullNote="false" colorFullNoteMap=""/> + <dynamicRule></dynamicRule> + </datagrid> + <reportSetting></reportSetting> + <chartSetting></chartSetting> + </dataView> + <userextendbuttons/> + <userextendbehaviors> + <userextendbehavior id="openmodifyform" name=""> + <templatecall>onclick%3D</templatecall> + <templatescript></templatescript> + </userextendbehavior> + </userextendbehaviors> + <iconFontCode></iconFontCode> + <iconFontColor></iconFontColor> +</AWSDWModel> diff --git a/com.actionsoft.apps.coe.pal.publisher/repository/form/_8b4d5d27-f539-4c5b-a62c-4a342974fae6/8b4d5d27-f539-4c5b-a62c-4a342974fae6.xml b/com.actionsoft.apps.coe.pal.publisher/repository/form/_8b4d5d27-f539-4c5b-a62c-4a342974fae6/8b4d5d27-f539-4c5b-a62c-4a342974fae6.xml new file mode 100644 index 00000000..2beb9a47 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/repository/form/_8b4d5d27-f539-4c5b-a62c-4a342974fae6/8b4d5d27-f539-4c5b-a62c-4a342974fae6.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<formModel> + <id>8b4d5d27-f539-4c5b-a62c-4a342974fae6</id> + <createUser>admin</createUser> + <createTime>2023-06-09 18:49:46</createTime> + <updateUser>admin</updateUser> + <updateTime>2023-06-14 14:30:12</updateTime> + <signature>tGOmxiTgjT/77UoYpSlq8Vc+hHPRoJWHdZexXc7zEpYuMNdhvSICeJnlc/RzRHGr55kp5e0k4Z5XyR4z5p3R/+XA2ehXxsaOtH+gsvMyNRftHQoyfjo/8Cnmdjw1qLHH</signature> + <managed>false</managed> + <title>建模导引配置 + false + 发布流程 + admin + + + + + + + b6933764-f10a-45ae-9898-aa9b081554c5 + 建模导引配置 + {"tablet":"发布流程-建模导引配置.htm","pc":"发布流程-建模导引配置.htm","mobile":"发布流程-建模导引配置_m.htm"} + false + + + 0 + 96e935b1-0c70-47a3-8dbf-b3745569da1a + + false + {"pc":"_bpm.platform","mobile":"_bpm.platform"} + + {"pc":"scheme_aws.css","mobile":""} + + + + + + + + + false + false + + + diff --git a/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.bpmn b/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.bpmn new file mode 100644 index 00000000..b325bf93 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.bpmn @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + {"multiSelectDisabledCheckBox":true,"includeSelf":true,"ignoreOptionVal":"auto","isHistoryRoute":true,"routeType":"com.actionsoft.bpms.commons.performer.impl.user.DynamicUsers","multiSelect":true,"ignoreOptions":""} + + + + + + + + + + + + + + + + + + + + + userTask + + + + + + {"orientation":"vertical","fontFamily":"Arial","color":"50,50,50","size":13,"textAlign":"center","underline":false,"bold":false,"italic":false,"vAlign":"middle"} + {"lineStyle":"solid","lineColor":"0,100,0","lineWidth":2} + [{"name":"Name","id":"_c5e431a09e8000019667a030a612172c","category":"default","type":"string","value":""},{"name":"documentation","id":"_c5e431a09e800001a51b1ad665702f80","category":"default","type":"string","value":""},{"name":"AWSProperties","id":"_c5e431a09e800001e350169f14944c00","category":"default","type":"string","value":""},{"listItems":["","StandardLoopCharacteristics","MultipleLoopCharacteristics"],"name":"loopCharacteristics","id":"_c5e431a09e8000011134166057601c8d","category":"default","type":"list","value":""},{"name":"isSequantial","id":"_c5e431a09e80000179f9bc834a226940","category":"default","type":"boolean","value":"true"},{"name":"isForCompensation","id":"_c5e431a09e8000013df09cc0b50010f9","category":"default","type":"boolean","value":"false"},{"name":"renderings","id":"_c5e431a09e80000198201540eeb0cf70","category":"default","type":"string","value":""},{"name":"implementation","id":"_c5e431a09e8000012e3c1f101730a630","category":"default","type":"string","value":""},{"name":"resources","id":"_c5e431a09e900001ce78702013301212","category":"default","type":"string","value":""},{"name":"ioSpecification","id":"_c5e431a09e900001b62b10196bf81699","category":"default","type":"string","value":""},{"name":"dataInputAssociations","id":"_c5e431a09e900001f6305df0112f1b79","category":"default","type":"string","value":""},{"name":"dataOutputAssociations","id":"_c5e431a09e900001b9e91930bd0c1f9c","category":"default","type":"string","value":""}] + + + + + + + + + + \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.draw b/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.draw new file mode 100644 index 00000000..6228b6e6 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6.draw @@ -0,0 +1 @@ +{"versionId":"obj_c4b68176b3084b63a57461d17f3d76b6","chartId":"obj_c4b68176b3084b63a57461d17f3d76b6","userIds":["admin"],"messages":[],"userNames":"管理员","remark":"","updateTime":"2023-06-09 18:52:09","definitionId":"obj_c4b68176b3084b63a57461d17f3d76b6"} \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6_small.png b/com.actionsoft.apps.coe.pal.publisher/repository/process/obj_c4b68176b3084b63a57461d17f3d76b6/obj_c4b68176b3084b63a57461d17f3d76b6_small.png new file mode 100644 index 0000000000000000000000000000000000000000..7e8fd210d20716fc963098a9b3ff4e2d0ba75692 GIT binary patch literal 1612 zcmcgtdpOf;9N)#Z+^Ppz=9Gt{9J#E^I&%pVa&+MwPSjkxt>iLg7_rf9WFF^~EFnuS zk6a^SwmMM}$xj<=F4YiQE|JY;E1jQG=XuUQ=fCrOp7-{=&-?japU<1}tGlbF8b%EQ zfoQt@;_L~oQ{ZS_0R!iQ>y-!y1gY)j?D#viccRZXIpY|lMa=VjX1>*2ErU>%dg*X? zx4b^K4L4?{6UgDmvPAZ&LFmgc{@S{M*IrGo@JF4#1QpS{;6n2gtzUg$@8@o@SY)d zx%~>z6mj)A3l$OG;zvOi{(u;NW6CJ4-+SR*Uac-KVz;=gDdizX9T+l?BeWo8$?2N{ z-Iz6!3tlkJUP7nhq~MwdBW>a6ybOLT@#1zQTj+;jMV4aid&mO={v*-hF9n-J+RG|t z8fOFfk#8IBl=}xhf!pk2H&!;_>_^utsBc=kf3)=D{K2*Fy1bT0lil)lt&2|3!{%rK z(~yMEJ(Fp4W@kgsqNuEPteq;(NJL^zuv4LN^2gKGtl?}fwIyktDe#r{3EL;PGGVv| z>YqvBL=zizBy?KaXTs|`S<%hx_gQBoj_m!X*$n#2PjA(=J$<7|;})qlD+7cvV~ZAI z;X@5TJUcA9(lIN|3GERGqc23T!iCm}Hsqr}OE@n=WB zpU<9K|AE$tre*n6?I&H0+o5dZrt5?*<V9zDX8;gJ9kUGQPglV-DKy|5ULHR=YKrikJuYFQwpq4Q!wu;I8Q2vV$&Tuo z!w8JT4Ekxj#MCD&O0S*9aJRcLGssk0W6l0Tl5fLoEZL=(b{e1C2oOFyuu(i8`Lm~- zCaipAE;oDW9^-&hFrLiW-w^G*tDh8@HC;a5uC|$d z1g>}$Q=0h^R~w}ML*%O>I)2nE-=Lvay;ubYyxqngQc*|^iixu2uHlU226${2`pUor zYJ!PF!(~?-1is&{pN${wVK-ZZ7srR!LDxH&5xOAH(MC zoi7mctlilgKp^g_EF&><8M=VhGX7KWmPGFh&HqRB%_kV~UotG+B*WMLG + + + + + 建模导引配置 + + + + + + [#AWSImport] + [#AWSUIImport] + + + + + +
+
+ + + + + + + + + + + + +
建模导引配置
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
[#STEP]
模型类型[#MODELTYPE]
标题[#TITLE]
位置[#POSITION]
导引作用对象[#GUIDETARGET]
[#CONTENT]
+
[#Actionsoft]
+
+
+ + \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal.publisher/template/form/发布流程-建模导引配置_m.htm b/com.actionsoft.apps.coe.pal.publisher/template/form/发布流程-建模导引配置_m.htm new file mode 100644 index 00000000..e22ac7c5 --- /dev/null +++ b/com.actionsoft.apps.coe.pal.publisher/template/form/发布流程-建模导引配置_m.htm @@ -0,0 +1,55 @@ + + + + + + + 建模导引配置 + + + + + + [#AWSImport] + [#AWSUIImport] + + + + + +
+ +
+ + + + + + + + + + + + +
+ + + + + + +
[#STEP]
[#CONTENT]
+
[#Actionsoft]
+
+
+ + \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java index 57fd9e72..f220fa1c 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java @@ -3546,4 +3546,43 @@ public class CoEPALController { return web.deleteLeadRearRelationData(uuid, data); } + + /** + * 获得建模导引前端页面 + * + * @param me me + * @return {@link String} + */ + @Mapping("com.actionsoft.apps.coe.pal_modeling_guide") + public String getModelingGuide(UserContext me , String methodId , String sid) { + DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(me); + return web.getModelingGuide(methodId, sid); + } + + /** + * 获得建模导引前端页面 + * + * @param me me + * @return {@link String} + */ + @Mapping("com.actionsoft.apps.coe.pal_guide_carousel") + public String getModelingGuideCarousel(UserContext me , String step , String modelType) { + DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(me); + return web.getModelingGuideCarousel(step , modelType); + } + + /** + * 检查用户是否第一次创建模型 + * + * @param me me + * @param methodId 模型类型 + * @return {@link String} + */ + @Mapping("com.actionsoft.apps.coe.pal_guide_check_create") + public String checkUserFirstCreateModel(UserContext me , String methodId ) { + DesignerRelationShapeWeb web = new DesignerRelationShapeWeb(me); + return web.checkUserFirstCreateModel(methodId); + } + + } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java index 09a0c301..7b0818cf 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/designer/relation/web/DesignerRelationShapeWeb.java @@ -11,6 +11,7 @@ import com.actionsoft.apps.coe.pal.cooperation.CoeCooperationAPIManager; import com.actionsoft.apps.coe.pal.cooperation.cache.CooperationCache; import com.actionsoft.apps.coe.pal.cooperation.cache.model.TeamInfo; import com.actionsoft.apps.coe.pal.cooperation.cache.model.UserInfo; +import com.actionsoft.apps.coe.pal.pal.manage.publish.constant.PublishConst; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.manager.DesignerShapeCopyCache; @@ -19,8 +20,10 @@ import com.actionsoft.apps.coe.pal.pal.repository.web.CoeProcessLevelWeb; import com.actionsoft.apps.coe.pal.system.util.StringUtil; import com.actionsoft.apps.coe.pal.util.BpmOrgUtil; import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; +import com.actionsoft.bpms.bo.engine.BO; import com.actionsoft.bpms.commons.cache.Cache; import com.actionsoft.bpms.commons.database.RowMap; +import com.actionsoft.bpms.commons.formfile.model.delegate.FormFile; import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate; import com.actionsoft.bpms.commons.mvc.view.ActionWeb; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; @@ -34,6 +37,8 @@ import com.actionsoft.bpms.org.cache.UserCache; import com.actionsoft.bpms.org.model.*; import com.actionsoft.bpms.org.web.CompanyWeb; import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.server.fs.DCContext; +import com.actionsoft.bpms.server.fs.dc.DCProfileManager; import com.actionsoft.bpms.util.*; import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodJsonModel; @@ -71,1060 +76,1057 @@ import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang.StringUtils; public class DesignerRelationShapeWeb extends ActionWeb { - private UserContext _uc; + private UserContext _uc; - public DesignerRelationShapeWeb(UserContext uc) { - super(uc); - _uc = uc; - } - - /** - * 复制时将不同用户复制的数据缓存到服务器上 - * - * @param userId 用户id - * @param clientId 客户端id - * @param subject 复制文件的UUID - * @param type 类型 - * @param ver 版本 - * @param shapeId 图形 id - * @param messageJson 存缓存的图形信息 - * @return - */ - public String respositoryDesignerRelationShapeCopy(String userId, String clientId, String subject, String type, String ver, String shapeId, String messageJson, String shapeGroupId) { - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = relationShapeCache.getShapemap(); - List elementList = ShapeUtil.getShapeList(messageJson); - boolean isAssigned = CoeProcessLevelUtil.hasAssigned(subject); - if (isAssigned) { - return "false"; - } - - Map relationShapeMap = shapeMap.get(userId); - if (relationShapeMap == null) { - relationShapeMap = new HashMap(); - } - relationShapeMap.put("shapeCopyContent", messageJson);// 将传过来的图形信息保存到缓存中 - relationShapeMap.put("shapeFileId", subject); - relationShapeMap.put("shapeTypeId", type); - relationShapeMap.put("shapeCopyTime", Long.valueOf(System.currentTimeMillis())); - - if (validationUser(shapeMap, userId)) {// 如果是同一用户,则将最后一次复制的内容更新到同一用户对应的缓存中 - shapeMap.put(userId, relationShapeMap); - } else {// 对应新连接的用户 - List list = new ArrayList(); - list.add(messageJson); - shapeMap.put(userId, relationShapeMap); - } - if (copyToDatabase(elementList, subject)) { - return "true"; - } else { - // 如何插入数据库失败则清空缓存中的数据 - relationShapeMap = shapeMap.get(userId); - relationShapeMap.put("shapeCopyContent", null);// 将传过来的图形信息保存到缓存中 - relationShapeMap.put("shapeFileId", null); - relationShapeMap.put("shapeTypeId", null); - relationShapeMap.put("shapeCopyTime", null); - shapeMap.put(userId, relationShapeMap); - return "false"; - } - } + public DesignerRelationShapeWeb(UserContext uc) { + super(uc); + _uc = uc; + } + + /** + * 复制时将不同用户复制的数据缓存到服务器上 + * + * @param userId 用户id + * @param clientId 客户端id + * @param subject 复制文件的UUID + * @param type 类型 + * @param ver 版本 + * @param shapeId 图形 id + * @param messageJson 存缓存的图形信息 + * @return + */ + public String respositoryDesignerRelationShapeCopy(String userId, String clientId, String subject, String type, String ver, String shapeId, String messageJson, String shapeGroupId) { + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = relationShapeCache.getShapemap(); + List elementList = ShapeUtil.getShapeList(messageJson); + boolean isAssigned = CoeProcessLevelUtil.hasAssigned(subject); + if (isAssigned) { + return "false"; + } + + Map relationShapeMap = shapeMap.get(userId); + if (relationShapeMap == null) { + relationShapeMap = new HashMap(); + } + relationShapeMap.put("shapeCopyContent", messageJson);// 将传过来的图形信息保存到缓存中 + relationShapeMap.put("shapeFileId", subject); + relationShapeMap.put("shapeTypeId", type); + relationShapeMap.put("shapeCopyTime", Long.valueOf(System.currentTimeMillis())); + + if (validationUser(shapeMap, userId)) {// 如果是同一用户,则将最后一次复制的内容更新到同一用户对应的缓存中 + shapeMap.put(userId, relationShapeMap); + } else {// 对应新连接的用户 + List list = new ArrayList(); + list.add(messageJson); + shapeMap.put(userId, relationShapeMap); + } + if (copyToDatabase(elementList, subject)) { + return "true"; + } else { + // 如何插入数据库失败则清空缓存中的数据 + relationShapeMap = shapeMap.get(userId); + relationShapeMap.put("shapeCopyContent", null);// 将传过来的图形信息保存到缓存中 + relationShapeMap.put("shapeFileId", null); + relationShapeMap.put("shapeTypeId", null); + relationShapeMap.put("shapeCopyTime", null); + shapeMap.put(userId, relationShapeMap); + return "false"; + } + } - /** - * 粘贴时请求由服务器返回的数据 - * - * @param userId 用户id - * @param clientId 客户端Id - * @param subject 文件id - * @param action 动作 - * @param type  类型 - * @param ver 版本 - * @return - */ - public String respositoryDesignerRelationShapePasteAjax(String userId, String clientId, String subject, String action, String type, String ver) { - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - // 得到用户缓存的数据 - Map> shapeMap = relationShapeCache.getShapemap(); - Map relationShapeMap = shapeMap.get(userId); - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject json = new JSONObject(); - PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(subject); - String shapeType = levelModel.getMethodId(); - if (relationShapeMap != null && validationUser(shapeMap, userId)) { - Object shapeCopyContent = relationShapeMap.get("shapeCopyContent");// 从缓存中取得对应用户的复制的图形信息 - Object shapeTypeId = relationShapeMap.get("shapeTypeId"); // 拿到复制的图形所属的文件类型,除bpmn外都可以粘贴 - levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance((String) shapeTypeId); - List elementList = null; - if (shapeCopyContent != null) { - elementList = ShapeUtil.getShapeList((String) shapeCopyContent); - } - if (validationPaste(shapeType, levelModel.getMethodId(), subject, elementList) && validationIsNotSameRepository((String) shapeTypeId, subject)) { - json.put("shape", (String) relationShapeMap.get("shapeCopyContent")); - json.put("result", "ok"); - } else { - json.put("result", "noShape"); - } - } else { - json.put("result", "error"); - } - ro.setData(json); - return ro.toString(); - } + /** + * 粘贴时请求由服务器返回的数据 + * + * @param userId 用户id + * @param clientId 客户端Id + * @param subject 文件id + * @param action 动作 + * @param type  类型 + * @param ver 版本 + * @return + */ + public String respositoryDesignerRelationShapePasteAjax(String userId, String clientId, String subject, String action, String type, String ver) { + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + // 得到用户缓存的数据 + Map> shapeMap = relationShapeCache.getShapemap(); + Map relationShapeMap = shapeMap.get(userId); + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(subject); + String shapeType = levelModel.getMethodId(); + if (relationShapeMap != null && validationUser(shapeMap, userId)) { + Object shapeCopyContent = relationShapeMap.get("shapeCopyContent");// 从缓存中取得对应用户的复制的图形信息 + Object shapeTypeId = relationShapeMap.get("shapeTypeId"); // 拿到复制的图形所属的文件类型,除bpmn外都可以粘贴 + levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance((String) shapeTypeId); + List elementList = null; + if (shapeCopyContent != null) { + elementList = ShapeUtil.getShapeList((String) shapeCopyContent); + } + if (validationPaste(shapeType, levelModel.getMethodId(), subject, elementList) && validationIsNotSameRepository((String) shapeTypeId, subject)) { + json.put("shape", (String) relationShapeMap.get("shapeCopyContent")); + json.put("result", "ok"); + } else { + json.put("result", "noShape"); + } + } else { + json.put("result", "error"); + } + ro.setData(json); + return ro.toString(); + } - /** - * 粘贴时存入数据库的操作 - * - * @param messageJson 对应的操作的图形的信息 - * @param subject 文件的id - * @return - */ - public String pasteToDatabse(String subject, String messageJson) { - // 粘贴时对缓存中的的图形的id进行更新 - List elementList = ShapeUtil.getShapeList(messageJson); - final List list = new ArrayList(); - for (int i = 0; i < elementList.size(); i++) { - JSONObject jsonObj = JSONObject.parseObject(elementList.get(i)); - DesignerShapePasteModel model = new DesignerShapePasteModel(); - model.setShapeId(jsonObj.getString("id")); - JSONArray jsonArr = JSONArray.parseArray(jsonObj.getString("dataAttributes")); - for (int j = 0; j < jsonArr.size(); j++) { - JSONObject jObj = JSONObject.parseObject(jsonArr.getString(j)); - String shapeGroupId = jObj.getString("shapeGroupId"); - if (null != shapeGroupId && !"".equals(shapeGroupId)) { - model.setShapeGroupId(shapeGroupId); - break; - } - } - model.setShapeMessage(elementList.get(i)); - model.setShapecategoryName(jsonObj.containsKey("category") ? jsonObj.getString("category") : ""); - model.setShapeName(jsonObj.getString("name")); - model.setIsPaste("Y"); - model.setPalRepositoryId(subject); - model.setShapeType(jsonObj.containsKey("title") ? jsonObj.getString("title") : ""); - model.setIsDelete("N"); - model.setShapeText(jsonObj.containsKey("text") ? jsonObj.getString("text") : ""); - list.add(model); - } - - new Thread(new Runnable() { - @Override - public void run() { - // 粘贴时对粘贴时的图形的之间的关系进行处理 - pasteChangeRelationShapes(list); - } - }).start(); - - return CoeProcessLevelDaoFacotory.createCoeProcessLevel().pasteToDatabse(list) + ""; - } + /** + * 粘贴时存入数据库的操作 + * + * @param messageJson 对应的操作的图形的信息 + * @param subject 文件的id + * @return + */ + public String pasteToDatabse(String subject, String messageJson) { + // 粘贴时对缓存中的的图形的id进行更新 + List elementList = ShapeUtil.getShapeList(messageJson); + final List list = new ArrayList(); + for (int i = 0; i < elementList.size(); i++) { + JSONObject jsonObj = JSONObject.parseObject(elementList.get(i)); + DesignerShapePasteModel model = new DesignerShapePasteModel(); + model.setShapeId(jsonObj.getString("id")); + JSONArray jsonArr = JSONArray.parseArray(jsonObj.getString("dataAttributes")); + for (int j = 0; j < jsonArr.size(); j++) { + JSONObject jObj = JSONObject.parseObject(jsonArr.getString(j)); + String shapeGroupId = jObj.getString("shapeGroupId"); + if (null != shapeGroupId && !"".equals(shapeGroupId)) { + model.setShapeGroupId(shapeGroupId); + break; + } + } + model.setShapeMessage(elementList.get(i)); + model.setShapecategoryName(jsonObj.containsKey("category") ? jsonObj.getString("category") : ""); + model.setShapeName(jsonObj.getString("name")); + model.setIsPaste("Y"); + model.setPalRepositoryId(subject); + model.setShapeType(jsonObj.containsKey("title") ? jsonObj.getString("title") : ""); + model.setIsDelete("N"); + model.setShapeText(jsonObj.containsKey("text") ? jsonObj.getString("text") : ""); + list.add(model); + } - /** - * 粘贴时关联关系的同步 - * - * 些方法的作用如下:比如对A图形进行复制,现在粘贴时图形为A派生出来的称为B,此时的B中的属性还有关联关系应该和A是完全一样的 - * - * - * @param list - */ - private void pasteChangeRelationShapes(List list) { - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - Map> userShapeMap = relationShapeCache.getShapemap(); - Map shapeMap = userShapeMap.get(_uc.getUID()); - - String copyMessageJson = (String) shapeMap.get("shapeCopyContent"); - JSONArray jsonArr = JSONArray.parseArray(copyMessageJson); - Map copyMessageMap = new HashMap(); - for (int i = 0; i < jsonArr.size(); i++) { - JSONObject messageObject = JSONObject.parseObject(jsonArr.getString(i)); - copyMessageMap.put(messageObject.getJSONArray("dataAttributes").getJSONObject(0).getString("shapeGroupId"), messageObject.getString("id")); - } - - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - for (DesignerShapePasteModel model : list) { - String shapeGroupId = model.getShapeGroupId(); - String copyShapeId = ""; - if (copyMessageMap.containsKey(shapeGroupId)) { - copyShapeId = copyMessageMap.get(shapeGroupId); - } - List copyShapeRelationModel = dao.getModelListByShapeId(copyShapeId); - for (DesignerShapeRelationModel copyRelationModel : copyShapeRelationModel) { - DesignerShapeRelationModel relationModel = new DesignerShapeRelationModel(); - relationModel.setId(UUIDGener.getUUID()); - relationModel.setFileId(model.getPalRepositoryId()); - relationModel.setShapeId(model.getShapeId()); - relationModel.setShapeText(model.getShapeText()); - relationModel.setAttrId(copyRelationModel.getAttrId()); - relationModel.setRelationFileId(copyRelationModel.getRelationFileId()); - relationModel.setRelationShapeId(copyRelationModel.getRelationShapeId()); - relationModel.setRelationShapeText(copyRelationModel.getRelationShapeText()); - dao.insert(relationModel); - } - } - } + new Thread(new Runnable() { + @Override + public void run() { + // 粘贴时对粘贴时的图形的之间的关系进行处理 + pasteChangeRelationShapes(list); + } + }).start(); - /** - * 判断当前这个文件是否可以粘贴被复制的图形,只有当当前的文件中存大更多图形并且已选择要粘贴的图形的类别时才能进行粘贴和解析,BPMN只能粘贴 - * 在BPMN中,不能粘贴到其它类别文件中 - * - * @param methodId 当前文件的methodId - * @param pasteMethodId 服务器上存在的这个要粘贴的图形的所属于的methodId - * @param subject 当前文件的UUID - * @return - */ - public boolean validationPaste(String methodId, String pasteMethodId, String subject, List elementList) { - if (elementList == null) { - return false; - } else { - Set set = new HashSet(); - int linkerCount = 0; - int textCount = 0; - for (String s : elementList) { - JSONObject jsonObj = JSONObject.parseObject(s); - if (jsonObj.containsKey("category")) { - set.add(jsonObj.getString("category").replace("_", ".")); - if("standard".equals(jsonObj.getString("category"))) { - textCount ++; - } - } - if (jsonObj.containsKey("name") && "linker".equals(jsonObj.getString("name"))) { - linkerCount ++; - } - } - if ((linkerCount + textCount) == elementList.size()) {// 只有箭头或插入的文本或者只包含这两者 - return true; - } - if (set.size() == 0) { - return false; - } - if (methodId.equals(pasteMethodId) || set.contains(methodId)) { - return true; - } else { - String methodIds = PALMethodUtil.getCustom(methodId, subject);// 得到当前这个文件所关联的图形methodID - if (!"".equals(methodIds)) { - String strs[] = methodIds.split(","); - for (String str : strs) { - if (str.equals(pasteMethodId) || set.contains(str)) - return true; - } - return false; - } else - return false; - } - } - } + return CoeProcessLevelDaoFacotory.createCoeProcessLevel().pasteToDatabse(list) + ""; + } - /** - * 校验是否是在同一资产库下,不能跨资产库复制和粘贴可以跨文件和浏览器,只限同一用户 - * - * @param pasteFileUUID 服务器上缓存中的文件ID - * @param TargetFileUUID 粘贴的目标的源文件的ID - * @return boolean - */ - public boolean validationIsNotSameRepository(String pasteFileUUID, String TargetFileUUID) { - PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(TargetFileUUID); - String targetWsID = levelModel.getWsId(); - levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(pasteFileUUID); - String pasteWsID = levelModel.getWsId(); - if (pasteWsID.equals(targetWsID)) { - return true; - } - return false; - } + /** + * 粘贴时关联关系的同步 + *

+ * 些方法的作用如下:比如对A图形进行复制,现在粘贴时图形为A派生出来的称为B,此时的B中的属性还有关联关系应该和A是完全一样的 + * + * @param list + */ + private void pasteChangeRelationShapes(List list) { + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> userShapeMap = relationShapeCache.getShapemap(); + Map shapeMap = userShapeMap.get(_uc.getUID()); - /** - * 判断是不是同一用户 - * - * @return - */ - public boolean validationUser(Map> shapeMap, String userId) { - if (!shapeMap.isEmpty()) { - Set set = shapeMap.keySet(); - for (String u : set) { - if (u.equals(userId)) {// 如果是同一用户,则将最后一次复制的内容更新到同一用户对应的缓存中 - return true; - } - } - } - return false; - } + String copyMessageJson = (String) shapeMap.get("shapeCopyContent"); + JSONArray jsonArr = JSONArray.parseArray(copyMessageJson); + Map copyMessageMap = new HashMap(); + for (int i = 0; i < jsonArr.size(); i++) { + JSONObject messageObject = JSONObject.parseObject(jsonArr.getString(i)); + copyMessageMap.put(messageObject.getJSONArray("dataAttributes").getJSONObject(0).getString("shapeGroupId"), messageObject.getString("id")); + } - /** - * 将第一次复制的数据插入到数据库 - * @param elementList - * @param subject - * @return - */ - public boolean copyToDatabase(List elementList, String subject) { - List list = new ArrayList(); - for (int i = 0; i < elementList.size(); i++) { - String messageJson = elementList.get(i); - JSONObject jsonObj = JSONObject.parseObject(messageJson); - // 对连线不作任何操作 - if ("linker".equals(jsonObj.getString("name"))) { - continue; - } - Map map = ShapeUtil.getIsCopy(messageJson); - String shapeGroupId = map.get("shapeGroupId"); - String isCopy = map.get("isCopy"); - if ("N".equals(isCopy)) { - continue; - } - DesignerShapeCopyModel model = new DesignerShapeCopyModel(); - model.setShapeId(jsonObj.getString("id")); - model.setShapeGroupId(shapeGroupId); - model.setShapeMessage(elementList.get(i)); - model.setShapecategoryName(jsonObj.getString("category")); - model.setShapeName(jsonObj.getString("name")); - model.setisCopy(isCopy); - model.setPalRepositoryId(subject); - model.setShapeType(jsonObj.getString("title")); - model.setIsDelete("N"); - list.add(model); - } - try { - return CoeProcessLevelDaoFacotory.createCoeProcessLevel().createShape(list); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + for (DesignerShapePasteModel model : list) { + String shapeGroupId = model.getShapeGroupId(); + String copyShapeId = ""; + if (copyMessageMap.containsKey(shapeGroupId)) { + copyShapeId = copyMessageMap.get(shapeGroupId); + } + List copyShapeRelationModel = dao.getModelListByShapeId(copyShapeId); + for (DesignerShapeRelationModel copyRelationModel : copyShapeRelationModel) { + DesignerShapeRelationModel relationModel = new DesignerShapeRelationModel(); + relationModel.setId(UUIDGener.getUUID()); + relationModel.setFileId(model.getPalRepositoryId()); + relationModel.setShapeId(model.getShapeId()); + relationModel.setShapeText(model.getShapeText()); + relationModel.setAttrId(copyRelationModel.getAttrId()); + relationModel.setRelationFileId(copyRelationModel.getRelationFileId()); + relationModel.setRelationShapeId(copyRelationModel.getRelationShapeId()); + relationModel.setRelationShapeText(copyRelationModel.getRelationShapeText()); + dao.insert(relationModel); + } + } + } - /** - * 改变出现复制的图形的名称或属性,对出现复制的图形的名称和属性进行同步,如: - * 对A图形进行复制派生出B那改变B或者A时两者的名称和属性应该是同步的并有相同的属性和名称 - * @param jsonObj - * @param uuid - */ - public void updateShapes(JSONObject jsonObj, String uuid) { - // JSONObject jsonObj = JSONObject.fromObject(messages); - JSONArray jsonArr1 = jsonObj.getJSONArray("updates"); - DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - Map> map = event.getEventMap(); - // 只针对单个 图形进行操作 - if (jsonArr1.size() > 1) { - event.setFlag(false); - return; - } - JSONObject jsonObj2 = jsonArr1.getJSONObject(0); - if (!jsonObj2.containsKey("anchors")) { - event.setFlag(false); - return; - } - String name = jsonObj2.getString("text"); - String id = jsonObj2.getString("id"); - if (map != null) { - Set l = map.get(uuid); - if (l != null) { - // 如果名称或属性没有什么变化,只是改变改图形的位置、连线什么的, 则不会唤醒正在阻塞的http长连接的线程 - for (JSONObject jsonObject : l) { - if (id.equals(jsonObject.getString("id")) && name.equals(jsonObject.getString("text")) && isTheSame(jsonObj2.getJSONArray("dataAttributes"), jsonObject.getJSONArray("dataAttributes"))) { - event.setFlag(false); - return; - } - } - } else { - // 否则唤醒正在等待的http长连接的线程 - event.setFlag(false); - } - } - } + /** + * 判断当前这个文件是否可以粘贴被复制的图形,只有当当前的文件中存大更多图形并且已选择要粘贴的图形的类别时才能进行粘贴和解析,BPMN只能粘贴 + * 在BPMN中,不能粘贴到其它类别文件中 + * + * @param methodId 当前文件的methodId + * @param pasteMethodId 服务器上存在的这个要粘贴的图形的所属于的methodId + * @param subject 当前文件的UUID + * @return + */ + public boolean validationPaste(String methodId, String pasteMethodId, String subject, List elementList) { + if (elementList == null) { + return false; + } else { + Set set = new HashSet(); + int linkerCount = 0; + int textCount = 0; + for (String s : elementList) { + JSONObject jsonObj = JSONObject.parseObject(s); + if (jsonObj.containsKey("category")) { + set.add(jsonObj.getString("category").replace("_", ".")); + if ("standard".equals(jsonObj.getString("category"))) { + textCount++; + } + } + if (jsonObj.containsKey("name") && "linker".equals(jsonObj.getString("name"))) { + linkerCount++; + } + } + if ((linkerCount + textCount) == elementList.size()) {// 只有箭头或插入的文本或者只包含这两者 + return true; + } + if (set.size() == 0) { + return false; + } + if (methodId.equals(pasteMethodId) || set.contains(methodId)) { + return true; + } else { + String methodIds = PALMethodUtil.getCustom(methodId, subject);// 得到当前这个文件所关联的图形methodID + if (!"".equals(methodIds)) { + String strs[] = methodIds.split(","); + for (String str : strs) { + if (str.equals(pasteMethodId) || set.contains(str)) + return true; + } + return false; + } else + return false; + } + } + } - /** - * 更新复制副本的内容 - * - * @param shapeGroupId 组id - * @param title 标题 - * @param text 文本 - * @param jsonDataArr 属性数据 - */ - private void updateShapeCache(String shapeGroupId, String title, String text, JSONArray jsonDataArr) { - DesignerRelationShapeCacheManager cache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = cache.getShapemap(); - Set key = shapeMap.keySet(); - for (String k : key) { - Map relationShapeMap = shapeMap.get(k); - String messageJson = (String) relationShapeMap.get("shapeCopyContent"); - if (messageJson != null) { - JSONArray jArr = JSONArray.parseArray(messageJson); - for (int i = 0; i < jArr.size(); i++) { - JSONObject shape = jArr.getJSONObject(i); - if (!"linker".equals(shape.get("name")) && shape.get("dataAttributes") != null) { - JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); - for (int j = 0; j < dataAttributes.size(); j++) { - JSONObject attr = dataAttributes.getJSONObject(j); - if (attr.containsKey("attributesContent") && attr.containsKey("shapeGroupId") && shapeGroupId.equals(attr.get("shapeGroupId"))) { - if (shapeGroupId.equals(attr.get("shapeGroupId"))) { - shape.put("text", text); - shape.put("title", title); - shape.put("dataAttributes", jsonDataArr); - relationShapeMap.put("shapeCopyContent", jArr.toString()); - return; - } - } - } + /** + * 校验是否是在同一资产库下,不能跨资产库复制和粘贴可以跨文件和浏览器,只限同一用户 + * + * @param pasteFileUUID 服务器上缓存中的文件ID + * @param TargetFileUUID 粘贴的目标的源文件的ID + * @return boolean + */ + public boolean validationIsNotSameRepository(String pasteFileUUID, String TargetFileUUID) { + PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(TargetFileUUID); + String targetWsID = levelModel.getWsId(); + levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(pasteFileUUID); + String pasteWsID = levelModel.getWsId(); + if (pasteWsID.equals(targetWsID)) { + return true; + } + return false; + } - } - } - } - } - } + /** + * 判断是不是同一用户 + * + * @return + */ + public boolean validationUser(Map> shapeMap, String userId) { + if (!shapeMap.isEmpty()) { + Set set = shapeMap.keySet(); + for (String u : set) { + if (u.equals(userId)) {// 如果是同一用户,则将最后一次复制的内容更新到同一用户对应的缓存中 + return true; + } + } + } + return false; + } - /** - * 判断新的数据和旧的数据是否相同 - * fastjson - * - * @param dataAttributes1 - * @param dataAttributes2 - * @return - */ - private boolean isTheSame(JSONArray dataAttributes1, JSONArray dataAttributes2) { - String attributesContent = ""; - String linksArray = ""; - String privateAttribute = ""; - String attributesJsonArray = ""; - String privateAttributeContent = ""; - String shapeDesc = ""; - String upFilesArray = ""; - String relevanceShapes = ""; - for (int i = 0; i < dataAttributes1.size(); i++) { - JSONObject attr = dataAttributes1.getJSONObject(i); - if (attr.containsKey("attributesContent")) { - attributesContent = attr.getString("attributesContent"); - linksArray = attr.getJSONArray("linksArray").toString(); - attributesJsonArray = attr.getJSONArray("attributesJsonArray").toString(); - privateAttribute = attr.getString("privateAttribute"); - privateAttributeContent = attr.getString("privateAttributeContent"); - shapeDesc = attr.getString("shapeDesc"); - if (attr.containsKey("upFilesArray")) { - upFilesArray = attr.getJSONArray("upFilesArray").toString(); - } - if (attr.containsKey("relevanceShapes")) { - relevanceShapes = attr.getJSONArray("relevanceShapes").toString(); - } - } - } - String attributesContent1 = ""; - String linksArray1 = ""; - String privateAttribute1 = ""; - String attributesJsonArray1 = ""; - String privateAttributeContent1 = ""; - String shapeDesc1 = ""; - String upFilesArray1 = ""; - String relevanceShapes1 = ""; - for (int i = 0; i < dataAttributes2.size(); i++) { - JSONObject attr = dataAttributes2.getJSONObject(i); - if (attr.containsKey("attributesContent")) { - attributesContent1 = attr.getString("attributesContent"); - linksArray1 = attr.getJSONArray("linksArray").toString(); - attributesJsonArray1 = attr.getJSONArray("attributesJsonArray").toString(); - privateAttribute1 = attr.getString("privateAttribute"); - privateAttributeContent1 = attr.getString("privateAttributeContent"); - shapeDesc1 = attr.getString("shapeDesc"); - if (attr.containsKey("upFilesArray")) { - upFilesArray1 = attr.getJSONArray("upFilesArray").toString(); - } - if (attr.containsKey("relevanceShapes")) { - relevanceShapes1 = attr.getJSONArray("relevanceShapes").toString(); - } - } - } - if (relevanceShapes1.equals(relevanceShapes) && attributesContent1.equals(attributesContent) && linksArray1.equals(linksArray) && attributesJsonArray1.equals(attributesJsonArray) && privateAttribute1.equals(privateAttribute) && privateAttributeContent1.equals(privateAttributeContent) && shapeDesc1.equals(shapeDesc) && upFilesArray1.equals(upFilesArray)) { - return true; - } - return false; - } + /** + * 将第一次复制的数据插入到数据库 + * + * @param elementList + * @param subject + * @return + */ + public boolean copyToDatabase(List elementList, String subject) { + List list = new ArrayList(); + for (int i = 0; i < elementList.size(); i++) { + String messageJson = elementList.get(i); + JSONObject jsonObj = JSONObject.parseObject(messageJson); + // 对连线不作任何操作 + if ("linker".equals(jsonObj.getString("name"))) { + continue; + } + Map map = ShapeUtil.getIsCopy(messageJson); + String shapeGroupId = map.get("shapeGroupId"); + String isCopy = map.get("isCopy"); + if ("N".equals(isCopy)) { + continue; + } + DesignerShapeCopyModel model = new DesignerShapeCopyModel(); + model.setShapeId(jsonObj.getString("id")); + model.setShapeGroupId(shapeGroupId); + model.setShapeMessage(elementList.get(i)); + model.setShapecategoryName(jsonObj.getString("category")); + model.setShapeName(jsonObj.getString("name")); + model.setisCopy(isCopy); + model.setPalRepositoryId(subject); + model.setShapeType(jsonObj.getString("title")); + model.setIsDelete("N"); + list.add(model); + } + try { + return CoeProcessLevelDaoFacotory.createCoeProcessLevel().createShape(list); + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } - /** - * 更新出现复制过的文件的的信息 - * - * @param fileIdList - * @throws UnsupportedEncodingException - */ - private void updateFile(Set> fileIdList, final String shapeGroupId, final String title, final String text, final JSONArray jsonDataArr, final Map> map) throws UnsupportedEncodingException { - DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - Map uuidSet = event.getUuidSet(); - final Set set = new HashSet(); - for (Map fileMap : fileIdList) {// 快速响应已经打开的文件 - String uuid = fileMap.get("palRepositoryId"); - if (uuidSet.containsKey(uuid)) { - PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - String filePath = levelModel.getFilePath(); - UtilFile utilFile = new UtilFile(filePath); - File[] file = utilFile.listFiles(); - for (int j = 0; j < file.length; j++) { - String path = file[j].getPath(); - if (path.endsWith(".png") || path.endsWith(".json") || path.endsWith(".draw")) { - continue; - } - utilFile = new UtilFile(path); - String messageJson = utilFile.readStrUTF8(); - String s = ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, true, uuid); - utilFile.write(s.getBytes("utf-8")); - } - // 更新缓存 - utilFile = new UtilFile(filePath + File.separator + uuid); - String messageJson = utilFile.readStrUTF8(); - BaseModel definModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - definModel.setDefinition(ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, false, uuid)); - } else { - set.add(uuid); - } - } - new Thread(new Runnable() {// 启用另一个线程来对未打的文件进行操作,减少用户等待时间 - @Override - public void run() { - for (String uuid : set) { - PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); - if (levelModel == null) { - continue; - } - String filePath = levelModel.getFilePath(); - UtilFile utilFile = new UtilFile(filePath); - File[] file = utilFile.listFiles(); - for (int j = 0; j < file.length; j++) { - String path = file[j].getPath(); - if (path.endsWith(".png") || path.endsWith(".json") || path.endsWith(".draw")) { - continue; - } - utilFile = new UtilFile(path); - String messageJson = utilFile.readStrUTF8(); - String s = ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, true, uuid); - try { - utilFile.write(s.getBytes("utf-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - // 更新缓存 - utilFile = new UtilFile(filePath + File.separator + uuid); - String messageJson = utilFile.readStrUTF8(); - BaseModel definModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); - definModel.setDefinition(ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, false, uuid)); - } - } - }).start(); - } + /** + * 改变出现复制的图形的名称或属性,对出现复制的图形的名称和属性进行同步,如: + * 对A图形进行复制派生出B那改变B或者A时两者的名称和属性应该是同步的并有相同的属性和名称 + * + * @param jsonObj + * @param uuid + */ + public void updateShapes(JSONObject jsonObj, String uuid) { + // JSONObject jsonObj = JSONObject.fromObject(messages); + JSONArray jsonArr1 = jsonObj.getJSONArray("updates"); + DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + Map> map = event.getEventMap(); + // 只针对单个 图形进行操作 + if (jsonArr1.size() > 1) { + event.setFlag(false); + return; + } + JSONObject jsonObj2 = jsonArr1.getJSONObject(0); + if (!jsonObj2.containsKey("anchors")) { + event.setFlag(false); + return; + } + String name = jsonObj2.getString("text"); + String id = jsonObj2.getString("id"); + if (map != null) { + Set l = map.get(uuid); + if (l != null) { + // 如果名称或属性没有什么变化,只是改变改图形的位置、连线什么的, 则不会唤醒正在阻塞的http长连接的线程 + for (JSONObject jsonObject : l) { + if (id.equals(jsonObject.getString("id")) && name.equals(jsonObject.getString("text")) && isTheSame(jsonObj2.getJSONArray("dataAttributes"), jsonObject.getJSONArray("dataAttributes"))) { + event.setFlag(false); + return; + } + } + } else { + // 否则唤醒正在等待的http长连接的线程 + event.setFlag(false); + } + } + } - /** - * 对于打开的文件中有出现复制的图形进行同步 - * - * @param clientId 客户端id - * @param userId 用户id - * @param name 文件名称 - * @param subject 文件id - * @param listenTime 监听时间 - * @return - */ - @SuppressWarnings("deprecation") - public String listen(String clientId, String userId, String name, String subject, String listenTime) { - DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - long start = System.currentTimeMillis(); - Map uuidSet = event.getUuidSet(); - uuidSet.put(subject, start); + /** + * 更新复制副本的内容 + * + * @param shapeGroupId 组id + * @param title 标题 + * @param text 文本 + * @param jsonDataArr 属性数据 + */ + private void updateShapeCache(String shapeGroupId, String title, String text, JSONArray jsonDataArr) { + DesignerRelationShapeCacheManager cache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = cache.getShapemap(); + Set key = shapeMap.keySet(); + for (String k : key) { + Map relationShapeMap = shapeMap.get(k); + String messageJson = (String) relationShapeMap.get("shapeCopyContent"); + if (messageJson != null) { + JSONArray jArr = JSONArray.parseArray(messageJson); + for (int i = 0; i < jArr.size(); i++) { + JSONObject shape = jArr.getJSONObject(i); + if (!"linker".equals(shape.get("name")) && shape.get("dataAttributes") != null) { + JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); + for (int j = 0; j < dataAttributes.size(); j++) { + JSONObject attr = dataAttributes.getJSONObject(j); + if (attr.containsKey("attributesContent") && attr.containsKey("shapeGroupId") && shapeGroupId.equals(attr.get("shapeGroupId"))) { + if (shapeGroupId.equals(attr.get("shapeGroupId"))) { + shape.put("text", text); + shape.put("title", title); + shape.put("dataAttributes", jsonDataArr); + relationShapeMap.put("shapeCopyContent", jArr.toString()); + return; + } + } + } - event.awaitRes(30 * 1000); - long end = System.currentTimeMillis(); - //如果等待时间超过30秒,则说明没有做修改 - if ((end - start) > (30 * 1000)) { - event.setFlag(false); - } - Map> eventMap = event.getEventMap(); - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject json = new JSONObject(); - try { - if (eventMap != null && eventMap.size() > 0 && event.isFlag()) { - json.put("shapes", getUpdateShapes(eventMap, subject)); - json.put("result", "ok"); - } else { - json.put("result", "error"); - } - } catch (Exception e) { - ro = ResponseObject.newErrResponse(); - json.put("result", "error"); - } - ro.setData(json); - return ro.toString(); - } + } + } + } + } + } - private List getUpdateShapes(Map> eventMap, String subject) { - Set set = eventMap.get(subject); - List list = new ArrayList(); - DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - String shapeGroupId = event.getShapeGroupId(); - for (JSONObject shape : set) { - if (!"linker".equals(shape.get("name")) && shape.get("dataAttributes") != null) { - JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); - for (int j = 0; j < dataAttributes.size(); j++) { - JSONObject attr = dataAttributes.getJSONObject(j); - if (attr.containsKey("attributesContent") && attr.containsKey("shapeGroupId") && shapeGroupId.equals(attr.get("shapeGroupId"))) { - if (shapeGroupId.equals(attr.get("shapeGroupId"))) { - list.add(shape); - break; - } - } - } - } - } - return list; - } + /** + * 判断新的数据和旧的数据是否相同 + * fastjson + * + * @param dataAttributes1 + * @param dataAttributes2 + * @return + */ + private boolean isTheSame(JSONArray dataAttributes1, JSONArray dataAttributes2) { + String attributesContent = ""; + String linksArray = ""; + String privateAttribute = ""; + String attributesJsonArray = ""; + String privateAttributeContent = ""; + String shapeDesc = ""; + String upFilesArray = ""; + String relevanceShapes = ""; + for (int i = 0; i < dataAttributes1.size(); i++) { + JSONObject attr = dataAttributes1.getJSONObject(i); + if (attr.containsKey("attributesContent")) { + attributesContent = attr.getString("attributesContent"); + linksArray = attr.getJSONArray("linksArray").toString(); + attributesJsonArray = attr.getJSONArray("attributesJsonArray").toString(); + privateAttribute = attr.getString("privateAttribute"); + privateAttributeContent = attr.getString("privateAttributeContent"); + shapeDesc = attr.getString("shapeDesc"); + if (attr.containsKey("upFilesArray")) { + upFilesArray = attr.getJSONArray("upFilesArray").toString(); + } + if (attr.containsKey("relevanceShapes")) { + relevanceShapes = attr.getJSONArray("relevanceShapes").toString(); + } + } + } + String attributesContent1 = ""; + String linksArray1 = ""; + String privateAttribute1 = ""; + String attributesJsonArray1 = ""; + String privateAttributeContent1 = ""; + String shapeDesc1 = ""; + String upFilesArray1 = ""; + String relevanceShapes1 = ""; + for (int i = 0; i < dataAttributes2.size(); i++) { + JSONObject attr = dataAttributes2.getJSONObject(i); + if (attr.containsKey("attributesContent")) { + attributesContent1 = attr.getString("attributesContent"); + linksArray1 = attr.getJSONArray("linksArray").toString(); + attributesJsonArray1 = attr.getJSONArray("attributesJsonArray").toString(); + privateAttribute1 = attr.getString("privateAttribute"); + privateAttributeContent1 = attr.getString("privateAttributeContent"); + shapeDesc1 = attr.getString("shapeDesc"); + if (attr.containsKey("upFilesArray")) { + upFilesArray1 = attr.getJSONArray("upFilesArray").toString(); + } + if (attr.containsKey("relevanceShapes")) { + relevanceShapes1 = attr.getJSONArray("relevanceShapes").toString(); + } + } + } + if (relevanceShapes1.equals(relevanceShapes) && attributesContent1.equals(attributesContent) && linksArray1.equals(linksArray) && attributesJsonArray1.equals(attributesJsonArray) && privateAttribute1.equals(privateAttribute) && privateAttributeContent1.equals(privateAttributeContent) && shapeDesc1.equals(shapeDesc) && upFilesArray1.equals(upFilesArray)) { + return true; + } + return false; + } - /** - * 出现复制统计 - * - * @param shapeGroupId 组id - * @param shapeId 图形id - * @param isCopy 是不是复制的 - * @return - */ - public String designerRelationShapeCount(String shapeGroupId, String shapeId, String isCopy) { - List> list = CoeProcessLevelDaoFacotory.createCoeProcessLevel().designerRelationShapeCount(shapeGroupId, shapeId, isCopy); - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject json = new JSONObject(); - if (list.size() > 0) { - json.put("list", list); - json.put("result", "ok"); - } - ro.setData(json); - return ro.toString(); - } + /** + * 更新出现复制过的文件的的信息 + * + * @param fileIdList + * @throws UnsupportedEncodingException + */ + private void updateFile(Set> fileIdList, final String shapeGroupId, final String title, final String text, final JSONArray jsonDataArr, final Map> map) throws UnsupportedEncodingException { + DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + Map uuidSet = event.getUuidSet(); + final Set set = new HashSet(); + for (Map fileMap : fileIdList) {// 快速响应已经打开的文件 + String uuid = fileMap.get("palRepositoryId"); + if (uuidSet.containsKey(uuid)) { + PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + String filePath = levelModel.getFilePath(); + UtilFile utilFile = new UtilFile(filePath); + File[] file = utilFile.listFiles(); + for (int j = 0; j < file.length; j++) { + String path = file[j].getPath(); + if (path.endsWith(".png") || path.endsWith(".json") || path.endsWith(".draw")) { + continue; + } + utilFile = new UtilFile(path); + String messageJson = utilFile.readStrUTF8(); + String s = ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, true, uuid); + utilFile.write(s.getBytes("utf-8")); + } + // 更新缓存 + utilFile = new UtilFile(filePath + File.separator + uuid); + String messageJson = utilFile.readStrUTF8(); + BaseModel definModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + definModel.setDefinition(ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, false, uuid)); + } else { + set.add(uuid); + } + } + new Thread(new Runnable() {// 启用另一个线程来对未打的文件进行操作,减少用户等待时间 + @Override + public void run() { + for (String uuid : set) { + PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(uuid); + if (levelModel == null) { + continue; + } + String filePath = levelModel.getFilePath(); + UtilFile utilFile = new UtilFile(filePath); + File[] file = utilFile.listFiles(); + for (int j = 0; j < file.length; j++) { + String path = file[j].getPath(); + if (path.endsWith(".png") || path.endsWith(".json") || path.endsWith(".draw")) { + continue; + } + utilFile = new UtilFile(path); + String messageJson = utilFile.readStrUTF8(); + String s = ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, true, uuid); + try { + utilFile.write(s.getBytes("utf-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + // 更新缓存 + utilFile = new UtilFile(filePath + File.separator + uuid); + String messageJson = utilFile.readStrUTF8(); + BaseModel definModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0); + definModel.setDefinition(ShapeUtil.fileJsonToObject(messageJson, shapeGroupId, title, text, jsonDataArr, map, false, uuid)); + } + } + }).start(); + } - /** - * 图形的删除 - * - * @param jsonArr 图形信息 - */ - public void removeShapes(JSONArray jsonArr, String uuid) { - DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - Map> map = event.getEventMap(); - Set list = map.get(uuid); - Set l = new HashSet(); - Set set = new HashSet(); - for (int i = 0; i < jsonArr.size(); i++) { - JSONObject obj = jsonArr.getJSONObject(i); - set.add(obj.getString("id")); - } - if (list != null) { - for (JSONObject jsonObj : list) { - if (set.contains(jsonObj.getString("id"))) { - continue; - } - l.add(jsonObj); - } - } - if (l.size() > 0) { - map.put(uuid, l); - } - CoeProcessLevelDaoFacotory.createCoeProcessLevel().removeShapes(jsonArr);// 复制出现的图形删除 - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - for (int j = 0; j < jsonArr.size(); j++) { - JSONObject obj = jsonArr.getJSONObject(j); - dao.deleteByShapeId(uuid, obj.getString("id"));// 关联/被关联的图形删除 - } - } + /** + * 对于打开的文件中有出现复制的图形进行同步 + * + * @param clientId 客户端id + * @param userId 用户id + * @param name 文件名称 + * @param subject 文件id + * @param listenTime 监听时间 + * @return + */ + @SuppressWarnings("deprecation") + public String listen(String clientId, String userId, String name, String subject, String listenTime) { + DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + long start = System.currentTimeMillis(); + Map uuidSet = event.getUuidSet(); + uuidSet.put(subject, start); - /** - * 针对CTRL+Z和CTRL+Y的动作,撤销和恢复的动作 - * - * @param jsonArray - */ - public void recoverRemoveShapes(JSONArray jsonArray) { - CoeProcessLevelDaoFacotory.createCoeProcessLevel().recoverRemoveShapes(jsonArray); - } + event.awaitRes(30 * 1000); + long end = System.currentTimeMillis(); + //如果等待时间超过30秒,则说明没有做修改 + if ((end - start) > (30 * 1000)) { + event.setFlag(false); + } + Map> eventMap = event.getEventMap(); + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + try { + if (eventMap != null && eventMap.size() > 0 && event.isFlag()) { + json.put("shapes", getUpdateShapes(eventMap, subject)); + json.put("result", "ok"); + } else { + json.put("result", "error"); + } + } catch (Exception e) { + ro = ResponseObject.newErrResponse(); + json.put("result", "error"); + } + ro.setData(json); + return ro.toString(); + } - /** - * 添加属性关联页面 - * - * @param wsId - * @param ref - * @param attrId 属性Id - * @param relationShapeIds 被关联的形状Ids - * @param ruuid 模型id - * @return - */ - public String designerRelevanceShapes(String wsId, String modelId, String ref, String shapeId, String attrId, String relationShapeIds, String relationFileIds,String teamId, String ruuid) { - Map macroLibraries = new HashMap(); - JSONObject refObj = JSONObject.parseObject(ref); - String method = refObj.getString("method");// 建模大类或建模方法 - String category = method; - if (method.contains(".")) { - category = method.substring(0, method.indexOf("."));// 截取建模大类 - } - String type = refObj.getString("type");// 关联类型 file shape + private List getUpdateShapes(Map> eventMap, String subject) { + Set set = eventMap.get(subject); + List list = new ArrayList(); + DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + String shapeGroupId = event.getShapeGroupId(); + for (JSONObject shape : set) { + if (!"linker".equals(shape.get("name")) && shape.get("dataAttributes") != null) { + JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); + for (int j = 0; j < dataAttributes.size(); j++) { + JSONObject attr = dataAttributes.getJSONObject(j); + if (attr.containsKey("attributesContent") && attr.containsKey("shapeGroupId") && shapeGroupId.equals(attr.get("shapeGroupId"))) { + if (shapeGroupId.equals(attr.get("shapeGroupId"))) { + list.add(shape); + break; + } + } + } + } + } + return list; + } + + /** + * 出现复制统计 + * + * @param shapeGroupId 组id + * @param shapeId 图形id + * @param isCopy 是不是复制的 + * @return + */ + public String designerRelationShapeCount(String shapeGroupId, String shapeId, String isCopy) { + List> list = CoeProcessLevelDaoFacotory.createCoeProcessLevel().designerRelationShapeCount(shapeGroupId, shapeId, isCopy); + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + if (list.size() > 0) { + json.put("list", list); + json.put("result", "ok"); + } + ro.setData(json); + return ro.toString(); + } + + /** + * 图形的删除 + * + * @param jsonArr 图形信息 + */ + public void removeShapes(JSONArray jsonArr, String uuid) { + DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + Map> map = event.getEventMap(); + Set list = map.get(uuid); + Set l = new HashSet(); + Set set = new HashSet(); + for (int i = 0; i < jsonArr.size(); i++) { + JSONObject obj = jsonArr.getJSONObject(i); + set.add(obj.getString("id")); + } + if (list != null) { + for (JSONObject jsonObj : list) { + if (set.contains(jsonObj.getString("id"))) { + continue; + } + l.add(jsonObj); + } + } + if (l.size() > 0) { + map.put(uuid, l); + } + CoeProcessLevelDaoFacotory.createCoeProcessLevel().removeShapes(jsonArr);// 复制出现的图形删除 + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + for (int j = 0; j < jsonArr.size(); j++) { + JSONObject obj = jsonArr.getJSONObject(j); + dao.deleteByShapeId(uuid, obj.getString("id"));// 关联/被关联的图形删除 + } + } + + /** + * 针对CTRL+Z和CTRL+Y的动作,撤销和恢复的动作 + * + * @param jsonArray + */ + public void recoverRemoveShapes(JSONArray jsonArray) { + CoeProcessLevelDaoFacotory.createCoeProcessLevel().recoverRemoveShapes(jsonArray); + } + + /** + * 添加属性关联页面 + * + * @param wsId + * @param ref + * @param attrId 属性Id + * @param relationShapeIds 被关联的形状Ids + * @param ruuid 模型id + * @return + */ + public String designerRelevanceShapes(String wsId, String modelId, String ref, String shapeId, String attrId, String relationShapeIds, String relationFileIds, String teamId, String ruuid) { + Map macroLibraries = new HashMap(); + JSONObject refObj = JSONObject.parseObject(ref); + String method = refObj.getString("method");// 建模大类或建模方法 + String category = method; + if (method.contains(".")) { + category = method.substring(0, method.indexOf("."));// 截取建模大类 + } + String type = refObj.getString("type");// 关联类型 file shape // macroLibraries.put("treeData", getTreeJson(wsId, "", category, type, method)); // by bzp - String treeJson=getTreeJson(wsId, "", category, type, method, ruuid, attrId,teamId); + String treeJson = getTreeJson(wsId, "", category, type, method, ruuid, attrId, teamId); - boolean showflag = true; - //JSONObject jsonObject = JSONObject.parseObject(json); - JSONArray jsonArr_new = new JSONArray(); - JSONArray objects = JSONArray.parseArray(treeJson); - //角色图属性代码是role/绩效图属性代码为Process_performance_metrics进行判断 - if (attrId.equals("Process_performance_metrics")) { - if (objects != null) { - for (int i = 0; i < objects.size(); i++) { - JSONObject jsonObject = objects.getJSONObject(i); - String id = jsonObject.getString("id"); - String isParent = jsonObject.getString("isParent"); + boolean showflag = true; + //JSONObject jsonObject = JSONObject.parseObject(json); + JSONArray jsonArr_new = new JSONArray(); + JSONArray objects = JSONArray.parseArray(treeJson); + //角色图属性代码是role/绩效图属性代码为Process_performance_metrics进行判断 + if (attrId.equals("Process_performance_metrics")) { + if (objects != null) { + for (int i = 0; i < objects.size(); i++) { + JSONObject jsonObject = objects.getJSONObject(i); + String id = jsonObject.getString("id"); + String isParent = jsonObject.getString("isParent"); - if (isParent != null) { - if (isParent.equals("true")) { - String title = jsonObject.getString("title"); - if (title.equals("末级流程绩效")) { - jsonArr_new.add(objects.getJSONObject(i)); - } else { - List coeProcessLevelModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(id, wsId); - if (coeProcessLevelModels.size() > 0) { - for (int k = 0; k < coeProcessLevelModels.size(); k++) { - PALRepositoryModel coeProcessLevelModel = coeProcessLevelModels.get(k); - if (coeProcessLevelModel != null) { - List data = new ArrayList(); - data.add(0, "control.kpi"); - data.add(1, ruuid); - RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?", coeProcessLevelModel.getId(), data.toString()); - if (rowMap != null) { - JSONObject json = getJSon(coeProcessLevelModel); - jsonArr_new.add(json); - } - } - } - } - } + if (isParent != null) { + if (isParent.equals("true")) { + String title = jsonObject.getString("title"); + if (title.equals("末级流程绩效")) { + jsonArr_new.add(objects.getJSONObject(i)); + } else { + List coeProcessLevelModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(id, wsId); + if (coeProcessLevelModels.size() > 0) { + for (int k = 0; k < coeProcessLevelModels.size(); k++) { + PALRepositoryModel coeProcessLevelModel = coeProcessLevelModels.get(k); + if (coeProcessLevelModel != null) { + List data = new ArrayList(); + data.add(0, "control.kpi"); + data.add(1, ruuid); + RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?", coeProcessLevelModel.getId(), data.toString()); + if (rowMap != null) { + JSONObject json = getJSon(coeProcessLevelModel); + jsonArr_new.add(json); + } + } + } + } + } - } else { - List data = new ArrayList(); - data.add(0, "control.kpi"); - data.add(1, ruuid); - RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?", id, data.toString()); - if (rowMap != null) { - jsonArr_new.add(objects.getJSONObject(i)); - } - } - } else { - jsonArr_new.add(objects.getJSONObject(i)); - } + } else { + List data = new ArrayList(); + data.add(0, "control.kpi"); + data.add(1, ruuid); + RowMap rowMap = DBSql.getMap("SELECT EXT2 FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=? AND EXT2=?", id, data.toString()); + if (rowMap != null) { + jsonArr_new.add(objects.getJSONObject(i)); + } + } + } else { + jsonArr_new.add(objects.getJSONObject(i)); + } - } - } - macroLibraries.put("treeData", jsonArr_new.toString()); - }else if(attrId.equals("L1L3_Performance")){ - if (objects != null) { - for (int i = 0; i < objects.size(); i++) { - JSONObject jsonObject = objects.getJSONObject(i); - String id = jsonObject.getString("id"); - String isParent = jsonObject.getString("isParent"); + } + } + macroLibraries.put("treeData", jsonArr_new.toString()); + } else if (attrId.equals("L1L3_Performance")) { + if (objects != null) { + for (int i = 0; i < objects.size(); i++) { + JSONObject jsonObject = objects.getJSONObject(i); + String id = jsonObject.getString("id"); + String isParent = jsonObject.getString("isParent"); - if (isParent != null) { - if (isParent.equals("true")) { - String title = jsonObject.getString("title"); - if (title.equals("L1-L3流程绩效")) { - jsonArr_new.add(objects.getJSONObject(i)); - } - } - } else { - jsonArr_new.add(objects.getJSONObject(i)); - } + if (isParent != null) { + if (isParent.equals("true")) { + String title = jsonObject.getString("title"); + if (title.equals("L1-L3流程绩效")) { + jsonArr_new.add(objects.getJSONObject(i)); + } + } + } else { + jsonArr_new.add(objects.getJSONObject(i)); + } - } - } - macroLibraries.put("treeData", jsonArr_new.toString()); - } else if (attrId.equals("post")) { - if (objects != null) { - for (int i = 0; i < objects.size(); i++) { - String id = objects.getJSONObject(i).getString("id"); - String url = objects.getJSONObject(i).getString("url"); + } + } + macroLibraries.put("treeData", jsonArr_new.toString()); + } else if (attrId.equals("post")) { + if (objects != null) { + for (int i = 0; i < objects.size(); i++) { + String id = objects.getJSONObject(i).getString("id"); + String url = objects.getJSONObject(i).getString("url"); - if (UtilString.isNotEmpty(url)) { - String titles = objects.getJSONObject(i).getString("title"); - if (titles.equals("岗位模型")) { - objects.getJSONObject(i).put("nocheck",true); - jsonArr_new.add(objects.getJSONObject(i)); - } else { - List> nodeElements = CoeDesignerUtil.getShapeMessageJson4(id); - if (nodeElements.size() > 0) { - String title = nodeElements.get(0).get("title").toString(); - if (title.equals("岗位")) { - jsonArr_new.add(objects.getJSONObject(i)); - } - } - } + if (UtilString.isNotEmpty(url)) { + String titles = objects.getJSONObject(i).getString("title"); + if (titles.equals("岗位模型")) { + objects.getJSONObject(i).put("nocheck", true); + jsonArr_new.add(objects.getJSONObject(i)); + } else { + List> nodeElements = CoeDesignerUtil.getShapeMessageJson4(id); + if (nodeElements.size() > 0) { + String title = nodeElements.get(0).get("title").toString(); + if (title.equals("岗位")) { + jsonArr_new.add(objects.getJSONObject(i)); + } + } + } - } else { - jsonArr_new.add(objects.getJSONObject(i)); - } - } - } - macroLibraries.put("treeData", jsonArr_new.toString()); - } else if (attrId.equals("R_relevant_flies") || attrId.equals("related_files")) {//相关文件 - for (int i = 0; i < objects.size(); i++) { - JSONObject jsonObject = objects.getJSONObject(i); - String isParent = jsonObject.getString("isParent"); - if (isParent != null) { - //过滤架构图 - if(jsonObject.get("name").equals("流程架构图")){ - continue; - } - if (isParent.equals("false")) { - //过滤废止数据 - RowMap rowMap = DBSql.getMap("SELECT PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISSTOP=? AND ISUSE=? ", jsonObject.getString("name"), 1, 1); - if (rowMap != null) { - continue; - } - RowMap publishRowMap = DBSql.getMap("SELECT PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISPUBLISH=? AND ISUSE=? ", jsonObject.getString("name"), 1, 1); - if (publishRowMap != null) { - jsonObject.put("nocheck", false); - jsonArr_new.add(jsonObject); - } - } else { - jsonObject.put("nocheck", true); - jsonArr_new.add(jsonObject); - } - } else { - jsonObject.put("nocheck", true); - jsonArr_new.add(jsonObject); - } + } else { + jsonArr_new.add(objects.getJSONObject(i)); + } + } + } + macroLibraries.put("treeData", jsonArr_new.toString()); + } else if (attrId.equals("R_relevant_flies") || attrId.equals("related_files")) {//相关文件 + for (int i = 0; i < objects.size(); i++) { + JSONObject jsonObject = objects.getJSONObject(i); + String isParent = jsonObject.getString("isParent"); + if (isParent != null) { + //过滤架构图 + if (jsonObject.get("name").equals("流程架构图")) { + continue; + } + if (isParent.equals("false")) { + //过滤废止数据 + RowMap rowMap = DBSql.getMap("SELECT PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISSTOP=? AND ISUSE=? ", jsonObject.getString("name"), 1, 1); + if (rowMap != null) { + continue; + } + RowMap publishRowMap = DBSql.getMap("SELECT PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISPUBLISH=? AND ISUSE=? ", jsonObject.getString("name"), 1, 1); + if (publishRowMap != null) { + jsonObject.put("nocheck", false); + jsonArr_new.add(jsonObject); + } + } else { + jsonObject.put("nocheck", true); + jsonArr_new.add(jsonObject); + } + } else { + jsonObject.put("nocheck", true); + jsonArr_new.add(jsonObject); + } - } - macroLibraries.put("treeData", jsonArr_new.toString()); - } else if (attrId.equals("support_files")) { //支持文件 - for (int i = 0; i < objects.size(); i++) { - JSONObject jsonObject = objects.getJSONObject(i); - String isParent = jsonObject.getString("isParent"); + } + macroLibraries.put("treeData", jsonArr_new.toString()); + } else if (attrId.equals("support_files")) { //支持文件 + for (int i = 0; i < objects.size(); i++) { + JSONObject jsonObject = objects.getJSONObject(i); + String isParent = jsonObject.getString("isParent"); - if (isParent != null) { + if (isParent != null) { - if (isParent.equals("false")) { - RowMap isPublishRowMap = DBSql.getMap("SELECT ISPUBLISH FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", jsonObject.getString("name"), 1); + if (isParent.equals("false")) { + RowMap isPublishRowMap = DBSql.getMap("SELECT ISPUBLISH FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", jsonObject.getString("name"), 1); /*if(isPublishRowMap.getString("ISPUBLISH").equals("0")){*/ - //过滤废止数据 - RowMap rowMap = DBSql.getMap("SELECT ISSTOP FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", jsonObject.getString("name"), 1); - String isstop=rowMap.getString("ISSTOP"); - if (isstop.equals("1")) { - continue; - }else{ - jsonObject.put("nocheck", false); - jsonArr_new.add(jsonObject); - } - /*}*/ + //过滤废止数据 + RowMap rowMap = DBSql.getMap("SELECT ISSTOP FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", jsonObject.getString("name"), 1); + String isstop = rowMap.getString("ISSTOP"); + if (isstop.equals("1")) { + continue; + } else { + jsonObject.put("nocheck", false); + jsonArr_new.add(jsonObject); + } + /*}*/ - } else { - jsonObject.put("nocheck", true); - jsonArr_new.add(jsonObject); - } - } else { - jsonObject.put("nocheck", true); - jsonArr_new.add(jsonObject); - } + } else { + jsonObject.put("nocheck", true); + jsonArr_new.add(jsonObject); + } + } else { + jsonObject.put("nocheck", true); + jsonArr_new.add(jsonObject); + } - } - macroLibraries.put("treeData", jsonArr_new.toString()); - }else if(attrId.equals("lead_process") || attrId.equals("rear_process")){//前置属性、后置属性 - for (int i = 0; i < objects.size(); i++) { - JSONObject jsonObject = objects.getJSONObject(i); - String isParent = jsonObject.getString("isParent"); - if (isParent != null) { - if (isParent.equals("true")) { - jsonObject.put("nocheck", true); - jsonArr_new.add(jsonObject); - }else{ - jsonObject.put("nocheck", false); - jsonArr_new.add(jsonObject); - } - } else { - jsonObject.put("nocheck", true); - jsonArr_new.add(jsonObject); - } - } - macroLibraries.put("treeData", jsonArr_new.toString()); - }else{ - macroLibraries.put("treeData", treeJson); - } + } + macroLibraries.put("treeData", jsonArr_new.toString()); + } else if (attrId.equals("lead_process") || attrId.equals("rear_process")) {//前置属性、后置属性 + for (int i = 0; i < objects.size(); i++) { + JSONObject jsonObject = objects.getJSONObject(i); + String isParent = jsonObject.getString("isParent"); + if (isParent != null) { + if (isParent.equals("true")) { + jsonObject.put("nocheck", true); + jsonArr_new.add(jsonObject); + } else { + jsonObject.put("nocheck", false); + jsonArr_new.add(jsonObject); + } + } else { + jsonObject.put("nocheck", true); + jsonArr_new.add(jsonObject); + } + } + macroLibraries.put("treeData", jsonArr_new.toString()); + } else { + macroLibraries.put("treeData", treeJson); + } - //macroLibraries.put("treeData", getTreeJson(wsId, "", category, type, method,ruuid)); - macroLibraries.put("sid", _uc.getSessionId()); - macroLibraries.put("wsid", wsId); - macroLibraries.put("attrId", attrId); - macroLibraries.put("refObj", refObj); - macroLibraries.put("category", category); - macroLibraries.put("modelId", modelId == null ? "" : modelId); - macroLibraries.put("teamId",teamId); + //macroLibraries.put("treeData", getTreeJson(wsId, "", category, type, method,ruuid)); + macroLibraries.put("sid", _uc.getSessionId()); + macroLibraries.put("wsid", wsId); + macroLibraries.put("attrId", attrId); + macroLibraries.put("refObj", refObj); + macroLibraries.put("category", category); + macroLibraries.put("modelId", modelId == null ? "" : modelId); + macroLibraries.put("teamId", teamId); - //查询已关联图形 + //查询已关联图形 - JSONArray relationShapeList = new JSONArray(); - if (attrId != null && !"".equals(attrId)) { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - if ("file".equals(type)) {// 关联模型文件 - Set ids = new HashSet<>();// 之前代码会造成数据库出现多余数据,过滤重复数据 - List versionIds = new ArrayList(); - String [] arr = relationFileIds.split(","); - for (int i = 0; i < arr.length; i++) { - PALRepositoryModel model = PALRepositoryCache.getCache().get(arr[i]); - if (model != null) { - versionIds.add(model.getVersionId()); - } else { - if (PALRepositoryCache.getByVersionId(arr[i]) != null && PALRepositoryCache.getByVersionId(arr[i]).size() > 0) { - versionIds.add(arr[i]); - } - } - } - String tmpStr = StringUtils.join(versionIds, ","); - List list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, null, tmpStr); - list.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); - for (DesignerShapeRelationModel model : list) { - if (ids.contains(model.getRelationFileId())) { - continue; - } - if (attrId.equals(model.getAttrId())) { - List list2 = PALRepositoryCache.getByVersionId(wsId, model.getRelationFileId());// relationFileId存储的是versionId - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - model.setRelationFileId(model2.getId()); - model.setRelationShapeText(model2.getName()); - break; - } - } - relationShapeList.add(model); - ids.add(model.getRelationFileId()); - } - } - } else {// 关联形状 - Set ids = new HashSet<>(); - List list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, relationShapeIds, null); - list.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); - for (DesignerShapeRelationModel model : list) { - if (ids.contains(model.getRelationShapeId()) && !"shapeAndFile".equals(type)) { - continue; - } - if (attrId.equals(model.getAttrId())) { - List list2 = PALRepositoryCache.getByVersionId(wsId, model.getRelationShapeId()); - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - model.setRelationShapeText(model2.getName()); - break; - } - } - relationShapeList.add(model); - ids.add(model.getRelationShapeId()); - } - } - } - } + JSONArray relationShapeList = new JSONArray(); + if (attrId != null && !"".equals(attrId)) { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + if ("file".equals(type)) {// 关联模型文件 + Set ids = new HashSet<>();// 之前代码会造成数据库出现多余数据,过滤重复数据 + List versionIds = new ArrayList(); + String[] arr = relationFileIds.split(","); + for (int i = 0; i < arr.length; i++) { + PALRepositoryModel model = PALRepositoryCache.getCache().get(arr[i]); + if (model != null) { + versionIds.add(model.getVersionId()); + } else { + if (PALRepositoryCache.getByVersionId(arr[i]) != null && PALRepositoryCache.getByVersionId(arr[i]).size() > 0) { + versionIds.add(arr[i]); + } + } + } + String tmpStr = StringUtils.join(versionIds, ","); + List list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, null, tmpStr); + list.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); + for (DesignerShapeRelationModel model : list) { + if (ids.contains(model.getRelationFileId())) { + continue; + } + if (attrId.equals(model.getAttrId())) { + List list2 = PALRepositoryCache.getByVersionId(wsId, model.getRelationFileId());// relationFileId存储的是versionId + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + model.setRelationFileId(model2.getId()); + model.setRelationShapeText(model2.getName()); + break; + } + } + relationShapeList.add(model); + ids.add(model.getRelationFileId()); + } + } + } else {// 关联形状 + Set ids = new HashSet<>(); + List list = dao.getModelListByShapeIdAndRelationShapeId(ruuid, shapeId, relationShapeIds, null); + list.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); + for (DesignerShapeRelationModel model : list) { + if (ids.contains(model.getRelationShapeId()) && !"shapeAndFile".equals(type)) { + continue; + } + if (attrId.equals(model.getAttrId())) { + List list2 = PALRepositoryCache.getByVersionId(wsId, model.getRelationShapeId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + model.setRelationShapeText(model2.getName()); + break; + } + } + relationShapeList.add(model); + ids.add(model.getRelationShapeId()); + } + } + } + } - macroLibraries.put("relationShapeList", relationShapeList); - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.shapes.htm", macroLibraries); - } + macroLibraries.put("relationShapeList", relationShapeList); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.shapes.htm", macroLibraries); + } - - - public String getTreeJson(String wsId, String pid, String category, String type, String method, String ruuid,String attrId,String teamId) { - StringBuffer treeJson = new StringBuffer(); - if (pid.equals("")) { - return getRootJson(wsId, category, type, method,ruuid,attrId,teamId); // 加载根 - } - // 加载二级 + public String getTreeJson(String wsId, String pid, String category, String type, String method, String ruuid, String attrId, String teamId) { + StringBuffer treeJson = new StringBuffer(); + if (pid.equals("")) { + return getRootJson(wsId, category, type, method, ruuid, attrId, teamId); // 加载根 + } + // 加载二级 // treeJson.append(getTwoNodeJson(pid, wsId)); - // by bzp - treeJson.append(getTwoNodeJson(pid, wsId, method, ruuid, teamId)); + // by bzp + treeJson.append(getTwoNodeJson(pid, wsId, method, ruuid, teamId)); - return treeJson.toString(); - } + return treeJson.toString(); + } + /** + * 获取第二级及其以下目录 + * by bzp 增加method方法 判断 + * + * @param pid + * @return + */ + public String getTwoNodeJson(String pid, String wsId, String method, String ruuid, String teamId) { + Set versionIds = new HashSet<>(); + if (UtilString.isNotEmpty(teamId)) { + // 小组下 当前人员角色的权限数据 + UserInfo userInfo = CooperationCache.getUserInfo(teamId, _uc.getUID()); + if (userInfo != null) { + if (userInfo.getIsAllDataPermission()) { + TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); + versionIds = teamInfo.getVersionIds(); + } else { + versionIds = userInfo.getDataPermission().keySet(); + } + } + } + List coeProcessLevelModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(pid, wsId); + if (versionIds.size() > 0) { + List modelList = new ArrayList<>(); + for (PALRepositoryModel model : coeProcessLevelModels) { + if (versionIds.contains(model.getId())) { + modelList.add(model); + } + } + coeProcessLevelModels = modelList; + } + JSONArray jsonArray = new JSONArray(); + for (int i = 0; i < coeProcessLevelModels.size(); i++) { + PALRepositoryModel coeProcessLevelModel = coeProcessLevelModels.get(i); + if (coeProcessLevelModel != null) { + JSONObject json = getJSon(coeProcessLevelModel); + jsonArray.add(json); + } + } + return jsonArray.toString(); + } + protected String getRootJson(String wsuuid, String category, String type, String methodScope, String ruuid, String attrId, String teamId) { + JSONArray jsonArray = new JSONArray(); + if ("file".equals(type)) {// 关联的文件模型 + PALMethodJsonModel processpmjm = new PALMethodJsonModel(); + processpmjm.setId(category); + processpmjm.setName(I18nRes.findValue(CoEConstant.APP_ID, category)); + processpmjm.setUrl("./jd?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_process_models_info&ruuid=process&uuid=process&wsId=" + wsuuid); + processpmjm.setIcon("../apps/" + CoEConstant.APP_ID + "/img/method/" + processpmjm.getId() + ".png"); + processpmjm.setMenu(false); + processpmjm.setOpen(true); + jsonArray.add(processpmjm); + JSONArray nodes = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsuuid, processpmjm.getId(), teamId); + for (int i = 0; i < nodes.size(); i++) { + JSONObject node = nodes.getJSONObject(i); + node.put("url", "./jd?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_process_models_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id") + "&wsId=" + wsuuid); + String id = node.getString("id"); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null) { + if (!model.getMethodCategory().equals(methodScope) && !model.getMethodId().equals(methodScope)) { + node.put("nocheck", true); + } - /** - * 获取第二级及其以下目录 - * by bzp 增加method方法 判断 - * - * @param pid - * @return - */ - public String getTwoNodeJson(String pid, String wsId, String method, String ruuid, String teamId) { - Set versionIds = new HashSet<>(); - if (UtilString.isNotEmpty(teamId)){ - // 小组下 当前人员角色的权限数据 - UserInfo userInfo = CooperationCache.getUserInfo(teamId, _uc.getUID()); - if (userInfo != null){ - if (userInfo.getIsAllDataPermission()) { - TeamInfo teamInfo = CooperationCache.getTeamInfo(teamId); - versionIds = teamInfo.getVersionIds(); - }else { - versionIds = userInfo.getDataPermission().keySet(); - } - } - } - List coeProcessLevelModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(pid, wsId); - if (versionIds.size() > 0){ - List modelList = new ArrayList<>(); - for (PALRepositoryModel model : coeProcessLevelModels) { - if (versionIds.contains(model.getId())){ - modelList.add(model); - } - } - coeProcessLevelModels = modelList; - } - JSONArray jsonArray = new JSONArray(); - for (int i = 0; i < coeProcessLevelModels.size(); i++) { - PALRepositoryModel coeProcessLevelModel = coeProcessLevelModels.get(i); - if (coeProcessLevelModel != null) { - JSONObject json = getJSon(coeProcessLevelModel); - jsonArray.add(json); - } - } - return jsonArray.toString(); - } - - protected String getRootJson(String wsuuid, String category, String type, String methodScope,String ruuid,String attrId,String teamId) { - JSONArray jsonArray = new JSONArray(); - if ("file".equals(type)) {// 关联的文件模型 - PALMethodJsonModel processpmjm = new PALMethodJsonModel(); - processpmjm.setId(category); - processpmjm.setName(I18nRes.findValue(CoEConstant.APP_ID, category)); - processpmjm.setUrl("./jd?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_process_models_info&ruuid=process&uuid=process&wsId=" + wsuuid); - processpmjm.setIcon("../apps/" + CoEConstant.APP_ID + "/img/method/" + processpmjm.getId() + ".png"); - processpmjm.setMenu(false); - processpmjm.setOpen(true); - jsonArray.add(processpmjm); - JSONArray nodes = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsuuid, processpmjm.getId(),teamId); - for (int i = 0; i < nodes.size(); i++) { - JSONObject node = nodes.getJSONObject(i); - node.put("url", "./jd?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_process_models_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id") + "&wsId=" + wsuuid); - String id = node.getString("id"); - PALRepositoryModel model = PALRepositoryCache.getCache().get(id); - if (model != null) { - if (!model.getMethodCategory().equals(methodScope) && !model.getMethodId().equals(methodScope)) { - node.put("nocheck", true); - } - - //by bzp control.kpi - String methodId = node.getString("plMethodId"); - if ("control.kpi".equals(methodId) && methodScope.equals(methodId)) { - //根据ID去查 是否有关联管流程 - String tmpId = node.getString("id"); - String sql = "select FILEID from APP_ACT_COE_PAL_SHAPE_RLAT where ATTRID='Process_performance_metrics' and RELATIONFILEID='%s'"; - String reId = DBSql.getString(String.format(sql, tmpId)); - //还要判断是不是当前流程 - if (!reId.isEmpty() && !ruuid.equals(reId)) { - continue; - } - } - } - jsonArray.add(node); - } - } else { - // 关联的形状节点 - PALMethodJsonModel controlpmjm = new PALMethodJsonModel(); - controlpmjm.setId(category); - controlpmjm.setName(I18nRes.findValue(CoEConstant.APP_ID, category)); - controlpmjm.setUrl(""); - controlpmjm.setIcon("../apps/" + CoEConstant.APP_ID + "/img/method/" + controlpmjm.getId() + ".png"); - controlpmjm.setMenu(false); - controlpmjm.setOpen(true); - jsonArray.add(controlpmjm); + //by bzp control.kpi + String methodId = node.getString("plMethodId"); + if ("control.kpi".equals(methodId) && methodScope.equals(methodId)) { + //根据ID去查 是否有关联管流程 + String tmpId = node.getString("id"); + String sql = "select FILEID from APP_ACT_COE_PAL_SHAPE_RLAT where ATTRID='Process_performance_metrics' and RELATIONFILEID='%s'"; + String reId = DBSql.getString(String.format(sql, tmpId)); + //还要判断是不是当前流程 + if (!reId.isEmpty() && !ruuid.equals(reId)) { + continue; + } + } + } + jsonArray.add(node); + } + } else { + // 关联的形状节点 + PALMethodJsonModel controlpmjm = new PALMethodJsonModel(); + controlpmjm.setId(category); + controlpmjm.setName(I18nRes.findValue(CoEConstant.APP_ID, category)); + controlpmjm.setUrl(""); + controlpmjm.setIcon("../apps/" + CoEConstant.APP_ID + "/img/method/" + controlpmjm.getId() + ".png"); + controlpmjm.setMenu(false); + controlpmjm.setOpen(true); + jsonArray.add(controlpmjm); /*if(attrId.equals("R_relevant_flies")||attrId.equals("support_files")){ PALMethodJsonModel controlpmjm1 = new PALMethodJsonModel(); @@ -1146,19 +1148,19 @@ public class DesignerRelationShapeWeb extends ActionWeb { controlpmjm2.setOpen(true); jsonArray.add(controlpmjm2); }*/ - JSONArray nodes = null; - if(attrId.equals("role")){ - nodes=PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPidRole(_uc, wsuuid, controlpmjm.getId(),ruuid,teamId); - }else{ - nodes = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsuuid, controlpmjm.getId(),teamId); - } + JSONArray nodes = null; + if (attrId.equals("role")) { + nodes = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPidRole(_uc, wsuuid, controlpmjm.getId(), ruuid, teamId); + } else { + nodes = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsuuid, controlpmjm.getId(), teamId); + } - for (int i = 0; i < nodes.size(); i++) { - JSONObject node = nodes.getJSONObject(i); - node.put("url", "./jd?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id")); - jsonArray.add(node); - } - } + for (int i = 0; i < nodes.size(); i++) { + JSONObject node = nodes.getJSONObject(i); + node.put("url", "./jd?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id")); + jsonArray.add(node); + } + } // for (int i = 0; i < palMethodList.size(); i++) { // String str = palMethodList.get(i); // if (str.equals("process") || str.equals("org") || str.equals("data") || str.equals("product") || str.equals("control") || str.equals("itsystem")) { @@ -1174,162 +1176,163 @@ public class DesignerRelationShapeWeb extends ActionWeb { // } // // } - return jsonArray.toString(); - } + return jsonArray.toString(); + } + /** + * 关联属性快速搜索 + * + * @param wsId + * @param scope + * @return + */ + public String getShapesTreeDataJson(String wsId, String category, String autoContent) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); + List list = new ArrayList(); + if (!"".equals(category)) { + List modelList = coeProcessLevel.getCoeProcessLevelByNameAndCategory(autoContent, wsId, category); + if (modelList != null && modelList.size() > 0) { + for (PALRepositoryModel palModel : modelList) { + if (palModel == null) { + continue; + } + /****************************过滤已废止数据**by zhaolei*********************/ + RowMap rowMap = DBSql.getMap("SELECT isStop FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=?", palModel.getId()); + if (rowMap != null) { + String isStop = rowMap.getString("isStop"); + if (isStop.equals("0")) { + CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); + bean.setName(palModel.getName()); + bean.setType(palModel.getMethodId()); + bean.setExt1(palModel.getId()); + bean.setExt2(palModel.getVersionId()); + StringBuilder sBuilder = new StringBuilder();// 名称组合 + StringBuilder idBuilder = new StringBuilder();// Id组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(bean.getName()); + idBuilder.append(palModel.getId()); + idSets.add(palModel.getId()); + Map topLevelmap = new HashMap(); + topLevelmap.put("topLevel", palModel.getLevel()); //topLevel:为计算后的顶级目录的级别。没有顶级目录的流程舍去 + getFilePath(palModel, sBuilder, idBuilder, idSets, topLevelmap);// 递归获取当前文件名称路径 + if (topLevelmap != null && topLevelmap.get("topLevel") != null && topLevelmap.get("topLevel") > 1) { + continue; + } + // bean.setUi("

" + sBuilder.toString() + "
"); + bean.setUi(sBuilder.toString()); + bean.setValue(idBuilder.toString()); + list.add(bean); + } + } - /** - * 关联属性快速搜索 - * @param wsId - * @param scope - * @return - */ - public String getShapesTreeDataJson(String wsId, String category, String autoContent) { - ResponseObject ro = ResponseObject.newOkResponse(); - PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); - List list = new ArrayList(); - if (!"".equals(category)) { - List modelList = coeProcessLevel.getCoeProcessLevelByNameAndCategory(autoContent, wsId, category); - if (modelList != null && modelList.size() > 0) { - for (PALRepositoryModel palModel : modelList) { - if (palModel == null) { - continue; - } - - /****************************过滤已废止数据**by zhaolei*********************/ - RowMap rowMap=DBSql.getMap("SELECT isStop FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID=?",palModel.getId()); - if(rowMap!=null){ - String isStop=rowMap.getString("isStop"); - if(isStop.equals("0")){ - CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); - bean.setName(palModel.getName()); - bean.setType(palModel.getMethodId()); - bean.setExt1(palModel.getId()); - bean.setExt2(palModel.getVersionId()); - StringBuilder sBuilder = new StringBuilder();// 名称组合 - StringBuilder idBuilder = new StringBuilder();// Id组合 - Set idSets = new HashSet<>();// id记录,校验防止递归死循环 - sBuilder.append(bean.getName()); - idBuilder.append(palModel.getId()); - idSets.add(palModel.getId()); - Map topLevelmap = new HashMap(); - topLevelmap.put("topLevel", palModel.getLevel()); //topLevel:为计算后的顶级目录的级别。没有顶级目录的流程舍去 - getFilePath(palModel, sBuilder, idBuilder, idSets, topLevelmap);// 递归获取当前文件名称路径 - if(topLevelmap!=null && topLevelmap.get("topLevel")!=null && topLevelmap.get("topLevel")>1) { - continue; - } - // bean.setUi("
" + sBuilder.toString() + "
"); - bean.setUi(sBuilder.toString()); - bean.setValue(idBuilder.toString()); - list.add(bean); - } - } - - } - } - } - List list2 = new ArrayList(); - boolean isBeyond = false;// 查询结果是否超出一定数量并截取 - if (list != null && list.size() > 0) { - // 排序 - Collections.sort(list, new Comparator() { - @Override - public int compare(CoeProcessLevelAutoBean o1, CoeProcessLevelAutoBean o2) { - String ui1 = o1.getUi(); - String ui2 = o2.getUi(); - return ui2.compareToIgnoreCase(ui1); - } - }); - // 取前15个 - if (list.size() > 15) { - isBeyond = true; - } - for (int i = 0; i < list.size(); i++) { + } + } + } + List list2 = new ArrayList(); + boolean isBeyond = false;// 查询结果是否超出一定数量并截取 + if (list != null && list.size() > 0) { + // 排序 + Collections.sort(list, new Comparator() { + @Override + public int compare(CoeProcessLevelAutoBean o1, CoeProcessLevelAutoBean o2) { + String ui1 = o1.getUi(); + String ui2 = o2.getUi(); + return ui2.compareToIgnoreCase(ui1); + } + }); + // 取前15个 + if (list.size() > 15) { + isBeyond = true; + } + for (int i = 0; i < list.size(); i++) { /*if (i >= 15) { // 取前15个 break; }*/ - list2.add(list.get(i)); - } - } - ro.put("result", com.alibaba.fastjson.JSONArray.toJSON(list2)); - ro.put("isBeyond", isBeyond); - return ro.toString(); - } - - /** - * 获取文件名称全路径 - * @param model - * @return - */ - protected void getFilePath(PALRepositoryModel model, StringBuilder sBuilder, StringBuilder idBuilder, Set idSets, Map topLevelmap) { - if (model.getParentId().length() == 36 && !idSets.contains(model.getParentId())) { - String parentId = model.getParentId(); - PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(parentId); - if (parentModel != null) { - sBuilder.insert(0, parentModel.getName() + ">"); - idBuilder.insert(0, parentModel.getId() + ","); - idSets.add(parentModel.getId()); - topLevelmap.put("topLevel", parentModel.getLevel()); - getFilePath(parentModel, sBuilder, idBuilder, idSets, topLevelmap); - } - } - } - - /** - * 得到tree json 结构 - * - * @param wsId - * @param pid - * @return - */ - public String getTreeJson(String wsId, String pid,String attrId,String uuid,String teamId) { - JSONArray list; - if(attrId.equals("Process_performance_metrics") || attrId.equals("role") || attrId.equals("R_relevant_flies") || attrId.equals("L1L3_Performance") || attrId.equals("post")){ - list= PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPidAnduuid(_uc, wsId,pid,attrId,uuid,teamId); - }else{ - list= PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsId, pid,teamId); - } + list2.add(list.get(i)); + } + } + ro.put("result", com.alibaba.fastjson.JSONArray.toJSON(list2)); + ro.put("isBeyond", isBeyond); + return ro.toString(); + } - JSONArray result = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - JSONObject node = list.getJSONObject(i); - node.put("url", "./jd?sid=" + super.getContext().getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id")); - result.add(node); - } - return result.toString(); - } - - /** - * 得到流程tree json结构 - * @param wsId - * @param pid - * @param methodScope - * @return - */ - public String getProcessModelsTreeJson(String wsId, String pid, String methodScope,String attrId,String ruuid,String teamId) { - JSONArray list = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsId, pid,teamId); - JSONArray result = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - JSONObject node = list.getJSONObject(i); - String isPublish=node.getString("isPublish"); - String isParent=node.getString("isParent"); - String isStop=node.getString("isStop"); - String name=node.getString("name"); - node.put("url", "./jd?sid=" + super.getContext().getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_process_models_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id") + "&wsId=" + wsId); - String id = node.getString("id"); - PALRepositoryModel model = PALRepositoryCache.getCache().get(id); - if (model != null) { + /** + * 获取文件名称全路径 + * + * @param model + * @return + */ + protected void getFilePath(PALRepositoryModel model, StringBuilder sBuilder, StringBuilder idBuilder, Set idSets, Map topLevelmap) { + if (model.getParentId().length() == 36 && !idSets.contains(model.getParentId())) { + String parentId = model.getParentId(); + PALRepositoryModel parentModel = PALRepositoryCache.getCache().get(parentId); + if (parentModel != null) { + sBuilder.insert(0, parentModel.getName() + ">"); + idBuilder.insert(0, parentModel.getId() + ","); + idSets.add(parentModel.getId()); + topLevelmap.put("topLevel", parentModel.getLevel()); + getFilePath(parentModel, sBuilder, idBuilder, idSets, topLevelmap); + } + } + } - RowMap stoprowMap=DBSql.getMap("SELECT ISSTOP FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", name,1); - if(stoprowMap.getString("ISSTOP").equals("0")){ - //如果为相关文件 未发布不可选中 - if(attrId.equals("R_relevant_flies") || attrId.equals("related_files")){ + /** + * 得到tree json 结构 + * + * @param wsId + * @param pid + * @return + */ + public String getTreeJson(String wsId, String pid, String attrId, String uuid, String teamId) { + JSONArray list; + if (attrId.equals("Process_performance_metrics") || attrId.equals("role") || attrId.equals("R_relevant_flies") || attrId.equals("L1L3_Performance") || attrId.equals("post")) { + list = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPidAnduuid(_uc, wsId, pid, attrId, uuid, teamId); + } else { + list = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsId, pid, teamId); + } - if(model.getName().equals("流程架构图")){ - continue; - } + JSONArray result = new JSONArray(); + for (int i = 0; i < list.size(); i++) { + JSONObject node = list.getJSONObject(i); + node.put("url", "./jd?sid=" + super.getContext().getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id")); + result.add(node); + } + return result.toString(); + } + + /** + * 得到流程tree json结构 + * + * @param wsId + * @param pid + * @param methodScope + * @return + */ + public String getProcessModelsTreeJson(String wsId, String pid, String methodScope, String attrId, String ruuid, String teamId) { + JSONArray list = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryTreeDataByPid(_uc, wsId, pid, teamId); + JSONArray result = new JSONArray(); + for (int i = 0; i < list.size(); i++) { + JSONObject node = list.getJSONObject(i); + String isPublish = node.getString("isPublish"); + String isParent = node.getString("isParent"); + String isStop = node.getString("isStop"); + String name = node.getString("name"); + node.put("url", "./jd?sid=" + super.getContext().getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_process_models_info&ruuid=" + node.getString("id") + "&uuid=" + node.getString("id") + "&wsId=" + wsId); + String id = node.getString("id"); + PALRepositoryModel model = PALRepositoryCache.getCache().get(id); + if (model != null) { + + RowMap stoprowMap = DBSql.getMap("SELECT ISSTOP FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", name, 1); + if (stoprowMap.getString("ISSTOP").equals("0")) { + //如果为相关文件 未发布不可选中 + if (attrId.equals("R_relevant_flies") || attrId.equals("related_files")) { + + if (model.getName().equals("流程架构图")) { + continue; + } /*RowMap rowMap=DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISPUBLISH=? AND ISUSE=?", name,1,1); if(isParent.equals("true")){ node.put("nocheck", true); @@ -1338,57 +1341,57 @@ public class DesignerRelationShapeWeb extends ActionWeb { node.put("nocheck", false); }*/ - RowMap rowMap=DBSql.getMap("SELECT ISPUBLISH FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", name,1); + RowMap rowMap = DBSql.getMap("SELECT ISPUBLISH FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", name, 1); - if(isParent.equals("true")){ - node.put("nocheck", true); - result.add(node); - }else if(isParent.equals("false")){ - if(rowMap.getString("ISPUBLISH").equals("1")) { - node.put("nocheck", false); - result.add(node); - } - } + if (isParent.equals("true")) { + node.put("nocheck", true); + result.add(node); + } else if (isParent.equals("false")) { + if (rowMap.getString("ISPUBLISH").equals("1")) { + node.put("nocheck", false); + result.add(node); + } + } - } - //如果为支持文件 - if(attrId.equals("support_files")){ - RowMap rowMap=DBSql.getMap("SELECT ISPUBLISH FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", name,1); - if(isParent.equals("true")){ - node.put("nocheck", true); - result.add(node); - }else if(isParent.equals("false")){ + } + //如果为支持文件 + if (attrId.equals("support_files")) { + RowMap rowMap = DBSql.getMap("SELECT ISPUBLISH FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLNAME=? AND ISUSE=?", name, 1); + if (isParent.equals("true")) { + node.put("nocheck", true); + result.add(node); + } else if (isParent.equals("false")) { node.put("nocheck", false); result.add(node); - } + } - } else if (attrId.equals("lead_process") || attrId.equals("rear_process")) { - if(isParent.equals("true")) { - node.put("nocheck", true); - result.add(node); - }else{ - node.put("nocheck", false); - result.add(node); - } - }else{ - String methodId = node.getString("plMethodId"); - if ("control.kpi".equals(methodId) && methodScope.equals(methodId)) { - //根据ID去查 是否有关联管流程 - String tmpId = node.getString("id"); - String sql = "select FILEID from APP_ACT_COE_PAL_SHAPE_RLAT where ATTRID='Process_performance_metrics' and RELATIONFILEID='%s'"; - String reId = DBSql.getString(String.format(sql, tmpId)); - //还要判断是不是当前流程 - if (!reId.isEmpty() && !ruuid.equals(reId)) { - continue; - } - result.add(node); - } + } else if (attrId.equals("lead_process") || attrId.equals("rear_process")) { + if (isParent.equals("true")) { + node.put("nocheck", true); + result.add(node); + } else { + node.put("nocheck", false); + result.add(node); + } + } else { + String methodId = node.getString("plMethodId"); + if ("control.kpi".equals(methodId) && methodScope.equals(methodId)) { + //根据ID去查 是否有关联管流程 + String tmpId = node.getString("id"); + String sql = "select FILEID from APP_ACT_COE_PAL_SHAPE_RLAT where ATTRID='Process_performance_metrics' and RELATIONFILEID='%s'"; + String reId = DBSql.getString(String.format(sql, tmpId)); + //还要判断是不是当前流程 + if (!reId.isEmpty() && !ruuid.equals(reId)) { + continue; + } + result.add(node); + } - } - } + } + } - } + } /*if(attrId.equals("R_relevant_flies")){ if(isPublish.equals("true") && isStop.equals("false")){ result.add(node); @@ -1414,1207 +1417,1218 @@ public class DesignerRelationShapeWeb extends ActionWeb { }*/ - } - return result.toString(); - } - - /** - * 装载所有的节点 - * - * @param pid - * @param wsId - * @return - */ - public void putAllNodeJson(String pid, String wsId, JSONArray jsonArray) { - List coeProcessLevelModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(pid, wsId); - for (int i = 0; i < coeProcessLevelModels.size(); i++) { - PALRepositoryModel coeProcessLevelModel = coeProcessLevelModels.get(i); - if (coeProcessLevelModel != null) { - JSONObject json = getJSon(coeProcessLevelModel); - jsonArray.add(json); - putAllNodeJson(coeProcessLevelModel.getId(), wsId, jsonArray); - } - } - } + } + return result.toString(); + } - /** - * 获取tree json - * - * @param coeProcessLevelModel - * @param i - * @return - */ - private JSONObject getJSon(PALRepositoryModel coeProcessLevelModel) { - JSONObject rootJson = new JSONObject(); - rootJson.put("id", coeProcessLevelModel.getId()); - rootJson.put("pid", coeProcessLevelModel.getParentId()); - rootJson.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(coeProcessLevelModel.getId(), coeProcessLevelModel.getWsId())); - rootJson.put("name", I18nRes.findValue(CoEConstant.APP_ID, super.getContext().getLanguage(), coeProcessLevelModel.getName())); - rootJson.put("title", rootJson.get("name") + " " + VersionUtil.getVersionStrV(coeProcessLevelModel.getVersion())); - rootJson.put("drop", false); - rootJson.put("isSystemFile", coeProcessLevelModel.isSystemFile()); - rootJson.put("plMethodId", coeProcessLevelModel.getMethodId()); - if (!"default".equals(coeProcessLevelModel.getMethodId())) { - if (PALMethodCache.getPALMethodModelById(coeProcessLevelModel.getMethodId()) == null) { - rootJson.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); - } else { - rootJson.put("icon", "../apps/" + PALMethodCache.getPALMethodModelById(coeProcessLevelModel.getMethodId()).getApp().getId() + "/img/method/" + coeProcessLevelModel.getMethodId() + "/16.png"); - } - } else { - rootJson.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); - } - rootJson.put("isParent", coeProcessLevelModel.isBottomLevel() == 0 ? true : false); - rootJson.put("plLevel", coeProcessLevelModel.getLevel()); - rootJson.put("plOrdexIndex", coeProcessLevelModel.getOrderIndex()); - rootJson.put("plDiagramUrl", coeProcessLevelModel.getDiagramUrl()); - rootJson.put("plSecurityR", coeProcessLevelModel.getPlSecurityR()); - rootJson.put("plSecurityW", coeProcessLevelModel.getPlSecurityW()); - rootJson.put("url", "./jd?sid=" + super.getContext().getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_info&ruuid=" + coeProcessLevelModel.getId() + "&uuid=" + coeProcessLevelModel.getId()); - rootJson.put("plCategory", coeProcessLevelModel.getMethodCategory()); - return rootJson; - } + /** + * 装载所有的节点 + * + * @param pid + * @param wsId + * @return + */ + public void putAllNodeJson(String pid, String wsId, JSONArray jsonArray) { + List coeProcessLevelModels = CoeProcessLevelDaoFacotory.createCoeProcessLevel().getCoeProcessLevelByPid(pid, wsId); + for (int i = 0; i < coeProcessLevelModels.size(); i++) { + PALRepositoryModel coeProcessLevelModel = coeProcessLevelModels.get(i); + if (coeProcessLevelModel != null) { + JSONObject json = getJSon(coeProcessLevelModel); + jsonArray.add(json); + putAllNodeJson(coeProcessLevelModel.getId(), wsId, jsonArray); + } + } + } - public String designerRelevanceShapesInfo(String relationFileId, String shapeId, String attrId) { - ResponseObject ro = ResponseObject.newOkResponse(); - List> list = CoeDesignerUtil.getShapeMessageJson(relationFileId); - JSONObject json = new JSONObject(); - if (list != null && list.size() > 0) { - for (Map map : list) { - map.put("category", I18nRes.findValue(super.getContext().getLanguage(), (String) map.get("category"))); - } - - UtilMapSort mapSort = new UtilMapSort(); - mapSort.sort(list, "text", "string", null); - for (Map map : list) { - map.put("text", StringHandleUtil.replaceSpecialChart(map.get("text").toString())); - map.put("name", StringHandleUtil.replaceSpecialChart(map.get("name").toString())); - } - json.put("list", list); - ro.put("result", "ok"); - } else { - ro.put("result", "error"); - } - ro.setData(json); - return ro.toString(); - } + /** + * 获取tree json + * + * @param coeProcessLevelModel + * @param i + * @return + */ + private JSONObject getJSon(PALRepositoryModel coeProcessLevelModel) { + JSONObject rootJson = new JSONObject(); + rootJson.put("id", coeProcessLevelModel.getId()); + rootJson.put("pid", coeProcessLevelModel.getParentId()); + rootJson.put("plNo", CoeProcessLevelUtil.getProcessLevelNoByUUId(coeProcessLevelModel.getId(), coeProcessLevelModel.getWsId())); + rootJson.put("name", I18nRes.findValue(CoEConstant.APP_ID, super.getContext().getLanguage(), coeProcessLevelModel.getName())); + rootJson.put("title", rootJson.get("name") + " " + VersionUtil.getVersionStrV(coeProcessLevelModel.getVersion())); + rootJson.put("drop", false); + rootJson.put("isSystemFile", coeProcessLevelModel.isSystemFile()); + rootJson.put("plMethodId", coeProcessLevelModel.getMethodId()); + if (!"default".equals(coeProcessLevelModel.getMethodId())) { + if (PALMethodCache.getPALMethodModelById(coeProcessLevelModel.getMethodId()) == null) { + rootJson.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); + } else { + rootJson.put("icon", "../apps/" + PALMethodCache.getPALMethodModelById(coeProcessLevelModel.getMethodId()).getApp().getId() + "/img/method/" + coeProcessLevelModel.getMethodId() + "/16.png"); + } + } else { + rootJson.put("icon", "../apps/" + CoEConstant.APP_ID + "/img/method/default/16.png"); + } + rootJson.put("isParent", coeProcessLevelModel.isBottomLevel() == 0 ? true : false); + rootJson.put("plLevel", coeProcessLevelModel.getLevel()); + rootJson.put("plOrdexIndex", coeProcessLevelModel.getOrderIndex()); + rootJson.put("plDiagramUrl", coeProcessLevelModel.getDiagramUrl()); + rootJson.put("plSecurityR", coeProcessLevelModel.getPlSecurityR()); + rootJson.put("plSecurityW", coeProcessLevelModel.getPlSecurityW()); + rootJson.put("url", "./jd?sid=" + super.getContext().getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_info&ruuid=" + coeProcessLevelModel.getId() + "&uuid=" + coeProcessLevelModel.getId()); + rootJson.put("plCategory", coeProcessLevelModel.getMethodCategory()); + return rootJson; + } - public String designerRelevanceProcessModelsInfo(String uuid, String wsId) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject json = new JSONObject(); - List pList = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryModelsByPid(wsId, uuid); - List> list = new ArrayList<>(); - for (PALRepositoryModel model : pList) { + public String designerRelevanceShapesInfo(String relationFileId, String shapeId, String attrId) { + ResponseObject ro = ResponseObject.newOkResponse(); + List> list = CoeDesignerUtil.getShapeMessageJson(relationFileId); + JSONObject json = new JSONObject(); + if (list != null && list.size() > 0) { + for (Map map : list) { + map.put("category", I18nRes.findValue(super.getContext().getLanguage(), (String) map.get("category"))); + } + + UtilMapSort mapSort = new UtilMapSort(); + mapSort.sort(list, "text", "string", null); + for (Map map : list) { + map.put("text", StringHandleUtil.replaceSpecialChart(map.get("text").toString())); + map.put("name", StringHandleUtil.replaceSpecialChart(map.get("name").toString())); + } + json.put("list", list); + ro.put("result", "ok"); + } else { + ro.put("result", "error"); + } + ro.setData(json); + return ro.toString(); + } + + public String designerRelevanceProcessModelsInfo(String uuid, String wsId) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + List pList = PALRepositoryQueryAPIManager.getInstance().getUsedPalRepositoryModelsByPid(wsId, uuid); + List> list = new ArrayList<>(); + for (PALRepositoryModel model : pList) { // if ("default".equals(model.getMethodId())) { // continue; // } - Map map = new HashMap<>(); - map.put("id", model.getVersionId()); - map.put("text", model.getName()); - list.add(map); - } - json.put("list", list); - ro.put("result", "ok"); - ro.setData(json); - return ro.toString(); - } + Map map = new HashMap<>(); + map.put("id", model.getVersionId()); + map.put("text", model.getName()); + list.add(map); + } + json.put("list", list); + ro.put("result", "ok"); + ro.setData(json); + return ro.toString(); + } - // public void updateEventMap(com.alibaba.fastjson.JSONArray jsonArray, String uuid) { - // DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - // Map> map = event.getEventMap(); - // Set listJsonObj = map.get(uuid); - // if (listJsonObj == null) { - // listJsonObj = new HashSet(); - // - // } - // for (int j = 0; j < jsonArray.size(); j++) { - // com.alibaba.fastjson.JSONObject jsonObj = jsonArray.getJSONObject(j); - // listJsonObj.add(jsonObj); - // } - // map.put(uuid, listJsonObj); - // } - public void updateEventMap(JSONArray jsonArray, String uuid) { - DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); - Map> map = event.getEventMap(); - Set listJsonObj = map.get(uuid); - if (listJsonObj == null) { - listJsonObj = new HashSet(); + // public void updateEventMap(com.alibaba.fastjson.JSONArray jsonArray, String uuid) { + // DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + // Map> map = event.getEventMap(); + // Set listJsonObj = map.get(uuid); + // if (listJsonObj == null) { + // listJsonObj = new HashSet(); + // + // } + // for (int j = 0; j < jsonArray.size(); j++) { + // com.alibaba.fastjson.JSONObject jsonObj = jsonArray.getJSONObject(j); + // listJsonObj.add(jsonObj); + // } + // map.put(uuid, listJsonObj); + // } + public void updateEventMap(JSONArray jsonArray, String uuid) { + DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance(); + Map> map = event.getEventMap(); + Set listJsonObj = map.get(uuid); + if (listJsonObj == null) { + listJsonObj = new HashSet(); - } - for (int j = 0; j < jsonArray.size(); j++) { - JSONObject jsonObj = JSONObject.parseObject(jsonArray.getString(j)); - listJsonObj.add(jsonObj); - } - map.put(uuid, listJsonObj); - } + } + for (int j = 0; j < jsonArray.size(); j++) { + JSONObject jsonObj = JSONObject.parseObject(jsonArray.getString(j)); + listJsonObj.add(jsonObj); + } + map.put(uuid, listJsonObj); + } - /** - * 自定义复制 - * - * @param userId 用户id 如admin - * @param clientId 客户端id - * @param subject 文件id - * @param type 文件类型 - * @param ver 文件版本 - * @param shapeId 形状di - * @param messageJson 形状json 信息 - * @param shapeGroupId 组id - * @return - */ - public String respositoryDesignerRelationShapeCustomCopy(String userId, String clientId, String subject, String type, String ver, String shapeId, String messageJson, String shapeGroupId) { - DesignerShapeCopyCache copyCache = DesignerShapeCopyCache.getCache(); - boolean isAssigned = CoeProcessLevelUtil.hasAssigned(subject); - if (isAssigned) { - return "false"; - } + /** + * 自定义复制 + * + * @param userId 用户id 如admin + * @param clientId 客户端id + * @param subject 文件id + * @param type 文件类型 + * @param ver 文件版本 + * @param shapeId 形状di + * @param messageJson 形状json 信息 + * @param shapeGroupId 组id + * @return + */ + public String respositoryDesignerRelationShapeCustomCopy(String userId, String clientId, String subject, String type, String ver, String shapeId, String messageJson, String shapeGroupId) { + DesignerShapeCopyCache copyCache = DesignerShapeCopyCache.getCache(); + boolean isAssigned = CoeProcessLevelUtil.hasAssigned(subject); + if (isAssigned) { + return "false"; + } - HashMap relationShapeMap = new HashMap(); - relationShapeMap.put("shapeCustomCopyContent", messageJson);// 将传过来的图形信息保存到缓存中 - relationShapeMap.put("shapeTypeId", type); - relationShapeMap.put("shapeFileId", subject); - relationShapeMap.put("shapeCuntomCopyTime", Long.valueOf(System.currentTimeMillis())); - // 被动关联的信息存储 - getRelationShape(messageJson, relationShapeMap); - DesignerShapeCopyCache.getCache().put(userId, relationShapeMap); - return "true"; - } + HashMap relationShapeMap = new HashMap(); + relationShapeMap.put("shapeCustomCopyContent", messageJson);// 将传过来的图形信息保存到缓存中 + relationShapeMap.put("shapeTypeId", type); + relationShapeMap.put("shapeFileId", subject); + relationShapeMap.put("shapeCuntomCopyTime", Long.valueOf(System.currentTimeMillis())); + // 被动关联的信息存储 + getRelationShape(messageJson, relationShapeMap); + DesignerShapeCopyCache.getCache().put(userId, relationShapeMap); + return "true"; + } - /** - * 获取所有相关图形的被动关联信息 - */ - private void getRelationShape(String messageJson, Map relationShapeMap) { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(messageJson); - com.alibaba.fastjson.JSONArray shapeArray = new com.alibaba.fastjson.JSONArray(); - for (int i = 0; i < array.size(); i++) { - com.alibaba.fastjson.JSONObject shapeObject = array.getJSONObject(i); - if (shapeObject.getString("id") != null) { - List list = dao.getModelListByRelationShapeId(shapeObject.getString("id")); - for (DesignerShapeRelationModel model : list) { - com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); - object.put("fileId", model.getFileId()); - object.put("shapeId", model.getShapeId()); - object.put("shapeText", model.getShapeText()); - object.put("attrId", model.getAttrId()); - object.put("relationFileId", model.getRelationFileId()); - object.put("relationShapeId", model.getRelationShapeId()); - object.put("relationShapeText", model.getRelationShapeText()); - shapeArray.add(object); - } - } - } - relationShapeMap.put("relationShape", shapeArray); - } - - /** - * 自定义粘贴 - * - * @param userId 用户id 如admin - * @param clientId 客户端id - * @param subject 文件id - * @param type 文件类型 - * @param ver 文件版本 - * @return - */ - public String respositoryDesignerRelationShapeCustomPasteAjax(String userId, String clientId, String subject, String action, String type, String ver) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject json = new JSONObject(); - PALRepositoryModel levelModel = PALRepositoryCache.getCache().get(subject); - String shapeType = levelModel.getMethodId(); - if (DesignerShapeCopyCache.getCache().get(userId) != null) { - Map relationShapeMap = DesignerShapeCopyCache.getCache().get(userId); - String shapeFileId = (String) relationShapeMap.get("shapeFileId"); - Long shapeCuntomCopyTime = (Long) relationShapeMap.get("shapeCuntomCopyTime"); - Long shapeCopyTime = (Long) relationShapeMap.get("shapeCopyTime"); - levelModel = PALRepositoryCache.getCache().get(shapeFileId); - List elementList = null; - if ((shapeCopyTime != null && shapeCuntomCopyTime == null) || (shapeCuntomCopyTime != null && shapeCopyTime != null && shapeCuntomCopyTime < shapeCopyTime)) { - Object shapeCopyContent = relationShapeMap.get("shapeCopyContent");// 从缓存中取得对应用户的复制的图形信息 - if (shapeCopyContent != null) { - elementList = ShapeUtil.getShapeList((String) shapeCopyContent); - } - if (validationPaste(shapeType, levelModel.getMethodId(), subject, elementList) && validationIsNotSameRepository(shapeFileId, subject)) { - json.put("shape", (String) relationShapeMap.get("shapeCopyContent")); - json.put("result", "ok"); - json.put("copyContent", "shapeCopyContent"); - json.put("relationShape", relationShapeMap.get("relationShape"));// 返回被动关联数据 - } else { - json.put("result", "noShape"); - } - } else if ((shapeCuntomCopyTime != null && shapeCopyTime == null) || (shapeCuntomCopyTime != null && shapeCopyTime != null && shapeCuntomCopyTime > shapeCopyTime)) { - Object shapeCopyContent = relationShapeMap.get("shapeCustomCopyContent");// 从缓存中取得对应用户的复制的图形信息 - if (shapeCopyContent != null) { - elementList = ShapeUtil.getShapeList((String) shapeCopyContent); - } - if (validationPaste(shapeType, levelModel.getMethodId(), subject, elementList) && validationIsNotSameRepository((String) shapeFileId, subject)) { - json.put("shape", (String) relationShapeMap.get("shapeCustomCopyContent")); - json.put("result", "ok"); - json.put("copyContent", "shapeCustomCopyContent"); - json.put("relationShape", relationShapeMap.get("relationShape"));// 返回被动关联数据 - } else { - json.put("result", "noShape"); - } - } - } else { - json.put("result", "error"); - } - ro.setData(json); - return ro.toString(); - } + /** + * 获取所有相关图形的被动关联信息 + */ + private void getRelationShape(String messageJson, Map relationShapeMap) { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(messageJson); + com.alibaba.fastjson.JSONArray shapeArray = new com.alibaba.fastjson.JSONArray(); + for (int i = 0; i < array.size(); i++) { + com.alibaba.fastjson.JSONObject shapeObject = array.getJSONObject(i); + if (shapeObject.getString("id") != null) { + List list = dao.getModelListByRelationShapeId(shapeObject.getString("id")); + for (DesignerShapeRelationModel model : list) { + com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); + object.put("fileId", model.getFileId()); + object.put("shapeId", model.getShapeId()); + object.put("shapeText", model.getShapeText()); + object.put("attrId", model.getAttrId()); + object.put("relationFileId", model.getRelationFileId()); + object.put("relationShapeId", model.getRelationShapeId()); + object.put("relationShapeText", model.getRelationShapeText()); + shapeArray.add(object); + } + } + } + relationShapeMap.put("relationShape", shapeArray); + } - /** - * 判断使用哪种进行粘贴 - * - * @param userId 用户id 如admin - * @return - */ - public boolean respositoryDesignerRelationShapeUsed(String userId) { - boolean isAppearCopy = true; - DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); - Map> shapeMap = relationShapeCache.getShapemap(); - if (shapeMap.get(_uc.getUID()) != null && shapeMap.get(_uc.getUID()).get("shapeCopyContent") != null) { - isAppearCopy = true;// 默认为定义复制 - } else if (shapeMap.get(_uc.getUID()) != null && shapeMap.get(_uc.getUID()).get("shapeCustomCopyContent") != null) { - isAppearCopy = false;// 默认为定义复制 - } - return isAppearCopy; - } + /** + * 自定义粘贴 + * + * @param userId 用户id 如admin + * @param clientId 客户端id + * @param subject 文件id + * @param type 文件类型 + * @param ver 文件版本 + * @return + */ + public String respositoryDesignerRelationShapeCustomPasteAjax(String userId, String clientId, String subject, String action, String type, String ver) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + PALRepositoryModel levelModel = PALRepositoryCache.getCache().get(subject); + String shapeType = levelModel.getMethodId(); + if (DesignerShapeCopyCache.getCache().get(userId) != null) { + Map relationShapeMap = DesignerShapeCopyCache.getCache().get(userId); + String shapeFileId = (String) relationShapeMap.get("shapeFileId"); + Long shapeCuntomCopyTime = (Long) relationShapeMap.get("shapeCuntomCopyTime"); + Long shapeCopyTime = (Long) relationShapeMap.get("shapeCopyTime"); + levelModel = PALRepositoryCache.getCache().get(shapeFileId); + List elementList = null; + if ((shapeCopyTime != null && shapeCuntomCopyTime == null) || (shapeCuntomCopyTime != null && shapeCopyTime != null && shapeCuntomCopyTime < shapeCopyTime)) { + Object shapeCopyContent = relationShapeMap.get("shapeCopyContent");// 从缓存中取得对应用户的复制的图形信息 + if (shapeCopyContent != null) { + elementList = ShapeUtil.getShapeList((String) shapeCopyContent); + } + if (validationPaste(shapeType, levelModel.getMethodId(), subject, elementList) && validationIsNotSameRepository(shapeFileId, subject)) { + json.put("shape", (String) relationShapeMap.get("shapeCopyContent")); + json.put("result", "ok"); + json.put("copyContent", "shapeCopyContent"); + json.put("relationShape", relationShapeMap.get("relationShape"));// 返回被动关联数据 + } else { + json.put("result", "noShape"); + } + } else if ((shapeCuntomCopyTime != null && shapeCopyTime == null) || (shapeCuntomCopyTime != null && shapeCopyTime != null && shapeCuntomCopyTime > shapeCopyTime)) { + Object shapeCopyContent = relationShapeMap.get("shapeCustomCopyContent");// 从缓存中取得对应用户的复制的图形信息 + if (shapeCopyContent != null) { + elementList = ShapeUtil.getShapeList((String) shapeCopyContent); + } + if (validationPaste(shapeType, levelModel.getMethodId(), subject, elementList) && validationIsNotSameRepository((String) shapeFileId, subject)) { + json.put("shape", (String) relationShapeMap.get("shapeCustomCopyContent")); + json.put("result", "ok"); + json.put("copyContent", "shapeCustomCopyContent"); + json.put("relationShape", relationShapeMap.get("relationShape"));// 返回被动关联数据 + } else { + json.put("result", "noShape"); + } + } + } else { + json.put("result", "error"); + } + ro.setData(json); + return ro.toString(); + } - /** - * 更新关联形状的标题 - * - * @param messages - * @param uuid - */ - public void updateShapesName(JSONObject jsonObj, String uuid) { - // JSONObject jsonObj = JSONObject.fromObject(messages); - JSONArray jsonArr1 = jsonObj.getJSONArray("updates"); - if (jsonArr1.size() != 1) { - return; - } - JSONObject jsonObj2 = jsonArr1.getJSONObject(0); - String text = jsonObj2.getString("text"); - String shapeId = jsonObj2.getString("id"); - try { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - dao.updateByShapeId(uuid, shapeId, text); - dao.updateByRelationShapeId(uuid, shapeId, text); - } catch (Exception e) { - e.printStackTrace(); - } - } + /** + * 判断使用哪种进行粘贴 + * + * @param userId 用户id 如admin + * @return + */ + public boolean respositoryDesignerRelationShapeUsed(String userId) { + boolean isAppearCopy = true; + DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance(); + Map> shapeMap = relationShapeCache.getShapemap(); + if (shapeMap.get(_uc.getUID()) != null && shapeMap.get(_uc.getUID()).get("shapeCopyContent") != null) { + isAppearCopy = true;// 默认为定义复制 + } else if (shapeMap.get(_uc.getUID()) != null && shapeMap.get(_uc.getUID()).get("shapeCustomCopyContent") != null) { + isAppearCopy = false;// 默认为定义复制 + } + return isAppearCopy; + } - /** - * 关联关系的显示 - * - * @param shapeId 形状id - * @return - */ - public String respositoryDesignerRelationShapeRelevanceShow(String shapeId, String fileId) { - List list = DesignerShapeRelationCache.getListByRelationShapeId(fileId, shapeId); - - JSONArray resultArray = new JSONArray(); - if (list != null && list.size() > 0) { - for (DesignerShapeRelationModel model : list) { - if (!model.getRelationFileId().equals(fileId)) { - continue; - } - // 过滤在文件属性已经删除但是没在关联属性中删除的数据(设置关联时的缺陷处理) - if (UtilString.isEmpty(model.getShapeId())) { - PALRepositoryPropertyModel propertyModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getFileId(), model.getAttrId()); - if (propertyModel == null || UtilString.isEmpty(propertyModel.getPropertyValue())) { - continue; - } - } - JSONObject object = new JSONObject(); - object.put("id", model.getId()); - object.put("fileId", model.getFileId()); - PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getFileId()); - if (palModel != null) { - BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); - if (baseModel != null ) { - String define = baseModel.getDefinition(); - if (!define.contains(model.getShapeId())) { - continue; - } - } else { - continue; - } - object.put("fileName", palModel.getName()); - object.put("fileVersion", palModel.getVersion()); - object.put("fileVersionId", palModel.getVersionId()); - object.put("shapeId", model.getShapeId()); - object.put("shapeText", model.getShapeText()); - if (CoeCooperationAPIManager.getInstance().hasRepositoryPermision(model.getFileId())){ - //文件密级权限校验 - if(HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - CoeProcessLevelWeb web = new CoeProcessLevelWeb(_uc); - ResponseObject filePemission = web.checkFilePemission(model.getFileId()); - if (filePemission.isOk()){ - object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); - } - }else { - object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); - } - } - resultArray.add(object); - } - } - } - - List relationList = DesignerShapeRelationCache.getListByShapeId(fileId, shapeId); - if (relationList != null && relationList.size() > 0) { - for (DesignerShapeRelationModel model : relationList) { - if (!model.getFileId().equals(fileId)) { - continue; - } - JSONObject object = new JSONObject(); - object.put("id", model.getId()); - object.put("fileId", model.getRelationFileId()); - PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getRelationFileId()); - if (palModel != null) { - BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); - if (baseModel != null ) { - String define = baseModel.getDefinition(); - if (!define.contains(model.getShapeId())) { - continue; - } - } else { - continue; - } - object.put("fileName", palModel.getName()); - object.put("fileVersion", palModel.getVersion()); - object.put("fileVersionId", palModel.getVersionId()); - object.put("shapeId", model.getRelationShapeId()); - object.put("shapeText", model.getRelationShapeText()); - if (CoeCooperationAPIManager.getInstance().hasRepositoryPermision(model.getRelationFileId())){ - //文件密级权限校验 - if(HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()){ - CoeProcessLevelWeb web = new CoeProcessLevelWeb(_uc); - ResponseObject filePemission = web.checkFilePemission(model.getFileId()); - if (filePemission.isOk()){ - object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); - } - }else { - object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); - } - } - resultArray.add(object); - } - } - } - - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject json = new JSONObject(); - int size = resultArray.size(); - if (size == 0) { - json.put("result", "error"); - } else { - json.put("list", resultArray); - json.put("result", "ok"); - } - ro.setData(json); - return ro.toString(); - } + /** + * 更新关联形状的标题 + * + * @param messages + * @param uuid + */ + public void updateShapesName(JSONObject jsonObj, String uuid) { + // JSONObject jsonObj = JSONObject.fromObject(messages); + JSONArray jsonArr1 = jsonObj.getJSONArray("updates"); + if (jsonArr1.size() != 1) { + return; + } + JSONObject jsonObj2 = jsonArr1.getJSONObject(0); + String text = jsonObj2.getString("text"); + String shapeId = jsonObj2.getString("id"); + try { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + dao.updateByShapeId(uuid, shapeId, text); + dao.updateByRelationShapeId(uuid, shapeId, text); + } catch (Exception e) { + e.printStackTrace(); + } + } - /** - * 图形更多属性中,删除一些属性后,需要修改关联表中的关联 - * - * @param fileId - * @param shapeId - * @param attrIds 选中的属性key - * @author zhangming - */ - public String relationCheck(String fileId, String shapeId, String attrIds) { - List list = DesignerShapeRelationCache.getListByShapeId(fileId, shapeId); - if (list != null && list.size() > 0) { - List ids = new ArrayList(); - for (DesignerShapeRelationModel model : list) { - if (model.getShapeId().equals("")) { - continue; - } - String attrId = model.getAttrId(); - if (!attrIds.contains(attrId)) { - ids.add(model.getId()); - } - } - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - dao.deleteByIds(ids); - } - ResponseObject ro = ResponseObject.newOkResponse(); - return ro.toString(); - } - - public String relationSearch(String fileId, String shapeIds) { - StringBuilder relationShapes = new StringBuilder(""); - if (shapeIds != null && !"".equals(shapeIds)) { - String[] shapeArray = shapeIds.split(","); - for (String shapeId : shapeArray) { - Iterator iterator = DesignerShapeRelationCache.getByRelationShapeId(fileId, shapeId); - if (iterator.hasNext()) { - if (relationShapes.length() > 0) { - relationShapes.append(","); - } - relationShapes.append(iterator.next().getRelationShapeText()); - } - } - } - - ResponseObject ro = ResponseObject.newOkResponse(); - ro.put("relationShapes", relationShapes.toString()); - return ro.toString(); - } + /** + * 关联关系的显示 + * + * @param shapeId 形状id + * @return + */ + public String respositoryDesignerRelationShapeRelevanceShow(String shapeId, String fileId) { + List list = DesignerShapeRelationCache.getListByRelationShapeId(fileId, shapeId); - /** - * 查询形状节点的relation类型属性数据 - * @param fileId - * @param shapeId - * @param shapeName - * @param shapeCategory - * @return - */ - public String respositoryDesignerRelationShapeRelevanceName(String fileId, String shapeId, String shapeName, String shapeCategory) { - ResponseObject ro = ResponseObject.newOkResponse(); - PALRepositoryModel m = PALRepositoryCache.getCache().get(fileId); - if (m == null) { - throw new AWSObjectNotFindException("没有查找到关联的文件"); - } - String wsId = m.getWsId(); - if ("bpmn".equals(shapeCategory)) { - shapeCategory = "process.bpmn2"; - } - String shapeMethod = shapeCategory.replace("_", "."); - // 获取有效的属性内容 - List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, shapeMethod, shapeName, m.getMethodId()); - Map refMap = new HashMap(); - for (PALMethodAttributeModel model : attributeModelList) { - if ("relation".equals(model.getType())) { - refMap.put(model.getKey(), JSON.parseObject(model.getRef())); - } - } - List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(fileId, shapeId, null, null); - List modelList = new ArrayList(); - for (DesignerShapeRelationModel model : list) { - String attrId = model.getAttrId(); - if (refMap.containsKey(attrId)) { - String relationType = refMap.get(attrId).getString("type"); - if ("file".equals(relationType)) {// 关联的文件 - List list2 = PALRepositoryCache.getByVersionId(wsId, model.getRelationFileId()); - for (PALRepositoryModel model2 : list2) { - if (model2.isUse()) { - model.setRelationShapeText(model2.getName()); - model.setRelationFileId(model2.getId()); - break; - } - } - modelList.add(model); - } else { - modelList.add(model); - } - } - } - // 去重 - List tempList = new ArrayList(); - Set ids = new HashSet<>(); - for (DesignerShapeRelationModel model : modelList) { - String id = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId(); - if (!ids.contains(id)) { - tempList.add(model); - ids.add(id); - } - } - modelList = tempList; - ro.put("shapeRefObj", refMap); - ro.put("relationModelList", modelList); - return ro.toString(); - } + JSONArray resultArray = new JSONArray(); + if (list != null && list.size() > 0) { + for (DesignerShapeRelationModel model : list) { + if (!model.getRelationFileId().equals(fileId)) { + continue; + } + // 过滤在文件属性已经删除但是没在关联属性中删除的数据(设置关联时的缺陷处理) + if (UtilString.isEmpty(model.getShapeId())) { + PALRepositoryPropertyModel propertyModel = PALRepositoryPropertyCache.getPropertyByPropertyId(model.getFileId(), model.getAttrId()); + if (propertyModel == null || UtilString.isEmpty(propertyModel.getPropertyValue())) { + continue; + } + } + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("fileId", model.getFileId()); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getFileId()); + if (palModel != null) { + BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); + if (baseModel != null) { + String define = baseModel.getDefinition(); + if (!define.contains(model.getShapeId())) { + continue; + } + } else { + continue; + } + object.put("fileName", palModel.getName()); + object.put("fileVersion", palModel.getVersion()); + object.put("fileVersionId", palModel.getVersionId()); + object.put("shapeId", model.getShapeId()); + object.put("shapeText", model.getShapeText()); + if (CoeCooperationAPIManager.getInstance().hasRepositoryPermision(model.getFileId())) { + //文件密级权限校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + CoeProcessLevelWeb web = new CoeProcessLevelWeb(_uc); + ResponseObject filePemission = web.checkFilePemission(model.getFileId()); + if (filePemission.isOk()) { + object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); + } + } else { + object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); + } + } + resultArray.add(object); + } + } + } - /** - * 关联关系的保存 - * - * @param relationShapes 关联对象 - * @param shapeId 主动关联图形Id - * @param fileId 主动关联文件Id - * @param shapeGroupId - * @param attrId 关联属性Id - * @param ref 属性配置,属性的数据范围、单多选、关联类型 - * @return - */ - public String respositoryDesignerRelationShapeRelevanceSave(String relationShapes, String shapeId, String fileId, String shapeGroupId, String attrId, String ref) { - JSONObject refObj = JSONObject.parseObject(ref); - String relationType = refObj.getString("type"); - JSONArray relationDataArr = JSONArray.parseArray(relationShapes); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - List modelList = new ArrayList(); - try { - // 已保存节点删除 - dao.deleteByAttrId(fileId, shapeId, attrId); - for (int i = 0; i < relationDataArr.size(); i++) { - JSONObject object = relationDataArr.getJSONObject(i); - DesignerShapeRelationModel shapeRelationModel = new DesignerShapeRelationModel(); - shapeRelationModel.setId(UUIDGener.getUUID()); - shapeRelationModel.setFileId(object.getString("fileId")); - shapeRelationModel.setShapeId(object.getString("shapeId")); - shapeRelationModel.setShapeText(object.getString("shapeText")); - shapeRelationModel.setAttrId(object.getString("attrId")); - if ("file".equals(relationType)) { - String relationFileId = object.getString("relationFileId"); - // 不管relationFileId是文件ID还是文件VersionId,全部替换成versionId,兼容vue和非vue请求导致数据并不都是versionId的情况 - PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); - if (model == null) { - List models = PALRepositoryCache.getByVersionId(relationFileId); - if (models != null && models.size() > 0) { - relationFileId = models.get(0).getVersionId(); - } - } else { - relationFileId = model.getVersionId(); - } - shapeRelationModel.setRelationFileId(relationFileId); - shapeRelationModel.setRelationShapeId(""); - shapeRelationModel.setRelationShapeText(""); - } else { - shapeRelationModel.setRelationFileId(object.getString("relationFileId")); - shapeRelationModel.setRelationShapeId(object.getString("relationShapeId")); - shapeRelationModel.setRelationShapeText(object.getString("relationShapeText")); - } - dao.insert(shapeRelationModel); - shapeRelationModel.setRelationFileId(object.getString("relationFileId")); - shapeRelationModel.setRelationShapeText(object.getString("relationShapeText"));// 关联模型文件时该值为空,重新赋值 - modelList.add(shapeRelationModel); - } - } catch (Exception e) { - e.printStackTrace(); - ResponseObject responseObject = ResponseObject.newErrResponse("保存关联属性失败"); - return responseObject.toString(); - } - ResponseObject responseObject = ResponseObject.newOkResponse(); - responseObject.put("list", modelList); - return responseObject.toString(); - } + List relationList = DesignerShapeRelationCache.getListByShapeId(fileId, shapeId); + if (relationList != null && relationList.size() > 0) { + for (DesignerShapeRelationModel model : relationList) { + if (!model.getFileId().equals(fileId)) { + continue; + } + JSONObject object = new JSONObject(); + object.put("id", model.getId()); + object.put("fileId", model.getRelationFileId()); + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(model.getRelationFileId()); + if (palModel != null) { + BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); + if (baseModel != null) { + String define = baseModel.getDefinition(); + if (!define.contains(model.getShapeId())) { + continue; + } + } else { + continue; + } + object.put("fileName", palModel.getName()); + object.put("fileVersion", palModel.getVersion()); + object.put("fileVersionId", palModel.getVersionId()); + object.put("shapeId", model.getRelationShapeId()); + object.put("shapeText", model.getRelationShapeText()); + if (CoeCooperationAPIManager.getInstance().hasRepositoryPermision(model.getRelationFileId())) { + //文件密级权限校验 + if (HighSecurityUtil.isON() && HighSecurityUtil.fileSecuritySwitch()) { + CoeProcessLevelWeb web = new CoeProcessLevelWeb(_uc); + ResponseObject filePemission = web.checkFilePemission(model.getFileId()); + if (filePemission.isOk()) { + object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); + } + } else { + object.put("url", "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&uuid=" + model.getFileId() + "&openType=0&perms=w%2Cd%2Cv&filePerms=-"); + } + } + resultArray.add(object); + } + } + } - /** - * 关联与文件的关系 - * - * @param shapeList - * @param shapeId - * @return - */ - private List createAppearModel(List> shapeList, String shapeId) { - List l = new ArrayList(); - for (Map map : shapeList) { - if (shapeId.equals(map.get("shapeId"))) { - continue; - } - DesignerShapeFileRelationModel fileModel = new DesignerShapeFileRelationModel(); - fileModel.setUuid(map.get("shapeId")); - fileModel.setFileUUID(map.get("palRepositoryId")); - l.add(fileModel); - } - return l; - } + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject json = new JSONObject(); + int size = resultArray.size(); + if (size == 0) { + json.put("result", "error"); + } else { + json.put("list", resultArray); + json.put("result", "ok"); + } + ro.setData(json); + return ro.toString(); + } - /** - * 删除图形的某个关联属性 - * - * @param fileId - * @param shapeId - * @param attrId - * @return - */ - public String removeRelationByAttrId(String fileId, String shapeId, String attrId) { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - dao.deleteByAttrId(fileId, shapeId, attrId); - - ResponseObject ro = ResponseObject.newOkResponse(); - return ro.toString(); - } - - /** - * 粘贴时保存关联关系 - * @param shapeMap - * @return - */ - public String pasteRelationSave(String shapeMap, String relationShape, String pasteRelation) { - ResponseObject ro = ResponseObject.newOkResponse(); - // 主动关联关系处理 - JSONArray array = JSONArray.parseArray(shapeMap); - if (array.size() > 0) { - try { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - // 主动关联关系处理 - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - String copyShapeId = object.getString("copyShapeId"); - String pasteShapeId = object.getString("pasteShapeId"); - String pasteFileId = object.getString("pasteFileId"); - List list = dao.getModelListByShapeId(copyShapeId); - for (DesignerShapeRelationModel copyModel : list) { - DesignerShapeRelationModel pasteModel = new DesignerShapeRelationModel(); - pasteModel.setId(UUIDGener.getUUID()); - pasteModel.setFileId(pasteFileId); - pasteModel.setShapeId(pasteShapeId); - pasteModel.setShapeText(copyModel.getShapeText()); - pasteModel.setAttrId(copyModel.getAttrId()); - pasteModel.setRelationFileId(copyModel.getRelationFileId()); - pasteModel.setRelationShapeId(copyModel.getRelationShapeId()); - pasteModel.setRelationShapeText(copyModel.getRelationShapeText()); - dao.insert(pasteModel); - } - - } - } catch (Exception e) { - e.printStackTrace(); - return ResponseObject.newErrResponse("主动关联关系保存数据库失败").toString(); - } - // 被动关联关系处理 - if("true".equals(pasteRelation)) { - JSONArray jsArray = JSONArray.parseArray(relationShape); + /** + * 图形更多属性中,删除一些属性后,需要修改关联表中的关联 + * + * @param fileId + * @param shapeId + * @param attrIds 选中的属性key + * @author zhangming + */ + public String relationCheck(String fileId, String shapeId, String attrIds) { + List list = DesignerShapeRelationCache.getListByShapeId(fileId, shapeId); + if (list != null && list.size() > 0) { + List ids = new ArrayList(); + for (DesignerShapeRelationModel model : list) { + if (model.getShapeId().equals("")) { + continue; + } + String attrId = model.getAttrId(); + if (!attrIds.contains(attrId)) { + ids.add(model.getId()); + } + } + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + dao.deleteByIds(ids); + } + ResponseObject ro = ResponseObject.newOkResponse(); + return ro.toString(); + } + + public String relationSearch(String fileId, String shapeIds) { + StringBuilder relationShapes = new StringBuilder(""); + if (shapeIds != null && !"".equals(shapeIds)) { + String[] shapeArray = shapeIds.split(","); + for (String shapeId : shapeArray) { + Iterator iterator = DesignerShapeRelationCache.getByRelationShapeId(fileId, shapeId); + if (iterator.hasNext()) { + if (relationShapes.length() > 0) { + relationShapes.append(","); + } + relationShapes.append(iterator.next().getRelationShapeText()); + } + } + } + + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("relationShapes", relationShapes.toString()); + return ro.toString(); + } + + /** + * 查询形状节点的relation类型属性数据 + * + * @param fileId + * @param shapeId + * @param shapeName + * @param shapeCategory + * @return + */ + public String respositoryDesignerRelationShapeRelevanceName(String fileId, String shapeId, String shapeName, String shapeCategory) { + ResponseObject ro = ResponseObject.newOkResponse(); + PALRepositoryModel m = PALRepositoryCache.getCache().get(fileId); + if (m == null) { + throw new AWSObjectNotFindException("没有查找到关联的文件"); + } + String wsId = m.getWsId(); + if ("bpmn".equals(shapeCategory)) { + shapeCategory = "process.bpmn2"; + } + String shapeMethod = shapeCategory.replace("_", "."); + // 获取有效的属性内容 + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, shapeMethod, shapeName, m.getMethodId()); + Map refMap = new HashMap(); + for (PALMethodAttributeModel model : attributeModelList) { + if ("relation".equals(model.getType())) { + refMap.put(model.getKey(), JSON.parseObject(model.getRef())); + } + } + List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(fileId, shapeId, null, null); + List modelList = new ArrayList(); + for (DesignerShapeRelationModel model : list) { + String attrId = model.getAttrId(); + if (refMap.containsKey(attrId)) { + String relationType = refMap.get(attrId).getString("type"); + if ("file".equals(relationType)) {// 关联的文件 + List list2 = PALRepositoryCache.getByVersionId(wsId, model.getRelationFileId()); + for (PALRepositoryModel model2 : list2) { + if (model2.isUse()) { + model.setRelationShapeText(model2.getName()); + model.setRelationFileId(model2.getId()); + break; + } + } + modelList.add(model); + } else { + modelList.add(model); + } + } + } + // 去重 + List tempList = new ArrayList(); + Set ids = new HashSet<>(); + for (DesignerShapeRelationModel model : modelList) { + String id = model.getFileId() + model.getShapeId() + model.getAttrId() + model.getRelationFileId() + model.getRelationShapeId(); + if (!ids.contains(id)) { + tempList.add(model); + ids.add(id); + } + } + modelList = tempList; + ro.put("shapeRefObj", refMap); + ro.put("relationModelList", modelList); + return ro.toString(); + } + + /** + * 关联关系的保存 + * + * @param relationShapes 关联对象 + * @param shapeId 主动关联图形Id + * @param fileId 主动关联文件Id + * @param shapeGroupId + * @param attrId 关联属性Id + * @param ref 属性配置,属性的数据范围、单多选、关联类型 + * @return + */ + public String respositoryDesignerRelationShapeRelevanceSave(String relationShapes, String shapeId, String fileId, String shapeGroupId, String attrId, String ref) { + JSONObject refObj = JSONObject.parseObject(ref); + String relationType = refObj.getString("type"); + JSONArray relationDataArr = JSONArray.parseArray(relationShapes); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + List modelList = new ArrayList(); + try { + // 已保存节点删除 + dao.deleteByAttrId(fileId, shapeId, attrId); + for (int i = 0; i < relationDataArr.size(); i++) { + JSONObject object = relationDataArr.getJSONObject(i); + DesignerShapeRelationModel shapeRelationModel = new DesignerShapeRelationModel(); + shapeRelationModel.setId(UUIDGener.getUUID()); + shapeRelationModel.setFileId(object.getString("fileId")); + shapeRelationModel.setShapeId(object.getString("shapeId")); + shapeRelationModel.setShapeText(object.getString("shapeText")); + shapeRelationModel.setAttrId(object.getString("attrId")); + if ("file".equals(relationType)) { + String relationFileId = object.getString("relationFileId"); + // 不管relationFileId是文件ID还是文件VersionId,全部替换成versionId,兼容vue和非vue请求导致数据并不都是versionId的情况 + PALRepositoryModel model = PALRepositoryCache.getCache().get(relationFileId); + if (model == null) { + List models = PALRepositoryCache.getByVersionId(relationFileId); + if (models != null && models.size() > 0) { + relationFileId = models.get(0).getVersionId(); + } + } else { + relationFileId = model.getVersionId(); + } + shapeRelationModel.setRelationFileId(relationFileId); + shapeRelationModel.setRelationShapeId(""); + shapeRelationModel.setRelationShapeText(""); + } else { + shapeRelationModel.setRelationFileId(object.getString("relationFileId")); + shapeRelationModel.setRelationShapeId(object.getString("relationShapeId")); + shapeRelationModel.setRelationShapeText(object.getString("relationShapeText")); + } + dao.insert(shapeRelationModel); + shapeRelationModel.setRelationFileId(object.getString("relationFileId")); + shapeRelationModel.setRelationShapeText(object.getString("relationShapeText"));// 关联模型文件时该值为空,重新赋值 + modelList.add(shapeRelationModel); + } + } catch (Exception e) { + e.printStackTrace(); + ResponseObject responseObject = ResponseObject.newErrResponse("保存关联属性失败"); + return responseObject.toString(); + } + ResponseObject responseObject = ResponseObject.newOkResponse(); + responseObject.put("list", modelList); + return responseObject.toString(); + } + + /** + * 关联与文件的关系 + * + * @param shapeList + * @param shapeId + * @return + */ + private List createAppearModel(List> shapeList, String shapeId) { + List l = new ArrayList(); + for (Map map : shapeList) { + if (shapeId.equals(map.get("shapeId"))) { + continue; + } + DesignerShapeFileRelationModel fileModel = new DesignerShapeFileRelationModel(); + fileModel.setUuid(map.get("shapeId")); + fileModel.setFileUUID(map.get("palRepositoryId")); + l.add(fileModel); + } + return l; + } + + /** + * 删除图形的某个关联属性 + * + * @param fileId + * @param shapeId + * @param attrId + * @return + */ + public String removeRelationByAttrId(String fileId, String shapeId, String attrId) { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + dao.deleteByAttrId(fileId, shapeId, attrId); + + ResponseObject ro = ResponseObject.newOkResponse(); + return ro.toString(); + } + + /** + * 粘贴时保存关联关系 + * + * @param shapeMap + * @return + */ + public String pasteRelationSave(String shapeMap, String relationShape, String pasteRelation) { + ResponseObject ro = ResponseObject.newOkResponse(); + // 主动关联关系处理 + JSONArray array = JSONArray.parseArray(shapeMap); + if (array.size() > 0) { + try { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + // 主动关联关系处理 + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + String copyShapeId = object.getString("copyShapeId"); + String pasteShapeId = object.getString("pasteShapeId"); + String pasteFileId = object.getString("pasteFileId"); + List list = dao.getModelListByShapeId(copyShapeId); + for (DesignerShapeRelationModel copyModel : list) { + DesignerShapeRelationModel pasteModel = new DesignerShapeRelationModel(); + pasteModel.setId(UUIDGener.getUUID()); + pasteModel.setFileId(pasteFileId); + pasteModel.setShapeId(pasteShapeId); + pasteModel.setShapeText(copyModel.getShapeText()); + pasteModel.setAttrId(copyModel.getAttrId()); + pasteModel.setRelationFileId(copyModel.getRelationFileId()); + pasteModel.setRelationShapeId(copyModel.getRelationShapeId()); + pasteModel.setRelationShapeText(copyModel.getRelationShapeText()); + dao.insert(pasteModel); + } + + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse("主动关联关系保存数据库失败").toString(); + } + // 被动关联关系处理 + if ("true".equals(pasteRelation)) { + JSONArray jsArray = JSONArray.parseArray(relationShape); // System.out.println("被动关联的关联关系---" + jsArray); - List list = new ArrayList<>(); - try { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - // 关联关系存入数据库 - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - String copyShapeId = object.getString("copyShapeId"); - String pasteShapeId = object.getString("pasteShapeId"); - String pasteFileId = object.getString("pasteFileId"); - for (int j = 0; j < jsArray.size(); j++) { - JSONObject object2 = jsArray.getJSONObject(j); - if (!object2.getString("relationShapeId").equals(copyShapeId)) { - continue; - } - DesignerShapeRelationModel relationPasteModel = new DesignerShapeRelationModel(); - relationPasteModel.setId(UUIDGener.getUUID()); - relationPasteModel.setFileId(object2.getString("fileId")); - relationPasteModel.setShapeId(object2.getString("shapeId")); - relationPasteModel.setShapeText(object2.getString("shapeText")); - relationPasteModel.setAttrId(object2.getString("attrId")); - relationPasteModel.setRelationFileId(pasteFileId); - relationPasteModel.setRelationShapeId(pasteShapeId); - relationPasteModel.setRelationShapeText(object2.getString("relationShapeText")); - dao.insert(relationPasteModel); - list.add(relationPasteModel); - } - } - } catch (Exception e) { - e.printStackTrace(); - return ResponseObject.newErrResponse("被动关联关系保存数据库失败").toString(); - } - // 关联关系存到相关模型文件 - if (list.size() > 0) { - Set savedFile = new HashSet<>();// 记录更新成功的文件id - Set fileIds = new HashSet<>();// 记录文件id - for (DesignerShapeRelationModel model : list) { - fileIds.add(model.getFileId()); - } - try { - for (String fileId : fileIds) { - PALRepositoryModel palModel = PALRepositoryCache.getCache().get(fileId); - if (palModel == null) { - break; - } - BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); - if (model == null) { - break; - } - String define = model.getDefinition(); - JSONObject definition = JSONObject.parseObject(define); - JSONObject elements = definition.getJSONObject("elements"); - Iterator it = elements.keySet().iterator(); - while (it.hasNext()) { - String key = it.next(); - JSONObject shape = elements.getJSONObject(key); - String shapeName = shape.getString("name"); - for (DesignerShapeRelationModel model2 : list) { - if (!model2.getFileId().equals(fileId)) { - continue; - } - if (shape.getString("id").equals(model2.getShapeId())) { - if(!"linker".equals(shapeName)) { - shape = updateShapeAttribute(shape, model2); - elements.put(key, shape); - } - } - } - } - // 保存文件 - model.setDefinition(definition.toString()); - CoeDesignerAPIManager.getInstance().storeDefinition(model);// dao操作 - savedFile.add(fileId); - } - } catch (Exception e) { - e.printStackTrace(); - return ResponseObject.newErrResponse("更新被动关联关系相关流程文件失败").toString(); - } - JSONArray jArray = new JSONArray(); - if (savedFile.size() > 0) { - for (String fileId : savedFile) { - PALRepositoryModel palModel = PALRepositoryCache.getCache().get(fileId); - if (palModel != null) { - JSONObject object = new JSONObject(); - object.put("id", palModel.getId()); - object.put("name", palModel.getName() + " " + VersionUtil.getVersionStrV(palModel.getVersion()) ); - jArray.add(object); - } - } - } - ro.put("updated", jArray); - } - } - } - return ro.toString(); - } - - /** - * 更新图形属性 - * @param shape - * @param list - * @return - */ - private JSONObject updateShapeAttribute(JSONObject shape, DesignerShapeRelationModel model2) { - if (shape.get("dataAttributes") != null) { - JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); - if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) { - for (Object object : dataAttributes) { - JSONObject obj = (JSONObject) object; - if (obj.containsKey("attributesJsonArray")) { - JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray"); - for (int i = 0; i < attributesJsonArray.size(); i++) { - JSONObject object2 = attributesJsonArray.getJSONObject(i); - if(object2 == null || "null".equals(object2.toString())) { - continue; //attributesJsonArray包含空时,跳过空 - } - if (object2.getString("id").equals(model2.getAttrId())) { - if ("".equals(object2.getJSONArray("value"))) { // 空值直接跳过 - continue; - } - JSONArray jArray = object2.getJSONArray("value"); - if (jArray.size() > 0) { - if (jArray.contains(model2.getRelationShapeId())) { - continue; - } - jArray.add(model2.getRelationShapeId()); - } - } - } - } - } - } - } - if(shape.get("attributesJsonArray") != null) { - JSONArray attributesJsonArray = shape.getJSONArray("attributesJsonArray"); - for (int i = 0; i < attributesJsonArray.size(); i++) { - JSONObject object2 = attributesJsonArray.getJSONObject(i); - if(object2 == null || "null".equals(object2.toString())) { - continue; //attributesJsonArray包含空时,跳过空 - } - if (object2.getString("id").equals(model2.getAttrId())) { - if ("".equals(object2.getJSONArray("value"))) { // 空值直接跳过 - continue; - } - JSONArray jArray = object2.getJSONArray("value"); - if (jArray.size() > 0) { - if (jArray.contains(model2.getRelationShapeId())) { - continue; - } - jArray.add(model2.getRelationShapeId()); - } - } - } - } - return shape; - } - - /** - * 根据流程源文件校验节点关联属性是否存在有关联节点id但是数据库无该关联信息的情况 - * 根据流程源文件反向插入关联数据到APP_ACT_COE_PAL_SHAPE_RLAT - * @param wsId - * @return - */ - public String checkAndRepairShapeRelation(String wsId) { - ResponseObject ro = ResponseObject.newOkResponse(); - // 获取所有模型与节点的对应关系 + List list = new ArrayList<>(); + try { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + // 关联关系存入数据库 + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + String copyShapeId = object.getString("copyShapeId"); + String pasteShapeId = object.getString("pasteShapeId"); + String pasteFileId = object.getString("pasteFileId"); + for (int j = 0; j < jsArray.size(); j++) { + JSONObject object2 = jsArray.getJSONObject(j); + if (!object2.getString("relationShapeId").equals(copyShapeId)) { + continue; + } + DesignerShapeRelationModel relationPasteModel = new DesignerShapeRelationModel(); + relationPasteModel.setId(UUIDGener.getUUID()); + relationPasteModel.setFileId(object2.getString("fileId")); + relationPasteModel.setShapeId(object2.getString("shapeId")); + relationPasteModel.setShapeText(object2.getString("shapeText")); + relationPasteModel.setAttrId(object2.getString("attrId")); + relationPasteModel.setRelationFileId(pasteFileId); + relationPasteModel.setRelationShapeId(pasteShapeId); + relationPasteModel.setRelationShapeText(object2.getString("relationShapeText")); + dao.insert(relationPasteModel); + list.add(relationPasteModel); + } + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse("被动关联关系保存数据库失败").toString(); + } + // 关联关系存到相关模型文件 + if (list.size() > 0) { + Set savedFile = new HashSet<>();// 记录更新成功的文件id + Set fileIds = new HashSet<>();// 记录文件id + for (DesignerShapeRelationModel model : list) { + fileIds.add(model.getFileId()); + } + try { + for (String fileId : fileIds) { + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(fileId); + if (palModel == null) { + break; + } + BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(palModel.getId(), 0); + if (model == null) { + break; + } + String define = model.getDefinition(); + JSONObject definition = JSONObject.parseObject(define); + JSONObject elements = definition.getJSONObject("elements"); + Iterator it = elements.keySet().iterator(); + while (it.hasNext()) { + String key = it.next(); + JSONObject shape = elements.getJSONObject(key); + String shapeName = shape.getString("name"); + for (DesignerShapeRelationModel model2 : list) { + if (!model2.getFileId().equals(fileId)) { + continue; + } + if (shape.getString("id").equals(model2.getShapeId())) { + if (!"linker".equals(shapeName)) { + shape = updateShapeAttribute(shape, model2); + elements.put(key, shape); + } + } + } + } + // 保存文件 + model.setDefinition(definition.toString()); + CoeDesignerAPIManager.getInstance().storeDefinition(model);// dao操作 + savedFile.add(fileId); + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseObject.newErrResponse("更新被动关联关系相关流程文件失败").toString(); + } + JSONArray jArray = new JSONArray(); + if (savedFile.size() > 0) { + for (String fileId : savedFile) { + PALRepositoryModel palModel = PALRepositoryCache.getCache().get(fileId); + if (palModel != null) { + JSONObject object = new JSONObject(); + object.put("id", palModel.getId()); + object.put("name", palModel.getName() + " " + VersionUtil.getVersionStrV(palModel.getVersion())); + jArray.add(object); + } + } + } + ro.put("updated", jArray); + } + } + } + return ro.toString(); + } + + /** + * 更新图形属性 + * + * @param shape + * @param list + * @return + */ + private JSONObject updateShapeAttribute(JSONObject shape, DesignerShapeRelationModel model2) { + if (shape.get("dataAttributes") != null) { + JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); + if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) { + for (Object object : dataAttributes) { + JSONObject obj = (JSONObject) object; + if (obj.containsKey("attributesJsonArray")) { + JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray"); + for (int i = 0; i < attributesJsonArray.size(); i++) { + JSONObject object2 = attributesJsonArray.getJSONObject(i); + if (object2 == null || "null".equals(object2.toString())) { + continue; //attributesJsonArray包含空时,跳过空 + } + if (object2.getString("id").equals(model2.getAttrId())) { + if ("".equals(object2.getJSONArray("value"))) { // 空值直接跳过 + continue; + } + JSONArray jArray = object2.getJSONArray("value"); + if (jArray.size() > 0) { + if (jArray.contains(model2.getRelationShapeId())) { + continue; + } + jArray.add(model2.getRelationShapeId()); + } + } + } + } + } + } + } + if (shape.get("attributesJsonArray") != null) { + JSONArray attributesJsonArray = shape.getJSONArray("attributesJsonArray"); + for (int i = 0; i < attributesJsonArray.size(); i++) { + JSONObject object2 = attributesJsonArray.getJSONObject(i); + if (object2 == null || "null".equals(object2.toString())) { + continue; //attributesJsonArray包含空时,跳过空 + } + if (object2.getString("id").equals(model2.getAttrId())) { + if ("".equals(object2.getJSONArray("value"))) { // 空值直接跳过 + continue; + } + JSONArray jArray = object2.getJSONArray("value"); + if (jArray.size() > 0) { + if (jArray.contains(model2.getRelationShapeId())) { + continue; + } + jArray.add(model2.getRelationShapeId()); + } + } + } + } + return shape; + } + + /** + * 根据流程源文件校验节点关联属性是否存在有关联节点id但是数据库无该关联信息的情况 + * 根据流程源文件反向插入关联数据到APP_ACT_COE_PAL_SHAPE_RLAT + * + * @param wsId + * @return + */ + public String checkAndRepairShapeRelation(String wsId) { + ResponseObject ro = ResponseObject.newOkResponse(); + // 获取所有模型与节点的对应关系 // System.out.println("关联关系DB数据恢复"); // System.out.println("资产库Id:"+ wsId); // System.out.println("查询资产库下所有模型的节点"); - long a = System.currentTimeMillis(); - Iterator models = PALRepositoryCache.getCache().getByWsId(wsId); - Map shapeIdMap = new HashMap<>(); - Map shapeNameMap = new HashMap<>(); - while (models.hasNext()) { - PALRepositoryModel model = models.next(); - if (model == null || "default".equals(model.getMethodId()) || model.getFilePath() == null || "".equals(model.getFilePath())) { - continue; - } - List> list2 = CoeDesignerUtil.getShapeMessageJson2(model.getId()); - if (list2 == null || list2.size() == 0) continue; - for (Map map : list2) { - if (map != null) { - shapeIdMap.put((String)map.get("id"), model.getId()); - shapeNameMap.put((String)map.get("id"), (String)map.get("name")); - } - } - } - System.out.println("节点个数:" + shapeIdMap.size()); - System.out.println("查询时长:" + (System.currentTimeMillis() - a) + "ms"); - System.out.println("查询数据库中被删除的节点关联数据"); - Iterator list = PALRepositoryCache.getCache().getByWsId(wsId); - int count = 0; - com.alibaba.fastjson.JSONArray result = new com.alibaba.fastjson.JSONArray(); - com.alibaba.fastjson.JSONArray dataError = new com.alibaba.fastjson.JSONArray(); - while (list.hasNext()) { - PALRepositoryModel model = list.next(); - if (model == null || "default".equals(model.getMethodId()) || model.getFilePath() == null || "".equals(model.getFilePath())) { - continue; - } - // 获取文件 - List> list2 = CoeDesignerUtil.getShapeMessageJson2(model.getId()); - if (list2 == null || list2.size() == 0) continue; - for (Map map : list2) { - if (map != null) { - com.alibaba.fastjson.JSONObject attr = (com.alibaba.fastjson.JSONObject)map.get("attributes"); - if (attr != null && !attr.isEmpty()) { - if (attr.containsKey("attributesJsonArray")) { - com.alibaba.fastjson.JSONArray attrJson = attr.getJSONArray("attributesJsonArray"); - for (int i = 0; i < attrJson.size(); i++) { - com.alibaba.fastjson.JSONObject object = attrJson.getJSONObject(i); - if (object == null || "null".equals(object.toString())) { - continue; //跳过attributesJsonArray内的空内容 - } - String id = object.getString("id"); - String type = object.getString("type"); - if ("relation".equals(type)) { - Object value = (Object) object.get("value"); - if ("".equals(value)) { - continue; - } - if(!(value instanceof com.alibaba.fastjson.JSONArray)) { - com.alibaba.fastjson.JSONObject dataErrorObj = new com.alibaba.fastjson.JSONObject(); - dataErrorObj.put("msg", "模型源文件关系属性格式无法解析"); - dataErrorObj.put("id", model.getId()); - dataErrorObj.put("name", model.getName() +" "+ VersionUtil.getVersionStrV(model.getVersion())); - dataErrorObj.put("shapeId", map.get("id")); - dataErrorObj.put("shapeName", map.get("name")); - dataErrorObj.put("attrId", id); - dataError.add(dataErrorObj); - continue; - } - com.alibaba.fastjson.JSONArray values = (com.alibaba.fastjson.JSONArray)value; - - List relationModels = DesignerShapeRelationCache.getListByAttrId(model.getId(), (String)map.get("id"), id); - for (int j = 0; j < values.size(); j++) { - String v = values.getString(j); - boolean flag = true; - for (DesignerShapeRelationModel designerShapeRelationModel : relationModels) { - if(designerShapeRelationModel.getRelationShapeId().equals(v)) { - flag = false; - break; - } - } - if (flag) {// 数据库中没有该关联属性 - com.alibaba.fastjson.JSONObject object2 = new com.alibaba.fastjson.JSONObject(); - object2.put("processId", model.getId()); - object2.put("processName", model.getName()); - object2.put("processVer", VersionUtil.getVersionStr(model.getVersion())); - // 以下为关联信息 - object2.put("id", UUIDGener.getUUID()); - object2.put("fileId", model.getId()); - object2.put("shapeId", (String)map.get("id")); - object2.put("shapeText", (String)map.get("name")); - object2.put("attrId", id); - object2.put("relationShapeId", v); - - String relationFileId = ""; - String relationShapeText = ""; - if("rear_process".equals(id) || "lead_process".equals(id)) { // 前置流程后置流程 - PALRepositoryModel model2 = PALRepositoryCache.getCache().get(v); - if (model2 != null) { // model2为空跳过 - relationFileId = model2.getParentId(); - relationShapeText = model2.getName(); - } - } else {//节点关联 - relationFileId = (String)shapeIdMap.get(v); - relationShapeText = (String)shapeNameMap.get(v); - } - if (relationFileId != null && !"".equals(relationFileId)) { - count++; - object2.put("relationFileId", relationFileId); - object2.put("relationShapeText", relationShapeText); - result.add(object2); - } - } - } - } - } - } - } - - } - } - } - System.out.println("被删除个数" + count); - if(count == 0) { // 关联关系正常 - ro.put("result", "normal"); - } else { - ro.put("result", "exception"); - } - ro.put("count", count); - ro.put("lossData", result); - ro.put("errorData", dataError); - System.out.println("被删除数据:"); - System.out.println(result.toString()); - System.out.println("解析失败模型:"); - System.out.println(dataError.toString()); - - return ro.toString(); - } - - /** - * 关联关系DB数据恢复 - * @param lossData - * @return - */ - public String shapeRelationRestore(String lossData) { - ResponseObject ro = ResponseObject.newOkResponse(); - com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(lossData); - int status = 0; - if(!array.isEmpty() && array.size() > 0) { - List list = new ArrayList<>(); - for (int i = 0; i < array.size(); i++) { - com.alibaba.fastjson.JSONObject object = array.getJSONObject(i); - if (object == null || object.isEmpty()) continue; - DesignerShapeRelationModel model = new DesignerShapeRelationModel(); - model.setId(object.getString("id")); - model.setFileId(object.getString("fileId")); - model.setShapeId(object.getString("shapeId")); - model.setShapeText(object.getString("shapeText")); - model.setAttrId(object.getString("attrId")); - model.setRelationFileId(object.getString("relationFileId")); - model.setRelationShapeId(object.getString("relationShapeId")); - model.setRelationShapeText(object.getString("relationShapeText")); - list.add(model); - } - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - boolean flag = dao.barchInsert(list); - if (flag) { - status = 2;//成功 - } else { - status = 3;//失败 - } - } else { - status = 1;// 无数据 - } - if (status == 1) { - ro.put("result", "ok"); - ro.put("msg", "没有需要恢复的数据"); - } if (status == 2) { - ro.put("result", "ok"); - ro.put("msg", "恢复成功"); - } else { - ro.put("result", "error"); - ro.put("msg", "恢复失败"); - } - return ro.toString(); - } - - /** - * 手工保存流程时更新/删除图形的关联关系 - * @param uuid 流程id - * @param messages - * @return - */ - public void updateDesignerRelationText(String uuid, String messages) { - Map updateMap = new HashMap<>(); - Map deleteMap = new HashMap<>(); - JSONObject mesageObject = JSONObject.parseObject(messages); - Iterator iterator = mesageObject.keySet().iterator(); - while (iterator.hasNext()) { - String shapeId = iterator.next(); - JSONObject shape = JSONObject.parseObject(mesageObject.getString(shapeId)); - if (DesignerShapeRelationCache.getByRelationShapeId(uuid, shapeId).hasNext() || DesignerShapeRelationCache.getByShapeId(uuid, shapeId).hasNext()) { - if ("create".equals(shape.getString("action")) || "update".equals(shape.getString("action"))) { - updateMap.put(shapeId, shape.getString("name")); - } - if ("remove".equals(shape.getString("action"))) { - deleteMap.put(shapeId, shape.getString("name")); - } - } - } - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - if (!deleteMap.isEmpty()) { - dao.batchDeleteByShapeId(uuid, deleteMap); - } - if (!updateMap.isEmpty()) { - dao.batchUpdateByShapeId(uuid, updateMap); - dao.batchUpdateByRelationShapeId(uuid, updateMap); - } - } + long a = System.currentTimeMillis(); + Iterator models = PALRepositoryCache.getCache().getByWsId(wsId); + Map shapeIdMap = new HashMap<>(); + Map shapeNameMap = new HashMap<>(); + while (models.hasNext()) { + PALRepositoryModel model = models.next(); + if (model == null || "default".equals(model.getMethodId()) || model.getFilePath() == null || "".equals(model.getFilePath())) { + continue; + } + List> list2 = CoeDesignerUtil.getShapeMessageJson2(model.getId()); + if (list2 == null || list2.size() == 0) continue; + for (Map map : list2) { + if (map != null) { + shapeIdMap.put((String) map.get("id"), model.getId()); + shapeNameMap.put((String) map.get("id"), (String) map.get("name")); + } + } + } + System.out.println("节点个数:" + shapeIdMap.size()); + System.out.println("查询时长:" + (System.currentTimeMillis() - a) + "ms"); + System.out.println("查询数据库中被删除的节点关联数据"); + Iterator list = PALRepositoryCache.getCache().getByWsId(wsId); + int count = 0; + com.alibaba.fastjson.JSONArray result = new com.alibaba.fastjson.JSONArray(); + com.alibaba.fastjson.JSONArray dataError = new com.alibaba.fastjson.JSONArray(); + while (list.hasNext()) { + PALRepositoryModel model = list.next(); + if (model == null || "default".equals(model.getMethodId()) || model.getFilePath() == null || "".equals(model.getFilePath())) { + continue; + } + // 获取文件 + List> list2 = CoeDesignerUtil.getShapeMessageJson2(model.getId()); + if (list2 == null || list2.size() == 0) continue; + for (Map map : list2) { + if (map != null) { + com.alibaba.fastjson.JSONObject attr = (com.alibaba.fastjson.JSONObject) map.get("attributes"); + if (attr != null && !attr.isEmpty()) { + if (attr.containsKey("attributesJsonArray")) { + com.alibaba.fastjson.JSONArray attrJson = attr.getJSONArray("attributesJsonArray"); + for (int i = 0; i < attrJson.size(); i++) { + com.alibaba.fastjson.JSONObject object = attrJson.getJSONObject(i); + if (object == null || "null".equals(object.toString())) { + continue; //跳过attributesJsonArray内的空内容 + } + String id = object.getString("id"); + String type = object.getString("type"); + if ("relation".equals(type)) { + Object value = (Object) object.get("value"); + if ("".equals(value)) { + continue; + } + if (!(value instanceof com.alibaba.fastjson.JSONArray)) { + com.alibaba.fastjson.JSONObject dataErrorObj = new com.alibaba.fastjson.JSONObject(); + dataErrorObj.put("msg", "模型源文件关系属性格式无法解析"); + dataErrorObj.put("id", model.getId()); + dataErrorObj.put("name", model.getName() + " " + VersionUtil.getVersionStrV(model.getVersion())); + dataErrorObj.put("shapeId", map.get("id")); + dataErrorObj.put("shapeName", map.get("name")); + dataErrorObj.put("attrId", id); + dataError.add(dataErrorObj); + continue; + } + com.alibaba.fastjson.JSONArray values = (com.alibaba.fastjson.JSONArray) value; - /** - * 保存节点的地址簿属性内容到关联表 - * @return - */ - public String saveAddressShapeData(String data) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject object = JSONObject.parseObject(data); - String fileId = object.getString("uuid"); - String shapeId = object.getString("shapeId"); - String attrId = object.getString("attrId"); - String addressType = object.getString("addressType"); - String value = object.getString("value"); - String shapeText = object.getString("shapeText"); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - // 删除全部 - dao.deleteByAttrId(fileId, shapeId, attrId); - // 保存新数据 - List modelList = new ArrayList(); - if (!UtilString.isEmpty(value)) { - String [] values = value.split(" "); - for (String str : values) { - if (!UtilString.isEmpty(str)) { - DesignerShapeRelationModel shapeRelationModel = new DesignerShapeRelationModel(); - shapeRelationModel.setId(UUIDGener.getUUID()); - shapeRelationModel.setFileId(fileId); - shapeRelationModel.setShapeId(shapeId); - shapeRelationModel.setShapeText(shapeText); - shapeRelationModel.setAttrId(attrId); - shapeRelationModel.setRelationFileId("00000000-0000-0000-0000-000000000000"); - shapeRelationModel.setRelationShapeId(str); - String relationShapeText = ""; - if ("deptAddress".equals(addressType)) { - relationShapeText = SDK.getORGAPI().getDepartmentById(str).getName(); - } - if ("userAddress".equals(addressType)) { - relationShapeText = SDK.getORGAPI().getUser(str).getUserName(); - } - shapeRelationModel.setRelationShapeText(relationShapeText); - modelList.add(shapeRelationModel); - } - } - } - if (modelList.size() > 0) { - dao.barchInsert(modelList); - } - return ro.toString(); - } + List relationModels = DesignerShapeRelationCache.getListByAttrId(model.getId(), (String) map.get("id"), id); + for (int j = 0; j < values.size(); j++) { + String v = values.getString(j); + boolean flag = true; + for (DesignerShapeRelationModel designerShapeRelationModel : relationModels) { + if (designerShapeRelationModel.getRelationShapeId().equals(v)) { + flag = false; + break; + } + } + if (flag) {// 数据库中没有该关联属性 + com.alibaba.fastjson.JSONObject object2 = new com.alibaba.fastjson.JSONObject(); + object2.put("processId", model.getId()); + object2.put("processName", model.getName()); + object2.put("processVer", VersionUtil.getVersionStr(model.getVersion())); + // 以下为关联信息 + object2.put("id", UUIDGener.getUUID()); + object2.put("fileId", model.getId()); + object2.put("shapeId", (String) map.get("id")); + object2.put("shapeText", (String) map.get("name")); + object2.put("attrId", id); + object2.put("relationShapeId", v); - /** - * 获取关联的地址簿id - * @param objIds - * @param shapeId - * @return - */ - public String getAddressShape(String objIds, String shapeId, String uuid) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject object = new JSONObject(); - JSONArray array = JSONArray.parseArray(objIds); - if (!array.isEmpty()) { - for (int i = 0; i < array.size(); i++) { - String objId = array.getString(i); - List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, objId); - StringBuilder ids = new StringBuilder(); - if (list != null) { - for (int j = 0; j < list.size(); j++) { - ids.append(list.get(j).getRelationShapeId()); - if (j < list.size() - 1) { - ids.append(" "); - } - } - } - object.put(objId, ids.toString()); - } - } - ro.put("data", object); - return ro.toString(); - } + String relationFileId = ""; + String relationShapeText = ""; + if ("rear_process".equals(id) || "lead_process".equals(id)) { // 前置流程后置流程 + PALRepositoryModel model2 = PALRepositoryCache.getCache().get(v); + if (model2 != null) { // model2为空跳过 + relationFileId = model2.getParentId(); + relationShapeText = model2.getName(); + } + } else {//节点关联 + relationFileId = (String) shapeIdMap.get(v); + relationShapeText = (String) shapeNameMap.get(v); + } + if (relationFileId != null && !"".equals(relationFileId)) { + count++; + object2.put("relationFileId", relationFileId); + object2.put("relationShapeText", relationShapeText); + result.add(object2); + } + } + } + } + } + } + } - /** - * 获取地址簿名称字符串 - * @param objIds - * @param shapeId - * @param uuid - * @param type - * @return - */ - public String getAddressNames(String objIds, String shapeId, String uuid, String type) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject object = new JSONObject(); - JSONArray array = JSONArray.parseArray(objIds); - Set idSet = new HashSet<>(); - if (!array.isEmpty()) { - for (int i = 0; i < array.size(); i++) { - String objId = array.getString(i); - List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, objId); - if (list != null) { - for (int j = 0; j < list.size(); j++) { - idSet.add(list.get(j).getRelationShapeId()); - } - } - StringBuilder sb = new StringBuilder(); - if ("userAddress".equals(type)) { - Iterator iterator = idSet.iterator(); - while (iterator.hasNext()) { - String id = iterator.next(); - UserModel user = SDK.getORGAPI().getUser(id); - if (user != null) { - sb.append(user.getUserName()).append(" "); - } - } - } - if ("deptAddress".equals(type)) { - Iterator iterator = idSet.iterator(); - while (iterator.hasNext()) { - String id = iterator.next(); - DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); - if (model != null) { - sb.append(model.getName()).append(" "); - } - } - } - object.put(objId, sb.toString()); - idSet.clear(); - } - } - - - ro.put("data", object); - return ro.toString(); - } + } + } + } + System.out.println("被删除个数" + count); + if (count == 0) { // 关联关系正常 + ro.put("result", "normal"); + } else { + ro.put("result", "exception"); + } + ro.put("count", count); + ro.put("lossData", result); + ro.put("errorData", dataError); + System.out.println("被删除数据:"); + System.out.println(result.toString()); + System.out.println("解析失败模型:"); + System.out.println(dataError.toString()); - /** - * 获取aws平台的组织机构/岗位角色树和已选择的数据 - * @param wsId - * @param fileId - * @param shapeId - * @param attrId - * @return - */ - public String getAwsOrgPortal(String wsId, String fileId, String shapeId, String attrId, String ref) { - Map map = new HashMap<>(); - JSONObject refObj = JSONObject.parseObject(ref); - map.put("wsId", wsId); - map.put("shapeId", shapeId); - map.put("attrId", attrId); - map.put("fileId", fileId); - map.put("sid", _uc.getSessionId()); - map.put("refObj", refObj); + return ro.toString(); + } - JSONArray treeData = new JSONArray(); - String scope = refObj.getString("scope"); - if (scope.contains("department") || scope.contains("user")) {// 部门或人员,则显示部门 - // 组织机构 - JSONObject org = new JSONObject(); - org.put("id", "aws_node_org"); - org.put("name", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, "组织")); - org.put("open", false); - org.put("nocheck", true); - org.put("type", "orgRoot"); - org.put("uuid", "orgRoot"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.ORG_ROOT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.ORG_ROOT_ICON_COLOR); - org.put("iconFont", iconFont); - treeData.add(org); + /** + * 关联关系DB数据恢复 + * + * @param lossData + * @return + */ + public String shapeRelationRestore(String lossData) { + ResponseObject ro = ResponseObject.newOkResponse(); + com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(lossData); + int status = 0; + if (!array.isEmpty() && array.size() > 0) { + List list = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { + com.alibaba.fastjson.JSONObject object = array.getJSONObject(i); + if (object == null || object.isEmpty()) continue; + DesignerShapeRelationModel model = new DesignerShapeRelationModel(); + model.setId(object.getString("id")); + model.setFileId(object.getString("fileId")); + model.setShapeId(object.getString("shapeId")); + model.setShapeText(object.getString("shapeText")); + model.setAttrId(object.getString("attrId")); + model.setRelationFileId(object.getString("relationFileId")); + model.setRelationShapeId(object.getString("relationShapeId")); + model.setRelationShapeText(object.getString("relationShapeText")); + list.add(model); + } + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + boolean flag = dao.barchInsert(list); + if (flag) { + status = 2;//成功 + } else { + status = 3;//失败 + } + } else { + status = 1;// 无数据 + } + if (status == 1) { + ro.put("result", "ok"); + ro.put("msg", "没有需要恢复的数据"); + } + if (status == 2) { + ro.put("result", "ok"); + ro.put("msg", "恢复成功"); + } else { + ro.put("result", "error"); + ro.put("msg", "恢复失败"); + } + return ro.toString(); + } + + /** + * 手工保存流程时更新/删除图形的关联关系 + * + * @param uuid 流程id + * @param messages + * @return + */ + public void updateDesignerRelationText(String uuid, String messages) { + Map updateMap = new HashMap<>(); + Map deleteMap = new HashMap<>(); + JSONObject mesageObject = JSONObject.parseObject(messages); + Iterator iterator = mesageObject.keySet().iterator(); + while (iterator.hasNext()) { + String shapeId = iterator.next(); + JSONObject shape = JSONObject.parseObject(mesageObject.getString(shapeId)); + if (DesignerShapeRelationCache.getByRelationShapeId(uuid, shapeId).hasNext() || DesignerShapeRelationCache.getByShapeId(uuid, shapeId).hasNext()) { + if ("create".equals(shape.getString("action")) || "update".equals(shape.getString("action"))) { + updateMap.put(shapeId, shape.getString("name")); + } + if ("remove".equals(shape.getString("action"))) { + deleteMap.put(shapeId, shape.getString("name")); + } + } + } + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + if (!deleteMap.isEmpty()) { + dao.batchDeleteByShapeId(uuid, deleteMap); + } + if (!updateMap.isEmpty()) { + dao.batchUpdateByShapeId(uuid, updateMap); + dao.batchUpdateByRelationShapeId(uuid, updateMap); + } + } + + /** + * 保存节点的地址簿属性内容到关联表 + * + * @return + */ + public String saveAddressShapeData(String data) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject object = JSONObject.parseObject(data); + String fileId = object.getString("uuid"); + String shapeId = object.getString("shapeId"); + String attrId = object.getString("attrId"); + String addressType = object.getString("addressType"); + String value = object.getString("value"); + String shapeText = object.getString("shapeText"); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + // 删除全部 + dao.deleteByAttrId(fileId, shapeId, attrId); + // 保存新数据 + List modelList = new ArrayList(); + if (!UtilString.isEmpty(value)) { + String[] values = value.split(" "); + for (String str : values) { + if (!UtilString.isEmpty(str)) { + DesignerShapeRelationModel shapeRelationModel = new DesignerShapeRelationModel(); + shapeRelationModel.setId(UUIDGener.getUUID()); + shapeRelationModel.setFileId(fileId); + shapeRelationModel.setShapeId(shapeId); + shapeRelationModel.setShapeText(shapeText); + shapeRelationModel.setAttrId(attrId); + shapeRelationModel.setRelationFileId("00000000-0000-0000-0000-000000000000"); + shapeRelationModel.setRelationShapeId(str); + String relationShapeText = ""; + if ("deptAddress".equals(addressType)) { + relationShapeText = SDK.getORGAPI().getDepartmentById(str).getName(); + } + if ("userAddress".equals(addressType)) { + relationShapeText = SDK.getORGAPI().getUser(str).getUserName(); + } + shapeRelationModel.setRelationShapeText(relationShapeText); + modelList.add(shapeRelationModel); + } + } + } + if (modelList.size() > 0) { + dao.barchInsert(modelList); + } + return ro.toString(); + } + + /** + * 获取关联的地址簿id + * + * @param objIds + * @param shapeId + * @return + */ + public String getAddressShape(String objIds, String shapeId, String uuid) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject object = new JSONObject(); + JSONArray array = JSONArray.parseArray(objIds); + if (!array.isEmpty()) { + for (int i = 0; i < array.size(); i++) { + String objId = array.getString(i); + List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, objId); + StringBuilder ids = new StringBuilder(); + if (list != null) { + for (int j = 0; j < list.size(); j++) { + ids.append(list.get(j).getRelationShapeId()); + if (j < list.size() - 1) { + ids.append(" "); + } + } + } + object.put(objId, ids.toString()); + } + } + ro.put("data", object); + return ro.toString(); + } + + /** + * 获取地址簿名称字符串 + * + * @param objIds + * @param shapeId + * @param uuid + * @param type + * @return + */ + public String getAddressNames(String objIds, String shapeId, String uuid, String type) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject object = new JSONObject(); + JSONArray array = JSONArray.parseArray(objIds); + Set idSet = new HashSet<>(); + if (!array.isEmpty()) { + for (int i = 0; i < array.size(); i++) { + String objId = array.getString(i); + List list = DesignerShapeRelationCache.getListByAttrId(uuid, shapeId, objId); + if (list != null) { + for (int j = 0; j < list.size(); j++) { + idSet.add(list.get(j).getRelationShapeId()); + } + } + StringBuilder sb = new StringBuilder(); + if ("userAddress".equals(type)) { + Iterator iterator = idSet.iterator(); + while (iterator.hasNext()) { + String id = iterator.next(); + UserModel user = SDK.getORGAPI().getUser(id); + if (user != null) { + sb.append(user.getUserName()).append(" "); + } + } + } + if ("deptAddress".equals(type)) { + Iterator iterator = idSet.iterator(); + while (iterator.hasNext()) { + String id = iterator.next(); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + if (model != null) { + sb.append(model.getName()).append(" "); + } + } + } + object.put(objId, sb.toString()); + idSet.clear(); + } + } + + + ro.put("data", object); + return ro.toString(); + } + + /** + * 获取aws平台的组织机构/岗位角色树和已选择的数据 + * + * @param wsId + * @param fileId + * @param shapeId + * @param attrId + * @return + */ + public String getAwsOrgPortal(String wsId, String fileId, String shapeId, String attrId, String ref) { + Map map = new HashMap<>(); + JSONObject refObj = JSONObject.parseObject(ref); + map.put("wsId", wsId); + map.put("shapeId", shapeId); + map.put("attrId", attrId); + map.put("fileId", fileId); + map.put("sid", _uc.getSessionId()); + map.put("refObj", refObj); + + JSONArray treeData = new JSONArray(); + String scope = refObj.getString("scope"); + if (scope.contains("department") || scope.contains("user")) {// 部门或人员,则显示部门 + // 组织机构 + JSONObject org = new JSONObject(); + org.put("id", "aws_node_org"); + org.put("name", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, "组织")); + org.put("open", false); + org.put("nocheck", true); + org.put("type", "orgRoot"); + org.put("uuid", "orgRoot"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.ORG_ROOT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.ORG_ROOT_ICON_COLOR); + org.put("iconFont", iconFont); + treeData.add(org); // // 单位 // JSONArray companyArr = getCompanyTree(); // if (!isEmpty(companyArr)) { @@ -2622,50 +2636,50 @@ public class DesignerRelationShapeWeb extends ActionWeb { // treeData.add(companyArr.getJSONObject(i)); // } // } - } - if (scope.contains("position")) {// 显示岗位类角色 - // 岗位 - JSONObject position = new JSONObject(); - position.put("id", "aws_node_position"); - position.put("name", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, "岗位")); - position.put("open", false); - position.put("nocheck", true); - position.put("type", "positionRoot"); - position.put("uuid", "positionRoot"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.POSITION_ROOT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.POSITION_ROOT_ICON_COLOR); - position.put("iconFont", iconFont); - treeData.add(position); - } - if (scope.contains("role")) {// 显示角色类角色 - // 角色 - JSONObject role = new JSONObject(); - role.put("id", "aws_node_role"); - role.put("name", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, "角色")); - role.put("open", false); - role.put("nocheck", true); - role.put("type", "roleRoot"); - role.put("uuid", "roleRoot"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.ROLE_ROOT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.ROLE_ROOT_ICON_COLOR); - role.put("iconFont", iconFont); - treeData.add(role); - } + } + if (scope.contains("position")) {// 显示岗位类角色 + // 岗位 + JSONObject position = new JSONObject(); + position.put("id", "aws_node_position"); + position.put("name", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, "岗位")); + position.put("open", false); + position.put("nocheck", true); + position.put("type", "positionRoot"); + position.put("uuid", "positionRoot"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.POSITION_ROOT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.POSITION_ROOT_ICON_COLOR); + position.put("iconFont", iconFont); + treeData.add(position); + } + if (scope.contains("role")) {// 显示角色类角色 + // 角色 + JSONObject role = new JSONObject(); + role.put("id", "aws_node_role"); + role.put("name", I18nRes.findValue(AppsConst.SYS_APP_PLATFORM, "角色")); + role.put("open", false); + role.put("nocheck", true); + role.put("type", "roleRoot"); + role.put("uuid", "roleRoot"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.ROLE_ROOT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.ROLE_ROOT_ICON_COLOR); + role.put("iconFont", iconFont); + treeData.add(role); + } - JSONArray depjsonArray=new JSONArray(); - // 获取已保存数据 - JSONObject o = new JSONObject(); - Iterator modelIterator = DesignerShapeRelationCache.getByAttrId(fileId, shapeId, attrId); - Set filter = new HashSet(); - if (modelIterator != null) { - while (modelIterator.hasNext()) { - DesignerShapeRelationModel model = modelIterator.next(); - if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { - JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); - boolean flag = false; - // 查询最新名称 + JSONArray depjsonArray = new JSONArray(); + // 获取已保存数据 + JSONObject o = new JSONObject(); + Iterator modelIterator = DesignerShapeRelationCache.getByAttrId(fileId, shapeId, attrId); + Set filter = new HashSet(); + if (modelIterator != null) { + while (modelIterator.hasNext()) { + DesignerShapeRelationModel model = modelIterator.next(); + if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + boolean flag = false; + // 查询最新名称 /*if (scope.contains("department") && "department".equals(object.getString("type"))) { DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); if (dept != null && !filter.contains(dept.getId())) { @@ -2675,1298 +2689,1422 @@ public class DesignerRelationShapeWeb extends ActionWeb { } }*/ - //使用自定义排序规则 - if (scope.contains("department") && "department".equals(object.getString("type"))) { - DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); - if (dept != null && !filter.contains(dept.getId())) { - flag = true; + //使用自定义排序规则 + if (scope.contains("department") && "department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept != null && !filter.contains(dept.getId())) { + flag = true; depjsonArray.add(object); - } - } - if (scope.contains("user") && "user".equals(object.getString("type"))) { - UserModel user = SDK.getORGAPI().getUser(object.getString("id")); - if (user != null && !filter.contains(user.getUID())) { - flag = true; - object.put("name", user.getUserName()); - filter.add(user.getUID()); - } - } - if (scope.contains("position") && "position".equals(object.getString("type"))) { - RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); - if (roleModel != null && !filter.contains(roleModel.getId())) { - flag = true; - object.put("name", roleModel.getName()); - filter.add(roleModel.getId()); - } - } - if (scope.contains("role") && "role".equals(object.getString("type"))) { - RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); - if (roleModel != null && !filter.contains(roleModel.getId())) { - flag = true; - object.put("name", roleModel.getName()); - filter.add(roleModel.getId()); - } - } - if (flag) { - o.put(object.getString("id"), object); - } - } - } - } + } + } + if (scope.contains("user") && "user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user != null && !filter.contains(user.getUID())) { + flag = true; + object.put("name", user.getUserName()); + filter.add(user.getUID()); + } + } + if (scope.contains("position") && "position".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel != null && !filter.contains(roleModel.getId())) { + flag = true; + object.put("name", roleModel.getName()); + filter.add(roleModel.getId()); + } + } + if (scope.contains("role") && "role".equals(object.getString("type"))) { + RoleModel roleModel = SDK.getORGAPI().getRoleById(object.getString("id")); + if (roleModel != null && !filter.contains(roleModel.getId())) { + flag = true; + object.put("name", roleModel.getName()); + filter.add(roleModel.getId()); + } + } + if (flag) { + o.put(object.getString("id"), object); + } + } + } + } - map.put("treeData", treeData); + map.put("treeData", treeData); - /******************************自定义排序******************************************************/ - if(depjsonArray.size()>0 && depjsonArray.getJSONObject(0).getString("timestamp")!=null){ - depjsonArray.sort(Comparator.comparing(st ->((JSONObject)st).getString("timestamp"))); - JSONObject jo = new JSONObject(new LinkedHashMap()); - for(int b=0;b 0 && depjsonArray.getJSONObject(0).getString("timestamp") != null) { + depjsonArray.sort(Comparator.comparing(st -> ((JSONObject) st).getString("timestamp"))); + JSONObject jo = new JSONObject(new LinkedHashMap()); + for (int b = 0; b < depjsonArray.size(); b++) { + JSONObject onedata = depjsonArray.getJSONObject(b); + jo.put(onedata.getString("id"), onedata); } map.put("checkedList", jo); - }else{ + } else { map.put("checkedList", o); } - return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.shapes.aws.org.htm", map); - } - - private boolean isEmpty(List list) { - return (list == null || list.size() == 0); - } + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "pal.pl.repository.designer.shapes.aws.org.htm", map); + } - /** - * 获取aws平台树结构,单位为获取登录用户所属单位 - * 所有数据皆为未注销 - * @param pid - * @param uuid - * @param type - * @return - */ - public String getAwsOrgTreeData(String pid, String uuid, String type, String scope, boolean multiple) { - JSONArray data = new JSONArray(); - switch (type) { - case "orgRoot":// 获取单位 - data = getCompanyTree(); - break; - case "company":// 获取单位下第一级部门 - data = getDepartmentByCompany(pid, uuid, scope, multiple); - break; - case "department":// 获取部门下部门和人员 - data = getDepartmentByParent(pid, uuid, scope, multiple); - break; - case "roleRoot":// 获取角色下分组 - data = getRoleGroupTree(); - break; - case "roleGroup":// 获取角色分组下的具体角色 - data = getRoleByGroupId(pid, uuid, scope, multiple); - break; - case "positionRoot":// 获取岗位下分组 - data = getPositionGroupTree(); - break; - case "positionGroup":// 获取岗位分组下的具体岗位 - data = getPositionByGroupId(pid, uuid, scope, multiple); - break; - } - return data.toString(); - } + private boolean isEmpty(List list) { + return (list == null || list.size() == 0); + } - /** - * 获取aws平台树结构,所有数据皆是当前人能够有权限看到的单位 - * 所有数据皆为未注销 - * @param pid - * @param uuid - * @param type - * @return - */ - public String getPermAwsOrgTreeData(String pid, String uuid, String type, String scope, boolean multiple) { - JSONArray data = new JSONArray(); - switch (type) { - case "orgRoot":// 获取单位 - data = getValidPermCompany(_uc); - break; - case "company":// 获取单位下第一级部门 - data = getDepartmentByCompany(pid, uuid, scope, multiple); - break; - case "department":// 获取部门下部门和人员 - data = getDepartmentByParent(pid, uuid, scope, multiple); - break; - case "roleRoot":// 获取角色下分组 - data = getRoleGroupTree(); - break; - case "roleGroup":// 获取角色分组下的具体角色 - data = getRoleByGroupId(pid, uuid, scope, multiple); - break; - case "positionRoot":// 获取岗位下分组 - data = getPositionGroupTree(); - break; - case "positionGroup":// 获取岗位分组下的具体岗位 - data = getPositionByGroupId(pid, uuid, scope, multiple); - break; - } - return data.toString(); - } + /** + * 获取aws平台树结构,单位为获取登录用户所属单位 + * 所有数据皆为未注销 + * + * @param pid + * @param uuid + * @param type + * @return + */ + public String getAwsOrgTreeData(String pid, String uuid, String type, String scope, boolean multiple) { + JSONArray data = new JSONArray(); + switch (type) { + case "orgRoot":// 获取单位 + data = getCompanyTree(); + break; + case "company":// 获取单位下第一级部门 + data = getDepartmentByCompany(pid, uuid, scope, multiple); + break; + case "department":// 获取部门下部门和人员 + data = getDepartmentByParent(pid, uuid, scope, multiple); + break; + case "roleRoot":// 获取角色下分组 + data = getRoleGroupTree(); + break; + case "roleGroup":// 获取角色分组下的具体角色 + data = getRoleByGroupId(pid, uuid, scope, multiple); + break; + case "positionRoot":// 获取岗位下分组 + data = getPositionGroupTree(); + break; + case "positionGroup":// 获取岗位分组下的具体岗位 + data = getPositionByGroupId(pid, uuid, scope, multiple); + break; + } + return data.toString(); + } - /** - * 获取有效有权限的岗位 - * @param me - * @param pid - * @param uuid - * @param multiple - * @return - */ - public JSONArray getValidPermPositionByGroup(UserContext me, String pid, String uuid, boolean multiple) { - JSONArray result = new JSONArray(); - // 获取岗位列表 - JSONObject object = new JSONObject(); - object.put("showRole", true); - String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleGroup", uuid, "", "AWS_NODE_RG_ID_" + new MD5().toDigest(uuid), object); - JSONArray roleArr = JSONArray.parseArray(arr); - for (int i = 0; i < roleArr.size(); i++) { - JSONObject roleObj = roleArr.getJSONObject(i); - int roleType = roleObj.getInteger("roleType"); - if (roleType == 1) { - String id = roleObj.getString("id").replace("AWS_NODE_OR_ID_", ""); - RoleModel model = SDK.getORGAPI().getRoleById(id); - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_position_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !multiple); - obj.put("type", "position"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.POSITION_ICON_CODE); - iconFont.put("color", BpmOrgUtil.POSITION_ICON_COLOR); - obj.put("iconFont", iconFont); - result.add(obj); - } - } - return result; - } + /** + * 获取aws平台树结构,所有数据皆是当前人能够有权限看到的单位 + * 所有数据皆为未注销 + * + * @param pid + * @param uuid + * @param type + * @return + */ + public String getPermAwsOrgTreeData(String pid, String uuid, String type, String scope, boolean multiple) { + JSONArray data = new JSONArray(); + switch (type) { + case "orgRoot":// 获取单位 + data = getValidPermCompany(_uc); + break; + case "company":// 获取单位下第一级部门 + data = getDepartmentByCompany(pid, uuid, scope, multiple); + break; + case "department":// 获取部门下部门和人员 + data = getDepartmentByParent(pid, uuid, scope, multiple); + break; + case "roleRoot":// 获取角色下分组 + data = getRoleGroupTree(); + break; + case "roleGroup":// 获取角色分组下的具体角色 + data = getRoleByGroupId(pid, uuid, scope, multiple); + break; + case "positionRoot":// 获取岗位下分组 + data = getPositionGroupTree(); + break; + case "positionGroup":// 获取岗位分组下的具体岗位 + data = getPositionByGroupId(pid, uuid, scope, multiple); + break; + } + return data.toString(); + } - /** - * 获取有权限有效的岗位组 - * @param me - * @return - */ - public JSONArray getValidPermPositionGroup(UserContext me) { - JSONArray result = new JSONArray(); - // 获取岗位组 - JSONObject object = new JSONObject(); - object.put("showRole", true); - String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleRoot", "", "", "AWS_NODE_RT_ID_Role", object); - JSONArray roleGroupArr = JSONArray.parseArray(arr); - for (int i = 0; i < roleGroupArr.size(); i++) { - JSONObject o = roleGroupArr.getJSONObject(i); - String groupName = o.getString("groupName"); - List roleModels = SDK.getORGAPI().getRolesByCategory(groupName); - for (RoleModel model : roleModels) { - if (model.getRoleType() == 1) { - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_positionGroup_" + model.getName()); - obj.put("pid", "aws_node_position"); - obj.put("uuid", model.getName()); - obj.put("name", model.getName()); - obj.put("nocheck", true); - obj.put("open", false); - obj.put("type", "positionGroup"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.POSITION_GROUP_ICON_CODE); - iconFont.put("color", BpmOrgUtil.POSITION_GROUP_ICON_COLOR); - obj.put("iconFont", iconFont); - result.add(obj); - } - } - } - return result; - } + /** + * 获取有效有权限的岗位 + * + * @param me + * @param pid + * @param uuid + * @param multiple + * @return + */ + public JSONArray getValidPermPositionByGroup(UserContext me, String pid, String uuid, boolean multiple) { + JSONArray result = new JSONArray(); + // 获取岗位列表 + JSONObject object = new JSONObject(); + object.put("showRole", true); + String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleGroup", uuid, "", "AWS_NODE_RG_ID_" + new MD5().toDigest(uuid), object); + JSONArray roleArr = JSONArray.parseArray(arr); + for (int i = 0; i < roleArr.size(); i++) { + JSONObject roleObj = roleArr.getJSONObject(i); + int roleType = roleObj.getInteger("roleType"); + if (roleType == 1) { + String id = roleObj.getString("id").replace("AWS_NODE_OR_ID_", ""); + RoleModel model = SDK.getORGAPI().getRoleById(id); + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_position_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !multiple); + obj.put("type", "position"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.POSITION_ICON_CODE); + iconFont.put("color", BpmOrgUtil.POSITION_ICON_COLOR); + obj.put("iconFont", iconFont); + result.add(obj); + } + } + return result; + } - /** - * 根据角色组获取对应的角色 - * @param me - * @return - */ - public JSONArray getValidPermRoleByGroup(UserContext me, String pid, String uuid, boolean multiple) { - JSONArray result = new JSONArray(); - // 获取角色列表 - JSONObject object = new JSONObject(); - object.put("showRole", true); - String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleGroup", uuid, "", "AWS_NODE_RG_ID_" + new MD5().toDigest(uuid), object); - JSONArray roleArr = JSONArray.parseArray(arr); - for (int i = 0; i < roleArr.size(); i++) { - JSONObject roleObj = roleArr.getJSONObject(i); - int roleType = roleObj.getInteger("roleType"); - if (roleType == 0) { - String id = roleObj.getString("id").replace("AWS_NODE_OR_ID_", ""); - RoleModel model = SDK.getORGAPI().getRoleById(id); - // 获取角色类角色 - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_role_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !multiple); - obj.put("type", "role"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code",BpmOrgUtil.ROLE_ICON_CODE); - iconFont.put("color", BpmOrgUtil.ROLE_ICON_COLOR); - obj.put("iconFont", iconFont); - result.add(obj); - } - } - return result; - } + /** + * 获取有权限有效的岗位组 + * + * @param me + * @return + */ + public JSONArray getValidPermPositionGroup(UserContext me) { + JSONArray result = new JSONArray(); + // 获取岗位组 + JSONObject object = new JSONObject(); + object.put("showRole", true); + String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleRoot", "", "", "AWS_NODE_RT_ID_Role", object); + JSONArray roleGroupArr = JSONArray.parseArray(arr); + for (int i = 0; i < roleGroupArr.size(); i++) { + JSONObject o = roleGroupArr.getJSONObject(i); + String groupName = o.getString("groupName"); + List roleModels = SDK.getORGAPI().getRolesByCategory(groupName); + for (RoleModel model : roleModels) { + if (model.getRoleType() == 1) { + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_positionGroup_" + model.getName()); + obj.put("pid", "aws_node_position"); + obj.put("uuid", model.getName()); + obj.put("name", model.getName()); + obj.put("nocheck", true); + obj.put("open", false); + obj.put("type", "positionGroup"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.POSITION_GROUP_ICON_CODE); + iconFont.put("color", BpmOrgUtil.POSITION_GROUP_ICON_COLOR); + obj.put("iconFont", iconFont); + result.add(obj); + } + } + } + return result; + } - /** - * 获取角色组 - * @return - */ - public JSONArray getValidPermRoleGroup(UserContext me) { - JSONArray result = new JSONArray(); - JSONObject object = new JSONObject(); - object.put("showRole", true); - String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleRoot", "", "", "AWS_NODE_RT_ID_Role", object); - JSONArray roleGroupArr = JSONArray.parseArray(arr); - for (int i = 0; i < roleGroupArr.size(); i++) { - JSONObject o = roleGroupArr.getJSONObject(i); - String groupName = o.getString("groupName"); - List roleModels = SDK.getORGAPI().getRolesByCategory(groupName); - for (RoleModel model : roleModels) { - if (model.getRoleType() == 0) { - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_roleGroup_" + model.getName()); - obj.put("pid", "aws_node_role"); - obj.put("uuid", model.getName()); - obj.put("name", model.getName()); - obj.put("nocheck", true); - obj.put("open", false); - obj.put("type", "roleGroup"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.ROLE_GROUP_ICON_CODE); - iconFont.put("color", BpmOrgUtil.ROLE_GROUP_ICON_COLOR); - obj.put("iconFont", iconFont); - result.add(obj); - } - } - } - return result; - } + /** + * 根据角色组获取对应的角色 + * + * @param me + * @return + */ + public JSONArray getValidPermRoleByGroup(UserContext me, String pid, String uuid, boolean multiple) { + JSONArray result = new JSONArray(); + // 获取角色列表 + JSONObject object = new JSONObject(); + object.put("showRole", true); + String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleGroup", uuid, "", "AWS_NODE_RG_ID_" + new MD5().toDigest(uuid), object); + JSONArray roleArr = JSONArray.parseArray(arr); + for (int i = 0; i < roleArr.size(); i++) { + JSONObject roleObj = roleArr.getJSONObject(i); + int roleType = roleObj.getInteger("roleType"); + if (roleType == 0) { + String id = roleObj.getString("id").replace("AWS_NODE_OR_ID_", ""); + RoleModel model = SDK.getORGAPI().getRoleById(id); + // 获取角色类角色 + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_role_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !multiple); + obj.put("type", "role"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.ROLE_ICON_CODE); + iconFont.put("color", BpmOrgUtil.ROLE_ICON_COLOR); + obj.put("iconFont", iconFont); + result.add(obj); + } + } + return result; + } - /** - * 获取有效的部门的子部门、岗位角色、用户 - * @param me - * @param pid - * @param uuid - * @param scope - * @param multiple - * @return - */ - public JSONArray getValidPermDepartmentByParent(UserContext me, String pid, String uuid, String scope, boolean multiple) { - JSONArray result = new JSONArray(); - // 获取部门下的子部门以及角色 - JSONObject object = new JSONObject(); - object.put("showRole", true); - String arr = new CompanyWeb(me).getOrganizationTreeJsonData("Department", uuid, "", "AWS_NODE_OD_ID_" + uuid, object); - JSONArray deptArr = JSONArray.parseArray(arr); - for (int i = 0; i < deptArr.size(); i++) { - JSONObject o = deptArr.getJSONObject(i); - String objType = o.getString("type"); - if ("Department".equals(objType)) {// 部门 - String id = o.getString("param1"); - DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_department_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !scope.contains("department") || !multiple); - obj.put("open", false); - obj.put("type", "department"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); - obj.put("iconFont", iconFont); - result.add(obj); - } else if ("departmentRole".equals(objType)) {// 角色、岗位 - String id = o.getString("param1"); - // todo + /** + * 获取角色组 + * + * @return + */ + public JSONArray getValidPermRoleGroup(UserContext me) { + JSONArray result = new JSONArray(); + JSONObject object = new JSONObject(); + object.put("showRole", true); + String arr = new CompanyWeb(me).getOrganizationTreeJsonData("RoleRoot", "", "", "AWS_NODE_RT_ID_Role", object); + JSONArray roleGroupArr = JSONArray.parseArray(arr); + for (int i = 0; i < roleGroupArr.size(); i++) { + JSONObject o = roleGroupArr.getJSONObject(i); + String groupName = o.getString("groupName"); + List roleModels = SDK.getORGAPI().getRolesByCategory(groupName); + for (RoleModel model : roleModels) { + if (model.getRoleType() == 0) { + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_roleGroup_" + model.getName()); + obj.put("pid", "aws_node_role"); + obj.put("uuid", model.getName()); + obj.put("name", model.getName()); + obj.put("nocheck", true); + obj.put("open", false); + obj.put("type", "roleGroup"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.ROLE_GROUP_ICON_CODE); + iconFont.put("color", BpmOrgUtil.ROLE_GROUP_ICON_COLOR); + obj.put("iconFont", iconFont); + result.add(obj); + } + } + } + return result; + } - } else if ("User".equals(objType)) { - String uid = o.getString("uid"); - UserModel model = SDK.getORGAPI().getUser(uid); - if (model == null || model.isClosed()) { - continue; - } - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_user_" + model.getUID()); - obj.put("pid", pid); - obj.put("uuid", model.getUID()); - obj.put("name", model.getUserName()); - obj.put("nocheck", !multiple); - // obj.put("open", false); - obj.put("type", "user"); - if (model.isManager()) { - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.MANAGER_USER_ICON_CODE); - iconFont.put("color", BpmOrgUtil.MANAGER_USER_ICON_COLOR); - obj.put("iconFont", iconFont); - } else { - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.NORMAL_USER_ICON_CODE); - iconFont.put("color", BpmOrgUtil.NORMAL_USER_ICON_COLOR); - obj.put("iconFont", iconFont); - } - result.add(obj); - } - } - return result; - } + /** + * 获取有效的部门的子部门、岗位角色、用户 + * + * @param me + * @param pid + * @param uuid + * @param scope + * @param multiple + * @return + */ + public JSONArray getValidPermDepartmentByParent(UserContext me, String pid, String uuid, String scope, boolean multiple) { + JSONArray result = new JSONArray(); + // 获取部门下的子部门以及角色 + JSONObject object = new JSONObject(); + object.put("showRole", true); + String arr = new CompanyWeb(me).getOrganizationTreeJsonData("Department", uuid, "", "AWS_NODE_OD_ID_" + uuid, object); + JSONArray deptArr = JSONArray.parseArray(arr); + for (int i = 0; i < deptArr.size(); i++) { + JSONObject o = deptArr.getJSONObject(i); + String objType = o.getString("type"); + if ("Department".equals(objType)) {// 部门 + String id = o.getString("param1"); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_department_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !scope.contains("department") || !multiple); + obj.put("open", false); + obj.put("type", "department"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); + obj.put("iconFont", iconFont); + result.add(obj); + } else if ("departmentRole".equals(objType)) {// 角色、岗位 + String id = o.getString("param1"); + // todo - /** - * 获取单位下部门 - * @param me - * @param pid - * @param uuid - * @param scope - * @param multiple - * @return - */ - public JSONArray getValidPermDepartmentByCompany(UserContext me, String pid, String uuid, String scope, boolean multiple) { - JSONArray result = new JSONArray(); - JSONObject object = new JSONObject(); - object.put("showRole", true); - String arr = new CompanyWeb(me).getOrganizationTreeJsonData("Company", uuid, "", "AWS_NODE_OC_ID_" + uuid, object); - JSONArray deptArr = JSONArray.parseArray(arr); - for (int i = 0; i < deptArr.size(); i++) { - JSONObject deptObj = deptArr.getJSONObject(i); - String id = deptObj.getString("param1"); - DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_department_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !scope.contains("department") || !multiple); - obj.put("open", false); - obj.put("type", "department"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); - obj.put("iconFont", iconFont); - result.add(obj); - } - return result; - } + } else if ("User".equals(objType)) { + String uid = o.getString("uid"); + UserModel model = SDK.getORGAPI().getUser(uid); + if (model == null || model.isClosed()) { + continue; + } + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_user_" + model.getUID()); + obj.put("pid", pid); + obj.put("uuid", model.getUID()); + obj.put("name", model.getUserName()); + obj.put("nocheck", !multiple); + // obj.put("open", false); + obj.put("type", "user"); + if (model.isManager()) { + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.MANAGER_USER_ICON_CODE); + iconFont.put("color", BpmOrgUtil.MANAGER_USER_ICON_COLOR); + obj.put("iconFont", iconFont); + } else { + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.NORMAL_USER_ICON_CODE); + iconFont.put("color", BpmOrgUtil.NORMAL_USER_ICON_COLOR); + obj.put("iconFont", iconFont); + } + result.add(obj); + } + } + return result; + } - public boolean hasAC(String userId, String resourceId, String resourceType) { - // 获取AC权限列表 - List acList = Cache.iteratorToList(AccessControlCache.getACList(resourceType, resourceId)); - for (AccessControlModel acModel : acList) { - if ("company".equals(acModel._assignmentType)) {// 单位 - // acModel单位的人员可访问resourceId对象 - // 当前用户所属单位与二级权限单位匹配,可访问 - if (SDK.getORGAPI().getCompanyByUser(userId).getId().equals(acModel._assignmentId)) { - return true; - } - // 获取用户所有兼职单位,若包含当前单位,可访问 - List companyIdList = SDK.getORGAPI().getConcurrentlyCompanyId(userId); - for (String companyId : companyIdList) { - if (companyId.equals(acModel._assignmentId)) { - return true; - } - } - } else if ("department".equals(acModel._assignmentType)) {// 部门 - // acModel部门的人员可访问resourceId对象 - // 当前用户所属部门与二级权限部门匹配,可访问 - if (SDK.getORGAPI().getDepartmentByUser(userId).equals(acModel._assignmentId)) { - return true; - } - // 获取部门下所有用户(包含兼职),若包含当前用户,可访问 - List userList = SDK.getORGAPI().getAllUsersByDepartment(acModel._assignmentId); - for (UserModel user : userList) { - if (user.getUID().equals(userId)) { - return true; - } - } - } else if ("user".equals(acModel._assignmentType)) {// 用户 - // 当前用户与二级权限用户匹配,可访问 - if (userId.equals(acModel._assignmentId)) { - return true; - } - } else if ("role".equals(acModel._assignmentType)) {// 岗位角色 - // 当前用户所属岗位角色与二级权限岗位角色匹配,可访问 - if (SDK.getORGAPI().getRoleByUser(userId).getId().equals(acModel._assignmentId)) { - return true; - } - // 按角色查询用户对象(包含兼职到参数指定的角色的用户),包含当前用户,可访问 - List userModelList = SDK.getORGAPI().getUsersByRoleWithMap(acModel._assignmentId); - for (UserModel user : userModelList) { - if (user.getUID().equals(userId)) { - return true; - } - } - } - } - return false; - } + /** + * 获取单位下部门 + * + * @param me + * @param pid + * @param uuid + * @param scope + * @param multiple + * @return + */ + public JSONArray getValidPermDepartmentByCompany(UserContext me, String pid, String uuid, String scope, boolean multiple) { + JSONArray result = new JSONArray(); + JSONObject object = new JSONObject(); + object.put("showRole", true); + String arr = new CompanyWeb(me).getOrganizationTreeJsonData("Company", uuid, "", "AWS_NODE_OC_ID_" + uuid, object); + JSONArray deptArr = JSONArray.parseArray(arr); + for (int i = 0; i < deptArr.size(); i++) { + JSONObject deptObj = deptArr.getJSONObject(i); + String id = deptObj.getString("param1"); + DepartmentModel model = SDK.getORGAPI().getDepartmentById(id); + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_department_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !scope.contains("department") || !multiple); + obj.put("open", false); + obj.put("type", "department"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); + obj.put("iconFont", iconFont); + result.add(obj); + } + return result; + } - /** - * 获取个人有权限且有效的单位(包含二级管理员权限) - * @param me - * @return - */ - public JSONArray getValidPermCompany(UserContext me) { - List companyIds = new ArrayList<>(); - JSONArray result = new JSONArray(); - // 获取顶级单位数据 - List companyModels = SDK.getORGAPI().getCompanys(); - for (CompanyModel company : companyModels) { - if (!company.isClosed() && company.isValid()) { - // 当前人所属单位,可访问 - if (SDK.getORGAPI().getCompanyByUser(me.getUID()).equals(company.getId())) { - companyIds.add(company.getId()); - } else if (hasAC(me.getUID(), company.getId(), "platform.companyAdmin")) { - companyIds.add(company.getId()); - } - } - } - for (String companyId : companyIds) { - CompanyModel model = SDK.getORGAPI().getCompanyById(companyId); - if (!model.isClosed() && model.isValid()) { - JSONObject com = new JSONObject(); - com.put("id", "aws_node_company_" + model.getId()); - com.put("pid", "aws_node_org"); - com.put("uuid", model.getId()); - com.put("name", model.getName()); - com.put("nocheck", true); - com.put("open", false); - com.put("type", "company"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.COMPANY_ICON_CODE); - iconFont.put("color", BpmOrgUtil.COMPANY_ICON_COLOR); - com.put("iconFont", iconFont); - result.add(com); - } - } - return result; - } + public boolean hasAC(String userId, String resourceId, String resourceType) { + // 获取AC权限列表 + List acList = Cache.iteratorToList(AccessControlCache.getACList(resourceType, resourceId)); + for (AccessControlModel acModel : acList) { + if ("company".equals(acModel._assignmentType)) {// 单位 + // acModel单位的人员可访问resourceId对象 + // 当前用户所属单位与二级权限单位匹配,可访问 + if (SDK.getORGAPI().getCompanyByUser(userId).getId().equals(acModel._assignmentId)) { + return true; + } + // 获取用户所有兼职单位,若包含当前单位,可访问 + List companyIdList = SDK.getORGAPI().getConcurrentlyCompanyId(userId); + for (String companyId : companyIdList) { + if (companyId.equals(acModel._assignmentId)) { + return true; + } + } + } else if ("department".equals(acModel._assignmentType)) {// 部门 + // acModel部门的人员可访问resourceId对象 + // 当前用户所属部门与二级权限部门匹配,可访问 + if (SDK.getORGAPI().getDepartmentByUser(userId).equals(acModel._assignmentId)) { + return true; + } + // 获取部门下所有用户(包含兼职),若包含当前用户,可访问 + List userList = SDK.getORGAPI().getAllUsersByDepartment(acModel._assignmentId); + for (UserModel user : userList) { + if (user.getUID().equals(userId)) { + return true; + } + } + } else if ("user".equals(acModel._assignmentType)) {// 用户 + // 当前用户与二级权限用户匹配,可访问 + if (userId.equals(acModel._assignmentId)) { + return true; + } + } else if ("role".equals(acModel._assignmentType)) {// 岗位角色 + // 当前用户所属岗位角色与二级权限岗位角色匹配,可访问 + if (SDK.getORGAPI().getRoleByUser(userId).getId().equals(acModel._assignmentId)) { + return true; + } + // 按角色查询用户对象(包含兼职到参数指定的角色的用户),包含当前用户,可访问 + List userModelList = SDK.getORGAPI().getUsersByRoleWithMap(acModel._assignmentId); + for (UserModel user : userModelList) { + if (user.getUID().equals(userId)) { + return true; + } + } + } + } + return false; + } - /** - * 获取岗位 - * @param pid - * @param uuid 此处uuid为岗位组名称 - * @return - */ - public JSONArray getPositionByGroupId(String pid, String uuid, String scope, boolean multiple) { - JSONArray data = new JSONArray(); - List roleList = SDK.getORGAPI().getRolesByCategory(uuid); - if (!isEmpty(roleList)) { - for (RoleModel model : roleList) { - if (model != null && model.getRoleType() == 1) { - // 获取岗位类角色 - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_position_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !multiple); - obj.put("type", "position"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.POSITION_ICON_CODE); - iconFont.put("color", BpmOrgUtil.POSITION_ICON_COLOR); - obj.put("iconFont", iconFont); - data.add(obj); - } - } - } - return data; - } + /** + * 获取个人有权限且有效的单位(包含二级管理员权限) + * + * @param me + * @return + */ + public JSONArray getValidPermCompany(UserContext me) { + List companyIds = new ArrayList<>(); + JSONArray result = new JSONArray(); + // 获取顶级单位数据 + List companyModels = SDK.getORGAPI().getCompanys(); + for (CompanyModel company : companyModels) { + if (!company.isClosed() && company.isValid()) { + // 当前人所属单位,可访问 + if (SDK.getORGAPI().getCompanyByUser(me.getUID()).equals(company.getId())) { + companyIds.add(company.getId()); + } else if (hasAC(me.getUID(), company.getId(), "platform.companyAdmin")) { + companyIds.add(company.getId()); + } + } + } + for (String companyId : companyIds) { + CompanyModel model = SDK.getORGAPI().getCompanyById(companyId); + if (!model.isClosed() && model.isValid()) { + JSONObject com = new JSONObject(); + com.put("id", "aws_node_company_" + model.getId()); + com.put("pid", "aws_node_org"); + com.put("uuid", model.getId()); + com.put("name", model.getName()); + com.put("nocheck", true); + com.put("open", false); + com.put("type", "company"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.COMPANY_ICON_CODE); + iconFont.put("color", BpmOrgUtil.COMPANY_ICON_COLOR); + com.put("iconFont", iconFont); + result.add(com); + } + } + return result; + } - /** - * 获取角色 - * @param pid - * @param uuid 此处uuid为角色组名称 - * @return - */ - public JSONArray getRoleByGroupId(String pid, String uuid, String scope, boolean multiple) { - JSONArray data = new JSONArray(); - List roleList = SDK.getORGAPI().getRolesByCategory(uuid); - if (!isEmpty(roleList)) { - for (RoleModel model : roleList) { - if (model != null && model.getRoleType() == 0) { - // 获取角色类角色 - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_role_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !multiple); - obj.put("type", "role"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code",BpmOrgUtil.ROLE_ICON_CODE); - iconFont.put("color", BpmOrgUtil.ROLE_ICON_COLOR); - obj.put("iconFont", iconFont); - data.add(obj); - } - } - } - return data; - } + /** + * 获取岗位 + * + * @param pid + * @param uuid 此处uuid为岗位组名称 + * @return + */ + public JSONArray getPositionByGroupId(String pid, String uuid, String scope, boolean multiple) { + JSONArray data = new JSONArray(); + List roleList = SDK.getORGAPI().getRolesByCategory(uuid); + if (!isEmpty(roleList)) { + for (RoleModel model : roleList) { + if (model != null && model.getRoleType() == 1) { + // 获取岗位类角色 + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_position_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !multiple); + obj.put("type", "position"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.POSITION_ICON_CODE); + iconFont.put("color", BpmOrgUtil.POSITION_ICON_COLOR); + obj.put("iconFont", iconFont); + data.add(obj); + } + } + } + return data; + } - /** - * 获取岗位分组 - * @return - */ - public JSONArray getPositionGroupTree() { - JSONArray data = new JSONArray(); - String[] positionCategoryList = RoleCache.getCategoryNames(); - if (positionCategoryList != null && positionCategoryList.length > 0) { - for (String name : positionCategoryList) { - if (!UtilString.isEmpty(name)) { - // 判断是否包含角色 - List roleList = SDK.getORGAPI().getRolesByCategory(name); - boolean hasPosition = false; - if (!isEmpty(roleList)) { - for (RoleModel model : roleList) { - if (model != null && model.getRoleType() == 1) { - hasPosition = true; - } - } - } - if (hasPosition) { - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_positionGroup_" + name); - obj.put("pid", "aws_node_position"); - obj.put("uuid", name); - obj.put("name", name); - obj.put("nocheck", true); - obj.put("open", false); - obj.put("type", "positionGroup"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.POSITION_GROUP_ICON_CODE); - iconFont.put("color", BpmOrgUtil.POSITION_GROUP_ICON_COLOR); - obj.put("iconFont", iconFont); - data.add(obj); - } - } - } - } - return data; - } + /** + * 获取角色 + * + * @param pid + * @param uuid 此处uuid为角色组名称 + * @return + */ + public JSONArray getRoleByGroupId(String pid, String uuid, String scope, boolean multiple) { + JSONArray data = new JSONArray(); + List roleList = SDK.getORGAPI().getRolesByCategory(uuid); + if (!isEmpty(roleList)) { + for (RoleModel model : roleList) { + if (model != null && model.getRoleType() == 0) { + // 获取角色类角色 + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_role_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !multiple); + obj.put("type", "role"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.ROLE_ICON_CODE); + iconFont.put("color", BpmOrgUtil.ROLE_ICON_COLOR); + obj.put("iconFont", iconFont); + data.add(obj); + } + } + } + return data; + } - /** - * 获取角色分组 - * @return - */ - public JSONArray getRoleGroupTree() { - JSONArray data = new JSONArray(); - String[] roleCategoryList = RoleCache.getCategoryNames(); - if (roleCategoryList != null && roleCategoryList.length > 0) { - for (String name : roleCategoryList) { - if (!UtilString.isEmpty(name)) { - // 判断是否包含角色 - List roleList = SDK.getORGAPI().getRolesByCategory(name); - boolean hasRole = false; - if (!isEmpty(roleList)) { - for (RoleModel model : roleList) { - if (model != null && model.getRoleType() == 0) { - hasRole = true; - } - } - } - if (hasRole) { - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_roleGroup_" + name); - obj.put("pid", "aws_node_role"); - obj.put("uuid", name); - obj.put("name", name); - obj.put("nocheck", true); - obj.put("open", false); - obj.put("type", "roleGroup"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.ROLE_GROUP_ICON_CODE); - iconFont.put("color", BpmOrgUtil.ROLE_GROUP_ICON_COLOR); - obj.put("iconFont", iconFont); - data.add(obj); - } - } - } - } - return data; - } + /** + * 获取岗位分组 + * + * @return + */ + public JSONArray getPositionGroupTree() { + JSONArray data = new JSONArray(); + String[] positionCategoryList = RoleCache.getCategoryNames(); + if (positionCategoryList != null && positionCategoryList.length > 0) { + for (String name : positionCategoryList) { + if (!UtilString.isEmpty(name)) { + // 判断是否包含角色 + List roleList = SDK.getORGAPI().getRolesByCategory(name); + boolean hasPosition = false; + if (!isEmpty(roleList)) { + for (RoleModel model : roleList) { + if (model != null && model.getRoleType() == 1) { + hasPosition = true; + } + } + } + if (hasPosition) { + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_positionGroup_" + name); + obj.put("pid", "aws_node_position"); + obj.put("uuid", name); + obj.put("name", name); + obj.put("nocheck", true); + obj.put("open", false); + obj.put("type", "positionGroup"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.POSITION_GROUP_ICON_CODE); + iconFont.put("color", BpmOrgUtil.POSITION_GROUP_ICON_COLOR); + obj.put("iconFont", iconFont); + data.add(obj); + } + } + } + } + return data; + } - /** - * 获取部门下的部门和人员 - * @param pid - * @param uuid - * @return - */ - public JSONArray getDepartmentByParent(String pid, String uuid, String scope, boolean multiple) { - JSONArray data = new JSONArray(); - // 部门 - List subDepartmentList = SDK.getORGAPI().getSubDepartments(uuid); - if (!isEmpty(subDepartmentList)) { - for (DepartmentModel model : subDepartmentList) { - if (model == null || model.isClosed()) { - continue; - } - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_department_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !scope.contains("department") || !multiple); - obj.put("open", false); - obj.put("type", "department"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); - obj.put("iconFont", iconFont); - data.add(obj); - } - } - // 人员 - if (scope.contains("user")) { - List userlist = SDK.getORGAPI().getUsersByDepartment(uuid); - if (!isEmpty(userlist)) { - for (UserModel model : userlist) { - if (model == null || model.isClosed()) { - continue; - } - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_user_" + model.getUID()); - obj.put("pid", pid); - obj.put("uuid", model.getUID()); - obj.put("name", model.getUserName()); - obj.put("nocheck", !multiple); - // obj.put("open", false); - obj.put("type", "user"); - if (model.isManager()) { - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.MANAGER_USER_ICON_CODE); - iconFont.put("color", BpmOrgUtil.MANAGER_USER_ICON_COLOR); - obj.put("iconFont", iconFont); - } else { - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.NORMAL_USER_ICON_CODE); - iconFont.put("color", BpmOrgUtil.NORMAL_USER_ICON_COLOR); - obj.put("iconFont", iconFont); + /** + * 获取角色分组 + * + * @return + */ + public JSONArray getRoleGroupTree() { + JSONArray data = new JSONArray(); + String[] roleCategoryList = RoleCache.getCategoryNames(); + if (roleCategoryList != null && roleCategoryList.length > 0) { + for (String name : roleCategoryList) { + if (!UtilString.isEmpty(name)) { + // 判断是否包含角色 + List roleList = SDK.getORGAPI().getRolesByCategory(name); + boolean hasRole = false; + if (!isEmpty(roleList)) { + for (RoleModel model : roleList) { + if (model != null && model.getRoleType() == 0) { + hasRole = true; + } + } + } + if (hasRole) { + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_roleGroup_" + name); + obj.put("pid", "aws_node_role"); + obj.put("uuid", name); + obj.put("name", name); + obj.put("nocheck", true); + obj.put("open", false); + obj.put("type", "roleGroup"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.ROLE_GROUP_ICON_CODE); + iconFont.put("color", BpmOrgUtil.ROLE_GROUP_ICON_COLOR); + obj.put("iconFont", iconFont); + data.add(obj); + } + } + } + } + return data; + } - } - data.add(obj); - } - } - } - return data; - } + /** + * 获取部门下的部门和人员 + * + * @param pid + * @param uuid + * @return + */ + public JSONArray getDepartmentByParent(String pid, String uuid, String scope, boolean multiple) { + JSONArray data = new JSONArray(); + // 部门 + List subDepartmentList = SDK.getORGAPI().getSubDepartments(uuid); + if (!isEmpty(subDepartmentList)) { + for (DepartmentModel model : subDepartmentList) { + if (model == null || model.isClosed()) { + continue; + } + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_department_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !scope.contains("department") || !multiple); + obj.put("open", false); + obj.put("type", "department"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); + obj.put("iconFont", iconFont); + data.add(obj); + } + } + // 人员 + if (scope.contains("user")) { + List userlist = SDK.getORGAPI().getUsersByDepartment(uuid); + if (!isEmpty(userlist)) { + for (UserModel model : userlist) { + if (model == null || model.isClosed()) { + continue; + } + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_user_" + model.getUID()); + obj.put("pid", pid); + obj.put("uuid", model.getUID()); + obj.put("name", model.getUserName()); + obj.put("nocheck", !multiple); + // obj.put("open", false); + obj.put("type", "user"); + if (model.isManager()) { + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.MANAGER_USER_ICON_CODE); + iconFont.put("color", BpmOrgUtil.MANAGER_USER_ICON_COLOR); + obj.put("iconFont", iconFont); + } else { + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.NORMAL_USER_ICON_CODE); + iconFont.put("color", BpmOrgUtil.NORMAL_USER_ICON_COLOR); + obj.put("iconFont", iconFont); - /** - * 获取单位下部门 - * @param uuid - * @return - */ - public JSONArray getDepartmentByCompany(String pid, String uuid, String scope, boolean multiple) { - JSONArray data = new JSONArray(); - List departmentList = DepartmentCache.getListOfCompany(uuid); - if (!isEmpty(departmentList)) { - for (DepartmentModel model : departmentList) { - if (model != null && model.isClosed()) { - continue; - } - if (model != null && model.getParentDepartmentId().equals("0")) { - JSONObject obj = new JSONObject(); - obj.put("id", "aws_node_department_" + model.getId()); - obj.put("pid", pid); - obj.put("uuid", model.getId()); - obj.put("name", model.getName()); - obj.put("nocheck", !scope.contains("department") || !multiple); - obj.put("open", false); - obj.put("type", "department"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); - iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); - obj.put("iconFont", iconFont); - data.add(obj); - } - } - } - return data; - } + } + data.add(obj); + } + } + } + return data; + } - /** - * 获取单位 - * @return - */ - public JSONArray getCompanyTree() { - JSONArray data = new JSONArray(); - List companys = SDK.getORGAPI().getCompanys(); - if (!isEmpty(companys)) { - for (CompanyModel company : companys) { - if (!company.isClosed() && _uc.getCompanyModel().getId().equals(company.getId())) {// 暂定只取自己的单位组织 - JSONObject com = new JSONObject(); - com.put("id", "aws_node_company_" + company.getId()); - com.put("pid", "aws_node_org"); - com.put("uuid", company.getId()); - com.put("name", company.getName()); - com.put("nocheck", true); - com.put("open", false); - com.put("type", "company"); - JSONObject iconFont = new JSONObject(); - iconFont.put("code", BpmOrgUtil.COMPANY_ICON_CODE); - iconFont.put("color", BpmOrgUtil.COMPANY_ICON_COLOR); - com.put("iconFont", iconFont); - data.add(com); - } - } - } - return data; - } + /** + * 获取单位下部门 + * + * @param uuid + * @return + */ + public JSONArray getDepartmentByCompany(String pid, String uuid, String scope, boolean multiple) { + JSONArray data = new JSONArray(); + List departmentList = DepartmentCache.getListOfCompany(uuid); + if (!isEmpty(departmentList)) { + for (DepartmentModel model : departmentList) { + if (model != null && model.isClosed()) { + continue; + } + if (model != null && model.getParentDepartmentId().equals("0")) { + JSONObject obj = new JSONObject(); + obj.put("id", "aws_node_department_" + model.getId()); + obj.put("pid", pid); + obj.put("uuid", model.getId()); + obj.put("name", model.getName()); + obj.put("nocheck", !scope.contains("department") || !multiple); + obj.put("open", false); + obj.put("type", "department"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.DEPARTMENT_ICON_CODE); + iconFont.put("color", BpmOrgUtil.DEPARTMENT_ICON_COLOR); + obj.put("iconFont", iconFont); + data.add(obj); + } + } + } + return data; + } - /** - * 获取子节点 - * 所有已注销的除外 - * @param uuid - * @param type - * @return - */ - public String getAwsOrgTreeNodeChildData(String uuid, String type) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONObject data = new JSONObject(); - if ("company".equals(type)) {// 单位:部门+用户 - // 获取部门 - List departmentList = DepartmentCache.getListOfCompany(uuid); - if (!isEmpty(departmentList)) { - for (DepartmentModel model : departmentList) { - if (!model.isClosed() && model.getParentDepartmentId().equals("0")) { - JSONObject obj = new JSONObject(); - obj.put("id", model.getId()); - obj.put("type", "department"); - obj.put("name", model.getName()); - data.put(model.getId(), obj); - // 递归查询子部门及用户 - Set set = new HashSet<>();// 记录所有ID,防止出现深度递归溢出 - set.add(model.getId()); - getDepartmentAndUser(model.getId(), set, data); - } - } - } - } - if ("department".equals(type)) {// 部门:部门+用户 - DepartmentModel model = SDK.getORGAPI().getDepartmentById(uuid); - if (model != null && !model.isClosed()) { - JSONObject obj = new JSONObject(); - obj.put("id", model.getId()); - obj.put("type", "department"); - obj.put("name", model.getName()); - data.put(model.getId(), obj); - // 递归查询子部门及用户 - Set set = new HashSet<>();// 记录所有ID,防止出现深度递归溢出 - set.add(model.getId()); - getDepartmentAndUser(model.getId(), set, data); - } - } - if ("roleGroup".equals(type)) {// 角色组:角色 - // 查询所有角色 - List list = SDK.getORGAPI().getRolesByCategory(uuid); - if (!isEmpty(list)) { - for (RoleModel role : list) { - JSONObject obj = new JSONObject(); - obj.put("id", role.getId()); - obj.put("type", "role"); - obj.put("name", role.getName()); - data.put(role.getId(), obj); - } - } - } - ro.put("data", data); - return ro.toString(); - } + /** + * 获取单位 + * + * @return + */ + public JSONArray getCompanyTree() { + JSONArray data = new JSONArray(); + List companys = SDK.getORGAPI().getCompanys(); + if (!isEmpty(companys)) { + for (CompanyModel company : companys) { + if (!company.isClosed() && _uc.getCompanyModel().getId().equals(company.getId())) {// 暂定只取自己的单位组织 + JSONObject com = new JSONObject(); + com.put("id", "aws_node_company_" + company.getId()); + com.put("pid", "aws_node_org"); + com.put("uuid", company.getId()); + com.put("name", company.getName()); + com.put("nocheck", true); + com.put("open", false); + com.put("type", "company"); + JSONObject iconFont = new JSONObject(); + iconFont.put("code", BpmOrgUtil.COMPANY_ICON_CODE); + iconFont.put("color", BpmOrgUtil.COMPANY_ICON_COLOR); + com.put("iconFont", iconFont); + data.add(com); + } + } + } + return data; + } - /** - * 获取所有子部门/用户 - * @param pid - * @param set - * @param data - */ - private void getDepartmentAndUser(String pid, Set set, JSONObject data) { - // 获取子部门 - List list = SDK.getORGAPI().getSubDepartments(pid); - if (!isEmpty(list)) { - for (DepartmentModel model : list) { - if (!model.isClosed() && !set.contains(model.getId())) { - set.add(model.getId()); - JSONObject obj = new JSONObject(); - obj.put("id", model.getId()); - obj.put("type", "department"); - obj.put("name", model.getName()); - data.put(model.getId(), obj); - getDepartmentAndUser(model.getId(), set, data); - } - } - } - // 获取当前部门下用户 - List userlist = SDK.getORGAPI().getUsersByDepartment(pid); - if (!isEmpty(userlist)) { - for (UserModel model : userlist) { - if (!model.isClosed() && !set.contains(model.getUID())) { - JSONObject obj = new JSONObject(); - obj.put("id", model.getUID()); - obj.put("type", "user"); - obj.put("name", model.getUserName()); - data.put(model.getUID(), obj); - } - } - } - } + /** + * 获取子节点 + * 所有已注销的除外 + * + * @param uuid + * @param type + * @return + */ + public String getAwsOrgTreeNodeChildData(String uuid, String type) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONObject data = new JSONObject(); + if ("company".equals(type)) {// 单位:部门+用户 + // 获取部门 + List departmentList = DepartmentCache.getListOfCompany(uuid); + if (!isEmpty(departmentList)) { + for (DepartmentModel model : departmentList) { + if (!model.isClosed() && model.getParentDepartmentId().equals("0")) { + JSONObject obj = new JSONObject(); + obj.put("id", model.getId()); + obj.put("type", "department"); + obj.put("name", model.getName()); + data.put(model.getId(), obj); + // 递归查询子部门及用户 + Set set = new HashSet<>();// 记录所有ID,防止出现深度递归溢出 + set.add(model.getId()); + getDepartmentAndUser(model.getId(), set, data); + } + } + } + } + if ("department".equals(type)) {// 部门:部门+用户 + DepartmentModel model = SDK.getORGAPI().getDepartmentById(uuid); + if (model != null && !model.isClosed()) { + JSONObject obj = new JSONObject(); + obj.put("id", model.getId()); + obj.put("type", "department"); + obj.put("name", model.getName()); + data.put(model.getId(), obj); + // 递归查询子部门及用户 + Set set = new HashSet<>();// 记录所有ID,防止出现深度递归溢出 + set.add(model.getId()); + getDepartmentAndUser(model.getId(), set, data); + } + } + if ("roleGroup".equals(type)) {// 角色组:角色 + // 查询所有角色 + List list = SDK.getORGAPI().getRolesByCategory(uuid); + if (!isEmpty(list)) { + for (RoleModel role : list) { + JSONObject obj = new JSONObject(); + obj.put("id", role.getId()); + obj.put("type", "role"); + obj.put("name", role.getName()); + data.put(role.getId(), obj); + } + } + } + ro.put("data", data); + return ro.toString(); + } - /** - * 模糊查询 - * 查询部门/人员/角色/ - * @param autoContent - * @param wsId - * @param ref - * @return - */ - public String queryAwsOrgTree(String autoContent, String wsId, String ref) { - ResponseObject ro = ResponseObject.newOkResponse(); - List list = new ArrayList(); - // 部门 - List companys = SDK.getORGAPI().getCompanys(); - if (!isEmpty(companys)) { - for (CompanyModel company : companys) { - if (!company.isClosed() && _uc.getCompanyModel().getId().equals(company.getId())) {// 暂时只查询自己所在单位 - if (ref.contains("department")) { - List departmentList = DepartmentCache.getListOfCompany(company.getId()); - if (!isEmpty(departmentList)) { - for (DepartmentModel model : departmentList) { - if (model == null || model.isClosed()) { - continue; - } - if (model.getName().toUpperCase().contains(autoContent.toUpperCase())) {// 包含 - CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); - bean.setName(model.getName()); - bean.setType("department"); - StringBuilder sBuilder = new StringBuilder();// 名称组合 - StringBuilder idBuilder = new StringBuilder();// Id组合 - Set idSets = new HashSet<>();// id记录,校验防止递归死循环 - sBuilder.append(bean.getName()); - idBuilder.append(model.getId()); - idSets.add(model.getId()); - boolean isClosed = false; - isClosed = getDepartmentFilePath(model, sBuilder, idBuilder, idSets, isClosed);// 递归获取当前文件名称路径 - if (!isClosed) { - // bean.setUi("
" + sBuilder.toString() + "
"); - bean.setUi(sBuilder.toString()); - bean.setValue(idBuilder.toString()); - list.add(bean); - } - } - } - } - } - } - } - } - // 人员 - if (ref.contains("user")) { - List userList = UserCache.getActiveList(); - if (!isEmpty(userList)) { - for (UserModel model : userList) { - if (SDK.getORGAPI().getDepartmentById(model.getDepartmentId()).getCompanyId().equals(_uc.getCompanyModel().getId()) - && (model.getUserName().toUpperCase().contains(autoContent.toUpperCase()) || model.getUID().toUpperCase().contains(autoContent.toUpperCase()))) { - CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); - bean.setName(model.getUserName()); - bean.setType("user"); - StringBuilder sBuilder = new StringBuilder();// 名称组合 - StringBuilder idBuilder = new StringBuilder();// Id组合 - Set idSets = new HashSet<>();// id记录,校验防止递归死循环 - sBuilder.append(bean.getName()); - idBuilder.append(model.getUID()); - idSets.add(model.getUID()); - DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(model.getDepartmentId()); - if (departmentModel != null && !departmentModel.isClosed()) { - sBuilder.insert(0, departmentModel.getName() + ">"); - idBuilder.insert(0, departmentModel.getId() + ","); - idSets.add(departmentModel.getId()); - boolean isClosed = false; - isClosed = getDepartmentFilePath(departmentModel, sBuilder, idBuilder, idSets, isClosed);// 递归获取当前文件名称路径 - if (!isClosed) { - // bean.setUi("
" + sBuilder.toString() + "
"); - bean.setUi(sBuilder.toString()); - bean.setValue(idBuilder.toString()); - list.add(bean); - } - } - } - } - } - } - if (ref.contains("role")) { - // 角色 - List roleList = SDK.getORGAPI().getRoles(); - if (!isEmpty(roleList)) { - for (RoleModel model : roleList) { - if (model != null && model.getRoleType() == 0) { - if (model.getName().toUpperCase().contains(autoContent.toUpperCase())) {// 包含 - CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); - bean.setName(model.getName()); - bean.setType("role"); - // bean.setUi("
" + new StringBuilder(model.getCategoryName()).append(">").append(model.getName()) + "
"); - bean.setUi(new StringBuilder(model.getCategoryName()).append(">").append(model.getName()).toString()); - bean.setValue(model.getCategoryName() + "," + model.getId()); - list.add(bean); - } - } - } - } - } - if (ref.contains("position")) { - // 岗位 - List roleList = SDK.getORGAPI().getRoles(); - if (!isEmpty(roleList)) { - for (RoleModel model : roleList) { - if (model != null && model.getRoleType() == 1) { - if (model.getName().toUpperCase().contains(autoContent.toUpperCase())) {// 包含 - CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); - bean.setName(model.getName()); - bean.setType("position"); - // bean.setUi("
" + new StringBuilder(model.getCategoryName()).append(">").append(model.getName()) + "
"); - bean.setUi(new StringBuilder(model.getCategoryName()).append(">").append(model.getName()).toString()); - bean.setValue(model.getCategoryName() + "," + model.getId()); - list.add(bean); - } - } - } - } - } + /** + * 获取所有子部门/用户 + * + * @param pid + * @param set + * @param data + */ + private void getDepartmentAndUser(String pid, Set set, JSONObject data) { + // 获取子部门 + List list = SDK.getORGAPI().getSubDepartments(pid); + if (!isEmpty(list)) { + for (DepartmentModel model : list) { + if (!model.isClosed() && !set.contains(model.getId())) { + set.add(model.getId()); + JSONObject obj = new JSONObject(); + obj.put("id", model.getId()); + obj.put("type", "department"); + obj.put("name", model.getName()); + data.put(model.getId(), obj); + getDepartmentAndUser(model.getId(), set, data); + } + } + } + // 获取当前部门下用户 + List userlist = SDK.getORGAPI().getUsersByDepartment(pid); + if (!isEmpty(userlist)) { + for (UserModel model : userlist) { + if (!model.isClosed() && !set.contains(model.getUID())) { + JSONObject obj = new JSONObject(); + obj.put("id", model.getUID()); + obj.put("type", "user"); + obj.put("name", model.getUserName()); + data.put(model.getUID(), obj); + } + } + } + } - boolean isBeyond = false;// 查询结果是否超出一定数量并截取 - if (!isEmpty(list)) { - // 排序 - Collections.sort(list, new Comparator() { - @Override - public int compare(CoeProcessLevelAutoBean o1, CoeProcessLevelAutoBean o2) { - String ui1 = o1.getUi(); - String ui2 = o2.getUi(); - return ui2.compareToIgnoreCase(ui1); - } - }); - } - ro.put("result", JSONArray.toJSON(list)); - ro.put("isBeyond", isBeyond); - return ro.toString(); - } + /** + * 模糊查询 + * 查询部门/人员/角色/ + * + * @param autoContent + * @param wsId + * @param ref + * @return + */ + public String queryAwsOrgTree(String autoContent, String wsId, String ref) { + ResponseObject ro = ResponseObject.newOkResponse(); + List list = new ArrayList(); + // 部门 + List companys = SDK.getORGAPI().getCompanys(); + if (!isEmpty(companys)) { + for (CompanyModel company : companys) { + if (!company.isClosed() && _uc.getCompanyModel().getId().equals(company.getId())) {// 暂时只查询自己所在单位 + if (ref.contains("department")) { + List departmentList = DepartmentCache.getListOfCompany(company.getId()); + if (!isEmpty(departmentList)) { + for (DepartmentModel model : departmentList) { + if (model == null || model.isClosed()) { + continue; + } + if (model.getName().toUpperCase().contains(autoContent.toUpperCase())) {// 包含 + CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); + bean.setName(model.getName()); + bean.setType("department"); + StringBuilder sBuilder = new StringBuilder();// 名称组合 + StringBuilder idBuilder = new StringBuilder();// Id组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(bean.getName()); + idBuilder.append(model.getId()); + idSets.add(model.getId()); + boolean isClosed = false; + isClosed = getDepartmentFilePath(model, sBuilder, idBuilder, idSets, isClosed);// 递归获取当前文件名称路径 + if (!isClosed) { + // bean.setUi("
" + sBuilder.toString() + "
"); + bean.setUi(sBuilder.toString()); + bean.setValue(idBuilder.toString()); + list.add(bean); + } + } + } + } + } + } + } + } + // 人员 + if (ref.contains("user")) { + List userList = UserCache.getActiveList(); + if (!isEmpty(userList)) { + for (UserModel model : userList) { + if (SDK.getORGAPI().getDepartmentById(model.getDepartmentId()).getCompanyId().equals(_uc.getCompanyModel().getId()) + && (model.getUserName().toUpperCase().contains(autoContent.toUpperCase()) || model.getUID().toUpperCase().contains(autoContent.toUpperCase()))) { + CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); + bean.setName(model.getUserName()); + bean.setType("user"); + StringBuilder sBuilder = new StringBuilder();// 名称组合 + StringBuilder idBuilder = new StringBuilder();// Id组合 + Set idSets = new HashSet<>();// id记录,校验防止递归死循环 + sBuilder.append(bean.getName()); + idBuilder.append(model.getUID()); + idSets.add(model.getUID()); + DepartmentModel departmentModel = SDK.getORGAPI().getDepartmentById(model.getDepartmentId()); + if (departmentModel != null && !departmentModel.isClosed()) { + sBuilder.insert(0, departmentModel.getName() + ">"); + idBuilder.insert(0, departmentModel.getId() + ","); + idSets.add(departmentModel.getId()); + boolean isClosed = false; + isClosed = getDepartmentFilePath(departmentModel, sBuilder, idBuilder, idSets, isClosed);// 递归获取当前文件名称路径 + if (!isClosed) { + // bean.setUi("
" + sBuilder.toString() + "
"); + bean.setUi(sBuilder.toString()); + bean.setValue(idBuilder.toString()); + list.add(bean); + } + } + } + } + } + } + if (ref.contains("role")) { + // 角色 + List roleList = SDK.getORGAPI().getRoles(); + if (!isEmpty(roleList)) { + for (RoleModel model : roleList) { + if (model != null && model.getRoleType() == 0) { + if (model.getName().toUpperCase().contains(autoContent.toUpperCase())) {// 包含 + CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); + bean.setName(model.getName()); + bean.setType("role"); + // bean.setUi("
" + new StringBuilder(model.getCategoryName()).append(">").append(model.getName()) + "
"); + bean.setUi(new StringBuilder(model.getCategoryName()).append(">").append(model.getName()).toString()); + bean.setValue(model.getCategoryName() + "," + model.getId()); + list.add(bean); + } + } + } + } + } + if (ref.contains("position")) { + // 岗位 + List roleList = SDK.getORGAPI().getRoles(); + if (!isEmpty(roleList)) { + for (RoleModel model : roleList) { + if (model != null && model.getRoleType() == 1) { + if (model.getName().toUpperCase().contains(autoContent.toUpperCase())) {// 包含 + CoeProcessLevelAutoBean bean = new CoeProcessLevelAutoBean(); + bean.setName(model.getName()); + bean.setType("position"); + // bean.setUi("
" + new StringBuilder(model.getCategoryName()).append(">").append(model.getName()) + "
"); + bean.setUi(new StringBuilder(model.getCategoryName()).append(">").append(model.getName()).toString()); + bean.setValue(model.getCategoryName() + "," + model.getId()); + list.add(bean); + } + } + } + } + } - // 递归部门名称 - private boolean getDepartmentFilePath(DepartmentModel model, StringBuilder sBuilder, StringBuilder idBuilder, Set idSets, boolean isClosed) { - if (!idSets.contains(model.getParentDepartmentId())) { - if (!"0".equals(model.getParentDepartmentId())) {// 有父节点 - String pid = model.getParentDepartmentId(); - DepartmentModel parentModel = SDK.getORGAPI().getDepartmentById(pid); - if (parentModel != null) { - if (!parentModel.isClosed()) { - sBuilder.insert(0, parentModel.getName() + ">"); - idBuilder.insert(0, parentModel.getId() + ","); - idSets.add(parentModel.getId()); - getDepartmentFilePath(parentModel, sBuilder, idBuilder, idSets, isClosed); - return false; - } else { - // 任何一级注销,都作废 - return true; - } - } - } else { - // 单位 - CompanyModel companyModel = SDK.getORGAPI().getCompanyById(model.getCompanyId()); - if (companyModel == null || companyModel.isClosed()) { - return true; - } else { - sBuilder.insert(0, companyModel.getName() + ">"); - idBuilder.insert(0, companyModel.getId() + ","); - idSets.add(companyModel.getId()); - return false; - } - } - } - return false; - } + boolean isBeyond = false;// 查询结果是否超出一定数量并截取 + if (!isEmpty(list)) { + // 排序 + Collections.sort(list, new Comparator() { + @Override + public int compare(CoeProcessLevelAutoBean o1, CoeProcessLevelAutoBean o2) { + String ui1 = o1.getUi(); + String ui2 = o2.getUi(); + return ui2.compareToIgnoreCase(ui1); + } + }); + } + ro.put("result", JSONArray.toJSON(list)); + ro.put("isBeyond", isBeyond); + return ro.toString(); + } - /** - * 保存关联的AWS平台组织关联关系 - * @param relationAwsOrg - * @param shapeId - * @param fileId - * @param shapeGroupId - * @param attrId - * @param shapeText - * @return - */ - public String saveAwsOrgRelevance(String relationAwsOrg, String shapeId, String fileId, String shapeGroupId, String attrId, String shapeText) { - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - // 已保存节点删除 - dao.deleteByAttrId(fileId, shapeId, attrId); - JSONArray array = JSONArray.parseArray(relationAwsOrg); - if (array != null && !array.isEmpty()) { - List modelList = new ArrayList(); - try { - for (int i = 0; i < array.size(); i++) { - JSONObject object = array.getJSONObject(i); - DesignerShapeRelationModel shapeRelationModel = new DesignerShapeRelationModel(); - shapeRelationModel.setId(UUIDGener.getUUID()); - shapeRelationModel.setFileId(fileId); - shapeRelationModel.setShapeId(shapeId); - shapeRelationModel.setShapeText(shapeText); - shapeRelationModel.setAttrId(attrId); - shapeRelationModel.setRelationFileId("00000000-0000-0000-0000-000000000000"); - shapeRelationModel.setRelationShapeId("00000000-0000-0000-0000-000000000000"); - shapeRelationModel.setRelationShapeText(object.toString()); - modelList.add(shapeRelationModel); - } - if (modelList.size() > 0) { - dao.barchInsert(modelList); - } - } catch (Exception e) { - throw new AWSException("保存关联属性失败"); - } - } - CoeProcessLevelUtil.syncBPAProcessOwner(fileId, attrId, array); - ResponseObject responseObject = ResponseObject.newOkResponse(); - return responseObject.toString(); - } + // 递归部门名称 + private boolean getDepartmentFilePath(DepartmentModel model, StringBuilder sBuilder, StringBuilder idBuilder, Set idSets, boolean isClosed) { + if (!idSets.contains(model.getParentDepartmentId())) { + if (!"0".equals(model.getParentDepartmentId())) {// 有父节点 + String pid = model.getParentDepartmentId(); + DepartmentModel parentModel = SDK.getORGAPI().getDepartmentById(pid); + if (parentModel != null) { + if (!parentModel.isClosed()) { + sBuilder.insert(0, parentModel.getName() + ">"); + idBuilder.insert(0, parentModel.getId() + ","); + idSets.add(parentModel.getId()); + getDepartmentFilePath(parentModel, sBuilder, idBuilder, idSets, isClosed); + return false; + } else { + // 任何一级注销,都作废 + return true; + } + } + } else { + // 单位 + CompanyModel companyModel = SDK.getORGAPI().getCompanyById(model.getCompanyId()); + if (companyModel == null || companyModel.isClosed()) { + return true; + } else { + sBuilder.insert(0, companyModel.getName() + ">"); + idBuilder.insert(0, companyModel.getId() + ","); + idSets.add(companyModel.getId()); + return false; + } + } + } + return false; + } - /** - * awsorg关联类型查询关联的aws组织名称 - * @param fileId - * @param shapeId - * @param shapeName - * @param shapeCategory - * @return - */ - public String getAwsOrgRelevanceName(String fileId, String shapeId, String shapeName, String shapeCategory) { - PALRepositoryModel m = PALRepositoryCache.getCache().get(fileId); - if (m == null) { - throw new AWSException("没有查找到关联的文件"); - } - String wsId = m.getWsId(); - if ("bpmn".equals(shapeCategory)) {// BPM平台流程类型为bpmn而不是process.bpmn2 - shapeCategory = "process.bpmn2"; - } - String shapeMethod = shapeCategory.replace("_", "."); - // 获取有效的属性内容 - List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, shapeMethod, shapeName, m.getMethodId()); - Map refMap = new HashMap(); - for (PALMethodAttributeModel model : attributeModelList) { - if ("awsorg".equals(model.getType())) { - refMap.put(model.getKey(), JSON.parseObject(model.getRef())); - } - } + /** + * 保存关联的AWS平台组织关联关系 + * + * @param relationAwsOrg + * @param shapeId + * @param fileId + * @param shapeGroupId + * @param attrId + * @param shapeText + * @return + */ + public String saveAwsOrgRelevance(String relationAwsOrg, String shapeId, String fileId, String shapeGroupId, String attrId, String shapeText) { + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + // 已保存节点删除 + dao.deleteByAttrId(fileId, shapeId, attrId); + JSONArray array = JSONArray.parseArray(relationAwsOrg); + if (array != null && !array.isEmpty()) { + List modelList = new ArrayList(); + try { + for (int i = 0; i < array.size(); i++) { + JSONObject object = array.getJSONObject(i); + DesignerShapeRelationModel shapeRelationModel = new DesignerShapeRelationModel(); + shapeRelationModel.setId(UUIDGener.getUUID()); + shapeRelationModel.setFileId(fileId); + shapeRelationModel.setShapeId(shapeId); + shapeRelationModel.setShapeText(shapeText); + shapeRelationModel.setAttrId(attrId); + shapeRelationModel.setRelationFileId("00000000-0000-0000-0000-000000000000"); + shapeRelationModel.setRelationShapeId("00000000-0000-0000-0000-000000000000"); + shapeRelationModel.setRelationShapeText(object.toString()); + modelList.add(shapeRelationModel); + } + if (modelList.size() > 0) { + dao.barchInsert(modelList); + } + } catch (Exception e) { + throw new AWSException("保存关联属性失败"); + } + } + CoeProcessLevelUtil.syncBPAProcessOwner(fileId, attrId, array); + ResponseObject responseObject = ResponseObject.newOkResponse(); + return responseObject.toString(); + } + + /** + * awsorg关联类型查询关联的aws组织名称 + * + * @param fileId + * @param shapeId + * @param shapeName + * @param shapeCategory + * @return + */ + public String getAwsOrgRelevanceName(String fileId, String shapeId, String shapeName, String shapeCategory) { + PALRepositoryModel m = PALRepositoryCache.getCache().get(fileId); + if (m == null) { + throw new AWSException("没有查找到关联的文件"); + } + String wsId = m.getWsId(); + if ("bpmn".equals(shapeCategory)) {// BPM平台流程类型为bpmn而不是process.bpmn2 + shapeCategory = "process.bpmn2"; + } + String shapeMethod = shapeCategory.replace("_", "."); + // 获取有效的属性内容 + List attributeModelList = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, shapeMethod, shapeName, m.getMethodId()); + Map refMap = new HashMap(); + for (PALMethodAttributeModel model : attributeModelList) { + if ("awsorg".equals(model.getType())) { + refMap.put(model.getKey(), JSON.parseObject(model.getRef())); + } + } - List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(fileId, shapeId, null, null); - JSONObject attrObj = new JSONObject(); - Set filter = new HashSet(); - for (DesignerShapeRelationModel model : list) { - if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { - JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); - // 查询最新名称 - if ("department".equals(object.getString("type"))) { - DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); - if (dept != null && !filter.contains(dept.getId())) { - object.put("name", dept.getName()); - filter.add(dept.getId()); - } - } - if ("position".equals(object.getString("type"))) {// 岗位 - RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); - if (role != null && !filter.contains(role.getId())) { - object.put("name", role.getName()); - filter.add(role.getId()); - } - } - if ("user".equals(object.getString("type"))) { - UserModel user = SDK.getORGAPI().getUser(object.getString("id")); - if (user != null && !filter.contains(user.getUID())) { - object.put("name", user.getUserName()); - filter.add(user.getUID()); - } - } - if ("role".equals(object.getString("type"))) { - RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); - if (role != null && !filter.contains(role.getId())) { - object.put("name", role.getName()); - filter.add(role.getId()); - } - } - if (!attrObj.containsKey(model.getAttrId())) { - attrObj.put(model.getAttrId(), new JSONArray()); - } - attrObj.getJSONArray(model.getAttrId()).add(object); - } - } - ResponseObject ro = ResponseObject.newOkResponse(); - ro.put("attrData", attrObj); - ro.put("shapeRefObj", refMap); - return ro.toString(); - } + List list = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(fileId, shapeId, null, null); + JSONObject attrObj = new JSONObject(); + Set filter = new HashSet(); + for (DesignerShapeRelationModel model : list) { + if ("00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId())) { + JSONObject object = JSONObject.parseObject(model.getRelationShapeText()); + // 查询最新名称 + if ("department".equals(object.getString("type"))) { + DepartmentModel dept = SDK.getORGAPI().getDepartmentById(object.getString("id")); + if (dept != null && !filter.contains(dept.getId())) { + object.put("name", dept.getName()); + filter.add(dept.getId()); + } + } + if ("position".equals(object.getString("type"))) {// 岗位 + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + object.put("name", role.getName()); + filter.add(role.getId()); + } + } + if ("user".equals(object.getString("type"))) { + UserModel user = SDK.getORGAPI().getUser(object.getString("id")); + if (user != null && !filter.contains(user.getUID())) { + object.put("name", user.getUserName()); + filter.add(user.getUID()); + } + } + if ("role".equals(object.getString("type"))) { + RoleModel role = SDK.getORGAPI().getRoleById(object.getString("id")); + if (role != null && !filter.contains(role.getId())) { + object.put("name", role.getName()); + filter.add(role.getId()); + } + } + if (!attrObj.containsKey(model.getAttrId())) { + attrObj.put(model.getAttrId(), new JSONArray()); + } + attrObj.getJSONArray(model.getAttrId()).add(object); + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.put("attrData", attrObj); + ro.put("shapeRefObj", refMap); + return ro.toString(); + } - public String saveRearLeadProcessRelationData(String uuid, String relationFileId, String relationShapeText, String type) { - String attrId = null; - if ("lead".equals(type)) {// 前置流程 - attrId = "lead_process"; + public String saveRearLeadProcessRelationData(String uuid, String relationFileId, String relationShapeText, String type) { + String attrId = null; + if ("lead".equals(type)) {// 前置流程 + attrId = "lead_process"; - } else if ("rear".equals(type)) {// 后置流程 - attrId = "rear_process"; + } else if ("rear".equals(type)) {// 后置流程 + attrId = "rear_process"; - } else { - return ResponseObject.newErrResponse("保存错误").toString(); - } - List list = DesignerShapeRelationCache.getByFileId(uuid, attrId); - boolean exist = false; - for (DesignerShapeRelationModel model : list) { - if (UtilString.isEmpty(model.getShapeId())) { - if (relationFileId.equals(model.getRelationFileId())) { - exist = true; - } - } - } - if (!exist) { - DesignerShapeRelationModel model = new DesignerShapeRelationModel(); - model.setId(UUIDGener.getUUID()); - model.setFileId(uuid); - model.setShapeId(""); - model.setAttrId(attrId); - model.setRelationFileId(relationFileId); - model.setRelationShapeId(""); - model.setRelationShapeText(relationShapeText); - new DesignerShapeRelationDao().insert(model); - } - return ResponseObject.newOkResponse().toString(); - } + } else { + return ResponseObject.newErrResponse("保存错误").toString(); + } + List list = DesignerShapeRelationCache.getByFileId(uuid, attrId); + boolean exist = false; + for (DesignerShapeRelationModel model : list) { + if (UtilString.isEmpty(model.getShapeId())) { + if (relationFileId.equals(model.getRelationFileId())) { + exist = true; + } + } + } + if (!exist) { + DesignerShapeRelationModel model = new DesignerShapeRelationModel(); + model.setId(UUIDGener.getUUID()); + model.setFileId(uuid); + model.setShapeId(""); + model.setAttrId(attrId); + model.setRelationFileId(relationFileId); + model.setRelationShapeId(""); + model.setRelationShapeText(relationShapeText); + new DesignerShapeRelationDao().insert(model); + } + return ResponseObject.newOkResponse().toString(); + } - public String searchLeadRearRelationData(String fileId, String removeProcedureShapes) { - JSONArray result = new JSONArray(); + public String searchLeadRearRelationData(String fileId, String removeProcedureShapes) { + JSONArray result = new JSONArray(); - JSONArray removeShapeArr = JSONArray.parseArray(removeProcedureShapes); - if (removeShapeArr.size() > 0) { - // 获取前置和后置数据 - String attrId = "lead_process";// 前置流程 - Map leadMap = new HashMap<>(); - Map leadRelationIdMap = new HashMap<>(); - List list = DesignerShapeRelationCache.getByFileId(fileId, attrId); - for (DesignerShapeRelationModel model : list) { - if (UtilString.isEmpty(model.getShapeId())) { - String versionId = model.getRelationFileId(); - List tmpList = PALRepositoryCache.getByVersionId(versionId); - if (tmpList != null) { - for (PALRepositoryModel plModel : tmpList) { - if (plModel.isUse()) { - leadMap.put(model.getId(), plModel.getName()); - leadRelationIdMap.put(plModel.getVersionId(), model.getId()); - } - } - } - } - } - attrId = "rear_process";// 后置流程 - Map rearMap = new HashMap<>(); - Map rearRelationIdMap = new HashMap<>(); - List list2 = DesignerShapeRelationCache.getByFileId(fileId, attrId); - for (DesignerShapeRelationModel model : list2) { - if (UtilString.isEmpty(model.getShapeId())) { - String versionId = model.getRelationFileId(); - List tmpList = PALRepositoryCache.getByVersionId(versionId); - if (tmpList != null) { - for (PALRepositoryModel plModel : tmpList) { - if (plModel.isUse()) { - rearMap.put(model.getId(), plModel.getName()); - rearRelationIdMap.put(plModel.getVersionId(), model.getId()); - } - } - } - } - } - for (int i = 0; i < removeShapeArr.size(); i++) { - JSONObject removeShape = removeShapeArr.getJSONObject(i); - String shapeId = removeShape.getString("id"); - String shapeText = removeShape.getString("text"); - JSONArray fromLinkerArr = removeShape.getJSONArray("fromLinkerArr"); - JSONArray toLinkerArr = removeShape.getJSONArray("toLinkerArr"); - JSONObject attrMark = removeShape.getJSONObject("attrMark"); - boolean leadExist = false; - String leadRelationId = ""; - boolean rearExist = false; - String rearRelationId = ""; - if (attrMark == null) {// 根据出入线匹配 - // 前置查询 - if (fromLinkerArr.size() > 0 && toLinkerArr.size() == 0 && leadMap.containsValue(shapeText)) {// 多出线,零入线且名称存在匹配 - for (Map.Entry entry : leadMap.entrySet()) { - if (entry.getValue().equals(shapeText)) { - leadExist = true; - leadRelationId = entry.getKey(); + JSONArray removeShapeArr = JSONArray.parseArray(removeProcedureShapes); + if (removeShapeArr.size() > 0) { + // 获取前置和后置数据 + String attrId = "lead_process";// 前置流程 + Map leadMap = new HashMap<>(); + Map leadRelationIdMap = new HashMap<>(); + List list = DesignerShapeRelationCache.getByFileId(fileId, attrId); + for (DesignerShapeRelationModel model : list) { + if (UtilString.isEmpty(model.getShapeId())) { + String versionId = model.getRelationFileId(); + List tmpList = PALRepositoryCache.getByVersionId(versionId); + if (tmpList != null) { + for (PALRepositoryModel plModel : tmpList) { + if (plModel.isUse()) { + leadMap.put(model.getId(), plModel.getName()); + leadRelationIdMap.put(plModel.getVersionId(), model.getId()); + } + } + } + } + } + attrId = "rear_process";// 后置流程 + Map rearMap = new HashMap<>(); + Map rearRelationIdMap = new HashMap<>(); + List list2 = DesignerShapeRelationCache.getByFileId(fileId, attrId); + for (DesignerShapeRelationModel model : list2) { + if (UtilString.isEmpty(model.getShapeId())) { + String versionId = model.getRelationFileId(); + List tmpList = PALRepositoryCache.getByVersionId(versionId); + if (tmpList != null) { + for (PALRepositoryModel plModel : tmpList) { + if (plModel.isUse()) { + rearMap.put(model.getId(), plModel.getName()); + rearRelationIdMap.put(plModel.getVersionId(), model.getId()); + } + } + } + } + } + for (int i = 0; i < removeShapeArr.size(); i++) { + JSONObject removeShape = removeShapeArr.getJSONObject(i); + String shapeId = removeShape.getString("id"); + String shapeText = removeShape.getString("text"); + JSONArray fromLinkerArr = removeShape.getJSONArray("fromLinkerArr"); + JSONArray toLinkerArr = removeShape.getJSONArray("toLinkerArr"); + JSONObject attrMark = removeShape.getJSONObject("attrMark"); + boolean leadExist = false; + String leadRelationId = ""; + boolean rearExist = false; + String rearRelationId = ""; + if (attrMark == null) {// 根据出入线匹配 + // 前置查询 + if (fromLinkerArr.size() > 0 && toLinkerArr.size() == 0 && leadMap.containsValue(shapeText)) {// 多出线,零入线且名称存在匹配 + for (Map.Entry entry : leadMap.entrySet()) { + if (entry.getValue().equals(shapeText)) { + leadExist = true; + leadRelationId = entry.getKey(); - } - } - } - // 后置查询 - if (toLinkerArr.size() > 0 && fromLinkerArr.size() == 0 && rearMap.containsValue(shapeText)) {// 多入线,零出线且名称匹配 - for (Map.Entry entry : rearMap.entrySet()) { - if (entry.getValue().equals(shapeText)) { - rearExist = true; - rearRelationId = entry.getKey(); - } - } - } - } else { - String versionId = attrMark.getString("versionId"); + } + } + } + // 后置查询 + if (toLinkerArr.size() > 0 && fromLinkerArr.size() == 0 && rearMap.containsValue(shapeText)) {// 多入线,零出线且名称匹配 + for (Map.Entry entry : rearMap.entrySet()) { + if (entry.getValue().equals(shapeText)) { + rearExist = true; + rearRelationId = entry.getKey(); + } + } + } + } else { + String versionId = attrMark.getString("versionId"); - if (leadRelationIdMap.containsKey(versionId)) { - leadExist = true; - leadRelationId = leadRelationIdMap.get(versionId); - } - if (rearRelationIdMap.containsKey(versionId)) { - rearExist = true; - rearRelationId = rearRelationIdMap.get(versionId); - } - } - JSONObject obj = new JSONObject(); - obj.put("shapeId", shapeId); - obj.put("shapeText", shapeText); - obj.put("leadExist", leadExist); - obj.put("leadRelationId", leadRelationId); - obj.put("rearExist", rearExist); - obj.put("rearRelationId", rearRelationId); - result.add(obj); - } - } - ResponseObject ro = ResponseObject.newOkResponse(); - ro.setData(result); - return ro.toString(); - } + if (leadRelationIdMap.containsKey(versionId)) { + leadExist = true; + leadRelationId = leadRelationIdMap.get(versionId); + } + if (rearRelationIdMap.containsKey(versionId)) { + rearExist = true; + rearRelationId = rearRelationIdMap.get(versionId); + } + } + JSONObject obj = new JSONObject(); + obj.put("shapeId", shapeId); + obj.put("shapeText", shapeText); + obj.put("leadExist", leadExist); + obj.put("leadRelationId", leadRelationId); + obj.put("rearExist", rearExist); + obj.put("rearRelationId", rearRelationId); + result.add(obj); + } + } + ResponseObject ro = ResponseObject.newOkResponse(); + ro.setData(result); + return ro.toString(); + } - public String deleteLeadRearRelationData(String uuid, String data) { - ResponseObject ro = ResponseObject.newOkResponse(); - JSONArray dataArr = JSON.parseArray(data); - DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); - for (int i = 0; i < dataArr.size(); i++) { - JSONObject obj = dataArr.getJSONObject(i); - String shapeText = obj.getString("shapeText"); - boolean leadExist = obj.getBooleanValue("leadExist"); - if (leadExist) { - int r = dao.deleteById(obj.getString("leadRelationId")); - if (r > 0) { - SDK.getLogAPI().consoleInfo("[成功]PAL通过设计器删除形状的方式删除前置流程[" + shapeText + "]"); - } - } - boolean rearExist = obj.getBooleanValue("rearExist"); - if (rearExist) { - int r = dao.deleteById(obj.getString("rearRelationId")); - if (r > 0) { - SDK.getLogAPI().consoleInfo("[成功]PAL通过设计器删除形状的方式删除后置流程[" + shapeText + "]"); - } - } - } - return ro.toString(); - } -} + public String deleteLeadRearRelationData(String uuid, String data) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray dataArr = JSON.parseArray(data); + DesignerShapeRelationDao dao = new DesignerShapeRelationDao(); + for (int i = 0; i < dataArr.size(); i++) { + JSONObject obj = dataArr.getJSONObject(i); + String shapeText = obj.getString("shapeText"); + boolean leadExist = obj.getBooleanValue("leadExist"); + if (leadExist) { + int r = dao.deleteById(obj.getString("leadRelationId")); + if (r > 0) { + SDK.getLogAPI().consoleInfo("[成功]PAL通过设计器删除形状的方式删除前置流程[" + shapeText + "]"); + } + } + boolean rearExist = obj.getBooleanValue("rearExist"); + if (rearExist) { + int r = dao.deleteById(obj.getString("rearRelationId")); + if (r > 0) { + SDK.getLogAPI().consoleInfo("[成功]PAL通过设计器删除形状的方式删除后置流程[" + shapeText + "]"); + } + } + } + return ro.toString(); + } + + /** + * 根据配置动态拼接建模导引前端代码 + * + * @param methodId 方法id + * @return {@link String} + */ + public String getModelingGuide(String methodId, String sid) { + ResponseObject ro = ResponseObject.newOkResponse(); + JSONArray steps = new JSONArray(); + //轮播图的页面地址 + String url = "./w?sid=" + _uc.getSessionId() + "&cmd=com.actionsoft.apps.coe.pal_guide_carousel"; + String sql = "SELECT STEP,MODELTYPE,TITLE,POSITION,GUIDETARGET FROM BO_ACT_PAL_MODELING_GUIDANCE WHERE MODELTYPE=? ORDER BY STEP"; + List guideMaps = DBSql.getMaps(sql, methodId); + for (int i = 0; i < guideMaps.size(); i++) { + StringBuilder urlSb = new StringBuilder(); + urlSb.append(""); + popover.put("description", urlSb.toString()); + //导引每一步的class,目前用不到 + /*}else{ + popover.put("className","step"); + }*/ + } + }); + step.put("popover", popover); + steps.add(step); + + } + ro.put("steps", steps); + return ro.toString(); + + } + + /** + * 建模导引轮播图页面 + *9 + * @param step 步骤 + * @param modelType 模型类型 + * @return {@link String} + */ + public String getModelingGuideCarousel(String step, String modelType) { + Map macroLibraries = new HashMap<>(); + BO bo = SDK.getBOAPI().query("BO_ACT_PAL_MODELING_GUIDANCE").addQuery("step=", step).addQuery("MODELTYPE=" , modelType).detail(); + String boId = bo == null ? "" : bo.getId(); + JSONArray filePathArray = new JSONArray(); + //附件列表 + List formFiles = SDK.getBOAPI().getFiles(boId, "CONTENT"); + for (FormFile formFile : formFiles) { + DCContext fileDCContext = SDK.getBOAPI().getFileDCContext(formFile); + fileDCContext.setSession(_uc); + String downloadURL = fileDCContext.getDownloadURL(); + JSONObject jo = new JSONObject(); + String fileName = fileDCContext.getFileName(); + //视频支持mp4类型 + if(fileName.contains("mp4")){ + jo.put("video" , downloadURL); + }else if(fileName.contains("png") || fileName.contains("gif") || fileName.contains("jpg")){ + jo.put("picture" , downloadURL); + } + jo.put("picTitle" , fileName.split("\\.")[0]); + filePathArray.add(jo); + } + macroLibraries.put("filePaths", filePathArray); + return HtmlPageTemplate.merge(CoEConstant.APP_ID, "carousel.map.html", macroLibraries); + } + + /** + * 检查用户是否第一次创建模型 + * + * @param methodId 模型类型 + * @return {@link String} + */ + public String checkUserFirstCreateModel(String methodId){ + ResponseObject ro = ResponseObject.newOkResponse(); + String sql = "SELECT COUNT(1) FROM APP_ACT_COE_PAL_REPOSITORY WHERE CREATEUSER=? AND PLMETHODID=?"; + String uid = _uc.getUID(); + int anInt = DBSql.getInt(sql, new Object[]{uid, methodId}); + ro.put("isFirst" , anInt > 0 ? false : true); + return ro.toString(); + } +} \ No newline at end of file diff --git a/com.actionsoft.apps.coe.pal/template/page/carousel.map.html b/com.actionsoft.apps.coe.pal/template/page/carousel.map.html new file mode 100644 index 00000000..e321bc0b --- /dev/null +++ b/com.actionsoft.apps.coe.pal/template/page/carousel.map.html @@ -0,0 +1,298 @@ + + + + + + Document + + + + + + + + + + + +
+ + < + > + +
    + +
      + +
    +
    + + diff --git a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm index 3914dcce..cfa262c9 100755 --- a/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm +++ b/com.actionsoft.apps.coe.pal/template/page/pal.pl.repository.designer.htm @@ -72,6 +72,96 @@ .toolbarExtend{ height: 36px !important; } + + /* 1. 样式重置 */ + * { + margin: 0; + padding: 0; + } + li { + list-style: none; + } + + /* 外层盒子样式,左右箭头和小圆点都要采用绝对定位,所以其父盒子要采用相对定位*/ + .banners { + position: relative; + overflow: hidden; + width: 520px; + height: 280px; + margin: 100px auto; + } + /*滚动区 包裹所有图片的盒子 宽度要足够宽可以放下所有的图片*/ + .images { + position: absolute; + top: 0; + left: 0; + width: 700%; + } + /* 对图片使用浮动 使其排列在一行*/ + .images li{ + float: left; + } + /* 图片大小会撑大盒子,设置图片大小 */ + .banners img { + width: 520px; + height: 280px; + } + /*左右箭头相同样式*/ + .prev, + .next { + display: none; + position: absolute; + /* 绝对定位的盒子垂直居中 */ + top: 50%; + margin-top: -15px; + width: 20px; + height: 30px; + background: rgba(0,0,0, .3); + text-align: center; + line-height: 30px; + color: #fff; + text-decoration: none; + } + /*左箭头靠左定位*/ + .prev { + left: 0; + /* 设置圆角 */ + border-top-right-radius: 15px; + border-bottom-right-radius: 15px; + } + /*右箭头靠右定位*/ + .next { + right: 0; + /* 设置圆角 */ + border-top-left-radius: 15px; + border-bottom-left-radius: 15px; + } + /* 小圆点外层盒子的样式 */ + .dots { + position: absolute; + bottom: 10px; + left: 50%; + margin-left: -35px; + height: 13px; + background:rgba(255,255,255, .3); + border-radius:7px; + } + /* 小圆点样式*/ + .dots li { + float: left; + width: 8px; + height: 8px; + background-color: #fff; + border-radius: 50%; + margin: 3px; + } + .driver-popover-title{ + color: #00b800; + } + /* 小圆点被点击的样式 */ + .dots .active { + background-color: #ff5000; + } @@ -89,6 +179,8 @@ + +