Browse Source

feat:fix bugs

master
zhaobing 9 months ago
parent
commit
018984358c
  1. 45
      api/app/lib/controllers/bigScreen/leader.js
  2. 6
      web-screen/client/src/sections/bigScreen/components/leader/index.js
  3. 4
      web-screen/client/src/sections/bigScreen/components/leader/left.js

45
api/app/lib/controllers/bigScreen/leader.js

@ -6,11 +6,11 @@ const moment = require("moment");
function getPlanCount(startTime,endTime,frequencyUnit){
switch(frequencyUnit){
case '天':
return Math.ceil(moment(startTime).diff(endTime, 'days'))
return Math.ceil(moment(endTime).diff(startTime, 'days'))
case '周':
return Math.ceil(moment(startTime).diff(endTime, 'weeks'))
return Math.ceil(moment(endTime).diff(startTime, 'weeks'))
case '月':
return Math.ceil(moment(startTime).diff(endTime, 'months'))
return Math.ceil(moment(endTime).diff(startTime, 'months'))
default:
break
}
@ -23,18 +23,17 @@ async function findPatrolRecords(ctx, next) {
let rslt = { planCount: 0, done: 0,count:0,bCount:0 }
const models = ctx.fs.dc.models
const { projectId, startTime, endTime } = ctx.query
let planCount=0
const plan = await models.PatrolPlan.findAll({
where: {
structureId: { $in: projectId.split(',') },
$or: [{
startTime: { $lte: startTime },
endTime: { $gte: endTime }
startTime: { $lte: moment(startTime).format('YYYY-MM-DD HH:mm:ss') },
endTime: { $gte: moment(endTime).format('YYYY-MM-DD HH:mm:ss') }
},
{
startTime: { $gt: startTime },
endTime: { $lt: endTime }
startTime: { $gt: moment(startTime).format('YYYY-MM-DD HH:mm:ss') },
endTime: { $lt: moment(endTime).format('YYYY-MM-DD HH:mm:ss')}
},
{
startTime: { $between: [startTime, endTime] },
@ -60,6 +59,7 @@ async function findPatrolRecords(ctx, next) {
patrolPlanId: c.id
}
})
planCount=getPlanCount(startTime,endTime,frequencyUnit)
} else if (moment(c.startTime).isSameOrAfter(moment(startTime)) && moment(c.startTime).isSameOrBefore(moment(endTime))) {
done = await models.PatrolRecord.count({
@ -68,6 +68,8 @@ async function findPatrolRecords(ctx, next) {
patrolPlanId: c.id
}
})
planCount=getPlanCount(c.startTime,c.endTime,frequencyUnit)
} else if (moment(c.endTime).isSameOrAfter(moment(startTime)) && moment(c.endTime).isSameOrBefore(moment(endTime))) {
done = await models.PatrolRecord.count({
where: {
@ -75,6 +77,7 @@ async function findPatrolRecords(ctx, next) {
patrolPlanId: c.id
}
})
planCount=getPlanCount(c.startTime,endTime,frequencyUnit)
} else if (moment(c.startTime).isAfter(moment(startTime)) && moment(c.endTime).isBefore(moment(endTime))) {
done = await models.PatrolRecord.count({
where: {
@ -82,6 +85,7 @@ async function findPatrolRecords(ctx, next) {
patrolPlanId: c.id
}
})
planCount=getPlanCount(startTime,c.endTime,frequencyUnit)
}
let dones = await models.PatrolRecord.count({
where: {
@ -94,9 +98,9 @@ async function findPatrolRecords(ctx, next) {
count(case when prih.state!=6 then 1 end) as count,
count(case when prih.state=6 then 1 end) as bCount
from project p
left join patrol_record pr
inner join patrol_record pr
on p.id = pr.project_id
left join patrol_record_issue_handle prih
inner join patrol_record_issue_handle prih
on pr.id = prih.patrol_record_id
and prih.create_time
between '${startTime}'
@ -105,11 +109,10 @@ async function findPatrolRecords(ctx, next) {
group by p.name
`)
const planCount=getPlanCount(c.startTime,c.endTime,frequencyUnit)
rslt.planCount += frequencyNum * points * planCount- done
rslt.done += dones
rslt.bCount+=result[0][0].bCount
rslt.count=result[0][0].count
rslt.bCount+=result[0][0]?Number(result[0][0].bcount):0
rslt.count=result[0][0]?Number(result[0][0].count):0
}
}
@ -228,9 +231,9 @@ async function devicesGuarantee(ctx) {
const rs = await sequelize.query(`
SELECT d.type, COUNT(d.id) as count
FROM device d
LEFT JOIN point_device pd
inner JOIN point_device pd
ON d.id = pd.device_id
LEFT JOIN point p
inner JOIN point p
ON pd.point_id = p.id
WHERE p.project_id IN (${projectId})
GROUP by d.type`)
@ -256,9 +259,9 @@ async function getHistoricalFaults(ctx) {
count(1) as count,
count(case when prih.state=6 then 1 end) as bCount
from project p
left join patrol_record pr
inner join patrol_record pr
on p.id = pr.project_id
left join patrol_record_issue_handle prih
inner join patrol_record_issue_handle prih
on pr.id = prih.patrol_record_id
and prih.create_time
between '${startTime}'
@ -342,9 +345,9 @@ async function getCenterData(ctx) {
count(1) as count,
count(case when prih.state=6 then 1 end) as bCount
from project p
left join patrol_record pr
inner join patrol_record pr
on p.id = pr.project_id
left join patrol_record_issue_handle prih
inner join patrol_record_issue_handle prih
on pr.id = prih.patrol_record_id
where p.id in (${projectId})
`)
@ -364,7 +367,7 @@ async function getCenterData(ctx) {
rslt.deviceCount=res.length
rslt.questions=rs[0][0]?Number(rs[0][0].count):0
rslt.handleCount=rs[0][0]?Number(rs[0][0].count):0
rslt.handleCount=rs[0][0]?Number(rs[0][0].bcount):0
rslt.records=record
rslt.reportCount=reportCount
ctx.body = rslt

6
web-screen/client/src/sections/bigScreen/components/leader/index.js

@ -44,9 +44,9 @@ const Leader = (props) => {
</div>
<div style={{position:'absolute',top:'14.6rem',left:'37rem',}}><span style={{...centerFontStyle}}>设备总数</span><span style={{...centerNumFontStyle,color:'#6eece9',}}>{centerData.deviceCount}</span></div>
<div style={{position:'absolute',top:'10.5rem',left:'45rem',}}><span style={{...centerFontStyle}}>发现问题</span><span style={{...centerNumFontStyle,color:'rgb(204 193 84)',}}>{centerData.questions}</span></div>
<div style={{position:'absolute',top:'12.5rem',left:'56.5rem',}}><div style={{...centerNumFontStyle,height:'2.5rem',color:'#6eece9',textAlign:'center'}}>{centerData.handleCount}</div> <span style={{...centerFontStyle}}></span></div>
<div style={{position:'absolute',top:'10.5rem',left:'67.5rem',}}><span style={{...centerFontStyle}}>出具报告数</span><span style={{...centerNumFontStyle,color:'#6eece9',}}>{centerData.records}</span></div>
<div style={{position:'absolute',top:'14.6rem',left:'75rem',}}><span style={{...centerFontStyle}}>处理故障数</span><span style={{...centerNumFontStyle,color:'rgb(47 229 9)',}}>{centerData.reportCount}</span></div>
<div style={{position:'absolute',top:'12.5rem',left:'56.5rem',}}><div style={{...centerNumFontStyle,height:'2.5rem',color:'#6eece9',textAlign:'center'}}>{centerData.records}</div> <span style={{...centerFontStyle}}></span></div>
<div style={{position:'absolute',top:'10.5rem',left:'67.5rem',}}><span style={{...centerFontStyle}}>出具报告数</span><span style={{...centerNumFontStyle,color:'#6eece9',}}>{centerData.reportCount}</span></div>
<div style={{position:'absolute',top:'14.6rem',left:'75rem',}}><span style={{...centerFontStyle}}>处理故障数</span><span style={{...centerNumFontStyle,color:'rgb(47 229 9)',}}>{centerData.handleCount}</span></div>
</>

4
web-screen/client/src/sections/bigScreen/components/leader/left.js

@ -71,7 +71,7 @@ const Left = props => {
const data = res.payload.data
if (data && data.length) {
const repairObject = {}
for (let i = 0; i < 6; i++) {
for (let i = 5; i >=0; i--) {
const currentDate = moment().subtract(i, 'months')
const month = currentDate.month() + 1
const year = currentDate.year()
@ -90,8 +90,10 @@ const Left = props => {
})
//计算比例
Object.values(repairObject).forEach(item => {
console.log('item',item)
repair.push(item.quests === 0 ? 0 : Number((item.done / item.quests * 100).toFixed(2)));
});
console.log('x1111',repair,cRate)
setRRate(repair)
}
}

Loading…
Cancel
Save