Commit b89e2f8e by liimin

修改导入代码

1 parent 4c10471d
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="mysql://limin:limin1018@192.168.1.129:3306/app_admin?schema=public" DATABASE_URL="mysql://biz_app_admin:JLOVdxXk@192.168.3.222:3306/app_admin?schema=public"
QIWEI_WEBHOOK='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=8541005c-5f60-416b-821e-64b4d872cd77' QIWEI_WEBHOOK='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=16eaf975-65bc-4a7c-b744-a81f6236acc2'
SOCKET_PORT= 8080 SOCKET_PORT= 8080
APP_PORT= 3000 APP_PORT= 3000
STATIC_PATH = "public" STATIC_PATH = "public"
......
...@@ -29,7 +29,6 @@ export class BroadcastService { ...@@ -29,7 +29,6 @@ export class BroadcastService {
if (param?.code == RESPONSE_CODE.SUCCESS && param?.data?.command === Command.RemoveLog) { if (param?.code == RESPONSE_CODE.SUCCESS && param?.data?.command === Command.RemoveLog) {
const statusInfo: DeviceStatus.IDeviceStatus = { device_id: param.device_id, last_log_remove_time: new Date() } const statusInfo: DeviceStatus.IDeviceStatus = { device_id: param.device_id, last_log_remove_time: new Date() }
this.eventEmitter.emit(Events.OnLogFileRemoved, statusInfo) this.eventEmitter.emit(Events.OnLogFileRemoved, statusInfo)
return
} }
const res: AxiosResponse<any, any> = await this.httpService const res: AxiosResponse<any, any> = await this.httpService
.post(this.webHook, { .post(this.webHook, {
......
...@@ -217,13 +217,29 @@ export class DeviceService implements OnModuleInit { ...@@ -217,13 +217,29 @@ export class DeviceService implements OnModuleInit {
} }
async addAll(devices: Array<any>): Promise<CommonTypes.IResponseBase> { async addAll(devices: Array<any>): Promise<CommonTypes.IResponseBase> {
// devices =[
// {
// "设备编号": "26DYD23B25202154",
// "APP编码": "4DF8801064461802495A2452CCD04EE4",
// "保管人": "葛阳阳",
// "手机号": 15009585544,
// "品牌": "鸿蒙智行",
// "直营": "否",
// "业务场景": "延保",
// "督导": "刘洁琼",
// "最近使用时间": "2024-11-01",
// "最近使用人": "葛阳阳",
// "最近使用人所在门店": "银川华为2.(44212813)",
// "修改日期": "2024-09-19"
// },
// ]
for (let index = 0; index < devices.length; index++) { for (let index = 0; index < devices.length; index++) {
const el = devices[index] const el = devices[index]
await this.prisma.$transaction(async prisma => { await this.prisma.$transaction(async prisma => {
const { id } = await prisma.device.create({ data: { sn: el.设备编号 }, select: { id: true } }) const { id } = await prisma.device.create({ data: { sn: el.APP编码 }, select: { id: true } })
await prisma.device_info.create({ data: { device_id: id, mobile: el.手机号, merchant_name: el.最近使用人所在门店 || '', user: el.保管人, created_at: new Date(), updated_at: new Date() } }) await prisma.device_info.create({ data: { device_id: id, mobile: el.手机号 + '', merchant_name: el.最近使用人所在门店 || '', user: el.保管人, created_at: new Date(), updated_at: new Date() } })
await prisma.device_status.create({ data: { device_id: id, status: WsStatus.Offline, last_log_remove_time: new Date() } }) await prisma.device_status.create({ data: { device_id: id, status: WsStatus.Offline, last_log_remove_time: new Date() } })
await prisma.log_config.create({ data: { device_id: id, log_saved_days: 7 } }) await prisma.log_config.create({ data: { device_id: id, log_saved_days: 30 } })
await prisma.field_relation.createMany({ await prisma.field_relation.createMany({
data: [ data: [
{ device_id: id, field_id: 1 }, { device_id: id, field_id: 1 },
......
...@@ -30,7 +30,7 @@ export class FileController { ...@@ -30,7 +30,7 @@ export class FileController {
@Post('upload') @Post('upload')
@UsePipes(new FilePathPipe()) @UsePipes(new FilePathPipe())
@ApiOperation({ summary: '文件上传' }) @ApiOperation({ summary: '文件上传' })
@UploadFile('file', { fileFilter: FileMimeTypeFilter('text/plain'), limits: { fileSize: 1024 * 1024 * 100 } }) @UploadFile('file', { fileFilter: FileMimeTypeFilter('text/plain') })
async upload(@UploadedFile() file: Express.Multer.File, @Req() req: Request): Promise<CommonTypes.IResData<FileTypes.FileUpload<DocTypes>>> { async upload(@UploadedFile() file: Express.Multer.File, @Req() req: Request): Promise<CommonTypes.IResData<FileTypes.FileUpload<DocTypes>>> {
const { fieldname, encoding, stream, buffer, path: origin_path, ...o } = file const { fieldname, encoding, stream, buffer, path: origin_path, ...o } = file
const bodyData: Pick<FileTypes.FileUpload<DocTypes>, 'device_id' | 'type'> = { device_id: Number(req.body.deviceId), type: req.body.type } const bodyData: Pick<FileTypes.FileUpload<DocTypes>, 'device_id' | 'type'> = { device_id: Number(req.body.deviceId), type: req.body.type }
......
# http://localhost:3000/device?user=尹 # http://localhost:3000/device?user=尹
# http://localhost:3000/device/addAll http://localhost:3000/device/addAll
# http://localhost:3000/device/task # http://localhost:3000/device/task
...@@ -34,19 +34,19 @@ ...@@ -34,19 +34,19 @@
POST http://localhost:3000/broadcast/cmd HTTP/1.1 # POST http://localhost:3000/broadcast/cmd HTTP/1.1
content-type: application/json # content-type: application/json
{ # {
"event":"private", # "event":"private",
"device_id":"1000068", # "device_id":"1000068",
"data":{ # "data":{
"command":"getLog", # "command":"getLog",
"days":2, # "days":20,
"interval":1000, # "interval":1000,
"force":true # "force":true
} # }
} # }
# http://localhost:3000/file/list?device_id=1000000 # http://localhost:3000/file/list?device_id=1000000
# http://localhost:3000/config?device_id=1000000 # http://localhost:3000/config?device_id=1000000
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!