| 
						
						
							
								
							
						
						
					 | 
					@ -4,21 +4,40 @@ const moment = require('moment') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					async function list (ctx) { | 
					 | 
					 | 
					async function list (ctx) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					   try { | 
					 | 
					 | 
					   try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const models = ctx.fs.dc.models; | 
					 | 
					 | 
					      const models = ctx.fs.dc.models; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      const { keyword, alarmType, state, } = ctx.request.body | 
					 | 
					 | 
					      const sequelize = ctx.fs.dc.ORM; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const { clickHouse } = ctx.app.fs | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const { utils: { anxinStrucIdRange, pomsProjectRange } } = ctx.app.fs | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const { keyword, keywordTarget, alarmType, state, tactics, pomsProjectId } = ctx.request.body | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      let findOption = { | 
					 | 
					 | 
					      let findOption = { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         where: { | 
					 | 
					 | 
					         where: { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
					            del: false | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					         } | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      if (keyword) { | 
					 | 
					 | 
					      let anxinStrucsRange = await anxinStrucIdRange({ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					         findOption.where.$or = [ | 
					 | 
					 | 
					         ctx, pepProjectId: pomsProjectId, keywordTarget, keyword | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            { | 
					 | 
					 | 
					      }) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					               name: { $like: `%${keyword}%` } | 
					 | 
					 | 
					      if (keywordTarget && keyword) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            }, | 
					 | 
					 | 
					         if (keywordTarget == 'tactics') { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					         ] | 
					 | 
					 | 
					            findOption.where.name = { $like: `%${keyword}%` } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      } | 
					 | 
					 | 
					         } else if (keywordTarget == 'struc') { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            let bindAnixinStrucRes = await clickHouse.anxinyun.query(` | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               SELECT id, name FROM t_structure | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  WHERE name LIKE '%${keyword}%' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            `).toPromise()
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            let bindAnixinStrucIds = bindAnixinStrucRes.map(s => s.id) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            findOption.where.strucId = { $contains: bindAnixinStrucIds } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         } else if (keywordTarget == 'pepProject') { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const pomsProjectRes = await pomsProjectRange({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         ctx, pepProjectId: pomsProjectId, keywordTarget, keyword | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      let pomsProjectIds = pomsProjectRes.map(p => p.id) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      findOption.where.pomsProjectId = { $in: pomsProjectIds } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      if (alarmType) { | 
					 | 
					 | 
					      if (alarmType) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         findOption.where.alarmType = { $contains: [alarmType] } | 
					 | 
					 | 
					         findOption.where.alarmType = { $contains: [alarmType] } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -27,15 +46,99 @@ async function list (ctx) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            findOption.where.disable = false | 
					 | 
					 | 
					            findOption.where.disable = false | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         } else if (state == 'disable') { | 
					 | 
					 | 
					         } else if (state == 'disable') { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            findOption.where.disable = true | 
					 | 
					 | 
					            findOption.where.disable = true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					         } else if (state == 'overtime') { | 
					 | 
					 | 
					         } | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      if (tactics) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         findOption.where.tactics = tactics | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const listRes = await models.AlarmPushConfig.findAll(findOption) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      let allStrucIds = new Set() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      let allConfigId = [] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      let allReceiverIds = new Set() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      for (let p of listRes) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         for (let sid of p.strucId) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            allStrucIds.add(sid) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         allConfigId.push(p.id) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         for (let uid of p.receiverPepUserId) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            allReceiverIds.add(uid) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         } | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      // 查配置所包含的所有结构物
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const allStrucRes = allStrucIds.size ? await clickHouse.anxinyun.query(` | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         SELECT id, name FROM t_structure | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            WHERE id IN (${[...allStrucIds].join(',')}) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      `).toPromise() : []
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      const listRes = await models.AlarmPushConfig.findAndCountAll(findOption) | 
					 | 
					 | 
					      // 查所有配置的推送的次数
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const pushLogCountRes = await models.EmailSendLog.findAll({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         attributes: [ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            'pushConfigId', | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            [sequelize.fn('COUNT', sequelize.col('push_config_id')), 'count'] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         ], | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         where: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            pushConfigId: { $in: allConfigId } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         }, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         group: ['pushConfigId'] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      // 查询所有的用户信息
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      const userRes = allReceiverIds.size ? await clickHouse.pepEmis.query(` | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         SELECT id, name, delete FROM user  | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            WHERE id IN (${[...allReceiverIds].join(',')}) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      `).toPromise() : []
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      let returnD = [] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      for (let { dataValues: p } of listRes) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         // 查对应的 poms 绑定的结构物绑定关系
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         const corBind = pomsProjectRes.find(ppj => ppj.id == p.pomsProjectId) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         if (corBind.pepProjectId) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (state == 'notYet') { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               if (corBind.pepProject && p.timeType.some(pt => pt == corBind.pepProject.constructionStatusId)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  continue | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else if (state == 'takeEffect') { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               if (!corBind.pepProject || !p.timeType.some(pt => pt == corBind.pepProject.constructionStatusId)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  continue | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         // 结构物信息
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         let returnStruc = [] | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         for (let sid of p.strucId) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 查这个结构物的信息
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            let structure = allStrucRes.find(asr => asr.id == sid) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (structure) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               // 检查当前结构物有没有从已绑定的项目里解绑
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               // 查对应的可见的结构物信息
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               const anxinStrucSeen = anxinStrucsRange.find(axs => axs.strucId == sid) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               returnStruc.push({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  id: sid, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  name: structure.name, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                  unbind: !anxinStrucSeen || !corBind.anxinProjectId.includes(anxinStrucSeen.projectId) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					               // 这个结构物已删
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         // 查找日志数量
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         const corLogCount = pushLogCountRes.find(plc => plc.pushConfigId == p.id) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         // 查找接收人数据
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         const corReceiver = userRes.filter(u => p.receiverPepUserId.some(prId => u.id == prId)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         returnD.push({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            ...p, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            pomsProject: corBind, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            structure: returnStruc, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            pushCount: corLogCount ? corLogCount.count : 0, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            receiverPepUser: corReceiver | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      ctx.status = 200; | 
					 | 
					 | 
					      ctx.status = 200; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      ctx.body = listRes | 
					 | 
					 | 
					      ctx.body = returnD | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					   } catch (error) { | 
					 | 
					 | 
					   } catch (error) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | 
					 | 
					 | 
					      ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      ctx.status = 400; | 
					 | 
					 | 
					      ctx.status = 400; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -49,10 +152,12 @@ async function edit (ctx) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					   try { | 
					 | 
					 | 
					   try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const models = ctx.fs.dc.models; | 
					 | 
					 | 
					      const models = ctx.fs.dc.models; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const { userId, pepUserId } = ctx.fs.api | 
					 | 
					 | 
					      const { userId, pepUserId } = ctx.fs.api | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      const { pushId, name, pepProjectId = [], alarmType = [], receiverPepUserId = [], timeType = [], disable } = ctx.request.body | 
					 | 
					 | 
					      const { pushId, name, pomsProjectId, alarmType = [], receiverPepUserId = [], timeType = [], disable, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         strucId = [], tactics, tacticsParams } = ctx.request.body | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      let storageData = { | 
					 | 
					 | 
					      let storageData = { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					         name, pepProjectId, alarmType, receiverPepUserId, timeType, disable | 
					 | 
					 | 
					         name, pomsProjectId, alarmType, receiverPepUserId, timeType, disable, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         strucId, tactics, tacticsParams | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      if (pushId) { | 
					 | 
					 | 
					      if (pushId) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         await models.AlarmPushConfig.update(storageData, { | 
					 | 
					 | 
					         await models.AlarmPushConfig.update(storageData, { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -63,6 +168,7 @@ async function edit (ctx) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } else { | 
					 | 
					 | 
					      } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         storageData.createTime = moment().format() | 
					 | 
					 | 
					         storageData.createTime = moment().format() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         storageData.createUserId = userId | 
					 | 
					 | 
					         storageData.createUserId = userId | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					         storageData.del = false | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         await models.AlarmPushConfig.create(storageData) | 
					 | 
					 | 
					         await models.AlarmPushConfig.create(storageData) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -82,21 +188,16 @@ async function state (ctx) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const { pushId } = ctx.params | 
					 | 
					 | 
					      const { pushId } = ctx.params | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const { disable = undefined, del = undefined, } = ctx.request.body | 
					 | 
					 | 
					      const { disable = undefined, del = undefined, } = ctx.request.body | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      if (del) { | 
					 | 
					 | 
					      let updateData = { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					         await models.AlarmPushConfig.destroy({ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            where: { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					               id: pushId | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         }) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } else { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         await models.AlarmPushConfig.update({ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					         disable, | 
					 | 
					 | 
					         disable, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					         }, { | 
					 | 
					 | 
					         del, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      await models.AlarmPushConfig.update(updateData, { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         where: { | 
					 | 
					 | 
					         where: { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            id: pushId | 
					 | 
					 | 
					            id: pushId | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					         } | 
					 | 
					 | 
					         } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      }) | 
					 | 
					 | 
					      }) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      ctx.status = 204; | 
					 | 
					 | 
					      ctx.status = 204; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					   } catch (error) { | 
					 | 
					 | 
					   } catch (error) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |