def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) start_date = date.today().replace(day=1) _, days_in_month = calendar.monthrange(start_date.year, start_date.month) end_date = start_date + timedelta(days=days_in_month) # (('0', '工单已退回'), ('1', '新建-保存'), ('2', '提交-等待审批'), ('3', '已审批-等待执行'), ('4', '已执行-等待确认'), ('5', '工单已完成')) # 当月个人工单状态统计 work_order = WorkOrder.objects.filter( Q(add_time__range=(start_date, end_date)), Q(proposer_id=request.user.id) | Q(receiver_id=request.user.id) | Q(approver_id=request.user.id)) ret['work_order_1'] = work_order.filter(status="1").count() ret['work_order_2'] = work_order.filter(status="2").count() ret['work_order_3'] = work_order.filter(status="3").count() ret['work_order_4'] = work_order.filter(status="4").count() ret['start_date'] = start_date role = Role.objects.get(title='销售') if 'value' in request.GET and int(request.GET['value']) == 1: role = Role.objects.get(title='技术') if role: users = role.userprofile_set.filter(is_active=1).values( 'id', 'name') month_work_order_count = get_month_work_order_count( users, value=int(request.GET.get('value', 0))) year_work_order_count = get_year_work_order_count( users, value=int(request.GET.get('value', 0))) ret['month_work_order_count'] = month_work_order_count ret['year_work_order_count'] = year_work_order_count return render(request, 'personal/personal_index.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) start_date = date.today().replace(day=1) _, days_in_month = calendar.monthrange(start_date.year, start_date.month) end_date = start_date + timedelta(days=days_in_month) # (('0', '工单已退回'), ('1', '新建-保存'), ('2', '提交-等待审批'), ('3', '已审批-等待执行'), ('4', '已执行-等待确认'), ('5', '工单已完成')) # 当月个人工单状态统计 work_order = WorkOrder.objects.filter(Q(add_time__range=(start_date, end_date)), Q(proposer_id=request.user.id) | Q(receiver_id=request.user.id) | Q(approver_id=request.user.id) ) ret['work_order_1'] = work_order.filter(status="1").count() ret['work_order_2'] = work_order.filter(status="2").count() ret['work_order_3'] = work_order.filter(status="3").count() ret['work_order_4'] = work_order.filter(status="4").count() ret['start_date'] = start_date role = Role.objects.get(title='销售') if 'value' in request.GET and int(request.GET['value']) == 1: role = Role.objects.get(title='技术') if role: users = role.userprofile_set.filter(is_active=1).values('id', 'name') month_work_order_count = get_month_work_order_count(users, value=int(request.GET.get('value', 0))) year_work_order_count = get_year_work_order_count(users, value=int(request.GET.get('value', 0))) ret['month_work_order_count'] = month_work_order_count ret['year_work_order_count'] = year_work_order_count return render(request, 'personal/personal_index.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) if 'id' in request.GET and request.GET['id']: asset_use = get_object_or_404(AssetUseLog, pk=request.GET.get('id')) ret['asset_use'] = asset_use ret['asset'] = asset_use.asset return render(request, 'adm/asset/asset_back_use_info.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) type_list = [] for stock_type in Stock.finish_status_choices: type_dict = dict(item=stock_type[0], value=stock_type[1]) type_list.append(type_dict) ret['type_list'] = type_list return render(request, 'personal/stock/stock_create.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) # 审批内容 today = date.today() # 原计划按时间长度搜索,现在不用了。呵呵 start_date = today.replace(day=1) _, days_in_month = calendar.monthrange(start_date.year, start_date.month) end_date = start_date + timedelta(days=days_in_month) # (('0', '审批提交'), ('1', '审批中'), ('2', '审批完成'), ('3', '审批被退回')) # 当月个人立项统计 work_order = WorkOrder.objects.filter( Q(cretor_id=request.user.id) | Q(next_user_id=request.user.id)) ret['work_order_0'] = work_order.filter(cretor=request.user, status__in=['0', '3' ]).count() # 等待中 ret['work_order_1'] = work_order.filter(cretor=request.user, status__in=["1", "5" ]).count() # 审批中 ret['work_order_2'] = work_order.filter(cretor=request.user, status__in=["2", "4"]).count() # 完成 ret['work_order_x'] = work_order.filter( next_user_id=request.user.id, status__in=['1', '0']).count() # 等待我审批的 ret['start_date'] = start_date # 当月个人报销统计 busin_apply = BusinessApply.objects.filter( Q(cretor_id=request.user.id) | Q(next_user_id=request.user.id)) ret['apply_0'] = busin_apply.filter(cretor=request.user, status__in=['0', '3', '-1']).count() ret['apply_1'] = busin_apply.filter(cretor=request.user, status__in=["1", "5"]).count() ret['apply_2'] = busin_apply.filter(cretor=request.user, status__in=["2", "4"]).count() ret['apply_x'] = busin_apply.filter(next_user_id=request.user.id, status__in=['1', '0']).count() current_user_id = request.user.id cashier = SpecialRole.objects.filter(title='0').first() if cashier: if current_user_id == cashier.user.id: ret['work_order_x'] += WorkOrder.objects.filter( status='5').count() ret['apply_x'] += BusinessApply.objects.filter( status='5').count() # 物资到期提醒 three_months = today + timedelta(days=100) structure = request.user.department # 用户所在部门 asset = Asset.objects.filter(Q(dueremind='1'), Q(assetType__structure=structure), Q(dueDate__range=(today, three_months))) ret['asset'] = asset return render(request, 'personal/personal_index.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) status_list = [] for status in Asset.asset_status: status_dict = dict(item=status[0], value=status[1]) status_list.append(status_dict) asset_types = AssetType.objects.all() ret['status_list'] = status_list ret['asset_types'] = asset_types return render(request, 'adm/asset/asset_use.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) status_list = [] for status in Asset.asset_status: status_dict = dict(item=status[0], value=status[1]) status_list.append(status_dict) asset_types = AssetType.objects.all() ret['status_list'] = status_list ret['asset_types'] = asset_types return render(request, 'adm/asset/asset.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) equipment_types = EquipmentType.objects.all() filters = dict() if request.user.department_id == 9: # 销售部门只能看自己的设备信息 filters['belongs_to_id'] = request.user.id customers = Customer.objects.filter(**filters).order_by('unit') ret['equipment_types'] = equipment_types ret['customers'] = customers return render(request, 'adm/equipment/equipment.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) status_list = [] filters = dict() for work_order_status in WorkOrder.status_choices: status_dict = dict(item=work_order_status[0], value=work_order_status[1]) status_list.append(status_dict) if request.user.department_id == 9: # 销售部门只能看自己的设备信息 filters['belongs_to_id'] = request.user.id customers = Customer.objects.filter(**filters).order_by('unit') ret['status_list'] = status_list ret['customers'] = customers return render(request, 'personal/workorder/workorder.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) # 检查路径是否授权 ret.update(SystemSetup.getSystemSetupLastData()) # fields = ['id', 'item', 'user', 'create_time', 'status'] # data = [{'id': 123456, 'facName': "茶山", 'name': "李四", 'address': "宁波", 'status': 3,'begintime': '2020-4-1'}, # {'id': 123456, 'facName': "寒风岭", 'name': "小二", 'address': "大同", 'status': 2,'begintime': '2020-4-1'}, # {'id': 123456, 'facName': "茶山", 'name': "王五", 'address': "宁波", 'status': 3,'begintime': '2020-4-1'}, # {'id': 123456, 'facName': "寒风岭", 'name': "张三", 'address': "大同", 'status': 2,'begintime': '2020-4-1'}, # {'id': 123456, 'facName': "公司", 'name': "小甲", 'address': "杭州", 'status': 1,'begintime': '2020-4-1'}, # ] data = pms.PersonTrack.objects.all() ret['data'] = data return render(request, 'PMsys/pro_overview/pro_overview.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) start_date = date.today().replace(day=1) _, days_in_month = calendar.monthrange(start_date.year, start_date.month) end_date = start_date + timedelta(days_in_month) work_order = WorkOrder.objects.filter( Q(add_time__range=(start_date, end_date)), Q(proposer_id=request.user.id) | Q(receiver_id=request.user.id) | Q(approver_id=request.user.id)) ret['work_order_1'] = work_order.filter(status='1').count() ret['work_order_2'] = work_order.filter(status="2").count() ret['work_order_3'] = work_order.filter(status="3").count() ret['work_order_4'] = work_order.filter(status="4").count() ret['start_date'] = start_date return render(request, 'personal/personal_index.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) # 检查路径是否授权 ret.update(SystemSetup.getSystemSetupLastData()) fields = ['id', 'item_type', 'name', 'status', 'address', 'image'] pms.Items.objects.filter(pk=7) if 'status' in request.session and request.session['status']: val = request.session['status'].split('_')[1] if not val: ret['data'] = pms.Items.objects.all().order_by( '-id').distinct() else: ret['data'] = pms.Items.objects.filter( status=int(val)).order_by('-id').distinct() else: ret['data'] = pms.Items.objects.all() ret['itemfacilitys'] = pms.ItemFacilitys.objects.all() # pms.ItemFacilitys.objects.filter(itempower_items) # print(ret['itemfacilitys'][0].facilitys.get_modal_display()) # print(ret['itemfacilitys'][0].itempower.items) return render(request, 'PMsys/pro_list/pro_list.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'system/rbac/role_list.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) return render(request, 'personal/stock/stock.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) # 审批内容 today = date.today() # 原计划按时间长度搜索,现在不用了。呵呵 start_date = today.replace(day=1) _, days_in_month = calendar.monthrange(start_date.year, start_date.month) end_date = start_date + timedelta(days=days_in_month) # (('0', '审批提交'), ('1', '审批中'), ('2', '审批完成'), ('3', '审批被退回')) # 当月个人立项统计 work_order = WorkOrder.objects.filter( Q(cretor_id=request.user.id) | Q(next_user_id=request.user.id)) ret['work_order_lx'] = work_order.filter(next_user_id=request.user.id, status__in=['1', '0'], type='0').count() # 等待我审批的 ret['work_order_cc'] = work_order.filter(next_user_id=request.user.id, status__in=['1', '0'], type='1').count() # 等待我审批的 ret['start_date'] = start_date # 当月个人报销统计 busin_apply = BusinessApply.objects.filter( Q(cretor_id=request.user.id) | Q(next_user_id=request.user.id)) ret['apply_lx'] = busin_apply.filter(next_user_id=request.user.id, status__in=['1', '0'], type='0').count() ret['apply_cc'] = busin_apply.filter(next_user_id=request.user.id, status__in=['1', '0'], type='1').count() current_user_id = request.user.id cashier = SpecialRole.objects.filter(title='0').first() if cashier: if current_user_id == cashier.user.id: ret['work_order_lx'] += WorkOrder.objects.filter( status='5', type="0").count() ret['work_order_cc'] += WorkOrder.objects.filter( status='5', type="1").count() ret['apply_lx'] += BusinessApply.objects.filter( status='5', type='0').count() ret['apply_cc'] += BusinessApply.objects.filter( status='5', type='1').count() # 物资到期提醒 three_months = today + timedelta(days=100) structure = request.user.department # 用户所在部门 user = request.user if user.is_dep_administrator: asset = AssetInfo.objects.filter( Q(department=structure), Q(due_time__range=(today, three_months))) ret['asset'] = asset ret['asset_num'] = len(asset) gone_asset = AssetInfo.objects.filter(Q(department=structure), Q(due_time__lt=today)) ret['gone_asset'] = gone_asset ret['gone_asset_num'] = len(gone_asset) # 公告相关 bulletin = Bulletin.objects.filter(status='1') bulletin_amount = len(bulletin) ret['bulletin_amount'] = bulletin_amount unread_bulletin_num = request.session.get('unread_bulletin_num') ret['unread_bulletin_num'] = unread_bulletin_num # 物资相关 user_id = request.session.get("_auth_user_id") asset_approve_num = len( AssetApproveDetail.objects.filter(approver_id=user_id, is_pass=None, status='1')) ret['asset_approve_num'] = asset_approve_num # 报表的时间 mon = datetime.now().month year = datetime.now().year if mon == 1: mon = 12 year -= 1 else: mon -= 1 # 个人报表 Q(create_time__month=mon), Q(create_time__year=year), feeid = [] manid = UserProfile.objects.filter(name=request.user)[0].id post = UserProfile.objects.filter(id=manid)[0].post exist = WorkOrder.objects.filter(Q(create_time__month=mon), Q(create_time__year=year), Q(cretor_id=manid), ~Q(status=3), ~Q(status=0), ~Q(status=1)) if len(exist) == 0: ret.update({'status': 0, 'errors_info': '请提交工单在使用'}) else: for x in exist: if x.feeid_id not in feeid and x.feeid_id != None: feeid.append(x.feeid_id) if len(feeid) == 0: ret['status'] = 1 ret['errors_info'] = '你的工单里还没有使用费用类型的工单' else: ret['status'] = 2 feetype = [] allcost = [] perdata = [] for x in feeid: li = FeeType.objects.filter(fee_id=x) if li[0].fee_type not in feetype: feetype.append(li[0].fee_type) for x in feeid: cost = 0 li = WorkOrder.objects.filter(Q(create_time__month=mon), Q(create_time__year=year), Q(feeid_id=x), Q(cretor_id=manid), ~Q(status=3), ~Q(status=0), ~Q(status=1)) for y in li: cost += float(y.cost) allcost.append(cost) for x in range(len(allcost)): dic = {} dic['value'] = allcost[x] dic['name'] = feetype[x] perdata.append(dic) ret.update({'feetype': feetype, 'perdata': perdata}) print(ret) # 部门报表 if len(Structure.objects.filter(adm_list=manid)) != 0: if int(Structure.objects.filter( adm_list=manid)[0].adm_list) == int(manid): struid = Structure.objects.filter(adm_list=manid)[0].id depeople = [] defeeid = [] defeetype = [] decost = [] dedata = [] x = WorkOrder.objects.filter(Q(create_time__month=mon), Q(create_time__year=year), ~Q(status=3), ~Q(status=0), ~Q(status=1), Q(structure_id=struid), ~Q(feeid_id=None)) if len(x) == 0: ret['m'] = 0 else: for y in x: if y.feeid_id not in defeeid: defeeid.append(y.feeid_id) for x in defeeid: li = FeeType.objects.filter(fee_id=x) if li[0].fee_type not in defeetype: defeetype.append(li[0].fee_type) for x in defeeid: cost = 0 li = WorkOrder.objects.filter(Q(feeid=x), ~Q(status=3), ~Q(status=0), ~Q(status=1), Q(structure_id=struid), ~Q(feeid_id=None)) for y in li: cost += float(y.cost) decost.append(cost) for x in range(len(decost)): dic = {} dic['value'] = decost[x] dic['name'] = defeetype[x] dedata.append(dic) depeo = UserProfile.objects.filter(Q(department_id=struid), ~Q(id=manid)) for x in depeo: if x.name not in depeople: depeople.append(x.name) ret.update({ 'depeople': depeople, 'm': 1, 'defeetype': defeetype, 'dedata': dedata }) # 全体员工的报表 if post == '董事长' or post == '总经理': post = UserProfile.objects.filter(name=request.user)[0].post ret['post'] = post totalfeeid = [] totalfeetype = [] totalcost = [] totaldata = [] x = WorkOrder.objects.filter(Q(create_time__month=mon), Q(create_time__year=year), ~Q(status=3), ~Q(status=0), ~Q(status=1)) for y in x: if y.feeid_id not in totalfeeid and y.feeid_id != None: totalfeeid.append(y.feeid_id) for x in totalfeeid: li = FeeType.objects.filter(fee_id=x) if li[0].fee_type not in totalfeetype: totalfeetype.append(li[0].fee_type) for x in totalfeeid: cost = 0 li = WorkOrder.objects.filter(Q(create_time__month=mon), Q(create_time__year=year), Q(feeid=x), ~Q(status=3), ~Q(status=0), ~Q(status=1)) for y in li: cost += float(y.cost) totalcost.append(cost) for x in range(len(totalcost)): dic = {} dic['value'] = totalcost[x] dic['name'] = totalfeetype[x] totaldata.append(dic) ret.update({ 'totalfeetype': totalfeetype, 'totalcost': totalcost, 'totaldata': totaldata, }) return render(request, 'personal/personal_index.html', ret)
def equipmentTypeView(request): if request.method == 'GET': ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'adm/bsm/equipmenttype.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) return render(request, 'personal/workorder/document.html', ret)
def structureView(request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'system/structure/structure-list.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'system/structure')
def menuView(request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) print(ret) return render(request, 'system/rbac/menu-list.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'system/structure/structure-list.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) return render(request, 'bulletin/bulletin_manage.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, "oilWear/vehicle_list.html", ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'adm/asset/address.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'new/xiangmuguanli_list.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'system/tools/email-setup.html', ret)
def get(self, request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'adm/bsm/equipmenttype.html', ret)
def indexView(request): ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'adm/adm_index.html', ret)
def customerView(request): if request.method == 'GET': ret = Menu.getMenuByRequestUrl(url=request.path_info) ret.update(SystemSetup.getSystemSetupLastData()) return render(request, 'adm/bsm/customer.html', ret)
def workOrderDocumentView(request): if request.method == 'GET': ret = Menu.getMenuByRequestUrl(url=request.path_info) return render(request, 'personal/workorder/document.html', ret)