lyh
2 天以前 582bb2627712f66157b5608c8f5798775fc38266
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java
@@ -14,25 +14,23 @@
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog;
import org.jeecg.modules.eam.tree.FindsEquipmentEamCenterUtil;
import org.jeecg.modules.system.entity.BaseFactory;
import org.jeecg.modules.system.entity.BaseFactoryUser;
import org.jeecg.modules.system.service.IBaseFactoryService;
import org.jeecg.modules.system.service.IBaseFactoryUserService;
import org.jeecg.modules.eam.constant.AssetStatusEnum;
import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum;
import org.jeecg.modules.eam.constant.EquipmentRepairStatus;
import org.jeecg.modules.eam.constant.*;
import org.jeecg.modules.eam.dto.EchartsDto;
import org.jeecg.modules.eam.entity.EamEquipment;
import org.jeecg.modules.eam.entity.EamEquipmentExtend;
import org.jeecg.modules.eam.mapper.EamEquipmentMapper;
import org.jeecg.modules.eam.request.EamEquipmentQuery;
import org.jeecg.modules.eam.service.IEamEquipmentExtendService;
import org.jeecg.modules.eam.service.IEamEquipmentService;
import org.jeecg.modules.eam.tree.FindsEquipmentEamCenterUtil;
import org.jeecg.modules.eam.tree.FindsEquipmentProductionUtil;
import org.jeecg.modules.eam.vo.EamEquipmentTree;
import org.jeecg.modules.eam.vo.EquipmentSearchResult;
import org.jeecg.modules.system.entity.BaseFactory;
import org.jeecg.modules.system.entity.BaseFactoryUser;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.service.IBaseFactoryService;
import org.jeecg.modules.system.service.IBaseFactoryUserService;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -238,7 +236,7 @@
    }
    @Override
    public List<EquipmentSearchResult> asyncLoadEquipment(String keyword, Integer pageSize, String id) {
    public List<EquipmentSearchResult> asyncLoadEquipment(String keyword, Integer pageSize, String id, String factoryOrgCode) {
        if (StringUtils.isNotBlank(id)) {
            EamEquipment eamEquipment = eamEquipmentMapper.selectById(id);
            if (eamEquipment != null) {
@@ -264,7 +262,7 @@
                    list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId()));
            if(!CollectionUtils.isEmpty(baseFactoryUserList)){
                Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet());
                Set<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet());
                Set<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet());
                queryWrapper.in("e.factory_org_code", factoryCode);
            } else {
                return Collections.emptyList();
@@ -272,10 +270,13 @@
        }
        if (StringUtils.isNotBlank(keyword)) {
            queryWrapper.like("equipment_code", keyword);
            queryWrapper.or().like("equipment_name", keyword);
            queryWrapper.like("e.equipment_code", keyword);
            queryWrapper.or().like("e.equipment_name", keyword);
        }
        queryWrapper.eq("del_flag", CommonConstant.DEL_FLAG_0);
        if(StringUtils.isNotBlank(factoryOrgCode)){
            queryWrapper.likeRight("e.factory_org_code", factoryOrgCode);
        }
        queryWrapper.eq("e.del_flag", CommonConstant.DEL_FLAG_0);
        IPage<EamEquipment> pageResult = eamEquipmentMapper.queryPageList(page, queryWrapper);
        if (pageResult != null && CollectionUtil.isNotEmpty(pageResult.getRecords())) {
            List<EquipmentSearchResult> resultList = new ArrayList<>();
@@ -407,6 +408,59 @@
        return eamEquipmentMapper.queryList(queryWrapper);
    }
    @Override
    public List<EamEquipment> selectTechnicalEquipmentList() {
        QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("e.del_flag", CommonConstant.DEL_FLAG_0);
        queryWrapper.ne("ext.technology_status", TechnologyStatusEnum.PROHIBITED.name());
        queryWrapper.isNotNull("ext.technology_check_period");
        queryWrapper.isNotNull("ext.next_technology_check");
        return this.getBaseMapper().selectTechnicalEquipmentList(queryWrapper);
    }
    @Override
    public List<EamEquipment> selectThreeMaintenanceEquipmentList() {
        QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("e.del_flag", CommonConstant.DEL_FLAG_0);
        queryWrapper.ne("ext.maintenance_status", MaintenanceStatusEnum.PROHIBITED.name());
        queryWrapper.isNotNull("ext.third_maintenance_period");
        queryWrapper.isNotNull("ext.next_third_maintenance");
        return this.getBaseMapper().selectThreeMaintenanceEquipmentList(queryWrapper);
    }
    /**
     * 设备管理首页-技术状态
     * @return
     */
    @Override
    public List<EchartsDto> echartsList(){
        QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("e.del_flag", CommonConstant.DEL_FLAG_0);
        //用户数据权限
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        if (sysUser == null) {
            return null;
        }
        if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) {
            //选择了设备,根据设备id过滤设备
            List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(","));
            queryWrapper.in("e.equipment_code", equipArr);
        } else {
            //没有选择设备,根据中心过滤设备
            List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService.
                    list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId()));
            if(!CollectionUtils.isEmpty(baseFactoryUserList)){
                Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet());
                Set<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet());
                queryWrapper.in("e.factory_org_code", factoryCode);
            }else {
                return null;
            }
        }
        List<String> ids=this.baseMapper.queryList(queryWrapper).stream().map(EamEquipment::getId).collect(Collectors.toList());
        return this.baseMapper.echartsList(ids);
    }
    /**
     * 获取所有的产线id(包含所有上级)
     */