WipQueryManagerImpl.java

package com.mycim.server.wip.manager.impl;

import com.mycim.framework.utils.lang.collections.CollectionUtils;
import com.mycim.framework.utils.lang.collections.MapUtils;
import com.mycim.server.security.manager.UserGroupManager;
import com.mycim.server.wip.manager.LotQueryManager;
import com.mycim.server.wip.manager.WipQueryManager;
import com.mycim.valueobject.consts.ReferenceDetailNames;
import com.mycim.valueobject.consts.ReferenceFileConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author songpy
 * @version 1.0.0
 * @date 2021/2/4
 **/
@Service
@Transactional
public class WipQueryManagerImpl implements WipQueryManager {

    @Autowired
    LotQueryManager lotQueryManager;

    @Autowired
    UserGroupManager userGroupManager;

    @Override
    public String getDepartments(String holdCode) {
        StringBuilder departments = new StringBuilder();

        List<Map> releaseGroups = lotQueryManager.getReleaseGroup(holdCode, ReferenceDetailNames.HOLD_CODE);
        if (CollectionUtils.isNotEmpty(releaseGroups)) {
            for (Map<String, Object> map : releaseGroups) {
                String releaseGroup = MapUtils.getString(map, "releaseGroup");
                List<String> departmentIds = userGroupManager
                        .getDepartmentIds(ReferenceDetailNames.REASON_GROUP_DEPARTMENT, releaseGroup,
                                          ReferenceFileConst.DATA_1_VALUE);
                if (CollectionUtils.isNotEmpty(departmentIds)) {
                    for (String departmentId : departmentIds) {
                        if (departments.length() > 0) {
                            departments.append(",").append(departmentId);
                        } else {
                            departments.append(departmentId);
                        }
                    }
                }
            }
        }
        return departments.toString();
    }

}