Преглед на файлове

支持获取模板传入参数

Veronique преди 1 година
родител
ревизия
ce9f2de76c

+ 18 - 0
conf/KeyId.xml

@@ -172,4 +172,22 @@
             <TableWhere/>
         </Table>
     </Item>
+
+    <Item>
+        <IDName>deDesignOrder.id</IDName>
+        <Table>
+            <TableName>deDesignOrder</TableName>
+            <IDFieldName>id</IDFieldName>
+            <TableWhere/>
+        </Table>
+    </Item>
+
+    <Item>
+        <IDName>deDesignOrderItem.id</IDName>
+        <Table>
+            <TableName>deDesignOrderItem</TableName>
+            <IDFieldName>id</IDFieldName>
+            <TableWhere/>
+        </Table>
+    </Item>
 </Items>

+ 4 - 1
conf/rediskeys.properties

@@ -211,4 +211,7 @@ redis.erp.account.last.period = sdtool:mall:erp:account:last:period
 redis.designer.design.template.edit = sdtool:mall:designer:design:template:edit
 redis.designer.design.template.imposition = sdtool:mall:designer:design:template:imposition
 redis.designer.design.font = sdtool:mall:designer:design:font
-redis.designer.sys.user.token = sdtool:mall:designer:sys:user:token
+redis.designer.sys.user.token = sdtool:mall:designer:sys:user:token
+
+redis.designer.design.order.edit = sdtool:mall:designer:design:order:edit
+redis.designer.design.order.imposition = sdtool:mall:designer:design:order:imposition

+ 61 - 0
conf/script/0/init/Init_52_DesignOrder.groovy

@@ -0,0 +1,61 @@
+import com.sdtool.business.dao.DesignDao
+import com.sdtool.common.api.NoSqlKeysService
+import com.sdtool.common.datas.RedisKeys
+import com.dySweetFishPlugin.redis.RedisService
+import com.sdtool.common.entity.design.DesignOrder
+import com.sdtool.common.entity.design.DesignOrderItem
+import com.sdtool.common.entity.design.DesignTemplate
+import com.sdtool.common.entity.design.DesignTemplateItem
+import com.sweetfish.convert.json.JsonConvert
+import com.sweetfish.source.PageFlipper
+import org.apache.commons.lang3.StringUtils
+import org.apache.logging.log4j.Logger
+import org.rex.RMap
+
+import java.nio.file.Files
+import java.nio.file.Paths
+
+/**
+ * @Author: xl Created on 2024-05-11
+ * @Content:
+ */
+
+static def createRunnable(RedisService redisService, NoSqlKeysService keysService,
+                          DesignDao designDao, Logger logger, JsonConvert jsonConvert, String dataSourceId, long supplierCode) {
+    RMap params = new RMap()
+    return {
+        redisService.del(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_ORDER_EDIT, supplierCode))
+        redisService.del(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_ORDER_IMPOSITION, supplierCode))
+        Ignore_ExecPageFlipper.execute(1000, { PageFlipper p ->
+            List<DesignOrder> orders = designDao.selectDesignOrders(params, dataSourceId, supplierCode, p)
+
+            if (!orders.isEmpty()) {
+                orders.each {
+                    if (StringUtils.isNotEmpty(it.jsonContent)) {
+                        File file = new File(it.jsonContent)
+                        if (file.exists()) {
+                            String content = new String(Files.readAllBytes(Paths.get(it.jsonContent)), "UTF-8")
+                            it.setJsonContent(content)
+                        }
+                    }
+                }
+                Map<String, String> redisMap = orders.collectEntries { [String.valueOf(it.getId()), jsonConvert.convertTo(it)] }
+                redisService.hmset(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_ORDER_EDIT, supplierCode), redisMap)
+
+                RMap itemParams = new RMap()
+                orders.each {
+                    itemParams.set("idOrder", it.id)
+                    List<DesignOrderItem> itemList = designDao.selectDesignOrderItems(itemParams, dataSourceId, supplierCode)
+                    it.setItemList(itemList)
+                    it.setJsonContent("")
+                }
+                redisMap = orders.collectEntries { [String.valueOf(it.getId()), jsonConvert.convertTo(it)] }
+                redisService.hmset(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_ORDER_IMPOSITION, supplierCode), redisMap)
+
+                logger.info("设计订单共" + orders.size() + "条记录")
+            }
+        })
+    } as Runnable
+}
+
+createRunnable(redisService, keysService, designDao, logger, jsonConvert, dataSourceId, supplierCode)

+ 53 - 3
conf/sqlroot/com/sdtool/business/dao/DesignDao.dql

@@ -43,15 +43,41 @@ order by #{orderBy}
 -- [selectDesignTemplateItems]
 select * from $table$ where idTemplate = #{idTemplate};
 
+-- [selectDesignOrders]
+select *
+from $table$
+-- trim prefix=WHERE prefixOverrides=AND|OR
+  -- isNotEmpty voidFlag
+    -- if voidFlag >= 0
+        voidFlag = #{voidFlag}
+    -- end
+  -- end
+  -- isNotEmpty keyWord
+    and (orderName LIKE #{Like:keyWord})
+  -- end
+  -- isNotEmpty orderName
+    and templateName LIKE #{Like:orderName}
+  -- end
+-- end
+-- isEmpty orderBy
+order by createTime desc
+-- else
+order by #{orderBy}
+-- end
+;
+
+-- [selectDesignOrderItems]
+select * from $table$ where idOrder = #{idOrder};
+
 -- [addDesignTemplate]
 insert into $table$ (id, templateName, backgroundPath, viewThumbPath,
 canvasHeight, canvasWidth, breedHeight,
-breedWidth, idProduct, voidFlag,
+breedWidth, productIdentity, voidFlag,
 jsonContent, createBy, createTime,
 createTimeLong, updateBy, updateTime,
 updateTimeLong ) values ( #{id}, #{templatename}, #{backgroundpath}, #{viewthumbpath},
 #{canvasheight}, #{canvaswidth}, #{breedheight},
-#{breedwidth}, #{idproduct}, #{voidflag},
+#{breedwidth}, #{productidentity}, #{voidflag},
 #{jsoncontent}, #{createby}, #{createtime},
 #{createtimelong}, #{updateby}, #{updatetime},
 #{updatetimelong} );
@@ -87,4 +113,28 @@ update $table$ set
 voidFlag = #{voidflag},
 updateBy = #{updateby},
 updateTime = #{updatetime}
-where id = #{id};
+where id = #{id};
+
+-- [addDesignOrder]
+insert into $table$ (id, idTemplate, userIdentity, orderMame,
+backgroundPath, viewThumbPath, canvasHeight,
+canvasWidth, breedHeight, breedWidth,
+productIdentity, voidFlag, jsonContent,
+createBy, createTime, createTimeLong,
+updateBy, updateTime, updateTimeLong ) values ( #{id}, #{idtemplate}, #{useridentity}, #{ordermame},
+#{backgroundpath}, #{viewthumbpath}, #{canvasheight},
+#{canvaswidth}, #{breedheight}, #{breedwidth},
+#{productidentity}, #{voidflag}, #{jsoncontent},
+#{createby}, #{createtime}, #{createtimelong},
+#{updateby}, #{updatetime}, #{updatetimelong} );
+
+-- [addDesignOrderItem]
+insert into $table$ (id, idOrder, itemType, locationX,
+locationY, sizeWidth, sizeHeight,
+rotation, zIndex, jsonContent,
+createBy, createTime, createTimeLong,
+updateBy, updateTime, updateTimeLong ) values ( #{id}, #{idorder}, #{itemtype}, #{locationx},
+#{locationy}, #{sizewidth}, #{sizeheight},
+#{rotation}, #{zindex}, #{jsoncontent},
+#{createby}, #{createtime}, #{createtimelong},
+#{updateby}, #{updatetime}, #{updatetimelong} );

+ 21 - 3
sdBusiness/src/main/java/com/sdtool/business/dao/DesignDao.java

@@ -1,9 +1,7 @@
 package com.sdtool.business.dao;
 
 import com.dySweetFishPlugin.sql.dao.*;
-import com.sdtool.common.entity.design.DesignFont;
-import com.sdtool.common.entity.design.DesignTemplate;
-import com.sdtool.common.entity.design.DesignTemplateItem;
+import com.sdtool.common.entity.design.*;
 import com.sweetfish.source.PageFlipper;
 import org.rex.RMap;
 
@@ -64,4 +62,24 @@ public interface DesignDao extends DaoRepository {
     void voidDesignTemplate(DesignTemplate designTemplate, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
     //endregion
 
+    //region 设计订单
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = DesignDao.class, sql = "selectDesignOrders", table = "dedesignorder", params = {1})
+    List<DesignOrder> selectDesignOrders(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode,
+                                            PageFlipper pageFlipper);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = DesignDao.class, sql = "selectDesignOrderItems", table = "dedesignorderitem", params = {1})
+    List<DesignOrderItem> selectDesignOrderItems(RMap params, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = SupplierTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
+    @SqlId(clazz = DesignDao.class, sql = "addDesignOrder", table = "deDesignOrder", params = {1}, sort = 1)
+    @SqlId(clazz = DesignDao.class, sql = "addDesignOrderItem", table = "deDesignOrderItem", params = {2}, sort = 2)
+    void addDesignTemplate(DesignOrder designOrder, List<DesignOrderItem> itemList, @DatabaseShardingBy String dataSourceId, @TableShardingBy Long supplierCode);
+
+    //endregion
+
 }

+ 130 - 10
sdBusiness/src/main/java/com/sdtool/business/service/mall/DesignServiceImpl.java

@@ -1,5 +1,7 @@
 package com.sdtool.business.service.mall;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.dySweetFishPlugin.redis.RedisService;
 import com.dySweetFishPlugin.sql.TableIdService;
 import com.dySweetFishPlugin.sql.dao.TunaService;
@@ -11,19 +13,18 @@ import com.sdtool.common.datas.RedisKeys;
 import com.sdtool.common.entity.base.BaseEntity;
 import com.sdtool.common.entity.base.ProcessIdItem;
 import com.sdtool.common.entity.base.ProcessStringItem;
-import com.sdtool.common.entity.design.DesignFont;
-import com.sdtool.common.entity.design.DesignTemplate;
-import com.sdtool.common.entity.design.DesignTemplateItem;
+import com.sdtool.common.entity.design.*;
+import com.sdtool.common.entity.design.fabric.FabricMain;
 import com.sdtool.common.entity.site.ERPTokenUser;
 import com.sdtool.common.tool.ERPUtils;
 import com.sweetfish.convert.json.JsonConvert;
+import com.sweetfish.convert.json.JsonFactory;
 import com.sweetfish.service.Local;
 import com.sweetfish.service.RetResult;
 import com.sweetfish.source.PageFlipper;
 import com.sweetfish.util.AnyValue;
 import com.sweetfish.util.AutoLoad;
 import com.sweetfish.util.ResourceType;
-import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.rex.RMap;
 
@@ -35,10 +36,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.StandardOpenOption;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import java.util.*;
 
 @Local
 @AutoLoad(false)
@@ -60,6 +58,9 @@ public class DesignServiceImpl extends BaseService implements DesignService {
     @Resource
     private NoSqlKeysService keysService;
 
+    @Resource
+    JsonFactory jsonRootFactory;
+
     @Resource(name = "APP_HOME")
     private String appHome;
 
@@ -67,6 +68,7 @@ public class DesignServiceImpl extends BaseService implements DesignService {
     private String tokenKey;
 
     private String designContentRoot;
+    private String orderContentRoot;
 
     private DesignDao designDao;
 
@@ -75,6 +77,7 @@ public class DesignServiceImpl extends BaseService implements DesignService {
         designDao = tunaService.generate(DesignDao.class);
 
         designContentRoot = appHome + File.separator + "conf" + File.separator + "designContent";
+        orderContentRoot = appHome + File.separator + "conf" + File.separator + "orderContent";
     }
 
     @Override
@@ -133,6 +136,63 @@ public class DesignServiceImpl extends BaseService implements DesignService {
             return RetResult.<DesignTemplate>successT().result(redisTemplate);
     }
 
+    /**
+     * 获取供编辑的设计模板,带参数
+     *
+     * @param id
+     * @param params
+     * @param dataSourceId
+     * @param supplierCode
+     * @return
+     */
+    @Override
+    public RetResult<DesignTemplate> getDesignTemplateEdit(long id, RMap params, String dataSourceId, long supplierCode) {
+        DesignTemplate redisTemplate = getRedisDocInfo(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_TEMPLATE_EDIT, supplierCode),
+                String.valueOf(id), DesignTemplate.class);
+
+        if (redisTemplate == null) return RetResult.<DesignTemplate>errorT().retinfo("模板id不正确");
+        else {
+            FabricMain fabricMain = jsonConvert.convertFrom(FabricMain.class, redisTemplate.getJsonContent());
+
+            //根据传入参数不同,查找替换
+            if (ERPUtils.mapContainKey(params, "backgroundWidth") &&
+                    ERPUtils.mapContainKey(params, "backgroundHeight")) {
+                //传进来的默认都是mm,但是fabric记录的是px,需要转一下
+                double width = ERPUtils.mm2px(params.getDouble("backgroundWidth"));
+                double height = ERPUtils.mm2px(params.getDouble("backgroundHeight"));
+
+                fabricMain.setHeight(height * fabricMain.getZoom());
+                fabricMain.setWidth(width * fabricMain.getZoom());
+
+                fabricMain.getObjects().forEach(object -> {
+                    if (object.get("id").equals("WorkSpaceDrawType")) {
+                        //背景对象
+                        object.put("height", height);
+                        object.put("width", width);
+                    }
+                });
+            }
+            if (ERPUtils.mapContainKey(params, "backgroundColor")) {
+                //格式 rgba(125,125,125,1)
+                String color = params.getString("backgroundColor");
+                fabricMain.getObjects().forEach(object -> {
+                    if (object.get("id").equals("WorkSpaceDrawType")) {
+                        //背景对象
+                        object.put("color", color);
+                        object.put("fill", color);
+                    }
+                });
+
+                fabricMain.getWorkSpace().setColor(color);
+                fabricMain.getWorkSpace().setFill(color);
+            }
+//            redisTemplate.setJsonContent(jsonConvert.convertTo(fabricMain));
+            redisTemplate.setJsonContent(JSON.toJSONString(fabricMain, SerializerFeature.WriteMapNullValue));
+            return RetResult.<DesignTemplate>successT().result(redisTemplate);
+        }
+
+    }
+
     @Override
     public RetResult<DesignTemplate> getDesignTemplateImposition(long id, String dataSourceId, long supplierCode) {
         DesignTemplate redisTemplate = getRedisDocInfo(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_TEMPLATE_IMPOSITION, supplierCode),
@@ -144,7 +204,11 @@ public class DesignServiceImpl extends BaseService implements DesignService {
     }
 
     //todo 转换fabric的元素结构
-    private List<DesignTemplateItem> convertJsonObjectsToItems(String jsonObjects) {
+    private List<DesignTemplateItem> convertJsonObjectsToTemplateItems(String jsonObjects) {
+        return new ArrayList<>();
+    }
+
+    private List<DesignOrderItem> convertJsonObjectsToOrderItems(String jsonObjects) {
         return new ArrayList<>();
     }
 
@@ -183,7 +247,7 @@ public class DesignServiceImpl extends BaseService implements DesignService {
         }
 
         redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_TEMPLATE_EDIT, supplierCode), String.valueOf(template.getId()), template);
-        List<DesignTemplateItem> itemList = convertJsonObjectsToItems(template.getJsonContent());
+        List<DesignTemplateItem> itemList = convertJsonObjectsToTemplateItems(template.getJsonContent());
         template.setJsonContent(fileName);
         template.setItemList(itemList);
         redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_TEMPLATE_IMPOSITION, supplierCode), String.valueOf(template.getId()), template);
@@ -271,4 +335,60 @@ public class DesignServiceImpl extends BaseService implements DesignService {
 
         return RetResult.<ProcessStringItem>successT().result(resultItem);
     }
+
+    private DesignOrder convertTemplateToOrder(DesignTemplate designTemplate) {
+        DesignOrder designOrder = new DesignOrder();
+        designOrder.setIdTemplate(designTemplate.getId());
+        designOrder.setOrderMame("[" + designTemplate.getTemplateName() + "]" + ERPUtils.parseTimeFormat(new Date(), "yyyyMMdd") + "设计订单");
+        designOrder.setProductIdentity(designTemplate.getProductIdentity());
+        designOrder.setJsonContent(designTemplate.getJsonContent());
+
+        return designOrder;
+    }
+
+    @Override
+    public RetResult<DesignOrder> newDesignOrder(DesignTemplate customerDesign, String dataSourceId, long supplierCode, ERPTokenUser currentUser) {
+        DesignOrder designOrder = convertTemplateToOrder(customerDesign);
+        designOrder.setId(tableIdService.getTableIdMulti("deDesignOrder.id", 1, dataSourceId, String.valueOf(supplierCode)));
+        DesignOrder.create(designOrder, currentUser.getId());
+
+        String fileName = orderContentRoot + File.separator + supplierCode +
+                File.separator + designOrder.getId() + ".txt";
+        Path path = Paths.get(fileName);
+
+        String writeContent = "";
+        if (StringUtils.isNotEmpty(designOrder.getJsonContent())) {
+            writeContent = designOrder.getJsonContent();
+        }
+        try {
+            if (!Files.exists(path.getParent())) {
+                Files.createDirectories(path.getParent());
+            }
+            Files.write(path,
+                    Collections.singleton(new StringBuilder(writeContent)),
+                    StandardCharsets.UTF_8,
+                    StandardOpenOption.CREATE,
+                    StandardOpenOption.WRITE,
+                    StandardOpenOption.TRUNCATE_EXISTING);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_ORDER_EDIT, supplierCode), String.valueOf(designOrder.getId()), designOrder);
+        List<DesignOrderItem> itemList = convertJsonObjectsToOrderItems(designOrder.getJsonContent());
+        designOrder.setJsonContent(fileName);
+        designOrder.setItemList(itemList);
+        redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DESIGNER_DESIGN_ORDER_IMPOSITION, supplierCode), String.valueOf(designOrder.getId()), designOrder);
+
+        //todo 生成pdf
+
+        designDao.addDesignTemplate(designOrder, designOrder.getItemList(), dataSourceId, supplierCode);
+
+        return RetResult.<DesignOrder>successT().result(designOrder);
+    }
+
+    @Override
+    public RetResult<DesignOrder> updateDesignOrder(DesignOrder designOrder, String dataSourceId, long supplierCode, ERPTokenUser currentUser) {
+        return null;
+    }
 }

+ 10 - 0
sdCommon/src/main/java/com/sdtool/common/api/mall/DesignService.java

@@ -4,6 +4,7 @@ import com.sdtool.common.api.ScriptService;
 import com.sdtool.common.entity.base.ProcessIdItem;
 import com.sdtool.common.entity.base.ProcessStringItem;
 import com.sdtool.common.entity.design.DesignFont;
+import com.sdtool.common.entity.design.DesignOrder;
 import com.sdtool.common.entity.design.DesignTemplate;
 import com.sdtool.common.entity.site.ERPTokenUser;
 import com.sweetfish.service.RetResult;
@@ -26,6 +27,8 @@ public interface DesignService extends ScriptService {
 
     RetResult<DesignTemplate> getDesignTemplateEdit(long id, String dataSourceId, long supplierCode);
 
+    RetResult<DesignTemplate> getDesignTemplateEdit(long id, RMap params, String dataSourceId, long supplierCode);
+
     RetResult<DesignTemplate> getDesignTemplateImposition(long id, String dataSourceId, long supplierCode);
 
     RetResult<DesignTemplate> updateDesignTemplate(DesignTemplate template, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
@@ -41,4 +44,11 @@ public interface DesignService extends ScriptService {
     RetResult<ProcessStringItem> getCurrentUserTokenInfo(String virtualCode);
     //endregion
 
+    //region 设计订单
+    RetResult<DesignOrder> newDesignOrder(DesignTemplate customerDesign, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
+
+    RetResult<DesignOrder> updateDesignOrder(DesignOrder designOrder, String dataSourceId, long supplierCode, ERPTokenUser currentUser);
+    //endregion
+
+
 }

+ 5 - 1
sdCommon/src/main/java/com/sdtool/common/datas/RedisKeys.java

@@ -464,8 +464,12 @@ public class RedisKeys {
     //模板--给后面流程用的,记录itemList,不记录jsonContent
     public static final String KEY_DESIGNER_DESIGN_TEMPLATE_IMPOSITION = "redis.designer.design.template.imposition";
 
-    public static final String KEY_DESIGNER_DESIGN_FONT = "redis.designer.design.font";
+    //订单--给模板编辑用的,不记录item,全文记录jsonContent
+    public static final String KEY_DESIGNER_DESIGN_ORDER_EDIT = "redis.designer.design.order.edit";
+    //订单--给后面流程用的,记录itemList,不记录jsonContent
+    public static final String KEY_DESIGNER_DESIGN_ORDER_IMPOSITION = "redis.designer.design.order.imposition";
 
+    public static final String KEY_DESIGNER_DESIGN_FONT = "redis.designer.design.font";
     //系统流转间暂存token
     public static final String KEY_DESIGNER_SYS_USER_TOKEN = "redis.designer.sys.user.token";
     //endregion

+ 180 - 0
sdCommon/src/main/java/com/sdtool/common/entity/design/DesignOrder.java

@@ -0,0 +1,180 @@
+package com.sdtool.common.entity.design;
+
+import com.sdtool.common.entity.base.BaseEntity;
+import com.sweetfish.util.Comment;
+import org.rex.db.RColumn;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 设计订单,由模板转化而来
+ */
+public class DesignOrder extends BaseEntity {
+    @RColumn("id")
+    @Comment("")
+    private long id;
+
+    @RColumn("idtemplate")
+    @Comment("模板id")
+    private long idTemplate;
+
+    @Comment("用户id")
+    @RColumn("useridentity")
+    private String userIdentity;
+
+    @RColumn("ordermame")
+    @Comment("订单名称")
+    private String orderMame;
+
+    @RColumn("backgroundpath")
+    @Comment("背景图片")
+    private String backgroundPath;
+
+    @RColumn("viewthumbpath")
+    @Comment("缩略图")
+    private String viewThumbPath;
+
+    @RColumn("canvasheight")
+    @Comment("画布高(mm)")
+    private double canvasHeight;
+
+    @RColumn("canvaswidth")
+    @Comment("画布宽(mm)")
+    private double canvasWidth;
+
+    @RColumn("breedheight")
+    @Comment("拼版尺寸高")
+    private double breedHeight;
+
+    @RColumn("breedwidth")
+    @Comment("拼版尺寸宽")
+    private double breedWidth;
+
+    @RColumn("productidentity")
+    @Comment("产品id,暂时手传")
+    private String productIdentity;
+
+    @RColumn("voidflag")
+    @Comment("")
+    private int voidFlag;
+
+    @RColumn("jsoncontent")
+    @Comment("模板属性json,数据库记录的是文件链接")
+    private String jsonContent;
+
+    @Comment("元素")
+    private List<DesignOrderItem> itemList = new ArrayList<>();
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getUserIdentity() {
+        return userIdentity;
+    }
+
+    public void setUserIdentity(String userIdentity) {
+        this.userIdentity = userIdentity;
+    }
+
+    public long getIdTemplate() {
+        return idTemplate;
+    }
+
+    public void setIdTemplate(long idTemplate) {
+        this.idTemplate = idTemplate;
+    }
+
+    public String getOrderMame() {
+        return orderMame;
+    }
+
+    public void setOrderMame(String orderMame) {
+        this.orderMame = orderMame;
+    }
+
+    public String getBackgroundPath() {
+        return backgroundPath;
+    }
+
+    public void setBackgroundPath(String backgroundPath) {
+        this.backgroundPath = backgroundPath;
+    }
+
+    public String getViewThumbPath() {
+        return viewThumbPath;
+    }
+
+    public void setViewThumbPath(String viewThumbPath) {
+        this.viewThumbPath = viewThumbPath;
+    }
+
+    public double getCanvasHeight() {
+        return canvasHeight;
+    }
+
+    public void setCanvasHeight(double canvasHeight) {
+        this.canvasHeight = canvasHeight;
+    }
+
+    public double getCanvasWidth() {
+        return canvasWidth;
+    }
+
+    public void setCanvasWidth(double canvasWidth) {
+        this.canvasWidth = canvasWidth;
+    }
+
+    public double getBreedHeight() {
+        return breedHeight;
+    }
+
+    public void setBreedHeight(double breedHeight) {
+        this.breedHeight = breedHeight;
+    }
+
+    public double getBreedWidth() {
+        return breedWidth;
+    }
+
+    public void setBreedWidth(double breedWidth) {
+        this.breedWidth = breedWidth;
+    }
+
+    public String getProductIdentity() {
+        return productIdentity;
+    }
+
+    public void setProductIdentity(String productIdentity) {
+        this.productIdentity = productIdentity;
+    }
+
+    public int getVoidFlag() {
+        return voidFlag;
+    }
+
+    public void setVoidFlag(int voidFlag) {
+        this.voidFlag = voidFlag;
+    }
+
+    public String getJsonContent() {
+        return jsonContent;
+    }
+
+    public void setJsonContent(String jsonContent) {
+        this.jsonContent = jsonContent;
+    }
+
+    public List<DesignOrderItem> getItemList() {
+        return itemList;
+    }
+
+    public void setItemList(List<DesignOrderItem> itemList) {
+        this.itemList = itemList;
+    }
+}

+ 130 - 0
sdCommon/src/main/java/com/sdtool/common/entity/design/DesignOrderItem.java

@@ -0,0 +1,130 @@
+package com.sdtool.common.entity.design;
+
+import com.sdtool.common.entity.base.BaseEntity;
+import com.sweetfish.util.Comment;
+import org.rex.db.RColumn;
+
+/**
+ * 设计元素,订单的子表
+ */
+public class DesignOrderItem extends BaseEntity {
+    @Comment("")
+    @RColumn("id")
+    private long id;
+
+    @Comment("关联的订单id")
+    @RColumn("idorder")
+    private long idOrder;
+
+    @Comment("元素类型")
+    @RColumn("itemtype")
+    private int itemType;
+
+    @Comment("坐标x(锚点相对于拼版尺寸左上角)")
+    @RColumn("locationx")
+    private double locationX;
+
+    @Comment("坐标y(锚点相对于拼版尺寸左上角)")
+    @RColumn("locationy")
+    private double locationY;
+
+    @Comment("元素宽")
+    @RColumn("sizewidth")
+    private double sizeWidth;
+
+    @Comment("元素高")
+    @RColumn("sizeheight")
+    private double sizeHeight;
+
+    @Comment("旋转角度")
+    @RColumn("rotation")
+    private double rotation;
+
+    @Comment("z轴顺序,0最底层")
+    @RColumn("zindex")
+    private int zIndex;
+
+    @Comment("元素属性json,通常是文件链接")
+    @RColumn("jsoncontent")
+    private String jsonContent;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getIdOrder() {
+        return idOrder;
+    }
+
+    public void setIdOrder(long idOrder) {
+        this.idOrder = idOrder;
+    }
+
+    public int getItemType() {
+        return itemType;
+    }
+
+    public void setItemType(int itemType) {
+        this.itemType = itemType;
+    }
+
+    public double getLocationX() {
+        return locationX;
+    }
+
+    public void setLocationX(double locationX) {
+        this.locationX = locationX;
+    }
+
+    public double getLocationY() {
+        return locationY;
+    }
+
+    public void setLocationY(double locationY) {
+        this.locationY = locationY;
+    }
+
+    public double getSizeWidth() {
+        return sizeWidth;
+    }
+
+    public void setSizeWidth(double sizeWidth) {
+        this.sizeWidth = sizeWidth;
+    }
+
+    public double getSizeHeight() {
+        return sizeHeight;
+    }
+
+    public void setSizeHeight(double sizeHeight) {
+        this.sizeHeight = sizeHeight;
+    }
+
+    public double getRotation() {
+        return rotation;
+    }
+
+    public void setRotation(double rotation) {
+        this.rotation = rotation;
+    }
+
+    public int getzIndex() {
+        return zIndex;
+    }
+
+    public void setzIndex(int zIndex) {
+        this.zIndex = zIndex;
+    }
+
+    public String getJsonContent() {
+        return jsonContent;
+    }
+
+    public void setJsonContent(String jsonContent) {
+        this.jsonContent = jsonContent;
+    }
+}

+ 6 - 6
sdCommon/src/main/java/com/sdtool/common/entity/design/DesignTemplate.java

@@ -43,9 +43,9 @@ public class DesignTemplate extends BaseEntity {
     @Comment("拼版尺寸宽")
     private double breedWidth;
 
-    @RColumn("idproduct")
+    @RColumn("productidentity")
     @Comment("产品id,暂时手传")
-    private long idProduct;
+    private String productIdentity;
 
     @Comment("")
     @RColumn("voidflag")
@@ -122,12 +122,12 @@ public class DesignTemplate extends BaseEntity {
         this.breedWidth = breedWidth;
     }
 
-    public long getIdProduct() {
-        return idProduct;
+    public String getProductIdentity() {
+        return productIdentity;
     }
 
-    public void setIdProduct(long idProduct) {
-        this.idProduct = idProduct;
+    public void setProductIdentity(String productIdentity) {
+        this.productIdentity = productIdentity;
     }
 
     public List<DesignTemplateItem> getItemList() {

+ 90 - 0
sdCommon/src/main/java/com/sdtool/common/entity/design/fabric/FabricMain.java

@@ -0,0 +1,90 @@
+package com.sdtool.common.entity.design.fabric;
+
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * fabric导出对象
+ */
+public class FabricMain {
+    private String id;
+
+    private String background;
+
+    private double height;
+
+    private String version;
+
+    private double width;
+
+    private double zoom;
+
+    private WorkSpace workSpace;
+
+    private List<HashMap<String, Object>> objects;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getBackground() {
+        return background;
+    }
+
+    public void setBackground(String background) {
+        this.background = background;
+    }
+
+    public double getHeight() {
+        return height;
+    }
+
+    public void setHeight(double height) {
+        this.height = height;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public double getWidth() {
+        return width;
+    }
+
+    public void setWidth(double width) {
+        this.width = width;
+    }
+
+    public double getZoom() {
+        return zoom;
+    }
+
+    public void setZoom(double zoom) {
+        this.zoom = zoom;
+    }
+
+    public WorkSpace getWorkSpace() {
+        return workSpace;
+    }
+
+    public void setWorkSpace(WorkSpace workSpace) {
+        this.workSpace = workSpace;
+    }
+
+    public List<HashMap<String, Object>> getObjects() {
+        return objects;
+    }
+
+    public void setObjects(List<HashMap<String, Object>> objects) {
+        this.objects = objects;
+    }
+}

+ 97 - 0
sdCommon/src/main/java/com/sdtool/common/entity/design/fabric/WorkSpace.java

@@ -0,0 +1,97 @@
+package com.sdtool.common.entity.design.fabric;
+
+
+/**
+ * fabric导出对象-workSpace
+ */
+public class WorkSpace {
+    private double angle;
+
+    private String backgroundColor;
+
+    private String color;
+
+    private String fill;
+
+    private int fillType;
+
+    private double left;
+
+    private double top;
+
+    private double scaleX;
+
+    private double scaleY;
+
+    public double getAngle() {
+        return angle;
+    }
+
+    public void setAngle(double angle) {
+        this.angle = angle;
+    }
+
+    public String getBackgroundColor() {
+        return backgroundColor;
+    }
+
+    public void setBackgroundColor(String backgroundColor) {
+        this.backgroundColor = backgroundColor;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
+
+    public String getFill() {
+        return fill;
+    }
+
+    public void setFill(String fill) {
+        this.fill = fill;
+    }
+
+    public int getFillType() {
+        return fillType;
+    }
+
+    public void setFillType(int fillType) {
+        this.fillType = fillType;
+    }
+
+    public double getLeft() {
+        return left;
+    }
+
+    public void setLeft(double left) {
+        this.left = left;
+    }
+
+    public double getTop() {
+        return top;
+    }
+
+    public void setTop(double top) {
+        this.top = top;
+    }
+
+    public double getScaleX() {
+        return scaleX;
+    }
+
+    public void setScaleX(double scaleX) {
+        this.scaleX = scaleX;
+    }
+
+    public double getScaleY() {
+        return scaleY;
+    }
+
+    public void setScaleY(double scaleY) {
+        this.scaleY = scaleY;
+    }
+}

+ 8 - 0
sdCommon/src/main/java/com/sdtool/common/tool/ERPUtils.java

@@ -114,6 +114,8 @@ public class ERPUtils {
     public static final RMap<String, Integer> PARAM_VOID_FLAG_1 = new RMap<>(Utility.ofMap("voidFlag", 1));
     public static final RMap<String, Integer> PARAM_VOID_FLAG_ALL = new RMap<>(Utility.ofMap("voidFlag", -1));
 
+    private static final double DEFAULT_RATIO = 25.4;
+
     static {
         try {
             aesTokenEncrypter = new AESEncrypter("dnyERP@Token_LogiN");
@@ -1058,5 +1060,11 @@ public class ERPUtils {
         return qty.multiply(BigDecimal.valueOf(Math.pow(10, precise))).longValue();
     }
 
+    public static double px2mm(double px) {
+        return px / 300 * DEFAULT_RATIO;
+    }
 
+    public static double mm2px(double mm) {
+        return mm * 300 / DEFAULT_RATIO;
+    }
 }

+ 2 - 1
sdWebCore/src/main/java/com/sdtool/webcore/rest/DesignRest.java

@@ -108,12 +108,13 @@ public class DesignRest extends BaseService {
     @WebApiBean(result = true, type = DesignTemplate.class)
     public CompletableFuture<RMap> getDesignTemplateEdit(
             @RestParam(name = "id", comment = "id") long id,
+            @RestParam(name = "params", comment = "可变参数", required = false) RMap params,
             @RestParam(name = "&", comment = "登录用户,无需传入") ERPTokenUser currentUser,
             @RestHeader(name = ERPHeader.HTTPHEADER_DATASOURCE) String dataSourceId,
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-                    RetResult<DesignTemplate> result = designService.getDesignTemplateEdit(id, dataSourceId, Long.parseLong(supplierCode));
+                    RetResult<DesignTemplate> result = designService.getDesignTemplateEdit(id, params, dataSourceId, Long.parseLong(supplierCode));
                     if (result.isSuccess())
                         return RMapUtils.successV2(result.getResult(), null, result.getPageFlipper());
                     else return RMapUtils.error(HttpCode.BAD_REQUEST.value(), result.getRetinfo());