Exemple #1
0
 def diff_product(self, old_product, product, log_id):
     """
     比较产品
     :param old_product:
     :param product:
     :return:
     """
     if old_product != product:
         old_list = []
         new_list = []
         product_dict = get_product()
         for old_p in old_product:
             old_list.append(product_dict[old_p])
         for new_p in product:
             new_list.append(product_dict[new_p])
         pact_dict = {
             "word": "pact_products",
             "name": "合同产品",
             "new_value": new_list,
             "old_value": old_list,
             "log_id": log_id,
         }
         self.open_list.append(DetailLog(**pact_dict))
     else:
         pass
     return self.open_list
Exemple #2
0
    def train_contact(self, pk, data, log_id):
        """
        联系人变更记录
        :param pk:
        :param data:
        :param log_id:
        :param contact_info:
        :return:
        """
        detail_list = []
        matter_words = matter_word(Matter)
        matter_dict = Matter.objects.filter(pk=pk).values(
            "training_contact", "training_contactnum", "training_contactqq",
            "training_position").first()

        for contact in matter_dict:
            old_value = matter_dict.get(contact)
            new_value = data[contact]
            #   新值               旧值
            if new_value != old_value:
                detail_dict = {
                    "word": contact,
                    "name": matter_words[contact],
                    "old_value": old_value,
                    "new_value": new_value,
                    "log_id": log_id
                }
                detail_list.append(DetailLog(**detail_dict))
        ret = DetailLog.objects.bulk_create(detail_list)
        return ret
Exemple #3
0
 def diff_address(self, old_address, address, log_id):
     """
     比较
     :param old_address:
     :param address:
     :return:
     """
     if old_address != address:
         if old_address != None:
             old_p = AreaInfo.objects.get(
                 pk=old_address.get("province")).atitle
             old_c = AreaInfo.objects.get(pk=old_address.get("city")).atitle
         else:
             old_p, old_c, old_d = "无", "无", "无"
         new_p = AreaInfo.objects.get(pk=address["province"]).atitle
         new_c = AreaInfo.objects.get(pk=address["city"]).atitle
         address_dict = {
             "word": "company_address",
             "name": "公司详细地址",
             "new_value": new_p + new_c + address.get("detail"),
             "old_value": old_p + old_c + old_d,
             "log_id": log_id,
         }
         self.open_list.append(DetailLog(**address_dict))
     else:
         pass
     return self.open_list
Exemple #4
0
 def diff_company(self, old_company, company, log_id):
     """
     比较公司信息
     :param old_company:
     :param company:
     :return:
     """
     for c, v in old_company.items():
         # 判断url
         if c == "company_url":
             self.diff_url(old_company["company_url"],
                           company["company_url"], log_id)
         # 判断地址
         elif c == "company_address":
             self.diff_address(old_company["company_address"],
                               company["company_address"], log_id)
         elif company[c] != v:
             com_dict = {
                 "word": c,
                 "name": openstation_dict[c],
                 "new_value": company[c],
                 "old_value": v,
                 "log_id": log_id
             }
             self.open_list.append(DetailLog(**com_dict))
     return self.open_list
Exemple #5
0
 def diff_func(self, func_list, log_id):
     """
     获取功能开关更改信息
     :param func_list:
     :param log_id:
     :return:
     """
     for f in func_list:
         f.update({"log_id": log_id})
         self.open_list.append(DetailLog(**f))
     return self.open_list
Exemple #6
0
 def unify_put(self, request):
     data = request.data
     m_list = []
     # 操作模块
     operationmodule = data.get("operationmodule")
     # 操作对象唯一标识
     title = data.get("title")
     # 修改变化列表
     modify_list = data.get("modify_list")
     action = ACTION_MAP['PUT']
     # 创建基础日志
     log_id = OpenStationViewSet.create_base_log(request, title,
                                                 operationmodule, action)
     for i in modify_list:
         i.update({"log_id": log_id})
         m_list.append(DetailLog(**i))
     ret = DetailLog.objects.bulk_create(m_list)
     return Response(data={"info": "修改操作记录成功"}, status=status.HTTP_200_OK)
Exemple #7
0
    def diff_order_info(self, old_order, order_info, log_id):
        """
        比较order_info
        :param old_station:
        :param stations:
        :return:
        """
        for s, v in order_info.items():
            if order_info[s] != v:
                stations_dict = {
                    "word": s,
                    "name": openstation_dict[s],
                    "new_value": order_info[s],
                    "old_value": v,
                    "log_id": log_id
                }
                self.open_list.append(DetailLog(**stations_dict))

        return self.open_list
Exemple #8
0
 def diff_link(self, old_link, link, log_id):
     """
     比较联系人信息
     :param old_lind:
     :param link:
     :return:
     """
     if old_link != link:
         link_dict = {
             "word": "link_info",
             "name": "联系人信息",
             "new_value": link,
             "old_value": old_link,
             "log_id": log_id
         }
         self.open_list.append(DetailLog(**link_dict))
     else:
         pass
     return self.open_list
Exemple #9
0
 def diff_url(self, old_url, url, log_id):
     """
     比较url
     :param old_url:
     :param url:
     :return:
     """
     if old_url != url:
         url_dict = {
             "word": "company_url",
             "name": "公司url",
             "new_value": url,
             "old_value": old_url,
             "log_id": log_id,
         }
         self.open_list.append(DetailLog(**url_dict))
     else:
         pass
     return self.open_list
Exemple #10
0
 def diff_funckhk(self, old_func, func_info, log_id):
     old_values = []
     new_values = []
     contract_dict = dict(FUNCTION_SELECT)
     if old_func != func_info:
         for o in old_func:
             old_values.append(contract_dict[o])
         for n in func_info:
             new_values.append(contract_dict[n])
         func_dict = {
             "word": "contract",
             "name": "合同产品",
             "old_value": old_values,
             "new_value": new_values,
             "log_id": log_id
         }
         self.open_list.append(DetailLog(**func_dict))
     else:
         pass
     return self.open_list
Exemple #11
0
 def diff_account(self, old_account, account, log_id):
     """
     比较账户
     :param old_account:
     :param account:
     :return:
     """
     for a, v in old_account[0].items():
         if account[0][a] != v:
             account_dict = {
                 "word": a,
                 "name": openstation_dict[a],
                 "old_value": v,
                 "new_value": account[0][a],
                 "log_id": log_id
             }
             self.open_list.append(DetailLog(**account_dict))
         else:
             pass
     return self.open_list
Exemple #12
0
    def diff_station(self, old_station, stations, log_id):
        """
        比较站点
        :param old_station:
        :param stations:
        :return:
        """
        for s, v in old_station.items():
            if s == "pact_products":
                self.diff_product(old_station["pact_products"],
                                  stations["pact_products"], log_id)
            elif stations[s] != v:
                stations_dict = {
                    "word": s,
                    "name": openstation_dict[s],
                    "new_value": stations[s],
                    "old_value": v,
                    "log_id": log_id
                }
                self.open_list.append(DetailLog(**stations_dict))

        return self.open_list
Exemple #13
0
    def khk_put(self, request):
        data = request.data
        m_list = []
        # 操作模块
        operationmodule = data.get("operationmodule")
        # 客户id
        title = data.get("title")
        # 修改变化列表
        modify_list = data.get("modify_list")
        action = ACTION_MAP['PUT']
        # 创建基础日志
        log_id = self.create_base_log(request, title, operationmodule, action)

        for i in modify_list:
            word = i["word"]
            if word in openstation_dict:
                name = openstation_dict[word]
            else:
                name = word
            # 附件原值
            if word == "contract_accessory":
                old = i["old_value"]
                new = i["new_value"]
                if old == "":
                    i["old_value"] = ""
                    new_list = []
                    for n in eval(new):
                        new_list.append(n["name"])
                    i["new_value"] = new_list
                elif new == "[]":
                    old_list = []
                    for o in eval(old):
                        old_list.append(o["name"])
                    i["old_value"] = old_list
                    i["new_value"] = ""
                else:
                    old_list = []
                    new_list = []
                    for o in eval(old):
                        old_list.append(o["name"])
                    for n in eval(new):
                        new_list.append(n["name"])
                    i["old_value"] = old_list
                    i["new_value"] = new_list

            # 判断公司地址
            if word == "company_address":
                old_d = i["old_value"]
                new_d = i["new_value"]
                old_province = old_d.get("province")
                old_city = old_d.get("city")
                detail = old_d.get("detail")
                new_provinece = AreaInfo.objects.get(
                    pk=new_d.get("province")).atitle
                new_city = AreaInfo.objects.get(pk=new_d.get("city")).atitle
                new_detail = new_d.get("detail")
                if old_province == "":
                    i["old_value"] = ""
                else:
                    province = AreaInfo.objects.get(pk=old_province).atitle
                    city = AreaInfo.objects.get(pk=old_city).atitle
                    i["old_value"] = province + city + detail
                i["new_value"] = new_provinece + new_city + new_detail
            i.update({"log_id": log_id, "name": name})
            # 对值是数字的进行类型转换
            if word in khk_num:
                i["old_value"] = khk_num[word][i["old_value"]]
                i["new_value"] = khk_num[word][i["new_value"]]
            m_list.append(DetailLog(**i))
        ret = DetailLog.objects.bulk_create(m_list)
        return Response(data={"info": "修改操作记录成功"}, status=status.HTTP_200_OK)