|
|
@@ -3,11 +3,10 @@
|
|
|
namespace app\index\controller;
|
|
|
|
|
|
use app\common\controller\Frontend;
|
|
|
-use app\job\InsertDataJob;
|
|
|
-use think\Queue;
|
|
|
-use think\Db;
|
|
|
+
|
|
|
class Index extends Frontend
|
|
|
{
|
|
|
+ private const VECTOR_API_KEY = 'ZH17_K8B2N7C4M1';
|
|
|
|
|
|
protected $noNeedLogin = '*';
|
|
|
protected $noNeedRight = '*';
|
|
|
@@ -15,41 +14,123 @@ class Index extends Frontend
|
|
|
|
|
|
public function index()
|
|
|
{
|
|
|
- $data = [
|
|
|
- 'sczl_gdbh' => '2310201',
|
|
|
- 'sczl_yjno' => '1',
|
|
|
- 'sczl_gxh' => '3',
|
|
|
- 'sczl_type' => '03-喷码 ',
|
|
|
- 'sczl_rq' => '2024-01-03 00:00:00',
|
|
|
- 'sczl_jtbh' => 'PM02#',
|
|
|
- '班组车头产量' => '1500.0',
|
|
|
- '工价系数' => '0.0000',
|
|
|
- '工序难度系数' => '1.100',
|
|
|
- '装版工时' => '0.00',
|
|
|
- '保养工时' => '0.00',
|
|
|
- '打样工时' => '0.00',
|
|
|
- '异常停机工时' => '0.00',
|
|
|
- '车头产量占用机时' => '0.00',
|
|
|
- '日定额' => '32000.00',
|
|
|
- '千件工价' => '3.30',
|
|
|
- '补产标准' => '5400',
|
|
|
- '班组换算产量' => 0,
|
|
|
- '计时补差额工资' => '0.00',
|
|
|
- 'bh' => 'ZM00585',
|
|
|
- 'xm' => '徐钱鹏 ',
|
|
|
- 'Rate' => '0.68000',
|
|
|
- 'sczl_ms' => '0.00',
|
|
|
- '工时占比' => '0.0516',
|
|
|
- '达标定额' => '363.00',
|
|
|
- '个人计件工资' => '0.81',
|
|
|
- '个人加班工资' => '4.33',
|
|
|
- 'UniqID' => 253318494,
|
|
|
- 'sys_ny' => '202401',
|
|
|
- 'sys_rq' => '2024-03-20 13:44:50',
|
|
|
- 'sys_id' => '[0001/测试]',
|
|
|
- '法定天数' => '22'];
|
|
|
- $job = new InsertDataJob($data); // 创建任务实例
|
|
|
- Queue::push($job); // 推送任务到队列
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 调用第三方矢量转换接口
|
|
|
+ */
|
|
|
+ public function uploadVector()
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!$this->request->isPost()) {
|
|
|
+ return json(['code' => 0, 'msg' => '请求方式错误']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $file = $this->request->file('file');
|
|
|
+ if (!$file) {
|
|
|
+ return json(['code' => 0, 'msg' => '请上传文件']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $vectorFormat = trim((string)$this->request->post('vectorFormat', '.pdf'));
|
|
|
+ $maxlong = trim((string)$this->request->post('maxlong', ''));
|
|
|
+ $fileName = trim((string)$this->request->post('fileName', ''));
|
|
|
+
|
|
|
+ $realPath = $file->getRealPath();
|
|
|
+ if ($realPath === false || !is_file($realPath)) {
|
|
|
+ return json(['code' => 0, 'msg' => '上传文件读取失败']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $mimeType = (string)$file->getInfo('type');
|
|
|
+ if ($mimeType === '') {
|
|
|
+ $mimeType = 'application/octet-stream';
|
|
|
+ }
|
|
|
+
|
|
|
+ $postData = [
|
|
|
+ 'file' => new \CURLFile($realPath, $mimeType, $file->getInfo('name')),
|
|
|
+ 'apiKey' => self::VECTOR_API_KEY,
|
|
|
+ 'vectorFormat' => $vectorFormat,
|
|
|
+ ];
|
|
|
+ if ($maxlong !== '') {
|
|
|
+ $postData['maxlong'] = $maxlong;
|
|
|
+ }
|
|
|
+ if ($fileName !== '') {
|
|
|
+ $postData['fileName'] = $fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+ $ch = curl_init('http://mm.kknc.site/webapi/webapi.php');
|
|
|
+ curl_setopt($ch, CURLOPT_POST, true);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
|
|
+
|
|
|
+ $response = curl_exec($ch);
|
|
|
+ if ($response === false) {
|
|
|
+ $error = curl_error($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ return json(['code' => 0, 'msg' => '接口调用失败: ' . $error]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $httpCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
+ curl_close($ch);
|
|
|
+
|
|
|
+ if ($httpCode >= 400) {
|
|
|
+ return json([
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '接口返回异常状态码: ' . $httpCode,
|
|
|
+ 'data' => $response,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $jsonData = json_decode($response, true);
|
|
|
+ if (json_last_error() === JSON_ERROR_NONE) {
|
|
|
+ return json(['code' => 1, 'msg' => '请求成功', 'data' => $jsonData]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json(['code' => 1, 'msg' => '请求成功', 'data' => $response]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询任务状态并返回下载地址
|
|
|
+ */
|
|
|
+ public function queryVector()
|
|
|
+ {
|
|
|
+ $bianhao = trim((string)$this->request->request('bianhao', ''));
|
|
|
+ if ($bianhao === '') {
|
|
|
+ return json(['code' => 0, 'msg' => 'bianhao 不能为空']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $queryUrl = 'http://mm.kknc.site/webapi/webapi.php?' . http_build_query(['bianhao' => $bianhao]);
|
|
|
+ $ch = curl_init($queryUrl);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
|
|
+
|
|
|
+ $response = curl_exec($ch);
|
|
|
+ if ($response === false) {
|
|
|
+ $error = curl_error($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ return json(['code' => 0, 'msg' => '查询失败: ' . $error]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $httpCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
+ curl_close($ch);
|
|
|
+
|
|
|
+ if ($httpCode >= 400) {
|
|
|
+ return json([
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '查询接口异常状态码: ' . $httpCode,
|
|
|
+ 'data' => $response,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $jsonData = json_decode($response, true);
|
|
|
+ if (json_last_error() === JSON_ERROR_NONE) {
|
|
|
+ return json(['code' => 1, 'msg' => '查询成功', 'data' => $jsonData]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json(['code' => 1, 'msg' => '查询成功', 'data' => $response]);
|
|
|
}
|
|
|
|
|
|
}
|