Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
cf097c9f
Commit
cf097c9f
authored
Sep 28, 2025
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企微智能表格应用-fxj
parent
424c60b0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
240 additions
and
34 deletions
+240
-34
MonthCalculationUtils.java
.../plus/v1/yifu/common/core/util/MonthCalculationUtils.java
+86
-0
QwExcelApiController.java
...fu/cloud/plus/v1/ekp/controller/QwExcelApiController.java
+2
-2
QwExcelApiMapper.java
...a/com/yifu/cloud/plus/v1/ekp/mapper/QwExcelApiMapper.java
+19
-0
QwExcelApiService.java
...com/yifu/cloud/plus/v1/ekp/service/QwExcelApiService.java
+1
-19
QwExcelApiServiceImpl.java
...lus/v1/ekp/service/impl/QwExce/QwExcelApiServiceImpl.java
+44
-13
EkpQwExcelApiMapper.xml
...ekp-biz/src/main/resources/mapper/EkpQwExcelApiMapper.xml
+88
-0
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/MonthCalculationUtils.java
0 → 100644
View file @
cf097c9f
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
/**
* 月份计算工具类
* 提供根据当前时间向前推N个月的开始时间和结束时间计算功能
*
* @author fxj
*/
public
class
MonthCalculationUtils
{
/**
* 私有构造函数,防止实例化
*/
private
MonthCalculationUtils
()
{
throw
new
IllegalStateException
(
"MonthCalculationUtils class"
);
}
/**
* 根据给定的月份数,计算从当前时间往前推n个月的开始时间和结束时间
*
* @param months 往前推的月份数
* @return 包含开始时间和结束时间的字符串数组,索引0为开始时间,索引1为结束时间
*/
public
static
String
[]
calculateMonthRange
(
int
months
)
{
// 获取当前时间
LocalDateTime
now
=
LocalDateTime
.
now
();
// 计算目标月份的第一天 00:00:00
LocalDateTime
start
=
now
.
minusMonths
(
months
)
.
withDayOfMonth
(
1
)
.
withHour
(
0
)
.
withMinute
(
0
)
.
withSecond
(
0
)
.
withNano
(
0
);
// 计算目标月份的最后一天 23:59:59
LocalDateTime
end
=
start
.
withDayOfMonth
(
start
.
toLocalDate
().
lengthOfMonth
())
.
withHour
(
23
)
.
withMinute
(
59
)
.
withSecond
(
59
)
.
withNano
(
0
);
// 格式化时间
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
return
new
String
[]{
start
.
format
(
formatter
),
end
.
format
(
formatter
)
};
}
/**
* 根据给定的基准时间和月份数,计算从基准时间往前推n个月的开始时间和结束时间
*
* @param baseTime 基准时间
* @param months 往前推的月份数
* @return 包含开始时间和结束时间的字符串数组,索引0为开始时间,索引1为结束时间
*/
public
static
String
[]
calculateMonthRangeFromBase
(
LocalDateTime
baseTime
,
int
months
)
{
// 计算目标月份的第一天 00:00:00
LocalDateTime
start
=
baseTime
.
minusMonths
(
months
)
.
withDayOfMonth
(
1
)
.
withHour
(
0
)
.
withMinute
(
0
)
.
withSecond
(
0
)
.
withNano
(
0
);
// 计算目标月份的最后一天 23:59:59
LocalDateTime
end
=
start
.
withDayOfMonth
(
start
.
toLocalDate
().
lengthOfMonth
())
.
withHour
(
23
)
.
withMinute
(
59
)
.
withSecond
(
59
)
.
withNano
(
0
);
// 格式化时间
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
return
new
String
[]{
start
.
format
(
formatter
),
end
.
format
(
formatter
)
};
}
}
\ No newline at end of file
yifu-ekp/yifu-ekp-biz/src/main/java/com/yifu/cloud/plus/v1/ekp/controller/QwExcelApiController.java
View file @
cf097c9f
...
@@ -32,9 +32,9 @@ public class QwExcelApiController {
...
@@ -32,9 +32,9 @@ public class QwExcelApiController {
* @Param
* @Param
* @return
* @return
**/
**/
@PostMapping
(
"/
tesxW
xExcelApi"
)
@PostMapping
(
"/
w
xExcelApi"
)
public
void
tesxWxExcelApi
()
{
public
void
tesxWxExcelApi
()
{
qwExcelApiService
.
tesxW
xExcelApi
();
qwExcelApiService
.
w
xExcelApi
();
}
}
...
...
yifu-ekp/yifu-ekp-biz/src/main/java/com/yifu/cloud/plus/v1/ekp/mapper/QwExcelApiMapper.java
View file @
cf097c9f
...
@@ -63,4 +63,23 @@ public interface QwExcelApiMapper extends BaseMapper<EkpInvoiceInfo> {
...
@@ -63,4 +63,23 @@ public interface QwExcelApiMapper extends BaseMapper<EkpInvoiceInfo> {
"FROM view_contract_info"
)
"FROM view_contract_info"
)
List
<
Map
<
String
,
Object
>>
selectContractInfoAsMap
();
List
<
Map
<
String
,
Object
>>
selectContractInfoAsMap
();
/**
* 带参数的查询
* @param startDate 查询区间开始时间
* @param endDate 查询区间结束时间
* @return List<Map<String, Object>>
*/
List
<
Map
<
String
,
Object
>>
selectInvoiceList
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
/**
* 查询合同信息列表
* @return List<Map<String, Object>>
*/
List
<
Map
<
String
,
Object
>>
selectContractList
(
@Param
(
"limitStart"
)
int
limitStart
,
@Param
(
"limitEnd"
)
int
limitEnd
);
/**
* 查询合同信息列表
* @return List<Map<String, Object>>
*/
int
selectContractListCount
();
}
}
yifu-ekp/yifu-ekp-biz/src/main/java/com/yifu/cloud/plus/v1/ekp/service/QwExcelApiService.java
View file @
cf097c9f
...
@@ -14,23 +14,5 @@ import java.util.Map;
...
@@ -14,23 +14,5 @@ import java.util.Map;
*/
*/
public
interface
QwExcelApiService
extends
IService
<
EkpInvoiceInfo
>
{
public
interface
QwExcelApiService
extends
IService
<
EkpInvoiceInfo
>
{
void
tesxWxExcelApi
();
void
wxExcelApi
();
/**
* @Author fxj
* @Description 获取所有发票池信息
* @Date 16:09 2025/9/26
* @Param
* @return
**/
public
List
<
Map
<
String
,
Object
>>
getInvoiceList
();
/**
* @Author fxj
* @Description 获取所有合同数据
* @Date 16:09 2025/9/26
* @Param
* @return
**/
public
List
<
Map
<
String
,
Object
>>
getContractList
();
}
}
yifu-ekp/yifu-ekp-biz/src/main/java/com/yifu/cloud/plus/v1/ekp/service/impl/QwExce/QwExcelApiServiceImpl.java
View file @
cf097c9f
...
@@ -8,10 +8,13 @@ import com.yifu.cloud.plus.v1.ekp.mapper.EkpBankAttaMapper;
...
@@ -8,10 +8,13 @@ import com.yifu.cloud.plus.v1.ekp.mapper.EkpBankAttaMapper;
import
com.yifu.cloud.plus.v1.ekp.mapper.QwExcelApiMapper
;
import
com.yifu.cloud.plus.v1.ekp.mapper.QwExcelApiMapper
;
import
com.yifu.cloud.plus.v1.ekp.service.QwExcelApiService
;
import
com.yifu.cloud.plus.v1.ekp.service.QwExcelApiService
;
import
com.yifu.cloud.plus.v1.ekp.util.SmartSheetDebugService
;
import
com.yifu.cloud.plus.v1.ekp.util.SmartSheetDebugService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MonthCalculationUtils
;
import
lombok.extern.log4j.Log4j2
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -29,18 +32,46 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo
...
@@ -29,18 +32,46 @@ public class QwExcelApiServiceImpl extends ServiceImpl<QwExcelApiMapper, EkpInvo
@Autowired
@Autowired
private
WxConfig
wxConfig
;
private
WxConfig
wxConfig
;
@Override
@Override
public
void
tesxWxExcelApi
()
{
public
void
wxExcelApi
()
{
List
<
Map
<
String
,
Object
>>
records
=
baseMapper
.
selectInvoiceInfoAsMap
();
int
batchSize
=
1000
;
debugService
.
debugInsertIssue
(
wxConfig
,
records
);
int
batchCount
=
0
;
}
log
.
info
(
"微信智能表格发票数据插入开始..."
);
//获取最近24个月的发票信息,按月去插入到智能表格中
@Override
String
[]
monthRange
=
null
;
public
List
<
Map
<
String
,
Object
>>
getInvoiceList
()
{
List
<
Map
<
String
,
Object
>>
records
=
new
ArrayList
<>();
return
baseMapper
.
selectInvoiceInfoAsMap
();
List
<
Map
<
String
,
Object
>>
tempRecords
=
null
;
}
for
(
int
i
=
0
;
i
<
24
;
i
++){
monthRange
=
MonthCalculationUtils
.
calculateMonthRange
(
i
);
@Override
if
(
null
!=
monthRange
&&
monthRange
.
length
==
CommonConstants
.
dingleDigitIntArray
[
2
]){
public
List
<
Map
<
String
,
Object
>>
getContractList
()
{
tempRecords
=
baseMapper
.
selectInvoiceList
(
monthRange
[
0
],
monthRange
[
1
]);
return
baseMapper
.
selectContractInfoAsMap
();
}
if
(
tempRecords
!=
null
)
{
records
.
addAll
(
tempRecords
);
}
//分批插入
if
(
null
!=
records
&&
!
records
.
isEmpty
()){
batchCount
=
records
.
size
()
/
batchSize
;
for
(
int
j
=
0
;
j
<
batchCount
;
j
++)
{
tempRecords
=
records
.
subList
(
j
*
batchSize
,
(
j
+
1
)
*
batchSize
);
debugService
.
debugInsertIssue
(
wxConfig
,
tempRecords
);
}
}
}
log
.
info
(
"微信智能表格发票数据插入完成"
);
log
.
info
(
"微信智能表格合同数据插入开始..."
);
//开始处理合同信息,先获取合同数,然后分批次插入数据,每批次1000条
int
contractCount
=
baseMapper
.
selectContractListCount
();
batchCount
=
contractCount
/
batchSize
;
if
(
contractCount
%
batchSize
!=
0
)
{
batchCount
++;
batchSize
=
contractCount
/
batchCount
;
for
(
int
i
=
0
;
i
<
batchCount
;
i
++)
{
tempRecords
=
baseMapper
.
selectContractList
(
i
*
batchSize
,
(
i
+
1
)
*
batchSize
);
if
(
tempRecords
!=
null
)
{
debugService
.
debugInsertIssue
(
wxConfig
,
tempRecords
);
}
}
}
log
.
info
(
"微信智能表格合同数据插入完成"
);
}
}
}
}
yifu-ekp/yifu-ekp-biz/src/main/resources/mapper/EkpQwExcelApiMapper.xml
0 → 100644
View file @
cf097c9f
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.yifu.cloud.plus.v1.ekp.mapper.QwExcelApiMapper"
>
<select
id=
"selectInvoiceList"
resultType=
"java.util.Map"
>
SELECT
a.fd_3afa7c19036b66 AS "发票号",
a.fd_3b05ae02ff41ae AS "合同号",
a.fd_3b05ade863b120 AS "开票金额",
date_format(a.fd_3afa7c1b153ff8, '%Y-%m-%d') AS "开票时间",
date_format(a.fd_3afa7c1b153ff8, '%Y-%m') AS "开票月份",
a.fd_3afac373e38ec4 AS "购买名称",
a.fd_3b0f037ecc0ed0 AS "发票状态",
a.fd_3b1bb0ccc14760 AS "红冲状态",
concat(
a.fd_3afa7c19036b66,
'
&
',
ifnull(a.fd_3afac373e38ec4, ''),
'
&
',
ifnull(date_format(a.fd_3afa7c1b153ff8, '%Y-%m'), '')
) AS "发票号
&
购买方名称
&
开票月份组合"
FROM ekp_bacdf3a32d242279ceb6 a
LEFT JOIN modeling_simple_main b ON a.fd_id = b.fd_id
<where>
<!-- 基础时间条件
b.doc_create_time > (curdate() - INTERVAL 15 MONTH)
AND b.doc_create_time < (curdate() - INTERVAL 12 MONTH)
-->
<!-- 动态条件 -->
1 = 1
<if
test=
"startDate != null"
>
AND b.doc_create_time
<![CDATA[ >= ]]>
#{startDate}
</if>
<if
test=
"endDate != null"
>
AND b.doc_create_time
<![CDATA[ <= ]]>
#{endDate}
</if>
</where>
ORDER BY a.fd_3afa7c1b153ff8 DESC
</select>
<!-- 基础查询:返回合同信息列表 -->
<select
id=
"selectContractList"
resultType=
"java.util.Map"
>
SELECT
a.fd_3ade33763baa0e AS "合同号",
a.fd_3ade334bac0016 AS "合同名称",
a.fd_3ade3353d31f6c AS "客户名称",
a.fd_3aeae8ad0c9e62_text AS "客户编码",
a.fd_division AS "事业部",
a.fd_new_line AS "事业部条线",
b.fd_name AS "业务收入归属部门",
a.fd_3b107c2e2546a6 AS "合同状态"
FROM
ekp_0103c453b2848c3bb31c a
LEFT JOIN sys_org_element b ON a.fd_3b1141597b4894 = b.fd_id
<where>
<if
test=
"limitStart != null and limitEnd != null"
>
limit #{limitStart},#{limitEnd}
</if>
</where>
ORDER BY a.fd_3ade33763baa0e DESC
</select>
<select
id=
"selectContractListCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
FROM
ekp_0103c453b2848c3bb31c a
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment