当前位置: 首页>>代码示例>>Python>>正文


Python Utils.parse_datetime方法代码示例

本文整理汇总了Python中tinyms.core.common.Utils.parse_datetime方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.parse_datetime方法的具体用法?Python Utils.parse_datetime怎么用?Python Utils.parse_datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tinyms.core.common.Utils的用法示例。


在下文中一共展示了Utils.parse_datetime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dict

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_datetime [as 别名]
 def dict(self, dict_=None):
     """
     1, object to map
     2, map to object
     :param dict_:
     :return:
     """
     if not dict_:
         columns = [c.key for c in class_mapper(self.__class__).columns]
         return dict((c, getattr(self, c)) for c in columns)
     else:
         metas = self.cols_meta()
         for k, v in dict_.items():
             print(k, v)
             if not hasattr(self, k):
                 continue
             for m in metas:
                 if m["name"] == k:
                     if m["type"] == "int":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_int(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "numeric":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_float(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "datetime":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_datetime(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "date":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_date(v))
                         else:
                             setattr(self, k, v)
                     elif m["type"] == "time":
                         if type(v) == str:
                             setattr(self, k, Utils.parse_time(v))
                         else:
                             setattr(self, k, v)
                     else:
                         setattr(self, k, v)
             pass
         pass
开发者ID:tinyms,项目名称:Matty,代码行数:49,代码来源:orm.py

示例2: count

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_datetime [as 别名]
    def count(self, search_text, http_req):
        current_date = None
        if not current_date:
            current_date = Utils.format_date(Utils.current_datetime())
        cur_datetime = Utils.parse_datetime(current_date+" 00:00")
        year = cur_datetime.year
        month = cur_datetime.month
        sf = SessionFactory.new()
        #某月考勤人员,分组统计
        q = sf.query(func.count(ValidWorkCheckOn.id))\
            .join(Archives, ValidWorkCheckOn.archives_id == Archives.id)\
            .filter(func.YEAR(ValidWorkCheckOn.valid_start_time) == year)\
            .filter(func.MONTH(ValidWorkCheckOn.valid_start_time) == month)\
            .group_by(ValidWorkCheckOn.archives_id, Archives.name)

        if search_text:
            q = q.filter(Archives.name.contains(search_text))

        return q.scalar()
开发者ID:tinyms,项目名称:Matty,代码行数:21,代码来源:controller.py

示例3: list

# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import parse_datetime [as 别名]
    def list(self, search_text, start, limit, http_req):
        current_date = None
        if not current_date:
            current_date = Utils.format_date(Utils.current_datetime())
        cur_datetime = Utils.parse_datetime(current_date+" 00:00")
        year = cur_datetime.year
        month = cur_datetime.month

        sf = SessionFactory.new()
        #group by all people with the month
        checkon_subq = sf.query(ValidWorkCheckOn.archives_id)\
            .join(Archives, ValidWorkCheckOn.archives_id == Archives.id)\
            .filter(func.YEAR(ValidWorkCheckOn.valid_start_time) == year)\
            .filter(func.MONTH(ValidWorkCheckOn.valid_start_time) == month)\
            .group_by(ValidWorkCheckOn.archives_id).subquery()

        #迟到,早退,旷工,请假,加班分组统计
        late_subq = sf.query(ValidWorkCheckOn.archives_id, (func.count(1)).label("total"))\
            .filter(ValidWorkCheckOn.status_in == 1)\
            .filter(func.YEAR(ValidWorkCheckOn.valid_start_time) == year)\
            .filter(func.MONTH(ValidWorkCheckOn.valid_start_time) == month)\
            .group_by(ValidWorkCheckOn.archives_id).subquery()

        early_leave_subq = sf.query(ValidWorkCheckOn.archives_id, (func.count(1)).label("total"))\
            .filter(ValidWorkCheckOn.status_out == 1)\
            .filter(func.YEAR(ValidWorkCheckOn.valid_start_time) == year)\
            .filter(func.MONTH(ValidWorkCheckOn.valid_start_time) == month)\
            .group_by(ValidWorkCheckOn.archives_id).subquery()

        no_work_subq = sf.query(ValidWorkCheckOn.archives_id,
                                (func.sum(MinuteDiff(ValidWorkCheckOn.valid_start_time,
                                                     ValidWorkCheckOn.valid_end_time))/(60*24)).label("total"))\
            .filter(ValidWorkCheckOn.status_no_sign == 1)\
            .filter(func.YEAR(ValidWorkCheckOn.valid_start_time) == year)\
            .filter(func.MONTH(ValidWorkCheckOn.valid_start_time) == month)\
            .group_by(ValidWorkCheckOn.archives_id).subquery()
        #事假
        askforleave_subq1 = sf.query(ValidWorkAskForLeave.archives_id,
                                    (func.sum(MinuteDiff(ValidWorkAskForLeave.start_datetime,
                                                         ValidWorkAskForLeave.end_datetime))/(60*24)).label("total"))\
            .filter(func.YEAR(ValidWorkAskForLeave.start_datetime) == year)\
            .filter(func.MONTH(ValidWorkAskForLeave.start_datetime) == month)\
            .filter(ValidWorkAskForLeave.kind == 0)\
            .group_by(ValidWorkAskForLeave.archives_id).subquery()
        #病假
        askforleave_subq2 = sf.query(ValidWorkAskForLeave.archives_id,
                                    (func.sum(MinuteDiff(ValidWorkAskForLeave.start_datetime,
                                                         ValidWorkAskForLeave.end_datetime))/(60*24)).label("total"))\
            .filter(func.YEAR(ValidWorkAskForLeave.start_datetime) == year)\
            .filter(func.MONTH(ValidWorkAskForLeave.start_datetime) == month)\
            .filter(ValidWorkAskForLeave.kind == 1)\
            .group_by(ValidWorkAskForLeave.archives_id).subquery()
        #其它假
        askforleave_subq3 = sf.query(ValidWorkAskForLeave.archives_id,
                                    (func.sum(MinuteDiff(ValidWorkAskForLeave.start_datetime,
                                                         ValidWorkAskForLeave.end_datetime))/(60*24)).label("total"))\
            .filter(func.YEAR(ValidWorkAskForLeave.start_datetime) == year)\
            .filter(func.MONTH(ValidWorkAskForLeave.start_datetime) == month)\
            .filter(ValidWorkAskForLeave.kind == 2)\
            .group_by(ValidWorkAskForLeave.archives_id).subquery()

        overtime_subq = sf.query(ValidWorkOvertime.archives_id,
                                    (func.sum(MinuteDiff(ValidWorkOvertime.start_datetime,
                                                         ValidWorkOvertime.end_datetime))/60).label("total"))\
            .filter(func.YEAR(ValidWorkOvertime.start_datetime) == year)\
            .filter(func.MONTH(ValidWorkOvertime.start_datetime) == month)\
            .group_by(ValidWorkOvertime.archives_id).subquery()

        term_subq = sf.query(Term.name.label("term_name"), TermTaxonomy.id)\
            .filter(TermTaxonomy.term_id == Term.id).subquery()

        subq = sf.query(Archives.id, Archives.code, Archives.name, term_subq.c.term_name)\
            .select_from(Archives).outerjoin(term_subq, Archives.org_id == term_subq.c.id).subquery()

        q = sf.query(checkon_subq.c.archives_id,
                     subq.c.code,
                     subq.c.name,
                     late_subq.c.total,
                     early_leave_subq.c.total,
                     no_work_subq.c.total,
                     askforleave_subq1.c.total,
                     askforleave_subq2.c.total,
                     askforleave_subq3.c.total,
                     overtime_subq.c.total,
                     subq.c.term_name).select_from(checkon_subq)\
            .outerjoin(late_subq, checkon_subq.c.archives_id == late_subq.c.archives_id)\
            .outerjoin(early_leave_subq, checkon_subq.c.archives_id == early_leave_subq.c.archives_id)\
            .outerjoin(no_work_subq, checkon_subq.c.archives_id == no_work_subq.c.archives_id)\
            .outerjoin(askforleave_subq1, checkon_subq.c.archives_id == askforleave_subq1.c.archives_id)\
            .outerjoin(askforleave_subq2, checkon_subq.c.archives_id == askforleave_subq2.c.archives_id)\
            .outerjoin(askforleave_subq3, checkon_subq.c.archives_id == askforleave_subq3.c.archives_id)\
            .outerjoin(overtime_subq, checkon_subq.c.archives_id == overtime_subq.c.archives_id)\
            .join(subq, checkon_subq.c.archives_id == subq.c.id)

        if search_text:
            q = q.filter(checkon_subq.c.name.contains(search_text))

        ds = q.order_by(checkon_subq.c.archives_id).offset(start).limit(limit).all()
        items = list()
        for row in ds:
#.........这里部分代码省略.........
开发者ID:tinyms,项目名称:Matty,代码行数:103,代码来源:controller.py


注:本文中的tinyms.core.common.Utils.parse_datetime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。