def executeWaitingFlows(strEDIPath, strEDIConnection, strEDIDB, jsonEDIFlows, intFileBlockSize, strMessageSMTPServer, strMessageSMTPFrom, arrayMessageSMTPSuccessTo, arrayMessageSMTPFailureTo): listWaitingFlows = EDIEntity.getWaitingFlowList(strEDIConnection, strEDIDB, jsonEDIFlows["ediID"]) if len(listWaitingFlows) > 0: for listWaitingFlow in listWaitingFlows: jsonFlow = Common.filterJsonListFirst( jsonEDIFlows["flowList"], "flowID", listWaitingFlow["EDI_FLOW_ID"]) strRunningFlow = jsonEDIFlows["ediID"] + "." + jsonFlow[ "flowID"] + ".run" if jsonFlow != None and os.path.exists(strRunningFlow) == False: fileRunningFlow = open(strRunningFlow, "w") fileRunningFlow.close() thread = threading.Thread( target=executeFlow, args=(strEDIPath, jsonEDIFlows["ediID"], strEDIConnection, strEDIDB, listWaitingFlow, jsonFlow, intFileBlockSize, strMessageSMTPServer, strMessageSMTPFrom, arrayMessageSMTPSuccessTo, arrayMessageSMTPFailureTo)) thread.start() else: pass return True
def validateScheduleDaily(strEDIConnection, strEDIDB, jsonEDIFlows, jsonEDIFlow, intIntervalSeconds, datetimeNow): datetimeStart = Common.getDateTime(jsonEDIFlow["scheduleStartDate"] + " " + jsonEDIFlow["scheduleStartTime"]) datetimeToday = Common.getDateTime( Common.getDateString(datetimeNow) + " " + jsonEDIFlow["scheduleStartTime"]) if datetimeNow >= datetimeStart and \ datetimeNow >= datetimeToday+datetime.timedelta(seconds=-1) and \ datetimeNow < datetimeToday+datetime.timedelta(seconds=intIntervalSeconds*1.5): strEDIDate = Common.getDateSimple(datetimeNow) strEDIID = jsonEDIFlows["ediID"] strEDIFlowID = jsonEDIFlow["flowID"] strDataDate = Common.getDateSimple(datetimeNow + datetime.timedelta( days=jsonEDIFlow["scheduleDataDelay"])) EDIEntity.insertNewFlow(strEDIConnection, strEDIDB, strEDIDate, strEDIID, strEDIFlowID, strDataDate)
def main(): strLoggerName = sys.argv[1] strEDIConnection = sys.argv[2] strEDIDB = sys.argv[3] strEDINo = sys.argv[4] strJobPathRES = sys.argv[5] strDependOnJobPathRES = sys.argv[6] # logger = logging.getLogger(strLoggerName) # logger.info(str(sys.argv)) dictFlow = EDIEntity.getFlow(strEDIConnection, strEDIDB, strEDINo) strDataDate = dictFlow["DATA_DATE"] strMessageSMTPServer = "tw-mail02.want-want.com" strMessageSMTPFrom = "*****@*****.**" arrayMessageSMTPTo = ["*****@*****.**", "*****@*****.**"] strMessageSubject = "[测试] 业务人员花名册-%s" % strDataDate strAttachFileName = "[测试] 业务人员花名册-%s.xls" % strDataDate arrayColumnTitle = [ "员工号", "姓名", "人事范围", "人事子范围", "雇佣日期", "部门名称", "三级部门", "四级部门", "五级部门", "六级部门", "七级部门", "八级部门", "职位代码", "职位", "职位属性", "职位类型", "职位区域注记", "职位注记", "职务", "职等", "性别", "年资", ] with open(strDependOnJobPathRES, "r", encoding="utf-8-sig") as fileOriginal: objData = fileOriginal.read() with open(strJobPathRES, "w", encoding="utf-8-sig") as fileTarget: fileTarget.write(",".join(arrayColumnTitle) + "\n" + objData) Message.sendSMTPMail(strMessageSMTPServer, strMessageSMTPFrom, arrayMessageSMTPTo, strMessageSubject, "", strJobPathRES, strAttachFileName)
def main(): strLoggerName = sys.argv[1] strEDIConnection = sys.argv[2] strEDIDB = sys.argv[3] strEDINo = sys.argv[4] strJobPathRES = sys.argv[5] # strDependOnJobPathRES = sys.argv[6] Common.setLogging(strLoggerName) # logger = logging.getLogger(strLoggerName) dictFlow = EDIEntity.getFlow(strEDIConnection, strEDIDB, strEDINo) strDataDate = dictFlow["DATA_DATE"] execMailStoreMatlM(strLoggerName, strJobPathRES, strDataDate)