dcs 2 mēneši atpakaļ
vecāks
revīzija
01f5c92738

+ 58 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/controller/ProceController.java

@@ -0,0 +1,58 @@
+package com.bosshand.virgo.api.workark.controller;
+
+import com.bosshand.virgo.api.workark.model.Proce;
+import com.bosshand.virgo.api.workark.service.ProceService;
+import com.bosshand.virgo.core.response.Response;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("workarkProce")
+@Api(tags = {"过程"})
+public class ProceController {
+
+    @Autowired
+    ProceService proceService;
+
+    @ApiOperation(value = "获取", notes = "获取")
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(proceService.get(id));
+    }
+
+    @ApiOperation(value = "获取层级", notes = "获取层级")
+    @RequestMapping(value = "/getParentId/{orderId}/{parentId}", method = RequestMethod.GET)
+    public Response getParentId(@PathVariable long orderId, @PathVariable long parentId) {
+        return Response.ok(proceService.getParentId(orderId, parentId));
+    }
+
+    @ApiOperation(value = "获取列表", notes = "获取列表")
+    @RequestMapping(value = "/list/{orderId}", method = RequestMethod.GET)
+    public Response getList(@PathVariable long orderId) {
+        return Response.ok(proceService.getRoot(orderId));
+    }
+
+    @ApiOperation(value = "新增", notes = "新增")
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public Response save(@RequestBody Proce proce) {
+        proceService.save(proce);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "修改", notes = "修改")
+    @RequestMapping(value = "", method = RequestMethod.PUT)
+    public Response update(@RequestBody Proce proce) {
+        proceService.update(proce);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "删除", notes = "删除")
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public Response delete(@PathVariable long id) {
+        proceService.delete(id);
+        return Response.ok();
+    }
+
+}

+ 5 - 5
virgo.api/src/main/java/com/bosshand/virgo/api/workark/controller/ProceModelController.java

@@ -24,15 +24,15 @@ public class ProceModelController {
     }
 
     @ApiOperation(value = "获取层级", notes = "获取层级")
-    @RequestMapping(value = "/getParentId/{productCouponModelId}/{parentId}", method = RequestMethod.GET)
-    public Response getParentId(@PathVariable long productCouponModelId, @PathVariable long parentId) {
-        return Response.ok(proceModelService.getParentId(productCouponModelId, parentId));
+    @RequestMapping(value = "/getParentId/{productLevelId}/{parentId}", method = RequestMethod.GET)
+    public Response getParentId(@PathVariable long productLevelId, @PathVariable long parentId) {
+        return Response.ok(proceModelService.getParentId(productLevelId, parentId));
     }
 
     @ApiOperation(value = "获取列表", notes = "获取列表")
     @RequestMapping(value = "/list/{productCouponModelId}", method = RequestMethod.GET)
-    public Response getList(@PathVariable long productCouponModelId) {
-        return Response.ok(proceModelService.getRoot(productCouponModelId));
+    public Response getList(@PathVariable long productLevelId) {
+        return Response.ok(proceModelService.getRoot(productLevelId));
     }
 
     @ApiOperation(value = "新增", notes = "新增")

+ 25 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/dao/ProceDao.java

@@ -0,0 +1,25 @@
+package com.bosshand.virgo.api.workark.dao;
+
+import com.bosshand.virgo.api.workark.model.Proce;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface ProceDao {
+
+    public List<Proce> getRoot(long orderId);
+
+    public int save(Proce proce);
+
+    public int update(Proce proce);
+
+    public int delete(long id);
+
+    List<Proce> getList(long orderId);
+
+    List<Proce> getParentId(long parentId);
+
+    Proce get(long id);
+
+}

+ 2 - 2
virgo.api/src/main/java/com/bosshand/virgo/api/workark/dao/ProceModelDao.java

@@ -8,7 +8,7 @@ import java.util.List;
 @Mapper
 public interface ProceModelDao {
 
-    public List<ProceModel> getRoot(long productCouponModelId);
+    public List<ProceModel> getRoot(long productLevelId);
 
     public int save(ProceModel proceModel);
 
@@ -16,7 +16,7 @@ public interface ProceModelDao {
 
     public int delete(long id);
 
-    List<ProceModel> getList(long productCouponModelId);
+    List<ProceModel> getList(long productLevelId);
 
     List<ProceModel> getParentId(long parentId);
 

+ 169 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/Proce.java

@@ -0,0 +1,169 @@
+package com.bosshand.virgo.api.workark.model;
+
+import java.util.List;
+
+/**
+ * 过程
+ */
+public class Proce {
+
+    private long id;
+
+    private long parentId;
+
+    /**
+     * 订单id
+     */
+    private long orderId;
+
+    /**
+     * 商品id
+     */
+    private long productId;
+
+    /**
+     * 商品层级id
+     */
+    private long productLevelId;
+
+    /**
+     * 过程名称
+     */
+    private String name;
+
+    /**
+     * 排序字段
+     */
+    private int sequence;
+
+    /**
+     * 是否附件
+     */
+    private Integer attachment;
+
+    /**
+     * 附件个数
+     */
+    private Integer attachmentNumber;
+
+    /**
+     * 角色id(用户/服务商)
+     */
+    private long roleId;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    private List<Proce> children;
+
+    /**
+     * 附件内容
+     */
+    private String attachmentContent;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(long parentId) {
+        this.parentId = parentId;
+    }
+
+    public long getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(long orderId) {
+        this.orderId = orderId;
+    }
+
+    public long getProductId() {
+        return productId;
+    }
+
+    public void setProductId(long productId) {
+        this.productId = productId;
+    }
+
+    public long getProductLevelId() {
+        return productLevelId;
+    }
+
+    public void setProductLevelId(long productLevelId) {
+        this.productLevelId = productLevelId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getSequence() {
+        return sequence;
+    }
+
+    public void setSequence(int sequence) {
+        this.sequence = sequence;
+    }
+
+    public Integer getAttachment() {
+        return attachment;
+    }
+
+    public void setAttachment(Integer attachment) {
+        this.attachment = attachment;
+    }
+
+    public Integer getAttachmentNumber() {
+        return attachmentNumber;
+    }
+
+    public void setAttachmentNumber(Integer attachmentNumber) {
+        this.attachmentNumber = attachmentNumber;
+    }
+
+    public long getRoleId() {
+        return roleId;
+    }
+
+    public void setRoleId(long roleId) {
+        this.roleId = roleId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public List<Proce> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<Proce> children) {
+        this.children = children;
+    }
+
+    public String getAttachmentContent() {
+        return attachmentContent;
+    }
+
+    public void setAttachmentContent(String attachmentContent) {
+        this.attachmentContent = attachmentContent;
+    }
+}

+ 5 - 5
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/ProceModel.java

@@ -14,7 +14,7 @@ public class ProceModel {
     /**
      * 商品层级id
      */
-    private long productCouponModelId;
+    private long productLevelId;
 
     /**
      * 过程名称
@@ -64,12 +64,12 @@ public class ProceModel {
         this.parentId = parentId;
     }
 
-    public long getProductCouponModelId() {
-        return productCouponModelId;
+    public long getProductLevelId() {
+        return productLevelId;
     }
 
-    public void setProductCouponModelId(long productCouponModelId) {
-        this.productCouponModelId = productCouponModelId;
+    public void setProductLevelId(long productLevelId) {
+        this.productLevelId = productLevelId;
     }
 
     public String getName() {

+ 38 - 3
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/OrderInfoService.java

@@ -3,12 +3,11 @@ package com.bosshand.virgo.api.workark.service;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.bosshand.virgo.api.workark.dao.OrderInfoDao;
+import com.bosshand.virgo.api.workark.dao.ProceDao;
 import com.bosshand.virgo.api.workark.dao.ProductCouponDao;
 import com.bosshand.virgo.api.workark.dao.ProductDao;
 import com.bosshand.virgo.api.workark.enums.OrderStatus;
-import com.bosshand.virgo.api.workark.model.OrderInfo;
-import com.bosshand.virgo.api.workark.model.Product;
-import com.bosshand.virgo.api.workark.model.ProductCoupon;
+import com.bosshand.virgo.api.workark.model.*;
 import com.bosshand.virgo.api.workark.util.OrderNoUtils;
 import com.bosshand.virgo.core.utils.ContextUtils;
 import org.apache.commons.logging.Log;
@@ -40,6 +39,12 @@ public class OrderInfoService {
     @Autowired
     ProductCouponDao productCouponDao;
 
+    @Autowired
+    ProceDao proceDao;
+
+    @Autowired
+    ProceModelService proceModelService;
+
     public void delete(long id) {
         orderInfoDao.delete(id);
     }
@@ -106,9 +111,39 @@ public class OrderInfoService {
         orderInfo.setProductLevelId(product.getProductLevelId());
         orderInfo.setPayOrganizationId(payOrganizationId);
         orderInfoDao.save(orderInfo);
+
+        //生成订单过程
+        List<ProceModel> proceModelList = proceModelService.getRoot(product.getProductLevelId());
+        for(ProceModel proceModel : proceModelList){
+            generateProce(proceModel, product.getProductLevelId(), product.getId(), orderInfo.getId(), 0);
+        }
         return orderInfo;
     }
 
+    public void generateProce(ProceModel proceModel, long productLevelId, long productId, long orderId, long id) {
+        Proce proce = new Proce();
+        proce.setProductLevelId(productLevelId);
+        proce.setProductId(productId);
+        proce.setOrderId(orderId);
+        proce.setName(proceModel.getName());
+        if (proceModel.getParentId() == -1) {
+            proce.setParentId(proceModel.getParentId());
+        } else {
+            proce.setParentId(id);
+        }
+        proce.setSequence(proceModel.getSequence());
+        proce.setAttachment(proceModel.getAttachment());
+        proce.setAttachmentNumber(proceModel.getAttachmentNumber());
+        proce.setRoleId(proceModel.getRoleId());
+        proce.setRemark(proceModel.getRemark());
+        proceDao.save(proce);
+        if (proceModel.getChildren().size() > 0) {
+            for (ProceModel model : proceModel.getChildren()) {
+                generateProce(model, productLevelId, productId, orderId, proce.getId());
+            }
+        }
+    }
+
     public OrderInfo getOrderNo(String orderNo) {
         return orderInfoDao.getOrderNo(orderNo);
     }

+ 6 - 6
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/ProceModelService.java

@@ -16,14 +16,14 @@ public class ProceModelService {
 
     public ProceModel get(long id) {
         ProceModel proceModel = proceModelDao.get(id);
-        List<ProceModel> ls = proceModelDao.getList(proceModel.getProductCouponModelId());
+        List<ProceModel> ls = proceModelDao.getList(proceModel.getProductLevelId());
         return this.getNodeTreeById(id, ls);
     }
 
-    public List<ProceModel> getRoot(long productCouponModelId) {
+    public List<ProceModel> getRoot(long productLevelId) {
         List<ProceModel> list = new ArrayList<>();
-        List<ProceModel> roots = proceModelDao.getRoot(productCouponModelId);
-        List<ProceModel> ls = proceModelDao.getList(productCouponModelId);
+        List<ProceModel> roots = proceModelDao.getRoot(productLevelId);
+        List<ProceModel> ls = proceModelDao.getList(productLevelId);
         for (ProceModel model : roots) {
             list.add(this.getNodeTreeById(model.getId(), ls));
         }
@@ -75,11 +75,11 @@ public class ProceModelService {
     }
 
 
-    public List<ProceModel> getParentId(long productCouponModelId, long parentId) {
+    public List<ProceModel> getParentId(long productLevelId, long parentId) {
         List<ProceModel> list = proceModelDao.getParentId(parentId);
         if (list != null) {
             List<ProceModel> resultList = new ArrayList<>();
-            List<ProceModel> ls = proceModelDao.getList(productCouponModelId);
+            List<ProceModel> ls = proceModelDao.getList(productLevelId);
             for (ProceModel proceModel : list) {
                 resultList.add(getNodeTreeById(proceModel.getId(), ls));
             }

+ 92 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/ProceService.java

@@ -0,0 +1,92 @@
+package com.bosshand.virgo.api.workark.service;
+
+import com.bosshand.virgo.api.workark.dao.ProceDao;
+import com.bosshand.virgo.api.workark.model.Proce;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class ProceService {
+
+    @Autowired
+    ProceDao proceDao;
+
+    public Proce get(long id) {
+        Proce proce = proceDao.get(id);
+        List<Proce> ls = proceDao.getList(proce.getOrderId());
+        return this.getNodeTreeById(id, ls);
+    }
+
+    public List<Proce> getRoot(long orderId) {
+        List<Proce> list = new ArrayList<>();
+        List<Proce> roots = proceDao.getRoot(orderId);
+        List<Proce> ls = proceDao.getList(orderId);
+        for (Proce model : roots) {
+            list.add(this.getNodeTreeById(model.getId(), ls));
+        }
+        return list;
+    }
+
+    public int save(Proce proce) {
+        return proceDao.save(proce);
+    }
+
+    public int update(Proce proce) {
+        return proceDao.update(proce);
+    }
+
+    public int delete(long id) {
+        return proceDao.delete(id);
+    }
+
+    private Proce getNodeTreeById(long id, List<Proce> list) {
+        Proce node = null;
+        List<Proce> proceList = list;
+        for (Proce data : proceList) {
+            if (data.getId() == id) {
+                node = data;
+                break;
+            }
+        }
+        if (node != null) {
+            node.setChildren(getChildNode(node.getId(), proceList));
+        }
+        return node;
+    }
+
+    private List<Proce> getChildNode(long parentId, List<Proce> list) {
+        List<Proce> nodeList = new ArrayList<>();
+        nodeList.clear();
+        for (Proce data : list) {
+            if (data.getParentId() == parentId) {
+                nodeList.add(data);
+            }
+        }
+        if (nodeList.size() > 0) {
+            for (Proce data : nodeList) {
+                List<Proce> childList = getChildNode(data.getId(), list);
+                data.setChildren(childList);
+            }
+        }
+        return nodeList;
+    }
+
+
+    public List<Proce> getParentId(long orderId, long parentId) {
+        List<Proce> list = proceDao.getParentId(parentId);
+        if (list != null) {
+            List<Proce> resultList = new ArrayList<>();
+            List<Proce> ls = proceDao.getList(orderId);
+            for (Proce proce : list) {
+                resultList.add(getNodeTreeById(proce.getId(), ls));
+            }
+            return resultList;
+        }
+        return list;
+    }
+
+
+}

+ 63 - 0
virgo.api/src/main/resources/mapper/ProceMapper.xml

@@ -0,0 +1,63 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.api.workark.dao.ProceDao">
+
+    <resultMap type="com.bosshand.virgo.api.workark.model.Proce" id="result" >
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="parentId" property="parentId"/>
+        <result column="orderId" property="orderId"/>
+        <result column="productId" property="productId"/>
+        <result column="productLevelId" property="productLevelId"/>
+        <result column="sequence" property="sequence"/>
+        <result column="attachment" property="attachment"/>
+        <result column="attachmentNumber" property="attachmentNumber"/>
+        <result column="roleId" property="roleId"/>
+        <result column="remark" property="remark"/>
+    </resultMap>
+
+    <select id="get" resultMap="result">
+        select * from workark_proce where id = #{id}
+    </select>
+
+    <select id="getParentId" resultMap="result">
+        select * from workark_proce where parentId = #{parentId} order by sequence
+    </select>
+
+    <select id="getList" resultMap="result">
+        select * from workark_proce where orderId = #{orderId} order by sequence
+    </select>
+
+    <select id="getRoot" resultMap="result">
+        select * from workark_proce where parentId = -1 and orderId = #{orderId} order by sequence
+    </select>
+
+    <insert id="save" parameterType="com.bosshand.virgo.api.workark.model.ProceModel" useGeneratedKeys="true" keyProperty="id">
+        INSERT into workark_proce(name, parentId, orderId, productId, productLevelId, sequence, attachment, attachmentNumber, roleId, remark)
+        values(#{name}, #{parentId}, #{orderId}, #{productId}, #{productLevelId}, #{sequence}, #{attachment}, #{attachmentNumber}, #{roleId}, #{remark})
+    </insert>
+
+    <update id="update" parameterType="com.bosshand.virgo.api.workark.model.ProceModel">
+        UPDATE workark_proce
+        <trim prefix="set" suffixOverrides=",">
+            <if test="name!=null">name=#{name},</if>
+            <if test="parentId!=0">parentId=#{parentId},</if>
+            <if test="orderId!=0">orderId=#{orderId},</if>
+            <if test="parentId!=0">parentId=#{parentId},</if>
+            <if test="productId!=0">productId=#{productId},</if>
+            <if test="attachment!=null">attachment=#{attachment},</if>
+            <if test="roleId!=0">roleId=#{roleId},</if>
+            <if test="remark!=null">remark=#{remark},</if>
+            attachmentNumber=#{attachmentNumber},
+            sequence=#{sequence},
+        </trim>
+        WHERE id=#{id}
+    </update>
+
+    <delete id="delete">
+        DELETE FROM workark_proce where id = #{id}
+    </delete>
+
+</mapper>

+ 6 - 6
virgo.api/src/main/resources/mapper/ProceModelMapper.xml

@@ -8,7 +8,7 @@
         <id column="id" property="id"/>
         <result column="name" property="name"/>
         <result column="parentId" property="parentId"/>
-        <result column="productCouponModelId" property="productCouponModelId"/>
+        <result column="productLevelId" property="productLevelId"/>
         <result column="sequence" property="sequence"/>
         <result column="attachment" property="attachment"/>
         <result column="attachmentNumber" property="attachmentNumber"/>
@@ -25,16 +25,16 @@
     </select>
 
     <select id="getList" resultMap="result">
-        select * from workark_proce_model where productCouponModelId = #{productCouponModelId} order by sequence
+        select * from workark_proce_model where productLevelId = #{productLevelId} order by sequence
     </select>
 
     <select id="getRoot" resultMap="result">
-        select * from workark_proce_model where parentId = -1 and productCouponModelId = #{productCouponModelId} order by sequence
+        select * from workark_proce_model where parentId = -1 and productLevelId = #{productLevelId} order by sequence
     </select>
 
     <insert id="save" parameterType="com.bosshand.virgo.api.workark.model.ProceModel" useGeneratedKeys="true" keyProperty="id">
-        INSERT into workark_proce_model(name, parentId, productCouponModelId, sequence, attachment, attachmentNumber, roleId, remark)
-        values(#{name}, #{parentId}, #{productCouponModelId}, #{sequence}, #{attachment}, #{attachmentNumber}, #{roleId}, #{remark})
+        INSERT into workark_proce_model(name, parentId, productLevelId, sequence, attachment, attachmentNumber, roleId, remark)
+        values(#{name}, #{parentId}, #{productLevelId}, #{sequence}, #{attachment}, #{attachmentNumber}, #{roleId}, #{remark})
     </insert>
 
     <update id="update" parameterType="com.bosshand.virgo.api.workark.model.ProceModel">
@@ -42,7 +42,7 @@
         <trim prefix="set" suffixOverrides=",">
             <if test="name!=null">name=#{name},</if>
             <if test="parentId!=0">parentId=#{parentId},</if>
-            <if test="productCouponModelId!=0">productCouponModelId=#{productCouponModelId},</if>
+            <if test="productLevelId!=0">productLevelId=#{productLevelId},</if>
             <if test="attachment!=null">attachment=#{attachment},</if>
             <if test="roleId!=0">roleId=#{roleId},</if>
             <if test="remark!=null">remark=#{remark},</if>