123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638 |
- package com.sinosoft.common.excel;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import java.util.Vector;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import org.apache.log4j.Logger;
- import org.apache.poi.hssf.usermodel.HSSFCell;
- import org.apache.poi.hssf.usermodel.HSSFDateUtil;
- import org.apache.poi.hssf.usermodel.HSSFRow;
- import org.apache.poi.hssf.usermodel.HSSFSheet;
- import org.apache.poi.hssf.usermodel.HSSFWorkbook;
- import org.apache.poi.poifs.filesystem.POIFSFileSystem;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.DateUtil;
- import org.apache.poi.xssf.usermodel.XSSFCell;
- import org.apache.poi.xssf.usermodel.XSSFRow;
- import org.apache.poi.xssf.usermodel.XSSFSheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import com.formaction.Parameter;
- import com.formaction.Utils;
- 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.lz.system.util.JsonUtil;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- /**
- * 读取Excel将数据返回到頁面
- *
- * @author 徐威
- *
- */
- @Path("/findPlanInfo/")
- public class findPlanInfo {
- private static final Logger log = Logger.getLogger(findPlanInfo.class);
- @ProduceMime("application/json")
- @POST
- @Path("/getTeamExcel")
- public String readExcelByName(String params) throws Exception {
- findPlanInfo tool = new findPlanInfo();
- String fileName=Utils.getParameter("fileName", params) == null ? "" : Utils.getParameter(
- "fileName", params);
- // String fileName="E:\\javaDemo\\person.xls";
- int i=fileName.lastIndexOf(".");
- String type=fileName.substring(i+1);
- log.info("fileName===="+fileName);
- String result="";
- if("xls".equals(type)){
- result=tool.readExcel(fileName,"person");
- }else if("xlsx".equals(type)){
- result= tool.readExcel2007(fileName,"person");
- }
- result="{\"rows\":"+result+"}";
- log.info(result);
- return result;
- }
-
- // public void readExcel2007(DBModel dbConn, String filePath, String tableName)
- @SuppressWarnings({ "unchecked", "resource", "unused", "rawtypes" })
- public String readExcel2007( String filePath, String tableName)
- throws Exception {
- String result="";
- try {
- // InputStream inp = new FileInputStream(filePath);
- // Workbook wb = WorkbookFactory.create(inp);
- XSSFWorkbook wb = new XSSFWorkbook(filePath);
- int sheetSize = wb.getNumberOfSheets();
- // for (int i = 0; i < sheetSize; i++) {
- List list=new ArrayList();
- XSSFSheet sheet = wb.getSheetAt(0);
- // Sheet sheet = wb.getSheetAt(i);
- for (Iterator rit = sheet.rowIterator(); rit.hasNext();) {
- // 迭代行
- XSSFRow row = (XSSFRow) rit.next();
- // 迭代单元格
- Vector datas = new Vector();
- StringBuffer sb=new StringBuffer();
- Map<String, String>lineMap=new HashMap<String, String>();
- for (Iterator cit = row.cellIterator(); cit.hasNext();) {
- // 定义集合datas用于存Excel中一个行的数据
- XSSFCell cell = (XSSFCell) cit.next();
- String value = getValue2007(cell);
- sb.append(value+"|");
- // 注意行和列是基于0索引的
- // System.out.print(cell.getRowIndex() + ":" + cell.getColumnIndex() + " ");
- datas.add(value);
- // System.out.println();
- // 开始操作单元格
- }
- String[] arr=sb.toString().split("[|]");
- list.add(arr);
- // result = fillMap(list);;
- // 向表中插入数据
- // DBFactory.insertData(dbConn, tableName, datas);
- }
- result = fillMap(list);
- System.out.println(result);
- // }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- throw e;
- } catch (IOException e) {
- e.printStackTrace();
- throw e;
- }
- return result;
- }
-
- /**
- * 將数据转换成json
- * @param list
- * @return
- */
- public String fillMap(List<String[]> list){
-
- List<Map<String, String>>dataList=new ArrayList<Map<String,String>>();
- for(int i=0;i<list.size();i++){
- Map<String, String>tempMap=new HashMap<String, String>();
- String[]arr=list.get(i);
- tempMap.put("TEAM_SYSTEM_261", arr[0]);
- tempMap.put("", arr[1]);
- tempMap.put("TEAM_COMP_ID_261", arr[2]);
- tempMap.put("TEAM_NAME_261", arr[3]);
- tempMap.put("TEAM_TYPE_261", arr[4]);
- tempMap.put("TEAM_STAT_261", arr[5]);
- tempMap.put("TEAM_AEAR_261", arr[6]);
- tempMap.put("TEAM_ADDRESS_261", arr[7]);
- tempMap.put("TEAM_LEADER_261", arr[8]);
- tempMap.put("TEAM_TEL_261", arr[9]);
- tempMap.put("TEAM_PHONE_261", arr[10]);
- tempMap.put("TEAM_OFFICE_TEL_261", arr[11]);
- tempMap.put("TEAM_MEMBER_NUMBER_261", arr[12]);
- tempMap.put("TEAM_MEMBER_INFO_261", arr[13]);
- tempMap.put("TEAM_LEVEL_261", arr[14]);
- tempMap.put("TEAM_SPECIALITY_261", arr[15]);
- dataList.add(tempMap);
- }
- String result=JsonUtil.list2json(dataList);
- return result;
- }
-
-
-
- /**
- * 将Excel数据导入到表中
- *
- * @param filePath
- * Excel路径
- * @param tableName
- * 表名
- */
- // public void readExcel(DBModel dbConn, String filePath, String tableName)
- @SuppressWarnings({ "rawtypes", "unchecked", "resource", "deprecation" })
- public String readExcel( String filePath, String tableName)
- throws Exception {
- String result="";
- try {
- POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream( filePath));
- // 创建工作簿
- HSSFWorkbook workBook = new HSSFWorkbook(fs);
- log.info(workBook.getNumberOfSheets());
- // System.out.println("工作表个数 :" + workBook.getNumberOfSheets());
- for (int i = 0; i < workBook.getNumberOfSheets(); i++) {
- // 创建工作表
- HSSFSheet sheet = workBook.getSheetAt(i);
- int rows = sheet.getPhysicalNumberOfRows(); // 获得行数
- if (rows > 0) {
- sheet.getMargin(HSSFSheet.TopMargin);
- List list=new ArrayList();
- for (int r = 0; r < rows; r++) { // 行循环
- HSSFRow row = sheet.getRow(r);
- if (row != null && r != 0) {// 不取第一行
- int cells = row.getLastCellNum();// 获得列数
- // 定义集合datas用于存Excel中一个行的数据
- Vector datas = new Vector();
- String[]arr=new String[cells];
- List<String>paramList=new ArrayList<String>();
- for (short c = 0; c < cells; c++) { // 列循环
- HSSFCell cell = row.getCell(c);
- if (cell != null) {
- String value = getValue(cell);
- // System.out.println("第" + r + "行 " + "第" + c + "列:" + value);
- datas.add(value);
- paramList.add(value);
- arr[c]=value;
- }
- }
- list.add(arr);
- result = fillMap(list);
- // dataIntoDb(tableName, paramList);
- // 向表中插入数据
- // DBFactory.insertData(dbConn, tableName, datas);
- }
- }
- } else {
-
- }
- }
-
- } catch (Exception ex) {
- ex.printStackTrace();
- log.info(ex);
- throw ex;
- }
- return result;
- }
-
- public String getValue2007(XSSFCell cell) {
- String value = "";
- switch (cell.getCellType()) {
- case Cell.CELL_TYPE_STRING:
- // System.out.println(cell.getRichStringCellValue().getString());
- break;
- case Cell.CELL_TYPE_NUMERIC:
- if (DateUtil.isCellDateFormatted(cell)) {
- // System.out.println(cell.getDateCellValue());
- java.util.Date date = cell.getDateCellValue();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- value = format.format(date);
- } else {
- // System.out.println(cell.getNumericCellValue());
- value = String.valueOf(cell.getNumericCellValue());
- }
- break;
- case Cell.CELL_TYPE_BOOLEAN:
- // System.out.println(cell.getBooleanCellValue());
- value = " " + cell.getBooleanCellValue();
- break;
- case Cell.CELL_TYPE_FORMULA:
- // System.out.println(cell.getCellFormula());
- value = cell.getCellFormula();
- break;
- default:
- System.out.println();
- }
- return value;
- }
-
- /**
- * 获取Excel中某个单元格的值
- *
- * @param cell
- * @return
- * @throws ParseException
- */
- @SuppressWarnings("deprecation")
- public String getValue(HSSFCell cell) throws ParseException {
- String value = "";
- switch (cell.getCellType()) {
- case HSSFCell.CELL_TYPE_NUMERIC: // 数值型
- System.out.println("数字类型");
- if (HSSFDateUtil.isCellDateFormatted(cell)) {
- // 如果是date类型则 ,获取该cell的date值
- value = HSSFDateUtil.getJavaDate(cell.getNumericCellValue())
- .toString();
- java.util.Date date1 = new Date(value);
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- value = format.format(date1);
- } else {// 纯数字
- value = String.valueOf(cell.getNumericCellValue()).split("[.]")[0];
- }
- break;
- /* 此行表示单元格的内容为string类型 */
- case HSSFCell.CELL_TYPE_STRING: // 字符串型
- value = cell.getStringCellValue();
- break;
- case HSSFCell.CELL_TYPE_FORMULA:// 公式型
- // 读公式计算值
- value = String.valueOf(cell.getNumericCellValue());
- if (value.equals("NaN")) {// 如果获取的数据值为非法值,则转换为获取字符串
- value = cell.getStringCellValue().toString();
- }
- cell.getCellFormula();
- break;
- case HSSFCell.CELL_TYPE_BOOLEAN:// 布尔
- value = " " + cell.getBooleanCellValue();
- break;
- /* 此行表示该单元格值为空 */
- case HSSFCell.CELL_TYPE_BLANK: // 空值
- value = "";
- break;
- case HSSFCell.CELL_TYPE_ERROR: // 故障
- value = "";
- break;
- default:
- value = cell.getStringCellValue().toString();
- }
- return value;
- }
-
-
- // public boolean dataIntoDb(String tabName,List<String>list) throws ClassNotFoundException, SQLException{
- // Class.forName("dm.jdbc.driver.DmDriver");
- // Connection conn = DriverManager.getConnection("jdbc:dm://192.168.1.16:5236","NWYJ","NWYJ123456");
- // String sql="INSERT INTO SYS_MSG_MODEL(FD_OBJECTID,MSG_MODEL_TYPE,MSG_MODEL_CONTENT,MSG_MODEL_RANGE,MSG_MODEL_COMP,MSG_MODEL_USER,MSG_MODEL_TIME,IS_DEL)VALUES(?,?,?,?,?,?,?,?)";
- // PreparedStatement ps=null;
- // conn.setAutoCommit(false);
- // ps = conn.prepareStatement(sql);
- // ps.setString(1, (long) ((Math.random()+1)*1000000000)+"");
- // ps.setString(2, list.get(0));
- // ps.setString(3,list.get(1));
- // ps.setString(4, list.get(2));
- // ps.setString(5, list.get(3));
- // ps.setString(6, list.get(4));
- // ps.setString(7, list.get(5));
- // ps.setString(8,list.get(6));
- // int k=ps.executeUpdate();
- // conn.commit();
- //// System.out.println("k====="+k);
- // return false;
- // }
-
-
- /**
- * 将界面传输过来的数据保存到数据库
- * @param params
- * @return
- * @throws ClassNotFoundException
- */
- @SuppressWarnings("static-access")
- @ProduceMime("application/json")
- @POST
- @Path("/teamToDb")
- public Msg expertToDb(String params) throws ClassNotFoundException{
- Msg m=new Msg();
- String json = Utils.getParameter("json", params) == null ? "" : Utils.getParameter(
- "json", params);
- log.info("json===" + json);
- String classId = Utils.getParameter("classId", params) == null ? "" : Utils
- .getParameter("classId", params);
- log.info("classId===" + classId);
- json=json.replace("_"+classId, "");
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<TeamBean> list = JsonPluginsUtil.jsonToBeanList(json, TeamBean.class);
- String sql="INSERT INTO ECM_AM_EMERGENCY_TEAM (FD_OBJECTID,TEAM_SYSTEM,TEAM_COMP_ID,TEAM_NAME,TEAM_TYPE,"
- + "TEAM_STAT,TEAM_AEAR,TEAM_ADDRESS,TEAM_LEADER,TEAM_TEL,TEAM_PHONE,TEAM_OFFICE_TEL,"
- + "TEAM_MEMBER_NUMBER,TEAM_MEMBER_INFO,TEAM_LEVEL,TEAM_SPECIALITY, "
- + "UPDATEDATE,IS_DEL) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<list.size();i++){
- TeamBean eb=list.get(i);
- log.info(" eb.getEXPERT_AREA()===="+ eb.getTEAM_AEAR());
- st.setString(1, createMsgId(getMsgId()));
- st.setString(2, eb.getTEAM_SYSTEM());
- st.setString(3, eb.getTEAM_COMP_ID());//队伍所属单位,以后要改成绑定登陆用户的单位id
- st.setString(4, eb.getTEAM_NAME());
- st.setString(5, eb.getTEAM_TYPE());
- st.setString(6, eb.getTEAM_STAT());
- st.setString(7, eb.getTEAM_AEAR());
- st.setString(8, eb.getTEAM_ADDRESS());
- st.setString(9, eb.getTEAM_LEADER());
- st.setString(10, eb.getTEAM_TEL());
- st.setString(11, eb.getTEAM_PHONE());
- st.setString(12, eb.getTEAM_OFFICE_TEL());
- st.setString(13, eb.getTEAM_MEMBER_NUMBER());
- // st.setString(14, eb.getTEAM_MEMBER_INFO());
- st.setString(15, eb.getTEAM_LEVEL());
- st.setString(16, eb.getTEAM_SPECIALITY());
-
- st.setString(17, formatDate(new Date()));
- st.setString(18, "0");
-
- st.executeUpdate();
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 消息保存", e);
- } finally {
- db.close(st);
- db.close(conn);
- }
-
- }
-
- public String formatDate(Date d) {
- SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
- String date = sd.format(d);
- return date;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public List<String> getMsgId() throws ClassNotFoundException {
- String sql = "SELECT FD_OBJECTID FROM ECM_AM_EMERGENCY_TEAM";
- 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;
- }
- }
-
-
- @SuppressWarnings("unused")
- public String getRootTeam(String id){//获取本单位的树数据
- StringBuffer json=new StringBuffer();//应急预案的名称和ID
- String sql="SELECT FD_OBJECTID,PLAN_NAME FROM ECM_AM_YJYASERVER WHERE IS_DEL='0' AND UNITS ='"+id+"'";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- try {
- ArrayList<String[]> teamList = persistence.getSearchResult(99, sql.toString());
- int num = teamList.size();
- if (num > 0) {
- String selRootId=UUID.randomUUID()+"";
- for (int i = 0; i < num; i++) {
- String[] temp = teamList.get(i);
- String objectId = temp[0];
- String PLAN_NAME = temp[1];
- json.append("{");
- json.append(" \"id\":\"" + objectId + "\", \"parentId\":\""+selRootId
- + "\", \"name\": \"" + PLAN_NAME
- +"\", \"isParent\": \"false"
- +"\", \"open\": \"false"
- + "\", \"icon\":\"/nwyj/scripts/qui/libs/icons/swf.gif\"");
- json.append("},");
- }
- // json.append("{");//增加本单位节点
- // json.append(" \"id\":\""+selRootId+"\", \"parentId\":\""+id
- // + "\", \"name\": \"本部"
- // +"\", \"isParent\": \"true"
- // +"\", \"open\": \"true"
- // + "\", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- // json.append("},");
- }
-
- } catch (PersistenceException e) {
- log.error("查预案异常", e);
- }
- return json.toString();
- }
-
- public String getRootJson(String id){
- String sql="SELECT NAME FROM SYS_DEPARTMENT_0827 WHERE ID='"+id+"'";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer json=new StringBuffer();
- try {
- ArrayList<String[]> teamList = persistence.getSearchResult(99, sql.toString());
- int num = teamList.size();
- if (num > 0) {
- for (int i = 0; i < num; i++) {
- if(checkTeam(id)){
- String[] temp = teamList.get(i);
- String name=temp[0];
- json.append("{");//增加本单位节点
- json.append(" \"id\":\""+id+"\", \"parentId\":\"0"
- + "\", \"name\": \""+name
- +"\", \"isParent\": \"true"
- +"\", \"open\": \"true"
- + "\", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }else{
- String[] temp = teamList.get(i);
- String name=temp[0];
- json.append("{");//增加本单位节点
- json.append(" \"id\":\""+id+"\", \"parentId\":\"0"
- + "\", \"name\": \""+name
- +"\", \"isParent\": \"false"
- +"\", \"open\": \"false"
- + "\", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }
- }
- }
- }catch(Exception e){
- log.error("查询应急预案异常", e);
- }
- return json.toString();
- }
-
- @SuppressWarnings("unused")
- public String getChildJson(String id){
- StringBuffer json=new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql="SELECT ID,NAME FROM SYS_DEPARTMENT_0827 WHERE PARENT_ID='"+id+"'";
- List<String>list=new ArrayList<String>();
- try {
- ArrayList<String[]> teamList = persistence.getSearchResult(99, sql.toString());
- int num = teamList.size();
- if (num > 0) {
- for (int i = 0; i < num; i++) {
- String[] temp = teamList.get(i);
- String name=temp[1];
- String comp_id=temp[0];
- if(checkTeam(comp_id)){
- json.append("{");//增加本单位节点
- json.append(" \"id\":\""+comp_id+"\", \"parentId\":\""+id
- + "\", \"name\": \""+name
- +"\", \"isParent\": \"true"
- +"\", \"open\": \"false"
- + "\", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- json.append("},");
- }
- // else{
- // json.append("{");//增加本单位节点
- // json.append(" \"id\":\""+comp_id+"\", \"parentId\":\""+id
- // + "\", \"name\": \""+name
- // +"\", \"isParent\": \"false"
- // +"\", \"open\": \"false"
- // + "\", \"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- // json.append("},");
- // }
- }
- }
- }catch(Exception e){
- log.error("查询预案异常", e);
- }
- return json.toString();
- }
-
- public boolean checkTeam(String id){
- String sql="SELECT * FROM ECM_AM_EMERGENCY_TEAM WHERE TEAM_COMP_ID IN(SELECT ID FROM SYS_DEPARTMENT_0827 WHERE PARENT_ID='"+id+"') OR TEAM_COMP_ID='"+id+"'";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- try {
- ArrayList<String[]> teamList = persistence.getSearchResult(99, sql.toString());
- int num = teamList.size();
- if (num > 0) {
- return true;
- }
- }catch(Exception e){
- log.error("查询队伍异常", e);
- }
- return false;
- }
-
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/getTeamByCompId/")
- public String getTeamByCompId(String params) {
- StringBuffer sb = new StringBuffer();
- log.info("传过来的参数 为"+params);
- boolean flag=false;
- sb.append("{\"treeNodes\":[");
-
- String deptid = Utils.getParameter("deptId", params) == null ? "" : Utils.getParameter(
- "deptId", params);
- String id = Utils.getParameter("id", params) == null ? "" : Utils.getParameter(
- "id", params);
- if(id==null||"".equals(id)){
- id=deptid;
- flag=true;
- }
- if(flag){
- String root=getRootJson(id);
- sb.append(root);
- }
- String rootExpert=getRootTeam(id);
- sb.append(rootExpert);
- // String childList=getChildJson(id);
- // sb.append(childList);
-
-
- if (sb.lastIndexOf(",") > -1) {
- sb.deleteCharAt(sb.lastIndexOf(","));
- }
- sb.append("]}");
- log.info("json:" + sb);
- return sb.toString();
- }
- }
|