예제 #1
0
파일: serializer.py 프로젝트: xjohjrdy/df2
 def get_sub_name(obj):
     try:
         return model_to_dict(
             SubSite.objects.get(id=obj.sub_site.id))['name']
     except Exception as e:
         common_util.debug(e)
         return ""
예제 #2
0
파일: views.py 프로젝트: xjohjrdy/df2
def sync_guarantee(request):
    if request.method == 'POST':
        day_start = eval(request.body).get('day_start', None)
        day_end = eval(request.body).get('day_end', None)
        common_util.debug(day_start)
        common_util.debug(day_end)
        platform_util.do_sync_gurantee(day_start, day_end)
        return common_util.json_response(True, message="同步成功")
예제 #3
0
파일: views.py 프로젝트: xjohjrdy/df2
def get_platform_car_info(request):
    from util import platform_util
    VIN = request.GET.get("VIN", "")
    common_util.debug(VIN)
    if VIN:
        data = platform_util.get_info(VIN)
        if data is None:
            return common_util.json_response(False, message="该底盘号未获取到车辆信息")
        common_util.debug(data)
        return common_util.json_response(True, data=data, message="更新车辆信息成功")
    else:
        return common_util.json_response(False, message="未获取到车辆底盘号")
예제 #4
0
def _guarantee_to_xls():
    common_util.debug(day_start)
    common_util.debug(day_end)
    data = Gurantee.objects.filter(apply_date__range=(day_start, day_end)).order_by('apply_date')
    if not data:
        return
    style_del = xlwt.XFStyle()
    style_del.alignment.wrap = 1

    header = ['申请日期', '审核状态', 'VIN', '车型', '配件名称', '配件费', '工时费', '总金额', '维修站',
              '同步', '自增', '备注', '审核日期', '配件代码', '配件数', '工时数', '维修类型', '索赔类型', '活动费',
              '辅料费', '特殊费']
    param_list = ["apply_date", "check_state", "car_sn", "car_type",
                  "acc_name", "acc_fee", "guarantee_time_fee", "total_fee", "sub_site",
                  "is_sync", "is_fake", "remark", "acc_sn", "acc_count",
                  "guarantee_time", "repair_type", "gurantee_type", "event_fee", "material_fee", "special_fee",
                  "total_fee"]

    xls = xlwt.Workbook(style_compression=2)
    sheet = xls.add_sheet("Sheet1")
    sheet.col(2).width = (20 * 367)  # 设置表格的宽度
    sheet.col(4).width = (20 * 367)
    # sheet.col(9).width = (10 * 367)
    # sheet.col(10).width = (10 * 367)
    i = 0
    row = 1
    # 写表头
    for each_header in header:
        sheet.write(0, i, each_header)
        i += 1
    for model in data:
        i = 0
        item = model_to_dict(model)
        item['apply_date'] = item['apply_date'].strftime('%m-%d')
        item['is_sync'] = "是" if item['is_sync'] else "否"
        item['is_fake'] = "是" if item['is_fake'] else "否"
        common_util.debug(item)
        common_util.debug(item['sub_site'])
        try:
            item['sub_site'] = SubSite.objects.get(id=item['sub_site']).name
        except Exception as e:
            pass
        for key in param_list:
            sheet.write(row, i, item[key])
            i += 1
        row += 1

    xls.save(os.path.join(main_dir, 'templates/media/data/三包.xls'))
예제 #5
0
class StationViewSet(viewsets.ModelViewSet):
    common_util.debug('this is a log')
    '''
    站点列表,分页,搜索,过滤,权限,排序
    '''
    queryset = Station.objects.all()
    # 分页
    pagination_class = StationPagination
    # 序列化
    serializer_class = StationSerializer
    # 权限
    permission_classes = (permissions.DjangoModelPermissionsOrAnonReadOnly,)
    # 排序
    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    # 过滤
    filter_class = StationFilter
    # 搜索
    search_fields = ('name',)
    # 排序
    ordering_fields = ('id',)
예제 #6
0
파일: serializer.py 프로젝트: xjohjrdy/df2
 def get_fix_man_detail(obj):
     try:
         return model_to_dict(EmployeeManage.objects.get(id=obj.fix_man.id))
     except Exception as e:
         common_util.debug(e)
         return {}
예제 #7
0
파일: serializer.py 프로젝트: xjohjrdy/df2
 def get_car_detail(obj):
     try:
         return model_to_dict(CarInfoManage.objects.get(id=obj.car.id))
     except Exception as e:
         common_util.debug(e)
         return {}
예제 #8
0
        i = 0
        item = model_to_dict(model)
        item['apply_date'] = item['apply_date'].strftime('%m-%d')
        item['is_sync'] = "是" if item['is_sync'] else "否"
        item['is_fake'] = "是" if item['is_fake'] else "否"
        common_util.debug(item)
        common_util.debug(item['sub_site'])
        try:
            item['sub_site'] = SubSite.objects.get(id=item['sub_site']).name
        except Exception as e:
            pass
        for key in param_list:
            sheet.write(row, i, item[key])
            i += 1
        row += 1

    xls.save(os.path.join(main_dir, 'templates/media/data/三包.xls'))


if __name__ == '__main__':
    try:
        _, day_start, day_end = sys.argv
    except Exception as e:
        day_start = common_util.get_today()
        day_end = common_util.get_today(1)
    read_excel()
    try:
        _guarantee_to_xls()
    except Exception as e:
        common_util.debug(e)