| | |
| | | private DeviceExtMapper deviceExtMapper; |
| | | @Autowired |
| | | private UnqualifiedRecordMapper unqualifiedRecordMapper; |
| | | @Autowired |
| | | private CompanyUserExtMapper companyUserExtMapper; |
| | | |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | @Override |
| | |
| | | } |
| | | if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) |
| | | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material) |
| | | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.producing) |
| | | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.check) |
| | | && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该工单状态已流转,不能进行该操作!"); |
| | |
| | | wrModel.setType(Constants.WORKORDER_RECORD_TYPE.materail); |
| | | wrModel.setFactoryId(mp.getFactoryId()); |
| | | wrModel.setProcedureId(mp.getProcedureId()); |
| | | wrModel.setBatch(mp.getBatch()); |
| | | wrModel.setBatch(wStock.getBatch()); |
| | | wrModel.setUnitId(mp.getUnitId()); |
| | | wrModel.setPlanId(mp.getPlanId()); |
| | | //TODO 目前使用工装主键存储货位主键 |
| | |
| | | if(mp== null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,该记录不存在!"); |
| | | } |
| | | |
| | | Plans plans = plansExtMapper.selectById(mp.getPlanId()); |
| | | if(Objects.isNull(plans)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,工序计划记录不存在!"); |
| | | } |
| | | //查询工序计划下 所有工单已报工数量 |
| | | QueryWorkorderExtDTO dto = new QueryWorkorderExtDTO(); |
| | | dto.setPlanId(mp.getPlanId()); |
| | | dto.setDeleted(Constants.ZERO); |
| | | dto.setStatus(Constants.WORKORDER_STATUS.baogong); |
| | | List<WorkorderExtListVO> workorderList = workorderExtMapper.selectList(dto); |
| | | Integer plansQualifiedNum = 0 , plansUnQualifiedNum = 0; |
| | | plansQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getQualifiedNum()).reduce(Constants.ZERO, Integer::sum); |
| | | plansUnQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getUnqualifiedNum()).reduce(Constants.ZERO, Integer::sum); |
| | | if((BigDecimal.valueOf(plansQualifiedNum).add(BigDecimal.valueOf(plansUnQualifiedNum).add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum()) |
| | | .add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum()))).compareTo(BigDecimal.valueOf(plans.getNum()))>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,报工数量超出工序计划总数!"); |
| | | } |
| | | Workorder param = new Workorder(); |
| | | |
| | | param.setPlanId(mp.getPlanId()); |
| | | param.setId(autoWorkReportDTO.getCreateWorkorderRecordDTO().getWorkorderId()); |
| | | if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,工单已暂停!"); |
| | | } |
| | |
| | | List<Appliances> updateApplianceProList = new ArrayList<>(); |
| | | //待更新库存集合 |
| | | List<WStock> stockList = new ArrayList<>(); |
| | | //处理产出数据 |
| | | WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user,null); |
| | | //查询投料和报工记录列表 |
| | | List<WorkorderRecordExtListVO> allRecordList = workorderRecordExtMapper.selectAllList(getQueryRecordParam(param)); |
| | | if(Objects.isNull(allRecordList)||allRecordList.size()==Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询投料和报工记录!"); |
| | | } |
| | | //处理产出数据 |
| | | WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); |
| | | //检查数据信息 |
| | | // caculateCheckRecord(user, mp,allRecordList); |
| | | QueryBomDetailExtDTO bdparam = initBomParam(user,mp); |
| | |
| | | } |
| | | } |
| | | //更新工单状态为已报工 |
| | | mp.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue()); |
| | | mp.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue()); |
| | | updateOrderInfo(user,mp,Constants.WORKORDER_HISTORY_STATUS.baogong); |
| | | |
| | | //批量插入出入库明细记录 |
| | |
| | | detail.setWarehouseId(outbound.getWarehouseId()); |
| | | detail.setLocationId(mp.getFinishWarehouseLocationId()); |
| | | detail.setNum(BigDecimal.valueOf(doneType.equals(Constants.ZERO)?tModel.getQualifiedNum():tModel.getUnqualifiedNum())); |
| | | if(detail.getNum().compareTo(BigDecimal.ZERO)==Constants.ZERO){ |
| | | return; |
| | | } |
| | | detail.setStatus(Constants.ONE); |
| | | detail.setDoneNum(detail.getNum()); |
| | | detail.setDoneDate(new Date()); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo){ |
| | | public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo ,Integer userId){ |
| | | Workorder workorder = workorderExtMapper.selectById(createWorkorderRecordDTO.getWorkorderId()); |
| | | if(Objects.isNull(workorder)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到该工单信息!"); |
| | |
| | | //数据存储 |
| | | workorderRecord = new WorkorderRecord(); |
| | | workorderRecord.setDeleted(Constants.ZERO); |
| | | if(!Objects.isNull(userId)){ |
| | | CompanyUser companyUser = companyUserExtMapper.selectById(userId); |
| | | if(Objects.isNull(companyUser)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,未查询到生产人员对应企业用户信息!"); |
| | | } |
| | | workorderRecord.setCreateUser(companyUser.getUserId()); |
| | | workorderRecord.setRootDepartId(companyUser.getRootDepartId()); |
| | | workorderRecord.setDepartId(companyUser.getComDepartId()); |
| | | }else{ |
| | | workorderRecord.setCreateUser(loginUserInfo.getId()); |
| | | workorderRecord.setCreateTime(new Date()); |
| | | workorderRecord.setNum(num); |
| | | workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId()); |
| | | workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId()); |
| | | } |
| | | workorderRecord.setCreateTime(new Date()); |
| | | workorderRecord.setNum(num); |
| | | workorderRecord.setPlanId(workorder.getPlanId()); |
| | | workorderRecord.setWorkorderId(createWorkorderRecordDTO.getWorkorderId()); |
| | | workorderRecord.setBatch(workorder.getBatch()); |
| | |
| | | //计算工资信息 |
| | | SalaryParam salaryParam = salaryParamMapper.selectOne(new QueryWrapper<SalaryParam>().eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",workorderRecord.getMaterialId()) |
| | | .eq("DEPART_ID",workorderRecord.getFactoryId()).eq("PROCEDURE_ID",workorderRecord.getProcedureId()).last(" limit 1 ")); |
| | | if(!Objects.isNull(salaryParam)){ |
| | | if(!Objects.isNull(salaryParam)&&!Objects.isNull(createWorkorderRecordDTO.getDuration())){ |
| | | workorderRecord.setSalaryPrice(salaryParam.getSalary()); |
| | | workorderRecord.setSalaryType(salaryParam.getType()); |
| | | workorderRecord.setSalaryUnqualified(salaryParam.getUnqualified()); |