Merge remote-tracking branch 'origin/zcc'

This commit is contained in:
wangjinlei
2024-01-05 17:07:06 +08:00
5 changed files with 336 additions and 1 deletions

View File

@@ -0,0 +1,164 @@
package com.peanut.common.utils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CertificateUtil extends Thread{
String inputSrc;
String outputSrc;
String no;
String name;
String time;
String des;
String trans;
String trans2;
String trans3;
String endy;
String endm;
String endd;
public CertificateUtil(String inputSrc,String outputSrc,String no,String name,String time,
String des,String trans,String trans2,String trans3,String endy,String endm,String endd){
this.inputSrc=inputSrc;
this.outputSrc = outputSrc;
this.no = no;
this.name = name;
this.time = time;
this.des = des;
this.trans = trans;
this.trans2 = trans2;
this.trans3 = trans3;
this.endy = endy;
this.endm = endm;
this.endd = endd;
}
@Override
public void run() {
Date startTime = new Date();
System.out.println(name+"-开始!");
try {
Image src = ImageIO.read(new File(inputSrc));
// 获取图片的高和宽
int wideth = src.getWidth(null);
int height = src.getHeight(null);
// 新增一个图片缓冲
BufferedImage image = new BufferedImage(wideth, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(src, 0, 0, wideth, height, null);
// 设置字体颜色颜色也可以直接new定义rgba例如new Color(17, 16, 44)
g.setColor(new Color(51,82,132));
// size字体大小Font.BOLD字体加粗
g.setFont(new Font("Arial", Font.BOLD, 80));
FontMetrics metrics = g.getFontMetrics();
int nox = (wideth - metrics.stringWidth(no))/2;
int noy = 1405 - metrics.getHeight();//1305
g.drawString(no, nox, noy);
// 设置字体颜色颜色也可以直接new定义rgba例如new Color(17, 16, 44)
g.setColor(Color.BLACK);
// size字体大小Font.BOLD字体加粗
g.setFont(new Font("宋体", Font.BOLD, 150));
FontMetrics metricss = g.getFontMetrics();
int namex = (wideth - metricss.stringWidth(name))/2;
int namey = 2055 - metricss.getHeight();//1935
g.drawString(name, namex, namey);
g.setFont(new Font("宋体", Font.BOLD, 115));
FontMetrics times = g.getFontMetrics();
int timex = (wideth - times.stringWidth(time))/2;
int timey = 2370 - times.getHeight();//2270
g.drawString(time, timex, timey);
FontMetrics dess = g.getFontMetrics();
int desx = (wideth - dess.stringWidth(des))/2;
int desy = 2635 - dess.getHeight();//2535
g.drawString(des, desx, desy);
g.setFont(new Font("Arial", Font.BOLD, 75));
FontMetrics transs = g.getFontMetrics();
int transx = (wideth - transs.stringWidth(trans))/2;
int transy = 2735 - transs.getHeight();//2685
g.drawString(trans, transx, transy);
FontMetrics trans2s = g.getFontMetrics();
int trans2x = (wideth - trans2s.stringWidth(trans2))/2;
g.drawString(trans2, trans2x, transy+120);
FontMetrics trans3s = g.getFontMetrics();
int trans3x = (wideth - trans3s.stringWidth(trans3))/2;
g.drawString(trans3, trans3x, transy+240);
g.setFont(new Font("宋体", Font.BOLD, 80));
g.drawString(endy,1800,3440);
g.drawString(endm,2090,3440);
g.drawString(endd,2250,3440);
// 释放资源
g.dispose();
File outputfile = new File(outputSrc+name+".png");
ImageIO.write(image, "png", outputfile);
Date endTime = new Date();
System.out.println(endTime.getTime()-startTime.getTime() + "");
System.out.println(name+"-生成完成!");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws Exception{
String nameflie = "F:\\aimg\\name.txt"; //人名,一列
String inputSrc = "F:\\aimg\\c.png"; //图片模板
String outputSrc = "F:\\aimg\\形质病\\"; //生成地址
String no = "No.XZB202401";
int nostart = 0;
String time = "于2024年1月4日至5日";
String des = "圆满完成中医形质病学培训班";
String trans = "Successful completion of the";
String trans2 = "Chinese Medicine Morphology and Disease Training";
String trans3 = "course on 2024 1.4-5";
//Traditional Chinese Medicine Morphology and Disease Training Course
String endy = "2024";
String endm = "1";
String endd = "6";
// 1、创建服务创建线程池
ExecutorService service = Executors.newFixedThreadPool(30);
try (BufferedReader br = new BufferedReader(new FileReader(nameflie))) {
String line;
while ((line = br.readLine()) != null) {
// 对每一行进行处理
nostart++;
CertificateUtil c1 = new CertificateUtil(inputSrc,outputSrc,no+String.format("%03d",nostart),line,
time,des,trans,trans2,trans3,endy,endm,endd);
service.execute(c1);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -75,6 +75,7 @@ public class ShiroConfig {
filterMap.put("/swagger-resources/**", "anon");
filterMap.put("/captcha.jpg", "anon");
filterMap.put("/aaa.txt", "anon");
filterMap.put("/visitor/**","anon");//游客访问接口
filterMap.put("/**", "oauth2");
filterMap.put("/cent/**","anon");

View File

@@ -117,6 +117,7 @@ public class MedicaldesController {
if (map.containsKey("name")&&StringUtils.isNotEmpty(map.get("name").toString())){
wrapper.like(MedicaldesInherit::getName,map.get("name"));
}
wrapper.selectAs(MedicaldesInheritRelation::getTypeId,"type");
Page<MedicaldesInherit> page = inheritService.page(new Page<>(
Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())),wrapper);
return R.ok().put("result", page);

View File

@@ -34,7 +34,7 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
public PageUtils appQueryPage(Map<String, Object> params) {
IPage<ShopProduct> page = this.page(
new Query<ShopProduct>().getPage(params),
new QueryWrapper<ShopProduct>().orderByDesc("create_time")
new QueryWrapper<ShopProduct>().orderByAsc("sort")
.like("product_name", params.get("key"))
);
return new PageUtils(page);

View File

@@ -0,0 +1,169 @@
package com.peanut.modules.sys.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.PageUtils;
import com.peanut.common.utils.R;
import com.peanut.modules.book.dao.ShopProductToLabelDao;
import com.peanut.modules.book.entity.*;
import com.peanut.modules.book.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@Slf4j
@RestController
@RequestMapping("/visitor")
public class VisitorController {
@Autowired
private ShopProductService shopProductService;
@Autowired
private ShopProductToLabelDao shopProductToLabelDao;
@Autowired
private ShopProductLabelService shopProductLabelService;
@Autowired
private ShopCategoryService shopCategoryService;
@Autowired
private BookService bookService;
@Autowired
private ShopProductBookService shopProductBookService;
@Autowired
private ShopProductToLabelService shopProductToLabelService;
@Autowired
private UserRecordService userRecordService;
@Autowired
private MyUserService myUserService;
@Autowired
private UserFollowUpService userFollowUpService;
//新书
@RequestMapping("/getNewBook")
public R getNewBook(@RequestParam Map<String, Object> params) {
PageUtils page = shopProductService.getNewBook(params);
return R.ok().put("page", page);
}
/**
* 获取商品列表通过标签
* @return
*/
@RequestMapping("/getProductsByLabel")
public R getProductsByLabel(@RequestParam Integer splId,@RequestParam Integer limit,@RequestParam Integer page){
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
shopProductEntityMPJLambdaWrapper.selectAll(ShopProduct.class);
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProduct.class, ShopProduct::getProductId,ShopProductToLabelEntity::getProductId);
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId);
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
shopProductEntityMPJLambdaWrapper.eq(ShopProduct::getDelFlag,0);
shopProductEntityMPJLambdaWrapper.gt(ShopProduct::getProductStock,0);
Page<ShopProduct> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProduct>(page, limit), ShopProduct.class, shopProductEntityMPJLambdaWrapper);
return R.ok().put("page",shopProductEntityPage);
}
@RequestMapping("/getLabels")
public R getLabels(){
List<ShopProductLabelEntity> shopProductLabelEntities = shopProductLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductLabelEntity>()
.eq("del_flag",0));
Map re = new HashMap();
re.put("labels",shopProductLabelEntities);
return R.ok().put("result",re);
}
/**
* 信息
*
* @param productId
* @return
*/
@RequestMapping("/info/{productId}")
public R info(@PathVariable("productId") Integer productId) {
ShopProduct shopProduct = shopProductService.getBaseMapper().selectOne(new QueryWrapper<ShopProduct>().eq("product_id", productId).eq("del_flag", 0));
if (shopProduct == null) {
return R.error("该商品已下架,看看其他商品吧");
}
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
Integer poid = shopProduct.getProductPid();
Integer productId1 = shopProduct.getProductId();
List<Integer> poids = shopCategoryService.findPoid(poid);
shopProduct.setPoids(poids);
List<Object> list = new ArrayList<>();
List<Object> bookIdlist = new ArrayList<>();
ArrayList<String> booklist = new ArrayList<>();
List<ShopProductBookEntity> product = shopProductBookService.getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>()
.eq("product_id", productId1));
for (ShopProductBookEntity shopProductBookEntity : product) {
Integer id = shopProductBookEntity.getId();
Integer bookId = shopProductBookEntity.getBookId();
BookEntity byId = bookService.getById(bookId);
bookIdlist.add(id);
booklist.add(String.valueOf(bookId));
list.add(byId);
}
//添加获取标签逻辑
List<ShopProductToLabelEntity> shopProductToLabelEntities = shopProductToLabelService.getBaseMapper().selectList(new QueryWrapper<ShopProductToLabelEntity>()
.eq("product_id", productId).eq("del_flag", 0));
List labelList = new ArrayList();
for (ShopProductToLabelEntity sp : shopProductToLabelEntities) {
labelList.add(sp.getSplId());
}
shopProduct.setBookidsimages(list);
shopProduct.setBookids(booklist);
shopProduct.setShoproudIds(bookIdlist);
return R.ok().put("shopProduct", shopProduct).put("labels", labelList);
}
/**
* 查看全部评价
*/
@RequestMapping("/All")
public R All(@RequestBody UserRecord userRecordEntity) {
List list = new ArrayList<>();
//此处bookid实际传的是商品id
List<UserRecord> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecord>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
if (bookid != null) {
for (UserRecord userRecord : bookid) {
HashMap<Object, Object> map = new HashMap<>();
Integer bookid1 = userRecord.getBookid();
Integer userid1 = userRecord.getUserid();
Integer id1 = userRecord.getId();
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
String usser = "";
String name = "";
for (MyUserEntity user : id) {
usser = user.getAvatar();
name = user.getNickname();
}
List<UserFollowUpEntity> followUpEntity = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>()
.eq("oid", id1)
.eq("userId", userid1)
.orderByDesc("create_date"));
String conTent = "";
Date date = null;
for (UserFollowUpEntity followUp : followUpEntity) {
conTent = followUp.getConTent();
date = followUp.getCreateDate();
}
map.put("followUpdate", date);
map.put("followUpcontent", conTent);
map.put("avatar", usser);
map.put("name", name);
map.put("bookid", bookid1);
map.put("orderSn", userRecord.getOrderSn());
map.put("userid", userid1);
map.put("content", userRecord.getContent());
map.put("images", userRecord.getImages());
map.put("starlevel", userRecord.getStarLevel());
map.put("createdate", userRecord.getCreateDate());
list.add(map);
}
return R.ok().put("list", list);
}
return R.error("该商品暂无评论");
}
}