Exemple #1
0
 def get_quotations_task(self, quotation_id, user_id=0):
     """根据报价取task信息"""
     q_obj = self.get_quotation_by_id(quotation_id)
     result = {"task_list": [], "columns": [], "column_num": 0}
     if q_obj:
         quotation_name = q_obj.quotation_name
         quotation_ver = q_obj.quotation_ver
         proj_obj = q_obj.projects
         proj_name = proj_obj.insideName.inside_name
         proj_id = proj_obj.proj_id
         obj_quotation = get_ds_quotation(quotation_id)
         func_task_df = obj_quotation.get_func_task_df()
         func_task_df = func_task_df.fillna('')
         task_list = func_task_df.to_dict(orient="records")
         task_list = self.find_children_group(task_list)
         result["proj_id"] = proj_id
         result["proj_name"] = proj_name
         result["quotation_name"] = quotation_name
         result["quotation_ver"] = quotation_ver
         result["task_list"] = task_list
         result["columns"] = obj_quotation.get_func_columns(
         ) + obj_quotation.get_task_columns()
         result["column_num"] = obj_quotation.get_func_column_num(
         ) + obj_quotation.get_task_column_num()
         return result
     else:
         return False
Exemple #2
0
 def get(self, quotation_id):
     from app.data_server.ds_quotation import get_ds_quotation
     obj_quotation = get_ds_quotation(quotation_id)
     summary_df = obj_quotation.summary_manday_by_func()
     func_list = summary_df.to_dict(orient="records")
     # for func in func_list:
     #     print(func)
     return func_list
Exemple #3
0
    def get(self, quotation_id):
        from app.data_server.ds_quotation import get_ds_quotation
        obj_quotation = get_ds_quotation(quotation_id)
        func_df = obj_quotation.get_func_df()
        # Func和Task合并
        task_df = obj_quotation.get_task_df()
        func_task_df = obj_quotation.merge_func_task(func_df, task_df)
        func_list = func_task_df.to_dict(orient="records")
        # b = obj_quotation.manday_df.to_dict(orient="records")
        # for func in func_list:
        #     print(func)

        print(obj_quotation.get_func_columns())
        print(obj_quotation.get_func_column_num())
        print(obj_quotation.get_task_columns())
        return func_list
Exemple #4
0
 def get(self, quotation_id):
     from app.data_server.ds_quotation import get_ds_quotation
     obj_quotation = get_ds_quotation(quotation_id)
     # obj_quotation.load_function_task_manday_df()
     # func_df = obj_quotation.get_func_df()
     func_task_df = obj_quotation.get_func_task_df()
     group_ids = [1, 2]
     option_ids = [1]
     option_group_dict = obj_quotation.filter_and_split_manday_df(func_task_df=func_task_df,
                                                                  group_ids=group_ids,
                                                                  option_ids=option_ids)
     # func_task_manday_df = obj_quotation.merge_func_task_manday(group_ids=[1, 2])
     for (op, gp), df in option_group_dict.items():
         print(op, gp, '================================\n')
         func_list = df.to_dict(orient="records")
         for func in func_list:
             print(func)
         return func_list
Exemple #5
0
 def get_detail_cost(self, func_id):
     """
     获取一条function的详细工数
     :param func_id:
     :return:
     """
     result = dict()
     try:
         func_q = db.session.query(Functions).filter(
             Functions.func_id == func_id).first()
         if not func_q:
             return False, "func_id:%s不存在!" % func_id
         quotation_id = func_q.quotation_id
         option_list, option_ids = self.get_option_list(quotation_id)
         option_name_list = [
             option.get("option_name") for option in option_list
         ]
         cost_list = ["days", "precondition", "comment", "status"]
         data_list = []
         obj_quotation = get_ds_quotation(quotation_id)
         func_task_df, manday_dict, option_group_ids = obj_quotation.func_manday_detail(
             option_ids, func_id)
         option_group, group_name_list = self.install_option_group(
             option_list, option_name_list, option_group_ids)
         func_task_df = func_task_df.fillna('')
         for i in range(len(func_task_df)):
             func_task_dict = func_task_df.iloc[i].to_dict()
             self.to_int(func_task_dict)
             func_task_dict = self.find_children_group([func_task_dict])[0]
             cost_dict = self.get_cost_data(option_group, manday_dict, i)
             func_task_dict.update(cost_dict)
             data_list.append(func_task_dict)
         result["cost_list"] = cost_list
         result["data_list"] = data_list
         result["option_list"] = option_name_list
         result["group_list"] = group_name_list
         # TODO 有过滤条件时把实际返回的Feature/Task DataFrame作为参数传进来
         result["func_task_list"] = obj_quotation.get_task_columns(
             func_task_df)
         return True, result
     except Exception as e:
         current_app.logger.error('%s' % e)
         return False, "服务异常!请联系管理员!"
Exemple #6
0
 def summary_cost(self, quotation_id, user_id):
     """工数汇总"""
     role_list = CtrlUser().get_user_roles(user_id)
     if "SALES" not in role_list:
         return False, "您没有权限查看工数汇总!"
     q_obj = self.get_quotation_by_id(quotation_id)
     result = dict()
     if q_obj:
         quotation_name = q_obj.quotation_name
         quotation_ver = q_obj.quotation_ver
         proj_obj = q_obj.projects
         proj_name = proj_obj.insideName.inside_name
         cost_list = ["days", "precondition", "comment", "status"]
         data_list = []
         option_list, option_ids = self.get_option_list(quotation_id)
         option_name_list = [
             option.get("option_name") for option in option_list
         ]
         obj_quotation = get_ds_quotation(quotation_id)
         summary_manday_df_dict = obj_quotation.summary_manday_by_func(
             option_ids)
         func_df = obj_quotation.get_func_df()
         func_df = func_df.fillna('')
         for i in range(len(func_df)):
             func_dict = func_df.iloc[i].to_dict()
             self.to_int(func_dict)
             func_dict.update(
                 self._summary_cost(option_list, summary_manday_df_dict, i))
             data_list.append(func_dict)
         result["cost_list"] = cost_list
         result["data_list"] = data_list
         result["option_list"] = option_name_list
         result["proj_name"] = proj_name
         result["quotation_name"] = quotation_name
         result["quotation_ver"] = quotation_ver
         result["func_task_list"] = obj_quotation.get_func_columns()
         return result, ""
     else:
         return False, "该报价不存在!"
Exemple #7
0
 def get_quotations_cost(self, quotation_id, user_id, myself):
     """根据报价取task和工数信息"""
     role_list = CtrlUser().get_user_roles(user_id)
     my_role = None
     if "SGL" in role_list:
         my_role = "SGL"
     elif "GL" in role_list:
         my_role = "GL"
     q_obj = self.get_quotation_by_id(quotation_id)
     result = dict()
     if q_obj:
         proj_id = q_obj.proj_id
         quotation_name = q_obj.quotation_name
         quotation_ver = q_obj.quotation_ver
         proj_obj = q_obj.projects
         proj_name = proj_obj.insideName.inside_name
         my_group = CtrlUserGroup().get_my_group(user_id, proj_id)
         my_group_id = my_group.get("group_id")
         cost_list = ["days", "precondition", "comment", "status"]
         data_list = []
         select_data = dict()
         select_data["precondition"] = self.get_all_precondition(proj_id)
         select_data['status'] = self.get_status_by_role(user_id, proj_id)
         option_list, option_ids = self.get_option_list(quotation_id)
         group_list, group_ids, parent_sub_group_ids = self.get_group_list(
             user_id, quotation_id)
         option_name_list = [
             option.get("option_name") for option in option_list
         ]
         group_name_list = [group.get("group_name") for group in group_list]
         group_name_list = sorted(list(set(group_name_list)))  # 按组名称排序
         obj_quotation = get_ds_quotation(quotation_id)
         func_task_df, manday_dict = obj_quotation.filter_and_split_manday_df(
             set(group_ids),
             set(parent_sub_group_ids),
             option_ids,
             my=myself,
             my_group_id=my_group_id,
             my_role=my_role)
         # if myself:
         #     func_task_df = obj_quotation.get_my_func_task(set(parent_sub_group_ids))  # 筛选func_task也带上父组的id
         # else:
         #     func_task_df = obj_quotation.get_func_task_df()
         func_task_df = func_task_df.fillna('')
         # func_task_df.insert(loc=0, column="myself", value=[False]*len(func_task_df))
         # func_task_df["myself"] = func_task_df
         option_group = []
         for option in option_list:
             option_id = option.get("option_id")
             option_name = option.get("option_name")
             for group in group_list:
                 group_id = group.get("group_id")
                 group_name = group.get("group_name")
                 option_group.append(
                     ((option_id, group_id), (option_name, group_name)))
         for i in range(len(func_task_df)):
             func_task_dict = func_task_df.iloc[i].to_dict()
             self.to_int(func_task_dict)
             func_task_dict = self.find_children_group([func_task_dict])[0]
             cost_dict = self.get_cost_data(option_group, manday_dict, i)
             func_task_dict.update(cost_dict)
             data_list.append(func_task_dict)
         result["cost_list"] = cost_list
         result["data_list"] = data_list
         result["option_list"] = option_name_list
         result["group_list"] = group_name_list
         result["select_data"] = select_data
         result["proj_id"] = proj_id
         result["proj_name"] = proj_name
         result["quotation_name"] = quotation_name
         result["quotation_ver"] = quotation_ver
         # TODO 有过滤条件时把实际返回的Feature/Task DataFrame作为参数传进来
         if myself:
             result["func_task_list"] = (
                 obj_quotation.get_func_columns(func_task_df) +
                 obj_quotation.get_task_columns(func_task_df) +
                 ["分配大组", "分配小组"])
         else:
             result["func_task_list"] = (obj_quotation.get_func_columns() +
                                         obj_quotation.get_task_columns() +
                                         ["分配大组", "分配小组"])
         return True, result
     else:
         return False, "该报价不存在!"