From 0f54e90b33458c069841e5e1cc97217d12d239a5 Mon Sep 17 00:00:00 2001 From: ic_excellent Date: Fri, 3 Mar 2023 16:26:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=87=E8=B1=A1=E6=8A=A5=E8=A1=A8=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 16 + .../controller/YearReviewController.java | 29 +- .../porsche_review/mapper/ReviewMapper.java | 15 +- .../porsche_review/service/ReviewService.java | 2 +- .../service/impl/ReviewServiceImpl.java | 54 ++- .../controller/ReportController.java | 15 +- .../xiao/wx_report/entity/KeyTypeEntity.java | 19 + .../xiao/wx_report/entity/NetConfigItem.java | 18 + .../xiao/wx_report/entity/ReportDataVO.java | 83 ++++ .../xiao/wx_report/entity/ReportEntityVO.java | 19 + .../xiao/wx_report/mapper/ReportMapper.java | 11 +- .../xiao/wx_report/service/ReportService.java | 14 + .../xiao/wx_report/service/fun/Entry.java | 16 + .../wx_report/service/fun/GroupFunction.java | 18 + .../service/impl/ReportServiceImpl.java | 376 ++++++++++++++++++ src/test/java/bokang/xiao/NormalTest.java | 70 +++- .../java/bokang/xiao/entity/CourseEntity.java | 38 ++ .../bokang/xiao/entity/StudentEntity.java | 38 ++ .../bokang/xiao/entity/TeacherEntity.java | 25 ++ 19 files changed, 810 insertions(+), 66 deletions(-) create mode 100644 src/main/java/com/api/bokang/xiao/wx_report/entity/KeyTypeEntity.java create mode 100644 src/main/java/com/api/bokang/xiao/wx_report/entity/NetConfigItem.java create mode 100644 src/main/java/com/api/bokang/xiao/wx_report/entity/ReportDataVO.java create mode 100644 src/main/java/com/api/bokang/xiao/wx_report/service/fun/Entry.java create mode 100644 src/main/java/com/api/bokang/xiao/wx_report/service/fun/GroupFunction.java create mode 100644 src/test/java/bokang/xiao/entity/CourseEntity.java create mode 100644 src/test/java/bokang/xiao/entity/StudentEntity.java create mode 100644 src/test/java/bokang/xiao/entity/TeacherEntity.java diff --git a/pom.xml b/pom.xml index 48c519d..365f87d 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,22 @@ 4.4.0 + + cn.afterturn + easypoi-base + 4.0.0 + + + cn.afterturn + easypoi-web + 4.0.0 + + + cn.afterturn + easypoi-annotation + 4.0.0 + + diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java index d8d61f6..cb7c47a 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java @@ -20,7 +20,6 @@ import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Map; - /** * @ClassName YearReviewController * @Author 肖博亢 @@ -36,8 +35,11 @@ public class YearReviewController { /** 需要排除的流程id */ private final String workflowIds = new ToolUtil().getSystemParamValue("workflowIds"); - /** 建模表表名及字段 */ - private final String modelTables = new ToolUtil().getSystemParamValue("modelTables"); + /** 合同表名及条件信息 */ + private final String contractTable = new ToolUtil().getSystemParamValue("contractTable"); + + /** 用印表名及条件信息 */ + private final String sealTable = new ToolUtil().getSystemParamValue("sealTable"); /** *

获取创建或处理流程的总数

@@ -63,6 +65,7 @@ public class YearReviewController { } } + /** *

获取流程的总数

* @param request 请求体 @@ -86,20 +89,21 @@ public class YearReviewController { } /** - *

获取电子章的总数

+ *

获取电子章及合同总数的总数还有比例

* @param request 请求体 * @param response 响应体 * @param param 请求参数 * @return 请求结果 */ - @Path("/getElectronicSealCount") + @Path("/getContractAndSealCount") @POST @Produces(MediaType.APPLICATION_JSON) public String getElectronicSealCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { try{ - param.put("modelTables",modelTables); - int count = reviewService.getElectronicSealCount(param); - return ApiResult.success(count); + param.put("contractTable",contractTable); + param.put("sealTable",sealTable); + Map electronicSealCount = reviewService.getElectronicSealCount(param); + return ApiResult.success(electronicSealCount); }catch (Exception e){ log.error("获取电子章总数异常 ==> "+Util.getErrString(e)); return ApiResult.error(e.getMessage()); @@ -113,14 +117,17 @@ public class YearReviewController { * @param param 请求参数 * @return 请求结果 */ - @Path("/getWorkflowTop5") + @Path("/getWorkflowTop") @POST @Produces(MediaType.APPLICATION_JSON) - public String getWorkflowTop5(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + public String getWorkflowTop(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { try{ - log.info("into getWorkflowTop5 success params ==> "+param); + log.info("into getWorkflowTop success params ==> "+param); User loginUser = HrmUserVarify.getUser(request, response); param.put("workflowIds",workflowIds); + if(!param.containsKey("limit")){ + param.put("limit",3); + } String type = Util.null2String(param.get("type")); List> data = "create".equals(type) ? reviewService.getCreateTop5(param, loginUser) : reviewService.getOperateTop5(param, loginUser); return ApiResult.success(data); diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java b/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java index 98cc66e..4fba8ed 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java @@ -112,7 +112,7 @@ public interface ReviewMapper { " and workflowid not in (${param.workflowIds})" + "group by workflowid " + "ORDER BY wcount desc" + - "limit 5") + "limit ${param.limit}") List> queryCreateTop5(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); /** @@ -132,7 +132,7 @@ public interface ReviewMapper { " and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " + "group by workflowid " + "order by wcount desc " + - "limit 5") + "limit ${param.limit}") List> queryOperateTop5(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); /** @@ -171,12 +171,13 @@ public interface ReviewMapper { /** *

通过条件查询数量

* @param tableName 表名 - * @param fieldName 字段名 - * @param fieldValue 字段值 + * @param cusSql 自定义sql * @return 数量 */ - @Select("select count(*) from $t{tableName} where $t{fieldName} = #{fieldValue}") + @Select("select count(*) from $t{tableName} where $t{cusSql}") int queryCountByParam(@ParamMapper("tableName") String tableName, - @ParamMapper("fieldName") String fieldName, - @ParamMapper("fieldValue") String fieldValue); + @ParamMapper("cusSql") String cusSql); + + @Select("select tablename workflow_bill where id = #{tableId}") + String queryTableName(@ParamMapper("tableId")String tableId); } diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java b/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java index 10131ae..c75142c 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/service/ReviewService.java @@ -73,5 +73,5 @@ public interface ReviewService { * @param param 参数信息 * @return 查询结果 */ - int getElectronicSealCount(Map param); + Map getElectronicSealCount(Map param); } diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java b/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java index 76b18cf..e1a4966 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java @@ -3,6 +3,7 @@ package com.api.bokang.xiao.porsche_review.service.impl; import aiyh.utils.Util; import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; import com.api.bokang.xiao.porsche_review.service.ReviewService; +import org.apache.log4j.Logger; import weaver.hrm.User; import java.util.HashMap; @@ -21,6 +22,8 @@ public class ReviewServiceImpl implements ReviewService { private final ReviewMapper reviewMapper = Util.getMapper(ReviewMapper.class); + private final Logger log = Util.getLogger(); + private Integer resourceCount = 0; @Override @@ -73,19 +76,33 @@ public class ReviewServiceImpl implements ReviewService { } @Override - public int getElectronicSealCount(Map param) { - String modelTables = Util.null2String(param.get("modelTables")); - int totalCount = 0; - Map> modelTableMap = getModelTables(modelTables); - for (Map.Entry> entry : modelTableMap.entrySet()) { + public Map getElectronicSealCount(Map param) { + Map result = new HashMap<>(8); + String contractTableStr= Util.null2String(param.get("contractTable")); + String sealTableStr = Util.null2String(param.get("sealTable")); + int contractCount = 0; + int sealCount = 0; + Map contractTable = getModelTableSql(contractTableStr); + Map sealTable = getModelTableSql(sealTableStr); + log.info("contractTable ==>"+contractTable); + log.info("sealTable ==>"+sealTable); + //计算合同总数 + for (Map.Entry entry : contractTable.entrySet()) { String tableName = entry.getKey(); - Map fieldMap = entry.getValue(); - String fieldName = Util.null2String(fieldMap.get("fieldName")); - String fieldValue = Util.null2String(fieldMap.get("fieldValue")); - int count = reviewMapper.queryCountByParam(tableName, fieldName, fieldValue); - totalCount += count; + int count = reviewMapper.queryCountByParam(tableName,entry.getValue()); + contractCount += count; } - return totalCount; + //计算电子章总数 + for (Map.Entry entry : sealTable.entrySet()) { + String tableName = entry.getKey(); + int count = reviewMapper.queryCountByParam(tableName,entry.getValue()); + sealCount += count; + } + double exceed = 1.00*contractCount/sealCount; + result.put("contractCount",contractCount); + result.put("sealCount",sealCount); + result.put("exceed",exceed); + return result; } /** @@ -93,19 +110,16 @@ public class ReviewServiceImpl implements ReviewService { * @param sourceStr 原有表名字符串 * @return 表名集合 */ - public Map> getModelTables(String sourceStr){ - Map> modelTableMap = new HashMap<>(); - String regx = "\\{(?\\S+):(?\\S+):(?\\S+)}"; + public Map getModelTableSql(String sourceStr){ + Map modelTableMap = new HashMap<>(); + String regx = "\\{(?\\S+):(?\\S+)}"; Pattern compile = Pattern.compile(regx); Matcher matcher = compile.matcher(sourceStr); while (matcher.find()){ String tableName = matcher.group("tableName"); - String fieldName = matcher.group("fieldName"); - String fieldValue = matcher.group("fieldValue"); - Map fieldMap = new HashMap<>(); - fieldMap.put("fieldName",fieldName); - fieldMap.put("fieldValue",fieldValue); - modelTableMap.put(tableName,fieldMap); + String cusSql = matcher.group("cusSql"); + cusSql = cusSql.replaceAll("&"," and ").replaceAll("/|"," or "); + modelTableMap.put(tableName,cusSql); } return modelTableMap; } diff --git a/src/main/java/com/api/bokang/xiao/wx_report/controller/ReportController.java b/src/main/java/com/api/bokang/xiao/wx_report/controller/ReportController.java index bead34e..a885f86 100644 --- a/src/main/java/com/api/bokang/xiao/wx_report/controller/ReportController.java +++ b/src/main/java/com/api/bokang/xiao/wx_report/controller/ReportController.java @@ -4,17 +4,19 @@ import aiyh.utils.ApiResult; import aiyh.utils.Util; import com.api.bokang.xiao.wx_report.service.ReportService; import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl; +import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.log4j.Logger; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import java.util.Map; /** * @ClassName ReportController @@ -37,14 +39,15 @@ public class ReportController { * @return 请求结果 */ @Path("/getReportData") - @GET + @POST @Produces(MediaType.APPLICATION_JSON) - public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { try{ - log.info("====== into getCondition success ======="); + log.info("====== into getReportData success ======="); + log.info("param:"+param); User loginUser = HrmUserVarify.getUser(request, response); - - return ApiResult.success(""); + Map reportData = reportService.getReportData(loginUser, param); + return ApiResult.success(reportData); }catch (Exception e){ log.error("获取搜索组件信息 ==> "+Util.getErrString(e)); return ApiResult.error(e.getMessage()); diff --git a/src/main/java/com/api/bokang/xiao/wx_report/entity/KeyTypeEntity.java b/src/main/java/com/api/bokang/xiao/wx_report/entity/KeyTypeEntity.java new file mode 100644 index 0000000..22eebb1 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/wx_report/entity/KeyTypeEntity.java @@ -0,0 +1,19 @@ +package com.api.bokang.xiao.wx_report.entity; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +/** + * @ClassName KeyTypeEntity + * @Author 肖博亢 + * @Date 2023/2/28 13:18 + * @Description

+ **/ +@Data +@Builder +public class KeyTypeEntity { + private String key; + private List typeList; +} diff --git a/src/main/java/com/api/bokang/xiao/wx_report/entity/NetConfigItem.java b/src/main/java/com/api/bokang/xiao/wx_report/entity/NetConfigItem.java new file mode 100644 index 0000000..281a865 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/wx_report/entity/NetConfigItem.java @@ -0,0 +1,18 @@ +package com.api.bokang.xiao.wx_report.entity; + +import lombok.Builder; +import lombok.Data; + +/** + * @ClassName NetConfigItem + * @Author 肖博亢 + * @Date 2023/2/28 16:01 + * @Description

+ **/ + +@Data +@Builder +public class NetConfigItem { + private String dataInConfig; + private String dataOutConfig; +} diff --git a/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportDataVO.java b/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportDataVO.java new file mode 100644 index 0000000..faa0a68 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportDataVO.java @@ -0,0 +1,83 @@ +package com.api.bokang.xiao.wx_report.entity; + +import lombok.Data; + +import java.util.List; + +/** + * @ClassName ReportDataVO + * @Author 肖博亢 + * @Date 2023/2/27 11:52 + * @Description

+ **/ + +@Data +public class ReportDataVO { + + /** 经营性活动list */ + private List businessActivityList; + + /** 筹集资金list */ + private List financingList; + + /** 投资现金list */ + private List investmentList; + + /** 其他现金list */ + private List otherList; + + /** 经营性活动流入小计 */ + private Double businessInTotal; + + /** 经营性活动支出小计 */ + private Double businessOutTotal; + + /** 生产性经营支出小计 */ + private Double productionOutTotal; + + /** 固定支出小计 */ + private Double fixOutTotal; + + /** 经营性活动净额 */ + private Double businessNetTotal; + + /** 筹集资金流入小计 */ + private Double financingInTotal; + + /** 筹集资金流出小计 */ + private Double financingOutTotal; + + /** 筹集资金净额 */ + private Double financingNetTotal; + + /** 投资现金流入小计 */ + private Double investmentInTotal; + + /** 投资现金流出小计 */ + private Double investmentOutTotal; + + /** 投资现金净额 */ + private Double investmentNetTotal; + + /** 其他现金流入小计 */ + private Double otherInTotal; + + /** 其他现金流出小计 */ + private Double otherOutTotal; + + /** 其他现金净额 */ + private Double otherNetTotal; + + /** 收入小计 */ + private Double inTotal; + + /** 支出小计 */ + private Double outTotal; + + /** 本期净额 */ + private Double netTotal; + + /** 本期结余 */ + private Double balanceTotal; + +} diff --git a/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportEntityVO.java b/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportEntityVO.java index d475606..66351b3 100644 --- a/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportEntityVO.java +++ b/src/main/java/com/api/bokang/xiao/wx_report/entity/ReportEntityVO.java @@ -1,6 +1,13 @@ package com.api.bokang.xiao.wx_report.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; + +import java.text.DecimalFormat; +import java.text.NumberFormat; /** * @ClassName ReportEntity @@ -10,6 +17,9 @@ import lombok.Data; **/ @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor public class ReportEntityVO { /** 款项类别 */ @@ -24,6 +34,15 @@ public class ReportEntityVO { /** 月份 */ private Integer year; + /** 日 */ + private Integer day; + /** 金额合计 */ private Double amount; + + public void setAmount(Double amount) { + DecimalFormat format = new DecimalFormat("#.00"); + String str = format.format(amount); + this.amount = Double.parseDouble(str); + } } diff --git a/src/main/java/com/api/bokang/xiao/wx_report/mapper/ReportMapper.java b/src/main/java/com/api/bokang/xiao/wx_report/mapper/ReportMapper.java index 73c5805..6c1b966 100644 --- a/src/main/java/com/api/bokang/xiao/wx_report/mapper/ReportMapper.java +++ b/src/main/java/com/api/bokang/xiao/wx_report/mapper/ReportMapper.java @@ -63,7 +63,7 @@ public interface ReportMapper { */ @Select("select kxlb category,rq date,sum(hsjey) amount,month(rq) month,year(rq) year,day(rq) day " + "from uf_srmxb " + - "where kxlb is not null $t{queryStr}" + + "where kxlb is not null $t{queryStr} " + "group by kxlb,rq " + "order by category ") List queryDataInList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map param); @@ -77,7 +77,8 @@ public interface ReportMapper { @Select("select 90 category,sqrq date,sum(jkjey) amount,month(sqrq) month,year(sqrq) year,day(sqrq) day " + "from uf_byjjksqtzbb " + "where 1=1 $t{queryStr} " + - "group by sqrq ") + "group by sqrq " + + "order by category ") List queryPettyCashList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map param); /** @@ -89,7 +90,7 @@ public interface ReportMapper { @Select("select kxlb category,main.qwfkrq date,sum(fkjey) amount,month(main.qwfkrq) month,year(main.qwfkrq) year,day(main.qwfkrq) day " + "from uf_dgfksqtzbb main " + "inner join uf_dgfksqtzbb_dt1 dt on main.id = dt.mainid " + - "where kxlb is not null $t{queryStr}" + + "where kxlb is not null $t{queryStr} " + "group by dt.kxlb,main.qwfkrq " + "order by category ") List queryPublicPayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map param); @@ -103,7 +104,7 @@ public interface ReportMapper { @Select("select kxlb category,main.sqrq date,sum(bxjey) amount,month(main.sqrq) month,year(main.sqrq) year,day(main.sqrq) day " + "from uf_dsbxsqtzbb main " + "inner join uf_dsbxsqtzbb_dt1 dt on main.id = dt.mainid " + - "where kxlb is not null $t{queryStr}" + + "where kxlb is not null $t{queryStr} " + "group by dt.kxlb,main.sqrq " + "order by category ") List queryPrivatePayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map param); @@ -117,7 +118,7 @@ public interface ReportMapper { @Select("select kxlb category,main.sqrq date,sum(bxjey) amount,month(main.sqrq) month,year(main.sqrq) year,day(main.sqrq) day " + "from uf_dsbxsqtzclbb main " + "inner join uf_dsbxsqtzclbb_dt1 dt on main.id = dt.mainid " + - "where kxlb is not null $t{queryStr}" + + "where kxlb is not null $t{queryStr} " + "group by dt.kxlb,main.sqrq " + "order by category ") List queryBusinessList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map param); diff --git a/src/main/java/com/api/bokang/xiao/wx_report/service/ReportService.java b/src/main/java/com/api/bokang/xiao/wx_report/service/ReportService.java index 4efcb6c..664d6af 100644 --- a/src/main/java/com/api/bokang/xiao/wx_report/service/ReportService.java +++ b/src/main/java/com/api/bokang/xiao/wx_report/service/ReportService.java @@ -1,5 +1,11 @@ package com.api.bokang.xiao.wx_report.service; +import com.api.bokang.xiao.wx_report.entity.ReportEntityVO; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + /** * @ClassName ReportService * @Author 肖博亢 @@ -7,4 +13,12 @@ package com.api.bokang.xiao.wx_report.service; * @Description

**/ public interface ReportService { + + /** + *

获取报表数据

+ * @param user 登录用户 + * @param param 查询条件 + * @return 报表数据信息 + */ + Map getReportData(User user, Map param); } diff --git a/src/main/java/com/api/bokang/xiao/wx_report/service/fun/Entry.java b/src/main/java/com/api/bokang/xiao/wx_report/service/fun/Entry.java new file mode 100644 index 0000000..4e9a39b --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/wx_report/service/fun/Entry.java @@ -0,0 +1,16 @@ +package com.api.bokang.xiao.wx_report.service.fun; + +import lombok.Data; + +/** + * @ClassName Entry + * @Author 肖博亢 + * @Date 2023/2/28 12:33 + * @Description

+ **/ +@Data +public class Entry { + + private K key; + private V value; +} diff --git a/src/main/java/com/api/bokang/xiao/wx_report/service/fun/GroupFunction.java b/src/main/java/com/api/bokang/xiao/wx_report/service/fun/GroupFunction.java new file mode 100644 index 0000000..5f3827a --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/wx_report/service/fun/GroupFunction.java @@ -0,0 +1,18 @@ +package com.api.bokang.xiao.wx_report.service.fun; + +import java.util.List; + + +/** + * @ClassName GroupFunction + * @Author 肖博亢 + * @Date 2023/2/28 12:32 + * @Description

+ **/ +@FunctionalInterface +public interface GroupFunction { + + + Entry group(List list); + +} diff --git a/src/main/java/com/api/bokang/xiao/wx_report/service/impl/ReportServiceImpl.java b/src/main/java/com/api/bokang/xiao/wx_report/service/impl/ReportServiceImpl.java index 3883bcb..28667c7 100644 --- a/src/main/java/com/api/bokang/xiao/wx_report/service/impl/ReportServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/wx_report/service/impl/ReportServiceImpl.java @@ -1,6 +1,20 @@ package com.api.bokang.xiao.wx_report.service.impl; +import aiyh.utils.Util; +import com.api.bokang.xiao.wx_report.entity.KeyTypeEntity; +import com.api.bokang.xiao.wx_report.entity.NetConfigItem; +import com.api.bokang.xiao.wx_report.entity.ReportEntityVO; +import com.api.bokang.xiao.wx_report.mapper.ReportMapper; import com.api.bokang.xiao.wx_report.service.ReportService; +import com.api.bokang.xiao.wx_report.service.fun.Entry; +import com.api.bokang.xiao.wx_report.service.fun.GroupFunction; +import weaver.hrm.User; + +import java.text.DecimalFormat; +import java.util.*; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; /** * @ClassName ReportServiceImpl @@ -9,4 +23,366 @@ import com.api.bokang.xiao.wx_report.service.ReportService; * @Description

**/ public class ReportServiceImpl implements ReportService { + + private final ReportMapper reportMapper = Util.getMapper(ReportMapper.class); + + private static final List TYPE_IN_LIST = new ArrayList<>(); + private static final List TYPE_OUT_LIST = new ArrayList<>(); + + private static final Map NET_MAP_CONFIG = new HashMap<>(); + + static { + + //经营性活动现金流入 "0":销售回款; "1":电池租赁款; "2":国补"; "3":其他 + TYPE_IN_LIST.add(KeyTypeEntity.builder().key("businessInTotal").typeList(Arrays.asList("0","1","2","3")).build()); + + //筹资活动现金流入 "4":贷款流入; "5":借款流入; "6":内部往来款 + TYPE_IN_LIST.add(KeyTypeEntity.builder().key("financingInTotal").typeList(Arrays.asList("4","5","6")).build()); + + //投资活动资金流入 "7":收到投资款 + TYPE_IN_LIST.add(KeyTypeEntity.builder().key("investmentInTotal").typeList(Collections.singletonList("7")).build()); + + //其他收入 "8"退保证金; "9"电池背靠背收; "10"其他收入-其他 + TYPE_IN_LIST.add(KeyTypeEntity.builder().key("otherInTotal").typeList(Arrays.asList("8","9","10")).build()); + + } + + static { + + //生产经营支出 "1":水电、动力款; "8":采购货款(含零星); "4":广宣费; "2":运费(含快递费); + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("productionOutTotal").typeList(Arrays.asList("1","8","4","2")).build()); + + //固定支出 "7":税款; "3":社保/福利/奖金; "11":财务费用; "6":工资、劳务费; "0":费用报销 + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("fixOutTotal").typeList(Arrays.asList("7","3","11","6","0")).build()); + + //经营活动支出小计 生产经营支出 + 固定支出 + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("businessOutTotal").typeList(Arrays.asList("1","8","4","2","7","3","11","6","0")).build()); + + //固定支出 "7":税款; "3":社保/福利/奖金; "11":财务费用; "6":工资、劳务费; "0":费用报销 + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("fixOutTotal").typeList(Arrays.asList("7","3","11","6","0")).build()); + + //筹资活动现金流出 "9":融资还款(贷款); "10":内部往来还款 + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("financingOutTotal").typeList(Arrays.asList("9","10")).build()); + + //投资活动资金流出 "12":设备款; "13":基建工程款; "15":投资支付的现金; "14":资质准入; "5":研发款、检测款 + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("investmentOutTotal").typeList(Arrays.asList("12","13","14","15","5")).build()); + + //其他支出 "16":保证金; "19":电池背靠背支出; "17":其他支出-其他; "18":暂借款 + TYPE_OUT_LIST.add(KeyTypeEntity.builder().key("otherOutTotal").typeList(Arrays.asList("16","17","18","19")).build()); + + } + + static { + + NET_MAP_CONFIG.put("businessNetTotal",NetConfigItem.builder().dataInConfig("businessInTotal").dataOutConfig("businessOutTotal").build()); + NET_MAP_CONFIG.put("financingNetTotal",NetConfigItem.builder().dataInConfig("financingInTotal").dataOutConfig("financingOutTotal").build()); + NET_MAP_CONFIG.put("investmentNetTotal",NetConfigItem.builder().dataInConfig("investmentInTotal").dataOutConfig("investmentOutTotal").build()); + NET_MAP_CONFIG.put("otherNetTotal",NetConfigItem.builder().dataInConfig("businessInTotal").dataOutConfig("businessOutTotal").build()); + NET_MAP_CONFIG.put("netTotal",NetConfigItem.builder().dataInConfig("inTotal").dataOutConfig("outTotal").build()); + + } + + @Override + public Map getReportData(User user, Map param) { + Map result = new HashMap<>(); + Map sqlMap = this.buildSql(param); + List reportEntityList = new ArrayList<>(); + List dataInList = reportMapper.queryDataInList(sqlMap.get("dataInSql"), param); + List pettyCashList = reportMapper.queryPettyCashList(sqlMap.get("pettyCashSql"), param); + List publicPayList = reportMapper.queryPublicPayList(sqlMap.get("publicPaySql"), param); + List privatePayList = reportMapper.queryPrivatePayList(sqlMap.get("privatePaySql"), param); + List businessList = reportMapper.queryBusinessList(sqlMap.get("businessSql"), param); + reportEntityList.addAll(pettyCashList); + reportEntityList.addAll(publicPayList); + reportEntityList.addAll(privatePayList); + reportEntityList.addAll(businessList); + //分组求和 统计同一款项类别的数据集合,并计算统一款项类别,同一天的数据总和 + Map> dataOutMap = this.groupList(reportEntityList); + //分组 统计同一款项类别的数据集合 + Map> dataInMap = dataInList.stream().collect(Collectors.groupingBy(ReportEntityVO::getCategory)); + List dataInAllList = this.statisticsSum(dataInMap); + List dataOutAllList = this.statisticsSum(dataOutMap); + //分组统计总和 + Map> totalMap = this.getTotalMap(dataInAllList,1); + totalMap.putAll(this.getTotalMap(dataOutAllList,2)); + totalMap.putAll(this.getNetMap(totalMap)); + result.put("dataInMap",dataInMap); + result.put("dataOutMap",dataOutMap); + result.put("totalMap",totalMap); + result.put("currentCompanySpan",Util.null2String(param.get("currentCompanySpan"))); + result.put("month",Util.null2String(param.get("month"))); + return result; + } + + /** + *

获取净额数据

+ * @param totalMap 数据集合 + * @return 净额数据 + */ + public Map> getNetMap(Map> totalMap){ + + return NET_MAP_CONFIG.entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + e -> { + NetConfigItem netConfigItem = e.getValue(); + String dataInConfig = netConfigItem.getDataInConfig(); + String dataOutConfig = netConfigItem.getDataOutConfig(); + List dataInReportList = totalMap.get(dataInConfig); + List dataOutReportList = totalMap.get(dataOutConfig); + Map netTotalMap = new HashMap<>(); + if(dataInReportList!= null && !dataInReportList.isEmpty()) { + for (ReportEntityVO inReport : dataInReportList) { + netTotalMap.put(inReport.getDay(), inReport.getAmount()); + } + } + if(dataOutReportList!= null && !dataOutReportList.isEmpty()) { + for (ReportEntityVO outReport : dataOutReportList) { + if (netTotalMap.containsKey(outReport.getDay())) { + double inTotal = netTotalMap.get(outReport.getDay()); + double outTotal = outReport.getAmount(); + netTotalMap.put(outReport.getDay(), this.getTwoDouble(inTotal - outTotal)); + }else { + netTotalMap.put(outReport.getDay(),this.getTwoDouble(-1*(outReport.getAmount()))); + } + } + } + return netTotalMap.entrySet().stream().map(netEntry -> ReportEntityVO.builder() + .day(netEntry.getKey()) + .amount(netEntry.getValue()) + .build()).collect(Collectors.toList()); + })); + } + + + /** + *

保留两位小数

+ * @param amount 数量 + * @return double + */ + public double getTwoDouble(double amount) { + DecimalFormat format = new DecimalFormat("#.00"); + String str = format.format(amount); + return Double.parseDouble(str); + } + + /** + *

获取总数map集合

+ * @param dataList 数据集合 + * @param type 数据处理类型 1:收入 2:支出 + * @return 分组求和后的数据集合 + */ + public Map> getTotalMap(List dataList,int type){ + List typeList = type == 1 ? TYPE_IN_LIST : TYPE_OUT_LIST; + Map> totalMap = new HashMap<>(); + List dataTotalList = new ArrayList<>(); + Map> dayReportMap = dataList.stream().collect(Collectors.groupingBy(ReportEntityVO::getDay)); + for (Map.Entry> dayReportEntry : dayReportMap.entrySet()) { + Integer day = dayReportEntry.getKey(); + List dayReportList = dayReportEntry.getValue(); + double sum = dayReportList.stream().mapToDouble(ReportEntityVO::getAmount).sum(); + sum = this.getTwoDouble(sum); + dataTotalList.add(ReportEntityVO.builder() + .amount(sum) + .day(day) + .build() + ); + Map reportEntityMap = this.sumParse(dayReportList,typeList); + for (Map.Entry entry : reportEntityMap.entrySet()) { + String key = entry.getKey(); + ReportEntityVO value = entry.getValue(); + if(totalMap.containsKey(key)){ + totalMap.get(key).add(value); + }else { + List totalReportList = new ArrayList<>(); + totalReportList.add(value); + totalMap.put(key,totalReportList); + } + } + } + String totalKey = type == 1 ? "inTotal" : "outTotal"; + totalMap.put(totalKey,dataTotalList); + return totalMap; + } + + /** + *

根据配置条件分组求和

+ * @param reportEntityList 原数据集合 + * @param typeList 分组条件集合 + * @return 求和后的实体类 + */ + private Map sumParse(List reportEntityList,List typeList){ + List,ReportEntityVO>> groupFun = new ArrayList<>(); + + for (KeyTypeEntity keyTypeEntity : typeList) { + groupFun.add(list->parseGroup(reportEntityList,keyTypeEntity.getKey(), + item-> keyTypeEntity.getTypeList() + .contains(item),ReportEntityVO::getCategory)); + } + + Map result = new HashMap<>(16); + for (GroupFunction, ReportEntityVO> fun : groupFun) { + Entry> groupEntry = fun.group(reportEntityList); + if(Objects.isNull(groupEntry)){ + continue; + } + double sum = groupEntry.getValue().stream().mapToDouble(ReportEntityVO::getAmount).sum(); + sum = this.getTwoDouble(sum); + result.put(groupEntry.getKey(), ReportEntityVO.builder() + .amount(sum) + .day(groupEntry.getValue().get(0).getDay()) + .build()); + } + return result; + } + + /** + *

具体分组方法

+ * @param list 原数据集合 + * @param k 泛型 + * @param compare 比较方法 + * @param compareValue 获取对象比较值 + * @return 分组后对象 + * @param 键泛型 + * @param 分组list泛型 + * @param 分组值泛型 + */ + private Entry> parseGroup(List list, K k, + Predicate compare, + Function compareValue){ + Entry> entry = new Entry<>(); + for (T t : list) { + if(compare.test(compareValue.apply(t))){ + if(Objects.isNull(entry.getValue())){ + entry.setValue(new ArrayList<>()); + } + entry.getValue().add(t); + } + } + if(entry.getValue() == null || entry.getValue().isEmpty()){ + return null; + } + entry.setKey(k); + return entry; + } + + /** + *

将list分组求和

+ * @param reportEntityList 原数组 + * @return 分组后的map集合 + */ + public Map> groupList(List reportEntityList){ + return reportEntityList.stream() + .collect(Collectors.groupingBy(ReportEntityVO::getCategory)) + .entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + e -> e.getValue().stream() + .collect(Collectors.groupingBy(ReportEntityVO::getDate)) + .entrySet().stream() + .map(dateListEntry -> { + List dateList = dateListEntry.getValue(); + ReportEntityVO reportEntity = dateList.get(0); + double amount = dateList.stream().mapToDouble(ReportEntityVO::getAmount).sum(); + amount = this.getTwoDouble(amount); + return ReportEntityVO.builder() + .amount(amount) + .date(dateListEntry.getKey()) + .day(reportEntity.getDay()) + .year(reportEntity.getYear()) + .category(reportEntity.getCategory()) + .month(reportEntity.getMonth()) + .build(); + }).collect(Collectors.toList()) + )); + } + + /** + *

计算每一种款项类别的总和

+ * @param dataMap 数据信息 + * @return list集合 + */ + public List statisticsSum(Map> dataMap){ + List allReportList = new ArrayList<>(); + //计算每一行的总和并将结果加到list中 + for (Map.Entry> entry : dataMap.entrySet()) { + String category = entry.getKey(); + List reportList = entry.getValue(); + ReportEntityVO reportEntityVO = reportList.get(0); + double cateGoryTotal = reportList.stream().mapToDouble(ReportEntityVO::getAmount).sum(); + cateGoryTotal = this.getTwoDouble(cateGoryTotal); + ReportEntityVO totalEntity = ReportEntityVO.builder() + .amount(cateGoryTotal) + .day(-1) + .category(category) + .month(reportEntityVO.getMonth()) + .year(reportEntityVO.getYear()) + .build(); + reportList.add(totalEntity); + allReportList.addAll(reportList); + } + return allReportList; + } + + /** + *

构建查询sql

+ * @param param 条件 + * @return 查询sql的集合 + */ + public Map buildSql(Map param){ + Map sqlMap = new HashMap<>(); + StringBuilder pettyCashBuilder = new StringBuilder(); + StringBuilder publicPayBuilder = new StringBuilder(); + StringBuilder privatePayBuilder = new StringBuilder(); + StringBuilder businessBuilder = new StringBuilder(); + StringBuilder dataInBuilder = new StringBuilder(); + String month = Util.null2String(param.get("month")); + String year = Util.null2String(param.get("year")); + String date = Util.null2String(param.get("date")); + String company = Util.null2String(param.get("company")); + String depart = Util.null2String(param.get("depart")); + if(!"".equals(month)){ + dataInBuilder.append(" and ").append(" month(rq) = #{param.month}"); + pettyCashBuilder.append(" and ").append(" month(sqrq) = #{param.month}"); + publicPayBuilder.append(" and ").append(" month(main.qwfkrq) = #{param.month}"); + privatePayBuilder.append(" and ").append(" month(main.sqrq) = #{param.month}"); + businessBuilder.append(" and ").append(" month(main.sqrq) = #{param.month}"); + } + if(!"".equals(year)){ + dataInBuilder.append(" and ").append(" year(rq) = #{param.year}"); + pettyCashBuilder.append(" and ").append(" year(sqrq) = #{param.year}"); + publicPayBuilder.append(" and ").append(" year(main.qwfkrq) = #{param.year}"); + privatePayBuilder.append(" and ").append(" year(main.sqrq) = #{param.year}"); + businessBuilder.append(" and ").append(" year(main.sqrq) = #{param.year}"); + } + if(!"".equals(date)){ + dataInBuilder.append(" and ").append(" rq = #{param.date}"); + pettyCashBuilder.append(" and ").append(" sqrq = #{param.date}"); + publicPayBuilder.append(" and ").append(" main.qwfkrq = #{param.date}"); + privatePayBuilder.append(" and ").append(" main.sqrq = #{param.date}"); + businessBuilder.append(" and ").append(" main.sqrq = #{param.date}"); + } + if(!"".equals(depart)){ + dataInBuilder.append(" and ").append(" fycdbm = #{param.depart}"); + pettyCashBuilder.append(" and ").append(" sqbm = #{param.depart}"); + publicPayBuilder.append(" and ").append(" main.sqbm = #{param.depart}"); + privatePayBuilder.append(" and ").append(" main.sqbm = #{param.depart}"); + businessBuilder.append(" and ").append(" main.sqbm = #{param.depart}"); + } + if(!"".equals(company)){ + dataInBuilder.append(" and ").append(" fyzfgs = #{param.company}"); + pettyCashBuilder.append(" and ").append(" dwmc = #{param.company}"); + publicPayBuilder.append(" and ").append(" main.fycdgs = #{param.company}"); + privatePayBuilder.append(" and ").append(" main.fycdgs = #{param.company}"); + businessBuilder.append(" and ").append(" main.sqrq = #{param.company}"); + } + sqlMap.put("dataInSql",dataInBuilder.toString()); + sqlMap.put("pettyCashSql",pettyCashBuilder.toString()); + sqlMap.put("publicPaySql",publicPayBuilder.toString()); + sqlMap.put("privatePaySql",privatePayBuilder.toString()); + sqlMap.put("businessSql",businessBuilder.toString()); + return sqlMap; + } + + } diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 47eef00..d12497a 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -1,32 +1,43 @@ package bokang.xiao; import aiyh.utils.GenerateFileUtil; +import aiyh.utils.ThreadPoolConfig; import aiyh.utils.Util; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import basetest.BaseTest; +import bokang.xiao.entity.CourseEntity; +import bokang.xiao.entity.StudentEntity; +import bokang.xiao.entity.TeacherEntity; import bokang.xiao.mapper.TestMapper; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl; import com.api.bokang.xiao.wx_report.entity.ReportEntityVO; import com.api.bokang.xiao.wx_report.mapper.ReportMapper; +import com.api.bokang.xiao.wx_report.service.ReportService; +import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.apache.poi.POIXMLDocument; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.Range; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; import org.junit.Test; import weaver.bokang.xiao.dz_invoice.action.InvoiceDeductionAction; import weaver.bokang.xiao.dz_invoice.schedule.InvoiceQuerySchedule; +import weaver.hrm.User; import weaver.xiao.commons.config.entity.ResponseMapping; import weaver.xiao.commons.utils.DocImageFileUtil; import java.io.*; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; /** @@ -68,22 +79,10 @@ public class NormalTest extends BaseTest { Map queryParam = new HashMap<>(); queryParam.put("month","12"); queryParam.put("year","2022"); - StringBuilder PettyCashBuilder = new StringBuilder(); - StringBuilder PublicPayBuilder = new StringBuilder(); - StringBuilder PrivatePayBuilder = new StringBuilder(); - StringBuilder BusinessBuilder = new StringBuilder(); - StringBuilder whereBuilder = new StringBuilder(); - String month = Util.null2String(queryParam.get("month")); - String year = Util.null2String(queryParam.get("year")); - String date = Util.null2String(queryParam.get("date")); - String company = Util.null2String(queryParam.get("company")); - String depart = Util.null2String(queryParam.get("depart")); - if(StringUtils.isNotBlank(month)){ - - } - List reportEntityVOS = mapper.queryReportList(whereBuilder.toString(),queryParam); - Map> groupMap = reportEntityVOS.stream().collect(Collectors.groupingBy(ReportEntityVO::getCategory)); - System.out.println(groupMap); + //queryParam.put("date","2022-12-01"); + ReportService reportService = new ReportServiceImpl(); + Map reportData = reportService.getReportData(new User(1), queryParam); + System.out.println(reportData); } @Test @@ -129,6 +128,45 @@ public class NormalTest extends BaseTest { Map responseEntity = responeVo1.getResponseEntity(Map.class); System.out.println(responseEntity); + + } + + @Test + public void testExportExcel() throws Exception { + + List courseEntityList = new ArrayList<>(); + CourseEntity courseEntity = new CourseEntity(); + courseEntity.setId("1"); + courseEntity.setName("测试课程"); + TeacherEntity teacherEntity = new TeacherEntity(); + teacherEntity.setName("张老师"); + teacherEntity.setSex(1); + courseEntity.setMathTeacher(teacherEntity); + + courseEntity.setStingList(Arrays.asList("姜凯","加几个","hih")); + List studentEntities = new ArrayList<>(); + for (int i = 1; i <= 2; i++) { + StudentEntity studentEntity = new StudentEntity(); + studentEntity.setName("学生" + i); + studentEntity.setSex(i); + studentEntity.setBirthday(new Date()); + studentEntities.add(studentEntity); + } + courseEntity.setStudents(studentEntities); + courseEntityList.add(courseEntity); + Date start = new Date(); + Workbook workbook = ExcelExportUtil.exportExcel( new ExportParams("导出测试", null, "测试"), + CourseEntity.class, courseEntityList); + System.out.println(new Date().getTime() - start.getTime()); + File savefile = new File("D:/excel/"); + if (!savefile.exists()) { + savefile.mkdirs(); + } + FileOutputStream fos = new FileOutputStream("D:/excel/教师课程学生导出测试.xls"); + workbook.write(fos); + fos.close(); + + } } diff --git a/src/test/java/bokang/xiao/entity/CourseEntity.java b/src/test/java/bokang/xiao/entity/CourseEntity.java new file mode 100644 index 0000000..9688757 --- /dev/null +++ b/src/test/java/bokang/xiao/entity/CourseEntity.java @@ -0,0 +1,38 @@ +package bokang.xiao.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import cn.afterturn.easypoi.excel.annotation.ExcelEntity; +import lombok.Data; + +import java.util.List; + +/** + * @ClassName CourseEntity + * @Author 肖博亢 + * @Date 2023/3/3 13:35 + * @Description

+ **/ + +@Data +public class CourseEntity implements java.io.Serializable { + + /** 主键 */ + private String id; + /** 课程名称 */ + @Excel(name = "课程名称", orderNum = "1", width = 25,needMerge = true) + private String name; + /** 老师主键 */ + //@ExcelEntity(id = "major") + private TeacherEntity chineseTeacher; + /** 老师主键 */ + @ExcelEntity(id = "absent") + private TeacherEntity mathTeacher; + + @ExcelCollection(name = "学生", orderNum = "4") + private List students; + + @ExcelCollection(name = "kkl", orderNum = "4") + private List StingList; + +} diff --git a/src/test/java/bokang/xiao/entity/StudentEntity.java b/src/test/java/bokang/xiao/entity/StudentEntity.java new file mode 100644 index 0000000..02d449c --- /dev/null +++ b/src/test/java/bokang/xiao/entity/StudentEntity.java @@ -0,0 +1,38 @@ +package bokang.xiao.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * @ClassName StudentEntity + * @Author 肖博亢 + * @Date 2023/3/3 13:36 + * @Description

+ **/ + +@Data +public class StudentEntity { + /** + * id + */ + private String id; + /** + * 学生姓名 + */ + @Excel(name = "学生姓名", height = 20, width = 30, isImportField = "true_st") + private String name; + /** + * 学生性别 + */ + @Excel(name = "学生性别", replace = { "男_1", "女_2" }, suffix = "生", isImportField = "true_st") + private int sex; + + @Excel(name = "出生日期", exportFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd", isImportField = "true_st", width = 20) + private Date birthday; + + @Excel(name = "进校日期", exportFormat = "yyyyMMddHHmmss", format = "yyyy-MM-dd") + private Date registrationDate; + +} diff --git a/src/test/java/bokang/xiao/entity/TeacherEntity.java b/src/test/java/bokang/xiao/entity/TeacherEntity.java new file mode 100644 index 0000000..49517b7 --- /dev/null +++ b/src/test/java/bokang/xiao/entity/TeacherEntity.java @@ -0,0 +1,25 @@ +package bokang.xiao.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * @ClassName TeacherEntity + * @Author 肖博亢 + * @Date 2023/3/3 13:35 + * @Description

+ **/ + +@Data +public class TeacherEntity { + /** + * 学生姓名 + */ + @Excel(name = "教师姓名", height = 20, width = 30, isImportField = "true_st") + private String name; + /** + * 学生性别 + */ + @Excel(name = "教师性别", replace = {"男_1", "女_2"}, suffix = "生", isImportField = "true_st") + private int sex; +}