优化项

This commit is contained in:
cun-nan 2024-01-02 18:36:47 +08:00
parent 76befae703
commit b5d55b69f1
10 changed files with 185 additions and 20 deletions

View File

@ -59,3 +59,11 @@ export function delStaff(id) {
method: 'delete'
})
}
// 生成员工码
export function createStaffQrCode(id) {
return request({
url: '/business/member/staff/qrCode/' + id,
method: 'get'
})
}

View File

@ -72,16 +72,16 @@
<dict-tag :options="dict.type.ywqx" :value="scope.row.refund"/>
</template>
</el-table-column>
<el-table-column label="核销码" align="center" prop="writeOffCode">
<template slot-scope="scope">
<span @click="getQRcode(scope.row.writeOffCode,'woc')">
<svg t="1701161298120" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4306" width="16" height="16"><path d="M384 64l-249.6 0c-51.2 0-89.6 41.6-89.6 89.6l0 227.2c0 51.2 41.6 89.6 89.6 89.6l249.6 0c51.2 0 89.6-41.6 89.6-89.6l0-227.2C473.6 105.6 435.2 64 384 64zM428.8 380.8c0 25.6-19.2 44.8-44.8 44.8l-249.6 0c-25.6 0-44.8-19.2-44.8-44.8l0-227.2c0-25.6 19.2-44.8 44.8-44.8l249.6 0c25.6 0 44.8 19.2 44.8 44.8L428.8 380.8z" p-id="4307"></path><path d="M192 192l134.4 0 0 134.4-134.4 0 0-134.4Z" p-id="4308"></path><path d="M377.6 544l-243.2 0c-48 0-86.4 38.4-86.4 89.6l0 220.8c0 48 38.4 89.6 86.4 89.6l243.2 0c48 0 86.4-38.4 86.4-89.6l0-220.8C467.2 582.4 425.6 544 377.6 544zM422.4 851.2c0 25.6-19.2 44.8-44.8 44.8l-243.2 0c-25.6 0-44.8-19.2-44.8-44.8l0-220.8c0-25.6 19.2-44.8 44.8-44.8l243.2 0c25.6 0 44.8 19.2 44.8 44.8L422.4 851.2z" p-id="4309"></path><path d="M192 668.8l131.2 0 0 131.2-131.2 0 0-131.2Z" p-id="4310"></path><path d="M633.6 470.4l249.6 0c51.2 0 89.6-41.6 89.6-89.6l0-227.2c0-51.2-41.6-89.6-89.6-89.6l-249.6 0c-51.2 0-89.6 41.6-89.6 89.6l0 227.2C544 432 585.6 470.4 633.6 470.4zM588.8 153.6c0-25.6 19.2-44.8 44.8-44.8l249.6 0c25.6 0 44.8 19.2 44.8 44.8l0 227.2c0 25.6-19.2 44.8-44.8 44.8l-249.6 0c-25.6 0-44.8-19.2-44.8-44.8L588.8 153.6z" p-id="4311"></path><path d="M700.8 192l134.4 0 0 134.4-134.4 0 0-134.4Z" p-id="4312"></path><path d="M572.8 716.8l137.6 0c12.8 0 22.4-9.6 22.4-22.4l0-137.6c0-12.8-9.6-22.4-22.4-22.4l-137.6 0c-12.8 0-22.4 9.6-22.4 22.4l0 137.6C550.4 707.2 560 716.8 572.8 716.8z" p-id="4313"></path><path d="M886.4 563.2l0 38.4c0 12.8 12.8 25.6 25.6 25.6l38.4 0c12.8 0 25.6-12.8 25.6-25.6l0-38.4c0-12.8-12.8-25.6-25.6-25.6l-38.4 0C899.2 537.6 886.4 547.2 886.4 563.2z" p-id="4314"></path><path d="M582.4 944l48 0c12.8 0 22.4-9.6 22.4-22.4l0-48c0-12.8-9.6-22.4-22.4-22.4l-48 0c-12.8 0-22.4 9.6-22.4 22.4l0 48C560 934.4 569.6 944 582.4 944z" p-id="4315"></path><path d="M944 704l-99.2 0c-16 0-28.8 12.8-28.8 28.8l0 44.8-48 0c-19.2 0-32 12.8-32 32l0 99.2c0 16 12.8 28.8 28.8 28.8l179.2 3.2c16 0 28.8-12.8 28.8-28.8l0-179.2C972.8 716.8 960 704 944 704z" p-id="4316"></path></svg>
</span>
</template>
</el-table-column>
<!-- <el-table-column label="核销码" align="center" prop="writeOffCode">-->
<!-- <template slot-scope="scope">-->
<!-- <span @click="getQRcode(scope.row.writeOffCode,'woc')">-->
<!-- <svg t="1701161298120" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4306" width="16" height="16"><path d="M384 64l-249.6 0c-51.2 0-89.6 41.6-89.6 89.6l0 227.2c0 51.2 41.6 89.6 89.6 89.6l249.6 0c51.2 0 89.6-41.6 89.6-89.6l0-227.2C473.6 105.6 435.2 64 384 64zM428.8 380.8c0 25.6-19.2 44.8-44.8 44.8l-249.6 0c-25.6 0-44.8-19.2-44.8-44.8l0-227.2c0-25.6 19.2-44.8 44.8-44.8l249.6 0c25.6 0 44.8 19.2 44.8 44.8L428.8 380.8z" p-id="4307"></path><path d="M192 192l134.4 0 0 134.4-134.4 0 0-134.4Z" p-id="4308"></path><path d="M377.6 544l-243.2 0c-48 0-86.4 38.4-86.4 89.6l0 220.8c0 48 38.4 89.6 86.4 89.6l243.2 0c48 0 86.4-38.4 86.4-89.6l0-220.8C467.2 582.4 425.6 544 377.6 544zM422.4 851.2c0 25.6-19.2 44.8-44.8 44.8l-243.2 0c-25.6 0-44.8-19.2-44.8-44.8l0-220.8c0-25.6 19.2-44.8 44.8-44.8l243.2 0c25.6 0 44.8 19.2 44.8 44.8L422.4 851.2z" p-id="4309"></path><path d="M192 668.8l131.2 0 0 131.2-131.2 0 0-131.2Z" p-id="4310"></path><path d="M633.6 470.4l249.6 0c51.2 0 89.6-41.6 89.6-89.6l0-227.2c0-51.2-41.6-89.6-89.6-89.6l-249.6 0c-51.2 0-89.6 41.6-89.6 89.6l0 227.2C544 432 585.6 470.4 633.6 470.4zM588.8 153.6c0-25.6 19.2-44.8 44.8-44.8l249.6 0c25.6 0 44.8 19.2 44.8 44.8l0 227.2c0 25.6-19.2 44.8-44.8 44.8l-249.6 0c-25.6 0-44.8-19.2-44.8-44.8L588.8 153.6z" p-id="4311"></path><path d="M700.8 192l134.4 0 0 134.4-134.4 0 0-134.4Z" p-id="4312"></path><path d="M572.8 716.8l137.6 0c12.8 0 22.4-9.6 22.4-22.4l0-137.6c0-12.8-9.6-22.4-22.4-22.4l-137.6 0c-12.8 0-22.4 9.6-22.4 22.4l0 137.6C550.4 707.2 560 716.8 572.8 716.8z" p-id="4313"></path><path d="M886.4 563.2l0 38.4c0 12.8 12.8 25.6 25.6 25.6l38.4 0c12.8 0 25.6-12.8 25.6-25.6l0-38.4c0-12.8-12.8-25.6-25.6-25.6l-38.4 0C899.2 537.6 886.4 547.2 886.4 563.2z" p-id="4314"></path><path d="M582.4 944l48 0c12.8 0 22.4-9.6 22.4-22.4l0-48c0-12.8-9.6-22.4-22.4-22.4l-48 0c-12.8 0-22.4 9.6-22.4 22.4l0 48C560 934.4 569.6 944 582.4 944z" p-id="4315"></path><path d="M944 704l-99.2 0c-16 0-28.8 12.8-28.8 28.8l0 44.8-48 0c-19.2 0-32 12.8-32 32l0 99.2c0 16 12.8 28.8 28.8 28.8l179.2 3.2c16 0 28.8-12.8 28.8-28.8l0-179.2C972.8 716.8 960 704 944 704z" p-id="4316"></path></svg>-->
<!-- </span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="员工码" align="center" prop="staffCode">
<template slot-scope="scope">
<span @click="getQRcode(scope.row.writeOffCode,'staffCode')">
<span @click="getStaffQRcode(scope.row.id)">
<svg t="1701161298120" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4306" width="16" height="16"><path d="M384 64l-249.6 0c-51.2 0-89.6 41.6-89.6 89.6l0 227.2c0 51.2 41.6 89.6 89.6 89.6l249.6 0c51.2 0 89.6-41.6 89.6-89.6l0-227.2C473.6 105.6 435.2 64 384 64zM428.8 380.8c0 25.6-19.2 44.8-44.8 44.8l-249.6 0c-25.6 0-44.8-19.2-44.8-44.8l0-227.2c0-25.6 19.2-44.8 44.8-44.8l249.6 0c25.6 0 44.8 19.2 44.8 44.8L428.8 380.8z" p-id="4307"></path><path d="M192 192l134.4 0 0 134.4-134.4 0 0-134.4Z" p-id="4308"></path><path d="M377.6 544l-243.2 0c-48 0-86.4 38.4-86.4 89.6l0 220.8c0 48 38.4 89.6 86.4 89.6l243.2 0c48 0 86.4-38.4 86.4-89.6l0-220.8C467.2 582.4 425.6 544 377.6 544zM422.4 851.2c0 25.6-19.2 44.8-44.8 44.8l-243.2 0c-25.6 0-44.8-19.2-44.8-44.8l0-220.8c0-25.6 19.2-44.8 44.8-44.8l243.2 0c25.6 0 44.8 19.2 44.8 44.8L422.4 851.2z" p-id="4309"></path><path d="M192 668.8l131.2 0 0 131.2-131.2 0 0-131.2Z" p-id="4310"></path><path d="M633.6 470.4l249.6 0c51.2 0 89.6-41.6 89.6-89.6l0-227.2c0-51.2-41.6-89.6-89.6-89.6l-249.6 0c-51.2 0-89.6 41.6-89.6 89.6l0 227.2C544 432 585.6 470.4 633.6 470.4zM588.8 153.6c0-25.6 19.2-44.8 44.8-44.8l249.6 0c25.6 0 44.8 19.2 44.8 44.8l0 227.2c0 25.6-19.2 44.8-44.8 44.8l-249.6 0c-25.6 0-44.8-19.2-44.8-44.8L588.8 153.6z" p-id="4311"></path><path d="M700.8 192l134.4 0 0 134.4-134.4 0 0-134.4Z" p-id="4312"></path><path d="M572.8 716.8l137.6 0c12.8 0 22.4-9.6 22.4-22.4l0-137.6c0-12.8-9.6-22.4-22.4-22.4l-137.6 0c-12.8 0-22.4 9.6-22.4 22.4l0 137.6C550.4 707.2 560 716.8 572.8 716.8z" p-id="4313"></path><path d="M886.4 563.2l0 38.4c0 12.8 12.8 25.6 25.6 25.6l38.4 0c12.8 0 25.6-12.8 25.6-25.6l0-38.4c0-12.8-12.8-25.6-25.6-25.6l-38.4 0C899.2 537.6 886.4 547.2 886.4 563.2z" p-id="4314"></path><path d="M582.4 944l48 0c12.8 0 22.4-9.6 22.4-22.4l0-48c0-12.8-9.6-22.4-22.4-22.4l-48 0c-12.8 0-22.4 9.6-22.4 22.4l0 48C560 934.4 569.6 944 582.4 944z" p-id="4315"></path><path d="M944 704l-99.2 0c-16 0-28.8 12.8-28.8 28.8l0 44.8-48 0c-19.2 0-32 12.8-32 32l0 99.2c0 16 12.8 28.8 28.8 28.8l179.2 3.2c16 0 28.8-12.8 28.8-28.8l0-179.2C972.8 716.8 960 704 944 704z" p-id="4316"></path></svg>
</span>
</template>
@ -112,11 +112,11 @@
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="更新时间" align="center" prop="updateTime" width="150">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime) }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="更新时间" align="center" prop="updateTime" width="150">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.updateTime) }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -573,7 +573,7 @@
<script>
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;

View File

@ -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;

View File

@ -183,7 +183,12 @@
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>2.1.0</version>
</dependency>
<!-- 二维码所需依赖-->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.3</version>
</dependency>
</dependencies>

View File

@ -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

View File

@ -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<LJStaff> {
*/
public int updateStaff(LJStaff staff);
public void createStaffQrCode(int id, HttpServletRequest request);
/**
* 设定安全的密码生成随机的salt并经过1024次 sha-1 hash
*/

View File

@ -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<LJStaffMapper, LJStaff> 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<LJStaffMapper, LJStaff> 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);

View File

@ -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);
}
}

View File

@ -62,7 +62,7 @@
if (res.code==200){
uni.showToast({
title:"反馈成功!",
icon:none,
icon:"none",
})
this.reset()
}

View File

@ -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"
})
}
}
}