| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741 |
- package com.saga.util;
- import java.io.File;
- import java.io.UnsupportedEncodingException;
- import java.sql.Connection;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Map;
- import java.util.Map.Entry;
- import java.util.Set;
- import org.zillion.util.log.LogUtil;
- import com.saga.entity.Data;
- import com.saga.entity.EntityHbase;
- import com.saga.entity.EntityMysql;
- import com.saga.entity.PointSet;
- import com.saga.entity.Record;
- import com.saga.entity.RecordMsg;
- import com.saga.entity.Server;
- import com.saga.entity.Transfer;
- import com.zillion.database.agent.ZillionAgent;
- public class Constant {
- public static int PacketId = 0;
- public static int InsertThread = 1;
- public static ZillionAgent agent;
- public static Connection conn;
- public static ZillionAgent agentUpload;
- public static Connection connUpload;
- // public static List<ZillionAgent> agents = new ArrayList<ZillionAgent>();
- // public static boolean DBConn = true;
- public static String WaitingTimeControl = "5Second";
- public static long Disconnect = Constant.Millisecond.MINUTE_15;
- public static Map<String, Object> DbConnection = new HashMap<String, Object>();
- public static File setlog = new File(System.getProperty("user.dir") + "/setlog.log");
- public static List<String> CollectReportList = new ArrayList<String>();
- public static List<String> TransferReportList = new ArrayList<String>();
- public static List<Record> RecordListToDB = new ArrayList<Record>();
- public static Map<String, String> Meter_Collector = new HashMap<String, String>();
- public static Map<String, String> Meter_Collector_Control = new HashMap<String, String>();
- public static List<PointSet> pointSetList = new ArrayList<PointSet>();
- // public static Map<String, String> CollectorPointSetList = new
- // HashMap<String, String>();
- // public static Map<String, String> BuildingDB = new HashMap<String,
- // String>();
- public static Map<String, Boolean> BuildingOffset = new HashMap<String, Boolean>();
- public static String Database;
- // public static String UploadSource = null;
- // public static List<String> uploadList = new ArrayList<String>();
- public static Map<String, String> BuildingConv = new HashMap<String, String>();
- public static Map<String, List<String>> BuildingAdds = new HashMap<String, List<String>>();
- public static Map<String, String> FunctionConv = new HashMap<String, String>();
- public static Map<String, String> FunctionConvReverse = new HashMap<String, String>();
- // public static Map<String, String> TypePort = new HashMap<String,
- // String>();
- // public static Map<Integer, String> PortCompress = new HashMap<Integer,
- // String>();
- // public static Map<Integer, String> PortHistory = new HashMap<Integer,
- // String>();
- public static Map<String, Server> TypeServer = new HashMap<String, Server>();
- public static Transfer transfer = new Transfer();
- public static Map<String, Integer> RecordAddress = new HashMap<String, Integer>();
- public static List<Record> RecordList = new ArrayList<Record>();
- public static Map<String, Long> PresentFlag = new HashMap<String, Long>();
- // public static Map<String, Long> ps_NodeStatus = new HashMap<String,
- // Long>();
- public static Map<String, Long> ps_PointStatusUp = new HashMap<String, Long>();
- public static Map<String, Long> ps_PhysicalStatus = new HashMap<String, Long>();
- public static Map<String, Long> ps_ProjectStatus = new HashMap<String, Long>();
- public static Map<String, Long> ps_MeterStatusUp = new HashMap<String, Long>();
- public static Map<String, Long> ps_PointStatusDown = new HashMap<String, Long>();
- public static Map<String, Long> ps_MeterStatusDown = new HashMap<String, Long>();
- public static Map<String, List<String>> ps_PhysicalList = new HashMap<String, List<String>>();
- public static Map<String, List<String>> ps_ProjectList = new HashMap<String, List<String>>();
- public static Map<String, List<String>> ps_MeterList = new HashMap<String, List<String>>();
- public static Map<String, String> pointInfo = new HashMap<String, String>();
- public static Map<String, Data> nodeCache = new HashMap<String, Data>();
- public static Map<String, Data> pointCache = new HashMap<String, Data>();
- // public static Map<String, Long> pointListDown = new HashMap<String,
- // Long>();
- public static Map<String, Long> ps_ID2Time = new HashMap<String, Long>();
- public static Map<String, String> ps_ID2Point = new HashMap<String, String>();
- public static Map<String, String> ps_ID2Function = new HashMap<String, String>();
- public static Map<String, String> ps_ID2Status = new HashMap<String, String>();
- public static int collectRec = 0;
- public static int collectSend = 0;
- public static int sendRec = 0;
- public static int sendSend = 0;
- public static int writeDB = 0;
- public static int collectCount = 0;
- public static int transferSendCount = 0;
- public static int transferRecCount = 0;
- public static int collectReportCount = 0;
- public static int report2DBCount = 0;
- public static Map<String, String> pointMAC = new HashMap<String, String>();
- public static Map<String, String> black_Buildings = new HashMap<String, String>();
- public static Map<String, String> whilte_Points = new HashMap<String, String>();
- public static Map<String, String> transfer_List = new HashMap<String, String>();
- public static Map<String, Integer> pSeq = new HashMap<String, Integer>();
- public static Map<String, Integer> pMonth = new HashMap<String, Integer>();
- public static Set<String> saveTypeList = new HashSet<String>();
- public static long delay = Constant.Millisecond.SECOND_1;
- public static String activeMqBrokerUrl;
- public static String queueName;
- public static Set<String> activeMqPointSet = new HashSet<>();
- // static {
- // String resource = "\\config.json";
- // String path = null;
- // JsonParser config = new JsonParser();
- //
- // try {
- // LogUtil.info("System.get " + System.getProperty("user.dir") + resource);
- // LogUtil.info("LogUtil.get " + LogUtil.GetPath() + resource);
- // path = LogUtil.GetPath() + resource;
- //
- // JsonObject object = (JsonObject) config.parse(new FileReader(path));
- //
- // JsonArray db = object.get("DB").getAsJsonArray();
- // for (int i = 0; i < db.size(); i++) {
- // JsonObject subObject = db.get(i).getAsJsonObject();
- // if (subObject.get("building") != null) {
- // String building = subObject.get("building").getAsString();
- // Constant.BuildingDB.put(building,
- // subObject.get("database").getAsString());
- // Constant.Database = subObject.get("database").getAsString();
- //
- // if (subObject.get("buildingadds") != null) {
- // JsonArray buildingAdds = subObject.get("buildingadds").getAsJsonArray();
- // for (int j = 0; j < buildingAdds.size(); j++) {
- // JsonObject addObject = buildingAdds.get(j).getAsJsonObject();
- // if (!Constant.BuildingAdds.containsKey(building)) {
- // Constant.BuildingAdds.put(building, new ArrayList<String>());
- // }
- // Constant.BuildingAdds.get(building).add(addObject.get("building").getAsString());
- // Constant.BuildingDB.put(addObject.get("building").getAsString(),
- // subObject.get("database").getAsString());
- // Constant.Database = subObject.get("database").getAsString();
- // Constant.BuildingConv.put(addObject.get("building").getAsString(),
- // building);
- // }
- //
- // }
- // } else if (subObject.get("insertthread") != null) {
- // Constant.InsertThread = subObject.get("insertthread").getAsInt();
- // }
- // }
- // JsonArray port = object.get("Port").getAsJsonArray();
- // for (int i = 0; i < port.size(); i++) {
- // JsonObject subObject = port.get(i).getAsJsonObject();
- // String ports = subObject.get("port").getAsString();
- // Constant.TypePort.put(subObject.get("type").getAsString(), ports);
- // Constant.PortCompress.put(Integer.valueOf(ports),
- // subObject.get("Compress").getAsString());
- // Constant.PortHistory.put(Integer.valueOf(ports),
- // subObject.get("History").getAsString());
- // // for (String p : ports.split(",")) {
- // // Constant.PortCompress.put(Integer.valueOf(p),
- // // subObject.get("Compress").getAsString());
- // // Constant.PortHistory.put(Integer.valueOf(p),
- // // subObject.get("History").getAsString());
- // // }
- // }
- //
- // JsonArray blackList = object.get("BlackList").getAsJsonArray();
- // for (int i = 0; i < blackList.size(); i++) {
- // JsonObject subObject = blackList.get(i).getAsJsonObject();
- // if (subObject.get("buildings") != null) {
- // if (subObject.get("buildings") != null) {
- // JsonArray buildings = subObject.get("buildings").getAsJsonArray();
- // for (int j = 0; j < buildings.size(); j++) {
- // JsonObject addObject = buildings.get(j).getAsJsonObject();
- // Constant.black_Buildings.put(addObject.get("building").getAsString(),
- // null);
- // }
- // }
- // }
- // }
- //
- // JsonArray whiteList = object.get("WhiteList").getAsJsonArray();
- // for (int i = 0; i < whiteList.size(); i++) {
- // JsonObject subObject = whiteList.get(i).getAsJsonObject();
- // if (subObject.get("funcids") != null) {
- // if (subObject.get("funcids") != null) {
- // JsonArray funcids = subObject.get("funcids").getAsJsonArray();
- // for (int j = 0; j < funcids.size(); j++) {
- // JsonObject addObject = funcids.get(j).getAsJsonObject();
- // Constant.whilte_Funcs.put(addObject.get("funcid").getAsInt(), null);
- // }
- // }
- // }
- // }
- //
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // // LogUtil.info(e.getMessage());
- // LogUtil.warn(e.toString());
- // LogUtil.warn("No Config File(config.json) in " + path + ",Now Exit!");
- // System.exit(0);
- // }
- //
- // }
- // public static long getWaitingtime() {
- // // TODO Auto-generated method stub
- // try {
- // if (WaitingTimeControl.contains("Second")) {
- // return Integer.valueOf(WaitingTimeControl.replace(" ",
- // "").replace("Second", ""))
- // * Constant.Millisecond.SECOND_1;
- // } else if (WaitingTimeControl.contains("second")) {
- // return Integer.valueOf(WaitingTimeControl.replace(" ",
- // "").replace("second", ""))
- // * Constant.Millisecond.SECOND_1;
- // } else {
- // return Constant.Millisecond.SECOND_3;
- // }
- // } catch (Exception e) {
- // return Constant.Millisecond.SECOND_3;
- // }
- // }
- public static Map<String, Integer> toLower(Map<String, Integer> pty) {
- // TODO Auto-generated method stub
- Map<String, Integer> result = new HashMap<String, Integer>();
- for (Entry<String, Integer> m : pty.entrySet()) {
- result.put(m.getKey().toLowerCase(), m.getValue());
- // Constant.info(m.getKey() + "-->" + m.getKey().toLowerCase());
- }
- return result;
- }
- public static long getWaitingtime() {
- // TODO Auto-generated method stub
- try {
- if (WaitingTimeControl.contains("Second")) {
- return Integer.valueOf(WaitingTimeControl.replace(" ", "").replace("Second", ""))
- * Constant.Millisecond.SECOND_1;
- } else if (WaitingTimeControl.contains("second")) {
- return Integer.valueOf(WaitingTimeControl.replace(" ", "").replace("second", ""))
- * Constant.Millisecond.SECOND_1;
- } else {
- return Constant.Millisecond.SECOND_3;
- }
- } catch (Exception e) {
- return Constant.Millisecond.SECOND_3;
- }
- }
- // @SuppressWarnings("rawtypes")
- // public static InetAddress getLocalHostLANAddress() throws
- // UnknownHostException {
- // try {
- // InetAddress candidateAddress = null;
- // // 遍历所有的网络接口
- // for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
- // ifaces.hasMoreElements();) {
- // NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
- // // 在所有的接口下再遍历IP
- // for (Enumeration inetAddrs = iface.getInetAddresses();
- // inetAddrs.hasMoreElements();) {
- // InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();
- // if (!inetAddr.isLoopbackAddress()) {// 排除loopback类型地址
- // if (inetAddr.isSiteLocalAddress()) {
- // // 如果是site-local地址,就是它了
- // return inetAddr;
- // } else if (candidateAddress == null) {
- // // site-local类型的地址未被发现,先记录候选地址
- // candidateAddress = inetAddr;
- // }
- // }
- // }
- // }
- // if (candidateAddress != null) {
- // return candidateAddress;
- // }
- // // 如果没有发现 non-loopback地址.只能用最次选的方案
- // InetAddress jdkSuppliedAddress = InetAddress.getLocalHost();
- // if (jdkSuppliedAddress == null) {
- // throw new UnknownHostException("The JDK InetAddress.getLocalHost() method
- // unexpectedly returned null.");
- // }
- // return jdkSuppliedAddress;
- // } catch (Exception e) {
- // UnknownHostException unknownHostException = new UnknownHostException(
- // "Failed to determine LAN address: " + e);
- // unknownHostException.initCause(e);
- // throw unknownHostException;
- // }
- // }
- private static final SimpleDateFormat SIMPLEDATEFORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
- private static final SimpleDateFormat SIMPLEDATEFORMATDB = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- private static final SimpleDateFormat SIMPLEDATEFORMAT_Minute = new SimpleDateFormat("yyyyMMddHHmm");
- private static final SimpleDateFormat SIMPLEDATEFORMAT_DAY = new SimpleDateFormat("yyyyMMdd");
- private static final SimpleDateFormat SIMPLEDATEFORMAT_MONTH = new SimpleDateFormat("yyyyMM");
- private static final SimpleDateFormat SIMPLEDATEFORMATLOG = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
- // private static final SimpleDateFormat SIMPLEDATEFORMAT_LOG = new
- // SimpleDateFormat("yyyyMMddHHmmssSSS");
- // public synchronized static String format_LOG(Date value) {
- // return SIMPLEDATEFORMAT_LOG.format(value);
- // }
- public synchronized static String format_Minute(Date value) {
- return SIMPLEDATEFORMAT_Minute.format(value);
- }
- public synchronized static String format_DB(Date value) {
- return SIMPLEDATEFORMATDB.format(value);
- }
- public synchronized static String format_Log(Date value) {
- return SIMPLEDATEFORMATLOG.format(value);
- }
- // public synchronized static Date parse_LOG(String value) throws
- // ParseException {
- // return SIMPLEDATEFORMAT_LOG.parse(value);
- // }
- public synchronized static Date parse_Minute(String value) throws ParseException {
- return SIMPLEDATEFORMAT_Minute.parse(value);
- }
- public synchronized static Date parse_DB(String value) throws ParseException {
- return SIMPLEDATEFORMATDB.parse(value);
- }
- public synchronized static Date parse_MONTH(String value) throws ParseException {
- return SIMPLEDATEFORMAT_MONTH.parse(value);
- }
- public synchronized static String format(Date value) {
- if (value == null) {
- return "null";
- }
- return SIMPLEDATEFORMAT.format(value);
- }
- public synchronized static Date parse(String value) throws ParseException {
- return SIMPLEDATEFORMAT.parse(value);
- }
- public synchronized static String format_day(Date value) {
- return SIMPLEDATEFORMAT_DAY.format(value);
- }
- public synchronized static String format_month(Date value) {
- return SIMPLEDATEFORMAT_MONTH.format(value);
- }
- public synchronized static Date parse_day(String value) throws ParseException {
- return SIMPLEDATEFORMAT_DAY.parse(value);
- }
- public static void showStatus() {
- // TODO Auto-generated method stub
- LogUtil.info("ps_PointStatusUp:");
- for (Entry<String, Long> d : Constant.ps_PointStatusUp.entrySet()) {
- LogUtil.info(d.getKey() + " " + Constant.format(new Date(d.getValue())));
- }
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_PhysicalStatus:");
- for (Entry<String, Long> d : Constant.ps_PhysicalStatus.entrySet()) {
- LogUtil.info(d.getKey() + " " + Constant.format(new Date(d.getValue())));
- }
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_ProjectStatus:");
- for (Entry<String, Long> d : Constant.ps_ProjectStatus.entrySet()) {
- LogUtil.info(d.getKey() + " " + Constant.format(new Date(d.getValue())));
- }
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_MeterStatusUp:");
- for (Entry<String, Long> d : Constant.ps_MeterStatusUp.entrySet()) {
- LogUtil.info(d.getKey() + " " + Constant.format(new Date(d.getValue())));
- }
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_PointStatusDown:");
- for (Entry<String, Long> d : Constant.ps_PointStatusDown.entrySet()) {
- LogUtil.info(d.getKey() + " " + Constant.format(new Date(d.getValue())));
- }
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_MeterStatusDown:");
- for (Entry<String, Long> d : Constant.ps_MeterStatusDown.entrySet()) {
- LogUtil.info(d.getKey() + " " + Constant.format(new Date(d.getValue())));
- }
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_PhysicalList:\n" + Constant.ps_PhysicalList);
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_ProjectList:\n" + Constant.ps_ProjectList);
- LogUtil.info("-----------------------------------------------------");
- LogUtil.info("ps_MeterList:\n" + Constant.ps_MeterList);
- LogUtil.info("-----------------------------------------------------");
- }
- // public static void Insert_agents_ps_physical_log(String project, String
- // address_1, String address_2,
- // String address_3, String address_4, String receivetime, String status) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.Insert_ps_physical_log(Constant.BuildingDB.get(project),
- // project, address_1, address_2, address_3,
- // address_4, receivetime, status);
- // LogUtil.info(agent.getFull_name() + " insert into ps_physical_log " + "
- // project " + project + " address_1 "
- // + address_1 + " address_2 " + address_2 + " address_3 " + address_3 + "
- // address_4 " + address_4
- // + " receivetime " + receivetime + " status " + status);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // }
- //
- // public static void Insert_agents_ps_physical_status(String project,
- // String address_1, String address_2,
- // String address_3, String address_4, String status, String receivetime,
- // String detail) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.Insert_ps_physical_status(Constant.BuildingDB.get(project),
- // project, address_1, address_2,
- // address_3, address_4, status, receivetime, detail);
- // LogUtil.info(agent.getFull_name() + " insert into ps_physical_status " +
- // " project " + project
- // + " address_1 " + address_1 + " address_2 " + address_2 + " address_3 " +
- // address_3 + " address_4 "
- // + address_4 + " receivetime " + receivetime + " status " + status);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void Insert_agents_ps_virtual_meter_log(String project,
- // String meter, String updown,
- // String receivetime, String status) {
- // // TODO Auto-generated method stub
- //
- // try {
- // HBaseUtil.Insert_ps_virtual_meter_log(Constant.BuildingDB.get(project),
- // project, meter, updown, receivetime,
- // status);
- // LogUtil.info(agent.getFull_name() + " insert into ps_virtual_meter_log "
- // + " project " + project + " meter "
- // + meter + " updown " + updown + " receivetime " + receivetime + " status
- // " + status);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void Insert_agents_ps_virtual_meter_status(String project,
- // String meter, String updown, String status,
- // String receivetime, String detail) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.Insert_ps_virtual_meter_status(Constant.BuildingDB.get(project),
- // project, meter, updown, status,
- // receivetime, detail);
- // LogUtil.info(agent.getFull_name() + " insert into ps_virtual_meter_status
- // " + " project " + project
- // + " meter " + meter + " updown " + updown + " receivetime " + receivetime
- // + " status " + status);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void Insert_agents_ps_virtual_point_log(String building,
- // String meter, Long funcid, String updown,
- // Long time, Long seq, String status, String feedback) {
- // // TODO Auto-generated method stub
- // try {
- // if (time == null || time == 0) {
- // HBaseUtil.Insert_ps_virtual_point_log(Constant.BuildingDB.get(building),
- // building, meter,
- // Long.valueOf(funcid), updown, Constant.format(new Date()), seq, status,
- // feedback);
- // } else {
- // HBaseUtil.Insert_ps_virtual_point_log(Constant.BuildingDB.get(building),
- // building, meter,
- // Long.valueOf(funcid), updown, Constant.format(new Date(time)), seq,
- // status, feedback);
- // }
- // LogUtil.info(agent.getFull_name() + " insert into ps_virtual_point_log "
- // + " building " + building
- // + " meter " + meter + " updown " + updown + " funcid " + funcid + "
- // status " + status + " feedback "
- // + feedback);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void Insert_agents_ps_virtual_point_status(String building,
- // String meter, Long funcid, String updown,
- // String status, Long time, String detail) {
- // // TODO Auto-generated method stub
- // try {
- // if (time == null || time == 0) {
- // HBaseUtil.Insert_ps_virtual_point_status(Constant.BuildingDB.get(building),
- // building, meter,
- // Long.valueOf(funcid), "up", status, Constant.format(new Date()), "");
- //
- // } else {
- // HBaseUtil.Insert_ps_virtual_point_status(Constant.BuildingDB.get(building),
- // building, meter,
- // Long.valueOf(funcid), "up", status, Constant.format(new Date(time)), "");
- // }
- // LogUtil.info(agent.getFull_name() + " insert into ps_virtual_point_status
- // " + " building " + building
- // + " meter " + meter + " updown " + updown + " funcid " + funcid + "
- // status " + status + " detail "
- // + detail);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void Insert_agents_ps_virtual_project_log(String project,
- // String receivetime, String status) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.Insert_ps_virtual_project_log(Constant.BuildingDB.get(project),
- // project, receivetime, status);
- // LogUtil.info(agent.getFull_name() + " insert into ps_virtual_project_log
- // " + " project " + project
- // + " receivetime " + receivetime + " status " + status);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // }
- //
- // public static void Insert_agents_ps_virtual_project_status(String
- // project, String status, String receivetime,
- // String detail) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.Insert_ps_virtual_project_status(Constant.BuildingDB.get(project),
- // project, status, receivetime,
- // detail);
- // LogUtil.info(agent.getFull_name() + " insert into
- // ps_virtual_project_status " + " project " + project
- // + " receivetime " + receivetime + " status " + status);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- // public static List<String> getConfigFile(String directoryPath, String
- // directoryKey, String fileKey) {
- // List<String> list = new ArrayList<String>();
- // File baseFile = new File(directoryPath);
- // if (baseFile.isFile() || !baseFile.exists()) {
- // return list;
- // }
- // try {
- // File[] files = baseFile.listFiles();
- // SAXReader saxReader = new SAXReader();
- // for (File file : files) {
- // if (file.isDirectory() && file.getName().contains(directoryKey)) {
- // list.addAll(getConfigFile(file.getAbsolutePath(), directoryKey,
- // fileKey));
- // } else {
- // if (file.getName().contains(fileKey)) {
- // list.add(file.getAbsolutePath());
- // Document document = saxReader.read(file);
- // List<Element> devList = document.selectNodes("/root/portdev/devtype");
- // // LogUtil.info(file.getName());
- // // LogUtil.info(file.getName().indexOf(fileKey));
- // // LogUtil.info(file.getName().indexOf(".xml"));
- // String port = file.getName().substring(file.getName().indexOf(fileKey) +
- // fileKey.length(),
- // file.getName().indexOf(".xml"));
- // // LogUtil.info(port);
- // // LogUtil.info(file.getParentFile().getName());
- // // String building =
- // // file.getParentFile().getName().replace(directoryKey,
- // // "").substring(0, 10);
- // // String mac =
- // // file.getParentFile().getName().replace(directoryKey,
- // // "").substring(10);
- // String building = file.getParentFile().getName().replace(directoryKey,
- // "").split("-")[0];
- // String mac = file.getParentFile().getName().replace(directoryKey,
- // "").split("-")[1];
- // // LogUtil.info(building);
- // // LogUtil.info(mac);
- //
- // for (Element portdev : devList) {
- // String meter = portdev.attributeValue("meterid");
- // String info = port + "-" + portdev.element("addr").getText();
- // String point = building + "-" + mac + "-" + meter;
- // Constant.pointInfo.put(point, info);
- // // Iterator funcList =
- // // portdev.selectNodes("funset/funid").iterator();
- // // while (funcList.hasNext()) {
- // // Element func = (Element) funcList.next();
- // // String point = building + "-" + mac + "-" + meter
- // // + "." + func.getText();
- // // String info = port + "-" +
- // // portdev.element("addr").getText();
- // // Constant.pointInfo.put(point, info);
- // // LogUtil.info(meter + "." +
- // // func.getText());
- // // }
- // }
- //
- // }
- // }
- // }
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // return list;
- // }
- public synchronized static int getSeq(String point) {
- int month = Integer.valueOf(Constant.format_month(new Date()).substring(4));
- if (Constant.pMonth.containsKey(point) && (month == Constant.pMonth.get(point))) {
- int seq = Constant.pSeq.get(point) + 1;
- Constant.pMonth.put(point, month);
- Constant.pSeq.put(point, seq);
- return seq;
- }
- Constant.pMonth.put(point, month);
- Constant.pSeq.put(point, 1);
- return 1;
- }
- public synchronized static int getID() {
- if (PacketId > 65535) {
- PacketId = 1;
- } else {
- PacketId = PacketId + 1;
- }
- return PacketId;
- }
- public static class Millisecond {
- public static final long SECOND_1 = 1000L;
- public static final long SECOND_3 = 1000L * 3;
- public static final long SECOND_10 = 1000L * 10;
- public static final long SECOND_20 = 1000L * 20;
- public static final long SECOND_30 = 1000L * 30;
- public static final long MINUTE_1 = 1000L * 60 * 1;
- public static final long MINUTE_3 = 1000L * 60 * 3;
- public static final long MINUTE_5 = 1000L * 60 * 5;
- public static final long MINUTE_10 = 1000L * 60 * 10;
- public static final long MINUTE_15 = 1000L * 60 * 15;
- public static final long MINUTE_30 = 1000L * 60 * 30;
- public static final long MINUTE_60 = 1000L * 60 * 60;
- public static final long MINUTE_1440 = 1000L * 60 * 60 * 24;
- public static final long HOUR = 1000L * 60 * 60;
- public static final long DAY = 1000L * 60 * 60 * 24;
- }
- public static long getMillisecond(String request) {
- // TODO Auto-generated method stub
- try {
- if (request.contains("Second")) {
- return Integer.valueOf(request.replace(" ", "").replace("Second", "")) * Constant.Millisecond.SECOND_1;
- } else if (request.contains("second")) {
- return Integer.valueOf(request.replace(" ", "").replace("second", "")) * Constant.Millisecond.SECOND_1;
- } else if (request.contains("min")) {
- return Millisecond.MINUTE_1 * Integer.valueOf(request.replace("min", "").replace(" ", ""));
- } else {
- return Constant.Millisecond.SECOND_20;
- }
- } catch (Exception e) {
- return Constant.Millisecond.SECOND_20;
- }
- }
- public static void Insert_dy_pointlist(String building, String meter, Integer funcid, String system, String source,
- String address1, String ip_port, String address2, String address3, String address4, String collect_cycle,
- String data_type, String unit) {
- // TODO Auto-generated method stub
- try {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_dy_pointlist(Constant.Database, building, meter, funcid, system, source, address1,
- ip_port, address2, "", "", collect_cycle, data_type, unit);
- LogUtil.info(
- "insert into dy_pointlist " + "building " + building + " meter " + meter + " funcid " + funcid);
- } else {
- HBaseUtil.Insert_dy_pointlist(Constant.Database, building, meter, funcid, system, source, address1,
- ip_port, address2, "", "", collect_cycle, data_type, unit);
- LogUtil.info(agent.getFull_name() + " insert into dy_pointlist " + "building " + building + " meter "
- + meter + " funcid " + funcid);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- // public static void AgentsBatchInsert(String db, List<Record>
- // wtdbrecordList) {
- // // TODO Auto-generated method stub
- //
- // try {
- // HBaseUtil.BatchInsert(db, wtdbrecordList);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // }
- //
- // public static void AgentsBatchInsert_Set2(String db, PointSet ps) {
- // // TODO Auto-generated method stub
- //
- // try {
- // HBaseUtil.BatchInsert_Set2(db, ps);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void AgentsBatchInsert_Set3(String db, PointSet ps) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.BatchInsert_Set3(db, ps);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- //
- // public static void AgentsBatchInsert_Set1(String db, PointSet ps) {
- // // TODO Auto-generated method stub
- // try {
- // HBaseUtil.BatchInsert_Set1(db, ps);
- // } catch (Exception e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // }
- public static Map<String, List<Integer>> GetDBPointList2Cache(String db, String tb, String building) {
- // TODO Auto-generated method stub
- Map<String, List<Integer>> dbPointList = new HashMap<String, List<Integer>>();
- try {
- Map<String, List<Integer>> pl = GetDBPointList(db, tb, building);
- for (Entry<String, List<Integer>> m : pl.entrySet()) {
- if (!dbPointList.containsKey(m.getKey())) {
- dbPointList.put(m.getKey(), new ArrayList<Integer>());
- }
- for (Integer f : m.getValue()) {
- if (!dbPointList.get(m.getKey()).contains(f)) {
- dbPointList.get(m.getKey()).add(f);
- }
- }
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return dbPointList;
- }
- public static void loadDB2Cache_dy_pointlist() {
- // TODO Auto-generated method stub
- try {
- Constant.LoadDB2Cache_dy_pointlist(Constant.Database, "dy_pointlist");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static Map<String, String> ps_physical_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- return MySQLUtil.ps_physical_status(db, tb);
- } else {
- return HBaseUtil.ps_physical_status(db, tb);
- }
- }
- public static Map<String, String> ps_virtual_point_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- return MySQLUtil.ps_virtual_point_status(db, tb);
- } else {
- return HBaseUtil.ps_virtual_point_status(db, tb);
- }
- }
- public static Map<String, String> ps_virtual_meter_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- return MySQLUtil.ps_virtual_meter_status(db, tb);
- } else {
- return HBaseUtil.ps_virtual_meter_status(db, tb);
- }
- }
- public static Map<String, String> ps_virtual_project_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- return MySQLUtil.ps_virtual_project_status(db, tb);
- } else {
- return HBaseUtil.ps_virtual_project_status(db, tb);
- }
- }
- public static void LoadDB2Cache_dy_pointlist(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.LoadDB2Cache_dy_pointlist(db, tb);
- } else {
- HBaseUtil.LoadDB2Cache_dy_pointlist(db, tb);
- }
- }
- public static void LoadDB2Cache_ps_physical_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.LoadDB2Cache_ps_physical_status(db, tb);
- } else {
- HBaseUtil.LoadDB2Cache_ps_physical_status(db, tb);
- }
- }
- public static void LoadDB2Cache_ps_virtual_point_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.LoadDB2Cache_ps_virtual_point_status(db, tb);
- } else {
- HBaseUtil.LoadDB2Cache_ps_virtual_point_status(db, tb);
- }
- }
- public static void LoadDB2Cache_ps_virtual_meter_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.LoadDB2Cache_ps_virtual_meter_status(db, tb);
- } else {
- HBaseUtil.LoadDB2Cache_ps_virtual_meter_status(db, tb);
- }
- }
- public static void LoadDB2Cache_ps_virtual_project_status(String db, String tb) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.LoadDB2Cache_ps_virtual_project_status(db, tb);
- } else {
- HBaseUtil.LoadDB2Cache_ps_virtual_project_status(db, tb);
- }
- }
- public static Map<String, List<Integer>> GetDBPointList(String db, String tb, String building) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- return MySQLUtil.GetDBPointList(db, tb, building);
- } else {
- return HBaseUtil.GetDBPointList(db, tb, building);
- }
- }
- public static void Getset(String db, String tb, String building, String meter, long funcid, String query_from,
- String query_to) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Getset(db, tb, building, meter, funcid, query_from, query_to);
- } else {
- HBaseUtil.Getset(db, tb, building, meter, funcid, query_from, query_to);
- }
- }
- public static void Getset_present(String db, String tb, String building, String meter, long funcid)
- throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Getset_present(db, tb, building, meter, funcid);
- } else {
- HBaseUtil.Getset_present(db, tb, building, meter, funcid);
- }
- }
- public static void CreateDB(String DB) throws Exception {
- try {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateDB(DB);
- } else {
- HBaseUtil.CreateDB(DB);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static boolean tableExist(String DBName, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- return MySQLUtil.tableExist(DBName, tableName);
- } else {
- return HBaseUtil.tableExist(DBName, tableName);
- }
- }
- public static void CreateTable(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable(DB, tableName);
- } else {
- HBaseUtil.CreateTable(DB, tableName);
- }
- }
- public static void CreateTable_present(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_present(DB, tableName);
- } else {
- HBaseUtil.CreateTable_present(DB, tableName);
- }
- }
- public static void CreateTable_set(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_set(DB, tableName);
- } else {
- HBaseUtil.CreateTable_set(DB, tableName);
- }
- }
- public static void CreateTable_setpresent(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_setpresent(DB, tableName);
- } else {
- HBaseUtil.CreateTable_setpresent(DB, tableName);
- }
- }
- public static void CreateTable_fjd_0_buildingcomputetime(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_fjd_0_buildingcomputetime(DB, tableName);
- } else {
- HBaseUtil.CreateTable_fjd_0_buildingcomputetime(DB, tableName);
- }
- }
- public static void CreateTable_dy_pointlist(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_dy_pointlist(DB, tableName);
- } else {
- HBaseUtil.CreateTable_dy_pointlist(DB, tableName);
- }
- }
- public static void CreateTable_ps_physical_status(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_physical_status(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_physical_status(DB, tableName);
- }
- }
- public static void CreateTable_ps_physical_log(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_physical_log(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_physical_log(DB, tableName);
- }
- }
- public static void CreateTable_ps_virtual_point_status(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_virtual_point_status(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_virtual_point_status(DB, tableName);
- }
- }
- public static void CreateTable_ps_virtual_point_log(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_virtual_point_log(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_virtual_point_log(DB, tableName);
- }
- }
- public static void CreateTable_ps_virtual_meter_status(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_virtual_meter_status(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_virtual_meter_status(DB, tableName);
- }
- }
- public static void CreateTable_ps_virtual_meter_log(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_virtual_meter_log(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_virtual_meter_log(DB, tableName);
- }
- }
- public static void CreateTable_ps_virtual_project_status(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_virtual_project_status(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_virtual_project_status(DB, tableName);
- }
- }
- public static void CreateTable_ps_virtual_project_log(String DB, String tableName) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_ps_virtual_project_log(DB, tableName);
- } else {
- HBaseUtil.CreateTable_ps_virtual_project_log(DB, tableName);
- }
- }
- public static void Insert_fjd_0_buildingcomputetime(String DB, String building, String compute_time,
- String first_compute_time) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_fjd_0_buildingcomputetime(DB, building, compute_time, first_compute_time);
- } else {
- HBaseUtil.Insert_fjd_0_buildingcomputetime(DB, building, compute_time, first_compute_time);
- }
- }
- public static void Insert_ps_physical_status(String DB, String project, String address_1, String address_2,
- String address_3, String address_4, String status, String receivetime, String detail) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_physical_status(DB, project, address_1, address_2, address_3, address_4, status,
- receivetime, detail);
- } else {
- HBaseUtil.Insert_ps_physical_status(DB, project, address_1, address_2, address_3, address_4, status,
- receivetime, detail);
- }
- }
- public static void Insert_ps_physical_log(String DB, String project, String address_1, String address_2,
- String address_3, String address_4, String receivetime, String function) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_physical_log(DB, project, address_1, address_2, address_3, address_4, receivetime,
- function);
- } else {
- HBaseUtil.Insert_ps_physical_log(DB, project, address_1, address_2, address_3, address_4, receivetime,
- function);
- }
- }
- public static void Insert_ps_virtual_point_status(String DB, String project, String meter, long funcid,
- String updown, String status, String receivetime, String detail) throws Exception {
- if (receivetime == null || Constant.parse(receivetime).getTime() == 0) {
- receivetime = Constant.format(new Date());
- }
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_virtual_point_status(DB, project, meter, funcid, updown, status, receivetime, detail);
- } else {
- HBaseUtil.Insert_ps_virtual_point_status(DB, project, meter, funcid, updown, status, receivetime, detail);
- }
- }
- public static void Insert_ps_virtual_point_log(String DB, String project, String meter, long funcid, String updown,
- String receivetime, long seq, String function, String feedback) throws Exception {
- if (receivetime == null || Constant.parse(receivetime).getTime() == 0) {
- receivetime = Constant.format(new Date());
- }
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_virtual_point_log(DB, project, meter, funcid, updown, receivetime, seq, function,
- feedback);
- } else {
- HBaseUtil.Insert_ps_virtual_point_log(DB, project, meter, funcid, updown, receivetime, seq, function,
- feedback);
- }
- }
- public static void Insert_ps_virtual_meter_status(String DB, String project, String meter, String updown,
- String status, String receivetime, String detail) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_virtual_meter_status(DB, project, meter, updown, status, receivetime, detail);
- } else {
- HBaseUtil.Insert_ps_virtual_meter_status(DB, project, meter, updown, status, receivetime, detail);
- }
- }
- public static void Insert_ps_virtual_meter_log(String DB, String project, String meter, String updown,
- String receivetime, String function) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_virtual_meter_log(DB, project, meter, updown, receivetime, function);
- } else {
- HBaseUtil.Insert_ps_virtual_meter_log(DB, project, meter, updown, receivetime, function);
- }
- }
- public static void Insert_ps_virtual_project_status(String DB, String project, String status, String receivetime,
- String detail) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_virtual_project_status(DB, project, status, receivetime, detail);
- } else {
- HBaseUtil.Insert_ps_virtual_project_status(DB, project, status, receivetime, detail);
- }
- }
- public static void Insert_ps_virtual_project_log(String DB, String project, String receivetime, String function)
- throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.Insert_ps_virtual_project_log(DB, project, receivetime, function);
- } else {
- HBaseUtil.Insert_ps_virtual_project_log(DB, project, receivetime, function);
- }
- }
- public static void MsgBatchInsert(String DB, List<RecordMsg> dataList) throws Exception {
- LogUtil.warn("MsgBatchInsert Start, time:" + new Date().toString() + " ,size:" + dataList.size());
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.MsgBatchInsert(DB, dataList);
- } else {
- HBaseUtil.MsgBatchInsert(DB, dataList);
- }
- LogUtil.warn("MsgBatchInsert End, time:" + new Date().toString() + " ,size:" + dataList.size());
- }
- public static void MsgBatchDelte(String DB, List<RecordMsg> dataList) throws Exception {
- LogUtil.warn("MsgBatchDelte Start, time:" + new Date().toString() + " ,size:" + dataList.size());
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.MsgBatchDelte(DB, dataList);
- } else {
- // HBaseUtil.MsgBatchDelte(DB, dataList);
- }
- LogUtil.warn("MsgBatchInsert End, time:" + new Date().toString() + " ,size:" + dataList.size());
- }
- public static void BatchInsert(String DB, List<Record> dataList) throws Exception {
- LogUtil.warn("BatchInsert Start, time:" + new Date().toString() + " ,size:" + dataList.size());
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.BatchInsert(DB, dataList);
- } else {
- HBaseUtil.BatchInsert(DB, dataList);
- }
- LogUtil.warn("BatchInsert End, time:" + new Date().toString() + " ,size:" + dataList.size());
- }
- public static void BatchInsertUpload(List<Record> dataList) throws Exception {
- LogUtil.warn("BatchInsertUpload Start, time:" + new Date().toString() + " ,size:" + dataList.size());
- if (Constant.DbConnection.containsKey("Upload-Mysql") && Constant.DbConnection.get("Upload-Mysql") != null) {
- EntityMysql entityMysql = new EntityMysql();
- entityMysql = (EntityMysql) Constant.DbConnection.get("Upload-Mysql");
- MySQLUtil.BatchInsertUpload(entityMysql.UploadDatabase, Arrays.asList(entityMysql.UploadTable.split(",")),
- dataList);
- } else if (Constant.DbConnection.containsKey("Upload-Hbase")
- && Constant.DbConnection.get("Upload-Hbase") != null) {
- EntityHbase entityHbase = new EntityHbase();
- entityHbase = (EntityHbase) Constant.DbConnection.get("Upload-Hbase");
- HBaseUtil.BatchInsertUpload(entityHbase.UploadDatabase, Arrays.asList(entityHbase.UploadTable.split(",")),
- dataList);
- }
- LogUtil.warn("BatchInsertUpload End, time:" + new Date().toString() + " ,size:" + dataList.size());
- }
- public static void BatchInsert_Set1(String DB, PointSet ps) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.BatchInsert_Set1(DB, ps);
- } else {
- HBaseUtil.BatchInsert_Set1(DB, ps);
- }
- }
- public static void BatchInsert_Set2(String DB, PointSet ps) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.BatchInsert_Set2(DB, ps);
- } else {
- HBaseUtil.BatchInsert_Set2(DB, ps);
- }
- }
- public static void BatchInsert_Set3(String DB, PointSet ps) throws Exception {
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.BatchInsert_Set3(DB, ps);
- } else {
- HBaseUtil.BatchInsert_Set3(DB, ps);
- }
- }
- public static Date getOffSetTime(Record record) {
- // TODO Auto-generated method stub
- if (Constant.BuildingOffset.containsKey(record.buildingSign)
- && Constant.BuildingOffset.get(record.buildingSign)) {
- return new Date(record.receivetime.getTime() + 8 * Constant.Millisecond.HOUR);
- }
- return record.receivetime;
- }
- public static int getFunctionConv(Record record) {
- // TODO Auto-generated method stub
- if (Constant.FunctionConv.containsKey(record.funcID) && Constant.FunctionConv.get(record.funcID) != null) {
- return Integer.valueOf(Constant.FunctionConv.get(record.funcID));
- }
- return record.funcID;
- }
- public static void CreateTable_upload() throws Exception {
- if (Constant.DbConnection.containsKey("Upload-Mysql") && Constant.DbConnection.get("Upload-Mysql") != null) {
- EntityMysql entityMysql = new EntityMysql();
- entityMysql = (EntityMysql) Constant.DbConnection.get("Upload-Mysql");
- MySQLUtil.CreateUploadDB(entityMysql.UploadDatabase);
- MySQLUtil.CreateTable_upload(entityMysql.UploadDatabase, Arrays.asList(entityMysql.UploadTable.split(",")));
- } else if (Constant.DbConnection.containsKey("Upload-Hbase")
- && Constant.DbConnection.get("Upload-Hbase") != null) {
- EntityHbase entityHbase = new EntityHbase();
- entityHbase = (EntityHbase) Constant.DbConnection.get("Upload-Hbase");
- HBaseUtil.CreateUploadDB(entityHbase.UploadDatabase);
- HBaseUtil.CreateTable_upload(entityHbase.UploadDatabase, Arrays.asList(entityHbase.UploadTable.split(",")));
- }
- }
- public static void CreateTable_detail(String DB, String tableName) throws Exception {
- // TODO Auto-generated method stub
- if (Constant.DbConnection.containsKey("Db-Mysql") && Constant.DbConnection.get("Db-Mysql") != null) {
- MySQLUtil.CreateTable_detail(DB, tableName);
- } else {
- HBaseUtil.CreateTable_detail(DB, tableName);
- }
- }
- public static String unicodeDecode(String string) {
- String result = string;
- try {
- LogUtil.info(new String(string.getBytes("gbk")));
- LogUtil.info(new String(string.getBytes("utf-8"), "gbk"));
- LogUtil.info(new String(string.getBytes("iso-8859-1"), "gbk"));
- LogUtil.info(new String(string.getBytes("gb2312"), "gbk"));
- LogUtil.info(new String(string.getBytes("utf-8")));
- LogUtil.info(new String(string.getBytes("gbk"), "utf-8"));
- LogUtil.info(new String(string.getBytes("iso-8859-1"), "utf-8"));
- LogUtil.info(new String(string.getBytes("gb2312"), "utf-8"));
- LogUtil.info(new String(string.getBytes("iso-8859-1")));
- LogUtil.info(new String(string.getBytes("gbk"), "iso-8859-1"));
- LogUtil.info(new String(string.getBytes("utf-8"), "iso-8859-1"));
- LogUtil.info(new String(string.getBytes("gb2312"), "iso-8859-1"));
- LogUtil.info(new String(string.getBytes("gb2312")));
- LogUtil.info(new String(string.getBytes("gbk"), "gb2312"));
- LogUtil.info(new String(string.getBytes("utf-8"), "gb2312"));
- LogUtil.info(new String(string.getBytes("iso-8859-1"), "gb2312"));
- // result = new String(string.getBytes("ISO-8859-1"), "UTF-8");
- result = new String(string.getBytes("GB2312"), "8859_1");
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return result;
- // Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
- // Matcher matcher = pattern.matcher(string);
- // char ch;
- // while (matcher.find()) {
- // ch = (char) Integer.parseInt(matcher.group(2), 16);
- // string = string.replace(matcher.group(1), ch + "");
- // }
- // return string;
- }
- // 相似度计算
- public static double xiangsidu(String a, String b) {
- // 相似度公式:1 - 最小编辑距离/两个串中较长的长度
- int n = a.length();
- int m = b.length();
- if (n < 1 && m < 1)
- return 0; // 两个空串
- return 1 - minEditDist(a, b) / Math.max(n, m);
- }
- public static String xiangsidu(String s, List<String> m) {
- String result = s;
- Double xiangsi = 0d;
- for (int i = 0; i < m.size(); i++) {
- if (xiangsidu(s, m.get(i)) > xiangsi) {
- result = m.get(i);
- xiangsi = xiangsidu(s, m.get(i));
- }
- if (xiangsi == 1) {
- break;
- }
- }
- return result;
- }
- // 最小编辑距离计算
- public static double minEditDist(String a, String b) {
- int n = a.length();
- int m = b.length();
- if (n < 1 || m < 1)
- return (n + m) * 1.00; // 两个空串
- double[][] d = new double[n + 1][m + 1];
- double cost;
- for (int i = 0; i <= n; ++i)
- d[i][0] = i;
- for (int i = 0; i <= m; ++i)
- d[0][i] = i;
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= m; j++) {
- if (a.charAt(i - 1) == b.charAt(j - 1))
- cost = 0;
- else
- cost = 1;
- d[i][j] = Minimum(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
- }
- }
- return d[n][m];
- }
- private static double Minimum(double a, double b, double c) {
- double mi = a;
- if (b < mi) {
- mi = b;
- }
- if (c < mi) {
- mi = c;
- }
- return mi;
- }
- public static List<String> xuzhousuning() {
- List<String> result = new ArrayList<String>();
- result.add("7配2#变压器");
- result.add("7配1#变压器");
- result.add("10配1#变压器");
- result.add("10配2#变压器");
- result.add("8配1#变压器");
- result.add("8配2#变压器");
- result.add("9配1#变压器");
- result.add("9配2#变压器");
- result.add("11配1#变压器");
- result.add("11配2#变压器");
- result.add("1905D_低压进线柜");
- result.add("1907D_无功自动补偿电容柜");
- result.add("1910D_母联");
- result.add("1911D-1_一般照明1");
- result.add("1911D-2_备用");
- result.add("1912D-1_一般动力1");
- result.add("1912D-2_备用");
- result.add("1913D-1_M3区货梯1");
- result.add("1913D-2_C塔楼照明");
- result.add("1913D-3_变电所用电(主)");
- result.add("1913D-4_会所一般动力");
- result.add("1913D-5_D塔楼消防动力(常)");
- result.add("1913D-6_预留泛光照明");
- result.add("1914D-1_M3乘客电梯1(常)");
- result.add("1914D-2_M3乘客电梯2(常)");
- result.add("1914D-3_M3乘客电梯4(常)");
- result.add("1914D-4_M3乘客电梯5(常)");
- result.add("1914D-5_C塔楼进线客梯总电源(常)");
- result.add("1914D-6_CDE生活水泵房(常)");
- result.add("1914D-7_备用");
- result.add("1915D-1_C塔楼客梯总电源(常)");
- result.add("1915D-2_超市3");
- result.add("1915D-3_M3乘客电梯3(备)");
- result.add("1916D-1_D塔楼消防总电源(常)");
- result.add("1916D-2_备用");
- result.add("1916D-3_备用");
- result.add("1917D-1_消防动力1(常)");
- result.add("1917D-2_备用");
- result.add("1918D-1_消防动力2(备)电梯");
- result.add("1918D-2_备用");
- result.add("1919D-1_会所应急照明(常)");
- result.add("1919D-2_备用");
- result.add("1919D-3_备用");
- result.add("1919D-4_消防动力3(备)");
- result.add("1919D-5_商业应急照明(备)");
- result.add("1919D-6_B2充电桩");
- result.add("1920D-1_C塔楼公共应急照明(备)");
- result.add("1920D-2_C塔楼消防动力(常)");
- result.add("1920D-3_备用C塔楼消防电梯");
- result.add("1920D-4_C塔楼消防电梯备");
- result.add("1921D-1_D塔楼消控室");
- result.add("1921D-2_商业2变电所(常)");
- result.add("1921D-3_M3消防电梯(备)");
- result.add("1921D-4_D塔楼公共应急照明");
- result.add("1921D-5_穹顶膜(备)");
- result.add("1921D-6_D塔楼消防电梯总电源(常)");
- result.add("2005D_低压进线柜");
- result.add("2007D_无功自动补偿电容柜");
- result.add("2010D-1_一般照明2");
- result.add("2010D-2_备用");
- result.add("2011D-1_一般动力2");
- result.add("2011D-2_备用");
- result.add("2012D-1_会所一般照明");
- result.add("2012D-2_D塔照明");
- result.add("2012D-3_M3区货梯2");
- result.add("2012D-4_M3区扶梯");
- result.add("2012D-5_变电所用电(备)");
- result.add("2012D-6_D塔楼消防动力(备)");
- result.add("2012D-7_备用");
- result.add("2013D-1_M3乘客电梯1(备)");
- result.add("2013D-2_M3乘客电梯2(备)");
- result.add("2013D-3_M3乘客电梯4(备)");
- result.add("2013D-4_M3乘客电梯5(备)");
- result.add("2013D-5_C塔进线室电源");
- result.add("2013D-6_CDE生活水泵房(备)");
- result.add("2013D-7_备用");
- result.add("2014D-1_C塔楼客梯总电源(备)");
- result.add("2014D-2_备用");
- result.add("2014D-3_M3乘客电梯3(常)");
- result.add("2015D-1_D塔楼客梯总电源(备)");
- result.add("2015D-2_超市");
- result.add("2015D-3_备用");
- result.add("2016D-1_消防动力1(备)");
- result.add("2016D-2_备用");
- result.add("2017D-1_消防动力2(常)电梯");
- result.add("2017D-2_备用");
- result.add("2018D-1_会所应急照明(备)");
- result.add("2018D-2_备用");
- result.add("2018D-3_备用");
- result.add("2018D-4_消防动力3(常)");
- result.add("2018D-5_商业应急照明(常)");
- result.add("2018D-6_备用+商铺");
- result.add("2019D-1_C塔楼公共应急照明(常)");
- result.add("2019D-2_C塔楼消防动力(备)");
- result.add("2019D-3_备用");
- result.add("2019D-4_C塔楼消防电梯总电源(常)");
- result.add("2020D-1_D塔楼消控室(备)");
- result.add("2020D-2_商业2变电所(备)");
- result.add("2020D-3_M3消防电梯(常)");
- result.add("2020D-4_穹顶膜(常)");
- result.add("2020D-5_D塔楼公共应急照明(常)");
- result.add("2020D-6_D塔楼消防电梯总电源(备)");
- result.add("1505D_低压进线柜");
- result.add("1507D_无功自动补偿电容柜");
- result.add("1510D_低压母联柜");
- result.add("1511D-1_M4区一般照明1");
- result.add("1511D-2_备用");
- result.add("1512D-1_M4区一般照明3");
- result.add("1512D-2_备用");
- result.add("1513D-1_M4区一般动力1");
- result.add("1513D-2_备用");
- result.add("1514D-1_冷冻机房控制柜1");
- result.add("1514D-2_备用");
- result.add("1515D-1_M4区扶梯");
- result.add("1515D-2_备用");
- result.add("1515D-3_变电所用电(主)");
- result.add("1515D-4_电制冷水冷式冷水机组1");
- result.add("1515D-5_备用");
- result.add("1516D-1_M4区客梯1(常)");
- result.add("1516D-2_备用");
- result.add("1516D-3_M4区客梯2(备)");
- result.add("1516D-4_F塔楼电梯");
- result.add("1516D-5_公寓生活水泵房(常)");
- result.add("1516D-6_备用");
- result.add("1517D-1_M4区消防动力(备)");
- result.add("1517D-2_备用");
- result.add("1518D-1_M4区变电所(常)+8#AT");
- result.add("1518D-2_B楼消控室(常)");
- result.add("1518D-3_百货消防客梯(常)");
- result.add("1518D-4_M4区应急照明(常)");
- result.add("1518D-5_影院空调1(常)");
- result.add("1518D-6_影院空调2(备)");
- result.add("1519D-1_商业消控室(常)");
- result.add("1519D-2_影院空调3(常)");
- result.add("1519D-3_KTV 空调1(常)");
- result.add("1519D-4_KTV 空调2(备)");
- result.add("1519D-5_备用");
- result.add("1605D_低压进线柜");
- result.add("1607D_无功自动补偿电容柜");
- result.add("1610D-1_M4区一般照明2");
- result.add("1610D-2_备用");
- result.add("1611D-1_M4区一般照明4");
- result.add("1611D-2_备用");
- result.add("1612D-1_M4区一般动力2");
- result.add("1612D-2_备用");
- result.add("1613D-1_冷冻机房控制柜1");
- result.add("1613D-2_备用");
- result.add("1614D-1_变电所用电(备)");
- result.add("1614D-2_电制冷水冷式冷水机组2");
- result.add("1614D-3_LED屏(3F)");
- result.add("1614D-4_备用");
- result.add("1615D-1_M4区客梯1(备)");
- result.add("1615D-2_备用");
- result.add("1615D-3_M4区客梯2(常)");
- result.add("1615D-4_F塔M4TAT3");
- result.add("1615D-5_公寓生活水泵房(备)");
- result.add("1615D-6_备用");
- result.add("1616D-1_M4区消防动力(常)");
- result.add("1616D-2_备用");
- result.add("1617D-1_M4区变电所(备)");
- result.add("1617D-2_B楼消控室(备)");
- result.add("1617D-3_百货消防客梯(备)");
- result.add("1617D-4_M4区应急照明(备)");
- result.add("1617D-5_影院空调1(备)");
- result.add("1617D-6_影院空调2(常)");
- result.add("1618D-1_商业消控室(备)");
- result.add("1618D-2_影院空调3(备)");
- result.add("1618D-3_KTV 空调1(备)");
- result.add("1618D-4_KTV 空调2(常)");
- result.add("1618D-5_备用");
- result.add("2103D_低压进线柜");
- result.add("2104D_无功自动补偿电容柜");
- result.add("2107D-1_冰机2号");
- result.add("2107D-2_备用");
- result.add("2108D-1_冰机1号");
- result.add("2108D-2_变电所用电(主)");
- result.add("2109D-1_基载冷水机组");
- result.add("2109D-2_备用");
- result.add("2110D-1_发电机");
- result.add("2110D-2_市电");
- result.add("2111D-1_办公+商业冷冻机房控柜电源1");
- result.add("2111D-2_备用");
- result.add("2203D_低压进线柜");
- result.add("2204D_无功自动补偿电容柜");
- result.add("2207D-1_冰机3号");
- result.add("2207D-2_备用");
- result.add("2208D-1_冰机4号");
- result.add("2208D-2_变电所用电(主)");
- result.add("2209D-1_冷冻机房控柜电源2");
- result.add("2209D-2_备用");
- result.add("2110D_母联");
- result.add("1705D_低压进线柜");
- result.add("1706D_无功自动补偿电容柜");
- result.add("1707D_低压母联柜");
- result.add("1710D-1_一般照明1");
- result.add("1710D-2_备用");
- result.add("1711D-1_一般动力1");
- result.add("1711D-2_备用");
- result.add("1712D-1_扶梯");
- result.add("1712D-2_备用");
- result.add("1712D-3_变电所用电(主)");
- result.add("1713D-1_备用");
- result.add("1713D-2_预留泛光照明");
- result.add("1713D-3_商业1B3层水动力(备)");
- result.add("1713D-4_E塔楼客梯总电源(常)");
- result.add("1714D-1_消防动力1(常)");
- result.add("1714D-2_备用");
- result.add("1714D-3_M3乘客电梯2(备)");
- result.add("1715D-1_F-L117 E-JX-AT(客梯)");
- result.add("1715D-2_应急照明(备)");
- result.add("1715D-3_消防动力3(备)电梯");
- result.add("1715D-4_消防动力2(备)");
- result.add("1716D-1_M3区消防电梯(备)");
- result.add("1716D-2_商业1变电所(备)");
- result.add("1716D-3_备用");
- result.add("1716D-4_消防脑动力4(常)");
- result.add("1716D-5_E塔楼总消防动力(常)");
- result.add("1716D-6_备用");
- result.add("1717D-1_备用");
- result.add("1717D-2_E塔楼消防电梯总电源(常)");
- result.add("1718D-1_备用");
- result.add("1718D-2_E塔楼公共应急照明(备)");
- result.add("1718D-3_备用");
- result.add("1718D-4_备用");
- result.add("1718D-5_D塔楼F4插座");
- result.add("1805D_低压进线柜");
- result.add("1807D_无功自动补偿电容柜");
- result.add("1809D-1_一般照明2");
- result.add("1809D-2_备用");
- result.add("1810D-1_一般动力2");
- result.add("1810D-2_备用");
- result.add("1811D-1_E塔楼照明");
- result.add("1811D-2_备用");
- result.add("1811D-3_变电所用电(备)");
- result.add("1811D-4_备用");
- result.add("1811D-5_备用");
- result.add("1812D-1_备用");
- result.add("1812D-2_备用");
- result.add("1812D-3_商业1B3层水动力(常)");
- result.add("1812D-4_E塔楼客梯总电源(备)");
- result.add("1813D-1_消防动力1(备)");
- result.add("1813D-2_备用");
- result.add("1813D-3_M3乘客电梯2(常)");
- result.add("1814D-1_F-L217 E-JX-AT(客梯)");
- result.add("1814D-2_应急照明(常)");
- result.add("1814D-3_消防动力3(常)");
- result.add("1814D-4_消防动力2(常)");
- result.add("1815D-1_M3区消防电梯(常)");
- result.add("1815D-2_商业1变电所(常)");
- result.add("1815D-3_备用");
- result.add("1815D-4_消防动力4(备)");
- result.add("1815D-5_E塔楼消防动力(备)");
- result.add("1815D-6_备用");
- result.add("1816D-1_备用");
- result.add("1816D-2_E塔楼消防电梯总电源(备)");
- result.add("1817D-1_备用");
- result.add("1817D-2_E塔楼公共应急照明(常)");
- result.add("1817D-3_备用");
- result.add("1817D-4_备用");
- result.add("1817D-5_F4M2APXZ1 F-L 105 D塔楼");
- result.add("1405D_低压进线柜支路");
- result.add("1407D_无功自动补偿电容柜");
- result.add("1409D-1_一般照明2");
- result.add("1409D-2_备用");
- result.add("1410D-1_一般照明3");
- result.add("1410D-2_备用");
- result.add("1411D-1_配电所用电(备)");
- result.add("1411D-2_备用");
- result.add("1411D-3_备用");
- result.add("1411D-4_溜冰场制冷机房动力(备)");
- result.add("1412D-1_商业水泵房(备)");
- result.add("1412D-2_M1区乘客电梯(备)");
- result.add("1412D-3_B塔配电所用电");
- result.add("1412D-4_备用");
- result.add("1412D-5_备用");
- result.add("1413D-1_开闭所直流屏");
- result.add("1413D-2_M1区应急照明(备)");
- result.add("1413D-3_消防动力2(备)");
- result.add("1413D-4_消防动力3(备)");
- result.add("1413D-5_消防动力1(备)");
- result.add("1414D-1_开闭所照明(备)");
- result.add("1414D-2_开闭所直流屏(常)");
- result.add("1414D-3_商业冷冻机房变电所(备)");
- result.add("1414D-4_备用");
- result.add("1414D-5_超市");
- result.add("1305D_低压进线柜");
- result.add("1307D_无功自动补偿电容柜");
- result.add("1309D_低压母联柜");
- result.add("1310D-1_一般照明");
- result.add("1310D-2_备用");
- result.add("1311D-1_变电所用电(主)");
- result.add("1311D-2_扶梯");
- result.add("1311D-3_备用");
- result.add("1311D-4_溜冰场制冷机房动力(常)");
- result.add("1312D-1_商业水泵房(常)");
- result.add("1312D-2_M1区乘客电梯(常)");
- result.add("1312D-3_BDS-AT(6#客梯)");
- result.add("1312D-4_备用");
- result.add("1312D-5_B1M1-AP2");
- result.add("1313D-1_开闭所直流屏");
- result.add("1313D-2_M1区应急照明(常)");
- result.add("1313D-3_消防动力2(常)");
- result.add("1313D-4_消防动力3(常)");
- result.add("1313D-5_消防动力1(常)");
- result.add("1314D-1_开闭所照明(常)");
- result.add("1314D-2_开闭所直流屏(备)");
- result.add("1314D-3_商业冷冻机房变电所(常)");
- result.add("1314D-4_预留泛光照明");
- result.add("1314D-5_超市");
- result.add("1#直流屏");
- result.add("2#直流屏");
- result.add("1#进线总柜");
- result.add("1#出线柜");
- result.add("3#出线柜");
- result.add("5#出线柜");
- result.add("7#出线柜");
- result.add("母联断路器柜");
- result.add("2#进线总柜");
- result.add("2#出线柜");
- result.add("4#出线柜");
- result.add("6#出线柜");
- result.add("8#出线柜");
- result.add("1#进线总柜");
- result.add("1#出线柜");
- result.add("3#出线柜");
- result.add("5#出线柜");
- result.add("7#出线柜");
- result.add("母联断路器柜");
- result.add("2#进线总柜");
- result.add("2#出线柜");
- result.add("4#出线柜");
- result.add("6#出线柜");
- result.add("8#出线柜");
- result.add("1#高压进线柜");
- result.add("1#高压出线柜");
- result.add("母联断路器柜");
- result.add("2#高压进线柜");
- result.add("2#高压出线柜");
- result.add("1#高压进线柜");
- result.add("1#高压出线柜");
- result.add("母联断路器柜");
- result.add("2#高压进线柜");
- result.add("2#高压出线柜");
- result.add("1#高压进线柜");
- result.add("1#高压出线柜");
- result.add("母联断路器柜");
- result.add("2#高压进线柜");
- result.add("2#高压出线柜");
- result.add("1#高压进线柜");
- result.add("1#高压出线柜");
- result.add("母联断路器柜");
- result.add("2#高压进线柜");
- result.add("2#高压出线柜");
- result.add("1#高压出线柜");
- result.add("2#高压出线柜");
- return result;
- }
- public byte[] gbk2utf8(String chenese) {
- char c[] = chenese.toCharArray();
- byte[] fullByte = new byte[3 * c.length];
- for (int i = 0; i < c.length; i++) {
- int m = (int) c[i];
- String word = Integer.toBinaryString(m);
- // System.out.println(word);
- StringBuffer sb = new StringBuffer();
- int len = 16 - word.length();
- // 补零
- for (int j = 0; j < len; j++) {
- sb.append("0");
- }
- sb.append(word);
- sb.insert(0, "1110");
- sb.insert(8, "10");
- sb.insert(16, "10");
- // System.out.println(sb.toString());
- String s1 = sb.substring(0, 8);
- String s2 = sb.substring(8, 16);
- String s3 = sb.substring(16);
- byte b0 = Integer.valueOf(s1, 2).byteValue();
- byte b1 = Integer.valueOf(s2, 2).byteValue();
- byte b2 = Integer.valueOf(s3, 2).byteValue();
- byte[] bf = new byte[3];
- bf[0] = b0;
- fullByte[i * 3] = bf[0];
- bf[1] = b1;
- fullByte[i * 3 + 1] = bf[1];
- bf[2] = b2;
- fullByte[i * 3 + 2] = bf[2];
- }
- return fullByte;
- }
- }
|