From 64f046ed41c2ae607dc065c82b6d454f64e90584 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期四, 19 六月 2025 21:52:33 +0800
Subject: [PATCH] 预警分析管理-电源告警

---
 src/main/java/com/whyc/service/WorkflowMainService.java |  511 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 511 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/whyc/service/WorkflowMainService.java b/src/main/java/com/whyc/service/WorkflowMainService.java
new file mode 100644
index 0000000..8bce361
--- /dev/null
+++ b/src/main/java/com/whyc/service/WorkflowMainService.java
@@ -0,0 +1,511 @@
+package com.whyc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.whyc.constant.WorkflowEnum;
+import com.whyc.constant.WorkflowProcessEnum;
+import com.whyc.constant.WorkflowTypeEnum;
+import com.whyc.dto.Response;
+import com.whyc.mapper.WorkflowMainMapper;
+import com.whyc.pojo.db_user.User;
+import com.whyc.pojo.web_site.WorkflowDevice;
+import com.whyc.pojo.web_site.WorkflowLink;
+import com.whyc.pojo.web_site.WorkflowMain;
+import com.whyc.util.ActionUtil;
+import com.whyc.util.CommonUtil;
+import com.whyc.util.ThreadLocalUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import javax.servlet.ServletContext;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class WorkflowMainService {
+
+    @Resource
+    private WorkflowMainMapper mapper;
+
+    @Autowired(required = false)
+    private WorkflowLinkService linkService;
+
+    @Autowired
+    private WorkflowDeviceService deviceService;
+
+
+    /**
+     * 鍒嗘淳鍗曞彿:
+     * */
+    public String getNextOrderId(String typeName) {
+        ServletContext application = ActionUtil.getApplication();
+        List<String> orderIdList = (List) application.getAttribute("orderIdList");
+        if(orderIdList == null){
+            orderIdList = new LinkedList<>();
+        }
+        String nextSequence = "";
+        QueryWrapper<WorkflowMain> wrapper = Wrappers.query();
+
+        String orderId = typeName+"-";
+        String ymd = new SimpleDateFormat("yyyyMMdd").format(new Date());
+        orderId = orderId+ymd+"-";
+        //鍏堟煡璇㈡槸鍚︾紦瀛樹腑鏄惁瀛樺湪鍓嶇紑鐩稿悓鐨勫崟鍙�,鏈夌殑璇濆瓨璧锋潵
+        List<Integer> sequenceList = new LinkedList<>();
+        sequenceList.add(0);
+        for (String item : orderIdList) {
+            if(item.startsWith(orderId)){
+                String sequence = item.split("-")[3];
+                sequenceList.add(Integer.parseInt(sequence));
+            }
+        }
+        wrapper.likeRight("order_id",orderId).orderByDesc("order_id").last(" limit 1");
+        WorkflowMain workflowMain = mapper.selectOne(wrapper);
+        if(workflowMain != null){
+            String sequence = workflowMain.getOrderId().split("-")[3];
+            sequenceList.add(Integer.parseInt(sequence));
+        }
+        Integer maxSequence = sequenceList.stream().max(Comparator.comparing(Integer::intValue)).get();
+        nextSequence = String.format("%05d", maxSequence+1);
+        String nextOrderId = orderId + nextSequence;
+        //鍔犲叆缂撳瓨涓�
+        orderIdList.add(nextOrderId);
+        application.setAttribute("orderIdList",orderIdList);
+        return nextOrderId;
+    }
+
+    public void add(WorkflowMain main) {
+        mapper.insert(main);
+    }
+
+    public void addBatch(List<WorkflowMain> workflowMainList) {
+        mapper.insertBatchSomeColumn(workflowMainList);
+    }
+
+
+    public WorkflowMain getBaseInfo(Integer mainId) {
+        //鏍规嵁mainId鏌ヨ鏄摢绉嶇被鍨�
+        QueryWrapper<WorkflowMain> query = Wrappers.query();
+        query.eq("id",mainId).last(" limit 1");
+        WorkflowMain workflowMain = mapper.selectOne(query);
+        Integer type = workflowMain.getType();
+        if(type ==1){
+            //List<BattDischargePlanTemp> tempList = tempService.getListByMainId(mainId);
+            //workflowMain.setTempList(tempList);
+        }
+        List<WorkflowLink> linkList = linkService.getWorkflowInfo(mainId);
+        workflowMain.setLinkList(linkList);
+
+        return workflowMain;
+    }
+
+    public List<WorkflowLink> getAssignReply(Integer mainId) {
+        QueryWrapper<WorkflowLink> wrapper = Wrappers.query();
+        //wrapper.eq("main_id",mainId)
+        //return linkMapper.
+        return null;
+    }
+
+    public void updateById(WorkflowMain main) {
+        mapper.updateById(main);
+    }
+
+    /**
+     *
+     * @param userId
+     * @param type
+     * @see WorkflowEnum
+     *
+     * @return
+     */
+    public Response<Map<Integer,Integer>> getOwnStatistics(int userId, int type) {
+        Map<Integer,Integer> statistics = new HashMap<>();
+        statistics.put(1,0);
+        statistics.put(2,0);
+        statistics.put(3,0);
+        QueryWrapper<WorkflowMain> query = Wrappers.query();
+        query.eq("create_user_id",userId).eq("type",type);
+        List<WorkflowMain> mains = mapper.selectList(query);
+        Map<Integer, List<WorkflowMain>> statusListMap = mains.stream().collect(Collectors.groupingBy(WorkflowMain::getStatus));
+        Set<Integer> statusSet = statusListMap.keySet();
+        for (Integer status : statusSet) {
+            statistics.put(status,statusListMap.get(status).size());
+        }
+        return new Response<Map<Integer,Integer>>().set(1,statistics);
+    }
+
+    /**
+     * 浜屾鏍稿鍜屾晠闅滈殣鎮g殑缁熻
+     *
+     * 澧炲姞浜嗗叏閮� key=0
+     * @param type ={0,2,3} 0浠h〃浜屾鏍稿鍜屾晠闅滈殣鎮d竴璧�
+     * @see WorkflowEnum
+     *
+     * @return
+     */
+    public Response<Map<Integer,Integer>> getOwnStatistics2(int userId, int type) {
+        Map<Integer,Integer> statistics = new HashMap<>();
+        statistics.put(0,0);
+        statistics.put(1,0);
+        statistics.put(2,0);
+        statistics.put(3,0);
+        QueryWrapper<WorkflowMain> query = Wrappers.query();
+        query.eq("create_user_id", userId);
+        if(type == 0){
+            query.in("type",2,3);
+        }else {
+            query.eq("type", type);
+        }
+        List<WorkflowMain> mains = mapper.selectList(query);
+        Map<Integer, List<WorkflowMain>> statusListMap = mains.stream().collect(Collectors.groupingBy(WorkflowMain::getStatus));
+        Set<Integer> statusSet = statusListMap.keySet();
+        int sum = 0;
+        for (Integer status : statusSet) {
+            int size = statusListMap.get(status).size();
+            statistics.put(status, size);
+            sum+=size;
+        }
+        statistics.put(0,sum);
+        return new Response<Map<Integer,Integer>>().set(1,statistics);
+    }
+
+    public Response<PageInfo<WorkflowMain>> ownListPage(int userId, int type, int status, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum,pageSize);
+        List<WorkflowMain> mains = getOwnListByUserAndType(userId,type,status);
+        if(type == 1) {
+            for (WorkflowMain main : mains) {
+                Integer id = main.getId();
+                //List<BattDischargePlanTemp> tempList = tempService.getListByMainId(id);
+                //main.setTempList(tempList);
+            }
+        }
+        PageInfo<WorkflowMain> pageInfo = new PageInfo<>(mains);
+        return new Response<PageInfo<WorkflowMain>>().set(1,pageInfo);
+    }
+
+    private List<WorkflowMain> getOwnListByUserAndType(int userId, int type, int status) {
+        QueryWrapper<WorkflowMain> query = Wrappers.query();
+        if(status == 0){
+            query.eq("create_user_id",userId).eq("type",type).orderByDesc("id");
+        }else {
+            query.eq("create_user_id", userId).eq("type", type).eq("status", status).orderByDesc("id");
+        }
+        return mapper.selectList(query);
+    }
+
+    public Response<Map<Integer,Integer>> getReceivedStatistics(int type, User user) {
+        Map<Integer,Integer> statisticsMap = linkService.getReceivedStatistics(type,user);
+        return new Response<Map<Integer,Integer>>().set(1,statisticsMap);
+    }
+
+    public Response<PageInfo<WorkflowMain>> getReceivedListPage(int type, int status, User user, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum,pageSize);
+        List<WorkflowMain> mains = getReceivedListByUserAndType(user,type,status);
+        if (type == 1) {
+            for (WorkflowMain main : mains) {
+                Integer id = main.getId();
+                //List<BattDischargePlanTemp> tempList = tempService.getListByMainId(id);
+                //main.setTempList(tempList);
+            }
+        }
+        PageInfo<WorkflowMain> pageInfo = new PageInfo<>(mains);
+        return new Response<PageInfo<WorkflowMain>>().set(1, pageInfo);
+    }
+
+    private List<WorkflowMain> getReceivedListByUserAndType(User user, int type, int status) {
+        return mapper.getReceivedListByUserAndType(user, type, status);
+    }
+
+    public WorkflowMain getById(Integer mainId) {
+        return mapper.selectById(mainId);
+    }
+
+    //鏌ヨ琛ㄥ崟缂栧彿
+    public int getMaxId() {
+        Integer id = mapper.getMaxId();
+        if (id == null) {
+            id = 1;
+        } else {
+            id = id + 1;
+        }
+        return id;
+    }
+
+    /**
+     * 閫氱敤鎻愪氦鏂规硶,鎻愪氦缁欒鑹�-瑙掕壊灞�
+     * 濡傛灉related_id涓嶄负绌�,鍒欓渶瑕佺壒娈婂鐞�. 璇佹槑浼氬奖鍝嶅埌鍏宠仈鍗曟嵁
+     *
+     * 娑夊強鍒版柊鐨勯棶棰橀渶瑕佽В鍐�,鐜板満鏁呴殰鍚�,璁惧缁翠慨鐢宠 鎴� 鎶ュ簾鐢宠 鏄涓�,骞跺瓨鍏ュ伐鍗曡澶囪〃涓�. 骞朵笉鍙槸鍗曠函鐨勬暟閲�. TODO ?鑷姩鍖栧鐞嗘�庝箞鏇存柊
+     */
+
+    @Transactional
+    public Response submit(WorkflowMain main){
+        //1.鎻愪氦鍒板崟鎹鎵规祦绋�
+        //濡傛灉瀛樺湪鍏宠仈鍗曟嵁id,棣栧厛鏍¢獙鎻愪氦鐨勬暟閲�
+        Date now = new Date();
+        List<WorkflowDevice>  deviceListRelatedInDB = deviceService.getByMainId(main.getRelatedId());
+        List<WorkflowDevice> deviceList = main.getDeviceList();
+        if(main.getRelatedId() != null) {
+            //閬嶅巻deviceList,濡傛灉deviceList鍐呯殑瀵硅薄鐨剄uantity鍊煎ぇ浜� deviceListRelatedInDB鍐呭璞″垪琛ㄤ腑鐨勫璞℃墍鏈夊瓧娈电浉鍚岀殑璁板綍鐨剄uantityUnprocessed鍊�,鍒欒繑鍥為敊璇�
+            for (int i = 0; i < deviceList.size(); i++) {
+                WorkflowDevice device = deviceList.get(i);
+                for (int j = 0; j < deviceListRelatedInDB.size(); j++) {
+                    WorkflowDevice deviceInDB = deviceListRelatedInDB.get(j);
+                    if (device.getName().equals(deviceInDB.getName())
+                            && device.getModel().equals(deviceInDB.getModel())
+                            && device.getVersion().equals(deviceInDB.getVersion())
+                            && device.getBrand().equals(deviceInDB.getBrand())
+                            && device.getType().equals(deviceInDB.getType())
+                            && device.getSupplier().equals(deviceInDB.getSupplier())
+                    ) {
+                        if (device.getQuantity() > deviceInDB.getQuantityUnprocessed()) {
+                            return new Response().setII(1, "鍏ュ簱鏁伴噺涓嶈兘澶т簬缁翠慨鐢宠鍏宠仈鍗曟嵁鐨勬湭澶勭悊鏁伴噺");
+                        }else{
+                            //褰撳墠璁惧鐨勬牎楠岀粨鏉�,杩涘叆涓嬩竴涓澶囨牎楠�
+                            break;
+                        }
+                    }
+
+                }
+            }
+        }
+        //涓昏〃鎻掑叆
+        //鍒濆鍖栫浉鍏冲瓧娈�
+        WorkflowTypeEnum typeEnum = WorkflowTypeEnum.getByType(main.getType());
+        String name = typeEnum.getName();
+        String namingPrefix = typeEnum.getNamingPrefix();
+        String orderId = getNextOrderId(namingPrefix);
+        //String title = mainTypeCN+"瀹℃壒鍗�-"+ DateUtil.YYYY_MM_DD_HH_MM_SS.format(now);
+
+        String title = name + ThreadLocalUtil.format(ThreadLocalUtil.TIME_YYYY_MM_DD_HH_MM_SS, now);
+        Integer mainStatus = WorkflowEnum.MAIN_STATUS_DEALING.getValue();
+        User user = CommonUtil.getUser();
+        WorkflowProcessEnum process = getProcessLevel(main.getType(),user.getRole());
+        main.setOrderId(orderId);
+        main.setTitle(title);
+        main.setCreateUserId(user.getId());
+        main.setCreateTime(now);
+        main.setBeginTime(now);
+        main.setStatus(mainStatus);
+        main.setProcessStage(process.getStage());
+        if(main.getType() == WorkflowTypeEnum.DEVICE_REPAIR.getType().intValue()){ //缁翠慨鐢宠鍗�,闇�濉叆
+            for (int i = 0; i < deviceList.size(); i++) {
+                deviceList.get(i).setQuantityUnprocessed(deviceList.get(i).getQuantity());
+            }
+        }
+        add(main);
+        //涓昏〃鍏宠仈鐨勭墿鏂欐彃鍏�
+        for (WorkflowDevice device : deviceList) {
+            device.setMainId(main.getId());
+        }
+        deviceService.addBatch(deviceList);
+
+        //鍐呭瓨涓幓闄ゅ凡鎻掑叆鏁版嵁搴撶殑鍗曞彿
+        ServletContext application = ActionUtil.getApplication();
+        List<String> orderIdList = (List<String>) application.getAttribute("orderIdList");
+        //鏍¢獙鏄惁鍘婚櫎
+        boolean remove = orderIdList.remove(orderId);
+        if(!remove){
+            System.err.println("娌℃湁鍘婚櫎鎺�!!!!!!!!!!!!!");
+        }
+        application.setAttribute("orderIdList",orderIdList);
+
+        //鑺傜偣琛ㄦ彃鍏�
+        WorkflowLink link = new WorkflowLink();
+        link.setMainId(main.getId());
+        link.setParentId(0);
+        link.setProcessStage(process.getStage());
+        link.setProcessName(process.getName());
+        link.setCreateTime(now);
+        link.setDealRoleId(getNextDealRoleId(process.getName()));
+        link.setDealType(WorkflowEnum.TYPE_DELIVER.getValue());
+        link.setDealDesc(main.getTaskDesc());
+        link.setStatus(WorkflowEnum.LINK_STATUS_TAKING.getValue());
+
+        linkService.add(link);
+
+        //濡傛灉瀛樺湪鍏宠仈鍗曟嵁id,澶勭悊鍏宠仈鍗曟嵁鍙婅嚜鍔ㄧ敓鎴愭柊鍗曟嵁
+        checkRelatedAndDone(main, now, deviceListRelatedInDB, user);
+        return new Response().setII(1,"鎻愪氦瀹屾垚");
+    }
+
+    private void checkRelatedAndDone(WorkflowMain main, Date now, List<WorkflowDevice> deviceListRelatedInDB, User user) {
+        if(main.getRelatedId() != null){
+            //鐢宠鐨勬暟閲�<鍏宠仈鍗曟嵁鐨勬湭澶勭悊鏁伴噺,鍒欒鏄庢湁鍓╀綑. 闇�瑕佽嚜鍔ㄧ敓鎴愬绔嬪伐鍗�
+            List<WorkflowDevice> deviceList = main.getDeviceList();
+            //璁$畻deviceListn鍐卶uantity灞炴�у�肩殑鍜�
+            int sumQuantity = 0;
+            for (WorkflowDevice device : deviceList) {
+                sumQuantity += device.getQuantity();
+            }
+            //璁$畻deviceListRelatedInDBn鍐卶uantityUnprocessed灞炴�у�肩殑鍜�
+            int sumQuantityUnprocessedInDB = 0;
+            for (WorkflowDevice device : deviceListRelatedInDB) {
+                sumQuantityUnprocessedInDB += device.getQuantityUnprocessed();
+            }
+            if (sumQuantity < sumQuantityUnprocessedInDB){ //璇存槑闇�瑕佽嚜鍔ㄧ敓鎴愬叆搴撴垨鑰呮姤搴熷崟鎹�
+                //闇�瑕佽嚜鍔ㄧ敓鎴愭姤搴熺殑鐢宠
+                WorkflowMain mainAuto = new WorkflowMain();
+                WorkflowTypeEnum typeEnumAuto;
+
+                Integer statusAuto = WorkflowEnum.MAIN_STATUS_DEALING.getValue();
+                WorkflowProcessEnum processAuto = WorkflowProcessEnum.PROCESS_MANAGER1SIGN;
+                mainAuto.setCreateUserId(user.getId());
+                mainAuto.setCreateTime(now);
+                mainAuto.setBeginTime(now);
+                mainAuto.setProcessStage(processAuto.getStage());
+                mainAuto.setStatus(statusAuto);
+                mainAuto.setRelatedId(main.getRelatedId());
+                //鏁寸悊涓昏〃鐨勮澶囬檮琛�
+                List<WorkflowDevice> deviceListAuto = new ArrayList<>();
+                //閬嶅巻deviceListRelatedInDB,鍑忓幓deviceList涓敵璇风殑鏁伴噺
+                for (WorkflowDevice deviceInDB : deviceListRelatedInDB) {
+                    boolean deviceExists = false;
+                    for (WorkflowDevice device : deviceList) {
+                        if (device.getName().equals(deviceInDB.getName())
+                                && device.getModel().equals(deviceInDB.getModel())
+                                && device.getVersion().equals(deviceInDB.getVersion())
+                                && device.getBrand().equals(deviceInDB.getBrand())
+                                && device.getType().equals(deviceInDB.getType())
+                                && device.getSupplier().equals(deviceInDB.getSupplier())
+                        ){
+                            deviceExists = true;
+                            if (deviceInDB.getQuantityUnprocessed()-device.getQuantity() > 0){
+                                WorkflowDevice deviceAuto = new WorkflowDevice();
+                                deviceAuto.setName(deviceInDB.getName());
+                                deviceAuto.setModel(deviceInDB.getModel());
+                                deviceAuto.setVersion(deviceInDB.getVersion());
+                                deviceAuto.setQuantity(deviceInDB.getQuantityUnprocessed()-device.getQuantity());
+                                deviceAuto.setBrand(deviceInDB.getBrand());
+                                deviceAuto.setType(deviceInDB.getType());
+                                deviceAuto.setSupplier(deviceInDB.getSupplier());
+
+                                deviceListAuto.add(deviceAuto);
+                            }else{
+                                break;
+                            }
+                        }
+                    }
+                    if (!deviceExists){
+                        WorkflowDevice deviceAuto = new WorkflowDevice();
+                        deviceAuto.setName(deviceInDB.getName());
+                        deviceAuto.setModel(deviceInDB.getModel());
+                        deviceAuto.setVersion(deviceInDB.getVersion());
+                        deviceAuto.setQuantity(deviceInDB.getQuantityUnprocessed());
+                        deviceAuto.setBrand(deviceInDB.getBrand());
+                        deviceAuto.setType(deviceInDB.getType());
+                        deviceAuto.setSupplier(deviceInDB.getSupplier());
+
+                        deviceListAuto.add(deviceAuto);
+                    }
+                }
+
+                if(main.getType() == WorkflowTypeEnum.DEVICE_IN.getType().intValue()) { //鐢宠鐨勫叆搴�
+                    mainAuto.setTaskDesc("鎻愪氦浜嗙淮淇悗鐨勫叆搴撶敵璇�,绯荤粺鑷姩鐢熸垚鍓╀綑鏁伴噺鐨勬姤搴熺敵璇�");
+                    typeEnumAuto = WorkflowTypeEnum.DEVICE_SCRAP;
+                }else { //鐢宠鐨勬姤搴�
+                    mainAuto.setTaskDesc("鎻愪氦浜嗙淮淇悗鐨勬姤搴熺敵璇�,绯荤粺鑷姩鐢熸垚鍓╀綑鏁伴噺鐨勫叆搴撶敵璇�");
+                    typeEnumAuto = WorkflowTypeEnum.DEVICE_IN;
+                }
+                mainAuto.setOrderId(getNextOrderId(typeEnumAuto.getNamingPrefix()));
+                String titleAuto = typeEnumAuto.getName() + ThreadLocalUtil.format(ThreadLocalUtil.TIME_YYYY_MM_DD_HH_MM_SS, now);
+                mainAuto.setTitle(titleAuto);
+                mainAuto.setType(typeEnumAuto.getType());
+                add(mainAuto);
+                deviceListAuto.forEach(device -> {
+                    device.setMainId(mainAuto.getId());
+                });
+                //鎻掑叆涓昏〃鐨勮澶囬檮琛�
+                deviceService.addBatch(deviceListAuto);
+
+                //鑷姩鑺傜偣鐢熸垚
+                WorkflowLink linkAuto = new WorkflowLink();
+                linkAuto.setParentId(0);
+                linkAuto.setProcessStage(processAuto.getStage());
+                linkAuto.setProcessName(processAuto.getName());
+                linkAuto.setCreateTime(now);
+                linkAuto.setDealRoleId(getNextDealRoleId(processAuto.getName()));
+                linkAuto.setDealType(WorkflowEnum.TYPE_DELIVER.getValue());
+                linkAuto.setStatus(WorkflowEnum.LINK_STATUS_TAKING.getValue());
+                linkAuto.setMainId(mainAuto.getId());
+                linkAuto.setDealDesc(mainAuto.getTaskDesc());
+                linkService.add(linkAuto);
+
+            }
+            //鍏抽棴鍏宠仈鍗曟嵁鐨勭姸鎬�
+            WorkflowMain relatedMain = new WorkflowMain();
+            relatedMain.setId(main.getRelatedId());
+            relatedMain.setStatus(WorkflowEnum.MAIN_STATUS_END_DEALT.getValue());
+            relatedMain.setEndTime(now);
+            if(main.getType() == WorkflowTypeEnum.DEVICE_IN.getType().intValue()) {
+                relatedMain.setEndReason("鐢ㄦ埛鎻愪氦缁翠慨鐢宠鍚庣殑鍏ュ簱鐢宠,缁翠慨娴佺▼缁撴潫");
+            }else{
+                relatedMain.setEndReason("鐢ㄦ埛鎻愪氦缁翠慨鐢宠鍚庣殑鎶ュ簾鐢宠,缁翠慨娴佺▼缁撴潫");
+            }
+            updateById(relatedMain);
+            //鏇存柊鍏宠仈鍗曟嵁鐨勮澶囧墿浣欐湭澶勭悊鏁伴噺涓�0
+            deviceService.setQuantityUnprocessedZero(main.getRelatedId());
+        }
+    }
+
+    /**
+     * TODO 姣忔鏂板娴佺▼鏃�,闇�瑕佹寔缁淮鎶�
+     * 濡傛灉鍚庣画瀛樺湪浼氱,鍒欓渶瑕佽拷鍔犱竴涓type绫诲瀷鐨勫悓鍚嶆柟娉�
+     * @param processLevelName 娴佺▼闃舵鍚�
+     * @return 娴佺▼澶勭悊鐨勪笅涓�涓鑹�
+     */
+    private Integer getNextDealRoleId(String processLevelName) {
+        WorkflowProcessEnum processEnum = WorkflowProcessEnum.getByName(processLevelName);
+        switch (processEnum){
+            //瑙掕壊:1鏅�氱敤鎴凤紝2绠$悊灞傦紝3棰嗗灞傦紝4杩愮淮鐝粍
+            case PROCESS_MANAGER1SIGN:
+                return 2;
+            default:
+                return 2;
+        }
+    }
+
+    /**
+     * TODO 姣忔鏂板娴佺▼鏃�,闇�瑕佹寔缁淮鎶�
+     * @param type 娴佺▼鐨勭被鍨�
+     * @param roleId 鐜板湪鐨勮鑹�
+     * @return 娴佺▼澶勭悊鐨勪笅涓�涓鑹�
+     */
+    private WorkflowProcessEnum getProcessLevel(Integer type,Integer roleId) {
+        WorkflowTypeEnum typeEnum = WorkflowTypeEnum.getByType(type);
+        String name = typeEnum.getName();
+        //瑙掕壊:1鏅�氱敤鎴凤紝2绠$悊灞傦紝3棰嗗灞傦紝4杩愮淮鐝粍
+        switch (name){
+            //瀹℃壒椤哄簭涓� 鏅�氱敤鎴�->绠$悊鍛� ->鏅�氱敤鎴�(杩涜瀹岀粨)
+            case "璁惧缁翠慨鐢宠鍗�":
+            case "璁惧鍏ュ簱鐢宠鍗�":
+            case "璁惧鎶ュ簾鐢宠鍗�":
+            case "璁惧鍑哄簱鐢宠鍗�":
+                if (roleId == 1) {
+                    return WorkflowProcessEnum.PROCESS_MANAGER1SIGN;
+                }
+            default:
+                return WorkflowProcessEnum.PROCESS_SPECIALIST;
+        }
+    }
+
+    public void updateProcessLevel(String processLevel, Integer mainId) {
+        UpdateWrapper<WorkflowMain> update = Wrappers.update();
+        update.set("process_level",processLevel).eq("id",mainId);
+        mapper.update((WorkflowMain) ActionUtil.objeNull,update);
+    }
+
+    public void resetRepairStatus(Integer relatedId) {
+        UpdateWrapper<WorkflowMain> update = Wrappers.update();
+        update.set("status",WorkflowEnum.MAIN_STATUS_WAIT_FOR_DEALING.getValue())
+                .set("end_time",null)
+                .set("end_reason",null)
+                .eq("id",relatedId);
+        mapper.update((WorkflowMain) ActionUtil.objeNull,update);
+    }
+}

--
Gitblit v1.9.1