|  | @ -5,6 +5,9 @@ const Holiday = require('../holiday'); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | module.exports = { |  |  | module.exports = { | 
			
		
	
		
		
			
				
					|  |  |   entry(app, router, opts) { |  |  |   entry(app, router, opts) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     app.fs = app.fs || {}; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     app.fs.cache = app.fs.cache || {}; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     const ZENTAO_DOMAIN = opts.zentaoDomain; |  |  |     const ZENTAO_DOMAIN = opts.zentaoDomain; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     async function auth() { |  |  |     async function auth() { | 
			
		
	
	
		
		
			
				
					|  | @ -18,17 +21,9 @@ module.exports = { | 
			
		
	
		
		
			
				
					|  |  |         .query({ [`${sessionName}`]: sessionID }) |  |  |         .query({ [`${sessionName}`]: sessionID }) | 
			
		
	
		
		
			
				
					|  |  |         .send({ account: 'admin', password: 'Fashion123' }); |  |  |         .send({ account: 'admin', password: 'Fashion123' }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |       app.fs = app.fs || {}; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       app.fs.session = { sessionName, sessionID }; |  |  |       app.fs.session = { sessionName, sessionID }; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     (async function () { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       await auth(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       setInterval(async () => { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         await auth(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       }, 1200000); // 每 20分钟 刷新一次
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     }()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     function isWorkday(date) { |  |  |     function isWorkday(date) { | 
			
		
	
		
		
			
				
					|  |  |       let workday = false; |  |  |       let workday = false; | 
			
		
	
		
		
			
				
					|  |  |       const dateString = moment(date).format('YYYY-MM-DD'); |  |  |       const dateString = moment(date).format('YYYY-MM-DD'); | 
			
		
	
	
		
		
			
				
					|  | @ -131,8 +126,10 @@ module.exports = { | 
			
		
	
		
		
			
				
					|  |  |       return executionStats; |  |  |       return executionStats; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     async function getOngoingProjects(ctx, next) { |  |  |     async function cacheOngoingProjects() { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |       try { |  |  |       try { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!app.fs.cache.ongoingProjects) app.fs.cache.ongoingProjectsError = '数据缓存尚未完成'; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         const executions = []; |  |  |         const executions = []; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         // 执行(未开始)
 |  |  |         // 执行(未开始)
 | 
			
		
	
	
		
		
			
				
					|  | @ -170,22 +167,17 @@ module.exports = { | 
			
		
	
		
		
			
				
					|  |  |           }); |  |  |           }); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |         ctx.status = 200; |  |  |         app.fs.cache.ongoingProjects = executions; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         ctx.body = { |  |  |         app.fs.cache.ongoingProjectsError = null; | 
			
				
				
			
		
	
		
		
			
				
					|  |  |           total: executions.length, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           projects: executions, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }; |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |       } catch (e) { |  |  |       } catch (e) { | 
			
		
	
		
		
			
				
					
					|  |  |         ctx.status = 400; |  |  |         app.fs.cache.ongoingProjectsError = e; | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         ctx.body = { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           name: 'FindError', |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           message: `版本计划获取失败${e}`, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }; |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |       } |  |  |       } | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     async function getOngoingPersons(ctx, next) { |  |  |     async function cacheOngoingPersons() { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |       try { |  |  |       try { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!app.fs.cache.ongoingPersons) app.fs.cache.ongoingPersonsError = '数据缓存尚未完成'; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         const currentDate = moment(); |  |  |         const currentDate = moment(); | 
			
		
	
		
		
			
				
					|  |  |         // 获取当前周的第一天(周一)
 |  |  |         // 获取当前周的第一天(周一)
 | 
			
		
	
		
		
			
				
					|  |  |         const firstDayOfWeek = currentDate.clone().startOf('isoWeek'); |  |  |         const firstDayOfWeek = currentDate.clone().startOf('isoWeek'); | 
			
		
	
	
		
		
			
				
					|  | @ -262,16 +254,71 @@ module.exports = { | 
			
		
	
		
		
			
				
					|  |  |           return { ...initData, ...memberTasks }; |  |  |           return { ...initData, ...memberTasks }; | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |         ctx.status = 200; |  |  |         app.fs.cache.ongoingPersons = members; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         app.fs.cache.ongoingPersonsError = null; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       } catch (e) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         app.fs.cache.ongoingPersonsError = e; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     (async function () { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       await auth(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       cacheOngoingProjects(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       cacheOngoingPersons(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       setInterval(async () => { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         await auth(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         cacheOngoingProjects(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         cacheOngoingPersons(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       }, 1200000); // 每 20分钟 刷新一次
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     }()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     async function getOngoingProjects(ctx, next) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       try { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         const { ongoingProjects, ongoingProjectsError } = app.fs.cache; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (ongoingProjectsError) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.status = 400; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.body = { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             name: 'FindError', | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             message: `版本计划获取失败:${ongoingProjectsError}`, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           }; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.status = 200; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.body = { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             total: ongoingProjects.length, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             projects: ongoingProjects, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           }; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       } catch (e) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ctx.status = 400; | 
			
		
	
		
		
			
				
					|  |  |         ctx.body = { |  |  |         ctx.body = { | 
			
		
	
		
		
			
				
					
					|  |  |           total: members.length, |  |  |           name: 'FindError', | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |           projects: members, |  |  |           message: `版本计划获取失败:${e}`, | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         }; |  |  |         }; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     async function getOngoingPersons(ctx, next) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       try { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         const { ongoingPersons, ongoingPersonsError } = app.fs.cache; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (ongoingPersonsError) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.status = 400; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.body = { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             name: 'FindError', | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             message: `人员计划获取失败:${ongoingPersonsError}`, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           }; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.status = 200; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           ctx.body = { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             total: ongoingPersons.length, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             projects: ongoingPersons, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           }; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |       } catch (e) { |  |  |       } catch (e) { | 
			
		
	
		
		
			
				
					|  |  |         ctx.status = 400; |  |  |         ctx.status = 400; | 
			
		
	
		
		
			
				
					|  |  |         ctx.body = { |  |  |         ctx.body = { | 
			
		
	
		
		
			
				
					|  |  |           name: 'FindError', |  |  |           name: 'FindError', | 
			
		
	
		
		
			
				
					
					|  |  |           message: `人员计划获取失败${e}`, |  |  |           message: `人员计划获取失败:${e}`, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         }; |  |  |         }; | 
			
		
	
		
		
			
				
					|  |  |       } |  |  |       } | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
	
		
		
			
				
					|  | 
 |