Process102.java 3.1 KB
Newer Older
苗卫卫 committed
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 85 86
package com.boco.nbd.wios.flow.process;

import cn.hutool.core.util.StrUtil;
import com.boco.nbd.cams.core.util.LambdaUtils;
import com.boco.nbd.framework.workflow.entity.SubmitFlowRequest;
import com.boco.nbd.framework.workflow.entity.SubmitTypeEnum;
import com.boco.nbd.framework.workflow.entity.exception.FlowException;
import com.boco.nbd.framework.workflow.flow.AbstractFlow;
import com.boco.nbd.wios.flow.entity.FlowConstant;
import com.boco.nbd.wios.flow.entity.bo.LocalSubmitFlowBO;
import com.boco.nbd.wios.flow.entity.po.OrderPO;
import com.boco.nbd.wios.flow.enums.FlowNodeEnum;
import com.boco.nbd.wios.flow.service.IOrderService;
import com.boco.nbd.wios.manage.entity.bo.SupplierContractVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author:cao hai
 * @date:2022/6/30 17:04
 * @version:V1.0
 * @description:Process102
 * @modify:
 */
@Service("Process102")
public class Process102 extends AbstractFlow {

    @Autowired
    protected IOrderService orderService;

    /**
     * 预处理(业务数据调整)
     *
     * @param request
     */
    @Override
    protected void preProcess(SubmitFlowRequest request) {
        LocalSubmitFlowBO bo = (LocalSubmitFlowBO) request;
        if (SubmitTypeEnum.TaskFlow.equals(bo.getSubmitType())) {
            bo.setNextNodeEnum(FlowNodeEnum.NODE_103);
            bo.getBusiness().setDispatchTime(new Date());

            //验证
            if (bo.getBusiness().getInstallSupplierId() == null ||
                    StrUtil.isEmpty(bo.getBusiness().getInstallSupplierName())) {
                throw new FlowException("工单:" + bo.getBusiness().getId() + "安装服务商信息缺失");
            }
            SupplierContractVo supplierContract = orderService.getSupplierContract(bo.getBusiness().getInstallSupplierId());
            bo.getBusiness().setSupplierContractId(supplierContract.getId());
            //modify 2022-10-18赋值信息勘测安装服务商字段
            bo.getBusiness().setSurveySupplierId(bo.getBusiness().getInstallSupplierId());
            bo.getBusiness().setSurveySupplierName(bo.getBusiness().getInstallSupplierName());
            bo.getTaskParam().put(FlowConstant.SUPPLIER_ID, bo.getBusiness().getInstallSupplierId());
            bo.getTaskParam().put(FlowConstant.SUPPLIER_NAME, bo.getBusiness().getInstallSupplierName());
            StringBuffer builder = new StringBuffer();
            builder.append(LambdaUtils.getFieldApiModelProperty(OrderPO::getInstallSupplierName));
            builder.append(":" + bo.getBusiness().getInstallSupplierName());
            bo.setCommentMsg(builder.toString());
            if (StrUtil.isNotEmpty(bo.getBusiness().getMessage())) {
                bo.setCommentMsg(bo.getCommentMsg() + ";" + bo.getBusiness().getMessage());
            }
        }
    }

    /**
     * 验证参数
     *
     * @param request
     */
    @Override
    protected void verifyParam(SubmitFlowRequest request) {

    }

    /**
     * 后续处理
     *
     * @param request
     */
    @Override
    protected void postProcess(SubmitFlowRequest request) {

    }
}