Merge remote-tracking branch 'origin/master'

This commit is contained in:
liang.chao 2025-04-02 18:53:19 +08:00
commit 69038b9699
14 changed files with 95 additions and 1572 deletions

View File

@ -1,70 +0,0 @@
package com.bonus.imgTool.utils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.ResultMapping;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.util.CollectionUtils;
import com.bonus.imgTool.table.PageTableRequest;
public class ColumnProUtil {
private static String DEFAULT_ID = "BaseResultMap";
/**
* 获取java类属性和表字段对应关系
*
* @param dao
* @param id
* @return
*/
public static Map<String, String> getColumnPro(Class<?> dao, String... id) {
Map<String, String> map = new HashMap<>();
SqlSessionFactory sessionFactory = SpringUtil.getBean(SqlSessionFactory.class);
ResultMap resultMap = sessionFactory.getConfiguration()
.getResultMap(dao.getName() + "." + (id.length == 0 ? DEFAULT_ID : id[0]));
if (resultMap != null) {
List<ResultMapping> list = resultMap.getResultMappings();
list.forEach(rm -> {
String column = rm.getColumn();
String pro = rm.getProperty();
if (StringUtils.isNoneBlank(column) && StringUtils.isNotBlank(pro)) {
map.put(pro, column);
}
});
}
return map;
}
/**
* 将java类属性替换为表字段
*
* @param request
* @param map
* @return
*/
public static String pro2Column(PageTableRequest request, Map<String, String> map) {
String orderBy = (String) request.getParams().get("orderBy");
if (StringUtils.isNoneBlank(orderBy) && !CollectionUtils.isEmpty(map)) {
for (String pro : map.keySet()) {
String val = map.get(pro);
if (StringUtils.isNoneBlank(val)) {
orderBy = orderBy.replace(pro, val);
}
}
request.getParams().put("orderBy", orderBy);
}
return orderBy;
}
}

View File

@ -1,87 +0,0 @@
package com.bonus.imgTool.utils;
import org.apache.commons.lang3.StringUtils;
import java.text.DecimalFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author 10488
*/
public class CommonUtils {
/**
* @param num
* @param totalNum
* @return String
* @description 获取百分比
* @author cwchen
* @date 2023/9/25 16:09
*/
public static String getRate(int num, int totalNum) {
DecimalFormat decimalFormat = new DecimalFormat("0.00%");
if (totalNum == 0 || num == 0) {
return "0%";
} else {
return decimalFormat.format(num * 1.0 / totalNum * 1.0);
}
}
public static String getRate2(double num, double totalNum) {
DecimalFormat decimalFormat = new DecimalFormat("0.00%");
if (totalNum == 0D || num == 0D) {
return "0%";
} else {
return decimalFormat.format(num / totalNum);
}
}
/**
* @param str
* @return Double
* @description 获取字符串中的浮点数部分
* @author cwchen
* @date 2023/9/26 13:56
*/
public static Double getDoubleValue(String str) {
Double doubleValue = 0D;
if (StringUtils.isEmpty(str)) {
return doubleValue;
}
String regex = "([0-9]+[.][0-9]+)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
doubleValue = Double.valueOf(matcher.group());
}
return doubleValue;
}
/**
* @param value
* @return String
* @description 转换楼层
* @author cwchen
* @date 2023/9/28 11:20
*/
public static String convertFloor(String value) {
if (StringUtils.isNotEmpty(value)) {
value = value.replace("","");
String floor = null;
try {
floor = MoneyUtil.rmbBigToSmall(value);
} catch (Exception e) {
floor = "未知";
}
return floor;
}
return "未知";
}
public static void main(String[] args) {
System.err.println(convertFloor("一层"));
}
}

View File

@ -1,150 +0,0 @@
package com.bonus.imgTool.utils;
import com.bonus.imgTool.system.vo.TaskScheduleModel;
import java.util.Calendar;
/**
* @author 10488
* 生成cron 表达式
*/
public class CronUtil {
/**
* 方法摘要构建Cron表达式
*
* @param taskScheduleModel
* @return String
*/
public static String createCronExpression(TaskScheduleModel taskScheduleModel) throws Exception {
//拆分时间字符串
String[] split1 = taskScheduleModel.getStartDate().split(" |-|:");
StringBuffer cronExp = new StringBuffer("");
if (null == taskScheduleModel.getJobType()) {
System.out.println("执行周期未配置");//执行周期未配置
}
if (null != split1[5] && null != split1[4] && null != split1[3]) {
if (taskScheduleModel.getJobType().intValue() == 0) {
//
cronExp.append(split1[5]).append(" ");
//每分钟
cronExp.append("* ").append(" ");
cronExp.append("* ");//小时
cronExp.append("* ");//
cronExp.append("* ");//
cronExp.append("?");//
} else if (taskScheduleModel.getJobType().intValue() == 1) {
//
cronExp.append(split1[5]).append(" ");
//
cronExp.append(split1[4]).append(" ");
//每小时
cronExp.append("* ");//小时
cronExp.append("* ");//
cronExp.append("* ");//
cronExp.append("?");//
} else if (taskScheduleModel.getJobType().intValue() == 2 || taskScheduleModel.getJobType().intValue() == 3 ||
taskScheduleModel.getJobType().intValue() == 4 || taskScheduleModel.getJobType().intValue() == 5) {
//
cronExp.append(split1[5]).append(" ");
//
cronExp.append(split1[4]).append(" ");
//
cronExp.append(split1[3]).append(" ");
}
//按每日
if (taskScheduleModel.getJobType().intValue() == 2) {
cronExp.append("* ");//
cronExp.append("* ");//
cronExp.append("?");//
}
//按每周
else if (taskScheduleModel.getJobType().intValue() == 3) {
String[] split2 = taskScheduleModel.getStartDate().split(" ");
Calendar instance = Calendar.getInstance();//创建格林威治时间
// instance.setTime(date);//将传来的时间设置到格林威治时间内
int dayForWeek = instance.get(Calendar.DAY_OF_WEEK) - 1;
//获取本周的周几
// int dayForWeek = DataUtils.dayForWeek(split2[0]);
//一个月中第几天
cronExp.append("? ");
//月份
cronExp.append("* ");
//
cronExp.append(dayForWeek + 1);
}
//按每月
else if (taskScheduleModel.getJobType().intValue() == 4) {
//一个月中的哪几天
cronExp.append(split1[2]);
//月份
cronExp.append(" * ");
//
cronExp.append("?");
}
//按每年
else if (taskScheduleModel.getJobType().intValue() == 5) {
//一个月中的哪几天
cronExp.append(split1[2]).append(" ");
//月份
cronExp.append(split1[1]).append(" ");
//
cronExp.append("?");
}
} else {
System.out.println("时或分或秒参数未配置");//时或分或秒参数未配置
}
return cronExp.toString();
}
/**
* @param date
* @param type
* @return String
* @description 生成cron表达式
* @author cwchen
* @date 2023/10/25 14:51
*/
public static String getCronStr(String date, Integer type) {
TaskScheduleModel scheduleModel = new TaskScheduleModel();
scheduleModel.setJobType(type);
scheduleModel.setStartDate(date);
try {
String cronExpression = createCronExpression(scheduleModel);
System.out.println(cronExpression);
return cronExpression;
} catch (Exception e) {
System.err.println("生成cron表达式失败");
return null;
}
}
//每天早上8点执行
public static void main(String[] args) {
TaskScheduleModel scheduleModel = new TaskScheduleModel();
scheduleModel.setJobType(5);
scheduleModel.setStartDate("2023-10-25 14:56:00");
try {
String cronExpression = createCronExpression(scheduleModel);
System.out.println(cronExpression);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,224 +0,0 @@
package com.bonus.imgTool.utils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* @className:ExcelStyleUtil
* @author:cwchen
* @date:2024-07-27-20:18
* @version:1.0
* @description:原始记录导出excel工具类
*/
public class ExcelStyleUtil {
/**
* 表头字体
*
* @param wb
* @return Font
* @author cwchen
* @date 2024/7/27 20:20
*/
public static Font getHeaderFont(XSSFWorkbook wb) {
//表头字体
Font headerFont = wb.createFont();
headerFont.setFontName("宋体");
headerFont.setFontHeightInPoints((short) 18);
headerFont.setBold(true);
headerFont.setColor(Font.COLOR_NORMAL);
return headerFont;
}
/**
* 正文字体
*
* @param wb
* @return Font
* @author cwchen
* @date 2024/7/27 20:22
*/
public static Font getContentFont(XSSFWorkbook wb) {
//表头字体
Font contextFont = wb.createFont();
contextFont.setFontName("宋体");
contextFont.setFontHeightInPoints((short) 12);
return contextFont;
}
/**
* 表头样式左右上下居中
*
* @param wb
* @return XSSFCellStyle
* @author cwchen
* @date 2024/7/27 20:28
*/
public static CellStyle getHeaderStyle(XSSFWorkbook wb) {
XSSFCellStyle headerStyle = wb.createCellStyle();
headerStyle.setFont(getHeaderFont(wb));
// 左右居中
headerStyle.setAlignment(HorizontalAlignment.CENTER);
// 上下居中
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
headerStyle.setLocked(true);
// 自动换行
headerStyle.setWrapText(true);
return headerStyle;
}
/**
* 单元格样式左右上下居中 边框
*
* @param wb
* @return XSSFCellStyle
* @author cwchen
* @date 2024/7/27 20:28
*/
public static CellStyle getCommonStyle(XSSFWorkbook wb) {
XSSFCellStyle commonStyle = wb.createCellStyle();
commonStyle.setFont(getContentFont(wb));
// 左右居中
commonStyle.setAlignment(HorizontalAlignment.CENTER);
// 上下居中
commonStyle.setVerticalAlignment(VerticalAlignment.CENTER);
commonStyle.setLocked(true);
// 自动换行
commonStyle.setWrapText(true);
commonStyle.setBorderBottom(BorderStyle.THIN);
//左边框
commonStyle.setBorderLeft(BorderStyle.THIN);
//右边框
commonStyle.setBorderRight(BorderStyle.THIN);
//上边框
commonStyle.setBorderTop(BorderStyle.THIN);
//单元格样式左右上下居中 边框
return commonStyle;
}
/**
* @param wb
* @return CellStyle
* @author cwchen
* @date 2024/7/28 14:37
*/
public static CellStyle getCommonStyle2(XSSFWorkbook wb) {
XSSFCellStyle commonStyle = wb.createCellStyle();
commonStyle.setFont(getContentFont(wb));
// 左右居中
commonStyle.setAlignment(HorizontalAlignment.LEFT);
// 上下居中
commonStyle.setVerticalAlignment(VerticalAlignment.CENTER);
commonStyle.setLocked(true);
// 自动换行
commonStyle.setWrapText(true);
commonStyle.setBorderBottom(BorderStyle.THIN);
//左边框
commonStyle.setBorderLeft(BorderStyle.THIN);
//右边框
commonStyle.setBorderRight(BorderStyle.THIN);
//上边框
commonStyle.setBorderTop(BorderStyle.THIN);
//单元格样式左右上下居中 边框
return commonStyle;
}
/**
* 创建标题样式
*
* @param wb
* @return
*/
private static XSSFCellStyle createTitleCellStyle(XSSFWorkbook wb) {
XSSFCellStyle cellStyle = wb.createCellStyle();
//水平居中
cellStyle.setAlignment(HorizontalAlignment.CENTER);
//垂直对齐
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
//背景颜色
cellStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
// 创建字体样式
XSSFFont headerFont1 = (XSSFFont) wb.createFont();
//字体加粗
headerFont1.setBold(true);
// 设置字体类型
headerFont1.setFontName("黑体");
// 设置字体大小
headerFont1.setFontHeightInPoints((short) 15);
// 为标题样式设置字体样式
cellStyle.setFont(headerFont1);
return cellStyle;
}
/**
* 创建表头样式
*
* @param wb
* @return
*/
private static XSSFCellStyle createHeadCellStyle(XSSFWorkbook wb) {
XSSFCellStyle cellStyle = wb.createCellStyle();
// 设置自动换行
cellStyle.setWrapText(true);
//背景颜色
cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
//水平居中
cellStyle.setAlignment(HorizontalAlignment.CENTER);
//垂直对齐
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setBottomBorderColor(IndexedColors.BLACK.index);
//下边框
cellStyle.setBorderBottom(BorderStyle.THIN);
//左边框
cellStyle.setBorderLeft(BorderStyle.THIN);
//右边框
cellStyle.setBorderRight(BorderStyle.THIN);
//上边框
cellStyle.setBorderTop(BorderStyle.THIN);
// 创建字体样式
XSSFFont headerFont = (XSSFFont) wb.createFont();
//字体加粗
headerFont.setBold(true);
// 设置字体类型
headerFont.setFontName("黑体");
// 设置字体大小
headerFont.setFontHeightInPoints((short) 12);
// 为标题样式设置字体样式
cellStyle.setFont(headerFont);
return cellStyle;
}
/**
* 创建内容样式
*
* @param wb
* @return
*/
private static XSSFCellStyle createContentCellStyle(XSSFWorkbook wb) {
XSSFCellStyle cellStyle = wb.createCellStyle();
// 垂直居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 水平居中
cellStyle.setAlignment(HorizontalAlignment.CENTER);
// 设置自动换行
cellStyle.setWrapText(true);
//下边框
cellStyle.setBorderBottom(BorderStyle.THIN);
//左边框
cellStyle.setBorderLeft(BorderStyle.THIN);
//右边框
cellStyle.setBorderRight(BorderStyle.THIN);
//上边框
cellStyle.setBorderTop(BorderStyle.THIN);
// 生成12号字体
XSSFFont font = wb.createFont();
font.setColor((short) 8);
font.setFontHeightInPoints((short) 12);
cellStyle.setFont(font);
return cellStyle;
}
}

View File

@ -1,225 +0,0 @@
package com.bonus.imgTool.utils;
import cn.hutool.core.io.FileUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author 黑子
*/
public class ExcelWriterTest03 {
public static void main(String[] args) throws IOException {
int row =13;
// List<TestVo> list =getTestList();
String path = "D:\\poi\\";
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("检测报告");
//第一行
Row row1 = sheet.createRow(0);
//单元格-创建第一个头
Cell cell11 = row1.createCell(0);
cell11.setCellValue("安全帽检测报告");
//合并全部列
addMergedRegion(0,0,0,row-1,sheet);
XSSFCellStyle style= centerStyle(workbook);
cell11.setCellStyle(style);
//第二行
Row row2 = sheet.createRow(1);
Cell cell21 = row2.createCell(0);
cell21.setCellValue("报告编号");
cell21.setCellStyle(style);
//计算占用行数
int num21=(row-4)/2;
Cell cell22 = row2.createCell(1);
addMergedRegion(1,1,1,num21,sheet);
cell22.setCellValue("编号-value");
Cell cell23 = row2.createCell(num21+1);
cell23.setCellValue("收样日期");
cell23.setCellStyle(style);
Cell cell24 = row2.createCell(num21+2);
cell24.setCellValue("收样日期-值");
cell24.setCellStyle(style);
addMergedRegion(1,1,num21+2,row-3,sheet);
Cell cell25 = row2.createCell(row-2);
cell25.setCellValue("样品数量");
cell25.setCellStyle(style);
Cell cell26= row2.createCell(row-1);
cell26.setCellValue("样品数量-值");
cell26.setCellStyle(style);
//第三行
Row row3 = sheet.createRow(2);
Cell cell31 = row3.createCell(0);
cell31.setCellValue("检测设备");
cell31.setCellStyle(style);
Cell cell32 = row3.createCell(1);
cell32.setCellValue("检测设备-值");
cell32.setCellStyle(style);
addMergedRegion(2,2,1,row-1,sheet);
//第四行
Row row4= sheet.createRow(3);
Cell cell41 = row4.createCell(0);
cell41.setCellValue("检测依据");
cell41.setCellStyle(style);
Cell cell42 = row4.createCell(1);
cell42.setCellValue("检测依据-值");
cell42.setCellStyle(style);
addMergedRegion(3,3,1,row-1,sheet);
//第5行 //第六行
Row row5= sheet.createRow(4);
Row row6= sheet.createRow(5);
//第五行//第六号合并
Cell cell51 = row5.createCell(0);
cell51.setCellValue("序号");
cell51.setCellStyle(style);
addMergedRegion(4,5,0,0,sheet);
Cell cell52 = row5.createCell(1);
cell52.setCellValue("样品编号");
cell52.setCellStyle(style);
addMergedRegion(4,5,1,1,sheet);
//
Cell cell53 = row5.createCell(2);
cell53.setCellValue("样品信息");
cell53.setCellStyle(style);
addMergedRegion(4,4,2,5,sheet);//
//第六行固定数据
Cell cell62= row6.createCell(2);
cell62.setCellStyle(style);
cell62.setCellValue("客户自编号");
Cell cell63 = row6.createCell(3);
cell63.setCellStyle(style);
cell63.setCellValue("生成厂家");
Cell cell64 = row6.createCell(4);
cell64.setCellStyle(style);
cell64.setCellValue("生产日期");
Cell cell65 = row6.createCell(5);
cell65.setCellStyle(style);
cell65.setCellValue("规格型号");
//第五第六号非固定数据
AtomicInteger num= new AtomicInteger(5);
AtomicInteger rowNums= new AtomicInteger(5);
// list.forEach(vo->{
// List<TestVo> childList=vo.getData();
// int rowNum=childList.size();
// num.set(num.get() + 1);
// Cell cell54 = row5.createCell(num.get());
// cell54.setCellValue(vo.getName());
// cell54.setCellStyle(style);
// addMergedRegion(4,4,num.get(),num.get()+rowNum-1,sheet);
// num.addAndGet(rowNum-1);
// childList.forEach(child->{
// rowNums.set(rowNums.get() + 1);
// Cell cell4 = row6.createCell(rowNums.get());
// cell4.setCellStyle(style);
// cell4.setCellValue(child.getName());
// });
// });
// 判断文件是否存在不存在就创建
if (FileUtil.isEmpty(new File(path))) {
FileUtil.mkdir(path);
}
// 5.生成一张表03版本的工作簿是以.xls结尾
FileOutputStream fileOutputStream = new FileOutputStream(path + "03.xls");
// 输出
workbook.write(fileOutputStream);
// 6.关闭流
fileOutputStream.close();
System.out.println("03表生成成功");
}
public static XSSFCellStyle centerStyle(XSSFWorkbook workbook){
XSSFCellStyle commonStyle = workbook.createCellStyle();
// 左右居中
commonStyle.setAlignment(HorizontalAlignment.CENTER);
// 上下居中
commonStyle.setVerticalAlignment(VerticalAlignment.CENTER);
commonStyle.setLocked(true);
// 自动换行
commonStyle.setWrapText(false);
return commonStyle;
}
/**
* 合并单元格
* @param startRow 开始行
* @param endRow 结束行
* @param startCol 开始列
* @param endCol 结束列
* @param sheet 创建的sheet页
*/
public static void addMergedRegion(int startRow,int endRow,int startCol,int endCol,Sheet sheet){
CellRangeAddress cra = new CellRangeAddress(startRow,endRow,startCol,endCol);
sheet.addMergedRegion(cra);
}
// public static List<TestVo> getTestList(){
// List<TestVo> list=new ArrayList<>();
// List<TestVo> childeList=new ArrayList<>();
// List<TestVo> childeList2=new ArrayList<>();
// TestVo vo=new TestVo();
// vo.setName("测试1");
// TestVo vo11=new TestVo();
// vo11.setName("测试1-1");
// childeList.add(vo11);
// TestVo vo12=new TestVo();
// vo12.setName("测试1-2");
// childeList.add(vo12);
// TestVo vo13=new TestVo();
// vo13.setName("测试1-3");
// childeList.add(vo13);
// TestVo vo14=new TestVo();
// vo14.setName("测试1-4");
// childeList.add(vo14);
// vo.setData(childeList);
//
// list.add(vo);
// TestVo vo2=new TestVo();
// vo2.setName("测试2");
// TestVo vo21=new TestVo();
// vo21.setName("测试2-1");
// childeList2.add(vo21);
// TestVo vo22=new TestVo();
// vo22.setName("测试2-2");
// childeList2.add(vo22);
// TestVo vo23=new TestVo();
// vo23.setName("测试2-3");
// childeList2.add(vo23);
// vo2.setData(childeList2);
// list.add(vo2);
// return list;
// }
}

View File

@ -1,75 +0,0 @@
package com.bonus.imgTool.utils;
import lombok.Data;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* excel 导出功能
* @author 黑子
*/
@Data
public class ExportUtils {
/**
* 总列数
* @param row
*/
/*public void CreateWorkbook(int row){
Workbook workbook=new HSSFWorkbook();
Sheet sheet = workbook.createSheet("检测报告");
//第一行
Row row1 = sheet.createRow(0);
//单元格-创建第一个头
Cell cell11 = row1.createCell(0,row);
cell11.setCellValue("安全帽检测报告");
//合并全部列
addMergedRegion(1,1,0,row,sheet);
//第二行
Row row2 = sheet.createRow(1);
Cell cell21 = row2.createCell(0);
cell21.setCellValue("报告编号");
//计算占用行数
int num21=(row-4)/2;
Cell cell22 = row2.createCell(1,num21);
cell22.setCellValue("编号-value");
// Cell cell22 = row2.createCell(0);
// cell22.setCellValue("报告编号");
}*/
/**
* 合并单元格
* @param startRow 开始行
* @param endRow 结束行
* @param startCol 开始列
* @param endCol 结束列
* @param sheet 创建的sheet页
*/
public void addMergedRegion(int startRow,int endRow,int startCol,int endCol,Sheet sheet){
CellRangeAddress cra = new CellRangeAddress(1,2,0,1);
sheet.addMergedRegion(cra);
}
public void createRow(Row row1,int startNum,int endNum){
for (int i = startNum; i < endNum; i++) {
Cell cell11 = row1.createCell(i);
}
}
}

View File

@ -56,7 +56,7 @@ public class ImageDownloadHandler {
}
// 5. 设置缓存控制
// response.setHeader("Cache-Control", "max-age=3600"); // 1小时缓存
response.setHeader("Cache-Control", "max-age=3600"); // 1小时缓存
// 6. 读取文件并写入响应输出流
try (InputStream in = Files.newInputStream(path);

View File

@ -1,113 +0,0 @@
package com.bonus.imgTool.utils;
public class MoneyUtil {
/**
* 中文中简写的汉字金额 经常使用
*/
public static String[] rmbNumbers = new String[]{"", "", "", "", "", "", "" , "", "", "", "廿", "", ""};
/**
* 中文中繁写的汉字金额 经常使用
*/
public static String[] bigNumbers = new String[]{"","","","","","","","","", "", "廿", "",""};//大写的汉字
/**
* 与汉字相应的转化的数字
*/
public static Long[] tonumbers = new Long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 2L, 2L, 3L, 0L};//转化为阿拉伯数字
/**
* 倍数关键词 简写 注意一定要由大到小
*/
public static String[] rmbMult = new String[]{"亿","","","",""};//大写中间隔的倍数
/**
* 倍数关键词 繁写
*/
public static String[] bigRmbMult = new String[]{"","","","",""};
/**
* 与倍数关键词对应的倍数
*/
public static Long[] toMult = new Long[]{100000000L,10000L,1000L,100L,10L};//转化为阿拉伯的倍数
/**
* 大写转化为小写的过程操作只处理到元不带有单位
* @param money 大写的金额不带有单位 例如1.二十一万 2.六五四三 3 贰拾
* @return
*/
public static String rmbBigToSmall(String money) {
Long number = 0L;
//遍历倍数的中文词遍历的时候一定要注意 选取的倍数词为最后一个倍数词,此次遍历为第一次遍历
for(int i = 0; i < rmbMult.length; i++) {
int index = money.lastIndexOf(rmbMult[i]) == -1?money.lastIndexOf(bigRmbMult[i]):money.lastIndexOf(rmbMult[i]);
if(index >= 0) {
String storeMult = money.substring(0, index);
money = money.substring(index+1);
// System.out.println(rmbMult[i] + " " + toMult[i]);
/**对于 十九万 这样的特殊的十的情况进行特殊处理*/
if((storeMult == null || storeMult.length() <= 0) && toMult[i].intValue() == 10) {
number = number + toMult[i];
} else {
number = number + (toMult[i] * getPrexNum(storeMult));
}
}
}
/**
* 个位数的处理
*/
number = number + getNumByBig(money);
return number.toString();
}
/**
* 辅助类第二次循环
* 此循环一般处理的都是倍数前面的数字例如十九万在这里就处理十九
* @param storeMult 倍数前面的前缀词
* @return
*/
private static Long getPrexNum(String storeMult) {
Long result = 0L;
for(int i = 0; i < rmbMult.length; i++) {
int index = storeMult.lastIndexOf(rmbMult[i]) == -1?storeMult.lastIndexOf(bigRmbMult[i]):storeMult.lastIndexOf(rmbMult[i]);
if(index >= 0) {
String storeMult2 = storeMult.substring(0, index);
storeMult = storeMult.substring(index + 1);
if((storeMult2 == null || storeMult2.length() <= 0) && toMult[i].intValue() == 10) {
result = result + toMult[i];
} else {
result += getNumByBig(storeMult2) * toMult[i];
}
}
}
if(storeMult != null && storeMult.length() > 0) {
result = result + getNumByBig(storeMult);
}
return result;
}
/**
* 辅助类大写的中文数字 转化为小写的阿拉伯数字
* @param big
* @return
*/
private static Long getNumByBig(String big) {
Long result = 0L;
for(int j = 0; j < rmbNumbers.length; j++) {
big = big.replaceAll(rmbNumbers[j], tonumbers[j].toString());
big = big.replaceAll(bigNumbers[j], tonumbers[j].toString());
}
try {
result = Long.valueOf(big);
} catch(Exception e) {
result = 0L;
}
return result;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(rmbBigToSmall("三十三"));
}
}

View File

@ -1,99 +0,0 @@
package com.bonus.imgTool.utils;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class QRCodeUtil {
/*
* 创建二维码
*/
public static FileOutputStream createQRCode(String qrCode) {
//二维码的内容
String contents = qrCode;
//表示是二维码
BarcodeFormat format = BarcodeFormat.QR_CODE;
//二维码的宽
int width = 400;
//二维码的高
int height = 400;
//设置二维码的格式
Map<EncodeHintType,Object> hints = new HashMap<EncodeHintType,Object>();
//设置二维码的字符集
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
//设置二维码的外间距
hints.put(EncodeHintType.MARGIN, 10);
//设置二维码容错级别
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M );
//用于编制二维码的类
MultiFormatWriter mfw = new MultiFormatWriter();
//准备输出的文件
FileOutputStream fos = null;
Map<String,Object> QR = new HashMap<String,Object>();
try {
//创建二维码对象
BitMatrix bm = mfw.encode(contents, format, width, height, hints);
fos = new FileOutputStream(new File("QR.jpg"));
//输出二维码到fos文件文件格式为jpg
MatrixToImageWriter.writeToStream(bm, "jpg", fos);
} catch (WriterException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return fos;
}
/*
* 读取二维码
*/
public static void ReadQRCode(String imageUrl) {
//解读二维码的类
MultiFormatReader mfr = new MultiFormatReader();
//二维码的解码格式设置为编码一致不设置也可以它会用默认
Map<DecodeHintType,Object> hints = new HashMap<DecodeHintType,Object>();
//设置字符集
hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
//准备要读取的二维码文件
try {
BufferedImage image = ImageIO.read(new File(imageUrl));
//解码
Result rs = mfr.decode(new BinaryBitmap(new HybridBinarizer
(new BufferedImageLuminanceSource(image))), hints);
//获得文本内容
// System.out.println(rs.getText());
//获得时间戳
// System.out.println(rs.getTimestamp());
//获得编码格式
// System.out.println(rs.getBarcodeFormat());
//执行文本内容此次的例子执行会打开百度因为文本内容为https://www.baidu.com
Runtime.getRuntime().exec("explorer "+rs.getText());
} catch (IOException e) {
e.printStackTrace();
} catch (NotFoundException e) {
e.printStackTrace();
}
}
}

View File

@ -1,318 +0,0 @@
package com.bonus.imgTool.utils;
import java.io.File;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.bonus.imgTool.system.vo.GenerateInput;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TemplateUtil {
private static final Logger log = LoggerFactory.getLogger("adminLogger");
public static String getTemplete(String fileName) {
return FileUtil.getText(TemplateUtil.class.getClassLoader().getResourceAsStream("generate/" + fileName));
}
public static void saveJava(GenerateInput input) {
String path = input.getPath();
String beanPackageName = input.getBeanPackageName();
String beanName = input.getBeanName();
List<String> beanFieldName = input.getBeanFieldName();
List<String> beanFieldType = input.getBeanFieldType();
List<String> beanFieldValue = input.getBeanFieldValue();
String text = getTemplete("java.txt");
text = text.replace("{beanPackageName}", beanPackageName).replace("{beanName}", beanName);
String imports = "";
if (beanFieldType.contains(BigDecimal.class.getSimpleName())) {
imports += "import " + BigDecimal.class.getName() + ";\n";
}
if (beanFieldType.contains(Date.class.getSimpleName())) {
imports += "import " + Date.class.getName() + ";";
}
text = text.replace("{import}", imports);
String filelds = getFields(beanFieldName, beanFieldType, beanFieldValue);
text = text.replace("{filelds}", filelds);
text = text.replace("{getset}", getset(beanFieldName, beanFieldType));
FileUtil.saveTextFile(text, path + File.separator + getPackagePath(beanPackageName) + beanName + ".java");
log.debug("生成java model{}模板", beanName);
}
private static String getFields(List<String> beanFieldName, List<String> beanFieldType,
List<String> beanFieldValue) {
StringBuffer buffer = new StringBuffer();
int size = beanFieldName.size();
for (int i = 0; i < size; i++) {
String name = beanFieldName.get(i);
if ("id".equals(name) || "createTime".equals(name) || "updateTime".equals(name)) {
continue;
}
String type = beanFieldType.get(i);
buffer.append("\tprivate ").append(type).append(" ").append(name);
// 默认值
// String value = beanFieldValue.get(i);
// if (!StringUtils.isEmpty(value)) {
// buffer.append(" = ");
// if (type.equals(String.class.getSimpleName())) {
// value = "\"" + value + "\"";
// } else if (type.equals(Double.class.getSimpleName())) {
// value = value + "D";
// } else if (type.equals(Float.class.getSimpleName())) {
// value = value + "F";
// } else if (type.equals(BigDecimal.class.getSimpleName())) {
// value = "new BigDecimal(" + value + ")";
// }
//
// buffer.append(value);
// }
buffer.append(";\n");
}
return buffer.toString();
}
private static String getset(List<String> beanFieldName, List<String> beanFieldType) {
StringBuffer buffer = new StringBuffer();
int size = beanFieldName.size();
for (int i = 0; i < size; i++) {
String name = beanFieldName.get(i);
if ("id".equals(name) || "createTime".equals(name) || "updateTime".equals(name)) {
continue;
}
String type = beanFieldType.get(i);
buffer.append("\tpublic ").append(type).append(" get")
.append(StringUtils.substring(name, 0, 1).toUpperCase() + name.substring(1, name.length()))
.append("() {\n");
buffer.append("\t\treturn ").append(name).append(";\n");
buffer.append("\t}\n");
buffer.append("\tpublic void set")
.append(StringUtils.substring(name, 0, 1).toUpperCase() + name.substring(1, name.length()))
.append("(").append(type).append(" ").append(name).append(") {\n");
buffer.append("\t\tthis.").append(name).append(" = ").append(name).append(";\n");
buffer.append("\t}\n");
}
return buffer.toString();
}
public static void saveJavaDao(GenerateInput input) {
String path = input.getPath();
String tableName = input.getTableName();
String beanPackageName = input.getBeanPackageName();
String beanName = input.getBeanName();
String daoPackageName = input.getDaoPackageName();
String daoName = input.getDaoName();
String text = getTemplete("dao.txt");
text = text.replace("{daoPackageName}", daoPackageName);
text = text.replace("{beanPackageName}", beanPackageName);
text = text.replace("{daoName}", daoName);
text = text.replace("{table_name}", tableName);
text = text.replace("{beanName}", beanName);
text = text.replace("{beanParamName}", lowerFirstChar(beanName));
String insertColumns = getInsertColumns(input.getColumnNames());
text = text.replace("{insert_columns}", insertColumns);
String insertValues = getInsertValues(input.getColumnNames(), input.getBeanFieldName());
text = text.replace("{insert_values}", insertValues);
FileUtil.saveTextFile(text, path + File.separator + getPackagePath(daoPackageName) + daoName + ".java");
log.debug("生成java dao{}模板", beanName);
text = getTemplete("mapper.xml");
text = text.replace("{daoPackageName}", daoPackageName);
text = text.replace("{daoName}", daoName);
text = text.replace("{table_name}", tableName);
text = text.replace("{beanName}", beanName);
String sets = getUpdateSets(input.getColumnNames(), input.getBeanFieldName());
text = text.replace("{update_sets}", sets);
String where = getWhere(input.getColumnNames(), input.getBeanFieldName());
text = text.replace("{where}", where);
FileUtil.saveTextFile(text, path + File.separator + beanName + "Mapper.xml");
}
private static String getInsertValues(List<String> columnNames, List<String> beanFieldName) {
StringBuffer buffer = new StringBuffer();
int size = columnNames.size();
for (int i = 0; i < size; i++) {
String column = columnNames.get(i);
if (!"id".equals(column)) {
buffer.append("#{").append(beanFieldName.get(i)).append("}, ");
}
}
String sets = StringUtils.substringBeforeLast(buffer.toString(), ",");
return sets;
}
private static String getInsertColumns(List<String> columnNames) {
StringBuffer buffer = new StringBuffer();
int size = columnNames.size();
for (int i = 0; i < size; i++) {
String column = columnNames.get(i);
if (!"id".equals(column)) {
buffer.append(column).append(", ");
}
}
String insertColumns = StringUtils.substringBeforeLast(buffer.toString(), ",");
return insertColumns;
}
private static String getUpdateSets(List<String> columnNames, List<String> beanFieldName) {
StringBuffer buffer = new StringBuffer();
int size = columnNames.size();
for (int i = 0; i < size; i++) {
String column = columnNames.get(i);
if (!"id".equals(column)) {
buffer.append("\t\t\t<if test=\"" + column + " != null\">\n");
buffer.append("\t\t\t\t" + column).append(" = ").append("#{").append(beanFieldName.get(i))
.append("}, \n");
buffer.append("\t\t\t</if>\n");
}
}
return buffer.toString();
}
private static String getWhere(List<String> columnNames, List<String> beanFieldName) {
StringBuffer buffer = new StringBuffer();
int size = columnNames.size();
for (int i = 0; i < size; i++) {
String column = columnNames.get(i);
buffer.append("\t\t\t<if test=\"params." + column + " != null and params." + column + " != ''\">\n");
buffer.append("\t\t\t\tand " + column).append(" = ").append("#{params.").append(beanFieldName.get(i))
.append("} \n");
buffer.append("\t\t\t</if>\n");
}
return buffer.toString();
}
/**
* 变量名
*
* @param beanName
* @return
*/
public static String lowerFirstChar(String beanName) {
String name = StrUtil.str2hump(beanName);
String firstChar = name.substring(0, 1);
name = name.replaceFirst(firstChar, firstChar.toLowerCase());
return name;
}
private static String getPackagePath(String packageName) {
String packagePath = packageName.replace(".", "/");
if (!packagePath.endsWith("/")) {
packagePath = packagePath + "/";
}
return packagePath;
}
public static void saveController(GenerateInput input) {
String path = input.getPath();
String beanPackageName = input.getBeanPackageName();
String beanName = input.getBeanName();
String daoPackageName = input.getDaoPackageName();
String daoName = input.getDaoName();
String text = getTemplete("controller.txt");
text = text.replace("{daoPackageName}", daoPackageName);
text = text.replace("{beanPackageName}", beanPackageName);
text = text.replace("{daoName}", daoName);
text = text.replace("{daoParamName}", lowerFirstChar(daoName));
text = text.replace("{beanName}", beanName);
text = text.replace("{beanParamName}", lowerFirstChar(beanName));
text = text.replace("{controllerPkgName}", input.getControllerPkgName());
text = text.replace("{controllerName}", input.getControllerName());
FileUtil.saveTextFile(text, path + File.separator + getPackagePath(input.getControllerPkgName())
+ input.getControllerName() + ".java");
log.debug("生成controller{}模板", beanName);
}
public static void saveHtmlList(GenerateInput input) {
String path = input.getPath();
String beanName = input.getBeanName();
String beanParamName = lowerFirstChar(beanName);
String text = getTemplete("htmlList.txt");
text = text.replace("{beanParamName}", beanParamName);
text = text.replace("{beanName}", beanName);
List<String> beanFieldNames = input.getBeanFieldName();
text = text.replace("{columnsDatas}", getHtmlColumnsDatas(beanFieldNames));
text = text.replace("{ths}", getHtmlThs(beanFieldNames));
FileUtil.saveTextFile(text, path + File.separator + beanParamName + "List.html");
log.debug("生成查询页面:{}模板", beanName);
text = getTemplete("htmlAdd.txt");
text = text.replace("{beanParamName}", beanParamName);
text = text.replace("{addDivs}", getAddDivs(beanFieldNames));
FileUtil.saveTextFile(text, path + File.separator + "add" + beanName + ".html");
log.debug("生成添加页面:{}模板", beanName);
text = getTemplete("htmlUpdate.txt");
text = text.replace("{beanParamName}", beanParamName);
text = text.replace("{addDivs}", getAddDivs(beanFieldNames));
text = text.replace("{initData}", getInitData(beanFieldNames));
FileUtil.saveTextFile(text, path + File.separator + "update" + beanName + ".html");
log.debug("生成修改页面:{}模板", beanName);
}
private static CharSequence getInitData(List<String> beanFieldNames) {
StringBuilder builder = new StringBuilder();
beanFieldNames.forEach(b -> {
builder.append("\t\t\t\t\t\t$('#" + b + "').val(data." + b + ");\n");
});
return builder.toString();
}
private static String getAddDivs(List<String> beanFieldNames) {
StringBuilder builder = new StringBuilder();
beanFieldNames.forEach(b -> {
if (!"id".equals(b) && !"createTime".equals(b) && !"updateTime".equals(b)) {
builder.append("\t\t\t<div class='form-group'>\n");
builder.append("\t\t\t\t<label class='col-md-2 control-label'>" + b + "</label>\n");
builder.append("\t\t\t\t<div class='col-md-10'>\n");
builder.append("\t\t\t\t\t<input class='form-control' placeholder='" + b + "' type='text' name='" + b
+ "' id='" + b + "' data-bv-notempty='true' data-bv-notempty-message='" + b + " 不能为空'>\n");
builder.append("\t\t\t\t</div>\n");
builder.append("\t\t\t</div>\n");
}
});
return builder.toString();
}
private static String getHtmlThs(List<String> beanFieldNames) {
StringBuilder builder = new StringBuilder();
beanFieldNames.forEach(b -> {
builder.append("\t\t\t\t\t\t\t\t\t<th>{beanFieldName}</th>\n".replace("{beanFieldName}", b));
});
return builder.toString();
}
private static String getHtmlColumnsDatas(List<String> beanFieldNames) {
StringBuilder builder = new StringBuilder();
beanFieldNames.forEach(b -> {
builder.append("\t\t\t\t{\"data\" : \"{beanFieldName}\", \"defaultContent\" : \"\"},\n"
.replace("{beanFieldName}", b));
});
builder.append("");
return builder.toString();
}
}

View File

@ -1,203 +0,0 @@
//package com.bonus.zhly.utils;
//
//import com.bonus.zhly.base.entity.dto.MuiscScheduledDto;
//import com.bonus.zhly.base.entity.vo.MuiscScheduledVo;
//import com.bonus.zhly.base.mapper.BuildControlMapper;
//import org.apache.commons.collections4.CollectionUtils;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.Objects;
//
///**
// * @author 10488
// * 时间冲突工具类
// */
//@Component
//public class TimeConflictUtil {
//
// @Resource(name = "BuildControlMapper")
// private BuildControlMapper mapper;
//
// /**
// * @param time
// * @return boolean
// * @description 判断定时任务时间是否冲突
// * @author cwchen
// * @date 2023/9/22 9:52
// */
// public boolean timeIsConflict(String time, String scheduleType) {
// MuiscScheduledDto dto = new MuiscScheduledDto();
// List<MuiscScheduledVo> list = mapper.getMuiscScheduledList(dto);
// if (CollectionUtils.isNotEmpty(list)) {
// if (Objects.equals("1", scheduleType)) {
// // 每天
// String[] timeArr = time.split(" - ");
// long minTimeStamp = DateTimeHelper.getTimeStampConverter(timeArr[0], "HH:mm");
// long maxTimeStamp = DateTimeHelper.getTimeStampConverter(timeArr[1], "HH:mm");
// return compareScheduledByDay(minTimeStamp, maxTimeStamp, list);
// } else if (Objects.equals("2", scheduleType)) {
// // 工作日
// String[] timeArr = time.split(" - ");
// long minTimeStamp = DateTimeHelper.getTimeStampConverter(timeArr[0], "HH:mm");
// long maxTimeStamp = DateTimeHelper.getTimeStampConverter(timeArr[1], "HH:mm");
// return compareScheduledByWorkDay(minTimeStamp, maxTimeStamp, list);
// } else if (Objects.equals("3", scheduleType)) {
// // 自定义
// String[] timeArr = time.split(" - ");
// long minTimeStamp = DateTimeHelper.getTimeStampConverter(timeArr[0], "yyyy-MM-dd HH:mm");
// long maxTimeStamp = DateTimeHelper.getTimeStampConverter(timeArr[1], "yyyy-MM-dd HH:mm");
// return compareScheduledByCustom(timeArr[0], minTimeStamp, maxTimeStamp, list);
// }
// }
// return true;
// }
//
// /**
// * @param minTimeStamp
// * @param maxTimeStamp
// * @param list
// * @return boolean
// * @description 判断每天
// * @author cwchen
// * @date 2023/10/13 9:03
// */
// public boolean compareScheduledByDay(long minTimeStamp, long maxTimeStamp, List<MuiscScheduledVo> list) {
// boolean flag = true;
// for (MuiscScheduledVo vo : list) {
// String scheduleType = vo.getScheduleType();
// String startTime = vo.getStartTime();
// String endTime = vo.getEndTime();
// long startTimeTemp = 0;
// long endTimeTemp = 0;
// if (Objects.equals("自定义", scheduleType)) {
// startTimeTemp = DateTimeHelper.getTimeStampConverter(startTime.substring(11, startTime.length()), "HH:mm");
// endTimeTemp = DateTimeHelper.getTimeStampConverter(endTime.substring(11, endTime.length()), "HH:mm");
// } else {
// startTimeTemp = DateTimeHelper.getTimeStampConverter(startTime, "HH:mm");
// endTimeTemp = DateTimeHelper.getTimeStampConverter(endTime, "HH:mm");
// }
// if (Objects.equals(scheduleType, "每天")) {
// // 每天
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// } else if (Objects.equals(scheduleType, "工作日")) {
// // 工作日
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// } else if (Objects.equals(scheduleType, "自定义")) {
// // 自定义
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// }
// }
// return flag;
// }
//
// /**
// * @param minTimeStamp
// * @param maxTimeStamp
// * @param list
// * @return boolean
// * @description 判断工作日
// * @author cwchen
// * @date 2023/9/22 13:18
// */
// public boolean compareScheduledByWorkDay(long minTimeStamp, long maxTimeStamp, List<MuiscScheduledVo> list) {
// boolean flag = true;
// for (MuiscScheduledVo vo : list) {
// String scheduleType = vo.getScheduleType();
// String startTime = vo.getStartTime();
// String endTime = vo.getEndTime();
// long startTimeTemp = 0;
// long endTimeTemp = 0;
// if (Objects.equals("自定义", scheduleType)) {
// startTimeTemp = DateTimeHelper.getTimeStampConverter(startTime.substring(11, startTime.length()), "yyyy-MM-dd HH:mm");
// endTimeTemp = DateTimeHelper.getTimeStampConverter(endTime.substring(11, endTime.length()), "yyyy-MM-dd HH:mm");
// } else {
// startTimeTemp = DateTimeHelper.getTimeStampConverter(startTime, "HH:mm");
// endTimeTemp = DateTimeHelper.getTimeStampConverter(endTime, "HH:mm");
// }
// if (Objects.equals(scheduleType, "每天")) {
// // 每天
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// } else if (Objects.equals(scheduleType, "工作日")) {
// // 工作日
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// } else if (Objects.equals(scheduleType, "自定义")) {
// // 自定义
// boolean isWeek = DateTimeHelper.isWeek(startTime.substring(0, 10));
// if (!isWeek) {
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// }
// }
// }
// return flag;
// }
//
// /**
// * @param minTimeStamp
// * @param maxTimeStamp
// * @param list
// * @return boolean
// * @description 自定义
// * @author cwchen
// * @date 2023/9/22 13:18
// */
// public boolean compareScheduledByCustom(String startDate, long minTimeStamp, long maxTimeStamp, List<MuiscScheduledVo> list) {
// boolean flag = true;
// for (MuiscScheduledVo vo : list) {
// String scheduleType = vo.getScheduleType();
// String startTime = vo.getStartTime();
// String endTime = vo.getEndTime();
// long startTimeTemp = 0;
// long endTimeTemp = 0;
// if (Objects.equals("自定义", scheduleType)) {
// startTimeTemp = DateTimeHelper.getTimeStampConverter(startTime, "yyyy-MM-dd HH:mm");
// endTimeTemp = DateTimeHelper.getTimeStampConverter(endTime, "yyyy-MM-dd HH:mm");
// } else {
// startTimeTemp = DateTimeHelper.getTimeStampConverter(DateTimeHelper.getNowDate() + " " + startTime, "yyyy-MM-dd HH:mm");
// endTimeTemp = DateTimeHelper.getTimeStampConverter(DateTimeHelper.getNowDate() + " " + endTime, "yyyy-MM-dd HH:mm");
// }
// if (Objects.equals(scheduleType, "每天")) {
// // 每天
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// } else if (Objects.equals(scheduleType, "工作日")) {
// boolean isWeek = DateTimeHelper.isWeek(startDate);
// if (!isWeek) {
// // 工作日
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// }
// } else if (Objects.equals(scheduleType, "自定义")) {
// // 自定义
// if ((minTimeStamp >= startTimeTemp && minTimeStamp <= endTimeTemp) || (maxTimeStamp >= startTimeTemp && maxTimeStamp <= endTimeTemp)) {
// flag = false;
// break;
// }
// }
// }
// return flag;
// }
//}

View File

@ -152,10 +152,7 @@ function initImgData(list) {
/**水印下载*/
function waterImgDownLoad(item) {
alert(item.id)
}
/**收藏*/
function collectImg(that, item, type) {

View File

@ -27,7 +27,7 @@ function imgDownLoad(item) {
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader('Content-Type','application/json;charset=UTF-8')
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
@ -35,7 +35,7 @@ function imgDownLoad(item) {
var a = document.createElement("a");
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = orginalPath.substring(orginalPath.lastIndexOf('/') + 1,orginalPath.length); // 文件名
a.download = orginalPath.substring(orginalPath.lastIndexOf('/') + 1, orginalPath.length); // 文件名
} else {
layer.msg("原图下载发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
}
@ -44,4 +44,94 @@ function imgDownLoad(item) {
};
// xhr.send(params);
xhr.send();
}
/**水印下载*/
function waterImgDownLoad(item) {
/* let orginalPath = item.originalFilePath;
let obj = {
imgPath: orginalPath,
}
let loadingMsg = layer.msg("水印图片下载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
let url = dataUrl + "/common/download/downloadImage?token=" + tokens + "&encryptedData=" + encodeURIComponent(encryptCBC(JSON.stringify(obj)));
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader('Content-Type','application/json;charset=UTF-8')
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
let blob = this.response;
var a = document.createElement("a");
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = orginalPath.substring(orginalPath.lastIndexOf('/') + 1,orginalPath.length); // 文件名
} else {
layer.msg("水印图片下载发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
}
a.click();
window.URL.revokeObjectURL(url);
};
// xhr.send(params);
xhr.send();*/
function downloadImage(imageUrl) {
let orginalPath = item.originalFilePath;
let obj = {
imgPath: orginalPath,
}
$.ajax({
url: dataUrl + "/common/download/downloadImage?token=" + tokens,
type: 'GET',
data: {
encryptedData: encodeURIComponent(encryptCBC(JSON.stringify(obj)))
},
xhrFields: {
responseType: 'blob' // 重要指定响应类型为blob
},
success: function (data, status, xhr) {
// 检查是否是blob数据图片
if (data instanceof Blob) {
// 创建临时URL用于下载
var blobUrl = URL.createObjectURL(data);
// 创建下载链接
var a = document.createElement('a');
a.href = blobUrl;
a.download = orginalPath.substring(orginalPath.lastIndexOf('/') + 1,orginalPath.length); // 提取文件名
document.body.appendChild(a);
a.click();
// 清理
setTimeout(function () {
document.body.removeChild(a);
URL.revokeObjectURL(blobUrl);
}, 100);
} else {
// 如果返回的不是blob可能是错误信息
console.error('服务器返回意外响应:', data);
alert('下载失败: 服务器返回无效数据');
}
},
error: function (xhr, status, error) {
// 尝试解析错误信息
var errorMsg = '下载失败';
if (xhr.responseText) {
try {
var errorResponse = JSON.parse(xhr.responseText);
errorMsg = errorResponse.message || errorMsg;
} catch (e) {
errorMsg = xhr.responseText;
}
}
alert(errorMsg);
}
});
}
// 使用示例
$('#download-btn').click(function () {
var imageUrl = $('#image-url').val();
downloadImage(imageUrl);
});
}

View File

@ -39,7 +39,7 @@
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">工程</label>
<div class="layui-input-inline" style="width: 515px;">
<div class="layui-input-inline" style="width: 575px !important;">
<select class="layui-select" lay-search></select>
</div>
</div>