优化细节

This commit is contained in:
磷叶 2025-01-14 17:16:46 +08:00
parent a21d58b19a
commit 7dfcfdf823
7 changed files with 63 additions and 77 deletions

View File

@ -1,75 +1,5 @@
package com.ruoyi.common.utils.poi;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFPicture;
import org.apache.poi.hssf.usermodel.HSSFPictureData;
import org.apache.poi.hssf.usermodel.HSSFShape;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.PictureData;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFPicture;
import org.apache.poi.xssf.usermodel.XSSFShape;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
@ -85,6 +15,32 @@ import com.ruoyi.common.utils.file.FileTypeUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.file.ImageUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.*;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
* Excel相关处理
@ -406,12 +362,13 @@ public class ExcelUtil<T>
if (String.class == fieldType)
{
String s = Convert.toStr(val);
if (StringUtils.endsWith(s, ".0"))
{
// 过滤掉空字符串
if ("NULL".equals(s) || "null".equals(s)) {
val = "";
} else if (StringUtils.endsWith(s, ".0")) {
val = StringUtils.substringBefore(s, ".0");
}
else
{
} else {
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
if (StringUtils.isNotEmpty(dateFormat))
{

View File

@ -146,7 +146,7 @@ public class Price extends BaseEntity implements LogBizParam
@Excel(name = "备注")
private String remark;
@Excel(name = "代码")
@Excel(name = "代码", type = Excel.Type.EXPORT)
private String code;
@Excel(name = "表面处理")

View File

@ -106,4 +106,7 @@ public class ReportProd extends BaseEntity
@ApiModelProperty("工序代码")
private String priceCode;
@Excel(name = "表面处理")
@ApiModelProperty("表面处理")
private String surface;
}

View File

@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
brp.remark,
brp.price_code,
brp.total_amount,
brp.surface,
bp.dept_id as price_dept_id,
br.status as report_status,
sd.dept_name as price_dept_name
@ -57,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.deleted != null">and brp.deleted = #{deleted}</if>
<if test="query.reportStatus != null and query.reportStatus != ''">and br.status = #{query.reportStatus}</if>
<if test="query.priceCode != null and query.priceCode != ''">and brp.price_code like concat('%', #{query.priceCode}, '%')</if>
<if test="query.surface != null and query.surface != ''"> and brp.surface = like concat('%', #{query.surface}, '%')</if>
<if test="query.reportIds != null and query.reportIds.size() > 0">
and brp.report_id in
<foreach collection="query.reportIds" item="item" open="(" close=")" separator=",">
@ -104,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''">remark,</if>
<if test="totalAmount != null">total_amount,</if>
<if test="priceCode != null">price_code,</if>
<if test="surface != null">surface,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reportId != null">#{reportId},</if>
@ -125,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''">#{remark},</if>
<if test="totalAmount != null">#{totalAmount},</if>
<if test="priceCode != null">#{priceCode},</if>
<if test="surface != null">#{surface},</if>
</trim>
</insert>
@ -148,7 +152,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
price_type,
remark,
total_amount,
price_code
price_code,
surface
)
values
<foreach collection="list" item="i" separator=",">
@ -191,6 +196,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="i.totalAmount == null">default,</if>
<if test="i.priceCode != null">#{i.priceCode},</if>
<if test="i.priceCode == null">default,</if>
<if test="i.surface != null ">#{i.surface},</if>
<if test="i.surface == null ">default,</if>
</trim>
</foreach>
</insert>
@ -223,6 +230,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.remark != null and data.remark != ''">remark = #{data.remark},</if>
<if test="data.totalAmount != null">total_amount = #{data.totalAmount},</if>
<if test="data.priceCode != null">price_code = #{data.priceCode},</if>
<if test="data.surface != null">surface = #{data.surface},</if>
</sql>
<update id="batchUpdate">
@ -418,6 +426,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise>
</choose>
</foreach>
<foreach open="surface = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.surface != null ">
WHEN #{item.id} THEN #{item.surface}
</when>
<otherwise>
WHEN #{item.id} THEN `surface`
</otherwise>
</choose>
</foreach>
</trim>
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">

View File

@ -53,6 +53,7 @@ public class ReportProdConverterImpl implements ReportProdConverter {
bo.setRemark(vo.getRemark());
bo.setDefectNum(vo.getDefectNum());
bo.setPriceCode(vo.getPriceCode());
bo.setSurface(vo.getSurface());
bo.setTotalAmount(vo.getPricePrice().multiply(vo.getNum().add(vo.getDefectNum())));
// 用户产量明细
@ -104,6 +105,7 @@ public class ReportProdConverterImpl implements ReportProdConverter {
bo.setRemark(vo.getRemark());
bo.setDefectNum(vo.getDefectNum());
bo.setPriceCode(vo.getPriceCode());
bo.setSurface(vo.getSurface());
bo.setTotalAmount(vo.getPricePrice().multiply(vo.getNum().add(vo.getDefectNum())));
// 用户产量明细

View File

@ -19,6 +19,10 @@ public class ReportUserProdVO extends ReportUserProd {
@ApiModelProperty("用户名称")
private String userName;
@Excel(name = "员工编号")
@ApiModelProperty("员工编号")
private String userNo;
@Excel(name = "报表日期", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("报表日期")
private LocalDate reportDate;

View File

@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
brup.num,
brup.deleted,
su.nick_name as user_name,
su.user_no as user_no,
brp.price_name as price_name,
brp.price_unit as price_unit,
brp.price_price as price_price,
@ -52,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.userName != null and query.userName != ''">and su.nick_name like concat('%', #{query.userName}, '%')</if>
<if test="query.priceName != null and query.priceName != ''">and brp.price_name like concat('%', #{query.priceName}, '%')</if>
<if test="query.priceCode != null and query.priceCode != ''">and brp.price_code like concat('%', #{query.priceCode}, '%')</if>
<if test="query.userNo != null and query.userNo != ''">and su.user_no like concat('%', #{query.userNo}, '%')</if>
<if test="query.reportStatus != null and query.reportStatus != ''">and br.status = #{query.reportStatus}</if>
<if test="query.deptId != null">and br.dept_id = #{query.deptId}</if>
<if test="query.prodIds != null and query.prodIds.size() > 0 ">