|
|
@ -2,13 +2,13 @@ |
|
|
|
const moment = require('moment'); |
|
|
|
|
|
|
|
//设备维护记录
|
|
|
|
async function getEquipment(ctx) { |
|
|
|
async function getEquipment (ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc |
|
|
|
const sequelize = ctx.fs.dc.ORM |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { startTime, endTime, pageSize, pageIndex, projectId } = ctx.query |
|
|
|
console.log('ressss', ctx.query) |
|
|
|
|
|
|
|
let whereOption = {} |
|
|
|
if (projectId) { |
|
|
|
whereOption.projectId = projectId |
|
|
@ -16,7 +16,6 @@ async function getEquipment(ctx) { |
|
|
|
whereOption = undefined |
|
|
|
} |
|
|
|
|
|
|
|
//console.log('6666', ctx.query)
|
|
|
|
let resCount = await models.EquipmentMaintenanceRecord.count({ |
|
|
|
include: [{ |
|
|
|
model: models.EquipmentMaintenanceRecordProject, |
|
|
@ -28,8 +27,6 @@ async function getEquipment(ctx) { |
|
|
|
// sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '>=', moment(startTime).format('YYYY-MM-DD HH:mm:ss')),
|
|
|
|
// sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '<=', moment(endTime).format('YYYY-MM-DD HH:mm:ss')),
|
|
|
|
// ],
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
const res = await models.EquipmentMaintenanceRecord.findAll({ |
|
|
@ -54,7 +51,6 @@ async function getEquipment(ctx) { |
|
|
|
// sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '>=', moment(startTime).format('YYYY-MM-DD HH:mm:ss')),
|
|
|
|
// sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '<=', moment(endTime).format('YYYY-MM-DD HH:mm:ss')),
|
|
|
|
// ],
|
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
//用户id
|
|
|
@ -105,13 +101,13 @@ async function getEquipment(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
//编辑和新增
|
|
|
|
async function editEquipment(ctx) { |
|
|
|
async function editEquipment (ctx) { |
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
|
const query = ctx.request.body |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc |
|
|
|
const sequelize = ctx.fs.dc.ORM |
|
|
|
console.log('query1111', query) |
|
|
|
|
|
|
|
const { id, completedTime, deviceType, model, reason, reportTime, solution, status, solver, projectId } = query |
|
|
|
if (id) { |
|
|
|
await models.EquipmentMaintenanceRecord.update({ |
|
|
@ -162,8 +158,6 @@ async function editEquipment(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await transaction.commit(); |
|
|
|
ctx.status = 204 |
|
|
|
} catch (error) { |
|
|
@ -176,7 +170,7 @@ async function editEquipment(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
//删除
|
|
|
|
async function delEquipment(ctx) { |
|
|
|
async function delEquipment (ctx) { |
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
|
try { |
|
|
|
const params = ctx.params |
|
|
@ -196,10 +190,6 @@ async function delEquipment(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
getEquipment, editEquipment, delEquipment |
|
|
|
}; |