123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 |
- package com.sinosoft.em.alert.duty.records.dao;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import org.apache.log4j.Logger;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.assitant.generator.IdentityGenerator;
- import com.sinosoft.common.util.DateUtil;
- import com.sinosoft.em.alert.duty.records.vo.EcmDutyDetail;
- import com.sinosoft.em.alert.duty.records.vo.EcmEmDuty;
- import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDaoImpl;
- import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- public class EcmDutyDao {
- private static SysModel sysmodel = ModelFactory.getSysmodel();
- @SuppressWarnings("unused")
- private static SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- private final static Logger log = Logger.getLogger(QueryReportProgrammeDaoImpl.class);
-
- //主键生成方式
- //String fD_OBJECTID = IdentityGenerator.getIdentityGenerator().gerenalIdentity(887);
- public boolean saveDutyBatch(EcmEmDuty duty,List<EcmDutyDetail> detailList){
- boolean flag=false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- PreparedStatement pstm2 = null;
- 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) "
- +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?,?,?)";
- 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) "
- +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?) ";
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(dutySQL);
- pstm2 = conn.prepareStatement(detailSQL);
- if(duty.getFd_objectid()==null)
- duty.setFd_objectid(IdentityGenerator.getIdentityGenerator().gerenalIdentity(335));
- pstm.setString(1, duty.getFd_objectid());
- pstm.setString(2, duty.getName());
- pstm.setString(3, duty.getDept_names());
- pstm.setString(4, "0");
- pstm.setString(5, duty.getDuty_type());//1,预警值班 2 响应值班
- pstm.setString(6, duty.getOper_dept());
- pstm.setString(7, duty.getOper_name());
- pstm.setString(8, duty.getOper_time());
- pstm.setString(9, "0");
- pstm.setString(10, DateUtil.getCurrDateTimeStr());
- pstm.setString(11, duty.getRelease());
- pstm.setString(12, duty.getOper_name_id());
- pstm.setString(13, duty.getName_id());
- pstm.executeUpdate();//执行SQL语句
- // List<EcmDutyDetail> detailList = duty.getDutyDetailList();
- if(detailList!=null && !detailList.isEmpty()){
- for(int i=0;i<detailList.size();i++){
- EcmDutyDetail detail = detailList.get(i);
- String OBJECTID = IdentityGenerator.getIdentityGenerator().gerenalIdentity(336);
- pstm2.setString(1, OBJECTID);
- pstm2.setString(2, duty.getFd_objectid()); //主副表关联
- pstm2.setString(3, detail.getName());
- pstm2.setString(4, detail.getLeader());
- pstm2.setString(5, detail.getLeader_tel());
- pstm2.setString(6, detail.getDuty_date());
- pstm2.setString(7, detail.getStart_time());
- pstm2.setString(8, detail.getEnd_time());
- //pstm2.setString(9, detail.getTelephone());
- pstm2.setString(9, detail.getDuty_way());
- pstm2.setString(10, "0");
- pstm2.setString(11, DateUtil.getCurrDateTimeStr());
- pstm2.setString(12,detail.getAdministration_duty());
- pstm2.setString(13, detail.getAdministration_duty_tel());
- pstm2.setString(14, detail.getEveryday_duty());
- pstm2.setString(15, detail.getEveryday_duty_tel());
- pstm2.setString(16, detail.getSpot_duty());
- pstm2.setString(17, detail.getSpot_duty_tel());
- pstm2.setString(18, detail.getSpot_duty_address());
- pstm2.setString(19, detail.getSpot_duty_car());
- pstm2.addBatch();
- }
- pstm2.executeBatch(); //批量保存
- }
- conn.commit();
- conn.setAutoCommit(true);
- flag=true;
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- pstm2.close();
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
- }
-
- public void saveDuty(EcmEmDuty duty){
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- 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) "
- +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?,?,?)";
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(dutySQL);
- pstm.setString(1, duty.getFd_objectid());
- pstm.setString(2, duty.getName());
- pstm.setString(3, duty.getDept_names());
- pstm.setString(4, "0");
- pstm.setString(5, "2"); //duty.getDuty_type()值班类型 1为预警 2为响应
- pstm.setString(6, duty.getOper_dept());
- pstm.setString(7, duty.getOper_name());
- pstm.setString(8, duty.getOper_time());
- pstm.setString(9, "0");
- pstm.setString(10, DateUtil.getCurrDateTimeStr());
- pstm.setString(11, "0");
- pstm.setString(12, duty.getName_id());
- pstm.setString(13, duty.getOper_name_id());
- pstm.executeUpdate();
-
- conn.commit();
- conn.setAutoCommit(true);
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public boolean updateDuty(EcmEmDuty duty){
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String dutySQL = "update ECM_EM_DUTY "
- + " set NAME = ?, DEPT_NAMES = ?, OPER_DEPT = ?, OPER_NAME = ?, OPER_TIME = ? , UPDATEDATE = ? ,RELEASE = ? ,NAME_ID = ?"
- + " where FD_OBJECTID = ?";
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(dutySQL);
- pstm.setString(1, duty.getName());
- pstm.setString(2, duty.getDept_names());
- pstm.setString(3, duty.getOper_dept());
- pstm.setString(4, duty.getOper_name());
- pstm.setString(5, duty.getOper_time());
- pstm.setString(6, DateUtil.getCurrDateTimeStr());
- pstm.setString(7, duty.getRelease());
- pstm.setString(8, duty.getName_id());
- pstm.setString(9, duty.getFd_objectid());
- pstm.executeUpdate();
-
- conn.commit();
- conn.setAutoCommit(true);
- flag = true;
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- if(pstm!=null)
- pstm.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
- }
-
- public EcmEmDuty queryEcmDuty(String fd_objectid){
- EcmEmDuty duty = null;
- return duty;
- }
-
- public boolean deleteDetail(String fd_id){
- boolean ret = false;
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- //String delSQL = "delete from ECM_EM_DUTY_DETAIL t where t.FD_OBJECTID = ? ";
- String delSQL = "update ECM_EM_DUTY_DETAIL t set t.IS_DEL = '1' where t.FD_OBJECTID = ? ";
- try{
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(delSQL);
- pstm.setString(1, fd_id);
- pstm.executeUpdate();
- conn.commit();
- conn.setAutoCommit(true);
- ret = true;
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return ret;
- }
-
- public boolean saveDetail(EcmDutyDetail detail){
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- 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) "
- +" VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?) ";
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(detailSQL);
- String OBJECTID = IdentityGenerator.getIdentityGenerator().gerenalIdentity(336);
- pstm.setString(1, OBJECTID);
- pstm.setString(2, detail.getDuty_id()); //主副表关联
- pstm.setString(3, detail.getName());
- pstm.setString(4, detail.getLeader());
- pstm.setString(5, detail.getLeader_tel());
- pstm.setString(6, detail.getDuty_date());
- pstm.setString(7, detail.getStart_time());
- pstm.setString(8, detail.getEnd_time());
- //pstm.setString(9, detail.getTelephone());
- pstm.setString(9, detail.getDuty_way());
- pstm.setString(10, "0");
- pstm.setString(11, DateUtil.getCurrDateTimeStr());
- pstm.setString(12, detail.getAdministration_duty());
- pstm.setString(13, detail.getAdministration_duty_tel());
- pstm.setString(14, detail.getEveryday_duty());
- pstm.setString(15, detail.getEveryday_duty_tel());
- pstm.setString(16, detail.getSpot_duty());
- pstm.setString(17, detail.getSpot_duty_tel());
- pstm.setString(18, detail.getSpot_duty_address());
- pstm.setString(19, detail.getSpot_duty_car());
- pstm.executeUpdate();
- conn.commit();
- conn.setAutoCommit(true);
- flag = true;
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
- }
-
-
- public boolean updateDetail(EcmDutyDetail detail){
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update ECM_EM_DUTY_DETAIL " //DUTY_ID = ?,
- +" set FD_OBJECTID = ?, 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 = ?"
- + " where FD_OBJECTID = ?";
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, detail.getFd_objectid());
- // pstm.setString(2, detail.getDuty_id()); //主副表关联
- pstm.setString(2, detail.getName());
- pstm.setString(3, detail.getLeader());
- pstm.setString(4, detail.getLeader_tel());
- pstm.setString(5, detail.getDuty_date());
- pstm.setString(6, detail.getStart_time());
- pstm.setString(7, detail.getEnd_time());
- //pstm.setString(8, detail.getTelephone());
- pstm.setString(8, detail.getDuty_way());
- pstm.setString(9, "0");
- pstm.setString(10, DateUtil.getCurrDateTimeStr());
- pstm.setString(11, detail.getAdministration_duty());
- pstm.setString(12, detail.getAdministration_duty_tel());
- pstm.setString(13, detail.getEveryday_duty());
- pstm.setString(14, detail.getEveryday_duty_tel());
- pstm.setString(15, detail.getSpot_duty());
- pstm.setString(16, detail.getSpot_duty_tel());
- pstm.setString(17, detail.getSpot_duty_address());
- pstm.setString(18, detail.getSpot_duty_car());
- pstm.setString(19, detail.getFd_objectid());
- pstm.executeUpdate();
- conn.commit();
- conn.setAutoCommit(true);
- flag = true;
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
- }
- //分页查询 达梦分页方式
- @SuppressWarnings("rawtypes")
- public List queryDetailByDutyid(String dutyid){
- //,int pageStart,int pageSize
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- 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 "
- // 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 "
- +" from ECM_EM_DUTY_DETAIL "
- +" where DUTY_ID = ? and IS_DEL='0' "
- + " order by duty_date desc ,start_time desc ";
- List<EcmDutyDetail> detailList = new ArrayList<EcmDutyDetail>();
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(strSQL);
- pstm.setString(1, dutyid);
- rs = pstm.executeQuery();
-
- while(rs.next()){
- EcmDutyDetail detail = new EcmDutyDetail();
- detail.setFd_objectid(rs.getString("FD_OBJECTID"));
- detail.setDuty_id(rs.getString("DUTY_ID"));
- // detail.setName(rs.getString("NAME"));
- detail.setLeader(rs.getString("LEADER_NAME"));
- detail.setLeader_tel(rs.getString("LEADER_TEL"));
- detail.setDuty_date(rs.getString("DUTY_DATE"));
- detail.setStart_time(rs.getString("START_TIME"));
- detail.setEnd_time(rs.getString("END_TIME"));
- //detail.setTelephone(rs.getString("TELEPHONE"));
- detail.setDuty_way(rs.getString("DUTY_WAY"));
- detail.setIs_del(rs.getString("IS_DEL"));
- detail.setUpdatedate(rs.getString("UPDATEDATE"));
- detail.setAdministration_duty(rs.getString("ADMINISTRATION_DUTY"));
- detail.setAdministration_duty_tel(rs.getString("ADMINISTRATION_DUTY_TEL"));
- detail.setEveryday_duty(rs.getString("EVERYDAY_DUTY"));
- detail.setEveryday_duty_tel(rs.getString("EVERYDAY_DUTY_TEL"));
- detail.setSpot_duty(rs.getString("SPOT_DUTY"));
- detail.setSpot_duty_tel(rs.getString("SPOT_DUTY_TEL"));
- detail.setSpot_duty_address(rs.getString("SPOT_DUTY_ADDRESS"));
- detail.setSpot_duty_car(rs.getString("SPOT_DUTY_CAR"));
-
- detailList.add(detail);
- }
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- rs.close();
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return detailList;
- }
-
- public EcmEmDuty getDutyById(String dutyid){
- String sqlSql = "select FD_OBJECTID,NAME,DEPT_NAMES,STATE,DUTY_TYPE,OPER_DEPT,OPER_NAME,OPER_TIME,IS_DEL,UPDATEDATE,NAME_ID "
- +" from ECM_EM_DUTY where FD_OBJECTID = ? ";
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- EcmEmDuty duty = null;
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sqlSql);
- pstm.setString(1, dutyid);
- rs = pstm.executeQuery();
- while(rs.next()){
- duty = new EcmEmDuty();
- duty.setFd_objectid(rs.getString("FD_OBJECTID"));
- duty.setName(rs.getString("NAME"));
- duty.setDept_names(rs.getString("DEPT_NAMES"));
- duty.setState(rs.getString("STATE"));
- duty.setDuty_type(rs.getString("DUTY_TYPE"));
- duty.setOper_dept(rs.getString("OPER_DEPT"));
- duty.setOper_name(rs.getString("OPER_NAME"));
- duty.setOper_time(rs.getString("OPER_TIME"));
- duty.setIs_del(rs.getString("IS_DEL"));
- duty.setUpdatedate(rs.getString("UPDATEDATE"));
- duty.setName_id(rs.getString("NAME_ID"));
- }
-
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- rs.close();
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return duty;
- }
- public boolean updateStat(String[] fdids,String svalue,String rvalue,String releasetime,String reporttime){
- boolean flag = false;
- int handlestate = 0;
- String strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ? where FD_OBJECTID = ?" ;
- if(releasetime!=null){
- handlestate = 1;
- strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ?,RELEASE_TIME = ? where FD_OBJECTID = ?" ;
- }
- if(reporttime!=null){
- handlestate = 2;
- strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ?,REPORTING_TIME = ? where FD_OBJECTID = ?" ;
- }
- if(releasetime!=null && reporttime!=null){
- handlestate = 3;
- strSql = " update ECM_EM_DUTY set STATE = ?, RELEASE = ?,REPORTING_TIME = ?,RELEASE_TIME = ? where FD_OBJECTID = ?" ;
- }
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(strSql);
- for(int i=0;i<fdids.length;i++){
- pstm.setString(1, svalue);
- pstm.setString(2, rvalue);
- if(handlestate==0){
- pstm.setString(3, fdids[i]);
- }
- if(handlestate==1){
- pstm.setString(3, releasetime);
- pstm.setString(4, fdids[i]);
- }
- if(handlestate==2){
- pstm.setString(3, reporttime);
- pstm.setString(4, fdids[i]);
- }
- if(handlestate==3){
- pstm.setString(3, reporttime);
- pstm.setString(4, releasetime);
- pstm.setString(5, fdids[i]);
- }
- pstm.addBatch();
- }
- pstm.executeBatch();
- conn.commit();
- conn.setAutoCommit(true);
- flag = true;
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
-
- }
- public boolean deleteDuty(String[] objectIDs){
- boolean ret = false;
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- PreparedStatement pstm2 = null;
- String delDuty = "update ECM_EM_DUTY t set t.IS_DEL = '1' where t.FD_OBJECTID = ? ";
- String delDetail = "update ECM_EM_DUTY_DETAIL t set t.IS_DEL = '1' where t.DUTY_ID = ? ";
- try{
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(delDuty);
- pstm2 = conn.prepareStatement(delDetail);
- for(int i=0;i<objectIDs.length;i++){
- String fd_id = objectIDs[i];
- pstm.setString(1, fd_id);
- pstm.addBatch();
- pstm2.setString(1, fd_id);
- pstm2.addBatch();
-
- }
- pstm.executeBatch();
- pstm2.executeBatch();
- conn.commit();
- conn.setAutoCommit(true);
- ret = true;
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
-
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- return ret;
- }finally{
- try {
- pstm2.close();
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return ret;
- }
-
- public boolean deDutyDetail(String[] params){
- // TODO Auto-generated method stub
- boolean flag=false;
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- PreparedStatement pstm1 = null;
- String delDemandSQL="update ECM_EM_DUTY set IS_DEL ='1' where FD_OBJECTID=?";
- String delEquipSQL ="update ECM_EM_DUTY_DETAIL set IS_DEL ='1' where DUTY_ID=?";
- try{
- conn=dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm=conn.prepareStatement(delDemandSQL);
- pstm1=conn.prepareStatement(delEquipSQL);
- for(int i=0;i<params.length;i++){
-
- pstm.setString(1, params[i]);
- pstm1.setString(1, params[i]);
- pstm.executeUpdate();
- pstm1.executeUpdate();
- }
- conn.commit();
- conn.setAutoCommit(true);
- flag=true;
- //System.out.println(123123123);
-
- }catch(Exception e){
- try {
- conn.rollback();
- conn.setAutoCommit(true);
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
-
- }finally{
- try {
- if(pstm!=null)
- pstm.close();
- if(pstm1!=null)
- pstm1.close();
- if(conn!=null)
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
-
- return flag;
- }
- public List getDutyByParams(String oPER_DEPT) throws Exception {
- try {
- 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";
- log.info("getDutyByParams:"+sql);
- List<Map<String, String>> list = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResultToMap(336, sql);
-
- return list;
-
- } catch (Exception e) {
- throw e;
- }
- }
-
- }
|