¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | 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.core.toolkit.StringPool; |
| | | 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.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.mdc.dto.MdcEquDepDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquProDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDto; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; |
| | | import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.util.DncCopyEquipment; |
| | | import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil; |
| | | import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; |
| | | import org.jeecg.modules.mdc.vo.*; |
| | | import org.jeecg.modules.system.entity.*; |
| | | 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; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * @Description: 设å¤è¡¨ |
| | | * @Author: liuS |
| | | * @Date: 2023-03-22 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class MdcEquipmentServiceImpl extends ServiceImpl<MdcEquipmentMapper, MdcEquipment> implements IMdcEquipmentService { |
| | | |
| | | @Resource |
| | | private MdcEquipmentDepartMapper mdcEquipmentDepartMapper; |
| | | @Resource |
| | | private MdcProductionEquipmentMapper mdcProductionEquipmentMapper; |
| | | @Resource |
| | | private ISysUserDepartService sysUserDepartService; |
| | | @Resource |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | @Resource |
| | | private ISysDepartService sysDepartService; |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | @Resource |
| | | private IEquipmentWorkLineService equipmentWorkLineService; |
| | | @Resource |
| | | private IMdcDriveTypeParamConfigService mdcDriveTypeParamConfigService; |
| | | @Resource |
| | | private MdcTorqueConfigMapper mdcTorqueConfigMapper; |
| | | @Resource |
| | | private IEquipmentLogService equipmentLogService; |
| | | @Resource |
| | | private ISysBaseAPI sysBaseApi; |
| | | @Resource |
| | | private IMdcAlarmInfoService mdcAlarmInfoService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentThresholdService mdcEquipmentThresholdService; |
| | | |
| | | @Resource |
| | | private IMdcOverrunAlarmService mdcOverrunAlarmService; |
| | | |
| | | @Resource |
| | | private ISysParamsService ISysParamsService; |
| | | |
| | | @Resource |
| | | private IDncDevicePermissionService iDncDevicePermissionService; |
| | | |
| | | @Value("${fileNCPath}") |
| | | private String fileNCPath; |
| | | |
| | | @Autowired |
| | | private IEquipmentService equipmentService; |
| | | |
| | | |
| | | @Override |
| | | public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { |
| | | List<MdcEquipmentDepVo> list = this.baseMapper.getDepNamesByEquipmentIds(equipmentIds); |
| | | Map<String, String> res = new HashMap(5); |
| | | list.forEach(item -> res.merge(item.getEquipmentId(), item.getDepartName(), (a, b) -> a + "," + b)); |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, String> getProNamesByEquipmentIds(List<String> equipmentIds) { |
| | | List<MdcEquipmentProVo> list = this.baseMapper.getProNamesByEquipmentIds(equipmentIds); |
| | | Map<String, String> res = new HashMap(5); |
| | | list.forEach(item -> res.merge(item.getEquipmentId(), item.getProductionName(), (a, b) -> a + "," + b)); |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveMdcEquipment(MdcEquipment mdcEquipment, String selectedDeparts, String selectedProduction) { |
| | | if (mdcEquipment.getSystemValue()!=null) { |
| | | switch (mdcEquipment.getSystemValue()){ |
| | | case "1": |
| | | mdcEquipment.setDeviceTypeDnc("1"); |
| | | break; |
| | | case "2": |
| | | mdcEquipment.setDeviceTypeMdc("1"); |
| | | break; |
| | | case "3": |
| | | mdcEquipment.setDeviceTypeDnc("1"); |
| | | mdcEquipment.setDeviceTypeMdc("1"); |
| | | break; |
| | | } |
| | | }else { |
| | | //è·åç³»ç»ç±»å |
| | | SysParams sysParams = ISysParamsService.getSysPramBySettingKey("system_type"); |
| | | //MDCç³»ç» |
| | | if ("-1".equals(sysParams.getSettingValue())){ |
| | | mdcEquipment.setDeviceTypeMdc("1"); |
| | | } |
| | | //DNCç³»ç» |
| | | if ("1".equals(sysParams.getSettingValue())) { |
| | | mdcEquipment.setDeviceTypeDnc("1"); |
| | | } |
| | | } |
| | | //step.1 ä¿åè®¾å¤ |
| | | this.save(mdcEquipment); |
| | | //DNCæ·»å è®¾å¤æé |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | iDncDevicePermissionService.addDevicePermission(mdcEquipment.getId(), user.getId()); |
| | | //step.2 ä¿åæå±é¨é¨ |
| | | if (oConvertUtils.isNotEmpty(selectedDeparts)) { |
| | | String[] arr = selectedDeparts.split(","); |
| | | for (String departId : arr) { |
| | | MdcEquipmentDepart equipmentDepart = new MdcEquipmentDepart(mdcEquipment.getId(), departId); |
| | | mdcEquipmentDepartMapper.insert(equipmentDepart); |
| | | } |
| | | } |
| | | //step.3 ä¿åæå±äº§çº¿ |
| | | if (oConvertUtils.isNotEmpty(selectedProduction)) { |
| | | String[] arr = selectedProduction.split(","); |
| | | for (String productionId : arr) { |
| | | MdcProductionEquipment mdcProductionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId); |
| | | mdcProductionEquipmentMapper.insert(mdcProductionEquipment); |
| | | } |
| | | } |
| | | //step.3 ä¿å设å¤å¯¹åºç产线æé |
| | | addDevicePermission(mdcEquipment); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @CacheEvict(value = {"mdc:cache:encrypt:equipment"}, allEntries = true) |
| | | public void editMdcEquipment(MdcEquipment mdcEquipment) { |
| | | if (mdcEquipment.getSystemValue()!=null) { |
| | | switch (mdcEquipment.getSystemValue()){ |
| | | case "1": |
| | | mdcEquipment.setDeviceTypeDnc("1"); |
| | | mdcEquipment.setDeviceTypeMdc("0"); |
| | | break; |
| | | case "2": |
| | | mdcEquipment.setDeviceTypeDnc("0"); |
| | | mdcEquipment.setDeviceTypeMdc("1"); |
| | | break; |
| | | case "3": |
| | | mdcEquipment.setDeviceTypeDnc("1"); |
| | | mdcEquipment.setDeviceTypeMdc("1"); |
| | | break; |
| | | } |
| | | } |
| | | //平移设å¤ç®å½ä¸ç°æç»æä¸æä»¶ |
| | | //è·ååæç»æ |
| | | String OldPath=""; |
| | | String NewPath=""; |
| | | List<String> OldStrings=mdcProductionService.findListParentTreeAll(mdcEquipment.getId()); |
| | | if (OldStrings != null && !OldStrings.isEmpty()) { |
| | | OldPath = fileNCPath+"/"+StringUtils.join(OldStrings.toArray(), "/")+"/"+mdcEquipment.getEquipmentId(); |
| | | } |
| | | //step.1 ä¿®æ¹è®¾å¤åºç¡ä¿¡æ¯ |
| | | this.updateById(mdcEquipment); |
| | | //step.2 ä¿®æ¹é¨é¨ |
| | | String departs = mdcEquipment.getSelectedDeparts(); |
| | | String[] arr = {}; |
| | | if (oConvertUtils.isNotEmpty(departs)) { |
| | | arr = departs.split(","); |
| | | } |
| | | //å
å åå |
| | | mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getEquipmentId, mdcEquipment.getId())); |
| | | if (oConvertUtils.isNotEmpty(departs)) { |
| | | for (String departId : arr) { |
| | | MdcEquipmentDepart equipmentDepart = new MdcEquipmentDepart(mdcEquipment.getId(), departId); |
| | | mdcEquipmentDepartMapper.insert(equipmentDepart); |
| | | } |
| | | } |
| | | //å 餿æè®¾å¤æé |
| | | iDncDevicePermissionService.remove(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getDeviceId, mdcEquipment.getId())); |
| | | //step.3 ä¿®æ¹äº§çº¿ |
| | | String productions = mdcEquipment.getSelectedProduction(); |
| | | String[] array = {}; |
| | | if (oConvertUtils.isNotEmpty(productions)) { |
| | | array = productions.split(","); |
| | | } |
| | | //å
å åå |
| | | mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, mdcEquipment.getId())); |
| | | if (oConvertUtils.isNotEmpty(productions)) { |
| | | for (String productionId : array) { |
| | | MdcProductionEquipment productionEquipment = new MdcProductionEquipment(mdcEquipment.getId(), productionId); |
| | | mdcProductionEquipmentMapper.insert(productionEquipment); |
| | | } |
| | | } |
| | | List<String> NewStrings = mdcProductionService.findListParentTreeAll(mdcEquipment.getId()); |
| | | if (NewStrings != null && !NewStrings.isEmpty()) { |
| | | NewPath = fileNCPath+"/"+StringUtils.join(NewStrings.toArray(), "/")+"/"+mdcEquipment.getEquipmentId(); |
| | | } |
| | | // 平移OldPathä¸çæä»¶å°NewPathä¸ |
| | | DncCopyEquipment.CopyEquipmentPath(OldPath,NewPath); |
| | | //ä¿å设å¤å¯¹åºç产线æé |
| | | addDevicePermission(mdcEquipment); |
| | | //step.4 ä¿®æ¹è®¾å¤æé |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | List<DncDevicePermission> dncDevicePermissions=iDncDevicePermissionService.list(new LambdaQueryWrapper<DncDevicePermission>() |
| | | .eq(DncDevicePermission::getDeviceId, mdcEquipment.getId()).eq(DncDevicePermission ::getUserId, user.getId())); |
| | | if (CollectionUtils.isEmpty(dncDevicePermissions)){ |
| | | iDncDevicePermissionService.addDevicePermission(mdcEquipment.getId(), user.getId()); |
| | | } |
| | | } |
| | | |
| | | private void addDevicePermission(MdcEquipment mdcEquipment) { |
| | | List<String> productionIds=mdcProductionEquipmentMapper |
| | | .selectList(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, mdcEquipment.getId())) |
| | | .stream().map(MdcProductionEquipment::getProductionId).collect(Collectors.toList()); |
| | | List<MdcUserProduction> mdcUserProductionList=mdcUserProductionService.queryByProductionIds(productionIds); |
| | | mdcUserProductionList.forEach(item->{ |
| | | iDncDevicePermissionService.addDevicePermission(mdcEquipment.getId(), item.getUserId()); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @CacheEvict(value = {"mdc:cache:encrypt:equipment"}, allEntries = true) |
| | | public boolean deleteById(String id) { |
| | | // 1. å é¤è®¾å¤ |
| | | int line = this.baseMapper.deleteById(id); |
| | | // 2. å é¤è®¾å¤é¨é¨å
³ç³» |
| | | line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getEquipmentId, id)); |
| | | // 3. å é¤è®¾å¤äº§çº¿å
³ç³» |
| | | line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, id)); |
| | | // 4. å é¤è®¾å¤æé |
| | | line += iDncDevicePermissionService.remove(new LambdaQueryWrapper<DncDevicePermission>().eq(DncDevicePermission::getDeviceId, id))? 1 : 0; |
| | | return line != 0; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @CacheEvict(value = {"mdc:cache:encrypt:equipment"}, allEntries = true) |
| | | public boolean deleteByIds(List<String> equipmentIds) { |
| | | // 1. å é¤è®¾å¤ |
| | | int line = this.baseMapper.deleteBatchIds(equipmentIds); |
| | | // 2. å é¤è®¾å¤é¨é¨å
³ç³» |
| | | line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().in(MdcEquipmentDepart::getEquipmentId, equipmentIds)); |
| | | // 3. å é¤è®¾å¤äº§çº¿å
³ç³» |
| | | line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getEquipmentId, equipmentIds)); |
| | | |
| | | return line != 0; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MdcEquipment> pageListByDepId(Page<MdcEquipment> page, String departId, String equipmentId) { |
| | | return this.baseMapper.pageListByDepId(page, departId, equipmentId); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MdcEquipment> pageListByProId(Page<MdcEquipment> page, String productionId, String equipmentId) { |
| | | return this.baseMapper.pageListByProId(page, productionId, equipmentId); |
| | | } |
| | | |
| | | @Override |
| | | public void removeEquipmentForDepart(String departId, String equipmentId) { |
| | | mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getDepId, departId).eq(MdcEquipmentDepart::getEquipmentId, equipmentId)); |
| | | } |
| | | |
| | | @Override |
| | | public void removeEquipmentsForDepart(String departId, List<String> equipmentIdList) { |
| | | mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getDepId, departId).in(MdcEquipmentDepart::getEquipmentId, equipmentIdList)); |
| | | } |
| | | |
| | | @Override |
| | | public void removeEquipmentForProduction(String productionId, String equipmentId) { |
| | | mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).eq(MdcProductionEquipment::getEquipmentId, equipmentId)); |
| | | //ç§»é¤è®¾å¤æé |
| | | iDncDevicePermissionService.remove(new LambdaQueryWrapper<DncDevicePermission>().eq(DncDevicePermission::getDeviceId, equipmentId)); |
| | | } |
| | | |
| | | @Override |
| | | public void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList) { |
| | | mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).in(MdcProductionEquipment::getEquipmentId, equipmentIdList)); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcEquipmentTree> loadTreeListByDepart(String userId) { |
| | | //è·åææé¨é¨æ°æ® |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(SysDepart::getDepartOrder)); |
| | | //æ ¹æ®ç¨æ·IDè·åæ¥æçé¨é¨idéå |
| | | List<String> departIds = sysUserDepartService.queryDepartIdsByUserId(userId); |
| | | List<String> allDepartIds = new ArrayList<>(); |
| | | //æ¾å°ææé¨é¨idçä¸çº§id |
| | | if (departIds != null && !departIds.isEmpty()) { |
| | | for (String departId : departIds) { |
| | | this.getAllDepartIds(departList, departId, allDepartIds); |
| | | } |
| | | } |
| | | //è¿æ»¤é¨é¨æ°æ® |
| | | List<SysDepart> list = departList.stream().filter((SysDepart sysDepart) -> allDepartIds.contains(sysDepart.getId())).collect(Collectors.toList()); |
| | | //ç»è£
é¨é¨è®¾å¤æ |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentDepartUtil.wrapEquipmentDepartTreeList(list); |
| | | //å¡«å
è®¾å¤æ°æ® |
| | | FillEquipmentByDepart(treeList); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * é¨é¨è®¾å¤æ å¡«å
è®¾å¤æ°æ® |
| | | * |
| | | * @param treeList |
| | | */ |
| | | private void FillEquipmentByDepart(List<MdcEquipmentTree> treeList) { |
| | | for (MdcEquipmentTree mdcEquipmentTree : treeList) { |
| | | List<MdcEquipment> equipmentList = this.baseMapper.queryByDepartId(mdcEquipmentTree.getKey()); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); |
| | | |
| | | tree.setParentId(mdcEquipmentTree.getKey()); |
| | | mdcEquipmentTree.getChildren().add(tree); |
| | | } |
| | | mdcEquipmentTree.setLeaf(false); |
| | | } |
| | | if (!mdcEquipmentTree.getChildren().isEmpty()) { |
| | | FillEquipmentByDepart(mdcEquipmentTree.getChildren()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åææçé¨é¨idï¼å
嫿æä¸çº§ï¼ |
| | | */ |
| | | private void getAllDepartIds(List<SysDepart> departList, String departId, List<String> allDepartIds) { |
| | | if (!allDepartIds.contains(departId)) { |
| | | allDepartIds.add(departId); |
| | | } |
| | | for (SysDepart sysDepart : departList) { |
| | | if (StringUtils.isEmpty(sysDepart.getParentId())) { |
| | | continue; |
| | | } |
| | | if (departId.equals(sysDepart.getId())) { |
| | | if (!allDepartIds.contains(sysDepart.getParentId())) { |
| | | allDepartIds.add(sysDepart.getParentId()); |
| | | getAllDepartIds(departList, sysDepart.getParentId(), allDepartIds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { |
| | | //è·åææäº§çº¿æ°æ® |
| | | 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<>(); |
| | | //æ¾å°ææäº§çº¿idçä¸çº§id |
| | | if (productionIds != null && !productionIds.isEmpty()) { |
| | | for (String productionId : productionIds) { |
| | | this.getAllProductionIds(productionList, productionId, allProductionIds); |
| | | } |
| | | } |
| | | //è¿æ»¤äº§çº¿æ°æ® |
| | | List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); |
| | | //ç»è£
äº§çº¿è®¾å¤æ |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //å¡«å
è®¾å¤æ°æ® |
| | | FillEquipmentByProduction(treeList); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * 设å¤çæ§å表 |
| | | */ |
| | | @Override |
| | | public List<MdcEquipmentMonitor> queryEquipmentMonitorList(String userId, String key) { |
| | | List<String> equipmentIds = this.getEquipmentIdsProduction(userId, key); |
| | | if (equipmentIds == null || equipmentIds.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<MdcEquipmentMonitor> result = this.baseMapper.checkStatusFromEquipmentIds(equipmentIds); |
| | | if (result != null && !result.isEmpty()) { |
| | | for (MdcEquipmentMonitor mdcEquipmentMonitor : result) { |
| | | if (mdcEquipmentMonitor.getOporation() != null) { |
| | | switch (mdcEquipmentMonitor.getOporation()) { |
| | | case 1: |
| | | case 2: |
| | | mdcEquipmentMonitor.setOporationDict("å¾
æº"); |
| | | break; |
| | | case 3: |
| | | mdcEquipmentMonitor.setOporationDict("è¿è¡"); |
| | | break; |
| | | case 22: |
| | | mdcEquipmentMonitor.setOporationDict("æ¥è¦"); |
| | | break; |
| | | case 5: |
| | | mdcEquipmentMonitor.setOporationDict("æ
é"); |
| | | break; |
| | | default: |
| | | mdcEquipmentMonitor.setOporationDict("å
³æº"); |
| | | break; |
| | | } |
| | | } else { |
| | | mdcEquipmentMonitor.setOporationDict("å
³æº"); |
| | | mdcEquipmentMonitor.setOporation(0); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 设å¤çæ§ - 设å¤è¯¦ç»ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public Map<String, Object> mdcEquipmentDetailedInfo(String id) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | MdcEquipmentDetailedDto mdcEquipmentDetailedDto = this.baseMapper.findById(id); |
| | | result.put("equipment", mdcEquipmentDetailedDto); |
| | | // æ¥è¯¢è®¾å¤ç¶æ |
| | | EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipmentDetailedDto.getEquipmentId()); |
| | | if (equipmentLog == null) { |
| | | return result; |
| | | } |
| | | Integer oporation = equipmentLog.getOporation(); |
| | | //è·å工使°æ®å¹¶åå§å |
| | | String saveTableName = mdcEquipmentDetailedDto.getSaveTableName(); |
| | | Map<String, Object> mapData = equipmentWorkLineService.getDataList(saveTableName); |
| | | if (mapData != null) { |
| | | // Map<String, Object> runData = new LinkedHashMap<>(); |
| | | List<Map<String, Object>> runData = new ArrayList<>(); |
| | | //è·å MDC 驱å¨å¯¹åºçå±ç¤ºåæ° å¹¶æ ¹æ®key æ¼è£
ä» workData æ¥è¯¢çæ°æ® |
| | | List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipmentDetailedDto.getDriveType()); |
| | | if (mdcDriveTypeParamList != null && !mdcDriveTypeParamList.isEmpty()) { |
| | | for (MdcDriveTypeParamConfig mdcDriveTypeParamConfig : mdcDriveTypeParamList) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | String englishName = mdcDriveTypeParamConfig.getEnglishName(); |
| | | String chineseName = mdcDriveTypeParamConfig.getChineseName(); |
| | | map.put("key", chineseName); |
| | | if (mapData.containsKey(englishName)) { |
| | | Object object = mapData.get(englishName); |
| | | String value = ""; |
| | | if ("CollectTime".equals(englishName)) { |
| | | Date date = object == null ? null : (Date) object; |
| | | value = DateUtils.format(date, DateUtils.STR_DATE_TIME_SMALL); |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "AI01".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设å¤çµæµå段AI01 |
| | | value = BigDecimal.valueOf(Math.random() * 15 + 0).setScale(1, RoundingMode.HALF_UP).toString(); |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindlespeed".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设å¤ä¸»è½´è½¬éåæ®µspindlespeed |
| | | value = String.valueOf(((new Random().nextInt(35)) + 1) * 100); |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindleload".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设å¤ä¸»è½´è´è·å段spindleload |
| | | value = String.valueOf(Integer.valueOf(new Random().nextInt(21))); |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindlebeilv".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设å¤ä¸»è½´åçåæ®µspindlebeilv |
| | | value = String.valueOf((new Random().nextInt(13)) * 10); |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "feedbeilv".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设å¤è¿ç»åçåæ®µfeedbeilv |
| | | value = String.valueOf((new Random().nextInt(13)) * 10); |
| | | } else if ("spindle_current".equals(englishName)) { |
| | | // å
¶ä»è®¾å¤çµæµå段 |
| | | String devicePower = mdcEquipmentDetailedDto.getDevicePower(); |
| | | Object spindleload = mapData.get("spindleload"); |
| | | BigDecimal load = spindleload == null ? BigDecimal.ZERO : new BigDecimal(spindleload.toString()); |
| | | if (StringUtils.isNotEmpty(devicePower) && oporation == 3) { |
| | | value = new BigDecimal(devicePower).divide(new BigDecimal("380"), 2, BigDecimal.ROUND_HALF_UP).add(load).toString(); |
| | | } else { |
| | | value = "0"; |
| | | } |
| | | } else if ("torque".equals(englishName)) { |
| | | // æç©å段 |
| | | MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipmentDetailedDto.getEquipmentId()); |
| | | if (mdcTorqueConfig != null) { |
| | | value = String.valueOf(mdcTorqueConfig.getTorqueValue()); |
| | | } else { |
| | | value = "0"; |
| | | } |
| | | } else if ("alarm".equals(englishName)) { |
| | | if (oporation == 22) { |
| | | value = equipmentLog.getAlarm(); |
| | | } else { |
| | | value = "æ "; |
| | | } |
| | | } else if ("alarmContent".equals(englishName)) { |
| | | if (oporation == 22) { |
| | | List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, mdcEquipmentDetailedDto.getDriveType()).eq(MdcAlarmInfo::getAlarmCode, equipmentLog.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0)); |
| | | if (mdcAlarmInfo != null && !mdcAlarmInfo.isEmpty()) { |
| | | value = mdcAlarmInfo.get(0).getAlarmContent(); |
| | | } |
| | | } else { |
| | | value = "æ "; |
| | | } |
| | | } else { |
| | | value = object == null ? "" : object.toString(); |
| | | } |
| | | map.put("value", value); |
| | | runData.add(map); |
| | | if ("spindlebeilv".equals(englishName)) { |
| | | result.put("spindlebeilv", value); |
| | | } |
| | | if ("feedbeilv".equals(englishName)) { |
| | | result.put("feedbeilv", value); |
| | | } |
| | | if ("spindleload".equals(englishName)) { |
| | | result.put("spindleload", value); |
| | | } |
| | | if ("rapidfeed".equals(englishName)) { |
| | | result.put("rapidfeed", value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | result.put("runData", runData); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * éè¿ç¨æ·é¨é¨å
³ç³»è·å设å¤idéå |
| | | */ |
| | | @Override |
| | | public List<String> getEquipmentIdsByDepart(String userId, String key) { |
| | | //è·åææé¨é¨æ°æ® |
| | | List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(SysDepart::getDepartOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æçé¨é¨ä¿¡æ¯éå |
| | | List<String> departIds = sysUserDepartService.queryDepartIdsByUserId(userId); |
| | | List<String> allDepartIds = new ArrayList<>(); |
| | | if (departIds != null && !departIds.isEmpty()) { |
| | | for (String departId : departIds) { |
| | | this.getAllDepartIds(departList, departId, allDepartIds); |
| | | } |
| | | } |
| | | //æ ¹æ®äº§çº¿éåæ¥æ¾ææè®¾å¤id |
| | | if (allDepartIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> equipmentIds = this.baseMapper.queryIdsByDeparts(allDepartIds); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | //keyä¸ä¸ºç©ºï¼æ¥è¯¢ææä¸çº§é¨é¨id |
| | | List<String> partDepart = this.findAllDeparts(key); |
| | | partDepart.add(key); |
| | | //è¿æ»¤æ æéé¨é¨id |
| | | List<String> allDepartIdsByKey = partDepart.stream().filter(allDepartIds::contains).collect(Collectors.toList()); |
| | | equipmentIds = this.baseMapper.queryIdsByDeparts(allDepartIdsByKey); |
| | | } |
| | | return equipmentIds; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶çº§idé彿¥è¯¢ææä¸çº§idéå |
| | | */ |
| | | private List<String> findAllDeparts(String key) { |
| | | List<String> departs = new ArrayList<>(); |
| | | List<SysDepart> sysDeparts = sysDepartService.queryDeptByPid(key); |
| | | if (sysDeparts != null && !sysDeparts.isEmpty()) { |
| | | List<String> ids = sysDeparts.stream().map(SysDepart::getId).collect(Collectors.toList()); |
| | | departs.addAll(ids); |
| | | for (SysDepart sysDepart : sysDeparts) { |
| | | List<String> allDeparts = findAllDeparts(sysDepart.getId()); |
| | | departs.addAll(allDeparts); |
| | | } |
| | | } |
| | | return departs; |
| | | } |
| | | |
| | | /** |
| | | * éè¿ç¨æ·äº§çº¿å
³ç³»è·å设å¤idéå |
| | | */ |
| | | @Override |
| | | public List<String> getEquipmentIdsProduction(String userId, String key) { |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå |
| | | List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); |
| | | List<String> allProductionIds = new ArrayList<>(); |
| | | //æ¾å°ææäº§çº¿idçä¸çº§id |
| | | if (productionIds != null && !productionIds.isEmpty()) { |
| | | for (String productionId : productionIds) { |
| | | this.getAllProductionIds(productionList, productionId, allProductionIds); |
| | | } |
| | | } |
| | | //æ ¹æ®äº§çº¿éåæ¥æ¾ææè®¾å¤id |
| | | if (allProductionIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<String> equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIds); |
| | | if (StringUtils.isNotEmpty(key)) { |
| | | //keyä¸ä¸ºç©ºï¼æ¥è¯¢ææä¸çº§äº§çº¿id |
| | | List<String> partProduction = this.findAllProductions(key); |
| | | partProduction.add(key); |
| | | //è¿æ»¤æ æé产线id |
| | | List<String> allProductionIdsByKey = partProduction.stream().filter(allProductionIds::contains).collect(Collectors.toList()); |
| | | equipmentIds = this.baseMapper.queryIdsByProductions(allProductionIdsByKey); |
| | | } |
| | | return equipmentIds; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è®¾å¤idæ¥è¯¢è®¾å¤åç§° |
| | | */ |
| | | @Override |
| | | public MdcEquipment findEquipmentNameByEquipmentId(String equipmentId) { |
| | | return this.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); |
| | | } |
| | | |
| | | /** |
| | | * éæ©è®¾å¤å页å表 |
| | | */ |
| | | @Override |
| | | public IPage<MdcEquipment> findEquipmentList(Page<MdcEquipment> page, String userId, MdcEquipmentVo mdcEquipment) { |
| | | List<String> equipmentIdsByDepart = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcEquipment.getDepartId())) { |
| | | equipmentIdsByDepart = getEquipmentIdsByDepart(userId, mdcEquipment.getDepartId()); |
| | | } |
| | | List<String> equipmentIdsProduction = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcEquipment.getProductionId())) { |
| | | equipmentIdsProduction = getEquipmentIdsProduction(userId, mdcEquipment.getProductionId()); |
| | | } |
| | | List<String> allEquipments = new ArrayList<>(); |
| | | if (StringUtils.isEmpty(mdcEquipment.getDepartId()) && StringUtils.isEmpty(mdcEquipment.getProductionId())) { |
| | | List<String> idsByDepart = getEquipmentIdsByDepart(userId, null); |
| | | List<String> idsProduction = getEquipmentIdsProduction(userId, null); |
| | | // å»éå¹¶é |
| | | allEquipments = Stream.of(idsByDepart, idsProduction).flatMap(Collection::stream).distinct().collect(Collectors.toList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcEquipment.getDepartId()) && StringUtils.isNotEmpty(mdcEquipment.getProductionId())) { |
| | | // 交é |
| | | allEquipments = equipmentIdsByDepart.stream().filter(equipmentIdsProduction::contains).collect(Collectors.toList()); |
| | | } |
| | | LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.isNotNull(MdcEquipment::getEquipmentId); |
| | | if (StringUtils.isNotEmpty(mdcEquipment.getEquipmentId())) { |
| | | queryWrapper.like(MdcEquipment::getEquipmentId, mdcEquipment.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcEquipment.getEquipmentName())) { |
| | | queryWrapper.like(MdcEquipment::getEquipmentName, mdcEquipment.getEquipmentName()); |
| | | } |
| | | if (!allEquipments.isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, allEquipments); |
| | | } else if (!equipmentIdsByDepart.isEmpty() && equipmentIdsProduction.isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, equipmentIdsByDepart); |
| | | } else if (equipmentIdsByDepart.isEmpty() && !equipmentIdsProduction.isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, equipmentIdsProduction); |
| | | } |
| | | queryWrapper.orderByAsc(MdcEquipment::getEquipmentName); |
| | | return this.baseMapper.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶çº§idé彿¥è¯¢ææä¸çº§idéå |
| | | */ |
| | | private List<String> findAllProductions(String key) { |
| | | List<String> productions = new ArrayList<>(); |
| | | List<MdcProduction> mdcProductions = mdcProductionService.queryProdByPid(key); |
| | | if (mdcProductions != null && !mdcProductions.isEmpty()) { |
| | | List<String> ids = mdcProductions.stream().map(MdcProduction::getId).collect(Collectors.toList()); |
| | | productions.addAll(ids); |
| | | for (MdcProduction mdcProduction : mdcProductions) { |
| | | List<String> allProductions = findAllProductions(mdcProduction.getId()); |
| | | productions.addAll(allProductions); |
| | | } |
| | | } |
| | | return productions; |
| | | } |
| | | |
| | | /** |
| | | * äº§çº¿è®¾å¤æ å¡«å
è®¾å¤æ°æ® |
| | | */ |
| | | private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList) { |
| | | for (MdcEquipmentTree mdcEquipmentTree : treeList) { |
| | | List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey()); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); |
| | | tree.setParentId(mdcEquipmentTree.getKey()); |
| | | tree.setEntity(mdcEquipment); |
| | | tree.setType(2); |
| | | mdcEquipmentTree.getChildren().add(tree); |
| | | } |
| | | mdcEquipmentTree.setLeaf(false); |
| | | } |
| | | if (!mdcEquipmentTree.getChildren().isEmpty()) { |
| | | FillEquipmentByProduction(mdcEquipmentTree.getChildren()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åææç产线idï¼å
嫿æä¸çº§ï¼ |
| | | */ |
| | | private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) { |
| | | if (!allProductionIds.contains(productionId)) { |
| | | allProductionIds.add(productionId); |
| | | } |
| | | for (MdcProduction mdcProduction : productionList) { |
| | | if (StringUtils.isEmpty(mdcProduction.getParentId())) { |
| | | continue; |
| | | } |
| | | if (productionId.equals(mdcProduction.getId())) { |
| | | if (!allProductionIds.contains(mdcProduction.getParentId())) { |
| | | allProductionIds.add(mdcProduction.getParentId()); |
| | | getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿å±çº§æ¥è¯¢è®¾å¤å个 |
| | | */ |
| | | @Override |
| | | public MdcEquipment getEquipmentByPid(String pid, String userId) { |
| | | List<String> idsProduction = this.getEquipmentIdsProduction(userId, pid); |
| | | if (idsProduction != null && !idsProduction.isEmpty()) { |
| | | return super.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, idsProduction.get(0))); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è®¾å¤ç¼å·æ¥è¯¢è®¾å¤ä¿¡æ¯åé¨é¨ä¿¡æ¯ |
| | | * |
| | | * @param equipmentIdList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquDepDto> findEquDepList(List<String> equipmentIdList) { |
| | | return this.baseMapper.findEquDepList(equipmentIdList); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è®¾å¤ç¼å·æ¥è¯¢è®¾å¤ä¿¡æ¯åäº§çº¿ä¿¡æ¯ |
| | | * |
| | | * @param equipmentIdList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquProDto> findEquProList(List<String> equipmentIdList) { |
| | | return this.baseMapper.findEquProList(equipmentIdList); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨å±çº§æ¥è¯¢è®¾å¤å个 |
| | | */ |
| | | @Override |
| | | public MdcEquipment getEquipmentByDepPid(String pid, String userId) { |
| | | List<String> idsByDepart = this.getEquipmentIdsByDepart(userId, pid); |
| | | if (idsByDepart != null && !idsByDepart.isEmpty()) { |
| | | return super.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, idsByDepart.get(0))); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å¤§å±è½¦é´idæ¥è¯¢è®¾å¤å表 |
| | | */ |
| | | @Override |
| | | public IPage<MdcEquipment> getEquipmentByWorkshopId(Page<MdcEquipment> page, WorkshopEquipmentVo workshopEquipmentVo) { |
| | | return this.baseMapper.getEquipmentByWorkshopId(page, workshopEquipmentVo); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> listEquipmentId(MdcEfficiencyReportQueryVo vo) { |
| | | LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (vo.getEquipmentIdList() != null && !vo.getEquipmentIdList().isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, vo.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentType, Arrays.asList(vo.getEquipmentType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDeviceLevel())) { |
| | | queryWrapper.in(MdcEquipment::getDeviceLevel, Arrays.asList(vo.getDeviceLevel().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDriveType())) { |
| | | queryWrapper.in(MdcEquipment::getDriveType, Arrays.asList(vo.getDriveType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDeviceCategory())) { |
| | | queryWrapper.in(MdcEquipment::getDeviceCategory, Arrays.asList(vo.getDeviceCategory().split(","))); |
| | | } |
| | | List<MdcEquipment> list = super.list(queryWrapper); |
| | | // List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList)); |
| | | return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MdcEquipment> pageList(Page<MdcEquipment> page, MdcEquipmentVo mdcEquipment, HttpServletRequest req) { |
| | | if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { |
| | | // é彿¥è¯¢ææåèç¹ |
| | | List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); |
| | | mdcEquipment.setProductionIds(productionIds); |
| | | } |
| | | IPage<MdcEquipment> equipmentIPage= this.baseMapper.pageList(page, mdcEquipment); |
| | | equipmentIPage.getRecords().forEach(item->{ |
| | | if (("1").equals(item.getDeviceTypeDnc())&&("1").equals(item.getDeviceTypeMdc())){ |
| | | item.setSystemValue("3"); |
| | | }else { |
| | | if (("1").equals(item.getDeviceTypeDnc())){ |
| | | item.setSystemValue("1"); |
| | | } |
| | | if (("1").equals(item.getDeviceTypeMdc())){ |
| | | item.setSystemValue("2"); |
| | | } |
| | | } |
| | | }); |
| | | return equipmentIPage; |
| | | } |
| | | |
| | | /** |
| | | * çæ§è®¾å¤è¿è¡åæ°ä»»å¡ |
| | | */ |
| | | @Override |
| | | public void monitoringSpeedProcess() { |
| | | // List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getDriveType, "FANUC")); |
| | | List<MdcEquipment> equipmentList = super.list(); |
| | | //List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, "2140198")); |
| | | |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | List<MdcEquipmentThreshold> mdcEquipmentThresholdList = mdcEquipmentThresholdService.list(new LambdaQueryWrapper<MdcEquipmentThreshold>().eq(MdcEquipmentThreshold::getControlSystemType, mdcEquipment.getDriveType())); |
| | | if (mdcEquipmentThresholdList != null && !mdcEquipmentThresholdList.isEmpty()) { |
| | | String saveTableName = mdcEquipment.getSaveTableName(); |
| | | StringBuilder builder = new StringBuilder(); |
| | | for (MdcEquipmentThreshold mdcEquipmentThreshold : mdcEquipmentThresholdList) { |
| | | builder.append(",").append(mdcEquipmentThreshold.getEnglishName()).append(" as \"").append(mdcEquipmentThreshold.getEnglishName()).append("\" "); |
| | | } |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("columns", builder.toString()); |
| | | param.put("tableName", saveTableName); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | map = this.baseMapper.getWorkLineLast(param); |
| | | } catch (Exception e) { |
| | | log.error("æ¥è¯¢åè¡¨æ°æ®åºå·®ï¼", e); |
| | | } |
| | | if (!map.isEmpty()) { |
| | | for (MdcEquipmentThreshold mdcEquipmentThreshold : mdcEquipmentThresholdList) { |
| | | Integer actualValue = Integer.valueOf(map.get(mdcEquipmentThreshold.getEnglishName()).toString()); |
| | | Integer max = mdcEquipmentThreshold.getMaxThreshold(); |
| | | Integer min = mdcEquipmentThreshold.getMinThreshold(); |
| | | MessageDTO messageDTO = new MessageDTO(); |
| | | messageDTO.setTitle("设å¤" + mdcEquipmentThreshold.getChineseName() + "æ¥è¦ï¼"); |
| | | messageDTO.setCategory("é¢è¦æ¶æ¯"); |
| | | messageDTO.setFromUser("admin"); |
| | | messageDTO.setToUser("admin"); |
| | | MdcOverrunAlarm mdcOverrunAlarm = new MdcOverrunAlarm(); |
| | | mdcOverrunAlarm.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | mdcOverrunAlarm.setSetValue(min + "-" + max); |
| | | mdcOverrunAlarm.setRealValue(actualValue.toString()); |
| | | if (actualValue > max) { |
| | | // é« |
| | | messageDTO.setContent("设å¤ç¼å·ä¸º [" + mdcEquipment.getEquipmentId() + "] ç设å¤" + mdcEquipmentThreshold.getChineseName() + "髿¥è¦ï¼"); |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "髿¥è¦"); |
| | | mdcOverrunAlarmService.save(mdcOverrunAlarm); |
| | | } else if (actualValue < min) { |
| | | // ä½ |
| | | messageDTO.setContent("设å¤ç¼å·ä¸º [" + mdcEquipment.getEquipmentId() + "] ç设å¤" + mdcEquipmentThreshold.getChineseName() + "使¥è¦ï¼"); |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "使¥è¦"); |
| | | mdcOverrunAlarmService.save(mdcOverrunAlarm); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 导åºlist |
| | | * |
| | | * @param mdcEquipment |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> exportXlsList(MdcEquipmentVo mdcEquipment) { |
| | | if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { |
| | | // é彿¥è¯¢ææåèç¹ |
| | | List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); |
| | | mdcEquipment.setProductionIds(productionIds); |
| | | } |
| | | return this.baseMapper.exportXlsList(mdcEquipment); |
| | | } |
| | | |
| | | /** |
| | | * éè¿è½¦é´idsè·åè®¾å¤æ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { |
| | | List<String> productionIds = Arrays.asList(ids.split(",")); |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | List<String> allProductionIds = new ArrayList<>(); |
| | | //æ¾å°ææäº§çº¿idçä¸çº§id |
| | | if (!productionIds.isEmpty()) { |
| | | for (String productionId : productionIds) { |
| | | this.getAllProductionIds(productionList, productionId, allProductionIds); |
| | | } |
| | | } |
| | | //è¿æ»¤äº§çº¿æ°æ® |
| | | List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); |
| | | //ç»è£
äº§çº¿è®¾å¤æ |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //å¡«å
è®¾å¤æ°æ® |
| | | FillEquipmentByProduction(treeList); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åè¡¨æ°æ® |
| | | * |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MdcEquipmentDto getWorkLineLast(String tableName) { |
| | | try { |
| | | return this.baseMapper.findWorkLineLast(tableName); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> listEquipmentIdShift(MdcEfficiencyReportShiftQueryVo vo) { |
| | | LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (vo.getEquipmentIdList() != null && !vo.getEquipmentIdList().isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, vo.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentType, Arrays.asList(vo.getEquipmentType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDeviceLevel())) { |
| | | queryWrapper.in(MdcEquipment::getDeviceLevel, Arrays.asList(vo.getDeviceLevel().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDriveType())) { |
| | | queryWrapper.in(MdcEquipment::getDriveType, Arrays.asList(vo.getDriveType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDeviceCategory())) { |
| | | queryWrapper.in(MdcEquipment::getDeviceCategory, Arrays.asList(vo.getDeviceCategory().split(","))); |
| | | } |
| | | List<MdcEquipment> list = super.list(queryWrapper); |
| | | // List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList)); |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿idéååé
éå°ç»æ¥è¯¢è®¾å¤å表 |
| | | * @param mdcProductionIds |
| | | * @param teamCodeList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> findByProIdsAndTeamCode(List<String> mdcProductionIds, List<String> teamCodeList) { |
| | | return this.baseMapper.findByProIdsAndTeamCode(mdcProductionIds, teamCodeList); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿idéåå设å¤ç±»åæ¥è¯¢è®¾å¤å表 |
| | | * @param allProductionIds |
| | | * @param typeList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> findByProIdsAndType(List<String> allProductionIds, List<String> typeList) { |
| | | return this.baseMapper.findByProIdsAndType(allProductionIds, typeList); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcEquipment> getEquipmentList() { |
| | | |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | if (StringUtils.isNotEmpty(user.getEquipmentIds())) { |
| | | return this.baseMapper.selectList(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getEquipmentId, Arrays.asList(user.getEquipmentIds().split(StringPool.COMMA)))); |
| | | } |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå |
| | | List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); |
| | | List<String> allProductionIds = new ArrayList<>(); |
| | | //æ¾å°ææäº§çº¿idçä¸çº§id |
| | | if (productionIds != null && !productionIds.isEmpty()) { |
| | | for (String productionId : productionIds) { |
| | | this.getAllProductionIds(productionList, productionId, allProductionIds); |
| | | } |
| | | } |
| | | //æ ¹æ®äº§çº¿éåæ¥æ¾ææè®¾å¤id |
| | | if (allProductionIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<MdcEquipment> equipmentIds = this.baseMapper.getEquipmentList(allProductionIds); |
| | | return equipmentIds; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getEquIdsByProIds(List<String> proIds) { |
| | | return this.baseMapper.getEquIdsByProIds(proIds); |
| | | } |
| | | |
| | | } |