1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435 |
- package com.sinosoft.em.gps.dao;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import net.sf.json.JSONArray;
- import org.apache.log4j.Logger;
- import org.jfree.util.Log;
- import com.formaction.Parameter;
- import com.formaction.vo.Msg;
- import com.google.gson.JsonArray;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.assitant.generator.IdentityGenerator;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
- import com.sinosoft.common.excel.JsonPluginsUtil;
- import com.sinosoft.common.util.DateUtil;
- import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDaoImpl;
- import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
- import com.sinosoft.em.gps.vo.Detp;
- import com.sinosoft.em.gps.vo.GPSBaoBiao;
- import com.sinosoft.em.gps.vo.GPSDutyMsg;
- import com.sinosoft.em.gps.vo.GPSTask;
- import com.sinosoft.em.gps.vo.GPSUserMsg;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- public class BaoGongDianTaskDao {
- StringBuffer json = new StringBuffer();
- private static SysModel sysmodel = ModelFactory.getSysmodel();
- private static SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- private final static Logger log = Logger.getLogger(QueryReportProgrammeDaoImpl.class);
- public Msg saveUser(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String task_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_USER (FD_OBJECTID,USER_ID,USER_NAME,USER_ADDRESS,"+
- "POWER_SUPPLY_UNIT_NAME,IMPORTANT_USER_LEVEL,ELECTROR_TYPE,VOLTAGE_LEVEL,IS_DEL,"+
- "UPDATEDATE,INPUT_NAME,INPUT_TIME,INPUT_UNIT,FD_TASK,AGREEMENT_CAPACITY,LOAD_KIND,"
- + "OWNED_SOURCE_FLAG,OWNED_SOURCE_CAPACITY,ENXTEND) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(612);
- st.setString(1, fd_id);
- st.setString(2, map.get("USER_ID_612"));
- st.setString(3, map.get("USER_NAME_612"));
- st.setString(4, map.get("USER_ADDRESS_612"));
- st.setString(5, map.get("POWER_SUPPLY_UNIT_NAME_612"));
- st.setString(6, map.get("IMPORTANT_USER_LEVEL_612"));
- st.setString(7, map.get("ELECTROR_TYPE_612"));
- st.setString(8, map.get("VOLTAGE_LEVEL_612"));
- st.setString(9, "0");
- st.setString(10, time);
- st.setString(11, real_name);
- st.setString(12, time);
- st.setString(13, comp_id);
- st.setString(14, task_id);
- st.setString(15, map.get("AGREEMENT_CAPACITY_612"));
- st.setString(16, map.get("LOAD_KIND_612"));
- st.setString(17, map.get("OWNED_SOURCE_FLAG_612"));
- st.setString(18, map.get("OWNED_SOURCE_CAPACITY_612"));
- st.setString(19, map.get("ENXTEND_612"));
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
- public Msg saveUser1(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String task_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into NWYJ.ECM_GPS_USER1(FD_OBJECTID, KHBH, KHMC, TASK_ID, INPUT_UNIT, INPUT_USER, INPUT_TIME, UPDATEDATE, "
- + "IS_DEL, KHLB, GDDW, ZYDJ, DYDJ, ZJRL, BAFH, GDXL1, SJBDZ1, GDXL2, SJBDZ2, GDXL3, SJBDZ3, GDXL4, SJBDZ4, GDDYSFMZBZ,"
- + " ZBYJDYRL, ZBYJDYPB, ZBYJDYSFMZBZ, BEIZHU) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(617);
- st.setString(1, fd_id);
- st.setString(2, map.get("KHBH_617"));
- st.setString(3, map.get("KHMC_617"));
- st.setString(4, task_id);
- st.setString(5, comp_id);
- st.setString(6, real_name);
- st.setString(7, time);
- st.setString(8, time);
- st.setString(9, "0");
- st.setString(10, map.get("KHLB_617"));
- st.setString(11, map.get("GDDW_617"));
- st.setString(12, map.get("ZYDJ_617"));
- st.setString(13, map.get("DYDJ_617"));
- st.setString(14, map.get("ZJRL_617"));
- st.setString(15, map.get("BAFH_617"));
- st.setString(16, map.get("GDXL1_617"));
- st.setString(17, map.get("SJBDZ1_617"));
- st.setString(18, map.get("GDXL2_617"));
- st.setString(19, map.get("SJBDZ2_617"));
- st.setString(20, map.get("GDXL3_617"));
- st.setString(21, map.get("SJBDZ3_617"));
- st.setString(22, map.get("GDXL4_617"));
- st.setString(23, map.get("SJBDZ4_617"));
- st.setString(24, map.get("GDDYSFMZBZ_617"));
- st.setString(25, map.get("ZBYJDYRL_617"));
- st.setString(26, map.get("ZBYJDYPB_617"));
- st.setString(27, map.get("ZBYJDYSFMZBZ_617"));
- st.setString(28, map.get("BEIZHU_617"));
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
- public Msg saveBaoBiao(String json, String real_name, String comp_id, String task_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_JOURNALING ( FD_OBJECTID, INPUT_NAME, INPUT_TIME, INPUT_DEPT, MAN_COUNT,"
- + " CAR_COUNT, IS_DEL, UPDATEDATE, FD_TASK, FD_TASK_NAME, BGD_FDC, BGD_FDJ, BGD_RW_TIME, BGD_DW ,"
- + "BGD_LEVEL,XINGHAO,RONGLIANG,CHANJIA,QTZHUNGBEI)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- String sql1 = "select PROGRAM_NAME,TO_CHAR(UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),GPS_LEVEL from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID='"+task_id+"'";
- log.info("queryTask_sql:"+sql1);
- List<String[]> tempList = persistence.getSearchResult(610, sql1.toString());
- String taskName = "";
- String taskTime = "";
- String taskLevel = "";
- if(tempList!=null && tempList.size()>0){
- String[] arr = tempList.get(0);
- taskName = arr[0];
- taskTime = arr[1];
- taskLevel = arr[2];
- }
- if("0".equals(taskLevel)){
- taskLevel = "特级";
- }else if("1".equals(taskLevel)){
- taskLevel = "一级";
- }else if("2".equals(taskLevel)){
- taskLevel = "二级";
- }else if("3".equals(taskLevel)){
- taskLevel = "三级";
- }
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(613);
- st.setString(1, fd_id);
- st.setString(2, real_name);
- st.setString(3, time);
- st.setString(4, comp_id);
- st.setString(5, map.get("MAN_COUNT_613"));
- st.setString(6, map.get("CAR_COUNT_613"));
- st.setString(7, "0");
- st.setString(8, time);
- st.setString(9, task_id);
- st.setString(10, taskName);
- st.setString(11, map.get("BGD_FDC_613"));
- st.setString(12, map.get("BGD_FDJ_613"));
- st.setString(13, taskTime);
- st.setString(14, map.get("BGD_DW_613"));
- st.setString(15, taskLevel);
- st.setString(16, map.get("XINGHAO_613"));
- st.setString(17, map.get("RONGLIANG_613"));
- st.setString(18, map.get("CHANJIA_613"));
- st.setString(19, map.get("QTZHUNGBEI_613"));
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (Exception e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
- public Msg saveDuty(String json, String real_name, String comp_id, String task_id, String user_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_DUTY (FD_OBJECTID,START_TIME,END_TIME,LEADER,"+
- "LEADER_TEL,WATCH_MAN,WATCH_TEL,DUTY_MODE,TIANBAO_TIME,IS_DEL,"+
- "UPDATEDATE,TIANBAO_PERSON,FLOW_ID,DEPT,TASK_ID,LEADER_DUTY_MODE,INPUT_NAME_ID) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
- String startim = map.get("START_TIME_632")+":00";
- String entim = map.get("END_TIME_632")+":00";
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(632);
- st.setString(1, fd_id);
- st.setString(2, startim);
- st.setString(3, entim);
- st.setString(4, map.get("LEADER_632"));
- st.setString(5, map.get("LEADER_TEL_632"));
- st.setString(6, map.get("WATCH_MAN_632"));
- st.setString(7, map.get("WATCH_TEL_632"));
- st.setString(8, map.get("DUTY_MODE_632"));
- st.setString(9, time);
- st.setString(10, "0");
- st.setString(11, time);
- st.setString(12, real_name);
- st.setString(13, "0");
- st.setString(14, comp_id);
- st.setString(15, task_id);
- st.setString(16, map.get("LEADER_DUTY_MODE_632"));
- st.setString(17, user_id);
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
-
-
- /**
- * 导入后保存 保供电场所
- * @param json
- * @param real_name
- * @param comp_id
- * @param task_id
- * @param user_id
- * @return
- * @throws ClassNotFoundException
- */
- public Msg saveBaoBiao1(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String comp_name, String task_id, String user_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_ZIYUANBAOBIAO (FD_OBJECTID, UPDATEDATE,IS_DEL,INPUT_NAME, INPUT_NAME_ID,INPUT_UNIT_NAME,INPUT_UNIT_ID, TASK_ID, "
- + " INPUT_TIME, ISSUE_TIME, ISSUE_DEPT, GPS_TASK_NUMBER,"
- + " GPS_TASK_FDC_DAY, GPS_TASK__FDC_TOTAL, GPS_TASK_FDJ_DAY, GPS_TASK_FDJ_TOTAL, GPS_TASK_CAR, GPS_TASK_ZBZHGLRY, "
- + "GPS_TASK_BDWBZRY, GPS_TASK_ABRY, GPS_TASK_WWSCRY, START_TIME, END_TIME, GPS_CONTINATION_TIME) "
- + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(620);
- st.setString(1, fd_id);
- st.setString(2, time);
- st.setString(3, "0");
- st.setString(4, real_name);
- st.setString(5, user_id);
- st.setString(6, comp_name);
- st.setString(7, comp_id);
- st.setString(8, task_id);
- st.setString(9, time);
- st.setString(10, time);
- st.setString(11, comp_id);
- st.setString(12, map.get("GPS_TASK_NUMBER_620"));
- st.setString(13, map.get("GPS_TASK_FDC_DAY_620"));
- st.setString(14, map.get("GPS_TASK__FDC_TOTAL_620"));
- st.setString(15, map.get("GPS_TASK_FDJ_DAY_620"));
- st.setString(16, map.get("GPS_TASK_FDJ_TOTAL_620"));
- st.setString(17, map.get("GPS_TASK_CAR_620"));
- st.setString(18, map.get("GPS_TASK_ZBZHGLRY_620"));
- st.setString(19, map.get("GPS_TASK_BDWBZRY_620"));
- st.setString(20, map.get("GPS_TASK_ABRY_620"));
- st.setString(21, map.get("GPS_TASK_WWSCRY_620"));
- st.setString(22, map.get("START_TIME_620"));
- st.setString(23, map.get("END_TIME_620"));
- st.setString(24, map.get("GPS_CONTINATION_TIME_620"));
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
-
-
-
-
-
-
- /**
- * 导入后保存 保供电场所
- * @param json
- * @param real_name
- * @param comp_id
- * @param task_id
- * @param user_id
- * @return
- * @throws ClassNotFoundException
- */
- public Msg saveGpsPlace(String json/*,String user_id*/, String real_name/*, String report_type*/, String comp_id, String comp_name, String task_id, String user_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_PLACE(FD_OBJECTID, UPDATEDATE, IS_DEL, INPUT_OPER_NAME, INPUT_OPER_ID, INPUT_UNIT_NAME, "
- + "INPUT_UNIT_ID, TASK_FDID, TASK_NUMBER, PLACE_NAME, PLACE_NUMBER, PLACE_CLASSIFICATION, PLACE_LEVEL, "
- + "PLACE_VOLTAGE_LEVEL, QXJHTD, KZYDJC, XZYHCSSY, YJDYZBZY, CYCGXCZS, GPS_START_DATE, GPS_END_DATE, "
- + "GPS_CONTINUED_TIME, FDCDR, FDJDR) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(619);
- st.setString(1, fd_id);
- st.setString(2, time);
- st.setString(3, "0");
- st.setString(4, real_name);
- st.setString(5, user_id);
- st.setString(6, comp_name);
- st.setString(7, comp_id);
- st.setString(8, task_id);
- st.setString(9, map.get("TASK_NUMBER_619"));
- st.setString(10, map.get("PLACE_NAME_619"));
- st.setString(11, map.get("PLACE_NUMBER_619"));
- st.setString(12, map.get("PLACE_CLASSIFICATION_619"));
- st.setString(13, map.get("PLACE_LEVEL_619"));
- st.setString(14, map.get("PLACE_VOLTAGE_LEVEL_619"));
- st.setString(15, map.get("QXJHTD_619"));
- st.setString(16, map.get("KZYDJC_619"));
- st.setString(17, map.get("XZYHCSSY_619"));
- st.setString(18, map.get("YJDYZBZY_619"));
- st.setString(19, map.get("CYCGXCZS_619"));
- st.setString(20, map.get("GPS_START_DATE_619"));
- st.setString(21, map.get("GPS_END_DATE_619"));
- st.setString(22, map.get("GPS_CONTINUED_TIME_619"));
- st.setString(23, map.get("FDCDR_619"));
- st.setString(24, map.get("FDJDR_619"));
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
- public Msg saveGpsEquipment(String json, String real_name, String comp_id,
- String comp_name, String task_id, String user_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_EQUIPMENT(FD_OBJECTID, UPDATEDATE, IS_DEL, INPUT_OPER_NAME, INPUT_OPER_ID, "
- + "INPUT_UNIT_NAME, INPUT_UNIT_ID, TASK_FDID, TASK_NUMBER, EQ_NAME, EQ_NUMBER, EQ_CLASSIFICATION, EQ_LEVEL,"
- + " EQ_VOLTAGE_LEVEL, XUNSHI, BTDJCJPJ, TDSYJPJ, GPS_START_DATE, GPS_END_DATE, GPS_CONTINUED_TIME) "
- + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- List<Map<String, String>> list = JsonPluginsUtil.jsonToMapList(json);
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for (Map<String, String> map : list) {
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(618);
- st.setString(1, fd_id);
- st.setString(2, time);
- st.setString(3, "0");
- st.setString(4, real_name);
- st.setString(5, user_id);
- st.setString(6, comp_name);
- st.setString(7, comp_id);
- st.setString(8, task_id);
- st.setString(9, map.get("TASK_NUMBER_618"));
- st.setString(10, map.get("EQ_NAME_618"));
- st.setString(11, map.get("EQ_NUMBER_618"));
- st.setString(12, map.get("EQ_CLASSIFICATION_618"));
- st.setString(13, map.get("EQ_LEVEL_618"));
- st.setString(14, map.get("EQ_VOLTAGE_LEVEL_618"));
- st.setString(15, map.get("XUNSHI_618"));
- st.setString(16, map.get("BTDJCJPJ_618"));
- st.setString(17, map.get("TDSYJPJ_618"));
- st.setString(18, map.get("GPS_START_DATE_618"));
- st.setString(19, map.get("GPS_END_DATE_618"));
- st.setString(20, map.get("GPS_CONTINUED_TIME_618"));
- st.executeUpdate();
- log.info(sql);
- num++;
- }
- if(num==list.size()){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
- public boolean saveUser(GPSUserMsg detail) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update ECM_GPS_USER "
- +" set USER_ID = ?, USER_NAME = ?, USER_ADDRESS = ?, POWER_SUPPLY_UNIT_NAME = ?, "
- + "IMPORTANT_USER_LEVEL = ?, ELECTROR_TYPE = ?, VOLTAGE_LEVEL = ?, UPDATEDATE = ? , ENXTEND = ? "
- + " where FD_OBJECTID = ?";
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, detail.getUSER_ID());
- pstm.setString(2, detail.getUSER_NAME());
- pstm.setString(3, detail.getUSER_ADDRESS());
- pstm.setString(4, detail.getPOWER_SUPPLY_UNIT_NAME());
- pstm.setString(5, detail.getIMPORTANT_USER_LEVEL());
- pstm.setString(6, detail.getELECTROR_TYPE());
- pstm.setString(7, detail.getVOLTAGE_LEVEL());
- pstm.setString(8, detail.getUPDATEDATE());
- pstm.setString(9, detail.getENXTEND());
- pstm.setString(10, detail.getFD_OBJECTID());
- pstm.executeUpdate();
- 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 Msg saveBaoBiao1(GPSBaoBiao detail, String real_name, String comp_id, String task_id) throws ClassNotFoundException {
- Msg m=new Msg();
- String sql="insert into ECM_GPS_JOURNALING ( FD_OBJECTID, INPUT_NAME, INPUT_TIME, INPUT_DEPT, MAN_COUNT,"
- + " CAR_COUNT, IS_DEL, UPDATEDATE, FD_TASK, FD_TASK_NAME, BGD_FDC, BGD_FDJ, BGD_RW_TIME, BGD_DW ,"
- + "BGD_LEVEL,XINGHAO,RONGLIANG,CHANJIA,QTZHUNGBEI)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- String sql1 = "select PROGRAM_NAME,TO_CHAR(UPDATEDATE,'yyyy-mm-dd hh24:mi:ss'),GPS_LEVEL from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID='"+task_id+"'";
- log.info("queryTask_sql:"+sql1);
- List<String[]> tempList = persistence.getSearchResult(610, sql1.toString());
- String taskName = "";
- String taskTime = "";
- String taskLevel = "";
- if(tempList!=null && tempList.size()>0){
- String[] arr = tempList.get(0);
- taskName = arr[0];
- taskTime = arr[1];
- taskLevel = arr[2];
- }
- if("0".equals(taskLevel)){
- taskLevel = "特级";
- }else if("1".equals(taskLevel)){
- taskLevel = "一级";
- }else if("2".equals(taskLevel)){
- taskLevel = "二级";
- }else if("3".equals(taskLevel)){
- taskLevel = "三级";
- }
- conn = db.getConnection();
- int num=0;
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- //系统当前时间
- Date date=new Date();
- String time=format.format(date);
-
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(613);
- st.setString(1, fd_id);
- st.setString(2, real_name);
- st.setString(3, time);
- st.setString(4, comp_id);
- st.setString(5, detail.getMAN_COUNT());
- st.setString(6, detail.getCAR_COUNT());
- st.setString(7, "0");
- st.setString(8, time);
- st.setString(9, task_id);
- st.setString(10, taskName);
- st.setString(11, detail.getBGD_FDC());
- st.setString(12, detail.getBGD_FDJ());
- st.setString(13, taskTime);
- st.setString(14, detail.getBGD_DW());
- st.setString(15, taskLevel);
- st.setString(16, detail.getXINGHAO());
- st.setString(17, detail.getRONGLIANG());
- st.setString(18, detail.getCHANJIA());
- st.setString(19, detail.getQTZHUAGNBEI());
- st.executeUpdate();
- log.info(sql);
- num++;
- if(num==1){
- log.info("保存成功");
- conn.commit();
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- // st.executeBatch();
- conn.rollback();
- log.info("保存失败");
- return m;
- }
- } catch (Exception e) {
- this.log.error(e.getMessage(), e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
- public boolean saveJournaling(GPSBaoBiao detail) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "";
- try {
- if("undefined".equals(detail.getFD_OBJECTID())){
- saveBaoBiao1(detail,detail.getINPUT_NAME(),detail.getINPUT_DEPT(),detail.getFD_TASK());
- flag = true;
- }else{
- detailSQL = "update ECM_GPS_JOURNALING "
- +" set INPUT_DEPT = ?, MAN_COUNT = ?, CAR_COUNT = ?, INPUT_NAME = ?, "
- + "INPUT_TIME = ?, UPDATEDATE = ?, XINGHAO = ? , RONGLIANG = ? , CHANJIA = ? , QTZHUNGBEI = ?,BGD_FDC = ?,"
- + "BGD_FDJ = ? where FD_OBJECTID = ?";
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, detail.getINPUT_DEPT());
- pstm.setString(2, detail.getMAN_COUNT());
- pstm.setString(3, detail.getCAR_COUNT());
- pstm.setString(4, detail.getINPUT_NAME());
- pstm.setString(5, detail.getINPUT_TIME());
- pstm.setString(6, detail.getUPDATEDATE());
- pstm.setString(7, detail.getXINGHAO());
- pstm.setString(8, detail.getRONGLIANG());
- pstm.setString(9, detail.getCHANJIA());
- pstm.setString(10, detail.getQTZHUAGNBEI());
- pstm.setString(11, detail.getBGD_FDC());
- pstm.setString(12, detail.getBGD_FDJ());
- pstm.setString(13, detail.getFD_OBJECTID());
-
- int n = 0;
- n = pstm.executeUpdate();
- 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 boolean saveDuty(GPSDutyMsg detail) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String insertSql = "insert into ECM_GPS_DUTY(FD_OBJECTID, IS_DEL, UPDATEDATE, TASK_ID, START_TIME, END_TIME, LEADER, "
- + "LEADER_TEL, WATCH_MAN, WATCH_TEL, DUTY_MODE, TIANBAO_TIME, DEPT, TIANBAO_PERSON, FLOW_ID, "
- + "INPUT_NAME_ID, LEADER_DUTY_MODE) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
- int num = 0 ;
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(insertSql);
- String fd_id=IdentityGenerator.getIdentityGenerator().gerenalIdentity(632);
- pstm.setString(1, fd_id);
- pstm.setString(2, "0");
- pstm.setString(3, detail.getUPDATEDATE_632());
- pstm.setString(4, detail.getTASK_ID());
- pstm.setString(5, detail.getSTART_TIME_632());
- pstm.setString(6, detail.getEND_TIME_632());
- pstm.setString(7, detail.getLEADER_632());
- pstm.setString(8, detail.getLEADER_TEL_632());
- pstm.setString(9, detail.getWATCH_MAN_632());
- pstm.setString(10, detail.getWATCH_TEL_632());
- pstm.setString(11, detail.getDUTY_MODE_632());
- pstm.setString(12, detail.getUPDATEDATE_632());
- pstm.setString(13, detail.getDEPT());
- pstm.setString(14, detail.getTIANBAO_PERSON());
- pstm.setString(15, "0");
- pstm.setString(16, detail.getINPUT_NAME_ID_632());
- pstm.setString(17, detail.getLEADER_DUTY_MODE_632());
- num = pstm.executeUpdate();
- conn.commit();
- flag = true;
- }catch(Exception e){
- try {
- conn.rollback();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
-
-
- }
- public boolean updateDuty(GPSDutyMsg detail) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update ECM_GPS_DUTY "
- +" set START_TIME = ?, END_TIME = ?, LEADER = ?, LEADER_TEL = ?, LEADER_DUTY_MODE=?, "
- + "WATCH_MAN = ?, WATCH_TEL = ?,DUTY_MODE = ?,UPDATEDATE = ? "
- + " where FD_OBJECTID = ?";
- int num = 0 ;
- try {
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, detail.getSTART_TIME_632());
- pstm.setString(2, detail.getEND_TIME_632());
- pstm.setString(3, detail.getLEADER_632());
- pstm.setString(4, detail.getLEADER_TEL_632());
- pstm.setString(5, detail.getLEADER_DUTY_MODE_632());
- pstm.setString(6, detail.getWATCH_MAN_632());
- pstm.setString(7, detail.getWATCH_TEL_632());
- pstm.setString(8, detail.getDUTY_MODE_632());
- pstm.setString(9, detail.getUPDATEDATE_632());
- pstm.setString(10, detail.getFD_OBJECTID());
- num = pstm.executeUpdate();
- conn.commit();
- flag = true;
- }catch(Exception e){
- try {
- conn.rollback();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return flag;
-
-
- }
- /**
- * 返回部门节点json字符串
- *
- * @param unitCode
- * @return
- */
- public List<Detp> getDeptChlidrenString(String unitCode) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<Detp> deptList = new ArrayList<Detp>();
- StringBuffer sql = new StringBuffer();
- sql.append("-- 查询组织机构子节点 \n");
- sql.append(" select DEPT_ID,DEPT_NAME,FD_OBJECTID \n");
- sql.append(" from Sys_Department where DEPT_TYPE='1' and (FD_OBJECTID='" + unitCode + "' or parent_id='" + unitCode + "') \n");
- sql.append(" ORDER BY SORT asc \n");
- // log.info("=="+sql);
- try {
- ArrayList<String[]> listDept = persistence.getSearchResult(99, sql.toString());
- int num = listDept.size();
- for (int i = 0; i < num; i++) {
- String[] temp = listDept.get(i);
- String deptId = temp[0];
- String deptName = temp[1];
- if(unitCode.equals(deptId)){
- deptList.add(0, new Detp(deptId, deptName));
- }else{
- deptList.add(new Detp(deptId, deptName));
- }
- // String objectId = temp[2];
- // json.append("{ ");
- // json.append(" id:'" + deptId + "', parentId:'" + unitCode + "',");
- // json.append(" classId:'800',objectId:'" + objectId + "',");
- // json.append(" name:'" + deptName + "',");
- // json.append(" type:'unit',menuType:'nonLeafMenu',");
- // json.append(" icon:'/nwyj/scripts/qui/libs/icons/user_group.gif'");
- // json.append("}, ");
- }
- } catch (PersistenceException e) {
- log.error("查询子单位id错误", e);
- }
- return deptList;
- }
- /**
- * 根据查询条件an查询任务
- * @param string
- * @return
- */
- public List<GPSTask> queryTask(String condition) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<GPSTask> tasks = new ArrayList<GPSTask>();
- StringBuffer sql = new StringBuffer();
- sql.append("--根据查询条件an查询任务 \n");
- sql.append(" select START_TIME,END_TIME,PROGRAM_NAME,GPS_LEVEL,GPS_AREA_ID,INPUT_UNIT_ID ");
- sql.append(" from ECM_GPS_PROGRAM_MANAGEMENT where IS_DEL=0 and PROGRAM_STATE=1 " + condition + " \n");
- log.info("=="+sql);
- try {
- ArrayList<String[]> list = persistence.getSearchResult(610, sql.toString());
- int num = list.size();
- for (int i = 0; i < num; i++) {
- String[] temp = list.get(i);
- String START_TIME = temp[0];
- String END_TIME = temp[1];
- String PROGRAM_NAME = temp[2];
- String GPS_LEVEL = temp[3];
- String GPS_AREA_ID = temp[4];
- String INPUT_UNIT_ID = temp[5];
-
- tasks.add(new GPSTask(START_TIME, END_TIME, PROGRAM_NAME, GPS_LEVEL, GPS_AREA_ID, INPUT_UNIT_ID));
- }
- } catch (PersistenceException e) {
- log.error("查询任务错误", e);
- }
- return tasks;
- }
- public String getdeptTreeById(String areaId, StringBuffer areaIdsArr, String unitId) {
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- StringBuffer sql = new StringBuffer();
- StringBuffer json = new StringBuffer();
- String[] areaIdArr = areaId.split(",");
- json.append("{\"treeNodes\":[");
- boolean isarea = false;
- for (int i = 0; i < areaIdArr.length; i++) {
- if(areaIdArr[i].equals(unitId)){
- isarea = true;
- }
-
- }
- sql.append("--查询给定id一级子机构的信息(不包括他本身) \n");
- //sql.append("SELECT A.ORG_ID,A.ORG_NAME,A.PARENT_ORG_ID, \n");
- //sql.append("DECODE((SELECT COUNT(1) FROM SYS_DEPARTMENT_1111 B WHERE B.PARENT_ORG_ID = A.ORG_ID),'0','0','1') AS 是否有子机构, \n");
- //sql.append("DECODE((SELECT COUNT(1) FROM EMC_4A_USER C WHERE C.PARENT_ORG_ID = A.ORG_ID),'0','0','1') AS 是否有员工 , \n");
- //sql.append("A.ORG_LEVEL ");
- sql.append("SELECT A.DEPT_ID,A.DEPT_NAME,A.PARENT_ID, \n");
- sql.append("DECODE((SELECT COUNT(1) FROM SYS_DEPARTMENT B WHERE B.PARENT_ID = A.DEPT_ID),'0','0','1') AS 是否有子机构, \n");
- sql.append("A.DEPT_LEVEL ");
- if(unitId !="" && isarea){
- //sql.append("FROM SYS_DEPARTMENT_1111 A WHERE (PARENT_ORG_ID = '" + unitId + "' or ORG_ID in "+areaIdsArr+") \n");
- sql.append("FROM SYS_DEPARTMENT A WHERE (PARENT_ID = '" + unitId + "' or DEPT_ID in "+areaIdsArr+") \n");
-
- }else{
- //sql.append("FROM SYS_DEPARTMENT_1111 A WHERE ORG_ID in "+areaIdsArr+" \n");
- sql.append("FROM SYS_DEPARTMENT A WHERE DEPT_ID in "+areaIdsArr+" \n");
- }
-
- try {
- ArrayList<String[]> listRoot = persistence.getSearchResult(99, sql.toString());
- // 显示人员
- //json.append(getPersonById(id));
- int listLen = listRoot.size();
-
- for (int i = 0; i < listLen; i++) {
- String[] temp = listRoot.get(i);
- String orgId = temp[0];
- String orgName = temp[1];
- String parentOrgId = temp[2];
- boolean isHasChildOrg = !("0".equals(temp[3]));
- String orgLevel = temp[4];
- json.append("{");
- json.append(" \"id\":\"" + orgId + "\", \"parentId\":\"" + parentOrgId
- + "\", \"name\": \"" + orgName + "\",\"orgLevel\":\"" + orgLevel + "\"");
- json.append(",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.gif\"");
- if (isHasChildOrg) {
- json.append(",\"open\": \"true\"");
- } else {
- json.append(",\"isParent\": \"fasle\" ");
- }
- if(!parentOrgId.equals(unitId)){
- json.append(",\"chkDisabled\": \"true\"");
- }else{
- json.append(",\"chkDisabled\": \"false\"");
- }
- boolean flag = false;
- for (int j = 0; j < areaIdArr.length;j++) {
- if(orgId.equals(areaIdArr[j])){
- flag = true;
- }
- }
- if(flag){
- json.append(",\"checked\": \"true\"");
- }else{
- json.append(",\"checked\": \"false\"");
- }
- json.append("},");
-
- }
- if (json.lastIndexOf(",") > -1) {
- json.deleteCharAt(json.lastIndexOf(","));
- };
- json.append("]}");
- Log.info(json.toString());
- } catch (PersistenceException e) {
- e.printStackTrace();
- }
- return json.toString();
- }
- public String getAreaId(String fd_id) throws ClassNotFoundException {
- String sql="select GPS_AREA_ID from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID ='"+fd_id+"'";
- Connection conn = null;
- PreparedStatement st = null;
- DbConnection db = new DbConnection();
- ResultSet rs = null;
- String areaId = "";
- try {
- conn = db.getConnection();
- st = conn.prepareStatement(sql);
- rs = st.executeQuery();
- rs.next();
- areaId = rs.getString("GPS_AREA_ID");
- return areaId;
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- } finally {
- if(rs!=null){
- try {
- rs.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- db.close(st);
- db.close(conn);
- }
- return areaId;
- }
- public String quiTaskDutyByType(String type, String dept, String task_id) {
- StringBuffer result = new StringBuffer();
- result.append("{\"rows\":");
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<GPSTask> tasks = new ArrayList<GPSTask>();
- StringBuffer sql = new StringBuffer();
- SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
- Calendar caldate = Calendar.getInstance();
- if("1".equals(type)){
- sql.append("select FD_OBJECTID FD_OBJECTID632,UPDATEDATE UPDATEDATE_632, SUBSTR(START_TIME, 0,16) START_TIME_632, SUBSTR(END_TIME, 0,16) END_TIME_632,LEADER LEADER_632,LEADER_TEL LEADER_TEL_632,WATCH_MAN WATCH_MAN_632,WATCH_TEL WATCH_TEL_632,DUTY_MODE DUTY_MODE_632,TIANBAO_TIME TIANBAO_TIME_632,DEPT DEPT_632,TIANBAO_PERSON TIANBAO_PERSON_632,INPUT_NAME_ID INPUT_NAME_ID_632,LEADER_DUTY_MODE LEADER_DUTY_MODE_632 from ECM_GPS_DUTY where TASK_ID='"+task_id+"' and DEPT='"+dept+"' and is_del=0 and (START_TIME is not null or END_TIME is not null or START_TIME <> '' or END_TIME <> '') and regexp_like(END_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') order by LEADER");
- }else if("2".equals(type)){
- sql.append("select b.dept_name DEPTNAME, a.FD_OBJECTID FD_OBJECTID632 , a.UPDATEDATE UPDATEDATE_632, SUBSTR(a.START_TIME, 0,16) START_TIME_632, SUBSTR(a.END_TIME, 0,16) END_TIME_632, a.LEADER LEADER_632, a.LEADER_TEL LEADER_TEL_632, a.WATCH_MAN WATCH_MAN_632, a.WATCH_TEL WATCH_TEL_632, a.DUTY_MODE DUTY_MODE_632, a.TIANBAO_TIME TIANBAO_TIME_632, a.DEPT DEPT_632, a.TIANBAO_PERSON TIANBAO_PERSON_632, a.INPUT_NAME_ID INPUT_NAME_ID_632, a.LEADER_DUTY_MODE LEADER_DUTY_MODE_632 from sys_department b left join ECM_GPS_DUTY a on a.dept=b.dept_id where TASK_ID='"+task_id+"' and a.is_del=0 and (START_TIME is not null or END_TIME is not null or START_TIME <> '' or END_TIME <> '') and regexp_like(START_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') and regexp_like(START_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') and regexp_like(END_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') order by LEADER");
- }else if("3".equals(type)){
- sql.append("select b.dept_name deptname, a.FD_OBJECTID FD_OBJECTID632 , a.UPDATEDATE UPDATEDATE_632,SUBSTR(a.START_TIME, 0,16) groupdate, SUBSTR(a.START_TIME, 0,16) START_TIME_632, SUBSTR(a.END_TIME, 0,16) END_TIME_632, a.LEADER LEADER_632, a.LEADER_TEL LEADER_TEL_632, a.WATCH_MAN WATCH_MAN_632, a.WATCH_TEL WATCH_TEL_632, a.DUTY_MODE DUTY_MODE_632, a.TIANBAO_TIME TIANBAO_TIME_632, a.DEPT DEPT_632, a.TIANBAO_PERSON TIANBAO_PERSON_632, a.INPUT_NAME_ID INPUT_NAME_ID_632, a.LEADER_DUTY_MODE LEADER_DUTY_MODE_632 from sys_department b left join ECM_GPS_DUTY a on a.dept=b.dept_id where TASK_ID='"+task_id+"' and a.is_del=0 and (START_TIME is not null or END_TIME is not null or START_TIME <> '' or END_TIME <> '') and regexp_like(START_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') and regexp_like(END_TIME,'\\d{4}-{1}\\d{2}-{1}\\d{2} \\d{2}:{1}\\d{2}+') order by LEADER,groupdate ");
- }
- log.info("=="+sql);
- try {
- ArrayList<Map<String,String>> tempList = new ArrayList<Map<String,String>>();
- ArrayList<Map<String,String>> list = persistence.getSearchResultToMap(632, sql.toString());
- int num = list.size();
- if("1".equals(type)){
- tempList = list;
- }else if("2".equals(type)){
- tempList = list;
- }else if("3".equals(type)){
- for (int i = 0; i < list.size(); i++) {
- Map<String, String> map = list.get(i);
- tempList.add(map);
- String grouptdate = map.get("GROUPDATE");
- String startime = map.get("START_TIME_632");
- String endtime = map.get("END_TIME_632");
- if("".equals(startime) || "".equals(endtime)
- || startime==null || endtime==null
- || "".equals(startime.trim()) || "".equals(endtime.trim())){
- continue;
- }
- startime = startime.split(" ")[0];
- endtime = endtime.split(" ")[0];
-
- Date stime = dateformat.parse(startime);
- Date etime = dateformat.parse(endtime);
- Date gtime = dateformat.parse(grouptdate);
- if(etime.after(stime)){
- caldate.setTime(gtime);
- caldate.add(Calendar.DAY_OF_MONTH, 1);
- while(!caldate.getTime().after(etime)){
- Map<String, String> map1 = new HashMap<String, String>();
- map1.putAll(map);
- //String aa = dateformat.format(caldate.getTime());
- //boolean bb = caldate.getTime().after(etime);
- map1.put("GROUPDATE", dateformat.format(caldate.getTime()));
- tempList.add(map1);
- caldate.add(Calendar.DAY_OF_MONTH, 1);
- }
- }
- }
- }
- result.append(JSONArray.fromObject(tempList).toString());
- result.append("}");
- } catch (PersistenceException e) {
- log.error("查询任务错误", e);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return result.toString();
- }
- public List<Map<String, String>> getDeptMsgByTaskId(String taskId) {
- String sql = "select FD_OBJECTID,PROGRAM_NAME,GPS_LEVEL,GPS_AREA_NAME,IMPLEMENT_TIME,PROGRAM_STATE,INPUT_UNIT_ID,INPUT_TIME,INPUT_NAME,START_TIME,END_TIME,COMMENT_TEXT,TASK_STATE,UPDATEDATE,IS_DEL,GPS_AREA_ID,INPUT_UNIT_NAME,GPS_AREA_CITY,HAS_DUTY,GPS_YEAR,GPS_AREA_ID_FU,ISSUE_DEPT,INPUT_NAME_ID,ISSUE_TIME,PARENT_DEPT_ID,GPS_AREA_CITY_ID from ECM_GPS_PROGRAM_MANAGEMENT where FD_OBJECTID='"+taskId+"'";
- try {
- List<Map<String, String>> list = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResultToMap(610, sql);
- return list;
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
-
- }
- public boolean saveUser1(String[] strs) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update NWYJ.ECM_GPS_USER1 set KHBH = ?, KHMC = ?, TASK_ID = ?, INPUT_UNIT = ?, "
- + "INPUT_USER = ?, INPUT_TIME = ?, UPDATEDATE = ?, IS_DEL = ?, KHLB = ?, GDDW = ?, ZYDJ = ?, DYDJ = ?, ZJRL = ?,"
- + " BAFH = ?, GDXL1 = ?, SJBDZ1 = ?, GDXL2 =?, SJBDZ2 = ?, GDXL3 = ?, SJBDZ3 = ?, GDXL4 = ?, SJBDZ4 = ?, "
- + "GDDYSFMZBZ = ?, ZBYJDYRL = ?, ZBYJDYPB = ?, ZBYJDYSFMZBZ = ?, BEIZHU = ? where FD_OBJECTID = ?";
- try {
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date=new Date();
- String time=format.format(date);
-
- conn = dbConn.getConnection();
- conn.setAutoCommit(false);
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(28, getDataByParam(strs[21]));
- pstm.setString(1, getDataByParam(strs[0]));
- pstm.setString(2, getDataByParam(strs[1]));
- pstm.setString(3, getDataByParam(strs[24]));
- pstm.setString(4, getDataByParam(strs[22]));
- pstm.setString(5, getDataByParam(strs[23]));
- pstm.setString(6, time);
- pstm.setString(7, time);
- pstm.setString(8, "0");
- pstm.setString(9, getDataByParam(strs[2]));
- pstm.setString(10, getDataByParam(strs[3]));
- pstm.setString(11, getDataByParam(strs[4]));
- pstm.setString(12, getDataByParam(strs[5]));
- pstm.setString(13, getDataByParam(strs[6]));
- pstm.setString(14, getDataByParam(strs[7]));
- pstm.setString(15, getDataByParam(strs[8]));
- pstm.setString(16, getDataByParam(strs[9]));
- pstm.setString(17, getDataByParam(strs[10]));
- pstm.setString(18, getDataByParam(strs[11]));
- pstm.setString(19, getDataByParam(strs[12]));
- pstm.setString(20, getDataByParam(strs[13]));
- pstm.setString(21, getDataByParam(strs[14]));
- pstm.setString(22, getDataByParam(strs[15]));
- pstm.setString(23, getDataByParam(strs[16]));
- pstm.setString(24, getDataByParam(strs[17]));
- pstm.setString(25, getDataByParam(strs[18]));
- pstm.setString(26, getDataByParam(strs[19]));
- pstm.setString(27, getDataByParam(strs[20]));
- pstm.executeUpdate();
- 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;
-
- }
- private String getDataByParam(String param) {
- String data = "";
- if(param!=null && !"".equals(param) && param.contains("=")){
- String[] arr = param.split("=");
- if(arr.length==2){
- data = param.split("=")[1];
- }
- }
- return data;
- }
- /**
- * 表格编辑后保存
- * @param strs
- */
- public boolean saveGpsPlace1(String[] strs) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update ECM_GPS_PLACE set UPDATEDATE = ?, PLACE_NAME = ?,"
- + " PLACE_CLASSIFICATION = ?, PLACE_LEVEL = ?, PLACE_VOLTAGE_LEVEL = ?,"
- + " QXJHTD = ?,KZYDJC = ?, XZYHCSSY = ?, YJDYZBZY = ?, CYCGXCZS = ?, FDCDR = ?, FDJDR = ? ,PLACE_NUMBER = ? where FD_OBJECTID = ?";
- try {
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date=new Date();
- String time=format.format(date);
-
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, time);
- pstm.setString(2, getDataByParam(strs[0]));
- pstm.setString(3, getDataByParam(strs[1]));
- pstm.setString(4, getDataByParam(strs[2]));
- pstm.setString(5, getDataByParam(strs[3]));
- pstm.setString(6, getDataByParam(strs[4]));
- pstm.setString(7, getDataByParam(strs[5]));
- pstm.setString(8, getDataByParam(strs[6]));
- pstm.setString(9, getDataByParam(strs[7]));
- pstm.setString(10, getDataByParam(strs[8]));
- pstm.setString(11, getDataByParam(strs[9]));
- pstm.setString(12, getDataByParam(strs[10]));
- pstm.setString(13, getDataByParam(strs[15]));
- pstm.setString(14, getDataByParam(strs[11]));
- pstm.executeUpdate();
- flag = true;
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return flag;
-
- }
- public boolean saveGpsEquipment1(String[] strs) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update ECM_GPS_EQUIPMENT set UPDATEDATE = ?, EQ_NAME = ?,"
- + " EQ_CLASSIFICATION = ?, EQ_LEVEL = ?, EQ_VOLTAGE_LEVEL = ?,"
- + " XUNSHI = ?,BTDJCJPJ = ?, TDSYJPJ = ?,EQ_NUMBER = ? where FD_OBJECTID = ?";
- try {
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date=new Date();
- String time=format.format(date);
-
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, time);
- pstm.setString(2, getDataByParam(strs[0]));
- pstm.setString(3, getDataByParam(strs[1]));
- pstm.setString(4, getDataByParam(strs[2]));
- pstm.setString(5, getDataByParam(strs[3]));
- pstm.setString(6, getDataByParam(strs[4]));
- pstm.setString(7, getDataByParam(strs[5]));
- pstm.setString(8, getDataByParam(strs[6]));
- pstm.setString(9, getDataByParam(strs[11]));
- pstm.setString(10, getDataByParam(strs[7]));
- pstm.executeUpdate();
- flag = true;
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch ( Exception e) {
- e.printStackTrace();
- }
- }
- return flag;
-
- }
- public boolean saveZiYuanBaoBiao(String[] strs) {
- boolean flag = false;
- DbConnection dbConn = new DbConnection();
-
- Connection conn = null;
- PreparedStatement pstm = null;
- String detailSQL = "update NWYJ.ECM_GPS_ZIYUANBAOBIAO set UPDATEDATE = ?, GPS_TASK_FDC_DAY = ?, "
- + "GPS_TASK__FDC_TOTAL = ?, GPS_TASK_FDJ_DAY = ?, GPS_TASK_FDJ_TOTAL = ?, GPS_TASK_CAR = ?, "
- + "GPS_TASK_ZBZHGLRY = ?, GPS_TASK_BDWBZRY = ?, GPS_TASK_ABRY = ?, GPS_TASK_WWSCRY = ? "
- + "where FD_OBJECTID = ?";
- try {
- DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date=new Date();
- String time=format.format(date);
-
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(detailSQL);
- pstm.setString(1, time);
- pstm.setString(2, getDataByParam(strs[0]));
- pstm.setString(3, getDataByParam(strs[1]));
- pstm.setString(4, getDataByParam(strs[2]));
- pstm.setString(5, getDataByParam(strs[3]));
- pstm.setString(6, getDataByParam(strs[4]));
- pstm.setString(7, getDataByParam(strs[5]));
- pstm.setString(8, getDataByParam(strs[6]));
- pstm.setString(9, getDataByParam(strs[7]));
- pstm.setString(10, getDataByParam(strs[8]));
- pstm.setString(11, getDataByParam(strs[9]));
- pstm.executeUpdate();
- flag = true;
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- pstm.close();
- conn.close();
- } catch ( Exception e) {
- e.printStackTrace();
- }
- }
- return flag;
-
- }
- public String queryTaskUserByTaskId(String taskId) throws SQLException {
- String sql = "select OBJECT_ID , PLAND_ID , CUSTOMER_ID , CUSTOMER_NAME , CUSTOMER_TYPE , POWER_SUPPLY_UNIT , b.dept_name POWER_SUPPLY_UNIT_NAME, (case IMPORT_LEVEL when '0' then '特级' when '1' then '一级' when '2' then '二级' when '3' then '三级' end) IMPORT_LEVEL,C.FD_DESCRIPTION VOLTAGE_LEVEL_SHOW, VOLTAGE_LEVEL , INSTALLED_CAPA_CITY , SECURITY_LOAD , (case ISMEET_OF_SUPPLY when '0' then '满足' when '1' then '不满足' end) ISMEET_OF_SUPPLY , (case IS_MEET_OF_SELF_POVIDE when '0' then '满足' when '1' then '不满足' end) IS_MEET_OF_SELF_POVIDE , RE_MARK , UP_DATE , POWER_SUPPLY , SELF_PROVIDE from NWYJ_SERVICE.MK_POWER_SUPPLY_USER_DATA a,nwyj.sys_department b,bm_mapvaluecanst c where a.POWER_SUPPLY_UNIT = b.base_org_id and to_number(a.VOLTAGE_LEVEL)=to_number(c.fd_code) and c.fd_type='BM_NWYJ_SERVICE_VOLTAGE_GPS' and a.PLAND_ID=?";
- List<Map<String, String>> list = new ArrayList<Map<String,String>>();
- list = new ORGTemplate().query(sql, taskId);
- if(list!=null && list.size()==0){
- Map<String, String> map = new HashMap<String, String>();
- map.put("aa", "");
- list.add(map);
- }
- return "{\"rows\":"+JSONArray.fromObject(list).toString()+"}";
- }
- public String getDeptLevelById(String unitId) throws SQLException {
- String sql = "select dept_level from sys_department where dept_id=? and is_del='0' ";
- List<Map<String, String>> list = new ArrayList<Map<String,String>>();
- list = new ORGTemplate().query(sql, unitId);
- String dept_level = "";
- if(list!=null && list.size()>0){
- dept_level = list.get(0).get("DEPT_LEVEL");
- }
- return dept_level;
- }
- public String getFenZiUnit() throws SQLException {
- String sql = "select DEPT_ID value,DEPT_NAME key from sys_department where DEPT_LEVEL=2 AND DEPT_LEVEL IS NOT NULL and is_del='0' ";
- List<Map<String, String>> list = new ArrayList<Map<String,String>>();
- list = new ORGTemplate().query(sql);
- if(list!=null && list.size()>0){
- return "{\"list\":"+JSONArray.fromObject(list).toString()+"}";
- }else{
- return "{\"list\":[]}";
- }
- }
-
- }
|