Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
adb71540
Commit
adb71540
authored
Jun 25, 2018
by
frank.xa.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[data migration] migration data from old table to new table
parent
c7939ead
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1483 additions
and
51 deletions
+1483
-51
DateUtils.java
...src/main/java/pwc/taxtech/atms/common/util/DateUtils.java
+667
-0
CellTemplateConfigMapper.java
...n/java/pwc/taxtech/atms/dao/CellTemplateConfigMapper.java
+3
-0
CellTemplateMapper.java
...rc/main/java/pwc/taxtech/atms/dao/CellTemplateMapper.java
+2
-0
CellTemplate.java
.../src/main/java/pwc/taxtech/atms/entitiy/CellTemplate.java
+68
-0
CellTemplateExample.java
...in/java/pwc/taxtech/atms/entitiy/CellTemplateExample.java
+140
-0
CellTemplateConfigMapper.xml
...sources/pwc/taxtech/atms/dao/CellTemplateConfigMapper.xml
+36
-0
CellTemplateMapper.xml
...ain/resources/pwc/taxtech/atms/dao/CellTemplateMapper.xml
+57
-9
CommonIT.java
atms-api/src/test/java/pwc/taxtech/atms/CommonIT.java
+18
-42
DataMigration.java
atms-api/src/test/java/pwc/taxtech/atms/DataMigration.java
+492
-0
No files found.
atms-api/src/main/java/pwc/taxtech/atms/common/util/DateUtils.java
0 → 100644
View file @
adb71540
package
pwc
.
taxtech
.
atms
.
common
.
util
;
import
java.text.ParseException
;
import
java.text.ParsePosition
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
DateUtils
{
/**
* 获取现在时间
*
* @return 返回时间类型 yyyy-MM-dd HH:mm:ss
*/
public
static
Date
getNowDate
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateString
=
formatter
.
format
(
currentTime
);
ParsePosition
pos
=
new
ParsePosition
(
8
);
Date
currentTime_2
=
formatter
.
parse
(
dateString
,
pos
);
return
currentTime_2
;
}
/**
* 获取现在时间
*
* @return返回短时间格式 yyyy-MM-dd
*/
public
static
Date
getNowDateShort
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
dateString
=
formatter
.
format
(
currentTime
);
ParsePosition
pos
=
new
ParsePosition
(
8
);
Date
currentTime_2
=
formatter
.
parse
(
dateString
,
pos
);
return
currentTime_2
;
}
/**
* 获取现在时间
*
* @return返回字符串格式 yyyy-MM-dd HH:mm:ss
*/
public
static
String
getStringDate
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateString
=
formatter
.
format
(
currentTime
);
return
dateString
;
}
/**
* 获取现在时间
*
* @return 返回短时间字符串格式yyyy-MM-dd
*/
public
static
String
getStringDateShort
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
dateString
=
formatter
.
format
(
currentTime
);
return
dateString
;
}
/**
* 获取时间 小时:分;秒 HH:mm:ss
*
* @return
*/
public
static
String
getTimeShort
()
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
Date
currentTime
=
new
Date
();
String
dateString
=
formatter
.
format
(
currentTime
);
return
dateString
;
}
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
*
* @param strDate
* @return
*/
public
static
Date
strToDateLong
(
String
strDate
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
ParsePosition
pos
=
new
ParsePosition
(
0
);
Date
strtodate
=
formatter
.
parse
(
strDate
,
pos
);
return
strtodate
;
}
/**
* 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
*
* @param dateDate
* @return
*/
public
static
String
dateToStrLong
(
java
.
util
.
Date
dateDate
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateString
=
formatter
.
format
(
dateDate
);
return
dateString
;
}
/**
* 将短时间格式时间转换为字符串 yyyy-MM-dd
*
* @param dateDate
* @return
*/
public
static
String
dateToStr
(
java
.
util
.
Date
dateDate
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
dateString
=
formatter
.
format
(
dateDate
);
return
dateString
;
}
/**
* 将短时间格式字符串转换为时间 yyyy-MM-dd
*
* @param strDate
* @return
*/
public
static
Date
strToDate
(
String
strDate
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
ParsePosition
pos
=
new
ParsePosition
(
0
);
Date
strtodate
=
formatter
.
parse
(
strDate
,
pos
);
return
strtodate
;
}
/**
* 得到现在时间
*
* @return
*/
public
static
Date
getNow
()
{
Date
currentTime
=
new
Date
();
return
currentTime
;
}
/**
* 提取一个月中的最后一天
*
* @param day
* @return
*/
public
static
Date
getLastDate
(
long
day
)
{
Date
date
=
new
Date
();
long
date_3_hm
=
date
.
getTime
()
-
3600000
*
34
*
day
;
Date
date_3_hm_date
=
new
Date
(
date_3_hm
);
return
date_3_hm_date
;
}
/**
* 得到现在时间
*
* @return 字符串 yyyyMMdd HHmmss
*/
public
static
String
getStringToday
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd HHmmss"
);
String
dateString
=
formatter
.
format
(
currentTime
);
return
dateString
;
}
/**
* 得到现在小时
*/
public
static
String
getHour
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateString
=
formatter
.
format
(
currentTime
);
String
hour
;
hour
=
dateString
.
substring
(
11
,
13
);
return
hour
;
}
/**
* 得到现在分钟
*
* @return
*/
public
static
String
getTime
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateString
=
formatter
.
format
(
currentTime
);
String
min
;
min
=
dateString
.
substring
(
14
,
16
);
return
min
;
}
/**
* 根据用户传入的时间表示格式,返回当前时间的格式 如果是yyyyMMdd,注意字母y不能大写。
*
* @param sformat yyyyMMddhhmmss
* @return
*/
public
static
String
getUserDate
(
String
sformat
)
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
sformat
);
String
dateString
=
formatter
.
format
(
currentTime
);
return
dateString
;
}
/**
* 二个小时时间间的差值,必须保证二个时间都是"HH:MM"的格式,返回字符型的分钟
*/
public
static
String
getTwoHour
(
String
st1
,
String
st2
)
{
String
[]
kk
=
null
;
String
[]
jj
=
null
;
kk
=
st1
.
split
(
":"
);
jj
=
st2
.
split
(
":"
);
if
(
Integer
.
parseInt
(
kk
[
0
])
<
Integer
.
parseInt
(
jj
[
0
]))
return
"0"
;
else
{
double
y
=
Double
.
parseDouble
(
kk
[
0
])
+
Double
.
parseDouble
(
kk
[
1
])
/
60
;
double
u
=
Double
.
parseDouble
(
jj
[
0
])
+
Double
.
parseDouble
(
jj
[
1
])
/
60
;
if
((
y
-
u
)
>
0
)
return
y
-
u
+
""
;
else
return
"0"
;
}
}
/**
* 得到二个日期间的间隔天数
*/
public
static
String
getTwoDay
(
String
sj1
,
String
sj2
)
{
SimpleDateFormat
myFormatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
long
day
=
0
;
try
{
java
.
util
.
Date
date
=
myFormatter
.
parse
(
sj1
);
java
.
util
.
Date
mydate
=
myFormatter
.
parse
(
sj2
);
day
=
(
date
.
getTime
()
-
mydate
.
getTime
())
/
(
24
*
60
*
60
*
1000
);
}
catch
(
Exception
e
)
{
return
""
;
}
return
day
+
""
;
}
/**
* 时间前推或后推分钟,其中JJ表示分钟.
*/
public
static
String
getPreTime
(
String
sj1
,
String
jj
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
mydate1
=
""
;
try
{
Date
date1
=
format
.
parse
(
sj1
);
long
Time
=
(
date1
.
getTime
()
/
1000
)
+
Integer
.
parseInt
(
jj
)
*
60
;
date1
.
setTime
(
Time
*
1000
);
mydate1
=
format
.
format
(
date1
);
}
catch
(
Exception
e
)
{
}
return
mydate1
;
}
/**
* 得到一个时间延后或前移几天的时间,nowdate为时间,delay为前移或后延的天数
*/
public
static
String
getNextDay
(
String
nowdate
,
String
delay
)
{
try
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
mdate
=
""
;
Date
d
=
strToDate
(
nowdate
);
long
myTime
=
(
d
.
getTime
()
/
1000
)
+
Integer
.
parseInt
(
delay
)
*
24
*
60
*
60
;
d
.
setTime
(
myTime
*
1000
);
mdate
=
format
.
format
(
d
);
return
mdate
;
}
catch
(
Exception
e
)
{
return
""
;
}
}
/**
* 判断是否润年
*
* @param ddate
* @return
*/
public
static
boolean
isLeapYear
(
String
ddate
)
{
/**
* 详细设计: 1.被400整除是闰年,否则: 2.不能被4整除则不是闰年 3.能被4整除同时不能被100整除则是闰年
* 3.能被4整除同时能被100整除则不是闰年
*/
Date
d
=
strToDate
(
ddate
);
GregorianCalendar
gc
=
(
GregorianCalendar
)
Calendar
.
getInstance
();
gc
.
setTime
(
d
);
int
year
=
gc
.
get
(
Calendar
.
YEAR
);
if
((
year
%
400
)
==
0
)
return
true
;
else
if
((
year
%
4
)
==
0
)
{
if
((
year
%
100
)
==
0
)
return
false
;
else
return
true
;
}
else
return
false
;
}
/**
* 返回美国时间格式 26 Apr 2006
*
* @param str
* @return
*/
public
static
String
getEDate
(
String
str
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
ParsePosition
pos
=
new
ParsePosition
(
0
);
Date
strtodate
=
formatter
.
parse
(
str
,
pos
);
String
j
=
strtodate
.
toString
();
String
[]
k
=
j
.
split
(
" "
);
return
k
[
2
]
+
k
[
1
].
toUpperCase
()
+
k
[
5
].
substring
(
2
,
4
);
}
/**
* 获取一个月的最后一天
*
* @param dat
* @return
*/
public
static
String
getEndDateOfMonth
(
String
dat
)
{
// yyyy-MM-dd
String
str
=
dat
.
substring
(
0
,
8
);
String
month
=
dat
.
substring
(
5
,
7
);
int
mon
=
Integer
.
parseInt
(
month
);
if
(
mon
==
1
||
mon
==
3
||
mon
==
5
||
mon
==
7
||
mon
==
8
||
mon
==
10
||
mon
==
12
)
{
str
+=
"31"
;
}
else
if
(
mon
==
4
||
mon
==
6
||
mon
==
9
||
mon
==
11
)
{
str
+=
"30"
;
}
else
{
if
(
isLeapYear
(
dat
))
{
str
+=
"29"
;
}
else
{
str
+=
"28"
;
}
}
return
str
;
}
/**
* 判断二个时间是否在同一个周
*
* @param date1
* @param date2
* @return
*/
public
static
boolean
isSameWeekDates
(
Date
date1
,
Date
date2
)
{
Calendar
cal1
=
Calendar
.
getInstance
();
Calendar
cal2
=
Calendar
.
getInstance
();
cal1
.
setTime
(
date1
);
cal2
.
setTime
(
date2
);
int
subYear
=
cal1
.
get
(
Calendar
.
YEAR
)
-
cal2
.
get
(
Calendar
.
YEAR
);
if
(
0
==
subYear
)
{
if
(
cal1
.
get
(
Calendar
.
WEEK_OF_YEAR
)
==
cal2
.
get
(
Calendar
.
WEEK_OF_YEAR
))
return
true
;
}
else
if
(
1
==
subYear
&&
11
==
cal2
.
get
(
Calendar
.
MONTH
))
{
// 如果12月的最后一周横跨来年第一周的话则最后一周即算做来年的第一周
if
(
cal1
.
get
(
Calendar
.
WEEK_OF_YEAR
)
==
cal2
.
get
(
Calendar
.
WEEK_OF_YEAR
))
return
true
;
}
else
if
(-
1
==
subYear
&&
11
==
cal1
.
get
(
Calendar
.
MONTH
))
{
if
(
cal1
.
get
(
Calendar
.
WEEK_OF_YEAR
)
==
cal2
.
get
(
Calendar
.
WEEK_OF_YEAR
))
return
true
;
}
return
false
;
}
/**
* 产生周序列,即得到当前时间所在的年度是第几周
*
* @return
*/
public
static
String
getSeqWeek
()
{
Calendar
c
=
Calendar
.
getInstance
(
Locale
.
CHINA
);
String
week
=
Integer
.
toString
(
c
.
get
(
Calendar
.
WEEK_OF_YEAR
));
if
(
week
.
length
()
==
1
)
week
=
"0"
+
week
;
String
year
=
Integer
.
toString
(
c
.
get
(
Calendar
.
YEAR
));
return
year
+
week
;
}
/**
* 获得一个日期所在的周的星期几的日期,如要找出2002年2月3日所在周的星期一是几号
*
* @param sdate
* @param num
* @return
*/
public
static
String
getWeek
(
String
sdate
,
String
num
)
{
// 再转换为时间
Date
dd
=
DateUtils
.
strToDate
(
sdate
);
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
dd
);
if
(
num
.
equals
(
"1"
))
// 返回星期一所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
else
if
(
num
.
equals
(
"2"
))
// 返回星期二所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
TUESDAY
);
else
if
(
num
.
equals
(
"3"
))
// 返回星期三所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
WEDNESDAY
);
else
if
(
num
.
equals
(
"4"
))
// 返回星期四所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
THURSDAY
);
else
if
(
num
.
equals
(
"5"
))
// 返回星期五所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
FRIDAY
);
else
if
(
num
.
equals
(
"6"
))
// 返回星期六所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
SATURDAY
);
else
if
(
num
.
equals
(
"0"
))
// 返回星期日所在的日期
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
SUNDAY
);
return
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
c
.
getTime
());
}
/**
* 根据一个日期,返回是星期几的字符串
*
* @param sdate
* @return
*/
public
static
String
getWeek
(
String
sdate
)
{
// 再转换为时间
Date
date
=
DateUtils
.
strToDate
(
sdate
);
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
date
);
// int hour=c.get(Calendar.DAY_OF_WEEK);
// hour中存的就是星期几了,其范围 1~7
// 1=星期日 7=星期六,其他类推
return
new
SimpleDateFormat
(
"EEEE"
).
format
(
c
.
getTime
());
}
public
static
String
getWeekStr
(
String
sdate
)
{
String
str
=
""
;
str
=
DateUtils
.
getWeek
(
sdate
);
if
(
"1"
.
equals
(
str
))
{
str
=
"星期日"
;
}
else
if
(
"2"
.
equals
(
str
))
{
str
=
"星期一"
;
}
else
if
(
"3"
.
equals
(
str
))
{
str
=
"星期二"
;
}
else
if
(
"4"
.
equals
(
str
))
{
str
=
"星期三"
;
}
else
if
(
"5"
.
equals
(
str
))
{
str
=
"星期四"
;
}
else
if
(
"6"
.
equals
(
str
))
{
str
=
"星期五"
;
}
else
if
(
"7"
.
equals
(
str
))
{
str
=
"星期六"
;
}
return
str
;
}
/**
* 两个时间之间的天数
*
* @param date1
* @param date2
* @return
*/
public
static
long
getDays
(
String
date1
,
String
date2
)
{
if
(
date1
==
null
||
date1
.
equals
(
""
))
return
0
;
if
(
date2
==
null
||
date2
.
equals
(
""
))
return
0
;
// 转换为标准时间
SimpleDateFormat
myFormatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
java
.
util
.
Date
date
=
null
;
java
.
util
.
Date
mydate
=
null
;
try
{
date
=
myFormatter
.
parse
(
date1
);
mydate
=
myFormatter
.
parse
(
date2
);
}
catch
(
Exception
e
)
{
}
long
day
=
(
date
.
getTime
()
-
mydate
.
getTime
())
/
(
24
*
60
*
60
*
1000
);
return
day
;
}
/**
* 形成如下的日历 , 根据传入的一个时间返回一个结构 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是当月的各个时间
* 此函数返回该日历第一行星期日所在的日期
*
* @param sdate
* @return
*/
public
static
String
getNowMonth
(
String
sdate
)
{
// 取该时间所在月的一号
sdate
=
sdate
.
substring
(
0
,
8
)
+
"01"
;
// 得到这个月的1号是星期几
Date
date
=
DateUtils
.
strToDate
(
sdate
);
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
date
);
int
u
=
c
.
get
(
Calendar
.
DAY_OF_WEEK
);
String
newday
=
DateUtils
.
getNextDay
(
sdate
,
(
1
-
u
)
+
""
);
return
newday
;
}
/**
* 取得数据库主键 生成格式为yyyymmddhhmmss+k位随机数
*
* @param k 表示是取几位随机数,可以自己定
*/
public
static
String
getNo
(
int
k
)
{
return
getUserDate
(
"yyyyMMddhhmmss"
)
+
getRandom
(
k
);
}
/**
* 返回一个随机数
*
* @param i
* @return
*/
public
static
String
getRandom
(
int
i
)
{
Random
jjj
=
new
Random
();
// int suiJiShu = jjj.nextInt(9);
if
(
i
==
0
)
return
""
;
String
jj
=
""
;
for
(
int
k
=
0
;
k
<
i
;
k
++)
{
jj
=
jj
+
jjj
.
nextInt
(
9
);
}
return
jj
;
}
/**
* @param date
*/
public
static
boolean
RightDate
(
String
date
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
;
if
(
date
==
null
)
return
false
;
if
(
date
.
length
()
>
10
)
{
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm:ss"
);
}
else
{
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
}
try
{
sdf
.
parse
(
date
);
}
catch
(
ParseException
pe
)
{
return
false
;
}
return
true
;
}
// /***************************************************************************
// * //nd=1表示返回的值中包含年度 //yf=1表示返回的值中包含月份 //rq=1表示返回的值中包含日期 //format表示返回的格式 1
// * 以年月日中文返回 2 以横线-返回 // 3 以斜线/返回 4 以缩写不带其它符号形式返回 // 5 以点号.返回
// **************************************************************************/
// public static String getStringDateMonth(String sdate, String nd, String yf, String rq, String format) {
// Date currentTime = new Date();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// String dateString = formatter.format(currentTime);
// String s_nd = dateString.substring(0, 4); // 年份
// String s_yf = dateString.substring(5, 7); // 月份
// String s_rq = dateString.substring(8, 10); // 日期
// String sreturn = "";
// roc.util.MyChar mc = new roc.util.MyChar();
// if (sdate == null || sdate.equals("") || !mc.Isdate(sdate)) { // 处理空值情况
// if (nd.equals("1")) {
// sreturn = s_nd;
// // 处理间隔符
// if (format.equals("1"))
// sreturn = sreturn + "年";
// else if (format.equals("2"))
// sreturn = sreturn + "-";
// else if (format.equals("3"))
// sreturn = sreturn + "/";
// else if (format.equals("5"))
// sreturn = sreturn + ".";
// }
// // 处理月份
// if (yf.equals("1")) {
// sreturn = sreturn + s_yf;
// if (format.equals("1"))
// sreturn = sreturn + "月";
// else if (format.equals("2"))
// sreturn = sreturn + "-";
// else if (format.equals("3"))
// sreturn = sreturn + "/";
// else if (format.equals("5"))
// sreturn = sreturn + ".";
// }
// // 处理日期
// if (rq.equals("1")) {
// sreturn = sreturn + s_rq;
// if (format.equals("1"))
// sreturn = sreturn + "日";
// }
// } else {
// // 不是空值,也是一个合法的日期值,则先将其转换为标准的时间格式
// sdate = roc.util.RocDate.getOKDate(sdate);
// s_nd = sdate.substring(0, 4); // 年份
// s_yf = sdate.substring(5, 7); // 月份
// s_rq = sdate.substring(8, 10); // 日期
// if (nd.equals("1")) {
// sreturn = s_nd;
// // 处理间隔符
// if (format.equals("1"))
// sreturn = sreturn + "年";
// else if (format.equals("2"))
// sreturn = sreturn + "-";
// else if (format.equals("3"))
// sreturn = sreturn + "/";
// else if (format.equals("5"))
// sreturn = sreturn + ".";
// }
// // 处理月份
// if (yf.equals("1")) {
// sreturn = sreturn + s_yf;
// if (format.equals("1"))
// sreturn = sreturn + "月";
// else if (format.equals("2"))
// sreturn = sreturn + "-";
// else if (format.equals("3"))
// sreturn = sreturn + "/";
// else if (format.equals("5"))
// sreturn = sreturn + ".";
// }
// // 处理日期
// if (rq.equals("1")) {
// sreturn = sreturn + s_rq;
// if (format.equals("1"))
// sreturn = sreturn + "日";
// }
// }
// return sreturn;
// }
// public static String getNextMonthDay(String sdate, int m) {
// sdate = getOKDate(sdate);
// int year = Integer.parseInt(sdate.substring(0, 4));
// int month = Integer.parseInt(sdate.substring(5, 7));
// month = month + m;
// if (month < 0) {
// month = month + 12;
// year = year - 1;
// } else if (month > 12) {
// month = month - 12;
// year = year + 1;
// }
// String smonth = "";
// if (month < 10)
// smonth = "0" + month;
// else
// smonth = "" + month;
// return year + "-" + smonth + "-10";
// }
//
// public static String getOKDate(String sdate) {
// if (sdate == null || sdate.equals(""))
// return getStringDateShort();
//
// if (!VeStr.Isdate(sdate)) {
// sdate = getStringDateShort();
// }
// // 将“/”转换为“-”
// sdate = VeStr.Replace(sdate, "/", "-");
// // 如果只有8位长度,则要进行转换
// if (sdate.length() == 8)
// sdate = sdate.substring(0, 4) + "-" + sdate.substring(4, 6) + "-" + sdate.substring(6, 8);
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// ParsePosition pos = new ParsePosition(0);
// Date strtodate = formatter.parse(sdate, pos);
// String dateString = formatter.format(strtodate);
// return dateString;
// }
//
// public static void main(String[] args) throws Exception {
// try {
// //System.out.print(Integer.valueOf(getTwoDay("2006-11-03 12:22:10", "2006-11-02 11:22:09")));
// } catch (Exception e) {
// throw new Exception();
// }
// //System.out.println("sss");
// }
}
atms-api/src/main/java/pwc/taxtech/atms/dao/CellTemplateConfigMapper.java
View file @
adb71540
...
...
@@ -111,4 +111,6 @@ public interface CellTemplateConfigMapper extends MyMapper {
int
deleteCellTemplateConfigByCellTemplate
(
@Param
(
"templateDbID"
)
Long
templateDbID
);
void
batchInsert
(
List
<
CellTemplateConfig
>
list
);
void
batchInser2
(
List
<
CellTemplateConfig
>
list
);
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/dao/CellTemplateMapper.java
View file @
adb71540
...
...
@@ -108,5 +108,6 @@ public interface CellTemplateMapper extends MyMapper {
void
batchInsert
(
List
<
CellTemplate
>
list
);
void
batchInsert2
(
List
<
CellTemplate
>
list
);
}
\ No newline at end of file
atms-api/src/main/java/pwc/taxtech/atms/entitiy/CellTemplate.java
View file @
adb71540
...
...
@@ -119,6 +119,24 @@ public class CellTemplate implements Serializable {
*/
private
Boolean
isReadOnly
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cell_template.create_by
*
* @mbg.generated
*/
private
String
createBy
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cell_template.update_by
*
* @mbg.generated
*/
private
String
updateBy
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table cell_template
...
...
@@ -415,6 +433,54 @@ public class CellTemplate implements Serializable {
this
.
isReadOnly
=
isReadOnly
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column cell_template.create_by
*
* @return the value of cell_template.create_by
*
* @mbg.generated
*/
public
String
getCreateBy
()
{
return
createBy
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column cell_template.create_by
*
* @param createBy the value for cell_template.create_by
*
* @mbg.generated
*/
public
void
setCreateBy
(
String
createBy
)
{
this
.
createBy
=
createBy
==
null
?
null
:
createBy
.
trim
();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column cell_template.update_by
*
* @return the value of cell_template.update_by
*
* @mbg.generated
*/
public
String
getUpdateBy
()
{
return
updateBy
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column cell_template.update_by
*
* @param updateBy the value for cell_template.update_by
*
* @mbg.generated
*/
public
void
setUpdateBy
(
String
updateBy
)
{
this
.
updateBy
=
updateBy
==
null
?
null
:
updateBy
.
trim
();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cell_template
...
...
@@ -439,6 +505,8 @@ public class CellTemplate implements Serializable {
sb
.
append
(
", copyFromId="
).
append
(
copyFromId
);
sb
.
append
(
", dataType="
).
append
(
dataType
);
sb
.
append
(
", isReadOnly="
).
append
(
isReadOnly
);
sb
.
append
(
", createBy="
).
append
(
createBy
);
sb
.
append
(
", updateBy="
).
append
(
updateBy
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
...
...
atms-api/src/main/java/pwc/taxtech/atms/entitiy/CellTemplateExample.java
View file @
adb71540
...
...
@@ -944,6 +944,146 @@ public class CellTemplateExample {
addCriterion
(
"is_read_only not between"
,
value1
,
value2
,
"isReadOnly"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByIsNull
()
{
addCriterion
(
"create_by is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByIsNotNull
()
{
addCriterion
(
"create_by is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByEqualTo
(
String
value
)
{
addCriterion
(
"create_by ="
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByNotEqualTo
(
String
value
)
{
addCriterion
(
"create_by <>"
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByGreaterThan
(
String
value
)
{
addCriterion
(
"create_by >"
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"create_by >="
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByLessThan
(
String
value
)
{
addCriterion
(
"create_by <"
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"create_by <="
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByLike
(
String
value
)
{
addCriterion
(
"create_by like"
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByNotLike
(
String
value
)
{
addCriterion
(
"create_by not like"
,
value
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByIn
(
List
<
String
>
values
)
{
addCriterion
(
"create_by in"
,
values
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"create_by not in"
,
values
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"create_by between"
,
value1
,
value2
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andCreateByNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"create_by not between"
,
value1
,
value2
,
"createBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByIsNull
()
{
addCriterion
(
"update_by is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByIsNotNull
()
{
addCriterion
(
"update_by is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByEqualTo
(
String
value
)
{
addCriterion
(
"update_by ="
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByNotEqualTo
(
String
value
)
{
addCriterion
(
"update_by <>"
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByGreaterThan
(
String
value
)
{
addCriterion
(
"update_by >"
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"update_by >="
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByLessThan
(
String
value
)
{
addCriterion
(
"update_by <"
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"update_by <="
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByLike
(
String
value
)
{
addCriterion
(
"update_by like"
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByNotLike
(
String
value
)
{
addCriterion
(
"update_by not like"
,
value
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByIn
(
List
<
String
>
values
)
{
addCriterion
(
"update_by in"
,
values
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"update_by not in"
,
values
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"update_by between"
,
value1
,
value2
,
"updateBy"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUpdateByNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"update_by not between"
,
value1
,
value2
,
"updateBy"
);
return
(
Criteria
)
this
;
}
}
/**
...
...
atms-api/src/main/resources/pwc/taxtech/atms/dao/CellTemplateConfigMapper.xml
View file @
adb71540
...
...
@@ -564,4 +564,39 @@ WHERE
#{item.validationDescription,jdbcType=VARCHAR}, #{item.voucherKeyword,jdbcType=VARCHAR})
</foreach>
</insert>
<insert
id=
"batchInsert2"
parameterType=
"pwc.taxtech.atms.entitiy.CellTemplateConfig"
>
INSERT INTO tax_admin.cell_template_config
(id,
cell_template_id,
report_template_id,
data_source_type,
formula,
formula_description,
account_codes,
invoice_type,
tax_rate,
invoice_amount_type,
model_ids,
create_by,
create_time,
update_by,
update_time,
invoice_category,
formula_data_source,
validation,
validation_description,
voucher_keyword
)
VALUES
<foreach
collection =
"list"
item=
"item"
separator =
","
>
(#{item.id,jdbcType=INTEGER}, #{item.cellTemplateId,jdbcType=INTEGER}, #{item.reportTemplateId,jdbcType=INTEGER},
#{item.dataSourceType,jdbcType=INTEGER}, #{item.formula,jdbcType=VARCHAR}, #{item.formulaDescription,jdbcType=VARCHAR},
#{item.accountCodes,jdbcType=VARCHAR}, #{item.invoiceType,jdbcType=INTEGER}, #{item.taxRate,jdbcType=VARCHAR},
#{item.invoiceAmountType,jdbcType=INTEGER}, #{item.modelIds,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
#{item.invoiceCategory,jdbcType=VARCHAR}, #{item.formulaDataSource,jdbcType=VARCHAR}, #{item.validation,jdbcType=VARCHAR},
#{item.validationDescription,jdbcType=VARCHAR}, #{item.voucherKeyword,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>
\ No newline at end of file
atms-api/src/main/resources/pwc/taxtech/atms/dao/CellTemplateMapper.xml
View file @
adb71540
...
...
@@ -18,6 +18,8 @@
<result
column=
"copy_from_id"
jdbcType=
"BIGINT"
property=
"copyFromId"
/>
<result
column=
"data_type"
jdbcType=
"INTEGER"
property=
"dataType"
/>
<result
column=
"is_read_only"
jdbcType=
"SMALLINT"
property=
"isReadOnly"
/>
<result
column=
"create_by"
jdbcType=
"VARCHAR"
property=
"createBy"
/>
<result
column=
"update_by"
jdbcType=
"VARCHAR"
property=
"updateBy"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<!--
...
...
@@ -91,7 +93,7 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, report_template_id, row_index, row_name, column_index, column_name, comment,
create_time, update_time, copy_from_id, data_type, is_read_only
create_time, update_time, copy_from_id, data_type, is_read_only
, create_by, update_by
</sql>
<select
id=
"selectByExample"
parameterType=
"pwc.taxtech.atms.entitiy.CellTemplateExample"
resultMap=
"BaseResultMap"
>
<!--
...
...
@@ -147,13 +149,13 @@
insert into cell_template (id, report_template_id, row_index,
row_name, column_index, column_name,
comment, create_time, update_time,
copy_from_id, data_type, is_read_only
)
copy_from_id, data_type, is_read_only
,
create_by, update_by
)
values (#{id,jdbcType=BIGINT}, #{reportTemplateId,jdbcType=BIGINT}, #{rowIndex,jdbcType=INTEGER},
#{rowName,jdbcType=VARCHAR}, #{columnIndex,jdbcType=INTEGER}, #{columnName,jdbcType=VARCHAR},
#{comment,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{copyFromId,jdbcType=BIGINT}, #{dataType,jdbcType=INTEGER}, #{isReadOnly,jdbcType=SMALLINT}
)
#{copyFromId,jdbcType=BIGINT}, #{dataType,jdbcType=INTEGER}, #{isReadOnly,jdbcType=SMALLINT}
,
#{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"pwc.taxtech.atms.entitiy.CellTemplate"
>
<!--
...
...
@@ -198,6 +200,12 @@
<if
test=
"isReadOnly != null"
>
is_read_only,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
...
...
@@ -236,6 +244,12 @@
<if
test=
"isReadOnly != null"
>
#{isReadOnly,jdbcType=SMALLINT},
</if>
<if
test=
"createBy != null"
>
#{createBy,jdbcType=VARCHAR},
</if>
<if
test=
"updateBy != null"
>
#{updateBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"pwc.taxtech.atms.entitiy.CellTemplateExample"
resultType=
"java.lang.Long"
>
...
...
@@ -291,6 +305,12 @@
<if
test=
"record.isReadOnly != null"
>
is_read_only = #{record.isReadOnly,jdbcType=SMALLINT},
</if>
<if
test=
"record.createBy != null"
>
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if
test=
"record.updateBy != null"
>
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
...
...
@@ -313,7 +333,9 @@
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
copy_from_id = #{record.copyFromId,jdbcType=BIGINT},
data_type = #{record.dataType,jdbcType=INTEGER},
is_read_only = #{record.isReadOnly,jdbcType=SMALLINT}
is_read_only = #{record.isReadOnly,jdbcType=SMALLINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
update_by = #{record.updateBy,jdbcType=VARCHAR}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
...
...
@@ -358,6 +380,12 @@
<if
test=
"isReadOnly != null"
>
is_read_only = #{isReadOnly,jdbcType=SMALLINT},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
...
...
@@ -377,7 +405,9 @@
update_time = #{updateTime,jdbcType=TIMESTAMP},
copy_from_id = #{copyFromId,jdbcType=BIGINT},
data_type = #{dataType,jdbcType=INTEGER},
is_read_only = #{isReadOnly,jdbcType=SMALLINT}
is_read_only = #{isReadOnly,jdbcType=SMALLINT},
create_by = #{createBy,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"selectByExampleWithRowbounds"
parameterType=
"pwc.taxtech.atms.entitiy.CellTemplateExample"
resultMap=
"BaseResultMap"
>
...
...
@@ -406,12 +436,29 @@
CopyFromID, DataType, IsReadOnly
)
values
<foreach
collection
=
"list"
item=
"item"
separator
=
","
>
<foreach
collection
=
"list"
item=
"item"
separator
=
","
>
(#{item.ID,jdbcType=VARCHAR}, #{item.reportTemplateID,jdbcType=VARCHAR}, #{item.rowIndex,jdbcType=INTEGER},
#{item.rowName,jdbcType=VARCHAR}, #{item.columnIndex,jdbcType=INTEGER}, #{item.columnName,jdbcType=VARCHAR},
#{item.comment,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP},
#{item.copyFromID,jdbcType=VARCHAR}, #{item.dataType,jdbcType=INTEGER}, #{item.isReadOnly,jdbcType=INTEGER}
)
</foreach >
</foreach>
</insert>
<insert
id=
"batchInsert2"
>
insert into cell_template (id, report_template_id, row_index,
row_name, column_index, column_name,
comment, create_time, update_time,
copy_from_id, data_type, is_read_only, create_by, update_by
)
values
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(#{item.id,jdbcType=INTEGER}, #{item.reportTemplateId,jdbcType=INTEGER}, #{item.rowIndex,jdbcType=INTEGER},
#{item.rowName,jdbcType=VARCHAR}, #{item.columnIndex,jdbcType=INTEGER}, #{item.columnName,jdbcType=VARCHAR},
#{item.comment,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP},
#{item.copyFromId,jdbcType=INTEGER}, #{item.dataType,jdbcType=INTEGER}, #{item.isReadOnly,jdbcType=SMALLINT},
#{item.createBy,jdbcType=VARCHAR}, #{item.updateBy,jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
atms-api/src/test/java/pwc/taxtech/atms/CommonIT.java
View file @
adb71540
...
...
@@ -16,48 +16,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
pwc.taxtech.atms.dao.AccountMappingMapper
;
import
pwc.taxtech.atms.dao.AreaMapper
;
import
pwc.taxtech.atms.dao.AreaRegionMapper
;
import
pwc.taxtech.atms.dao.BusinessUnitMapper
;
import
pwc.taxtech.atms.dao.CacheMapper
;
import
pwc.taxtech.atms.dao.CustomerMapper
;
import
pwc.taxtech.atms.dao.DictionaryMapper
;
import
pwc.taxtech.atms.dao.DimensionMapper
;
import
pwc.taxtech.atms.dao.DimensionValueMapper
;
import
pwc.taxtech.atms.dao.DimensionValueOrgMapper
;
import
pwc.taxtech.atms.dao.EnterpriseAccountMapper
;
import
pwc.taxtech.atms.dao.EnterpriseAccountSetMapper
;
import
pwc.taxtech.atms.dao.EnterpriseAccountSetOrgMapper
;
import
pwc.taxtech.atms.dao.IndustryMapper
;
import
pwc.taxtech.atms.dao.MailQueueMapper
;
import
pwc.taxtech.atms.dao.MenuMapper
;
import
pwc.taxtech.atms.dao.OperationLogBasicDataMapper
;
import
pwc.taxtech.atms.dao.OperationLogEnterPriseMapper
;
import
pwc.taxtech.atms.dao.OperationLogOrganizationMapper
;
import
pwc.taxtech.atms.dao.OperationLogRoleMapper
;
import
pwc.taxtech.atms.dao.OperationLogUserMapper
;
import
pwc.taxtech.atms.dao.OrganizationMapper
;
import
pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper
;
import
pwc.taxtech.atms.dao.OrganizationStructureMapper
;
import
pwc.taxtech.atms.dao.PermissionMapper
;
import
pwc.taxtech.atms.dao.ProjectClientMapper
;
import
pwc.taxtech.atms.dao.RegionMapper
;
import
pwc.taxtech.atms.dao.RoleCategoryMapper
;
import
pwc.taxtech.atms.dao.RoleMapper
;
import
pwc.taxtech.atms.dao.RolePermissionMapper
;
import
pwc.taxtech.atms.dao.ServiceTypeMapper
;
import
pwc.taxtech.atms.dao.StandardAccountMapper
;
import
pwc.taxtech.atms.dao.StatisticAttributeDimensionMapper
;
import
pwc.taxtech.atms.dao.StatisticAttributeMapper
;
import
pwc.taxtech.atms.dao.TemplateGroupMapper
;
import
pwc.taxtech.atms.dao.UserDimensionValueMapper
;
import
pwc.taxtech.atms.dao.UserDimensionValueOrgMapper
;
import
pwc.taxtech.atms.dao.UserDimensionValueRoleMapper
;
import
pwc.taxtech.atms.dao.UserMapper
;
import
pwc.taxtech.atms.dao.UserOrganizationMapper
;
import
pwc.taxtech.atms.dao.UserOrganizationRoleMapper
;
import
pwc.taxtech.atms.dao.UserRoleMapper
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
pwc.taxtech.atms.dao.*
;
import
pwc.taxtech.atms.entitiy.AreaExample
;
import
pwc.taxtech.atms.entitiy.AreaRegionExample
;
import
pwc.taxtech.atms.entitiy.CustomerExample
;
...
...
@@ -74,7 +34,9 @@ import pwc.taxtech.atms.entitiy.RegionExample;
import
pwc.taxtech.atms.entitiy.ServiceTypeExample
;
import
pwc.taxtech.atms.entitiy.StandardAccountExample
;
import
pwc.taxtech.atms.entitiy.TemplateGroupExample
;
import
pwc.taxtech.atms.service.impl.DistributedIDService
;
@WebAppConfiguration
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath:applicationContext.xml"
})
public
abstract
class
CommonIT
{
...
...
@@ -131,6 +93,8 @@ public abstract class CommonIT {
@Autowired
protected
TemplateGroupMapper
templateGroupMapper
;
@Autowired
protected
TemplateMapper
templateMapper
;
@Autowired
protected
ServiceTypeMapper
serviceTypeMapper
;
@Autowired
protected
ProjectClientMapper
projectClientMapper
;
...
...
@@ -174,6 +138,18 @@ public abstract class CommonIT {
protected
OperationLogUserMapper
operationLogUserMapper
;
@Autowired
protected
OrganizationServiceTemplateGroupMapper
organizationServiceTemplateGroupMapper
;
@Autowired
protected
DistributedIDService
distributedIDService
;
@Autowired
protected
CellTemplateMapper
cellTemplateMapper
;
@Autowired
protected
CellTemplateConfigMapper
cellTemplateConfigMapper
;
@Autowired
protected
TaxPayerReportRuleMapper
taxPayerReportRuleMapper
;
@Autowired
protected
TaxRuleSettingOrganizationMapper
taxRuleSettingOrganizationMapper
;
@Autowired
protected
TaxRuleSettingMapper
taxRuleSettingMapper
;
protected
void
execSqlFile
(
String
sqlFilePath
)
{
...
...
atms-api/src/test/java/pwc/taxtech/atms/DataMigration.java
0 → 100644
View file @
adb71540
package
pwc
.
taxtech
.
atms
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
pwc.taxtech.atms.common.util.DateUtils
;
import
pwc.taxtech.atms.entitiy.*
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
DataMigration
extends
CommonIT
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
private
List
<
Map
<
String
,
Object
>>
template20180622List
;
private
List
<
Map
<
String
,
Object
>>
templateList
;
private
List
<
CellTemplate
>
cellTemplates
;
private
List
<
Map
<
String
,
Object
>>
cellTemplate20180622List
;
@Test
public
void
doMigrationTemplateGroup
()
{
String
sql
=
"Select * from TemplateGroup_20180622"
;
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM template_group"
;
jdbcTemplate
.
execute
(
sql
);
TemplateGroup
templateGroup
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
templateGroup
=
new
TemplateGroup
();
templateGroup
.
setId
(
distributedIDService
.
nextId
());
templateGroup
.
setName
((
MapUtils
.
getString
(
item
,
"Name"
)));
templateGroup
.
setServiceTypeId
((
MapUtils
.
getString
(
item
,
"ServiceTypeID"
)));
templateGroup
.
setIndustryIds
((
MapUtils
.
getString
(
item
,
"IndustryIDs"
)));
templateGroup
.
setPayTaxType
((
MapUtils
.
getInteger
(
item
,
"PayTaxType"
)
!=
null
?
MapUtils
.
getInteger
(
item
,
"PayTaxType"
)
:
0
));
templateGroup
.
setGroupType
((
MapUtils
.
getInteger
(
item
,
"GroupType"
)));
templateGroup
.
setCopyFrom
(
0L
);
templateGroup
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
templateGroup
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
templateGroup
.
setIsSystemType
((
MapUtils
.
getBoolean
(
item
,
"IsSystemType"
)));
templateGroup
.
setCreateBy
(
StringUtils
.
EMPTY
);
templateGroup
.
setUpdateBy
(
StringUtils
.
EMPTY
);
templateGroupMapper
.
insert
(
templateGroup
);
}
}
@Test
public
void
doMigrationTemplate
()
{
String
sql
=
"Select * from Template_20180622"
;
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM template"
;
jdbcTemplate
.
execute
(
sql
);
Template
template
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
template
=
new
Template
();
template
.
setId
(
distributedIDService
.
nextId
());
template
.
setName
(
MapUtils
.
getString
(
item
,
"Name"
));
template
.
setCode
(
MapUtils
.
getString
(
item
,
"Code"
)
!=
null
?
MapUtils
.
getString
(
item
,
"Code"
)
:
StringUtils
.
EMPTY
);
template
.
setPath
(
MapUtils
.
getString
(
item
,
"Path"
));
template
.
setReportType
(
MapUtils
.
getInteger
(
item
,
"ReportType"
)
!=
null
?
MapUtils
.
getInteger
(
item
,
"ReportType"
)
:
0
);
template
.
setOrderIndex
(
MapUtils
.
getInteger
(
item
,
"OrderIndex"
));
template
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
template
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
template
.
setIsSystemType
(
MapUtils
.
getBoolean
(
item
,
"IsSystemType"
));
template
.
setIsActiveAssociation
(
MapUtils
.
getBoolean
(
item
,
"IsActiveAssociation"
));
template
.
setParentId
(
MapUtils
.
getString
(
item
,
"ParentId"
)
!=
null
?
MapUtils
.
getString
(
item
,
"ParentId"
)
:
StringUtils
.
EMPTY
);
template
.
setCreateBy
(
StringUtils
.
EMPTY
);
template
.
setUpdateBy
(
StringUtils
.
EMPTY
);
template
.
setTemplateGroupId
(
getIdFromExistTable
(
MapUtils
.
getString
(
item
,
"TemplateGroupID"
)));
templateMapper
.
insert
(
template
);
}
}
/**
* 根据老表templategroupid获取新表id
*
* @param id 老表templategroupid
* @return 新表templategroupid
*/
private
Long
getIdFromExistTable
(
String
id
)
{
try
{
String
sql
=
"SELECT `Name`,UpdateTime from TemplateGroup_20180622 where id='"
+
id
+
"'"
;
Map
<
String
,
Object
>
result
=
jdbcTemplate
.
queryForMap
(
sql
);
String
name
=
MapUtils
.
getString
(
result
,
"Name"
);
String
updateTime
=
MapUtils
.
getString
(
result
,
"UpdateTime"
);
sql
=
"SELECT id from template_group a WHERE a.update_time='"
+
updateTime
+
"' AND `name`='"
+
name
+
"'"
;
result
=
jdbcTemplate
.
queryForMap
(
sql
);
return
MapUtils
.
getLong
(
result
,
"id"
);
}
catch
(
Exception
e
)
{
return
0L
;
}
}
//todo:cell_template --220081
@Test
public
void
doMigrationCellTemplate
()
{
String
sql
=
"Select * from CellTemplate_20180622"
;
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
System
.
out
.
println
(
sql
);
sql
=
"DELETE FROM cell_template"
;
System
.
out
.
println
(
sql
);
jdbcTemplate
.
execute
(
sql
);
CellTemplate
cellTemplate
;
cellTemplates
=
new
ArrayList
<>();
List
<
CellTemplate
>
cellTemplateList
=
new
ArrayList
<>();
sql
=
"SELECT ID,`Name`,Code,CreateTime from Template_20180622"
;
template20180622List
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"SELECT id,`name`,code,create_time from template"
;
templateList
=
jdbcTemplate
.
queryForList
(
sql
);
int
i
=
0
,
j
=
0
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
i
++;
j
++;
cellTemplate
=
new
CellTemplate
();
cellTemplate
.
setId
(
distributedIDService
.
nextId
());
cellTemplate
.
setReportTemplateId
(
getIdFromExistTable2
(
MapUtils
.
getString
(
item
,
"ReportTemplateID"
)));
cellTemplate
.
setRowIndex
(
MapUtils
.
getInteger
(
item
,
"RowIndex"
));
cellTemplate
.
setRowName
(
MapUtils
.
getString
(
item
,
"RowName"
)
!=
null
?
MapUtils
.
getString
(
item
,
"RowName"
)
:
""
);
cellTemplate
.
setColumnIndex
(
MapUtils
.
getInteger
(
item
,
"ColumnIndex"
));
cellTemplate
.
setColumnName
(
MapUtils
.
getString
(
item
,
"ColumnName"
)
!=
null
?
MapUtils
.
getString
(
item
,
"ColumnName"
)
:
""
);
cellTemplate
.
setComment
(
MapUtils
.
getString
(
item
,
"Comment"
)
!=
null
?
MapUtils
.
getString
(
item
,
"Comment"
)
:
""
);
cellTemplate
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
cellTemplate
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
cellTemplate
.
setCopyFromId
(
0L
);
cellTemplate
.
setDataType
(
MapUtils
.
getInteger
(
item
,
"DataType"
)
!=
null
?
MapUtils
.
getInteger
(
item
,
"DataType"
)
:
0
);
cellTemplate
.
setIsReadOnly
(
MapUtils
.
getBoolean
(
item
,
"IsReadOnly"
)
!=
null
?
MapUtils
.
getBoolean
(
item
,
"IsReadOnly"
)
:
true
);
cellTemplate
.
setUpdateBy
(
StringUtils
.
EMPTY
);
cellTemplate
.
setCreateBy
(
StringUtils
.
EMPTY
);
// cellTemplateMapper.insert(cellTemplate);
cellTemplateList
.
add
(
cellTemplate
);
System
.
out
.
println
(
"i="
+
i
);
System
.
out
.
println
(
"j="
+
j
);
if
(
i
==
1000
&&
j
<
queryForList
.
size
())
{
cellTemplateMapper
.
batchInsert2
(
cellTemplateList
);
cellTemplateList
.
clear
();
i
=
0
;
}
else
{
if
(
j
==
queryForList
.
size
())
{
cellTemplateMapper
.
batchInsert2
(
cellTemplateList
);
cellTemplateList
.
clear
();
}
}
}
//handleList(queryForList, 2);
}
/**
* 根据template老表ID获取新表ID
*
* @param id template老表ID
* @return
*/
private
Long
getIdFromExistTable2
(
String
id
)
{
try
{
// String sql = "SELECT `Name`,Code,CreateTime from Template_20180622 where id='" + id + "'";
// System.out.println(sql);
Map
<
String
,
Object
>
item
=
template20180622List
.
stream
()
.
filter
(
a
->
MapUtils
.
getString
(
a
,
"ID"
).
equals
(
id
))
.
findFirst
().
get
();
//Map<String, Object> result = jdbcTemplate.queryForMap(sql);
String
name
=
MapUtils
.
getString
(
item
,
"Name"
);
String
code
=
MapUtils
.
getString
(
item
,
"Code"
);
String
createTime
=
MapUtils
.
getString
(
item
,
"CreateTime"
);
//template20180622List.remove(item);
item
=
templateList
.
stream
()
.
filter
(
a
->
MapUtils
.
getString
(
a
,
"name"
).
equals
(
name
)
&&
MapUtils
.
getString
(
a
,
"code"
).
equals
(
code
)
&&
MapUtils
.
getString
(
a
,
"create_time"
).
equals
(
createTime
))
.
findFirst
().
get
();
//sql = "SELECT id from template a WHERE create_time='" + createTime + "' AND `name`='" + name + "' AND code='" + code + "'";
//System.out.println(sql);
//result = jdbcTemplate.queryForMap(sql);
Long
newId
=
MapUtils
.
getLong
(
item
,
"id"
);
//templateList.remove(item);
return
newId
;
}
catch
(
Exception
e
)
{
return
0L
;
}
finally
{
}
}
/**
* 多线程处理list
*
* @param data 数据list
* @param threadNum 线程数
*/
public
synchronized
void
handleList
(
List
<
Map
<
String
,
Object
>>
data
,
int
threadNum
)
{
int
length
=
data
.
size
();
int
tl
=
length
%
threadNum
==
0
?
length
/
threadNum
:
(
length
/
threadNum
+
1
);
for
(
int
i
=
0
;
i
<
threadNum
;
i
++)
{
int
end
=
(
i
+
1
)
*
tl
;
HandleThread
thread
=
new
HandleThread
(
"线程["
+
(
i
+
1
)
+
"] "
,
data
,
i
*
tl
,
end
>
length
?
length
:
end
);
System
.
out
.
println
(
"线程["
+
(
i
+
1
)
+
"] started"
);
thread
.
start
();
}
}
class
HandleThread
extends
Thread
{
private
String
threadName
;
private
List
<
Map
<
String
,
Object
>>
data
;
private
int
start
;
private
int
end
;
public
HandleThread
(
String
threadName
,
List
<
Map
<
String
,
Object
>>
data
,
int
start
,
int
end
)
{
this
.
threadName
=
threadName
;
this
.
data
=
data
;
this
.
start
=
start
;
this
.
end
=
end
;
}
public
void
run
()
{
// TODO 这里处理数据
CellTemplate
cellTemplate
;
for
(
Map
<
String
,
Object
>
item
:
data
)
{
cellTemplate
=
new
CellTemplate
();
cellTemplate
.
setId
(
distributedIDService
.
nextId
());
//cellTemplate.setReportTemplateId(getIdFromExistTable2(MapUtils.getString(item, "ReportTemplateID")));
cellTemplate
.
setRowIndex
(
MapUtils
.
getInteger
(
item
,
"RowIndex"
));
cellTemplate
.
setRowName
(
MapUtils
.
getString
(
item
,
"RowName"
)
!=
null
?
MapUtils
.
getString
(
item
,
"RowName"
)
:
""
);
cellTemplate
.
setColumnIndex
(
MapUtils
.
getInteger
(
item
,
"ColumnIndex"
));
cellTemplate
.
setColumnName
(
MapUtils
.
getString
(
item
,
"ColumnName"
)
!=
null
?
MapUtils
.
getString
(
item
,
"ColumnName"
)
:
""
);
cellTemplate
.
setComment
(
MapUtils
.
getString
(
item
,
"Comment"
)
!=
null
?
MapUtils
.
getString
(
item
,
"Comment"
)
:
""
);
cellTemplate
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
cellTemplate
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
cellTemplate
.
setCopyFromId
(
0L
);
cellTemplate
.
setDataType
(
MapUtils
.
getInteger
(
item
,
"DataType"
)
!=
null
?
MapUtils
.
getInteger
(
item
,
"DataType"
)
:
0
);
cellTemplate
.
setIsReadOnly
(
MapUtils
.
getBoolean
(
item
,
"IsReadOnly"
)
!=
null
?
MapUtils
.
getBoolean
(
item
,
"IsReadOnly"
)
:
true
);
cellTemplate
.
setUpdateBy
(
StringUtils
.
EMPTY
);
cellTemplate
.
setCreateBy
(
StringUtils
.
EMPTY
);
synchronized
(
cellTemplates
)
{
cellTemplates
.
add
(
cellTemplate
);
}
if
(
cellTemplates
.
size
()
==
100
)
{
synchronized
(
cellTemplates
)
{
cellTemplateMapper
.
batchInsert2
(
cellTemplates
);
cellTemplates
.
clear
();
}
System
.
out
.
println
(
threadName
+
"处理了"
+
data
.
size
()
+
"条!"
);
}
//cellTemplateMapper.insert(cellTemplate);
}
synchronized
(
cellTemplates
)
{
cellTemplateMapper
.
batchInsert2
(
cellTemplates
);
cellTemplates
.
clear
();
}
System
.
out
.
println
(
threadName
+
"处理了"
+
data
.
size
()
+
"条!"
);
//doMigrationCellTemplate();
// List<String> subList = data.subList(start, end)/*.add("^&*")*/;
// System.out.println(threadName+"处理了"+subList.size()+"条!");
}
}
//todo:cell_template_config --76577
@Test
public
void
doMigrationCellTemplateConfig
()
{
String
sql
=
"Select * from CellTemplateConfig_20180622"
;
System
.
out
.
println
(
sql
);
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM cell_template_config"
;
System
.
out
.
println
(
sql
);
jdbcTemplate
.
execute
(
sql
);
sql
=
"SELECT ID,`Name`,Code,CreateTime from Template_20180622"
;
template20180622List
=
jdbcTemplate
.
queryForList
(
sql
);
List
<
Template
>
templateList
=
templateMapper
.
selectByExample
(
new
TemplateExample
());
List
<
CellTemplate
>
cellTemplateList
=
cellTemplateMapper
.
selectByExample
(
new
CellTemplateExample
());
sql
=
"SELECT ID,ReportTemplateID,RowIndex,ColumnIndex from CellTemplate_20180622"
;
cellTemplate20180622List
=
jdbcTemplate
.
queryForList
(
sql
);
List
<
CellTemplateConfig
>
cellTemplateConfigList
=
new
ArrayList
<>();
CellTemplateConfig
cellTemplateConfig
;
int
i
=
0
,
j
=
0
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
i
++;
j
++;
cellTemplateConfig
=
new
CellTemplateConfig
();
cellTemplateConfig
.
setId
(
distributedIDService
.
nextId
());
cellTemplateConfig
.
setCellTemplateId
(
getIdFromExistTable3
(
MapUtils
.
getString
(
item
,
"CellTemplateID"
),
MapUtils
.
getString
(
item
,
"ReportTemplateID"
)));
cellTemplateConfig
.
setReportTemplateId
(
getIdFromExistTable2
(
MapUtils
.
getString
(
item
,
"ReportTemplateID"
)));
cellTemplateConfig
.
setDataSourceType
(
MapUtils
.
getInteger
(
item
,
"DataSourceType"
));
cellTemplateConfig
.
setFormula
(
MapUtils
.
getString
(
item
,
"Formula"
));
cellTemplateConfig
.
setFormulaDescription
(
MapUtils
.
getString
(
item
,
"FormulaDescription"
));
cellTemplateConfig
.
setAccountCodes
(
MapUtils
.
getString
(
item
,
"AccountCodes"
));
cellTemplateConfig
.
setInvoiceType
(
MapUtils
.
getInteger
(
item
,
"InvoiceType"
));
cellTemplateConfig
.
setTaxRate
(
MapUtils
.
getString
(
item
,
"TaxRate"
));
cellTemplateConfig
.
setInvoiceAmountType
(
MapUtils
.
getInteger
(
item
,
"InvoiceAmountType"
));
cellTemplateConfig
.
setModelIds
(
MapUtils
.
getString
(
item
,
"ModelIDs"
));
cellTemplateConfig
.
setCreateBy
(
MapUtils
.
getString
(
item
,
"Creator"
));
cellTemplateConfig
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
cellTemplateConfig
.
setUpdateBy
(
MapUtils
.
getString
(
item
,
"Updater"
));
cellTemplateConfig
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
cellTemplateConfig
.
setInvoiceCategory
(
MapUtils
.
getString
(
item
,
"InvoiceCategory"
));
cellTemplateConfig
.
setFormulaDataSource
(
MapUtils
.
getString
(
item
,
"FormulaDataSource"
));
cellTemplateConfig
.
setValidation
(
MapUtils
.
getString
(
item
,
"Validation"
));
cellTemplateConfig
.
setValidationDescription
(
MapUtils
.
getString
(
item
,
"ValidationDescription"
));
cellTemplateConfig
.
setVoucherKeyword
(
MapUtils
.
getString
(
item
,
"VoucherKeyword"
));
System
.
out
.
println
(
"i="
+
i
);
System
.
out
.
println
(
"j="
+
j
);
cellTemplateConfigList
.
add
(
cellTemplateConfig
);
if
(
i
==
1000
&&
j
<
queryForList
.
size
())
{
//cellTemplateConfigMapper.batchInsert2(cellTemplateConfigList);
cellTemplateConfigList
.
clear
();
i
=
0
;
}
else
{
if
(
j
==
queryForList
.
size
())
{
//cellTemplateConfigMapper.batchInsert2(cellTemplateConfigList);
cellTemplateConfigList
.
clear
();
}
}
}
}
/**
* 根据templateid 和 celltemplateid 获取新表cellTemplate ID
*
* @param id celltemplateid
* @param id2 templateid
* @return
*/
private
Long
getIdFromExistTable3
(
String
id
,
String
id2
)
{
try
{
//根据templateid 获取 新表 templateid
Long
templateId
=
getIdFromExistTable2
(
id2
);
//根据新表templateid 还有 rowIndex,columnIndex 获取 celltemplate 新表ID
Map
<
String
,
Object
>
item
=
cellTemplate20180622List
.
stream
()
.
filter
(
a
->
MapUtils
.
getString
(
a
,
"ID"
).
equals
(
id
))
.
findFirst
().
get
();
Integer
rowIndex
=
MapUtils
.
getInteger
(
item
,
"RowIndex"
);
Integer
columnIndex
=
MapUtils
.
getInteger
(
item
,
"ColumnIndex"
);
CellTemplate
cellTemplate
=
cellTemplates
.
stream
()
.
filter
(
a
->
a
.
getReportTemplateId
().
equals
(
templateId
)
&&
a
.
getRowIndex
().
equals
(
rowIndex
)
&&
a
.
getColumnIndex
().
equals
(
columnIndex
))
.
findFirst
().
get
();
return
cellTemplate
.
getId
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
0L
;
}
}
//todo:organization_service_template_group --284
@Test
public
void
doMigrationOrganizationServiceTemplateGroup
()
{
String
sql
=
"Select * from OrganizationServiceTemplateGroup"
;
System
.
out
.
println
(
sql
);
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM organization_service_template_group"
;
System
.
out
.
println
(
sql
);
jdbcTemplate
.
execute
(
sql
);
OrganizationServiceTemplateGroup
organizationServiceTemplateGroup
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
organizationServiceTemplateGroup
=
new
OrganizationServiceTemplateGroup
();
organizationServiceTemplateGroup
.
setId
(
distributedIDService
.
nextId
());
organizationServiceTemplateGroup
.
setTemplateGroupId
(
getIdFromExistTable
(
MapUtils
.
getString
(
item
,
"TemplateGroupID"
)));
organizationServiceTemplateGroup
.
setOrganizationId
(
MapUtils
.
getString
(
item
,
"OrganizationID"
));
organizationServiceTemplateGroup
.
setServiceTypeId
(
MapUtils
.
getString
(
item
,
"ServiceTypeID"
));
organizationServiceTemplateGroupMapper
.
insert
(
organizationServiceTemplateGroup
);
}
}
//todo:tax_payer_report_rule --120
@Test
public
void
doMigrationTaxPayerReportRule
()
{
String
sql
=
"Select * from TaxPayerReportRule_20180622"
;
System
.
out
.
println
(
sql
);
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM tax_payer_report_rule"
;
System
.
out
.
println
(
sql
);
jdbcTemplate
.
execute
(
sql
);
TaxPayerReportRule
taxPayerReportRule
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
taxPayerReportRule
=
new
TaxPayerReportRule
();
taxPayerReportRule
.
setId
(
distributedIDService
.
nextId
());
taxPayerReportRule
.
setTemplateGroupId
(
getIdFromExistTable
(
MapUtils
.
getString
(
item
,
"TemplateGroupID"
)));
taxPayerReportRule
.
setOrganizationId
(
MapUtils
.
getString
(
item
,
"OrganizationID"
));
taxPayerReportRule
.
setTaxPayerType
(
MapUtils
.
getInteger
(
item
,
"TaxPayerType"
));
taxPayerReportRule
.
setIsDefault
(
MapUtils
.
getBoolean
(
item
,
"IsDefault"
));
taxPayerReportRule
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
taxPayerReportRule
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
taxPayerReportRule
.
setCreateBy
(
StringUtils
.
EMPTY
);
taxPayerReportRule
.
setUpdateBy
(
StringUtils
.
EMPTY
);
taxPayerReportRuleMapper
.
insert
(
taxPayerReportRule
);
}
}
//todo:tax_rule_setting --13
@Test
public
void
doMigrationTaxRuleSetting
()
{
String
sql
=
"Select * from TaxRuleSetting_20180622"
;
System
.
out
.
println
(
sql
);
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM tax_rule_setting"
;
System
.
out
.
println
(
sql
);
jdbcTemplate
.
execute
(
sql
);
TaxRuleSetting
taxRuleSetting
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
taxRuleSetting
=
new
TaxRuleSetting
();
taxRuleSetting
.
setId
(
distributedIDService
.
nextId
());
taxRuleSetting
.
setTaxBase
(
MapUtils
.
getString
(
item
,
"TaxBase"
));
taxRuleSetting
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
taxRuleSetting
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
taxRuleSetting
.
setGroupName
(
MapUtils
.
getString
(
item
,
"GroupName"
));
taxRuleSetting
.
setName
(
MapUtils
.
getString
(
item
,
"Name"
));
taxRuleSetting
.
setIsDefault
(
MapUtils
.
getBoolean
(
item
,
"IsDefault"
));
taxRuleSetting
.
setTaxRate
(
new
BigDecimal
(
MapUtils
.
getFloat
(
item
,
"TaxRate"
)));
taxRuleSetting
.
setCreateBy
(
StringUtils
.
EMPTY
);
taxRuleSetting
.
setUpdateBy
(
StringUtils
.
EMPTY
);
taxRuleSettingMapper
.
insert
(
taxRuleSetting
);
}
}
private
List
<
Map
<
String
,
Object
>>
taxRuleSetting20180622List
;
private
List
<
TaxRuleSetting
>
taxRuleSettingList
;
//todo:tax_rule_setting_organization --17
@Test
public
void
doMigrationTaxRuleSettingOrganization
()
{
String
sql
=
"Select * from TaxRuleSettingOrganization_20180622"
;
System
.
out
.
println
(
sql
);
List
<
Map
<
String
,
Object
>>
queryForList
=
jdbcTemplate
.
queryForList
(
sql
);
sql
=
"DELETE FROM tax_rule_setting_organization"
;
System
.
out
.
println
(
sql
);
jdbcTemplate
.
execute
(
sql
);
sql
=
"SELECT ID,CreateTime FROM TaxRuleSetting_20180622"
;
taxRuleSetting20180622List
=
jdbcTemplate
.
queryForList
(
sql
);
taxRuleSettingList
=
taxRuleSettingMapper
.
selectByExample
(
new
TaxRuleSettingExample
());
TaxRuleSettingOrganization
taxRuleSettingOrganization
;
for
(
Map
<
String
,
Object
>
item
:
queryForList
)
{
taxRuleSettingOrganization
=
new
TaxRuleSettingOrganization
();
taxRuleSettingOrganization
.
setId
(
distributedIDService
.
nextId
());
taxRuleSettingOrganization
.
setTaxSettingId
(
getIdFromExistTable4
(
MapUtils
.
getString
(
item
,
"TaxSettingID"
)));
taxRuleSettingOrganization
.
setOrganizationId
(
MapUtils
.
getString
(
item
,
"OrganizationID"
));
taxRuleSettingOrganization
.
setCreateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"CreateTime"
)));
taxRuleSettingOrganization
.
setUpdateTime
(
DateUtils
.
strToDateLong
(
MapUtils
.
getString
(
item
,
"UpdateTime"
)));
taxRuleSettingOrganization
.
setCreateBy
(
StringUtils
.
EMPTY
);
taxRuleSettingOrganization
.
setUpdateBy
(
StringUtils
.
EMPTY
);
taxRuleSettingOrganizationMapper
.
insert
(
taxRuleSettingOrganization
);
}
}
/**
* 获取taxSetting 新表ID
* @param id 旧表ID
* @return 新表ID
*/
private
Long
getIdFromExistTable4
(
String
id
){
try
{
Map
<
String
,
Object
>
item
=
taxRuleSetting20180622List
.
stream
()
.
filter
(
a
->
MapUtils
.
getString
(
a
,
"ID"
).
equals
(
id
))
.
findFirst
().
get
();
String
name
=
MapUtils
.
getString
(
item
,
"Name"
);
String
createTime
=
MapUtils
.
getString
(
item
,
"CreateTime"
);
TaxRuleSetting
taxRuleSetting
=
taxRuleSettingList
.
stream
()
.
filter
(
a
->
a
.
getName
().
equals
(
name
)
&&
a
.
getCreateTime
().
equals
(
createTime
))
.
findFirst
().
get
();
Long
newId
=
taxRuleSetting
.
getId
();
return
newId
;
}
catch
(
Exception
e
)
{
return
0L
;
}
finally
{
}
}
}
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