Ejemplo n.º 1
0
    def get(self):
        substid = self.get_argument('substid')
        subst = manage.get_subst_info(substid = substid)
        eu = manage.get_eu_info(substid)

        EVENT = []
        for e in eu:
            euaddr = e.get('euaddr')
            euaddr = '1' * 24
            fields = ['euaddr', 'HappenTime', 'Note', 'Content', 'DealWith']
            sql = "select {} from JQR_EVENT_ERC where euaddr='{}' order by HappenTime DESC".format(','.join(fields), euaddr)
            data, t = mysql_util.m_query(sql, fields, findall=True)

            for d in data:
                d['name'] = e.get('name')
                d['HappenTime'] = str(d['HappenTime'])

            EVENT.extend(data)

        fields = ['pointid', 'HappenTime', 'Note', 'Content']
        sql = "select {} from YW_EVENT_ERC where substid='{}' and DealWith=0 order by HappenTime DESC".format(','.join(fields), substid)
        data, t = mysql_util.m_query(sql, fields, findall=True)

        data = [{'pointid':'1', 'HappenTime': '2', 'Note': '3', 'Content':'4'}]

        for d in data:
            d['HappenTime'] = str(d['HappenTime'])

        EVENT.extend(data)

        self.render("erc_history.html", data = EVENT)
Ejemplo n.º 2
0
    def get(self):
        substid = self.get_argument('substid')
        subst = manage.get_subst_info(substid = substid)
        eu = manage.get_eu_info(substid)

        jqr_event = []
        for e in eu:
            euaddr = e.get('euaddr')
            fields = ['ERC_ID', 'euaddr', 'HappenTime', 'Note', 'Content']
            sql = "select {} from JQR_EVENT_ERC where euaddr='{}' and DealWith=0 order by HappenTime DESC".format(','.join(fields), euaddr)
            data, t = mysql_util.m_query(sql, fields, findall=True)
            if not data:
                data = [{'ERC_ID': 1, 'euaddr': '0000000100000001', 'HappenTime': 'HappenTime', 'Note': 'Note', 'Content': 'Content'},
                        {'ERC_ID': 2, 'euaddr': '0000000100000001', 'HappenTime': 'HappenTime', 'Note': 'Note', 'Content': 'Content'}]

            for d in data:
                d['name'] = e.get('name')
                d['HappenTime'] = str(d.get('HappenTime'))

            jqr_event.extend(data)

        fields = ['ERC_ID', 'PointID', 'HappenTime', 'Note', 'Content']
        sql = "select {} from YW_EVENT_ERC where substid='{}' and DealWith=0 order by HappenTime DESC".format(','.join(fields), substid)
        yw_event, t = mysql_util.m_query(sql, fields, findall=True)

        if not yw_event:
            yw_event = [{'PointID':'1', 'HappenTime': '2', 'Note': '5', 'Content':'4'}]

        for d in yw_event:
            d['HappenTime'] = str(d['HappenTime'])

        self.write(dict(status = True, jqr_event = jqr_event, yw_event = yw_event))
Ejemplo n.º 3
0
    def get(self):
        bind_args = dict((k, v[-1]) for k, v in self.request.arguments.items())
        substid = self.get_argument('substid')
        euaddr = self.get_argument('euaddr', None)

        eu = get_eu_info(substid)
        if not euaddr and eu:
            euaddr = eu[0].get('euaddr')

        # 地图点信息
        fields = ['mapid', 'mapnum', 'substid', 'mapx', 'mapy', 'phyid', 'name', 'used']
        MapInfo, p = mysql_util.m_query("select {} from {}".format(','.join(fields),T_MAPINFO),fields,findall=True)

        # 测量点信息
        fields = ['pointid', 'pointnum', 'PAttribute', 'mapid', 'eqid', 'dataid', 'name', 'used']
        MeasuringPoint, p = mysql_util.m_query("select {} from {}".format(','.join(fields),T_MEASURING_POINT_INFO),fields,findall=True)

        #方案
        fields = ['SchemeID', 'SchemeNum', 'SchemePro', 'SchemeCycle', 'CycleUnit', 'PointNum', 'SchemeUsed']
        Scheme, p = mysql_util.m_query("select {} from {} where SubstID='{}'".format(','.join(fields),'Scheme',bind_args.get('substid')),fields,findall=True)

        #计划
        fields = ['PlanID', 'PlanNum', 'SchemeNum', 'PlanPro', 'PlanStartTime', 'PlanEndTime', 'PlanUsed']
        Plan, p = mysql_util.m_query("select {} from {} where SubstID='{}'".format(','.join(fields),'Plan',bind_args.get('substid')),fields,findall=True)

        self.render('params.html', eu = eu,MapInfo=MapInfo,MeasuringPoint=MeasuringPoint,Scheme=Scheme,Plan=Plan,substid=substid, euaddr=euaddr)
Ejemplo n.º 4
0
def get_map_info_by_substid(substid):
    fields_s = ['mapid', 'mapnum', 'mapx', 'mapy', 'phyid', 'name', 'used', 'NearMapIDs']

    sql = "select {}".format(','.join(fields_s))
    sql += " from {} where substid = '{}'"

    data,page = mysql_util.m_query(sql.format(T_MAPINFO,substid), fields_s, findall = True)

    for d in data:
        """
            8   mapx
            7   x

            28      17
            mapy    y
        """
        width_map = 800
        height_map = 600
        mapx = d.get('mapx')
        mapy = d.get('mapy')
        d['x'] = float(mapx) / 100 * 80 + 1
        d['y'] = float(mapy) / 100 * 60 + 1
        NearMapIDs = d.get('NearMapIDs') or json.dumps([])
        d['NearMapIDs'] = json.loads(NearMapIDs)

    map_data = dict((d.get('mapnum'), d) for d in data)

    return data, map_data
Ejemplo n.º 5
0
    def get(self):
        pointid = self.get_argument("pointid")
        start = self.get_argument("start")
        end = self.get_argument("end")

        pointids = pointid.split(",")
        data = []
        for pointid in pointids:
            fields = [
                "PointID",
                "CollectTime",
                "ResultData",
                "DataID",
                "PointNum",
                "MDBIndex",
                "MDBReferIndex",
                "MDBConfigIndex",
            ]
            sql = "select {} from MeasuCalculationData where pointid='{}' and CollectTime>='{}' and CollectTime<='{}'".format(
                ",".join(fields), pointid, start, end
            )
            print sql
            r, page = mysql_util.m_query(sql, fields, findall=True)

            # 造数据
            import random
            import time

            r = [
                dict(
                    PointNum=1,
                    DataID="1",
                    ResultData=random.random(),
                    CollectTime=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() + i * 60)),
                )
                for i in range(50)
            ]
            ######

            if r:
                DataID = str(r[0].get("DataID", ""))
                PointNum = r[0].get("PointNum")
                x = [item.get("CollectTime") for item in r]
                y = [item.get("ResultData") for item in r]
                data.append(
                    {
                        "x": x,
                        "y": y,
                        "name": "{} {} 单位({})".format(
                            PointNum,
                            MeasuringData_Map.get(DataID, {}).get("name"),
                            MeasuringData_Map.get(DataID, {}).get("unit", "无"),
                        ),
                        "type": "scatter",
                        "mode": "lines+markers",
                    }
                )

        self.write(dict(status=True, data=data))
Ejemplo n.º 6
0
def get_map_info(mapid=None):
    fields = ['mapid', 'name', 'substid', 'mapnum']
    if not mapid:
        sql = "select {} from {}".format(','.join(fields),T_MAPINFO)
        data,p = mysql_util.m_query(sql, fields,findall=True)
    else:
        sql = "select {} from {} where mapid='{}'".format(','.join(fields),T_MAPINFO,mapid)
        data = mysql_util.m_query_one(sql, fields)

    return data
Ejemplo n.º 7
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        fields_s = ['datatid', 'name', 'used']

        sql = "select {},{},{}".format(*fields_s)
        sql += " from {}"

        data,page = mysql_util.m_query(sql.format(T_DATATYPE), fields_s, **kwargs)

        self.render("manageDataType.html", data = data, page = page)
Ejemplo n.º 8
0
def get_eq_info(substid):
    fields_s = ['eqid', 'eqnum', 'eqareaid', 'eqtype', 'eq618id', 'name', 'eqattribute', 'note', 'used', 'substid', 'name']
    fields_d = ['eqid', 'eqnum', 'eqareaid', 'eqtype', 'eq618id', 'name', 'eqattribute', 'note', 'used', 'substid', 'subst_name']

    sql = "select t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
    sql += " from {} t1, {} t2 where t1.substid = t2.substid and t1.substid='{}'"

    data,page = mysql_util.m_query(sql.format(T_MEASURINGDEVICE, T_SUBST_INFO,substid), fields_d, findall=True)

    return data
Ejemplo n.º 9
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        fields_s = ['dataid', 'unit', 'dyprecision', 'name', 'used', 'datatid', 'name']
        fields_d = ['dataid', 'unit', 'dyprecision', 'name', 'used', 'datatid', 'datatype_name']

        sql = "select t.{},t.{},t.{},t.{},t.{},t1.{},t1.{}".format(*fields_s)
        sql += " from {} t, {} t1 where t.datatid = t1.datatid"

        data,page = mysql_util.m_query(sql.format(T_MEASURINGDATA, T_DATATYPE), fields_d, **kwargs)
        datatype = get_datatype()

        self.render("manageMeasuringData.html", data = data, page = page, datatype = datatype)
Ejemplo n.º 10
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        fields_s = ['euid', 'euaddr', 'name', 'Protocol','ProtocolVersion', 'used', 'substid', 'name']
        fields_d = ['euid', 'euaddr', 'name', 'Protocol','ProtocolVersion', 'used', 'substid', 'subst_name']

        sql = "select t.{},t.{},t.{},t.{},t.{},t.{},t1.{},t1.{}".format(*fields_s)
        sql += " from {} t, {} t1 where t.substid = t1.substid"

        data,page = mysql_util.m_query(sql.format(T_EU_INFO, T_SUBST_INFO), fields_d, **kwargs)
        subst_info = get_subst_info()

        self.render("manageEu_Info.html", data = data, page = page, subst_info = subst_info,fields = fields_d)
Ejemplo n.º 11
0
    def get(self):
        substid = self.get_argument('substid')

        fields_s = ['mapid', 'mapnum', 'mapx', 'mapy', 'phyid', 'name', 'used']

        sql = "select {},{},{},{},{},{},{}".format(*fields_s)
        sql += " from {} where substid = '{}'"

        data,page = mysql_util.m_query(sql.format(T_MAPINFO,substid), fields_s, findall = True)

        subst_info = get_subst_info(substid = substid)

        self.render("MapInfoPoint.html",data = data, substid = substid, subst_info = subst_info)
Ejemplo n.º 12
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        substid = self.get_argument('substid')
        fields_s = ['eqid', 'eqnum', 'eqareaid', 'eqtype', 'eq618id', 'name', 'eqattribute', 'note', 'used', 'substid', 'name']
        fields_d = ['eqid', 'eqnum', 'eqareaid', 'eqtype', 'eq618id', 'name', 'eqattribute', 'note', 'used', 'substid', 'subst_name']

        sql = "select t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
        sql += " from {} t1, {} t2 where t1.substid = t2.substid and t1.substid='{}'"

        data,page = mysql_util.m_query(sql.format(T_MEASURINGDEVICE, T_SUBST_INFO,substid), fields_d, **kwargs)
        subst_info = get_subst_info()

        self.render("manageMeasuringDevice.html", data = data, page = page, subst_info = subst_info, bind_args = kwargs)
Ejemplo n.º 13
0
def get_subst_info(uid = None, substid = None):
    fields = ['substid', 'name', 'fid', 'location_name', 'location_lat', 'location_lng']
    if not substid:
        sql = "select {} from {}"
        if uid:
            substid = mongo_util.m_find_one(T_PASSPORT,_id=ObjectId(uid)).get('substid') or ['']
            substid = ["'" + item + "'" for item in substid]
            sql += " where substid IN ({})".format(','.join(substid))
        data,p = mysql_util.m_query(sql.format(','.join(fields), T_SUBST_INFO), fields, findall=True)
    else:
        sql = "select {} from {} where substid='{}'"
        data = mysql_util.m_query_one(sql.format(','.join(fields), T_SUBST_INFO, substid), fields)

    return data
Ejemplo n.º 14
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        substid = self.get_argument('substid')
        bind_args = kwargs
        fields_s = ['mapid', 'mapnum', 'mapx', 'mapy', 'phyid', 'name', 'used', 'substid', 'name']
        fields_d = ['mapid', 'mapnum', 'mapx', 'mapy', 'phyid', 'name', 'used', 'substid', 'subst_name']

        sql = "select t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
        sql += " from {} t1, {} t2 where t1.substid = t2.substid and t1.substid='{}'"

        data,page = mysql_util.m_query(sql.format(T_MAPINFO, T_SUBST_INFO, substid), fields_d, findall=True, **kwargs)
        subst_info = get_subst_info()

        self.render("manageMapInfo.html", data = data, page = page, subst_info = subst_info, bind_args = bind_args)
Ejemplo n.º 15
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        substid = self.get_argument('substid')
        bind_args = kwargs
        fields_s = ['SchemeID', 'SchemeNum', 'SchemePro', 'SchemeCycle', 'CycleUnit', 'PointNum', 'SchemeUsed', 'Note', 'substid', 'name']
        fields_d = ['SchemeID', 'SchemeNum', 'SchemePro', 'SchemeCycle', 'CycleUnit', 'PointNum', 'SchemeUsed', 'Note', 'substid', 'subst_name']

        sql = "select t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
        sql += " from {} t1, {} t2 where t1.substid = t2.substid and t1.substid='{}'"

        data,page = mysql_util.m_query(sql.format('Scheme', T_SUBST_INFO, substid), fields_d, **kwargs)
        subst_info = get_subst_info()

        self.render("manageScheme.html", data = data, page = page, subst_info = subst_info, bind_args = bind_args, fields = fields_d)
Ejemplo n.º 16
0
    def get(self):
        substid = self.get_argument('substid')
        subst = manage.get_subst_info(substid = substid)
        m, mapinfo = manage.get_map_info_by_substid(substid)
        eu = manage.get_eu_info(substid)

        data = []
        for e in eu:
            euaddr = e.get('euaddr')
            fields = ['EuAddr', 'CollectTime', 'SchemeNum', 'PlanNum', 'MeasuNum', 'JqrTime', 'BatteryCapat', 'BatteryVar', 'JqrConMode', 'LocalTemp', 'LocalHum', 'LocalWind', 'SysTemp', 'JqrSpeed', 'CurrentPoint', 'CurrentPointLog', 'FrontPoint', 'FrontPointLog']

            sql = "select {} from TermRealTimeShowData where euaddr='{}'".format(','.join(fields), euaddr)
            d, t = mysql_util.m_query(sql, fields, findall=True)
            for _d in d:
                _d['name'] = e.get('name')
                _d['JqrTime'] = str(_d.get('JqrTime'))
                _d['CollectTime'] = str(_d.get('CollectTime'))
            data.extend(d)

        self.write(dict(status = True, data = data, mapinfo = mapinfo))
Ejemplo n.º 17
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        view = kwargs.pop('view', None)

        substid = self.get_argument('substid')
        EqAreaID = self.get_argument('EqAreaID', None)
        EqType = self.get_argument('EqType', None)
        PatrolType = self.get_argument('PatrolType', None)

        fields_s = ['pointid', 'pointnum', 'PAttribute', 'name', 'dataid', 'patroltype', 'RigPrePoint', 'LefPrePoint', 'PointMaxValue', 'PointMinValue', 'PointNormalValue', 'used', 'mapid', 'name', 'eqid', 'name']
        fields_d = ['pointid', 'pointnum', 'PAttribute', 'name', 'dataid', 'patroltype', 'RigPrePoint', 'LefPrePoint','PointMaxValue', 'PointMinValue', 'PointNormalValue', 'used', 'mapid', 'mapname', 'eqid', 'eqname']


        sql = "select t.{},t.{},t.{},t.{},t.{},t.{},t.{},t.{},t.{},t.{},t.{},t.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
        sql += " from {} t left join {} t1 on t.mapid=t1.mapid left join {} t2 on t.eqid = t2.eqid"
        sql += " where t.substid='{}'"

        if EqAreaID:
            eq_info = manage.get_eq_info(substid)
            eqid = ["'" + item.get('eqid') + "'" for item in eq_info if item.get('eqareaid') == EqAreaID] or ['EqAreaID']
            sql += " and t.eqid in ({})".format(','.join(eqid))

        if EqType:
            eq_info = manage.get_eq_info(substid)
            eqid = ["'" + item.get('eqid') + "'" for item in eq_info if item.get('eqtype') == int(EqType)] or ['EqType']
            sql += " and t.eqid in ({})".format(','.join(eqid))


        if PatrolType: sql += " and t.patroltype="+PatrolType

        data,page = mysql_util.m_query(sql.format(T_MEASURING_POINT_INFO, T_MAPINFO, T_MEASURINGDEVICE, substid), fields_d, **kwargs)

        map_info, map_data = get_map_info_by_substid(substid)
        eq_info = get_eq_info(substid)

        if view == 'assist':
            self.render("manageMeasuring_Point_Info_assist.html", data = data, page = page, map_info = map_info, eq_info = eq_info,
                    fields = fields_d, bind_args = kwargs, view = 'assist')
        else:
            self.render("manageMeasuring_Point_Info.html", data = data, page = page, map_info = map_info, eq_info = eq_info,
                    fields = fields_d, bind_args = kwargs)
Ejemplo n.º 18
0
    def get(self):
        kwargs = dict((k, v[-1]) for k, v in self.request.arguments.items())
        substid = self.get_argument('substid')
        bind_args = kwargs
        fields_s = ['PlanID', 'PlanNum', 'SchemeNum', 'PlanPro', 'PlanStartTime', 'PlanEndTime', 'PlanUsed', 'substid', 'name']
        fields_d = ['PlanID', 'PlanNum', 'SchemeNum', 'PlanPro', 'PlanStartTime', 'PlanEndTime', 'PlanUsed', 'substid', 'subst_name']

        sql = "select t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
        sql += " from {} t1, {} t2 where t1.substid = t2.substid and t1.substid='{}'"

        data,page = mysql_util.m_query(sql.format('Plan', T_SUBST_INFO, substid), fields_d, **kwargs)
        for d in data:
            PlanStartTime = d.get('PlanStartTime')
            PlanEndTime = d.get('PlanEndTime')
            if PlanStartTime:
                d['PlanStartTime'] = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.mktime(time.strptime(PlanStartTime, "%S%M%H%d%m%y"))))
            if PlanEndTime:
                d['PlanEndTime'] = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.mktime(time.strptime(PlanEndTime, "%S%M%H%d%m%y"))))
        subst_info = get_subst_info()

        self.render("managePlan.html", data = data, page = page, subst_info = subst_info, bind_args = bind_args, fields = fields_d)
Ejemplo n.º 19
0
Archivo: index.py Proyecto: 9wfox/robot
    def get(self):
        substid = self.get_argument('substid')
        fields_s = ['PlanID', 'PlanNum', 'SchemeNum', 'PlanPro', 'PlanStartTime', 'PlanEndTime', 'PlanUsed', 'substid', 'name']
        fields_d = ['PlanID', 'PlanNum', 'SchemeNum', 'PlanPro', 'PlanStartTime', 'PlanEndTime', 'PlanUsed', 'substid', 'subst_name']

        sql = "select t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t1.{},t2.{},t2.{}".format(*fields_s)
        sql += " from {} t1, {} t2 where t1.substid = t2.substid and t1.substid='{}'"

        data,page = mysql_util.m_query(sql.format('Plan', T_SUBST_INFO, substid), fields_d)
        result = []
        for d in data:
            PlanStartTime = d.get('PlanStartTime')
            PlanEndTime = d.get('PlanEndTime')
            if PlanStartTime:
                d['PlanStartTime'] = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.mktime(time.strptime(PlanStartTime, "%S%M%H%d%m%y"))))
            if PlanEndTime:
                d['PlanEndTime'] = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.mktime(time.strptime(PlanEndTime, "%S%M%H%d%m%y"))))

            result.append({'title': '计划{}号, 执行方案号:{}'.format(d.get('PlanNum'), d.get('SchemeNum')),
                'start': d.get('PlanStartTime'), 'end': d.get('PlanEndTime'), 'PlanID': d.get('PlanID'), 'color': '#1abc9c'})

            result.append({'title': '已检', 'start': d.get('PlanStartTime'), 'color': '#428bca'})

        self.write(json.dumps(result))
Ejemplo n.º 20
0
def get_measuring_point(substid):
    fields = ['pointid', 'pointnum', 'patroltype', 'eqid','name']
    sql = "select {} from {} where substid = '{}'"
    data,t = mysql_util.m_query(sql.format(','.join(fields), T_MEASURING_POINT_INFO, substid), fields,findall=True)
    return data
Ejemplo n.º 21
0
def get_datatype():
    sql = "select datatid, name, used from {}"
    data,p = mysql_util.m_query(sql.format(T_DATATYPE), ['datatid', 'name', 'used'],findall=True)
    return data
Ejemplo n.º 22
0
def get_eu_info(substid):
    fields = ['euid', 'euaddr', 'name']
    sql = "select {} from {} where substid = '{}'"
    eu,t = mysql_util.m_query(sql.format(','.join(fields), T_EU_INFO, substid), fields,findall=True)

    return eu
Ejemplo n.º 23
0
def get_data_info():
    sql = "select dataid, name from {}"
    data,p = mysql_util.m_query(sql.format(T_MEASURINGDATA), ['dataid', 'name'],findall=True)
    return data