From 1e8e849c1cbd576dde8dc01efc63f80cf602e2eb Mon Sep 17 00:00:00 2001 From: Fancy <Fancy.fx@outlook.com> Date: 星期六, 06 七月 2024 10:00:00 +0800 Subject: [PATCH] station name can not have the same name --- pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java | 131 +++++++++++++++++++++++++++++-------------- 1 files changed, 89 insertions(+), 42 deletions(-) diff --git a/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java b/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java index b01da47..6ed248b 100644 --- a/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java +++ b/pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java @@ -9,6 +9,7 @@ import com.dy.pmsGlobal.daoSta.StaAssemblyWorkHistoryMapper; import com.dy.pmsGlobal.daoSta.StaAssemblyWorkLastMapper; import com.dy.pmsGlobal.pojoBa.BaUser; +import com.dy.pmsGlobal.pojoPlt.PltProduct; import com.dy.pmsGlobal.pojoPlt.PltStation; import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan; import com.dy.pmsGlobal.pojoPr.PrProductionNode; @@ -120,42 +121,6 @@ return stationInfo; } - public StaAssemblyWorkLast checkStationUsed(String id) { - StaAssemblyWorkLast result = new StaAssemblyWorkLast(); - PltStation stationInfo = null; - if (StringUtils.isBlank(id)) { - throw new RuntimeException("宸ョ珯缂栫爜涓嶈兘涓虹┖,璇锋鏌�"); - } - stationInfo = getStationInfo(id); - //妫�鏌ヨ〃涓璼tationId鏄惁宸茬粡瀛樺湪 - StaAssemblyWorkLast param = new StaAssemblyWorkLast(); - param.setStationId(stationInfo.getId()); - param.setStatus(STATUS_NORMAL); - List<StaAssemblyWorkLast> workLasts = assemblyWorkLastDao.selectList(param); - if (workLasts.size() > 0) { - BeanUtils.copyProperties(workLasts.get(0), result); - //鏍¢獙planId processId nodeId - PrAssemblyPlan assyPlan = assemblyDao.selectByPrimaryKey(workLasts.get(0).getPlanId()); - if (assyPlan == null) { - //鐩存帴鍒犻櫎璁板綍 - logout(workLasts.get(0).getId().toString()); - } - boolean hasNodeId = assyPlan.getProcess().getNodes().stream() - .anyMatch(node -> node.id.equals(workLasts.get(0).getNodeId())); - if (!hasNodeId) { - //鐩存帴鍒犻櫎璁板綍 - logout(workLasts.get(0).getId().toString()); - } else { - result.setPlan(assyPlan); - } - } - result.setStationId(stationInfo.getId()); - result.setStationName(stationInfo.getName()); - result.setLineId(stationInfo.getLineId()); - result.setLineName(stationInfo.getLineName()); - return result; - } - public StaAssemblyWorkLast checkUserAndStationUsed(QueryVo vo) { StaAssemblyWorkLast result = new StaAssemblyWorkLast(); PltStation stationInfo = null; @@ -204,6 +169,80 @@ return result; } + public StaAssemblyWorkLast getWorkLast(String workId) { + StaAssemblyWorkLast result = assemblyWorkLastDao.selectByPrimaryKey(Long.parseLong(workId)); + if (result == null) { + return null; + } + BaUser userInfo = getUserInfo(result.getUserId().toString()); + PltStation stationInfo = getStationInfo(result.getStationId().toString()); + //鏍¢獙planId processId nodeId + PrAssemblyPlan assyPlan = assemblyDao.selectByPrimaryKey(result.getPlanId()); + boolean hasNodeId = assyPlan.getProcess().getNodes().stream() + .anyMatch(node -> node.id.equals(result.getNodeId())); + if (userInfo == null || stationInfo == null || assyPlan == null || (!hasNodeId)) { + //鐩存帴鍒犻櫎璁板綍 + logout(result.getId().toString()); + result.setId(null); + if(userInfo == null){ + result.setUserId(null); + result.setUserName(""); + } + if(stationInfo == null){ + result.setStationId(null); + result.setStationName(""); + } + if(assyPlan == null){ + result.setPlanId(null); + result.setPlanName(""); + } + if(!hasNodeId){ + result.setNodeId(null); + result.setNodeName(""); + } + return result; + }else { + result.setPlanName(assyPlan.getName()); + result.setProcessName(assyPlan.getProcessName()); + result.setNodeName(assyPlan.getProcess().getNodes().get(0).getContent()); + //鎵惧埌瀵瑰簲鐨勪骇鍝佷俊鎭� + PltProduct product = productDao.selectByPrimaryKey(assyPlan.getProId()); + if (product != null) { + result.setProId(product.getId()); + result.setProName(product.getName()); + String devicePrefix = "110" + product.getCode() + assyPlan.getBatchNo(); + result.setDevicePrefix(devicePrefix); + } + } + result.setStationId(stationInfo.getId()); + result.setStationName(stationInfo.getName()); + result.setLineId(stationInfo.getLineId()); + result.setLineName(stationInfo.getLineName()); + return result; + } + + public StaAssemblyWorkLast checkStationUsed(String stationId) { + StaAssemblyWorkLast result = new StaAssemblyWorkLast(); + PltStation stationInfo = null; + if (StringUtils.isBlank(stationId)) { + throw new RuntimeException("宸ョ珯缂栫爜涓嶈兘涓虹┖,璇锋鏌�"); + } + stationInfo = getStationInfo(stationId); + //妫�鏌ヨ〃涓璼tationId鏄惁宸茬粡瀛樺湪 + StaAssemblyWorkLast param = new StaAssemblyWorkLast(); + param.setStationId(stationInfo.getId()); + param.setStatus(STATUS_NORMAL); + List<StaAssemblyWorkLast> workLasts = assemblyWorkLastDao.selectList(param); + if (workLasts.size() > 0) { + result = getWorkLast(workLasts.get(0).getId().toString()); + } + result.setStationId(stationInfo.getId()); + result.setStationName(stationInfo.getName()); + result.setLineId(stationInfo.getLineId()); + result.setLineName(stationInfo.getLineName()); + return result; + } + @Transactional public StaAssemblyWorkLast save(QueryVo vo) { //鍏坈heck @@ -219,7 +258,7 @@ throw new RuntimeException("鑺傜偣淇℃伅鏈夎鎴栬鍏朵粬浜哄憳淇敼,璇烽噸鏂伴�夋嫨鑺傜偣淇℃伅"); } - //鎬庝箞灏嗗彧鍖呭惈杩欎釜鑺傜偣鐨勪俊鎭叏閮ㄥ洖浼犲憿 + //鏁版嵁閫愪釜灏佽杩斿洖 vo.setLineId(checkResult.getLineId()); StaAssemblyWorkLast staLast = new StaAssemblyWorkLast(); BeanUtils.copyProperties(vo, staLast); @@ -227,7 +266,7 @@ staLast.setStationId(checkResult.getStationId()); int count = 0; if (checkResult.getId() == null) { - BeanUtils.copyProperties(vo, staLast); + BeanUtils.copyProperties(vo, staLast);//vo鎷疯礉鍒皊taLast staLast.setUserId(checkResult.getUserId()); staLast.setStationId(checkResult.getStationId()); staLast.setStatus(STATUS_NORMAL); @@ -249,8 +288,18 @@ StaAssemblyWorkLast result = assemblyWorkLastDao.selectByPrimaryKey(staLast.getId()); List<PrProductionNode> nodeInfo = assyPlan.getProcess().getNodes().stream() .filter(node -> node.id.equals(vo.getNodeId())).collect(Collectors.toList()); - assyPlan.getProcess().setNodes(nodeInfo); - result.setPlan(assyPlan); + result.setPlanName(assyPlan.getName()); + result.setProcessName(assyPlan.getProcessName()); + result.setNodeName(assyPlan.getProcess().getNodes().get(0).getContent()); + //鎵惧埌瀵瑰簲鐨勪骇鍝佷俊鎭� + PltProduct product = productDao.selectByPrimaryKey(assyPlan.getProId()); + if (product == null) { + throw new RuntimeException("浜у搧淇℃伅鏈夎鎴栬鍏朵粬浜哄憳淇敼,璇风櫥褰曠鐞嗙郴缁熸煡鐪嬩换鍔″叧鑱斾骇鍝両D涓�:" + assyPlan.getProId()); + } + result.setProId(product.getId()); + result.setProName(product.getName()); + String devicePrefix = "110" + product.getCode() + assyPlan.getBatchNo(); + result.setDevicePrefix(devicePrefix); return result; } @@ -370,6 +419,4 @@ List<BaUser> assistantList = baUserDao.selectByAssistants(workLast.getAssistants()); return assistantList; } - - } \ No newline at end of file -- Gitblit v1.8.0