单位换算器
<h3>简介</h3>
<ul>
<li>提供单位转换功能,进行不同单位之间的转换,包括长度、重量、体积、温度、速度、时间、压力等各种常见的物理量单位。应用于科学研究、工程计算、物流运输等,为开发者提供方便、快捷和准确的单位转换功能。实现在线长度、面积、重量、体积、容量、温度计量、功率的压力等计量单位转换。</li>
<li>提供了2个接口,分别为:单位换算、单位换算支持类型</li>
</ul>
<h3>接口调用说明</h3>
<h4>请求方式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>POST</strong></p>
<h4>请求格式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>application/form-data</strong></p>
<h4>请求参数</h4>
<p>请求参数均包括公共参数和业务参数(业务参数见具体接口说明)
如接口没有单独说明,所有接口调用时,均需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交</p>
<p><a name="公共请求参数"></a></p>
<h5>公共请求参数</h5>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>appId</td>
<td>String</td>
<td>是</td>
<td>服务商分配的唯一标识</td>
</tr>
<tr>
<td>timestamp</td>
<td>Long</td>
<td>是</td>
<td>当前时间戳(毫秒)</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>签名,详见签名算法说明</td>
</tr>
</tbody>
</table>
<h5>签名算法说明</h5>
<pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre>
<p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间戳(毫秒) <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p>
<pre><code class="language-java">String appId = &quot;xyzxy2121zxyz&quot;;
String timestamp = &quot;1555378976238&quot;;
String appSecret = &quot;efcefcef1121cefcefc1212121&quot;;
String str = appId + appSecret + timestamp;
String sign = sha256(str);</code></pre>
<h4>返回说明</h4>
<h5>返回字段说明</h5>
<p>所有接口均返回以下公共字段:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th><div style="width:420px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>返回码,详见:code返回码说明</td>
</tr>
<tr>
<td>msg</td>
<td>code对应的描述</td>
</tr>
<tr>
<td>charge</td>
<td>计费标志 true为计费,false为不计费</td>
</tr>
<tr>
<td>taskNo</td>
<td>本次请求号</td>
</tr>
<tr>
<td>data</td>
<td>返回具体结果,object类型,详见data返回字段描述</td>
</tr>
</tbody>
</table>
<p><a name="code返回码说明"></a></p>
<h5>code返回码说明</h5>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功(计费)</td>
</tr>
<tr>
<td>400</td>
<td>参数错误</td>
</tr>
<tr>
<td>404</td>
<td>请求地址不正确</td>
</tr>
<tr>
<td>500</td>
<td>服务商维护,请稍候再试</td>
</tr>
<tr>
<td>601</td>
<td>接口未开通</td>
</tr>
<tr>
<td>602</td>
<td>账号停用</td>
</tr>
<tr>
<td>603</td>
<td>余额不足请充值</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>606</td>
<td>调用超限,请稍候再试</td>
</tr>
<tr>
<td>607</td>
<td>ip不在白名单</td>
</tr>
<tr>
<td>609</td>
<td>请求过于频繁,请稍候再试</td>
</tr>
<tr>
<td>610</td>
<td>请求超时</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>
<hr />
<h3>单位换算</h3>
<ul>
<li>支持公里(km)、米(m)、分米(dm)、厘米(cm)、里、丈、尺、寸、分、厘、海里(nmi)、英寻、英里、弗隆(fur)、码(yd)、英尺(ft)、英寸(in)、毫米(mm)、微米(um)等单位转换。</li>
</ul>
<h3>请求地址</h3>
<p><code>https://api.jumdata.com/unit/converter</code></p>
<h3>业务参数</h3>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>num</td>
<td>Number</td>
<td>是</td>
<td>需要转换的数值</td>
</tr>
<tr>
<td>from</td>
<td>String</td>
<td>是</td>
<td>源单位 譬如:km</td>
</tr>
<tr>
<td>to</td>
<td>String</td>
<td>是</td>
<td>目标单位 譬如:m</td>
</tr>
<tr>
<td>type</td>
<td>String</td>
<td>是</td>
<td>类型<br> angle-角度<br> dataStorage-数据存储<br> speed-速度<br> time-时间<br> energy-力<br> density-密度<br> work-功、能、热<br> power-功率<br> pressure-压力<br> temperature-温度<br> weight-质量<br> volume-体积<br> area-面积 <br>longness-长度</td>
</tr>
</tbody>
</table>
<p>公共请求参数请参阅:<a href="#公共请求参数">公共请求参数</a></p>
<h3>成功返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 200,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,// 返回码对应描述
&quot;taskNo&quot;: &quot;453369684185684165653173&quot;,// 本次请求号
&quot;charge&quot;: true,// 计费标志
&quot;data&quot;: [
{
&quot;result&quot;: 1.234,//结果
&quot;unit&quot;: &quot;米&quot;,//单位
&quot;type&quot;: &quot;longness&quot;,//类型描述
&quot;resultStr&quot;: &quot;1.234&quot;//字符型结果
}
]
}</code></pre>
<h3>失败返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 400,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;需要转换的数字不能为空&quot;,// 返回码对应描述
}</code></pre>
<hr />
<h3>单位换算支持类型</h3>
<ul>
<li>查询单位换算支持的类型</li>
</ul>
<h3>请求地址</h3>
<p><code>https://api.jumdata.com/unit/converter/type</code></p>
<h3>业务参数</h3>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td>String</td>
<td>是</td>
<td>类型<br> angle-角度<br> dataStorage-数据存储<br> speed-速度<br> time-时间<br> energy-力<br> density-密度<br> work-功、能、热<br> power-功率<br> pressure-压力<br> temperature-温度<br> weight-质量<br> volume-体积<br> area-面积 <br>longness-长度</td>
</tr>
</tbody>
</table>
<p>公共请求参数请参阅:<a href="#公共请求参数">公共请求参数</a></p>
<h3>成功返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 200,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,// 返回码对应描述
&quot;taskNo&quot;: &quot;103240660220697069006565&quot;,// 本次请求号
&quot;charge&quot;: true, // 计费标志
&quot;data&quot;: [
{
&quot;type&quot;: &quot;temperature&quot;,//所属分类
&quot;unit&quot;: &quot;兰氏度&quot;, //单位名称
&quot;code&quot;: &quot;oRe&quot; // 单位
}
]
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 400,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;type不能为空&quot;,// 返回码对应描述
}</code></pre>