b7b7c8ef41143ffe5dcbabf3a782035b4de06a71.svn-base 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. package com.sinosoft.em.baobiao.rcbb.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.ParseException;
  7. import java.text.SimpleDateFormat;
  8. import java.util.ArrayList;
  9. import java.util.Arrays;
  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 java.util.UUID;
  16. import net.sf.json.JSONArray;
  17. import org.apache.log4j.Logger;
  18. import com.formaction.Parameter;
  19. import com.formaction.vo.Msg;
  20. import com.persistence.DbConnection;
  21. import com.persistence.service.PersistenceFactory;
  22. import com.persistence.service.SysPersistence;
  23. import com.persistence.service.assitant.generator.IdentityGenerator;
  24. import com.persistence.service.exception.PersistenceException;
  25. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  26. import com.sinosoft.em.alert.report.manage.SQLPreparedUtil;
  27. import com.sinosoft.em.baobiao.rcbb.vo.ReportPlanBean;
  28. import com.sinosoft.em.baobiao.rcbb.vo.ReportProgress;
  29. import com.sinosoft.em.baobiao.rcbb.vo.reportPlan;
  30. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  31. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  32. public class RCReportPlanDao{
  33. private static SysModel sysmodel = ModelFactory.getSysmodel();
  34. @SuppressWarnings("unused")
  35. private static SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  36. private final static Logger log = Logger.getLogger(RCReportPlanDao.class);
  37. /**
  38. * 查询部门下报告填报信息
  39. */
  40. public List<ReportProgress> loadReportProgramme(String deptId,
  41. String[] progressTime,String report_type) throws Exception {
  42. String currprogressTime ="";
  43. String currprogressTimeE = "";
  44. String preproTime="";
  45. String sql="";
  46. //上一个计划时间
  47. preproTime = progressTime[0];
  48. //当前计划时间
  49. currprogressTime = progressTime[1];
  50. currprogressTimeE = progressTime[2];
  51. if(preproTime.length()==4){
  52. sql = "SELECT a.FD_OBJECTID,to_char(a.REPORT_TIME,'yyyy-mm-dd hh24:mi:ss'),b.real_name REPORTER_ID,to_char(a.UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),a.REPORT_TYPE,a.comp_id FROM ECM_EM_REPORT_RECORDS a,sys_user_info b WHERE a.REPORTER_ID=b.user_id and "+
  53. "a.COMP_ID='"+deptId+"'"+
  54. " AND a.IS_DEL=0 AND a.APPEAR_STAT=1 AND a.year='"+preproTime+"' and a.season='"+currprogressTimeE+"' and a.report_type='"+report_type+"' order by updatedate desc";
  55. }else{
  56. sql = "SELECT a.FD_OBJECTID,to_char(a.REPORT_TIME,'yyyy-mm-dd hh24:mi:ss'),b.real_name REPORTER_ID,to_char(a.UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),a.REPORT_TYPE,a.comp_id FROM ECM_EM_REPORT_RECORDS a,sys_user_info b WHERE a.REPORTER_ID=b.user_id and "+
  57. "a.COMP_ID='"+deptId+"'"+
  58. " AND a.IS_DEL=0 AND a.APPEAR_STAT=1 AND to_char(a.UPDATEDATE,'yyyy-mm-dd') BETWEEN '"+preproTime+"' AND '"+currprogressTimeE+"' and a.report_type='"+report_type+"' order by updatedate desc";
  59. }
  60. // DbConnection db = new DbConnection();
  61. // Connection conn = null;
  62. // PreparedStatement ps = null;
  63. // ResultSet rs = null;
  64. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  65. try {
  66. // 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.UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),a.REPORT_TYPE,a.comp_id FROM ECM_EM_REPORT_RECORDS a,sys_user_info b WHERE a.REPORTER_ID=b.user_id and "+
  67. // "a.COMP_ID='"+deptId+"'"+
  68. // " AND a.IS_DEL=0 AND a.APPEAR_STAT=1 AND to_char(a.UPDATEDATE,'yyyy-mm-dd') BETWEEN '"+preproTime+"' AND '"+currprogressTimeE+"' and a.report_type='"+report_type+"' order by updatedate desc";
  69. log.info("loadReportProgramme_sql:"+sql);
  70. // conn = db.getConnection();
  71. // ps = conn.prepareStatement(sql);
  72. // rs = ps.executeQuery();
  73. ArrayList<ReportProgress> list = new ArrayList<ReportProgress>();
  74. List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
  75. if(tempList!=null&&tempList.size()>0){
  76. String[]arr=tempList.get(0);
  77. ReportProgress pro = new ReportProgress();
  78. pro.setFd_object_id(arr[0]);
  79. pro.setWRITE_TIME(arr[1]);
  80. pro.setUpdateTime(arr[3]);
  81. pro.setWRITER(arr[2]);
  82. pro.setCOMP_ID(arr[5]);
  83. pro.setREPORT_TYPE(arr[4]);
  84. list.add(pro);
  85. }
  86. // while (rs.next()) {
  87. // ReportProgress pro = new ReportProgress();
  88. // pro.setFd_object_id(rs.getString("FD_OBJECTID"));
  89. // pro.setWRITE_TIME(dateformat.format(rs.getDate("REPORT_TIME")));
  90. // pro.setUpdateTime(dateformat.format(rs.getDate("UPDATEDATE")));
  91. // pro.setWRITER(rs.getString("REPORTER_ID"));
  92. // pro.setCOMP_ID(rs.getString("COMP_ID"));
  93. // pro.setREPORT_TYPE(rs.getString("REPORT_TYPE"));
  94. // list.add(pro);
  95. // }
  96. log.info("proList:"+list);
  97. return list;
  98. } catch (Exception e) {
  99. throw e;
  100. }
  101. }
  102. /**
  103. * 查询计划
  104. */
  105. public List<reportPlan> loadReportPlan(String deptId,String role_id) throws Exception {
  106. DbConnection db = new DbConnection();
  107. Connection conn = null;
  108. PreparedStatement ps = null;
  109. ResultSet rs = null;
  110. try {
  111. //系统当前时间
  112. Long currentTime = System.currentTimeMillis();
  113. Date currDate = new Date(currentTime);
  114. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
  115. SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  116. String strcurr = dateformat.format(currDate);
  117. String sql="";
  118. sql="select project_name,FD_OBJECTID,UPDATEDATE,FILL_IN_SCHEDULE,TEMPORARY_TIME from ECM_EM_RC_SCHEDULE where (COMP_ID=? or ','||report_dept||',' like ?) and is_del='0' and send_stat='1'";
  119. log.info("loadReportProgramme_sql:"+sql);
  120. conn = db.getConnection();
  121. ps = conn.prepareStatement(sql);
  122. ps.setString(1, deptId);
  123. ps.setString(2, "%"+deptId+"%");
  124. rs = ps.executeQuery();
  125. ArrayList<reportPlan> list = new ArrayList<reportPlan>();
  126. while(rs.next()){
  127. String updatedate = rs.getString("UPDATEDATE").split(" ")[0];
  128. String write_type = rs.getString("FILL_IN_SCHEDULE");
  129. String temp_time = rs.getString("TEMPORARY_TIME");
  130. reportPlan plan = new reportPlan();
  131. plan.setPlanId(rs.getString("FD_OBJECTID"));
  132. plan.setPlanName(rs.getString("PROJECT_NAME"));
  133. plan.setCompId(deptId);
  134. list.add(plan);
  135. // }
  136. }
  137. log.info("planList"+list);
  138. return list;
  139. } catch (Exception e) {
  140. throw e;
  141. }finally{
  142. rs.close();
  143. ps.close();
  144. conn.close();
  145. }
  146. }
  147. /**
  148. * 查询部门
  149. */
  150. public List<ReportPlanBean> loadReportDept(String planId,String comp_id,String role_id) throws Exception {
  151. DbConnection db = new DbConnection();
  152. Connection conn = null;
  153. PreparedStatement ps = null;
  154. ResultSet rs = null;
  155. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  156. try {
  157. String sql = "select project_name,comp_id,REPORT_DEPT,"+
  158. "FILL_IN_SCHEDULE,TEMPORARY_TIME,UPDATEDATE FROM ECM_EM_RC_SCHEDULE "+
  159. "WHERE FD_OBJECTID='"+planId+"' AND IS_DEL=0 AND SEND_STAT=1";
  160. log.info("loadReportProgramme_sql:"+sql);
  161. conn = db.getConnection();
  162. ps = conn.prepareStatement(sql);
  163. rs = ps.executeQuery();
  164. //填报部门ID,可以有多个,要进行字符串截取
  165. String deptIds = "";
  166. //计划名称
  167. String pro_name="";
  168. //截止日期
  169. Date expirationData = new Date();
  170. //填报时间表
  171. String writeDataType = "";
  172. //临时性
  173. String temporaryTime = "";
  174. String comp="";
  175. List<String>deptList=new ArrayList<String>();
  176. List<String>tabList=new ArrayList<String>();
  177. Boolean flag=false;
  178. String updatedate = "";
  179. while(rs.next()){
  180. deptIds = rs.getString("REPORT_DEPT");
  181. // earlyWarningId = rs.getString("WARNiNG_NUMBER");
  182. // expirationData = rs.getDate("END_TIME");
  183. pro_name=rs.getString("PROJECT_NAME").split("_")[0];
  184. // start_time = rs.getDate("START_TIME");
  185. writeDataType = rs.getString("FILL_IN_SCHEDULE");
  186. // circleTime = rs.getString("ROUND_TIME");
  187. updatedate = rs.getString("UPDATEDATE").split(" ")[0];
  188. comp=rs.getString("COMP_ID");
  189. //修改
  190. // List<String>deptList=new ArrayList<String>();
  191. // List<String[]>tabList=new ArrayList<String[]>();
  192. // if(deptIds.startsWith("应急办")){
  193. // if("R002105430205".equals(role_id)){
  194. // deptIds=deptIds.split(":")[1];
  195. // String[]arr=deptIds.split("[|]");
  196. // for(int i=0;i<arr.length;i++){
  197. // String info=arr[i];
  198. // deptList.add(info.split(";")[0]);
  199. // tabList.add(info.split(";")[1].split(","));
  200. // }
  201. // }else{
  202. // deptIds=deptIds.split(":")[1];
  203. // String[]arr=deptIds.split("[|]");
  204. // for(int i=0;i<arr.length;i++){
  205. // String info=arr[i];
  206. // if(role_id.equals(info.split(";")[0])){
  207. // deptList.add(info.split(";")[0]);
  208. // tabList.add(info.split(";")[1].split(","));
  209. // }
  210. // }
  211. // }
  212. //
  213. // flag=true;
  214. // }else{
  215. // deptIds=deptIds.split(":")[1];
  216. // String[]arr=deptIds.split(";");
  217. for(int i=0;i<deptIds.split(",").length;i++){
  218. deptList.add(deptIds.split(",")[i]);
  219. }
  220. tabList.add(getClassIdByName(pro_name));
  221. temporaryTime = rs.getString("TEMPORARY_TIME");
  222. }
  223. // }
  224. //通过判断获取离当前时间最近的计划时间
  225. String progressTime = judgeTime(writeDataType, temporaryTime);
  226. log.info("progressTime====="+progressTime);
  227. // String[] deptIdArr = deptIds.split(",");
  228. // /*********打桩**********************************************/
  229. // log.info("deptIdArr:"+Arrays.toString(deptIdArr));
  230. if(comp_id.equals(comp)){
  231. flag=true;
  232. }
  233. List<ReportPlanBean> depts = loadReportDeptById(flag,deptList,getClassIdByName(pro_name),progressTime,comp_id);
  234. return depts;
  235. } catch (Exception e) {
  236. throw e;
  237. }finally{
  238. rs.close();
  239. ps.close();
  240. conn.close();
  241. }
  242. }
  243. /**
  244. * 通过部门ID到部门表中查询出相应的部门名称
  245. * **/
  246. public List<ReportPlanBean> loadReportDeptById(boolean flag,List<String> deptIdArr,String report_type,
  247. String progressTime,String comp_id) throws Exception{
  248. DbConnection db = new DbConnection();
  249. Connection conn = null;
  250. PreparedStatement ps = null;
  251. ResultSet rs = null;
  252. try {
  253. conn = db.getConnection();
  254. //生成sql语句中in的问号
  255. // String inCondition =
  256. // SQLPreparedUtil.preparePlaceHolders(deptIdArr.length);
  257. // log.info("inCondition:"+inCondition);
  258. StringBuffer sb=new StringBuffer();
  259. for(int i=0;i<deptIdArr.size();i++){
  260. sb.append("'"+deptIdArr.get(i)+"',");
  261. }
  262. if (sb.lastIndexOf(",") > -1) {
  263. sb.deleteCharAt(sb.lastIndexOf(","));
  264. }
  265. log.info(sb.toString());
  266. String sql="";
  267. // if(flag){
  268. // sql = "select role_name,role_id FROM sys_role "+
  269. // "WHERE role_id "+
  270. // "IN("+sb.toString()+") order by role_id";
  271. //
  272. // }else{
  273. if(flag){
  274. sql="select dept_id role_id,dept_name role_name from sys_department where dept_id in("+sb.toString()+")";
  275. }else{
  276. sql="select dept_id role_id,dept_name role_name from sys_department where dept_id ='"+comp_id+"'";
  277. }
  278. // log.info("sql_write_dept:"+sql);
  279. ps = conn.prepareStatement(sql);
  280. // for (int i = 0; i < deptIdArr.length; i++) {
  281. // ps.setString(i+1,deptIdArr[i]);
  282. // }
  283. rs = ps.executeQuery();
  284. //用于存储部门信息
  285. ArrayList<ReportPlanBean> depts = new ArrayList<ReportPlanBean>();
  286. int i=0;
  287. while(rs.next()){
  288. ReportPlanBean dept=new ReportPlanBean();
  289. dept.setID(rs.getString("ROLE_ID"));
  290. dept.setRESPONSIBLE_NAME(rs.getString("ROLE_NAME"));
  291. dept.setIconClass("icon_home");
  292. dept.setOpen(false);
  293. // dept.setEarlyWarningId(earlyWarningId);//预警编号
  294. StringBuffer tabType=new StringBuffer();
  295. //log.info("tabList==="+tabList.size());
  296. // if(flag){
  297. // for(int j=0;j<tabList.get(i).length;j++){
  298. // tabType.append(getTypeByName(tabList.get(i)[j])+";");
  299. // }
  300. // }else{
  301. // for(int j=0;j<tabList.get(0).length;j++){
  302. // tabType.append(tabList.get(0)[j]+";");
  303. // }
  304. // }
  305. // for(int j=0;j<tabList.get(i).length;j++){
  306. // if(flag){
  307. // tabType.append(getTypeByName(tabList.get(i)[j])+";");
  308. // }else{
  309. // tabType.append(tabList.get(0)[j]+";");
  310. // }
  311. // }
  312. if(tabType.lastIndexOf(";")>-1){
  313. tabType.deleteCharAt(tabType.lastIndexOf(";"));
  314. }
  315. //参数,查看部门下报告填报情况时所用
  316. // if(flag){
  317. // dept.setParams(tabType.toString()+","+dept.getEarlyWarningId()+","+progressTime+","+comp_id);
  318. // }else{
  319. dept.setParams(report_type+","+progressTime+","+rs.getString("ROLE_ID"));
  320. // }
  321. // dept.setParams(tabType.toString()+","+dept.getEarlyWarningId()+","+progressTime+","+comp_id);
  322. depts.add(dept);
  323. i++;
  324. }
  325. //部门id和部门名打桩
  326. log.info("depts:"+depts);
  327. return depts ;
  328. } catch (Exception e) {
  329. throw e;
  330. }finally{
  331. rs.close();
  332. ps.close();
  333. conn.close();
  334. }
  335. }
  336. public String getClassIdByName(String report_name){
  337. String result="";
  338. String sql="select report_type from bm_mapforrcreport where REPORT_NAME='"+report_name+"'";
  339. SysModel sysmodel = ModelFactory.getSysmodel();
  340. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  341. try {
  342. List<String[]>tempList = persistence.getSearchResult(99, sql.toString());
  343. if(tempList!=null&&tempList.size()>0){
  344. result=tempList.get(0)[0];
  345. }
  346. } catch (PersistenceException e) {
  347. // TODO Auto-generated catch block
  348. e.printStackTrace();
  349. }
  350. return result;
  351. }
  352. public String judgeTime(String writeDataType,
  353. String temporaryTime) throws ParseException{
  354. String beforeDate="";
  355. String afterDate="";
  356. String scheduleDate="";
  357. String year="";
  358. String season="";
  359. Date currentDate=new Date();
  360. String curDate="";
  361. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
  362. curDate=sdf.format(currentDate);
  363. String cur_year=curDate.split("-")[0];
  364. String cur_month=curDate.split("-")[1];
  365. String cur_day=curDate.split("-")[2];
  366. afterDate=sdf.format(new Date());
  367. if("1".equals(writeDataType)){
  368. if("01".equals(cur_month)){//年报
  369. scheduleDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"31";
  370. beforeDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"25";
  371. }else{
  372. scheduleDate=cur_year+"-"+"12"+"-"+"31";
  373. beforeDate=cur_year+"-"+"12"+"-"+"25";
  374. }
  375. // beforeDate=
  376. }else if("2".equals(writeDataType)){//半年报
  377. if("01".equals(cur_month)){
  378. scheduleDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"31";
  379. beforeDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"25";
  380. }
  381. // else if("07".equals(cur_month)){
  382. // scheduleDate=cur_year+"-"+"06"+"-"+"31";
  383. // beforeDate=cur_year+"-"+"06"+"-"+"25";
  384. // }
  385. else if(Integer.parseInt(cur_month)<=7){
  386. scheduleDate=cur_year+"-"+"06"+"-"+"31";
  387. beforeDate=cur_year+"-"+"06"+"-"+"25";
  388. }else{
  389. scheduleDate=cur_year+"-"+"12"+"-"+"31";
  390. beforeDate=cur_year+"-"+"12"+"-"+"25";
  391. }
  392. }else if("3".equals(writeDataType)){//季报
  393. if("01".equals(cur_month)){
  394. year=Integer.parseInt(cur_year)-1+"";
  395. season="4";
  396. scheduleDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"31";
  397. beforeDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"25";
  398. }else if(Integer.parseInt(cur_month)<=4){
  399. year=cur_year;
  400. season="1";
  401. scheduleDate=cur_year+"-"+"03"+"-"+"31";
  402. beforeDate=cur_year+"-"+"03"+"-"+"25";
  403. }else if(Integer.parseInt(cur_month)<=7){
  404. year=cur_year;
  405. season="2";
  406. scheduleDate=cur_year+"-"+"06"+"-"+"31";
  407. beforeDate=cur_year+"-"+"06"+"-"+"25";
  408. }else if(Integer.parseInt(cur_month)<=10){
  409. year=cur_year;
  410. season="3";
  411. scheduleDate=cur_year+"-"+"09"+"-"+"30";
  412. beforeDate=cur_year+"-"+"09"+"-"+"25";
  413. }else{
  414. year=cur_year;
  415. season="4";
  416. scheduleDate=cur_year+"-"+"12"+"-"+"31";
  417. beforeDate=cur_year+"-"+"12"+"-"+"25";
  418. }
  419. }else if("4".equals(writeDataType)){//月报
  420. if("01".equals(cur_month)){
  421. if(Integer.parseInt(cur_day)<=5){
  422. scheduleDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"31";
  423. beforeDate=(Integer.parseInt(cur_year)-1)+"-"+"12"+"-"+"25";
  424. }else{
  425. scheduleDate=cur_year+"-"+"01"+"-"+"31";
  426. beforeDate=cur_year+"-"+"01"+"-"+"25";
  427. }
  428. }else if(Integer.parseInt(cur_month)<=10){
  429. if(Integer.parseInt(cur_day)<=5){
  430. scheduleDate=cur_year+"-"+"0"+(Integer.parseInt(cur_month)-1)+"-"+"31";
  431. beforeDate=cur_year+"-"+"0"+(Integer.parseInt(cur_month)-1)+"-"+"25";
  432. }else{
  433. scheduleDate=cur_year+"-"+"0"+cur_month+"-"+"31";
  434. beforeDate=cur_year+"-"+"0"+cur_month+"-"+"25";
  435. }
  436. }
  437. }else if("5".equals(writeDataType)){//自定义
  438. scheduleDate=temporaryTime;
  439. beforeDate=sdf.format(sdf.parse(temporaryTime).getTime()- 5*24*60*60*1000);
  440. return beforeDate + "|" + scheduleDate + "|" + afterDate;
  441. }
  442. // return beforeDate + "," + scheduleDate + "," + afterDate;
  443. return year+"|"+scheduleDate+"|"+season;
  444. }
  445. /**
  446. * 根据报告类别的常量id查询相应的报告类别名称
  447. */
  448. public String loadReportTypeName(String id) throws Exception {
  449. DbConnection db = new DbConnection();
  450. Connection conn = null;
  451. PreparedStatement ps = null;
  452. ResultSet rs = null;
  453. String name="";
  454. try {
  455. // String conditionOfReportType = "";
  456. // if(id.length()==1){
  457. // conditionOfReportType = " FD_CODE='"+id+"'";
  458. // }else if(id.length()==2){
  459. // conditionOfReportType = " FD_CODE in ('3','4')";
  460. // }
  461. String sql = "select report_name,report_type from BM_MAPFORrcREPORT "+
  462. "where report_type='"+id+"'";
  463. conn = db.getConnection();
  464. ps = conn.prepareStatement(sql);
  465. rs = ps.executeQuery();
  466. ArrayList<String[] >list = new ArrayList<String[]>();
  467. while(rs.next()){
  468. name = rs.getString("REPORT_NAME");
  469. // String type = rs.getString("REPORT_TYPE");
  470. // String[]arr=new String[]{name,type};
  471. // list.add(arr);
  472. }
  473. } catch (Exception e) {
  474. throw e;
  475. }finally{
  476. rs.close();
  477. ps.close();
  478. conn.close();
  479. }
  480. return name;
  481. }
  482. private String pretime(String time){
  483. String hour = time.substring(0,time.indexOf(":"));
  484. String minit = time.substring(time.indexOf(":"),time.length());
  485. Integer prehour = Integer.parseInt(hour)-1;
  486. return prehour.toString()+""+minit;
  487. }
  488. /**
  489. * 发布预警/响应通知单时创建报表填报计划
  490. * @param areaName
  491. * @param areaId
  492. * @param alertName
  493. * @param real_name
  494. * @param deptName
  495. * @param isAlert
  496. * @param alertId
  497. * @param planId
  498. * @return
  499. * @throws ClassNotFoundException
  500. * @throws ParseException
  501. */
  502. public Msg createPlanByAlert(String WARNING_NUMBER, String START_TIME,String FILL_IN_SCHEDULE,
  503. String REPORT_DEPT,String DEPT_ID,String ROUND_TIME,String TEMPORARY_TIME,String USER_ID,
  504. String role_id,String deptName,String real_name,String alertName,String areaId,String areaName, String isAlert) throws ClassNotFoundException, ParseException{
  505. Msg m=new Msg();
  506. log.info("REPORT_DEPT=="+REPORT_DEPT);
  507. log.info("DEPT_ID==="+DEPT_ID);
  508. if(DEPT_ID==null||"".equals(DEPT_ID)){
  509. return m;
  510. }
  511. //REPORT_DEPT="11,线路停运及恢复情况表,||@31,线路停运及恢复情况表,||@111,线路停运及恢复情况表,||@78,线路停运及恢复情况表,||@";
  512. //"11,线路停运及恢复情况表,||@12,线路停运及恢复情况表,||@13,线路停运及恢复情况表,||@14,线路停运及恢复情况表,||@"
  513. String[]table=REPORT_DEPT.replace("***","-").split("-")[0].replace("@", "").split("[|][|]");
  514. List<String>table_fdList=new ArrayList<String>();
  515. for(int i=0;i<table.length;i++){
  516. table_fdList.add(table[i].split(",")[0]);
  517. }
  518. REPORT_DEPT=getTabInfo(table_fdList);
  519. //应急办:R002105430210;线路停运及恢复情况表,变电站停运及恢复情况表|R002105430211;线路倒杆情况统计表,线路及配变受损情况表|R002105430212;供电损失及客户停电情况表,行政区域停电情况表|R002105430213;预警发布或响应启动情况表,应急资源情况表|
  520. for(int i=0;i<table_fdList.size();i++){
  521. }
  522. String sql="insert into REPORT_SCHEDULE(FD_OBJECTID,WARNING_NUMBER,PROJECT_NAME,START_TIME,END_TIME,FILL_IN_SCHEDULE,REPORT_DEPT,comp_id,IS_DEL,SEND_STAT,ROUND_TIME,TEMPORARY_TIME,USER_ID,ROLE_ID,dept,real_name,updatedate)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  523. //报告填报要求sql
  524. String sql1="insert into ECM_EM_ALERT_REPORT_PLAN"
  525. + "(FD_OBJECTID,EARLY_WARNING_ID,EARLY_WARNING_NAME,"
  526. + "PROGRAMME_NAME,START_TIME,EXPIRATION_DATE,REPORT_TYPE,WRITE_DEPT_ID,WRITE_DEPT_NAME,"
  527. + "WRITE_DATE_TYPE,CIRCLE_TIME,TEMPORARY_TIME,WRITER,WRITE_TIME,INPUT_DEPT,UPDATEDATE,"
  528. + "IS_RELEASE,IS_ALERT,EARLY_WARNING,USER_ID,IS_DEL)"
  529. + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  530. Connection conn = null;
  531. PreparedStatement st = null;
  532. PreparedStatement st1 = null;
  533. DbConnection db = new DbConnection();
  534. ROUND_TIME=ROUND_TIME.replace("#", ",");
  535. Date crrDate = new Date();
  536. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  537. String crrStr = dateformat.format(crrDate);//当前日期字符串
  538. SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd");
  539. try {
  540. conn = db.getConnection();
  541. int num = 0;
  542. int num1 = 0;
  543. conn.setAutoCommit(false);
  544. st = conn.prepareStatement(sql);
  545. st1 = conn.prepareStatement(sql1);
  546. // String fd_id=createMsgId(getMsgId());
  547. //报表填报要求部分
  548. st.setString(1, IdentityGenerator.getIdentityGenerator().gerenalIdentity(337));
  549. st.setString(2, WARNING_NUMBER);// 线路停运为1
  550. st.setString(3, WARNING_NUMBER+"报表计划");
  551. st.setString(4, START_TIME.split(" ")[0]);
  552. st.setString(5, "");
  553. st.setString(6, FILL_IN_SCHEDULE);
  554. st.setString(7, REPORT_DEPT);
  555. st.setString(8, DEPT_ID);
  556. st.setString(9, "0");
  557. st.setString(10, "0");
  558. // st.setString(11, DEPT_ID);
  559. if("周期性".equals(FILL_IN_SCHEDULE)){
  560. if(ROUND_TIME.startsWith(",")){
  561. ROUND_TIME=ROUND_TIME.substring(1);
  562. }
  563. st.setString(11, ROUND_TIME);
  564. st.setString(12, "");
  565. }else{
  566. st.setString(11, "");
  567. List<String>tempList=new ArrayList<String>();
  568. String[]tempArr=TEMPORARY_TIME.split(",");
  569. TEMPORARY_TIME="";
  570. for(int i=0;i<tempArr.length;i++){
  571. TEMPORARY_TIME+=tempArr[i]+";";
  572. }
  573. st.setString(12, TEMPORARY_TIME);
  574. }
  575. RcBbDao bbd=new RcBbDao();
  576. st.setString(13, USER_ID);
  577. st.setString(14, role_id);
  578. st.setString(15, bbd.getNameByCompId(DEPT_ID));
  579. st.setString(16, bbd.getNameByUserId(USER_ID));
  580. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  581. st.setString(17, sdf.format(new Date()));
  582. st.executeUpdate();
  583. num++;
  584. //报告填报要求部分
  585. st1.setString(1, IdentityGenerator.getIdentityGenerator().gerenalIdentity(320));
  586. st1.setString(2, WARNING_NUMBER);// 预警编号
  587. st1.setString(3, WARNING_NUMBER);// 预警名称,存的数据是预警编号
  588. st1.setDate(5, new java.sql.Date(dateformat1.parse(START_TIME).getTime()));// 开始日期
  589. st1.setDate(6, null);// 结束日期
  590. if("0".equals(isAlert)){
  591. st1.setString(4, WARNING_NUMBER+"预警报告填报要求");// 填报要求名称
  592. st1.setString(7, "1,2");// 预警报告类别,同时生成预警行动信息报告和总结报告
  593. }else if("1".equals(isAlert)){
  594. st1.setString(4, WARNING_NUMBER+"响应报告填报要求");// 填报要求名称
  595. st1.setString(7, "3,4");// 响应报告类别
  596. }
  597. st1.setString(8, areaId);// 预警范围部门id
  598. st1.setString(9, areaName);// 预警范围部门名称
  599. st1.setString(10, FILL_IN_SCHEDULE);// 填报性质:周期性还是临时性
  600. if("周期性".equals(FILL_IN_SCHEDULE)){
  601. st1.setString(11, ROUND_TIME);// 周期性时间
  602. st1.setString(12, "");// 临时性时间
  603. }else{
  604. st1.setString(11, "");
  605. List<String>tempList=new ArrayList<String>();
  606. String[]tempArr=TEMPORARY_TIME.split(",");
  607. TEMPORARY_TIME="";
  608. for(int i=0;i<tempArr.length;i++){
  609. TEMPORARY_TIME+=tempArr[i]+";";
  610. }
  611. st1.setString(12, TEMPORARY_TIME);
  612. }
  613. st1.setString(13, real_name);// 填报人
  614. st1.setString(14, crrStr);// 填报时间
  615. st1.setString(15, DEPT_ID);// 填报人部门id
  616. st1.setString(16, crrStr);// 更新时间
  617. st1.setString(17, "0");// 是否发布
  618. st1.setString(18, isAlert);// 是否预警
  619. st1.setString(19, alertName);//真实预警名称
  620. st1.setString(20, USER_ID);//用户id
  621. st1.setInt(21, 0);//是否删除
  622. st1.executeUpdate();
  623. num1++;
  624. if (num == 1 && num1==1) {
  625. log.info("新增填报要求成功");
  626. conn.commit();
  627. //新增报告填报要求
  628. m.setSucsess(new Boolean(true).toString());
  629. m.setInfo(Parameter.DELETE_SUCSESS);
  630. return m;
  631. } else {
  632. m.setSucsess(new Boolean(false).toString());
  633. m.setInfo(Parameter.DELETE_FAILURE);
  634. // st.executeBatch();
  635. conn.rollback();
  636. log.info("新增填报要求失败");
  637. return m;
  638. }
  639. } catch (SQLException e) {
  640. this.log.error(e.getMessage(), e);
  641. throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  642. } finally {
  643. db.close(st1);
  644. db.close(st);
  645. db.close(conn);
  646. }
  647. }
  648. public String getTabInfo(List<String> fd_id){
  649. StringBuffer result=new StringBuffer();
  650. Map<String, String>tempMap=new HashMap<String, String>();
  651. List<String>keyList=new ArrayList<String>();
  652. for(int i=0;i<fd_id.size();i++){
  653. String sql="select b.role_id,a.report_name from EMC_AM_REPORT_DICTIONARY a,BM_MAPFORREPORT B WHERE A.REPORT_TYPE='"+fd_id.get(i)+"' AND A.REPORT_TYPE=B.REPORT_TYPE";
  654. try {
  655. List<String[]> tempList = persistence.getSearchResult(99, sql.toString());
  656. if(tempList!=null&&tempList.size()>0){
  657. String key=tempList.get(0)[0];
  658. String value=tempList.get(0)[1];
  659. if(tempMap.containsKey(tempList.get(0)[0])){
  660. tempMap.put(key, tempMap.get(key)+","+value+"|");
  661. }else{
  662. tempMap.put(key, value);
  663. keyList.add(key);
  664. }
  665. }
  666. } catch (PersistenceException e) {
  667. // TODO Auto-generated catch block
  668. e.printStackTrace();
  669. }
  670. }
  671. result.append("应急办:");
  672. for(int i=0;i<keyList.size();i++){
  673. result.append(keyList.get(i)+";"+tempMap.get(keyList.get(i)));
  674. }
  675. if (result.lastIndexOf("|") > -1) {
  676. result.deleteCharAt(result.lastIndexOf("|"));
  677. }
  678. return result.toString();
  679. }
  680. public Msg updatePlan(String newWarn,String oldWarn,String comp_id) throws ClassNotFoundException{
  681. Msg m=new Msg();
  682. String sql="update REPORT_SCHEDULE set WARNING_NUMBER=?,PROJECT_NAME=?||'计划' where WARNING_NUMBER=? and comp_id=?";
  683. String sql1="update ECM_EM_ALERT_REPORT_PLAN set EARLY_WARNING_ID=?,PROGRAMME_NAME=?,EARLY_WARNING_NAME=?,EARLY_WARNING=?,UPDATEDATE=? where EARLY_WARNING_ID=? and INPUT_DEPT=?";
  684. Connection conn = null;
  685. PreparedStatement st = null;
  686. PreparedStatement st1 = null;
  687. DbConnection db = new DbConnection();
  688. Date crrDate = new Date();
  689. SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  690. String crrStr = dateformat.format(crrDate);//当前日期字符串
  691. try {
  692. conn = db.getConnection();
  693. int num = 0;
  694. int num1 = 0;
  695. conn.setAutoCommit(false);
  696. st = conn.prepareStatement(sql);
  697. st1 = conn.prepareStatement(sql1);
  698. //报表
  699. st.setString(1, newWarn);
  700. st.setString(2, newWarn);
  701. st.setString(3, oldWarn);
  702. st.setString(4, comp_id);
  703. st.executeUpdate();
  704. num++;
  705. //报告
  706. String earlyName = newWarn.split("-")[0];
  707. st1.setString(1, newWarn);
  708. st1.setString(2, newWarn+"报告填报要求");
  709. st1.setString(3, newWarn);
  710. st1.setString(4, earlyName);
  711. st1.setString(5, crrStr);
  712. st1.setString(6, oldWarn);
  713. st1.setString(7, comp_id);
  714. st1.executeUpdate();
  715. num1++;
  716. if (num == 1 && num1==1) {
  717. log.info("修改填报要求成功");
  718. conn.commit();
  719. m.setSucsess(new Boolean(true).toString());
  720. m.setInfo(Parameter.DELETE_SUCSESS);
  721. return m;
  722. } else {
  723. m.setSucsess(new Boolean(false).toString());
  724. m.setInfo(Parameter.DELETE_FAILURE);
  725. // st.executeBatch();
  726. conn.rollback();
  727. log.info("修改填报要求失败");
  728. return m;
  729. }
  730. } catch (SQLException e) {
  731. this.log.error(e.getMessage(), e);
  732. throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  733. } finally {
  734. db.close(st1);
  735. db.close(st);
  736. db.close(conn);
  737. }
  738. }
  739. public Msg sendPlan(){
  740. Msg m=new Msg();
  741. String sql="update REPORT_RECORDS set SEND_STAT='1' where WARNING_NUMBER=? and comp_id=?";//0-未发布 1-发布 2-发布解除
  742. return m;
  743. }
  744. public Msg releasePlan(String WARNING_NUMBER,String COMP_ID) throws ClassNotFoundException{
  745. Msg m=new Msg();
  746. String sql="update REPORT_SCHEDULE set SEND_STAT='2',end_time=? where warning_number=? and comp_id=?";//0-未发布 1-发布 2-发布解除
  747. String sql1="update ECM_EM_ALERT_REPORT_PLAN set EXPIRATION_DATE=?,IS_RELEASE=? where EARLY_WARNING_ID=? and INPUT_DEPT=?";
  748. Connection conn = null;
  749. PreparedStatement st = null;
  750. PreparedStatement st1 = null;
  751. DbConnection db = new DbConnection();
  752. try {
  753. conn = db.getConnection();
  754. int num=0;
  755. int num1=0;
  756. Date dd=new Date();
  757. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
  758. String date=sdf.format(dd);
  759. conn.setAutoCommit(false);
  760. st = conn.prepareStatement(sql);
  761. st1 = conn.prepareStatement(sql1);
  762. st.setString(1, date);
  763. st.setString(2, WARNING_NUMBER);
  764. st.setString(3, COMP_ID);
  765. st.executeUpdate();
  766. num++;
  767. st1.setString(1, date);
  768. st1.setString(2, "2");
  769. st1.setString(3, WARNING_NUMBER);
  770. st1.setString(4, COMP_ID);
  771. st1.executeUpdate();
  772. num1++;
  773. if(num==1&&num1==1){
  774. log.info("预警/响应通知单解除报表记录表成功");
  775. conn.commit();
  776. m.setSucsess(new Boolean(true).toString());
  777. m.setInfo(Parameter.DELETE_SUCSESS);
  778. }else{
  779. m.setSucsess(new Boolean(false).toString());
  780. m.setInfo(Parameter.DELETE_FAILURE);
  781. // st.executeBatch();
  782. conn.rollback();
  783. log.info("预警/响应通知单解除报表记录表成功");
  784. }
  785. } catch (SQLException e) {
  786. this.log.error(e.getMessage(), e);
  787. throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  788. } finally {
  789. try{
  790. if(st1!= null){
  791. st1.close();
  792. }
  793. } catch (SQLException e) {
  794. e.printStackTrace();
  795. }
  796. db.close(st);
  797. db.close(conn);
  798. }
  799. return m;
  800. }
  801. // public Msg createPlan(Report_Schedule rs) throws ClassNotFoundException{
  802. // Msg m=new Msg();
  803. // String sql="insert into REPORT_SCHEDULE(FD_OBJECTID,WARNING_NUMBER,PROJECT_NAME,START_TIME,END_TIME,FILL_IN_SCHEDULE,REPORT_DEPT,DEPT_ID,IS_DEL,COMP_ID,SEND_STAT,ROUND_TIME,TEMPORARY_TIME,USER_ID)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  804. // Connection conn = null;
  805. // PreparedStatement st = null;
  806. // DbConnection db = new DbConnection();
  807. // try {
  808. // conn = db.getConnection();
  809. // int num=0;
  810. // conn.setAutoCommit(false);
  811. // st = conn.prepareStatement(sql);
  812. // st.setString(1, UUID.randomUUID()+"");
  813. // st.setString(2, rs.getWARNING_NUMBER());
  814. // st.setString(3, rs.getWARNING_NUMBER()+"报表");
  815. // st.setString(4, rs.getSTART_TIME());
  816. // st.setString(5, rs.getEND_TIME());
  817. // st.setString(6, rs.getFILL_IN_SCHEDULE());
  818. // st.setString(7, rs.getREPORT_DEPT());
  819. // st.setString(8, rs.getDEPT_ID());
  820. // st.setString(9, "0");
  821. // st.setString(10, rs.getDEPT_ID());
  822. // st.setString(11, "0");
  823. // st.setString(12, rs.getROUND_TIME());
  824. // st.setString(13, rs.getTEMPORARY_TIME());
  825. // st.setString(14, rs.getUSER_ID());
  826. // st.executeUpdate();
  827. // num++;
  828. // if(num==1){
  829. // log.info("预警/响应通知单发布报表记录表成功");
  830. // conn.commit();
  831. // m.setSucsess(new Boolean(true).toString());
  832. // m.setInfo(Parameter.DELETE_SUCSESS);
  833. // return m;
  834. // }else{
  835. // m.setSucsess(new Boolean(false).toString());
  836. // m.setInfo(Parameter.DELETE_FAILURE);
  837. //// st.executeBatch();
  838. // conn.rollback();
  839. // log.info("预警/响应通知单发布报表记录表成功");
  840. // return m;
  841. // }
  842. // } catch (SQLException e) {
  843. // this.log.error(e.getMessage(), e);
  844. // throw new ClassNotFoundException("DAO Layou: 消息保存", e);
  845. // } finally {
  846. // db.close(st);
  847. // db.close(conn);
  848. // }
  849. // }
  850. /**
  851. * 获取所有的日常报表
  852. * @return
  853. */
  854. public String getRcReport(){
  855. String sql = "select REPORT_TYPE,REPORT_NAME from BM_MAPFORRCREPORT";
  856. ORGTemplate org = new ORGTemplate();
  857. String result = "";
  858. try {
  859. List<Map<String,String>> list = org.getSerachResult(sql);
  860. if(list!=null && list.size()>0){
  861. result = JSONArray.fromObject(list).toString();
  862. }
  863. } catch (SQLException e) {
  864. // TODO Auto-generated catch block
  865. e.printStackTrace();
  866. }
  867. return result;
  868. }
  869. public String queryReportComp(String comp_id,String comp_name,String report_type){
  870. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  871. Date date = new Date();
  872. String cur=sdf.format(date);
  873. String month=cur.split("-")[1];
  874. String day=cur.split("-")[2];
  875. String year=cur.split("-")[0];
  876. String time = "";
  877. String report_time = "";
  878. String season = "";
  879. try {
  880. if(date.compareTo(sdf.parse(year+"-01-10"))>0 && date.compareTo(sdf.parse(year+"-04-10"))<=0){
  881. time += "between '"+year+"-03-20' and '"+year+"-04-10'";
  882. report_time = year+"-03-20";
  883. season = "1";
  884. }else if(date.compareTo(sdf.parse(year+"-04-10"))>0 && date.compareTo(sdf.parse(year+"-07-10"))<=0){
  885. time += "between '"+year+"-06-20' and '"+year+"-07-10'";
  886. report_time = year+"-06-20";
  887. season = "2";
  888. }else if(date.compareTo(sdf.parse(year+"-07-10"))>0 && date.compareTo(sdf.parse(year+"-10-10"))<=0){
  889. time += "between '"+year+"-09-20' and '"+year+"-10-10'";
  890. report_time = year+"-09-20";
  891. season = "3";
  892. }else if(date.compareTo(sdf.parse(year+"-10-10"))>0 && date.compareTo(sdf.parse(Integer.valueOf(year)+1+"-01-10"))<=0){
  893. time += "between '"+year+"-12-20' and '"+(Integer.valueOf(year)+1)+"-01-10'";
  894. report_time = year+"-12-20";
  895. season = "4";
  896. }else{//超时
  897. time += "between '"+(Integer.valueOf(year)-1)+"-12-20' and '"+year+"-01-10'";
  898. report_time = (Integer.valueOf(year)-1)+"-12-20";
  899. season = "4";
  900. }
  901. } catch (NumberFormatException e) {
  902. // TODO Auto-generated catch block
  903. e.printStackTrace();
  904. } catch (ParseException e) {
  905. // TODO Auto-generated catch block
  906. e.printStackTrace();
  907. }
  908. ReportPlanBean rpb = new ReportPlanBean();
  909. rpb.setID(comp_id);
  910. rpb.setOpen(false);
  911. rpb.setRESPONSIBLE_NAME(comp_name);
  912. rpb.setIconClass("icon_home");
  913. rpb.setParams(report_type+","+year+"|"+report_time+"|"+season+","+comp_id);
  914. return "{\"rows\":"+JSONArray.fromObject(rpb).toString()+"}";
  915. }
  916. /**
  917. * 获取本单位报表的填报情况
  918. * @param report_type
  919. * @param comp_id
  920. * @param role_id
  921. * @return
  922. */
  923. public String queryReportRecords(String report_type,String comp_id,String role_id,String comp_name,String report_name){
  924. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  925. Date date = new Date();
  926. String cur=sdf.format(date);
  927. String month=cur.split("-")[1];
  928. String day=cur.split("-")[2];
  929. String year=cur.split("-")[0];
  930. String time = "";
  931. String report_time = "";
  932. String season = "";
  933. ORGTemplate org = new ORGTemplate();
  934. List<com.sinosoft.em.alert.report.manage.vo.ReportProgress> compList = getChildComp(comp_id,comp_name);
  935. try {
  936. if(date.compareTo(sdf.parse(year+"-01-31"))>0 && date.compareTo(sdf.parse(year+"-04-30"))<=0){
  937. time += "between '"+year+"-03-01' and '"+year+"-04-30'";
  938. report_time = year+"-03-31";
  939. season = "1";
  940. }else if(date.compareTo(sdf.parse(year+"-04-30"))>0 && date.compareTo(sdf.parse(year+"-07-31"))<=0){
  941. time += "between '"+year+"-06-01' and '"+year+"-07-31'";
  942. report_time = year+"-06-31";
  943. season = "2";
  944. }else if(date.compareTo(sdf.parse(year+"-07-31"))>0 && date.compareTo(sdf.parse(year+"-10-31"))<=0){
  945. time += "between '"+year+"-09-01' and '"+year+"-10-31'";
  946. report_time = year+"-09-30";
  947. season = "3";
  948. }else if(date.compareTo(sdf.parse(year+"-10-31"))>0 && date.compareTo(sdf.parse(Integer.valueOf(year)+1+"-01-31"))<=0){
  949. time += "between '"+year+"-12-01' and '"+(Integer.valueOf(year)+1)+"-01-31'";
  950. report_time = year+"-12-31";
  951. season = "4";
  952. }else{//超时
  953. time += "between '"+(Integer.valueOf(year)-1)+"-12-01' and '"+year+"-01-31'";
  954. report_time = (Integer.valueOf(year)-1)+"-12-31";
  955. season = "4";
  956. }
  957. String sql = "select *,(case when APPEAR_TIME>'"+report_time+"' then '是' when APPEAR_TIME<='"+report_time+"' then '否' else null end) overstat from ECM_EM_REPORT_RECORDS where COMP_ID=? and REPORT_TYPE=? and to_date(APPEAR_TIME,'yyyy-mm-dd') "+time+" and IS_DEL='0'";
  958. for(int i=0;i<compList.size();i++){
  959. List<Map<String,String>> list = org.getSerachResult(sql, compList.get(i).getDeptId(),report_type);
  960. if(list!=null && list.size()>0){
  961. Map<String,String> map = list.get(0);
  962. com.sinosoft.em.alert.report.manage.vo.ReportProgress rpb = compList.get(i);
  963. rpb.setFd_object_id(map.get("FD_OBJECTID"));
  964. rpb.setReport_type(report_type);
  965. rpb.setRESPONSIBLE_NAME_322(report_name);
  966. rpb.setPROGRAMME_TIME_322(report_time);
  967. rpb.setWRITER_322(map.get("REPORTER"));
  968. rpb.setWRITER_ID_322(map.get("REPORTER_ID"));
  969. rpb.setWRITE_TIME_322(map.get("APPEAR_TIME"));
  970. rpb.setWRITER_STATE_322("已填报");
  971. rpb.setIS_OVERTIME_322(map.get("OVERSTAT"));
  972. rpb.setUpdateTime(map.get("APPEAR_TIME"));
  973. }else{
  974. com.sinosoft.em.alert.report.manage.vo.ReportProgress rpb = compList.get(i);
  975. rpb.setReport_type(report_type);
  976. rpb.setRESPONSIBLE_NAME_322(report_name);
  977. rpb.setPROGRAMME_TIME_322(report_time);
  978. rpb.setWRITER_STATE_322("未填报");
  979. if(date.compareTo(sdf.parse(report_time))<0){
  980. rpb.setIS_OVERTIME_322("否");
  981. }else{
  982. rpb.setIS_OVERTIME_322("是");
  983. }
  984. }
  985. }
  986. return "{\"rows\":"+JSONArray.fromObject(compList).toString()+"}";
  987. } catch (SQLException e) {
  988. // TODO Auto-generated catch block
  989. e.printStackTrace();
  990. } catch (ParseException e) {
  991. // TODO Auto-generated catch block
  992. e.printStackTrace();
  993. }
  994. return "{\"rows\":[]}";
  995. }
  996. public List<com.sinosoft.em.alert.report.manage.vo.ReportProgress> getChildComp(String comp_id,String comp_name){
  997. String sql = "select dept_id,dept_name from SYS_DEPARTMENT where parent_id=? and dept_name like '%供电局%' and is_del='0' order by sort";
  998. ORGTemplate org = new ORGTemplate();
  999. List<com.sinosoft.em.alert.report.manage.vo.ReportProgress> compList = new ArrayList<com.sinosoft.em.alert.report.manage.vo.ReportProgress>();
  1000. try {
  1001. List<Map<String,String>> list = org.getSerachResult(sql, comp_id);
  1002. if(list!=null && list.size()>0){
  1003. for(int i=0;i<list.size();i++){
  1004. com.sinosoft.em.alert.report.manage.vo.ReportProgress rp = new com.sinosoft.em.alert.report.manage.vo.ReportProgress();
  1005. rp.setDeptId(list.get(i).get("DEPT_ID"));
  1006. rp.setDeptName(list.get(i).get("DEPT_NAME"));
  1007. compList.add(rp);
  1008. }
  1009. }
  1010. } catch (SQLException e) {
  1011. // TODO Auto-generated catch block
  1012. e.printStackTrace();
  1013. }
  1014. return compList;
  1015. }
  1016. }