# EcnServiceImpl.java

    package com.mycim.server.ecn.service;

    import com.alipay.sofa.runtime.api.annotation.SofaService;
    import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
    import com.mycim.server.edc.manager.EcnManager;
    import com.mycim.valueobject.consts.VersionStatus;
    import com.mycim.valueobject.prp.Ecn;
    import org.springframework.stereotype.Service;

    /**
     * @author Johnson.Wang
     * @version 6.0.0
     * @date 2019/8/31
     **/
    @Service
    @SofaService(interfaceType = EcnService.class, bindings = {@SofaServiceBinding(bindingType = "bolt")})
    public class EcnServiceImpl implements EcnService {

        private final EcnManager ecnManager;

        public EcnServiceImpl(EcnManager ecnManager) {
            this.ecnManager = ecnManager;
        }

        @Override
        public Ecn generateUnFrozenEcnForProcessPlan(long requestBy) {
            return ecnManager.generateUnFrozenEcnForProcessPlan(requestBy);
        }

        @Override
        public Ecn generateUnFrozenEcnForContext(long requestBy) {
            return ecnManager.generateUnFrozenEcnForContext(requestBy);
        }

        @Override
        public void activateEcn(Long ecnRrn) {
            ecnManager.updateEcnStatus(VersionStatus.ACTIVE_KEY, ecnRrn);
        }

        @Override
        public void frozenEcn(long ecnRrn) {
            ecnManager.updateEcnStatus(VersionStatus.FROZEN_KEY, ecnRrn);
        }

        @Override
        public void unFrozenEcn(long ecnRrn) {
            ecnManager.updateEcnStatus(VersionStatus.UNFROZEN_KEY, ecnRrn);
        }

        @Override
        public Ecn getEcn(String ecnId) {
            return ecnManager.getEcn(ecnId);
        }

        @Override
        public Ecn getEcn(long ecnRrn) {
            return ecnManager.getEcn(ecnRrn);
        }

        @Override
        public long getEcnSignOffRrn(String ecnType, String refNamedSpace, String tNamedSpace) {
            return ecnManager.getEcnSignOffRrn(ecnType, refNamedSpace, tNamedSpace);
        }

        @Override
        public Ecn generateActiveEcnForContext(long requestBy) {
            return ecnManager.generateActiveEcnForContext(requestBy);
        }

        @Override
        public void activateEcn(Long ecnRrn, String userId) {
            ecnManager.activateEcn(ecnRrn, userId);
        }

    }