Exemple #1
0
def get_apply_records(proj_id, page, filters):
    filter_condition = {'proj_id': proj_id, 'is_del': 0}
    expressions = []
    search_key = filters['searchKey'] if 'searchKey' in filters else None
    if search_key:
        crew_expression = [
            or_(CrewMgr.model.crew_name == search_key,
                CrewMgr.model.phone == search_key,
                CrewMgr.model.id_card_num == search_key,
                CrewMgr.model.crew_account == search_key)
        ]
        search_crews = CrewMgr.query({'is_del': 0},
                                     expressions=crew_expression)
        search_crew_ids = [item.id for item in search_crews]
        expressions.append(CrewProjMapMgr.model.crew_id.in_(search_crew_ids))
    if 'crew_id' in filters and filters['crew_id']:
        expressions.append(CrewProjMapMgr.model.crew_id == filters['crew_id'])
    if 'entry_status' in filters:
        expressions.append(
            CrewProjMapMgr.model.entry_status == filters['entry_status'])
    count = CrewProjMapMgr.count(expressions=expressions,
                                 filter_conditions=filter_condition)
    if page != 0:
        records = CrewProjMapMgr.query(
            expressions=expressions,
            filter_conditions=filter_condition,
            limit=10,
            offset=(page - 1) * 10,
            order_list=[CrewProjMapMgr.model.create_time.desc()])
    else:
        if count > 5000:  # 数据量过大保护
            records = CrewProjMapMgr.query(
                expressions=expressions,
                filter_conditions=filter_condition,
                limit=5000,
                order_list=[CrewProjMapMgr.model.create_time.desc()])
        else:
            records = CrewProjMapMgr.query(expressions=expressions,
                                           filter_conditions=filter_condition)
    data = {'proj_id': proj_id, 'count': count, 'records': records}
    for record in data['records']:
        crew = CrewMgr.get(record.crew_id)
        if not crew:
            continue
        crew = to_dict(crew)
        crew['create_time'] = time_util.timestamp2dateString(
            crew['create_time'])
        crew['start_time'] = time_util.timestamp2dateString(
            record.start_time) if record.start_time else '待定'
        crew['entry_status'] = CrewProjMapMgr.translate_entry_status(
            record.entry_status)
        crew['age'] = GetInformation(crew['id_card_num']).get_age()
        crew['gender'] = GetInformation(crew['id_card_num']).get_gender_text()
        crew['apply_id'] = record.id
        data['result'].append(crew)
    data['result'] = json.dumps(data['result'])
    return data['result']
Exemple #2
0
 def add_occur_time_str(data):
     """
     赔付发生日期yyyy-mm-dd
     """
     if 'occur_time' in data:
         data['occur_time_str'] = time_util.timestamp2dateString(
             data['occur_time'])
Exemple #3
0
 def add_modify_time_str(data):
     """
     获取结束时间字段
     """
     if 'modify_time' in data:
         data['modify_time_str'] = time_util.timestamp2dateString(
             data['modify_time'])
Exemple #4
0
 def add_start_time_str(data):
     """
     获取开始时间字段
     """
     if 'start_time' in data:
         data['start_time_str'] = time_util.timestamp2dateString(
             data['start_time'])
Exemple #5
0
 def add_wage_time_str(data):
     """
     工作数据产生日期yyyy-mm-dd
     """
     if 'create_time' in data:
         data['wage_time_str'] = time_util.timestamp2dateString(
             data['wage_time'])
Exemple #6
0
 def add_create_time_str(data):
     """
     员工创建(第一次报名或被导入系统)日期yyyy-mm-dd
     """
     if 'create_time' in data:
         data['create_time_str'] = time_util.timestamp2dateString(data['create_time'])