This commit is contained in:
commit
33b8f17e99
|
@ -457,9 +457,9 @@ def drequipments(companyid,path):
|
|||
numsdict[num]=name
|
||||
i = i+1
|
||||
if numsdict:
|
||||
return {'code':1,'msg':'全部导入成功!'}
|
||||
else:
|
||||
return {'code':2,'msg':'部分未导入成功!','info':numsdict}
|
||||
else:
|
||||
return {'code':1,'msg':'全部导入成功!'}
|
||||
|
||||
|
||||
def drusers(companyid,path):
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# Generated by Django 2.2.8 on 2021-12-19 18:12
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0390_auto_20211006_1819'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CheckList',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='清单名称')),
|
||||
('qrcode', models.CharField(blank=True, max_length=200, null=True)),
|
||||
('createtime', models.DateTimeField(default=django.utils.timezone.now, verbose_name='创建时间')),
|
||||
('updatetime', models.DateTimeField(auto_now=True)),
|
||||
('deletemark', models.IntegerField(default=1)),
|
||||
('createby', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='checklist_createby', to='safesite.User')),
|
||||
('updateby', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='checklist_updateby', to='safesite.User')),
|
||||
('usecomp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.Partment', verbose_name='所属公司')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='operspxq',
|
||||
name='suggestion',
|
||||
field=models.CharField(blank=True, max_length=200, null=True),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CheckListItem',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('content', models.TextField(verbose_name='检查项目')),
|
||||
('checklist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.CheckList', verbose_name='关联检查表')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -695,7 +695,8 @@ class Operspxq(models.Model): # 作业审批流
|
|||
Partment, on_delete=models.CASCADE, null=True, blank=True)
|
||||
spr = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
action = models.CharField(max_length=200)
|
||||
checked = models.IntegerField(default=1) # 0未通过,1通过,2提交
|
||||
suggestion = models.CharField(max_length=200, null=True, blank=True)
|
||||
checked = models.IntegerField(default=1) # 0未通过,1通过,2提交上级,3未通过
|
||||
submittime = models.DateTimeField(default=timezone.now)
|
||||
|
||||
|
||||
|
@ -1450,3 +1451,23 @@ class SafeFeedBack(models.Model):
|
|||
content = models.TextField('反馈内容')
|
||||
createtime = models.DateTimeField(default=timezone.now, verbose_name="创建时间")
|
||||
updatetime = models.DateTimeField(auto_now=True)
|
||||
|
||||
class CheckList(models.Model):
|
||||
"""
|
||||
检查表
|
||||
"""
|
||||
name = models.CharField('清单名称', max_length=200)
|
||||
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name="所属公司")
|
||||
qrcode = models.CharField(max_length=200, blank=True, null=True) # 检查表二维码
|
||||
createtime = models.DateTimeField(default=timezone.now, verbose_name="创建时间")
|
||||
updatetime = models.DateTimeField(auto_now=True)
|
||||
createby = models.ForeignKey(User, on_delete=models.CASCADE, related_name='checklist_createby')
|
||||
updateby = models.ForeignKey(User, on_delete=models.CASCADE, related_name='checklist_updateby')
|
||||
deletemark = models.IntegerField(default=1)
|
||||
|
||||
class CheckListItem(models.Model):
|
||||
"""
|
||||
检查表条目
|
||||
"""
|
||||
content = models.TextField('检查项目')
|
||||
checklist = models.ForeignKey(CheckList, on_delete=models.CASCADE, verbose_name='关联检查表')
|
|
@ -382,12 +382,12 @@
|
|||
removeLoading();
|
||||
if (data.code == 1) {
|
||||
$.messager.alert('提示', data.msg, 'info', function () {
|
||||
$("#main").panel({ href: 'html/equipment', title: '设备设施' });
|
||||
$("#sbtable").datagrid('reload');
|
||||
});
|
||||
}
|
||||
else if (data.code == 2) {
|
||||
$.messager.alert('提示', data.msg + data.info, 'info', function () {
|
||||
$("#main").panel({ href: 'html/equipment', title: '用户' });
|
||||
$("#sbtable").datagrid('reload');
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -44,7 +44,7 @@ from .models import CompanyInfo
|
|||
from .safespider import getAqzs, getTzzs
|
||||
from .tasks import (gettime, send_wechatmsg, send_wechatmsgs, updateAqzs,
|
||||
updateTzzs, yjjs, yjjs_gc, yjjs_px, yjjs_ws, yjjs_yl)
|
||||
|
||||
from django.db import transaction
|
||||
from datetime import date, datetime, timedelta
|
||||
logger = logging.getLogger('log')
|
||||
|
||||
|
@ -4027,11 +4027,8 @@ def drapi(req):
|
|||
with open(filepath, 'wb') as f:
|
||||
f.write(req.FILES['upfile'].read())
|
||||
# try:
|
||||
equipmentdict = drequipments(companyid, filepath)
|
||||
if equipmentdict:
|
||||
return JsonResponse({"code": 2, "equipmentdict": equipmentdict})
|
||||
else:
|
||||
return JsonResponse({"code": 1})
|
||||
ret = drequipments(companyid, filepath)
|
||||
return JsonResponse(ret)
|
||||
elif a == 'risk':
|
||||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
|
@ -5472,6 +5469,7 @@ def apinotice(req):
|
|||
return JsonResponse({"code": 1, 'downloadurl': v})
|
||||
|
||||
@apicheck_login
|
||||
@transaction.atomic
|
||||
def apioperation(req):
|
||||
a = req.GET.get('a')
|
||||
userid = req.session['userid']
|
||||
|
@ -5598,6 +5596,133 @@ def apioperation(req):
|
|||
}
|
||||
send_wechatmsgs.delay(postdict, b)
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'edit':
|
||||
userid = req.session['userid']
|
||||
oneuser = User.objects.get(userid=userid)
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj = Operation.objects.get(zyid=data['zyid'])
|
||||
obj.zydd = data['zydd']
|
||||
obj.zynr = data['zynr']
|
||||
obj.kssj = data['kssj']
|
||||
obj.jssj = data['jssj']
|
||||
if 'zyqy' in data:
|
||||
obj.zyqy = Area.objects.get(
|
||||
id=data['zyqy']) if data['zyqy'] else None
|
||||
obj.zylx = Dickey.objects.get(dickeyid=data['zylx'])
|
||||
obj.zybm = oneuser.ubelongpart
|
||||
if 'zybm' in data:
|
||||
obj.zybm = Partment.objects.get(partid=data['zybm'])
|
||||
obj.sdbm = Partment.objects.get(partid=data['sdbm'])
|
||||
obj.zyfzr = oneuser
|
||||
if 'zyfzr' in data:
|
||||
obj.zyfzr = User.objects.get(userid=data['zyfzr'])
|
||||
obj.usecomp = oneuser.usecomp
|
||||
if 'splc' in data:
|
||||
if data['splc']==0:#无审批
|
||||
obj.zyzt = {'zyzt':'待关闭','index':0,'splc':0}
|
||||
obj.save()
|
||||
for i in data['zyry']:
|
||||
Operzyry.objects.create(oper=obj, operzyry=User.objects.get(userid=i), checked=1)
|
||||
return JsonResponse({"code": 1})
|
||||
if 'zyimg' in data:
|
||||
obj.zyimg = '?'.join(data['zyimg'])
|
||||
obj.fxcs = '?'.join(map(str, data['fxcs']))
|
||||
obj.zyzt = {'zyzt': '确认中', 'index': 0}
|
||||
splc = []
|
||||
if 'spr1s' in data:
|
||||
spr1s = [data['spr1s']]
|
||||
else:
|
||||
spr1s = getsprs(userid, obj.zybm)
|
||||
if 'spr2s' in data:
|
||||
spr2s = [data['spr2s']]
|
||||
else:
|
||||
spr2s = getsprs(userid, obj.sdbm)
|
||||
splc.append({'jdmc': '作业负责人审批', 'sprs': [userid]})
|
||||
splc.append({'jdmc': '作业部门审批', 'sprs': spr1s})
|
||||
splc.append({'jdmc': '属地部门审批', 'sprs': spr2s})
|
||||
for i in Operationspjd.objects.filter(zylx=obj.zylx, usecomp=Partment.objects.get(partid=getcompany(userid))).order_by('id'):
|
||||
splc.append({'jdmc': i.jdmc, 'sprs': i.sprs})
|
||||
obj.zyzt['splc'] = splc
|
||||
obj.save()
|
||||
# Operspxq.objects.create(oper=obj,jdmc='作业负责人审批',spr=obj.zyfzr,checked=1,spbm=obj.zyfzr.ubelongpart)
|
||||
b = [] # 发送通知
|
||||
for i in data['zyry']:
|
||||
x = User.objects.get(userid=i)
|
||||
if int(userid) == int(i): # 申请人包含作业人直接确认
|
||||
Operzyry.objects.create(oper=obj, operzyry=x, checked=1)
|
||||
else:
|
||||
Operzyry.objects.create(oper=obj, operzyry=x)
|
||||
b.append(x.openid)
|
||||
if b:
|
||||
pass
|
||||
else: # 工作人员全部确认
|
||||
obj.zyzt['zyzt'] = '审批中'
|
||||
obj.zyzt['index'] = 0
|
||||
index = obj.zyzt['index']
|
||||
sprs = [] # 初始化审批人列表
|
||||
if 'sprs' in obj.zyzt['splc'][index]:
|
||||
sprs = obj.zyzt['splc'][index]['sprs']
|
||||
else:
|
||||
sprs = [obj.zyzt['splc'][index]['spr']]
|
||||
jdmc = obj.zyzt['splc'][index]['jdmc']
|
||||
obj.zyzt['jdmc'] = jdmc
|
||||
obj.todousers = sprs
|
||||
obj.save()
|
||||
Operspxq.objects.create(
|
||||
oper=obj, jdmc='重新提交', spr=oneuser, checked=1)
|
||||
postdict = {
|
||||
'touser': '',
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
'miniprogram': {'appid': 'wx5c39b569f01c27db'},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': obj.zylx.dickeyname + '作业审批,审批节点:' + obj.zyzt['jdmc']
|
||||
},
|
||||
'keyword1': {
|
||||
'value': obj.zynr
|
||||
},
|
||||
'keyword2': {
|
||||
'value': obj.kssj
|
||||
},
|
||||
'keyword3': {
|
||||
'value': obj.zydd
|
||||
},
|
||||
'remark': {
|
||||
'value': '请您及时完成审批!'
|
||||
}
|
||||
}
|
||||
}
|
||||
tolist = list(User.objects.filter(
|
||||
userid__in=sprs).values_list('openid', flat=True))
|
||||
send_wechatmsgs.delay(postdict, tolist)
|
||||
|
||||
return JsonResponse({"code": 1})
|
||||
postdict = {
|
||||
'touser': '',
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram": {"appid": "wx5c39b569f01c27db"},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': obj.zylx.dickeyname + '作业通知:'
|
||||
},
|
||||
'keyword1': {
|
||||
'value': obj.zynr
|
||||
},
|
||||
'keyword2': {
|
||||
'value': obj.kssj
|
||||
},
|
||||
'keyword3': {
|
||||
'value': obj.zydd
|
||||
},
|
||||
'remark': {
|
||||
'value': obj.zyfzr.name+'为作业负责人,请确认参与作业'
|
||||
}
|
||||
}
|
||||
}
|
||||
send_wechatmsgs.delay(postdict, b)
|
||||
Operspxq.objects.create(
|
||||
oper=obj, jdmc='重新提交', spr=oneuser, checked=1)
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'listall':
|
||||
userid = req.session['userid']
|
||||
usecomp = User.objects.get(userid=userid).usecomp
|
||||
|
@ -5664,12 +5789,8 @@ def apioperation(req):
|
|||
elif a == 'detail':
|
||||
zyid = req.GET.get('zyid')
|
||||
a = Operation.objects.filter(zyid=zyid)
|
||||
x = a.values('zyid', 'zydd', 'zylx__dickeyname', 'zynum', 'zyfzr__name', 'zynr', 'zyzt', 'zyimg',
|
||||
x = a.values('zyid', 'zydd', 'zylx__dickeyname', 'zynum', 'zyfzr__name', 'zynr', 'zyzt', 'zyimg', 'zylx', 'sdbm',
|
||||
'submittime', 'zybm__partname', 'sdbm__partname', 'kssj', 'jssj', 'fxcs', 'zyimg2','zyqy__name')[0]
|
||||
if x['zyzt']['splc']:
|
||||
for i in x['zyzt']['splc']:
|
||||
i['sprs'] = ','.join(list(User.objects.filter(
|
||||
userid__in=i['sprs']).values_list('name', flat=True)))
|
||||
if x['zyimg'] != '':
|
||||
x['zyimg'] = x['zyimg'].split('?')
|
||||
else:
|
||||
|
@ -5678,19 +5799,26 @@ def apioperation(req):
|
|||
x['zyimg2'] = x['zyimg2'].split('?')
|
||||
else:
|
||||
x['zyimg2'] = []
|
||||
x['fxcs'] = list(Fxcs.objects.filter(
|
||||
id__in=x['fxcs'].split('?')).values('id', 'fxfx', 'aqcs', 'cslx'))
|
||||
x['fxcs'] = [int(i) for i in x['fxcs'].split('?')]
|
||||
x['fxcs_'] = list(Fxcs.objects.filter(
|
||||
id__in=x['fxcs']).values('id', 'fxfx', 'aqcs', 'cslx'))
|
||||
# 确认详情
|
||||
qrxqobjs = Operzyry.objects.filter(
|
||||
oper=Operation.objects.get(zyid=zyid))
|
||||
qrxq = qrxqobjs.values('operzyry__name', 'checked')
|
||||
x['qrxq'] = list(qrxq)
|
||||
x['zyry'] = ','.join(
|
||||
x['zyry'] = list(qrxqobjs.values_list('operzyry__userid', flat=True))
|
||||
x['zyry_names'] = ','.join(
|
||||
list(qrxqobjs.values_list('operzyry__name', flat=True)))
|
||||
# 审批详情
|
||||
spxq = Operspxq.objects.filter(oper=Operation.objects.get(zyid=zyid)).order_by(
|
||||
'submittime').values('jdmc', 'spbm__partname', 'spr__name', 'submittime', 'checked')
|
||||
'submittime').values('jdmc', 'spbm__partname', 'spr__name', 'submittime', 'checked', 'suggestion')
|
||||
x['spxq'] = list(spxq)
|
||||
x['lastsuggestion'] = x['spxq'][-1]['suggestion'] if len(x['spxq']) >=1 else ''
|
||||
if 'splc' in x['zyzt']:
|
||||
for i in x['zyzt']['splc']:
|
||||
i['sprs'] = ','.join(list(User.objects.filter(
|
||||
userid__in=i['sprs']).values_list('name', flat=True)))
|
||||
return HttpResponse(json.dumps(x, cls=MyEncoder), content_type="application/json")
|
||||
else:
|
||||
return HttpResponse(json.dumps(x, cls=MyEncoder), content_type="application/json")
|
||||
|
@ -5806,6 +5934,36 @@ def apioperation(req):
|
|||
send_wechatmsgs.delay(postdict, tolist)
|
||||
return JsonResponse({"code": 1})
|
||||
nextindex = nextindex + 1
|
||||
if 'bhzy' in data: # 如果驳回作业
|
||||
Operspxq.objects.create(
|
||||
oper=obj, jdmc=obj.zyzt['splc'][oldindex]['jdmc'], spr=spruser, checked=3, spbm=spruser.ubelongpart, suggestion=data.get('suggestion', None))
|
||||
obj.zyzt = {'zyzt': '驳回修改中', 'index': -1}
|
||||
obj.todouser = obj.zyfzr
|
||||
obj.save()
|
||||
postdict = {
|
||||
'touser': obj.todouser.openid,
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
'miniprogram': {'appid': 'wx5c39b569f01c27db'},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': obj.zylx.dickeyname + '作业审批未通过:'
|
||||
},
|
||||
'keyword1': {
|
||||
'value': obj.zynr
|
||||
},
|
||||
'keyword2': {
|
||||
'value': obj.kssj
|
||||
},
|
||||
'keyword3': {
|
||||
'value': obj.zydd
|
||||
},
|
||||
'remark': {
|
||||
'value': '你是作业负责人,请及时修改作业申请并重新提交!'
|
||||
}
|
||||
}
|
||||
}
|
||||
send_wechatmsg.delay(postdict)
|
||||
return JsonResponse({"code": 1})
|
||||
if 'zjsp' in data: # 转交上级审批
|
||||
if spruser.ubelongpart.parentid:
|
||||
newsprs = getsprs(userid, spruser.ubelongpart.parentid)
|
||||
|
|
Loading…
Reference in New Issue