12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157 |
- package com.sinosoft.lz.system.department;
- import java.io.UnsupportedEncodingException;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.Arrays;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import net.sf.json.JSONObject;
- import org.apache.log4j.Logger;
- import com.formaction.Utils;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.em.response.equipment.records.service.RespEquipmentService;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- /**
- *
- * 1 组织机构管理tree,通过循环查询表800,807返回json数据
- *
- */
- @Path("/DeptService/")
- public class DepartExc{
- private Logger log = Logger.getLogger(this.getClass());
- @ProduceMime("application/json")
- @POST
- @Path("/getDepartTree")
- public String getDepartTree(String params) {
- String id = Utils.getParameter("id", params) == null ? "" : Utils
- .getParameter("id", params);
- String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter("name",
- params);
- /**
- * 组织机构树,需加载到人员时,传参 type='per' 注:人员表读取的sys_user_info
- */
- String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type",
- params);
- String dept = Utils.getParameter("dept", params) == null ? "" : Utils.getParameter("dept",
- params);
- log.info("id-- " + id + " -------name---" + name);
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- sql.append("-- 查询组织机构根节点 \n");
- sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
- sql.append(" from Sys_Department where 1=1 \n");
- if (id.equals("")) {
- sql.append(" and PARENT_ID='0'");
- } else {
- sql.append(" and PARENT_ID='" + id + "'");
- }
- if(!dept.equals("")){
- sql.append(" and dept_type='"+dept+"'");
- }
- sql.append(" ORDER BY SORT asc \n");
- log.info(sql.toString());
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99, sql.toString());
- String[] temp = listRoot.get(0);
- String deptId = temp[0];
- String deptName = temp[1];
- String objectId = temp[2];
- json.append("{treeNodes:[");
- if (listRoot.size() > 1) {
- if(this.hasPersonLeaf(id)&&"per".equals(type)){
- json.append(this.getPersonJson(id)); }
-
- json.append(this.getDeptChlidrenJson(id, type));
- } else {
- json.append("{");
- json.append(" id:'" + deptId + "',parentId:'0', ");
- json.append(" classId:'800',objectId:'" + objectId + "', ");
- json.append(" name:'" + deptName + "', ");
- json.append(" type:'unit',menuType:'nonLeafMenu',");
- json.append(" icon:'/nwyj/scripts/qui/libs/icons/home.gif'");
- json.append("},");
- /** 加载人员信息 */
- if (this.hasPersonLeaf(deptId) && "per".equals(type)) {
- json.append(this.getPersonJson(deptId));
- }
- json.append(this.getDeptChlidrenJson(deptId, type));
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- json.append("]}");
- } catch (PersistenceException e) {
- log.error("查询组织机构错误", e);
- }
- log.info(JSONObject.fromObject(json.toString()).toString());
- return JSONObject.fromObject(json.toString()).toString();
- }
- @ProduceMime("application/json")
- @POST
- @Path("/getCompanyTree")
- public String getCompanyTree(String params) {
- String id = Utils.getParameter("id", params) == null ? "" : Utils
- .getParameter("id", params);
- String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter("name",
- params);
- /**
- * 组织机构树,需加载到人员时,传参 type='per' 注:人员表读取的sys_user_info
- */
- String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type",
- params);
- log.info("id-- " + id + " -------name---" + name);
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- sql.append("-- 查询组织机构根节点 \n");
- sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
- sql.append(" from Sys_Department where 1=1 \n");
- // sql.append(" from Sys_Department where sort>=11 and sort<=29 and fd_objectid!='03E6F6D693F94335B242739D5D2A53E0' and fd_objectid!='0C1FE77E3C314D24B3D15FE38A3250AB' and fd_objectid!='106E3F1BC3914EA5B8E69E6EED7E4F0A' \n");
- if (id.equals("")) {
- sql.append(" and PARENT_ID='0'");
- } else {
- sql.append(" and PARENT_ID='" + id + "'");
- }
- sql.append(" ORDER BY SORT asc \n");
- log.info("*********"+sql.toString());
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99, sql.toString());
- String[] temp = listRoot.get(0);
- String deptId = temp[0];
- String deptName = temp[1];
- String objectId = temp[2];
- json.append("{fromList:[");
- if (listRoot.size() > 1) {
- if(this.hasPersonLeaf(id)&&"per".equals(type)){
- json.append(this.getPersonJson(id)); }
-
- json.append(this.getCompanyChlidrenJson(id, type));
- } else {
- json.append("{");
- json.append(" value:'" + deptId + "',parentId:'0', ");
- json.append(" key:'" + deptName + "'");
- json.append("},");
- json.append(this.getCompanyChlidrenJson(deptId, type));
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- json.append("],'toList':[]}");
- } catch (PersistenceException e) {
- log.error("查询组织机构错误", e);
- }
- log.info(JSONObject.fromObject(json.toString()).toString());
- return JSONObject.fromObject(json.toString()).toString();
- }
-
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/getCompanyTreeTeamAndEquip")
- public String getCompanyTreeTeamAndEquip(String params) {//队伍需求(之前的------备份--20160815)
- String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter("id", params);
- String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter("name",params);
- String needUnit = Utils.getParameter("deptId_self", params) == null ? "" : Utils.getParameter("deptId_self", params);//需求单位
- /**
- * 组织机构树,需加载到人员时,传参 type='per' 注:人员表读取的sys_user_info
- */
- String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type",params);
- log.info("id-- " + id + " -------name---" + name);
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- String sql1=" select DEPT_ID,DEPT_NAME,FD_OBJECTID from Sys_Department where 1=1"+
- " and PARENT_ID='"+id+"' and dept_type='1' and dept_level=3 and DEPT_ID != '"+needUnit+"' ORDER BY SORT asc ";
- ArrayList<String[]> listRoot;
- try {
- json.append("{'fromList':[ ");
- listRoot = persistence.getSearchResult(99, sql1);
- if(listRoot!=null&&listRoot.size()>0){
-
- for(int i=0;i<listRoot.size();i++){
- String[]arr=listRoot.get(i);
- json.append("{ ");
- json.append(" value:'" + arr[0] + "', parentId:'" + id + "',");
- json.append(" key:'" + arr[1] + "',");
- json.append("}, ");
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- json.append("],'toList':[]}");
- log.info(JSONObject.fromObject(json.toString()).toString());
- return JSONObject.fromObject(json.toString()).toString();
- }
- @ProduceMime("application/json")
- @POST
- @Path("/getEquipType")
- public String getEquipType(String params) {//装备需求
-
- String fdId_382 = Utils.getParameter("fdId", params) == null ? "" : Utils.getParameter("fdId", params);//装备需求ID
-
- StringBuffer sb = new StringBuffer();
-
- RespEquipmentService res = new RespEquipmentService();
-
- sb.append("{\"equipTypes\":[");//单选下拉框
- /**
- *需求信息表--ID:383--表名:ECM_EM_EQUIPMENT_DEMAND_DETAIL 该表中EQUIPMENT_NAME字段的值代表装备类型
- *(0:发电车--ID:265--表名:EMC_AM_GENERATOR_CAR--状态:IS_USED='1')
- *(1:发电机--ID:266--表名:EMC_AM_GENERATOR--状态:USED_STAT='1')
- *(2:移动餐车--ID:270--表名:EMC_AM_DINING_CAR--状态:IS_USED='1')
- *(3:指挥通信车--ID:269--表名:EMC_AM_EMERGENCY_COMMAND_CAR--状态:USED_STAT='1')
- *
- */
- //1 通过需求id382在表ECM_EM_EQUIPMENT_DEMAND_DETAIL中查出需求下的各种装备类型(可能不是一个)
- String equipTypes = res.getEquipTypes(fdId_382);
-
- int n = equipTypes.split(",").length;//装备类型的个数
- for(int i=0;i<n;i++){
- if("0".equals(equipTypes.split(",")[i])){
- sb.append("{\"equipType\":\"发电车\"},");
- }else if("1".equals(equipTypes.split(",")[i])){
- sb.append("{\"equipType\":\"发电机\"},");
- }
- }
- if (sb.lastIndexOf(",") > -1) {
- sb.deleteCharAt(sb.lastIndexOf(","));
- }
- sb.append("]}");
- System.out.println("**********"+sb.toString());
- // log.info(JSONObject.fromObject(sb.toString()).toString());
- return sb.toString();
- }
- /*@ProduceMime("application/json")
- @POST
- @Path("/getCompanyTreeTeamAndEquip")
- public String getCompanyTreeTeamAndEquip(String params) {//队伍需求
- String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter("id", params);
- String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter("name",params);
- String needUnit = Utils.getParameter("deptId_self", params) == null ? "" : Utils.getParameter("deptId_self", params);//需求单位
-
- String recipDept = Utils.getParameter("deptid", params) == null ? "" : Utils.getParameter("deptid",params);//需求申请单位
- String fdId_382 = Utils.getParameter("fdId", params) == null ? "" : Utils.getParameter("fdId", params);//队伍需求ID
- // 组织机构树,需加载到人员时,传参 type='per' 注:人员表读取的sys_user_info
- String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type",params);
- log.info("id-- " + id + " -------name---" + name);
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- // String sql1=" select DEPT_ID,DEPT_NAME,FD_OBJECTID from Sys_Department where 1=1 and PARENT_ID='"+id+"' and dept_type='1' and dept_name like'%供电%' and DEPT_ID != '"+needUnit+"' ORDER BY SORT asc ";
- String sql1=" select DEPT_ID,DEPT_NAME,FD_OBJECTID from Sys_Department where 1=1 and PARENT_ID='"+id+"' and dept_type='1' and dept_name like'%供电%' and DEPT_ID != '"+recipDept+"' ORDER BY SORT asc ";
- ArrayList<String[]> listRoot;
- try {
- listRoot = persistence.getSearchResult(99, sql1);
- if(listRoot!=null&&listRoot.size()>0){
- // json.append("{'fromList':[ ");//双选器
- // json.append("{'list':[ ");//单选下拉框
- json.append("{'treeNodes':[ ");//多选下拉框
- for(int i=0;i<listRoot.size();i++){
- String[]arr=listRoot.get(i);
- json.append("{ ");
- json.append(" \"name\":\"" + arr[1] + "\", \"parentId\":\"" + id + "\", \"id\":\"" + arr[0] + "\"");
- json.append("}, ");
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- // json.append("],'toList':[]}");
- json.append("]}");
- log.info(JSONObject.fromObject(json.toString()).toString());
- return JSONObject.fromObject(json.toString()).toString();
- }*/
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/getCompanyTreeEquip")
- public String getCompanyTreeEquip(String params) {//装备需求
- String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter("id", params);//登录人单位id
- String name = Utils.getParameter("name", params) == null ? "" : Utils.getParameter("name",params);//空值(“”)
- String recipDept = Utils.getParameter("deptid", params) == null ? "" : Utils.getParameter("deptid",params);//需求申请单位ID
- String fdId_382 = Utils.getParameter("fdId", params) == null ? "" : Utils.getParameter("fdId", params);//装备需求ID
- /**
- * 组织机构树,需加载到人员时,传参 type='per' 注:人员表读取的sys_user_info
- */
- String type = Utils.getParameter("type", params) == null ? "" : Utils.getParameter("type",params);
-
- log.info("id-- " + id + " -------name---" + name);
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- RespEquipmentService res = new RespEquipmentService();
- String sql1 = " select DEPT_ID,DEPT_NAME,FD_OBJECTID from Sys_Department where '1'='1' and PARENT_ID='"+id+"' and dept_type='1' and dept_name like'%供电%' and DEPT_ID!='"+recipDept+"' ORDER BY SORT asc ";
- ArrayList<String[]> listRoot;
- try {
- listRoot = persistence.getSearchResult(99, sql1);
- if(listRoot!=null&&listRoot.size()>0){
- //json.append("{'treeNodes':[ ");//多选下拉框
- json.append("{\"treeNodes\":[");//多选下拉框
- for(int i=0;i<listRoot.size();i++){
- String[]arr=listRoot.get(i);
- json.append("{");
- // json.append("value:'" + arr[0] + "', parentId:'" + id + "',key:'" + arr[1] + "',");//单选下拉框
- /**
- *需求信息表--ID:383--表名:ECM_EM_EQUIPMENT_DEMAND_DETAIL 该表中EQUIPMENT_NAME字段的值代表装备类型
- *(0:发电车--ID:265--表名:EMC_AM_GENERATOR_CAR--状态:IS_USED='1')
- *(1:发电机--ID:266--表名:EMC_AM_GENERATOR--状态:USED_STAT='1')
- *(2:移动餐车--ID:270--表名:EMC_AM_DINING_CAR--状态:IS_USED='1')
- *(3:指挥通信车--ID:269--表名:EMC_AM_EMERGENCY_COMMAND_CAR--状态:USED_STAT='1')
- */
- //1 先通过需求id382在表ECM_EM_EQUIPMENT_DEMAND_DETAIL中查出需求下的各种装备类型(可能不是一个)
- String equipTypes = res.getEquipTypes(fdId_382);
-
- //2 再通过装备类型查各装备在表中可调拨的数量
- String equipTypeAndCount = "";
- if(!"".equals(equipTypes)){
- String[] str = equipTypes.split(",");
- equipTypeAndCount = res.getEquipNumUseful(str,arr[0]);
- }
-
- //3 把上述装备数量拼接到下面JSON中返回前台
-
- /*json.append("id:'" + arr[0] + "', parentId:'" + id + "',name:'" + arr[1] + "--" + equipTypeAndCount + "',");//多选下拉框
- json.append("}, ");*/
- json.append("\"id\":\"" + arr[0] + "\",\"parentId\":\"" + id + "\",\"name\":\"" + arr[1] + "--" + equipTypeAndCount + "\"");//多选下拉框
- json.append("},");
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- }
- json.append("]}");
- log.info(JSONObject.fromObject(json.toString()).toString());
- return JSONObject.fromObject(json.toString()).toString();
- }
- private String getCompanyChlidrenJsonTeamAndEquip(String unitCode, String type) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- sql.append("-- 查询组织机构子节点 \n");
- sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
- // sql.append(" from Sys_Department where dept_type='CORP' and parent_id='" + unitCode + "' \n");
- sql.append(" from Sys_Department where dept_type='CORP' and parent_id='" + unitCode + "' \n");
- sql.append(" and sort>=11 and sort<=29 and fd_objectid!='03E6F6D693F94335B242739D5D2A53E0' and fd_objectid!='0C1FE77E3C314D24B3D15FE38A3250AB' and fd_objectid!='106E3F1BC3914EA5B8E69E6EED7E4F0A' \n");
- sql.append(" ORDER BY SORT asc \n");
- log.info("=="+sql);
- try {
- ArrayList<String[]> listDept = persistence.getSearchResult(99, sql.toString());
- int num = listDept.size();
- for (int i = 0; i < num; i++) {
- String[] temp = listDept.get(i);
- String deptId = temp[0];
- String deptName = temp[1];
- String objectId = temp[2];
- json.append("{ ");
- json.append(" value:'" + deptId + "', parentId:'" + unitCode + "',");
- json.append(" key:'" + deptName + "',");
-
- json.append("}, ");
- /**
- * 加载人员信息 if(this.hasPersonLeaf(deptId)&&"per".equals(type)){
- * json.append(this.getPersonJson(deptId)); }
- */
- /*if (this.isExitLeaf(deptId)) {
- json.append(this.getDeptChlidrenJson(deptId, type));
- }*/
- }
- } catch (PersistenceException e) {
- log.error("查询组织机构子节点错误", e);
- }
- return json.toString();
- }
- /**
- * 返回部门节点json字符串
- *
- * @param unitCode
- * @return
- */
- private String getDeptChlidrenJson(String unitCode, String type) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- sql.append("-- 查询组织机构子节点 \n");
- sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
- sql.append(" from Sys_Department where parent_id='" + unitCode + "' \n");
- sql.append(" ORDER BY SORT asc \n");
- log.info("=="+sql);
- try {
- ArrayList<String[]> listDept = persistence.getSearchResult(99, sql.toString());
- int num = listDept.size();
- for (int i = 0; i < num; i++) {
- String[] temp = listDept.get(i);
- String deptId = temp[0];
- String deptName = temp[1];
- String objectId = temp[2];
- json.append("{ ");
- json.append(" id:'" + deptId + "', parentId:'" + unitCode + "',");
- json.append(" classId:'800',objectId:'" + objectId + "',");
- json.append(" name:'" + deptName + "',");
- json.append(" type:'unit',menuType:'nonLeafMenu',");
- json.append(" icon:'/nwyj/scripts/qui/libs/icons/user_group.gif'");
- json.append("}, ");
- /**
- * 加载人员信息 if(this.hasPersonLeaf(deptId)&&"per".equals(type)){
- * json.append(this.getPersonJson(deptId)); }
- */
- /*if (this.isExitLeaf(deptId)) {
- json.append(this.getDeptChlidrenJson(deptId, type));
- }*/
- }
- } catch (PersistenceException e) {
- log.error("查询组织机构子节点错误", e);
- }
- return json.toString();
- }
- /**
- * 返回部门节点json字符串
- *
- * @param unitCode
- * @return
- */
- private String getCompanyChlidrenJson(String unitCode, String type) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- StringBuffer sql = new StringBuffer();
- sql.append("-- 查询组织机构子节点 \n");
- sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
- sql.append(" from Sys_Department where dept_type='CORP' and parent_id='" + unitCode + "' \n");
- sql.append(" ORDER BY SORT asc \n");
- log.info("=="+sql);
- try {
- ArrayList<String[]> listDept = persistence.getSearchResult(99, sql.toString());
- int num = listDept.size();
- for (int i = 0; i < num; i++) {
- String[] temp = listDept.get(i);
- String deptId = temp[0];
- String deptName = temp[1];
- String objectId = temp[2];
- json.append("{ ");
- json.append(" value:'" + deptId + "', parentId:'" + unitCode + "',");
- json.append(" key:'" + deptName + "',");
-
- json.append("}, ");
- /**
- * 加载人员信息 if(this.hasPersonLeaf(deptId)&&"per".equals(type)){
- * json.append(this.getPersonJson(deptId)); }
- */
- /*if (this.isExitLeaf(deptId)) {
- json.append(this.getDeptChlidrenJson(deptId, type));
- }*/
- }
- } catch (PersistenceException e) {
- log.error("查询组织机构子节点错误", e);
- }
- return json.toString();
- }
- /**
- * 判断是否有子节点
- *
- * @param persistence
- * @param mId
- * @return
- */
- private boolean isExitLeaf(String unitCode) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- boolean flag = false;
- try {
- String sql = " select count(dept_id) from Sys_Department where parent_ID='" + unitCode
- + "' ";
- ArrayList<String[]> list = persistence.getSearchResult(99, sql);
- int num = Integer.parseInt(list.get(0)[0]);
- if (num > 0) {
- flag = true;
- }
- } catch (PersistenceException e) {
- log.error("是否存在子节点-- ", e);
- }
- return flag;
- }
- /**
- * 根据部门id 查询人员 返回人员数据json
- *
- * @param deptId
- * @return
- */
- private String getPersonJson(String deptId) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json = new StringBuffer();
- // String sql =
- // "select FD_OBJECTID,PERSON_CODE,NAME ,SEX from Sys_Person where IS_DEL='0' and DEPT_ID='"+deptId+"' ORDER BY PERSON_CODE ASC ";
- String sql = "select FD_OBJECTID,USER_ID,DISPLAY_NAME,NAME from sys_user_info where IS_DEL='0' and UNIT_CODE='"
- + deptId + "' ORDER BY user_id ASC ";
- // log.info("=="+sql);
- try {
- ArrayList<String[]> list = persistence.getSearchResult(99, sql.toString());
- int num = list.size();
- for (int i = 0; i < num; i++) {
- String[] temp = list.get(i);
- String objectId = temp[0];
- String pCode = temp[1];
- String name = temp[2];
- // String sex = temp[3]== null ? "0" : temp[3];
- json.append("{ ");
- json.append(" id:'" + pCode + "', parentId:'" + deptId + "',");
- json.append(" classId:'807',objectId:'" + objectId + "',");
- // json.append(" name:'"+name+"',nocheck:true,");
- json.append(" type:'per',name:'" + name + "',");
- json.append(" menuType:'leafMenu'");
- /*
- * if(sex.equals("0")){ json.append(
- * " icon:'../../../scripts/qui/libs/icons/user_female.gif'");
- * }else{
- * json.append(" icon:'../../../scripts/qui/libs/icons/user.gif'"
- * ); }
- */
- json.append("}, ");
- }
- } catch (PersistenceException e) {
- log.error("查询人员数据错误-- ", e);
- }
- return json.toString();
- }
- private boolean hasPersonLeaf(String deptId) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- /*String sql = "select count(FD_OBJECTID) from sys_user_info where IS_DEL='0' and UNIT_CODE='"
- + deptId + "' ORDER BY user_id ASC ";*/
- String sql = "select count(FD_OBJECTID) from sys_user_info where IS_DEL='0' ORDER BY user_id ASC ";
- // log.info("=="+sql);
- boolean flag = false;
- try {
- ArrayList<String[]> list = persistence.getSearchResult(99, sql);
- int num = Integer.parseInt(list.get(0)[0]);
- if (num > 0) {
- flag = true;
- }
- } catch (PersistenceException e) {
- log.error("是否存在人员-- ", e);
- }
- return flag;
- }
- /**
- * 新增机构或人员时,生成编号Id
- *
- * @param params
- * @return
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getCreateNodeNum")
- public String getCreateNodeNum(String params) {
- params = decode(params);
- // 树节点id
- String node = Utils.getParameter("deptId", params) == null ? "" : Utils.getParameter(
- "deptId", params);
- // 800 机构; 807人员
- Integer classid = Integer.parseInt(Utils.getParameter("classid", params) == null ? ""
- : Utils.getParameter("classid", params));
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String num = "";
- try {
- String sql = "";
- if (classid == 800) {
- sql = "select Max(Dept_Id) from Sys_Department where Depts_Id='" + node + "'";
- } else if (classid == 807) {
- sql = "select Max(user_id) from sys_user_info where UNIT_CODE='" + node + "'";
- }
- ArrayList<String[]> list = persistence.getSearchResult(classid, sql);
- // 如果节点下没有子节点,返回节点nodeid+‘01’,作为该节点的第一个子节点。
- if (list.get(0)[0] == null) {
- num = node + "01";
- } else {
- String deptCode = list.get(0)[0];
- num = Long.valueOf(deptCode) + 1 + "";
- }
- } catch (PersistenceException e) {
- log.error("生成机构人员编码错误", e);
- }
- log.info("num--- " + num);
- return num;
- }
- // 根据单位deptid获取单位名称
- public String getBMTableByNameIds(String tablename, String fdCode) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql = "";
- // 单位部门表时,查询字段特殊
- if (tablename.equalsIgnoreCase("Sys_Department")) {
- sql = "select DEPT_NAME,Dept_Id from " + tablename + " where is_del ='0' and Dept_Id='"
- + fdCode + "'";
- } else {
- sql = "select fd_description,fd_code from BM$_MapValueCanst where fd_type='"
- + tablename + "' and fd_code='" + fdCode + "' ";
- }
- ArrayList<String[]> codes;
- String value = "";
- try {
- codes = persistence.getSearchResult(99, sql);
- if (codes.size() > 0) {
- for (String[] s : codes) {
- if (s[1].equals(fdCode)) {
- value = s[0];
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- log.error("" + e);
- }
- return value;
- }
- // 编码解析
- protected String decode(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- return params;
- }
- /**
- * 根据部门deptid删除人员信息
- *
- * @param params
- */
- @ProduceMime("application/json")
- @POST
- @Path("/delPersonByDeptId")
- public void delPersonByDeptId(String params) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String depts = Utils.getParameter("DEPT_ID", params).trim() == null ? "" : Utils
- .getParameter("DEPT_ID", params).trim();
- String sql = "update sys_user_info set is_del='1' where UNIT_CODE='" + depts + "'";
- log.info(sql);
- try {
- persistence.getSearchResult(99, sql);
- } catch (Exception e) {
- log.error("" + e);
- }
- }
- /**
- * 根据人员Id删除人员信息
- *
- * @param params
- */
- @ProduceMime("application/json")
- @POST
- @Path("/delPersonByPid")
- public String delPersonByPid(String params) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String objectId = Utils.getParameter("ObjectID", params).trim() == null ? "" : Utils
- .getParameter("ObjectID", params).trim();
- String sql = "update sys_user_info set is_del='1' where FD_OBJECTID='" + objectId + "'";
- log.info(sql);
- boolean flag = false;
- try {
- int num = persistence.executeUpdateSQL(99, sql);
- if (num > 0) {
- flag = true;
- }
- } catch (Exception e) {
- log.error("" + e);
- }
- return new Boolean(flag).toString();
- }
- /**
- * 根据人员Id删除人员信息
- *
- * @param params
- */
- @ProduceMime("application/json")
- @POST
- @Path("/delDeptById")
- public String delDeptById(String params) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String objectId = Utils.getParameter("ObjectID", params).trim() == null ? "" : Utils
- .getParameter("ObjectID", params).trim();
- String sql = "update Sys_Department set is_del='1' where FD_OBJECTID='" + objectId + "'";
- log.info(sql);
- boolean flag = false;
- try {
- int num = persistence.executeUpdateSQL(99, sql);
- if (num > 0) {
- flag = true;
- }
- } catch (Exception e) {
- log.error("" + e);
- }
- return new Boolean(flag).toString();
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getEquipArg")
- public String getEquipArg(String params) {////查询装备属性(通过工器具类型ID)
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-
- String equipmentTypeID = Utils.getParameter("equipTypeID", params) == null ? "" : Utils.getParameter("equipTypeID", params);//工器具类型ID
-
- // String sql = "select ID,COLUMN_NAME from NWYJ_SERVICE.SP_SS_EMERGENCY_PARAMETER where INSTRUMENT_TYPE_ID in ( select ID from NWYJ_SERVICE.SP_SS_INSTRUMENT_TYPE where PROVINCE_CODE=? and BUREAU_CODE=? and INSTRUMENT_NAME=? )";
- String sql = "select ID,COLUMN_NAME from NWYJ_SERVICE.SP_SS_EMERGENCY_PARAMETER where INSTRUMENT_TYPE_ID=?";
-
- StringBuffer sb = new StringBuffer();
- sb.append("{\"equipResult\":[");
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- pstm.setString(1, equipmentTypeID);
- rs = pstm.executeQuery();
- while(rs.next()){
- // sb.append(rs.getString("EQUIPMENT_NAME") == null ? "" : rs.getString("EQUIPMENT_NAME"));
- // sb.append(",");
- sb.append("{\"equipArg\":\""+(rs.getString("COLUMN_NAME") == null ? "" : rs.getString("COLUMN_NAME"))+"\","
- +"\"equipArgId\":\""+(rs.getString("ID") == null ? "" : rs.getString("ID"))+"\""
- +"},");
- }
- if (sb.lastIndexOf(",") > -1) {
- sb.deleteCharAt(sb.lastIndexOf(","));
- // sb.deleteCharAt(sb.length()-1);
- }
- sb.append("]}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null)
- rs.close();
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- // System.out.println("******************"+sb.toString());
- return sb.toString();
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getEquipArgVal")
- public String getEquipArgVal(String params) {//获取满足条件的装备类型属性的值和id
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- // String equipArg = Utils.getParameter("equipArg", params) == null ? "" : Utils.getParameter("equipArg", params);//装备属性
- String equipArgId = Utils.getParameter("equipArgId", params) == null ? "" : Utils.getParameter("equipArgId",params);//装备属性值
- // String equipArg = Utils.getParameter("equipArg", params) == null ? "" : Utils.getParameter("equipArg",params);//装备属性值
-
- String sql = "select ID,COLUMN_NAME,COLUMN_CODE,COLUMN_VALUE from NWYJ_SERVICE.SP_SS_EMERGENCY_PARAMETER_VAL where EMERGENCY_PARAMETER_ID=?";
-
- StringBuffer sb = new StringBuffer();
- sb.append("{\"equipVal\":[");
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- pstm.setString(1, equipArgId);
- rs = pstm.executeQuery();
- while(rs.next()){
- sb.append("{"+
- "\"equipArgValId\":\""+(rs.getString("ID") == null ? "" : rs.getString("ID"))+"\","+
- "\"equipArgValName\":\""+(rs.getString("COLUMN_NAME") == null ? "" : rs.getString("COLUMN_NAME"))+"\","+
- "\"equipArgValCode\":\""+(rs.getString("COLUMN_CODE") == null ? "" : rs.getString("COLUMN_CODE"))+"\","+
- "\"equipArgVal\":\""+(rs.getString("COLUMN_VALUE") == null ? "" : rs.getString("COLUMN_VALUE"))+"\""+
- "},");
- }
- if (sb.lastIndexOf(",") > -1) {
- sb.deleteCharAt(sb.lastIndexOf(","));
- // sb.deleteCharAt(sb.length()-1);
- }
- sb.append("]}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null)
- rs.close();
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- // System.out.println("******************"+sb.toString());
- return sb.toString();
- }
- @POST
- @ProduceMime("application/json")
- @Path("/getIdByEquipMsg")
- public String getIdByEquipMsg(String params) {//获取工器具类型ID
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-
- String equipmentType = Utils.getParameter("jkEquipmentType", params) == null ? "" : Utils.getParameter("jkEquipmentType",params);//装备类型(PARENT_NAME)
-
- String sql = "select ID from NWYJ_SERVICE.SP_SS_INSTRUMENT_TYPE where INSTRUMENT_NAME=?";
-
- StringBuffer sb = new StringBuffer();
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- pstm.setString(1, params);
- rs = pstm.executeQuery();
- while(rs.next()){
- sb.append(rs.getString("ID") == null ? "" : rs.getString("ID"));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null)
- rs.close();
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- // System.out.println("******************"+sb.toString());
- return sb.toString();
- }
-
- @POST
- @ProduceMime("application/json")
- @Path("/getTeamMsg")
- public String getTeamMsg(String params) {//获取队伍
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-
- String unite_id = Utils.getParameter("uniteID", params) == null ? "" : Utils.getParameter("uniteID",params);//单位ID
- String teamType = Utils.getParameter("teamType", params) == null ? "" : Utils.getParameter("teamType",params);//队伍类型
- String teamTypeCode = "";//队伍类型常量值(select * from bm_mapvaluecanst where fd_type='BM_TEAMTYPE')
- if(teamType == "输电"){//"输电".equals(teamType)
- teamTypeCode="124";
- } else if(teamType == "变电"){
- teamTypeCode="125";
- } else if(teamType == "配电"){
- teamTypeCode="126";
- } else if(teamType == "通信"){
- teamTypeCode="127";
- } else if(teamType.equals("网络信息")){//--------------------------------------
- teamTypeCode="124";//--------------------------------------
- } else if(teamType == "试验"){
- teamTypeCode="129";
- } else if(teamType == "其他"){
- teamTypeCode="130";
- }
-
- String sql = "select FD_OBJECTID,TEAM_NAME,TEAM_MEMBER_NUMBER from ECM_AM_EMERGENCY_TEAM where TEAM_COMP_ID=? and TEAM_TYPE=? and TEAM_STAT='1'";
-
- StringBuffer sb = new StringBuffer();
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- pstm.setString(1, unite_id);
- pstm.setString(2, teamTypeCode);
- rs = pstm.executeQuery();
- sb.append("{\"treeNodes\":[");
- while(rs.next()){
- // sb.append("{\"id\":\""+rs.getString("FD_OBJECTID")==null ? "" : rs.getString("FD_OBJECTID")+"\",\"parentId\":\"0\",\"name\":\""+rs.getString("TEAM_NAME")==null ? "" : rs.getString("TEAM_NAME")+"("+rs.getString("TEAM_MEMBER_NUMBER") == null ? "" : rs.getString("TEAM_MEMBER_NUMBER")+")\"},");
- sb.append("{\"id\":\""+rs.getString("FD_OBJECTID")+"\",\"parentId\":\"0\",\"name\":\""+rs.getString("TEAM_NAME")+"("+rs.getString("TEAM_MEMBER_NUMBER")+")\"},");
- }
- if(sb.lastIndexOf(",")>-1){
- sb.deleteCharAt(sb.lastIndexOf(","));
- }
- sb.append("]}");
- } catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null)
- rs.close();
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- // System.out.println("******************"+sb.toString());
- return sb.toString();
- }
-
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/initZtree_unitAndEquipMsg")
- public String initZtree_unitAndEquipMsg(String params) {//单位及装备、装备属性、属性值的下拉树
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- String id = Utils.getParameter("corpId", params) == null ? "" : Utils.getParameter("corpId", params);//登录人单位id
- String corpName = Utils.getParameter("corpName", params) == null ? "" : Utils.getParameter("corpName",params);//登录人单位name
- String recipDept = Utils.getParameter("equipNeedUnit", params) == null ? "" : Utils.getParameter("equipNeedUnit",params);//需求申请单位ID
- String fdId_382 = Utils.getParameter("fdId", params) == null ? "" : Utils.getParameter("fdId", params);//装备需求ID
-
- StringBuffer sb = new StringBuffer();
- RespEquipmentService res = new RespEquipmentService();
-
- String sql =" select DEPT_ID,DEPT_NAME,FD_OBJECTID,UNICODE "+
- " from Sys_Department "+
- " where 1=1 and "+
- " PARENT_ID='"+id+"' and "+
- " dept_type='1' and "+
- " dept_name like'%供电%' and "+
- " DEPT_ID!='"+recipDept+"' "+
- " ORDER BY SORT asc ";
-
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
-
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sql);
- rs = pstm.executeQuery();
- sb.append("{\"treeNodes\":[");
- sb.append("{\"id\":\""+id+"\",\"parentId\":\"99999\",\"name\":\""+corpName+"\",\"open\":\"true\"},");//第一级--本级单位(制定调拨令的人的单位)
- while(rs.next()){
- String deptId = rs.getString("DEPT_ID") == null ? "" : rs.getString("DEPT_ID");//下级单位id
- String deptName = rs.getString("DEPT_NAME") == null ? "" : rs.getString("DEPT_NAME");//下级单位NAME
- String unitcode = rs.getString("UNICODE") == null ? "" : rs.getString("UNICODE");//单位编码
- /******************************************************************************************************/
- sb.append("{\"id\":\""+deptId+"\",\"parentId\":\""+id+"\",\"name\":\""+deptName+"\"},");//第二级--下级单位
-
- /**
- *需求信息表--ID:383--表名:ECM_EM_EQUIPMENT_DEMAND_DETAIL 该表中EQUIPMENT_NAME字段的值代表装备类型
- *(0:发电车--ID:265--表名:EMC_AM_GENERATOR_CAR--状态:IS_USED='1')
- *(1:发电机--ID:266--表名:EMC_AM_GENERATOR--状态:USED_STAT='1')
- *(2:移动餐车--ID:270--表名:EMC_AM_DINING_CAR--状态:IS_USED='1')
- *(3:指挥通信车--ID:269--表名:EMC_AM_EMERGENCY_COMMAND_CAR--状态:USED_STAT='1')
- */
- //先通过需求id382在表ECM_EM_EQUIPMENT_DEMAND_DETAIL中查出需求下的各种装备类型(可能不是一个)
- String equipTypes = res.getEquipTypes(fdId_382);
- int equipTypesNum = 0;//装备类型的数量(多少种装备)
- equipTypesNum = equipTypes.split(",").length;
- for(int i=0;i<equipTypesNum;i++){//装备类型
- if("0".equals(equipTypes.split(",")[i])){//发电车
- sb.append("{\"id\":\""+deptId+","+"fadianche\",\"parentId\":\""+deptId+"\",\"name\":\"发电车\"},");//第三级--装备类型
-
- String gqjlxId = getIdByEquipMsg("发电车");//查询“工器具类型”
- String equipArg = res.getEquipArg(gqjlxId);//查询装备属性(通过工器具类型ID)【属性,属性ID;属性,属性ID;...】
- int equipArgNum = 0;//装备属性的个数
- equipArgNum = equipArg.split(";").length;
- String idAndParentId = "";
- for(int j=0;j<equipArgNum;j++){//装备属性
- idAndParentId = equipArg.split(";")[j].split(",")[1];
- sb.append("{\"id\":\""+deptId+","+idAndParentId+","+"0"+"\",\"parentId\":\""+deptId+","+"fadianche\",\"name\":\""+equipArg.split(";")[j].split(",")[0]+"\"},");//第四级--装备属性
-
- String equipArgValMsg = res.getEquipArgVal(equipArg.split(";")[j].split(",")[1]);//获取装备属性值信息【具体信息排序,可以查看方法RespEquipmentService.getEquipArgVal】
- int equipArgValMsgNum = 0;//装备属性值的个数
- equipArgValMsgNum = equipArgValMsg.split(";").length;
- for(int k=0;k<equipArgValMsgNum;k++){//装备属性值
- sb.append("{\"id\":\""+equipArgValMsg.split(";")[k].split(",")[1]+"\",\"parentId\":\""+deptId+","+idAndParentId+","+"0"+"\",\"name\":\""+equipArgValMsg.split(";")[k].split(",")[0]+"\","+
- "\"appendMsg\":\""+deptName+"-发电车-"+equipArg.split(";")[j].split(",")[0]+":"+equipArgValMsg.split(";")[k].split(",")[0]+"\","+//XX供电局-发电车-属性:属性值
- "\"deptMsg\":\""+deptId+","+deptName+","+"发电车"+"\","+
- "\"queryEquipNum_JK\":\""+
- gqjlxId+","+//工器具类型ID
- unitcode+","+//单位编码
- equipArgValMsg.split(";")[k].split(",")[1]+","+//属性值ID
- equipArgValMsg.split(";")[k].split(",")[2]+","+//属性
- equipArgValMsg.split(";")[k].split(",")[0]+//属性值
- "\"},");//第五级--装备属性值(queryEquipNum_JK:工器具类型ID,单位编码,属性值ID,属性,属性值)
- }
- }
- }else if("1".equals(equipTypes.split(",")[i])){//发电机
- sb.append("{\"id\":\""+deptId+","+"fadianji\",\"parentId\":\""+deptId+"\",\"name\":\"发电机\"},");//第三级--装备类型
-
- String gqjlxId = getIdByEquipMsg("发电机");//查询“工器具类型”
- String equipArg = res.getEquipArg(gqjlxId);//查询装备属性(通过工器具类型ID)【属性,属性ID;属性,属性ID;...】
- int equipArgNum = 0;//装备属性的个数
- equipArgNum = equipArg.split(";").length;
- String idAndParentId = "";
- for(int j=0;j<equipArgNum;j++){//装备属性
- idAndParentId = equipArg.split(";")[j].split(",")[1];//属性ID
- sb.append("{\"id\":\""+deptId+","+idAndParentId+","+"1"+"\",\"parentId\":\""+deptId+","+"fadianji\",\"name\":\""+equipArg.split(";")[j].split(",")[0]+"\"},");//第四级--装备属性
-
- String equipArgValMsg = res.getEquipArgVal(equipArg.split(";")[j].split(",")[1]);//获取装备属性值信息【具体信息排序,可以查看方法RespEquipmentService.getEquipArgVal】
- int equipArgValMsgNum = 0;//装备属性值的个数
- equipArgValMsgNum = equipArgValMsg.split(";").length;
- for(int k=0;k<equipArgValMsgNum;k++){//装备属性值
- sb.append("{\"id\":\""+equipArgValMsg.split(";")[k].split(",")[1]+"\",\"parentId\":\""+deptId+","+idAndParentId+","+"1"+"\",\"name\":\""+equipArgValMsg.split(";")[k].split(",")[0]+"\","+
- "\"appendMsg\":\""+deptName+"-发电机-"+equipArg.split(";")[j].split(",")[0]+":"+equipArgValMsg.split(";")[k].split(",")[0]+"\","+//XX供电局-发电车-属性:属性值
- "\"deptMsg\":\""+deptId+","+deptName+","+"发电机"+"\","+//单位ID,单位NAME,装备类型,,,
- "\"queryEquipNum_JK\":\""+
- gqjlxId+","+//工器具类型ID
- unitcode+","+//单位编码
- equipArgValMsg.split(";")[k].split(",")[1]+","+//属性值ID
- equipArgValMsg.split(";")[k].split(",")[2]+","+//属性
- equipArgValMsg.split(";")[k].split(",")[0]+//属性值
- "\"},");//第五级--装备属性值(queryEquipNum_JK:工器具类型ID,单位编码,属性值ID,属性,属性值)
- }
- }
- }//else if("2".endsWith(equipTypes.split(",")[i])){}
- }
- }
- if(sb.lastIndexOf(",") > -1){
- sb.deleteCharAt(sb.lastIndexOf(","));
- }
- sb.append("]}");
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- try {
- if(rs!=null)
- rs.close();
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- //System.out.println("///////////****************"+sb.toString());
- return sb.toString();
- }
-
-
-
-
-
- }
|