Quellcode durchsuchen

流程审批初稿

chenminghua vor 4 Jahren
Ursprung
Commit
6f1552f694
34 geänderte Dateien mit 817 neuen und 76 gelöschten Zeilen
  1. 2 0
      src/main/java/com/gyee/frame/common/conf/MybatisConfig.java
  2. 12 3
      src/main/java/com/gyee/frame/controller/ticket/LaborController.java
  3. 14 5
      src/main/java/com/gyee/frame/controller/ticket/WfactionController.java
  4. 1 1
      src/main/java/com/gyee/frame/controller/ticket/WfinstanceController.java
  5. 38 1
      src/main/java/com/gyee/frame/controller/ticket/WftransController.java
  6. 9 0
      src/main/java/com/gyee/frame/mapper/ticket/LaborMapper.java
  7. 10 0
      src/main/java/com/gyee/frame/mapper/ticket/WfactionMapper.java
  8. 5 0
      src/main/java/com/gyee/frame/mapper/ticket/WfassignmentMapper.java
  9. 1 0
      src/main/java/com/gyee/frame/mapper/ticket/WfinstanceMapper.java
  10. 5 0
      src/main/java/com/gyee/frame/mapper/ticket/WftransMapper.java
  11. 3 1
      src/main/java/com/gyee/frame/model/ticket/FlowAction.java
  12. 14 0
      src/main/java/com/gyee/frame/service/impl/ticket/LaborServiceImpl.java
  13. 86 29
      src/main/java/com/gyee/frame/service/impl/ticket/WfactionServiceImpl.java
  14. 95 0
      src/main/java/com/gyee/frame/service/impl/ticket/WfassignmentServiceImpl.java
  15. 151 21
      src/main/java/com/gyee/frame/service/impl/ticket/WfinstanceServiceImpl.java
  16. 13 1
      src/main/java/com/gyee/frame/service/impl/ticket/WfnodeServiceImpl.java
  17. 2 3
      src/main/java/com/gyee/frame/service/impl/ticket/WfprocessServiceImpl.java
  18. 12 0
      src/main/java/com/gyee/frame/service/impl/ticket/WftaskassignServiceImpl.java
  19. 93 1
      src/main/java/com/gyee/frame/service/impl/ticket/WftransServiceImpl.java
  20. 22 0
      src/main/java/com/gyee/frame/service/impl/ticket/WorkticketServiceImpl.java
  21. 15 0
      src/main/java/com/gyee/frame/service/ticket/LaborService.java
  22. 27 0
      src/main/java/com/gyee/frame/service/ticket/WfactionService.java
  23. 47 2
      src/main/java/com/gyee/frame/service/ticket/WfassignmentService.java
  24. 35 2
      src/main/java/com/gyee/frame/service/ticket/WfinstanceService.java
  25. 11 1
      src/main/java/com/gyee/frame/service/ticket/WfnodeService.java
  26. 2 2
      src/main/java/com/gyee/frame/service/ticket/WfprocessService.java
  27. 10 0
      src/main/java/com/gyee/frame/service/ticket/WftaskassignService.java
  28. 24 1
      src/main/java/com/gyee/frame/service/ticket/WftransService.java
  29. 10 0
      src/main/java/com/gyee/frame/service/ticket/WorkticketService.java
  30. 36 1
      src/main/java/com/gyee/frame/util/ticket/TicketUtil.java
  31. 1 1
      src/main/resources/application-dev.yml
  32. 4 0
      src/main/resources/mybatis/ticket/WfassignmentMapper.xml
  33. 4 0
      src/main/resources/mybatis/ticket/WfinstanceMapper.xml
  34. 3 0
      src/main/resources/mybatis/ticket/WftransMapper.xml

+ 2 - 0
src/main/java/com/gyee/frame/common/conf/MybatisConfig.java

@@ -21,6 +21,7 @@ import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 import javax.sql.DataSource;
 import java.util.HashMap;
@@ -35,6 +36,7 @@ import java.util.Properties;
  * @date 2019-12-06 21:11
  */
 @Configuration
+@EnableTransactionManagement
 @MapperScan(basePackages = "com.gyee.frame.mapper")
 public class MybatisConfig {
 	

+ 12 - 3
src/main/java/com/gyee/frame/controller/ticket/LaborController.java

@@ -11,6 +11,7 @@ import com.gyee.frame.util.ticket.TicketUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -43,11 +44,19 @@ public class LaborController {
     @PostMapping(value = "single")
     public AjaxResult getLaborSingle(@RequestParam("info") String info) {
         JSONObject jsonObject = JSONObject.parseObject(info);
-        List<Labor> role = laborService.getLaborSingle(jsonObject.getDouble("instid"), jsonObject.getString("role"));
-        if (role == null || role.size() == 0)
+        Double instId = jsonObject.getDouble("instid");
+        String role = jsonObject.getString("role");
+
+        List<Labor> labors = null;
+        if (role.contains("流程启动者") || role.contains("流程人员变更"))
+            labors = laborService.getFlowStarter(instId);
+        else
+            labors = laborService.getLaborSingle(jsonObject.getDouble("instid"), jsonObject.getString("role"));
+
+        if (labors == null || labors.size() == 0)
             return AjaxResult.error(4004, "人员获取失败");
 
-        return AjaxResult.successData(role);
+        return AjaxResult.successData(labors);
     }
 }
 

+ 14 - 5
src/main/java/com/gyee/frame/controller/ticket/WfactionController.java

@@ -35,12 +35,21 @@ public class WfactionController {
     @DataSource(value = DataSourceType.TICKET)
     @PostMapping(value = "index")
     public AjaxResult index(@RequestParam("info") String info) {
+        Map<String, Object> actionMap = null;
         JSONObject jsonObject = JSONObject.parseObject(info);
-        Map<String, Object> actionMap = wfactionService.listAction(
-                jsonObject.getInteger("status"),
-                jsonObject.getDouble("nodeid"),
-                jsonObject.getDouble("version"),
-                jsonObject.getString("wfname"));
+        int status = jsonObject.getInteger("status");
+        if (status == 0){
+            actionMap = wfactionService.listAction(
+                    jsonObject.getInteger("status"), -1, -1, jsonObject.getString("wfname"));
+        }
+
+        if (status == 2){
+            actionMap = wfactionService.listAction(
+                    jsonObject.getInteger("status"),
+                    jsonObject.getDouble("nodeid"),
+                    jsonObject.getDouble("version"),
+                    jsonObject.getString("wfname"));
+        }
 
         if(actionMap == null || actionMap.size() == 0)
             return AjaxResult.error(4004, "工作流下一步操作查询失败");

+ 1 - 1
src/main/java/com/gyee/frame/controller/ticket/WfinstanceController.java

@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @since 2020-07-21
  */
 @RestController
-@RequestMapping("//wfinstance")
+@RequestMapping("/wfinstance")
 public class WfinstanceController {
 
 }

+ 38 - 1
src/main/java/com/gyee/frame/controller/ticket/WftransController.java

@@ -1,11 +1,13 @@
 package com.gyee.frame.controller.ticket;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.gyee.frame.common.dataSources.DataSource;
 import com.gyee.frame.common.dataSources.DataSourceType;
 import com.gyee.frame.common.domain.AjaxResult;
-import com.gyee.frame.model.ticket.FlowStep;
+import com.gyee.frame.service.ticket.WfassignmentService;
 import com.gyee.frame.service.ticket.WfinstanceService;
+import com.gyee.frame.service.ticket.WftransService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -26,6 +28,10 @@ public class WftransController {
 
     @Autowired
     WfinstanceService wfinstanceService;
+    @Autowired
+    WfassignmentService wfassignmentService;
+    @Autowired
+    WftransService wftransService;
 
     @DataSource(value = DataSourceType.TICKET)
     @GetMapping(value = "index")
@@ -38,5 +44,36 @@ public class WftransController {
         return AjaxResult.successData(result);
     }
 
+
+    @DataSource(DataSourceType.TICKET)
+    @PostMapping(value = "flow")
+    public AjaxResult postTransFlow(@RequestParam("info") String info){
+        JSONObject jsonObject = JSONObject.parseObject(info);
+        int status = jsonObject.getInteger("status");
+        double actionId = jsonObject.getDouble("actionid");
+        double ownerId = jsonObject.getDouble("ownerid");
+        String wfName = jsonObject.getString("wfname");
+        String role = jsonObject.getString("role");
+        String ticketNum = jsonObject.getString("ticketnum");
+        String principal = jsonObject.getString("principal");
+        List<String> labors = (List<String>) jsonObject.get("labors");
+
+        // 流程正在进行
+        if (status == 2){
+            boolean result = wftransService.insertTrans(jsonObject.getDouble("currnodeid"), jsonObject.getDouble("prenodeid"),
+                    actionId, jsonObject.getDouble("instid"), jsonObject.getDouble("version"), ownerId, wfName, ticketNum, role, labors);
+            if(!result)
+                AjaxResult.error(4004, "流程发送失败");
+        }
+        // 流程初始化
+        if (status == 0){
+            boolean result = wfinstanceService.initInstance(ownerId, wfName, ticketNum, principal, labors.get(0), role);
+            if (!result)
+                return AjaxResult.error(4004, "流程发送失败");
+        }
+
+        return AjaxResult.success("流程发送成功");
+    }
+
 }
 

+ 9 - 0
src/main/java/com/gyee/frame/mapper/ticket/LaborMapper.java

@@ -34,4 +34,13 @@ public interface LaborMapper extends BaseMapper<Labor> {
      */
     @Select("select top 1 t1.* from LABOR t1 LEFT JOIN  WFASSIGNMENT t2 ON t1.LABORNUM=t2.ASSIGNCODE WHERE t2.WFINSTID = #{instId} and t2.WFROLE = #{role}")
     List<Labor> getLaborSingle(double instId, String role);
+
+    /**
+     * 查询流程启动者
+     *
+     * @param instId
+     * @return
+     */
+    @Select("select top 1 t1.* from LABOR t1 LEFT JOIN  WFINSTANCE t2 ON t1.LABORNUM=t2.STARTOR WHERE t2.id = #{instId}")
+    List<Labor> getFlowStarter(double instId);
 }

+ 10 - 0
src/main/java/com/gyee/frame/mapper/ticket/WfactionMapper.java

@@ -2,6 +2,7 @@ package com.gyee.frame.mapper.ticket;
 
 import com.gyee.frame.model.ticket.Wfaction;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * <p>
@@ -13,4 +14,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface WfactionMapper extends BaseMapper<Wfaction> {
 
+
+    /**
+     * 流程初始化查询
+     *
+     * @return
+     */
+    @Select("select a.* from WFPROCESS p left join WFNODE n ON p.wfrevision = n.wfrevision and p.wfname = n.wfname " +
+            "left join WFACTION a ON a.startnodeid = n.id WHERE p.wfname = '风电机组工作票' AND p.active = '是' AND a.actiontype = '空操作' AND n.nodetype='开始'")
+    Wfaction initAction();
 }

+ 5 - 0
src/main/java/com/gyee/frame/mapper/ticket/WfassignmentMapper.java

@@ -13,4 +13,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface WfassignmentMapper extends BaseMapper<Wfassignment> {
 
+    /**
+     *  查询最大id
+     * @return
+     */
+    int selectMaxId();
 }

+ 1 - 0
src/main/java/com/gyee/frame/mapper/ticket/WfinstanceMapper.java

@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface WfinstanceMapper extends BaseMapper<Wfinstance> {
 
+    int selectMaxId();
 }

+ 5 - 0
src/main/java/com/gyee/frame/mapper/ticket/WftransMapper.java

@@ -13,4 +13,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface WftransMapper extends BaseMapper<Wftrans> {
 
+    /**
+     *  查询最大id
+     * @return
+     */
+    int selectMaxId();
 }

+ 3 - 1
src/main/java/com/gyee/frame/model/ticket/FlowAction.java

@@ -5,10 +5,12 @@ import lombok.Data;
 @Data
 public class FlowAction {
 
+    private double actionId;
+
     /**
      * 下个节点
      */
-    private String nodeId;
+    private String nextNodeId;
 
     /**
      * 节点描述

+ 14 - 0
src/main/java/com/gyee/frame/service/impl/ticket/LaborServiceImpl.java

@@ -38,4 +38,18 @@ public class LaborServiceImpl extends ServiceImpl<LaborMapper, Labor> implements
 
         return labor;
     }
+
+    @Override
+    public Labor getItemLabor(String laborNum) {
+        QueryWrapper<Labor> wrapper = new QueryWrapper<>();
+        wrapper.eq("LABORNUM", laborNum);
+        Labor labor = baseMapper.selectOne(wrapper);
+
+        return labor;
+    }
+
+    @Override
+    public List<Labor> getFlowStarter(double instId) {
+        return baseMapper.getFlowStarter(instId);
+    }
 }

+ 86 - 29
src/main/java/com/gyee/frame/service/impl/ticket/WfactionServiceImpl.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.frame.model.ticket.FlowAction;
 import com.gyee.frame.model.ticket.Wfaction;
 import com.gyee.frame.mapper.ticket.WfactionMapper;
+import com.gyee.frame.model.ticket.Wfprocess;
 import com.gyee.frame.model.ticket.Wftaskassign;
 import com.gyee.frame.service.ticket.WfactionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.frame.service.ticket.WfprocessService;
 import com.gyee.frame.service.ticket.WftaskassignService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -33,54 +35,109 @@ public class WfactionServiceImpl extends ServiceImpl<WfactionMapper, Wfaction> i
 
     @Override
     public Map<String, Object> listAction(int status, double startNodeId, double version, String wfName) {
-        QueryWrapper<Wfaction> wrapper = new QueryWrapper<>();
-        wrapper.eq("STARTNODEID", startNodeId);
-        wrapper.eq("WFREVISION", version);
-        wrapper.eq("WFNAME", wfName);
-        wrapper.orderByAsc("ENDNODEID");
-        wrapper.in("ACTIONTYPE", "空操作", "自定义类");
-
-        List<Wfaction> wfactions = baseMapper.selectList(wrapper);
-
-        if (wfactions == null)
-           return null;
-
-        /**
-         * 查询绑定的人员组信息
-         */
-        List<Wftaskassign> wftaskassigns = wftaskassignService.listTaskAssign(version, wfName);
-        Map<Double, String> taskMap = wftaskassigns.stream().collect(Collectors.toMap(Wftaskassign::getNodeid, Wftaskassign::getWfrole));
-
         /**
          * 返回结果 -- map
          */
         Map<String, Object> map = new HashMap<>();
         List<FlowAction> list = new ArrayList<>();
 
-        double temp = 0.0;
-        for (Wfaction wfaction : wfactions){
+        // 流程未启动
+        if (status == 0){
+            Wfaction wfaction = baseMapper.initAction();
+            Wftaskassign wftaskassign = wftaskassignService.taskAssign(wfaction.getEndnodeid(), wfaction.getWfrevision(), wfName);
             FlowAction action = new FlowAction();
             action.setDescription(wfaction.getDescription());
             action.setActionType(wfaction.getActiontype());
-            action.setNodeId(String.valueOf(wfaction.getEndnodeid()));
-            action.setRole(taskMap.get(wfaction.getEndnodeid()));
+            action.setNextNodeId(String.valueOf(wfaction.getEndnodeid()));
+            action.setRole(wftaskassign.getWfrole());
             action.setChecked(false);
+            action.setFilter("Y");
+            list.add(action);
+        }
+
+        // 流程已启动
+        if (status == 2){
+            QueryWrapper<Wfaction> wrapper = new QueryWrapper<>();
+            wrapper.eq("STARTNODEID", startNodeId);
+            wrapper.eq("WFREVISION", version);
+            wrapper.eq("WFNAME", wfName);
+            wrapper.orderByAsc("ENDNODEID");
+            wrapper.in("ACTIONTYPE", "空操作", "自定义类");
+
+            List<Wfaction> wfactions = baseMapper.selectList(wrapper);
+
+            if (wfactions == null)
+                return null;
 
             /**
-             * 过滤重复项  判定是否需要手动选择人员
+             * 查询绑定的人员组信息
              */
-            if (temp != wfaction.getEndnodeid()){
-                action.setFilter("N");
-                list.add(action);
-            }else {
-                action = list.get(list.size() - 1);
+            List<Wftaskassign> wftaskassigns = wftaskassignService.listTaskAssign(version, wfName);
+            Map<Double, String> taskMap = wftaskassigns.stream().collect(Collectors.toMap(Wftaskassign::getNodeid, Wftaskassign::getWfrole));
+
+            double temp = 0.0;
+            for (Wfaction wfaction : wfactions) {
+                FlowAction action = new FlowAction();
+                action.setDescription(wfaction.getDescription());
+                action.setActionType(wfaction.getActiontype());
+                action.setNextNodeId(String.valueOf(wfaction.getEndnodeid()));
+                action.setRole(taskMap.get(wfaction.getEndnodeid()));
+                action.setChecked(false);
                 action.setFilter("Y");
+
+                if (wfaction.getActiontype().equals("空操作")) {
+                    action.setActionId(wfaction.getId());
+                    if (wfaction.getAction().contains("完成") || wfaction.getAction().contains("取消此操作")
+                            || wfaction.getAction().contains("关闭")){
+                        action.setIsEndNode("Y");
+                    }
+                }
+                /**
+                 * 过滤重复项  判定是否需要手动选择人员
+                 */
+                if (temp != wfaction.getEndnodeid()) {
+                    action.setFilter("N");
+                    list.add(action);
+                } else {
+                    action = list.get(list.size() - 1);
+                    action.setFilter("Y");
+                }
+                temp = wfaction.getEndnodeid();
             }
-            temp = wfaction.getEndnodeid();
         }
 
         map.put("action", list);
 
         return map;
     }
+
+    @Override
+    public List<Wfaction> getAction(double nodeId, double version, String wfName) {
+        QueryWrapper<Wfaction> wrapper = new QueryWrapper<>();
+        wrapper.eq("STARTNODEID", nodeId);
+        wrapper.eq("WFREVISION", version);
+        wrapper.eq("WFNAME", wfName);
+        wrapper.eq("ACTIONTYPE", "空操作");
+
+        List<Wfaction> wfactions = baseMapper.selectList(wrapper);
+
+        return wfactions;
+    }
+
+    @Override
+    public Wfaction initAction() {
+        return baseMapper.initAction();
+    }
+
+    @Override
+    public Wfaction getActionStatus(double startNodeId, double endNodeId) {
+        QueryWrapper<Wfaction> wrapper = new QueryWrapper<>();
+        wrapper.eq("STARTNODEID", startNodeId);
+        wrapper.eq("ENDNODEID", endNodeId);
+        wrapper.eq("ACTIONTYPE", "更改状态");
+
+        Wfaction wfaction = baseMapper.selectOne(wrapper);
+
+        return wfaction;
+    }
 }

+ 95 - 0
src/main/java/com/gyee/frame/service/impl/ticket/WfassignmentServiceImpl.java

@@ -1,14 +1,20 @@
 package com.gyee.frame.service.impl.ticket;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.frame.model.ticket.Wfassignment;
 import com.gyee.frame.mapper.ticket.WfassignmentMapper;
+import com.gyee.frame.model.ticket.Wftaskassign;
 import com.gyee.frame.service.ticket.WfassignmentService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.frame.service.ticket.WftaskassignService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -22,6 +28,14 @@ import java.util.List;
 @Service
 public class WfassignmentServiceImpl extends ServiceImpl<WfassignmentMapper, Wfassignment> implements WfassignmentService {
 
+    @Autowired
+    WftaskassignService wftaskassignService;
+
+    @Override
+    public int selectMaxId() {
+        return baseMapper.selectMaxId();
+    }
+
     @Override
     public IPage<Wfassignment> selectPage(long pageNum) {
         QueryWrapper<Wfassignment> wrapper = new QueryWrapper();
@@ -46,4 +60,85 @@ public class WfassignmentServiceImpl extends ServiceImpl<WfassignmentMapper, Wfa
 
         return wfassignments;
     }
+
+    @Override
+    public Wfassignment updateAssignment(double instId, double version, double ownerId, String wfName) {
+        //TODO
+        //根据登录角色删除其它多余项
+        QueryWrapper<Wfassignment> wrapper = new QueryWrapper<>();
+        wrapper.eq("WFREVISION", version);
+        wrapper.eq("WFINSTID", instId);
+        wrapper.eq("WFNAME", wfName);
+        wrapper.eq("OWNERID", ownerId);
+        wrapper.eq("ASSIGNSTATUS", "活动");
+
+        Wfassignment assignment = baseMapper.selectOne(wrapper);
+        assignment.setAssignstatus("完成");
+        assignment.setEnddate(new Date());
+
+        int update = baseMapper.updateById(assignment);
+        if (update == 0)
+            throw new RuntimeException();
+
+        return assignment;
+    }
+
+    @Transactional
+    @Override
+    public boolean insertAssignment(double currNodeId, double instId, double version, double ownerId, String wfName,
+                                         String ticketNum, String starter, String table, String role, List<String> labors) {
+        int maxId = selectMaxId();
+        Wftaskassign task= wftaskassignService.taskAssign(currNodeId, version, wfName);
+
+        for (int i = 0; i < labors.size(); i++){
+            Wfassignment wfassignment = new Wfassignment();
+            double id = (double)maxId + i + 1;
+            wfassignment.setId(id);
+            wfassignment.setDescription(task.getDescription().replace(":{TICKETNUM}", ticketNum));
+            wfassignment.setAssigncode(labors.get(i));
+            wfassignment.setApp(task.getApp());
+            wfassignment.setStartdate(new Date());
+            wfassignment.setEmailnotify("否");
+            wfassignment.setAssignstatus("活动");
+            wfassignment.setWfinstid(instId);
+            wfassignment.setWfname(wfName);
+            wfassignment.setWfrevision(version);
+            wfassignment.setInitperson(starter);
+            wfassignment.setOwnertable(table);
+            wfassignment.setOwnerid(ownerId);
+            wfassignment.setWfrole(role);
+            wfassignment.setDealtimeout(0.0);
+            wfassignment.setDealtype("0");
+            wfassignment.setDealtype("自动发送");
+            wfassignment.setPriority(0.0);
+            wfassignment.setEnddate(null);
+            wfassignment.setNodeid(currNodeId);
+            wfassignment.setTaskid(task.getId());
+            wfassignment.setNeedpass("否");
+
+            // 插入新的待办任务
+            int insert = baseMapper.insert(wfassignment);
+            if (insert == 0)
+                throw new RuntimeException();
+        }
+
+        return true;
+    }
+
+    @Override
+    public Wfassignment getLastItem(double instId, double version, double ownerId, String status) {
+        QueryWrapper<Wfassignment> wrapper = new QueryWrapper<>();
+        if (status != null)
+            wrapper.eq("ASSIGNSTATUS", status);
+        wrapper.eq("WFREVISION", version);
+        wrapper.eq("WFINSTID", instId);
+        wrapper.eq("OWNERID", ownerId);
+        wrapper.orderByAsc("ID");
+
+        List<Wfassignment> wfassignments = baseMapper.selectList(wrapper);
+
+        return wfassignments.get(0);
+    }
+
+
 }

+ 151 - 21
src/main/java/com/gyee/frame/service/impl/ticket/WfinstanceServiceImpl.java

@@ -6,8 +6,10 @@ import com.gyee.frame.mapper.ticket.WfinstanceMapper;
 import com.gyee.frame.service.ticket.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.frame.util.DateUtils;
+import com.gyee.frame.util.ticket.TicketUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -32,6 +34,20 @@ public class WfinstanceServiceImpl extends ServiceImpl<WfinstanceMapper, Wfinsta
     WfassignmentService wfassignmentService;
     @Autowired
     LaborService laborService;
+    @Autowired
+    WfprocessService wfprocessService;
+    @Autowired
+    WfactionService wfactionService;
+    @Autowired
+    WorkticketService workticketService;
+    @Autowired
+    WftaskassignService wftaskassignService;
+
+
+    @Override
+    public int selectMaxId() {
+        return baseMapper.selectMaxId();
+    }
 
     /**
      * map的status属性  0:未开始  1:结束  2:正在进行
@@ -67,35 +83,25 @@ public class WfinstanceServiceImpl extends ServiceImpl<WfinstanceMapper, Wfinsta
          * 查询流程相关历史
          */
         List<Wftrans> wftrans = wftransService.listTrans(wfinstance.getId());
-        List<Wfnode> wfnodes = wfnodeService.getWfNode(wfinstance.getWfname(), wfinstance.getWfrevision());
-        List<Wfassignment> wfassignments = wfassignmentService.listAssignment(wfinstance.getId(), ownerId);
+        List<Wfnode> wfnodes = wfnodeService.getListNodes(wfinstance.getWfname(), wfinstance.getWfrevision());
 
         Map<Double, String> nodeMap = wfnodes.stream().collect(Collectors.toMap(Wfnode::getId, Wfnode::getTitle));
-        Map<Double, Date> assignmentMap = wfassignments.stream()
-                .filter(e -> e.getEnddate() != null)
-                .collect(Collectors.toMap(Wfassignment::getId, Wfassignment::getEnddate));
 
-        List<Double> nodes = new ArrayList<>();
-        List<String> principals = new ArrayList<>();
         for (int i = 0; i < wftrans.size(); i++) {
-            nodes.add(i, wftrans.get(i).getNodeid());
-            principals.add(i, wftrans.get(i).getAssigncode());
-        }
-        for (int i = 0; i < nodes.size(); i++) {
             FlowStep obj = null;
             switch (wftrans.get(i).getNodetype()) {
                 case "开始":
-                    obj = new FlowStep("节点:" + nodeMap.get(nodes.get(i)),
-                            "人员:" + laborMap.get(principals.get(i)),
-                            "日期:" + DateUtils.format(wftrans.get(0).getTransdate().toString(), DateUtils.DATE_TIME_PATTERN));
+                    obj = new FlowStep("节点:" + nodeMap.get(wftrans.get(i).getNodeid()),
+                            "人员:" + laborMap.get(wfinstance.getStartor()),
+                            "日期:" + DateUtils.format(wftrans.get(i).getTransdate().toString(), DateUtils.DATE_TIME_PATTERN));
                     break;
                 case "任务":
-                    obj = new FlowStep("节点:" + nodeMap.get(nodes.get(i)),
-                            "人员:" + laborMap.get(principals.get(i)),
-                            "日期:" + DateUtils.format(assignmentMap.get(wftrans.get(i).getAssignid()).toString(), DateUtils.DATE_TIME_PATTERN));
+                    obj = new FlowStep("节点:" + nodeMap.get(wftrans.get(i).getNodeid()),
+                            "人员:" + laborMap.get(wftrans.get(i).getAssigncode()),
+                            "日期:" + DateUtils.format(wftrans.get(i).getTransdate().toString(), DateUtils.DATE_TIME_PATTERN));
                     break;
                 case "结束":
-                    obj = new FlowStep("节点:" + nodeMap.get(nodes.get(i)));
+                    obj = new FlowStep("节点:" + nodeMap.get(wftrans.get(i).getNodeid()));
                     break;
             }
             list.add(obj);
@@ -114,17 +120,141 @@ public class WfinstanceServiceImpl extends ServiceImpl<WfinstanceMapper, Wfinsta
          * 如果active值为‘是’,表示流程正在进行
          */
         if (wfinstance.getActive().equals("是")) {
-            FlowStep obj = new FlowStep("节点:" + nodeMap.get(wfassignments.get(wfassignments.size() - 1).getNodeid()),
-                    "人员:" + laborMap.get(wfassignments.get(wfassignments.size() - 1).getAssigncode()),
+            // 添加最后一条待办信息
+            Wfassignment lastItem = wfassignmentService.getLastItem(wfinstance.getId(), wfinstance.getWfrevision(), wfinstance.getOwnerid(), "活动");
+            FlowStep obj = new FlowStep("节点:" + nodeMap.get(lastItem.getNodeid()),
+                    "人员:" + laborMap.get(lastItem.getAssigncode()),
                     "日期:");
             list.add(obj);
             map.put("flow", list);
             map.put("status", 2);
-            map.put("nodeid", wfassignments.get(wfassignments.size() - 1).getNodeid());
+            map.put("nodeid", lastItem.getNodeid());
             map.put("version", wfinstance.getWfrevision());
             map.put("instid", wfinstance.getId());
         }
 
         return map;
     }
+
+    @Override
+    public Wfinstance instance(double ownerId) {
+        QueryWrapper<Wfinstance> wrapper = new QueryWrapper<>();
+        wrapper.eq("OWNERID", ownerId);
+        Wfinstance wfinstance = baseMapper.selectOne(wrapper);
+
+        return wfinstance;
+    }
+
+    @Transactional
+    @Override
+    public boolean initInstance(double ownerId, String wfName, String ticketNum, String principal, String laborNum, String role) {
+        QueryWrapper<Wfinstance> wrapper = new QueryWrapper<>();
+        wrapper.eq("OWNERID", ownerId);
+        List<Wfinstance> wfinstances = baseMapper.selectList(wrapper);
+        // 判断流程是否已经开始
+        if (wfinstances != null && wfinstances.size() > 0)
+            return false;
+
+        Wfprocess process = wfprocessService.activeVersion(wfName);
+        Wfaction action = wfactionService.initAction();
+        if (process == null || action == null)
+            throw new RuntimeException();
+
+        // 生成描述
+        String description = process.getWfinstdesc();
+        description = description.replace(":{ticketnum}", ticketNum);
+        description = description.replace(":{principal}", principal);
+
+        int id = selectMaxId();
+        Wfinstance instance = new Wfinstance();
+        instance.setId((double)id + 1);
+        instance.setWfname(wfName);
+        instance.setWfrevision(process.getWfrevision());
+        instance.setOwnertable(process.getTablename());
+        instance.setOwnerid(ownerId);
+        instance.setActive("是");
+        instance.setStartor(principal);
+        instance.setStarttime(new Date());
+        instance.setCurnodeid(action.getEndnodeid());
+        instance.setDescription(description);
+
+        int insert = baseMapper.insert(instance);
+        if (insert <= 0)
+            throw new RuntimeException();
+
+        Wftaskassign task= wftaskassignService.taskAssign(action.getEndnodeid(), process.getWfrevision(), wfName);
+        Wfassignment assignment = new Wfassignment();
+        assignment.setDescription(task.getDescription().replace(":{TICKETNUM}", ticketNum));
+        assignment.setId((double)wfassignmentService.selectMaxId() + 1);
+        assignment.setAssigncode(laborNum);
+        assignment.setApp(TicketUtil.wfNameFormat(wfName));
+        assignment.setStartdate(new Date());
+        assignment.setEmailnotify("否");
+        assignment.setAssignstatus("活动");
+        assignment.setWfinstid((double)id + 1);
+        assignment.setWfname(wfName);
+        assignment.setWfrevision(process.getWfrevision());
+        assignment.setInitperson("");
+        assignment.setOwnertable(process.getTablename());
+        assignment.setOwnerid(ownerId);
+        assignment.setWfrole(role);
+        assignment.setDealtimeout(0.0);
+        assignment.setDealtype("0");
+        assignment.setDealtype("自动发送");
+        assignment.setPriority(0.0);
+        assignment.setEnddate(null);
+        assignment.setNodeid(action.getEndnodeid());
+        assignment.setTaskid(task.getId());
+        assignment.setNeedpass("否");
+
+        boolean save = wfassignmentService.save(assignment);
+        if(!save)
+            throw new RuntimeException();
+
+        Wftrans trans = new Wftrans();
+        trans.setId((double)wftransService.selectMaxId() + 1);
+        trans.setNodeid(action.getStartnodeid());
+        trans.setWfinstid((double)id + 1);
+        trans.setAssignid(null);
+        trans.setActionid(action.getId());
+        trans.setTranstype("开始");
+        trans.setTransdate(new Date());
+        trans.setMemo(null);
+        trans.setNodetype("开始");
+        trans.setWfname(wfName);
+        trans.setWfrevision(process.getWfrevision());
+        trans.setOwnertable(process.getTablename());
+        trans.setOwnerid(ownerId);
+        // TODO
+        // 根据当前登录角色添加
+        trans.setAssigncode(laborNum);
+        trans.setPriority(Double.valueOf(0));
+
+        boolean result = wftransService.save(trans);
+        if(!result)
+            throw new RuntimeException();
+
+        // 更新票据状态
+        boolean update = workticketService.updateTicket(ownerId, action.getStartnodeid(), action.getEndnodeid());
+        if (!update)
+            return false;
+
+        return true;
+    }
+
+    @Transactional
+    @Override
+    public boolean updateInstance(double id, double nodeId, String active) {
+        Wfinstance instance = new Wfinstance();
+        instance.setId(id);
+        instance.setCurnodeid(nodeId);
+        if (active != null)
+            instance.setActive(active);
+
+        int i = baseMapper.updateById(instance);
+        if (i <= 0)
+            throw new RuntimeException();
+
+        return true;
+    }
 }

+ 13 - 1
src/main/java/com/gyee/frame/service/impl/ticket/WfnodeServiceImpl.java

@@ -25,7 +25,7 @@ import java.util.List;
 public class WfnodeServiceImpl extends ServiceImpl<WfnodeMapper, Wfnode> implements WfnodeService {
 
     @Override
-    public List<Wfnode> getWfNode(String wfName, double version) {
+    public List<Wfnode> getListNodes(String wfName, double version) {
         QueryWrapper<Wfnode> wrapper = new QueryWrapper<>();
         wrapper.eq("WFNAME", wfName);
         wrapper.eq("WFREVISION", version);
@@ -34,4 +34,16 @@ public class WfnodeServiceImpl extends ServiceImpl<WfnodeMapper, Wfnode> impleme
 
         return wfnodes;
     }
+
+    @Override
+    public Wfnode getNode(double id, double version, String wfName) {
+        QueryWrapper<Wfnode> wrapper = new QueryWrapper<>();
+        wrapper.eq("ID", id);
+        wrapper.eq("WFNAME", wfName);
+        wrapper.eq("WFREVISION", version);
+
+        Wfnode wfnode = baseMapper.selectOne(wrapper);
+
+        return wfnode;
+    }
 }

+ 2 - 3
src/main/java/com/gyee/frame/service/impl/ticket/WfprocessServiceImpl.java

@@ -19,11 +19,10 @@ import org.springframework.stereotype.Service;
 public class WfprocessServiceImpl extends ServiceImpl<WfprocessMapper, Wfprocess> implements WfprocessService {
 
     @Override
-    public Wfprocess activeVersion(String app) {
+    public Wfprocess activeVersion(String wfName) {
         QueryWrapper<Wfprocess> wrapper = new QueryWrapper<>();
-        wrapper.eq("APP", app);
+        wrapper.eq("WFNAME", wfName);
         wrapper.eq("ACTIVE", "是");
-        wrapper.eq("TABLENAME", "WORKTICKET");
 
         Wfprocess wfprocess = baseMapper.selectOne(wrapper);
 

+ 12 - 0
src/main/java/com/gyee/frame/service/impl/ticket/WftaskassignServiceImpl.java

@@ -30,4 +30,16 @@ public class WftaskassignServiceImpl extends ServiceImpl<WftaskassignMapper, Wft
 
         return wftaskassigns;
     }
+
+    @Override
+    public Wftaskassign taskAssign(double nodeId, double version, String wfName) {
+        QueryWrapper<Wftaskassign> wrapper = new QueryWrapper<>();
+        wrapper.eq("WFREVISION", version);
+        wrapper.eq("WFNAME", wfName);
+        wrapper.eq("NODEID", nodeId);
+
+        Wftaskassign wftaskassign = baseMapper.selectOne(wrapper);
+
+        return wftaskassign;
+    }
 }

+ 93 - 1
src/main/java/com/gyee/frame/service/impl/ticket/WftransServiceImpl.java

@@ -2,12 +2,17 @@ package com.gyee.frame.service.impl.ticket;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.frame.model.ticket.Wfassignment;
+import com.gyee.frame.model.ticket.Wfinstance;
+import com.gyee.frame.model.ticket.Wfnode;
 import com.gyee.frame.model.ticket.Wftrans;
 import com.gyee.frame.mapper.ticket.WftransMapper;
-import com.gyee.frame.service.ticket.WftransService;
+import com.gyee.frame.service.ticket.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -21,6 +26,22 @@ import java.util.List;
 @Service
 public class WftransServiceImpl extends ServiceImpl<WftransMapper, Wftrans> implements WftransService {
 
+    @Autowired
+    WfactionService wfactionService;
+    @Autowired
+    WfinstanceService wfinstanceService;
+    @Autowired
+    WfassignmentService wfassignmentService;
+    @Autowired
+    WorkticketService workticketService;
+    @Autowired
+    WfnodeService wfnodeService;
+
+    @Override
+    public int selectMaxId() {
+        return baseMapper.selectMaxId();
+    }
+
     @Override
     public List<Wftrans> listTrans(double instanceId) {
         QueryWrapper<Wftrans> wrapper = new QueryWrapper<>();
@@ -31,4 +52,75 @@ public class WftransServiceImpl extends ServiceImpl<WftransMapper, Wftrans> impl
 
         return trans;
     }
+
+    @Transactional
+    @Override
+    public boolean insertTrans(double currNodeId, double preNodeId, double actionId, double instId,
+                               double version, double ownerId, String wfName, String ticketNum, String role, List<String> labors) {
+        Wfinstance instance = wfinstanceService.instance(ownerId);
+        if (instance == null || instance.getActive().equals("否"))
+            return false;
+
+        Wfnode node = wfnodeService.getNode(currNodeId, version, wfName);
+        if (node == null)
+            return false;
+
+        int maxId = selectMaxId();
+        // 流程结束
+        if (node.getNodetype().equals("结束")){
+            wfinstanceService.updateInstance(instId, currNodeId, "否");
+            // 更新之前的待办任务
+            Wfassignment assignment = wfassignmentService.updateAssignment(instId, version, ownerId, wfName);
+            // 插入事务
+            saveTrans((double)maxId + 1, preNodeId, instId, assignment.getId(), actionId, "任务", "任务",
+                    wfName, version, instance.getOwnertable(), ownerId, assignment.getAssigncode());
+            // 插入结束事务
+            saveTrans((double)maxId + 2, preNodeId, instId, 0, actionId, "结束", "结束",
+                    wfName, version, instance.getOwnertable(), ownerId, assignment.getAssigncode());
+            // 更新票据状态
+            workticketService.updateTicket(ownerId, preNodeId, currNodeId);
+        }else {
+            wfinstanceService.updateInstance(instId, currNodeId, null);
+            // 更新之前的待办任务
+            Wfassignment assignment = wfassignmentService.updateAssignment(instId, version, ownerId, wfName);
+            // 插入新的待办任务
+            wfassignmentService.insertAssignment(currNodeId, instId, version, ownerId, wfName, ticketNum,
+                    instance.getStartor(), instance.getOwnertable(), role, labors);
+
+            // 插入事务
+            saveTrans((double)maxId + 1, preNodeId, instId, assignment.getId(), actionId, "任务", "任务",
+                    wfName, version, instance.getOwnertable(), ownerId, assignment.getAssigncode());
+
+            // 更新票据状态
+            workticketService.updateTicket(ownerId, preNodeId, currNodeId);
+        }
+
+        return true;
+    }
+
+    private void saveTrans(double id, double nodeId, double instId, double assignId, double actionId, String transType,
+                           String nodeType, String wfName, double version, String table, double ownerId, String assignCode){
+        Wftrans trans = new Wftrans();
+        trans.setId(id);
+        trans.setNodeid(nodeId);
+        trans.setWfinstid(instId);
+        if (assignId > 0)
+            trans.setAssignid(assignId);
+        trans.setActionid(actionId);
+        trans.setTranstype(transType);
+        trans.setTransdate(new Date());
+        trans.setMemo(null);
+        trans.setNodetype(nodeType);
+        trans.setWfname(wfName);
+        trans.setWfrevision(version);
+        trans.setOwnertable(table);
+        trans.setOwnerid(ownerId);
+        trans.setAssigncode(assignCode);
+        trans.setPriority(Double.valueOf(0));
+
+        // 事务里边插入之前的待办任务
+        int insert = baseMapper.insert(trans);
+        if (insert == 0)
+            throw new RuntimeException();
+    }
 }

+ 22 - 0
src/main/java/com/gyee/frame/service/impl/ticket/WorkticketServiceImpl.java

@@ -3,13 +3,18 @@ package com.gyee.frame.service.impl.ticket;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.frame.model.ticket.Wfaction;
+import com.gyee.frame.service.ticket.WfactionService;
 import com.gyee.frame.util.ticket.TicketUtil;
 import com.gyee.frame.model.ticket.Workticket;
 import com.gyee.frame.mapper.ticket.WorkticketMapper;
 import com.gyee.frame.service.ticket.WorkticketService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+
 /**
  * <p>
  *  服务实现类
@@ -21,6 +26,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class WorkticketServiceImpl extends ServiceImpl<WorkticketMapper, Workticket> implements WorkticketService {
 
+    @Autowired
+    WfactionService wfactionService;
 
     @Override
     public IPage<Workticket> selectPage(long pageNum, String type) {
@@ -35,4 +42,19 @@ public class WorkticketServiceImpl extends ServiceImpl<WorkticketMapper, Worktic
 
         return iPage;
     }
+
+    @Override
+    public boolean updateTicket(double id, double startNodeId, double endNodeId) {
+        Wfaction action = wfactionService.getActionStatus(startNodeId, endNodeId);
+
+        Workticket ticket = new Workticket();
+        ticket.setId(id);
+        ticket.setStatus(action.getAction());
+        ticket.setStatusdate(new Date());
+        int i = baseMapper.updateById(ticket);
+        if (i <= 0)
+            throw new RuntimeException();
+
+        return true;
+    }
 }

+ 15 - 0
src/main/java/com/gyee/frame/service/ticket/LaborService.java

@@ -37,4 +37,19 @@ public interface LaborService extends IService<Labor> {
      * @return
      */
     List<Labor> getLaborSingle(double instId, String role);
+
+    /**
+     * 根据人员登录名查询一条
+     *
+     * @param laborNum
+     * @return
+     */
+    Labor getItemLabor(String laborNum);
+
+    /**
+     * 查询流程启动者
+     *
+     * @param instId
+     */
+    List<Labor> getFlowStarter(double instId);
 }

+ 27 - 0
src/main/java/com/gyee/frame/service/ticket/WfactionService.java

@@ -26,4 +26,31 @@ public interface WfactionService extends IService<Wfaction> {
      * @return
      */
     Map<String, Object> listAction(int status, double startNodeId, double version, String wfName);
+
+    /**
+     * 根据待办任务的id查询
+     *
+     * @param nodeId
+     * @param version
+     * @param wfName
+     * @return
+     */
+    List<Wfaction> getAction(double nodeId, double version, String wfName);
+
+    /**
+     * 流程启动需要的开始id
+     * @return
+     */
+    Wfaction initAction();
+
+    /**
+     * 查询工作票更新需要的状态
+     *
+     * ACTIONTYPE -- 更改状态
+     *
+     * @param  startNodeId
+     * @param endNodeId
+     * @return
+     */
+    Wfaction getActionStatus(double startNodeId, double endNodeId);
 }

+ 47 - 2
src/main/java/com/gyee/frame/service/ticket/WfassignmentService.java

@@ -8,7 +8,7 @@ import java.util.List;
 
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author chenmh
@@ -17,7 +17,15 @@ import java.util.List;
 public interface WfassignmentService extends IService<Wfassignment> {
 
     /**
+     * 查询最大ID
+     *
+     * @return
+     */
+    int selectMaxId();
+
+    /**
      * 分页
+     *
      * @param pageNum
      * @return
      */
@@ -26,7 +34,7 @@ public interface WfassignmentService extends IService<Wfassignment> {
 
     /**
      * 根据WFINSTID获取所有流程历史
-     *
+     * <p>
      * WFINSTID 对应 WFINSTANCE表的id
      *
      * @param instanceId
@@ -34,4 +42,41 @@ public interface WfassignmentService extends IService<Wfassignment> {
      * @return
      */
     List<Wfassignment> listAssignment(double instanceId, double ownerId);
+
+
+    /**
+     * 更新待办任务
+     *
+     * @param instId
+     * @param version
+     * @param ownerId
+     * @param wfName
+     * @return
+     */
+    Wfassignment updateAssignment(double instId, double version, double ownerId, String wfName);
+
+    /**
+     * 写入待办 返回 ID
+     *
+     * @param currNodeId
+     * @param instId
+     * @param version
+     * @param ownerId
+     * @param wfName
+     * @param labors
+     * @param role
+     * @return
+     */
+    boolean insertAssignment(double currNodeId, double instId, double version, double ownerId, String wfName,
+                                  String ticketNum, String starter, String tableName, String role, List<String> labors);
+
+    /**
+     * 查询最后一条活动记录
+     *
+     * @param instId
+     * @param version
+     * @param ownerId
+     * @return
+     */
+    Wfassignment getLastItem(double instId, double version, double ownerId, String status);
 }

+ 35 - 2
src/main/java/com/gyee/frame/service/ticket/WfinstanceService.java

@@ -17,12 +17,45 @@ import java.util.Map;
  */
 public interface WfinstanceService extends IService<Wfinstance> {
 
+    int selectMaxId();
+
     /**
-     * 根据 ticketid 获取是流程状态 ---- 启用 or 结束
-     * workticket 表的id = wfinstance 表的 id
+     * 根据 ticketid 获取流程状态 ---- 启用 or 结束
+     * workticket 表的id = wfinstance 表的 ownerid
      *
      * @param ownerId
      * @return
      */
     Map<String, Object> flowInstance(double ownerId);
+
+    /**
+     * 查询工作票对应的状态
+     *
+     * @param ownerId
+     * @return
+     */
+    Wfinstance instance(double ownerId);
+
+    /**
+     * 流程启动时插入一条信息
+     *
+     * @param ownerId
+     * @param wfName
+     * @param ticketNum
+     * @param principal
+     * @param laborNum
+     * @param role
+     * @return
+     */
+    boolean initInstance(double ownerId, String wfName, String ticketNum, String principal, String laborNum, String role);
+
+    /**
+     * 更新 cuenodeid 字段及状态
+     *
+     * @param id
+     * @param nodeId
+     * @param active
+     * @return
+     */
+    boolean updateInstance(double id, double nodeId, String active);
 }

+ 11 - 1
src/main/java/com/gyee/frame/service/ticket/WfnodeService.java

@@ -22,5 +22,15 @@ public interface WfnodeService extends IService<Wfnode> {
      * @param version
      * @return
      */
-    List<Wfnode> getWfNode(String wfName, double version);
+    List<Wfnode> getListNodes(String wfName, double version);
+
+    /**
+     * 根据id查询一个节点
+     *
+     * @param id
+     * @param version
+     * @param wfName
+     * @return
+     */
+    Wfnode getNode(double id, double version, String wfName);
 }

+ 2 - 2
src/main/java/com/gyee/frame/service/ticket/WfprocessService.java

@@ -16,8 +16,8 @@ public interface WfprocessService extends IService<Wfprocess> {
     /**
      * 获取当前激活的流程
      *
-     * @param app
+     * @param wfName
      * @return
      */
-    Wfprocess activeVersion(String app);
+    Wfprocess activeVersion(String wfName);
 }

+ 10 - 0
src/main/java/com/gyee/frame/service/ticket/WftaskassignService.java

@@ -23,4 +23,14 @@ public interface WftaskassignService extends IService<Wftaskassign> {
      * @return
      */
     List<Wftaskassign> listTaskAssign(double version, String wfName);
+
+    /**
+     * 查询节点的任务描述信息
+     *
+     * @param nodeId
+     * @param version
+     * @param wfName
+     * @return
+     */
+    Wftaskassign taskAssign(double nodeId, double version, String wfName);
 }

+ 24 - 1
src/main/java/com/gyee/frame/service/ticket/WftransService.java

@@ -16,10 +16,33 @@ import java.util.List;
 public interface WftransService extends IService<Wftrans> {
 
     /**
-     * 根据流程实例表WFINSTANCE的 id 获取所有流程历史
+     * 查询最大ID
+     * @return
+     */
+    int selectMaxId();
+
+    /**
+     * 获取流程实例表 WFINSTANCE 所有流程历史
      *
      * @param instanceId
      * @return
      */
     List<Wftrans> listTrans(double instanceId);
+
+    /**
+     * 写入流程事务
+     *
+     * @param currNodeId
+     * @param preNodeId
+     * @param actionId
+     * @param instId
+     * @param version
+     * @param ownerId
+     * @param wfName
+     * @param role
+     * @param labors
+     * @return
+     */
+    boolean insertTrans(double currNodeId, double preNodeId, double actionId, double instId,
+                        double version, double ownerId, String wfName, String ticketNum, String role, List<String> labors);
 }

+ 10 - 0
src/main/java/com/gyee/frame/service/ticket/WorkticketService.java

@@ -23,4 +23,14 @@ public interface WorkticketService extends IService<Workticket> {
      */
     IPage<Workticket> selectPage(long pageNum, String type);
 
+
+    /**
+     * 更新workticket主表状态
+     *
+     * @param id
+     * @param startNodeId
+     * @param endNodeId
+     * @return
+     */
+    boolean updateTicket(double id, double startNodeId, double endNodeId);
 }

+ 36 - 1
src/main/java/com/gyee/frame/util/ticket/TicketUtil.java

@@ -84,7 +84,7 @@ public class TicketUtil {
      * @param role
      * @return
      */
-    public static String roleFormat(String role){
+    public static String roleFormat(String role) {
         String groupName = null;
         switch (role) {
             case "工作票签发人":
@@ -112,4 +112,39 @@ public class TicketUtil {
 
         return groupName;
     }
+
+    /**
+     * 各种票据的 name 映射
+     *
+     * @param wfName
+     * @return
+     */
+    public static String wfNameFormat(String wfName) {
+        String app = null;
+        switch (wfName) {
+            case "风电机组工作票":
+                app = "WINDELEC";
+                break;
+            case "电气一种工作票":
+                app = "ELEC1";
+                break;
+            case "电气二种工作票":
+                app = "ELEC2";
+                break;
+            case "风场动火工作票":
+                app = "WOMOVEFIRE";
+                break;
+            case "二级动火工作票":
+                app = "WOMOVEFIRE2";
+                break;
+            case "线路一种工作票":
+                app = "ELECFIRST";
+                break;
+            case "线路二种工作票":
+                app = "ELECFIRST2";
+                break;
+        }
+
+        return app;
+    }
 }

+ 1 - 1
src/main/resources/application-dev.yml

@@ -22,7 +22,7 @@ spring:
      ticket:
         url: jdbc:sqlserver://10.155.32.2:1433;DatabaseName=test
         username: sa
-        password: gyee54321
+        password: Gyee@321#!
         driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
      #配置初始化连接数大小
      initial-size: 10

+ 4 - 0
src/main/resources/mybatis/ticket/WfassignmentMapper.xml

@@ -34,4 +34,8 @@
         ID, DESCRIPTION, ASSIGNCODE, APP, STARTDATE, EMAILNOTIFY, ASSIGNSTATUS, WFINSTID, WFNAME, WFREVISION, INITPERSON, OWNERTABLE, OWNERID, WFROLE, DEALTIMEOUT, UPWFROLE, LASTMEMO, DEALTYPE, PRIORITY, ENDDATE, NODEID, TASKID, NEEDPASS
     </sql>
 
+    <select id="selectMaxId" resultType="Integer">
+        select max(id) from WFASSIGNMENT
+    </select>
+
 </mapper>

+ 4 - 0
src/main/resources/mybatis/ticket/WfinstanceMapper.xml

@@ -21,4 +21,8 @@
         ID, WFNAME, WFREVISION, OWNERTABLE, OWNERID, ACTIVE, STARTOR, STARTTIME, CURNODEID, DESCRIPTION
     </sql>
 
+    <select id="selectMaxId" resultType="Integer">
+        select max(id) from WFINSTANCE
+    </select>
+
 </mapper>

+ 3 - 0
src/main/resources/mybatis/ticket/WftransMapper.xml

@@ -26,4 +26,7 @@
         ID, NODEID, WFINSTID, ASSIGNID, ACTIONID, TRANSTYPE, TRANSDATE, MEMO, NODETYPE, WFNAME, WFREVISION, OWNERTABLE, OWNERID, ASSIGNCODE, PRIORITY
     </sql>
 
+    <select id="selectMaxId" resultType="Integer">
+        select max(id) from WFTRANS
+    </select>
 </mapper>