12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543 |
- package com.sinosoft.am.org.department.inner.busi;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import net.sf.json.JsonConfig;
- import org.apache.log4j.Logger;
- import org.jfree.util.Log;
- import com.formaction.Parameter;
- import com.formaction.vo.Msg;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
- import com.sinosoft.am.pinyin4j.Pinyin4jUtil;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- /**
- *
- * @author 云涛 此方法用于内部组织机构的增删改查所有方法
- *
- *
- */
- public class InDepartmentBusi {
-
- private Logger log = Logger.getLogger(this.getClass());
-
-
- /**
- * 加载给定机构的信息
- * @param id 传入的机构id
- * @param getPerson 是否带人
- * @param isFirstLoad 是否第一次加载
- * @return
- */
- public String getOrgInfoById(String id, boolean getPerson, boolean isFirstLoad,String deptLevel) {
- String result = new String();
- if (getPerson) {
- result = loadInDepartmentPerById(id, isFirstLoad,deptLevel);
- } else {
- result = loadInDepartmentById(id, isFirstLoad,deptLevel);
- }
- return result;
- }
-
- /**
- * 2016-11-06 唐群胜加 只显示应急机构
- * @param id
- * @param getPerson
- * @param isFirstLoad
- * @return
- */
- public String getOnlyOrgInfoById(String id, boolean getPerson, boolean isFirstLoad,String deptLevel) {
- String result = new String();
- // if (getPerson) {
- // result = loadInDepartmentPerById(id, isFirstLoad);
- // } else {
- result = onlyInDepartmentById(id, isFirstLoad,deptLevel);
- // }
- return result;
- }
- /**
- *
- * 根据传来的机构id加载下级节点信息加载人员的方法
- *
- * @param id
- * @param isFirstLoad
- * isFirstLoad= true 表示第一次加载(第一次调用该方法),那么就将他自己的节点信息和子节点信息加载出来
- * isFirstLoad= false 表示不是第一次调用该方法 就只加载当前节点的子节点信息
- * @return
- */
- public String loadInDepartmentPerById(String id, boolean isFirstLoad,String deptLevel) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
-
-
- json.append("{\"treeNodes\":[");
- if (isFirstLoad) {
- sql.append("--查询给定id及其一级子机构的信息 \n");
- sql.append("SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, \n");
- sql.append("DECODE((SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID),'0','0','1') AS 是否有子机构 \n");
- sql.append("FROM V_DEPARTMENT A WHERE PARENT_ID = '"
- + id + "' OR ORG_ID='" + id + "' AND IS_DEL='0'\n ");
- } else {
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
- sql.append("SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, \n");
- sql.append("DECODE((SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID),'0','0','1') AS 是否有子机构 \n");
- sql.append("FROM V_DEPARTMENT A WHERE PARENT_ID = '"
- + id + "' AND IS_DEL='0' \n");
- }
- // log.info(sql);
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99,
- sql.toString());
- // 显示人员
- json.append(getPersonById(id));
- int listLen = listRoot.size();
- for (int i = 0; i < listLen; i++) {
- String[] temp = listRoot.get(i);
- String orgId = temp[0];
- String orgName = getOrgAbbreviation(temp[0],deptLevel);//temp[1];
- String parentOrgId = temp[2];
- String orgLevel = temp[3];
- String isVirtual = temp[4];
- // 判定是否存在子节点
- boolean isHasChildOrg = !("0".equals(temp[5]));
- // 判定是否为第一次加载的id(用来展开初始化的节点)
- String isRootNode = id.equals(orgId) ? "true" : "false";
- // 判定是虚拟机构还是实体机构
- String icon = isVirtual == "1" ? "\"/nwyj/scripts/qui/libs/icons/home.gif\""
- : "\"/nwyj/scripts/qui/libs/icons/home.png\"";
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\""
- + parentOrgId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- // 是否展开
- json.append("\"open\":\"" + isRootNode + "\",");
- //设定区别机构人员的属性
- json.append("\"leafType\":\"org\",");
- if (isHasChildOrg) {
- json.append("\"isParent\": \"true\" ");
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
- json.append(", \"icon\":" + icon + "");
- // json.append(", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }
- // 去掉多余的","
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- ;
- json.append("]}");
- log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
-
- /**
- * 加载给定机构id的人员信息
- * @param deptId
- * @return
- */
- private String getPersonById(String deptId) {
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("SELECT A.USER_ID,A.REAL_NAME,A.ORG_ID,A.HR_CODE,A.GENDER,A.POSITION, A.MOBILE "
- + "FROM SYS_USER_INFO A ,SYS_DEPARTMENT D,SYS_DEPT_USER DU "
- + " WHERE A.USER_ID = DU.USER_ID AND D.DEPT_ID = DU.DEPT_ID AND D.DEPT_ID='"
- + deptId + "'");
- // log.info("人员sql================="+sql);
- try {
- ArrayList<String[]> list = persistence.getSearchResult(99, sql.toString());
- if (list.size() > 0) {
- for (int i = 0; i < list.size(); i++) {
- String[] temp = list.get(i);
- String id = temp[0];
- String name = temp[1];
- //String hr = temp[3];
- String gender = temp[4];
- String manDuty = temp[5];
- String manPhone = temp[6];
- json.append("{");
- json.append(" \"name\":\"" + name +"\",");
- json.append(" \"id\":\"" + id + "\",");
- json.append(" \"parentId\":\"" + deptId + "\",");
- json.append(" \"manDuty\":\"" + manDuty + "\",");
- json.append(" \"manPhone\":\"" + manPhone + "\",");
- json.append("\"leafType\":\"per\",");
- json.append("\"tagValue\":\"1\",");
- if ("男".equals(gender)) {
- json.append(" \"icon\":\"/nwyj/scripts/qui/libs/icons/user-black.png\"");
- } else if ("女".equals(gender)) {
- json.append(" \"icon\":\"/nwyj/scripts/qui/libs/icons/user-red-female.png\"");
- } else {
- json.append(" \"icon\":\"/nwyj/scripts/qui/libs/icons/user-black.png\"");
- }
- json.append("},");
- }
- }
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
-
- /**
- *
- * 根据传来的机构id加载下级节点信息(排序字段为sort_no)
- *
- * @param id
- * @param isFirstLoad
- * isFirstLoad= true 表示第一次加载(第一次调用该方法),那么就将他自己的节点信息加载出来
- * isFirstLoad= false 表示不是第一次调用该方法 就只加载当前节点的子节点信息
- * @return
- */
- public String loadInDepartmentById(String id, boolean isFirstLoad,String deptLevel) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- json.append("{\"treeNodes\":[");
- if (isFirstLoad) {
- sql.append("--查询给定id及其一级子机构的信息 \n");
- sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 ,CORP_ID,ORG_TYPE FROM V_DEPARTMENT A WHERE ( PARENT_ID = '"+id+"' OR ORG_ID IN (SELECT DEPT_ID FROM SYS_DEPARTMENT where dept_type='1' start with DEPT_ID = '"+id+"' connect by prior parent_id = dept_id ) OR (PARENT_ID IN (SELECT ORG_ID FROM V_DEPARTMENT where ORG_TYPE='1' and ORG_ID != '"+id+"' start with ORG_ID = '"+id+"' connect by prior parent_id = ORG_ID) and IS_VIRTUAL = '1')) AND IS_DEL='0' and ( ( (org_name like '%' or org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_name like '%电网有限责任公司' or org_name like '%输电%' or org_name like '%变电%' or org_name like '%抢修中心%' or org_name like '%调度%' or org_id='"+id+"' )and is_virtual='0' ) or is_virtual='1' ) AND ORG_LEVEL IS NOT NULL ORDER BY SORT_NO )");
- // sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 ,CORP_ID FROM V_DEPARTMENT A WHERE ( PARENT_ID = '"+id+"' OR ORG_ID = '"+id+"') AND IS_DEL='0' and ( ( (org_name like '%' or org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_name like '%电网有限责任公司' or org_name like '%输电%' or org_name like '%变电%' or org_name like '%抢修中心%' or org_name like '%调度%' or org_id='"+id+"' )and is_virtual='0' ) or is_virtual='1' ) AND ORG_LEVEL IS NOT NULL ORDER BY SORT_NO )");
- // sql.append("(SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL,A.SORT_NO, \n");
- // sql.append("DECODE((SELECT COUNT(1) FROM EMC_DEPARTMENT_IN B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL='0'),'0','0','1') AS 是否有子机构 \n");
- // sql.append("FROM EMC_DEPARTMENT_IN A WHERE (PARENT_ID = '"
- // + id + "' OR ORG_ID='" + id + "') AND IS_DEL='0' and ((org_name like '%供电局') or(org_name like '%供电分局') ) and is_virtual='0' ORDER BY SORT_NO\n)");
- } else {
-
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
- sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 ,CORP_ID,ORG_TYPE FROM V_DEPARTMENT A WHERE ( PARENT_ID = '"+id+"') AND IS_DEL='0' and ( ( (org_name like '%' or org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_name like '%电网有限责任公司' )and is_virtual='0' ) or is_virtual='1' ) AND ORG_LEVEL IS NOT NULL ORDER BY SORT_NO )");
- // sql.append("SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL,A.SORT_NO, \n");
- // sql.append("DECODE((SELECT COUNT(1) FROM EMC_DEPARTMENT_IN B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL='0'),'0','0','1') AS 是否有子机构 \n");
- // sql.append("FROM EMC_DEPARTMENT_IN A WHERE PARENT_ID = '"
- // + id + "' AND IS_DEL='0' and ((org_name like '%供电局') or(org_name like '%供电分局') ) ORDER BY SORT_NO \n");
- }
- // log.info(sql);
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99,
- sql.toString());
- int listLen = listRoot.size();
- for (int i = 0; i < listLen; i++) {
- String[] temp = listRoot.get(i);
- String orgId = temp[0];
- String orgName = getOrgAbbreviation(temp[0],deptLevel);
- String parentOrgId = temp[2];
- String orgLevel = temp[3];
- String isVirtual = temp[4];
- String sortNo = temp[5];
- // 判定是否存在子节点
- boolean isHasChildOrg = !("0".equals(temp[6]));
-
- String corpId = temp[7];
- String orgType = temp[8];//机构类型
- // 判定是否为第一次加载的id(用来展开初始化的节点)废弃 2017-09-20
- String isRootNode = id.equals(orgId) ? "true" : "false";
- // 判定是虚拟机构还是实体机构
- String icon = "1".equals(isVirtual) ? "\"/nwyj/scripts/qui/libs/icons/home.gif\""
- : "\"/nwyj/scripts/qui/libs/icons/home.png\"";
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\""
- + parentOrgId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加排序标识
- json.append("\"sortNo\":\""+sortNo+"\",");
- //添加单位ID
- json.append("\"corpId\":\""+corpId+"\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- json.append("\"orgtype\":\""+orgType+"\",");
- // 是否展开
- json.append("\"open\":\"" + (openoroff(id,orgId)?"true" : "false") + "\",");
- //设置标记字段值(用于额外的属性)
- json.append("\"tagValue\":\"1\",");
- if (isHasChildOrg) {
- json.append("\"isParent\": \"true\" ");
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
- json.append(", \"icon\":" + icon + "");
- // json.append(", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }
- // 去掉多余的","
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- ;
- json.append("]}");
- log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
- //判断是否要展开节点
- private boolean openoroff(String id,String orgid) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- try{
- String sql="select * from sys_department where dept_id in (select dept_id from sys_department where dept_type='1' start with DEPT_ID = '"+id+"' connect by prior parent_id = dept_id) and dept_id like '%"+orgid+"%' ";
- List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
- if(tempList!=null&&tempList.size()>0){
- return true;
- }else{
- return false;
- }
- }catch(Exception e){
- e.printStackTrace();
- return false;
- }
- }
-
- public String onlyInDepartmentById(String id, boolean isFirstLoad,String deptlevel) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- json.append("{\"treeNodes\":[");
- if (isFirstLoad) {
- sql.append("--查询给定id及其一级子机构的信息 \n");
- sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 ,CORP_ID FROM (select distinct * from V_DEPARTMENT where is_del = '0' start with fd_objectid in (select fd_objectid from EMC_DEPARTMENT_IN where is_del = '0') connect by prior parent_id = fd_objectid) A WHERE ( PARENT_ID = '"+id+"' OR ORG_ID ='"+id+"' ) AND IS_DEL='0' and ( ( (org_name like '%' or org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_name like '%电网有限责任公司' or org_name like '%输电%' or org_name like '%变电%' or org_name like '%抢修中心%' or org_name like '%调度%' or org_id='"+id+"' )and is_virtual='0' ) or is_virtual='1' ) ORDER BY SORT_NO )");
- } else {
-
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
- sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 ,CORP_ID FROM (select distinct * from V_DEPARTMENT where is_del = '0' start with fd_objectid in (select fd_objectid from EMC_DEPARTMENT_IN where is_del = '0') connect by prior parent_id = fd_objectid) A WHERE ( PARENT_ID = '"+id+"') AND IS_DEL='0' and ( ( (org_name like '%' or org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_name like '%电网有限责任公司' )and is_virtual='0' ) or is_virtual='1' ) ORDER BY SORT_NO )");
- }
- log.info(sql);
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99,
- sql.toString());
- int listLen = listRoot.size();
- log.info("listLen=========="+listLen);
- if(listLen==0 && isFirstLoad){
- String sql1 = "( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 ,CORP_ID FROM V_DEPARTMENT A WHERE ORG_ID ='"+id+"' AND IS_DEL='0' and ( ( (org_name like '%' or org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_name like '%电网有限责任公司' or org_name like '%输电%' or org_name like '%变电%' or org_name like '%抢修中心%' or org_name like '%调度%' or org_id='"+id+"' )and is_virtual='0' ) or is_virtual='1' ) ORDER BY SORT_NO )";
- listRoot = persistence.getSearchResult(99, sql1.toString());
- listLen = listRoot.size();
- log.info("listLen2=========="+listLen);
- }
- for (int i = 0; i < listLen; i++) {
- String[] temp = listRoot.get(i);
- String orgId = temp[0];
- String orgName = getOrgAbbreviation(temp[0],deptlevel);//temp[1];
- String parentOrgId = temp[2];
- String orgLevel = temp[3];
- String isVirtual = temp[4];
- String sortNo = temp[5];
- // 判定是否存在子节点
- boolean isHasChildOrg = !("0".equals(temp[6]));
-
- String corpId = temp[7];
- // 判定是否为第一次加载的id(用来展开初始化的节点)
- String isRootNode = id.equals(orgId) ? "true" : "false";
- // 判定是虚拟机构还是实体机构
- String icon = "1".equals(isVirtual) ? "\"/nwyj/scripts/qui/libs/icons/home.gif\""
- : "\"/nwyj/scripts/qui/libs/icons/home.png\"";
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\""
- + parentOrgId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加排序标识
- json.append("\"sortNo\":\""+sortNo+"\",");
- //添加单位ID
- json.append("\"corpId\":\""+corpId+"\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- // 是否展开
- json.append("\"open\":\"" + isRootNode + "\",");
- //设置标记字段值(用于额外的属性)
- json.append("\"tagValue\":\"1\",");
- if (isHasChildOrg) {
- json.append("\"isParent\": \"true\" ");
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
- json.append(", \"icon\":" + icon + "");
- // json.append(", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }
- // 去掉多余的","
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- ;
- json.append("]}");
- log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
-
-
-
- /**
- *根据id获得机构信息以 treeNode 的形式返回(用于新增修改后返回json)
- * @param id
- * @return
- */
-
- public String getOrgInfoTree(String id ){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- sql.append("SELECT ORG_ID,ORG_NAME,PARENT_ID,ORG_LEVEL,IS_VIRTUAL,SORT_NO,CORP_ID,");
- sql.append("DECODE((SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID),'0','0','1') AS 是否有子机构 ");
- sql.append("FROM V_DEPARTMENT A WHERE ORG_ID = '"+id+"' AND IS_DEL ='0'");
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99,
- sql.toString());
- String[] temp = listRoot.get(0);
- String orgId = temp[0];
- String orgName = temp[1];
- String parentOrgId = temp[2];
- String orgLevel = temp[3];
- String isVirtual = temp[4];
- String sortNo = temp[5];
- String corpId = temp[6];
- // 判定是否存在子节点
- boolean isHasChildOrg = !("0".equals(temp[7]));
-
- // 判定是虚拟机构还是实体机构
- String icon = "1".equals(isVirtual) ? "\"/nwyj/scripts/qui/libs/icons/home.gif\""
- : "\"/nwyj/scripts/qui/libs/icons/home.png\"";
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\""
- + parentOrgId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加排序标识
- json.append("\"sortNo\":\""+sortNo+"\",");
- //添加corpId
- json.append("\"corpId\":\""+corpId+"\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- if (isHasChildOrg) {
- json.append("\"isParent\": \"true\" ");
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
- json.append(", \"icon\":" + icon + "");
- // json.append(", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("}");
-
-
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
-
- return json.toString();
- }
- /**
- * 根据id查询机构的信息 包括机构所有字段的信息
- * @return
- */
- public String queryOrgInfoById(String id){
-
- // SysModel sysmodel = ModelFactory.getSysmodel();
- // SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer sql2 = new StringBuffer();
- StringBuffer json = new StringBuffer();
- sql.append("SELECT FD_OBJECTID,ORG_NAME,ORG_ID,PARENT_ID,ORG_TYPE,ORG_PROP,OFFICE_TYPE,FORMATION_PEOPLE,");
- sql.append("HAVE_PEOPLE,ORG_ADDRESS,DUTY_TEL,DUTY_FAX,DUTY_EMAIL,EMERGENCY_TEL,EMERGENCY_FAX,EMERGENCY_EMAIL,");
- sql.append("ENTRY_MAN_ID,SORT_NO,IS_VIRTUAL,PATH_ID,PATH_NAME,PINYIN,JIANPIN,ORG_LEVEL,IS_DEL,UPDATEDATE,");
- sql.append("SHORT_NAME,UNICODE,HR_MRID,CORP_ID,CORP_NAME, ");
- //orgTypeshow
- sql.append("(SELECT FD_DESCRIPTION FROM BM_MAPVALUECANST WHERE FD_CODE =ORG_TYPE AND FD_TYPE IN ('BM_ENTITY_ORG_TYPE','BM_VIRTUAL_ORG_TYPE')) ORG_TYPE_SHOW ,");
- //orgPropshow
- sql.append("(SELECT FD_DESCRIPTION FROM BM_MAPVALUECANST WHERE FD_CODE =ORG_PROP AND FD_TYPE IN ('BM_ORG_PROP')) ORG_PROP_SHOW ,");
- //officeTypeshow
- sql.append("(SELECT FD_DESCRIPTION FROM BM_MAPVALUECANST WHERE FD_CODE =OFFICE_TYPE AND FD_TYPE IN ('BM_ORG_OFFICE_TYPE')) ORG_OFFICE_TYPE ,ENTRY_MAN_NAME ");
- sql.append("FROM V_DEPARTMENT WHERE FD_OBJECTID = ? AND IS_DEL =? ");
- log.info(sql);
-
- sql2.append("select sum(case EMC_ROLE when '1' then 1 else 0 end) as zzh, ");
- sql2.append("sum(case EMC_ROLE when '2' then 1 else 0 end) as fzzh, ");
- sql2.append("sum(case EMC_ROLE when '3' then 1 else 0 end) as zr, ");
- sql2.append("sum(case EMC_ROLE when '4' then 1 else 0 end) as fzr, ");
- sql2.append("sum(case when EMC_ROLE='5' or EMC_ROLE is null then 1 else 0 end) as cy ");
- sql2.append("from EMC_AM_ORG_INLINK where IS_DEL='0' AND VIRTUAL_ORG_ID=? AND INLINK_NAME IS NOT NULL ");
- log.info(sql2);
-
- Connection conn = null;
- PreparedStatement stat1 = null;
- ResultSet rs = null;
- DbConnection db = new DbConnection();
-
- try {
-
- /* conn = db.getConnection();
- stat1 = conn.prepareStatement(sql.toString());
- stat1.setString(1, id);
- stat1.setString(2, "0");
- rs = stat1.executeQuery();*/
- List<String[]> li = new ORGTemplate().getSearchResult(sql.toString(), id,"0");
- List<String[]> li2 = new ORGTemplate().getSearchResult(sql2.toString(), id);
- /* ArrayList<String[]> listRoot = persistence.getSearchResult(99,
- sql.toString());*/
- String[] temp = li.get(0);
- String[] temp2 = li2.get(0);
-
- String fd_objectid = returnForDMNull(temp[0]);
- String orgName = returnForDMNull(temp[1]);
- String orgId = returnForDMNull(temp[2]);
- String parentId = returnForDMNull(temp[3]);
- String orgType = returnForDMNull(temp[4]);
- String orgProp = returnForDMNull(temp[5]);
- String officeType = returnForDMNull(temp[6]);
- String formationPeople = returnForDMNull(temp[7]);
- String havePeople = returnForDMNull(temp[8]);
- String orgAddress = returnForDMNull(temp[9]);
- String dutyTel = returnForDMNull(temp[10]);
- String dutyFax = returnForDMNull(temp[11]);
- String dutyEmail = returnForDMNull(temp[12]);
- String EmergencyTel = returnForDMNull(temp[13]);
- String EmergencyFax = returnForDMNull(temp[14]);
- String EmergencyEmail = returnForDMNull(temp[15]);
- String entryManId = returnForDMNull(temp[16]);
- String sortNo = returnForDMNull(temp[17]);
- String isVirtual = returnForDMNull(temp[18]);
- String pathId = returnForDMNull(temp[19]);
- String pathName = returnForDMNull(temp[20]);
- String pinyin = returnForDMNull(temp[21]);
- String jianpin = returnForDMNull(temp[22]);
- String orgLevel = returnForDMNull(temp[23]);
- String isDel = returnForDMNull(temp[24]);
- String updateDate = returnForDMNull(temp[25]);
- String shortName = returnForDMNull(temp[26]);
- String unicode = returnForDMNull(temp[27]);
- String hrMRID = returnForDMNull(temp[28]);
- String corpId = returnForDMNull(temp[29]);
- String corpName = returnForDMNull(temp[30]);
- String orgTypeShow = returnForDMNull(temp[31]);
- String orgPropShow = returnForDMNull(temp[32]);
- String officeTypeShow = returnForDMNull(temp[33]);
- String entryManName = returnForDMNull(temp[34]);
-
- String ZZH = returnForDMNull(temp2[0]);
- String FZZH = returnForDMNull(temp2[1]);
- String ZR = returnForDMNull(temp2[2]);
- String FZR = returnForDMNull(temp2[3]);
- String CY = returnForDMNull(temp2[4]);
-
- json.append("{");
- json.append("\"FD_OBJECTID\":\""+fd_objectid+"\",");
- json.append("\"ORG_NAME\":\""+orgName+"\",");
- json.append("\"ORG_ID\":\""+orgId+"\",");
- json.append("\"PARENT_ID\":\""+parentId+"\",");
- json.append("\"ORG_TYPE\":\""+orgType+"\",");
- json.append("\"ORG_PROP\":\""+orgProp+"\",");
- json.append("\"OFFICE_TYPE\":\""+officeType+"\",");
- json.append("\"FORMATION_PEOPLE\":\""+formationPeople+"\",");
- json.append("\"HAVE_PEOPLE\":\""+havePeople+"\",");
- json.append("\"ORG_ADDRESS\":\""+orgAddress+"\",");
- json.append("\"DUTY_TEL\":\""+dutyTel+"\",");
- json.append("\"DUTY_FAX\":\""+dutyFax+"\",");
- json.append("\"DUTY_EMAIL\":\""+dutyEmail+"\",");
- json.append("\"EMERGENCY_TEL\":\""+EmergencyTel+"\",");
- json.append("\"EMERGENCY_FAX\":\""+EmergencyFax+"\",");
- json.append("\"EMERGENCY_EMAIL\":\""+EmergencyEmail+"\",");
- json.append("\"ENTRY_MAN_ID\":\""+entryManId+"\",");
- json.append("\"ENTRY_MAN_NAME\":\""+entryManName+"\",");
- json.append("\"SORT_NO\":\""+sortNo+"\",");
- json.append("\"IS_VIRTUAL\":\""+isVirtual+"\",");
- json.append("\"PATH_ID\":\""+pathId+"\",");
- json.append("\"PATH_NAME\":\""+pathName+"\",");
- json.append("\"PINYIN\":\""+pinyin+"\",");
- json.append("\"JIANPIN\":\""+jianpin+"\",");
- json.append("\"ORG_LEVEL\":\""+orgLevel+"\",");
- json.append("\"IS_DEL\":\""+isDel+"\",");
- json.append("\"UPDATEDATE\":\""+updateDate+"\",");
- json.append("\"SHORT_NAME\":\""+shortName+"\",");
- json.append("\"UNICODE\":\""+unicode+"\",");
- json.append("\"HR_MRID\":\""+hrMRID+"\",");
- json.append("\"CORP_ID\":\""+corpId+"\",");
- json.append("\"ORG_TYPE_SHOW\":\""+orgTypeShow+"\",");
- json.append("\"ORG_PROP_SHOW\":\""+orgPropShow+"\",");
- json.append("\"OFFICE_TYPE_SHOW\":\""+officeTypeShow+"\",");
- json.append("\"CORP_NAME\":\""+corpName+"\",");
- json.append("\"ZONGZHIHUI\":\""+((ZZH==null||ZZH=="")?"0":ZZH)+"\",");
- json.append("\"FUZONGZHIHUI\":\""+((FZZH==null||FZZH=="")?"0":FZZH)+"\",");
- json.append("\"ZHUREN\":\""+((ZR==null||ZR=="")?"0":ZR)+"\",");
- json.append("\"FUZHUREN\":\""+((FZR==null||FZR=="")?"0":FZR)+"\",");
- json.append("\"CHENGYUAN\":\""+((CY==null||CY=="")?"0":CY)+"\"");
- json.append("}");
-
-
- }catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- db.close(rs);
- db.close(stat1);
- db.close(conn);
- }
-
- return json.toString();
- }
-
- public String getDeptById(String id){
-
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- sql.append("select DECODE((select count(1) from sys_department A WHERE A.DEPT_ID = B.DEPT_ID AND A.DEPT_TYPE = '1'), '0',");
- sql.append("(SELECT SUBSTR((select DEPT_PATH_NAME from sys_department D where D.dept_id=B.dept_id),(select len(DEPT_PATH_NAME)");
- sql.append("from sys_department E where E.dept_id in (select G.CORP_ID from sys_department G where G.dept_id=B.dept_id))+2,");
- sql.append("(select len(DEPT_PATH_NAME) from sys_department F where F.dept_id=B.dept_id)) FROM DUAL),");
- sql.append("(select C.PROVINCE_NAME_TWO from DEPARTMENT_ABBR C WHERE C.FD_OBJECTID = B.DEPT_ID)) DEPT_NAME");
- sql.append(" from sys_department B where B.dept_id=?");
- log.info(sql);
-
-
- Connection conn = null;
- PreparedStatement stat1 = null;
- ResultSet rs = null;
- DbConnection db = new DbConnection();
-
- try {
-
- List<String[]> li = new ORGTemplate().getSearchResult(sql.toString(), id);
- String dept_name = "";
- if(li.size()>0){
- String[] temp = li.get(0);
- dept_name =returnForDMNull(temp[0]);
- }
- json.append("{");
- json.append("\"DEPT_NAME\":\""+dept_name+"\"");
- json.append("}");
-
-
- }catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- db.close(rs);
- db.close(stat1);
- db.close(conn);
- }
-
- return json.toString();
- }
-
- /**
- * 调用此方法将拖动的节点的排序字段变更为目的节点的sort_no-0.00001
- *
- * @param dragNodeId
- * 拖动的节点Id
- * @param destNode
- * 拖动目的地的的排序值
- * @return
- */
- public String updateSortNo(String dragNodeId, String destNode) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- String result = "";
- sql.append("--更新拖动节点的排序号 \n");
- sql.append("UPDATE EMC_DEPARTMENT_IN SET SORT_NO ='"
- + (Float.parseFloat(destNode) + 0.123401) + "' WHERE ORG_ID ='"
- + dragNodeId + "'");
- try {
- result = String.valueOf(persistence.executeUpdateSQL(99,
- sql.toString()));
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return result;
- }
- /**
- * 通过传入的模糊名称和 根节点的 id 进行搜索
- * @param name 模糊名称
- * @param rootId 根节点的id
- * @return
- */
- public String getOrgInfoByName(String name, String rootId) {
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("WITH A AS(SELECT * FROM V_DEPARTMENT B WHERE INSTR(PATH_ID,'_"
- + rootId + "_')>0 AND B.IS_DEL ='0' ) \n");
- sql.append("SELECT TOP 0 , 30 C.ORG_ID,C.ORG_NAME,C.PATH_NAME \n");
- sql.append("FROM A C WHERE (C.ORG_NAME LIKE '%" + name + "%' \n");
- sql.append("OR C.PINYIN LIKE '%" + name + "%' \n");
- sql.append("OR C.JIANPIN LIKE '%" + name + "%') \n");
- sql.append("ORDER BY C.ORG_LEVEL ASC \n");
-
-
- // log.info(sql);
- try {
- ArrayList<String[]> listOrgInfo = persistence.getSearchResult(99,
- sql.toString());
- json.append("[");
- for (int i = 0; i < listOrgInfo.size(); i++) {
- String[] temp = listOrgInfo.get(i);
- String orgId = temp[0];
- String orgName = temp[1];
- String orgPath = temp[2];
- String orgSimplePath = orgPath.length() > 16 ? (orgPath
- .substring(0, 17) + "...") : orgPath;
- json.append("{");
- json.append("\"id\":\"" + orgId + "\", ");
- json.append("\"name\":\"" + orgName + "\", ");
- json.append("\"spath\":\"" + orgSimplePath + "\", ");
- json.append("\"path\":\"" + orgPath + "\" ");
- json.append("},");
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- ;
- json.append("]");
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
- /**
- * 查询出给定orgId的所有上级ids 已数组形式返回
- * @param orgId
- * @return
- */
- public String getHigherIds(String orgId){
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- json.append("[");
- sql.append("SELECT WM_CONCAT(ORG_ID) FROM V_DEPARTMENT START WITH ORG_ID = '"+orgId+"' CONNECT BY PRIOR PARENT_ID = ORG_ID ");
- try {
- ArrayList<String[]> listOrgInfo= persistence.getSearchResult(99, sql.toString());
- for (int i = 0; i < listOrgInfo.size(); i++) {
- String[] temp = listOrgInfo.get(i);
- json.append("\""+temp[0].replace(",","\",\"")+"\"");
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- json.append("]");
- return json.toString();
-
- }
-
- /**
- * 显示录入人的信息 :姓名,电话号码, 4a的机构信息 ,岗位, 单位
- * @param entryManId 录入人的识别id
- * @return
- */
- public String queryEntryManInfo(String entryManId){
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("--查询给定id录入人信息 \n");
- sql.append("SELECT U.USER_ID,U.REAL_NAME,U.MOBILE,D.DEPT_NAME,U.POSITION,D.CORP_NAME FROM SYS_USER_INFO U ,SYS_DEPT_USER DU, SYS_DEPARTMENT D \n");
- sql.append("WHERE U.USER_ID = DU.USER_ID AND DU.DEPT_ID = D.DEPT_ID AND U.USER_ID='"+entryManId+"' AND U.IS_DEL ='0' AND D.IS_DEL='0' AND DU.IS_DEL='0' \n");
- json.append("{\"entryInfo\":");
- try {
- ArrayList<String[]> listManInfo = persistence.getSearchResult(99, sql.toString());
-
- for (int i = 0; i < listManInfo.size(); i++) {
- String[] temp = listManInfo.get(i);
- String userId = temp[0];
- String real_name = temp[1];
- String mobile = temp[2];
- String deptName = temp[3];
- String job = temp[4];
- String corpName = temp[5];
- json.append(" \"userId\":\"" + userId + "\", \"real_name\":\"" + real_name
- + "\", \"mobile\": \"" + mobile + "\",\"deptName\":\"" + deptName + "\",");
- json.append("\"job\":\""+job+"\",\"corpName\":\""+corpName+"\"");
- }
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- json.append("");
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- };
- json.append("}");
- return json.toString();
- }
-
- public String updateEntryManTel(String userId,String tel){
- String result = "";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- //正则验证
- if(!tel.matches("^[1]([3][0-9]{1}|59|58|88|89)[0-9]{8}$")){
-
- return result = "-2";
-
- }
- sql.append("UPDATE SYS_USER_INFO SET MOBILE ='"+tel+"' WHERE USER_ID =''"+userId+"' AND IS_DEL='0'");
-
- try {
- result =String.valueOf(persistence.executeUpdateSQL(99, sql.toString()));
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
-
-
-
-
- }
- /**
- * 根据传来的人员识别id 查询出 人员的信息 存入EMC_AM_DEPARTMENT_IN_LINKMAN ,其中 link_man_num 为当前该机构下的联系人数量+1
- * @param manID
- * @return
- */
- public String addMoreLinkMan(String manID){
- String result = "";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("--插入联系人 \n");
- sql.append("INSERT INTO EMC_AM_DEPARTMENT_IN_LINKMAN (SELECT SYS_GUID(), \n");
- sql.append("(SELECT NVL(MAX(A.LINK_MAN_NUM),0)+1 FROM V_DEPARTMENT_LINKMAN A WHERE A.LINK_ORG_ID= parent_org_id AND A.IS_DEL='0'), \n");
- sql.append("VIRTUAL_ORG_ID,INLINK_INDEX,INLINK_NAME,PHONE,'0',getDate() from emc_am_org_inlink where fd_objectid ='"+manID+"')");
- try {
- result =String.valueOf(persistence.executeUpdateSQL(99, sql.toString()));
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return result;
- }
-
- public String queryOrg_LinkManInfo(String orgId){
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- ArrayList<String[]> listManInfo;
- try {
- listManInfo = persistence.getSearchResult(99, sql.toString());
- for (int i = 0; i < listManInfo.size(); i++) {
- String[] temp = listManInfo.get(i);
- String userId = temp[0];
- String real_name = temp[1];
- String mobile = temp[2];
- String deptName = temp[3];
- String job = temp[4];
- String corpName = temp[5];
- json.append(" \"userId\":\"" + userId + "\", \"real_name\":\"" + real_name
- + "\", \"mobile\": \"" + mobile + "\",\"deptName\":\"" + deptName + "\",");
- json.append("\"job\":\""+job+"\",\"corpName\":\""+corpName+"\"");
- }
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
-
-
-
- return null;
-
- }
- /**
- * 根据传来的机构id查询出 该机构的上级单位id,如果他本身是corp 那么他 返回他自己的id 如果是部门dept 那找到离他最近的corp
- * 思路:1.查询出该机构的所有上级机构id(倒序排序如dept,dept,..,corp,corp,..),2.过滤掉dept 3.取出第一个结果就是离他最近的corp
- * @param id
- * @return
- */
- public String getCorpId(String id){
- String result = "";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("SELECT DEPT_ID FROM SYS_DEPARTMENT WHERE DEPT_TYPE='CORP' AND ROWNUM = 1 \n");
- sql.append(" START WITH DEPT_ID ='"+id+"' CONNECT BY PRIOR PARENT_ID = DEPT_ID \n");
- try {
- ArrayList<String[]> corpId = persistence.getSearchResult(99, sql.toString());
- if(corpId.size()>0){
-
- result = corpId.get(0)[0];
- }
-
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return result;
- }
- /**
- * 思路同 getCorpId(String id)这个方法,
- */
- public void refreshAllCorpId(){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("MERGE INTO SYS_DEPARTMENT_1111_BACKUP P1 \n");
- sql.append("USING (SELECT B.ORG_NAME,B.ORG_ID,B.FD_OBJECTID,(SELECT A.ORG_ID FROM SYS_DEPARTMENT_1111_BACKUP A WHERE A.ORG_TYPE='CORP' AND ROWNUM =1 \n");
- sql.append("START WITH A.ORG_ID = B.ORG_ID \n");
- sql.append("CONNECT BY PRIOR A.PARENT_ORG_ID= A.ORG_ID) PCORPID FROM SYS_DEPARTMENT_1111_BACKUP B) P2 \n");
- sql.append("ON P1.FD_OBJECTID=P2.FD_OBJECTID \n");
- sql.append("WHEN MATCHED THEN \n");
- sql.append("UPDATE SET P1.CORP_ID = P2.PCORPID, \n");
- sql.append("P1.CORP_NAME = P2.ORG_NAME \n");
- try {
- persistence.executeUpdateSQL(99, sql.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
-
- }
-
- /**
- * 新增虚拟机构信息 fd_objectid = org_id
- * @param params(map集合)
- * @return 新插入的主键id
- */
- // public String createVirtualOrg(Map<String,String> params){
- public String createVirtualOrg(String fd_objectid,String orgName,String parentId,String shortName,String orgType,String orgProp,String officeType,String formation_people,String
- havePeople,String orgAddress,String dutyTel,String dutyFax,String dutyEmail,String entryManId,String emergencyTel,String emergencyFax,String emergencyEmail,String entryManNAME){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- int sqlExecute = 0;
- String result = "";
- // String fd_objectid = params.get("FD_OBJECTID");
- fd_objectid = UUID.randomUUID().toString().replace("-", "");
- // String orgName = params.get("ORG_NAME");
- //String orgId = params.get("ORG_ID");
- // String parentId = params.get("PARENT_ID");
- //如果上级机构id为空 那么返回
- if("".equals(parentId)){
-
- return result;
-
- }
- // String shortName = params.get("SHORT_NAME");
- // String orgType = params.get("ORG_TYPE");
- // String orgProp = params.get("ORG_PROP");
- // String officeType = params.get("OFFICE_TYPE");
- // String formation_people = params.get("FORMATION_PEOPLE");
- // String havePeople = params.get("HAVE_PEOPLE");
- // String orgAddress = params.get("ORG_ADDRESS");
- // String dutyTel = params.get("DUTY_TEL");
- // String dutyFax = params.get("DUTY_FAX");
- // String dutyEmail = params.get("DUTY_EMAIL");
- // String entryManId = params.get("ENTRY_MAN_ID");
- // String emergencyTel = params.get("EMERGENCY_TEL");
- // String emergencyFax = params.get("EMERGENCY_FAX");
- // String emergencyEmail = params.get("EMERGENCY_EMAIL");
- //String pathId = params.get("PATH_ID");
- //String pathName = params.get("PATH_NAME");
- String pinyin = Pinyin4jUtil.getPinYin(orgName);
- String jianpin = Pinyin4jUtil.getPinYinHeadChar(orgName);
- //String sortNo = params.get("SORT_NO");
-
- StringBuffer sqlInsert = new StringBuffer();
- sqlInsert.append("INSERT INTO EMC_DEPARTMENT_IN (FD_OBJECTID,ENTRY_MAN_ID,ORG_NAME,SHORT_NAME,ORG_ID,PARENT_ID,ORG_TYPE,ORG_PROP,OFFICE_TYPE,FORMATION_PEOPLE,HAVE_PEOPLE, \n");
- sqlInsert.append("ORG_ADDRESS,DUTY_TEL,DUTY_FAX,DUTY_EMAIL,EMERGENCY_TEL,EMERGENCY_FAX,EMERGENCY_EMAIL,SORT_NO,IS_VIRTUAL,PATH_ID,PATH_NAME,PINYIN,JIANPIN,ORG_LEVEL,CORP_ID,CORP_NAME,IS_DEL,UPDATEDATE,ENTRY_MAN_NAME) \n");
- sqlInsert.append("VALUES('"+returnForDMNull(fd_objectid)+"','"+returnForDMNull(entryManId)+"','"+returnForDMNull(orgName)
- +"','"+returnForDMNull(shortName)+"','"+returnForDMNull(fd_objectid)+"','"+returnForDMNull(parentId)+"','"+returnForDMNull(orgType)
- +"','"+returnForDMNull(orgProp)+"','"+returnForDMNull(officeType)+"','"+returnForDMNull(formation_people)+"',");
- sqlInsert.append("'"+returnForDMNull(havePeople)+"','"+returnForDMNull(orgAddress)+"','"+returnForDMNull(dutyTel)+"','"+returnForDMNull(dutyFax)+"','"+returnForDMNull(dutyEmail)
- +"','"+returnForDMNull(emergencyTel)+"','"+returnForDMNull(emergencyFax)+"','"+returnForDMNull(emergencyEmail)+"',");
- //插入排序号 数据库序列,每查询一次自动增加"1",
- //sqlInsert.append(" (SELECT DEPARTMENT_SORT_SEQUENCE.NEXTVAL FROM DUAL),");
- //2016-06-07更改为固定值10
- sqlInsert.append("'10',");
- sqlInsert.append("'1',");
- //PATH_ID 的插入方法
- sqlInsert.append("(SELECT PATH_ID FROM V_DEPARTMENT WHERE ORG_ID ='"+parentId+"')||"+"'/_"+returnForDMNull(fd_objectid)+"_'");
- //PATH_NAME 的插入方法
- sqlInsert.append(",(SELECT PATH_NAME FROM V_DEPARTMENT WHERE ORG_ID ='"+parentId+"')||"+"'/"+returnForDMNull(orgName)+"'");
- sqlInsert.append(",'"+returnForDMNull(pinyin)+"','"+returnForDMNull(jianpin)+"'");
- //org_level 的插入方法
- sqlInsert.append(",NVL((SELECT ORG_LEVEL FROM V_DEPARTMENT WHERE ORG_ID ='"+parentId+"'),0)+1");
- //插入公司id 的方法(因为是新增的虚拟机构 写在一条sql里面 所以fd_id 不存在 所以用parent_id 作为起始节点)
- sqlInsert.append(",(SELECT ORG_ID FROM V_DEPARTMENT WHERE ROWNUM = 1 AND ORG_TYPE='1' START WITH ORG_ID ='"+parentId+"' CONNECT BY PRIOR PARENT_ID = ORG_ID )");
- //插入公司名称的方法
- sqlInsert.append(",(SELECT ORG_NAME FROM V_DEPARTMENT WHERE ROWNUM = 1 AND ORG_TYPE='1' START WITH ORG_ID ='"+parentId+"' CONNECT BY PRIOR PARENT_ID = ORG_ID)");
- sqlInsert.append(",'0',getDate(),'"+returnForDMNull(entryManNAME)+"')");
- log.info("sqlInsert=========="+sqlInsert);
- try {
- sqlExecute = persistence.executeUpdateSQL(99, sqlInsert.toString());
- //判定是否插入数据成功
- if(sqlExecute==1){
-
- result = getOrgInfoTree(fd_objectid);
-
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
- }
- /**
- * 更新 EMC_DEPARTMENT_IN 中的 pathId 字段 规则 /_id_ PATH_NAME 规则 /name/name/name。。。。 org_level 设置 南方电网为1
- * @return
- */
- public String refreshOrgPathIdNameLevel(){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
-
- return null;
- }
- /**
- * 更新部门表
- * @param params
- * @return 更新成功返回主键id
- */
- public String updateVirtualOrg(Map<String,String> params){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- int sqlExecute = 0;
- String result = "";
- StringBuffer json = new StringBuffer();
- String fd_objectid = params.get("FD_OBJECTID");
- String orgName = params.get("ORG_NAME");
- String orgLevel = params.get("ORG_LEVEL");
- String sortNo = params.get("SORT_NO");
- String isVirtual = params.get("IS_VIRTUAL");
- //String orgId = params.get("ORG_ID");
- String parentId = params.get("PARENT_ID");
- //如果上级机构id为空 那么返回
- /*if("".equals(parentId)){
-
- return result;
-
- }*/
- String orgType = params.get("ORG_TYPE");
- String orgProp = params.get("ORG_PROP");
- String officeType = params.get("OFFICE_TYPE");
- //String formation_people = params.get("FORMATION_PEOPLE");
- //String havePeople = params.get("HAVE_PEOPLE");
- String orgAddress = params.get("ORG_ADDRESS");
- String dutyTel = params.get("DUTY_TEL");
- String dutyFax = params.get("DUTY_FAX");
- String dutyEmail = params.get("DUTY_EMAIL");
- String entryManId = params.get("ENTRY_MAN_ID");
- String entryManName = params.get("ENTRY_MAN_NAME");
- String shortName = params.get("SHORT_NAME");
-
-
- String emergencyTel = params.get("EMERGENCY_TEL");
- String emergencyFax = params.get("EMERGENCY_FAX");
- String emergencyEmail = params.get("EMERGENCY_EMAIL");
-
- //String pathId = params.get("PATH_ID");
- //String pathName = params.get("PATH_NAME");
- String pinyin = Pinyin4jUtil.getPinYin(orgName);
- String jianpin = Pinyin4jUtil.getPinYinHeadChar(orgName);
-
- StringBuffer sqlUpdate = new StringBuffer();
-
- sqlUpdate.append("UPDATE EMC_DEPARTMENT_IN SET ORG_NAME =NVL("+returnForDM(orgName)+",ORG_NAME) ,SHORT_NAME = NVL("+returnForDM(shortName)+",SHORT_NAME),OFFICE_TYPE = NVL("+returnForDM(officeType)+",OFFICE_TYPE),ORG_TYPE=NVL("+returnForDM(orgType)+",ORG_TYPE),");
- sqlUpdate.append("ORG_PROP=NVL("+returnForDM(orgProp)+",ORG_PROP),ORG_ADDRESS= NVL("+returnForDM(orgAddress)+",ORG_ADDRESS),DUTY_TEL=NVL("+returnForDM(dutyTel)+",DUTY_TEL),DUTY_FAX=NVL("+returnForDM(dutyFax)+",DUTY_FAX),");
- sqlUpdate.append("EMERGENCY_TEL=NVL("+returnForDM(emergencyTel)+",EMERGENCY_TEL),EMERGENCY_FAX=NVL("+returnForDM(emergencyFax)+",EMERGENCY_FAX),EMERGENCY_EMAIL=NVL("+returnForDM(emergencyEmail)
- +",EMERGENCY_EMAIL),ENTRY_MAN_ID=NVL("+returnForDM(entryManId)+",ENTRY_MAN_ID),ENTRY_MAN_NAME=NVL("+returnForDM(entryManName)+",ENTRY_MAN_NAME),");
- sqlUpdate.append("DUTY_EMAIL= NVL("+returnForDM(dutyEmail)+",DUTY_EMAIL),PINYIN = NVL("+returnForDM(pinyin)+",PINYIN),JIANPIN= NVL("+returnForDM(jianpin)+",JIANPIN),");
- //更新PATH_NAME
- sqlUpdate.append("PATH_NAME =REPLACE(PATH_NAME,ORG_NAME,NVL("+returnForDM(orgName)+",ORG_NAME)),");
- sqlUpdate.append("UPDATEDATE = getDate() WHERE FD_OBJECTID='"+fd_objectid+"' AND IS_DEL='0'");
- log.info(sqlUpdate);
- try {
- sqlExecute = persistence.executeUpdateSQL(99, sqlUpdate.toString());
- //判定是否更改数据成功
- if(sqlExecute==1){
-
- json.append("{");
- json.append(" \"id\":\"" + fd_objectid + "\", \"parentId\":\""
- + parentId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加排序标识
- json.append("\"sortNo\":\""+sortNo+"\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- json.append("\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\"");
- json.append("}");
- result = json.toString();
-
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
- }
- //用于返回数据库(使用nvl时 判定传入参数 为null 就返回 null,不为null 需在数据库显示'str' 故加上单引号)
- public String returnForDM(String str){
-
- return str== null ? null :"'"+str+"'";
-
- }
- //用于返回数据库格式(当数据为null 时 保证存入的不会是'null' 存入"")
- public String returnForDMNull(String str){
-
-
- return str == null ? "" : str ;
- }
-
- /**
- * 删除机构 将is_del 设置为 '1'
- * @param orgId
- * @return
- */
- public String deleteVirtualOrg(String orgId){
-
-
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- int sqlExecute = 0;
- String result = "";
- //判定orgId是否为空
- if("".equals(orgId)){
- return result;
-
- }
- StringBuffer sqlDelete = new StringBuffer();
- sqlDelete.append("UPDATE EMC_DEPARTMENT_IN B SET B.IS_DEL='1' WHERE B.FD_OBJECTID='"
- +orgId+"' AND (SELECT COUNT(1) FROM V_DEPARTMENT A WHERE A.PARENT_ID = '"+orgId+"' AND A.IS_DEL='0' )<1 ");
- sqlDelete.append(" AND (SELECT COUNT(1) FROM EMC_AM_ORG_INLINK A WHERE A.VIRTUAL_ORG_ID = '"+orgId+"' AND A.IS_DEL='0' )<1 ");
- log.info(sqlDelete);
- try {
- sqlExecute = persistence.executeUpdateSQL(99, sqlDelete.toString());
- //判定是否删除数据成功
- if(sqlExecute==1){
-
- result = "\""+orgId+"\"";
-
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
-
-
- }
- /**
- *
- * 删除第*联系人
- * @param fdId EMC_AM_DEPARTMENT_IN_LINKMAN中的主键id
- * @return 删除成功返回 fdId
- */
- public String deleteMoreLinkMan(String fdId){
-
-
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- int sqlExecute = 0;
- String result = "";
- StringBuffer sqlDelete = new StringBuffer();
- sqlDelete.append("UPDATE EMC_AM_DEPARTMENT_IN_LINKMAN SET IS_DEL='1' WHERE FD_OBJECTID='"+fdId+"'");
- try {
- sqlExecute = persistence.executeUpdateSQL(99, sqlDelete.toString());
- //判定是否删除数据成功
- if(sqlExecute==1){
-
- result = fdId;
-
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
-
- }
- /**
- * 异步加载还未加载出来的机构信息
- * @param id
- * @param level
- * @param type
- * @return
- */
- public String newOrgInfoById(String id, String level, String type) {
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
-
- sql.append("WITH TA AS(SELECT * FROM V_DEPARTMENT WHERE IS_DEL='0') \n");
-
- sql.append("SELECT B.ORG_ID,B.ORG_NAME,B.PARENT_ID,B.ORG_LEVEL , B.IS_VIRTUAL, B.SORT_NO,\n");
- sql.append("DECODE((SELECT COUNT(1) FROM TA WHERE TA.PARENT_ID=B.ORG_ID),'0','0','1')AS 是否有子机构, \n");
- sql.append("DECODE((SELECT COUNT(1) FROM SYS_USER_INFO U,SYS_DEPT_USER DU WHERE U.USER_ID=DU.USER_ID AND DU.DEPT_ID=B.ORG_ID),'0','0','1')AS 是否员工 \n");
- sql.append("FROM TA B \n");
- sql.append("WHERE B.PARENT_ID IN (SELECT C.ORG_ID FROM TA C \n");
- sql.append("WHERE C.ORG_ID<>'" + id + "' \n");
- sql.append("START WITH C.ORG_ID ='" + id + "' \n");
- sql.append("CONNECT BY C.ORG_ID = PRIOR C.PARENT_ID AND C.ORG_LEVEL >= '" + level
- + "') \n");
- sql.append("ORDER BY B.ORG_LEVEL");
- json.append("{\"treeNodes\":[");
- try {
- ArrayList<String[]> listOrgInfo = persistence.getSearchResult(99, sql.toString());
- for (int i = 0; i < listOrgInfo.size(); i++) {
- String[] temp = listOrgInfo.get(i);
- String orgId = temp[0];
- String orgName = temp[1];
- String parentOrgId = temp[2];
- String orgLevel = temp[3];
- String isVirtual = temp[4];
- String sortNo = temp[5];
- // 判定是否存在子节点
- boolean isHasChildOrg = !("0".equals(temp[6]));
- //判断是否存在员工
- boolean isHasStaff = ("1".equals(temp[7]));
- // 判定是虚拟机构还是实体机构
- String icon = isVirtual == "1" ? "\"/nwyj/scripts/qui/libs/icons/home.gif\""
- : "\"/nwyj/scripts/qui/libs/icons/home.png\"";
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\""
- + parentOrgId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加排序标识
- json.append("\"sortNo\":\""+sortNo+"\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- json.append("\"leafType\":\"org\",");
- if("per".equals(type)){
- if (isHasChildOrg||isHasStaff) {
- json.append("\"isParent\": \"true\" ");
-
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
-
- }else{
-
- if (isHasChildOrg) {
- json.append("\"isParent\": \"true\" ");
-
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
-
- }
- json.append(", \"icon\":"+icon);
- json.append("},");
-
- }
- if("per".equals(type)){
- json.append(addOrgInfoByIdHasPer(id,level));
-
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- };
- json.append("]}");
- log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
-
- }
-
-
- /**
- * 异步搜索查询方法(带人)
- * 思路:查询出需要重新加载的id然后再汇总所有机构的parentId ,根据汇总的parentId 加载parentId 下的所有人员
- *
- * @param id
- * @param level
- * @return
- */
- public String addOrgInfoByIdHasPer(String id, String level) {
-
- StringBuffer json = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- sql.append("--查询给定id下指定级别的 机构信息 \n");
- sql.append("WITH TA AS(SELECT * FROM SYS_DEPARTMENT_1111) \n");
- sql.append("SELECT B.USER_ID,B.REAL_NAME,B.GENDER,D.DEPT_ID,B.MOBILE,B.POSITION \n");
- sql.append("FROM SYS_USER_INFO B,SYS_DEPT_USER D \n");
- sql.append("WHERE B.USER_ID=D.USER_ID AND D.DEPT_ID IN (SELECT C.ORG_ID FROM TA C \n");
- sql.append("WHERE C.ORG_ID<>'" + id + "' \n");
- sql.append("START WITH C.ORG_ID ='" + id + "' \n");
- sql.append("CONNECT BY C.ORG_ID = PRIOR C.PARENT_ORG_ID AND C.ORG_LEVEL >= '" + level
- + "') \n");
- //json.append("{\"treeNodes\":[");
- log.info(sql);
- try {
- ArrayList<String[]> listOrgInfo = persistence.getSearchResult(99, sql.toString());
- for (int i = 0; i < listOrgInfo.size(); i++) {
- String[] temp = listOrgInfo.get(i);
- String userId = temp[0];
- String realName = temp[1];
- String userGender = temp[2];
- String parentOrgId = temp[3];
- String manPhone = temp[4];
- String manDuty = temp[5];
- json.append("{");
- json.append(" \"id\":\"" + userId + "\", \"parentId\":\"" + parentOrgId
- + "\", \"name\": \"" + realName + "\",");
- json.append("\"leafType\":\"per\",");
- json.append("\"manPhone\":\""+manPhone+"\",");
- json.append("\"leafType\":\""+manDuty+"\",");
- if ("男".equals(userGender)) {
- json.append(" \"icon\":\"/nwyj/scripts/qui/libs/icons/user-black.png\"");
- } else if ("女".equals(userGender)) {
- json.append(" \"icon\":\"/nwyj/scripts/qui/libs/icons/user-red-female.png\"");
- } else {
- json.append(" \"icon\":\"/nwyj/scripts/qui/libs/icons/user_group.gif\"");
- }
- json.append("},");
- }
- /*if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- };*/
- //json.append("]}");
- Log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
- /***************************************************************************************************************************************************************************/
- public String statisticInfo(Map<String, String> statisticMap) {
- String statisticId = statisticMap.get("statisticId");
- String orgProp = statisticMap.get("orgProp");
- String fromDate = statisticMap.get("fromDate");
- String toDate = statisticMap.get("toDate");
- StringBuffer sql=new StringBuffer();
- ORGTemplate org = new ORGTemplate();
- StringBuffer result = new StringBuffer();
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- sql.append("WITH A AS(SELECT * FROM V_DEPARTMENT WHERE CORP_ID IN (SELECT ORG_ID FROM V_DEPARTMENT WHERE( \n");
- sql.append("PARENT_ID = ? OR ORG_ID = ?)AND IS_VIRTUAL='0' AND IS_DEL ='0')AND(ORG_PROP = ? OR ORG_PROP IS NULL)AND IS_DEL ='0' and ( ( ( org_name like '%供电局' or org_name like '%供电分局' or org_name like '%供电所' or org_id='C984DC9C294A486096C25FAA78C99AED' )and is_virtual='0' ) or is_virtual='1' ) \n");//20160516广东电网id更改为C984DC9C294A486096C25FAA78C99AED
- //时间过滤
- if(fromDate!=null&&!"".equals(fromDate)){
- sql.append("AND UPDATEDATE BETWEEN TO_DATE('"+fromDate+"','yyyy-mm-dd') \n");
- if(toDate!=null&&!"".equals(toDate)){
-
- sql.append(" AND TO_DATE('"+toDate+"','yyyy-mm-dd') \n");
- }else{
-
-
- sql.append(" AND getdate() \n");
- }
-
- }
- sql.append(") \n");
- sql.append("SELECT \n");
- sql.append("(SELECT TO_NUMBER(SORT) FROM SYS_DEPARTMENT WHERE DEPT_ID = A.CORP_ID)AS SO, \n");
- sql.append("CORP_ID AS ORGID, \n");
- sql.append("(SELECT ORG_NAME FROM V_DEPARTMENT WHERE ORG_ID = A.CORP_ID)AS DWLB , \n");
- sql.append("SUM(DECODE(OFFICE_TYPE, 'DDBG', 1, 0)) AS DDBG, \n");
- sql.append("SUM(DECODE(OFFICE_TYPE, 'HSBG', 1, 0)) AS HSBG, \n");
- sql.append("SUM(DECODE(IS_VIRTUAL, '1', 1, 0)) AS JGZS , \n");
- sql.append("(SELECT COUNT(1)FROM EMC_AM_ORG_INLINK WHERE VIRTUAL_ORG_ID IN (SELECT C.ORG_ID FROM V_DEPARTMENT C WHERE C.CORP_ID =A.CORP_ID AND(ORG_PROP = ? ) AND IS_DEL ='0')AND IS_DEL='0' \n");
- //时间过滤
- if(fromDate!=null&&!"".equals(fromDate)){
- sql.append("AND UPDATEDATE BETWEEN TO_DATE('"+fromDate+"','yyyy-mm-dd') \n");
- if(toDate!=null&&!"".equals(toDate)){
-
- sql.append(" AND TO_DATE('"+toDate+"','yyyy-mm-dd') \n");
- }else{
-
-
- sql.append(" AND getdate() \n");
- }
-
- }
- sql.append(" ) AS BZRS, \n");
- sql.append("(SELECT COUNT(DISTINCT INLINK_INDEX) FROM EMC_AM_ORG_INLINK WHERE VIRTUAL_ORG_ID IN ( SELECT C.ORG_ID FROM V_DEPARTMENT C WHERE C.CORP_ID =A.CORP_ID AND( ORG_PROP = ? ) AND IS_DEL ='0' )AND IS_DEL='0' \n");
- //时间过滤
- if(fromDate!=null&&!"".equals(fromDate)){
- sql.append("AND UPDATEDATE BETWEEN TO_DATE('"+fromDate+"','yyyy-mm-dd') \n");
- if(toDate!=null&&!"".equals(toDate)){
-
- sql.append(" AND TO_DATE('"+toDate+"','yyyy-mm-dd') \n");
- }else{
-
-
- sql.append(" AND getdate() \n");
- }
-
- }
- sql.append(" )AS DWRS \n");
- sql.append("FROM \n");
- sql.append(" A \n");
- sql.append("GROUP BY \n");
- sql.append("A.CORP_ID \n");
- sql.append("ORDER BY SO \n");
- log.info(sql.toString());
- result.append("{\"rows\":[");
- try {
- list = org.query(sql.toString(),statisticId,statisticId,orgProp,orgProp,orgProp);
- if(list.size()==0){return "";}
- //添加总计
- Map<String,String> totalList = new HashMap<String,String>();
- for (Map.Entry<String, String> entry : list.get(0).entrySet()) {
- totalList.put(entry.getKey(),"0");
- }
- totalList.put("ORGID", "ZJ");
- totalList.put("DWLB", "合计");
- totalList.put("SO", "排序");
- for(int i = 0;i<list.size();i++){
- for (Map.Entry<String, String> entry : list.get(i).entrySet()) {
- //sb.append("\""+entry.getKey()+"\":\""+entry.getValue()+"\",");
- if(!("ORGID".equals(entry.getKey())||"DWLB".equals(entry.getKey())||"SO".equals(entry.getKey()))){
-
- totalList.put(entry.getKey(), Integer.toString(Integer.parseInt(entry.getValue())+Integer.parseInt(totalList.get(entry.getKey()))));
-
- }
- }
- }
- list.add(totalList);
- result.append(org.listToString(list));
- log.info(result);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- result.append("]}");
- return result.toString();
- }
- public String getOrgAndPerInfo(Map<String, String> loadOrgPerMap) {
- String id = loadOrgPerMap.get("autoSubmitId");
- boolean isFirstLoad = false;
- if(id==null||"".equals(id)){
- id=loadOrgPerMap.get("fromDeptId");
- isFirstLoad=true;
- }
- String toDeptId = loadOrgPerMap.get("toDeptId");
-
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
-
- StringBuffer json = new StringBuffer();
-
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- json.append("{\"treeNodes\":[");
- if (isFirstLoad) {
- sql.append("--查询给定id及其一级子机构的信息 \n");
- sql.append("WITH P AS(SELECT U.USER_ID \"id\",U.REAL_NAME \"name\",U.ORG_ID \"parentId\",'/nwyj/scripts/qui/libs/icons/user-black.png' \"icon\",U.POSITION \"orgLevel\", U.MOBILE \"perPhone\",U.GENDER \"isParent\",'per' \"leafType\" \n");
- sql.append("FROM SYS_USER_INFO U ,SYS_DEPARTMENT D,SYS_DEPT_USER DU \n");
- sql.append("WHERE U.USER_ID = DU.USER_ID AND D.DEPT_ID = DU.DEPT_ID AND D.DEPT_ID=? \n");
- sql.append("AND U.USER_ID NOT IN (SELECT INLINK_INDEX FROM EMC_AM_ORG_INLINK X \n");
- sql.append("WHERE X.VIRTUAL_ORG_ID =? AND X.IS_DEL ='0') ) , \n");
- sql.append("O AS(SELECT A.DEPT_ID ,A.DEPT_NAME ,A.PARENT_ID ,'/nwyj/scripts/qui/libs/icons/home.png' icon,A.DEPT_LEVEL,A.CORP_ID e, \n");
- sql.append("DECODE(DECODE((SELECT COUNT(1) FROM SYS_DEPARTMENT B WHERE B.PARENT_ID = A.DEPT_ID),0,0,1)+ \n");
- sql.append("DECODE((SELECT COUNT(1) FROM SYS_USER_INFO U ,SYS_DEPARTMENT D,SYS_DEPT_USER DU \n");
- sql.append("WHERE U.USER_ID = DU.USER_ID AND D.DEPT_ID = DU.DEPT_ID AND D.DEPT_ID=A.DEPT_ID \n");
- sql.append("AND U.USER_ID NOT IN (SELECT INLINK_INDEX FROM EMC_AM_ORG_INLINK X \n");
- sql.append("WHERE X.VIRTUAL_ORG_ID =? AND X.IS_DEL ='0') \n");
- sql.append("),0,0,1),0,'false','true') AS isParent,'org' leafType \n");
- sql.append("FROM SYS_DEPARTMENT A WHERE (A.PARENT_ID = ? OR A.DEPT_ID=?)) \n");
- sql.append("SELECT * FROM P \n");
- sql.append("UNION ALL \n");
- sql.append("SELECT * FROM O \n");
- try {
- list = org.query(sql.toString(),id,toDeptId,toDeptId,id,id);
- json.append(org.listToString(list));
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
-
-
- } else {
-
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
-
- sql.append("WITH P AS(SELECT U.USER_ID \"id\",U.REAL_NAME \"name\",U.ORG_ID \"parentId\",'/nwyj/scripts/qui/libs/icons/user-black.png' \"icon\",U.POSITION \"orgLevel\", U.MOBILE \"perPhone\",U.GENDER \"gender\",'per' \"leafType\" \n");
- sql.append("FROM SYS_USER_INFO U ,SYS_DEPARTMENT D,SYS_DEPT_USER DU \n");
- sql.append("WHERE U.USER_ID = DU.USER_ID AND D.DEPT_ID = DU.DEPT_ID AND D.DEPT_ID=? \n");
- sql.append("AND U.USER_ID NOT IN (SELECT INLINK_INDEX FROM EMC_AM_ORG_INLINK X \n");
- sql.append("WHERE X.VIRTUAL_ORG_ID =? AND X.IS_DEL ='0') ) , \n");
- sql.append("O AS(SELECT A.DEPT_ID ,A.DEPT_NAME ,A.PARENT_ID ,'/nwyj/scripts/qui/libs/icons/home.png' icon,A.DEPT_LEVEL,A.CORP_ID e, \n");
- sql.append("DECODE(DECODE((SELECT COUNT(1) FROM SYS_DEPARTMENT B WHERE B.PARENT_ID = A.DEPT_ID),0,0,1)+ \n");
- sql.append("DECODE((SELECT COUNT(1) FROM SYS_USER_INFO U ,SYS_DEPARTMENT D,SYS_DEPT_USER DU \n");
- sql.append("WHERE U.USER_ID = DU.USER_ID AND D.DEPT_ID = DU.DEPT_ID AND D.DEPT_ID=A.DEPT_ID \n");
- sql.append("AND U.USER_ID NOT IN (SELECT INLINK_INDEX FROM EMC_AM_ORG_INLINK X \n");
- sql.append("WHERE X.VIRTUAL_ORG_ID =? AND X.IS_DEL ='0') \n");
- sql.append("),0,0,1),0,'false','true') AS isParent,'org' leafType \n");
- sql.append("FROM SYS_DEPARTMENT A WHERE A.PARENT_ID = ?) \n");
- sql.append("SELECT * FROM P \n");
- sql.append("UNION ALL \n");
- sql.append("SELECT * FROM O \n");
-
- try {
- list = org.query(sql.toString(),id,toDeptId,toDeptId,id);
- json.append(org.listToString(list));
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
- }
- //log.info(sql.toString());
- json.append("]}");
- return json.toString();
- }
- public String getDepartmentInfo(Map<String, String> departmentInfoMap) {
- String adminRoleId = departmentInfoMap.get("adminRoleId");//权限id
- String id = departmentInfoMap.get("autoSubmitId");//自动提交的id
- boolean isFirstLoad = false;
- if(id==null||"".equals(id)){
- id=departmentInfoMap.get("FirstDeptId");
- isFirstLoad=true;
- }
-
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
-
- StringBuffer json = new StringBuffer();
-
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- json.append("{\"treeNodes\":[");
-
- if (isFirstLoad) {
- sql.append("--查询给定id一级子机构的信息 \n");
- // sql.append("WITH T AS (SELECT * FROM SYS_DEPARTMENT WHERE INSTR(DEPT_PATH,'_'||?||'_')>0) \n");
- sql.append("WITH T AS (SELECT * FROM SYS_DEPARTMENT ) \n");
- sql.append("SELECT A.DEPT_ID \"id\",A.DEPT_NAME \"name\",A.PARENT_ID \"parentId\",A.DEPT_LEVEL \"orgLevel\", \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/home.png' \"icon\", \n");
- sql.append("DECODE((SELECT COUNT(1) FROM T B WHERE B.PARENT_ID = A.DEPT_ID),0,'false','true') AS \"isParent\" \n");
- sql.append(",'true' \"open\" \n ");
- sql.append("FROM T A WHERE A.PARENT_ID = ? OR A.DEPT_ID =? order by sort \n ");
-
-
-
-
- try {
- list = org.query(sql.toString(),id,id);
- json.append(org.listToString(list));
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
-
-
- } else {
-
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
- // sql.append("WITH T AS (SELECT * FROM SYS_DEPARTMENT WHERE INSTR(DEPT_PATH,'_'||?||'_')>0) \n");
- sql.append("WITH T AS (SELECT * FROM SYS_DEPARTMENT ) \n");
- sql.append("--查询给定id及其一级子机构的信息 \n");
- sql.append("SELECT A.DEPT_ID \"id\",A.DEPT_NAME \"name\",A.PARENT_ID \"parentId\",A.DEPT_LEVEL \"orgLevel\", \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/home.png' \"icon\", \n");
- sql.append("DECODE((SELECT COUNT(1) FROM T B WHERE B.PARENT_ID = A.DEPT_ID),0,'false','true') AS \"isParent\" \n");
- sql.append("FROM T A WHERE A.PARENT_ID = ? order by sort \n ");
-
-
-
- try {
- list = org.query(sql.toString(),id);
- json.append(org.listToString(list));
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
- }
- log.info(sql.toString());
- json.append("]}");
- return json.toString();
- }
-
-
- /**
- * 系统管理 组织机构 获取树
- * @param params
- * @return
- */
- public String getSysOrgInfoById(String id, boolean getPerson, boolean isFirstLoad) {
- String result = new String();
- if (getPerson) {
- result = loadInDepartmentPerById(id, isFirstLoad,null);
- } else {
- result = loadSysInDepartmentById(id, isFirstLoad);
- }
- return result;
- }
- /**
- * 系统管理 组织机构 获取树
- * @param params
- * @return
- */
- public String loadSysInDepartmentById(String id, boolean isFirstLoad) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- json.append("{\"treeNodes\":[");
- if (isFirstLoad) {
- sql.append("--查询给定id及其一级子机构的信息 \n");
- sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 FROM V_DEPARTMENT A WHERE ( PARENT_ID = '"+id+"' OR ORG_ID ='"+id+"' ) AND IS_DEL='0' and is_virtual='0' ORDER BY SORT_NO )");
- // sql.append("(SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL,A.SORT_NO, \n");
- // sql.append("DECODE((SELECT COUNT(1) FROM EMC_DEPARTMENT_IN B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL='0'),'0','0','1') AS 是否有子机构 \n");
- // sql.append("FROM EMC_DEPARTMENT_IN A WHERE (PARENT_ID = '"
- // + id + "' OR ORG_ID='" + id + "') AND IS_DEL='0' and ((org_name like '%供电局') or(org_name like '%供电分局') ) and is_virtual='0' ORDER BY SORT_NO\n)");
- } else {
-
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
- sql.append("( SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL, A.SORT_NO,DECODE( ( SELECT COUNT(1) FROM V_DEPARTMENT B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL ='0' ),'0', '0', '1') AS 是否有子机构 FROM V_DEPARTMENT A WHERE ( PARENT_ID = '"+id+"') AND IS_DEL='0' and is_virtual='0' ORDER BY SORT_NO )");
- // sql.append("SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ID,A.ORG_LEVEL,A.IS_VIRTUAL,A.SORT_NO, \n");
- // sql.append("DECODE((SELECT COUNT(1) FROM EMC_DEPARTMENT_IN B WHERE B.PARENT_ID = A.ORG_ID AND B.IS_DEL='0'),'0','0','1') AS 是否有子机构 \n");
- // sql.append("FROM EMC_DEPARTMENT_IN A WHERE PARENT_ID = '"
- // + id + "' AND IS_DEL='0' and ((org_name like '%供电局') or(org_name like '%供电分局') ) ORDER BY SORT_NO \n");
- }
- // log.info(sql);
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99,
- sql.toString());
- int listLen = listRoot.size();
- for (int i = 0; i < listLen; i++) {
- String[] temp = listRoot.get(i);
- String orgId = temp[0];
- String orgName = temp[1];
- String parentOrgId = temp[2];
- String orgLevel = temp[3];
- String isVirtual = temp[4];
- String sortNo = temp[5];
- // 判定是否存在子节点
- boolean isHasChildOrg = !("0".equals(temp[6]));
- // 判定是否为第一次加载的id(用来展开初始化的节点)
- String isRootNode = id.equals(orgId) ? "true" : "false";
- // 判定是虚拟机构还是实体机构
- String icon = "1".equals(isVirtual) ? "\"/nwyj/scripts/qui/libs/icons/home.gif\""
- : "\"/nwyj/scripts/qui/libs/icons/home.png\"";
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\""
- + parentOrgId + "\", \"name\": \"" + orgName
- + "\",\"orgLevel\":\"" + orgLevel + "\",");
- //添加排序标识
- json.append("\"sortNo\":\""+sortNo+"\",");
- //添加是否为虚拟机构的属性
- json.append("\"isVirtual\":\""+isVirtual+"\",");
- // 是否展开
- json.append("\"open\":\"" + isRootNode + "\",");
- //设置标记字段值(用于额外的属性)
- json.append("\"tagValue\":\"1\",");
- if (isHasChildOrg) {
- json.append("\"isParent\": \"true\" ");
- } else {
- json.append("\"isParent\": \"fasle\" ");
- }
- json.append(", \"icon\":" + icon + "");
- // json.append(", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }
- // 去掉多余的","
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- ;
- json.append("]}");
- log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
- /**
- * 更新常用联系人群的方法
- * @param commonGroupMap
- * @return
- */
- public String updateCommomGroupById(Map<String, String> commonGroupMap) {
- String id = commonGroupMap.get("loginManId");
- String name = commonGroupMap.get("editName");
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
- String json = "";
-
- sql.append("--根据传入的id更改常用组的名称 \n");
- sql.append("UPDATE EMC_AM_COMMON_MAN_GROUP SET GROUP_NAME=? WHERE GROUP_ID=?");
- try {
- json = String.valueOf(org.update(sql.toString(), name,id));
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return json;
- }
- /**
- * 删除常用群组人员的方法
- * @param commonGroupMap
- * @return
- */
- public String deleteCommGroupById(Map<String, String> commonGroupMap) {
- String groupId = commonGroupMap.get("groupId");
- String nodeType = commonGroupMap.get("nodeType");
- String result = "fail";
- log.info("==================="+groupId+"_____"+nodeType);
- StringBuffer sql1 = new StringBuffer();
- StringBuffer sql2 = new StringBuffer();
- StringBuffer sql3 = new StringBuffer();
- sql1.append("--根据id删除常用组 \n");
- sql1.append("UPDATE EMC_AM_COMMON_MAN_GROUP SET IS_DEL = '1' WHERE GROUP_ID = ? AND IS_DEL='0' \n");
- sql2.append("--根据groupid删除常用组织 \n");
- sql2.append("UPDATE EMC_AM_COMMON_MAN SET IS_DEL = '1' WHERE GROUP_ID = ? AND IS_DEL='0' \n");
- sql3.append("--根据id删除常用组织 \n");
- sql3.append("UPDATE EMC_AM_COMMON_MAN SET IS_DEL = '1' WHERE MAN_ID= ? AND IS_DEL='0' \n");
-
- ORGTemplate org = new ORGTemplate();
- try {
- if("commGroup".equals(nodeType)){
-
- int i = org.update(sql1.toString(),groupId);
-
- int j = org.update(sql2.toString(),groupId);
-
- result = i+j==2?"success":"false";
-
- }else if("commmMan".equals(nodeType)){
-
- int i = org.update(sql3.toString(),groupId);
-
- result = i==1?"success":"false";
-
- }else{
-
-
- result = "fail";
- }
-
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- return result;
- }
- /**
- * 添加自定义常用联系人组
- * @param diyGroupMap
- * @return
- */
- public String addDiyGroup(Map<String, String> diyGroupMap) {
- StringBuffer result=new StringBuffer();
- String linkLoginId = diyGroupMap.get("loginManId");
- String diyName = diyGroupMap.get("diyName");
- String uuid = getUUID();
-
- if ("".equals(linkLoginId) || "".equals(diyName)) {
- return result.toString();
- }
-
- StringBuffer sql = new StringBuffer();
- sql.append("--根据id新增一个常用组 \n");
- sql.append("INSERT INTO EMC_AM_COMMON_MAN_GROUP (FD_OBJECTID,GROUP_ID,GROUP_NAME,LOGIN_ID,IS_DEL,UPDATEDATE) \n");
- sql.append("VALUES(?,?,?,?,'0',GETDATE()) \n");
-
- ORGTemplate org = new ORGTemplate();
- int excute = 0;
- try {
- excute = org.update(sql.toString(), uuid,uuid,diyName,linkLoginId);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- if(excute==1){
- result.append("[{");
- result.append("\"id\":\"" + uuid + "\",");
- result.append("\"parentId\":\"" + "0" + "\",");
- result.append("\"name\":\"" + diyName+"(0)" + "\",");
- result.append("\"realOrgName\":\"" + diyName + "\",");
- result.append("\"childNums\":\"" + "0" + "\",");
- result.append("\"fdId\":\"" + linkLoginId + "\",");
- result.append("\"nodeType\":\"" + "father" + "\",");
- result.append("\"linkOrgId\":\"" + linkLoginId + "\",");
- result.append("\"icon\":\"/nwyj/scripts/qui/sample/tree/layers.gif\"");
- result.append("},");
-
- result.append("{");
- result.append("\"id\":\"" + "virtual" + "\",");
- result.append("\"parentId\":\"" + uuid + "\",");
- result.append("\"name\":\"" + "添加常用联系人" + "\",");
- result.append("\"font\":{\"color\":\"gray\"},");
- result.append("\"click\":\"addCommonOrg('"+uuid+"','"+diyName+"');\",");
- result.append("\"nodeType\":\"" + "virtual" + "\",");
- result.append("\"linkOrgId\":\"" + "virtual" + "\",");
- result.append("\"isParent\":\"" + "false" + "\",");
- result.append("\"icon\":\"/nwyj/scripts/qui/libs/icons/add.png\"");
- result.append("}]");
-
-
- }
-
-
- return result.toString();
- }
- /**
- * 生成uuid
- * @return
- */
- public static String getUUID(){
- String s = UUID.randomUUID().toString();
- //去掉“-”符号
- return s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24);
- }
- public String loadCommonLinkmanGroupInfo(Map<String, String> loadParamMap) {
- String id = loadParamMap.get("loginId");//登陆人关联id
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- sql.append("WITH TA AS(SELECT *,(SELECT COUNT(1) FROM EMC_AM_COMMON_MAN M WHERE M.IS_DEL='0' AND M.GROUP_ID = CP.GROUP_ID) NUM \n");
- /********群组*******/
- sql.append("FROM EMC_AM_COMMON_MAN_GROUP CP WHERE CP.LOGIN_ID = ? AND CP.IS_DEL ='0' ) \n");
- sql.append("SELECT TA.GROUP_ID \"id\",TA.GROUP_NAME||'('||TA.NUM||')' \"name\", '0' \"parentId\", \n");
- sql.append("'/nwyj/scripts/qui/sample/tree/layers.gif' \"icon\", \n");
- sql.append("TA.GROUP_NAME \"realName\", \n");
- sql.append("'commGroup' \"leafType\", \n");
- sql.append("'false' \"nocheck\", \n");
- sql.append("TA.NUM \"childNums\"\n");
- sql.append("FROM TA \n");
- /********虚拟人员*******/
- sql.append("UNION ALL \n");
- sql.append("SELECT 'virtual'||GROUP_ID,'添加常用联系人组', GROUP_ID, \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/add.png' \"icon\", \n");
- sql.append("TA.GROUP_NAME \"realName\", \n");
- sql.append("'virtual' \"leafType\", \n");
- sql.append("'true' \"nocheck\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM TA \n");
- sql.append("UNION ALL \n");
- /********人员*******/
- sql.append("SELECT A.MAN_ID,U.REAL_NAME,A.GROUP_ID, \n");
- sql.append("DECODE(U.MAN_TYPE,'INNER','/nwyj/scripts/qui/libs/icons/user-black.png','/nwyj/scripts/qui/libs/icons/user_group.gif') \"icon\", \n");
- sql.append("U.REAL_NAME \"realName\", \n");
- sql.append("'commmMan' \"leafType\", \n");
- sql.append("'true' \"nocheck\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM EMC_AM_COMMON_MAN A,V_EMC_COMMON_MAN U WHERE A.MAN_ID=U.USER_ID AND GROUP_ID IN (SELECT GROUP_ID FROM TA ) AND A.IS_DEL='0' \n");
-
- try {
- list = org.query(sql.toString(), id);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- json.append("{\"treeNodes\":[");
- //处理list
- for(int i= 0 ;i<list.size();i++){
- Map<String,String> map = list.get(i);
- Map<String,String> new_map = map;
- if(("virtual"+map.get("parentId")).equals(map.get("id"))){
- String orgGroupId = map.get("parentId");
- String orgName = map.get("name");
- new_map.put("font", "{\"color\":\"gray\"}");
- new_map.put("click", "addCommonOrg('"+orgGroupId+"','"+orgName+"');");
-
- }
- list.set(i,new_map);
- }
- json.append(org.listToString(list));
- json.append("]}");
- return json.toString().replace("\"{", "{").replace("}\"", "}");
- }
-
- public String loadCommonLinkmanGroupInfo2(Map<String, String> loadParamMap) {
- String corp_id = loadParamMap.get("corp_id");
- String id = loadParamMap.get("loginId");//登陆人关联id
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- sql.append("WITH TA AS(SELECT *,(SELECT COUNT(1) FROM EMC_AM_COMMON_MAN M WHERE M.IS_DEL='0' AND M.GROUP_ID = CP.GROUP_ID) NUM \n");
- /********群组*******/
- sql.append("FROM EMC_AM_COMMON_MAN_GROUP CP WHERE CP.LOGIN_ID = ? AND CP.IS_DEL ='0' ) \n");
- sql.append("SELECT TA.GROUP_ID \"id\",TA.GROUP_NAME||'('||TA.NUM||')' \"name\", '0' \"parentId\", \n");
- sql.append("'/nwyj/scripts/qui/sample/tree/layers.gif' \"icon\", \n");
- sql.append("TA.GROUP_NAME \"realName\", \n");
- sql.append("'commGroup' \"leafType\", \n");
- sql.append("'false' \"nocheck\", \n");
- sql.append("TA.NUM \"childNums\"\n");
- sql.append("FROM TA \n");
- /*********固定群组**********/
- //指挥中心
- sql.append("UNION ALL \n");
- sql.append("SELECT 'zhzx' \"id\",'默认应急指挥中心' \"name\", '0' \"parentId\", \n");
- sql.append("'/nwyj/scripts/qui/sample/tree/layers.gif' \"icon\", \n");
- sql.append("'默认应急指挥中心' \"realName\", \n");
- sql.append("'commGroup' \"leafType\", \n");
- sql.append("'false' \"nocheck\", \n");
- sql.append("'' \"childNums\"\n");
- sql.append("FROM EMC_AM_COMMON_MAN_GROUP where fd_objectid = 'zhzx' \n");
- //应急办
- sql.append("UNION ALL \n");
- sql.append("SELECT 'zhyjb' \"id\",'默认应急办' \"name\", '0' \"parentId\", \n");
- sql.append("'/nwyj/scripts/qui/sample/tree/layers.gif' \"icon\", \n");
- sql.append("'默认应急办' \"realName\", \n");
- sql.append("'commGroup' \"leafType\", \n");
- sql.append("'false' \"nocheck\", \n");
- sql.append("'' \"childNums\"\n");
- sql.append("FROM EMC_AM_COMMON_MAN_GROUP where fd_objectid = 'zhyjb' \n");
- /********添加按钮*******/
- sql.append("UNION ALL \n");
- sql.append("SELECT 'virtual'||GROUP_ID,'添加常用联系人组', GROUP_ID, \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/add.png' \"icon\", \n");
- sql.append("TA.GROUP_NAME \"realName\", \n");
- sql.append("'virtual' \"leafType\", \n");
- sql.append("'true' \"nocheck\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM TA \n");
- /********人员*******/
- //应急单位人员 指挥中心
- sql.append("UNION ALL \n");
- sql.append("SELECT L.FD_OBJECTID,L.INLINK_NAME, 'zhzx', \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/user-black.png' \"icon\", \n");
- sql.append("L.INLINK_NAME \"realName\", \n");
- sql.append("'commmMan' \"leafType\", \n");
- sql.append("'true' \"nocheck\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM EMC_DEPARTMENT_IN D, EMC_AM_ORG_INLINK L WHERE D.IS_DEL='0' AND L.IS_DEL='0' AND D.ORG_TYPE = 'ZHZX' AND L.VIRTUAL_ORG_ID = D.FD_OBJECTID AND D.CORP_ID = '"+corp_id+"' \n");
- //应急办
- sql.append("UNION ALL \n");
- sql.append("SELECT L.FD_OBJECTID,L.INLINK_NAME, 'zhyjb', \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/user-black.png' \"icon\", \n");
- sql.append("L.INLINK_NAME \"realName\", \n");
- sql.append("'commmMan' \"leafType\", \n");
- sql.append("'true' \"nocheck\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM EMC_DEPARTMENT_IN D, EMC_AM_ORG_INLINK L WHERE D.IS_DEL='0' AND L.IS_DEL='0' AND D.ORG_TYPE = 'ZHZXYJB' AND L.VIRTUAL_ORG_ID = D.FD_OBJECTID AND D.CORP_ID = '"+corp_id+"' \n");
- //联系人
- sql.append("UNION ALL \n");
- sql.append("SELECT A.MAN_ID,U.REAL_NAME,A.GROUP_ID, \n");
- sql.append("DECODE(U.MAN_TYPE,'INNER','/nwyj/scripts/qui/libs/icons/user-black.png','/nwyj/scripts/qui/libs/icons/user_group.gif') \"icon\", \n");
- sql.append("U.REAL_NAME \"realName\", \n");
- sql.append("'commmMan' \"leafType\", \n");
- sql.append("'true' \"nocheck\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM EMC_AM_COMMON_MAN A,V_EMC_COMMON_MAN U WHERE A.MAN_ID=U.USER_ID AND GROUP_ID IN (SELECT GROUP_ID FROM TA ) AND A.IS_DEL='0' \n");
-
- try {
- list = org.query(sql.toString(), id);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- json.append("{\"treeNodes\":[");
- //处理list
- for(int i= 0 ;i<list.size();i++){
- Map<String,String> map = list.get(i);
- Map<String,String> new_map = map;
- if(("virtual"+map.get("parentId")).equals(map.get("id"))){
- String orgGroupId = map.get("parentId");
- String orgName = map.get("name");
- new_map.put("font", "{\"color\":\"gray\"}");
- new_map.put("click", "addCommonOrg('"+orgGroupId+"','"+orgName+"');");
-
- }
- list.set(i,new_map);
- }
- json.append(org.listToString(list));
- json.append("]}");
- return json.toString().replace("\"{", "{").replace("}\"", "}");
- }
- public String addCommonMan(Map<String, String> addCommonManMap) {
- StringBuffer result=new StringBuffer();
- String addManIds = addCommonManMap.get("addManIds");
- String destGroupId = addCommonManMap.get("destGroupId");
-
- if ("".equals(addManIds) || "".equals(addManIds)) {
- return result.toString();
- }
-
- StringBuffer sql = new StringBuffer();
- sql.append("MERGE INTO \n");
- sql.append("EMC_AM_COMMON_MAN P1 \n");
- sql.append("USING \n");
- sql.append("(SELECT USER_ID,? GROUP_ID, MAN_TYPE FROM V_EMC_COMMON_MAN A \n");
- sql.append("WHERE A.USER_ID IN ('_?my?_')) P2 \n");
- sql.append("ON P1.MAN_ID = P2.USER_ID AND P1.GROUP_ID = P2.GROUP_ID AND P1.IS_DEL='0' AND P1.MAN_TYPE= P2.MAN_TYPE \n");
- sql.append("WHEN NOT MATCHED THEN \n");
- sql.append("INSERT (FD_OBJECTID,MAN_ID,GROUP_ID, MAN_TYPE, IS_DEL, UPDATEDATE) \n");
- sql.append("VALUES( SYS_GUID() ,P2.USER_ID ,P2.GROUP_ID, P2.MAN_TYPE,'0', GETDATE()) \n");
-
- String updateSql = sql.toString();
-
- if(addManIds.contains(",")){
-
- addManIds=addManIds.replace(",","','");
-
- }
- updateSql = updateSql.replaceFirst("\\_\\?my\\?\\_", addManIds);
- log.info(updateSql);
- ORGTemplate org = new ORGTemplate();
- int excute = 0;
- try {
- excute = org.update(updateSql, destGroupId);
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
-
- return String.valueOf(excute);
- }
- public String queryCommonLinkmanGroupInfo(Map<String, String> queryParamMap) {
- String id = queryParamMap.get("loginId");//登陆人关联id
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- sql.append("WITH TA AS(SELECT *,(SELECT COUNT(1) FROM EMC_AM_COMMON_MAN M WHERE M.IS_DEL='0' AND M.GROUP_ID = CP.GROUP_ID) NUM \n");
- /********群组*******/
- sql.append("FROM EMC_AM_COMMON_MAN_GROUP CP WHERE CP.LOGIN_ID = ? AND CP.IS_DEL ='0' ) \n");
- sql.append("SELECT TA.GROUP_ID \"id\",TA.GROUP_NAME||'('||TA.NUM||')' \"name\", '0' \"parentId\", \n");
- sql.append("'/nwyj/scripts/qui/sample/tree/layers.gif' \"icon\", \n");
- sql.append("TA.GROUP_NAME \"realName\", \n");
- sql.append("'commGroup' \"leafType\", \n");
- sql.append("TA.NUM \"childNums\"\n");
- sql.append("FROM TA \n");
- /********虚拟人员*******/
- sql.append("UNION ALL \n");
- sql.append("SELECT 'virtual'||GROUP_ID,'添加常用联系人组', GROUP_ID, \n");
- sql.append("'/nwyj/scripts/qui/libs/icons/add.png' \"icon\", \n");
- sql.append("TA.GROUP_NAME \"realName\", \n");
- sql.append("'virtual' \"leafType\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM TA \n");
- sql.append("UNION ALL \n");
- /********人员*******/
- sql.append("SELECT A.MAN_ID,U.REAL_NAME,A.GROUP_ID, \n");
- sql.append("DECODE(U.MAN_TYPE,'INNER','/nwyj/scripts/qui/libs/icons/user-black.png','/nwyj/scripts/qui/libs/icons/user_group.gif') \"icon\", \n");
- sql.append("U.REAL_NAME \"realName\", \n");
- sql.append("'commmMan' \"leafType\", \n");
- sql.append("'' \"childNums\" \n");
- sql.append("FROM EMC_AM_COMMON_MAN A,V_EMC_COMMON_MAN U WHERE A.MAN_ID=U.USER_ID AND GROUP_ID IN (SELECT GROUP_ID FROM TA ) AND A.IS_DEL='0' \n");
-
- try {
- list = org.query(sql.toString(), id);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- json.append("{\"treeNodes\":[");
- //处理list
- for(int i= 0 ;i<list.size();i++){
- Map<String,String> map = list.get(i);
- Map<String,String> new_map = map;
- if(("virtual"+map.get("parentId")).equals(map.get("id"))){
- String orgGroupId = map.get("parentId");
- new_map.put("font", "{\"color\":\"gray\"}");
- new_map.put("click", "addCommonOrg('"+orgGroupId+"');");
-
- }
- list.set(i,new_map);
- }
- json.append(org.listToString(list));
- json.append("]}");
- return json.toString().replace("\"{", "{").replace("}\"", "}");
- }
- public String test(Map<String, String> queryParamMap) {
- String id = queryParamMap.get("id");//登陆人关联id
- ORGTemplate org = new ORGTemplate();
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- List<Map<String,String>> list = new ArrayList<Map<String,String>>();
- sql.append("select dept_id \"id\", dept_name \"name\",parent_id \"parentId\" from sys_department\n");
- try {
- list = org.query(sql.toString());
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- json.append("{\"treeNodes\":[");
- json.append(org.listToString(list));
- json.append("]}");
- return json.toString();
- }
- public String getMoveUp(String id,String sortNo,String parentId){
-
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- int sqlExecute = 0;
- String result = "";
- //判定sortNo是否为空
- if("".equals(sortNo) || sortNo==null ){
- return result;
-
- }
- StringBuffer sqlmoveUp = new StringBuffer();
- sqlmoveUp.append("update SYS_DEPARTMENT set SORT = '0' where SORT = '"+sortNo+"' and PARENT_ID='"+parentId+"';");
- sqlmoveUp.append("update SYS_DEPARTMENT set SORT = '"+sortNo+"' where SORT = '"+(Integer.parseInt(sortNo)-1)+"' and PARENT_ID='"+parentId+"';");
- sqlmoveUp.append("update SYS_DEPARTMENT set SORT = '"+(Integer.parseInt(sortNo)-1)+"' where SORT = '0' and PARENT_ID='"+parentId+"';");
- log.info(sqlmoveUp);
- try {
- sqlExecute = persistence.executeUpdateSQL(99, sqlmoveUp.toString());
- //判定是否删除数据成功
- if(sqlExecute==1){
-
- result = "\""+id+"\"";
- // result = "1";
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
-
- }
-
- public String getMoveDown(String id,String sortNo,String parentId){
-
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- int sqlExecute = 0;
- String result = "";
- //判定sortNo是否为空
- if("".equals(sortNo) || sortNo==null ){
- return result;
-
- }
- StringBuffer sqlmoveUp = new StringBuffer();
- sqlmoveUp.append("update SYS_DEPARTMENT set SORT = '0' where SORT = '"+sortNo+"' and PARENT_ID='"+parentId+"';");
- sqlmoveUp.append("update SYS_DEPARTMENT set SORT = '"+sortNo+"' where SORT = '"+(Integer.parseInt(sortNo)+1)+"' and PARENT_ID='"+parentId+"';");
- sqlmoveUp.append("update SYS_DEPARTMENT set SORT = '"+(Integer.parseInt(sortNo)+1)+"' where SORT = '0' and PARENT_ID='"+parentId+"';");
- log.info(sqlmoveUp);
- try {
- sqlExecute = persistence.executeUpdateSQL(99, sqlmoveUp.toString());
- //判定是否删除数据成功
- if(sqlExecute==1){
-
- result = "\""+id+"\"";
- // result = "1";
- }
- } catch (PersistenceException e) {
-
- e.printStackTrace();
- }
- return result;
-
- }
-
- public Msg getDepartmentUilt(String id,String sortNo, String corpName, String corpId, String type) throws ClassNotFoundException{
-
- Msg m=new Msg();
-
- String []arr=id.split(",");
- String []arr1=sortNo.split(",");
- String []arr2=corpName.split(",");
- String []arr3=corpId.split(",");
- String []arr4=type.split(",");
-
- String sql="UPDATE SYS_DEPARTMENT SET SORT=?,CORP_NAME=?,CORP_ID=?,DEPT_TYPE=? where fd_objectid=?;"
- + "UPDATE SYS_DEPARTMENT SET CORP_NAME='"+corpName+"',CORP_ID='"+corpId+"' where fd_objectid in (select fd_objectid from"
- + " sys_department WHERE DEPT_ID!='"+id+"' start with dept_id='"+id+"' connect by prior dept_id = parent_id);";
-
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
-
- try {
-
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr1[i]);
- st.setString(2, arr2[i]);
- st.setString(3, arr3[i]);
- st.setString(4, arr4[i]);
- st.setString(5, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.OPER_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.OPER_FAILURE);
- conn.rollback();
- return m;
- }
-
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 发布消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /******************2016-03-07谢仲铠 批量修改突发事件类型*************************/
- public Msg getEmergencyTypeUilt(String id,String event_number, String event_type_name, String lead_department) throws ClassNotFoundException{
-
- Msg m=new Msg();
-
- String []arr=id.split(",");
- String []arr1=event_number.split(",");
- String []arr2=event_type_name.split(",");
- String []arr3=lead_department.split(",");
-
- String sql="UPDATE ECM_EM_EMERGENCY_TYPE SET EVENT_NUMBER=?,EVENT_TYPE_NAME=?,LEAD_DEPARTMENT=? where fd_objectid=?;";
-
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
-
- try {
-
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr1[i]);
- st.setString(2, arr2[i]);
- st.setString(3, arr3[i]);
- st.setString(4, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.OPER_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.OPER_FAILURE);
- conn.rollback();
- return m;
- }
-
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 发布消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
-
-
- /**********************2016-09-12 唐群胜新增 修改内部人员电话、邮箱****************************/
- public Msg getMEupdate(String id,String mobile, String email) throws ClassNotFoundException{
-
- Msg m=new Msg();
-
- String []arr=id.split(",");
- String []arr1=mobile.split(",");
- String []arr2=email.split(",");
-
- String sql="UPDATE SYS_USER_INFO SET MOBILE=?,EMAIL=? where fd_objectid=?";
-
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
-
- try {
-
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr1[i]);
- st.setString(2, arr2[i]);
- st.setString(3, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.OPER_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.OPER_FAILURE);
- conn.rollback();
- return m;
- }
-
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 发布消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**********************2016-09-13 唐群胜 机构类型****************************/
-
- public String getOrgType(String id,String update){
- log.info("update====="+update);
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql="";
- if(update.equals("updatetype")){
- sql="select ORG_TYPE from V_DEPARTMENT where IS_DEL ='0' and ORG_ID !='"+id+"' and (ORG_TYPE = 'ZHZX' OR ORG_TYPE = 'ZHZXYJB') start with ORG_ID ='"+id+"' connect by prior PARENT_ID = ORG_ID";
- }else{
- sql="select ORG_TYPE from V_DEPARTMENT where IS_DEL ='0' and (ORG_TYPE = 'ZHZX' OR ORG_TYPE = 'ZHZXYJB') start with ORG_ID ='"+id+"' connect by prior PARENT_ID = ORG_ID";
- }
- log.info("sql====="+sql);
- try {
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- return "";
- }else if(tempList.size()==1){
- String name=tempList.get(0)[0];
- log.info("name===="+name);
- return name;
- }else{
- return "ZHZXZHZXYJB";
- }
- } catch (PersistenceException e) {
- e.printStackTrace();
- return "";
- }
- }
-
-
- /*************************************2017-03-14 唐群胜 机构简称*********************************************/
-
- public String getOrgAbbreviation(String id,String level) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql = "";
- if(level.equals("1")){
- sql ="select NETWORK_NAME from \"NWYJ\".\"DEPARTMENT_ABBR\" where FD_OBJECTID ='"+id+"' ";
- }else if(level.equals("2")){
- sql ="select PROVINCE_NAME from \"NWYJ\".\"DEPARTMENT_ABBR\" where FD_OBJECTID ='"+id+"' ";
- }else if(level.equals("3")){
- sql ="select PREFECTURE_NAME from \"NWYJ\".\"DEPARTMENT_ABBR\" where FD_OBJECTID ='"+id+"' ";
- }else if(level.equals("4")){
- sql ="select COUNTY_NAME from \"NWYJ\".\"DEPARTMENT_ABBR\" where FD_OBJECTID ='"+id+"' ";
- }else{
- sql ="select FULL_NAME from \"NWYJ\".\"DEPARTMENT_ABBR\" where FD_OBJECTID ='"+id+"' ";
- }
- log.info("sql====="+sql);
- try{
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- log.info(tempList.size());
- if(tempList==null||tempList.size()==0){
- String sql2 ="select ORG_NAME from \"NWYJ\".\"V_DEPARTMENT\" where FD_OBJECTID ='"+id+"' ";
- List<String[]>tempList2= persistence.getSearchResult(99, sql2.toString());
- if(tempList2==null||tempList2.size()==0){
- return "";
- }else{
- return tempList2.get(0)[0];
- }
- }else if(tempList.size()==1){
- String name=tempList.get(0)[0];
- log.info("name===="+name);
- return name;
- }else{
- return "";
- }
- }catch(Exception e){
- this.log.error(e.getMessage(), e);
- return "";
- }
- }
-
-
- //人员角色表插入信息
- public String getRoleupdate(String id,String role) throws ClassNotFoundException{
- String result = "";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
-
- if(role.equals("1")){//总指挥
- role="R002105430201";
- }else if(role.equals("2")||role.equals("3")){//副总指挥
- role="R002105430202";
- }else if(role.equals("4")){//主任
- role="R002105430203";
- }else if(role.equals("5")||role.equals("6")){//副主任
- role="R002105430204";
- }else if(role.equals("7")){//成员
- role="R002105430205";
- }else{
- role="";
- }
- if(!role.equals("")){
- StringBuffer sql = new StringBuffer();
- sql.append("--插入联系人 \n");
- sql.append("INSERT INTO SYS_USER_ROLE_REL (\"FD_OBJECTID\", \"ROLE_ID\", \"USER_ID\", \"IS_DEL\", \"MOD_DATE\") \n");
- sql.append(" VALUES('"+createMsgId(getMsgId())+"','"+role+"','"+id+"','0',GETDATE()); ");
- try {
- result =String.valueOf(persistence.executeUpdateSQL(99, sql.toString()));
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- }
- return result;
- }
- //去重复主键
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public List<String> getMsgId() throws ClassNotFoundException {
- String sql = "SELECT FD_OBJECTID FROM SYS_USER_ROLE_REL";
- Connection conn = null;
- Statement stat = null;
- ResultSet rs = null;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- stat = conn.createStatement();
- rs = stat.executeQuery(sql);
- List<String> list = new ArrayList();
- while (rs.next()) {
- list.add(rs.getString("FD_OBJECTID"));
- }
- return list;
- } catch (SQLException e) {
- // this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 获得数据库消息ID集合"
- + sql, e);
- } finally {
- db.close(rs);
- db.close(stat);
- db.close(conn);
- }
- }
- //随机生成主键
- public String createMsgId(List<String> list) throws ClassNotFoundException{
- long l=(long) ((Math.random()+1)*1000000000);
- String msgId=l+"";
- if(list.contains(msgId)){
- return createMsgId(list);
- }
- else{
- // log.info("msgid==="+msgId);
- return msgId;
- }
- }
-
- //开发中,未完成
- public String getOrgChart(String id) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
-
- JSONArray array = null;
- String sql = "SELECT ORG_ID,ORG_NAME,PARENT_ID,PATH_ID,(select count(*) from EMC_AM_ORG_INLINK where is_del='0' and VIRTUAL_ORG_ID=ORG_ID) num,ORG_TYPE,DUTY_TEL,EMERGENCY_TEL FROM V_DEPARTMENT WHERE CORP_ID = '"+id+"' AND IS_DEL='0' order by path_id ";
- try {
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
-
- List<TreeJson> list = new ArrayList<TreeJson>();
- log.info(tempList.size());
- for(int i=0;i<tempList.size();i++){
- TreeJson tree = new TreeJson();
- tree.setId(tempList.get(i)[0]);
- tree.setPid(tempList.get(i)[2]);
- tree.setName(tempList.get(i)[0].equals(id)?tempList.get(i)[1]:tempList.get(i)[1]+"("+tempList.get(i)[4]+"人)");
- tree.setOrg_type(tempList.get(i)[5]);
- tree.setDuty_tel(tempList.get(i)[6]);
- tree.setEmergency_tel(tempList.get(i)[7]);
- list.add(tree);
- }
- List<TreeJson> json = TreeJson.formatTree(list);
- JsonConfig config = new JsonConfig();
- config.setJsonPropertyFilter(new IgnoreFieldProcessorImpl(true, new String[]{"attributes"})); // 忽略掉name属性及集合对象
- array = JSONArray.fromObject(json,config);
- log.info(array);
-
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return "{\"data\": "+array+"}";
- }
-
-
-
- }
|