From 1d27648989e69042db607d14c474d9ea90f86d7b Mon Sep 17 00:00:00 2001 From: Fancy <Fancy.fx@outlook.com> Date: 星期五, 19 七月 2024 14:39:33 +0800 Subject: [PATCH] lineName change --- pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/workOrder/WorkOrderSv.java | 104 +++++++++++++++++++++++++++++++--------------------- 1 files changed, 62 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 58a8910..43c43f0 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 @@ -15,6 +15,7 @@ import com.dy.pmsGlobal.pojoPr.PrProductionNode; import com.dy.pmsGlobal.pojoSta.StaAssemblyWorkHistory; import com.dy.pmsGlobal.pojoSta.StaAssemblyWorkLast; +import com.dy.pmsGlobal.util.QrCodeConstant; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -32,6 +33,11 @@ private static final int STATUS_WORK_LAST_LOGOUT = 2; private static final int STATUS_REPAIR = 3; private static final int STATUS_WASTE = 4; + + private static final String WORK_TYPE_ASSEMBLY = "1"; + private static final String WORK_TYPE_TEST = "2"; + private static final String WORK_TYPE_INSPECTION = "3"; + private static final String WORK_TYPE_REPAIR = "4"; private static final String USER_PREFIX = "101"; private static final String STATION_PREFIX = "103"; @@ -155,11 +161,16 @@ if (workLasts.size() > 0) { List<StaAssemblyWorkLast> userStationList = workLasts.stream().filter(item -> userId == item.getUserId()).collect(Collectors.toList()); if (userStationList.size() == 0) { - throw new RuntimeException("鍛樺伐(" + workLasts.get(0).getUserName() + ")缂栫爜:" + workLasts.get(0).getUserId() + "宸茬粡缁戝畾璇ュ伐绔�(" + workLasts.get(0).getStationName() + ")缂栫爜:" + workLasts.get(0).getStationId() + ".璇峰厛璁╁叾瑙g粦"); + //鍒犻櫎宸ョ珯鐧诲綍淇℃伅 + for (int i = 0; i < workLasts.size(); i++) { + logout(workLasts.get(i).getId().toString()); + } + //throw new RuntimeException("鍛樺伐(" +userInfo.getName() + ")缂栫爜:" + workLasts.get(0).getUserId() + "宸茬粡缁戝畾璇ュ伐绔�(" + stationInfo.getName() + ")缂栫爜:" + workLasts.get(0).getStationId() + ".璇峰厛璁╁叾瑙g粦"); } else { BeanUtils.copyProperties(userStationList.get(0), result); } - } else { + } + if (result.getId() == null) { result.setUserId(userInfo.getId()); result.setUserName(userInfo.getName()); result.setStationId(stationInfo.getId()); @@ -170,48 +181,56 @@ } public StaAssemblyWorkLast getWorkLast(String workId) { + if (StringUtils.isBlank(workId)) { + throw new RuntimeException("鐧诲綍ID涓虹┖,璇疯仈绯荤鐞嗗憳鏌ョ湅骞惰В鍐抽棶棰�."); + } StaAssemblyWorkLast result = assemblyWorkLastDao.selectByPrimaryKey(Long.parseLong(workId)); if (result == null) { - return null; + throw new RuntimeException("绯荤粺涓病鏈夎鏉$櫥褰曚俊鎭�"); + //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); + //濡傛灉鏄淮淇畐ork_type 娌℃湁 planId processId nodeId + if (WORK_TYPE_REPAIR.equals(result.getWorkType())) { + //鏍¢獙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); + result.setStatus(STATUS_WORK_LAST_LOGOUT); + 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 = QrCodeConstant.TypeProduct + product.getCode() + assyPlan.getBatchNo(); + result.setDevicePrefix(devicePrefix); + } } } result.setStationId(stationInfo.getId()); @@ -234,7 +253,7 @@ param.setStatus(STATUS_NORMAL); List<StaAssemblyWorkLast> workLasts = assemblyWorkLastDao.selectList(param); if (workLasts.size() > 0) { - result = getWorkLast(workLasts.get(0).getId().toString()); + result = getWorkLast(workLasts.get(0).getId().toString()); } result.setStationId(stationInfo.getId()); result.setStationName(stationInfo.getName()); @@ -292,13 +311,13 @@ result.setProcessName(assyPlan.getProcessName()); result.setNodeName(assyPlan.getProcess().getNodes().get(0).getContent()); //鎵惧埌瀵瑰簲鐨勪骇鍝佷俊鎭� - PltProduct product = productDao.selectByPrimaryKey(assyPlan.getProId()); + 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(); + String devicePrefix = QrCodeConstant.TypeProduct + product.getCode() + assyPlan.getBatchNo(); result.setDevicePrefix(devicePrefix); return result; } @@ -316,6 +335,7 @@ // 淇濆瓨history StaAssemblyWorkHistory history = new StaAssemblyWorkHistory(); BeanUtils.copyProperties(workLast, history); + history.setWorkId(workLast.getId()); //history.setId(null); int count = assemblyWorkHistoryDao.insertSelective(history); //鍒犻櫎last -- Gitblit v1.8.0