| | |
| | | order.setUrgent(mp.getUrgent()); |
| | | order.setFactoryId(mp.getFactoryId()); |
| | | order.setBackorderId(mp.getBackorderId()); |
| | | order.setUnqualifiedNum(param.getUnqualifiedNum()); |
| | | order.setQualifiedNum(param.getQualifiedNum()); |
| | | order.setOriginId(systemDictDataBiz.queryByCode(Constants.WORKORDER_SOURCE,Constants.WORKORDER_SOURCE_PLAN).getId()); |
| | | //工单编码 |
| | | order.setCode(workorderExtService.getNextCode(user.getCompany().getId())); |
| | |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | | public void autoWorkReport(LoginUserInfo user, AutoWorkReportDTO autoWorkReportDTO){ |
| | | if(Objects.isNull(autoWorkReportDTO) |
| | | || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO()) |
| | | || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum())|| autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().compareTo(BigDecimal.ZERO) < Constants.ZERO |
| | | || Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum())|| autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().compareTo(BigDecimal.ZERO) < Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | //查询工工序计划状态 |
| | | Plans plans = plansExtMapper.selectById(autoWorkReportDTO.getPlansId()); |
| | | if(Objects.isNull(plans)){ |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"工序计划已暂停,无法操作"); |
| | | } |
| | | if(Objects.isNull(autoWorkReportDTO.getCreateWorkorderRecordDTO())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"参数错误:产出数据"); |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"参数错误:产出数据"); |
| | | } |
| | | //查询工序计划已分配数量 |
| | | List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().eq("PLAN_ID",plans.getId()) |
| | |
| | | Integer produceNum = workorderList.stream().map(s -> s.getPlanNum()).reduce(Constants.ZERO, Integer::sum); |
| | | Integer surplusNum = plans.getNum() - produceNum; |
| | | if(num.compareTo(BigDecimal.valueOf(surplusNum))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"参数错误:超出工单剩余可分配数量"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"超出当前工序计划可报工数量"); |
| | | } |
| | | Workorder param = new Workorder(); |
| | | param.setPlanId(autoWorkReportDTO.getPlansId()); |
| | |
| | | param.setProUserList(autoWorkReportDTO.getProUserList()); |
| | | param.setPlanNum(num.intValue()); |
| | | //生成工单信息 |
| | | Workorder workorder = this.distributeDone(user,param,plans.getNum()); |
| | | param.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue()); |
| | | param.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue()); |
| | | Workorder workorder = this.distributeDone(user,param,num.intValue()); |
| | | //工单投料记录 |
| | | CreateMaterialDTO createMaterialDTO = new CreateMaterialDTO(); |
| | | if(!Objects.isNull(autoWorkReportDTO.getRecordList())&&autoWorkReportDTO.getRecordList().size()>Constants.ZERO){ |
| | |
| | | autoWorkReportDTO.getCreateWorkorderRecordDTO().setWorkorderId(workorder.getId()); |
| | | WorkorderRecord workorderRecord = workorderRecordStandardService.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); |
| | | //工单报工 |
| | | workorderRecordStandardService.comfirmDone(workorder); |
| | | workorderRecordStandardService.comfirmDone(workorder,false); |
| | | //更新工单状态 |
| | | if(num.compareTo(BigDecimal.valueOf(surplusNum))==Constants.ZERO){ |
| | | plans.setStatus(Constants.PLAN_STATUS.done); |
| | |
| | | } |
| | | } |
| | | plansExtMapper.updateById(plans); |
| | | //发送消息队列处理分享操作 |
| | | workorderExtService.statisticNum(workorder); |
| | | //存储报工不良项数据 |
| | | if(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().compareTo(BigDecimal.ZERO)<=Constants.ZERO){ |
| | | if(!Objects.isNull(autoWorkReportDTO.getCreateUnqualifiedDTOList())&&autoWorkReportDTO.getCreateUnqualifiedDTOList().size()>Constants.ZERO){ |