Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
rec-fj
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
史连宁
rec-fj
Commits
998ef1d6
提交
998ef1d6
authored
11月 14, 2024
作者:
史连宁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
da66be47
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
319 行增加
和
29 行删除
+319
-29
pom.xml
pom.xml
+4
-0
RecController.java
...va/com/reconciliation/recfj/Controller/RecController.java
+30
-0
RecExcel.java
src/main/java/com/reconciliation/recfj/entity/RecExcel.java
+2
-4
ReturnValue.java
...ain/java/com/reconciliation/recfj/entity/ReturnValue.java
+33
-0
RecItem.java
src/main/java/com/reconciliation/recfj/enums/RecItem.java
+21
-6
RecTable.java
src/main/java/com/reconciliation/recfj/enums/RecTable.java
+63
-0
RecMapper.java
src/main/java/com/reconciliation/recfj/mapper/RecMapper.java
+45
-0
RecService.java
...ain/java/com/reconciliation/recfj/service/RecService.java
+46
-0
RecTask.java
src/main/java/com/reconciliation/recfj/task/RecTask.java
+33
-0
application-dev.yml
src/main/resources/application-dev.yml
+20
-0
application-prod.yml
src/main/resources/application-prod.yml
+20
-0
application.yml
src/main/resources/application.yml
+2
-19
没有找到文件。
pom.xml
浏览文件 @
998ef1d6
...
...
@@ -82,6 +82,10 @@
<artifactId>
jackson-databind
</artifactId>
<version>
2.12.6
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/reconciliation/recfj/Controller/RecController.java
0 → 100644
浏览文件 @
998ef1d6
package
com
.
reconciliation
.
recfj
.
Controller
;
import
com.reconciliation.recfj.entity.RecExcel
;
import
com.reconciliation.recfj.entity.ReturnValue
;
import
com.reconciliation.recfj.service.RecService
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
/**
* @author 史连宁
*/
@Controller
@RequestMapping
(
"rec"
)
public
class
RecController
{
@Resource
private
RecService
recService
;
@RequestMapping
(
"/create_rec_data_to_excel"
)
@ResponseBody
public
ReturnValue
createRecDataToExcel
(
RecExcel
rec
)
{
if
(
rec
==
null
)
{
rec
=
new
RecExcel
();
}
return
recService
.
createRecDataToExcel
(
rec
);
}
}
src/main/java/com/reconciliation/recfj/entity/RecExcel.java
浏览文件 @
998ef1d6
...
...
@@ -2,10 +2,7 @@ package com.reconciliation.recfj.entity;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.*
;
import
java.util.Date
;
...
...
@@ -14,6 +11,7 @@ import java.util.Date;
* @author 史连宁
*/
@Data
@Builder
@EqualsAndHashCode
()
@AllArgsConstructor
()
@NoArgsConstructor
()
...
...
src/main/java/com/reconciliation/recfj/entity/ReturnValue.java
0 → 100644
浏览文件 @
998ef1d6
package
com
.
reconciliation
.
recfj
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* 返回值
* @author 史连宁
*/
@Data
@Builder
@AllArgsConstructor
()
@NoArgsConstructor
()
public
class
ReturnValue
{
private
boolean
success
;
private
String
msg
;
private
Object
data
;
public
static
ReturnValue
ok
()
{
return
ReturnValue
.
builder
().
success
(
true
).
build
();
}
public
static
ReturnValue
ok
(
String
msg
)
{
return
ReturnValue
.
builder
().
success
(
true
).
msg
(
msg
).
build
();
}
public
static
ReturnValue
fail
()
{
return
ReturnValue
.
builder
().
success
(
false
).
build
();
}
public
static
ReturnValue
fail
(
String
msg
)
{
return
ReturnValue
.
builder
().
success
(
false
).
msg
(
msg
).
build
();
}
}
src/main/java/com/reconciliation/recfj/enums/RecItem.java
浏览文件 @
998ef1d6
...
...
@@ -5,23 +5,25 @@ package com.reconciliation.recfj.enums;
* @author 史连宁
*/
public
enum
RecItem
{
IDX1
(
"IDX1"
,
"IDX1数据总量"
),
IDX2
(
"IDX2"
,
"IDX2创建时间月统计值"
),
IDX3
(
"IDX3"
,
"IDX3创建时间日统计值(近30天)"
),
IDX4
(
"IDX4"
,
"IDX4更新时间月统计值"
),
IDX5
(
"IDX5"
,
"IDX5更新时间日统计值(近30天)"
);
IDX1
(
"IDX1"
,
"IDX1数据总量"
,
"getRecAll"
),
IDX2
(
"IDX2"
,
"IDX2创建时间月统计值"
,
"getRecMon"
),
IDX3
(
"IDX3"
,
"IDX3创建时间日统计值(近30天)"
,
"getRecDay"
),
IDX4
(
"IDX4"
,
"IDX4更新时间月统计值"
,
"getRecMon"
),
IDX5
(
"IDX5"
,
"IDX5更新时间日统计值(近30天)"
,
"getRecDay"
);
private
final
String
id
;
private
final
String
name
;
private
final
String
func
;
/**
* 对账指标枚举类
* @param id 编码
* @param name 名称
*/
RecItem
(
String
id
,
String
name
)
{
RecItem
(
String
id
,
String
name
,
String
func
)
{
this
.
id
=
id
;
this
.
name
=
name
;
this
.
func
=
func
;
}
public
String
getId
()
{
...
...
@@ -31,4 +33,17 @@ public enum RecItem {
public
String
getName
()
{
return
name
;
}
public
String
getFunc
()
{
return
func
;
}
public
static
RecItem
parse
(
String
str
)
throws
EnumConstantNotPresentException
{
for
(
RecItem
rec
:
RecItem
.
values
())
{
if
(
rec
.
id
.
equals
(
str
))
{
return
rec
;
}
}
throw
new
EnumConstantNotPresentException
(
RecItem
.
class
,
str
);
}
}
src/main/java/com/reconciliation/recfj/enums/RecTable.java
0 → 100644
浏览文件 @
998ef1d6
package
com
.
reconciliation
.
recfj
.
enums
;
/**
* 对账表枚举类
* @author 史连宁
*/
public
enum
RecTable
{
SD_MS_DFS
(
"table34904"
,
"SD_MS_DFS"
,
"稻飞虱模式报表"
,
"1"
),
SD_MS_ZJYM
(
"table34903"
,
"SD_MS_ZJYM"
,
"纵卷叶螟模式报表"
,
"1"
),
SD_MS_MCDCYC
(
"table34905"
,
"SD_MS_MCDCYC"
,
"螟虫各代调查及下代预测模式报表"
,
"1"
),
SD_MS_YHPKQSW
(
"table34909"
,
"SD_MS_YHPKQSW"
,
"孕穗-破口期稻瘟病发生情况和穗瘟发生预测模式报表"
,
"1"
),
SD_MS_WKB
(
"table34902"
,
"SD_MS_WKB"
,
"水稻纹枯病模式报表"
,
"1"
),
FJ_DSZBB_SDBCZBB3
(
"table34906"
,
"FJ_DSZBB_SDBCZBB3"
,
"中稻及一季晚稻主要病虫周报表一"
,
"2"
),
FJ_DSZBB_SDBCZBB4
(
"table34907"
,
"FJ_DSZBB_SDBCZBB4"
,
"中稻及一季晚稻主要病虫周报表二"
,
"2"
),
FJ_DSZBB_SDBCZBB5
(
"table34901"
,
"FJ_DSZBB_SDBCZBB5"
,
"双季晚稻主要病虫周报表一"
,
"2"
),
FJ_DSZBB_SDBCZBB6
(
"table34911"
,
"FJ_DSZBB_SDBCZBB6"
,
"双季晚稻主要病虫周报表二"
,
"2"
),
FJ_DSZBB_SDBCZBBY
(
"table34908"
,
"FJ_DSZBB_SDBCZBBY"
,
"双季早稻主要病虫周报表一"
,
"2"
),
FJ_DSZBB_SDBCZBBE
(
"table34910"
,
"FJ_DSZBB_SDBCZBBE"
,
"双季早稻主要病虫周报表二"
,
"2"
);
private
final
String
hjTable
;
private
final
String
sysTable
;
private
final
String
tableName
;
private
final
String
sqlType
;
/**
* 对账表枚举类
* @param hjTable 汇聚平台表名
* @param sysTable 系统表名
* @param tableName 表中文名
* @param sqlType sql处理类型
*/
RecTable
(
String
hjTable
,
String
sysTable
,
String
tableName
,
String
sqlType
)
{
this
.
hjTable
=
hjTable
;
this
.
tableName
=
tableName
;
this
.
sqlType
=
sqlType
;
this
.
sysTable
=
sysTable
;
}
public
String
getHjTable
()
{
return
hjTable
;
}
public
String
getSysTable
()
{
return
sysTable
;
}
public
String
getTableName
()
{
return
tableName
;
}
public
String
getSqlType
()
{
return
sqlType
;
}
public
static
RecTable
parse
(
String
str
)
throws
EnumConstantNotPresentException
{
for
(
RecTable
rec
:
RecTable
.
values
())
{
if
(
rec
.
hjTable
.
equals
(
str
)
||
rec
.
sysTable
.
equals
(
str
))
{
return
rec
;
}
}
throw
new
EnumConstantNotPresentException
(
RecTable
.
class
,
str
);
}
}
src/main/java/com/reconciliation/recfj/mapper/RecMapper.java
0 → 100644
浏览文件 @
998ef1d6
package
com
.
reconciliation
.
recfj
.
mapper
;
import
com.reconciliation.recfj.entity.RecExcel
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
* 对账mapper
* @author 史连宁
*/
@Mapper
public
interface
RecMapper
{
@Select
(
"<script>"
+
" select count(*) value, max(tbrq) latestUpdateDate from ${table} t "
+
"</script"
)
List
<
RecExcel
>
getRecAll1
(
String
table
);
@Select
(
"<script>"
+
" select count(*) value, max(t.tbrq) latestUpdateDate from ${table} t, ${table}_D d where t.recordid=d.recordid"
+
"</script"
)
List
<
RecExcel
>
getRecAll2
(
String
table
);
@Select
(
"<script>"
+
" "
+
"</script"
)
List
<
RecExcel
>
getRecMon1
(
String
table
);
@Select
(
"<script>"
+
" "
+
"</script"
)
List
<
RecExcel
>
getRecMon2
(
String
table
);
@Select
(
"<script>"
+
" "
+
"</script"
)
List
<
RecExcel
>
getRecDay1
(
String
table
);
@Select
(
"<script>"
+
" "
+
"</script"
)
List
<
RecExcel
>
getRecDay2
(
String
table
);
}
src/main/java/com/reconciliation/recfj/service/RecService.java
浏览文件 @
998ef1d6
package
com
.
reconciliation
.
recfj
.
service
;
import
com.reconciliation.recfj.entity.RecExcel
;
import
com.reconciliation.recfj.entity.ReturnValue
;
import
com.reconciliation.recfj.enums.RecItem
;
import
com.reconciliation.recfj.enums.RecTable
;
import
com.reconciliation.recfj.mapper.RecMapper
;
import
io.micrometer.common.util.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
* 对账实现类
* @author 史连宁
*/
@Service
public
class
RecService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Resource
private
RecMapper
recMapper
;
public
ReturnValue
createRecDataToExcel
(
RecExcel
rec
)
{
ReturnValue
rtv
=
ReturnValue
.
fail
();
try
{
RecTable
[]
recTableList
=
RecTable
.
values
();
RecItem
[]
recItemList
=
RecItem
.
values
();
if
(
rec
!=
null
&&
StringUtils
.
isNotBlank
(
rec
.
getThirdTable
()))
{
recTableList
=
new
RecTable
[]{
RecTable
.
parse
(
rec
.
getThirdTable
())};
}
if
(
rec
!=
null
&&
StringUtils
.
isNotBlank
(
rec
.
getRecItem
()))
{
recItemList
=
new
RecItem
[]{
RecItem
.
parse
(
rec
.
getRecItem
())};
}
List
<
RecExcel
>
list
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
for
(
RecTable
recTable
:
recTableList
)
{
for
(
RecItem
recItem
:
recItemList
)
{
Date
now
=
new
Date
();
}
}
rtv
.
setSuccess
(
true
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"汇聚平台对账数据生成失败"
,
e
);
rtv
.
setMsg
(
e
.
getMessage
());
}
return
rtv
;
}
}
src/main/java/com/reconciliation/recfj/task/RecTask.java
浏览文件 @
998ef1d6
package
com
.
reconciliation
.
recfj
.
task
;
import
com.reconciliation.recfj.entity.RecExcel
;
import
com.reconciliation.recfj.entity.ReturnValue
;
import
com.reconciliation.recfj.service.RecService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* 对账定时任务
* @author 史连宁
...
...
@@ -10,4 +20,27 @@ import org.springframework.stereotype.Component;
@EnableScheduling
@Component
(
"RecTask"
)
public
class
RecTask
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Resource
private
RecService
recService
;
@Scheduled
(
cron
=
"${task.rec.default}"
)
public
void
createRecDataToExcel
()
{
ReturnValue
rtv
=
recService
.
createRecDataToExcel
(
new
RecExcel
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
if
(
rtv
.
isSuccess
())
{
logger
.
info
(
"[{}]汇聚平台对账数据生成成功"
,
sdf
.
format
(
new
Date
())
);
}
else
{
logger
.
warn
(
"[{}]汇聚平台对账数据生成失败: {}"
,
sdf
.
format
(
new
Date
()),
rtv
.
getMsg
()
);
}
}
}
src/main/resources/application-dev.yml
0 → 100644
浏览文件 @
998ef1d6
spring
:
application
:
name
:
rec-fj
datasource
:
driver-class-name
:
com.kingbase.Driver
url
:
jdbc:kingbase://10.51.210.2:54321/FJZX
username
:
NYBDB
password
:
Fjny6467
mybatis-plus
:
mapper-locations
:
-
"
classpath*:mappers/**/*.xml"
logging
:
level
:
com.reconciliation.recfj
:
DEBUG
task
:
rec
:
default
:
0 0 6 * * ?
src/main/resources/application-prod.yml
0 → 100644
浏览文件 @
998ef1d6
spring
:
application
:
name
:
rec-fj
datasource
:
driver-class-name
:
com.kingbase.Driver
url
:
jdbc:kingbase://127.0.0.1:54321/FJZX
username
:
NYBDB
password
:
Fjny6467
mybatis-plus
:
mapper-locations
:
-
"
classpath*:mappers/**/*.xml"
logging
:
level
:
com.reconciliation.recfj
:
DEBUG
task
:
rec
:
default
:
0 0 6 * * ?
src/main/resources/application.yml
浏览文件 @
998ef1d6
spring
:
application
:
name
:
rec-fj
datasource
:
driver-class-name
:
com.kingbase.Driver
url
:
jdbc:kingbase://127.0.0.1:54321/FJZX
username
:
NYBDB
password
:
Fjny6467
mybatis-plus
:
mapper-locations
:
-
"
classpath*:mappers/**/*.xml"
logging
:
level
:
com.reconciliation.recfj
:
DEBUG
task
:
rec
:
default
:
0 0 6 * * ?
profiles
:
active
:
dev
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论