Ejemplo n.º 1
0
def performance_dataSource():
    try:
        if request.method == "POST":
            raise Exception("method must be get")
        retrieve_list = ["performance_id", "corporation_id", "user_id",
                         "hr_id", "value", "description", "registerdate", "department", "post"]
        querylist = Performance.get_obj(retrieve_list)
        msg = db.session.query(*querylist, Person.user_id, Person.name).\
            filter(Performance.user_id == Person.user_id)
        return_msg = []

        return_list = ["performance_id", "corporation_id", "user_id",
                         "hr_id", "value", "description", "registerdate", "department", "post", "name"]
        for line in msg:
            line = list(line)
            line[6] = line[6].strftime('%Y-%m-%d')
            del line[9]
            temp = zip(return_list, line)
            return_msg.append(dict(temp))

        return dict(
            status=1,
            message="success",
            data=return_msg
        )
    except Exception as e:
        return dict(
            status=0,
            message=str(e),
            data="none"
        )
Ejemplo n.º 2
0
def newdataSource_dataSource():
    try:
        if request.method == "POST":
            raise Exception("method must be get")

        corporation_id = request.values.get("corporation_id")
        if not corporation_id:
            raise Exception("corporation_id must not be empty")

        retrieve_list = ["performance_id", "corporation_id", "user_id",
                         "hr_id", "value", "description", "registerdate", "department", "post"]
        querylist = Performance.get_obj(retrieve_list)
        msg = db.session.query(*querylist, Person.user_id, Person.name).\
            filter(Performance.corporation_id == corporation_id).\
            filter(Performance.user_id == Person.user_id)

        tempmessage = dict()
        for line in msg:
            user_id = line[retrieve_list.index("user_id")]
            if tempmessage.get(user_id, 0) == 0:
                tempmessage[user_id] = line
            else:
                history_date = tempmessage[user_id][retrieve_list.index("registerdate")]
                new_date = line[retrieve_list.index("registerdate")]
                if new_date > history_date:
                    tempmessage[user_id] = line

        return_msg = []
        return_list = ["performance_id", "corporation_id", "user_id",
                       "hr_id", "value", "description", "registerdate", "department", "post", "name"]

        for line in tempmessage.values():
            line = list(line)
            line[6] = line[6].strftime('%Y-%m-%d')
            del line[9]
            temp = zip(return_list, line)
            return_msg.append(dict(temp))

        return dict(
            status=1,
            message="success",
            data=return_msg
        )
    except Exception as e:
        return dict(
            status=0,
            message=str(e),
            data="none"
        )
Ejemplo n.º 3
0
def jixiaoCheck():
    try:
        if request.method == "GET":
            raise Exception("method must be post")

        user_id = request.form.get('uid')

        if not all([user_id]):
            raise Exception("uid must not be empty")

        retrieve_list = [
            "performance_id", "corporation_id", "user_id", "hr_id", "value",
            "description", "registerdate", "department", "post"
        ]
        querylist = Performance.get_obj(retrieve_list)
        msg = db.session.query(*querylist, Hr.hr_id, Hr.name,
                               Corporation.corporation_id, Corporation.name). \
            filter(Performance.user_id == user_id). \
            filter(Performance.hr_id == Hr.hr_id). \
            filter(Performance.corporation_id == Corporation.corporation_id). \
            order_by(Performance.registerdate.desc())

        retrieve_list = [
            "performance_id", "corporation_id", "user_id", "hr_id", "value",
            "description", "registerdate", "department", "post", "hr_name",
            "corporation_id"
        ]

        return_msg = []
        for line in msg:
            line = list(line)
            line[6] = line[6].strftime('%Y-%m-%d')
            del line[9]
            del line[10]
            temp = zip(retrieve_list, line)
            return_msg.append(dict(temp))
        return dict(status=1, message="success", data=return_msg)
    except Exception as e:
        return dict(status=0, message=str(e), data="none")