20201112
This commit is contained in:
@@ -23,9 +23,6 @@ class Img extends Controller {
|
||||
public function reviewerImport() {
|
||||
//接收信息
|
||||
$data = $this->request->post();
|
||||
|
||||
// $data['url'] = 'zhengshu/import/20210610/e7a3ae0879619862f0f5584d674ffc69.xlsx';
|
||||
// $data['course'] = 'ZYMR';
|
||||
//读取excel
|
||||
$path = ROOT_PATH . 'public' . DS . $data['url'];
|
||||
$arr = self::readExcel($path);
|
||||
@@ -39,13 +36,8 @@ class Img extends Controller {
|
||||
|
||||
Queue::push('app\api\job\img@fire', $datae, "img");
|
||||
}
|
||||
|
||||
// $this->imgCL($arr,$data['course']);
|
||||
}
|
||||
|
||||
// public function t(){
|
||||
// Queue::push( 'app\api\job\img@fire',[], "img" );
|
||||
// }
|
||||
|
||||
/**
|
||||
* 接收导入文件
|
||||
@@ -195,11 +187,8 @@ class Img extends Controller {
|
||||
} else {
|
||||
$zip->open($zipName, \ZIPARCHIVE::CREATE);
|
||||
}
|
||||
|
||||
|
||||
$dir = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'img' . DS . $data['course'] . '/';
|
||||
$files = scandir($dir);
|
||||
|
||||
foreach ($files as $val) {
|
||||
if ($val == '.' || $val == '..') {
|
||||
continue;
|
||||
@@ -211,14 +200,55 @@ class Img extends Controller {
|
||||
}
|
||||
}
|
||||
$zip->close(); //关闭
|
||||
|
||||
if (!file_exists($zipName)) {
|
||||
exit("无法找到文件"); //即使创建,仍有可能失败
|
||||
}
|
||||
$re['url'] = 'public/zhengshu' . DS . 'zip' . DS . $data['course'] . '.zip';
|
||||
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
public function testaaa(){
|
||||
$this->imgZL('王金磊', 'ZLLJ');
|
||||
}
|
||||
/**
|
||||
* 获取当前证书流水号最大值
|
||||
*/
|
||||
private function getmax($course) {
|
||||
$dir = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'img/' . $course . DS;
|
||||
$res = scandir($dir);
|
||||
$big = 0;
|
||||
foreach ($res as $v) {
|
||||
if ($v == '.' || $v == '..') {
|
||||
continue;
|
||||
}
|
||||
$cac = intval(substr($v, 0, stripos($v, '_')));
|
||||
if ($cac > $big) {
|
||||
$big = $cac;
|
||||
}
|
||||
}
|
||||
return $big;
|
||||
}
|
||||
/**
|
||||
* 处理图片主方法
|
||||
*/
|
||||
public function imgZL($name, $course) {
|
||||
$max = $this->getmax($course);
|
||||
$lim = [];
|
||||
if (preg_match("/^[\x7f-\xff]+$/", $name) && strlen($name) == 9) {
|
||||
$lim = [640, 890];
|
||||
} else if (preg_match("/^[\x7f-\xff]+$/", $name) && strlen($name) == 6) {
|
||||
$lim = [670, 890];
|
||||
} else {
|
||||
$left = (730 - ((35 * strlen($name)) / 2));
|
||||
$lim = [$left, 890];
|
||||
}
|
||||
$template = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'template1.png';
|
||||
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
|
||||
$image = \think\Image::open($template);
|
||||
$image->text($name, $ziti, 50, '#00000000', $lim)
|
||||
->text('NO.ZLLJ' . (20210807001 + $max), $ziti, 30, '#00000000', [573, 660])
|
||||
->save(ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'img' . DS . $course . DS . (1 + $max) . '_' . $name . '.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取excel数据
|
||||
|
||||
Reference in New Issue
Block a user