示例#1
0
    def updateLineSite(self, openid, data):
        busline_id = int(data.busline_id)
        name_change = data.name_change.split(";")
        end_change = data.end_change.split(";")
        #名称修改

        for site_name in name_change:
            if site_name == "":
                continue
            site_id, name = site_name.split(":")
            site_id = int(site_id)
            db.update("Sites", where="id=$site_id", name=name, vars=locals())
        #序号变更
        for endchange in end_change:
            if endchange == "":
                continue
            seq, is_end = endchange.split(":")
            seq = int(seq)
            db.update("LineSites",
                      where="busline_id=$busline_id AND seq=$seq",
                      is_end=is_end,
                      vars=locals())

        sites = linedb.getSitesByLineid(busline_id)
        cfgPara = uTools.formatPostMsg({
            "result": "success",
            "msg": "busline config succeed!",
            "sites": sites
        })
        return cfgPara
示例#2
0
    def designLinePrice(self, openid, data):
        jdkSign = objWeixin.get_jdk_sign(self.url)
        busline_id = data.busline_id
        company_id = data.company_id
        #获取相关数据
        sites = linedb.getSitesByLineid(busline_id)
        prices = linedb.getLinePrice(busline_id)
        _ret = db.query(
            "SELECT * FROM BusLine WHERE id = {0}".format(busline_id))
        busline = _ret[0]
        line_name = busline.from_name + "-" + busline.to_name
        #结果拼装
        cfgPara = {
            "openid": openid,
            "sites": sites,
            "prices": prices,
            "line_name": line_name,
            "busline_id": busline_id,
            "company_id": company_id
        }

        fixPara = icfg.getFixPara(openid,
                                  busline_id=busline_id,
                                  company_id=company_id)
        _cfgPara = json.dumps(cfgPara, ensure_ascii=False)
        ret = self.render.design_line_price(_cfgPara, jdkSign, fixPara)
        return ret
示例#3
0
    def designLineSiteQQ(self, openid, data):
        jdkSign = objWeixin.get_jdk_sign(self.url)
        #对站点进行排序

        if data.has_key('busline_id'):  #已有的线路重新调整
            sites = linedb.getSitesByLineid(data.busline_id, "manual")
            busline = linedb.getBuslineByid(data.busline_id, format="string")
            linedb.orderLineSiteSeq(busline["id"])
        else:  #创建新的线路
            sites = {"manual": [], "auto": []}
            busline = {"id": -1, "from_name": "", "to_name": ""}
        user = userdb.getUserByOpenid(objWeixin.weixinName, openid)

        cfgPara = {
            "openid": openid,
            "sites": sites,
            "user": user,
            "busline": busline,
            "company_id": data.company_id
        }
        fixPara = icfg.getFixPara(openid,
                                  busline=busline,
                                  company_id=data.company_id)
        _cfgPara = json.dumps(cfgPara, ensure_ascii=False)
        ret = self.render.line_sites_qq(_cfgPara, jdkSign, fixPara)
        return ret
示例#4
0
    def getLineSite(self, openid, data):
        imei = data.imei

        busline = linedb.getBuslineByImei(imei)
        sites = linedb.getSitesByLineid(busline["id"], setting_type="manual")
        rows = sites["manual"]
        ret = uTools.formatPostMsg({"total": len(rows), "rows": rows})
        return ret
示例#5
0
    def getMineTrackMsg(self, openid, data):
        #jdkSign = objWeixin.get_jdk_sign(self.url)
        company_id = data.company_id
        jdkSign = {}
        dev = devdb.getDevice(data.imei)

        if dev != "":
            #查询设备位置信息
            arm = historyTrackMgr.getMineTrack(dev['imei'])
            _ret = db.query(
                "SELECT * FROM BusLine WHERE busgroupid={0}".format(
                    dev["groupid"]))
            busline = _ret[0]

            sites = linedb.getSitesByLineid(busline.id, "manual")
            cfgPara = {
                "pt":
                arm,
                'openid':
                openid,
                'dev':
                dev,
                'busline_id':
                busline.id,
                'sites':
                sites["manual"],
                'url':
                "gxsaiwei/m/bustrack?act=MINE_TRACK&openid={0}&imei=".format(
                    openid),
                'imei':
                dev['imei'],
                "company_id":
                company_id,
            }
        else:
            cfgPara = {
                "pt": "",
                'openid': openid,
                'dev': "",
                'url': "#",
                'imei': "",
                'sites': [],
                'busline_id': -1,
                "company_id": company_id,
            }
        if web.ctx.method == 'GET':
            jdkSign = objWeixin.get_jdk_sign(self.url)
            sharePara = tradeObj.genPreSharePara("share_view", openid,
                                                 cfgPara['imei'])
            _cfgPara = json.dumps(cfgPara, ensure_ascii=False)
            ret = self.render.mytrackqq_v2(_cfgPara, jdkSign, sharePara)
            #ret = self.render.mytrackqq_v1(cfgPara,_cfgPara)
        else:
            ret = uTools.formatPostMsg(cfgPara)
        return ret
示例#6
0
    def setLineSite(self, openid, data):
        busline_id = data.busline_id
        _ret = db.query(
            "SELECT MAX(seq)  AS max_seq FROM LineSites WHERE busline_id = {0}"
            .format(busline_id))
        max_seq = _ret[0].max_seq
        changeType = data.changeType
        #新加入的站点
        if changeType == "add-new":
            #依据微信上报信息获取位置信息
            _ret = db.query(
                "SELECT * FROM Customer WHERE openid='{0}'".format(openid))
            user = _ret[0]
            site_id = db.insert("Sites",
                                gpsLat=user.gpsLat,
                                gpsLng=user.gpsLng,
                                baiduLat=user.baiduLat,
                                baiduLng=user.baiduLng,
                                qqLat=user.qqLat,
                                qqLng=user.qqLng,
                                name=data.name,
                                address=user.address,
                                setting_type="manual")
            db.insert("LineSites",
                      site_id=site_id,
                      seq=max_seq + 1,
                      busline_id=busline_id)

        else:
            _ret = db.query(
                "SELECT * AS sum FROM LineSites WHERE busline_id = {0} AND seq={1}"
                .format(busline_id, data.old_seq))
            linesite = _ret[0]
            site_id = linesite.site_id
            db.update("Sites",
                      where="id=$site_id",
                      name=data.name,
                      vars=locals())
            db.update("LineSites",
                      where="id=$site_id",
                      vars=locals(),
                      seq=data.new_seq)
        linedb.orderLineSiteSeq(busline_id)
        sites = linedb.getSitesByLineid(busline_id)
        cfgPara = uTools.formatPostMsg({
            "result": "success",
            "msg": "busline config succeed!",
            "sites": sites
        })
        return cfgPara
示例#7
0
    def addLineSite(self, openid, data):
        imei = data.imei
        hispos_id = long(data.hispos_id)
        busline = linedb.getBuslineByImei(imei)
        swtool.addBuslineSite(busline["id"],
                              hispos_id,
                              site_type="customer_site",
                              setting_type="manual")

        sites = linedb.getSitesByLineid(busline["id"], setting_type="manual")
        rows = sites["manual"]
        ret = uTools.formatPostMsg({
            "result": "success",
            "total": len(rows),
            "rows": rows
        })
        return ret
示例#8
0
    def delLineSite(self, openid, data):
        busline_id = data.busline_id
        site_seq = data.site_seq
        #获取站点信息
        #print("SELECT * FROM LineSites WHERE busline_id={0} AND seq={1}".format(busline_id,data.site_seq))
        _ret = db.query(
            "SELECT * FROM LineSites WHERE busline_id={0} AND seq={1}".format(
                busline_id, site_seq))
        linesite = _ret[0]

        #删除LineSite的站点
        db.query("DELETE FROM LineSites WHERE id={0}".format(linesite.id))
        #删除Sites站点信息
        db.query("DELETE FROM Sites WHERE id={0}".format(linesite.site_id))
        linedb.orderLineSiteSeq(busline_id)
        sites = linedb.getSitesByLineid(busline_id)
        cfgPara = uTools.formatPostMsg({
            "result": "success",
            "msg": "busline delete succeed!",
            "sites": sites
        })
        return cfgPara
示例#9
0
    def setLineSite2(self, openid, data):
        busline_id = data.busline_id
        _ret = db.query(
            "SELECT COUNT(*) AS sum FROM LineSites WHERE busline_id = {0}".
            format(busline_id))
        site_sum = _ret[0]
        #新加入的站点
        if (site_sum < data.old_seq):
            changeType = "add-new"  #缺省是增加新站点
        else:
            changeType = "renew-old"
            _ret = db.query(
                "SELECT * AS sum FROM LineSites WHERE busline_id = {0} AND seq={1}"
                .format(busline_id, data.old_seq))
            linesite = _ret[0]

        #调整现有站点顺序
        if (data.new_seq < data.old_seq):  #站点向前调整顺序
            changeSites = db.query(
                "SELECT * FROM LineSites WHERE seq>={0} AND seq<{1}".format(
                    data.new_seq, data.old_seq))
            for site in changeSites:
                db.update("LineSites",
                          where="id=$site.id",
                          seq=site.seq + 1,
                          vars=locals())
        else:
            changeSites = db.query(
                "SELECT * FROM LineSites WHERE seq>{0} AND seq<={1}".format(
                    data.old_seq, data.new_seq))
            for site in changeSites:
                db.update("LineSites",
                          where="id=$site.id",
                          seq=site.seq - 1,
                          vars=locals())

        if changeType == "add-new":
            #依据微信上报信息获取位置信息
            _ret = db.query(
                "SELECT * FROM Customer WHERE openid='{0}'".format(openid))
            user = _ret[0]
            site_id = db.insert("Sites",
                                gpsLat=user.gpsLat,
                                gpsLng=user.gpsLng,
                                baiduLat=user.baiduLat,
                                baiduLng=user.baiduLng,
                                qqLat=user.qqLat,
                                qqLng=user.qqLng,
                                name=data.name,
                                address=user.address,
                                setting_type="manual")
            db.insert("LineSites",
                      site_id=site_id,
                      seq=data.new_seq,
                      busline_id=busline_id)
        else:
            site_id = linesite.site_id
            db.update("Sites",
                      where="id=$site_id",
                      name=data.name,
                      vars=locals())
            db.update("LineSites", where="id=$linesite,id", seq=data.new_seq)
        sites = linedb.getSitesByLineid(busline_id)
        cfgPara = uTools.formatPostMsg({
            "result": "success",
            "msg": "busline config succeed!",
            "sites": sites
        })
        return cfgPara