| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import io.micrometer.core.instrument.binder.BaseUnits; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | 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.base.entity.BaseFactory; |
| | | import org.jeecg.modules.eam.base.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.eam.base.service.IBaseFactoryService; |
| | | import org.jeecg.modules.eam.base.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.vo.EquipmentSearchResult; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private IEamEquipmentExtendService equipmentExtendService; |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | @Autowired |
| | | private IBaseFactoryUserService baseFactoryUserService; |
| | | @Autowired |
| | | private IBaseFactoryService baseFactoryService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | //扩展表数据同步添加 |
| | | EamEquipmentExtend eamEquipmentExtend = new EamEquipmentExtend(); |
| | | eamEquipmentExtend.setId(eamEquipment.getId()); |
| | | BeanUtils.copyProperties(eamEquipment, eamEquipmentExtend); |
| | | eamEquipmentExtend.setMaintenanceStatus(EquipmentMaintenanceStatus.NORMAL.name()); |
| | | eamEquipmentExtend.setRepairStatus(EquipmentRepairStatus.NORMAL.name()); |
| | | |
| | | equipmentExtendService.save(eamEquipmentExtend); |
| | | |
| | | //插入设备履历 @EquipmentHistoryLog |
| | | return eamEquipment; |
| | | } |
| | | |
| | | /** |
| | | * 台账设备编辑 |
| | | * @param eamEquipment |
| | | */ |
| | | @Override |
| | | public EamEquipment updateEquipment(EamEquipment eamEquipment){ |
| | | if (eamEquipment == null) { |
| | | return null; |
| | | } |
| | | eamEquipmentMapper.updateById(eamEquipment); |
| | | EamEquipmentExtend eamEquipmentExtend = new EamEquipmentExtend(); |
| | | BeanUtils.copyProperties(eamEquipment, eamEquipmentExtend); |
| | | equipmentExtendService.updateById(eamEquipmentExtend); |
| | | return eamEquipment; |
| | | } |
| | | |
| | |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id", sysUser.getId()); |
| | | //没有选择设备,根据中心过滤设备 |
| | | List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService. |
| | | list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId())); |
| | | if(!CollectionUtils.isEmpty(baseFactoryUserList)){ |
| | | List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); |
| | | List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); |
| | | queryWrapper.in("e.factory_code", factoryCode); |
| | | } |
| | | |
| | | } |
| | | //查询条件过滤 |
| | | if (eamEquipment != null) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 设备台账导出 |
| | | * @param eamEquipment |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EamEquipment> exportList(EamEquipmentQuery eamEquipment){ |
| | | QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("e.del_flag", CommonConstant.DEL_FLAG_0); |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | 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)){ |
| | | List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); |
| | | List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); |
| | | queryWrapper.in("e.factory_code", factoryCode); |
| | | } |
| | | |
| | | } |
| | | //查询条件过滤 |
| | | if (eamEquipment != null) { |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentCode())) { |
| | | queryWrapper.like("e.equipment_code", eamEquipment.getEquipmentCode()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentName())) { |
| | | queryWrapper.like("e.equipment_name", eamEquipment.getEquipmentName()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentImportance())) { |
| | | queryWrapper.eq("e.equipment_importance", eamEquipment.getEquipmentImportance()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getAssetStatus())) { |
| | | queryWrapper.like("e.asset_status", eamEquipment.getAssetStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getTechnologyStatus())) { |
| | | queryWrapper.like("e.technology_status", eamEquipment.getTechnologyStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getOperationSystem())) { |
| | | queryWrapper.like("e.operation_system", eamEquipment.getOperationSystem()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getOrgId())) { |
| | | //车间编码不为空 |
| | | List<String> productIds = mdcProductionService.recursionChildren(eamEquipment.getOrgId()); |
| | | if (CollectionUtil.isNotEmpty(productIds)) { |
| | | //不做筛选 |
| | | queryWrapper.in("e.org_id", productIds); |
| | | } |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentCategory())) { |
| | | queryWrapper.like("e.equipment_category", eamEquipment.getEquipmentCategory()); |
| | | } |
| | | if (StringUtils.isNotBlank(eamEquipment.getId())) { |
| | | queryWrapper.eq("e.id", eamEquipment.getId()); |
| | | } |
| | | //排序 |
| | | if (StringUtils.isNotBlank(eamEquipment.getColumn()) && StringUtils.isNotBlank(eamEquipment.getOrder())) { |
| | | //queryWrapper.like("column", eamEquipment.getColumn()); |
| | | String column = eamEquipment.getColumn(); |
| | | if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); |
| | | } |
| | | if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(eamEquipment.getOrder())) { |
| | | queryWrapper.orderByAsc("e." + oConvertUtils.camelToUnderline(column)); |
| | | } else { |
| | | queryWrapper.orderByDesc("e." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("e.create_time"); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("e.create_time"); |
| | | } |
| | | return eamEquipmentMapper.queryList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有的产线id(包含所有上级) |
| | | */ |
| | | private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) { |