Commit c8062cfd by DESKTOP-E0VCCBD\zedan

update

parent 4b46d3b0
......@@ -10,7 +10,7 @@ async def check_low_stock_and_notify():
async with AsyncSession() as db: # หรือ Depends(get_db)
# 1) หาอุปกรณ์ใกล้หมดในทุกโปรเจ็กต์
stmt = select(ProjectEquipment).where(
ProjectEquipment.quantity_in_project <= ProjectEquipment.low_stock_threshold
ProjectEquipment.quantity_in_project <= 5
)
res = await db.execute(stmt)
lows = res.scalars().all()
......@@ -33,12 +33,12 @@ async def check_low_stock_and_notify():
notif = Notification(
projectId=pe.projectId,
equipmentId=pe.equipmentId,
message=f"อุปกรณ์ {pe.equipmentId} ในโครงการ {pe.projectId} เหลือน้อยกว่า {pe.low_stock_threshold}"
message=f"อุปกรณ์ {pe.equipmentId} ในโครงการ {pe.projectId} เหลือน้อยกว่า 5"
)
db.add(notif)
await db.commit()
def start_notification_scheduler():
scheduler = AsyncIOScheduler()
scheduler.add_job(check_low_stock_and_notify, "interval", hours=24) # ทุก 24 ชม.
scheduler.add_job(check_low_stock_and_notify, "interval", minutes=1) # ทุก 24 ชม.
scheduler.start()
......@@ -152,15 +152,14 @@ export class HomeInstallerComponent {
type: 'datetime',
},
};
companyId: string = '';
constructor(private el: ElementRef, private renderer: Renderer2, private cdr: ChangeDetectorRef, private userService: UserService, public translate: TranslateService, private tokenService: TokenService, private ProjectService: ProjectService, private EquipmentService: EquipmentService, private DashboardService: DashboardService, private route: ActivatedRoute,private comService: ProjectService) {
this.companyId = this.route.snapshot.paramMap.get('companyId')!;
this.comService.getById(this.companyId).subscribe(result => {
projectId = ""
constructor(private el: ElementRef, private renderer: Renderer2, private cdr: ChangeDetectorRef, private userService: UserService, public translate: TranslateService, private tokenService: TokenService, private projectService: ProjectService, private EquipmentService: EquipmentService, private DashboardService: DashboardService, private route: ActivatedRoute,private comService: ProjectService) {
this.projectId = this.route.snapshot.paramMap.get('projectId')!;
this.projectService.getById(this.projectId).subscribe(result => {
console.log("SAVEEE")
this.tokenService.saveSelectCompany(result);
// this.router.navigate(["/company"]);
})
this.chartOptions9 = {
series: [
{
......@@ -920,7 +919,7 @@ export class HomeInstallerComponent {
this.itemsList = result
this.updatePagedItems()
})
this.ProjectService.getLists().subscribe(result => {
this.projectService.getLists().subscribe(result => {
this.projectList = result
})
this.EquipmentService.getLists().subscribe(result => {
......
......@@ -152,7 +152,7 @@ export class NavService implements OnDestroy {
{ headTitle: 'จัดการโครงการ' },
{
icon: 'home',
path: '/company/home/:projectId',
path: '/company/home/'+this.tokenService.getSelectCompany().projectId,
title: 'หน้าแรก',
type: 'link',
selected: false,
......@@ -205,7 +205,7 @@ export class NavService implements OnDestroy {
// { headTitle: 'User Management' }
{
icon: 'home',
path: '/company/home/:projectId',
path: '/company/home/'+this.tokenService.getSelectCompany().projectId,
title: 'หน้าแรก',
type: 'link',
selected: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment