From 537d302507bf5bdc6f6b81ece701abb6e8b6a1e1 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 20 十一月 2025 17:26:39 +0800
Subject: [PATCH] 工位改为默认查询所有状态
---
smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java | 139 +++++++++++++++++++---------------------------
1 files changed, 57 insertions(+), 82 deletions(-)
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java
index cde5f80..982bd70 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java
@@ -29,6 +29,7 @@
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;
@@ -42,10 +43,11 @@
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;
@@ -59,6 +61,7 @@
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;
@@ -87,7 +90,6 @@
import com.qianwen.smartman.modules.smis.service.ICalendarService;
import com.qianwen.smartman.modules.smis.service.ICommonGroupOfItemService;
import com.qianwen.smartman.modules.smis.service.ICommonGroupService;
-import com.qianwen.smartman.modules.smis.service.IDmpVariablesService;
import com.qianwen.smartman.modules.smis.service.IMachineService;
import com.qianwen.smartman.modules.smis.service.IWorkstationOfMachineService;
import com.qianwen.smartman.modules.smis.service.IWorkstationService;
@@ -135,8 +137,7 @@
private WorkstationMapper workstationMapper;
@Autowired
private OssBuilder ossBuilder;
- @Autowired
- private IDmpVariablesService dmpVariablesService;
+
@Autowired
private IWorkstationWorkbenchService workbenchService;
@@ -149,6 +150,10 @@
private MqttMessageSender mqttMsgSender;
@Autowired
private WorkstationDatapointsService wsDpService;
+ @Autowired
+ private LicenseWrapper licenseWrapper;
+ @Autowired
+ private WorkstationDatapointsService dataPointService;
private final String NAME = "榛樿宸ヤ綔鍙�";
private final Integer SORT = 1;
@@ -188,6 +193,9 @@
@Override
@Transactional(rollbackFor = {Exception.class})
public WorkstationVO submit(WorkstationSubmitVO workstationSubmitVO) {
+
+ checkLicenseCount();
+
checkWorkstation(workstationSubmitVO);
if (Func.isEmpty(workstationSubmitVO.getId())) {
checkUnableWorkstation(workstationSubmitVO);
@@ -215,7 +223,7 @@
submitWorkstationWorkbench(workstationSubmitVO, workstation);
WorkstationCache.clearWorkstationCache();
WorkstationCache.clearWorkstationRealTime(workstation.getId());
- CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE);
+ CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE);
CacheUtil.clear(ExtCacheConstant.POSTING_MACHINE, Boolean.FALSE);
CacheUtil.clear(ExtCacheConstant.WORKSTATION_MACHINE, Boolean.FALSE);
String redisKey = ExtCacheConstant.CPS_CACHE.concat(":").concat(":").concat(WorkstationCache.CRC);
@@ -230,6 +238,21 @@
}
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) {
@@ -358,6 +381,9 @@
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();
@@ -366,14 +392,14 @@
return v0.getItemId();
}, workstationIds));*/
WorkstationCache.clearWorkstationCache();
- CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE);
+ CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE);
CacheUtil.clear(ExtCacheConstant.POSTING_MACHINE, Boolean.FALSE);
CacheUtil.clear(ExtCacheConstant.WORKSTATION_MACHINE, Boolean.FALSE);
CacheUtil.clear(redisKey, Boolean.FALSE);
}
changeStatus(workstationIds, CommonConstant.DEACTIVATE);
WorkstationCache.clearWorkstationCache();
- CacheUtil.clear(ExtCacheConstant.POSTING_WORKSTATION, Boolean.FALSE);
+ CacheUtil.clear(ExtCacheConstant.COLLECT_WORKSTATION, Boolean.FALSE);
CacheUtil.clear(ExtCacheConstant.POSTING_MACHINE, Boolean.FALSE);
CacheUtil.clear(ExtCacheConstant.WORKSTATION_MACHINE, Boolean.FALSE);
CacheUtil.clear(redisKey, Boolean.FALSE);
@@ -389,7 +415,7 @@
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)) {
@@ -579,7 +605,7 @@
@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());
@@ -589,65 +615,16 @@
return manualBuildIPage(query, buildProperties(result, dto.getDeviceStatus()));
}
- @Override
- public List<RealTimeStatusVO> getRealTimeProperties(Long workstationId, Long machineId) {
- List<RealTimeStatusVO> properties = new ArrayList<>();
- Map<String, Object> map = WorkstationCache.getWorkstationRealTime(String.valueOf(workstationId));
- List<DmpVariablesVO> list = this.dmpVariablesService.getDmpVariablesByWorkstationId(workstationId);
- if (CollectionUtil.isNotEmpty(list)) {
- list.forEach(dmpVariablesVO -> {
- RealTimeStatusVO vo = new RealTimeStatusVO();
- vo.setKey(dmpVariablesVO.getName());
- vo.setName(dmpVariablesVO.getDescription());
- vo.setUnit(dmpVariablesVO.getDmpType());
- vo.setSort(dmpVariablesVO.getIdx());
- vo.setWcsDataType(dmpVariablesVO.getWcsDataType());
- vo.setBigScreen(dmpVariablesVO.getBigScreen());
- vo.setRealTimeData(dmpVariablesVO.getRealTimeData());
- if (map.containsKey(dmpVariablesVO.getName())) {
- TelemetryDataResponseDTO t = (TelemetryDataResponseDTO) MapUtils.getObject(map, dmpVariablesVO.getName());
- vo.setValue(t.getV());
- }
- properties.add(vo);
- });
- }
- return properties;
- }
+
+ /**
+ * 鑾峰彇瀹炴椂鏁版嵁灞曠ず鐨勬暟鎹偣鍒楄〃
+ * @param workstationIdList 宸ヤ綅id闆嗗悎
+ * @return map(宸ヤ綅id -> 鏁版嵁鐐归泦鍚�)
+ */
public Map<Long, List<RealTimeStatusVO>> getRealTimeProperties(List<Long> workstationIdList) {
Map<Long, List<RealTimeStatusVO>> properties = new HashMap<>();
- //鍦ㄨ繖閲岋紒锛侊紒锛�
- //椤堕《椤堕《
- //List<DmpVariablesVO> list = this.dmpVariablesService.getDmpVariablesByWorkstationIds(workstationIdList);
- //this.wsDpService.getDatapointsByWorkstationIds();
- //if (Func.isNotEmpty(list)) {
- /*
- Map<Long, List<DmpVariablesVO>> dmpVariablesMap =list.stream().collect(Collectors.groupingBy((v0) -> {
- return v0.getWorkstationId();
- }));
- dmpVariablesMap.forEach((workstationId, dmpVariablesVOList) -> {
- ArrayList<RealTimeStatusVO> arrayList = new ArrayList<>();
- Map<String, Object> map = WorkstationCache.getWorkstationRealTime(String.valueOf(workstationId));//搴旇鏈夋暟鎹紝鍥犱负缂撳瓨娌℃湁锛岀洿鎺ユ煡鐨剄ueryLastParameter
- dmpVariablesVOList.forEach(dmpVariablesVO -> {
- RealTimeStatusVO vo = new RealTimeStatusVO();
- vo.setKey(dmpVariablesVO.getName());
- vo.setName(dmpVariablesVO.getDescription());
- vo.setUnit(dmpVariablesVO.getDmpType());
- vo.setSort(dmpVariablesVO.getIdx());
- vo.setWcsDataType(dmpVariablesVO.getWcsDataType());
- vo.setBigScreen(dmpVariablesVO.getBigScreen());
- vo.setRealTimeData(dmpVariablesVO.getRealTimeData());
- if (map.containsKey(dmpVariablesVO.getName())) {
- TelemetryDataResponseDTO t = (TelemetryDataResponseDTO) MapUtils.getObject(map, dmpVariablesVO.getName());
- vo.setValue(t.getV());
- }
- arrayList.add(vo);
- });
- properties.put(workstationId, arrayList);
- });
- */
-
- //}
+
//yangys淇敼锛屾敼涓烘暟鎹偣浣嶇殑鏂瑰紡
for(Long workstationId: workstationIdList) {
@@ -659,7 +636,7 @@
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);
@@ -667,7 +644,7 @@
RealTimeStatusVO vo = new RealTimeStatusVO();
prop = cfgRow.getString("dpName");
vo.setKey(prop);
-
+ /*
label = prop;
if(StringUtils.equals("DeviceStatus", prop)) {
label = "鐘舵��";
@@ -675,11 +652,9 @@
label = "浜ч噺";
}else if(StringUtils.equals("AlarmNo", prop)) {
label = "鍛婅鍙�";
- }
- vo.setName(label);
- //vo.setUnit(headRow.getString("dpUnit"));
+ }*/
+ vo.setName(cfgRow.getString("dpLabel"));
vo.setSort(i);
- //vo.setWcsDataType(dmpVariablesVO.getWcsDataType());
vo.setBigScreen(false);
vo.setRealTimeData(true);
@@ -698,7 +673,7 @@
@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
@@ -1041,7 +1016,7 @@
}
return null;
}
-
+ /*
@Override
public List<DmpVariablesVO> getDmpVariables(String workstationId, String machineId) {
if (Func.isBlank(machineId)) {
@@ -1052,6 +1027,7 @@
return v0.getRealTimeData();
}).collect(Collectors.toList());
}
+ */
private void checkWorkstation(WorkstationSubmitVO workstationSubmitVO) {
if (Func.isNotEmpty(workstationSubmitVO.getCode()) && workstationSubmitVO.getCode().length() > 24) {
@@ -1198,16 +1174,16 @@
}
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;
}
@@ -1218,12 +1194,11 @@
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;
}
--
Gitblit v1.9.3