| | |
| | | private MaterialExtMapper materialExtMapper; |
| | | @Autowired |
| | | private SalaryParamMapper salaryParamMapper; |
| | | @Autowired |
| | | private PlansExtMapper plansExtMapper; |
| | | @Autowired |
| | | private DeviceExtMapper deviceExtMapper; |
| | | |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | |
| | | return mp; |
| | | } |
| | | |
| | | private void getPlansAndValid(LoginUserInfo user, Plans mp) throws BusinessException{ |
| | | if(mp== null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该记录不存在!"); |
| | | } |
| | | if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,工单已暂停!"); |
| | | } |
| | | } |
| | | |
| | | private QueryBomDetailExtDTO initBomParam(LoginUserInfo user, Workorder mp) throws BusinessException{ |
| | | QueryBomExtDTO bb = new QueryBomExtDTO(); |
| | |
| | | bom.setBomId(versionBom.getBomVersionId()); |
| | | // bom.setProcedureId(mp.getProcedureId()); |
| | | bom.setWorkorderId(mp.getId()); |
| | | return bom; |
| | | } |
| | | |
| | | private QueryBomDetailExtDTO initBomParamForPlans(LoginUserInfo user, Plans plans) throws BusinessException{ |
| | | QueryBomExtDTO bb = new QueryBomExtDTO(); |
| | | bb.setDepartId(plans.getDepartId()); |
| | | bb.setDeleted(Constants.ZERO); |
| | | bb.setRootDepartId(user.getRootDepartment().getId()); |
| | | bb.setMaterialId(plans.getMaterialId()); |
| | | bb.setProcedureId(plans.getProcedureId()); |
| | | BomExtListVO versionBom = bomExtMapper.selectByModel( bb); |
| | | if(versionBom == null || StringUtils.isBlank(versionBom.getVersion()) || versionBom.getBomVersionId() == null){ |
| | | return null; |
| | | // throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该工单物料BOM信息配置有误,请联系管理员!"); |
| | | } |
| | | plans.setBomModel(versionBom); |
| | | QueryBomDetailExtDTO bom = new QueryBomDetailExtDTO(); |
| | | bom.setDeleted(Constants.ZERO); |
| | | bom.setBomId(versionBom.getBomVersionId()); |
| | | // bom.setProcedureId(mp.getProcedureId()); |
| | | bom.setPlansId(plans.getId()); |
| | | return bom; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void updateOrderInfo(LoginUserInfo user, Workorder mp,int status) { |
| | | |
| | | List<WorkorderHistory> whList = new ArrayList<>(); |
| | | //工单历史数据 |
| | | Workorder order = new Workorder(); |
| | |
| | | order.setStatus(Constants.WORKORDER_STATUS.material); |
| | | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.done){ |
| | | order.setStatus(Constants.WORKORDER_STATUS.done); |
| | | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material){ |
| | | }else if(status ==Constants.WORKORDER_HISTORY_STATUS.material ||status ==Constants.WORKORDER_HISTORY_STATUS.produce){ |
| | | //投料操作 |
| | | if(Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) |
| | | ||Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material)){ |
| | |
| | | return PageData.from(new PageInfo<>(result)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageData<WStockExtListVO> choiceStockPageForPlans(PageWrap<QueryWStockDto> pageWrap,LoginUserInfo userInfo) { |
| | | Plans plans =plansExtMapper.selectById(pageWrap.getModel().getPlansId()); |
| | | if(Objects.isNull(plans)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到工序计划信息!"); |
| | | } |
| | | Device device = deviceExtMapper.selectById(pageWrap.getModel().getDeviceId()); |
| | | if(Objects.isNull(plans)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到设备信息!"); |
| | | } |
| | | //查询并验证工单信息 |
| | | this.getPlansAndValid(userInfo,plans); |
| | | //查询全部bom组成数据,如果有BOM配置,按照BOM组成进行投料,如果没有BOM配置,则投料物料为待生产库位的物料本身 |
| | | QueryBomDetailExtDTO bdparam = initBomParamForPlans(userInfo,plans); |
| | | List<BomDetailExtListVO> bomDetailList = null; |
| | | if(bdparam!=null){ |
| | | bomDetailList = bomDetailExtMapper.selectList(bdparam); |
| | | List<Integer> materialDistributeId = bomDetailList.stream().map(BomDetailExtListVO::getMaterialId).collect(Collectors.toList()); |
| | | pageWrap.getModel().setMaterialDistributeId(materialDistributeId); |
| | | }else{ |
| | | //查询物料BOM信息 |
| | | Bom bom = bomExtMapper.selectOne(new QueryWrapper<Bom>().eq("MATERIAL_ID",plans.getMaterialId()).eq("DELETED",Constants.ZERO).last(" limit 1 ")); |
| | | if(Objects.isNull(bom)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到BOM信息!"); |
| | | } |
| | | RouteProcedure currentRouteProcedure = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>() |
| | | .eq("ROUTE_ID",bom.getRouteId()) |
| | | .eq("PROCEDURE_ID",plans.getProcedureId()) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(currentRouteProcedure!=null){ |
| | | RouteProcedure routeProcedure = routeProcedureExtMapper.selectOne(new QueryWrapper<RouteProcedure>() |
| | | .eq("ROUTE_ID",currentRouteProcedure.getRouteId()).apply(" SORTNUM < " + currentRouteProcedure.getSortnum() ).eq("STATUS",Constants.ONE).orderByDesc(" SORTNUM ").last(" limit 1 ") |
| | | ); |
| | | if(Objects.isNull(routeProcedure)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到生产物料上一步工序信息!"); |
| | | } |
| | | pageWrap.getModel().setProcedureId(routeProcedure.getProcedureId()); |
| | | pageWrap.getModel().setMaterialId(plans.getMaterialId()); |
| | | } |
| | | } |
| | | pageWrap.getModel().setLocationId(device.getProduceWarehouseLocationId()); |
| | | PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | List<WStockExtListVO> result = wStockExtMapper.choiceStockList(pageWrap.getModel()); |
| | | return PageData.from(new PageInfo<>(result)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | |
| | | workorderRecord.setSalary(BigDecimal.valueOf(createWorkorderRecordDTO.getDuration()).multiply(salaryParam.getSalary()).divide(new BigDecimal(3600))); |
| | | } |
| | | |
| | | //插入工单操作记录,并且判断是否更改为工单的状态【生产中】 |
| | | updateOrderInfo(loginUserInfo,workorder,Constants.WORKORDER_HISTORY_STATUS.produce); |
| | | workorderRecordExtMapper.insert(workorderRecord); |
| | | return workorderRecord; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |