1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.vci.web.other;
 
import com.vci.corba.common.PLException;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.omd.utils.ObjectTool;
import com.vci.web.annotation.FlowNotifyBefore;
import com.vci.web.annotation.FlowNotifyWeb;
import com.vci.bo.FlowNoticeInfo;
import com.vci.web.service.WebBoServiceI;
import com.vci.web.util.PlatformClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
 
import java.util.*;
 
/**
 * Description: 流程终止时,恢复CodeAllCode状态
 *
 * @author LiHang
 * @date Created on 2022/5/6
 */
@FlowNotifyWeb
public class WorkFlowEndedNotice {
    /**
     * 当前类的日志输出
     */
    private Logger logger = LoggerFactory.getLogger(getClass());
 
    @Autowired
    private WebBoServiceI boService;
 
    @Autowired
    private PlatformClientUtil platformClientUtil;
 
 
    @FlowNotifyBefore
    public void callBefore(FlowNoticeInfo noticeInfo) {
        try {
            if ("end".equals(noticeInfo.getOutcome())) {
                logger.info("当前是流程终止操作,开始恢复编码生命周期");
                List<Map> finishItemList = noticeInfo.getFinishItemList();
                String wfOid = String.valueOf(finishItemList.get(finishItemList.size() - 1).get("oid"));
                if (StringUtils.isBlank(wfOid)) {
                    logger.info("没有找到流程主键");
                    return;
                }
 
                String sql = "SELECT T_OID,T_BTWNAME FROM PLATFORMLT_INPUT WHERE F_OID = '" + wfOid + "'";
                List<BusinessObject> queryResult = boService.queryBySql(sql, new HashMap<>());
                if (queryResult.size() == 0) {
                    logger.info("没有找到业务数据");
                    return;
                }
                String btmName = ObjectTool.getBOAttributeValue(queryResult.get(0),"t_btwname");
                String oid = ObjectTool.getBOAttributeValue(queryResult.get(0),"t_oid");
                String querySql = "select cac.oid from PLATFORMBTM_CODEALLCODE cac\n" +
                        " left join PLATFORMBTM_" + btmName + " wp on cac.CREATECODEOID = wp.OID\n" +
                        " where wp.OID = '" + oid + "'";
                Map<String, String> conditionMap = new HashMap<>();
                conditionMap.put("oid", oid);
                List<BusinessObject> codeResult = boService.queryCBO(btmName, conditionMap);
                conditionMap.clear();
                conditionMap.put("createCodeOid", ObjectTool.getBOAttributeValue(queryResult.get(0),"oid"));
                List<BusinessObject> allCodeList = boService.queryCBO("codeAllCode", conditionMap);
                if (allCodeList.size() == 0) {
                    logger.info("没有找到编码");
                    return;
                }
                for (BusinessObject codeAllCode : allCodeList) {
                    codeAllCode.lcStatus = "Editing";
                    ObjectTool.setBOAttributeValue(codeAllCode,"lcstatus", "Editing");
                }
 
                platformClientUtil.getBOFService().batchUpdateBusinessObject(allCodeList.toArray(new BusinessObject[0]));
                logger.info("编码生命周期恢复完成");
            }
        } catch (PLException e) {
            e.printStackTrace();
        }
    }
 
}