2 Commits e95bfe1e32 ... 2af2b6bca0

Auteur SHA1 Bericht Datum
  user 2af2b6bca0 增加支出报表的meun 4 jaren geleden
  user 1eff478078 init 4 jaren geleden
74 gewijzigde bestanden met toevoegingen van 731 en 9 verwijderingen
  1. 8 0
      .idea/dataSources.xml
  2. 1 1
      .idea/misc.xml
  3. 1 1
      .idea/testthree.iml
  4. 1 0
      .idea/vcs.xml
  5. 9 1
      Pipfile.lock
  6. 0 0
      detailmptt/__init__.py
  7. BIN
      detailmptt/__pycache__/__init__.cpython-37.pyc
  8. BIN
      detailmptt/__pycache__/admin.cpython-37.pyc
  9. BIN
      detailmptt/__pycache__/models.cpython-37.pyc
  10. BIN
      detailmptt/__pycache__/urls.cpython-37.pyc
  11. BIN
      detailmptt/__pycache__/views.cpython-37.pyc
  12. 3 0
      detailmptt/admin.py
  13. 5 0
      detailmptt/apps.py
  14. 36 0
      detailmptt/migrations/0001_initial.py
  15. 0 0
      detailmptt/migrations/__init__.py
  16. BIN
      detailmptt/migrations/__pycache__/0001_initial.cpython-37.pyc
  17. BIN
      detailmptt/migrations/__pycache__/__init__.cpython-37.pyc
  18. 44 0
      detailmptt/models.py
  19. 11 0
      detailmptt/tests.py
  20. 24 0
      detailmptt/urls.py
  21. 44 0
      detailmptt/views.py
  22. 0 0
      django-admin
  23. 0 0
      pivottable/__init__.py
  24. BIN
      pivottable/__pycache__/__init__.cpython-37.pyc
  25. BIN
      pivottable/__pycache__/admin.cpython-37.pyc
  26. BIN
      pivottable/__pycache__/models.cpython-37.pyc
  27. BIN
      pivottable/__pycache__/serializer.cpython-37.pyc
  28. BIN
      pivottable/__pycache__/urls.cpython-37.pyc
  29. BIN
      pivottable/__pycache__/views.cpython-37.pyc
  30. 3 0
      pivottable/admin.py
  31. 5 0
      pivottable/apps.py
  32. 37 0
      pivottable/migrations/0001_initial.py
  33. 16 0
      pivottable/migrations/0002_delete_menu.py
  34. 38 0
      pivottable/migrations/0003_menu.py
  35. 16 0
      pivottable/migrations/0004_delete_menu.py
  36. 0 0
      pivottable/migrations/__init__.py
  37. BIN
      pivottable/migrations/__pycache__/0001_initial.cpython-37.pyc
  38. BIN
      pivottable/migrations/__pycache__/0002_delete_menu.cpython-37.pyc
  39. BIN
      pivottable/migrations/__pycache__/0003_menu.cpython-37.pyc
  40. BIN
      pivottable/migrations/__pycache__/0004_delete_menu.cpython-37.pyc
  41. BIN
      pivottable/migrations/__pycache__/__init__.cpython-37.pyc
  42. 36 0
      pivottable/models.py
  43. 20 0
      pivottable/serializer.py
  44. 13 0
      pivottable/tests.py
  45. 29 0
      pivottable/urls.py
  46. 37 0
      pivottable/views.py
  47. 0 0
      relation/__init__.py
  48. BIN
      relation/__pycache__/__init__.cpython-37.pyc
  49. BIN
      relation/__pycache__/admin.cpython-37.pyc
  50. BIN
      relation/__pycache__/models.cpython-37.pyc
  51. BIN
      relation/__pycache__/serializer.cpython-37.pyc
  52. BIN
      relation/__pycache__/urls.cpython-37.pyc
  53. BIN
      relation/__pycache__/views.cpython-37.pyc
  54. 3 0
      relation/admin.py
  55. 5 0
      relation/apps.py
  56. 37 0
      relation/migrations/0001_initial.py
  57. 49 0
      relation/migrations/0002_daptpost_daptuser_postuser.py
  58. 0 0
      relation/migrations/__init__.py
  59. BIN
      relation/migrations/__pycache__/0001_initial.cpython-37.pyc
  60. BIN
      relation/migrations/__pycache__/0002_daptpost_daptuser_postuser.cpython-37.pyc
  61. BIN
      relation/migrations/__pycache__/__init__.cpython-37.pyc
  62. 47 0
      relation/models.py
  63. 23 0
      relation/serializer.py
  64. 4 0
      relation/tests.py
  65. 30 0
      relation/urls.py
  66. 83 0
      relation/views.py
  67. BIN
      testthree/__pycache__/settings.cpython-37.pyc
  68. BIN
      testthree/__pycache__/urls.cpython-37.pyc
  69. 8 4
      testthree/settings.py
  70. 4 1
      testthree/urls.py
  71. BIN
      workreport/__pycache__/urls.cpython-37.pyc
  72. BIN
      workreport/__pycache__/views.cpython-37.pyc
  73. 1 1
      workreport/migrations/0001_initial.py
  74. BIN
      workreport/migrations/__pycache__/0001_initial.cpython-37.pyc

+ 8 - 0
.idea/dataSources.xml

@@ -7,5 +7,13 @@
       <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
       <jdbc-url>jdbc:sqlite:E:\python\test\testthree\lvsh_django</jdbc-url>
     </data-source>
+    <data-source source="LOCAL" name="Django default" uuid="632ce503-001e-47c7-9113-f213d84c308a">
+      <driver-ref>mysql.8</driver-ref>
+      <synchronize>true</synchronize>
+      <imported>true</imported>
+      <remarks>$PROJECT_DIR$/testthree/settings.py</remarks>
+      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
+      <jdbc-url>jdbc:mysql://www.test.linkerplus.com:3310/lvsh_django</jdbc-url>
+    </data-source>
   </component>
 </project>

+ 1 - 1
.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="JavaScriptSettings">
     <option name="languageLevel" value="ES6" />
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (lvshihai-w2fUPLQ-)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (testthree-kKtqvWDd)" project-jdk-type="Python SDK" />
 </project>

+ 1 - 1
.idea/testthree.iml

@@ -14,7 +14,7 @@
   </component>
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$" />
-    <orderEntry type="jdk" jdkName="Python 3.7 (lvshihai-w2fUPLQ-)" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.7 (testthree-kKtqvWDd)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
   <component name="TemplatesService">

+ 1 - 0
.idea/vcs.xml

@@ -2,5 +2,6 @@
 <project version="4">
   <component name="VcsDirectoryMappings">
     <mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
   </component>
 </project>

+ 9 - 1
Pipfile.lock

@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "a82a50f1ac082a5c593ae284fef3ad41c1207d45234dae53e38582c753d012eb"
+            "sha256": "c775d44ee2191d8fc65e8105b1a7afca200d75a5af7ce971f8795749e825283d"
         },
         "pipfile-spec": 6,
         "requires": {
@@ -32,6 +32,14 @@
             "markers": "python_version >= '3.6'",
             "version": "==3.0.8"
         },
+        "django-filter": {
+            "hashes": [
+                "sha256:11e63dd759835d9ba7a763926ffb2662cf8a6dcb4c7971a95064de34dbc7e5af",
+                "sha256:616848eab6fc50193a1b3730140c49b60c57a3eda1f7fc57fa8505ac156c6c75"
+            ],
+            "index": "pypi",
+            "version": "==2.3.0"
+        },
         "djangorestframework": {
             "hashes": [
                 "sha256:05809fc66e1c997fd9a32ea5730d9f4ba28b109b9da71fccfa5ff241201fd0a4",

+ 0 - 0
detailmptt/__init__.py


BIN
detailmptt/__pycache__/__init__.cpython-37.pyc


BIN
detailmptt/__pycache__/admin.cpython-37.pyc


BIN
detailmptt/__pycache__/models.cpython-37.pyc


BIN
detailmptt/__pycache__/urls.cpython-37.pyc


BIN
detailmptt/__pycache__/views.cpython-37.pyc


+ 3 - 0
detailmptt/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
detailmptt/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class DetailmpttConfig(AppConfig):
+    name = 'detailmptt'

+ 36 - 0
detailmptt/migrations/0001_initial.py

@@ -0,0 +1,36 @@
+# Generated by Django 3.0.8 on 2020-07-24 07:47
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='DailyMptt',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('title', models.CharField(max_length=50)),
+                ('content', models.TextField()),
+                ('create_at', models.DateTimeField(auto_now=True)),
+                ('son_size', models.IntegerField(default=0)),
+                ('lft', models.PositiveIntegerField(editable=False)),
+                ('rght', models.PositiveIntegerField(editable=False)),
+                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
+                ('level', models.PositiveIntegerField(editable=False)),
+                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+                ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='detailmptt.DailyMptt', verbose_name='上级区域')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+    ]

+ 0 - 0
detailmptt/migrations/__init__.py


BIN
detailmptt/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
detailmptt/migrations/__pycache__/__init__.cpython-37.pyc


+ 44 - 0
detailmptt/models.py

@@ -0,0 +1,44 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+# Create your models here.
+from mptt.models import MPTTModel
+
+
+class DailyMptt(MPTTModel):
+    #verbose_name表示,on_delete父级删除时的处理
+    parent = models.ForeignKey('self', verbose_name='上级区域', null=True, blank=True, related_name='children', on_delete = models.CASCADE)
+    title = models.CharField(max_length=50)
+    content = models.TextField()
+    create_at = models.DateTimeField(auto_now=True)
+    create_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
+    son_size = models.IntegerField(default=0)
+
+    # def toKeyToVal(self):
+
+
+    def getObject(self, data):
+        for key, val in data.items():
+            if hasattr(self, key):
+                self.__setattr__(key, val)
+        return self
+
+    class MPTTMeta:
+        order_insertion_by = ['title']#自然顺序
+
+
+# 权限表
+class Role(models.Model):
+    title = models.CharField(max_length=32)
+    permissions = models.ManyToManyField('Permission')
+
+    def __str__(self):
+        return self.title
+
+#菜单表
+class menu(models.Model):
+    title = models.CharField(max_length=32)
+    url = models.CharField(max_length=32)
+
+    def __str__(self):
+        return self.title

+ 11 - 0
detailmptt/tests.py

@@ -0,0 +1,11 @@
+from random import random
+
+from django.test import TestCase
+
+# Create your tests here.
+from detailmptt.models import DailyMptt
+
+
+
+
+

+ 24 - 0
detailmptt/urls.py

@@ -0,0 +1,24 @@
+"""testthree URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+from django.conf.urls import url
+from django.contrib import admin
+from django.urls import path, include
+
+from detailmptt.views import DetailMpttView
+
+urlpatterns = [
+    url(r'^detail/', DetailMpttView.as_view())
+]

+ 44 - 0
detailmptt/views.py

@@ -0,0 +1,44 @@
+from random import random
+
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+
+from detailmptt.models import DailyMptt
+from workreport.models import DailyRreport
+from workreport.serializer import DailyReportSerializer
+
+
+class DetailMpttView(APIView):
+    # def get(self,request):
+    #     objects_all = DailyMptt.objects.all()
+    #     dailyMpttList =
+    #设置查询条件
+    def get(self,request):
+        dailyMptt = DailyMptt()
+        #获取全部get信息
+        params = request.GET
+        #赋值
+        dailyMptt.getObject(params)
+        parent_id = params.get('parent_id')
+        dailyMpttList = DailyMptt.objects.filter(parent_id = parent_id).values()
+        return Response(data=dailyMpttList, status=status.HTTP_200_OK)
+
+    def post(self, request):
+        # pass
+        data = request.data
+        dailyMptt = DailyMptt()
+        dailyMptt.getObject(data)
+
+        dailyMptt.save()
+        return Response(status = status.HTTP_201_CREATED)
+
+    def delete(self, request):
+        id = request.data['id']
+        DailyMptt.objects.filter(id = id).delete()
+
+        return Response(data=True, status=status.HTTP_200_OK)

+ 0 - 0
django-admin


+ 0 - 0
pivottable/__init__.py


BIN
pivottable/__pycache__/__init__.cpython-37.pyc


BIN
pivottable/__pycache__/admin.cpython-37.pyc


BIN
pivottable/__pycache__/models.cpython-37.pyc


BIN
pivottable/__pycache__/serializer.cpython-37.pyc


BIN
pivottable/__pycache__/urls.cpython-37.pyc


BIN
pivottable/__pycache__/views.cpython-37.pyc


+ 3 - 0
pivottable/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
pivottable/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class PivottableConfig(AppConfig):
+    name = 'pivottable'

+ 37 - 0
pivottable/migrations/0001_initial.py

@@ -0,0 +1,37 @@
+# Generated by Django 3.0.8 on 2020-07-28 11:40
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import mptt.fields
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Menu',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=100)),
+                ('config', models.TextField()),
+                ('create_at', models.DateTimeField(auto_now_add=True)),
+                ('code', models.CharField(max_length=100)),
+                ('lft', models.PositiveIntegerField(editable=False)),
+                ('rght', models.PositiveIntegerField(editable=False)),
+                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
+                ('level', models.PositiveIntegerField(editable=False)),
+                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+                ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pivottable.Menu')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+    ]

+ 16 - 0
pivottable/migrations/0002_delete_menu.py

@@ -0,0 +1,16 @@
+# Generated by Django 3.0.8 on 2020-07-28 11:49
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('pivottable', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.DeleteModel(
+            name='Menu',
+        ),
+    ]

+ 38 - 0
pivottable/migrations/0003_menu.py

@@ -0,0 +1,38 @@
+# Generated by Django 3.0.8 on 2020-07-28 11:55
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import mptt.fields
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('pivottable', '0002_delete_menu'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Menu',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=100)),
+                ('config', models.TextField()),
+                ('create_at', models.DateTimeField(auto_now_add=True)),
+                ('code', models.CharField(max_length=100)),
+                ('lft', models.PositiveIntegerField(editable=False)),
+                ('rght', models.PositiveIntegerField(editable=False)),
+                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
+                ('level', models.PositiveIntegerField(editable=False)),
+                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+                ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='pivottable.Menu')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+    ]

+ 16 - 0
pivottable/migrations/0004_delete_menu.py

@@ -0,0 +1,16 @@
+# Generated by Django 3.0.8 on 2020-07-28 11:57
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('pivottable', '0003_menu'),
+    ]
+
+    operations = [
+        migrations.DeleteModel(
+            name='Menu',
+        ),
+    ]

+ 0 - 0
pivottable/migrations/__init__.py


BIN
pivottable/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
pivottable/migrations/__pycache__/0002_delete_menu.cpython-37.pyc


BIN
pivottable/migrations/__pycache__/0003_menu.cpython-37.pyc


BIN
pivottable/migrations/__pycache__/0004_delete_menu.cpython-37.pyc


BIN
pivottable/migrations/__pycache__/__init__.cpython-37.pyc


+ 36 - 0
pivottable/models.py

@@ -0,0 +1,36 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+# Create your models here.
+from mptt.fields import TreeForeignKey
+from mptt.models import MPTTModel
+
+
+class Payment(models.Model):
+    payment_type = models.CharField(max_length=100)
+    price_type = models.CharField(max_length=100)
+    item_type = models.CharField(max_length=100)
+    index_type = models.CharField(max_length=100)
+    index_price = models.IntegerField()
+    year = models.CharField(max_length=4)
+    month = models.CharField(max_length=2)
+
+    class Meta:
+        app_label = 'payment'
+        db_table = 'pay'
+        verbose_name = '支出报表'
+        verbose_name_plural = '支出报表列表'
+
+class Menu(MPTTModel):
+    name = models.CharField(max_length=100)
+    config = models.TextField()
+    create_at = models.DateTimeField(auto_now_add=True)
+    create_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
+    parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
+    code = models.CharField(max_length=100)
+
+    class Meta:
+        app_label = 'basic'
+        db_table = 'basic_menu'
+        verbose_name = '报表菜单'
+        verbose_name_plural = '报表菜单列表'

+ 20 - 0
pivottable/serializer.py

@@ -0,0 +1,20 @@
+
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from pivottable.models import Payment, Menu
+
+
+class PaymentSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Payment
+        # fields = ['url', 'username', 'email', 'is_staff']
+        list_serializer = ListSerializer
+        fields = '__all__'
+
+class MenuSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Menu
+        # fields = ['url', 'username', 'email', 'is_staff']
+        list_serializer = ListSerializer
+        fields = '__all__'

+ 13 - 0
pivottable/tests.py

@@ -0,0 +1,13 @@
+from threading import Thread
+
+from django.test import TestCase
+
+# Create your tests here.
+if __name__ == '__main__':
+    def forr(n, s):
+        for i in range(n):
+            print(s)
+    for i in range(30):
+        Thread(
+            forr(10, i)
+        ).start()

+ 29 - 0
pivottable/urls.py

@@ -0,0 +1,29 @@
+"""testthree URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+from django.conf.urls import url
+from rest_framework_bulk.routes import BulkRouter
+
+# 给智能路由注册
+from pivottable.views import *
+
+router = BulkRouter()
+router.register(r'payment', PaymentViews)
+router.register(r'menu', MenuView)
+
+urlpatterns = router.urls
+urlpatterns += [
+    url(r'^paystat/', PayStatViews.as_view())
+]

+ 37 - 0
pivottable/views.py

@@ -0,0 +1,37 @@
+from django.db.models import Sum, Count
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework import permissions, status
+from rest_framework.decorators import permission_classes
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+
+from pivottable.models import *
+from pivottable.serializer import *
+
+# @permission_classes((permissions.AllowAny,))
+class PaymentViews(ModelViewSet):
+    pagination_class = None
+    queryset = Payment.objects.all()
+    serializer_class = PaymentSerializer
+    
+    
+
+# @permission_classes((permissions.AllowAny,))
+class MenuView(ModelViewSet):
+    queryset = Menu.objects.all()
+    serializer_class = MenuSerializer  # 序列化
+    pagination_class = None
+
+class PayStatViews(APIView):
+    # 统计 {order_by:0(默认0升序,1降序)}
+    def get(self, request):
+        data = request.GET
+        order_by = "price_sum"
+        if hasattr(data, "order_by") and data['order_by'] == 1:
+            order_by = "-price_sum"
+        data = Payment.objects.values('payment_type',price_sum=Sum('index_price'))\
+            .annotate(payment_type_count=Count('payment_type')).order_by(order_by)
+        return Response(data=data, status=status.HTTP_200_OK)

+ 0 - 0
relation/__init__.py


BIN
relation/__pycache__/__init__.cpython-37.pyc


BIN
relation/__pycache__/admin.cpython-37.pyc


BIN
relation/__pycache__/models.cpython-37.pyc


BIN
relation/__pycache__/serializer.cpython-37.pyc


BIN
relation/__pycache__/urls.cpython-37.pyc


BIN
relation/__pycache__/views.cpython-37.pyc


+ 3 - 0
relation/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
relation/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class RelationConfig(AppConfig):
+    name = 'relation'

+ 37 - 0
relation/migrations/0001_initial.py

@@ -0,0 +1,37 @@
+# Generated by Django 3.0.8 on 2020-07-24 07:47
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Post',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=50)),
+            ],
+        ),
+        migrations.CreateModel(
+            name='Dapt',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=50)),
+                ('lft', models.PositiveIntegerField(editable=False)),
+                ('rght', models.PositiveIntegerField(editable=False)),
+                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
+                ('level', models.PositiveIntegerField(editable=False)),
+                ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='pid', to='relation.Dapt', verbose_name='上级部门')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+    ]

+ 49 - 0
relation/migrations/0002_daptpost_daptuser_postuser.py

@@ -0,0 +1,49 @@
+# Generated by Django 3.0.8 on 2020-07-24 07:50
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('relation', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='PostUser',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pu_post', to='relation.Post', verbose_name='岗位')),
+                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pu_user', to=settings.AUTH_USER_MODEL, verbose_name='人员')),
+            ],
+            options={
+                'unique_together': {('post', 'user')},
+            },
+        ),
+        migrations.CreateModel(
+            name='DaptUser',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('dapt', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='du_dapt', to='relation.Dapt', verbose_name='部门')),
+                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='du_user', to=settings.AUTH_USER_MODEL, verbose_name='人员')),
+            ],
+            options={
+                'unique_together': {('dapt', 'user')},
+            },
+        ),
+        migrations.CreateModel(
+            name='DaptPost',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('dapt', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dp_dapt', to='relation.Dapt', verbose_name='部门')),
+                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dp_post', to='relation.Post', verbose_name='岗位')),
+            ],
+            options={
+                'unique_together': {('dapt', 'post')},
+            },
+        ),
+    ]

+ 0 - 0
relation/migrations/__init__.py


BIN
relation/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
relation/migrations/__pycache__/0002_daptpost_daptuser_postuser.cpython-37.pyc


BIN
relation/migrations/__pycache__/__init__.cpython-37.pyc


+ 47 - 0
relation/models.py

@@ -0,0 +1,47 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+# Create your models here.
+from mptt.models import MPTTModel
+
+#部门表
+class Dapt(MPTTModel):
+    name = models.CharField(max_length=50)
+    parent = models.ForeignKey('self', verbose_name='上级部门', null=True, blank=True, related_name='pid',
+                               on_delete=models.CASCADE)
+    def setObject(self, data):
+        for key, val in data.items():
+            if hasattr(self, key):
+                self.__setattr__(key, val)
+        return self
+
+#岗位
+class Post(models.Model):
+    name = models.CharField(max_length=50)
+
+#部门岗位关联表
+class DaptPost(models.Model):
+    dapt = models.ForeignKey('Dapt', verbose_name='部门', null=False, blank=False, related_name='dp_dapt', on_delete=models.CASCADE)
+    post = models.ForeignKey('Post', verbose_name='岗位', null=False, blank=False, related_name='dp_post', on_delete=models.CASCADE)
+
+    class Meta:
+        unique_together = ('dapt', 'post')
+
+#部门人员关联表
+class DaptUser(models.Model):
+    dapt = models.ForeignKey('Dapt', verbose_name='部门', null=False, blank=False, related_name='du_dapt', on_delete=models.CASCADE)
+    user = models.ForeignKey(User, verbose_name='人员', null=False, blank=False, related_name='du_user', on_delete=models.CASCADE)
+    def setObject(self, data):
+        for key, val in data.items():
+            if hasattr(self, key):
+                self.__setattr__(key, val)
+        return self
+    class Meta:
+        unique_together = ('dapt', 'user')
+
+#岗位人员关联表
+class PostUser(models.Model):
+    post = models.ForeignKey('Post', verbose_name='岗位', null=False, blank=False, related_name='pu_post', on_delete=models.CASCADE)
+    user = models.ForeignKey(User, verbose_name='人员', null=False, blank=False, related_name='pu_user', on_delete=models.CASCADE)
+    class Meta:
+        unique_together = ('post', 'user')

+ 23 - 0
relation/serializer.py

@@ -0,0 +1,23 @@
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from relation.models import *
+class DaptSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Dapt
+        fields = '__all__'
+
+class PostSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Post
+        fields = '__all__'
+
+class UserSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = User
+        fields = '__all__'
+
+class DaptUserSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = DaptUser
+        fields = '__all__'

+ 4 - 0
relation/tests.py

@@ -0,0 +1,4 @@
+from django.test import TestCase
+
+# Create your tests here.
+

+ 30 - 0
relation/urls.py

@@ -0,0 +1,30 @@
+"""testthree URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+from django.conf.urls import url
+from rest_framework_bulk.routes import BulkRouter
+from relation.views import *
+
+# 给智能路由注册
+# router = BulkRouter()
+# router.register(r'dept', DaptViews)
+# # router.register(r'post',PostViews)
+#
+# urlpatterns = router.urls
+urlpatterns = [
+    url(r'^daptuser/', DaptUserViews.as_view()),
+    url(r'^dapt/', DaptViews.as_view()),
+    url(r'^user/', UserViews.as_view())
+]

+ 83 - 0
relation/views.py

@@ -0,0 +1,83 @@
+from django.shortcuts import render
+
+# Create your views here.
+
+from rest_framework import status, permissions
+from rest_framework.decorators import permission_classes
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+
+from relation.serializer import *
+from rest_framework.response import Response
+
+class DaptViews(APIView):
+    def get(self, request):
+        parent_id = request.GET.get('parent_id')
+        daptSet = Dapt.objects.filter(parent_id = parent_id).values()
+        return Response(data=daptSet, status=status.HTTP_200_OK)
+
+    def post(self, request):
+        dapt = Dapt()
+        data = request.data
+        dapt.setObject(data)
+        dapt.save()
+        return Response(data=dapt.id, status=status.HTTP_200_OK)
+
+    def delete(self, request):
+        id = request.data['id']
+        Dapt.objects.filter(id = id).delete()
+        return Response(data=True, status=status.HTTP_200_OK)
+
+class PostViews(ModelViewSet):
+    queryset = Post.objects.all()
+    serializer_class = PostSerializer
+
+class UserViews(APIView):
+    def post(self, request):
+        data = request.data
+        user = User(last_name = data['last_name'], id=data['id'])
+        user.save()
+        return Response(data=True, status=status.HTTP_200_OK)
+    def get(self, request):
+        user = User.objects.values()
+        return Response(data=user, status=status.HTTP_200_OK)
+
+# class DaptPostViews(APIView):
+#     def get(self, request):
+#         get = request.GET
+#         return Response(status=status.HTTP_200_OK)
+#部门人员
+class DaptUserViews(APIView):
+    def get(self, request):
+        daptId = request.GET.get('dapt_id')
+        userId = request.GET.get('user_id')
+        if daptId != None:
+            daptUserList = list(DaptUser.objects.filter(dapt_id=daptId))
+            userList = list()
+            for daptUser in daptUserList:
+                userList.append(daptUser.user)
+            data = UserSerializer(userList, many=True)
+        elif userId != None:
+            daptUserList = list(DaptUser.objects.filter(user_id=userId))
+            daptList = list()
+            for daptUser in daptUserList:
+                daptList.append(daptUser.dapt)
+            data = DaptSerializer(daptList, many=True)
+        return Response(data=data.data, status=status.HTTP_200_OK)
+
+    def post(self, reques):
+        data = reques.data
+        daptUser = DaptUser()
+        daptUser.setObject(data)
+        daptUser.save()
+        return Response(data=True, status=status.HTTP_200_OK)
+
+    def delete(self, reques):
+        userId = reques.data['user_id']
+        daptId = reques.data['dapt_id']
+        DaptUser.objects.get(user_id = userId, dapt_id=daptId).delete()
+        return Response(data=True, status=status.HTTP_200_OK)
+
+
+
+        

BIN
testthree/__pycache__/settings.cpython-37.pyc


BIN
testthree/__pycache__/urls.cpython-37.pyc


+ 8 - 4
testthree/settings.py

@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
 INSTALLED_APPS = [
     'django.contrib.admin',
     'django.contrib.auth',
+    'mptt',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',
@@ -38,6 +39,9 @@ INSTALLED_APPS = [
     'rest_framework',
     'django_filters',
     'workreport',
+    'detailmptt',
+    'relation',
+    'pivottable'
 ]
 
 MIDDLEWARE = [
@@ -79,7 +83,7 @@ DATABASES = {
         'NAME': "lvsh_django",
         'USER': 'root',
         'PASSWORD': 'abc.123',
-        'HOST': 'srv.test.linkerplus.com',
+        'HOST': 'www.test.linkerplus.com',
         'PORT': '3310'
     }
 }
@@ -133,6 +137,6 @@ REST_FRAMEWORK = {
     ]
 }
 
-# AUTHENTICATION_BACKENDS = (
-#     'django.contrib.auth.backends.ModelBackend'
-# )
+AUTHENTICATION_BACKENDS = (
+    'django.contrib.auth.backends.ModelBackend'
+)

+ 4 - 1
testthree/urls.py

@@ -20,5 +20,8 @@ from django.urls import path, include
 urlpatterns = [
     path('admin/', admin.site.urls),
     url(r'^api-auth/', include('rest_framework.urls')),
-    url(r'^report/', include('workreport.urls'))
+    url(r'^report/', include('workreport.urls')),
+    url(r'^report/mptt/', include('detailmptt.urls')),
+    url(r'^report/relation/', include('relation.urls')),
+    url(r'^report/pivottable/', include('pivottable.urls'))
 ]

BIN
workreport/__pycache__/urls.cpython-37.pyc


BIN
workreport/__pycache__/views.cpython-37.pyc


+ 1 - 1
workreport/migrations/0001_initial.py

@@ -1,4 +1,4 @@
-# Generated by Django 3.0.8 on 2020-07-16 03:36
+# Generated by Django 3.0.8 on 2020-07-24 07:47
 
 from django.conf import settings
 from django.db import migrations, models

BIN
workreport/migrations/__pycache__/0001_initial.cpython-37.pyc