Compare commits
2 Commits
4a54e7f5c7
...
680e4b9343
Author | SHA1 | Date |
---|---|---|
ic_excellent | 680e4b9343 | |
ic_excellent | 0f54e90b33 |
16
pom.xml
16
pom.xml
|
@ -97,6 +97,22 @@
|
||||||
<version>4.4.0</version>
|
<version>4.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.afterturn</groupId>
|
||||||
|
<artifactId>easypoi-base</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.afterturn</groupId>
|
||||||
|
<artifactId>easypoi-web</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.afterturn</groupId>
|
||||||
|
<artifactId>easypoi-annotation</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import javax.ws.rs.core.MediaType;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName YearReviewController
|
* @ClassName YearReviewController
|
||||||
* @Author 肖博亢
|
* @Author 肖博亢
|
||||||
|
@ -36,8 +35,11 @@ public class YearReviewController {
|
||||||
/** 需要排除的流程id */
|
/** 需要排除的流程id */
|
||||||
private final String workflowIds = new ToolUtil().getSystemParamValue("workflowIds");
|
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");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取创建或处理流程的总数</h2>
|
* <h2>获取创建或处理流程的总数</h2>
|
||||||
|
@ -63,6 +65,7 @@ public class YearReviewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取流程的总数</h2>
|
* <h2>获取流程的总数</h2>
|
||||||
* @param request 请求体
|
* @param request 请求体
|
||||||
|
@ -86,20 +89,21 @@ public class YearReviewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取电子章的总数</h2>
|
* <h2>获取电子章及合同总数的总数还有比例</h2>
|
||||||
* @param request 请求体
|
* @param request 请求体
|
||||||
* @param response 响应体
|
* @param response 响应体
|
||||||
* @param param 请求参数
|
* @param param 请求参数
|
||||||
* @return 请求结果
|
* @return 请求结果
|
||||||
*/
|
*/
|
||||||
@Path("/getElectronicSealCount")
|
@Path("/getContractAndSealCount")
|
||||||
@POST
|
@POST
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public String getElectronicSealCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
public String getElectronicSealCount(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||||
try{
|
try{
|
||||||
param.put("modelTables",modelTables);
|
param.put("contractTable",contractTable);
|
||||||
int count = reviewService.getElectronicSealCount(param);
|
param.put("sealTable",sealTable);
|
||||||
return ApiResult.success(count);
|
Map<String, Object> electronicSealCount = reviewService.getElectronicSealCount(param);
|
||||||
|
return ApiResult.success(electronicSealCount);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("获取电子章总数异常 ==> "+Util.getErrString(e));
|
log.error("获取电子章总数异常 ==> "+Util.getErrString(e));
|
||||||
return ApiResult.error(e.getMessage());
|
return ApiResult.error(e.getMessage());
|
||||||
|
@ -113,14 +117,17 @@ public class YearReviewController {
|
||||||
* @param param 请求参数
|
* @param param 请求参数
|
||||||
* @return 请求结果
|
* @return 请求结果
|
||||||
*/
|
*/
|
||||||
@Path("/getWorkflowTop5")
|
@Path("/getWorkflowTop")
|
||||||
@POST
|
@POST
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public String getWorkflowTop5(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
public String getWorkflowTop(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||||
try{
|
try{
|
||||||
log.info("into getWorkflowTop5 success params ==> "+param);
|
log.info("into getWorkflowTop success params ==> "+param);
|
||||||
User loginUser = HrmUserVarify.getUser(request, response);
|
User loginUser = HrmUserVarify.getUser(request, response);
|
||||||
param.put("workflowIds",workflowIds);
|
param.put("workflowIds",workflowIds);
|
||||||
|
if(!param.containsKey("limit")){
|
||||||
|
param.put("limit",3);
|
||||||
|
}
|
||||||
String type = Util.null2String(param.get("type"));
|
String type = Util.null2String(param.get("type"));
|
||||||
List<Map<String, Object>> data = "create".equals(type) ? reviewService.getCreateTop5(param, loginUser) : reviewService.getOperateTop5(param, loginUser);
|
List<Map<String, Object>> data = "create".equals(type) ? reviewService.getCreateTop5(param, loginUser) : reviewService.getOperateTop5(param, loginUser);
|
||||||
return ApiResult.success(data);
|
return ApiResult.success(data);
|
||||||
|
|
|
@ -112,7 +112,7 @@ public interface ReviewMapper {
|
||||||
" and workflowid not in (${param.workflowIds})" +
|
" and workflowid not in (${param.workflowIds})" +
|
||||||
"group by workflowid " +
|
"group by workflowid " +
|
||||||
"ORDER BY wcount desc" +
|
"ORDER BY wcount desc" +
|
||||||
"limit 5")
|
"limit ${param.limit}")
|
||||||
List<Map<String, Object>> queryCreateTop5(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
|
List<Map<String, Object>> queryCreateTop5(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +132,7 @@ public interface ReviewMapper {
|
||||||
" and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " +
|
" and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " +
|
||||||
"group by workflowid " +
|
"group by workflowid " +
|
||||||
"order by wcount desc " +
|
"order by wcount desc " +
|
||||||
"limit 5")
|
"limit ${param.limit}")
|
||||||
List<Map<String, Object>> queryOperateTop5(@ParamMapper("param") Map<String, Object> param,@ParamMapper("uid") int uid);
|
List<Map<String, Object>> queryOperateTop5(@ParamMapper("param") Map<String, Object> param,@ParamMapper("uid") int uid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,12 +171,13 @@ public interface ReviewMapper {
|
||||||
/**
|
/**
|
||||||
* <h2>通过条件查询数量</h2>
|
* <h2>通过条件查询数量</h2>
|
||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @param fieldName 字段名
|
* @param cusSql 自定义sql
|
||||||
* @param fieldValue 字段值
|
|
||||||
* @return 数量
|
* @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,
|
int queryCountByParam(@ParamMapper("tableName") String tableName,
|
||||||
@ParamMapper("fieldName") String fieldName,
|
@ParamMapper("cusSql") String cusSql);
|
||||||
@ParamMapper("fieldValue") String fieldValue);
|
|
||||||
|
@Select("select tablename workflow_bill where id = #{tableId}")
|
||||||
|
String queryTableName(@ParamMapper("tableId")String tableId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,5 +73,5 @@ public interface ReviewService {
|
||||||
* @param param 参数信息
|
* @param param 参数信息
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
int getElectronicSealCount(Map<String, Object> param);
|
Map<String,Object> getElectronicSealCount(Map<String, Object> param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.api.bokang.xiao.porsche_review.service.impl;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
|
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
|
||||||
import com.api.bokang.xiao.porsche_review.service.ReviewService;
|
import com.api.bokang.xiao.porsche_review.service.ReviewService;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -21,6 +22,8 @@ public class ReviewServiceImpl implements ReviewService {
|
||||||
|
|
||||||
private final ReviewMapper reviewMapper = Util.getMapper(ReviewMapper.class);
|
private final ReviewMapper reviewMapper = Util.getMapper(ReviewMapper.class);
|
||||||
|
|
||||||
|
private final Logger log = Util.getLogger();
|
||||||
|
|
||||||
private Integer resourceCount = 0;
|
private Integer resourceCount = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,19 +76,33 @@ public class ReviewServiceImpl implements ReviewService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getElectronicSealCount(Map<String, Object> param) {
|
public Map<String, Object> getElectronicSealCount(Map<String, Object> param) {
|
||||||
String modelTables = Util.null2String(param.get("modelTables"));
|
Map<String,Object> result = new HashMap<>(8);
|
||||||
int totalCount = 0;
|
String contractTableStr= Util.null2String(param.get("contractTable"));
|
||||||
Map<String, Map<String, Object>> modelTableMap = getModelTables(modelTables);
|
String sealTableStr = Util.null2String(param.get("sealTable"));
|
||||||
for (Map.Entry<String, Map<String, Object>> entry : modelTableMap.entrySet()) {
|
int contractCount = 0;
|
||||||
|
int sealCount = 0;
|
||||||
|
Map<String, String> contractTable = getModelTableSql(contractTableStr);
|
||||||
|
Map<String, String> sealTable = getModelTableSql(sealTableStr);
|
||||||
|
log.info("contractTable ==>"+contractTable);
|
||||||
|
log.info("sealTable ==>"+sealTable);
|
||||||
|
//计算合同总数
|
||||||
|
for (Map.Entry<String, String> entry : contractTable.entrySet()) {
|
||||||
String tableName = entry.getKey();
|
String tableName = entry.getKey();
|
||||||
Map<String, Object> fieldMap = entry.getValue();
|
int count = reviewMapper.queryCountByParam(tableName,entry.getValue());
|
||||||
String fieldName = Util.null2String(fieldMap.get("fieldName"));
|
contractCount += count;
|
||||||
String fieldValue = Util.null2String(fieldMap.get("fieldValue"));
|
|
||||||
int count = reviewMapper.queryCountByParam(tableName, fieldName, fieldValue);
|
|
||||||
totalCount += count;
|
|
||||||
}
|
}
|
||||||
return totalCount;
|
//计算电子章总数
|
||||||
|
for (Map.Entry<String, String> 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 原有表名字符串
|
* @param sourceStr 原有表名字符串
|
||||||
* @return 表名集合
|
* @return 表名集合
|
||||||
*/
|
*/
|
||||||
public Map<String,Map<String,Object>> getModelTables(String sourceStr){
|
public Map<String,String> getModelTableSql(String sourceStr){
|
||||||
Map<String,Map<String,Object>> modelTableMap = new HashMap<>();
|
Map<String,String> modelTableMap = new HashMap<>();
|
||||||
String regx = "\\{(?<tableName>\\S+):(?<fieldName>\\S+):(?<fieldValue>\\S+)}";
|
String regx = "\\{(?<tableName>\\S+):(?<cusSql>\\S+)}";
|
||||||
Pattern compile = Pattern.compile(regx);
|
Pattern compile = Pattern.compile(regx);
|
||||||
Matcher matcher = compile.matcher(sourceStr);
|
Matcher matcher = compile.matcher(sourceStr);
|
||||||
while (matcher.find()){
|
while (matcher.find()){
|
||||||
String tableName = matcher.group("tableName");
|
String tableName = matcher.group("tableName");
|
||||||
String fieldName = matcher.group("fieldName");
|
String cusSql = matcher.group("cusSql");
|
||||||
String fieldValue = matcher.group("fieldValue");
|
cusSql = cusSql.replaceAll("&"," and ").replaceAll("/|"," or ");
|
||||||
Map<String,Object> fieldMap = new HashMap<>();
|
modelTableMap.put(tableName,cusSql);
|
||||||
fieldMap.put("fieldName",fieldName);
|
|
||||||
fieldMap.put("fieldValue",fieldValue);
|
|
||||||
modelTableMap.put(tableName,fieldMap);
|
|
||||||
}
|
}
|
||||||
return modelTableMap;
|
return modelTableMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,19 @@ import aiyh.utils.ApiResult;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import com.api.bokang.xiao.wx_report.service.ReportService;
|
import com.api.bokang.xiao.wx_report.service.ReportService;
|
||||||
import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl;
|
import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl;
|
||||||
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import weaver.hrm.HrmUserVarify;
|
import weaver.hrm.HrmUserVarify;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName ReportController
|
* @ClassName ReportController
|
||||||
|
@ -37,14 +39,15 @@ public class ReportController {
|
||||||
* @return 请求结果
|
* @return 请求结果
|
||||||
*/
|
*/
|
||||||
@Path("/getReportData")
|
@Path("/getReportData")
|
||||||
@GET
|
@POST
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
|
||||||
try{
|
try{
|
||||||
log.info("====== into getCondition success =======");
|
log.info("====== into getReportData success =======");
|
||||||
|
log.info("param:"+param);
|
||||||
User loginUser = HrmUserVarify.getUser(request, response);
|
User loginUser = HrmUserVarify.getUser(request, response);
|
||||||
|
Map<String,Object> reportData = reportService.getReportData(loginUser, param);
|
||||||
return ApiResult.success("");
|
return ApiResult.success(reportData);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("获取搜索组件信息 ==> "+Util.getErrString(e));
|
log.error("获取搜索组件信息 ==> "+Util.getErrString(e));
|
||||||
return ApiResult.error(e.getMessage());
|
return ApiResult.error(e.getMessage());
|
||||||
|
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class KeyTypeEntity {
|
||||||
|
private String key;
|
||||||
|
private List<String> typeList;
|
||||||
|
}
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class NetConfigItem {
|
||||||
|
private String dataInConfig;
|
||||||
|
private String dataOutConfig;
|
||||||
|
}
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReportDataVO {
|
||||||
|
|
||||||
|
/** 经营性活动list */
|
||||||
|
private List<ReportEntityVO> businessActivityList;
|
||||||
|
|
||||||
|
/** 筹集资金list */
|
||||||
|
private List<ReportEntityVO> financingList;
|
||||||
|
|
||||||
|
/** 投资现金list */
|
||||||
|
private List<ReportEntityVO> investmentList;
|
||||||
|
|
||||||
|
/** 其他现金list */
|
||||||
|
private List<ReportEntityVO> 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;
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,13 @@
|
||||||
package com.api.bokang.xiao.wx_report.entity;
|
package com.api.bokang.xiao.wx_report.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName ReportEntity
|
* @ClassName ReportEntity
|
||||||
|
@ -10,6 +17,9 @@ import lombok.Data;
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class ReportEntityVO {
|
public class ReportEntityVO {
|
||||||
|
|
||||||
/** 款项类别 */
|
/** 款项类别 */
|
||||||
|
@ -24,6 +34,15 @@ public class ReportEntityVO {
|
||||||
/** 月份 */
|
/** 月份 */
|
||||||
private Integer year;
|
private Integer year;
|
||||||
|
|
||||||
|
/** 日 */
|
||||||
|
private Integer day;
|
||||||
|
|
||||||
/** 金额合计 */
|
/** 金额合计 */
|
||||||
private Double amount;
|
private Double amount;
|
||||||
|
|
||||||
|
public void setAmount(Double amount) {
|
||||||
|
DecimalFormat format = new DecimalFormat("#.00");
|
||||||
|
String str = format.format(amount);
|
||||||
|
this.amount = Double.parseDouble(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 " +
|
@Select("select kxlb category,rq date,sum(hsjey) amount,month(rq) month,year(rq) year,day(rq) day " +
|
||||||
"from uf_srmxb " +
|
"from uf_srmxb " +
|
||||||
"where kxlb is not null $t{queryStr}" +
|
"where kxlb is not null $t{queryStr} " +
|
||||||
"group by kxlb,rq " +
|
"group by kxlb,rq " +
|
||||||
"order by category ")
|
"order by category ")
|
||||||
List<ReportEntityVO> queryDataInList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
|
List<ReportEntityVO> queryDataInList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> 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 " +
|
@Select("select 90 category,sqrq date,sum(jkjey) amount,month(sqrq) month,year(sqrq) year,day(sqrq) day " +
|
||||||
"from uf_byjjksqtzbb " +
|
"from uf_byjjksqtzbb " +
|
||||||
"where 1=1 $t{queryStr} " +
|
"where 1=1 $t{queryStr} " +
|
||||||
"group by sqrq ")
|
"group by sqrq " +
|
||||||
|
"order by category ")
|
||||||
List<ReportEntityVO> queryPettyCashList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
|
List<ReportEntityVO> queryPettyCashList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> 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 " +
|
@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 " +
|
"from uf_dgfksqtzbb main " +
|
||||||
"inner join uf_dgfksqtzbb_dt1 dt on main.id = dt.mainid " +
|
"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 " +
|
"group by dt.kxlb,main.qwfkrq " +
|
||||||
"order by category ")
|
"order by category ")
|
||||||
List<ReportEntityVO> queryPublicPayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
|
List<ReportEntityVO> queryPublicPayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> 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 " +
|
@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 " +
|
"from uf_dsbxsqtzbb main " +
|
||||||
"inner join uf_dsbxsqtzbb_dt1 dt on main.id = dt.mainid " +
|
"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 " +
|
"group by dt.kxlb,main.sqrq " +
|
||||||
"order by category ")
|
"order by category ")
|
||||||
List<ReportEntityVO> queryPrivatePayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
|
List<ReportEntityVO> queryPrivatePayList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> 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 " +
|
@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 " +
|
"from uf_dsbxsqtzclbb main " +
|
||||||
"inner join uf_dsbxsqtzclbb_dt1 dt on main.id = dt.mainid " +
|
"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 " +
|
"group by dt.kxlb,main.sqrq " +
|
||||||
"order by category ")
|
"order by category ")
|
||||||
List<ReportEntityVO> queryBusinessList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
|
List<ReportEntityVO> queryBusinessList(@ParamMapper("queryStr") String queryStr,@ParamMapper("param") Map<String,Object> param);
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package com.api.bokang.xiao.wx_report.service;
|
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
|
* @ClassName ReportService
|
||||||
* @Author 肖博亢
|
* @Author 肖博亢
|
||||||
|
@ -7,4 +13,12 @@ package com.api.bokang.xiao.wx_report.service;
|
||||||
* @Description <h1></h1>
|
* @Description <h1></h1>
|
||||||
**/
|
**/
|
||||||
public interface ReportService {
|
public interface ReportService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取报表数据</h2>
|
||||||
|
* @param user 登录用户
|
||||||
|
* @param param 查询条件
|
||||||
|
* @return 报表数据信息
|
||||||
|
*/
|
||||||
|
Map<String, Object> getReportData(User user, Map<String,Object> param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class Entry<K,V> {
|
||||||
|
|
||||||
|
private K key;
|
||||||
|
private V value;
|
||||||
|
}
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface GroupFunction<K,V,T> {
|
||||||
|
|
||||||
|
|
||||||
|
Entry<K,V> group(List<T> list);
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,20 @@
|
||||||
package com.api.bokang.xiao.wx_report.service.impl;
|
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.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
|
* @ClassName ReportServiceImpl
|
||||||
|
@ -9,4 +23,366 @@ import com.api.bokang.xiao.wx_report.service.ReportService;
|
||||||
* @Description <h1></h1>
|
* @Description <h1></h1>
|
||||||
**/
|
**/
|
||||||
public class ReportServiceImpl implements ReportService {
|
public class ReportServiceImpl implements ReportService {
|
||||||
|
|
||||||
|
private final ReportMapper reportMapper = Util.getMapper(ReportMapper.class);
|
||||||
|
|
||||||
|
private static final List<KeyTypeEntity> TYPE_IN_LIST = new ArrayList<>();
|
||||||
|
private static final List<KeyTypeEntity> TYPE_OUT_LIST = new ArrayList<>();
|
||||||
|
|
||||||
|
private static final Map<String, NetConfigItem> 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<String, Object> getReportData(User user, Map<String, Object> param) {
|
||||||
|
Map<String,Object> result = new HashMap<>();
|
||||||
|
Map<String, String> sqlMap = this.buildSql(param);
|
||||||
|
List<ReportEntityVO> reportEntityList = new ArrayList<>();
|
||||||
|
List<ReportEntityVO> dataInList = reportMapper.queryDataInList(sqlMap.get("dataInSql"), param);
|
||||||
|
List<ReportEntityVO> pettyCashList = reportMapper.queryPettyCashList(sqlMap.get("pettyCashSql"), param);
|
||||||
|
List<ReportEntityVO> publicPayList = reportMapper.queryPublicPayList(sqlMap.get("publicPaySql"), param);
|
||||||
|
List<ReportEntityVO> privatePayList = reportMapper.queryPrivatePayList(sqlMap.get("privatePaySql"), param);
|
||||||
|
List<ReportEntityVO> businessList = reportMapper.queryBusinessList(sqlMap.get("businessSql"), param);
|
||||||
|
reportEntityList.addAll(pettyCashList);
|
||||||
|
reportEntityList.addAll(publicPayList);
|
||||||
|
reportEntityList.addAll(privatePayList);
|
||||||
|
reportEntityList.addAll(businessList);
|
||||||
|
//分组求和 统计同一款项类别的数据集合,并计算统一款项类别,同一天的数据总和
|
||||||
|
Map<String, List<ReportEntityVO>> dataOutMap = this.groupList(reportEntityList);
|
||||||
|
//分组 统计同一款项类别的数据集合
|
||||||
|
Map<String, List<ReportEntityVO>> dataInMap = dataInList.stream().collect(Collectors.groupingBy(ReportEntityVO::getCategory));
|
||||||
|
List<ReportEntityVO> dataInAllList = this.statisticsSum(dataInMap);
|
||||||
|
List<ReportEntityVO> dataOutAllList = this.statisticsSum(dataOutMap);
|
||||||
|
//分组统计总和
|
||||||
|
Map<String, List<ReportEntityVO>> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取净额数据</h2>
|
||||||
|
* @param totalMap 数据集合
|
||||||
|
* @return 净额数据
|
||||||
|
*/
|
||||||
|
public Map<String,List<ReportEntityVO>> getNetMap(Map<String, List<ReportEntityVO>> 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<ReportEntityVO> dataInReportList = totalMap.get(dataInConfig);
|
||||||
|
List<ReportEntityVO> dataOutReportList = totalMap.get(dataOutConfig);
|
||||||
|
Map<Integer,Double> 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());
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>保留两位小数</h2>
|
||||||
|
* @param amount 数量
|
||||||
|
* @return double
|
||||||
|
*/
|
||||||
|
public double getTwoDouble(double amount) {
|
||||||
|
DecimalFormat format = new DecimalFormat("#.00");
|
||||||
|
String str = format.format(amount);
|
||||||
|
return Double.parseDouble(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>获取总数map集合</h2>
|
||||||
|
* @param dataList 数据集合
|
||||||
|
* @param type 数据处理类型 1:收入 2:支出
|
||||||
|
* @return 分组求和后的数据集合
|
||||||
|
*/
|
||||||
|
public Map<String,List<ReportEntityVO>> getTotalMap(List<ReportEntityVO> dataList,int type){
|
||||||
|
List<KeyTypeEntity> typeList = type == 1 ? TYPE_IN_LIST : TYPE_OUT_LIST;
|
||||||
|
Map<String, List<ReportEntityVO>> totalMap = new HashMap<>();
|
||||||
|
List<ReportEntityVO> dataTotalList = new ArrayList<>();
|
||||||
|
Map<Integer, List<ReportEntityVO>> dayReportMap = dataList.stream().collect(Collectors.groupingBy(ReportEntityVO::getDay));
|
||||||
|
for (Map.Entry<Integer, List<ReportEntityVO>> dayReportEntry : dayReportMap.entrySet()) {
|
||||||
|
Integer day = dayReportEntry.getKey();
|
||||||
|
List<ReportEntityVO> 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<String, ReportEntityVO> reportEntityMap = this.sumParse(dayReportList,typeList);
|
||||||
|
for (Map.Entry<String, ReportEntityVO> entry : reportEntityMap.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
ReportEntityVO value = entry.getValue();
|
||||||
|
if(totalMap.containsKey(key)){
|
||||||
|
totalMap.get(key).add(value);
|
||||||
|
}else {
|
||||||
|
List<ReportEntityVO> totalReportList = new ArrayList<>();
|
||||||
|
totalReportList.add(value);
|
||||||
|
totalMap.put(key,totalReportList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String totalKey = type == 1 ? "inTotal" : "outTotal";
|
||||||
|
totalMap.put(totalKey,dataTotalList);
|
||||||
|
return totalMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>根据配置条件分组求和</h2>
|
||||||
|
* @param reportEntityList 原数据集合
|
||||||
|
* @param typeList 分组条件集合
|
||||||
|
* @return 求和后的实体类
|
||||||
|
*/
|
||||||
|
private Map<String,ReportEntityVO> sumParse(List<ReportEntityVO> reportEntityList,List<KeyTypeEntity> typeList){
|
||||||
|
List<GroupFunction<String,List<ReportEntityVO>,ReportEntityVO>> groupFun = new ArrayList<>();
|
||||||
|
|
||||||
|
for (KeyTypeEntity keyTypeEntity : typeList) {
|
||||||
|
groupFun.add(list->parseGroup(reportEntityList,keyTypeEntity.getKey(),
|
||||||
|
item-> keyTypeEntity.getTypeList()
|
||||||
|
.contains(item),ReportEntityVO::getCategory));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, ReportEntityVO> result = new HashMap<>(16);
|
||||||
|
for (GroupFunction<String, List<ReportEntityVO>, ReportEntityVO> fun : groupFun) {
|
||||||
|
Entry<String, List<ReportEntityVO>> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>具体分组方法</h2>
|
||||||
|
* @param list 原数据集合
|
||||||
|
* @param k 泛型
|
||||||
|
* @param compare 比较方法
|
||||||
|
* @param compareValue 获取对象比较值
|
||||||
|
* @return 分组后对象
|
||||||
|
* @param <K> 键泛型
|
||||||
|
* @param <T> 分组list泛型
|
||||||
|
* @param <R> 分组值泛型
|
||||||
|
*/
|
||||||
|
private <K,T,R> Entry<K,List<T>> parseGroup(List<T> list, K k,
|
||||||
|
Predicate<R> compare,
|
||||||
|
Function<T,R> compareValue){
|
||||||
|
Entry<K,List<T>> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>将list分组求和</h2>
|
||||||
|
* @param reportEntityList 原数组
|
||||||
|
* @return 分组后的map集合
|
||||||
|
*/
|
||||||
|
public Map<String, List<ReportEntityVO>> groupList(List<ReportEntityVO> 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<ReportEntityVO> 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())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>计算每一种款项类别的总和</h2>
|
||||||
|
* @param dataMap 数据信息
|
||||||
|
* @return list集合
|
||||||
|
*/
|
||||||
|
public List<ReportEntityVO> statisticsSum(Map<String, List<ReportEntityVO>> dataMap){
|
||||||
|
List<ReportEntityVO> allReportList = new ArrayList<>();
|
||||||
|
//计算每一行的总和并将结果加到list中
|
||||||
|
for (Map.Entry<String, List<ReportEntityVO>> entry : dataMap.entrySet()) {
|
||||||
|
String category = entry.getKey();
|
||||||
|
List<ReportEntityVO> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h2>构建查询sql</h2>
|
||||||
|
* @param param 条件
|
||||||
|
* @return 查询sql的集合
|
||||||
|
*/
|
||||||
|
public Map<String,String> buildSql(Map<String, Object> param){
|
||||||
|
Map<String,String> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,43 @@
|
||||||
package bokang.xiao;
|
package bokang.xiao;
|
||||||
|
|
||||||
import aiyh.utils.GenerateFileUtil;
|
import aiyh.utils.GenerateFileUtil;
|
||||||
|
import aiyh.utils.ThreadPoolConfig;
|
||||||
import aiyh.utils.Util;
|
import aiyh.utils.Util;
|
||||||
import aiyh.utils.httpUtil.ResponeVo;
|
import aiyh.utils.httpUtil.ResponeVo;
|
||||||
import aiyh.utils.httpUtil.util.HttpUtils;
|
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
|
import bokang.xiao.entity.CourseEntity;
|
||||||
|
import bokang.xiao.entity.StudentEntity;
|
||||||
|
import bokang.xiao.entity.TeacherEntity;
|
||||||
import bokang.xiao.mapper.TestMapper;
|
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.mapper.ReviewMapper;
|
||||||
import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl;
|
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.entity.ReportEntityVO;
|
||||||
import com.api.bokang.xiao.wx_report.mapper.ReportMapper;
|
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.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.poi.POIXMLDocument;
|
import org.apache.poi.POIXMLDocument;
|
||||||
import org.apache.poi.hwpf.HWPFDocument;
|
import org.apache.poi.hwpf.HWPFDocument;
|
||||||
import org.apache.poi.hwpf.usermodel.Range;
|
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.XWPFDocument;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import weaver.bokang.xiao.dz_invoice.action.InvoiceDeductionAction;
|
import weaver.bokang.xiao.dz_invoice.action.InvoiceDeductionAction;
|
||||||
import weaver.bokang.xiao.dz_invoice.schedule.InvoiceQuerySchedule;
|
import weaver.bokang.xiao.dz_invoice.schedule.InvoiceQuerySchedule;
|
||||||
|
import weaver.hrm.User;
|
||||||
import weaver.xiao.commons.config.entity.ResponseMapping;
|
import weaver.xiao.commons.config.entity.ResponseMapping;
|
||||||
import weaver.xiao.commons.utils.DocImageFileUtil;
|
import weaver.xiao.commons.utils.DocImageFileUtil;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,22 +79,10 @@ public class NormalTest extends BaseTest {
|
||||||
Map<String,Object> queryParam = new HashMap<>();
|
Map<String,Object> queryParam = new HashMap<>();
|
||||||
queryParam.put("month","12");
|
queryParam.put("month","12");
|
||||||
queryParam.put("year","2022");
|
queryParam.put("year","2022");
|
||||||
StringBuilder PettyCashBuilder = new StringBuilder();
|
//queryParam.put("date","2022-12-01");
|
||||||
StringBuilder PublicPayBuilder = new StringBuilder();
|
ReportService reportService = new ReportServiceImpl();
|
||||||
StringBuilder PrivatePayBuilder = new StringBuilder();
|
Map<String, Object> reportData = reportService.getReportData(new User(1), queryParam);
|
||||||
StringBuilder BusinessBuilder = new StringBuilder();
|
System.out.println(reportData);
|
||||||
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<ReportEntityVO> reportEntityVOS = mapper.queryReportList(whereBuilder.toString(),queryParam);
|
|
||||||
Map<String, List<ReportEntityVO>> groupMap = reportEntityVOS.stream().collect(Collectors.groupingBy(ReportEntityVO::getCategory));
|
|
||||||
System.out.println(groupMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -129,6 +128,45 @@ public class NormalTest extends BaseTest {
|
||||||
Map responseEntity = responeVo1.getResponseEntity(Map.class);
|
Map responseEntity = responeVo1.getResponseEntity(Map.class);
|
||||||
System.out.println(responseEntity);
|
System.out.println(responseEntity);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExportExcel() throws Exception {
|
||||||
|
|
||||||
|
List<CourseEntity> 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<StudentEntity> 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();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@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<StudentEntity> students;
|
||||||
|
|
||||||
|
@ExcelCollection(name = "kkl", orderNum = "4")
|
||||||
|
private List<String> StingList;
|
||||||
|
|
||||||
|
}
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
}
|
|
@ -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 <h1></h1>
|
||||||
|
**/
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
Loading…
Reference in New Issue