Пример #1
0
def delete_factor_appraisal(args):
    try:
        lock.acquire()
        ret = {}
        error_message = None
        if args['data'] != None:
            if args['data'].has_key('job_w_code'):
                if args['data'].has_key('rec_id'):
                    ret = JobWorking.delete_evaluation_factor(args)
                    lock.release()
                    return ret
                else:
                    error_message = "parameter 'rec_id' is not exist"
            else:
                error_message = "parameter 'job_w_code' is not exist"

            lock.release()
            return dict(error=error_message)
        else:
            error_message = "request parameter is not exist"

        lock.release()
        return dict(error=error_message)
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #2
0
def update_kpi(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            collection = common.get_collection('HCSLS_JobWorking')
            if args['data']['kpi'].has_key('rec_id'):
                check_exist = collection.find_one({
                    "job_w_code":
                    args['data']['job_w_code'],
                    "kpi": {
                        "$elemMatch": {
                            "rec_id": args['data']['kpi']["rec_id"]
                        }
                    }
                })
                if check_exist != None:
                    kpi = set_dict_update_kpi(args['data']['kpi'])
                    ret = JobWorking.update_job_kpi(args, kpi)

            lock.release()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #3
0
def update_factor_appraisal(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            collection = common.get_collection('HCSLS_JobWorking')
            if args['data']['factor_appraisal'].has_key('rec_id'):
                check_exist = collection.find_one({
                    "job_w_code":
                    args['data']['job_w_code'],
                    "factor_appraisal": {
                        "$elemMatch": {
                            "rec_id":
                            args['data']['factor_appraisal']["rec_id"]
                        }
                    }
                })
                if check_exist != None:
                    factor = set_dict_update_factor_appraisal(
                        args['data']['factor_appraisal'])
                    if (factor.has_key('factor_code')):
                        ret = JobWorking.update_evaluation_factor(args, factor)
                    else:
                        return dict(
                            error=dict(fields=['factor_code'], code="missing"))

            lock.release()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #4
0
def insert_kpi(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            if not args['data']['kpi'].has_key('rec_id'):
                if args['data'].has_key('job_w_code'):
                    kpi = set_dict_insert_kpi(args['data']['kpi'])
                    if (kpi.has_key('task_name')):
                        ret = JobWorking.insert_kpi(args, kpi)
                    else:
                        return dict(
                            error=dict(fields=['task_name'], code="missing"))
                else:
                    lock.release()
                    return dict(
                        error="request parameter job_w_code is not exist")

            lock.release()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #5
0
def update_task(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            collection = common.get_collection('HCSLS_JobWorking')
            if args['data']['task'].has_key('rec_id'):
                check_exist = collection.find_one({
                    "job_w_code":
                    args['data']['job_w_code'],
                    "task": {
                        "$elemMatch": {
                            "rec_id": args['data']['task']["rec_id"]
                        }
                    }
                })
                if check_exist != None:
                    task = set_dict_update_task(args['data']['task'])
                    if (task.has_key('task_name')):
                        ret = JobWorking.update_job_description(args, task)
                    else:
                        return dict(
                            error=dict(fields=['task_name'], code="missing"))

            lock.release()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #6
0
def get_job_description(args):
    try:
        if args['data'].has_key('job_w_code'):
            return JobWorking.get_job_description_by_job_working_code(
                args['data']['job_w_code']).get_item()

        return None
    except Exception as ex:
        raise ex
Пример #7
0
def get_job_working_group_by_group_code(args):
    try:
        if args['data'].has_key('gjw_code') and args['data'][
                'gjw_code'] != None and args['data']['gjw_code'] != "":
            return JobWorking.get_job_working_group_by_group_code(
                args['data']['gjw_code'])
        return None
    except Exception as ex:
        raise ex
Пример #8
0
def get_list_permission_and_mission(args):
    searchText = args['data'].get('search', '')
    pageSize = args['data'].get('pageSize', 0)
    pageIndex = args['data'].get('pageIndex', 20)
    sort = args['data'].get('sort', 20)

    pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex)
    pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize)

    ret = JobWorking.get_list_permission_and_mission_by_job_working_code(
        args['data']['job_w_code'], searchText)

    if (sort != None):
        ret.sort(sort)

    return ret.get_page(pageIndex, pageSize)
Пример #9
0
def insert(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            data = set_dict_insert_data(args['data'])
            ret = qmongo.models.HCSLS_JobWorking.insert(data)
            lock.release()
            ret['data'] = JobWorking.get_job_description_by_job_working_code(
                data['job_w_code']).get_item()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #10
0
def insert_factor_appraisal(args):
    try:
        lock.acquire()
        ret = {}
        if args['data'] != None:
            if not args['data']['factor_appraisal'].has_key('rec_id'):
                if args['data'].has_key('job_w_code'):
                    if (args['data']['factor_appraisal'].has_key('factor_code')
                        ):
                        for x in args['data']['factor_appraisal'][
                                'factor_code']:
                            try:
                                param = {
                                    "job_w_code":
                                    args['data']['job_w_code'],
                                    "factor_code":
                                    str(x).format(),
                                    "weight":
                                    (lambda x: x['weight']
                                     if x.has_key('weight') else None)(
                                         args['data']['factor_appraisal']),
                                }
                                factor = set_dict_insert_factor_appraisal(
                                    param)
                                ret = JobWorking.insert_evaluation_factor(
                                    args, factor)
                            except Exception as ex:
                                raise ex
                    else:
                        return dict(
                            error=dict(fields=['factor_code'], code="missing"))
                else:
                    lock.release()
                    return dict(
                        error=dict(fields=['factor_code'], code="missing"))

            lock.release()
            return ret

        lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        lock.release()
        raise (ex)
Пример #11
0
def get_list_with_searchtext(args):
    searchText = args['data'].get('search', '')
    pageSize = args['data'].get('pageSize', 0)
    pageIndex = args['data'].get('pageIndex', 20)
    sort = args['data'].get('sort', 20)

    pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex)
    pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize)

    ret=JobWorking.display_list_job_working(args['data']['gjw_code'])
    
    if(searchText != None):
        ret.match("contains(job_w_name, @name) or contains(report_to_job_w, @name)" + \
            " or contains(job_w_code, @name) or contains(ordinal, @name)",name=searchText.strip())

    if(sort != None):
        ret.sort(sort)
        
    return ret.get_page(pageIndex, pageSize)
Пример #12
0
def get_list_evaluation_factor(args):
    try:
        searchText = args['data'].get('search', '')
        pageSize = args['data'].get('pageSize', 0)
        pageIndex = args['data'].get('pageIndex', 20)
        sort = args['data'].get('sort', 20)

        pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex)
        pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize)
        if args['data'].has_key('job_w_code'):
            ret = JobWorking.get_list_evaluation_factor_by_job_working_code(
                args['data']['job_w_code'])
            if (sort != None):
                ret.sort(sort)
            return ret.get_page(pageIndex, pageSize)

        return None
    except Exception as ex:
        raise ex
Пример #13
0
def get_list_with_searchtext(args):
    if args['data'].has_key('gjw_code') and args['data'][
            'gjw_code'] != None and args['data']['gjw_code'] != "":
        searchText = args['data'].get('search', '')
        pageSize = args['data'].get('pageSize', 0)
        pageIndex = args['data'].get('pageIndex', 20)
        sort = args['data'].get('sort', 20)

        pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex)
        pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize)

        ret = JobWorking.display_list_job_working(args['data']['gjw_code'])

        ret = common.filter_lock(ret, args)

        if (searchText != None):
            ret.match("contains(job_w_name, @name) or contains(report_to_job_w, @name)" + \
                " or contains(job_w_code, @name) or contains(ordinal, @name)",name=searchText.strip())

        if (sort != None):
            ret.sort(sort)

        return ret.get_page(pageIndex, pageSize)
    return None
Пример #14
0
def insert_factor_appraisal(args):
    try:
        #lock.acquire()
        ret = {}
        rs = {"upserted": 0, "error": None}
        if args['data'] != None:
            if args['data'].has_key('factor_code'):
                if (args['data'].has_key('job_w_code')):
                    collection = common.get_collection('HCSLS_JobWorking')
                    collection.update_many(
                        {
                            "factor_appraisal": {
                                "$elemMatch": {
                                    "factor_code": args['data']['factor_code']
                                }
                            }
                        }, {"$set": {
                            'factor_appraisal': [],
                        }})
                    if args['data']['job_w_code'] != None and len(
                            args['data']['job_w_code']) > 0:
                        for x in args['data']['job_w_code']:
                            try:
                                param = {
                                    "job_w_code": str(x).format(),
                                    "factor_code": args['data']['factor_code'],
                                    "rec_id": common.generate_guid(),
                                    "weight": None,
                                    "created_on": datetime.datetime.now(),
                                    "created_by": common.get_user_id(),
                                    "modified_on": None,
                                    "modified_by": ''
                                }
                                factor = param

                                ret = JobWorking.insert_evaluation_factor(
                                    {"data": {
                                        "job_w_code": str(x).format()
                                    }}, factor)
                                if ret['updatedExisting'] and ret[
                                        'nModified'] > 0:
                                    rs['upserted'] += ret['nModified']
                            except Exception as ex:
                                raise ex
                        #lock.release()
                        return rs
                else:
                    return dict(
                        error=dict(fields=['job_w_code'], code="missing"))
            else:
                #lock.release()
                return dict(error=dict(fields=['factor_code'], code="missing"))

            #lock.release()
            return ret

        #lock.release()
        return dict(error="request parameter is not exist")
    except Exception as ex:
        #lock.release()
        raise (ex)