From a0cfb4bd64fbbcfd828759efe50561e5346b929b Mon Sep 17 00:00:00 2001 From: lihongyu <504404568@qq.com> Date: Sun, 21 Aug 2022 17:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=91=E5=B8=83=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=BC=96=E5=8F=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/util/ProcesNumberUtil.java | 371 +++++++++++++----- 1 file changed, 278 insertions(+), 93 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java index 5d114c03..36d623d1 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/client/util/ProcesNumberUtil.java @@ -1,5 +1,7 @@ package com.actionsoft.apps.coe.pal.publisher.client.util; +import java.util.List; + import com.actionsoft.bpms.bo.engine.BO; import com.actionsoft.bpms.commons.database.RowMap; import com.actionsoft.bpms.util.DBSql; @@ -7,8 +9,6 @@ import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.bpms.util.UtilString; import com.actionsoft.sdk.local.SDK; -import java.util.List; - /** * @author baizp * @Description: 生成流程编号工具 @@ -22,101 +22,286 @@ public class ProcesNumberUtil { * @param regionCode * @return */ - public synchronized String getProcessNum(String levelCode, String regionCode) { - String querySql = "select ID,NUMBERS from BO_ACT_PROCESSNUMBER where LEVELNUM = '%s' and REGIONCODE='%s'"; - RowMap result = DBSql.getMap(String.format(querySql, levelCode, regionCode)); - //如果没有就新增 - if (result == null) { - String sql = "insert into BO_ACT_PROCESSNUMBER (ID,LEVELNUM,REGIONCODE,NUMBERS) values ('%s', '%s', '%s',%s)"; - String id = UUIDGener.getUUID(); - DBSql.update(String.format(sql, id, levelCode, regionCode, 1)); - return "01"; - } - int nowNum = result.getInt("NUMBERS"); - String updateSql = "update BO_ACT_PROCESSNUMBER set NUMBERS=%s where ID='%s'"; - DBSql.update(String.format(updateSql, nowNum + 1, result.getString("ID"))); - if (nowNum < 10) { - return "0" + nowNum; - } + public String getProcessNum(String levelCode, String regionCode,String plcategory) { + int nowNum = 1; + //流程编号 + if (plcategory.contains("process")) { + String querySql = "select ID,PROCESS_NUMBERS from BO_ACT_PROCESSNUMBER where LEVELNUM = '%s' and REGIONCODE='%s'"; + RowMap result = DBSql.getMap(String.format(querySql, levelCode, regionCode)); + //如果没有就新增 + if (result == null) { + String sql = "insert into BO_ACT_PROCESSNUMBER (ID,LEVELNUM,REGIONCODE,PROCESS_NUMBERS,SYSTEM_NUMBERS,FORM_NUMBERS) values ('%s', '%s', '%s', %s, %s, %s)"; + String id = UUIDGener.getUUID(); + int update = DBSql.update(String.format(sql, id, levelCode, regionCode, nowNum + 1, 1, 1)); + return "01"; + } + nowNum = result.getInt("PROCESS_NUMBERS"); + String updateSql = "update BO_ACT_PROCESSNUMBER set PROCESS_NUMBERS=%s where ID='%s'"; + DBSql.update(String.format(updateSql, nowNum + 1, result.getString("ID"))); + if (nowNum < 10) { + return "0" + nowNum; + } + + } else if (plcategory.contains("control")) { + //制度编号 + String querySql = "select ID,SYSTEM_NUMBERS from BO_ACT_PROCESSNUMBER where LEVELNUM = '%s' and REGIONCODE='%s'"; + RowMap result = DBSql.getMap(String.format(querySql, levelCode, regionCode)); + //如果没有就新增 + if (result == null) { + String sql = "insert into BO_ACT_PROCESSNUMBER (ID,LEVELNUM,REGIONCODE,PROCESS_NUMBERS,SYSTEM_NUMBERS,FORM_NUMBERS) values ('%s', '%s', '%s', %s, %s, %s)"; + String id = UUIDGener.getUUID(); + DBSql.update(String.format(sql, id, levelCode, regionCode, 1, 1, 1)); + return "01"; + } + nowNum = result.getInt("SYSTEM_NUMBERS"); + String updateSql = "update BO_ACT_PROCESSNUMBER set SYSTEM_NUMBERS=%s where ID='%s'"; + DBSql.update(String.format(updateSql, nowNum + 1, result.getString("ID"))); + if (nowNum < 10) { + return "0" + nowNum; + } + + } else if (plcategory.contains("form")) { + //表单编号 + String querySql = "select ID,FORM_NUMBERS from BO_ACT_PROCESSNUMBER where LEVELNUM = '%s' and REGIONCODE='%s'"; + RowMap result = DBSql.getMap(String.format(querySql, levelCode, regionCode)); + //如果没有就新增 + if (result == null) { + String sql = "insert into BO_ACT_PROCESSNUMBER (ID,LEVELNUM,REGIONCODE,PROCESS_NUMBERS,SYSTEM_NUMBERS,FORM_NUMBERS) values ('%s', '%s', '%s', %s, %s, %s)"; + String id = UUIDGener.getUUID(); + DBSql.update(String.format(sql, id, levelCode, regionCode, 1, 1, 1)); + return "01"; + } + nowNum = result.getInt("FORM_NUMBERS"); + String updateSql = "update BO_ACT_PROCESSNUMBER set FORM_NUMBERS=%s where ID='%s'"; + DBSql.update(String.format(updateSql, nowNum + 1, result.getString("ID"))); + if (nowNum < 10) { + return "0" + nowNum; + } + + + } + + + return nowNum + ""; } - /** - * 生成编号并写入数据库 - * @param bindId - * @return - */ - public String getNumber(String bindId) { - System.out.println("生成编号并写入数据库==============="); - //查询出主表数据 - BO mainData = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", bindId); - //根据主表数据查询出权限的编码 - String qxSql = "select * from BO_ACT_AUTH_INFO where ORGNAME='%s' and LEVEL_1_PROCESS_NAME='%s' and LEVEL_2_PROCESS_NAME='%s' and LEVEL_3_PROCESS_NAME='%s'" + - " and ADAPT_REGION_NAME = '%s' and APPLICABLE_PRODUCT='%s'"; - RowMap authData = DBSql.getMap(String.format(qxSql, mainData.getString("ADAPT_NAME_THE_COMPANY"), mainData.getString("LEVEL_1_PROCESS_NAME") - , mainData.getString("LEVEL_2_PROCESS_NAME"), mainData.getString("LEVEL_3_PROCESS_NAME"), mainData.getString("ADAPT_REGION_NAME"), mainData.getString("APPLICABLE_PRODUCT"))); - //获取所有的流程编码 如果为空则为00 - String orgCode = authData.getString("ORGCODE"); - String levelOne = authData.getString("LEVEL_1_PROCESS_ID"); - String levelTwo = authData.getString("LEVEL_2_PROCESS_ID"); - String levelThree = authData.getString("LEVEL_3_PROCESS_ID"); - String regionCode = authData.getString("ADAPT_REGION_CODE"); - String productCode = authData.getString("APPLICABLE_PRODUCT_CODE"); - //查询出所有的发布流程 - List dataList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).list(); - //依次生成编号~并回填 修改 - if(UtilString.isNotEmpty(levelTwo)){ - levelTwo =levelTwo.substring(levelTwo.indexOf(".")+1,levelTwo.length()); - }else{ - levelTwo = "00"; - } - if(UtilString.isNotEmpty(levelThree)){ - levelThree =levelThree.substring(levelThree.lastIndexOf(".")+1,levelThree.length()); - }else{ - levelThree = "00"; - } - String levelnum = levelOne + "." + levelTwo + "." + levelThree; + /** + * 生成编号并写入数据库 + * + * @param bindId + * @return + */ + public String getNumber(String bindId) { - String updateSql = "update BO_ACT_COE_PUBLISH_N set PUBLISH_NUMBER='%s' where ID = '%s'"; - for (BO nowData : dataList) { - String number = getProcessNum(levelnum, orgCode); - String publishfileid=nowData.getString("PUBLISHFILEID"); + System.out.println("生成编号并写入数据库==============="); - RowMap rowMap=DBSql.getMap("SELECT PLVER,PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID='"+publishfileid+"' AND" - + " ISUSE = 1 "); - String name = "00R00"; - String fileName = "file_number"; - String plver= "1.0"; - if(rowMap!=null){ - String plcategory=rowMap.getString("PLMETHODID"); - String plvers=rowMap.getString("PLVER"); - if(plcategory.contains("process")){ - name = number + "/P"+number; - }else if(plcategory.contains("control")){ - name = "00/R00"; - }else if(plcategory.contains("form")){ - fileName = "form_number"; - name = "00/T00"; - } - if(!"".equals(plvers)) { - if(plvers.length()>1) { - plver = plvers.substring(0,1)+"."+plvers.substring(plvers.length()-1,plvers.length()); - }else { - plver = plvers.substring(0,1)+".0"; - } - } - } + // 查询出所有的发布流程 + List dataList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N").addQuery("BINDID=", bindId).list(); + // 查询出所有的变更流程 + List changList = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C").addQuery("BINDID=", bindId).list(); + if (changList.size() != 0) { + for (BO changData : changList) { + String publish_numner = changData.getString("PUBLISH_NUMBER"); + String changFileId = changData.getString("CHANGEFILEID"); + String changAfterFileId = changData.getString("CHANGEDFILEIDNEW"); + if(UtilString.isEmpty(publish_numner)) { + RowMap rowMap = DBSql.getMap("SELECT * FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID='" + changFileId + "'"); + String Vsion1Id = DBSql.getString("SELECT ID FROM APP_ACT_COE_PAL_REPOSITORY WHERE PLRID='" + + rowMap.getString("PLRID") + "' AND" + " PLVER = 1 "); + String publish_number = DBSql.getString( + "SELECT PUBLISH_NUMBER FROM BO_ACT_COE_PUBLISH_N WHERE PUBLISHFILEID ='" + Vsion1Id + "'"); + + if (UtilString.isNotEmpty(publish_number)) { + // 设置模型ID + String plver = "2.0"; + String plvers = rowMap.getString("PLVER"); + if (!"".equals(plvers)) { + if (plvers.length() > 1) { + plver = plvers.substring(0, 1) + "." + + plvers.substring(plvers.length() - 1, plvers.length()); + } else { + plver = plvers.substring(0, 1) + ".0"; + } + } + + String new_number = publish_number.replaceAll("V1.0", "V"+plver); + String updateSql = "update BO_ACT_COE_PUBLISH_C set PUBLISH_NUMBER='%s' where CHANGEDFILEIDNEW = '%s'"; + //更新子表文件编码属性 + int update = DBSql.update(String.format(updateSql, new_number, changAfterFileId)); + System.out.println("更新子表文件编号:" + update + "--->" + new_number); + String fileName = "file_number"; + if (rowMap != null) { + String plcategory = rowMap.getString("PLMETHODID"); + if (plcategory.contains("form")) { + fileName = "form_number"; + } + + } + //更新模型文件编码属性 + String updateAttrsql = "update APP_ACT_COE_PAL_PROP set PROPERTYVALUE='%s' where PROPERTYID='%s' AND PLID='%s'"; + int update2 = DBSql.update(String.format(updateAttrsql, new_number, fileName, changAfterFileId)); + System.out.println("更新模型文件编号:" + update2 + "--->" + new_number); + }else { + + + // 查询出主表数据 + BO mainData = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", bindId); + // 根据主表数据查询出权限的编码 + String qxSql = "select * from BO_ACT_AUTH_INFO where ORGNAME='%s' and LEVEL_1_PROCESS_NAME='%s' and LEVEL_2_PROCESS_NAME='%s' and LEVEL_3_PROCESS_NAME='%s'" + + " and ADAPT_REGION_NAME = '%s' and APPLICABLE_PRODUCT='%s'"; + RowMap authData = DBSql.getMap(String.format(qxSql, mainData.getString("ADAPT_NAME_THE_COMPANY"), + mainData.getString("LEVEL_1_PROCESS_NAME"), mainData.getString("LEVEL_2_PROCESS_NAME"), + mainData.getString("LEVEL_3_PROCESS_NAME"), mainData.getString("ADAPT_REGION_NAME"), + mainData.getString("APPLICABLE_PRODUCT"))); + // 获取所有的流程编码 如果为空则为00 + String orgCode = authData.getString("ORGCODE"); + String levelOne = authData.getString("LEVEL_1_PROCESS_ID"); + String levelTwo = authData.getString("LEVEL_2_PROCESS_ID"); + String levelThree = authData.getString("LEVEL_3_PROCESS_ID"); + String regionCode = authData.getString("ADAPT_REGION_CODE"); + String productCode = authData.getString("APPLICABLE_PRODUCT_CODE"); - String processNum = levelnum + "." + name +"V"+plver+orgCode + regionCode + productCode; - String s = nowData.getId(); - int update = DBSql.update(String.format(updateSql, processNum, s.toLowerCase())); - System.out.println("表单文件编号回填:"+update+"--->"+processNum); - String publishFileId = nowData.getString("PUBLISHFILEID"); - String updateAttrsql = "update APP_ACT_COE_PAL_PROP set PROPERTYVALUE='%s' where PROPERTYID='%s' AND PLID='%s'"; - int update2 = DBSql.update(String.format(updateAttrsql, processNum, fileName, publishFileId)); - System.out.println("模型文件编号回填:"+update2+"--->"+processNum); - //更新流程绩效的编号----规则没看懂 - } - return "OK"; - } + // 依次生成编号~并回填 修改 + if (UtilString.isNotEmpty(levelTwo)) { + levelTwo = levelTwo.substring(levelTwo.indexOf(".") + 1, levelTwo.length()); + } else { + levelTwo = "00"; + } + if (UtilString.isNotEmpty(levelThree)) { + levelThree = levelThree.substring(levelThree.lastIndexOf(".") + 1, levelThree.length()); + } else { + levelThree = "00"; + } + String levelnum = levelOne + "." + levelTwo + "." + levelThree; + + String updateSql = "update BO_ACT_COE_PUBLISH_C set PUBLISH_NUMBER='%s' where ID = '%s'"; + rowMap = DBSql.getMap("SELECT PLVER,PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID='" + + changAfterFileId + "' AND" + " ISUSE = 1 "); + String name = "00R00"; + String fileName = "file_number"; + String plver = "1.0"; + if (rowMap != null) { + String plcategory = rowMap.getString("PLMETHODID"); + String plvers = rowMap.getString("PLVER"); + String number = getProcessNum(levelnum, orgCode,plcategory); + if (plcategory.contains("process")) { + name = number + "/P" + number; + } else if (plcategory.contains("control")) { + name = number + "/R" + number; + } else if (plcategory.contains("form")) { + fileName = "form_number"; + name = number + "/T" + number; + } + if (!"".equals(plvers)) { + if (plvers.length() > 1) { + plver = plvers.substring(0, 1) + "." + + plvers.substring(plvers.length() - 1, plvers.length()); + } else { + plver = plvers.substring(0, 1) + ".0"; + } + } + } + + String processNum = levelnum + "." + name + "V" + plver + orgCode + regionCode + productCode; + String s = changData.getId(); + int update = DBSql.update(String.format(updateSql, processNum, s.toLowerCase())); + System.out.println("更新表单文件编号回填:" + update + "--->" + processNum+" 文件id"+s); + String updateAttrsql = "update APP_ACT_COE_PAL_PROP set PROPERTYVALUE='%s' where PROPERTYID='%s' AND PLID='%s'"; + int update2 = DBSql.update(String.format(updateAttrsql, processNum, fileName, changAfterFileId)); + System.out.println("更新模型文件编号回填:" + update2 + "--->" + processNum +" 文件id"+changAfterFileId); + // 更新流程绩效的编号----规则没看懂 + + + + } + + + + + + + + } + + } + } + + if (dataList.size() != 0) { + // 查询出主表数据 + BO mainData = SDK.getBOAPI().getByProcess("BO_ACT_COE_PUBLISH", bindId); + // 根据主表数据查询出权限的编码 + String qxSql = "select * from BO_ACT_AUTH_INFO where ORGNAME='%s' and LEVEL_1_PROCESS_NAME='%s' and LEVEL_2_PROCESS_NAME='%s' and LEVEL_3_PROCESS_NAME='%s'" + + " and ADAPT_REGION_NAME = '%s' and APPLICABLE_PRODUCT='%s'"; + RowMap authData = DBSql.getMap(String.format(qxSql, mainData.getString("ADAPT_NAME_THE_COMPANY"), + mainData.getString("LEVEL_1_PROCESS_NAME"), mainData.getString("LEVEL_2_PROCESS_NAME"), + mainData.getString("LEVEL_3_PROCESS_NAME"), mainData.getString("ADAPT_REGION_NAME"), + mainData.getString("APPLICABLE_PRODUCT"))); + // 获取所有的流程编码 如果为空则为00 + String orgCode = authData.getString("ORGCODE"); + String levelOne = authData.getString("LEVEL_1_PROCESS_ID"); + String levelTwo = authData.getString("LEVEL_2_PROCESS_ID"); + String levelThree = authData.getString("LEVEL_3_PROCESS_ID"); + String regionCode = authData.getString("ADAPT_REGION_CODE"); + String productCode = authData.getString("APPLICABLE_PRODUCT_CODE"); + + // 依次生成编号~并回填 修改 + if (UtilString.isNotEmpty(levelTwo)) { + levelTwo = levelTwo.substring(levelTwo.indexOf(".") + 1, levelTwo.length()); + } else { + levelTwo = "00"; + } + if (UtilString.isNotEmpty(levelThree)) { + levelThree = levelThree.substring(levelThree.lastIndexOf(".") + 1, levelThree.length()); + } else { + levelThree = "00"; + } + String levelnum = levelOne + "." + levelTwo + "." + levelThree; + + String updateSql = "update BO_ACT_COE_PUBLISH_N set PUBLISH_NUMBER='%s' where ID = '%s'"; + for (BO nowData : dataList) { + String publish_numner = nowData.getString("PUBLISH_NUMBER"); + if(UtilString.isEmpty(publish_numner)) { + String publishfileid = nowData.getString("PUBLISHFILEID"); + RowMap rowMap = DBSql.getMap("SELECT PLVER,PLMETHODID FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID='" + + publishfileid + "' AND" + " ISUSE = 1 "); + String name = "00R00"; + String fileName = "file_number"; + String plver = "1.0"; + if (rowMap != null) { + String plcategory = rowMap.getString("PLMETHODID"); + String plvers = rowMap.getString("PLVER"); + String number = getProcessNum(levelnum, orgCode,plcategory); + if (plcategory.contains("process")) { + name = number + "/P" + number; + } else if (plcategory.contains("control")) { + name = number + "/R" + number; + } else if (plcategory.contains("form")) { + fileName = "form_number"; + name = number + "/T" + number; + } + if (!"".equals(plvers)) { + if (plvers.length() > 1) { + plver = plvers.substring(0, 1) + "." + + plvers.substring(plvers.length() - 1, plvers.length()); + } else { + plver = plvers.substring(0, 1) + ".0"; + } + } + } + + String processNum = levelnum + "." + name + "V" + plver + orgCode + regionCode + productCode; + String s = nowData.getId(); + int update = DBSql.update(String.format(updateSql, processNum, s.toLowerCase())); + System.out.println("表单文件编号回填:" + update + "--->" + processNum); + String publishFileId = nowData.getString("PUBLISHFILEID"); + String updateAttrsql = "update APP_ACT_COE_PAL_PROP set PROPERTYVALUE='%s' where PROPERTYID='%s' AND PLID='%s'"; + int update2 = DBSql.update(String.format(updateAttrsql, processNum, fileName, publishFileId)); + System.out.println("模型文件编号回填:" + update2 + "--->" + processNum); + // 更新流程绩效的编号----规则没看懂 + } + } + } + return "OK"; + } }