1bd868fdbd7b6c7c1eb25e770b9399a5bae2e8c1.svn-base 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. package com.sinosoft.em.gps.dao;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.text.DateFormat;
  7. import java.text.ParseException;
  8. import java.text.SimpleDateFormat;
  9. import java.util.ArrayList;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Map;
  15. import net.sf.json.JSONArray;
  16. import org.apache.log4j.Logger;
  17. import org.jfree.util.Log;
  18. import com.formaction.Parameter;
  19. import com.formaction.vo.Msg;
  20. import com.google.gson.JsonArray;
  21. import com.persistence.DbConnection;
  22. import com.persistence.service.PersistenceFactory;
  23. import com.persistence.service.SysPersistence;
  24. import com.persistence.service.assitant.generator.IdentityGenerator;
  25. import com.persistence.service.exception.PersistenceException;
  26. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  27. import com.sinosoft.common.excel.JsonPluginsUtil;
  28. import com.sinosoft.common.util.DateUtil;
  29. import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDaoImpl;
  30. import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
  31. import com.sinosoft.em.gps.vo.Detp;
  32. import com.sinosoft.em.gps.vo.GPSBaoBiao;
  33. import com.sinosoft.em.gps.vo.GPSDutyMsg;
  34. import com.sinosoft.em.gps.vo.GPSTask;
  35. import com.sinosoft.em.gps.vo.GPSUserMsg;
  36. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  37. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  38. public class BaoGongDianTaskDao {
  39. StringBuffer json = new StringBuffer();
  40. private static SysModel sysmodel = ModelFactory.getSysmodel();
  41. private static SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  42. private final static Logger log = Logger.getLogger(QueryReportProgrammeDaoImpl.class);
  43. public Msg saveUser(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String task_id) throws ClassNotFoundException {
  44. Msg m=new Msg();
  45. String sql="insert into ECM_GPS_USER (FD_OBJECTID,USER_ID,USER_NAME,USER_ADDRESS,"+
  46. "POWER_SUPPLY_UNIT_NAME,IMPORTANT_USER_LEVEL,ELECTROR_TYPE,VOLTAGE_LEVEL,IS_DEL,"+
  47. "UPDATEDATE,INPUT_NAME,INPUT_TIME,INPUT_UNIT,FD_TASK,AGREEMENT_CAPACITY,LOAD_KIND,"
  48. + "OWNED_SOURCE_FLAG,OWNED_SOURCE_CAPACITY,ENXTEND) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  49. Connection conn = null;
  50. PreparedStatement st = null;
  51. DbConnection db = new DbConnection();
  52. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  53. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  54. try {
  55. conn = db.getConnection();
  56. int num=0;
  57. conn.setAutoCommit(false);
  58. st = conn.prepareStatement(sql);
  59. for (Map<String, String> map : list) {
  60. //系统当前时间
  61. Date date=new Date();
  62. String time=format.format(date);
  63. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(612);
  64. st.setString(1, fd_id);
  65. st.setString(2, map.get("USER_ID_612"));
  66. st.setString(3, map.get("USER_NAME_612"));
  67. st.setString(4, map.get("USER_ADDRESS_612"));
  68. st.setString(5, map.get("POWER_SUPPLY_UNIT_NAME_612"));
  69. st.setString(6, map.get("IMPORTANT_USER_LEVEL_612"));
  70. st.setString(7, map.get("ELECTROR_TYPE_612"));
  71. st.setString(8, map.get("VOLTAGE_LEVEL_612"));
  72. st.setString(9, "0");
  73. st.setString(10, time);
  74. st.setString(11, real_name);
  75. st.setString(12, time);
  76. st.setString(13, comp_id);
  77. st.setString(14, task_id);
  78. st.setString(15, map.get("AGREEMENT_CAPACITY_612"));
  79. st.setString(16, map.get("LOAD_KIND_612"));
  80. st.setString(17, map.get("OWNED_SOURCE_FLAG_612"));
  81. st.setString(18, map.get("OWNED_SOURCE_CAPACITY_612"));
  82. st.setString(19, map.get("ENXTEND_612"));
  83. st.executeUpdate();
  84. log.info(sql);
  85. num++;
  86. }
  87. if(num==list.size()){
  88. log.info("保存成功");
  89. conn.commit();
  90. m.setSucsess(new Boolean(true).toString());
  91. m.setInfo(Parameter.DELETE_SUCSESS);
  92. return m;
  93. }else{
  94. m.setSucsess(new Boolean(false).toString());
  95. m.setInfo(Parameter.DELETE_FAILURE);
  96. // st.executeBatch();
  97. conn.rollback();
  98. log.info("保存失败");
  99. return m;
  100. }
  101. } catch (SQLException e) {
  102. this.log.error(e.getMessage(), e);
  103. } finally {
  104. db.close(st);
  105. db.close(conn);
  106. }
  107. return m;
  108. }
  109. public Msg saveUser1(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String task_id) throws ClassNotFoundException {
  110. Msg m=new Msg();
  111. String sql="insert into NWYJ.ECM_GPS_USER1(FD_OBJECTID, KHBH, KHMC, TASK_ID, INPUT_UNIT, INPUT_USER, INPUT_TIME, UPDATEDATE, "
  112. + "IS_DEL, KHLB, GDDW, ZYDJ, DYDJ, ZJRL, BAFH, GDXL1, SJBDZ1, GDXL2, SJBDZ2, GDXL3, SJBDZ3, GDXL4, SJBDZ4, GDDYSFMZBZ,"
  113. + " ZBYJDYRL, ZBYJDYPB, ZBYJDYSFMZBZ, BEIZHU) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  114. Connection conn = null;
  115. PreparedStatement st = null;
  116. DbConnection db = new DbConnection();
  117. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  118. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  119. try {
  120. conn = db.getConnection();
  121. int num=0;
  122. conn.setAutoCommit(false);
  123. st = conn.prepareStatement(sql);
  124. for (Map<String, String> map : list) {
  125. //系统当前时间
  126. Date date=new Date();
  127. String time=format.format(date);
  128. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(617);
  129. st.setString(1, fd_id);
  130. st.setString(2, map.get("KHBH_617"));
  131. st.setString(3, map.get("KHMC_617"));
  132. st.setString(4, task_id);
  133. st.setString(5, comp_id);
  134. st.setString(6, real_name);
  135. st.setString(7, time);
  136. st.setString(8, time);
  137. st.setString(9, "0");
  138. st.setString(10, map.get("KHLB_617"));
  139. st.setString(11, map.get("GDDW_617"));
  140. st.setString(12, map.get("ZYDJ_617"));
  141. st.setString(13, map.get("DYDJ_617"));
  142. st.setString(14, map.get("ZJRL_617"));
  143. st.setString(15, map.get("BAFH_617"));
  144. st.setString(16, map.get("GDXL1_617"));
  145. st.setString(17, map.get("SJBDZ1_617"));
  146. st.setString(18, map.get("GDXL2_617"));
  147. st.setString(19, map.get("SJBDZ2_617"));
  148. st.setString(20, map.get("GDXL3_617"));
  149. st.setString(21, map.get("SJBDZ3_617"));
  150. st.setString(22, map.get("GDXL4_617"));
  151. st.setString(23, map.get("SJBDZ4_617"));
  152. st.setString(24, map.get("GDDYSFMZBZ_617"));
  153. st.setString(25, map.get("ZBYJDYRL_617"));
  154. st.setString(26, map.get("ZBYJDYPB_617"));
  155. st.setString(27, map.get("ZBYJDYSFMZBZ_617"));
  156. st.setString(28, map.get("BEIZHU_617"));
  157. st.executeUpdate();
  158. log.info(sql);
  159. num++;
  160. }
  161. if(num==list.size()){
  162. log.info("保存成功");
  163. conn.commit();
  164. m.setSucsess(new Boolean(true).toString());
  165. m.setInfo(Parameter.DELETE_SUCSESS);
  166. return m;
  167. }else{
  168. m.setSucsess(new Boolean(false).toString());
  169. m.setInfo(Parameter.DELETE_FAILURE);
  170. // st.executeBatch();
  171. conn.rollback();
  172. log.info("保存失败");
  173. return m;
  174. }
  175. } catch (SQLException e) {
  176. this.log.error(e.getMessage(), e);
  177. } finally {
  178. db.close(st);
  179. db.close(conn);
  180. }
  181. return m;
  182. }
  183. public Msg saveBaoBiao(String json, String real_name, String comp_id, String task_id) throws ClassNotFoundException {
  184. Msg m=new Msg();
  185. String sql="insert into ECM_GPS_JOURNALING ( FD_OBJECTID, INPUT_NAME, INPUT_TIME, INPUT_DEPT, MAN_COUNT,"
  186. + " CAR_COUNT, IS_DEL, UPDATEDATE, FD_TASK, FD_TASK_NAME, BGD_FDC, BGD_FDJ, BGD_RW_TIME, BGD_DW ,"
  187. + "BGD_LEVEL,XINGHAO,RONGLIANG,CHANJIA,QTZHUNGBEI)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  188. Connection conn = null;
  189. PreparedStatement st = null;
  190. DbConnection db = new DbConnection();
  191. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  192. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  193. try {
  194. String sql1 = "select PROGRAM_NAME,TO_CHAR(UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),GPS_LEVEL from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID='"+task_id+"'";
  195. log.info("queryTask_sql:"+sql1);
  196. List<String[]> tempList = persistence.getSearchResult(610, sql1.toString());
  197. String taskName = "";
  198. String taskTime = "";
  199. String taskLevel = "";
  200. if(tempList!=null && tempList.size()>0){
  201. String[] arr = tempList.get(0);
  202. taskName = arr[0];
  203. taskTime = arr[1];
  204. taskLevel = arr[2];
  205. }
  206. if("0".equals(taskLevel)){
  207. taskLevel = "特级";
  208. }else if("1".equals(taskLevel)){
  209. taskLevel = "一级";
  210. }else if("2".equals(taskLevel)){
  211. taskLevel = "二级";
  212. }else if("3".equals(taskLevel)){
  213. taskLevel = "三级";
  214. }
  215. conn = db.getConnection();
  216. int num=0;
  217. conn.setAutoCommit(false);
  218. st = conn.prepareStatement(sql);
  219. for (Map<String, String> map : list) {
  220. //系统当前时间
  221. Date date=new Date();
  222. String time=format.format(date);
  223. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(613);
  224. st.setString(1, fd_id);
  225. st.setString(2, real_name);
  226. st.setString(3, time);
  227. st.setString(4, comp_id);
  228. st.setString(5, map.get("MAN_COUNT_613"));
  229. st.setString(6, map.get("CAR_COUNT_613"));
  230. st.setString(7, "0");
  231. st.setString(8, time);
  232. st.setString(9, task_id);
  233. st.setString(10, taskName);
  234. st.setString(11, map.get("BGD_FDC_613"));
  235. st.setString(12, map.get("BGD_FDJ_613"));
  236. st.setString(13, taskTime);
  237. st.setString(14, map.get("BGD_DW_613"));
  238. st.setString(15, taskLevel);
  239. st.setString(16, map.get("XINGHAO_613"));
  240. st.setString(17, map.get("RONGLIANG_613"));
  241. st.setString(18, map.get("CHANJIA_613"));
  242. st.setString(19, map.get("QTZHUNGBEI_613"));
  243. st.executeUpdate();
  244. log.info(sql);
  245. num++;
  246. }
  247. if(num==list.size()){
  248. log.info("保存成功");
  249. conn.commit();
  250. m.setSucsess(new Boolean(true).toString());
  251. m.setInfo(Parameter.DELETE_SUCSESS);
  252. return m;
  253. }else{
  254. m.setSucsess(new Boolean(false).toString());
  255. m.setInfo(Parameter.DELETE_FAILURE);
  256. // st.executeBatch();
  257. conn.rollback();
  258. log.info("保存失败");
  259. return m;
  260. }
  261. } catch (Exception e) {
  262. this.log.error(e.getMessage(), e);
  263. } finally {
  264. db.close(st);
  265. db.close(conn);
  266. }
  267. return m;
  268. }
  269. public Msg saveDuty(String json, String real_name, String comp_id, String task_id, String user_id) throws ClassNotFoundException {
  270. Msg m=new Msg();
  271. String sql="insert into ECM_GPS_DUTY (FD_OBJECTID,START_TIME,END_TIME,LEADER,"+
  272. "LEADER_TEL,WATCH_MAN,WATCH_TEL,DUTY_MODE,TIANBAO_TIME,IS_DEL,"+
  273. "UPDATEDATE,TIANBAO_PERSON,FLOW_ID,DEPT,TASK_ID,LEADER_DUTY_MODE,INPUT_NAME_ID) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  274. Connection conn = null;
  275. PreparedStatement st = null;
  276. DbConnection db = new DbConnection();
  277. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  278. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  279. try {
  280. conn = db.getConnection();
  281. int num=0;
  282. conn.setAutoCommit(false);
  283. st = conn.prepareStatement(sql);
  284. for (Map<String, String> map : list) {
  285. //系统当前时间
  286. Date date=new Date();
  287. String time=format.format(date);
  288. String startim = map.get("START_TIME_632")+":00";
  289. String entim = map.get("END_TIME_632")+":00";
  290. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(632);
  291. st.setString(1, fd_id);
  292. st.setString(2, startim);
  293. st.setString(3, entim);
  294. st.setString(4, map.get("LEADER_632"));
  295. st.setString(5, map.get("LEADER_TEL_632"));
  296. st.setString(6, map.get("WATCH_MAN_632"));
  297. st.setString(7, map.get("WATCH_TEL_632"));
  298. st.setString(8, map.get("DUTY_MODE_632"));
  299. st.setString(9, time);
  300. st.setString(10, "0");
  301. st.setString(11, time);
  302. st.setString(12, real_name);
  303. st.setString(13, "0");
  304. st.setString(14, comp_id);
  305. st.setString(15, task_id);
  306. st.setString(16, map.get("LEADER_DUTY_MODE_632"));
  307. st.setString(17, user_id);
  308. st.executeUpdate();
  309. log.info(sql);
  310. num++;
  311. }
  312. if(num==list.size()){
  313. log.info("保存成功");
  314. conn.commit();
  315. m.setSucsess(new Boolean(true).toString());
  316. m.setInfo(Parameter.DELETE_SUCSESS);
  317. return m;
  318. }else{
  319. m.setSucsess(new Boolean(false).toString());
  320. m.setInfo(Parameter.DELETE_FAILURE);
  321. // st.executeBatch();
  322. conn.rollback();
  323. log.info("保存失败");
  324. return m;
  325. }
  326. } catch (SQLException e) {
  327. this.log.error(e.getMessage(), e);
  328. } finally {
  329. db.close(st);
  330. db.close(conn);
  331. }
  332. return m;
  333. }
  334. /**
  335. * 导入后保存 保供电场所
  336. * @param json
  337. * @param real_name
  338. * @param comp_id
  339. * @param task_id
  340. * @param user_id
  341. * @return
  342. * @throws ClassNotFoundException
  343. */
  344. public Msg saveBaoBiao1(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String comp_name, String task_id, String user_id) throws ClassNotFoundException {
  345. Msg m=new Msg();
  346. String sql="insert into ECM_GPS_ZIYUANBAOBIAO (FD_OBJECTID, UPDATEDATE,IS_DEL,INPUT_NAME, INPUT_NAME_ID,INPUT_UNIT_NAME,INPUT_UNIT_ID, TASK_ID, "
  347. + " INPUT_TIME, ISSUE_TIME, ISSUE_DEPT, GPS_TASK_NUMBER,"
  348. + " GPS_TASK_FDC_DAY, GPS_TASK__FDC_TOTAL, GPS_TASK_FDJ_DAY, GPS_TASK_FDJ_TOTAL, GPS_TASK_CAR, GPS_TASK_ZBZHGLRY, "
  349. + "GPS_TASK_BDWBZRY, GPS_TASK_ABRY, GPS_TASK_WWSCRY, START_TIME, END_TIME, GPS_CONTINATION_TIME) "
  350. + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  351. Connection conn = null;
  352. PreparedStatement st = null;
  353. DbConnection db = new DbConnection();
  354. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  355. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  356. try {
  357. conn = db.getConnection();
  358. int num=0;
  359. conn.setAutoCommit(false);
  360. st = conn.prepareStatement(sql);
  361. for (Map<String, String> map : list) {
  362. //系统当前时间
  363. Date date=new Date();
  364. String time=format.format(date);
  365. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(620);
  366. st.setString(1, fd_id);
  367. st.setString(2, time);
  368. st.setString(3, "0");
  369. st.setString(4, real_name);
  370. st.setString(5, user_id);
  371. st.setString(6, comp_name);
  372. st.setString(7, comp_id);
  373. st.setString(8, task_id);
  374. st.setString(9, time);
  375. st.setString(10, time);
  376. st.setString(11, comp_id);
  377. st.setString(12, map.get("GPS_TASK_NUMBER_620"));
  378. st.setString(13, map.get("GPS_TASK_FDC_DAY_620"));
  379. st.setString(14, map.get("GPS_TASK__FDC_TOTAL_620"));
  380. st.setString(15, map.get("GPS_TASK_FDJ_DAY_620"));
  381. st.setString(16, map.get("GPS_TASK_FDJ_TOTAL_620"));
  382. st.setString(17, map.get("GPS_TASK_CAR_620"));
  383. st.setString(18, map.get("GPS_TASK_ZBZHGLRY_620"));
  384. st.setString(19, map.get("GPS_TASK_BDWBZRY_620"));
  385. st.setString(20, map.get("GPS_TASK_ABRY_620"));
  386. st.setString(21, map.get("GPS_TASK_WWSCRY_620"));
  387. st.setString(22, map.get("START_TIME_620"));
  388. st.setString(23, map.get("END_TIME_620"));
  389. st.setString(24, map.get("GPS_CONTINATION_TIME_620"));
  390. st.executeUpdate();
  391. log.info(sql);
  392. num++;
  393. }
  394. if(num==list.size()){
  395. log.info("保存成功");
  396. conn.commit();
  397. m.setSucsess(new Boolean(true).toString());
  398. m.setInfo(Parameter.DELETE_SUCSESS);
  399. return m;
  400. }else{
  401. m.setSucsess(new Boolean(false).toString());
  402. m.setInfo(Parameter.DELETE_FAILURE);
  403. // st.executeBatch();
  404. conn.rollback();
  405. log.info("保存失败");
  406. return m;
  407. }
  408. } catch (SQLException e) {
  409. this.log.error(e.getMessage(), e);
  410. } finally {
  411. db.close(st);
  412. db.close(conn);
  413. }
  414. return m;
  415. }
  416. /**
  417. * 导入后保存 保供电场所
  418. * @param json
  419. * @param real_name
  420. * @param comp_id
  421. * @param task_id
  422. * @param user_id
  423. * @return
  424. * @throws ClassNotFoundException
  425. */
  426. public Msg saveGpsPlace(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String comp_name, String task_id, String user_id) throws ClassNotFoundException {
  427. Msg m=new Msg();
  428. String sql="insert into ECM_GPS_PLACE(FD_OBJECTID, UPDATEDATE, IS_DEL, INPUT_OPER_NAME, INPUT_OPER_ID, INPUT_UNIT_NAME, "
  429. + "INPUT_UNIT_ID, TASK_FDID, TASK_NUMBER, PLACE_NAME, PLACE_NUMBER, PLACE_CLASSIFICATION, PLACE_LEVEL, "
  430. + "PLACE_VOLTAGE_LEVEL, QXJHTD, KZYDJC, XZYHCSSY, YJDYZBZY, CYCGXCZS, GPS_START_DATE, GPS_END_DATE, "
  431. + "GPS_CONTINUED_TIME, FDCDR, FDJDR) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  432. Connection conn = null;
  433. PreparedStatement st = null;
  434. DbConnection db = new DbConnection();
  435. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  436. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  437. try {
  438. conn = db.getConnection();
  439. int num=0;
  440. conn.setAutoCommit(false);
  441. st = conn.prepareStatement(sql);
  442. for (Map<String, String> map : list) {
  443. //系统当前时间
  444. Date date=new Date();
  445. String time=format.format(date);
  446. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(619);
  447. st.setString(1, fd_id);
  448. st.setString(2, time);
  449. st.setString(3, "0");
  450. st.setString(4, real_name);
  451. st.setString(5, user_id);
  452. st.setString(6, comp_name);
  453. st.setString(7, comp_id);
  454. st.setString(8, task_id);
  455. st.setString(9, map.get("TASK_NUMBER_619"));
  456. st.setString(10, map.get("PLACE_NAME_619"));
  457. st.setString(11, map.get("PLACE_NUMBER_619"));
  458. st.setString(12, map.get("PLACE_CLASSIFICATION_619"));
  459. st.setString(13, map.get("PLACE_LEVEL_619"));
  460. st.setString(14, map.get("PLACE_VOLTAGE_LEVEL_619"));
  461. st.setString(15, map.get("QXJHTD_619"));
  462. st.setString(16, map.get("KZYDJC_619"));
  463. st.setString(17, map.get("XZYHCSSY_619"));
  464. st.setString(18, map.get("YJDYZBZY_619"));
  465. st.setString(19, map.get("CYCGXCZS_619"));
  466. st.setString(20, map.get("GPS_START_DATE_619"));
  467. st.setString(21, map.get("GPS_END_DATE_619"));
  468. st.setString(22, map.get("GPS_CONTINUED_TIME_619"));
  469. st.setString(23, map.get("FDCDR_619"));
  470. st.setString(24, map.get("FDJDR_619"));
  471. st.executeUpdate();
  472. log.info(sql);
  473. num++;
  474. }
  475. if(num==list.size()){
  476. log.info("保存成功");
  477. conn.commit();
  478. m.setSucsess(new Boolean(true).toString());
  479. m.setInfo(Parameter.DELETE_SUCSESS);
  480. return m;
  481. }else{
  482. m.setSucsess(new Boolean(false).toString());
  483. m.setInfo(Parameter.DELETE_FAILURE);
  484. // st.executeBatch();
  485. conn.rollback();
  486. log.info("保存失败");
  487. return m;
  488. }
  489. } catch (SQLException e) {
  490. this.log.error(e.getMessage(), e);
  491. } finally {
  492. db.close(st);
  493. db.close(conn);
  494. }
  495. return m;
  496. }
  497. public Msg saveGpsEquipment(String json, String real_name, String comp_id,
  498. String comp_name, String task_id, String user_id) throws ClassNotFoundException {
  499. Msg m=new Msg();
  500. String sql="insert into ECM_GPS_EQUIPMENT(FD_OBJECTID, UPDATEDATE, IS_DEL, INPUT_OPER_NAME, INPUT_OPER_ID, "
  501. + "INPUT_UNIT_NAME, INPUT_UNIT_ID, TASK_FDID, TASK_NUMBER, EQ_NAME, EQ_NUMBER, EQ_CLASSIFICATION, EQ_LEVEL,"
  502. + " EQ_VOLTAGE_LEVEL, XUNSHI, BTDJCJPJ, TDSYJPJ, GPS_START_DATE, GPS_END_DATE, GPS_CONTINUED_TIME) "
  503. + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
  504. Connection conn = null;
  505. PreparedStatement st = null;
  506. DbConnection db = new DbConnection();
  507. List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
  508. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  509. try {
  510. conn = db.getConnection();
  511. int num=0;
  512. conn.setAutoCommit(false);
  513. st = conn.prepareStatement(sql);
  514. for (Map<String, String> map : list) {
  515. //系统当前时间
  516. Date date=new Date();
  517. String time=format.format(date);
  518. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(618);
  519. st.setString(1, fd_id);
  520. st.setString(2, time);
  521. st.setString(3, "0");
  522. st.setString(4, real_name);
  523. st.setString(5, user_id);
  524. st.setString(6, comp_name);
  525. st.setString(7, comp_id);
  526. st.setString(8, task_id);
  527. st.setString(9, map.get("TASK_NUMBER_618"));
  528. st.setString(10, map.get("EQ_NAME_618"));
  529. st.setString(11, map.get("EQ_NUMBER_618"));
  530. st.setString(12, map.get("EQ_CLASSIFICATION_618"));
  531. st.setString(13, map.get("EQ_LEVEL_618"));
  532. st.setString(14, map.get("EQ_VOLTAGE_LEVEL_618"));
  533. st.setString(15, map.get("XUNSHI_618"));
  534. st.setString(16, map.get("BTDJCJPJ_618"));
  535. st.setString(17, map.get("TDSYJPJ_618"));
  536. st.setString(18, map.get("GPS_START_DATE_618"));
  537. st.setString(19, map.get("GPS_END_DATE_618"));
  538. st.setString(20, map.get("GPS_CONTINUED_TIME_618"));
  539. st.executeUpdate();
  540. log.info(sql);
  541. num++;
  542. }
  543. if(num==list.size()){
  544. log.info("保存成功");
  545. conn.commit();
  546. m.setSucsess(new Boolean(true).toString());
  547. m.setInfo(Parameter.DELETE_SUCSESS);
  548. return m;
  549. }else{
  550. m.setSucsess(new Boolean(false).toString());
  551. m.setInfo(Parameter.DELETE_FAILURE);
  552. // st.executeBatch();
  553. conn.rollback();
  554. log.info("保存失败");
  555. return m;
  556. }
  557. } catch (SQLException e) {
  558. this.log.error(e.getMessage(), e);
  559. } finally {
  560. db.close(st);
  561. db.close(conn);
  562. }
  563. return m;
  564. }
  565. public boolean saveUser(GPSUserMsg detail) {
  566. boolean flag = false;
  567. DbConnection dbConn = new DbConnection();
  568. Connection conn = null;
  569. PreparedStatement pstm = null;
  570. String detailSQL = "update ECM_GPS_USER "
  571. +" set USER_ID = ?, USER_NAME = ?, USER_ADDRESS = ?, POWER_SUPPLY_UNIT_NAME = ?, "
  572. + "IMPORTANT_USER_LEVEL = ?, ELECTROR_TYPE = ?, VOLTAGE_LEVEL = ?, UPDATEDATE = ? , ENXTEND = ? "
  573. + " where FD_OBJECTID = ?";
  574. try {
  575. conn = dbConn.getConnection();
  576. conn.setAutoCommit(false);
  577. pstm = conn.prepareStatement(detailSQL);
  578. pstm.setString(1, detail.getUSER_ID());
  579. pstm.setString(2, detail.getUSER_NAME());
  580. pstm.setString(3, detail.getUSER_ADDRESS());
  581. pstm.setString(4, detail.getPOWER_SUPPLY_UNIT_NAME());
  582. pstm.setString(5, detail.getIMPORTANT_USER_LEVEL());
  583. pstm.setString(6, detail.getELECTROR_TYPE());
  584. pstm.setString(7, detail.getVOLTAGE_LEVEL());
  585. pstm.setString(8, detail.getUPDATEDATE());
  586. pstm.setString(9, detail.getENXTEND());
  587. pstm.setString(10, detail.getFD_OBJECTID());
  588. pstm.executeUpdate();
  589. conn.setAutoCommit(true);
  590. flag = true;
  591. }catch(Exception e){
  592. try {
  593. conn.rollback();
  594. conn.setAutoCommit(true);
  595. } catch (SQLException e1) {
  596. e1.printStackTrace();
  597. }
  598. e.printStackTrace();
  599. }finally{
  600. try {
  601. pstm.close();
  602. conn.close();
  603. } catch (SQLException e) {
  604. e.printStackTrace();
  605. }
  606. }
  607. return flag;
  608. }
  609. public Msg saveBaoBiao1(GPSBaoBiao detail, String real_name, String comp_id, String task_id) throws ClassNotFoundException {
  610. Msg m=new Msg();
  611. String sql="insert into ECM_GPS_JOURNALING ( FD_OBJECTID, INPUT_NAME, INPUT_TIME, INPUT_DEPT, MAN_COUNT,"
  612. + " CAR_COUNT, IS_DEL, UPDATEDATE, FD_TASK, FD_TASK_NAME, BGD_FDC, BGD_FDJ, BGD_RW_TIME, BGD_DW ,"
  613. + "BGD_LEVEL,XINGHAO,RONGLIANG,CHANJIA,QTZHUNGBEI)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  614. Connection conn = null;
  615. PreparedStatement st = null;
  616. DbConnection db = new DbConnection();
  617. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  618. try {
  619. String sql1 = "select PROGRAM_NAME,TO_CHAR(UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),GPS_LEVEL from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID='"+task_id+"'";
  620. log.info("queryTask_sql:"+sql1);
  621. List<String[]> tempList = persistence.getSearchResult(610, sql1.toString());
  622. String taskName = "";
  623. String taskTime = "";
  624. String taskLevel = "";
  625. if(tempList!=null && tempList.size()>0){
  626. String[] arr = tempList.get(0);
  627. taskName = arr[0];
  628. taskTime = arr[1];
  629. taskLevel = arr[2];
  630. }
  631. if("0".equals(taskLevel)){
  632. taskLevel = "特级";
  633. }else if("1".equals(taskLevel)){
  634. taskLevel = "一级";
  635. }else if("2".equals(taskLevel)){
  636. taskLevel = "二级";
  637. }else if("3".equals(taskLevel)){
  638. taskLevel = "三级";
  639. }
  640. conn = db.getConnection();
  641. int num=0;
  642. conn.setAutoCommit(false);
  643. st = conn.prepareStatement(sql);
  644. //系统当前时间
  645. Date date=new Date();
  646. String time=format.format(date);
  647. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(613);
  648. st.setString(1, fd_id);
  649. st.setString(2, real_name);
  650. st.setString(3, time);
  651. st.setString(4, comp_id);
  652. st.setString(5, detail.getMAN_COUNT());
  653. st.setString(6, detail.getCAR_COUNT());
  654. st.setString(7, "0");
  655. st.setString(8, time);
  656. st.setString(9, task_id);
  657. st.setString(10, taskName);
  658. st.setString(11, detail.getBGD_FDC());
  659. st.setString(12, detail.getBGD_FDJ());
  660. st.setString(13, taskTime);
  661. st.setString(14, detail.getBGD_DW());
  662. st.setString(15, taskLevel);
  663. st.setString(16, detail.getXINGHAO());
  664. st.setString(17, detail.getRONGLIANG());
  665. st.setString(18, detail.getCHANJIA());
  666. st.setString(19, detail.getQTZHUAGNBEI());
  667. st.executeUpdate();
  668. log.info(sql);
  669. num++;
  670. if(num==1){
  671. log.info("保存成功");
  672. conn.commit();
  673. m.setSucsess(new Boolean(true).toString());
  674. m.setInfo(Parameter.DELETE_SUCSESS);
  675. return m;
  676. }else{
  677. m.setSucsess(new Boolean(false).toString());
  678. m.setInfo(Parameter.DELETE_FAILURE);
  679. // st.executeBatch();
  680. conn.rollback();
  681. log.info("保存失败");
  682. return m;
  683. }
  684. } catch (Exception e) {
  685. this.log.error(e.getMessage(), e);
  686. } finally {
  687. db.close(st);
  688. db.close(conn);
  689. }
  690. return m;
  691. }
  692. public boolean saveJournaling(GPSBaoBiao detail) {
  693. boolean flag = false;
  694. DbConnection dbConn = new DbConnection();
  695. Connection conn = null;
  696. PreparedStatement pstm = null;
  697. String detailSQL = "";
  698. try {
  699. if("undefined".equals(detail.getFD_OBJECTID())){
  700. saveBaoBiao1(detail,detail.getINPUT_NAME(),detail.getINPUT_DEPT(),detail.getFD_TASK());
  701. flag = true;
  702. }else{
  703. detailSQL = "update ECM_GPS_JOURNALING "
  704. +" set INPUT_DEPT = ?, MAN_COUNT = ?, CAR_COUNT = ?, INPUT_NAME = ?, "
  705. + "INPUT_TIME = ?, UPDATEDATE = ?, XINGHAO = ? , RONGLIANG = ? , CHANJIA = ? , QTZHUNGBEI = ?,BGD_FDC = ?,"
  706. + "BGD_FDJ = ? where FD_OBJECTID = ?";
  707. conn = dbConn.getConnection();
  708. conn.setAutoCommit(false);
  709. pstm = conn.prepareStatement(detailSQL);
  710. pstm.setString(1, detail.getINPUT_DEPT());
  711. pstm.setString(2, detail.getMAN_COUNT());
  712. pstm.setString(3, detail.getCAR_COUNT());
  713. pstm.setString(4, detail.getINPUT_NAME());
  714. pstm.setString(5, detail.getINPUT_TIME());
  715. pstm.setString(6, detail.getUPDATEDATE());
  716. pstm.setString(7, detail.getXINGHAO());
  717. pstm.setString(8, detail.getRONGLIANG());
  718. pstm.setString(9, detail.getCHANJIA());
  719. pstm.setString(10, detail.getQTZHUAGNBEI());
  720. pstm.setString(11, detail.getBGD_FDC());
  721. pstm.setString(12, detail.getBGD_FDJ());
  722. pstm.setString(13, detail.getFD_OBJECTID());
  723. int n = 0;
  724. n = pstm.executeUpdate();
  725. conn.setAutoCommit(true);
  726. flag = true;
  727. }
  728. }catch(Exception e){
  729. try {
  730. conn.rollback();
  731. conn.setAutoCommit(true);
  732. } catch (SQLException e1) {
  733. e1.printStackTrace();
  734. }
  735. e.printStackTrace();
  736. }finally{
  737. try {
  738. if(pstm!=null){
  739. pstm.close();
  740. }
  741. if(conn!=null){
  742. conn.close();
  743. }
  744. } catch (SQLException e) {
  745. e.printStackTrace();
  746. }
  747. }
  748. return flag;
  749. }
  750. public boolean saveDuty(GPSDutyMsg detail) {
  751. boolean flag = false;
  752. DbConnection dbConn = new DbConnection();
  753. Connection conn = null;
  754. PreparedStatement pstm = null;
  755. String insertSql = "insert into ECM_GPS_DUTY(FD_OBJECTID, IS_DEL, UPDATEDATE, TASK_ID, START_TIME, END_TIME, LEADER, "
  756. + "LEADER_TEL, WATCH_MAN, WATCH_TEL, DUTY_MODE, TIANBAO_TIME, DEPT, TIANBAO_PERSON, FLOW_ID, "
  757. + "INPUT_NAME_ID, LEADER_DUTY_MODE) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
  758. int num = 0 ;
  759. try {
  760. conn = dbConn.getConnection();
  761. conn.setAutoCommit(false);
  762. pstm = conn.prepareStatement(insertSql);
  763. String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(632);
  764. pstm.setString(1, fd_id);
  765. pstm.setString(2, "0");
  766. pstm.setString(3, detail.getUPDATEDATE_632());
  767. pstm.setString(4, detail.getTASK_ID());
  768. pstm.setString(5, detail.getSTART_TIME_632());
  769. pstm.setString(6, detail.getEND_TIME_632());
  770. pstm.setString(7, detail.getLEADER_632());
  771. pstm.setString(8, detail.getLEADER_TEL_632());
  772. pstm.setString(9, detail.getWATCH_MAN_632());
  773. pstm.setString(10, detail.getWATCH_TEL_632());
  774. pstm.setString(11, detail.getDUTY_MODE_632());
  775. pstm.setString(12, detail.getUPDATEDATE_632());
  776. pstm.setString(13, detail.getDEPT());
  777. pstm.setString(14, detail.getTIANBAO_PERSON());
  778. pstm.setString(15, "0");
  779. pstm.setString(16, detail.getINPUT_NAME_ID_632());
  780. pstm.setString(17, detail.getLEADER_DUTY_MODE_632());
  781. num = pstm.executeUpdate();
  782. conn.commit();
  783. flag = true;
  784. }catch(Exception e){
  785. try {
  786. conn.rollback();
  787. } catch (SQLException e1) {
  788. e1.printStackTrace();
  789. }
  790. e.printStackTrace();
  791. }finally{
  792. try {
  793. pstm.close();
  794. conn.close();
  795. } catch (SQLException e) {
  796. e.printStackTrace();
  797. }
  798. }
  799. return flag;
  800. }
  801. public boolean updateDuty(GPSDutyMsg detail) {
  802. boolean flag = false;
  803. DbConnection dbConn = new DbConnection();
  804. Connection conn = null;
  805. PreparedStatement pstm = null;
  806. String detailSQL = "update ECM_GPS_DUTY "
  807. +" set START_TIME = ?, END_TIME = ?, LEADER = ?, LEADER_TEL = ?, LEADER_DUTY_MODE=?, "
  808. + "WATCH_MAN = ?, WATCH_TEL = ?,DUTY_MODE = ?,UPDATEDATE = ? "
  809. + " where FD_OBJECTID = ?";
  810. int num = 0 ;
  811. try {
  812. conn = dbConn.getConnection();
  813. conn.setAutoCommit(false);
  814. pstm = conn.prepareStatement(detailSQL);
  815. pstm.setString(1, detail.getSTART_TIME_632());
  816. pstm.setString(2, detail.getEND_TIME_632());
  817. pstm.setString(3, detail.getLEADER_632());
  818. pstm.setString(4, detail.getLEADER_TEL_632());
  819. pstm.setString(5, detail.getLEADER_DUTY_MODE_632());
  820. pstm.setString(6, detail.getWATCH_MAN_632());
  821. pstm.setString(7, detail.getWATCH_TEL_632());
  822. pstm.setString(8, detail.getDUTY_MODE_632());
  823. pstm.setString(9, detail.getUPDATEDATE_632());
  824. pstm.setString(10, detail.getFD_OBJECTID());
  825. num = pstm.executeUpdate();
  826. conn.commit();
  827. flag = true;
  828. }catch(Exception e){
  829. try {
  830. conn.rollback();
  831. } catch (SQLException e1) {
  832. e1.printStackTrace();
  833. }
  834. e.printStackTrace();
  835. }finally{
  836. try {
  837. pstm.close();
  838. conn.close();
  839. } catch (SQLException e) {
  840. e.printStackTrace();
  841. }
  842. }
  843. return flag;
  844. }
  845. /**
  846. * 返回部门节点json字符串
  847. *
  848. * @param unitCode
  849. * @return
  850. */
  851. public List<Detp> getDeptChlidrenString(String unitCode) {
  852. SysModel sysmodel = ModelFactory.getSysmodel();
  853. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  854. List<Detp> deptList = new ArrayList<Detp>();
  855. StringBuffer sql = new StringBuffer();
  856. sql.append("-- 查询组织机构子节点 \n");
  857. sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
  858. sql.append(" from Sys_Department where DEPT_TYPE='1' and (FD_OBJECTID='" + unitCode + "' or parent_id='" + unitCode + "') \n");
  859. sql.append(" ORDER BY SORT asc \n");
  860. // log.info("=="+sql);
  861. try {
  862. ArrayList<String[]> listDept = persistence.getSearchResult(99, sql.toString());
  863. int num = listDept.size();
  864. for (int i = 0; i < num; i++) {
  865. String[] temp = listDept.get(i);
  866. String deptId = temp[0];
  867. String deptName = temp[1];
  868. if(unitCode.equals(deptId)){
  869. deptList.add(0, new Detp(deptId, deptName));
  870. }else{
  871. deptList.add(new Detp(deptId, deptName));
  872. }
  873. // String objectId = temp[2];
  874. // json.append("{ ");
  875. // json.append(" id:'" + deptId + "', parentId:'" + unitCode + "',");
  876. // json.append(" classId:'800',objectId:'" + objectId + "',");
  877. // json.append(" name:'" + deptName + "',");
  878. // json.append(" type:'unit',menuType:'nonLeafMenu',");
  879. // json.append(" icon:'/nwyj/scripts/qui/libs/icons/user_group.gif'");
  880. // json.append("}, ");
  881. }
  882. } catch (PersistenceException e) {
  883. log.error("查询子单位id错误", e);
  884. }
  885. return deptList;
  886. }
  887. /**
  888. * 根据查询条件an查询任务
  889. * @param string
  890. * @return
  891. */
  892. public List<GPSTask> queryTask(String condition) {
  893. SysModel sysmodel = ModelFactory.getSysmodel();
  894. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  895. List<GPSTask> tasks = new ArrayList<GPSTask>();
  896. StringBuffer sql = new StringBuffer();
  897. sql.append("--根据查询条件an查询任务 \n");
  898. sql.append(" select START_TIME,END_TIME,PROGRAM_NAME,GPS_LEVEL,GPS_AREA_ID,INPUT_UNIT_ID ");
  899. sql.append(" from ECM_GPS_PROGRAM_MANAGEMENT where IS_DEL=0 and PROGRAM_STATE=1 " + condition + " \n");
  900. log.info("=="+sql);
  901. try {
  902. ArrayList<String[]> list = persistence.getSearchResult(610, sql.toString());
  903. int num = list.size();
  904. for (int i = 0; i < num; i++) {
  905. String[] temp = list.get(i);
  906. String START_TIME = temp[0];
  907. String END_TIME = temp[1];
  908. String PROGRAM_NAME = temp[2];
  909. String GPS_LEVEL = temp[3];
  910. String GPS_AREA_ID = temp[4];
  911. String INPUT_UNIT_ID = temp[5];
  912. tasks.add(new GPSTask(START_TIME, END_TIME, PROGRAM_NAME, GPS_LEVEL, GPS_AREA_ID, INPUT_UNIT_ID));
  913. }
  914. } catch (PersistenceException e) {
  915. log.error("查询任务错误", e);
  916. }
  917. return tasks;
  918. }
  919. public String getdeptTreeById(String areaId, StringBuffer areaIdsArr, String unitId) {
  920. SysModel sysmodel = ModelFactory.getSysmodel();
  921. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  922. StringBuffer sql = new StringBuffer();
  923. StringBuffer json = new StringBuffer();
  924. String[] areaIdArr = areaId.split(",");
  925. json.append("{\"treeNodes\":[");
  926. boolean isarea = false;
  927. for (int i = 0; i < areaIdArr.length; i++) {
  928. if(areaIdArr[i].equals(unitId)){
  929. isarea = true;
  930. }
  931. }
  932. sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
  933. //sql.append("SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ORG_ID, \n");
  934. //sql.append("DECODE((SELECT COUNT(1) FROM SYS_DEPARTMENT_1111 B WHERE B.PARENT_ORG_ID = A.ORG_ID),'0','0','1') AS 是否有子机构, \n");
  935. //sql.append("DECODE((SELECT COUNT(1) FROM EMC_4A_USER C WHERE C.PARENT_ORG_ID = A.ORG_ID),'0','0','1') AS 是否有员工 , \n");
  936. //sql.append("A.ORG_LEVEL ");
  937. sql.append("SELECT A.DEPT_ID,A.DEPT_NAME,A.PARENT_ID, \n");
  938. sql.append("DECODE((SELECT COUNT(1) FROM SYS_DEPARTMENT B WHERE B.PARENT_ID = A.DEPT_ID),'0','0','1') AS 是否有子机构, \n");
  939. sql.append("A.DEPT_LEVEL ");
  940. if(unitId !="" && isarea){
  941. //sql.append("FROM SYS_DEPARTMENT_1111 A WHERE (PARENT_ORG_ID = '" + unitId + "' or ORG_ID in "+areaIdsArr+") \n");
  942. sql.append("FROM SYS_DEPARTMENT A WHERE (PARENT_ID = '" + unitId + "' or DEPT_ID in "+areaIdsArr+") \n");
  943. }else{
  944. //sql.append("FROM SYS_DEPARTMENT_1111 A WHERE ORG_ID in "+areaIdsArr+" \n");
  945. sql.append("FROM SYS_DEPARTMENT A WHERE DEPT_ID in "+areaIdsArr+" \n");
  946. }
  947. try {
  948. ArrayList<String[]> listRoot = persistence.getSearchResult(99, sql.toString());
  949. // 显示人员
  950. //json.append(getPersonById(id));
  951. int listLen = listRoot.size();
  952. for (int i = 0; i < listLen; i++) {
  953. String[] temp = listRoot.get(i);
  954. String orgId = temp[0];
  955. String orgName = temp[1];
  956. String parentOrgId = temp[2];
  957. boolean isHasChildOrg = !("0".equals(temp[3]));
  958. String orgLevel = temp[4];
  959. json.append("{");
  960. json.append(" \"id\":\"" + orgId + "\", \"parentId\":\"" + parentOrgId
  961. + "\", \"name\": \"" + orgName + "\",\"orgLevel\":\"" + orgLevel + "\"");
  962. json.append(",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
  963. if (isHasChildOrg) {
  964. json.append(",\"open\": \"true\"");
  965. } else {
  966. json.append(",\"isParent\": \"fasle\" ");
  967. }
  968. if(!parentOrgId.equals(unitId)){
  969. json.append(",\"chkDisabled\": \"true\"");
  970. }else{
  971. json.append(",\"chkDisabled\": \"false\"");
  972. }
  973. boolean flag = false;
  974. for (int j = 0; j < areaIdArr.length;j++) {
  975. if(orgId.equals(areaIdArr[j])){
  976. flag = true;
  977. }
  978. }
  979. if(flag){
  980. json.append(",\"checked\": \"true\"");
  981. }else{
  982. json.append(",\"checked\": \"false\"");
  983. }
  984. json.append("},");
  985. }
  986. if (json.lastIndexOf(",") > -1) {
  987. json.deleteCharAt(json.lastIndexOf(","));
  988. };
  989. json.append("]}");
  990. Log.info(json.toString());
  991. } catch (PersistenceException e) {
  992. e.printStackTrace();
  993. }
  994. return json.toString();
  995. }
  996. public String getAreaId(String fd_id) throws ClassNotFoundException {
  997. String sql="select GPS_AREA_ID from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID ='"+fd_id+"'";
  998. Connection conn = null;
  999. PreparedStatement st = null;
  1000. DbConnection db = new DbConnection();
  1001. ResultSet rs = null;
  1002. String areaId = "";
  1003. try {
  1004. conn = db.getConnection();
  1005. st = conn.prepareStatement(sql);
  1006. rs = st.executeQuery();
  1007. rs.next();
  1008. areaId = rs.getString("GPS_AREA_ID");
  1009. return areaId;
  1010. } catch (SQLException e) {
  1011. this.log.error(e.getMessage(), e);
  1012. } finally {
  1013. if(rs!=null){
  1014. try {
  1015. rs.close();
  1016. } catch (SQLException e) {
  1017. e.printStackTrace();
  1018. }
  1019. }
  1020. db.close(st);
  1021. db.close(conn);
  1022. }
  1023. return areaId;
  1024. }
  1025. public String quiTaskDutyByType(String type, String dept, String task_id) {
  1026. StringBuffer result = new StringBuffer();
  1027. result.append("{\"rows\":");
  1028. SysModel sysmodel = ModelFactory.getSysmodel();
  1029. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  1030. List<GPSTask> tasks = new ArrayList<GPSTask>();
  1031. StringBuffer sql = new StringBuffer();
  1032. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
  1033. Calendar caldate = Calendar.getInstance();
  1034. if("1".equals(type)){
  1035. sql.append("select FD_OBJECTID FD_OBJECTID632,UPDATEDATE UPDATEDATE_632, SUBSTR(START_TIME, 0,16) START_TIME_632, SUBSTR(END_TIME, 0,16) END_TIME_632,LEADER LEADER_632,LEADER_TEL LEADER_TEL_632,WATCH_MAN WATCH_MAN_632,WATCH_TEL WATCH_TEL_632,DUTY_MODE DUTY_MODE_632,TIANBAO_TIME TIANBAO_TIME_632,DEPT DEPT_632,TIANBAO_PERSON TIANBAO_PERSON_632,INPUT_NAME_ID INPUT_NAME_ID_632,LEADER_DUTY_MODE LEADER_DUTY_MODE_632 from ECM_GPS_DUTY where TASK_ID='"+task_id+"' and DEPT='"+dept+"' and is_del=0 and (START_TIME is not null or END_TIME is not null or START_TIME <> '' or END_TIME <> '') and regexp_like(END_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') order by LEADER");
  1036. }else if("2".equals(type)){
  1037. sql.append("select b.dept_name DEPTNAME, a.FD_OBJECTID FD_OBJECTID632 , a.UPDATEDATE UPDATEDATE_632, SUBSTR(a.START_TIME, 0,16) START_TIME_632, SUBSTR(a.END_TIME, 0,16) END_TIME_632, a.LEADER LEADER_632, a.LEADER_TEL LEADER_TEL_632, a.WATCH_MAN WATCH_MAN_632, a.WATCH_TEL WATCH_TEL_632, a.DUTY_MODE DUTY_MODE_632, a.TIANBAO_TIME TIANBAO_TIME_632, a.DEPT DEPT_632, a.TIANBAO_PERSON TIANBAO_PERSON_632, a.INPUT_NAME_ID INPUT_NAME_ID_632, a.LEADER_DUTY_MODE LEADER_DUTY_MODE_632 from sys_department b left join ECM_GPS_DUTY a on a.dept=b.dept_id where TASK_ID='"+task_id+"' and a.is_del=0 and (START_TIME is not null or END_TIME is not null or START_TIME <> '' or END_TIME <> '') and regexp_like(START_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') and regexp_like(START_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') and regexp_like(END_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') order by LEADER");
  1038. }else if("3".equals(type)){
  1039. sql.append("select b.dept_name deptname, a.FD_OBJECTID FD_OBJECTID632 , a.UPDATEDATE UPDATEDATE_632,SUBSTR(a.START_TIME, 0,16) groupdate, SUBSTR(a.START_TIME, 0,16) START_TIME_632, SUBSTR(a.END_TIME, 0,16) END_TIME_632, a.LEADER LEADER_632, a.LEADER_TEL LEADER_TEL_632, a.WATCH_MAN WATCH_MAN_632, a.WATCH_TEL WATCH_TEL_632, a.DUTY_MODE DUTY_MODE_632, a.TIANBAO_TIME TIANBAO_TIME_632, a.DEPT DEPT_632, a.TIANBAO_PERSON TIANBAO_PERSON_632, a.INPUT_NAME_ID INPUT_NAME_ID_632, a.LEADER_DUTY_MODE LEADER_DUTY_MODE_632 from sys_department b left join ECM_GPS_DUTY a on a.dept=b.dept_id where TASK_ID='"+task_id+"' and a.is_del=0 and (START_TIME is not null or END_TIME is not null or START_TIME <> '' or END_TIME <> '') and regexp_like(START_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') and regexp_like(END_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') order by LEADER,groupdate ");
  1040. }
  1041. log.info("=="+sql);
  1042. try {
  1043. ArrayList<Map<String,String>> tempList = new ArrayList<Map<String,String>>();
  1044. ArrayList<Map<String,String>> list = persistence.getSearchResultToMap(632, sql.toString());
  1045. int num = list.size();
  1046. if("1".equals(type)){
  1047. tempList = list;
  1048. }else if("2".equals(type)){
  1049. tempList = list;
  1050. }else if("3".equals(type)){
  1051. for (int i = 0; i < list.size(); i++) {
  1052. Map<String, String> map = list.get(i);
  1053. tempList.add(map);
  1054. String grouptdate = map.get("GROUPDATE");
  1055. String startime = map.get("START_TIME_632");
  1056. String endtime = map.get("END_TIME_632");
  1057. if("".equals(startime) || "".equals(endtime)
  1058. || startime==null || endtime==null
  1059. || "".equals(startime.trim()) || "".equals(endtime.trim())){
  1060. continue;
  1061. }
  1062. startime = startime.split(" ")[0];
  1063. endtime = endtime.split(" ")[0];
  1064. Date stime = dateformat.parse(startime);
  1065. Date etime = dateformat.parse(endtime);
  1066. Date gtime = dateformat.parse(grouptdate);
  1067. if(etime.after(stime)){
  1068. caldate.setTime(gtime);
  1069. caldate.add(Calendar.DAY_OF_MONTH, 1);
  1070. while(!caldate.getTime().after(etime)){
  1071. Map<String, String> map1 = new HashMap<String, String>();
  1072. map1.putAll(map);
  1073. //String aa = dateformat.format(caldate.getTime());
  1074. //boolean bb = caldate.getTime().after(etime);
  1075. map1.put("GROUPDATE", dateformat.format(caldate.getTime()));
  1076. tempList.add(map1);
  1077. caldate.add(Calendar.DAY_OF_MONTH, 1);
  1078. }
  1079. }
  1080. }
  1081. }
  1082. result.append(JSONArray.fromObject(tempList).toString());
  1083. result.append("}");
  1084. } catch (PersistenceException e) {
  1085. log.error("查询任务错误", e);
  1086. } catch (ParseException e) {
  1087. // TODO Auto-generated catch block
  1088. e.printStackTrace();
  1089. }
  1090. return result.toString();
  1091. }
  1092. public List<Map<String, String>> getDeptMsgByTaskId(String taskId) {
  1093. String sql = "select FD_OBJECTID,PROGRAM_NAME,GPS_LEVEL,GPS_AREA_NAME,IMPLEMENT_TIME,PROGRAM_STATE,INPUT_UNIT_ID,INPUT_TIME,INPUT_NAME,START_TIME,END_TIME,COMMENT_TEXT,TASK_STATE,UPDATEDATE,IS_DEL,GPS_AREA_ID,INPUT_UNIT_NAME,GPS_AREA_CITY,HAS_DUTY,GPS_YEAR,GPS_AREA_ID_FU,ISSUE_DEPT,INPUT_NAME_ID,ISSUE_TIME,PARENT_DEPT_ID,GPS_AREA_CITY_ID from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID='"+taskId+"'";
  1094. try {
  1095. List<Map<String, String>> list = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResultToMap(610, sql);
  1096. return list;
  1097. } catch (PersistenceException e) {
  1098. // TODO Auto-generated catch block
  1099. e.printStackTrace();
  1100. }
  1101. return null;
  1102. }
  1103. public boolean saveUser1(String[] strs) {
  1104. boolean flag = false;
  1105. DbConnection dbConn = new DbConnection();
  1106. Connection conn = null;
  1107. PreparedStatement pstm = null;
  1108. String detailSQL = "update NWYJ.ECM_GPS_USER1 set KHBH = ?, KHMC = ?, TASK_ID = ?, INPUT_UNIT = ?, "
  1109. + "INPUT_USER = ?, INPUT_TIME = ?, UPDATEDATE = ?, IS_DEL = ?, KHLB = ?, GDDW = ?, ZYDJ = ?, DYDJ = ?, ZJRL = ?,"
  1110. + " BAFH = ?, GDXL1 = ?, SJBDZ1 = ?, GDXL2 =?, SJBDZ2 = ?, GDXL3 = ?, SJBDZ3 = ?, GDXL4 = ?, SJBDZ4 = ?, "
  1111. + "GDDYSFMZBZ = ?, ZBYJDYRL = ?, ZBYJDYPB = ?, ZBYJDYSFMZBZ = ?, BEIZHU = ? where FD_OBJECTID = ?";
  1112. try {
  1113. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1114. Date date=new Date();
  1115. String time=format.format(date);
  1116. conn = dbConn.getConnection();
  1117. conn.setAutoCommit(false);
  1118. pstm = conn.prepareStatement(detailSQL);
  1119. pstm.setString(28, getDataByParam(strs[21]));
  1120. pstm.setString(1, getDataByParam(strs[0]));
  1121. pstm.setString(2, getDataByParam(strs[1]));
  1122. pstm.setString(3, getDataByParam(strs[24]));
  1123. pstm.setString(4, getDataByParam(strs[22]));
  1124. pstm.setString(5, getDataByParam(strs[23]));
  1125. pstm.setString(6, time);
  1126. pstm.setString(7, time);
  1127. pstm.setString(8, "0");
  1128. pstm.setString(9, getDataByParam(strs[2]));
  1129. pstm.setString(10, getDataByParam(strs[3]));
  1130. pstm.setString(11, getDataByParam(strs[4]));
  1131. pstm.setString(12, getDataByParam(strs[5]));
  1132. pstm.setString(13, getDataByParam(strs[6]));
  1133. pstm.setString(14, getDataByParam(strs[7]));
  1134. pstm.setString(15, getDataByParam(strs[8]));
  1135. pstm.setString(16, getDataByParam(strs[9]));
  1136. pstm.setString(17, getDataByParam(strs[10]));
  1137. pstm.setString(18, getDataByParam(strs[11]));
  1138. pstm.setString(19, getDataByParam(strs[12]));
  1139. pstm.setString(20, getDataByParam(strs[13]));
  1140. pstm.setString(21, getDataByParam(strs[14]));
  1141. pstm.setString(22, getDataByParam(strs[15]));
  1142. pstm.setString(23, getDataByParam(strs[16]));
  1143. pstm.setString(24, getDataByParam(strs[17]));
  1144. pstm.setString(25, getDataByParam(strs[18]));
  1145. pstm.setString(26, getDataByParam(strs[19]));
  1146. pstm.setString(27, getDataByParam(strs[20]));
  1147. pstm.executeUpdate();
  1148. conn.setAutoCommit(true);
  1149. flag = true;
  1150. }catch(Exception e){
  1151. try {
  1152. conn.rollback();
  1153. conn.setAutoCommit(true);
  1154. } catch (SQLException e1) {
  1155. e1.printStackTrace();
  1156. }
  1157. e.printStackTrace();
  1158. }finally{
  1159. try {
  1160. pstm.close();
  1161. conn.close();
  1162. } catch (SQLException e) {
  1163. e.printStackTrace();
  1164. }
  1165. }
  1166. return flag;
  1167. }
  1168. private String getDataByParam(String param) {
  1169. String data = "";
  1170. if(param!=null && !"".equals(param) && param.contains("=")){
  1171. String[] arr = param.split("=");
  1172. if(arr.length==2){
  1173. data = param.split("=")[1];
  1174. }
  1175. }
  1176. return data;
  1177. }
  1178. /**
  1179. * 表格编辑后保存
  1180. * @param strs
  1181. */
  1182. public boolean saveGpsPlace1(String[] strs) {
  1183. boolean flag = false;
  1184. DbConnection dbConn = new DbConnection();
  1185. Connection conn = null;
  1186. PreparedStatement pstm = null;
  1187. String detailSQL = "update ECM_GPS_PLACE set UPDATEDATE = ?, PLACE_NAME = ?,"
  1188. + " PLACE_CLASSIFICATION = ?, PLACE_LEVEL = ?, PLACE_VOLTAGE_LEVEL = ?,"
  1189. + " QXJHTD = ?,KZYDJC = ?, XZYHCSSY = ?, YJDYZBZY = ?, CYCGXCZS = ?, FDCDR = ?, FDJDR = ? ,PLACE_NUMBER = ? where FD_OBJECTID = ?";
  1190. try {
  1191. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1192. Date date=new Date();
  1193. String time=format.format(date);
  1194. conn = dbConn.getConnection();
  1195. pstm = conn.prepareStatement(detailSQL);
  1196. pstm.setString(1, time);
  1197. pstm.setString(2, getDataByParam(strs[0]));
  1198. pstm.setString(3, getDataByParam(strs[1]));
  1199. pstm.setString(4, getDataByParam(strs[2]));
  1200. pstm.setString(5, getDataByParam(strs[3]));
  1201. pstm.setString(6, getDataByParam(strs[4]));
  1202. pstm.setString(7, getDataByParam(strs[5]));
  1203. pstm.setString(8, getDataByParam(strs[6]));
  1204. pstm.setString(9, getDataByParam(strs[7]));
  1205. pstm.setString(10, getDataByParam(strs[8]));
  1206. pstm.setString(11, getDataByParam(strs[9]));
  1207. pstm.setString(12, getDataByParam(strs[10]));
  1208. pstm.setString(13, getDataByParam(strs[15]));
  1209. pstm.setString(14, getDataByParam(strs[11]));
  1210. pstm.executeUpdate();
  1211. flag = true;
  1212. }catch(Exception e){
  1213. e.printStackTrace();
  1214. }finally{
  1215. try {
  1216. pstm.close();
  1217. conn.close();
  1218. } catch (Exception e) {
  1219. e.printStackTrace();
  1220. }
  1221. }
  1222. return flag;
  1223. }
  1224. public boolean saveGpsEquipment1(String[] strs) {
  1225. boolean flag = false;
  1226. DbConnection dbConn = new DbConnection();
  1227. Connection conn = null;
  1228. PreparedStatement pstm = null;
  1229. String detailSQL = "update ECM_GPS_EQUIPMENT set UPDATEDATE = ?, EQ_NAME = ?,"
  1230. + " EQ_CLASSIFICATION = ?, EQ_LEVEL = ?, EQ_VOLTAGE_LEVEL = ?,"
  1231. + " XUNSHI = ?,BTDJCJPJ = ?, TDSYJPJ = ?,EQ_NUMBER = ? where FD_OBJECTID = ?";
  1232. try {
  1233. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1234. Date date=new Date();
  1235. String time=format.format(date);
  1236. conn = dbConn.getConnection();
  1237. pstm = conn.prepareStatement(detailSQL);
  1238. pstm.setString(1, time);
  1239. pstm.setString(2, getDataByParam(strs[0]));
  1240. pstm.setString(3, getDataByParam(strs[1]));
  1241. pstm.setString(4, getDataByParam(strs[2]));
  1242. pstm.setString(5, getDataByParam(strs[3]));
  1243. pstm.setString(6, getDataByParam(strs[4]));
  1244. pstm.setString(7, getDataByParam(strs[5]));
  1245. pstm.setString(8, getDataByParam(strs[6]));
  1246. pstm.setString(9, getDataByParam(strs[11]));
  1247. pstm.setString(10, getDataByParam(strs[7]));
  1248. pstm.executeUpdate();
  1249. flag = true;
  1250. }catch(Exception e){
  1251. e.printStackTrace();
  1252. }finally{
  1253. try {
  1254. pstm.close();
  1255. conn.close();
  1256. } catch ( Exception e) {
  1257. e.printStackTrace();
  1258. }
  1259. }
  1260. return flag;
  1261. }
  1262. public boolean saveZiYuanBaoBiao(String[] strs) {
  1263. boolean flag = false;
  1264. DbConnection dbConn = new DbConnection();
  1265. Connection conn = null;
  1266. PreparedStatement pstm = null;
  1267. String detailSQL = "update NWYJ.ECM_GPS_ZIYUANBAOBIAO set UPDATEDATE = ?, GPS_TASK_FDC_DAY = ?, "
  1268. + "GPS_TASK__FDC_TOTAL = ?, GPS_TASK_FDJ_DAY = ?, GPS_TASK_FDJ_TOTAL = ?, GPS_TASK_CAR = ?, "
  1269. + "GPS_TASK_ZBZHGLRY = ?, GPS_TASK_BDWBZRY = ?, GPS_TASK_ABRY = ?, GPS_TASK_WWSCRY = ? "
  1270. + "where FD_OBJECTID = ?";
  1271. try {
  1272. DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1273. Date date=new Date();
  1274. String time=format.format(date);
  1275. conn = dbConn.getConnection();
  1276. pstm = conn.prepareStatement(detailSQL);
  1277. pstm.setString(1, time);
  1278. pstm.setString(2, getDataByParam(strs[0]));
  1279. pstm.setString(3, getDataByParam(strs[1]));
  1280. pstm.setString(4, getDataByParam(strs[2]));
  1281. pstm.setString(5, getDataByParam(strs[3]));
  1282. pstm.setString(6, getDataByParam(strs[4]));
  1283. pstm.setString(7, getDataByParam(strs[5]));
  1284. pstm.setString(8, getDataByParam(strs[6]));
  1285. pstm.setString(9, getDataByParam(strs[7]));
  1286. pstm.setString(10, getDataByParam(strs[8]));
  1287. pstm.setString(11, getDataByParam(strs[9]));
  1288. pstm.executeUpdate();
  1289. flag = true;
  1290. }catch(Exception e){
  1291. e.printStackTrace();
  1292. }finally{
  1293. try {
  1294. pstm.close();
  1295. conn.close();
  1296. } catch ( Exception e) {
  1297. e.printStackTrace();
  1298. }
  1299. }
  1300. return flag;
  1301. }
  1302. public String queryTaskUserByTaskId(String taskId) throws SQLException {
  1303. String sql = "select OBJECT_ID , PLAND_ID , CUSTOMER_ID , CUSTOMER_NAME , CUSTOMER_TYPE , POWER_SUPPLY_UNIT , b.dept_name POWER_SUPPLY_UNIT_NAME, (case IMPORT_LEVEL when '0' then '特级' when '1' then '一级' when '2' then '二级' when '3' then '三级' end) IMPORT_LEVEL,C.FD_DESCRIPTION VOLTAGE_LEVEL_SHOW, VOLTAGE_LEVEL , INSTALLED_CAPA_CITY , SECURITY_LOAD , (case ISMEET_OF_SUPPLY when '0' then '满足' when '1' then '不满足' end) ISMEET_OF_SUPPLY , (case IS_MEET_OF_SELF_POVIDE when '0' then '满足' when '1' then '不满足' end) IS_MEET_OF_SELF_POVIDE , RE_MARK , UP_DATE , POWER_SUPPLY , SELF_PROVIDE from NWYJ_SERVICE.MK_POWER_SUPPLY_USER_DATA a,nwyj.sys_department b,bm_mapvaluecanst c where a.POWER_SUPPLY_UNIT = b.base_org_id and to_number(a.VOLTAGE_LEVEL)=to_number(c.fd_code) and c.fd_type='BM_NWYJ_SERVICE_VOLTAGE_GPS' and a.PLAND_ID=?";
  1304. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  1305. list = new ORGTemplate().query(sql, taskId);
  1306. if(list!=null && list.size()==0){
  1307. Map<String, String> map = new HashMap<String, String>();
  1308. map.put("aa", "");
  1309. list.add(map);
  1310. }
  1311. return "{\"rows\":"+JSONArray.fromObject(list).toString()+"}";
  1312. }
  1313. public String getDeptLevelById(String unitId) throws SQLException {
  1314. String sql = "select dept_level from sys_department where dept_id=? and is_del='0' ";
  1315. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  1316. list = new ORGTemplate().query(sql, unitId);
  1317. String dept_level = "";
  1318. if(list!=null && list.size()>0){
  1319. dept_level = list.get(0).get("DEPT_LEVEL");
  1320. }
  1321. return dept_level;
  1322. }
  1323. public String getFenZiUnit() throws SQLException {
  1324. String sql = "select DEPT_ID value,DEPT_NAME key from sys_department where DEPT_LEVEL=2 AND DEPT_LEVEL IS NOT NULL and is_del='0' ";
  1325. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  1326. list = new ORGTemplate().query(sql);
  1327. if(list!=null && list.size()>0){
  1328. return "{\"list\":"+JSONArray.fromObject(list).toString()+"}";
  1329. }else{
  1330. return "{\"list\":[]}";
  1331. }
  1332. }
  1333. }