/** * */ package com.sinosoft.lz.common.generaldata; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import javax.ws.rs.*; import net.sf.json.JSONObject; import org.apache.log4j.Logger; import com.formaction.Utils; import com.persistence.service.JDBCHelper; import com.persistence.service.PersistenceFactory; import com.persistence.service.SysPersistence; import com.persistence.service.exception.PersistenceException; import com.sysmodel.datamodel.xmlmodel.DataContent; import com.sysmodel.datamodel.xmlmodel.ModelFactory; import com.sysmodel.datamodel.xmlmodel.able.MdpClass; import com.sysmodel.datamodel.xmlmodel.able.MdpConstant; import com.sysmodel.datamodel.xmlmodel.able.SysModel; import com.sinosoft.lz.system.constant.vo.ConstantVo; import com.sinosoft.lz.system.constant.vo.ConstantVos; /** * @author IBM * */ @Path("/GeneraDataService/") public class GeneraDataService{ private final Logger log = Logger.getLogger(getClass()); /** * 查询公路局树形数据(只包括公路局(单位)) * * @return json */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/geCommonUnit") public String geCommonUnit(String params) { String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); StringBuffer sb = new StringBuffer(); String sql = "select Dept_Id ,Dept_Name,FD_OBJECTID,type from Sys_Department where Depts_Id ='" + node + "' and type in ('1','2') and DeptMent_Type in( '3','4','6','10','20') and Is_Del='0' ORDER BY DeptMent_Type DESC,SORT"; log.info("管理单位查询-----------" + sql); try { list = persistence.getSearchResult(800, sql); } catch (PersistenceException e) { log.error(e.getMessage(), e); } sb.append("["); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; String fd_objectid = rs[2] == null ? "" : rs[2]; String type = rs[3] == null ? "" : rs[3]; if (isLeaf(code)) { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } } else { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } } } } if (sb.lastIndexOf(",") > -1) { sb.deleteCharAt(sb.lastIndexOf(",")); } sb.append("]"); return sb.toString(); } /** * 查询公路局树形数据(只包括公路局(单位)) * * @return json */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/getUnitJson") public String getUnitJson(String params) { String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); StringBuffer sb = new StringBuffer(); String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='" + node + "' and t1.type in ('1','2') and t1.Is_Del='0'"; try { list = persistence.getSearchResult(800, sql); } catch (PersistenceException e) { log.error(e.getMessage(), e); } sb.append("["); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; String fd_objectid = rs[2] == null ? "" : rs[2]; String type = rs[3] == null ? "" : rs[3]; if (isLeaf(code)) { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } } else { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } } } } if (sb.lastIndexOf(",") > -1) { sb.deleteCharAt(sb.lastIndexOf(",")); } sb.append("]"); return sb.toString(); } /** * 养护巡查 综合查询 管理单位 * * @return json */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/getManagementJson") public String getManagementJson(String params) { String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); StringBuffer sb = new StringBuffer(); String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='" + node + "' and t1.deptment_type in ('1','2','10','20') and t1.Is_Del='0'"; try { list = persistence.getSearchResult(800, sql); } catch (PersistenceException e) { log.error(e.getMessage(), e); } sb.append("["); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; String fd_objectid = rs[2] == null ? "" : rs[2]; String type = rs[3] == null ? "" : rs[3]; if (isLeaf(code)) { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/p1.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/road/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } } else { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/p1.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/road/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } } } } if (sb.lastIndexOf(",") > -1) { sb.deleteCharAt(sb.lastIndexOf(",")); } sb.append("]"); return sb.toString(); } @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/getDepJson") public String getDepJson(String params) { String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); StringBuffer sb = new StringBuffer(); String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='" + node + "' and t1.type='2' and t1.Is_Del='0'"; try { list = persistence.getSearchResult(800, sql); } catch (PersistenceException e) { log.error(e.getMessage(), e); } log.info("sql: " + sql); sb.append("["); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; String fd_objectid = rs[2] == null ? "" : rs[2]; String type = rs[3] == null ? "" : rs[3]; if (isLeaf(code)) { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } } else { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } } } } if (sb.lastIndexOf(",") > -1) { sb.deleteCharAt(sb.lastIndexOf(",")); } sb.append("]"); return sb.toString(); } // 判定是否有子节点 @SuppressWarnings("rawtypes") public boolean isLeaf(String node) { boolean flag = false; SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList childList = new ArrayList(); String sql = "select distinct t1.Dept_Id from Sys_Department t1 where t1.Depts_Id ='" + node + "' and t1.type in ('1','2') and t1.Is_Del='0'"; try { childList = persistence.getSearchResult(800, sql); } catch (PersistenceException e) { log.error(e.getMessage(), e); } if (childList.size() > 0) { flag = true; } return flag; } /** * 更加单位id获取该单位的部门 * * @param 单位id * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) @ProduceMime("application/json") @POST @Path("/getDepartementJson") public String getDepartment(String params) { String unitid = Utils.getParameter("unitid", params) == null ? "" : Utils.getParameter( "unitid", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); ArrayList listvo = new ArrayList(); String sql = "select t1.Dept_Id ,t1.Dept_Name from Sys_Department t1 where t1.Depts_Id ='" + unitid + "' and t1.type='2' and t1.Is_Del='0'"; ConstantVos cvos = new ConstantVos(); try { list = persistence.getSearchResult(800, sql); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { ConstantVo cvo = new ConstantVo(); String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; cvo.setName(name); cvo.setValue(code); listvo.add(cvo); } cvos.setConstants(listvo); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } return JSONObject.fromObject(cvos).toString(); } /** * 查询宁波市行政区划树形数据 * * @return json */ @SuppressWarnings("unused") @ProduceMime("application/json") @GET @Path("/getDistJson") public String getDistJson(String params) { String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); MdpConstant mdpConstant = sysmodel.getMdpConstantByName("BM$_Dists"); List childDataContents = mdpConstant.getChildDataContentByNodeID(node); StringBuffer sb = new StringBuffer(); sb.append("["); if (childDataContents.size() > 0) { for (int i = 0; i < childDataContents.size(); i++) { DataContent fieldValue = (DataContent) childDataContents.get(i); String fd_code = (String) fieldValue.getValue("fd_code") == null ? "" : (String) fieldValue.getValue("fd_code"); String fd_Name = (String) fieldValue.getValue("fd_name") == null ? "" : (String) fieldValue.getValue("fd_name"); String fd_parentcode = (String) fieldValue.getValue("fd_parentcode") == null ? "" : (String) fieldValue.getValue("fd_parentcode"); String fd_parentname = (String) fieldValue.getValue("fd_parentname") == null ? "" : (String) fieldValue.getValue("fd_parentname"); String fd_province = (String) fieldValue.getValue("fd_province") == null ? "" : (String) fieldValue.getValue("fd_province"); String fd_city = (String) fieldValue.getValue("fd_city") == null ? "" : (String) fieldValue.getValue("fd_city"); if (mdpConstant.getChildDataContentByNodeID(fd_code).isEmpty()) { sb.append("{text:'") .append(fd_Name) .append("',id:'") .append(fd_code) .append("',fd_parentcode:'" + fd_parentcode + "',fd_province:'" + fd_province + "',fd_city:'" + fd_city + "',leaf:true},"); } else { sb.append("{text:'") .append(fd_Name) .append("',id:'") .append(fd_code) .append("',fd_parentcode:'" + fd_parentcode + "',fd_parentname:'" + fd_parentname + "',fd_province:'" + fd_province + "',fd_city:'" + fd_city + "',leaf:false},"); } } }; if (sb.lastIndexOf(",") > -1) { sb.deleteCharAt(sb.length() - 1); } sb.append("]"); return sb.toString(); } /** * 判断管理单位 路线是否重复 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/judgeRoute") public String judgeRoute(String params) { ArrayList list = new ArrayList(); int reValue = 0; try { params = java.net.URLDecoder.decode(params, "UTF-8"); String manageCode = Utils.getParameter("magCode", params);// 管理单位代码 String roadCode = Utils.getParameter("roadCode", params);// 路线代码 SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); String sql = "select FD_OBJECTID from HBI_LP_BASIC_INFO where ManagementUnit_Code='" + manageCode + "' and Road_Code='" + roadCode + "' and IS_DEL='0'"; list = persistence.getSearchResult(238, sql); if (list.size() > 0) { reValue = list.size(); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } return String.valueOf(reValue); } /** * 判断路线是否重复 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/judgeRoadCode") public String judgeRoadCode(String params) { ArrayList list = new ArrayList(); int reValue = 0; try { params = java.net.URLDecoder.decode(params, "UTF-8"); String roadCode = Utils.getParameter("roadCode", params);// 路线代码 SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); String sql = "select FD_OBJECTID from HBI_LP_INFO where Road_Code='" + roadCode + "' and IS_DEL='0'"; list = persistence.getSearchResult(238, sql); if (list.size() > 0) { reValue = list.size(); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } return String.valueOf(reValue); } /** * 根据管理单位得到 路线代码 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/getRoadByMag") public String getRoadByMag(String params) { ArrayList list = new ArrayList(); StringBuffer jsonStr = new StringBuffer(); try { params = java.net.URLDecoder.decode(params, "UTF-8"); String manageCode = Utils.getParameter("magCode", params);// 管理单位代码 SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); StringBuffer sb = new StringBuffer(); sb.append(" SELECT "); sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START , "); sb.append(" CASE when SUBSTR(Road_Code, 1, 1) = 'G' then 1 "); sb.append(" when SUBSTR(Road_Code, 1, 1) = 'S' then 2 "); sb.append(" else 3 "); sb.append(" end sequ "); sb.append(" from "); sb.append(" ( SELECT "); sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START "); sb.append(" from HBI_LP_INFO "); sb.append(" where Is_Del = '0' and (ROAD_CODE like 'G%' OR ROAD_CODE LIKE 'S%') "); sb.append(" union ALL "); sb.append(" SELECT "); sb.append(" Substr(ROAD_CODE,0,Len(ROAD_CODE)-6),ROAD_NAME,ROAD_START "); sb.append(" from HBI_LP_BASIC_INFO "); sb.append(" where ManagementUnit_Code like '" + manageCode + "%'"); sb.append(" and IS_DEL='0' and ROAD_CODE not like 'G%' "); sb.append(" and ROAD_CODE not like 'S%' "); sb.append(" )a "); sb.append(" order by sequ,ROAD_CODE "); log.info("根据管理单位查询路线:" + sb.toString()); list = persistence.getSearchResult(99, sb.toString()); jsonStr.append("{'constants':["); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { String[] data = (String[]) list.get(i); jsonStr.append("{'value':'" + data[0] + "','name':'" + data[0] + "(" + data[1] + ")'},"); } } if (jsonStr.lastIndexOf(",") > -1) { jsonStr.deleteCharAt(jsonStr.lastIndexOf(",")); } jsonStr.append("]}"); } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } return jsonStr.toString(); } /** * 判断管理单位 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/judgeMagRoadTime") public String judgeMagRoadTime(String params) { ArrayList list = new ArrayList(); int reValue = 0; try { params = java.net.URLDecoder.decode(params, "UTF-8"); String manageCode = Utils.getParameter("magCode", params);// 管理单位代码 String roadCode = Utils.getParameter("roadCode", params);// 路线代码 String roadStart = Utils.getParameter("roadStart", params);// 起点桩号 String tableName = Utils.getParameter("tableID", params);// 表名称 SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); MdpClass mapClass = sysmodel.getMdpClassByClassID(Integer.parseInt(tableName)); tableName = mapClass.getName(); String sql = "select FD_OBJECTID from " + tableName + " where MANAGEMENTUNIT_CODE='" + manageCode + "' and ROAD_CODE='" + roadCode + "' and ROAD_START='" + roadStart + "' and IS_DEL='0'"; list = persistence.getSearchResult(238, sql); if (list.size() > 0) { reValue = list.size(); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } return String.valueOf(reValue); } /** * 判断若干字段是否重复 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/judgeCommonRepeat") public String judgeCommonRepeat(String params) { ArrayList list = new ArrayList(); int reValue = 0; try { params = java.net.URLDecoder.decode(params, "UTF-8"); String condtionStr = Utils.getParameter("condtion", params);// 需要判断的字符串 String tableName = Utils.getParameter("tableID", params);// 表名称 SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); MdpClass mapClass = sysmodel.getMdpClassByClassID(Integer.parseInt(tableName)); tableName = mapClass.getName(); String[] array = condtionStr.split(","); StringBuffer conStr = new StringBuffer(); for (int i = 0; i < array.length; i++) { String[] temp = array[i].split("'"); conStr.append(" and " + temp[0] + "='" + temp[1] + "'"); } String sql = "select FD_OBJECTID from " + tableName + " where " + conStr.substring(4).toString() + " and IS_DEL='0'"; list = persistence.getSearchResult(238, sql); if (list.size() > 0) { reValue = list.size(); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } return String.valueOf(reValue); } /** * 根据管理单位得到行政区划 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/getAdminDivisionCode") public String getAdminDivisionCode(String params) { ArrayList list = new ArrayList(); String reValue = "0"; try { params = java.net.URLDecoder.decode(params, "UTF-8"); String depCode = Utils.getParameter("depId", params);// 管理单位代码 SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); String sql = "select t2.FD_CODE,t2.FD_NAME from SYS_DEPARTMENT t1,bm$_dists t2 where t1.DEPT_ID='" + depCode + "' and t1.IS_DEL='0' and t1.ROAD_DIST=t2.FD_CODE"; list = persistence.getSearchResult(238, sql); if (list.size() > 0) { String[] data = (String[]) list.get(0); reValue = data[0] + "," + data[1]; } } catch (PersistenceException e) { log.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { log.error(e.getMessage(), e); } return reValue; } /** * 查询分局管理单位名称 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings({ "rawtypes", "unchecked" }) @ProduceMime("application/json") @POST @Path("/getManagementByCode") public String getManagementByCode(String params) { String management_unit = Utils.getParameter("name", params) == null ? "" : Utils .getParameter("name", params); log.info("管理单位代码:" + management_unit); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); ArrayList listvo = new ArrayList(); String sql = "select fd_code,fd_name from BM$_MANAGEMENTUNIT where fd_code = '" + management_unit + "'"; ConstantVos cvos = new ConstantVos(); try { list = persistence.getSearchResult(99, sql); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { ConstantVo cvo = new ConstantVo(); String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; cvo.setName(name); cvo.setValue(code); listvo.add(cvo); } cvos.setConstants(listvo); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } return JSONObject.fromObject(cvos).toString(); } /** * 查询绿化管理单位名称 * * @return String * @throws UnsupportedEncodingException */ @SuppressWarnings({ "rawtypes", "unchecked" }) @ProduceMime("application/json") @POST @Path("/getManagementLhByCode") public String getManagementLhByCode(String params) { String management_unit = Utils.getParameter("name", params) == null ? "" : Utils .getParameter("name", params); log.info("管理单位代码:" + management_unit); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); ArrayList listvo = new ArrayList(); String sql = "select fd_code,fd_description from HM_LH_DFCOFFICEEXCHANGE where fd_code = '" + management_unit + "'"; ConstantVos cvos = new ConstantVos(); try { list = persistence.getSearchResult(99, sql); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { ConstantVo cvo = new ConstantVo(); String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; cvo.setName(name); cvo.setValue(code); listvo.add(cvo); } cvos.setConstants(listvo); } } catch (PersistenceException e) { log.error(e.getMessage(), e); } return JSONObject.fromObject(cvos).toString(); } /** * 养护人员管理-工作单位 */ @SuppressWarnings("rawtypes") @ProduceMime("application/json") @POST @Path("/getPersonUnitJson") public String getPersonUnitJson(String params) { String node = Utils.getParameter("node", params) == null ? "" : Utils.getParameter("node", params); String deptid = Utils.getParameter("deptid", params) == null ? "" : Utils.getParameter( "deptid", params); SysModel sysmodel = ModelFactory.getSysmodel(); SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); ArrayList list = new ArrayList(); StringBuffer sb = new StringBuffer(); String sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='" + node + "' and t1.type in ('1','2') and t1.Is_Del='0' and t1.DEPT_ID like '" + deptid + "%'"; if (node.equals("0")) { sql = "select t1.Dept_Id ,t1.Dept_Name,t1.FD_OBJECTID,t1.type from Sys_Department t1 where t1.Depts_Id ='" + node + "' and t1.type in ('1','2') and t1.Is_Del='0'"; } log.info("sql:" + sql); try { list = persistence.getSearchResult(800, sql); } catch (PersistenceException e) { log.error(e.getMessage(), e); } sb.append("["); if (!list.isEmpty()) { for (int i = 0; i < list.size(); i++) { String[] rs = (String[]) list.get(i); String code = rs[0] == null ? "" : rs[0]; String name = rs[1] == null ? "" : rs[1]; String fd_objectid = rs[2] == null ? "" : rs[2]; String type = rs[3] == null ? "" : rs[3]; if (isLeaf(code)) { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:false},"); } } else { if ("1".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/p1.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } else if ("2".equals(type)) { sb.append("{text:'" + name + "',id:'" + code + "',icon:'/yxwh/images/maintain/png-0702.png',fd_objectid:'" + fd_objectid + "',leaf:true},"); } } } } if (sb.lastIndexOf(",") > -1) { sb.deleteCharAt(sb.lastIndexOf(",")); } sb.append("]"); return sb.toString(); } /** * 方法的作用 : 根据G,S.....筛选路线 * * @param params * the params * @return json串,在combo中显示 * @author赵瑞 * @version 2013-10-29-09:15:31 */ @ProduceMime("application/json") @POST @Path("/getRoad") public String getRoad(String params) { String unitCode = Utils.getParameter("unitCode", params) == null ? "" : Utils.getParameter( "unitCode", params); String result = this.getChargeStanderTree(unitCode); return result; } /** * 方法的作用: 分配路线时,根据G,S.....筛选路线,且按照G.S.X排序 * * @param name * the name * @param codition * the codition * @return commonServiceImp - charge stander tree * @author 赵瑞 * @version 2013-10-28-09:16:44 */ public String getChargeStanderTree(String unitCode) { JDBCHelper jdbc = new JDBCHelper(); jdbc.begin(); StringBuffer sb = new StringBuffer(); ArrayList listG = new ArrayList(); try { sb.append(" SELECT "); sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START ,ROAD_END, "); sb.append(" CASE when SUBSTR(Road_Code, 1, 1) = 'G' then 1 "); sb.append(" when SUBSTR(Road_Code, 1, 1) = 'S' then 2 "); sb.append(" else 3 "); sb.append(" end sequ "); sb.append(" from "); sb.append(" ( SELECT "); sb.append(" ROAD_CODE,ROAD_NAME,ROAD_START,ROAD_END "); sb.append(" from HBI_LP_INFO "); sb.append(" where Is_Del = '0' and (ROAD_CODE like 'G%' OR ROAD_CODE LIKE 'S%') "); sb.append(" union ALL "); sb.append(" SELECT "); sb.append(" Substr(ROAD_CODE,0,Len(ROAD_CODE)-6),ROAD_NAME,ROAD_START,ROAD_END "); sb.append(" from HBI_LP_BASIC_INFO "); sb.append(" where ManagementUnit_Code like '" + unitCode + "%'"); sb.append(" and IS_DEL='0' and ROAD_CODE not like 'G%' "); sb.append(" and ROAD_CODE not like 'S%' "); sb.append(" )a "); sb.append(" order by sequ,ROAD_CODE "); log.info("sb.toString()==============" + sb.toString()); listG = jdbc.getSearchResult(99, sb.toString()); } catch (PersistenceException e) { log.error(e.getMessage(), e); } StringBuffer sb1 = new StringBuffer(); sb1.append("{\"constants\":["); for (String[] temp : listG) { String info = temp[0] + temp[1] + "(" + (temp[2] == null ? "" : temp[2]) + "~" + (temp[3] == null ? "" : temp[3] + ")"); log.info("info:" + info); sb1.append("{\"roadcode\":\"" + temp[0] + "\",\"roadname\":\"" + temp[1] + "\",\"start\":\"" + temp[2] + "\",\"end\":\"" + temp[3] + "\",\"info\":\"" + info + "\"},"); } if (sb1.lastIndexOf(",") > -1) { sb1.deleteCharAt(sb1.lastIndexOf(",")); } sb1.append("]}"); jdbc.release(); log.info("sb1.toString()=================" + sb1.toString()); return sb1.toString(); } }