123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892 |
- /**
- *
- */
- 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<DataContent> 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<String[]> listG = new ArrayList<String[]>();
- 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();
- }
- }
|