7052f3a5c9ab3a228dba1a5d984c6261432c3fcc.svn-base 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. package com.sinosoft.em.baobiao.xianlutingyun.dao;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Arrays;
  9. import java.util.Calendar;
  10. import java.util.Collections;
  11. import java.util.Comparator;
  12. import java.util.Date;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. import org.apache.log4j.Logger;
  17. import com.formaction.vo.Msg;
  18. import com.persistence.DbConnection;
  19. import com.persistence.service.PersistenceFactory;
  20. import com.persistence.service.SysPersistence;
  21. import com.persistence.service.exception.PersistenceException;
  22. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  23. import com.sinosoft.cm.ex.SQLStringException;
  24. import com.sinosoft.em.alert.report.manage.SQLPreparedUtil;
  25. import com.sinosoft.em.alert.report.manage.vo.ReportKV;
  26. import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
  27. import com.sinosoft.em.alert.report.manage.vo.reportDept;
  28. import com.sinosoft.em.baobiao.xianlutingyun.vo.ProjectNameVo;
  29. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  30. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  31. public class QueryReportProgrammeDaoImpl implements QueryReportProgrammeDao {
  32. private static SysModel sysmodel = ModelFactory.getSysmodel();
  33. @SuppressWarnings("unused")
  34. private static SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  35. private final static Logger log = Logger.getLogger(QueryReportProgrammeDaoImpl.class);
  36. /**
  37. * 查询部门下报告填报信息
  38. */
  39. public List<ReportProgress> loadReportProgramme(String deptId,String planId,String reportType,
  40. String preproTime,String currprogressTime,String aftTime) throws Exception {
  41. try {
  42. String sql = "SELECT a.FD_OBJECTID,to_char(a.REPORT_TIME,'yyyy-mm-dd hh24:mi:ss'),b.real_name REPORTER_ID,to_char(a.appear_time,'yyyy-mm-dd hh24:mi:ss'),a.REPORT_TYPE,a.comp_id,b.user_id FROM REPORT_RECORDS a,sys_user_info b WHERE a.REPORTER_ID=b.user_id and "+
  43. "a.COMP_ID='"+deptId+"'"+
  44. " AND a.IS_DEL=0 AND a.SEND_STAT='1' AND a.appear_time>=to_char(to_date('"+currprogressTime+"','yyyy-mm-dd hh24:mi:ss')- interval '1' hour,'yyyy-mm-dd hh24:mi:ss') AND a.appear_time<=to_char(to_date('"+currprogressTime+"','yyyy-mm-dd hh24:mi:ss')+ interval '1' hour,'yyyy-mm-dd hh24:mi:ss') and a.report_type='"+reportType+"' and report_id like'%"+planId+"%' order by updatedate desc";
  45. log.info("loadReportProgramme_sql:"+sql);
  46. List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
  47. ArrayList<ReportProgress> list = new ArrayList<ReportProgress>();
  48. if(tempList!=null && tempList.size()>0){
  49. String[] arr = tempList.get(0);
  50. ReportProgress pro = new ReportProgress();
  51. pro.setFd_object_id(arr[0]);
  52. pro.setWRITE_TIME_322(arr[1]);
  53. pro.setWRITER_322(arr[2]);
  54. pro.setUpdateTime(arr[3]);
  55. pro.setWRITER_ID_322(arr[6]);
  56. list.add(pro);
  57. }
  58. log.info("proList:"+list);
  59. return list;
  60. } catch (Exception e) {
  61. throw e;
  62. }
  63. }
  64. /**
  65. * 查询部门
  66. */
  67. public List<reportDept> loadReportDept(String planId,String tbzt) throws Exception {
  68. DbConnection db = new DbConnection();
  69. Connection conn = null;
  70. PreparedStatement ps = null;
  71. ResultSet rs = null;
  72. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  73. try {
  74. String sql = "select WRITE_DEPT_ID,EARLY_WARNING_ID,REPORT_TYPE,START_TIME,(case when "
  75. + "EXPIRATION_DATE='' then to_char(sysdate,'yyyy-mm-dd')||' 23:59:59' else EXPIRATION_DATE end)"
  76. + " as EXPIRATION_DATE,WRITE_DATE_TYPE,CIRCLE_TIME,TEMPORARY_TIME,UPDATEDATE FROM ECM_EM_ALERT_REPORT_PLAN "
  77. +"WHERE FD_OBJECTID='"+planId+"' AND IS_DEL=0 AND IS_RELEASE=1";
  78. log.info("loadReportProgramme_sql:"+sql);
  79. conn = db.getConnection();
  80. ps = conn.prepareStatement(sql);
  81. rs = ps.executeQuery();
  82. //填报部门ID,可以有多个,要进行字符串截取
  83. String deptIds = "";
  84. //预警编号
  85. String earlyWarningId = "";
  86. //报告类别
  87. String reportType = "";
  88. //截止日期
  89. Date expirationData = new Date();
  90. //开始日期
  91. Date startDate = new Date();
  92. //填报时间表
  93. String writeDataType = "";
  94. //周期性
  95. String circleTime = "";
  96. //临时性
  97. String temporaryTime = "";
  98. String updatedate = "";
  99. while(rs.next()){
  100. deptIds = rs.getString("WRITE_DEPT_ID");
  101. earlyWarningId = rs.getString("EARLY_WARNING_ID");
  102. reportType = rs.getString("REPORT_TYPE");
  103. expirationData = rs.getDate("EXPIRATION_DATE");
  104. writeDataType = rs.getString("WRITE_DATE_TYPE");
  105. circleTime = rs.getString("CIRCLE_TIME");
  106. temporaryTime = rs.getString("TEMPORARY_TIME");
  107. startDate = rs.getDate("START_TIME");
  108. //updatedate = rs.getString("UPDATEDATE").split(" ")[0];
  109. updatedate = rs.getString("UPDATEDATE");
  110. }
  111. //通过判断获取离当前时间最近的计划时间
  112. //String progressTime = judgeTime(startDate,expirationData, writeDataType, circleTime, temporaryTime,updatedate);
  113. String progressTime = getProgressTime(writeDataType, circleTime, temporaryTime,updatedate);
  114. String[] deptIdArr = deptIds.split(",");
  115. /*********打桩**********************************************/
  116. log.info("deptIdArr:"+Arrays.toString(deptIdArr));
  117. List<reportDept> depts = loadReportDeptById(deptIdArr, earlyWarningId, reportType,progressTime,planId,tbzt);
  118. return depts;
  119. } catch (Exception e) {
  120. throw e;
  121. }finally{
  122. rs.close();
  123. ps.close();
  124. conn.close();
  125. }
  126. }
  127. /**
  128. * 通过部门ID到部门表中查询出相应的部门名称
  129. * @param planId
  130. * @param tbzt
  131. * @throws Exception
  132. * **/
  133. public List<ReportProgress> loadDeptById(List<String> list) throws Exception{
  134. DbConnection db = new DbConnection();
  135. Connection conn = null;
  136. PreparedStatement ps = null;
  137. ResultSet rs = null;
  138. try {
  139. conn = db.getConnection();
  140. //生成sql语句中in的问号
  141. String inCondition =
  142. SQLPreparedUtil.preparePlaceHolders(list.size());
  143. log.info("inCondition:"+inCondition);
  144. String sql = "select DEPT_NAME,DEPT_ID FROM SYS_DEPARTMENT "+
  145. "WHERE DEPT_ID "+
  146. "IN("+inCondition+")";
  147. log.info("sql_write_dept:"+sql);
  148. ps = conn.prepareStatement(sql);
  149. for (int i = 0; i < list.size(); i++) {
  150. ps.setString(i+1,list.get(i));
  151. }
  152. rs = ps.executeQuery();
  153. //用于存储部门信息
  154. ArrayList<ReportProgress> depts = new ArrayList<ReportProgress>();
  155. while(rs.next()){
  156. ReportProgress dept = new ReportProgress();
  157. dept.setDeptId(rs.getString("DEPT_ID"));
  158. dept.setDeptName(rs.getString("DEPT_NAME"));
  159. depts.add(dept);
  160. }
  161. //部门id和部门名打桩
  162. log.info("depts:"+depts);
  163. return depts ;
  164. } catch (Exception e) {
  165. throw e;
  166. }finally{
  167. rs.close();
  168. ps.close();
  169. conn.close();
  170. }
  171. }
  172. /**
  173. * 通过部门ID到部门表中查询出相应的部门名称
  174. * @param planId
  175. * @param tbzt
  176. * **/
  177. public List<reportDept> loadReportDeptById(String[] deptIdArr,String earlyWarningId,
  178. String reportType,String progressTime, String planId, String tbzt) throws Exception{
  179. DbConnection db = new DbConnection();
  180. Connection conn = null;
  181. PreparedStatement ps = null;
  182. ResultSet rs = null;
  183. try {
  184. conn = db.getConnection();
  185. //生成sql语句中in的问号
  186. String inCondition =
  187. SQLPreparedUtil.preparePlaceHolders(deptIdArr.length);
  188. log.info("inCondition:"+inCondition);
  189. String sql = "select DEPT_NAME,DEPT_ID FROM SYS_DEPARTMENT "+
  190. "WHERE DEPT_ID "+
  191. "IN("+inCondition+")";
  192. log.info("sql_write_dept:"+sql);
  193. ps = conn.prepareStatement(sql);
  194. for (int i = 0; i < deptIdArr.length; i++) {
  195. ps.setString(i+1,deptIdArr[i]);
  196. }
  197. rs = ps.executeQuery();
  198. //用于存储部门信息
  199. ArrayList<reportDept> depts = new ArrayList<reportDept>();
  200. while(rs.next()){
  201. reportDept dept = new reportDept();
  202. dept.setID(rs.getString("DEPT_ID"));
  203. dept.setRESPONSIBLE_NAME_322(rs.getString("DEPT_NAME"));
  204. dept.setIconClass("icon_home");
  205. dept.setOpen(false);
  206. dept.setEarlyWarningId(earlyWarningId);//预警编号
  207. dept.setReportType(reportType);//报告类别
  208. //参数,查看部门下报告填报情况时所用
  209. dept.setParams(dept.getID()+","+planId+","+progressTime+","+dept.getReportType()+","+tbzt);
  210. depts.add(dept);
  211. }
  212. //部门id和部门名打桩
  213. log.info("depts:"+depts);
  214. return depts ;
  215. } catch (Exception e) {
  216. throw e;
  217. }finally{
  218. rs.close();
  219. ps.close();
  220. conn.close();
  221. }
  222. }
  223. /**
  224. * 根据单位id和预警还是响应is_alert,查询相应未完成的填报要求
  225. */
  226. public List<ProjectNameVo> loadReportPlan(String deptId,String role_id) throws Exception {
  227. //系统当前时间
  228. Long currentTime = System.currentTimeMillis();
  229. Date currDate = new Date(currentTime);
  230. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  231. SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  232. String strcurr = dateformat.format(currDate);
  233. String sql="";
  234. List<ProjectNameVo> list1 = new ArrayList<ProjectNameVo>();
  235. List<Map<String,String>> allList = new ArrayList<Map<String,String>>();
  236. List<Map<String,String>> corpList = new ArrayList<Map<String,String>>();
  237. List<Map<String,String>> deptList = new ArrayList<Map<String,String>>();
  238. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  239. List<String> nameList = new ArrayList<String>();
  240. Map<String ,ProjectNameVo> voMap = new HashMap<String,ProjectNameVo>();
  241. if("R002105430205".equals(role_id)||"R002105430204".equals(role_id)||"R002105430203".equals(role_id)||"R002105430202".equals(role_id)||"R002105430201".equals(role_id)||"R002105430200".equals(role_id)){//应急办角色查看本级应急办填报的计划和同级专业管理部门已发布的计划
  242. sql="select comp_id,project_name,warning_number,FD_OBJECTID,START_TIME,UPDATEDATE,SEND_TIME,FILL_IN_SCHEDULE,ROUND_TIME,TEMPORARY_TIME,report_dept,role_id,end_time,send_stat from REPORT_SCHEDULE where (END_TIME>=TO_CHAR(TO_DATE(?,'yyyy-mm-dd'),'yyyy-mm-dd') or END_TIME IS NULL or end_time='') and TO_CHAR(TO_DATE(START_TIME,'yyyy-mm-dd'),'yyyy-mm-dd')<=TO_CHAR(TO_DATE(?,'yyyy-mm-dd'),'yyyy-mm-dd') and ((role_id=? and comp_id=?) or (role_id <>? and send_stat='1' and comp_id=?)) and is_del='0' and send_stat='1' AND (round_time is not null or TEMPORARY_TIME is not null ) order by to_number(substr(role_id,4))";
  243. list=new ORGTemplate().query(sql, strcurr,strcurr,role_id,deptId,role_id,deptId);
  244. }else{//专业管理部门角色查看本级应急办已发布的计划和上级专业管理部门已发布的计划还有给下级的计划
  245. sql="select comp_id,project_name,warning_number,FD_OBJECTID,START_TIME,UPDATEDATE,SEND_TIME,FILL_IN_SCHEDULE,ROUND_TIME,TEMPORARY_TIME,report_dept,role_id,end_time,send_stat from REPORT_SCHEDULE where (END_TIME>=TO_CHAR(TO_DATE(?,'yyyy-mm-dd'),'yyyy-mm-dd') or END_TIME IS NULL or end_time='') and TO_CHAR(TO_DATE(START_TIME,'yyyy-mm-dd'),'yyyy-mm-dd')<=TO_CHAR(TO_DATE(?,'yyyy-mm-dd'),'yyyy-mm-dd') and ((role_id='R002105430205'and comp_id=? and send_stat='1' and report_dept like ?) or (role_id =? and send_stat='1' and comp_id in(select parent_id from sys_department where dept_id=?)) or(comp_id=? and role_id=?)) and send_stat='1' order by to_number(substr(role_id,4))";
  246. list=new ORGTemplate().query(sql, strcurr,strcurr,deptId,"%"+role_id+"%",role_id,deptId,deptId,role_id);
  247. }
  248. log.info("loadReportProgramme_sql:"+sql);
  249. try {
  250. for (int i = 0; i < list.size(); i++) {
  251. Map<String, String> map = list.get(i);
  252. String WRITE_DATE_TYPE = map.get("FILL_IN_SCHEDULE");//填报类型
  253. String send_stat= map.get("SEND_STAT");//发布状态
  254. if("2".equals(send_stat)){
  255. map.put("PROJECT_NAME", map.get("PROJECT_NAME")+"(已结束)");
  256. }
  257. if("周期性".equals(WRITE_DATE_TYPE)){//周期性
  258. String CIRCLE_TIME = map.get("ROUND_TIME");//周期性时间
  259. if(!"".equals(CIRCLE_TIME.trim()) && CIRCLE_TIME.indexOf("NaN")==-1){//只有当周期性时间不为空 且 没有有错误时间格式时,才添加该条数据
  260. String sendTime = map.get("SEND_TIME");
  261. String sendTime1 = "";
  262. if(sendTime!=null && !"".equals(sendTime)){
  263. sendTime1 = sendTime.split(" ")[0];
  264. }
  265. String currTime = strcurr.split(" ")[0];//年月日
  266. if(sendTime1.equals(currTime)){//当发布日期与当前日期处于同一日时,再判断周期性最后那个时间点是否已经超过当前时间的时间点,比如发布时间:2-7 17:30 周期性时间:8:00,17:00
  267. // int lastRoundTime = getLastRoundTime(CIRCLE_TIME);//取得周期性时间的最大时间的小时值
  268. //String currHour = strcurr.split(" ")[1].split(":")[0];
  269. // if(Integer.parseInt(currHour) < lastRoundTime){
  270. if("R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  271. if(!voMap.containsKey("本级计划")){
  272. ProjectNameVo allVo = new ProjectNameVo();
  273. allVo.setName("本级计划");
  274. allList.add(map);
  275. allVo.setList(allList);
  276. if(!nameList.contains("本级计划")){
  277. nameList.add("本级计划");
  278. }
  279. voMap.put("本级计划", allVo);
  280. }else {
  281. ProjectNameVo allVo = voMap.get("本级计划");
  282. List<Map<String,String>> li = allVo.getList();
  283. li.add(map);
  284. allVo.setList(li);
  285. voMap.put("本级计划", allVo);
  286. }
  287. }
  288. if(!"R002105430205".equals(role_id)){
  289. if(checkLevel(deptId, role_id,map.get("FD_OBJECTID"))){
  290. if(!voMap.containsKey("上级计划")){
  291. ProjectNameVo corpVo = new ProjectNameVo();
  292. corpVo.setName("上级计划");
  293. corpList.add(map);
  294. corpVo.setList(corpList);
  295. if(!nameList.contains("上级计划")){
  296. nameList.add("上级计划");
  297. }
  298. voMap.put("上级计划", corpVo);
  299. }else {
  300. ProjectNameVo corpVo = voMap.get("上级计划");
  301. List<Map<String,String>> li = corpVo.getList();
  302. li.add(map);
  303. corpVo.setList(li);
  304. voMap.put("上级计划", corpVo);
  305. }
  306. }
  307. if(!"R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  308. if(!voMap.containsKey("下级计划")){
  309. ProjectNameVo deptVo = new ProjectNameVo();
  310. deptVo.setName("下级计划");
  311. deptList.add(map);
  312. deptVo.setList(deptList);
  313. if(!nameList.contains("下级计划")){
  314. nameList.add("下级计划");
  315. }
  316. voMap.put("下级计划", deptVo);
  317. }else {
  318. ProjectNameVo deptVo = voMap.get("下级计划");
  319. List<Map<String,String>> li = deptVo.getList();
  320. li.add(map);
  321. deptVo.setList(li);
  322. voMap.put("下级计划", deptVo);
  323. }
  324. }
  325. }
  326. }else{
  327. if("R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  328. if(!voMap.containsKey("本级计划")){
  329. ProjectNameVo allVo = new ProjectNameVo();
  330. allVo.setName("本级计划");
  331. allList.add(map);
  332. allVo.setList(allList);
  333. if(!nameList.contains("本级计划")){
  334. nameList.add("本级计划");
  335. }
  336. voMap.put("本级计划", allVo);
  337. }else {
  338. ProjectNameVo allVo = voMap.get("本级计划");
  339. List<Map<String,String>> li = allVo.getList();
  340. li.add(map);
  341. allVo.setList(li);
  342. voMap.put("本级计划", allVo);
  343. }
  344. }
  345. if(!"R002105430205".equals(role_id)){
  346. if(checkLevel(deptId, role_id,map.get("FD_OBJECTID"))){
  347. if(!voMap.containsKey("上级计划")){
  348. ProjectNameVo corpVo = new ProjectNameVo();
  349. corpVo.setName("上级计划");
  350. corpList.add(map);
  351. corpVo.setList(corpList);
  352. if(!nameList.contains("上级计划")){
  353. nameList.add("上级计划");
  354. }
  355. voMap.put("上级计划", corpVo);
  356. }else {
  357. ProjectNameVo corpVo = voMap.get("上级计划");
  358. List<Map<String,String>> li = corpVo.getList();
  359. li.add(map);
  360. corpVo.setList(li);
  361. voMap.put("上级计划", corpVo);
  362. }
  363. }
  364. if(!"R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  365. if(!voMap.containsKey("下级计划")){
  366. ProjectNameVo deptVo = new ProjectNameVo();
  367. deptVo.setName("下级计划");
  368. deptList.add(map);
  369. deptVo.setList(deptList);
  370. if(!nameList.contains("下级计划")){
  371. nameList.add("下级计划");
  372. }
  373. voMap.put("下级计划", deptVo);
  374. }else {
  375. ProjectNameVo deptVo = voMap.get("下级计划");
  376. List<Map<String,String>> li = deptVo.getList();
  377. li.add(map);
  378. deptVo.setList(li);
  379. voMap.put("下级计划", deptVo);
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }else{//临时性
  386. String TEMPORARY_TIME = map.get("TEMPORARY_TIME");
  387. if(TEMPORARY_TIME!=null && !"".equals(TEMPORARY_TIME.trim()) && TEMPORARY_TIME.indexOf("NaN")==-1){//只有当周期性时间不为空 且 没有有错误时间格式时,才添加该条数据
  388. if("R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  389. if(!voMap.containsKey("本级计划")){
  390. ProjectNameVo allVo = new ProjectNameVo();
  391. allVo.setName("本级计划");
  392. allList.add(map);
  393. allVo.setList(allList);
  394. if(!nameList.contains("本级计划")){
  395. nameList.add("本级计划");
  396. }
  397. voMap.put("本级计划", allVo);
  398. }else {
  399. ProjectNameVo allVo = voMap.get("本级计划");
  400. List<Map<String,String>> li = allVo.getList();
  401. li.add(map);
  402. allVo.setList(li);
  403. voMap.put("本级计划", allVo);
  404. }
  405. }
  406. if(!"R002105430205".equals(role_id)){
  407. if(checkLevel(deptId, role_id,map.get("FD_OBJECTID"))){
  408. if(!voMap.containsKey("上级计划")){
  409. ProjectNameVo corpVo = new ProjectNameVo();
  410. corpVo.setName("上级计划");
  411. corpList.add(map);
  412. corpVo.setList(corpList);
  413. if(!nameList.contains("上级计划")){
  414. nameList.add("上级计划");
  415. }
  416. voMap.put("上级计划", corpVo);
  417. }else {
  418. ProjectNameVo corpVo = voMap.get("上级计划");
  419. List<Map<String,String>> li = corpVo.getList();
  420. li.add(map);
  421. corpVo.setList(li);
  422. voMap.put("上级计划", corpVo);
  423. }
  424. }
  425. if(!"R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  426. if(!voMap.containsKey("下级计划")){
  427. ProjectNameVo deptVo = new ProjectNameVo();
  428. deptVo.setName("下级计划");
  429. deptList.add(map);
  430. deptVo.setList(deptList);
  431. if(!nameList.contains("下级计划")){
  432. nameList.add("下级计划");
  433. }
  434. voMap.put("下级计划", deptVo);
  435. }else {
  436. ProjectNameVo deptVo = voMap.get("下级计划");
  437. List<Map<String,String>> li = deptVo.getList();
  438. li.add(map);
  439. deptVo.setList(li);
  440. voMap.put("下级计划", deptVo);
  441. }
  442. }
  443. }
  444. }
  445. }
  446. }
  447. Collections.sort(nameList, new compareList());
  448. for(int k=0;k<nameList.size();k++){
  449. log.info(nameList.get(k)+"=====k");
  450. list1.add(voMap.get(nameList.get(k)));
  451. }
  452. return list1;
  453. } catch (Exception e) {
  454. e.printStackTrace();
  455. }
  456. return null;
  457. }
  458. /**
  459. * 根据单位id和预警还是响应is_alert,查询相应未完成的填报要求
  460. */
  461. public List<ProjectNameVo> loadReportPlan(String deptId,String role_id,String flag,String task_id) throws Exception {
  462. //系统当前时间
  463. Long currentTime = System.currentTimeMillis();
  464. Date currDate = new Date(currentTime);
  465. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  466. SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  467. String strcurr = dateformat.format(currDate);
  468. List<ProjectNameVo> list1 = new ArrayList<ProjectNameVo>();
  469. List<Map<String,String>> allList = new ArrayList<Map<String,String>>();
  470. List<Map<String,String>> corpList = new ArrayList<Map<String,String>>();
  471. List<Map<String,String>> deptList = new ArrayList<Map<String,String>>();
  472. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  473. List<String> nameList = new ArrayList<String>();
  474. Map<String ,ProjectNameVo> voMap = new HashMap<String,ProjectNameVo>();
  475. StringBuffer sb = new StringBuffer();
  476. if(task_id.indexOf(",")>-1){
  477. String[] arr = task_id.split(",");
  478. for (int i = 0; i < arr.length; i++) {
  479. sb.append("'"+arr[i]+"',");
  480. }
  481. sb.deleteCharAt(sb.lastIndexOf(","));
  482. }else{
  483. sb.append("'"+task_id+"'");
  484. }
  485. //根据任务ID查询
  486. String sql = "select comp_id,project_name,warning_number,FD_OBJECTID,START_TIME,UPDATEDATE,SEND_TIME,FILL_IN_SCHEDULE,ROUND_TIME,TEMPORARY_TIME,report_dept,role_id,end_time,send_stat from REPORT_SCHEDULE where fd_objectid in("+sb.toString()+")";
  487. log.info("loadReportProgramme_sql:"+sql);
  488. list = new ORGTemplate().query(sql);
  489. try {
  490. for (int i = 0; i < list.size(); i++) {
  491. Map<String, String> map = list.get(i);
  492. String WRITE_DATE_TYPE = map.get("FILL_IN_SCHEDULE");//填报类型
  493. String send_stat= map.get("SEND_STAT");//发布状态
  494. if("2".equals(send_stat)){
  495. map.put("PROJECT_NAME", map.get("PROJECT_NAME")+"(已结束)");
  496. }
  497. if("周期性".equals(WRITE_DATE_TYPE)){//周期性
  498. String CIRCLE_TIME = map.get("ROUND_TIME");//周期性时间
  499. if(!"".equals(CIRCLE_TIME.trim()) && CIRCLE_TIME.indexOf("NaN")==-1){//只有当周期性时间不为空 且 没有有错误时间格式时,才添加该条数据
  500. String sendTime = map.get("SEND_TIME");
  501. String sendTime1 = "";
  502. if(sendTime!=null && !"".equals(sendTime)){
  503. sendTime1 = sendTime.split(" ")[0];
  504. }
  505. String currTime = strcurr.split(" ")[0];//年月日
  506. if(sendTime1.equals(currTime)){//当发布日期与当前日期处于同一日时,再判断周期性最后那个时间点是否已经超过当前时间的时间点,比如发布时间:2-7 17:30 周期性时间:8:00,17:00
  507. // int lastRoundTime = getLastRoundTime(CIRCLE_TIME);//取得周期性时间的最大时间的小时值
  508. //String currHour = strcurr.split(" ")[1].split(":")[0];
  509. // if(Integer.parseInt(currHour) < lastRoundTime){
  510. if("R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  511. if(!voMap.containsKey("本级计划")){
  512. ProjectNameVo allVo = new ProjectNameVo();
  513. allVo.setName("本级计划");
  514. allList.add(map);
  515. allVo.setList(allList);
  516. if(!nameList.contains("本级计划")){
  517. nameList.add("本级计划");
  518. }
  519. voMap.put("本级计划", allVo);
  520. }else {
  521. ProjectNameVo allVo = voMap.get("本级计划");
  522. List<Map<String,String>> li = allVo.getList();
  523. li.add(map);
  524. allVo.setList(li);
  525. voMap.put("本级计划", allVo);
  526. }
  527. }
  528. if(!"R002105430205".equals(role_id)){
  529. if(checkLevel(deptId, role_id,map.get("FD_OBJECTID"))){
  530. if(!voMap.containsKey("上级计划")){
  531. ProjectNameVo corpVo = new ProjectNameVo();
  532. corpVo.setName("上级计划");
  533. corpList.add(map);
  534. corpVo.setList(corpList);
  535. if(!nameList.contains("上级计划")){
  536. nameList.add("上级计划");
  537. }
  538. voMap.put("上级计划", corpVo);
  539. }else {
  540. ProjectNameVo corpVo = voMap.get("上级计划");
  541. List<Map<String,String>> li = corpVo.getList();
  542. li.add(map);
  543. corpVo.setList(li);
  544. voMap.put("上级计划", corpVo);
  545. }
  546. }
  547. if(!"R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  548. if(!voMap.containsKey("下级计划")){
  549. ProjectNameVo deptVo = new ProjectNameVo();
  550. deptVo.setName("下级计划");
  551. deptList.add(map);
  552. deptVo.setList(deptList);
  553. if(!nameList.contains("下级计划")){
  554. nameList.add("下级计划");
  555. }
  556. voMap.put("下级计划", deptVo);
  557. }else {
  558. ProjectNameVo deptVo = voMap.get("下级计划");
  559. List<Map<String,String>> li = deptVo.getList();
  560. li.add(map);
  561. deptVo.setList(li);
  562. voMap.put("下级计划", deptVo);
  563. }
  564. }
  565. }
  566. }else{
  567. if("R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  568. if(!voMap.containsKey("本级计划")){
  569. ProjectNameVo allVo = new ProjectNameVo();
  570. allVo.setName("本级计划");
  571. allList.add(map);
  572. allVo.setList(allList);
  573. if(!nameList.contains("本级计划")){
  574. nameList.add("本级计划");
  575. }
  576. voMap.put("本级计划", allVo);
  577. }else {
  578. ProjectNameVo allVo = voMap.get("本级计划");
  579. List<Map<String,String>> li = allVo.getList();
  580. li.add(map);
  581. allVo.setList(li);
  582. voMap.put("本级计划", allVo);
  583. }
  584. }
  585. if(!"R002105430205".equals(role_id)){
  586. if(checkLevel(deptId, role_id,map.get("FD_OBJECTID"))){
  587. if(!voMap.containsKey("上级计划")){
  588. ProjectNameVo corpVo = new ProjectNameVo();
  589. corpVo.setName("上级计划");
  590. corpList.add(map);
  591. corpVo.setList(corpList);
  592. if(!nameList.contains("上级计划")){
  593. nameList.add("上级计划");
  594. }
  595. voMap.put("上级计划", corpVo);
  596. }else {
  597. ProjectNameVo corpVo = voMap.get("上级计划");
  598. List<Map<String,String>> li = corpVo.getList();
  599. li.add(map);
  600. corpVo.setList(li);
  601. voMap.put("上级计划", corpVo);
  602. }
  603. }
  604. if(!"R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  605. if(!voMap.containsKey("下级计划")){
  606. ProjectNameVo deptVo = new ProjectNameVo();
  607. deptVo.setName("下级计划");
  608. deptList.add(map);
  609. deptVo.setList(deptList);
  610. if(!nameList.contains("下级计划")){
  611. nameList.add("下级计划");
  612. }
  613. voMap.put("下级计划", deptVo);
  614. }else {
  615. ProjectNameVo deptVo = voMap.get("下级计划");
  616. List<Map<String,String>> li = deptVo.getList();
  617. li.add(map);
  618. deptVo.setList(li);
  619. voMap.put("下级计划", deptVo);
  620. }
  621. }
  622. }
  623. }
  624. }
  625. }else{//临时性
  626. String TEMPORARY_TIME = map.get("TEMPORARY_TIME");
  627. if(TEMPORARY_TIME!=null && !"".equals(TEMPORARY_TIME.trim()) && TEMPORARY_TIME.indexOf("NaN")==-1){//只有当周期性时间不为空 且 没有有错误时间格式时,才添加该条数据
  628. if("R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  629. if(!voMap.containsKey("本级计划")){
  630. ProjectNameVo allVo = new ProjectNameVo();
  631. allVo.setName("本级计划");
  632. allList.add(map);
  633. allVo.setList(allList);
  634. if(!nameList.contains("本级计划")){
  635. nameList.add("本级计划");
  636. }
  637. voMap.put("本级计划", allVo);
  638. }else {
  639. ProjectNameVo allVo = voMap.get("本级计划");
  640. List<Map<String,String>> li = allVo.getList();
  641. li.add(map);
  642. allVo.setList(li);
  643. voMap.put("本级计划", allVo);
  644. }
  645. }
  646. if(!"R002105430205".equals(role_id)){
  647. if(checkLevel(deptId, role_id,map.get("FD_OBJECTID"))){
  648. if(!voMap.containsKey("上级计划")){
  649. ProjectNameVo corpVo = new ProjectNameVo();
  650. corpVo.setName("上级计划");
  651. corpList.add(map);
  652. corpVo.setList(corpList);
  653. if(!nameList.contains("上级计划")){
  654. nameList.add("上级计划");
  655. }
  656. voMap.put("上级计划", corpVo);
  657. }else {
  658. ProjectNameVo corpVo = voMap.get("上级计划");
  659. List<Map<String,String>> li = corpVo.getList();
  660. li.add(map);
  661. corpVo.setList(li);
  662. voMap.put("上级计划", corpVo);
  663. }
  664. }
  665. if(!"R002105430205".equals(map.get("ROLE_ID"))&& deptId.equals(map.get("COMP_ID"))){
  666. if(!voMap.containsKey("下级计划")){
  667. ProjectNameVo deptVo = new ProjectNameVo();
  668. deptVo.setName("下级计划");
  669. deptList.add(map);
  670. deptVo.setList(deptList);
  671. if(!nameList.contains("下级计划")){
  672. nameList.add("下级计划");
  673. }
  674. voMap.put("下级计划", deptVo);
  675. }else {
  676. ProjectNameVo deptVo = voMap.get("下级计划");
  677. List<Map<String,String>> li = deptVo.getList();
  678. li.add(map);
  679. deptVo.setList(li);
  680. voMap.put("下级计划", deptVo);
  681. }
  682. }
  683. }
  684. }
  685. }
  686. }
  687. Collections.sort(nameList, new compareList());
  688. for(int k=0;k<nameList.size();k++){
  689. log.info(nameList.get(k)+"=====k");
  690. list1.add(voMap.get(nameList.get(k)));
  691. }
  692. return list1;
  693. } catch (Exception e) {
  694. e.printStackTrace();
  695. }
  696. return null;
  697. }
  698. /**
  699. * 根据报告类别的常量id查询相应的报告类别名称
  700. */
  701. @Override
  702. public ArrayList<ReportKV> loadReportTypeName(String[] id,boolean flag) throws Exception {
  703. DbConnection db = new DbConnection();
  704. Connection conn = null;
  705. PreparedStatement ps = null;
  706. ResultSet rs = null;
  707. try {
  708. // String conditionOfReportType = "";
  709. // String bm = "BM_AlertRespReportInputState";
  710. // if(id.length==1){
  711. // conditionOfReportType = " FD_CODE='"+id+"'";
  712. // }else if(id.length()==3){
  713. // String[] reportArr = id.split(",");
  714. // conditionOfReportType = " FD_CODE in ('"+reportArr[0]+"','"+reportArr[1]+"')";
  715. // }
  716. StringBuffer condition=new StringBuffer();
  717. for(int i=0;i<id.length;i++){
  718. condition.append("'"+id[i]+"',");
  719. }
  720. if(condition.lastIndexOf(",")>-1){
  721. condition.deleteCharAt(condition.lastIndexOf(","));
  722. }
  723. String sql ="";
  724. if(flag){
  725. sql = "select report_name,report_type from bm_mapforreport "+
  726. "where report_name in("+condition.toString()+")";
  727. }else{
  728. sql = "select report_name,report_type from bm_mapforreport "+
  729. "where report_type in("+condition.toString()+")";
  730. }
  731. conn = db.getConnection();
  732. ps = conn.prepareStatement(sql);
  733. rs = ps.executeQuery();
  734. ArrayList<ReportKV>list = new ArrayList<ReportKV>();
  735. while(rs.next()){
  736. ReportKV rkv = new ReportKV();
  737. String name = rs.getString("REPORT_NAME");
  738. String proid = rs.getString("REPORT_TYPE");
  739. rkv.setId(proid);
  740. rkv.setName(name);
  741. list.add(rkv);
  742. }
  743. return list;
  744. } catch (Exception e) {
  745. throw e;
  746. }finally{
  747. rs.close();
  748. ps.close();
  749. conn.close();
  750. }
  751. }
  752. private String getProgressTime(String writeDataType, String circleTime, String temporaryTime, String updatedate) throws ParseException {
  753. //系统当前时间
  754. Long currentTime = System.currentTimeMillis();
  755. Date currDate = new Date(currentTime);
  756. //当前时间
  757. Calendar curr = Calendar.getInstance();
  758. curr.setTime(currDate);
  759. //日期
  760. String _date = ""+curr.get(Calendar.YEAR)+"-"
  761. +(curr.get(Calendar.MONTH)+1)+"-"+curr.get(Calendar.DATE);
  762. //计划时间
  763. String prograssTime = "";
  764. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  765. if("周期性".equals(writeDataType)){
  766. String[] cirTimeArr1 = circleTime.split(";");
  767. for (int i = 0; i < cirTimeArr1.length; i++) {
  768. if(!"".equals(cirTimeArr1[i].trim())){
  769. String timea = _date + " " +cirTimeArr1[i].trim()+":00";
  770. if(dateformat.parse(timea).after(dateformat.parse(updatedate))){//计划时间要在发布时间之后
  771. prograssTime += timea;
  772. if(i<cirTimeArr1.length-1){
  773. prograssTime += "|";
  774. }
  775. }
  776. }
  777. }
  778. }else if("临时性".equals(writeDataType)){
  779. String[] temArr = temporaryTime.split(";");
  780. for (int i = 0; i < temArr.length; i++) {
  781. prograssTime += temArr[i];
  782. if(i<temArr.length-1){
  783. prograssTime += "|";
  784. }
  785. }
  786. }
  787. return prograssTime;
  788. }
  789. public String judgeTime(Date startDate,Date expirationData, String writeDataType,String circleTime,
  790. String temporaryTime, String updatedate) throws ParseException{
  791. //系统当前时间
  792. Long currentTime = System.currentTimeMillis();
  793. Date currDate = new Date(currentTime);
  794. //当前时间
  795. Calendar curr = Calendar.getInstance();
  796. curr.setTime(currDate);
  797. //日期
  798. String _date = ""+curr.get(Calendar.YEAR)+"-"
  799. +(curr.get(Calendar.MONTH)+1)+"-"+curr.get(Calendar.DATE);
  800. //时间
  801. Integer _time = curr.get(Calendar.HOUR_OF_DAY);
  802. if(expirationData==null){
  803. expirationData = new Date(curr.get(Calendar.YEAR), (curr.get(Calendar.MONTH)+1),
  804. curr.get(Calendar.DATE));
  805. }
  806. //计划时间
  807. String prograssTime = ""+_date+" ";
  808. //当前计划时间监控的范围之开始时间
  809. String preProTime = _date + " 00:00";
  810. String aftProTime = _date + " 23:59";
  811. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  812. SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  813. //判断填报时间表类型
  814. if("周期性".equals(writeDataType)){
  815. if(updatedate.equals(_date)){
  816. String[] cirTimeArr = circleTime.split(",");
  817. int k = 0;
  818. for (int i = 0; i < cirTimeArr.length; i++) {
  819. String hour1 = cirTimeArr[i].substring(0,cirTimeArr[i].indexOf(":"));
  820. if(_time<=Integer.parseInt(hour1)){
  821. k = i;
  822. if(k != 0){ //若当前计划时间不是第一个
  823. preProTime = _date + " " + pretime(cirTimeArr[k]);
  824. }
  825. if(k != (cirTimeArr.length-1)){ //若当前计划时间不是最后一个
  826. aftProTime = _date + " " + pretime(cirTimeArr[k+1]);
  827. }
  828. }
  829. }
  830. }else{
  831. //如果填报时间表类型是周期性,可能存有多个时间点
  832. String[] cirTimeArr1 = circleTime.split(";");
  833. ArrayList<String> cirTimeArr = new ArrayList<String>();
  834. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  835. SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
  836. //计划截止时间
  837. Date expirationTime;
  838. expirationTime = sdf.parse(sdf1.format(expirationData)+" 23:59:59");/*+cirTimeArr[cirTimeArr.length-1]);*/
  839. if(expirationTime != null && expirationTime.before(currDate)){
  840. /*************/ return "";//抛出异常:当前计划已结束(过期)
  841. }
  842. for (int i = 0; i < cirTimeArr1.length; i++) {
  843. if(!"".equals(cirTimeArr1[i].trim())){
  844. cirTimeArr.add(cirTimeArr1[i].trim());
  845. }
  846. }
  847. //用于记录当前计划时间下标
  848. int k = 0;
  849. if(cirTimeArr.size()>1){
  850. //如果劈开有多个时间点,则判断哪个时间最近,取最近的时间
  851. //cirTimeArr.get(0)格式为16:30,需再劈开
  852. //数组长度
  853. int arrLength = cirTimeArr.size();
  854. //数组中第一个时间点
  855. String hour1 = cirTimeArr.get(0).substring(0,cirTimeArr.get(0).indexOf(":"));
  856. //数组中最后一个时间点
  857. String hour2 = cirTimeArr.get(arrLength-1).substring(0,cirTimeArr.get(arrLength-1).indexOf(":"));
  858. if(_time <= Integer.parseInt(hour1)){//如果在第一个时间点之前,则计划时间为第一个时间点
  859. k = 0;
  860. //第二个时间点
  861. aftProTime = _date + " " + pretime(cirTimeArr.get(1));
  862. }else if(_time >= Integer.parseInt(hour2)){//如果在最后一个时间点之后,则计划时间为最后一个时间点
  863. k = arrLength-1;
  864. //最后一个时间点
  865. preProTime = _date + " " + pretime(cirTimeArr.get(arrLength-1));
  866. }else if(Integer.parseInt(hour1) < _time && _time< Integer.parseInt(hour2)){//若是在第一个和最后一个时间点之间
  867. int j = 0;
  868. //遍历周期性时间,判断当前时间处于哪两个时间点之间
  869. while((j+1) <= cirTimeArr.size()-1){
  870. hour1 = cirTimeArr.get(j).substring(0,cirTimeArr.get(j).indexOf(":"));
  871. hour2 = cirTimeArr.get(j+1).substring(0,cirTimeArr.get(j+1).indexOf(":"));
  872. if(Integer.parseInt(hour1) <= _time && _time< Integer.parseInt(hour2)){
  873. if(_time < Integer.parseInt(hour2)-1){//如果在第二个计划时间-1小时之前,则第一个时间为计划时间
  874. k = j;
  875. if(k != 0){ //若当前计划时间不是第一个
  876. preProTime = _date + " " + pretime(cirTimeArr.get(k));
  877. }
  878. aftProTime = _date + " " + pretime(cirTimeArr.get(k+1));
  879. }else{
  880. k = j+1;
  881. if(k != (arrLength-1)){ //若当前计划时间不是最后一个
  882. aftProTime = _date + " " + pretime(cirTimeArr.get(k+1));
  883. }
  884. preProTime = _date + " " + pretime(cirTimeArr.get(k));
  885. }
  886. }
  887. j++;
  888. }
  889. }
  890. prograssTime += cirTimeArr.get(k);
  891. }else{
  892. //若数组中只有一个值
  893. prograssTime += cirTimeArr.get(0);
  894. }
  895. }
  896. }else if("临时性".equals(writeDataType)){
  897. preProTime = dateformat.format(startDate);
  898. aftProTime = _date + " 23:59";
  899. //如果填报时间表类型是临时性,临时性时间格式为:“2015-11-27 11:28,2015-12-17 10:28,2015-12-27 11:28”;
  900. String[] temArr = temporaryTime.split(",");
  901. int temArrLength = temArr.length;
  902. int k = 0;
  903. if(temArr.length>1){//两个或两个以上时间点
  904. if(currDate.before(dateformat1.parse(temArr[0]))){//若当前时间在第一个时间点之前,则计划时间为第一个时间,监控的结尾时间为下个时间点点前一个小时
  905. String aftDay = temArr[1].substring(0,10);
  906. String afthour = temArr[1].substring(11,13);
  907. aftProTime = aftDay + " " + afthour + ":00";
  908. }else if(currDate.after(dateformat1.parse(temArr[temArrLength-1]))){
  909. //若当前时间在最后时间点之后,则计划时间为最后后一个时间,监控的开始时间为上一个计划时间,监控的结尾时间为今日23点59分
  910. k = temArrLength-1;
  911. preProTime = temArr[temArrLength-2];
  912. }else{
  913. int j = 0;
  914. while((j+1) <= temArrLength-1){
  915. Date date1 = dateformat1.parse(temArr[j]);
  916. Date date2 = dateformat1.parse(temArr[j+1]);
  917. if(currDate.before(date2) && currDate.after(date1)){
  918. Calendar caldate2 = Calendar.getInstance();
  919. caldate2.setTime(date2);//date 换成已经已知的Date对象
  920. caldate2.add(Calendar.HOUR_OF_DAY, -1);// 第二个计划时间的前一个小时
  921. if(currDate.before(caldate2.getTime())){//如果在第二个计划时间-1小时之前,则第一个时间为计划时间
  922. k = j;
  923. if(k != 0){ //若当前计划时间不是第一个,则监控开始时间为k前一个计划时间
  924. Calendar caldate1 = Calendar.getInstance();
  925. caldate1.setTime(dateformat1.parse(temArr[k]));
  926. caldate1.add(Calendar.HOUR_OF_DAY, -1);// 前一个小时
  927. preProTime = dateformat1.format(caldate1.getTime());
  928. }
  929. aftProTime = dateformat1.format(caldate2.getTime());
  930. }else{
  931. k = j+1;
  932. if(k != (temArrLength-1)){ //若当前计划时间不是最后一个
  933. Calendar caldate3 = Calendar.getInstance();
  934. caldate3.setTime(dateformat1.parse(temArr[k+1]));
  935. caldate3.add(Calendar.HOUR_OF_DAY, -1);
  936. aftProTime = dateformat1.format(caldate3.getTime());
  937. }
  938. Calendar caldate4 = Calendar.getInstance();
  939. caldate4.setTime(dateformat1.parse(temArr[k]));
  940. caldate4.add(Calendar.HOUR_OF_DAY, -1);
  941. preProTime = dateformat1.format(caldate4.getTime());
  942. }
  943. }
  944. j++;
  945. }
  946. }
  947. prograssTime = temArr[k];
  948. }else{
  949. prograssTime = temArr[0];
  950. }
  951. }
  952. return preProTime + "," + prograssTime + "," + aftProTime;
  953. }
  954. /**
  955. * 解析字符串,返回前一个小时时间
  956. * 解析16:30字符串,返回15:30字符串
  957. * @param time
  958. * @return
  959. */
  960. private String pretime(String time){
  961. String hour = time.substring(0,time.indexOf(":"));
  962. String minit = time.substring(time.indexOf(":"),time.length());
  963. Integer prehour = Integer.parseInt(hour)-1;
  964. return prehour.toString()+""+minit;
  965. }
  966. // public static void main(String[] args) {
  967. // QueryReportProgrammeDaoImpl dao = new QueryReportProgrammeDaoImpl();
  968. // try {
  969. // dao.loadReportProgramme("320144176508172800000071100000");
  970. // } catch (Exception e) {
  971. //
  972. // e.printStackTrace();
  973. // }
  974. // }
  975. @Override
  976. public String send(/*String fd_id, String userId,*/ String comp_id) {
  977. Msg m = new Msg();
  978. String sql = "select c.real_name,c.mobile from sys_user_role_rel a,sys_dept_user b,sys_user_info c "
  979. + "where a.role_id='R002105430205' and a.user_id=b.user_id and b.dept_id in ("
  980. + comp_id+ ") and a.user_id=c.user_id";
  981. log.info("sendMsgToEmergencysql====" + sql);
  982. StringBuffer sbtel = new StringBuffer();
  983. StringBuffer sbname = new StringBuffer();
  984. StringBuffer sb = new StringBuffer();
  985. sbtel.append("");
  986. sb.append("");
  987. sbname.append("");
  988. sb.append("{\"list\":");
  989. try {
  990. List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
  991. if (tempList == null || tempList.size() == 0) {
  992. } else {
  993. for (int i = 0; i < tempList.size(); i++) {
  994. sbtel.append(tempList.get(i)[1]==null?"18588592971":tempList.get(i)[1]+";");
  995. sbname.append(tempList.get(i)[0]+";");
  996. }
  997. }
  998. sb.append("\"");
  999. if(sbname.length()>0){
  1000. sb.append(sbname.substring(0, sbname.length()-1));
  1001. }
  1002. sb.append("|");
  1003. if(sbtel.length()>0){
  1004. sb.append(sbtel.substring(0, sbtel.length()-1));
  1005. }
  1006. sb.append("\"}");
  1007. } catch (PersistenceException e) {
  1008. e.printStackTrace();
  1009. }
  1010. return sb.toString();
  1011. }
  1012. @Override
  1013. public List<reportDept> loadReportDeptById(String[] deptIdArr,
  1014. String earlyWarningId, String reportType, String progressTime,
  1015. String planId) throws Exception {
  1016. return null;
  1017. }
  1018. public List<Map<String, String>> loadReportPlanById(String planId){
  1019. String sql = "select FD_OBJECTID,EARLY_WARNING_ID,PROGRAMME_NAME,START_TIME,EXPIRATION_DATE,REPORT_TYPE,WRITE_DEPT_ID,WRITE_DATE_TYPE,CIRCLE_TIME,TEMPORARY_TIME,WRITER,WRITE_TIME,INPUT_DEPT,EARLY_WARNING_NAME,UPDATEDATE,IS_DEL,WRITE_DEPT_NAME,IS_RELEASE,IS_ALERT,EARLY_WARNING,USER_ID from ECM_EM_ALERT_REPORT_PLAN where FD_OBJECTID='"+planId+"'";
  1020. try {
  1021. List<Map<String, String>> list = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResultToMap(320, sql);
  1022. return list;
  1023. } catch (PersistenceException e) {
  1024. e.printStackTrace();
  1025. }
  1026. return null;
  1027. }
  1028. public List<String[]> loadReportPlanByDeptId(String preTime,
  1029. String aftTime, String planId, String deptId, String reportType) {
  1030. String sql = "select FD_OBJECTID from ECM_EM_ALERT_REPORT_INPUT where PLAN_ID='"+planId+"' and INPUT_UNIT='"+deptId+"' and IS_RELEASE=1 and UPDATEDATE between '"+preTime+"' and '"+aftTime+"' and is_del=0 and report_type='"+reportType+"'";
  1031. try {
  1032. List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
  1033. return tempList;
  1034. } catch (PersistenceException e) {
  1035. e.printStackTrace();
  1036. }
  1037. return null;
  1038. }
  1039. public int getLastRoundTime(String params){
  1040. if(params!=null || !"".equals(params)){
  1041. if(params.indexOf(";")==-1 && params.indexOf(":")>0){
  1042. return Integer.parseInt(params.split(":")[0]);
  1043. }else{
  1044. String[] timeArr = params.split(";");
  1045. int num = 0;
  1046. for(int i=0;i<timeArr.length;i++){
  1047. int hour = Integer.parseInt(timeArr[i].split(":")[0]);
  1048. if(num<hour){
  1049. num = hour;
  1050. }
  1051. }
  1052. return num;
  1053. }
  1054. }
  1055. return 0;
  1056. }
  1057. public boolean checkLevel(String compId,String roleId,String fd_id){
  1058. String sql = "select report_dept from report_schedule where comp_id in (select parent_id from sys_department where dept_id =?) and report_dept like ? and send_stat = '1' and role_id = ? and sysdate >= to_char(to_date(start_time,'yyyy-mm-dd hh24:mi:ss')) AND FD_OBJECTID=?";
  1059. boolean flag = false;
  1060. try {
  1061. List<String> list = new ORGTemplate().getResultList(sql, compId,"%"+compId+"%",roleId,fd_id);
  1062. if(list!=null&&list.size()>0){
  1063. flag = true;
  1064. }
  1065. } catch (SQLStringException e) {
  1066. e.printStackTrace();
  1067. }
  1068. return flag;
  1069. }
  1070. }
  1071. class compareList implements Comparator<String>{
  1072. @Override
  1073. public int compare(String o1, String o2) {
  1074. int i = o1.compareTo(o2);
  1075. if(i==0){
  1076. return 0;
  1077. }else if(i>0){
  1078. return 1;
  1079. }else{
  1080. //return -1;
  1081. if(o1.equals("本级计划") && !o2.equals("上级计划")|| o2.equals("本级计划")&&!o1.equals("上级计划")){
  1082. return 1;
  1083. }else{
  1084. return -1;
  1085. }
  1086. }
  1087. }
  1088. }