YtiotVCompanyServiceImpl.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. package cn.com.usky.iot.outcrypackage.service;
  2. import java.text.SimpleDateFormat;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import cn.com.usky.iot.admin.dao.YtiotTAdminDao;
  7. import cn.com.usky.iot.company.dao.YtiotVCompanyDao;
  8. import cn.com.usky.iot.entity.YtiotTAdmin;
  9. import cn.com.usky.iot.entity.YtiotVCompany;
  10. import cn.com.usky.iot.entity.YtiotVCompanyId;
  11. import cn.com.usky.utils.MD5Util;
  12. import net.sf.json.JSONArray;
  13. import net.sf.json.JSONObject;
  14. public class YtiotVCompanyServiceImpl implements YtiotVCompanyService {
  15. private YtiotVCompanyDao ytiotVCompanyDao;
  16. private YtiotTAdminDao ytiotTAdminDao;
  17. public YtiotVCompanyDao getYtiotVCompanyDao() {
  18. return ytiotVCompanyDao;
  19. }
  20. public void setYtiotVCompanyDao(YtiotVCompanyDao ytiotVCompanyDao) {
  21. this.ytiotVCompanyDao = ytiotVCompanyDao;
  22. }
  23. public YtiotTAdminDao getYtiotTAdminDao() {
  24. return ytiotTAdminDao;
  25. }
  26. public void setYtiotTAdminDao(YtiotTAdminDao ytiotTAdminDao) {
  27. this.ytiotTAdminDao = ytiotTAdminDao;
  28. }
  29. public boolean chk_string_param(String param) {
  30. if(param==null)
  31. return true;
  32. if(param.indexOf("=")>=0)
  33. return false;
  34. if(param.indexOf("\'")>=0)
  35. return false;
  36. if(param.indexOf("\"")>=0)
  37. return false;
  38. return true;
  39. }
  40. public String chkhw(String hqlwhere){
  41. if(hqlwhere==null)
  42. return " where ";
  43. else
  44. return hqlwhere+" and ";
  45. }
  46. public String fieldname(String field){
  47. if(field.equals("building_id"))
  48. return "buildingId";
  49. if(field.equals("building_name"))
  50. return "buildingName";
  51. if(field.equals("create_man"))
  52. return "createMan";
  53. if(field.equals("create_time"))
  54. return "createTime";
  55. if(field.equals("owner_address"))
  56. return "ownerAddress";
  57. if(field.equals("owner_id"))
  58. return "ownerId";
  59. if(field.equals("owner_man"))
  60. return "ownerMan";
  61. if(field.equals("owner_name"))
  62. return "ownerName";
  63. if(field.equals("owner_office"))
  64. return "ownerOffice";
  65. return field;
  66. }
  67. @Override
  68. public String getVCompanyList(String queryJson, String page, String start, String limit, String sort)
  69. throws Exception {
  70. // TODO Auto-generated method stub
  71. String addr1=null, addr2=null, addr3=null;
  72. String addr1list=null, addr2list=null, addr3list=null;
  73. String address=null, building_id=null, building_name=null, create_man=null;
  74. String data1=null, data2=null, data3=null, fulladdress=null;
  75. String h5=null, hls=null, id=null, owner_address=null;
  76. String owner_id=null, owner_man=null, owner_name=null;
  77. String owner_id_list=null, building_id_list=null;
  78. String owner_office=null, rtmp=null, xmlx=null, xmlx_list=null;
  79. String hqlwhere = null;
  80. String order = null;
  81. String dir = null;
  82. String Start = null;
  83. String Limit = null;
  84. String Page = null;
  85. String order_str = null;
  86. JSONObject q_json = null;
  87. JSONArray Sort = null;
  88. JSONArray jSONArray = new JSONArray();
  89. JSONObject json = new JSONObject();
  90. json.put("action", "getVCompanyList");
  91. // System.out.println(queryJson);
  92. if(queryJson!=null) {
  93. q_json = JSONObject.fromObject(queryJson);
  94. if(q_json.has("addr1")) {
  95. if(((JSONObject) q_json.get("addr1")).isArray())
  96. {
  97. JSONArray j_tmp = q_json.getJSONArray("addr1");
  98. for(int i=0;i<j_tmp.size();i++)
  99. {
  100. String tmp = j_tmp.getString(i);
  101. if(i==0)
  102. addr1list = tmp;
  103. else
  104. addr1list += ","+tmp;
  105. }
  106. }else
  107. addr1 = q_json.getString("addr1");
  108. }
  109. if(q_json.has("addr2")) {
  110. if(((JSONObject) q_json.getJSONObject("addr2")).isArray())
  111. {
  112. JSONArray j_tmp = q_json.getJSONArray("addr2");
  113. for(int i=0;i<j_tmp.size();i++)
  114. {
  115. String tmp = j_tmp.getString(i);
  116. if(i==0)
  117. addr2list = tmp;
  118. else
  119. addr2list += ","+tmp;
  120. }
  121. }else
  122. addr2 = q_json.getString("addr2");
  123. }
  124. if(q_json.has("addr3")) {
  125. if(((JSONObject)q_json.getJSONObject("addr3")).isArray())
  126. {
  127. JSONArray j_tmp = q_json.getJSONArray("addr3");
  128. for(int i=0;i<j_tmp.size();i++)
  129. {
  130. String tmp = j_tmp.getString(i);
  131. if(i==0)
  132. addr3list = tmp;
  133. else
  134. addr3list += ","+tmp;
  135. }
  136. }else
  137. addr3 = q_json.getString("addr3");
  138. }
  139. address = q_json.has("address")?q_json.getString("address"):null;
  140. if(q_json.has("building_id")) {
  141. if(((JSONObject)q_json.getJSONObject("building_id")).isArray())
  142. {
  143. JSONArray j_tmp = q_json.getJSONArray("building_id");
  144. for(int i=0;i<j_tmp.size();i++)
  145. {
  146. String tmp = j_tmp.getString(i);
  147. if(i==0)
  148. building_id_list = tmp;
  149. else
  150. building_id_list += ","+tmp;
  151. }
  152. }else
  153. building_id = q_json.getString("building_id");
  154. }
  155. building_name = q_json.has("building_name")?q_json.getString("building_name"):null;
  156. create_man = q_json.has("create_man")?q_json.getString("create_man"):null;
  157. data1 = q_json.has("data1")?q_json.getString("data1"):null;
  158. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  159. data3 = q_json.has("data3")?q_json.getString("data3"):null;
  160. fulladdress = q_json.has("fulladdress")?q_json.getString("fulladdress"):null;
  161. id = q_json.has("id")?q_json.getString("id"):null;
  162. if(q_json.has("owner_id"))
  163. {
  164. if(((JSONObject)q_json.getJSONObject("owner_id")).isArray())
  165. {
  166. JSONArray j_tmp = q_json.getJSONArray("owner_id");
  167. for(int i=0;i<j_tmp.size();i++)
  168. {
  169. String tmp = j_tmp.getString(i);
  170. if(i==0)
  171. owner_id_list = tmp;
  172. else
  173. owner_id_list += ","+tmp;
  174. }
  175. }else
  176. owner_id = q_json.getString("owner_id");
  177. }
  178. owner_address = q_json.has("owner_address")?q_json.getString("owner_address"):null;
  179. owner_office = q_json.has("owner_office")?q_json.getString("owner_office"):null;
  180. if(q_json.has("xmlx")) {
  181. if(((JSONObject)q_json.getJSONObject("xmlx")).isArray()) {
  182. JSONArray j_tmp = q_json.getJSONArray("xmlx");
  183. for(int i=0;i<j_tmp.size();i++) {
  184. String tmp = j_tmp.getString(i);
  185. if(i==0)
  186. xmlx_list = "'"+tmp+"'";
  187. else
  188. xmlx_list += ",'"+tmp+"'";
  189. }
  190. }else
  191. xmlx = q_json.getString("xmlx");
  192. }
  193. xmlx = q_json.has("xmlx")?q_json.getString("xmlx"):null;
  194. order = q_json.has("order")?q_json.getString("order"):null;
  195. dir = q_json.has("dir")?q_json.getString("dir"):null;
  196. Start = q_json.has("start")?q_json.getString("start"):(start!=null)?start:"0";
  197. Limit = q_json.has("limit")?q_json.getString("limit"):(limit!=null)?limit:null;
  198. Page = q_json.has("page")?q_json.getString("page"):(page!=null)?page:"0";
  199. //json.put("query", queryJson);
  200. }
  201. if(sort!=null) {
  202. Sort = JSONArray.fromObject(sort);
  203. if((Sort.isArray())&&(Sort.size()>0)) {
  204. JSONObject s_json = Sort.getJSONObject(0);
  205. order = s_json.has("property")?s_json.getString("property"):order;
  206. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  207. }
  208. json.put("sort", sort);
  209. }
  210. Start = start;
  211. Limit = limit;
  212. Page = page;
  213. if(addr1!=null)
  214. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" like '%"+addr1+"%' ";
  215. if(addr1list!=null)
  216. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" in ("+addr1list+") ";
  217. if(addr2!=null)
  218. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" like '%"+addr2+"%' ";
  219. if(addr2list!=null)
  220. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" in ("+addr2list+") ";
  221. if(addr3!=null)
  222. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" like '%"+addr3+"%' ";
  223. if(addr3list!=null)
  224. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" in ("+addr3list+") ";
  225. if(address!=null)
  226. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("address")+" like '%"+address+"%' ";
  227. if(building_id!=null)
  228. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" like '%"+building_id+"%' ";
  229. if(building_id_list!=null)
  230. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" in ("+building_id_list+") ";
  231. if(building_name!=null)
  232. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_name")+" like '%"+building_name+"%' ";
  233. if(create_man!=null)
  234. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("create_man")+" like '%"+create_man+"%' ";
  235. if(data1!=null)
  236. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data1")+" like '%"+data1+"%' ";
  237. if(data2!=null)
  238. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data2")+" like '%"+data2+"%' ";
  239. if(data3!=null)
  240. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data3")+" like '%"+data3+"%' ";
  241. if(fulladdress!=null)
  242. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("fulladdress")+" like '%"+fulladdress+"%' ";
  243. if(id!=null)
  244. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("id")+" = '"+id+"' ";
  245. if(owner_id!=null)
  246. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" = "+owner_id+" ";
  247. if(owner_id_list!=null)
  248. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_list+") ";
  249. if(owner_address!=null)
  250. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_address")+" like '%"+owner_address+"%' ";
  251. if(owner_office!=null)
  252. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_office")+" like '%"+owner_office+"%' ";
  253. if(xmlx!=null)
  254. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" like '%"+xmlx+"%' ";
  255. if(xmlx_list!=null)
  256. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" in ("+xmlx_list+") ";
  257. if(order!=null)
  258. order_str = " order by u.id."+fieldname(order);
  259. else
  260. order_str = " order by u.id."+fieldname("id");
  261. int totalCount = ytiotVCompanyDao.getCount(hqlwhere);
  262. //System.out.println(totalCount);
  263. json.put("totalCount", totalCount);
  264. if(Start!=null){
  265. if(Integer.parseInt(Start)>totalCount){
  266. Start = "0";
  267. Page = "0";
  268. }
  269. if(page==null)
  270. Page="0";
  271. }else{
  272. Start = "0";
  273. Page = "0";
  274. }
  275. json.put("page", Page);
  276. json.put("start", Start);
  277. json.put("limit", Limit);
  278. if(totalCount>0) {
  279. List list = ytiotVCompanyDao.query(hqlwhere, order_str, dir, Start, Limit);
  280. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  281. if(list.size()>0) {
  282. for(int i=0;i<list.size();i++) {
  283. YtiotVCompany o = (YtiotVCompany)list.get(i);
  284. YtiotVCompanyId Id = o.getId();
  285. Map map = new HashMap();
  286. map.put("addr1", Id.getAddr1());
  287. map.put("addr2", Id.getAddr2());
  288. map.put("addr3", Id.getAddr3());
  289. map.put("address", Id.getAddress());
  290. map.put("building_id", Id.getBuildingId());
  291. map.put("building_name", Id.getBuildingName());
  292. map.put("create_man", Id.getCreateMan());
  293. map.put("create_time", df.format(Id.getCreateTime()));
  294. map.put("data1", Id.getData1());
  295. map.put("data2", Id.getData2());
  296. map.put("data3", Id.getData3());
  297. map.put("fulladdress", Id.getFulladdress());
  298. map.put("h5", Id.getH5());
  299. map.put("hls", Id.getHls());
  300. map.put("id", Id.getId());
  301. map.put("owner_address", Id.getOwnerAddress());
  302. map.put("owner_id", Id.getOwnerId());
  303. map.put("owner_man", Id.getOwnerMan());
  304. map.put("owner_name", Id.getOwnerName());
  305. map.put("owner_office", Id.getOwnerOffice());
  306. map.put("position", Id.getPosition());
  307. map.put("rtmp", Id.getRtmp());
  308. map.put("xmlx", Id.getXmlx());
  309. JSONObject jSONObject = JSONObject.fromObject(map);
  310. jSONArray.add(jSONObject);
  311. }
  312. json.put("RESULT", jSONArray);
  313. }
  314. }
  315. return json.toString();
  316. }
  317. @Override
  318. public String getVCompanyNameList(String queryJson) throws Exception {
  319. // TODO Auto-generated method stub
  320. String addr1=null, addr2=null, addr3=null;
  321. String addr1list=null, addr2list=null, addr3list=null;
  322. String address=null, building_id=null, building_name=null, create_man=null;
  323. String data1=null, data2=null, data3=null, fulladdress=null;
  324. String h5=null, hls=null, id=null, owner_address=null;
  325. String owner_id=null, owner_man=null, owner_name=null;
  326. String owner_id_list=null, building_id_list=null;
  327. String owner_office=null, rtmp=null, xmlx=null, xmlx_list=null;
  328. String V_LOGINNAME = null;
  329. String V_PASSWORD = null;
  330. int E_STATUS=-1;
  331. String hqlwhere = null;
  332. JSONObject q_json = null;
  333. JSONArray Sort = null;
  334. JSONArray jSONArray = new JSONArray();
  335. JSONObject json = new JSONObject();
  336. json.put("action", "getVCompanyNameList");
  337. // System.out.println(queryJson);
  338. if(queryJson!=null) {
  339. q_json = JSONObject.fromObject(queryJson);
  340. if(q_json.has("addr1")) {
  341. if(((JSONObject) q_json.get("addr1")).isArray())
  342. {
  343. JSONArray j_tmp = q_json.getJSONArray("addr1");
  344. for(int i=0;i<j_tmp.size();i++)
  345. {
  346. String tmp = j_tmp.getString(i);
  347. if(i==0)
  348. addr1list = tmp;
  349. else
  350. addr1list += ","+tmp;
  351. }
  352. }else
  353. addr1 = q_json.getString("addr1");
  354. }
  355. if(q_json.has("addr2")) {
  356. if(((JSONObject) q_json.getJSONObject("addr2")).isArray())
  357. {
  358. JSONArray j_tmp = q_json.getJSONArray("addr2");
  359. for(int i=0;i<j_tmp.size();i++)
  360. {
  361. String tmp = j_tmp.getString(i);
  362. if(i==0)
  363. addr2list = tmp;
  364. else
  365. addr2list += ","+tmp;
  366. }
  367. }else
  368. addr2 = q_json.getString("addr2");
  369. }
  370. if(q_json.has("addr3")) {
  371. if(((JSONObject)q_json.getJSONObject("addr3")).isArray())
  372. {
  373. JSONArray j_tmp = q_json.getJSONArray("addr3");
  374. for(int i=0;i<j_tmp.size();i++)
  375. {
  376. String tmp = j_tmp.getString(i);
  377. if(i==0)
  378. addr3list = tmp;
  379. else
  380. addr3list += ","+tmp;
  381. }
  382. }else
  383. addr3 = q_json.getString("addr3");
  384. }
  385. address = q_json.has("address")?q_json.getString("address"):null;
  386. if(q_json.has("building_id")) {
  387. if(((JSONObject)q_json.getJSONObject("building_id")).isArray())
  388. {
  389. JSONArray j_tmp = q_json.getJSONArray("building_id");
  390. for(int i=0;i<j_tmp.size();i++)
  391. {
  392. String tmp = j_tmp.getString(i);
  393. if(i==0)
  394. building_id_list = tmp;
  395. else
  396. building_id_list += ","+tmp;
  397. }
  398. }else
  399. building_id = q_json.getString("building_id");
  400. }
  401. building_name = q_json.has("building_name")?q_json.getString("building_name"):null;
  402. create_man = q_json.has("create_man")?q_json.getString("create_man"):null;
  403. data1 = q_json.has("data1")?q_json.getString("data1"):null;
  404. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  405. data3 = q_json.has("data3")?q_json.getString("data3"):null;
  406. fulladdress = q_json.has("fulladdress")?q_json.getString("fulladdress"):null;
  407. id = q_json.has("id")?q_json.getString("id"):null;
  408. if(q_json.has("owner_id"))
  409. {
  410. if(((JSONObject)q_json.getJSONObject("owner_id")).isArray())
  411. {
  412. JSONArray j_tmp = q_json.getJSONArray("owner_id");
  413. for(int i=0;i<j_tmp.size();i++)
  414. {
  415. String tmp = j_tmp.getString(i);
  416. if(i==0)
  417. owner_id_list = tmp;
  418. else
  419. owner_id_list += ","+tmp;
  420. }
  421. }else
  422. owner_id = q_json.getString("owner_id");
  423. }
  424. owner_address = q_json.has("owner_address")?q_json.getString("owner_address"):null;
  425. owner_office = q_json.has("owner_office")?q_json.getString("owner_office"):null;
  426. if(q_json.has("xmlx")) {
  427. if(((JSONObject)q_json.getJSONObject("xmlx")).isArray()) {
  428. JSONArray j_tmp = q_json.getJSONArray("xmlx");
  429. for(int i=0;i<j_tmp.size();i++) {
  430. String tmp = j_tmp.getString(i);
  431. if(i==0)
  432. xmlx_list = "'"+tmp+"'";
  433. else
  434. xmlx_list += ",'"+tmp+"'";
  435. }
  436. }else
  437. xmlx = q_json.getString("xmlx");
  438. }
  439. xmlx = q_json.has("xmlx")?q_json.getString("xmlx"):null;
  440. //json.put("query", queryJson);
  441. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  442. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  443. }
  444. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  445. List list = ytiotTAdminDao.query(" where u.VLoginname='"+V_LOGINNAME+"' and u.VPassword='"
  446. +V_PASSWORD+"' ", null, null, null, null);
  447. if(list.size()>0) {
  448. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  449. E_STATUS = Integer.parseInt(o.getEStatus());
  450. }
  451. }
  452. if(addr1!=null)
  453. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" like '%"+addr1+"%' ";
  454. if(addr1list!=null)
  455. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" in ("+addr1list+") ";
  456. if(addr2!=null)
  457. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" like '%"+addr2+"%' ";
  458. if(addr2list!=null)
  459. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" in ("+addr2list+") ";
  460. if(addr3!=null)
  461. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" like '%"+addr3+"%' ";
  462. if(addr3list!=null)
  463. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" in ("+addr3list+") ";
  464. if(address!=null)
  465. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("address")+" like '%"+address+"%' ";
  466. if(building_id!=null)
  467. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" like '%"+building_id+"%' ";
  468. if(building_id_list!=null)
  469. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" in ("+building_id_list+") ";
  470. if(building_name!=null)
  471. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_name")+" like '%"+building_name+"%' ";
  472. if(create_man!=null)
  473. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("create_man")+" like '%"+create_man+"%' ";
  474. if(data1!=null)
  475. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data1")+" like '%"+data1+"%' ";
  476. if(data2!=null)
  477. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data2")+" like '%"+data2+"%' ";
  478. if(data3!=null)
  479. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data3")+" like '%"+data3+"%' ";
  480. if(fulladdress!=null)
  481. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("fulladdress")+" like '%"+fulladdress+"%' ";
  482. if(id!=null)
  483. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("id")+" = '"+id+"' ";
  484. if(owner_id!=null)
  485. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" = "+owner_id+" ";
  486. if(owner_id_list!=null)
  487. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_list+") ";
  488. if(owner_address!=null)
  489. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_address")+" like '%"+owner_address+"%' ";
  490. if(owner_office!=null)
  491. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_office")+" like '%"+owner_office+"%' ";
  492. if(xmlx!=null)
  493. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" like '%"+xmlx+"%' ";
  494. if(xmlx_list!=null)
  495. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" in ("+xmlx_list+") ";
  496. int totalCount = ytiotVCompanyDao.getCount(hqlwhere);
  497. json.put("totalCount", totalCount);
  498. if(totalCount>0) {
  499. List list = ytiotVCompanyDao.query(hqlwhere, null, null, null, null);
  500. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  501. if(list.size()>0) {
  502. for(int i=0;i<list.size();i++) {
  503. YtiotVCompany o = (YtiotVCompany)list.get(i);
  504. YtiotVCompanyId Id = o.getId();
  505. Map map = new HashMap();
  506. map.put("owner_id", Id.getOwnerId());
  507. map.put("owner_name", Id.getOwnerName());
  508. map.put("xmlx", Id.getXmlx());
  509. JSONObject jSONObject = JSONObject.fromObject(map);
  510. jSONArray.add(jSONObject);
  511. }
  512. json.put("RESULT", jSONArray);
  513. }
  514. }
  515. return json.toString();
  516. }
  517. }