| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.dto.message.MessageDTO; |
| | |
| | | import org.jeecg.modules.system.mapper.MdcEquipmentDepartMapper; |
| | | import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper; |
| | | import org.jeecg.modules.system.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * @Date: 2023-03-22 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class MdcEquipmentServiceImpl extends ServiceImpl<MdcEquipmentMapper, MdcEquipment> implements IMdcEquipmentService { |
| | | |
| | |
| | | |
| | | @Value("${fileNCPath}") |
| | | private String fileNCPath; |
| | | |
| | | @Autowired |
| | | private IEquipmentService equipmentService; |
| | | |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { |
| | | //获取所有产线数据 |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1).orderByAsc(MdcProduction::getProductionOrder)); |
| | | //根据用户id获取拥有的产线信息集合 |
| | | List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); |
| | | List<String> allProductionIds = new ArrayList<>(); |
| | |
| | | return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addNewEquipmentFromEam(MdcEquipment mdcEquipment, String productionId) { |
| | | //默认系统类型 |
| | | mdcEquipment.setSystemValue("3"); |
| | | //判断MDC是否已添加此设备 |
| | | MdcEquipment entity = this.getBaseMapper().selectOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, mdcEquipment.getEquipmentId())); |
| | | if (entity != null) { |
| | | //MDC已经存在此设备 |
| | | log.warn("MDC已经存在此设备, equipmentId={}", mdcEquipment.getEquipmentId()); |
| | | return; |
| | | } |
| | | Equipment equipment = equipmentService.getOne(new LambdaQueryWrapper<Equipment>().eq(Equipment::getEquipmentid, mdcEquipment.getEquipmentId())); |
| | | if(equipment == null) { |
| | | //采集未配置 |
| | | log.warn("采集未配置, equipmentId={}", mdcEquipment.getEquipmentId()); |
| | | return; |
| | | } |
| | | //设置值 |
| | | mdcEquipment.setEquipmentIp(equipment.getEquipmentip()); |
| | | mdcEquipment.setEquipmentModel(equipment.getEquipmentmodel()); |
| | | mdcEquipment.setDataPort(equipment.getDataport()); |
| | | mdcEquipment.setDriveType(equipment.getDrivetype()); |
| | | mdcEquipment.setControlSystem(equipment.getControlsystem()); |
| | | mdcEquipment.setSaveTableName(equipment.getSavetablename()); |
| | | mdcEquipment.setEquipmentStatus(CommonConstant.STATUS_NORMAL); |
| | | |
| | | this.saveMdcEquipment(mdcEquipment, null, productionId); |
| | | } |
| | | |
| | | /** |
| | | * 根据产线id集合查询设备列表 |
| | | * @param mdcProductionIds |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> findByProductionIds(List<String> mdcProductionIds) { |
| | | return this.baseMapper.findByProductionIds(mdcProductionIds); |
| | | } |
| | | |
| | | } |