提交修改
This commit is contained in:
parent
aa28ab1b24
commit
34a86db0f5
@ -38,6 +38,8 @@ public interface VvCategoryPropertyDao extends BaseMapper<VvCategoryPropertyEnti
|
|||||||
int updateCoverVvCategoryPropertyById(VvCategoryPropertyEntity vvCategoryProperty);
|
int updateCoverVvCategoryPropertyById(VvCategoryPropertyEntity vvCategoryProperty);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Realy
|
||||||
int deleteVvCategoryPropertyById(@Param("id") Long id);
|
int deleteVvCategoryPropertyById(@Param("id") Long id);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.lz.mybatis.plugin.annotations.IN;
|
import com.lz.mybatis.plugin.annotations.IN;
|
||||||
import com.lz.mybatis.plugin.annotations.OrderBy;
|
import com.lz.mybatis.plugin.annotations.OrderBy;
|
||||||
import com.lz.mybatis.plugin.annotations.OrderType;
|
import com.lz.mybatis.plugin.annotations.OrderType;
|
||||||
|
import com.lz.mybatis.plugin.annotations.Realy;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ public interface VvCategoryPropertyValueDao extends BaseMapper<VvCategoryPropert
|
|||||||
int updateCoverVvCategoryPropertyValueById(VvCategoryPropertyValueEntity vvCategoryPropertyValue);
|
int updateCoverVvCategoryPropertyValueById(VvCategoryPropertyValueEntity vvCategoryPropertyValue);
|
||||||
|
|
||||||
|
|
||||||
|
@Realy
|
||||||
int deleteVvCategoryPropertyValueById(@Param("id")Long id);
|
int deleteVvCategoryPropertyValueById(@Param("id")Long id);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -93,5 +93,5 @@ public interface OssFileUploadService {
|
|||||||
|
|
||||||
public List<Map<String, Object>> uploadImages(MultipartFile[] files);
|
public List<Map<String, Object>> uploadImages(MultipartFile[] files);
|
||||||
|
|
||||||
|
OssUploadResult uploadImageToOss(InputStream inputStream,String oss_buccket, String fileName, int fileSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,6 +124,39 @@ public class OssFileUploadServiceImpl implements OssFileUploadService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OssUploadResult uploadImageToOss(InputStream inputStream,String buccket, String fileName, int fileSize) {
|
||||||
|
OssUploadResult result = new OssUploadResult();
|
||||||
|
try {
|
||||||
|
String path = env + "/";
|
||||||
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
|
metadata.setContentLength(fileSize);
|
||||||
|
metadata.setContentType(this.getImageFileContentType(fileName));
|
||||||
|
PutObjectResult pubResult = ossClient.putObject(buccket, path + fileName, inputStream, metadata);
|
||||||
|
|
||||||
|
if (pubResult == null || StringUtils.isBlank(pubResult.getETag())) {
|
||||||
|
log.error("upload to oss error, put object result is null or etag is empty, fileName {}", fileName);
|
||||||
|
result.setSuccess(false);
|
||||||
|
result.setMsg("upload to oss error, put object result is null or etag is empty");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setMsg("upload inputStream to oss succeed");
|
||||||
|
result.setFileMd5(pubResult.getETag());
|
||||||
|
result.setUrl(oss_url + path + fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("upload inputStream to oss error", e);
|
||||||
|
result.setSuccess(false);
|
||||||
|
result.setMsg("upload inputStream to oss error, message is " + e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OssUploadResult uploadImageToOssAsync(InputStream inputStream, String fileName, int fileSize) {
|
public OssUploadResult uploadImageToOssAsync(InputStream inputStream, String fileName, int fileSize) {
|
||||||
return this.uploadImageToOss(inputStream, fileName, fileSize);
|
return this.uploadImageToOss(inputStream, fileName, fileSize);
|
||||||
|
|||||||
@ -1,5 +1,15 @@
|
|||||||
package com.heyu.api.data.utils;
|
package com.heyu.api.utils;
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.WriterException;
|
||||||
|
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
import com.heyu.api.data.utils.LineChartDTO;
|
||||||
|
import com.heyu.api.oss.OssFileUploadService;
|
||||||
|
import com.heyu.api.oss.OssUploadResult;
|
||||||
import com.lz.mybatis.plugin.utils.OsUtil;
|
import com.lz.mybatis.plugin.utils.OsUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jfree.chart.ChartFactory;
|
import org.jfree.chart.ChartFactory;
|
||||||
@ -23,11 +33,13 @@ import org.jfree.data.category.CategoryDataset;
|
|||||||
import org.jfree.data.general.DatasetUtilities;
|
import org.jfree.data.general.DatasetUtilities;
|
||||||
import org.jfree.data.general.DefaultPieDataset;
|
import org.jfree.data.general.DefaultPieDataset;
|
||||||
import org.jfree.data.general.PieDataset;
|
import org.jfree.data.general.PieDataset;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileOutputStream;
|
import java.nio.file.FileSystems;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -55,6 +67,16 @@ public class ChartUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OssFileUploadService ossFileUploadService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ChartUtil pm = new ChartUtil();
|
ChartUtil pm = new ChartUtil();
|
||||||
// // 生成饼状图
|
// // 生成饼状图
|
||||||
@ -117,6 +139,42 @@ public class ChartUtil {
|
|||||||
createTimeXYChar("七日同比还款数据", "16点", "repay percent %", dataset, "/repayChart.jpg");
|
createTimeXYChar("七日同比还款数据", "16点", "repay percent %", dataset, "/repayChart.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String generateQRCodeImage(String text, int width, int height, String fileName) throws WriterException, IOException {
|
||||||
|
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||||
|
Map<EncodeHintType, Object> hints = new HashMap<>();
|
||||||
|
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); // 设置纠错等级,L、M、Q、H
|
||||||
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); // 设置编码格式为UTF-8
|
||||||
|
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height, hints);
|
||||||
|
String filePath = CHART_PATH + "/" + fileName;
|
||||||
|
Path path = FileSystems.getDefault().getPath(filePath);
|
||||||
|
MatrixToImageWriter.writeToPath(bitMatrix, "jpeg", path); // 输出图片格式为PNG,也可以改为JPG等其他格式
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String generateQRCodeUp2Oss(String text) {
|
||||||
|
try {
|
||||||
|
String filePath = ChartUtil.generateQRCodeImage(text, 300, 300, System.currentTimeMillis() + ".png"); // 生成二维码并保存到文件系统
|
||||||
|
|
||||||
|
File file1 = new File(filePath);
|
||||||
|
|
||||||
|
String picUrl = "/qrcode" + System.currentTimeMillis() + ".jpg";
|
||||||
|
|
||||||
|
InputStream inputStream = new FileInputStream(file1);
|
||||||
|
|
||||||
|
OssUploadResult ossUploadResult = ossFileUploadService.uploadImageToOss(inputStream, picUrl, Integer.parseInt(String.valueOf(file1.length())));
|
||||||
|
|
||||||
|
//file1.delete();
|
||||||
|
|
||||||
|
String url = ossUploadResult.getUrl();
|
||||||
|
return url;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String makeLineAndShapeChart2(String headerName, String xName, String yName, List<LineChartDTO> list) {
|
public String makeLineAndShapeChart2(String headerName, String xName, String yName, List<LineChartDTO> list) {
|
||||||
Set<String> setName = new LinkedHashSet<>();
|
Set<String> setName = new LinkedHashSet<>();
|
||||||
@ -1,9 +1,10 @@
|
|||||||
package com.heyu.api.controller.mm;
|
package com.heyu.api.controller.mm;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.heyu.api.alibaba.request.mm.*;
|
import com.heyu.api.alibaba.request.mm.VvCategoryPropertyRequest;
|
||||||
|
import com.heyu.api.alibaba.request.mm.VvCategoryPropertySortRequest;
|
||||||
|
import com.heyu.api.alibaba.request.mm.VvCategoryPropertyValueSortRequest;
|
||||||
import com.heyu.api.data.dao.vv.VvCategoryPropertyDao;
|
import com.heyu.api.data.dao.vv.VvCategoryPropertyDao;
|
||||||
import com.heyu.api.data.dao.vv.VvCategoryPropertyValueDao;
|
import com.heyu.api.data.dao.vv.VvCategoryPropertyValueDao;
|
||||||
import com.heyu.api.data.dto.vv.VvCategoryPropertyDTO;
|
import com.heyu.api.data.dto.vv.VvCategoryPropertyDTO;
|
||||||
@ -13,7 +14,6 @@ import com.heyu.api.data.utils.R;
|
|||||||
import com.heyu.api.utils.ISelect;
|
import com.heyu.api.utils.ISelect;
|
||||||
import com.heyu.api.utils.PPageUtils;
|
import com.heyu.api.utils.PPageUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -72,29 +72,51 @@ public class AdminCategoryPropertyController {
|
|||||||
/***
|
/***
|
||||||
* 插入或更新
|
* 插入或更新
|
||||||
*
|
*
|
||||||
* @return
|
* /mm/category/property/insertOrUpdate
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/insertOrUpdate")
|
@RequestMapping("/insertOrUpdate")
|
||||||
public R insert(@RequestBody List<VvPropertyInsertOrUpdateRequest> vvPropertyInsertOrUpdateRequestList) {
|
public R insert(@RequestBody VvCategoryPropertyEntity vvCategoryProperty) {
|
||||||
for(VvPropertyInsertOrUpdateRequest vvPropertyInsertOrUpdateRequest : vvPropertyInsertOrUpdateRequestList){
|
vvCategoryPropertyDao.insertOrUpdateVvCategoryProperty(vvCategoryProperty);
|
||||||
VvCategoryPropertyEntity vvPropertyEntity = new VvCategoryPropertyEntity();
|
return R.ok().setData(vvCategoryProperty);
|
||||||
BeanUtils.copyProperties(vvPropertyInsertOrUpdateRequest, vvPropertyEntity);
|
|
||||||
vvCategoryPropertyDao.insertOrUpdateVvCategoryProperty(vvPropertyEntity);
|
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(vvPropertyInsertOrUpdateRequest.getVvCategoryPropertyValueEntities())) {
|
|
||||||
int i = 1;
|
|
||||||
for (VvCategoryPropertyValueEntity vvPropertyValueEntity : vvPropertyInsertOrUpdateRequest.getVvCategoryPropertyValueEntities()) {
|
|
||||||
vvPropertyValueEntity.setCategoryPropertyId(vvPropertyEntity.getId());
|
|
||||||
vvPropertyValueEntity.setDefaultSort(i);
|
|
||||||
vvCategoryPropertyValueDao.insertOrUpdateVvCategoryPropertyValue(vvPropertyValueEntity);
|
|
||||||
i ++ ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return R.ok().setData("保存成功");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 插入或更新
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/delete")
|
||||||
|
public R delete(@RequestBody VvCategoryPropertyEntity vvCategoryProperty) {
|
||||||
|
vvCategoryPropertyDao.deleteVvCategoryPropertyById(vvCategoryProperty.getId());
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 插入或更新
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/value/insertOrUpdate")
|
||||||
|
public R insert(@RequestBody VvCategoryPropertyValueEntity vvCategoryPropertyValueEntity) {
|
||||||
|
vvCategoryPropertyValueDao.insertOrUpdateVvCategoryPropertyValue(vvCategoryPropertyValueEntity);
|
||||||
|
return R.ok().setData(vvCategoryPropertyValueEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 插入或更新
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/value/delete")
|
||||||
|
public R delete(@RequestBody VvCategoryPropertyValueEntity vvCategoryProperty) {
|
||||||
|
vvCategoryPropertyValueDao.deleteVvCategoryPropertyValueById(vvCategoryProperty.getId());
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 排序
|
* 排序
|
||||||
@ -123,28 +145,6 @@ public class AdminCategoryPropertyController {
|
|||||||
return R.ok().setData("保存成功");
|
return R.ok().setData("保存成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
@RequestMapping("/update/sort/index")
|
|
||||||
public R updateSortIndex(@RequestBody VvCategoryPropertyIndexSortRequest vvCategorySortRequest) {
|
|
||||||
VvCategoryPropertyEntity vvPropertyEntity = vvCategoryPropertyDao.selectVvCategoryPropertyById(vvCategorySortRequest.getCategoryPropertyId());
|
|
||||||
vvPropertyEntity.setDefaultSort(vvCategorySortRequest.getDefaultSort());
|
|
||||||
vvCategoryPropertyDao.insertOrUpdateVvCategoryProperty(vvPropertyEntity);
|
|
||||||
return R.ok().setData("保存成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
|
||||||
* 排序
|
|
||||||
*/
|
|
||||||
@RequestMapping("/update/value/sort/index")
|
|
||||||
public R updateSortIndex(@RequestBody VvCategoryPropertyIndexValueSortRequest vvCategorySortRequest) {
|
|
||||||
VvCategoryPropertyValueEntity vvPropertyValue = vvCategoryPropertyValueDao.selectVvCategoryPropertyValueById(vvCategorySortRequest.getCategoryPropertyValueId());
|
|
||||||
vvPropertyValue.setDefaultSort(vvCategorySortRequest.getDefaultSort());
|
|
||||||
vvCategoryPropertyValueDao.insertOrUpdateVvCategoryPropertyValue(vvPropertyValue);
|
|
||||||
return R.ok().setData("保存成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import com.heyu.api.data.dto.PackageDelivedDelayDTO;
|
|||||||
import com.heyu.api.data.dto.VvCreateDataConfigDTO;
|
import com.heyu.api.data.dto.VvCreateDataConfigDTO;
|
||||||
import com.heyu.api.data.entity.vv.VvChartConfigEntity;
|
import com.heyu.api.data.entity.vv.VvChartConfigEntity;
|
||||||
import com.heyu.api.data.entity.vv.VvCreateDataConfigEntity;
|
import com.heyu.api.data.entity.vv.VvCreateDataConfigEntity;
|
||||||
import com.heyu.api.data.utils.ChartUtil;
|
import com.heyu.api.utils.ChartUtil;
|
||||||
import com.heyu.api.data.utils.DateUtils;
|
import com.heyu.api.data.utils.DateUtils;
|
||||||
import com.heyu.api.data.utils.R;
|
import com.heyu.api.data.utils.R;
|
||||||
import com.heyu.api.oss.OssFileUploadService;
|
import com.heyu.api.oss.OssFileUploadService;
|
||||||
@ -126,6 +126,28 @@ public class AppTestController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /app/test/qrcode
|
||||||
|
@Describe("测试延迟队列")
|
||||||
|
@RequestMapping("/qrcode")
|
||||||
|
public R qrcode(@RequestBody AppOrderRequest vvOrderRequest) throws Exception {
|
||||||
|
|
||||||
|
String url = chartUtil.generateQRCodeUp2Oss("9983989832983");
|
||||||
|
log.info("url:",url);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(System.currentTimeMillis());
|
System.out.println(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.heyu.api.data.dao.vv.VvAllDataDao;
|
import com.heyu.api.data.dao.vv.VvAllDataDao;
|
||||||
import com.heyu.api.data.entity.vv.VvAllDataEntity;
|
import com.heyu.api.data.entity.vv.VvAllDataEntity;
|
||||||
import com.heyu.api.data.entity.vv.VvChartConfigEntity;
|
import com.heyu.api.data.entity.vv.VvChartConfigEntity;
|
||||||
import com.heyu.api.data.utils.ChartUtil;
|
import com.heyu.api.utils.ChartUtil;
|
||||||
import com.heyu.api.data.utils.ExpressionParse;
|
import com.heyu.api.data.utils.ExpressionParse;
|
||||||
import com.heyu.api.data.utils.GouDeZhaoDDUtils;
|
import com.heyu.api.data.utils.GouDeZhaoDDUtils;
|
||||||
import com.heyu.api.data.utils.LineChartDTO;
|
import com.heyu.api.data.utils.LineChartDTO;
|
||||||
|
|||||||
19
api-web/api-interface/src/test/java/com/api/test/Test3.java
Normal file
19
api-web/api-interface/src/test/java/com/api/test/Test3.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.api.test;
|
||||||
|
|
||||||
|
import com.google.zxing.WriterException;
|
||||||
|
import com.heyu.api.utils.ChartUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class Test3 {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
ChartUtil.generateQRCodeImage("Hello World!", 300, 300, "qrcode1.png"); // 生成二维码并保存到文件系统
|
||||||
|
} catch (WriterException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
pom.xml
15
pom.xml
@ -359,6 +359,21 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>javase</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user