Loading src/Handler/MessageHandler.php +17 −0 Original line number Diff line number Diff line Loading @@ -131,4 +131,21 @@ class MessageHandler $this->messageService->SendMarkDownMessage($receiverIds, $application, 0, $sendUserId, [], $content, $title); } /** * 自动发送markdown 文本消息 * @param $receiverIds * @param $content * @param $title * @throws HttpResponseException */ public function sendAutoMarkDownText($receiverIds, $content, $title) { $application = $this->config->get('app_name'); if (!$application) { throw new HttpResponseException("请设置应用名app_name"); } $receiverIds = is_array($receiverIds) ? $receiverIds : [$receiverIds]; $this->messageService->SendMarkDownMessage($receiverIds, $application, 0, 0, [], $content, $title); } } src/Service/Interfaces/AppServiceInterface.php +9 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,13 @@ interface AppServiceInterface */ public function getByIdList(array $idList, array $relations = [], array $columns = ['id', 'title']): array; /** * 通过name列表获取应用数组 * @param array $nameList 默认去重 * @param array $relations 关联关系只有['group'] * @param array $columns 默认展示id和title,可传['title', 'name', 'entry', 'prefix', 'group_id', 'is_inside', 'is_active', 'icon', 'desc', 'weight'] * @return array 默认keyBy('id') */ public function getByNameList(array $nameList, array $relations = [], array $columns = ['id', 'title', 'name']): array; } src/Service/Interfaces/Flow/ProcessFormServiceInterface.php +5 −4 Original line number Diff line number Diff line Loading @@ -8,10 +8,11 @@ interface ProcessFormServiceInterface { /** * 创建流程申请 * @param $processId 流程id * @param $url 表单图片地址 * @param $data 表单详细内容 * @param integer $processId 流程id * @param string $url 表单图片地址 * @param array $data 表单详细内容 * @param string $user 当前用户信息 * @return mixed */ public function createProcessForm($processId,$url,$data); public function createProcessForm($processId, $url, array $data,$user); } No newline at end of file src/Tools/Drawer.php +69 −8 Original line number Diff line number Diff line Loading @@ -46,11 +46,12 @@ class Drawer */ public function downloadWebImage($url, $path = null) { $url = $this->parseUrl($url); // excel画图中下载图片时对图片名做urlencode处理,防止中文名不能正常画图片的bug $filename = urlencode(trim(pathinfo($url, PATHINFO_FILENAME))); $filename = trim(pathinfo($url, PATHINFO_FILENAME)); $ext = strtolower(pathinfo($url, PATHINFO_EXTENSION)); $filename = "$filename.$ext"; $url = $this->parseUrl($url); $path = $this->rootPath . '/download/images/' . ($path ?: $this->savePath); if (!is_dir($path)) { // 判断路径是否存在,不存在,则创建 Loading @@ -65,8 +66,7 @@ class Drawer curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $file = curl_exec($ch); curl_close($ch); $resource = fopen($path . '/' . $filename, 'a'); $resource = fopen($filePath, 'a'); fwrite($resource, $file); fclose($resource); } Loading @@ -75,9 +75,12 @@ class Drawer private function parseUrl($url) { if (!preg_match('/%[0-9A-Z]{2}/', $url)) { $url = rawurlencode($url); $url = str_replace("%3A", ":", $url); return str_replace("%2F", "/", $url); $url = str_replace("%2F", "/", $url); } return $url; } /** Loading Loading @@ -151,6 +154,64 @@ class Drawer return $res ? $imgNewPath : false; } /** * 拼图 * @param $imgPathList * @return bool|string */ public function mergeImages($imgPathList) { $maxW = $maxH = 0; $filenameList = []; $imageList = []; foreach ($imgPathList as $k => $path) { $path = $this->parseImagePath($path); $imgPathInfo = pathinfo($path); $filename = $imgPathInfo['filename']; // 图片名称 $ext = $imgPathInfo['extension']; // 图片扩展名 [$w, $h] = getimagesize($path); // 图片大小 $imageList[$k] = [ 'path' => $path, 'filename' => $filename, 'ext' => $ext, 'w' => $w, 'h' => $h, ]; $filenameList[] = $filename; $maxW += $w; if ($maxH < $h) { $maxH = $h; } } $filenameList = collect($filenameList)->unique()->sort()->toArray(); $filename = implode('_', $filenameList); $savePath = $this->rootPath . '/download/merge/' . $this->savePath; if (!is_dir($savePath)) { // 判断路径是否存在,不存在,则创建 mkdir($savePath, 0777, true); } $imgNewPath = $savePath . '/' . $filename . '.png'; if (file_exists($imgNewPath)) { return $imgNewPath; } // 黑色背景图片 $im = @imagecreatetruecolor($maxW, $maxH) or die ("Cannot Initialize new GD image stream"); // 为真彩色画布创建背景,再设置为透明 $color = imagecolorallocate($im, 0, 0, 0); imagefill($im, 0, 0, $color); imageColorTransparent($im, $color); // 循环画图片 $dstX = 0; foreach ($imageList as $item) { $resource = imagecreatefromstring(file_get_contents($item['path'])); imagecopy($im, $resource, $dstX, 0, 0, 0, $item['w'], $item['h']); $dstX += $item['w']; } $res = imagepng($im, $imgNewPath); imagedestroy($im); return $res ? $imgNewPath : false; } /** * 画图片 * @param string $path 图片路径 Loading @@ -167,7 +228,7 @@ class Drawer $path = $this->addBoard($path, $boardPx); } $drawing = new Drawing(); $drawing->setPath($path)->setCoordinates($p)->setHeight($h)->setWorksheet($sheet); $drawing->setPath($path)->setCoordinates($p)->setHeight($h)->setOffsetX(1)->setOffsetY(1)->setWorksheet($sheet); } catch (Exception $e) { put_log($e->getMessage()); } Loading Loading
src/Handler/MessageHandler.php +17 −0 Original line number Diff line number Diff line Loading @@ -131,4 +131,21 @@ class MessageHandler $this->messageService->SendMarkDownMessage($receiverIds, $application, 0, $sendUserId, [], $content, $title); } /** * 自动发送markdown 文本消息 * @param $receiverIds * @param $content * @param $title * @throws HttpResponseException */ public function sendAutoMarkDownText($receiverIds, $content, $title) { $application = $this->config->get('app_name'); if (!$application) { throw new HttpResponseException("请设置应用名app_name"); } $receiverIds = is_array($receiverIds) ? $receiverIds : [$receiverIds]; $this->messageService->SendMarkDownMessage($receiverIds, $application, 0, 0, [], $content, $title); } }
src/Service/Interfaces/AppServiceInterface.php +9 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,13 @@ interface AppServiceInterface */ public function getByIdList(array $idList, array $relations = [], array $columns = ['id', 'title']): array; /** * 通过name列表获取应用数组 * @param array $nameList 默认去重 * @param array $relations 关联关系只有['group'] * @param array $columns 默认展示id和title,可传['title', 'name', 'entry', 'prefix', 'group_id', 'is_inside', 'is_active', 'icon', 'desc', 'weight'] * @return array 默认keyBy('id') */ public function getByNameList(array $nameList, array $relations = [], array $columns = ['id', 'title', 'name']): array; }
src/Service/Interfaces/Flow/ProcessFormServiceInterface.php +5 −4 Original line number Diff line number Diff line Loading @@ -8,10 +8,11 @@ interface ProcessFormServiceInterface { /** * 创建流程申请 * @param $processId 流程id * @param $url 表单图片地址 * @param $data 表单详细内容 * @param integer $processId 流程id * @param string $url 表单图片地址 * @param array $data 表单详细内容 * @param string $user 当前用户信息 * @return mixed */ public function createProcessForm($processId,$url,$data); public function createProcessForm($processId, $url, array $data,$user); } No newline at end of file
src/Tools/Drawer.php +69 −8 Original line number Diff line number Diff line Loading @@ -46,11 +46,12 @@ class Drawer */ public function downloadWebImage($url, $path = null) { $url = $this->parseUrl($url); // excel画图中下载图片时对图片名做urlencode处理,防止中文名不能正常画图片的bug $filename = urlencode(trim(pathinfo($url, PATHINFO_FILENAME))); $filename = trim(pathinfo($url, PATHINFO_FILENAME)); $ext = strtolower(pathinfo($url, PATHINFO_EXTENSION)); $filename = "$filename.$ext"; $url = $this->parseUrl($url); $path = $this->rootPath . '/download/images/' . ($path ?: $this->savePath); if (!is_dir($path)) { // 判断路径是否存在,不存在,则创建 Loading @@ -65,8 +66,7 @@ class Drawer curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $file = curl_exec($ch); curl_close($ch); $resource = fopen($path . '/' . $filename, 'a'); $resource = fopen($filePath, 'a'); fwrite($resource, $file); fclose($resource); } Loading @@ -75,9 +75,12 @@ class Drawer private function parseUrl($url) { if (!preg_match('/%[0-9A-Z]{2}/', $url)) { $url = rawurlencode($url); $url = str_replace("%3A", ":", $url); return str_replace("%2F", "/", $url); $url = str_replace("%2F", "/", $url); } return $url; } /** Loading Loading @@ -151,6 +154,64 @@ class Drawer return $res ? $imgNewPath : false; } /** * 拼图 * @param $imgPathList * @return bool|string */ public function mergeImages($imgPathList) { $maxW = $maxH = 0; $filenameList = []; $imageList = []; foreach ($imgPathList as $k => $path) { $path = $this->parseImagePath($path); $imgPathInfo = pathinfo($path); $filename = $imgPathInfo['filename']; // 图片名称 $ext = $imgPathInfo['extension']; // 图片扩展名 [$w, $h] = getimagesize($path); // 图片大小 $imageList[$k] = [ 'path' => $path, 'filename' => $filename, 'ext' => $ext, 'w' => $w, 'h' => $h, ]; $filenameList[] = $filename; $maxW += $w; if ($maxH < $h) { $maxH = $h; } } $filenameList = collect($filenameList)->unique()->sort()->toArray(); $filename = implode('_', $filenameList); $savePath = $this->rootPath . '/download/merge/' . $this->savePath; if (!is_dir($savePath)) { // 判断路径是否存在,不存在,则创建 mkdir($savePath, 0777, true); } $imgNewPath = $savePath . '/' . $filename . '.png'; if (file_exists($imgNewPath)) { return $imgNewPath; } // 黑色背景图片 $im = @imagecreatetruecolor($maxW, $maxH) or die ("Cannot Initialize new GD image stream"); // 为真彩色画布创建背景,再设置为透明 $color = imagecolorallocate($im, 0, 0, 0); imagefill($im, 0, 0, $color); imageColorTransparent($im, $color); // 循环画图片 $dstX = 0; foreach ($imageList as $item) { $resource = imagecreatefromstring(file_get_contents($item['path'])); imagecopy($im, $resource, $dstX, 0, 0, 0, $item['w'], $item['h']); $dstX += $item['w']; } $res = imagepng($im, $imgNewPath); imagedestroy($im); return $res ? $imgNewPath : false; } /** * 画图片 * @param string $path 图片路径 Loading @@ -167,7 +228,7 @@ class Drawer $path = $this->addBoard($path, $boardPx); } $drawing = new Drawing(); $drawing->setPath($path)->setCoordinates($p)->setHeight($h)->setWorksheet($sheet); $drawing->setPath($path)->setCoordinates($p)->setHeight($h)->setOffsetX(1)->setOffsetY(1)->setWorksheet($sheet); } catch (Exception $e) { put_log($e->getMessage()); } Loading