diff --git a/enp/migrations/0020_archives.py b/enp/migrations/0020_archives.py
new file mode 100644
index 00000000..552b18f8
--- /dev/null
+++ b/enp/migrations/0020_archives.py
@@ -0,0 +1,38 @@
+# Generated by Django 2.2.8 on 2022-08-02 13:58
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('safesite', '0396_auto_20220304_1648'),
+ ('enp', '0019_auto_20220517_1717'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Archives',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
+ ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
+ ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
+ ('title', models.CharField(max_length=50)),
+ ('path', models.CharField(blank=True, max_length=200, null=True)),
+ ('createdate', models.DateTimeField(default=django.utils.timezone.now)),
+ ('deletemark', models.IntegerField(default=1)),
+ ('filepath', models.CharField(blank=True, max_length=200, null=True)),
+ ('reads', models.IntegerField(default='0')),
+ ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='archives_create_by', to='safesite.User', verbose_name='创建人')),
+ ('createuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.User')),
+ ('type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='safesite.Dickey')),
+ ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='archives_update_by', to='safesite.User', verbose_name='最后编辑人')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ ]
diff --git a/enp/migrations/0021_remove_archives_filepath.py b/enp/migrations/0021_remove_archives_filepath.py
new file mode 100644
index 00000000..0ad4dc62
--- /dev/null
+++ b/enp/migrations/0021_remove_archives_filepath.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.2.8 on 2022-08-02 14:09
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('enp', '0020_archives'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='archives',
+ name='filepath',
+ ),
+ ]
diff --git a/enp/migrations/0022_archives_usecomp.py b/enp/migrations/0022_archives_usecomp.py
new file mode 100644
index 00000000..1836629f
--- /dev/null
+++ b/enp/migrations/0022_archives_usecomp.py
@@ -0,0 +1,20 @@
+# Generated by Django 2.2.8 on 2022-08-02 14:55
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('safesite', '0396_auto_20220304_1648'),
+ ('enp', '0021_remove_archives_filepath'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='archives',
+ name='usecomp',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='safesite.Partment', verbose_name='所属公司'),
+ ),
+ ]
diff --git a/enp/migrations/0023_archives_note.py b/enp/migrations/0023_archives_note.py
new file mode 100644
index 00000000..b14e155d
--- /dev/null
+++ b/enp/migrations/0023_archives_note.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.8 on 2022-08-02 16:48
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('enp', '0022_archives_usecomp'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='archives',
+ name='note',
+ field=models.CharField(blank=True, max_length=500, null=True, verbose_name='备注'),
+ ),
+ ]
diff --git a/enp/migrations/0024_auto_20220803_1425.py b/enp/migrations/0024_auto_20220803_1425.py
new file mode 100644
index 00000000..5fbef5eb
--- /dev/null
+++ b/enp/migrations/0024_auto_20220803_1425.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.8 on 2022-08-03 14:25
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('enp', '0023_archives_note'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='prevention',
+ name='preventiontype',
+ field=models.IntegerField(blank=True, choices=[(1, '废水'), (2, '废气'), (3, '噪声')], default=1, null=True, verbose_name='防治类型'),
+ ),
+ ]
diff --git a/enp/migrations/0025_auto_20220803_1438.py b/enp/migrations/0025_auto_20220803_1438.py
new file mode 100644
index 00000000..0b36db92
--- /dev/null
+++ b/enp/migrations/0025_auto_20220803_1438.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.8 on 2022-08-03 14:38
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('enp', '0024_auto_20220803_1425'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='prevention',
+ name='hdl',
+ field=models.FloatField(blank=True, max_length=100, null=True, verbose_name='耗电率kWh'),
+ ),
+ ]
diff --git a/enp/models.py b/enp/models.py
index 5f76113a..a94d7c7a 100644
--- a/enp/models.py
+++ b/enp/models.py
@@ -1,6 +1,8 @@
from django.db import models
-from safesite.models import User, Partment
+from safesite.models import User, Partment,Dickey
from utils.models import CommonModel
+
+import django.utils.timezone as timezone
from django.contrib.postgres.fields import JSONField
# Create your models here.
@@ -154,11 +156,12 @@ class Facilities(CommonModel):
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司')
class Prevention(CommonModel):
"""
- 废气,废水防治设施
+ 废气,废水,噪声防治设施
"""
type_choices = (
(1, '废水'),
- (2, '废气')
+ (2, '废气'),
+ (3, '噪声')
)
name = models.CharField('防治设施名称', max_length=100)
number = models.CharField('编码', max_length=100)
@@ -178,7 +181,7 @@ class Prevention(CommonModel):
pkwd = models.FloatField('排口温度℃', max_length=200, null=True, blank=True)
yl = models.FloatField('压力kPa', max_length=100, null=True, blank=True)
pfsj = models.FloatField('排放时间h', max_length=100, null=True, blank=True)
- hdl = models.FloatField('耗电率kWh', max_length=100)
+ hdl = models.FloatField('耗电率kWh', max_length=100,null=True, blank=True)
fcpname = models.CharField('副产品名称', max_length=100, null=True, blank=True)
fcwcl = models.FloatField('副产物产生量t', max_length=100, null=True, blank=True)
yjname = models.CharField('药剂名称', max_length=100, null=True, blank=True)
@@ -252,3 +255,17 @@ class Waterequipment(CommonModel):
jcyqmodel = models.CharField('监测仪器型号', max_length=100, null=True, blank=True)
note = models.CharField('备注', max_length=500, null=True, blank=True)
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司')
+class Archives(CommonModel):
+ """
+ 档案管理
+ """
+ title = models.CharField(max_length=50)#标题
+ type=models.ForeignKey(Dickey,on_delete=models.CASCADE,null=True,blank=True)#档案类型
+ path = models.CharField(max_length=200,null=True,blank=True)#上传文件
+ createuser = models.ForeignKey(User,on_delete=models.CASCADE)#上传者
+ createdate = models.DateTimeField(default = timezone.now)#上传时间
+ deletemark = models.IntegerField(default=1)#是否删除
+ reads = models.IntegerField(default='0')
+ note = models.CharField('备注', max_length=500, null=True, blank=True)
+ usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, null=True, blank=True,verbose_name='所属公司')
+
diff --git a/enp/templates/archives.html b/enp/templates/archives.html
new file mode 100644
index 00000000..1ead04d0
--- /dev/null
+++ b/enp/templates/archives.html
@@ -0,0 +1,389 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/enp/templates/zprevention.html b/enp/templates/zprevention.html
new file mode 100644
index 00000000..f55c0492
--- /dev/null
+++ b/enp/templates/zprevention.html
@@ -0,0 +1,157 @@
+
+
+
+
\ No newline at end of file
diff --git a/enp/urls.py b/enp/urls.py
index 439ff14c..e8a6f7c2 100644
--- a/enp/urls.py
+++ b/enp/urls.py
@@ -13,4 +13,8 @@ urlpatterns = [
path('detection/', views.HtmlDetection),
path('fuel/', views.HtmlFuel),
path('waterequipment/', views.HtmlWaterequipment),
+ path('archives/', views.HtmlArchives),
+ path('zprevention/', views.HtmlZprevention),
+
+
]
\ No newline at end of file
diff --git a/enp/urls_api.py b/enp/urls_api.py
index 63b41bcd..a9bed6be 100644
--- a/enp/urls_api.py
+++ b/enp/urls_api.py
@@ -21,6 +21,9 @@ urlpatterns = [
path('detection//', views.ApiDetection),#废水污染物检测
path('fuel//', views.ApiFuel),#燃料信息表
path('waterequipment//', views.ApiWaterequipment),#废水监测仪器信息表
+ path('archives//', views.ApiArchives),#档案管理表
+ path('zprevention//', views.ApiZprevention),#噪声防治设施
+
diff --git a/enp/views.py b/enp/views.py
index e3a205e7..4690031e 100644
--- a/enp/views.py
+++ b/enp/views.py
@@ -1,9 +1,11 @@
+import time
+import os
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.authentication import BaseAuthentication
-from safesite.models import User
+from safesite.models import User,Dickey,Partment
from rest_framework.exceptions import AuthenticationFailed
-from .models import DWasteHandleRecord, DWasteKeepRecord, DWasteMakeList, DWasteMakeRecord, Drain, GasEmit, NormalWasteRecord, Waste, Facilities,Prevention,abnormal,Detection,Fuel,Waterequipment
+from .models import DWasteHandleRecord, DWasteKeepRecord, DWasteMakeList, DWasteMakeRecord, Drain, GasEmit, NormalWasteRecord, Waste, Facilities,Prevention,abnormal,Detection,Fuel,Waterequipment,Archives
from safesite.views import transjson, fenye, MyEncoder
from django.http import HttpResponse, JsonResponse
import json
@@ -44,8 +46,29 @@ def HtmlWaterequipment(request):
return render(request, 'waterequipment.html')
def HtmlGprevention(request):
return render(request, 'gprevention.html')
+def HtmlArchives(request):
+ return render(request, 'archives.html')
+def HtmlZprevention(request):
+ return render(request, 'zprevention.html')
+# 转换为combobox所用string
-
+
+def transstr(obj, str1, str2):
+ keylist = []
+ for i in list(obj):
+ keydictstr = '{"value":"' + str(i[str1])+'","text":"'+i[str2]+'"}'
+ keylist.append(keydictstr)
+ keystr = '['+','.join(keylist)+']'
+ return keystr
+ # 获取user所在公司
+
+
+def getcompany(x):
+ a = User.objects.get(userid=x)
+ if a.ubelongpart.iscompany == 1:
+ return str(a.ubelongpart.partid)
+ else:
+ return a.ubelongpart.partlink.split(',')[1]
def ApiWaste(request, action):
user = User.objects.get(userid=request.session['userid'])
if action == 'list':
@@ -538,6 +561,64 @@ def ApiWaterequipment(request, action):
obj = Waterequipment.objects.get(id=data['id'])
obj.delete()
return JsonResponse({"code":1})
+#噪声防治设施
+def ApiZprevention(request, action):
+ user = User.objects.get(userid=request.session['userid'])
+ if action == 'list':
+ objs = Prevention.objects.filter(usecomp=user.usecomp, is_deleted=False,preventiontype=3)
+ total = objs.count()
+ startnum, endnum = fenye(request)
+ objs = objs.order_by('-create_time')[startnum:endnum].values('id', 'name', 'number', 'type', 'cs_name',
+ 'desig_nnumber', 'em_unit', 'start_time', 'end_time', 'state','zlxl','clfs','hdl' )
+ return HttpResponse(transjson(total, objs), content_type="application/json")
+ elif action == 'create':
+ data = json.loads(request.body.decode('utf-8'))
+ obj = Prevention()
+ obj.create_by = user
+ obj.update_by = user
+ obj.usecomp = user.usecomp
+ obj.name = data['name']
+ obj.number = data['number']
+ obj.preventiontype=3
+ obj.type = data['type']
+ obj.cs_name = data['cs_name']
+ obj.desig_nnumber = data['desig_nnumber']
+ obj.em_unit = data['em_unit']
+ obj.start_time = data['start_time']
+ obj.end_time = data['end_time']
+ obj.state = data['state']
+ obj.zlxl = data['zlxl']
+ obj.clfs = data['clfs']
+ obj.hdl = data['hdl']
+
+ obj.save()
+ return JsonResponse({"code":1})
+ elif action == 'update':
+ data = json.loads(request.body.decode('utf-8'))
+ obj = Prevention.objects.get(id=data['id'])
+ obj.create_by = user
+ obj.update_by = user
+ obj.usecomp = user.usecomp
+ obj.name = data['name']
+ obj.number = data['number']
+ obj.preventiontype=3
+ obj.type = data['type']
+ obj.cs_name = data['cs_name']
+ obj.desig_nnumber = data['desig_nnumber']
+ obj.em_unit = data['em_unit']
+ obj.start_time = data['start_time']
+ obj.end_time = data['end_time']
+ obj.state = data['state']
+ obj.zlxl = data['zlxl']
+ obj.clfs = data['clfs']
+ obj.hdl = data['hdl']
+ obj.save()
+ return JsonResponse({"code":1})
+ elif action == 'delete':
+ data = json.loads(request.body.decode('utf-8'))
+ obj = Prevention.objects.get(id=data['id'])
+ obj.delete()
+ return JsonResponse({"code":1})
@@ -809,6 +890,73 @@ def ApiGasEmit(request,action):
obj.delete()
return JsonResponse({"code":1})
+#档案管理
+def ApiArchives(req,action):
+ userid = req.session['userid']
+ companyid = getcompany(userid)
+ if action =='dic':
+
+ dicclass=req.GET.get('dicclass')
+ a = Dickey.objects.filter(dicparent=dicclass,deletemark=1)
+ a = a.values('dickeyid','dicparent__dicname','dickeyname','dicparent__dicid','detail').order_by('dickeyid')
+ return HttpResponse(transstr(a,'dickeyid','dickeyname'),content_type="application/json")
+ elif action== 'upload':#文件上传
+ username = User.objects.get(userid=req.session['userid']).username
+ file_name = time.strftime('%Y%m%d%H%M%S')+ '_' + req.FILES ['mf'].name
+ user_upload_folder = os.path.join('media/caozuo', username)
+ if not os.path.exists(user_upload_folder):
+ os.mkdir(user_upload_folder)
+ filepath = os.path.join(user_upload_folder, file_name)
+ filepath = filepath.replace('\\','/')
+ with open( filepath, 'wb') as f:
+ f.write(req.FILES['mf'].read())
+ return JsonResponse({"code":1,"filename":file_name,"filepath":filepath})
+ elif action=='create':#新增档案
+
+ obj = Archives()
+ data = json.loads(req.body.decode('utf-8'))
+ obj.title = data['title']
+ obj.note = data['note']
+ if 'type' in data and data['type']:
+ obj.type= Dickey.objects.get(dickeyid=data['type'])
+ if data['filepath']:
+ obj.path=data['filepath']
+ obj.createuser=User.objects.get(userid=userid)
+ if 'createdate' in data and data['createdate']:
+ obj.createdate=data['createdate']
+ obj.usecomp=Partment.objects.get(partid=companyid)
+ obj.save()
+
+ return JsonResponse({"code":1})
+ elif action=='listall':#责任列表
+ startnum,endnum=fenye(req)
+ a = Archives.objects.filter(usecomp=companyid,deletemark=1).order_by('id')
+ total = a.count()
+ startnum,endnum=fenye(req)
+ a = a[startnum:endnum].values('id','title','path','type__dickeyname','createdate','createuser__name','reads','note')
+ return HttpResponse(transjson(total,a),content_type="application/json")
+ elif action == 'delete':
+ data = json.loads(req.body.decode('utf-8'))
+ obj = Archives.objects.get(id=data['id'])
+ obj.delete()
+ return JsonResponse({"code":1})
+
+ elif action == 'update':
+ data = json.loads(req.body.decode('utf-8'))
+ obj = Archives.objects.get(id=data['id'])
+ obj.title = data['title']
+ obj.note = data['note']
+ if 'type' in data and data['type']:
+ obj.type= Dickey.objects.get(dickeyid=data['type'])
+ if data['filepath']:
+ obj.path=data['filepath']
+ obj.createuser=User.objects.get(userid=userid)
+ if 'createdate' in data and data['createdate']:
+ obj.createdate=data['createdate']
+ obj.usecomp=Partment.objects.get(partid=companyid)
+ obj.save()
+ return JsonResponse({"code":1})
+
import numpy as np
from .predict import GM11
def ApiGasPredict(request, element, drainId):
diff --git a/safesite/models.py b/safesite/models.py
index 63efb9ce..5befb218 100644
--- a/safesite/models.py
+++ b/safesite/models.py
@@ -60,6 +60,8 @@ class Partment(models.Model):
def __str__(self):
return self.partname
+
+
class MySchedule(models.Model):
name = models.CharField('名称', max_length=200)
typeset = models.CharField('类型', default=1,max_length=10)
diff --git a/safesite/static/safesite/easyui/themes/icon.css b/safesite/static/safesite/easyui/themes/icon.css
index 76fa733d..9842488e 100644
--- a/safesite/static/safesite/easyui/themes/icon.css
+++ b/safesite/static/safesite/easyui/themes/icon.css
@@ -271,4 +271,4 @@
}
.icon-feishuijianceyq{
background:url('icons/feishuijianceyq.png') no-repeat center center;
-}
+}
\ No newline at end of file
diff --git a/safesite/static/safesite/easyui/themes/viewui/js/themes/icon.css b/safesite/static/safesite/easyui/themes/viewui/js/themes/icon.css
index c2d3b216..329724b7 100644
--- a/safesite/static/safesite/easyui/themes/viewui/js/themes/icon.css
+++ b/safesite/static/safesite/easyui/themes/viewui/js/themes/icon.css
@@ -94,3 +94,30 @@
.icon-large-chart{
background:url('icons/large_chart.png') no-repeat center center;
}
+
+
+.icon-fspftb{
+ background:url('icons/fspftb.png') no-repeat center center;
+}
+.icon-hanbosheshi{
+ background:url('icons/hanbosheshi.png') no-repeat center center;
+}
+.icon-shengchansheshi{
+ background:url('icons/shengchansheshi.png') no-repeat center center;
+}
+.icon-feiqifangzhiss{
+ background:url('icons/feiqifangzhiss.png') no-repeat center center;
+}
+.icon-feishuifangzhiss{
+ background:url('icons/feishuifangzhiss.png') no-repeat center center;
+}
+.icon-fangzhiyichang{
+ background:url('icons/fangzhiyichang.png') no-repeat center center;
+}
+
+.icon-ranliaoxinxi{
+ background:url('icons/ranliaoxinxi.png') no-repeat center center;
+}
+.icon-feishuijianceyq{
+ background:url('icons/feishuijianceyq.png') no-repeat center center;
+}
diff --git a/safesite/static/safesite/easyui/themes/viewui/js/themes/icons/ranliaoxinxi.png b/safesite/static/safesite/easyui/themes/viewui/js/themes/icons/ranliaoxinxi.png
new file mode 100644
index 00000000..a231af66
Binary files /dev/null and b/safesite/static/safesite/easyui/themes/viewui/js/themes/icons/ranliaoxinxi.png differ
diff --git a/safesite/templates/jianceditu.html b/safesite/templates/jianceditu.html
index 31ce57be..386b2423 100644
--- a/safesite/templates/jianceditu.html
+++ b/safesite/templates/jianceditu.html
@@ -1,9 +1,9 @@
-
-