Consts and Fields

const

存在于metadata, JIT 直接把值放入IL


如果另外一个assembly需要在执行时得到const的值,需要使用readonly的字段。


volatile

import { Service } from "egg"; export default class ExportAutoMeasureModule extends Service{ public async getMachineTime(){ console.log("measuremachinetime被调用"); const date = new Date(); date.setDate(date.getDate() - 1); const yesterdayStr = this.formatDate(date); //console.log("请求", this.ctx.request) const data = this.ctx.request.body; console.log("请求负载", data); const { formdata } = data; const datePicker = formdata._value.datePicker || []; //console.log(datePicker[0]) const startdatestr = datePicker.length > 0 ? this.formatDate(new Date(datePicker[0])) : yesterdayStr; const enddatestr = datePicker.length > 1 ? this.formatDate(new Date(datePicker[1])) : yesterdayStr; const machineGroups = formdata._value.filterMachineGroup || []; const measureRawData = await this.getMeasureRawData(machineGroups, startdatestr, enddatestr); const measureData = this.processMeasureTimeData(measureRawData); //console.log("measureData", measureData) const aggmethod = formdata._value.filterAggreMethod || ''; const result = this.aggregateAndCalculate(aggmethod, measureData); //console.log(result) return result; } private async getMeasureRawData(machineGroups: string[], startdatestr: string, enddatestr: string){ let measureMachineCondition = ` where t.machinename = q.machinename and t.machinetype = 'Measure' and (t.PE != 'YE1' and t.PE != 'BR' and t.PE != 'OQA') and (t.machinegroupname != 'SNPG' and t.machinegroupname != 'SVOC' and t.machinegroupname != 'MRSM' and t.machinegroupname != 'LPUI' and t.machinegroupname != 'IBFT' and t.machinegroupname != 'ITMW' and t.machinegroupname != 'IWBA' and t.machinegroupname != 'LAMO' and t.machinegroupname != 'LMDI') ` if(Array.isArray(machineGroups) && machineGroups.length > 0){ const quoteGroups = machineGroups.map(g => `'${g}'`).join(','); measureMachineCondition += ` and t.machinegroupname in (${quoteGroups})`; } const sql = ` with MeasureMachine as ( select t.machinename, t.description, t.machinegroupname, q.machinecapabilityname from RPT.BASE_MACHINE t, RPT.BASE_MACHINECAPABILITY q ${measureMachineCondition} order by t.machinename), YesterdayData as ( select d.factorydate, d.eqpid, TO_CHAR(to_date(d.factorydate, 'yyyyMMdd'), 'yyyy') || 'WW'|| TO_CHAR(to_date(d.factorydate, 'yyyyMMdd'), 'iW') as week, TO_CHAR(to_date(d.factorydate, 'yyyyMMdd'), 'MM') as month, d.tottime, round(d.uptime, 3) as uptime, round(d.downtime, 3) as downtime, round(d.idle, 3) as idletime, round(d.mon_rou, 3) as mon_rou from RPT.EQP_EVENT_HISTORY d where d.factorydate between '${startdatestr}' and '${enddatestr}' ) select a.*, b.* from MeasureMachine a join YesterdayData b on a.machinename = b.eqpid order by a.machinename, b.factorydate ` //console.log("查询", sql) const result = await this.ctx.service.oracleService.executeQuery( "FA", sql ); return result; } private processMeasureTimeData(rawdata: any[]){ return rawdata.map(item => { const { DOWNTIME, ...rest} = item; const processedDowntime = item.DOWNTIME - item.MON_ROU; const productionTime = 24 - item.IDLETIME - item.MON_ROU - processedDowntime; return { ...rest, DOWNTIME: processedDowntime, PRODUCTIONTIME: productionTime }; }); } private aggregateAndCalculate(aggmethod: string, data: any[]){ // console.log("aggmethod", aggmethod) const result: any[] = []; const fieldsToCopy = ['MACHINENAME', 'FACTORYDATE', 'WEEK', 'MONTH', 'TOTTIME', 'DOWNTIME', 'IDLETIME', 'MON_ROU', 'PRODUCTIONTIME']; // 聚合方式(Daily/Weekly/Monthly) const method = (aggmethod ? aggmethod : 'Daily').toLowerCase(); //console.log("method", method) const roundTo3Decimals = (num: number) => { const fixedNum = Math.round(num * 1000) / 1000; return fixedNum.toFixed(3) } if (method === 'daily') { data.forEach(item => { const monRatio = item.TOTTIME ? ((item.MON_ROU / item.TOTTIME) * 100).toFixed(2) : '0.00'; const productionRatio = item.TOTTIME ? ((item.PRODUCTIONTIME / item.TOTTIME) * 100).toFixed(2) : '0.00'; // 提取除fieldsToCopy外其他字段 const otherFields = Object.keys(item).reduce((acc, key) => { if (!fieldsToCopy.includes(key.toUpperCase())) { acc[key] = item[key]; } return acc; }, {} as Record<string, any>); result.push({ MACHINENAME: item.MACHINENAME, FACTORYDATE: item.FACTORYDATE, WEEK: item.WEEK, MONTH: item.MONTH, TOTTIME: item.TOTTIME, DOWNTIME: roundTo3Decimals(item.DOWNTIME), IDLETIME: roundTo3Decimals(item.IDLETIME), MON_ROU: roundTo3Decimals(item.MON_ROU), PRODUCTIONTIME: roundTo3Decimals(item.PRODUCTIONTIME), MON_RATIO: `${parseFloat(monRatio)}%`, PRODUCTION_RATIO: `${parseFloat(productionRatio)}%`, ...otherFields }); }) } else { const groupedData: { [key: string]: any } = {}; data.forEach(item => { let key: string; if (method === 'weekly') { key = `${item.MACHINENAME}-${item.WEEK}`; } else if (method === 'monthly') { key = `${item.MACHINENAME}-${item.MONTH}`; } else { return; } if (!groupedData[key]) { groupedData[key] = { MACHINENAME: item.MACHINENAME, WEEK: method === 'weekly' ? item.WEEK : undefined, MONTH: method === 'monthly' ? item.MONTH : undefined, TOTTIME: 0, DOWNTIME: 0, IDLETIME: 0, MON_ROU: 0, PRODUCTIONTIME: 0, otherFields: {} }; } groupedData[key].TOTTIME += item.TOTTIME; groupedData[key].DOWNTIME += item.DOWNTIME; groupedData[key].IDLETIME += item.IDLETIME; groupedData[key].MON_ROU += item.MON_ROU; groupedData[key].PRODUCTIONTIME += item.PRODUCTIONTIME; // 只保留第一条记录的其他字段 if (Object.keys(groupedData[key].otherFields).length === 0) { Object.keys(item).forEach(k => { if (!fieldsToCopy.includes(k.toUpperCase())) { groupedData[key].otherFields[k] = item[k]; } }); } }); for (const key in groupedData){ const item = groupedData[key]; const monRatio = item.TOTTIME ? ((item.MON_ROU / item.TOTTIME) * 100).toFixed(2) : '0.00'; const productionRatio = item.TOTTIME ? ((item.PRODUCTIONTIME / item.TOTTIME) * 100).toFixed(2) : '0.00'; result.push({ MACHINENAME: item.MACHINENAME, WEEK: item.WEEK, MONTH: item.MONTH, TOTTIME: item.TOTTIME, DOWNTIME: roundTo3Decimals(item.DOWNTIME), IDLETIME: roundTo3Decimals(item.IDLETIME), MON_ROU: roundTo3Decimals(item.MON_ROU), PRODUCTIONTIME: roundTo3Decimals(item.PRODUCTIONTIME), MON_RATIO: `${parseFloat(monRatio)}%`, PRODUCTION_RATIO: `${parseFloat(productionRatio)}%`, ...item.otherFields }); } } return result; } private formatDate(date: Date):string{ const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); return `${year}${month}${day}`; } public async getMachineGroupOptions(){ console.log("getMachineGroupOptions被调用"); const result = await this.getMachineGroups(); return result; } private async getMachineGroups(){ const sql = ` select distinct t.machinegroupname from RPT.BASE_MACHINE t where t.machinetype = 'Measure' and (t.PE != 'YE1' and t.PE != 'BR' and t.PE != 'OQA') and (t.machinegroupname != 'SNPG' and t.machinegroupname != 'SVOC' and t.machinegroupname != 'MRSM' and t.machinegroupname != 'LPUI' and t.machinegroupname != 'IBFT' and t.machinegroupname != 'ITMW' and t.machinegroupname != 'IWBA' and t.machinegroupname != 'LAMO' and t.machinegroupname != 'LMDI') order by t.machinegroupname ` const result = await this.ctx.service.oracleService.executeQuery( "FA", sql ); return result; } public async getMachineCapability(){ } } 请帮我分析这段service代码
最新发布
11-21
1、Experiment purpose (1)Write the txt file. (2)Class definition. (3)Function application. (4)Selections. (5)Loops 2、Experiment task Project 1: Define the Rectangle2D class that contains: Two double data fields named x and y that specify the center of the rectangle with constant get functions and set functions. (Assume that the rectangle sides are parallel to x- or y-axes.) The double data fields width and height with constant get functions and set functions. A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A constructor that creates a rectangle with the specified x, y, width, and height. A constant function getArea() that returns the area of the rectangle. A constant function getPerimeter() that returns the perimeter of the rectangle. A constant function contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle. See Figure a. A constant function contains(const Rectangle2D &r) that returns true if the specified rectangle is inside this rectangle. See Figure b. A constant function overlaps(const Rectangle2D &r) that returns true if the specified rectangle overlaps with this rectangle. See Figure c. Draw the UML for the class. Implement the class. Write a test program that creates three Rectangle2D objects r1(2, 2, 5.5, 4.9), r2(4, 5, 10.5, 3.2)), and r3(3, 5, 2.3, 5.4), and displays r1’s area and perimeter, and displays the result of r1.contains(3, 3), r1.contains(r2), and r1.overlaps(r3). And save all these results in the txt file that is called Result.txt.写一段c++代码
06-06
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值