| | |
| | | @Slf4j |
| | | @Service |
| | | public class WorkOrderSv { |
| | | private static final int STATUS_NORMAL = 1; |
| | | 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 USER_PREFIX = "101"; |
| | | private static final String STATION_PREFIX = "103"; |
| | | |
| | | private PrAssemblyPlanMapper assemblyDao; |
| | | private BaUserMapper baUserDao; |
| | | private PltStationMapper pltStationDao; |
| | |
| | | throw new RuntimeException("员工编码不能为空"); |
| | | } |
| | | //用户101 |
| | | if(id.startsWith("101")){ |
| | | if(id.startsWith(USER_PREFIX)){ |
| | | userId = Long.parseLong(id.toString().substring(3)); |
| | | }else{ |
| | | userId = Long.parseLong(id.toString()); |
| | |
| | | throw new RuntimeException("工站编码不能为空"); |
| | | } |
| | | //工站103 |
| | | if(id.startsWith("103")){ |
| | | if(id.startsWith(STATION_PREFIX)){ |
| | | stationId = Long.parseLong(id.toString().substring(3)); |
| | | }else{ |
| | | stationId = Long.parseLong(id.toString()); |
| | |
| | | //检查表中stationId是否已经存在 |
| | | StaAssemblyWorkLast param = new StaAssemblyWorkLast(); |
| | | param.setStationId(stationInfo.getId()); |
| | | param.setStatus(1); |
| | | param.setStatus(STATUS_NORMAL); |
| | | List<StaAssemblyWorkLast> workLasts = assemblyWorkLastDao.selectList(param); |
| | | if(workLasts.size() > 0){ |
| | | BeanUtils.copyProperties(workLasts.get(0),result); |
| | |
| | | throw new RuntimeException("工站编码或员工编码均不能为空,请检查"); |
| | | } |
| | | //工站103 |
| | | if(vo.getStationId().startsWith("101")){ |
| | | if(vo.getStationId().startsWith(USER_PREFIX)){ |
| | | userInfo = getUserInfo(vo.getStationId()); |
| | | }else{ |
| | | stationInfo = getStationInfo(vo.getStationId()); |
| | | } |
| | | if(vo.getUserId().startsWith("103")){ |
| | | if(vo.getUserId().startsWith(STATION_PREFIX)){ |
| | | stationInfo = getStationInfo(vo.getUserId()); |
| | | }else{ |
| | | userInfo = getUserInfo(vo.getUserId()); |
| | |
| | | //检查表中stationId是否已经存在 |
| | | StaAssemblyWorkLast param = new StaAssemblyWorkLast(); |
| | | param.setStationId(stationInfo.getId()); |
| | | param.setStatus(1); |
| | | param.setStatus(STATUS_NORMAL); |
| | | List<StaAssemblyWorkLast> workLasts = assemblyWorkLastDao.selectList(param); |
| | | long userId = userInfo.getId(); |
| | | if(workLasts.size() > 0){ |
| | |
| | | StaAssemblyWorkLast checkResult = checkUserAndStationUsed(vo); |
| | | //校验planId processId nodeId |
| | | PrAssemblyPlan params = new PrAssemblyPlan(); |
| | | params.setStatus(1); |
| | | params.setStatus(STATUS_NORMAL); |
| | | params.setId(vo.getPlanId()); |
| | | params.setProcessId(vo.getProcessId()); |
| | | List<PrAssemblyPlan> planList = selectAssyPlanList(params); |
| | |
| | | BeanUtils.copyProperties(vo,staLast); |
| | | staLast.setUserId(checkResult.getUserId()); |
| | | staLast.setStationId(checkResult.getStationId()); |
| | | staLast.setStatus(1); |
| | | staLast.setStatus(STATUS_NORMAL); |
| | | staLast.setStartTime(new Date()); |
| | | count = assemblyWorkLastDao.insertSelective(staLast); |
| | | }else{ |
| | |
| | | staLast.setPlanId(vo.getPlanId()); |
| | | staLast.setProcessId(vo.getProcessId()); |
| | | staLast.setNodeId(vo.getNodeId()); |
| | | staLast.setStatus(1); |
| | | staLast.setStatus(STATUS_NORMAL); |
| | | staLast.setStartTime(new Date()); |
| | | count = assemblyWorkLastDao.updateByPrimaryKeySelective(staLast); |
| | | } |
| | |
| | | throw new RuntimeException("系统中没有该条登录信息"); |
| | | } |
| | | //更新登录记录 |
| | | workLast.setStatus(2); |
| | | workLast.setStatus(STATUS_WORK_LAST_LOGOUT); |
| | | workLast.setEndTime(new Date()); |
| | | // 保存history |
| | | StaAssemblyWorkHistory history = new StaAssemblyWorkHistory(); |
| | |
| | | StringBuilder sb = new StringBuilder(); |
| | | String[] assistantArr = vo.getAssistants().split(","); |
| | | for (String item : assistantArr) { |
| | | if(item.startsWith("101")){ |
| | | if(item.startsWith(USER_PREFIX)){ |
| | | sb.append(item.substring(3)).append(","); |
| | | }else{ |
| | | sb.append(item).append(","); |
| | |
| | | if(workLast == null){ |
| | | throw new RuntimeException("系统中没有当前登录信息,请检查或重新登录"); |
| | | } |
| | | if((!StringUtils.isBlank(assistant)) && assistant.startsWith("101")){ |
| | | if((!StringUtils.isBlank(assistant)) && assistant.startsWith(USER_PREFIX)){ |
| | | assistant = assistant.substring(3); |
| | | } |
| | | if(!StringUtils.isBlank(workLast.getAssistants())){ |