|
@@ -54,50 +54,51 @@ class Trace extends Command
|
|
|
$this->line('-----------traceing---------');
|
|
|
$metas = Meta::where('status', 0)->get();
|
|
|
foreach ($metas as $meta) {
|
|
|
- $this->line('------开始:' . $meta['patch_num']);
|
|
|
- $this->save_dir = storage_path($meta['patch_num']);
|
|
|
- if (!is_dir($this->save_dir)) {
|
|
|
- mkdir($this->save_dir);
|
|
|
- }
|
|
|
- //1.生成txt
|
|
|
- $this->line('------开始生成txt:' . $meta['patch_num']);
|
|
|
- $myfile = fopen($this->save_dir . "/批次信息.txt", "w");
|
|
|
- $txt = "批次号:{$meta['patch_num']}\n";
|
|
|
- $txt .= "鸡种:{$meta['variety']}\n";
|
|
|
- $txt .= "年龄:{$meta['age']}\n";
|
|
|
- $txt .= "口粮:{$meta['food']}\n";
|
|
|
- $txt .= "水源:{$meta['water']}\n";
|
|
|
- fwrite($myfile, $txt);
|
|
|
- fclose($myfile);
|
|
|
- //2.生成质检信息
|
|
|
- $this->line('------开始生成质检信息:' . $meta['patch_num']);
|
|
|
- $myfile = fopen($this->save_dir . "/质检信息.html", "w");
|
|
|
- $txt = $meta['report'];
|
|
|
- fwrite($myfile, $txt);
|
|
|
- fclose($myfile);
|
|
|
- $this->line('------开始下载图片:' . $meta['patch_num']);
|
|
|
- $varietyImg = $this->downloadImg($this->save_dir, $meta['variety_img'], '鸡种');
|
|
|
- $foodImg = $this->downloadImg($this->save_dir, $meta['food_img'], '口粮');
|
|
|
- $waterImg = $this->downloadImg($this->save_dir, $meta['water_img'], '水源');
|
|
|
- $farms = \GuzzleHttp\json_decode($meta['farm'], true);
|
|
|
- foreach ($farms as $k => $v) {
|
|
|
- $farmImg = $this->downloadImg($this->save_dir, $v, '农场' . ($k + 1));
|
|
|
- }
|
|
|
- //生成zip包
|
|
|
- $this->line('------开始生成ZIP:' . $meta['patch_num']);
|
|
|
- $zipPath = storage_path() . '/' . $meta['patch_num'] . ".zip";
|
|
|
- $zip = Zip::create($zipPath);
|
|
|
- $zip->add($this->save_dir, true);
|
|
|
- $zip->close();
|
|
|
- $md5 = md5_file($zipPath);
|
|
|
- $this->line('------ZIP包MD5码:' . $md5);
|
|
|
-
|
|
|
- $zipUrl = Storage::put('/trace/' . date('Ym'), file_get_contents($zipPath));
|
|
|
- $data = [
|
|
|
- 'md5' => $md5,
|
|
|
- 'zip' => $zipUrl
|
|
|
- ];
|
|
|
- $this->line('zip地址:' . $zipUrl);
|
|
|
+// $this->line('------开始:' . $meta['patch_num']);
|
|
|
+// $this->save_dir = storage_path($meta['patch_num']);
|
|
|
+// if (!is_dir($this->save_dir)) {
|
|
|
+// mkdir($this->save_dir);
|
|
|
+// }
|
|
|
+// //1.生成txt
|
|
|
+// $this->line('------开始生成txt:' . $meta['patch_num']);
|
|
|
+// $myfile = fopen($this->save_dir . "/批次信息.txt", "w");
|
|
|
+// $txt = "批次号:{$meta['patch_num']}\n";
|
|
|
+// $txt .= "鸡种:{$meta['variety']}\n";
|
|
|
+// $txt .= "年龄:{$meta['age']}\n";
|
|
|
+// $txt .= "口粮:{$meta['food']}\n";
|
|
|
+// $txt .= "水源:{$meta['water']}\n";
|
|
|
+// fwrite($myfile, $txt);
|
|
|
+// fclose($myfile);
|
|
|
+// //2.生成质检信息
|
|
|
+// $this->line('------开始生成质检信息:' . $meta['patch_num']);
|
|
|
+// $myfile = fopen($this->save_dir . "/质检信息.html", "w");
|
|
|
+// $txt = $meta['report'];
|
|
|
+// fwrite($myfile, $txt);
|
|
|
+// fclose($myfile);
|
|
|
+// $this->line('------开始下载图片:' . $meta['patch_num']);
|
|
|
+// $varietyImg = $this->downloadImg($this->save_dir, $meta['variety_img'], '鸡种');
|
|
|
+// $foodImg = $this->downloadImg($this->save_dir, $meta['food_img'], '口粮');
|
|
|
+// $waterImg = $this->downloadImg($this->save_dir, $meta['water_img'], '水源');
|
|
|
+// $farms = \GuzzleHttp\json_decode($meta['farm'], true);
|
|
|
+// foreach ($farms as $k => $v) {
|
|
|
+// $farmImg = $this->downloadImg($this->save_dir, $v, '农场' . ($k + 1));
|
|
|
+// }
|
|
|
+// //生成zip包
|
|
|
+// $this->line('------开始生成ZIP:' . $meta['patch_num']);
|
|
|
+// $zipPath = storage_path() . '/' . $meta['patch_num'] . ".zip";
|
|
|
+// $zip = Zip::create($zipPath);
|
|
|
+// $zip->add($this->save_dir, true);
|
|
|
+// $zip->close();
|
|
|
+// $md5 = md5_file($zipPath);
|
|
|
+// $this->line('------ZIP包MD5码:' . $md5);
|
|
|
+//
|
|
|
+// $zipUrl = Storage::put('/trace/' . date('Ym'), file_get_contents($zipPath));
|
|
|
+// $data = [
|
|
|
+// 'md5' => $md5,
|
|
|
+// 'zip' => $zipUrl
|
|
|
+// ];
|
|
|
+// $this->line('zip地址:' . $zipUrl);
|
|
|
+ $md5 = md5(time());
|
|
|
$this->line('------开始上链:' . $md5);
|
|
|
$row = $this->transcation($md5);
|
|
|
$this->line('------上链结果:' . var_export($row, true));
|