From b5d55b69f1086a514136adb5d43a428c45c0a634 Mon Sep 17 00:00:00 2001
From: cun-nan <19819293608@163.com>
Date: Tue, 2 Jan 2024 18:36:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
fuintAdmin/src/api/staff/staff.js | 8 ++
fuintAdmin/src/views/staff/list.vue | 35 ++++---
.../src/views/staff/storeInfo/index.vue | 2 +-
fuintBackend/fuint-application/pom.xml | 7 +-
.../member/controller/LJStaffController.java | 7 ++
.../member/service/ILJStaffService.java | 3 +
.../service/impl/LJStaffServiceImpl.java | 39 ++++++++
.../business/member/utils/QrCodeUtils.java | 95 +++++++++++++++++++
gasStation-uni/pagesMy/feedback/feedback.vue | 2 +-
gasStation-uni/pagesMy/setup/index.vue | 7 +-
10 files changed, 185 insertions(+), 20 deletions(-)
create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java
diff --git a/fuintAdmin/src/api/staff/staff.js b/fuintAdmin/src/api/staff/staff.js
index 0b1b01c11..6f6a7a112 100644
--- a/fuintAdmin/src/api/staff/staff.js
+++ b/fuintAdmin/src/api/staff/staff.js
@@ -59,3 +59,11 @@ export function delStaff(id) {
method: 'delete'
})
}
+
+// 生成员工码
+export function createStaffQrCode(id) {
+ return request({
+ url: '/business/member/staff/qrCode/' + id,
+ method: 'get'
+ })
+}
diff --git a/fuintAdmin/src/views/staff/list.vue b/fuintAdmin/src/views/staff/list.vue
index fa5171c2b..dd0810621 100644
--- a/fuintAdmin/src/views/staff/list.vue
+++ b/fuintAdmin/src/views/staff/list.vue
@@ -72,16 +72,16 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
@@ -112,11 +112,11 @@
{{ parseTime(scope.row.createTime) }}
-
-
- {{ parseTime(scope.row.updateTime) }}
-
-
+
+
+
+
+
import QRCode from 'qrcode'
import {getName} from "../../utils/fuint";
-import {addStaff, delStaff, getStaff, listStaff, queryStaff, updateStaff} from "@/api/staff/staff";
+import {addStaff, createStaffQrCode, delStaff, getStaff, listStaff, queryStaff, updateStaff} from "@/api/staff/staff";
import {getDuty, listDuty} from "@/api/staff/duty";
export default {
@@ -730,6 +730,13 @@ export default {
// this.getStoreList();
},
methods: {
+ // 获取员工码
+ getStaffQRcode(id){
+ console.log(id)
+ createStaffQrCode(id).then(res => {
+ console.log(res)
+ })
+ },
// 根据字符串获取二维码图片url地址
getQRcode(code,name){
this.type = name;
diff --git a/fuintAdmin/src/views/staff/storeInfo/index.vue b/fuintAdmin/src/views/staff/storeInfo/index.vue
index ecc2eeea2..9ebe46231 100644
--- a/fuintAdmin/src/views/staff/storeInfo/index.vue
+++ b/fuintAdmin/src/views/staff/storeInfo/index.vue
@@ -152,7 +152,7 @@ export default {
getStore() {
ljStoreInfo().then(response => {
this.store = response.data
- console.log(response.data)
+ // console.log(response.data)
this.$emit("getUrl",this.store)
this.form.lat = this.store.latitude;
this.form.lng = this.store.longitude;
diff --git a/fuintBackend/fuint-application/pom.xml b/fuintBackend/fuint-application/pom.xml
index 13d4239fe..43b16ac1d 100644
--- a/fuintBackend/fuint-application/pom.xml
+++ b/fuintBackend/fuint-application/pom.xml
@@ -183,7 +183,12 @@
aliyun-java-sdk-dysmsapi
2.1.0
-
+
+
+ com.google.zxing
+ core
+ 3.3.3
+
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/controller/LJStaffController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/controller/LJStaffController.java
index e62c9da6c..41c37c665 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/controller/LJStaffController.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/controller/LJStaffController.java
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@@ -70,6 +71,12 @@ public class LJStaffController extends BaseController {
return getSuccessResult(staff);
}
+ @GetMapping("/qrCode/{id}")
+ public ResponseObject createStaffQrCode(HttpServletRequest request, @PathVariable Integer id){
+ mtStaffService.createStaffQrCode(id,request);
+ return getSuccessResult("ok");
+ }
+
/**
* 根据id查询员工信息
* @param map
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/ILJStaffService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/ILJStaffService.java
index d53c8d3e1..5caad4c85 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/ILJStaffService.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/ILJStaffService.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.member.entity.LJStaff;
+import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -64,6 +65,8 @@ public interface ILJStaffService extends IService {
*/
public int updateStaff(LJStaff staff);
+ public void createStaffQrCode(int id, HttpServletRequest request);
+
/**
* 设定安全的密码,生成随机的salt并经过1024次 sha-1 hash
*/
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/impl/LJStaffServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/impl/LJStaffServiceImpl.java
index 38921c7d9..78d1a3da4 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/impl/LJStaffServiceImpl.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/service/impl/LJStaffServiceImpl.java
@@ -8,22 +8,32 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.member.entity.LJStaff;
import com.fuint.business.member.mapper.LJStaffMapper;
import com.fuint.business.member.service.ILJStaffService;
+import com.fuint.business.storeInformation.entity.LJStore;
+import com.fuint.business.storeInformation.service.ILJStoreService;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.service.AccountService;
import com.fuint.common.util.StringUtils;
import com.fuint.common.util.TokenUtil;
+import com.fuint.framework.web.ResponseObject;
+import com.fuint.module.backendApi.controller.BackendFileController;
import com.fuint.repository.model.TAccount;
import com.fuint.utils.Digests;
import com.fuint.utils.Encodes;
import jdk.nashorn.internal.parser.Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
+import static com.fuint.business.member.utils.QrCodeUtils.createLogoCodePicture;
+
/**
* 员工管理 业务层
*/
@@ -125,6 +135,10 @@ public class LJStaffServiceImpl extends ServiceImpl impl
}
int row = baseMapper.insert(staff);
LJStaff staff1 = this.selectStaffByMobile(staff.getMobile());
+// 添加员工码
+ staff1.setStaffCode("https://www.tuofeng.cc/oilRefuel?storeId="+storeId+"&staffId="+staff1.getId());
+ this.updateStaff(staff1);
+
// 添加账户信息
TAccount account = new TAccount();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
@@ -160,6 +174,31 @@ public class LJStaffServiceImpl extends ServiceImpl impl
return row;
}
+ @Autowired
+ private ILJStoreService storeService;
+ @Autowired
+ private BackendFileController backendFileController;
+
+ @Override
+ public void createStaffQrCode(int id, HttpServletRequest request) {
+// 根据id查询员工信息和店铺信息
+ LJStaff staff = this.selectStaffById(id);
+ LJStore store = storeService.selectStoreByStoreId(staff.getStoreId());
+ //在图片上生成二维码
+ String backgroundImage = "D:/ruoyi/qrCode/cailibao_bg.jpg";
+ String logoImage = "D:/ruoyi/qrCode/logo.png";
+ String url = staff.getStaffCode();
+ String area = store.getName();
+ String finalPath="D:/ruoyi/qrCode/" + area + ".jpg";
+ //背景图片路径 loge图片 二维码 输出地址
+ createLogoCodePicture(backgroundImage, logoImage, url, finalPath, area,store.getAddress());
+
+// 返回图片路径
+ ResponseObject responseObject = backendFileController.uploadFileLocal(request);
+ System.out.println(responseObject.getData());
+// staff.setStaffCode("/statics"+url1.split("/statics")[1]);
+ }
+
@Override
public void entryptPassword(LJStaff staff) {
byte[] salt = Digests.generateSalt(8);
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java
new file mode 100644
index 000000000..55745866f
--- /dev/null
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/utils/QrCodeUtils.java
@@ -0,0 +1,95 @@
+package com.fuint.business.member.utils;
+
+import cn.hutool.extra.qrcode.QrCodeUtil;
+import cn.hutool.extra.qrcode.QrConfig;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import org.springframework.util.ResourceUtils;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * @Description: QrCodeUtils
+ * @Author xiaoyafeng
+ * @Date 2023/1/12 0012 13:38
+ * @Version 1.0
+ */
+public class QrCodeUtils {
+ /***
+ * 在一张背景图上添加二维码
+ */
+ public static void createLogoCodePicture(String roundImage, String logoImage, String url, String outImgPath, String storeName, String storeNumber) {
+ try {
+ // 读取原图片信息
+ //得到文件
+ File file = ResourceUtils.getFile(roundImage);
+ //文件转化为图片
+ Image srcImg = ImageIO.read(file);
+ //获取图片的宽
+ int srcImgWidth = srcImg.getWidth(null);
+ //获取图片的高
+ int srcImgHeight = srcImg.getHeight(null);
+ // 加水印
+ BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g = bufImg.createGraphics();
+ g.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null);
+ //使用工具类生成二维码
+ Image image = createQrCode(logoImage, url, 360, 360);
+ //将小图片绘到大图片上,500,300 .表示你的小图片在大图片上的位置。
+ g.drawImage(image, 260, 320, null);
+ // 设置字体,样式,字体大小
+ g.setFont(new Font("TimesRoman", Font.BOLD, 50));
+ //设置颜色。
+ g.setColor(Color.BLACK);
+ // 店铺名称位置文字绘制到指定位置
+ g.drawString(storeName, 290, 880);
+// // 将码牌编号文字绘制到指定位置
+ g.drawString(storeNumber, 290, 800);
+ g.dispose();
+ // 输出图片
+
+ FileOutputStream outImgStream = new FileOutputStream(outImgPath);
+ ImageIO.write(bufImg, "jpg", outImgStream);
+ outImgStream.flush();
+ outImgStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 将字符串转为二维码
+ *
+ * @param roundImage
+ * @param url
+ * @param width
+ * @param height
+ * @return
+ * @throws IOException
+ */
+ private static BufferedImage createQrCode(String roundImage, String url, int width, int height) throws IOException {
+ QrConfig config = new QrConfig(width, height);
+ Image image = ImageIO.read(new FileInputStream(roundImage));
+ config.setImg(image);
+ config.setMargin(1);
+ config.setErrorCorrection(ErrorCorrectionLevel.H);
+ return QrCodeUtil.generate(url, config);
+ }
+
+ public static void main(String[] args) {
+ //在图片上生成二维码
+ String backgroundImage = "D:/ruoyi/qrCode/laigeyouhui_bg.jpg";
+ String logoImage = "D:/ruoyi/qrCode/logo.png";
+ String url = "https://www.baidu.com";
+ String area = "来个油慧测试店铺";
+ String room = "lgyh15487";
+ String outImgPath = "D:/ruoyi/qrCode/" + area + ".jpg";
+ //背景图片路径 loge图片 二维码 输出地址 病区 病房号 床号
+ createLogoCodePicture(backgroundImage, logoImage, url, outImgPath, area, room);
+ }
+}
\ No newline at end of file
diff --git a/gasStation-uni/pagesMy/feedback/feedback.vue b/gasStation-uni/pagesMy/feedback/feedback.vue
index ff703fa59..d610829f2 100644
--- a/gasStation-uni/pagesMy/feedback/feedback.vue
+++ b/gasStation-uni/pagesMy/feedback/feedback.vue
@@ -62,7 +62,7 @@
if (res.code==200){
uni.showToast({
title:"反馈成功!",
- icon:none,
+ icon:"none",
})
this.reset()
}
diff --git a/gasStation-uni/pagesMy/setup/index.vue b/gasStation-uni/pagesMy/setup/index.vue
index 7782efd47..af12a9c36 100644
--- a/gasStation-uni/pagesMy/setup/index.vue
+++ b/gasStation-uni/pagesMy/setup/index.vue
@@ -72,7 +72,6 @@
let _this = this;
let tempFilePath = e.detail.avatarUrl //上传的图片地址
let maxSizeInBytes = 1024*1024 //限制大小
- console.log(111)
uni.getFileInfo({
filePath:tempFilePath,
success(res) {
@@ -94,7 +93,7 @@
_this.user.avatar = res.data.fileName
_this.editUser()
})
- }
+ },
})
},
// 修改用户信息
@@ -127,7 +126,9 @@
})
},
goBack() {
- uni.navigateBack()
+ uni.navigateTo({
+ url:"/pages/my/my"
+ })
}
}
}