cuilei
2025-06-11 cd00884c3db8fa6808b3b5949ab1a2b1459d6bdc
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java
@@ -9,8 +9,11 @@
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.FillRuleConstant;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.FillRuleUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.*;
@@ -21,8 +24,10 @@
import org.jeecg.modules.system.model.MdcProductionTreeModel;
import org.jeecg.modules.system.model.ProductionIdModel;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysDictService;
import org.jeecg.modules.system.service.ISysParamsService;
import org.jeecg.modules.system.util.FindsProductionsChildrenUtil;
import org.jeecg.modules.system.vo.MdcProOptionsVo;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -51,6 +56,9 @@
    @Resource
    private ISysParamsService sysParamsService;
    @Resource
    private ISysDictService sysDictService;
    /**
     * queryTreeList 对应 queryTreeList 查询所有的产线数据,以树结构形式响应给前端
     */
@@ -73,12 +81,25 @@
    @Override
    public List<MdcProductionTreeModel> queryTreeListByConfig(){
        SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_production");
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
        if (sysParams == null) {
            return null;
        }else {
            List<String> productionIds = new ArrayList<>();
            if (!("admin").equals(loginUser.getUsername())) {
                //不是超级管理员,获取用户拥有的产线
                if (loginUser.getProductionIds() != null) {
                    if (loginUser.getProductionIds().contains(",")) {
                        productionIds = Arrays.asList(loginUser.getProductionIds().split(","));
                    } else {
                        productionIds = Collections.singletonList(loginUser.getProductionIds());
                    }
                }
            }
            if (("0").equals(sysParams.getSettingValue())){
                query.eq(MdcProduction::getOrgType,"2");
                query.in(!productionIds.isEmpty(), MdcProduction::getId, productionIds);
                query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
                query.orderByAsc(MdcProduction::getProductionOrder);
                List<MdcProduction> list = this.list(query);
@@ -521,6 +542,64 @@
        return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list);
    }
    @Override
    public List<String> findChildren(List<String> mdcProductionIds) {
        return this.baseMapper.findChildren(mdcProductionIds);
    }
    /**
     * 根据用户id获取产线(中心)或班组下拉选项
     * @param userId
     * @param productionId
     * @return
     */
    @Override
    public List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId) {
        List<MdcProOptionsVo> result = new ArrayList<>();
        List<MdcProduction> mdcProductionList = this.baseMapper.loadProductionOptions(userId, productionId);
        if (mdcProductionList != null && !mdcProductionList.isEmpty()) {
            for (MdcProduction mdcProduction : mdcProductionList) {
                MdcProOptionsVo vo = new MdcProOptionsVo().convert(mdcProduction);
                result.add(vo);
            }
        }
        return result;
    }
    @Override
    public List<MdcProduction> findMdcPros(String userId, String productionId) {
        return this.baseMapper.loadProductionOptions(userId, productionId);
    }
    @Override
    public List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId) {
        List<MdcProOptionsVo> result = new ArrayList<>();
        List<String> productionList = this.findChildren(Arrays.asList(productionId.split(",")));
        if (productionList != null && !productionList.isEmpty()) {
            List<String> dictValues = this.baseMapper.findTeamValue(userId, productionList);
            if (dictValues != null && !dictValues.isEmpty()) {
                List<DictModel> dictModels = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM);
                if (dictModels != null && !dictModels.isEmpty()) {
                    for (DictModel dictModel : dictModels) {
                        if (dictValues.contains(dictModel.getValue())) {
                            MdcProOptionsVo vo = new MdcProOptionsVo();
                            vo.setKey(dictModel.getValue());
                            vo.setValue(dictModel.getValue());
                            vo.setTitle(dictModel.getText());
                            result.add(vo);
                        }
                    }
                }
            }
        }
        return result;
    }
    @Override
    public List<String> findProIdsByUId(String userId, List<String> allProductionIds) {
        return this.baseMapper.findProIdsByUId(userId, allProductionIds);
    }
    /**
     * 打开 父节点 及 以上的mdc标记
     * @param parentId
@@ -548,4 +627,14 @@
            super.update(updateWrapper);
        }
    }
    @Override
    public List<String> findChildByProId(String productionId) {
        return this.baseMapper.findChildByProId(productionId);
    }
    @Override
    public String findProName(String equipmentId) {
        return this.baseMapper.findProName(equipmentId);
    }
}