-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekReport.py
More file actions
517 lines (386 loc) · 13.7 KB
/
Copy pathWeekReport.py
File metadata and controls
517 lines (386 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
'''
Created on 2014-4-22
@author: Sindo
'''
import os,sys,locale
import re
import xlrd
from datetime import date
from datetime import datetime
from datetime import timedelta
from Navigator import Navigator
def printSecSepor(seporName="========") :
print ""
print "========================================================================"
print "=========================== %s ===================================" % (seporName)
print "========================================================================"
print ""
def saveFileContent(fileName, fileData):
fileObj = open(fileName, "wb")
fileObj.write(fileData)
fileObj.close()
class WeekReport :
def __init__(self, userName, userPswd, workDir, debug=False):
self.debug = debug
self.userName = userName
self.userPswd = userPswd
self.workDir = workDir
self.teamMemberTuple = (u"茅晓萍", u"程雷", u"朱孝明", u"陈宏梅", u"郑杭", u"陈强", u"苏志锦", u"柴增琪", u"汪闻鹏", u"张绪昌")
#self.navigator = Navigator("ailk\\" + userName, userPswd)
def openExcel(self, excelFile):
try:
data = xlrd.open_workbook(excelFile)
return data
except Exception,e:
print str(e)
return None
def parseReqInfo(self, excelSheet, bgnIdx):
rowNum = excelSheet.nrows #####行数
infoList =[]
infoColDict = {
"ReqId" : 0,
"Content": 1,
"Percent": 2,
"Workload":3,
"WorkedDays": 4,
"WorkingDays": 5,
"WorkDate":6,
"UrgentReq":7
}
for rowId in range(bgnIdx,rowNum):
row = excelSheet.row_values(rowId)
if not row or not row[0]:
continue
elif row[0] == u"系统BUG解决:本周处理的BUG":
break
info = {}
colName = "ReqId"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Content"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Percent"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "WorkingDays"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "WorkDate"
cellIdx = infoColDict[colName]
try:
dateTuple = xlrd.xldate_as_tuple(excelSheet.cell(rowId,cellIdx).value,0)
dateStr = "%4d-%02d-%02d" % (dateTuple[0],dateTuple[1],dateTuple[2])
except Exception,e:
print "pasring_date_format_error:%s" % str(e)
dateStr = row[cellIdx]
info[colName] = dateStr
colName = "UrgentReq"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
infoList.append(info)
print "reqInfo_end_at_rowId:%d" % (rowId)
return (infoList, rowId)
def parseBugInfo(self, excelSheet, bgnIdx):
rowNum = excelSheet.nrows #####行数
infoList = []
infoColDict = {
"BugId": 0,
"Content": 1,
"Percent": 2,
"Workload":3,
"WorkedDays": 4,
"WorkingDays": 5,
"WorkDate":6,
"Remark":7
}
rowId = bgnIdx
for rowId in range(bgnIdx,rowNum):
row = excelSheet.row_values(rowId)
if not row or not row[0]:
continue
elif row[0] == u"回退:各个现场提出的相关回退":
break
info = {}
colName = "BugId"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Content"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Percent"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "WorkingDays"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "WorkDate"
cellIdx = infoColDict[colName]
try:
dateTuple = xlrd.xldate_as_tuple(excelSheet.cell(rowId,cellIdx).value,0)
dateStr = "%4d-%02d-%02d" % (dateTuple[0],dateTuple[1],dateTuple[2])
except Exception,e:
print "pasring_date_format_error:%s" % str(e)
dateStr = row[cellIdx]
info[colName] = dateStr
infoList.append(info)
print "bugInfo_end_at_rowId:%d" % (rowId)
return infoList, rowId
def parseHtdInfo(self, excelSheet, bgnIdx):
rowNum = excelSheet.nrows #####行数
infoList = []
infoColDict = {
"HtdId": 0,
"Content": 1,
"Percent": 2,
"Workload":3,
"WorkedDays": 4,
"WorkingDays": 5,
"WorkDate":6,
"Remark":7
}
rowId = bgnIdx
for rowId in range(bgnIdx,rowNum):
row = excelSheet.row_values(rowId)
if not row or not row[0]:
continue
elif row[0] == u"各省现场问题处理:各个现场出现的问题以及解决方法":
break
info = {}
colName = "HtdId"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Content"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Percent"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
infoList.append(info)
print "bugInfo_end_at_rowId:%d" % (rowId)
return infoList, rowId
def parseCopeInfo(self, excelSheet, bgnIdx):
rowNum = excelSheet.nrows #####行数
infoList = []
infoColDict = {
"Prov": 0,
"Problem":1,
"Content": 2,
"Workload":5,
"WorkDate":6,
"Resolved":7
}
rowId = bgnIdx
for rowId in range(bgnIdx,rowNum):
row = excelSheet.row_values(rowId)
if not row or not row[0]:
continue
elif row[0] == u"学习、研究和其他:本周学习或者研究的相关内容":
break
info = {}
colName = "Prov"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Problem"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Content"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Workload"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "WorkDate"
cellIdx = infoColDict[colName]
try:
dateTuple = xlrd.xldate_as_tuple(excelSheet.cell(rowId,cellIdx).value,0)
dateStr = "%4d-%02d-%02d" % (dateTuple[0],dateTuple[1],dateTuple[2])
except Exception,e:
print "copeInfo_pasring_date_format_error:%s" % str(e)
dateStr = row[cellIdx]
info[colName] = dateStr
colName = "Resolved"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
infoList.append(info)
print "copeInfo_end_at_rowId:%d" % rowId
return infoList, rowId
def parseStudyInfo(self, excelSheet, bgnIdx):
rowNum = excelSheet.nrows #####行数
infoList = []
infoColDict = {
"ProcDesc":1,
"ResultDesc": 2,
"Workload":5,
"WorkDate":6,
"Remart":7
}
rowId = bgnIdx
for rowId in range(bgnIdx,rowNum):
row = excelSheet.row_values(rowId)
if not row or not row[0]:
continue
elif row[0] == u"各省上线支持:各个省份上线支持记录和内容。上线期间,7X24小时支持记录和内容。":
break
elif row[0] == u"序号":
break
print "rowId:%d, row0:%s" % (rowId, row[0])
info = {}
colName = "ProcDesc"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "ResultDesc"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "Workload"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "WorkDate"
cellIdx = infoColDict[colName]
try:
dateTuple = xlrd.xldate_as_tuple(excelSheet.cell(rowId,cellIdx).value,0)
dateStr = "%4d-%02d-%02d" % (dateTuple[0],dateTuple[1],dateTuple[2])
except Exception,e:
print "pasring_date_format_error:%s" % str(e)
dateStr = row[cellIdx]
info[colName] = dateStr
colName = "Remart"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
infoList.append(info)
print "studyInfo_end_at_rowId:%d" % rowId
return infoList, rowId
def parseLiveInfo(self, excelSheet, bgnIdx): #上线支持
rowNum = excelSheet.nrows #####行数
infoList = []
infoColDict = {
"ProcDesc":1,
"ResultDesc": 2,
"Remart":7
}
rowId = bgnIdx
for rowId in range(bgnIdx,rowNum):
row = excelSheet.row_values(rowId)
if not row or not row[0]:
continue
elif row[0] == u"下周工作内容:记录下周准备处理的内容":
break
elif row[0] == u"序号":
break
print "rowId:%d, row0:%s" % (rowId, row[0])
info = {}
colName = "ProcDesc"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
colName = "ResultDesc"
cellIdx = infoColDict[colName]
info[colName] = row[cellIdx]
infoList.append(info)
print "liveInfo_end_at_rowId:%d" % rowId
return infoList, rowId
def parseTable(self, excelFile):
excelData = self.openExcel(excelFile)
excelSheet = excelData.sheets()[0]
rowNum = excelSheet.nrows #行数
colNum = excelSheet.ncols #列数
print "total_rowNum:%d, total_colNum:%d" % (rowNum, colNum)
reqBgnIdx = 3
reqList, rowId = self.parseReqInfo(excelSheet, reqBgnIdx)
bugBgnIdx = rowId + 2
bugList, rowId = self.parseBugInfo(excelSheet, bugBgnIdx)
htdBgnIdx = rowId + 2 #htd=回退单
htdList, rowId = self.parseHtdInfo(excelSheet, htdBgnIdx)
copeBgnIdx = rowId + 2 #cope=各省现场问题处理
copeList, rowId = self.parseCopeInfo(excelSheet, copeBgnIdx)
studyBgnIdx = rowId + 2 #学习研究等其他内容
studyList, rowId = self.parseStudyInfo(excelSheet, studyBgnIdx)
liveBgnIdx = rowId + 2 #各省上线支持情况
liveList, rowId = self.parseLiveInfo(excelSheet, liveBgnIdx)
return (reqList, bugList, htdList, copeList, studyList, liveList)
def perform(self, reportDate):
resVal = False
fileData = ""
lineData = ""
reportDateStr = "%4d-%02d-%02d" % (reportDate/10000, (reportDate%10000/100), (reportDate%10000%100))
for memberName in self.teamMemberTuple:
excelFile = u"%s/%d/综合账务处理周报_%d(%s).xls" % (self.workDir, reportDate, reportDate, memberName)
if not os.path.isfile(excelFile):
print "no_excel_file_name: %s" % excelFile
excelFile = u"%s/%d/综合账务处理周报_%d(%s).xls" % (self.workDir, reportDate, reportDate, memberName)
if not os.path.isfile(excelFile):
print "no_excel_file_name: %s" % excelFile
excelFile = u"%s/%d/综合账务处理周报_%d(%s).xls" % (self.workDir, reportDate, reportDate, memberName)
if not os.path.isfile(excelFile):
print "no_excel_file_name: %s" % excelFile
excelFile = u"%s/%d/综合账务处理周报_%d(%s).xls" % (self.workDir, reportDate, reportDate, memberName)
if not os.path.isfile(excelFile):
print "the_member_s_weekReport_not_found: %s" % (memberName)
#return False
continue
print "current_excel_file_name: %s" % excelFile
printSecSepor(">" + memberName + "<")
reqList, bugList, htdList, copeList, studyList, liveList = self.parseTable(excelFile)
printSecSepor("ReqList")
for reqInfo in reqList:
lineData = u"\"%s:%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"" % (reqInfo["ReqId"], reqInfo["Content"], "", memberName, reportDateStr, reqInfo["Percent"])
fileData = u"%s\n%s" % (fileData, lineData)
print "reqInfo:%s" % lineData
printSecSepor("BugList")
for bugInfo in bugList:
lineData = u"\"%s:%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"" % (bugInfo["BugId"], bugInfo["Content"], "", memberName, reportDateStr, bugInfo["Percent"])
fileData = u"%s\n%s" % (fileData, lineData)
print "bugInfo: %s" % lineData
printSecSepor("HtdList")
for htdInfo in htdList:
lineData = u"\"%s:%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"" % (htdInfo["HtdId"], htdInfo["Content"], "", memberName, reportDateStr, htdInfo["Percent"])
fileData = u"%s\n%s" % (fileData, lineData)
print "htdInfo: %s" % lineData
printSecSepor("CopeList")
for copeInfo in copeList:
lineData = u"\"%s:%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"" % (copeInfo["Problem"], copeInfo["Content"], copeInfo["Prov"], memberName, reportDateStr, "100%")
fileData = u"%s\n%s" % (fileData, lineData)
print "copeInfo: %s" % lineData
printSecSepor("StudyList")
for studyInfo in studyList:
lineData = u"\"%s:%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"" % (studyInfo["ProcDesc"], studyInfo["ResultDesc"], "", memberName, reportDateStr, "100%")
fileData = u"%s\n%s" % (fileData, lineData)
print "studyInfo: %s" % lineData
printSecSepor("LiveList")
for liveInfo in liveList:
lineData = u"\"%s:%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"" % (liveInfo["ProcDesc"], liveInfo["ResultDesc"], "", memberName, reportDateStr, "100%")
fileData = u"%s\n%s" % (fileData, lineData)
print "liveInfo: %s" % lineData
printSecSepor("fileData")
print fileData
outputFile = u"%s/%d/综合账务处理周报_%d(Team).xls" % (self.workDir, reportDate, reportDate)
saveFileContent(outputFile, fileData.lstrip())
resVal = True
return resVal
def getReportDate():
wrDateObj = date.today()
weekDay = wrDateObj.weekday()+1
while not weekDay == 5:
wrDateObj = wrDateObj + timedelta(days = -1)
weekDay = wrDateObj.weekday()+1
#reportDate = "%d%02d%02d" % (wrDateObj.year, wrDateObj.month, wrDateObj.day)
reportDate = wrDateObj.year * 10000 + wrDateObj.month*100 + wrDateObj.day
return reportDate
if __name__ == '__main__': # sys.argv[0], sys.argv[1]
reload(sys)
sys.setdefaultencoding("utf-8")
print "WeekReport_process_begin...... %d,%s" % (len(sys.argv), sys.argv[0])
resVal = False
debugMode = False
userName = 'lijj'
userPswd = os.getenv("aintPswd")
reportDate = getReportDate()
if len(sys.argv) >=2:
"WeekReport_process_arg 1" + sys.argv[1]
reportDate = int(sys.argv[1])
workDir = "D:/LiatAilk/WeekRept"
weekReport = WeekReport(userName, userPswd, workDir, debugMode)
resVal= weekReport.perform(reportDate)
printSecSepor()
#python cp , rename Team周报-帐务处理维护团队* Team周报-帐务处理维护团队(2014xx).doc
if resVal: print "congratulations_your_work_is_done_successfully"
else: print "unfortunately_your_work_is_failed"