960bb8174554feeeea4821c56cdd7b36154ff9b5.svn-base 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. package com.sinosoft.em.alert.duty.records.dao;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. import java.util.Map;
  9. import org.apache.log4j.Logger;
  10. import com.persistence.DbConnection;
  11. import com.persistence.service.PersistenceFactory;
  12. import com.persistence.service.SysPersistence;
  13. import com.persistence.service.assitant.generator.IdentityGenerator;
  14. import com.sinosoft.common.util.DateUtil;
  15. import com.sinosoft.em.alert.duty.records.vo.EcmDutyDetail;
  16. import com.sinosoft.em.alert.duty.records.vo.EcmEmDuty;
  17. import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDaoImpl;
  18. import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
  19. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  20. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  21. public class EcmDutyDao {
  22. private static SysModel sysmodel = ModelFactory.getSysmodel();
  23. @SuppressWarnings("unused")
  24. private static SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  25. private final static Logger log = Logger.getLogger(QueryReportProgrammeDaoImpl.class);
  26. //主键生成方式
  27. //String fD_OBJECTID = IdentityGenerator.getIdentityGenerator().gerenalIdentity(887);
  28. public boolean saveDutyBatch(EcmEmDuty duty,List<EcmDutyDetail> detailList){
  29. boolean flag=false;
  30. DbConnection dbConn = new DbConnection();
  31. Connection conn = null;
  32. PreparedStatement pstm = null;
  33. PreparedStatement pstm2 = null;
  34. String dutySQL = "insert into ECM_EM_DUTY(FD_OBJECTID, NAME, DEPT_NAMES, STATE, DUTY_TYPE, OPER_DEPT, OPER_NAME, OPER_TIME, IS_DEL, UPDATEDATE,RELEASE,OPER_NAME_ID,NAME_ID) "
  35. +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?,?,?)";
  36. String detailSQL = "insert into ECM_EM_DUTY_DETAIL(FD_OBJECTID, DUTY_ID, NAME, LEADER_NAME, LEADER_TEL, DUTY_DATE, START_TIME, END_TIME, DUTY_WAY, IS_DEL, UPDATEDATE,ADMINISTRATION_DUTY,ADMINISTRATION_DUTY_TEL,EVERYDAY_DUTY,EVERYDAY_DUTY_TEL,SPOT_DUTY,SPOT_DUTY_TEL,SPOT_DUTY_ADDRESS,SPOT_DUTY_CAR) "
  37. +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?) ";
  38. try {
  39. conn = dbConn.getConnection();
  40. conn.setAutoCommit(false);
  41. pstm = conn.prepareStatement(dutySQL);
  42. pstm2 = conn.prepareStatement(detailSQL);
  43. if(duty.getFd_objectid()==null)
  44. duty.setFd_objectid(IdentityGenerator.getIdentityGenerator().gerenalIdentity(335));
  45. pstm.setString(1, duty.getFd_objectid());
  46. pstm.setString(2, duty.getName());
  47. pstm.setString(3, duty.getDept_names());
  48. pstm.setString(4, "0");
  49. pstm.setString(5, duty.getDuty_type());//1,预警值班 2 响应值班
  50. pstm.setString(6, duty.getOper_dept());
  51. pstm.setString(7, duty.getOper_name());
  52. pstm.setString(8, duty.getOper_time());
  53. pstm.setString(9, "0");
  54. pstm.setString(10, DateUtil.getCurrDateTimeStr());
  55. pstm.setString(11, duty.getRelease());
  56. pstm.setString(12, duty.getOper_name_id());
  57. pstm.setString(13, duty.getName_id());
  58. pstm.executeUpdate();//执行SQL语句
  59. // List<EcmDutyDetail> detailList = duty.getDutyDetailList();
  60. if(detailList!=null && !detailList.isEmpty()){
  61. for(int i=0;i<detailList.size();i++){
  62. EcmDutyDetail detail = detailList.get(i);
  63. String OBJECTID = IdentityGenerator.getIdentityGenerator().gerenalIdentity(336);
  64. pstm2.setString(1, OBJECTID);
  65. pstm2.setString(2, duty.getFd_objectid()); //主副表关联
  66. pstm2.setString(3, detail.getName());
  67. pstm2.setString(4, detail.getLeader());
  68. pstm2.setString(5, detail.getLeader_tel());
  69. pstm2.setString(6, detail.getDuty_date());
  70. pstm2.setString(7, detail.getStart_time());
  71. pstm2.setString(8, detail.getEnd_time());
  72. //pstm2.setString(9, detail.getTelephone());
  73. pstm2.setString(9, detail.getDuty_way());
  74. pstm2.setString(10, "0");
  75. pstm2.setString(11, DateUtil.getCurrDateTimeStr());
  76. pstm2.setString(12,detail.getAdministration_duty());
  77. pstm2.setString(13, detail.getAdministration_duty_tel());
  78. pstm2.setString(14, detail.getEveryday_duty());
  79. pstm2.setString(15, detail.getEveryday_duty_tel());
  80. pstm2.setString(16, detail.getSpot_duty());
  81. pstm2.setString(17, detail.getSpot_duty_tel());
  82. pstm2.setString(18, detail.getSpot_duty_address());
  83. pstm2.setString(19, detail.getSpot_duty_car());
  84. pstm2.addBatch();
  85. }
  86. pstm2.executeBatch(); //批量保存
  87. }
  88. conn.commit();
  89. conn.setAutoCommit(true);
  90. flag=true;
  91. }catch(Exception e){
  92. try {
  93. conn.rollback();
  94. conn.setAutoCommit(true);
  95. } catch (SQLException e1) {
  96. e1.printStackTrace();
  97. }
  98. e.printStackTrace();
  99. }finally{
  100. try {
  101. pstm2.close();
  102. pstm.close();
  103. conn.close();
  104. } catch (SQLException e) {
  105. e.printStackTrace();
  106. }
  107. }
  108. return flag;
  109. }
  110. public void saveDuty(EcmEmDuty duty){
  111. DbConnection dbConn = new DbConnection();
  112. Connection conn = null;
  113. PreparedStatement pstm = null;
  114. String dutySQL = "insert into ECM_EM_DUTY(FD_OBJECTID, NAME, DEPT_NAMES, STATE, DUTY_TYPE, OPER_DEPT, OPER_NAME, OPER_TIME, IS_DEL, UPDATEDATE, RELEASE,NAME_ID,OPER_NAME_ID) "
  115. +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?,?,?)";
  116. try {
  117. conn = dbConn.getConnection();
  118. conn.setAutoCommit(false);
  119. pstm = conn.prepareStatement(dutySQL);
  120. pstm.setString(1, duty.getFd_objectid());
  121. pstm.setString(2, duty.getName());
  122. pstm.setString(3, duty.getDept_names());
  123. pstm.setString(4, "0");
  124. pstm.setString(5, "2"); //duty.getDuty_type()值班类型 1为预警 2为响应
  125. pstm.setString(6, duty.getOper_dept());
  126. pstm.setString(7, duty.getOper_name());
  127. pstm.setString(8, duty.getOper_time());
  128. pstm.setString(9, "0");
  129. pstm.setString(10, DateUtil.getCurrDateTimeStr());
  130. pstm.setString(11, "0");
  131. pstm.setString(12, duty.getName_id());
  132. pstm.setString(13, duty.getOper_name_id());
  133. pstm.executeUpdate();
  134. conn.commit();
  135. conn.setAutoCommit(true);
  136. }catch(Exception e){
  137. try {
  138. conn.rollback();
  139. conn.setAutoCommit(true);
  140. } catch (SQLException e1) {
  141. e1.printStackTrace();
  142. }
  143. e.printStackTrace();
  144. }finally{
  145. try {
  146. pstm.close();
  147. conn.close();
  148. } catch (SQLException e) {
  149. e.printStackTrace();
  150. }
  151. }
  152. }
  153. public boolean updateDuty(EcmEmDuty duty){
  154. boolean flag = false;
  155. DbConnection dbConn = new DbConnection();
  156. Connection conn = null;
  157. PreparedStatement pstm = null;
  158. String dutySQL = "update ECM_EM_DUTY "
  159. + " set NAME = ?, DEPT_NAMES = ?, OPER_DEPT = ?, OPER_NAME = ?, OPER_TIME = ? , UPDATEDATE = ? ,RELEASE = ? ,NAME_ID = ?"
  160. + " where FD_OBJECTID = ?";
  161. try {
  162. conn = dbConn.getConnection();
  163. conn.setAutoCommit(false);
  164. pstm = conn.prepareStatement(dutySQL);
  165. pstm.setString(1, duty.getName());
  166. pstm.setString(2, duty.getDept_names());
  167. pstm.setString(3, duty.getOper_dept());
  168. pstm.setString(4, duty.getOper_name());
  169. pstm.setString(5, duty.getOper_time());
  170. pstm.setString(6, DateUtil.getCurrDateTimeStr());
  171. pstm.setString(7, duty.getRelease());
  172. pstm.setString(8, duty.getName_id());
  173. pstm.setString(9, duty.getFd_objectid());
  174. pstm.executeUpdate();
  175. conn.commit();
  176. conn.setAutoCommit(true);
  177. flag = true;
  178. }catch(Exception e){
  179. try {
  180. conn.rollback();
  181. conn.setAutoCommit(true);
  182. } catch (SQLException e1) {
  183. e1.printStackTrace();
  184. }
  185. e.printStackTrace();
  186. }finally{
  187. try {
  188. if(pstm!=null)
  189. pstm.close();
  190. if(conn!=null)
  191. conn.close();
  192. } catch (SQLException e) {
  193. e.printStackTrace();
  194. }
  195. }
  196. return flag;
  197. }
  198. public EcmEmDuty queryEcmDuty(String fd_objectid){
  199. EcmEmDuty duty = null;
  200. return duty;
  201. }
  202. public boolean deleteDetail(String fd_id){
  203. boolean ret = false;
  204. DbConnection dbConn = new DbConnection();
  205. Connection conn = null;
  206. PreparedStatement pstm = null;
  207. //String delSQL = "delete from ECM_EM_DUTY_DETAIL t where t.FD_OBJECTID = ? ";
  208. String delSQL = "update ECM_EM_DUTY_DETAIL t set t.IS_DEL = '1' where t.FD_OBJECTID = ? ";
  209. try{
  210. conn = dbConn.getConnection();
  211. conn.setAutoCommit(false);
  212. pstm = conn.prepareStatement(delSQL);
  213. pstm.setString(1, fd_id);
  214. pstm.executeUpdate();
  215. conn.commit();
  216. conn.setAutoCommit(true);
  217. ret = true;
  218. }catch(Exception e){
  219. e.printStackTrace();
  220. }finally{
  221. try {
  222. pstm.close();
  223. conn.close();
  224. } catch (SQLException e) {
  225. e.printStackTrace();
  226. }
  227. }
  228. return ret;
  229. }
  230. public boolean saveDetail(EcmDutyDetail detail){
  231. boolean flag = false;
  232. DbConnection dbConn = new DbConnection();
  233. Connection conn = null;
  234. PreparedStatement pstm = null;
  235. String detailSQL = "insert into ECM_EM_DUTY_DETAIL(FD_OBJECTID, DUTY_ID, NAME, LEADER_NAME, LEADER_TEL, DUTY_DATE, START_TIME, END_TIME, DUTY_WAY, IS_DEL, UPDATEDATE,ADMINISTRATION_DUTY,ADMINISTRATION_DUTY_TEL,EVERYDAY_DUTY,EVERYDAY_DUTY_TEL,SPOT_DUTY,SPOT_DUTY_TEL,SPOT_DUTY_ADDRESS,SPOT_DUTY_CAR) "
  236. +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?) ";
  237. try {
  238. conn = dbConn.getConnection();
  239. conn.setAutoCommit(false);
  240. pstm = conn.prepareStatement(detailSQL);
  241. String OBJECTID = IdentityGenerator.getIdentityGenerator().gerenalIdentity(336);
  242. pstm.setString(1, OBJECTID);
  243. pstm.setString(2, detail.getDuty_id()); //主副表关联
  244. pstm.setString(3, detail.getName());
  245. pstm.setString(4, detail.getLeader());
  246. pstm.setString(5, detail.getLeader_tel());
  247. pstm.setString(6, detail.getDuty_date());
  248. pstm.setString(7, detail.getStart_time());
  249. pstm.setString(8, detail.getEnd_time());
  250. //pstm.setString(9, detail.getTelephone());
  251. pstm.setString(9, detail.getDuty_way());
  252. pstm.setString(10, "0");
  253. pstm.setString(11, DateUtil.getCurrDateTimeStr());
  254. pstm.setString(12, detail.getAdministration_duty());
  255. pstm.setString(13, detail.getAdministration_duty_tel());
  256. pstm.setString(14, detail.getEveryday_duty());
  257. pstm.setString(15, detail.getEveryday_duty_tel());
  258. pstm.setString(16, detail.getSpot_duty());
  259. pstm.setString(17, detail.getSpot_duty_tel());
  260. pstm.setString(18, detail.getSpot_duty_address());
  261. pstm.setString(19, detail.getSpot_duty_car());
  262. pstm.executeUpdate();
  263. conn.commit();
  264. conn.setAutoCommit(true);
  265. flag = true;
  266. }catch(Exception e){
  267. try {
  268. conn.rollback();
  269. conn.setAutoCommit(true);
  270. } catch (SQLException e1) {
  271. e1.printStackTrace();
  272. }
  273. e.printStackTrace();
  274. }finally{
  275. try {
  276. pstm.close();
  277. conn.close();
  278. } catch (SQLException e) {
  279. e.printStackTrace();
  280. }
  281. }
  282. return flag;
  283. }
  284. public boolean updateDetail(EcmDutyDetail detail){
  285. boolean flag = false;
  286. DbConnection dbConn = new DbConnection();
  287. Connection conn = null;
  288. PreparedStatement pstm = null;
  289. String detailSQL = "update ECM_EM_DUTY_DETAIL " //DUTY_ID = ?,
  290. +" set FD_OBJECTID = ?, NAME = ?, LEADER_NAME = ?, LEADER_TEL = ?, DUTY_DATE = ?, START_TIME = ?, END_TIME = ?, DUTY_WAY = ?, IS_DEL = ?, UPDATEDATE = ? ,ADMINISTRATION_DUTY = ?, ADMINISTRATION_DUTY_TEL = ?,"
  291. + "EVERYDAY_DUTY = ?,EVERYDAY_DUTY_TEL = ?,SPOT_DUTY = ? ,SPOT_DUTY_TEL = ?,SPOT_DUTY_ADDRESS = ?,SPOT_DUTY_CAR = ?"
  292. + " where FD_OBJECTID = ?";
  293. try {
  294. conn = dbConn.getConnection();
  295. conn.setAutoCommit(false);
  296. pstm = conn.prepareStatement(detailSQL);
  297. pstm.setString(1, detail.getFd_objectid());
  298. // pstm.setString(2, detail.getDuty_id()); //主副表关联
  299. pstm.setString(2, detail.getName());
  300. pstm.setString(3, detail.getLeader());
  301. pstm.setString(4, detail.getLeader_tel());
  302. pstm.setString(5, detail.getDuty_date());
  303. pstm.setString(6, detail.getStart_time());
  304. pstm.setString(7, detail.getEnd_time());
  305. //pstm.setString(8, detail.getTelephone());
  306. pstm.setString(8, detail.getDuty_way());
  307. pstm.setString(9, "0");
  308. pstm.setString(10, DateUtil.getCurrDateTimeStr());
  309. pstm.setString(11, detail.getAdministration_duty());
  310. pstm.setString(12, detail.getAdministration_duty_tel());
  311. pstm.setString(13, detail.getEveryday_duty());
  312. pstm.setString(14, detail.getEveryday_duty_tel());
  313. pstm.setString(15, detail.getSpot_duty());
  314. pstm.setString(16, detail.getSpot_duty_tel());
  315. pstm.setString(17, detail.getSpot_duty_address());
  316. pstm.setString(18, detail.getSpot_duty_car());
  317. pstm.setString(19, detail.getFd_objectid());
  318. pstm.executeUpdate();
  319. conn.commit();
  320. conn.setAutoCommit(true);
  321. flag = true;
  322. }catch(Exception e){
  323. try {
  324. conn.rollback();
  325. conn.setAutoCommit(true);
  326. } catch (SQLException e1) {
  327. e1.printStackTrace();
  328. }
  329. e.printStackTrace();
  330. }finally{
  331. try {
  332. pstm.close();
  333. conn.close();
  334. } catch (SQLException e) {
  335. e.printStackTrace();
  336. }
  337. }
  338. return flag;
  339. }
  340. //分页查询 达梦分页方式
  341. @SuppressWarnings("rawtypes")
  342. public List queryDetailByDutyid(String dutyid){
  343. //,int pageStart,int pageSize
  344. DbConnection dbConn = new DbConnection();
  345. Connection conn = null;
  346. PreparedStatement pstm = null;
  347. ResultSet rs = null;
  348. String strSQL = "select FD_OBJECTID,DUTY_ID,LEADER_NAME,LEADER_TEL,DUTY_DATE,START_TIME,END_TIME,DUTY_WAY,IS_DEL,UPDATEDATE,ADMINISTRATION_DUTY,ADMINISTRATION_DUTY_TEL,EVERYDAY_DUTY,EVERYDAY_DUTY_TEL,SPOT_DUTY,SPOT_DUTY_TEL,SPOT_DUTY_ADDRESS,SPOT_DUTY_CAR "
  349. // String strSQL = "select top "+pageStart+","+pageSize+" FD_OBJECTID,DUTY_ID,NAME,LEADER,LEADER_TEL,DUTY_DATE,START_TIME,END_TIME,TELEPHONE,DUTY_WAY,IS_DEL,UPDATEDATE "
  350. +" from ECM_EM_DUTY_DETAIL "
  351. +" where DUTY_ID = ? and IS_DEL='0' "
  352. + " order by duty_date desc ,start_time desc ";
  353. List<EcmDutyDetail> detailList = new ArrayList<EcmDutyDetail>();
  354. try {
  355. conn = dbConn.getConnection();
  356. pstm = conn.prepareStatement(strSQL);
  357. pstm.setString(1, dutyid);
  358. rs = pstm.executeQuery();
  359. while(rs.next()){
  360. EcmDutyDetail detail = new EcmDutyDetail();
  361. detail.setFd_objectid(rs.getString("FD_OBJECTID"));
  362. detail.setDuty_id(rs.getString("DUTY_ID"));
  363. // detail.setName(rs.getString("NAME"));
  364. detail.setLeader(rs.getString("LEADER_NAME"));
  365. detail.setLeader_tel(rs.getString("LEADER_TEL"));
  366. detail.setDuty_date(rs.getString("DUTY_DATE"));
  367. detail.setStart_time(rs.getString("START_TIME"));
  368. detail.setEnd_time(rs.getString("END_TIME"));
  369. //detail.setTelephone(rs.getString("TELEPHONE"));
  370. detail.setDuty_way(rs.getString("DUTY_WAY"));
  371. detail.setIs_del(rs.getString("IS_DEL"));
  372. detail.setUpdatedate(rs.getString("UPDATEDATE"));
  373. detail.setAdministration_duty(rs.getString("ADMINISTRATION_DUTY"));
  374. detail.setAdministration_duty_tel(rs.getString("ADMINISTRATION_DUTY_TEL"));
  375. detail.setEveryday_duty(rs.getString("EVERYDAY_DUTY"));
  376. detail.setEveryday_duty_tel(rs.getString("EVERYDAY_DUTY_TEL"));
  377. detail.setSpot_duty(rs.getString("SPOT_DUTY"));
  378. detail.setSpot_duty_tel(rs.getString("SPOT_DUTY_TEL"));
  379. detail.setSpot_duty_address(rs.getString("SPOT_DUTY_ADDRESS"));
  380. detail.setSpot_duty_car(rs.getString("SPOT_DUTY_CAR"));
  381. detailList.add(detail);
  382. }
  383. }catch(Exception e){
  384. e.printStackTrace();
  385. }finally{
  386. try {
  387. rs.close();
  388. pstm.close();
  389. conn.close();
  390. } catch (SQLException e) {
  391. e.printStackTrace();
  392. }
  393. }
  394. return detailList;
  395. }
  396. public EcmEmDuty getDutyById(String dutyid){
  397. String sqlSql = "select FD_OBJECTID,NAME,DEPT_NAMES,STATE,DUTY_TYPE,OPER_DEPT,OPER_NAME,OPER_TIME,IS_DEL,UPDATEDATE,NAME_ID "
  398. +" from ECM_EM_DUTY where FD_OBJECTID = ? ";
  399. DbConnection dbConn = new DbConnection();
  400. Connection conn = null;
  401. PreparedStatement pstm = null;
  402. ResultSet rs = null;
  403. EcmEmDuty duty = null;
  404. try {
  405. conn = dbConn.getConnection();
  406. pstm = conn.prepareStatement(sqlSql);
  407. pstm.setString(1, dutyid);
  408. rs = pstm.executeQuery();
  409. while(rs.next()){
  410. duty = new EcmEmDuty();
  411. duty.setFd_objectid(rs.getString("FD_OBJECTID"));
  412. duty.setName(rs.getString("NAME"));
  413. duty.setDept_names(rs.getString("DEPT_NAMES"));
  414. duty.setState(rs.getString("STATE"));
  415. duty.setDuty_type(rs.getString("DUTY_TYPE"));
  416. duty.setOper_dept(rs.getString("OPER_DEPT"));
  417. duty.setOper_name(rs.getString("OPER_NAME"));
  418. duty.setOper_time(rs.getString("OPER_TIME"));
  419. duty.setIs_del(rs.getString("IS_DEL"));
  420. duty.setUpdatedate(rs.getString("UPDATEDATE"));
  421. duty.setName_id(rs.getString("NAME_ID"));
  422. }
  423. }catch(Exception e){
  424. e.printStackTrace();
  425. }finally{
  426. try {
  427. rs.close();
  428. pstm.close();
  429. conn.close();
  430. } catch (SQLException e) {
  431. e.printStackTrace();
  432. }
  433. }
  434. return duty;
  435. }
  436. public boolean updateStat(String[] fdids,String svalue,String rvalue,String releasetime,String reporttime){
  437. boolean flag = false;
  438. int handlestate = 0;
  439. String strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ? where FD_OBJECTID = ?" ;
  440. if(releasetime!=null){
  441. handlestate = 1;
  442. strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ?,RELEASE_TIME = ? where FD_OBJECTID = ?" ;
  443. }
  444. if(reporttime!=null){
  445. handlestate = 2;
  446. strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ?,REPORTING_TIME = ? where FD_OBJECTID = ?" ;
  447. }
  448. if(releasetime!=null && reporttime!=null){
  449. handlestate = 3;
  450. strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ?,REPORTING_TIME = ?,RELEASE_TIME = ? where FD_OBJECTID = ?" ;
  451. }
  452. DbConnection dbConn = new DbConnection();
  453. Connection conn = null;
  454. PreparedStatement pstm = null;
  455. try {
  456. conn = dbConn.getConnection();
  457. conn.setAutoCommit(false);
  458. pstm = conn.prepareStatement(strSql);
  459. for(int i=0;i<fdids.length;i++){
  460. pstm.setString(1, svalue);
  461. pstm.setString(2, rvalue);
  462. if(handlestate==0){
  463. pstm.setString(3, fdids[i]);
  464. }
  465. if(handlestate==1){
  466. pstm.setString(3, releasetime);
  467. pstm.setString(4, fdids[i]);
  468. }
  469. if(handlestate==2){
  470. pstm.setString(3, reporttime);
  471. pstm.setString(4, fdids[i]);
  472. }
  473. if(handlestate==3){
  474. pstm.setString(3, reporttime);
  475. pstm.setString(4, releasetime);
  476. pstm.setString(5, fdids[i]);
  477. }
  478. pstm.addBatch();
  479. }
  480. pstm.executeBatch();
  481. conn.commit();
  482. conn.setAutoCommit(true);
  483. flag = true;
  484. }catch(Exception e){
  485. e.printStackTrace();
  486. }finally{
  487. try {
  488. pstm.close();
  489. conn.close();
  490. } catch (SQLException e) {
  491. e.printStackTrace();
  492. }
  493. }
  494. return flag;
  495. }
  496. public boolean deleteDuty(String[] objectIDs){
  497. boolean ret = false;
  498. DbConnection dbConn = new DbConnection();
  499. Connection conn = null;
  500. PreparedStatement pstm = null;
  501. PreparedStatement pstm2 = null;
  502. String delDuty = "update ECM_EM_DUTY t set t.IS_DEL = '1' where t.FD_OBJECTID = ? ";
  503. String delDetail = "update ECM_EM_DUTY_DETAIL t set t.IS_DEL = '1' where t.DUTY_ID = ? ";
  504. try{
  505. conn = dbConn.getConnection();
  506. conn.setAutoCommit(false);
  507. pstm = conn.prepareStatement(delDuty);
  508. pstm2 = conn.prepareStatement(delDetail);
  509. for(int i=0;i<objectIDs.length;i++){
  510. String fd_id = objectIDs[i];
  511. pstm.setString(1, fd_id);
  512. pstm.addBatch();
  513. pstm2.setString(1, fd_id);
  514. pstm2.addBatch();
  515. }
  516. pstm.executeBatch();
  517. pstm2.executeBatch();
  518. conn.commit();
  519. conn.setAutoCommit(true);
  520. ret = true;
  521. }catch(Exception e){
  522. try {
  523. conn.rollback();
  524. conn.setAutoCommit(true);
  525. } catch (SQLException e1) {
  526. e1.printStackTrace();
  527. }
  528. e.printStackTrace();
  529. return ret;
  530. }finally{
  531. try {
  532. pstm2.close();
  533. pstm.close();
  534. conn.close();
  535. } catch (SQLException e) {
  536. e.printStackTrace();
  537. }
  538. }
  539. return ret;
  540. }
  541. public boolean deDutyDetail(String[] params){
  542. // TODO Auto-generated method stub
  543. boolean flag=false;
  544. DbConnection dbConn = new DbConnection();
  545. Connection conn = null;
  546. PreparedStatement pstm = null;
  547. PreparedStatement pstm1 = null;
  548. String delDemandSQL="update ECM_EM_DUTY set IS_DEL ='1' where FD_OBJECTID=?";
  549. String delEquipSQL ="update ECM_EM_DUTY_DETAIL set IS_DEL ='1' where DUTY_ID=?";
  550. try{
  551. conn=dbConn.getConnection();
  552. conn.setAutoCommit(false);
  553. pstm=conn.prepareStatement(delDemandSQL);
  554. pstm1=conn.prepareStatement(delEquipSQL);
  555. for(int i=0;i<params.length;i++){
  556. pstm.setString(1, params[i]);
  557. pstm1.setString(1, params[i]);
  558. pstm.executeUpdate();
  559. pstm1.executeUpdate();
  560. }
  561. conn.commit();
  562. conn.setAutoCommit(true);
  563. flag=true;
  564. //System.out.println(123123123);
  565. }catch(Exception e){
  566. try {
  567. conn.rollback();
  568. conn.setAutoCommit(true);
  569. } catch (SQLException e1) {
  570. e1.printStackTrace();
  571. }
  572. e.printStackTrace();
  573. }finally{
  574. try {
  575. if(pstm!=null)
  576. pstm.close();
  577. if(pstm1!=null)
  578. pstm1.close();
  579. if(conn!=null)
  580. conn.close();
  581. } catch (SQLException e) {
  582. e.printStackTrace();
  583. }
  584. }
  585. return flag;
  586. }
  587. public List getDutyByParams(String oPER_DEPT) throws Exception {
  588. try {
  589. String sql = "select a.FD_OBJECTID, a.DUTY_ID , a.NAME , a.LEADER_NAME, a.LEADER_TEL , a.DUTY_DATE , a.START_TIME , a.END_TIME , a.TELEPHONE , a.DUTY_WAY, b.DUTY_TYPE from ECM_EM_DUTY_DETAIL a,ECM_EM_DUTY b where a.duty_id = b.FD_OBJECTID and a.is_del ='0' and b.release='1' and b.OPER_DEPT='"+oPER_DEPT+"' and to_char(sysdate,'yyyy-mm-dd hh24:mi') between a.START_TIME and a.END_TIME order by b.DUTY_TYPE";
  590. log.info("getDutyByParams:"+sql);
  591. List<Map<String, String>> list = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResultToMap(336, sql);
  592. return list;
  593. } catch (Exception e) {
  594. throw e;
  595. }
  596. }
  597. }