职业技能标准查询(附源码)
本帖最后由 gufengaoyue 于 2024-6-3 17:31 编辑看到有人在找职业技能标准的相关Pdf.
http://www.osta.org.cn/skillStandard
就用VB.NET写了一个,有兴趣的可以试试。
.net framework 4.6.2及以上.
加载数据-(搜索)- 双击下载
勾选下载到当前目录,会在程序目录下创建一个pdf文件夹,并存放文件。
如果没有,就另存。
Imports System.ComponentModel
Imports System.Net
Imports System.Net.Http
Imports System.Text.Json
Imports System.Text.Json.Nodes
Public Class BookList
Private ReadOnly url As String = "http://www.osta.org.cn/api/public/skillStandardList?pageSize=10000"
Private ReadOnly DownUrl As String = "http://www.osta.org.cn/api/sys/downloadFile/decrypt?fileName="
Private jsonData As New List(Of Book)
Private webClient As New WebClient()
Private Sub BookList_Load(sender As Object, e As EventArgs) Handles Me.Load
AddHandler webClient.DownloadProgressChanged, AddressOf DownloadProgressChanged
AddHandler webClient.DownloadFileCompleted, AddressOf DownloadFileCompleted
End Sub
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim client As New HttpClient()
Dim response As HttpResponseMessage = Await client.GetAsync(url)
If response.IsSuccessStatusCode Then
Dim responseContent As String = Await response.Content.ReadAsStringAsync()
jsonData = JsonSerializer.Deserialize(Of List(Of Book))(JsonObject.Parse(responseContent)("body")("list").ToJsonString)
DataGridView1.DataSource = jsonData.Select(Function(x) New With {
.序号 = x.id,
.标准名称 = x.name,
.职业编号 = x.code,
.发文号 = x.issueNumber,
.PDF名称 = x.standardInfoName}).ToList()
DataGridView1.AutoResizeColumns()
Else
MessageBox.Show("请求失败,状态码:" & response.StatusCode)
End If
End Sub
Private Sub DataGridView1_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
DownLoadPDF()
End Sub
Private Sub DownLoadPDF()
If DataGridView1.SelectedRows Is Nothing Then Return
Dim row As DataGridViewRow = DataGridView1.SelectedRows(0)
Dim book = row.DataBoundItem
Dim selectUrl = jsonData.Find(Function(x) x.id = book.序号).standardInfo
Dim DownLoadUrl As String = DownUrl & selectUrl
If webClient.IsBusy Then MsgBox("已有文件在下载,请稍候!", MsgBoxStyle.Exclamation) : Return
If CheckBox1.Checked Then
Dim appPath As String = IO.Path.Combine(Application.StartupPath, "PDF")
If Not IO.Directory.Exists(appPath) Then
IO.Directory.CreateDirectory(appPath)
End If
Dim savePath As String = IO.Path.Combine(appPath, book.PDF名称)
webClient.DownloadFileAsync(New Uri(DownLoadUrl), savePath)
Else
With New SaveFileDialog
.Filter = "PDF 文件(*.pdf)|*.pdf"
.FileName = book.PDF名称
If .ShowDialog = DialogResult.OK Then
Dim fn As String = .FileName
webClient.DownloadFileAsync(New Uri(DownLoadUrl), fn)
End If
End With
End If
Timer1.Start()
End Sub
Private Sub DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs)
ProgressBar1.Value = e.ProgressPercentage
End Sub
Private Sub DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs)
Timer1.Stop()
If e.Cancelled Then
MessageBox.Show("下载已取消")
ElseIf e.Error IsNot Nothing Then
MessageBox.Show("发生错误: " & e.Error.Message)
Else
MessageBox.Show("文件下载完成")
End If
ProgressBar1.Value = 0
End Sub
Private Sub DataGridView1_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
Try
'添加行号
Dim v_SolidBrush As New SolidBrush(DataGridView1.RowHeadersDefaultCellStyle.ForeColor)
Dim v_LineNo As Integer = 0
v_LineNo = e.RowIndex + 1
Dim v_Line As String = v_LineNo.ToString()
e.Graphics.DrawString(v_Line, e.InheritedRowStyle.Font, v_SolidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5)
Catch ex As Exception
'MessageBox.Show("添加行号时发生错误,错误信息:" + ex.Message, "操作失败")
End Try
End Sub
Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
If jsonData IsNot Nothing Then
Dim filterList = jsonData.Where(Function(x) x.name.Contains(TextBox1.Text) OrElse
x.code.Contains(TextBox1.Text) OrElse
x.issueNumber.Contains(TextBox1.Text) OrElse
x.standardInfoName.Contains(TextBox1.Text)).ToList()
DataGridView1.DataSource = filterList.Select(Function(x) New With {
.序号 = x.id,
.标准名称 = x.name,
.职业编号 = x.code,
.发文号 = x.issueNumber,
.PDF名称 = x.standardInfoName}).ToList()
DataGridView1.AutoResizeColumns()
End If
End Sub
End Class
Public Class Book
Public Property id As Integer
Public Property name As String
Public Property code As String
Public Property issueNumber As String
Public Property standardInfo As String
Public Property standardInfoName As String
End Class
感谢分享。 感谢分享,很好的东西 这个技术标准一般用在哪里? 肆懿 发表于 2024-6-3 17:28
这个技术标准一般用在哪里?
应该是考资格证的时候需要参考的。 能不能下载团标网https://www.ttbz.org.cn/Home/Standard
感谢分享