| | |
| | | import com.alibaba.excel.write.merge.AbstractMergeStrategy; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.qianwen.core.mp.support.Query; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.secure.utils.AuthUtil; |
| | | import com.qianwen.core.tool.utils.CollectionUtil; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.core.tool.utils.StringUtil; |
| | | import com.qianwen.license.common.LicenseExtraModel; |
| | | import com.qianwen.license.common.LicenseVerify; |
| | | import com.qianwen.smartman.common.cache.DictCache; |
| | | import com.qianwen.smartman.common.cache.cps.WorkstationCache; |
| | | import com.qianwen.smartman.common.constant.CalendarConstant; |
| | |
| | | import com.qianwen.smartman.common.enums.DictEnum; |
| | | import com.qianwen.smartman.common.enums.StatusType; |
| | | import com.qianwen.smartman.common.enums.WcsDataTypeEnums; |
| | | import com.qianwen.smartman.common.license.LicenseWrapper; |
| | | import com.qianwen.smartman.common.mqtt.MqttMessageSender; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | |
| | | private MqttMessageSender mqttMsgSender; |
| | | @Autowired |
| | | private WorkstationDatapointsService wsDpService; |
| | | @Autowired |
| | | private LicenseWrapper licenseWrapper; |
| | | @Autowired |
| | | private WorkstationDatapointsService dataPointService; |
| | | |
| | | private final String NAME = "默认工作台"; |
| | | private final Integer SORT = 1; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public WorkstationVO submit(WorkstationSubmitVO workstationSubmitVO) { |
| | | |
| | | checkLicenseCount(); |
| | | |
| | | checkWorkstation(workstationSubmitVO); |
| | | if (Func.isEmpty(workstationSubmitVO.getId())) { |
| | | checkUnableWorkstation(workstationSubmitVO); |
| | |
| | | |
| | | } |
| | | return workstationVO; |
| | | } |
| | | |
| | | /** |
| | | * 验证许可中配置的设备数量 |
| | | */ |
| | | void checkLicenseCount() { |
| | | |
| | | Wrapper<Workstation> wrapper = Wrappers.lambdaQuery(Workstation.class).eq(Workstation::getIsDeleted, 0); |
| | | Long count = workstationMapper.selectCount(wrapper); |
| | | |
| | | |
| | | Long machineAmount = licenseWrapper.getWorkstationAmount(); |
| | | if(count >= machineAmount) { |
| | | throw new ServiceException("工位数超过许可上限数:"+ machineAmount); |
| | | } |
| | | } |
| | | /* |
| | | private void submitWorkstationFtpDirectory(WorkstationSubmitVO workstationSubmitVO, Workstation workstation) { |
| | |
| | | this.workstationWcsService.deleteByWorkstationIdList(workstationIds); |
| | | this.workstationOfMachineService.remove(Wrappers.<WorkstationOfMachine>lambdaQuery().in(WorkstationOfMachine::getWorkstationId, workstationIds)); |
| | | this.commonGroupOfItemService.remove(Wrappers.<CommonGroupOfItem>lambdaQuery().in(CommonGroupOfItem::getItemId, workstationIds)); |
| | | |
| | | //20250324新增,删除工位对应的数据点位配置。 |
| | | dataPointService.removeByWorkstation(workstationIds); |
| | | /* |
| | | this.workstationOfMachineService.remove((Wrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getWorkstationId(); |
| | |
| | | return String.valueOf(item.getId()); |
| | | }).collect(Collectors.toList())); |
| | | } |
| | | List<WorkstationVO> workstationVOS = this.workstationMapper.listPage(workStationGroupIdList, workstationVOIPage, keyWord, groupId, CommonGroupConstant.ALL_WORKSTATION_ID, status == null ? CommonConstant.ENABLE : status, type, Integer.valueOf(LocalDate.now().getYear())); |
| | | List<WorkstationVO> workstationVOS = this.workstationMapper.listPage(workStationGroupIdList, workstationVOIPage, keyWord, groupId, CommonGroupConstant.ALL_WORKSTATION_ID, status, type, LocalDate.now().getYear()); |
| | | workstationVOS.forEach(workstationVO -> { |
| | | String calendarName = workstationVO.getCalendarName(); |
| | | if (Func.isBlank(calendarName)) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Boolean deleteGroup(Long groupId) { |
| | | commonGroupOfItemService.lambdaUpdate().set(CommonGroupOfItem::getGroupId,CommonGroupConstant.DEFAULT_GROUP_ID) |
| | | .eq(CommonGroupOfItem::getGroupId, groupId).update(); |
| | | |
| | | if (this.commonGroupOfItemService.count(Lambda.eq(CommonGroupOfItem::getGroupId, groupId)) > 0) { |
| | | throw new ServiceException(MessageUtils.message("cps.common.group.production.line.delete.fail", new Object[0])); |
| | | } |
| | |
| | | @Override |
| | | public IPage<WorkstationRealTimeStatusVO> getRealTimeStatus(WorkstationRealTimeStatusDTO dto, Query query) { |
| | | List<String> workStationGroupIdList = dto.getWorkStationGroupIdList(); |
| | | if (workStationGroupIdList.size() == 1) { |
| | | if (workStationGroupIdList !=null && workStationGroupIdList.size() == 1) { |
| | | List<String> workStationGroupIdByParentList = getCommonGroupIds(workStationGroupIdList, new ArrayList<>()).stream().map(item -> { |
| | | return String.valueOf(item.getId()); |
| | | }).collect(Collectors.toList()); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取实时数据展示的数据点列表 |
| | | * @param workstationIdList 工位id集合 |
| | | * @return map(工位id -> 数据点集合) |
| | | */ |
| | | public Map<Long, List<RealTimeStatusVO>> getRealTimeProperties(List<Long> workstationIdList) { |
| | | Map<Long, List<RealTimeStatusVO>> properties = new HashMap<>(); |
| | | |
| | |
| | | WorkstationDatapointsVO dpVO = wsDpService.getDatapoints(workstationId); |
| | | if(dpVO!=null && ObjectUtil.isNotEmpty(dpVO.getDpHead())) { |
| | | |
| | | String prop,label; |
| | | String prop; |
| | | JSONArray dpCfgJson = JSONArray.parseArray(dpVO.getDpConfig()); |
| | | for(int i=0;i<dpCfgJson.size();i++) { |
| | | cfgRow = dpCfgJson.getJSONObject(i); |
| | |
| | | |
| | | @Override |
| | | public IPage<Workstation> listWorkStationOnShiftIndex(List<String> ids, LocalDate localDate, Query query, Integer shift, Integer type) { |
| | | return ((WorkstationMapper) this.baseMapper).listWorkStationOnShiftIndex(Condition.getPage(query), Integer.valueOf(localDate.getYear()), DateUtil.formatDate(localDate), shift, type, ids); |
| | | return this.baseMapper.listWorkStationOnShiftIndex(Condition.getPage(query), localDate.getYear(), DateUtil.formatDate(localDate), shift, type, ids); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | private IPage<WorkstationRealTimeStatusVO> manualBuildIPage(Query query, List<WorkstationRealTimeStatusVO> result) { |
| | | Page<WorkstationRealTimeStatusVO> page = new Page<>(query.getCurrent().intValue(), query.getSize().intValue(), result.size()); |
| | | Page<WorkstationRealTimeStatusVO> page = new Page<>(query.getCurrent(), query.getSize(), result.size()); |
| | | if (result.size() == 0) { |
| | | return page; |
| | | } |
| | | if (query.getSize().intValue() == -1) { |
| | | if (query.getSize() == -1) { |
| | | page.setRecords(result); |
| | | } else if (result.size() < ((query.getCurrent().intValue() - 1) * query.getSize().intValue()) + query.getSize().intValue()) { |
| | | page.setRecords(result.subList((query.getCurrent().intValue() - 1) * query.getSize().intValue(), result.size())); |
| | | } else if (result.size() < ((query.getCurrent() - 1) * query.getSize()) + query.getSize()) { |
| | | page.setRecords(result.subList((query.getCurrent() - 1) * query.getSize(), result.size())); |
| | | } else { |
| | | page.setRecords(result.subList((query.getCurrent().intValue() - 1) * query.getSize().intValue(), ((query.getCurrent().intValue() - 1) * query.getSize().intValue()) + query.getSize().intValue())); |
| | | page.setRecords(result.subList((query.getCurrent() - 1) * query.getSize(), ((query.getCurrent() - 1) * query.getSize()) + query.getSize())); |
| | | } |
| | | return page; |
| | | } |
| | |
| | | return dataList; |
| | | } |
| | | //TODO,格式太差 |
| | | Map<Long, List<RealTimeStatusVO>> realTimePropertiesMap = getRealTimeProperties( list.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList())); |
| | | Map<Long, List<RealTimeStatusVO>> realTimePropertiesMap = getRealTimeProperties( list.stream().map(WorkstationRealTimeStatusVO::getId).collect(Collectors.toList())); |
| | | |
| | | return list.stream().filter(i -> { |
| | | boolean filter = Boolean.TRUE.booleanValue(); |
| | | boolean filter = true; |
| | | |
| | | if (Func.isEmpty(i.getMachineId())) { |
| | | filter = false; |
| | | } |