# StatusServiceImpl.java

    package com.mycim.server.status.service;

    import com.alipay.sofa.runtime.api.annotation.SofaService;
    import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
    import com.mycim.framework.utils.lang.time.DateUtils;
    import com.mycim.server.ems.manager.EquipmentInqManager;
    import com.mycim.server.ems.manager.LogEventReqManager;
    import com.mycim.server.status.manager.StatusManager;
    import com.mycim.valueobject.consts.EventName;
    import com.mycim.valueobject.ems.Entity;
    import com.mycim.valueobject.ems.EntityStatus;
    import com.mycim.valueobject.ems.Equipment;
    import com.mycim.valueobject.ems.Event;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import java.util.*;

    @Service
    @SofaService(interfaceType = StatusService.class, bindings = {@SofaServiceBinding(bindingType = "bolt")})
    public class StatusServiceImpl implements StatusService {

        @Autowired
        private StatusManager statusManager;

        @Autowired
        private LogEventReqManager logEventReqManager;

        @Autowired
        private EquipmentInqManager equipmentInqManager;

        @Override
        public long updateEntityStatusByEntityId(List<EntityStatus> entityStatuss, String user, Long userRrn, Event event,
                                                 String comments, String comments1, String comments2, String statusEndTime,
                                                 long entityRrn) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("event", event);
            map.put("user", user);
            map.put("comments", comments);
            map.put("comments1", comments1);
            map.put("comments2", comments2);
            map.put("statusEndTime", DateUtils.getNowTime());
            map.put("entityrrn", entityRrn);
            statusManager.updateParentEntityByChamberAllInSameState(entityStatuss, map,
                                                                    Arrays.asList(EventName.DOWN, EventName.WAIT_ENG));
            long transRrn = statusManager
                    .updateEntityStatusByEntityId(entityStatuss, user, userRrn, event, comments, comments1, comments2,
                                                  statusEndTime, entityRrn);

            Equipment equipment = equipmentInqManager.getEquipment(entityRrn);
            if (equipment != null) {
                Long parentEquipmentRrn = equipment.getParentEntityRrn();
                if (parentEquipmentRrn != null) {
                    logEventReqManager.synChamberEqptStatus(parentEquipmentRrn);
                }
            }

            return transRrn;
        }

        @Override
        public void updateEntityStatus(List<EntityStatus> entityStatuss, HashMap map) {
            statusManager.updateEntityStatus(entityStatuss, map);
        }

        @Override
        public void updateEntityStatusOnly(Collection entityStatuss, HashMap<String, Object> map) {
            statusManager.updateEntityStatusOnly(entityStatuss, map);
        }

        /**
         * 修改设备状态，并且联动修改关联的父子设备
         */
        @Override
        public void updatEntityStatus(List<EntityStatus> entityStatuss, String user, Event event, String comments,
                                      String comments1, String comments2, String statusEndTime, Entity entity) {
            if (checkEnableLogEvent(event.getInstanceRrn(), entity.getInstanceRrn())) {
                HashMap map = new HashMap();
                map.put("event", event);
                map.put("user", user);
                map.put("comments", comments);
                map.put("comments1", comments1);
                map.put("comments2", comments2);
                map.put("statusEndTime", statusEndTime);
                map.put("entityrrn", new Long(entity.getInstanceRrn()));
                statusManager.updateEntityStatus(entityStatuss, map);
                // update parent Entity and Child Entity status
                statusManager.updateParentOrChildEntityStatus(map, entity, event, entityStatuss);
            }
        }

        @Override
        public void updateAllEntityStatus(Collection entityStatuss, Event event, long entityRrn, long transRrn) {
            //未找到调用方，暂不修改
            statusManager.updateAllEntityStatus(entityStatuss, event, entityRrn, transRrn);
        }

        @Override
        public void logEventImpl(long entityRrn, String eventId, long eventRrn, String userId, String comments,
                                 String comments1, String comments2) {
            statusManager.logEventImpl(entityRrn, eventId, eventRrn, userId, comments, comments1, comments2);
        }

        @Override
        public void changePcdStatusByLogEvent(Long facilityRrn, String user, String pcdId, String pcdType, String eventId,
                                              String comments, String targetStatus, String currentStatus,
                                              String cleanEqptId) {
            statusManager.changePcdStatusByLogEvent(facilityRrn, user, pcdId, pcdType, eventId, comments, targetStatus,
                                                    currentStatus, cleanEqptId);
        }

        @Override
        public boolean checkEnableLogEvent(long eventRrn, long entityRrn) {
            return statusManager.checkEnableLogEvent(eventRrn, entityRrn);
        }

        @Override
        public void updatePcdStatus(Long carrierRrn, Long podRrn, Long doorRrn, String status, Long transRrn,
                                    String comments) {
            statusManager.updatePcdStatus(carrierRrn, podRrn, doorRrn, status, transRrn, comments);
        }

        @Override
        public void logEventImpl(long entityRrn, String eventId, long eventRrn, String userId, Map maph) {
            statusManager.logEventImpl(entityRrn, eventId, eventRrn, userId, maph);
        }

    }