|
|
@@ -1,3 +1,4 @@
|
|
|
+import asyncio
|
|
|
import settings
|
|
|
import os
|
|
|
|
|
|
@@ -19,6 +20,20 @@ from natsort import ns, natsorted
|
|
|
# import math
|
|
|
from PIL import ImageFont
|
|
|
import settings
|
|
|
+from settings import sendSocketMessage
|
|
|
+
|
|
|
+
|
|
|
+def sendMessageAsync(code=0, msg="开始处理详情", data=None, msg_type="detail_progress"):
|
|
|
+ """异步发送消息"""
|
|
|
+ loop = asyncio.get_event_loop()
|
|
|
+ loop.create_task(
|
|
|
+ sendSocketMessage(
|
|
|
+ code=code,
|
|
|
+ msg=msg,
|
|
|
+ data=data,
|
|
|
+ msg_type=msg_type,
|
|
|
+ )
|
|
|
+ )
|
|
|
|
|
|
|
|
|
class DetailBase(object):
|
|
|
@@ -161,6 +176,12 @@ class DetailBase(object):
|
|
|
new_path,
|
|
|
"NUM{}".format(i["number"]),
|
|
|
)
|
|
|
+ sendMessageAsync(
|
|
|
+ code=0,
|
|
|
+ msg="详情页生成完成",
|
|
|
+ msg_type="detail_progress",
|
|
|
+ data={"goods_no": self.goods_no, "temp_name": self.template_name,"status":"已完成"},
|
|
|
+ )
|
|
|
return True
|
|
|
|
|
|
# 移动一张图片到新的文件夹
|
|
|
@@ -174,6 +195,16 @@ class DetailBase(object):
|
|
|
# 生成各个详情图切片
|
|
|
def deal_details(self):
|
|
|
detailed_images = []
|
|
|
+ sendMessageAsync(
|
|
|
+ code=0,
|
|
|
+ msg="正在生成详情页切片",
|
|
|
+ msg_type="detail_progress",
|
|
|
+ data={
|
|
|
+ "goods_no": self.goods_no,
|
|
|
+ "temp_name": self.template_name,
|
|
|
+ "status": "进行中",
|
|
|
+ },
|
|
|
+ )
|
|
|
for index, func in enumerate(self.deal_pic_func_list):
|
|
|
image_pp = func()
|
|
|
if not self.assigned_page_list:
|
|
|
@@ -190,6 +221,16 @@ class DetailBase(object):
|
|
|
# 生成拼接的图片
|
|
|
def generate_spliced_picture(self):
|
|
|
print("详情页切片", "详情页切片")
|
|
|
+ sendMessageAsync(
|
|
|
+ code=0,
|
|
|
+ msg="正在生成详情拼接图",
|
|
|
+ msg_type="detail_progress",
|
|
|
+ data={
|
|
|
+ "goods_no": self.goods_no,
|
|
|
+ "temp_name": self.template_name,
|
|
|
+ "status": "进行中",
|
|
|
+ },
|
|
|
+ )
|
|
|
detail_path = "{out_put_dir}/{goods_no}/详情页切片".format(
|
|
|
out_put_dir=self.out_put_dir, goods_no=self.goods_no
|
|
|
)
|
|
|
@@ -484,9 +525,7 @@ class DetailBase(object):
|
|
|
goods_art_no = goods_art_no_dict["货号"]
|
|
|
# print("goods_art_no:", goods_art_no)
|
|
|
# 移动颜色图=====================
|
|
|
- goods_art_no_f = "{}/{}".format(
|
|
|
- self.out_put_dir, self.goods_no
|
|
|
- )
|
|
|
+ goods_art_no_f = "{}/{}".format(self.out_put_dir, self.goods_no)
|
|
|
self.create_folder(goods_art_no_f)
|
|
|
# 放入一张主图
|
|
|
old_pic_path_1 = goods_art_no_dict["800x800"][0]
|