Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
80a28f85
Commit
80a28f85
authored
May 10, 2020
by
tangzhaoqian
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增自定义异常、faskjson配置更新、冗余java工具类删除
parent
1b1e55d3
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
444 additions
and
903 deletions
+444
-903
pom.xml
+6
-6
src/main/java/cn/timer/api/Application.java
+0
-26
src/main/java/cn/timer/api/bean/clazz/CommonArea.java
+53
-0
src/main/java/cn/timer/api/bean/spmk/SpmkApproveSummary.java
+3
-3
src/main/java/cn/timer/api/config/exception/CustomException.java
+44
-0
src/main/java/cn/timer/api/config/exception/GlobalExceptionHandler.java
+60
-0
src/main/java/cn/timer/api/config/interceptor/MyConfiguration.java
+42
-0
src/main/java/cn/timer/api/config/interceptor/WebSecurityConfig.java
+33
-5
src/main/java/cn/timer/api/controller/spmk/SpmkController.java
+8
-10
src/main/java/cn/timer/api/controller/yggl/YgglController.java
+21
-0
src/main/java/cn/timer/api/dao/clazz/CommonAreaMapper.java
+19
-0
src/main/java/cn/timer/api/dto/spmk/SpmkApproveSummaryDto.java
+0
-1
src/main/java/cn/timer/api/utils/ApiReturnObject.java
+0
-42
src/main/java/cn/timer/api/utils/ApiReturnUtil.java
+0
-50
src/main/java/cn/timer/api/utils/ExcelUtil.java
+0
-307
src/main/java/cn/timer/api/utils/ImportExcelUntil.java
+0
-171
src/main/java/cn/timer/api/utils/LevelPriceDateFromatUtils.java
+0
-68
src/main/java/cn/timer/api/utils/NumberedGeneration.java
+0
-49
src/main/java/cn/timer/api/utils/ResponseResultNew.java
+0
-126
src/main/java/cn/timer/api/utils/SerializationUtils.java
+2
-0
src/main/java/cn/timer/api/utils/router/RouterUtils.java
+5
-38
src/main/resources/mapping/clazz/CommonAreaMapper.xml
+133
-0
src/main/resources/mapping/spmk/SpmkApproveSummaryMapper.xml
+1
-1
src/main/resources/rebel.xml
+14
-0
No files found.
pom.xml
View file @
80a28f85
...
...
@@ -223,7 +223,7 @@
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.58
</version>
<version>
1.2.62
</version>
</dependency>
<dependency>
...
...
@@ -236,7 +236,7 @@
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
4.6.1
</version>
<version>
5.3.2
</version>
</dependency>
<!-- lombok -->
...
...
@@ -261,15 +261,15 @@
</dependency>
<!-- jackson -->
<dependency>
<
!-- <
dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
</dependency>
-->
<dependency>
<
!-- <
dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependency>
-->
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
src/main/java/cn/timer/api/Application.java
View file @
80a28f85
...
...
@@ -16,10 +16,6 @@ import org.springframework.web.cors.CorsConfiguration;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
import
cn.hutool.core.net.NetUtil
;
@MapperScan
(
"cn.timer.api.dao"
)
// 扫描的mapper
...
...
@@ -38,28 +34,6 @@ public class Application {
SpringApplication
.
run
(
Application
.
class
,
args
);
}
/**
* 配置FastJson方式二
*
* @return HttpMessageConverters
*/
@Bean
public
HttpMessageConverters
fastJsonHttpMessageConverters
()
{
// 1.定义一个converters转换消息的对象
FastJsonHttpMessageConverter
fastConverter
=
new
FastJsonHttpMessageConverter
();
// 2.添加fastjson的配置信息,比如: 是否需要格式化返回的json数据
FastJsonConfig
fastJsonConfig
=
new
FastJsonConfig
();
fastJsonConfig
.
setDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
fastJsonConfig
.
setSerializerFeatures
(
SerializerFeature
.
PrettyFormat
);
// 3.在converter中添加配置信息
fastConverter
.
setFastJsonConfig
(
fastJsonConfig
);
// 4.将converter赋值给HttpMessageConverter
HttpMessageConverter
<?>
converter
=
fastConverter
;
// 5.返回HttpMessageConverters对象
return
new
HttpMessageConverters
(
converter
);
}
// extends SpringBootServletInitializer
@Autowired
private
RestTemplateBuilder
restTemplateBuilder
;
...
...
src/main/java/cn/timer/api/bean/clazz/CommonArea.java
0 → 100644
View file @
80a28f85
package
cn
.
timer
.
api
.
bean
.
clazz
;
import
java.util.List
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author Tang 2020-05-09
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
"地区"
)
public
class
CommonArea
extends
Model
<
CommonArea
>
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
@TableId
(
type
=
IdType
.
AUTO
)
@ApiModelProperty
(
value
=
"编号"
,
example
=
"1"
)
private
Integer
codeId
;
@ApiModelProperty
(
value
=
"父编号"
,
example
=
"10"
)
private
Integer
parentId
;
@ApiModelProperty
(
value
=
"城市名称"
,
example
=
"1"
)
private
String
cityName
;
@ApiModelProperty
(
value
=
"下级"
,
example
=
"1"
)
private
List
<
CommonArea
>
commonAreas
;
}
\ No newline at end of file
src/main/java/cn/timer/api/bean/spmk/SpmkApproveSummary.java
View file @
80a28f85
...
...
@@ -88,11 +88,11 @@ public class SpmkApproveSummary extends Model<SpmkApproveSummary> {
private
String
digest
;
@ApiModelProperty
(
value
=
"岗位名称"
,
example
=
"
摘要
"
)
@ApiModelProperty
(
value
=
"岗位名称"
,
example
=
"
岗位名称
"
)
private
String
gwName
;
@ApiModelProperty
(
value
=
"
岗位名称"
,
example
=
"摘要
"
)
@ApiModelProperty
(
value
=
"
部门id"
,
example
=
"1
"
)
private
String
bmId
;
@ApiModelProperty
(
value
=
"
岗位名称"
,
example
=
"摘要
"
)
@ApiModelProperty
(
value
=
"
部门名称"
,
example
=
"部门名称
"
)
private
String
bmName
;
...
...
src/main/java/cn/timer/api/config/exception/CustomException.java
0 → 100644
View file @
80a28f85
package
cn
.
timer
.
api
.
config
.
exception
;
/**
* 自定义异常
*
* @author Tang
*/
public
class
CustomException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
code
;
private
String
message
;
public
CustomException
(
String
message
)
{
this
.
message
=
message
;
}
public
CustomException
(
String
message
,
String
code
)
{
this
.
message
=
message
;
this
.
code
=
code
;
}
public
CustomException
(
String
message
,
Throwable
e
)
{
super
(
message
,
e
);
this
.
message
=
message
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
String
getCode
()
{
return
code
;
}
}
src/main/java/cn/timer/api/config/exception/GlobalExceptionHandler.java
0 → 100644
View file @
80a28f85
package
cn
.
timer
.
api
.
config
.
exception
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
cn.hutool.core.util.StrUtil
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
/**
* 全局异常处理器
*
* @author Tang
*/
@RestControllerAdvice
// @ControllerAdvice + @ResponseBody 组合注解
public
class
GlobalExceptionHandler
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
@ExceptionHandler
(
Exception
.
class
)
public
Result
<
Object
>
handleException
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
ResultUtil
.
error
(
e
.
getMessage
());
}
/**
* 空指针异常
* @param e
* @return
*/
@ExceptionHandler
(
NullPointerException
.
class
)
public
Result
<
Object
>
nullPointerException
(
NullPointerException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
ResultUtil
.
error
(
e
.
getMessage
());
}
/**
* 类型强制转换异常
* @param e
* @return
*/
@ExceptionHandler
(
ClassCastException
.
class
)
public
Result
<
Object
>
classCastException
(
ClassCastException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
ResultUtil
.
error
(
e
.
getMessage
());
}
/**
* 业务异常
*/
@ExceptionHandler
(
CustomException
.
class
)
public
Result
<
Object
>
businessException
(
CustomException
e
)
{
if
(
StrUtil
.
isBlank
(
e
.
getCode
()))
{
return
ResultUtil
.
error
(
e
.
getMessage
());
}
return
ResultUtil
.
error
(
e
.
getCode
(),
e
.
getMessage
());
}
}
src/main/java/cn/timer/api/config/interceptor/MyConfiguration.java
0 → 100644
View file @
80a28f85
package
cn
.
timer
.
api
.
config
.
interceptor
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
import
org.springframework.boot.autoconfigure.http.HttpMessageConverters
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.List
;
@Configuration
public
class
MyConfiguration
{
@Bean
public
HttpMessageConverters
customConverters
()
{
FastJsonHttpMessageConverter
fastConverter
=
new
FastJsonHttpMessageConverter
();
// 创建配置类
FastJsonConfig
config
=
new
FastJsonConfig
();
config
.
setSerializerFeatures
(
SerializerFeature
.
WriteNullListAsEmpty
,
SerializerFeature
.
WriteMapNullValue
,
SerializerFeature
.
WriteNullStringAsEmpty
);
//此处是全局处理方式
config
.
setDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
config
.
setCharset
(
Charset
.
forName
(
"UTF-8"
));
fastConverter
.
setFastJsonConfig
(
config
);
List
<
MediaType
>
supportedMediaTypes
=
new
ArrayList
<>();
supportedMediaTypes
.
add
(
MediaType
.
ALL
);
fastConverter
.
setSupportedMediaTypes
(
supportedMediaTypes
);
//支持text 转string
StringHttpMessageConverter
stringHttpMessageConverter
=
new
StringHttpMessageConverter
();
return
new
HttpMessageConverters
(
fastConverter
,
stringHttpMessageConverter
);
}
}
src/main/java/cn/timer/api/config/interceptor/WebSecurityConfig.java
View file @
80a28f85
package
cn
.
timer
.
api
.
config
.
interceptor
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
javax.annotation.Resource
;
...
...
@@ -9,11 +11,13 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.serializer.ValueFilter
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
...
...
@@ -51,8 +55,21 @@ public class WebSecurityConfig implements WebMvcConfigurer {
// registry.addInterceptor(getSessionInterceptor()).addPathPatterns("/**").excludePathPatterns("/swagger-ui*");
}
/**
* 配置消息转换器--这里我用的是alibaba 开源的 fastjson
* @param converters
*/
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
// Iterator<HttpMessageConverter<?>> iterator = converters.iterator();
// while(iterator.hasNext()){
// HttpMessageConverter<?> converter = iterator.next();
// if(converter instanceof MappingJackson2HttpMessageConverter){
// iterator.remove();
// }
// }
// 1.需要先定义一个convert 转换消息的对象
FastJsonHttpMessageConverter
fastConverter
=
new
FastJsonHttpMessageConverter
();
// 2.添加fastJson的配置信息,比如,是否需要格式化返回的json数据
...
...
@@ -66,10 +83,21 @@ public class WebSecurityConfig implements WebMvcConfigurer {
// WriteNullNumberAsZero 将数值类型字段的空值输出为0
// WriteNullBooleanAsFalse 将Boolean类型字段的空值输出为false
fastJsonConfig
.
setSerializerFeatures
(
SerializerFeature
.
PrettyFormat
,
SerializerFeature
.
WriteMapNullValue
,
SerializerFeature
.
WriteDateUseDateFormat
,
SerializerFeature
.
WriteNullStringAsEmpty
);
SerializerFeature
.
PrettyFormat
// SerializerFeature.WriteEnumUsingToString,
// SerializerFeature.WriteNullStringAsEmpty,
// SerializerFeature.WriteMapNullValue,
// SerializerFeature.WriteDateUseDateFormat
);
// fastJsonConfig.setSerializeFilters((ValueFilter) (o, s, source) -> {
// if (source == null) {
// return "";//此处是关键,如果返回对象的变量为null,则自动变成""
// }
// if (source instanceof Date) {
// return ((Date) source).getTime();
// }
// return source;
// });
// 处理中文乱码问题
List
<
MediaType
>
fastMediaTypes
=
new
ArrayList
<>();
fastMediaTypes
.
add
(
MediaType
.
APPLICATION_JSON_UTF8
);
...
...
@@ -77,7 +105,7 @@ public class WebSecurityConfig implements WebMvcConfigurer {
// 3.在convert中添加配置信息
fastConverter
.
setFastJsonConfig
(
fastJsonConfig
);
// 4.将convert添加到converters当中
converters
.
add
(
fastConverter
);
converters
.
add
(
0
,
fastConverter
);
}
...
...
src/main/java/cn/timer/api/controller/spmk/SpmkController.java
View file @
80a28f85
...
...
@@ -43,6 +43,7 @@ import cn.timer.api.bean.spmk.SpmkInitiatorConfig;
import
cn.timer.api.bean.yggl.YgglMainEmp
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.config.exception.CustomException
;
import
cn.timer.api.controller.spmk.service.SpmkServiceImpl
;
import
cn.timer.api.controller.zzgl.service.ZzglBmgwMService
;
import
cn.timer.api.dao.spmk.SpmkApprovalGMapper
;
...
...
@@ -450,7 +451,7 @@ public class SpmkController {
.
currentApprover
(
currentApprover
).
build
();
if
(!
as
.
insert
())
{
return
ResultUtil
.
error
(
"操作失败!
"
);
throw
new
CustomException
(
"审批汇总-新增异常
"
);
}
// 插入记录
...
...
@@ -466,7 +467,7 @@ public class SpmkController {
ad
.
setFlowChildren
(
ObjectUtil
.
serialize
(
listFlowChildren
));
if
(!
ad
.
insert
())
throw
new
Exception
(
);
throw
new
CustomException
(
"审批详情-新增异常"
);
return
ResultUtil
.
success
(
"操作成功!"
);
...
...
@@ -477,6 +478,7 @@ public class SpmkController {
* 审批汇总
* @param summaryQueryDto
* @return
* @throws
*/
@PostMapping
(
value
=
"/select_approve_summary"
)
@ApiOperation
(
value
=
"18.审批汇总"
,
httpMethod
=
"POST"
,
notes
=
"审批汇总"
)
...
...
@@ -544,8 +546,7 @@ public class SpmkController {
@ApiOperationSupport
(
order
=
20
)
// @BindingResultCtrol(title = "审批人审批")
public
Result
<
Object
>
approving
(
@Valid
@RequestBody
ApprovingDto
approvingDto
,
BindingResult
bindingResult
)
throws
Exception
{
SpmkApproveDetail
ad
=
SpmkApproveDetail
.
builder
().
build
()
.
selectOne
(
new
QueryWrapper
<
SpmkApproveDetail
>()
SpmkApproveDetail
ad
=
SpmkApproveDetail
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SpmkApproveDetail
>()
.
lambda
()
.
select
(
SpmkApproveDetail:
:
getId
,
SpmkApproveDetail:
:
getRequestData
,
...
...
@@ -594,9 +595,6 @@ public class SpmkController {
if
(
aSummary
.
getSts
()
!=
3
)
{
SpmkApproveSummary
.
builder
().
id
(
approvingDto
.
getAsId
()).
endTime
(
new
Date
()).
sts
(
2
).
build
().
updateById
();
//审批完成后 业务
SpmkAssoBusiness
sab
=
SpmkAssoBusinessFactory
.
createSpmkAssoType
(
ApproveEnum
.
getEnums
(
aSummary
.
getAssoType
()));
if
(
sab
!=
null
)
...
...
@@ -661,7 +659,7 @@ public class SpmkController {
.
lambda
()
.
select
(
SpmkApproveExecuteRecord:
:
getId
)
.
eq
(
SpmkApproveExecuteRecord:
:
getApproveSummaryId
,
id
));
if
(
listAer
!=
null
)
{
if
(
listAer
!=
null
&&
listAer
.
size
()
>
0
)
{
for
(
SpmkApproveExecuteRecord
aer
:
listAer
)
{
spmkExecutorMapper
.
delete
(
new
QueryWrapper
<
SpmkExecutor
>().
lambda
().
eq
(
SpmkExecutor:
:
getApproveExecuteRecordId
,
aer
.
getId
()));
}
...
...
@@ -680,7 +678,7 @@ public class SpmkController {
* 删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据
*/
@DeleteMapping
(
value
=
"/delete_approval_data"
)
@ApiOperation
(
value
=
"90.(开发使用)删除-审批数据"
,
httpMethod
=
"DELETE"
,
notes
=
"审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据"
)
@ApiOperation
(
value
=
"90.(开发使用)删除-审批数据"
,
httpMethod
=
"DELETE"
,
notes
=
"审批
组、自定义审批、审批
汇总、审批详情、审批执行记录、审批执行人记录 所有数据"
)
@ApiOperationSupport
(
order
=
90
)
public
Result
<
Object
>
deleteApprovalData
(
@CurrentUser
UserBean
userBean
){
...
...
@@ -690,7 +688,7 @@ public class SpmkController {
spmkApproveDetailMapper
.
delete
(
null
);
spmkApproveExecuteRecordMapper
.
delete
(
null
);
spmkExecutorMapper
.
delete
(
null
);
System
.
out
.
println
(
"删除-审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据 完成!"
);
System
.
out
.
println
(
"删除-审批
组、自定义审批、审批
汇总、审批详情、审批执行记录、审批执行人记录 所有数据 完成!"
);
return
ResultUtil
.
data
(
null
,
"操作成功!"
);
}
...
...
src/main/java/cn/timer/api/controller/yggl/YgglController.java
View file @
80a28f85
...
...
@@ -49,6 +49,7 @@ import cn.hutool.core.collection.ListUtil;
import
cn.hutool.core.date.BetweenFormater.Level
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.timer.api.bean.clazz.CommonArea
;
import
cn.timer.api.bean.qyzx.QyzxEmpEntAsso
;
import
cn.timer.api.bean.qyzx.QyzxEmpLogin
;
import
cn.timer.api.bean.yggl.YgglAttaClfjb
;
...
...
@@ -71,6 +72,7 @@ import cn.timer.api.config.annotation.UserBean;
import
cn.timer.api.config.enuminterface.YgEnumInterface
;
import
cn.timer.api.config.enums.CommonEnum
;
import
cn.timer.api.controller.yggl.service.YgglService
;
import
cn.timer.api.dao.clazz.CommonAreaMapper
;
import
cn.timer.api.dao.qyzx.QyzxEmpLoginMapper
;
import
cn.timer.api.dao.yggl.YgAreaDtoMapper
;
import
cn.timer.api.dao.yggl.YgCityDtoMapper
;
...
...
@@ -1662,6 +1664,25 @@ public class YgglController {
return
ResultUtil
.
data
(
mz
,
"展示该民族"
);
}
@Autowired
CommonAreaMapper
commonAreaMapper
;
/**
* 籍贯树-Mini
*
* @param
* @return
*/
@GetMapping
(
value
=
"/native_place"
)
@ApiOperation
(
value
=
"籍贯树-Mini"
,
httpMethod
=
"GET"
,
notes
=
"籍贯树-Mini"
)
@ApiOperationSupport
(
order
=
60
)
public
Result
<
List
<
CommonArea
>>
selectNativePlace
()
{
List
<
CommonArea
>
listCommonArea
=
commonAreaMapper
.
AllAreaForTree
();
return
ResultUtil
.
data
(
listCommonArea
,
"操作成功!"
);
}
/**
* 展示籍贯/展示所有籍贯
*
...
...
src/main/java/cn/timer/api/dao/clazz/CommonAreaMapper.java
0 → 100644
View file @
80a28f85
package
cn
.
timer
.
api
.
dao
.
clazz
;
import
java.util.List
;
import
org.springframework.stereotype.Repository
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.timer.api.bean.clazz.CommonArea
;
/**
* 地区
* @author Tang 2020-05-09
*/
@Repository
public
interface
CommonAreaMapper
extends
BaseMapper
<
CommonArea
>
{
List
<
CommonArea
>
AllAreaForTree
();
}
src/main/java/cn/timer/api/dto/spmk/SpmkApproveSummaryDto.java
View file @
80a28f85
...
...
@@ -31,7 +31,6 @@ public class SpmkApproveSummaryDto{
@ApiModelProperty
(
value
=
"审批名称 "
,
example
=
"审批名称"
,
required
=
true
)
private
String
approveName
;
@NotBlank
(
message
=
"digest为空"
)
@ApiModelProperty
(
value
=
"摘要"
,
example
=
"摘要"
,
required
=
true
)
private
String
digest
;
...
...
src/main/java/cn/timer/api/utils/ApiReturnObject.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.io.Serializable
;
import
lombok.Data
;
@Data
public
class
ApiReturnObject
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
ApiReturnObject
(
String
errorCode
,
Object
errorMessage
,
Object
returnObject
)
{
super
();
this
.
errorCode
=
errorCode
;
this
.
errorMessage
=
errorMessage
;
this
.
returnObject
=
returnObject
;
}
public
ApiReturnObject
(
Object
errorMessage
,
Object
returnObject
)
{
super
();
this
.
errorMessage
=
errorMessage
;
this
.
returnObject
=
returnObject
;
}
String
errorCode
=
"00"
;
Object
errorMessage
;
Object
returnObject
;
String
pageNumber
;
String
pageSize
;
String
totalElements
;
String
totalPages
;
public
ApiReturnObject
(
String
pageNumber
,
String
pageSize
,
String
totalElements
,
String
totalPages
,
String
errorCode
,
Object
errorMessage
,
Object
returnObject
)
{
super
();
this
.
pageNumber
=
pageNumber
;
this
.
errorCode
=
errorCode
;
this
.
errorMessage
=
errorMessage
;
this
.
returnObject
=
returnObject
;
this
.
pageSize
=
pageSize
;
this
.
totalElements
=
totalElements
;
this
.
totalPages
=
totalPages
;
}
}
src/main/java/cn/timer/api/utils/ApiReturnUtil.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ApiReturnUtil
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
static
ApiReturnObject
error
(
Object
errorMessage
)
{
System
.
out
.
println
(
errorMessage
);
List
<
Object
>
object
=
new
ArrayList
<
Object
>();
return
new
ApiReturnObject
(
"01"
,
errorMessage
,
object
);
}
public
static
ApiReturnObject
error
(
Object
errorMessage
,
Object
returnObject
)
{
List
<
Object
>
object
=
new
ArrayList
<
Object
>();
object
.
add
(
returnObject
);
return
new
ApiReturnObject
(
"01"
,
errorMessage
,
object
);
}
public
static
ApiReturnObject
success
(
Object
returnObject
)
{
if
(
returnObject
instanceof
java
.
util
.
List
){
return
new
ApiReturnObject
(
"00"
,
"success"
,
returnObject
);
}
else
{
List
<
Object
>
object
=
new
ArrayList
<
Object
>();
object
.
add
(
returnObject
);
return
new
ApiReturnObject
(
"00"
,
"success"
,
object
);
}
}
public
static
ApiReturnObject
success
(
Object
errorMessage
,
Object
returnObject
)
{
if
(
returnObject
instanceof
java
.
util
.
List
){
return
new
ApiReturnObject
(
"00"
,
errorMessage
,
returnObject
);
}
else
{
List
<
Object
>
object
=
new
ArrayList
<
Object
>();
object
.
add
(
returnObject
);
return
new
ApiReturnObject
(
"00"
,
errorMessage
,
object
);
}
}
public
static
ApiReturnObject
pageManual
(
Integer
pageNumber
,
Integer
pageSize
,
Integer
countNum
,
List
<
Void
>
returnObject
)
{
return
new
ApiReturnObject
(
pageNumber
+
""
,
pageSize
+
""
,
countNum
+
""
,
getTotalPages
(
countNum
,
pageSize
),
"00"
,
"success"
,
returnObject
);
}
public
static
String
getTotalPages
(
Integer
countNum
,
Integer
pageSize
)
{
if
((
countNum
%
pageSize
)==
0
)
{
return
((
countNum
/
pageSize
))+
""
;
}
else
{
return
((
countNum
/
pageSize
)+
1
)+
""
;
}
}
}
src/main/java/cn/timer/api/utils/ExcelUtil.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.poi.hssf.usermodel.HSSFCell
;
import
org.apache.poi.hssf.usermodel.HSSFCellStyle
;
import
org.apache.poi.hssf.usermodel.HSSFDataFormat
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.hssf.usermodel.HSSFRow
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.poifs.filesystem.POIFSFileSystem
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.springframework.web.multipart.MultipartFile
;
public
class
ExcelUtil
<
T
>
{
/**
* HSSFWorkbook excel 的文档对象 HSSFSheet excel 的表单 HSSFRow excel 的行 HSSFCell excel
* 的格子单元
*/
/**
* 导出xls文件
*
* @param title sheet标题
* @param headers 第一行标题
* @param dataset 集合数据/表单内容
* @param out
* @param pattern
*/
public
void
exportExcel
(
String
title
,
String
[]
headers
,
Collection
<
T
>
dataset
,
OutputStream
out
,
String
pattern
)
{
// 创建工作簿
// SXSSFWorkbook workbook = new SXSSFWorkbook(1000);
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
// 创建SHEET页/表格页,title-表格标题
HSSFSheet
sheet
=
(
HSSFSheet
)
workbook
.
createSheet
(
title
);
// 设置表格默认列宽度为15个字节
sheet
.
setDefaultColumnWidth
((
short
)
15
);
// 创建行,从0开始
HSSFRow
row
=
(
HSSFRow
)
sheet
.
createRow
(
0
);
// 创建单元格样式对象(设置样式)
HSSFCellStyle
ztStyle
=
workbook
.
createCellStyle
();
// 创建字体对象
ztStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
// 水平居中
ztStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 垂直居中
ztStyle
.
setFillForegroundColor
((
short
)
42
);
// 前景填充色
// ztStyle.setFillForegroundColor(IndexedColors.YELLOW.index);//前景填充色-黄色
ztStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
// 设置前景填充样式
// 边框
ztStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
// 下边框
ztStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
// 左边框
ztStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
// 右边框
ztStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
// 上边框
HSSFCellStyle
namestyle
=
workbook
.
createCellStyle
();
namestyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
// 水平居中
namestyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 垂直居中
namestyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
// 下边框
namestyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
// 左边框
namestyle
.
setBorderRight
(
BorderStyle
.
THIN
);
// 右边框
namestyle
.
setBorderTop
(
BorderStyle
.
THIN
);
// 上边框
for
(
short
i
=
0
;
i
<
headers
.
length
;
i
++)
{
// 创建单元格
HSSFCell
cell
=
row
.
createCell
(
i
);
row
.
setHeightInPoints
(
30
);
// 设置行高
sheet
.
createFreezePane
(
0
,
1
);
// 冻结第1行
cell
.
setCellValue
(
headers
[
i
]);
// 设置每一列的值
cell
.
setCellStyle
(
ztStyle
);
// 样式应用到该单元格上
/**
* 四个参数的含义:
*
* a表示要冻结的列数;
*
* b表示要冻结的行数;
*
* c表示右边区域[可见]的首列序号;
*
* d表示下边区域[可见]的首行序号;
*/
// sheet.createFreezePane(a,b,c,d);
}
// 遍历集合数据,产生数据行
Iterator
<
T
>
it
=
dataset
.
iterator
();
int
index
=
0
;
while
(
it
.
hasNext
())
{
index
++;
row
=
sheet
.
createRow
(
index
);
// 创建第 index 行
T
t
=
it
.
next
();
// 利用反射,根据javabean属性的先后顺序,动态调用getXxx()方法得到属性值
Field
[]
fields
=
t
.
getClass
().
getDeclaredFields
();
for
(
short
i
=
0
;
i
<
fields
.
length
;
i
++)
{
HSSFCell
cell
=
row
.
createCell
(
i
);
Field
field
=
fields
[
i
];
String
fieldName
=
field
.
getName
();
// 动态拼接getXxx获取属性值方法 如:TUserLand类 loginname 动态获取 -》 getLoginname 这个方法名
String
getMethodName
=
"get"
+
fieldName
.
substring
(
0
,
1
).
toUpperCase
()
+
fieldName
.
substring
(
1
);
try
{
Class
<?
extends
Object
>
tclass
=
t
.
getClass
();
Method
getMethod
=
tclass
.
getMethod
(
getMethodName
,
new
Class
[]
{});
Object
value
=
getMethod
.
invoke
(
t
,
new
Object
[]
{});
String
textValue
=
null
;
if
(
value
instanceof
Date
)
{
Date
date
=
(
Date
)
value
;
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
textValue
=
sdf
.
format
(
date
);
}
else
if
(
fieldName
.
length
()
>=
4
&&
"Time"
.
equalsIgnoreCase
(
fieldName
.
substring
(
fieldName
.
length
()
-
4
)))
{
textValue
=
DateFormatUtils
.
getStringByTimestampAndParm
((
Long
)
value
,
"YYYY-MM-DD"
);
}
else
{
// 其它数据类型都当作字符串简单处理
textValue
=
value
!=
null
?
value
.
toString
()
:
""
;
}
// 如果不是图片数据,就利用正则表达式判断textValue是否全部由数字组成
if
(
textValue
!=
null
)
{
Pattern
p
=
Pattern
.
compile
(
"^//d+(//.//d+)?$"
);
// 正则表达式
Matcher
matcher
=
p
.
matcher
(
textValue
);
if
(
matcher
.
matches
())
{
// 是数字当作double处理
cell
.
setCellValue
(
Double
.
parseDouble
(
textValue
));
}
else
{
cell
.
setCellValue
(
textValue
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
// 清理资源
}
row
.
setHeightInPoints
(
25
);
// 设置行高为25(猜测单位为px)
cell
.
setCellStyle
(
namestyle
);
// 渲染单元格
}
}
try
{
workbook
.
write
(
out
);
workbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@SuppressWarnings
(
"unused"
)
public
Collection
<
T
>
importExcel
(
File
file
,
Collection
<
T
>
dataset
)
throws
Exception
{
// 装载流
POIFSFileSystem
fs
=
new
POIFSFileSystem
(((
MultipartFile
)
file
).
getInputStream
());
HSSFWorkbook
hw
=
new
HSSFWorkbook
(
fs
);
// 获取第一个sheet页
HSSFSheet
sheet
=
hw
.
getSheetAt
(
0
);
// 创建容器
//List<Map<String, Object>> ret = new ArrayList<Map<String, Object>>();
dataset
=
new
ArrayList
<
T
>(
sheet
.
getLastRowNum
()-
1
);
Iterator
<
T
>
it
=
dataset
.
iterator
();
// 遍历行 从下标第一行开始(去除标题)
for
(
int
i
=
1
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
T
t
=
it
.
next
();
Field
[]
fields
=
t
.
getClass
().
getDeclaredFields
();
HSSFRow
row
=
sheet
.
getRow
(
i
);
if
(
row
!=
null
)
{
// 装载obj
for
(
int
k
=
0
;
k
<
row
.
getLastCellNum
();
k
++)
{
HSSFCell
cell
=
row
.
getCell
(
k
);
Field
field
=
fields
[
k
];
String
fieldName
=
field
.
getName
();
//动态拼接getXxx获取属性值方法 如:TUserLand类 loginname 动态获取 -》 setLoginname 这个方法名
String
getMethodName
=
"set"
+
fieldName
.
substring
(
0
,
1
).
toUpperCase
()+
fieldName
.
substring
(
1
);
Class
<?
extends
Object
>
tclass
=
t
.
getClass
();
Method
getMethod
=
tclass
.
getMethod
(
getMethodName
,
new
Class
[]
{});
getMethod
.
invoke
(
t
,
ExcelUtil
.
cellFormat
(
cell
));
String
textValue
=
null
;
}
//ret.add(dataObj(dataset, row));
}
}
hw
.
close
();
return
dataset
;
}
@SuppressWarnings
(
"deprecation"
)
private
static
String
cellFormat
(
HSSFCell
cell
){
String
result
=
new
String
();
if
(
null
!=
cell
)
{
switch
(
cell
.
getCellType
())
{
case
HSSFCell
.
CELL_TYPE_NUMERIC
:
// 数字
String
cellValue
=
new
DecimalFormat
(
"0"
).
format
(
cell
.
getNumericCellValue
());
if
(
cellValue
.
lastIndexOf
(
"E"
)
>
-
1
)
{
cell
.
setCellValue
(
new
DecimalFormat
(
"#"
).
format
(
cell
.
getNumericCellValue
()));
}
String
str
=
String
.
valueOf
(
cell
);
if
(
str
.
indexOf
(
".0"
)
!=
-
1
||
str
.
indexOf
(
"-"
)
!=
-
1
)
{
if
(
HSSFDateUtil
.
isCellDateFormatted
(
cell
))
{
// 处理日期格式、时间格式
SimpleDateFormat
sdf
=
null
;
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
HSSFDataFormat
.
getBuiltinFormat
(
"h:mm"
))
{
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
}
else
{
// 日期
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
}
Date
date
=
cell
.
getDateCellValue
();
result
=
sdf
.
format
(
date
);
cell
.
setCellValue
(
result
);
}
else
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
176
)
{
// 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58)
double
value
=
cell
.
getNumericCellValue
();
Date
date
=
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
getJavaDate
(
value
);
result
=
DateFormatUtils
.
tranDate
(
date
,
"yyyyMMdd"
);
cell
.
setCellValue
(
result
);
}
else
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
14
||
cell
.
getCellStyle
().
getDataFormat
()
==
31
)
{
double
value
=
cell
.
getNumericCellValue
();
Date
date
=
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
getJavaDate
(
value
);
result
=
DateFormatUtils
.
tranDate
(
date
,
"yyyyMMdd"
);
cell
.
setCellValue
(
result
);
}
System
.
out
.
println
(
result
);
}
break
;
case
HSSFCell
.
CELL_TYPE_STRING
:
// 字符串
// System.out.print(cell.getStringCellValue()
// + " ");
break
;
case
HSSFCell
.
CELL_TYPE_BOOLEAN
:
// Boolean
// System.out.println(cell.getBooleanCellValue()
// + " ");
break
;
case
HSSFCell
.
CELL_TYPE_FORMULA
:
// 公式
// System.out.print(cell.getCellFormula() + " ");
break
;
case
HSSFCell
.
CELL_TYPE_BLANK
:
// 空值
// System.out.println(" ");
break
;
case
HSSFCell
.
CELL_TYPE_ERROR
:
// 故障
// System.out.println(" ");
break
;
default
:
// System.out.print("未知类型 ");
break
;
}
return
result
;
}
return
null
;
}
@SuppressWarnings
(
"unused"
)
private
static
Map
<
String
,
Object
>
dataObj
(
Object
obj
,
HSSFRow
row
)
throws
Exception
{
Class
<?>
rowClazz
=
obj
.
getClass
();
Field
[]
fields
=
FieldUtils
.
getAllFields
(
rowClazz
);
if
(
fields
==
null
||
fields
.
length
<
1
)
{
return
null
;
}
// 容器
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
// 注意excel表格字段顺序要和obj字段顺序对齐 (如果有多余字段请另作特殊下标对应处理)
for
(
int
j
=
0
;
j
<
fields
.
length
;
j
++)
{
map
.
put
(
fields
[
j
].
getName
(),
getVal
(
row
.
getCell
(
j
)));
}
return
map
;
}
@SuppressWarnings
(
"deprecation"
)
public
static
String
getVal
(
HSSFCell
hssfCell
)
{
if
(
hssfCell
!=
null
)
{
hssfCell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
return
hssfCell
.
getStringCellValue
();
}
else
{
return
""
;
}
}
}
src/main/java/cn/timer/api/utils/ImportExcelUntil.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.lang.reflect.Field
;
import
java.text.DecimalFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.reflect.FieldUtils
;
import
org.apache.poi.hssf.usermodel.HSSFCell
;
import
org.apache.poi.hssf.usermodel.HSSFDataFormat
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.hssf.usermodel.HSSFRow
;
import
org.apache.poi.hssf.usermodel.HSSFSheet
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.poifs.filesystem.POIFSFileSystem
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.springframework.web.multipart.MultipartFile
;
/**
*
* @author Tang
* @date 2019年7月26日
*
*/
public
class
ImportExcelUntil
{
/**
* 拼装单个obj
*
* @param obj
* @param row
* @return
* @throws Exception
*/
private
static
Map
<
String
,
Object
>
dataObj
(
Object
obj
,
HSSFRow
row
)
throws
Exception
{
Class
<?>
rowClazz
=
obj
.
getClass
();
Field
[]
fields
=
FieldUtils
.
getAllFields
(
rowClazz
);
if
(
fields
==
null
||
fields
.
length
<
1
)
{
return
null
;
}
// 容器
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
// 注意excel表格字段顺序要和obj字段顺序对齐 (如果有多余字段请另作特殊下标对应处理)
for
(
int
j
=
0
;
j
<
fields
.
length
;
j
++)
{
map
.
put
(
fields
[
j
].
getName
(),
getVal
(
row
.
getCell
(
j
)));
}
return
map
;
}
@SuppressWarnings
(
"deprecation"
)
public
static
List
<
Map
<
String
,
Object
>>
importExcel
(
MultipartFile
file
,
Object
obj
)
throws
Exception
{
// 装载流
POIFSFileSystem
fs
=
new
POIFSFileSystem
(
file
.
getInputStream
());
HSSFWorkbook
hw
=
new
HSSFWorkbook
(
fs
);
// 获取第一个sheet页
HSSFSheet
sheet
=
hw
.
getSheetAt
(
0
);
// 容器
List
<
Map
<
String
,
Object
>>
ret
=
new
ArrayList
<
Map
<
String
,
Object
>>();
// 遍历行 从下标第一行开始(去除标题)
for
(
int
i
=
1
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
HSSFRow
row
=
sheet
.
getRow
(
i
);
String
result
=
new
String
();
if
(
row
!=
null
)
{
// 装载obj
for
(
int
k
=
0
;
k
<
row
.
getLastCellNum
();
k
++)
{
HSSFCell
cell
=
row
.
getCell
(
k
);
if
(
null
!=
cell
)
{
switch
(
cell
.
getCellType
())
{
case
HSSFCell
.
CELL_TYPE_NUMERIC
:
// 数字
// System.out.print(cell.getNumericCellValue()
// + " ");
// System.out.print( new DecimalFormat("#").format(cellValue));
DecimalFormat
df
=
new
DecimalFormat
(
"0"
);
String
cellValue
=
df
.
format
(
cell
.
getNumericCellValue
());;
if
(
cellValue
.
lastIndexOf
(
"E"
)>-
1
){
cell
.
setCellValue
(
new
DecimalFormat
(
"#"
).
format
(
cell
.
getNumericCellValue
()));
}
String
str
=
String
.
valueOf
(
cell
);
if
(
str
.
indexOf
(
".0"
)
!=
-
1
||
str
.
indexOf
(
"-"
)
!=
-
1
)
{
if
(
HSSFDateUtil
.
isCellDateFormatted
(
cell
))
{
// 处理日期格式、时间格式
SimpleDateFormat
sdf
=
null
;
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
HSSFDataFormat
.
getBuiltinFormat
(
"h:mm"
))
{
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
}
else
{
// 日期
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
}
Date
date
=
cell
.
getDateCellValue
();
result
=
sdf
.
format
(
date
);
cell
.
setCellValue
(
result
);
}
else
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
176
)
{
// 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58)
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
double
value
=
cell
.
getNumericCellValue
();
Date
date
=
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
getJavaDate
(
value
);
result
=
sdf
.
format
(
date
);
cell
.
setCellValue
(
result
);
}
else
if
(
cell
.
getCellStyle
().
getDataFormat
()
==
14
||
cell
.
getCellStyle
().
getDataFormat
()
==
31
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
double
value
=
cell
.
getNumericCellValue
();
Date
date
=
org
.
apache
.
poi
.
ss
.
usermodel
.
DateUtil
.
getJavaDate
(
value
);
result
=
sdf
.
format
(
date
);
cell
.
setCellValue
(
result
);
}
System
.
out
.
println
(
result
);
}
break
;
case
HSSFCell
.
CELL_TYPE_STRING
:
// 字符串
// System.out.print(cell.getStringCellValue()
// + " ");
break
;
case
HSSFCell
.
CELL_TYPE_BOOLEAN
:
// Boolean
// System.out.println(cell.getBooleanCellValue()
// + " ");
break
;
case
HSSFCell
.
CELL_TYPE_FORMULA
:
// 公式
// System.out.print(cell.getCellFormula() + " ");
break
;
case
HSSFCell
.
CELL_TYPE_BLANK
:
// 空值
// System.out.println(" ");
break
;
case
HSSFCell
.
CELL_TYPE_ERROR
:
// 故障
// System.out.println(" ");
break
;
default
:
// System.out.print("未知类型 ");
break
;
}
}
}
ret
.
add
(
dataObj
(
obj
,
row
));
}
}
hw
.
close
();
return
ret
;
}
/**
* 处理val(暂时只处理string和number,可以自己添加自己需要的val类型)
*
* @param hssfCell
* @return
*/
@SuppressWarnings
(
"deprecation"
)
public
static
String
getVal
(
HSSFCell
hssfCell
)
{
if
(
hssfCell
!=
null
){
hssfCell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
return
hssfCell
.
getStringCellValue
();
}
else
{
return
""
;
}
}
}
\ No newline at end of file
src/main/java/cn/timer/api/utils/LevelPriceDateFromatUtils.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.util.Calendar
;
import
java.util.Date
;
public
class
LevelPriceDateFromatUtils
{
/**
* 时间运算
* @param unit
* @param num
* @param time
* @return
*/
public
static
Long
getTimestampByUnitAndNumAddTime
(
String
unit
,
Long
num
,
Long
time
)
{
//单位 1天 2月 3季 4年 5两年
Calendar
calendar
=
LevelPriceDateFromatUtils
.
getCalendarByTimestamp
(
time
);
switch
(
unit
)
{
case
"1"
:
calendar
.
add
(
Calendar
.
DATE
,
num
.
intValue
());
break
;
case
"2"
:
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
num
.
intValue
());
break
;
case
"3"
:
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
num
.
intValue
()*
3
);
//一季度等于三个月
break
;
case
"4"
:
calendar
.
add
(
Calendar
.
YEAR
,
num
.
intValue
());
break
;
case
"5"
:
calendar
.
add
(
Calendar
.
YEAR
,
num
.
intValue
()*
2
);
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
calendar
.
add
(
Calendar
.
YEAR
,
1
);
//买二送一
}
break
;
default
:
break
;
}
return
calendar
.
getTimeInMillis
();
}
public
static
Calendar
getCalendarByTimestamp
(
Long
time
)
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTimeInMillis
(
time
);
return
cal
;
}
public
static
Long
getTimestampByNow
()
{
Date
date
=
new
Date
();
return
date
.
getTime
();
}
public
static
void
main
(
String
[]
args
)
{
//System.out.println(3/2);
System
.
out
.
println
(
getCalendarByTimestamp
(
0L
).
get
(
Calendar
.
YEAR
));
}
}
src/main/java/cn/timer/api/utils/NumberedGeneration.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.text.SimpleDateFormat
;
/**
* 随机数生成
* @author Administrator
*/
public
class
NumberedGeneration
{
public
static
Integer
test
(
int
l
)
{
String
str
=
new
SimpleDateFormat
(
"yy-mm-dd"
)
.
format
(
new
java
.
util
.
Date
());
long
m
=
Long
.
parseLong
((
str
));
Integer
ret
=
(
int
)
(
m
+
l
);
long
n
=
l
+
1
;
System
.
out
.
println
(
n
);
return
ret
+
1000
;
}
public
static
Integer
six
()
{
Integer
ret
=(
int
)((
Math
.
random
()*
9
+
1
)*
100000
);
return
ret
;
}
public
static
Integer
eight
()
{
Integer
ret
=(
int
)((
Math
.
random
()*
9
+
1
)*
10000000
);
return
ret
;
}
public
static
Integer
nine
()
{
Integer
ret
=(
int
)((
Math
.
random
()*
9
+
1
)*
100000000
);
return
ret
;
}
public
static
Integer
test2
()
{
Integer
ret
=
(
int
)
(
Math
.
random
()*
9000
+
1000
);
return
ret
;
}
public
static
void
main
(
String
[]
args
)
{
//System.out.println(six());
}
}
src/main/java/cn/timer/api/utils/ResponseResultNew.java
deleted
100644 → 0
View file @
1b1e55d3
package
cn
.
timer
.
api
.
utils
;
import
java.io.Serializable
;
import
org.springframework.stereotype.Service
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* @Description:Json返回结果集工具类
* @Package:org.jeese.model
* @author:wubc
* @version:1.0
* @date:2017年10月30日-下午1:51:24
* @Copyright:2017 Inc. All rights reserved.
*/
@ApiModel
@Service
(
"responseResultnew"
)
public
class
ResponseResultNew
<
T
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"code"
,
example
=
"101"
)
private
String
code
;
@ApiModelProperty
(
value
=
"result"
,
example
=
"101"
)
private
boolean
result
;
@ApiModelProperty
(
value
=
"message"
,
example
=
"101"
)
private
String
message
;
@ApiModelProperty
(
value
=
"data"
,
example
=
"101"
)
private
T
data
;
// private List<T> datas;
//
// private T page;
//
//
// private static final String PAGE_KEY = "page";
// private static final String NUMBER_KEY = "number";
// private static final String SIZE_KEY = "size";
// private static final String TOTALELEMENTS_KEY = "totalelements";
// private static final String TOTALPAGES_KEY = "totalpages";
// private static final String OFFSET_KEY = "offset";
private
static
final
String
MESSAGE_SUCCESS
=
"操作成功"
;
// private static final String MESSAGE_FAIL = "操作失败";
// private static final String MESSAGE_ERROR = "操作错误";
// private static final String MESSAGE_UNLOGIN = "会话超时,请重新登录";
// private static final String MESSAGE_KICKOUT = "当前账户已在其他地方登录,请重新登录";
// private static final String MESSAGE_PARAMERROR = "参数错误";
// private static final String MESSAGE_UNAUTHORIZED = "授权错误";
// private static final String MESSAGE_UNAUTHENTICATED = "认证错误";
// private static final String MESSAGE_EXCEPTION = "服务器异常";
private
static
final
String
STATUS_CODE_SUCCESS
=
"200"
;
// private static final String STATUS_CODE_FAIL = "201";
// private static final String STATUS_CODE_ERROR = "202";
// private static final String STATUS_CODE_UNLOGIN = "301";
// private static final String STATUS_CODE_KICKOUT = "302";
// private static final String STATUS_CODE_UNPARAM = "400";
// private static final String STATUS_CODE_UNAUTHORIZED = "401";
// private static final String STATUS_CODE_UNAUTHENTICATED = "405";
// private static final String STATUS_CODE_EXCEPTION = "500";
public
ResponseResultNew
()
{
this
.
code
=
STATUS_CODE_SUCCESS
;
this
.
result
=
Boolean
.
TRUE
;
this
.
message
=
MESSAGE_SUCCESS
;
this
.
data
=
null
;
}
/**
* 请求成功
*
* @return
*/
@SuppressWarnings
(
"rawtypes"
)
public
ResponseResultNew
success
()
{
this
.
code
=
STATUS_CODE_SUCCESS
;
this
.
result
=
Boolean
.
TRUE
;
this
.
message
=
MESSAGE_SUCCESS
;
this
.
data
=
null
;
return
this
;
}
/**
* 请求成功,并带消息
*
* @param message
* @return
*/
@SuppressWarnings
(
"rawtypes"
)
public
ResponseResultNew
success
(
String
message
)
{
this
.
code
=
STATUS_CODE_SUCCESS
;
this
.
result
=
Boolean
.
TRUE
;
this
.
message
=
message
;
this
.
data
=
null
;
return
this
;
}
@SuppressWarnings
(
"rawtypes"
)
public
ResponseResultNew
fail
(
String
message
)
{
this
.
code
=
STATUS_CODE_SUCCESS
;
this
.
result
=
Boolean
.
TRUE
;
this
.
message
=
message
;
this
.
data
=
null
;
return
this
;
}
/**
* @param obj
* @return
*/
@SuppressWarnings
(
"rawtypes"
)
public
ResponseResultNew
successData
(
T
data
)
{
this
.
code
=
STATUS_CODE_SUCCESS
;
this
.
result
=
Boolean
.
TRUE
;
this
.
message
=
MESSAGE_SUCCESS
;
this
.
data
=
data
;
return
this
;
}
}
src/main/java/cn/timer/api/utils/SerializationUtils.java
View file @
80a28f85
...
...
@@ -3,8 +3,10 @@ package cn.timer.api.utils;
import
java.io.ByteArrayInputStream
;
import
java.io.ObjectInputStream
;
import
java.util.List
;
/**
* 反序列化
*
* @author Administrator
*/
public
class
SerializationUtils
{
...
...
src/main/java/cn/timer/api/utils/router/RouterUtils.java
View file @
80a28f85
...
...
@@ -11,8 +11,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.convert.ConvertException
;
import
cn.hutool.core.lang.Console
;
import
cn.hutool.core.util.NumberUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.timer.api.bean.spmk.SpmkApproveExecuteRecord
;
import
cn.timer.api.bean.spmk.SpmkApproveSummary
;
...
...
@@ -44,12 +44,12 @@ public class RouterUtils {
private
final
static
String
RELATION_TYPE_DEPARTMENT
=
"department"
;
private
final
static
String
RELATION_TYPE_USERS
=
"users"
;
public
static
List
<
Router
>
NextNode
(
List
<
Router
>
listRouter
,
JSONObject
obj
,
boolean
isFirse
)
{
public
static
List
<
Router
>
NextNode
(
List
<
Router
>
listRouter
,
JSONObject
obj
,
boolean
isFirse
)
throws
NumberFormatException
,
ConvertException
,
Exception
{
return
NextNode
(
listRouter
,
obj
,
isFirse
,
false
);
}
// 执行下一个节点
public
static
List
<
Router
>
NextNode
(
List
<
Router
>
listRouter
,
JSONObject
obj
,
boolean
isFirse
,
boolean
isAuditNext
)
{
public
static
List
<
Router
>
NextNode
(
List
<
Router
>
listRouter
,
JSONObject
obj
,
boolean
isFirse
,
boolean
isAuditNext
)
throws
NumberFormatException
,
ConvertException
,
Exception
{
Router
router
;
if
(
listRouter
!=
null
&&
listRouter
.
size
()
!=
0
)
{
...
...
@@ -261,39 +261,6 @@ public class RouterUtils {
}
private
static
boolean
stringCompare
(
String
s1
,
String
s2
,
String
symbol
)
{
double
d1
;
double
d2
;
switch
(
symbol
)
{
case
"<"
:
d1
=
Double
.
parseDouble
(
s1
);
d2
=
Double
.
parseDouble
(
s2
);
if
(
NumberUtil
.
compare
(
d1
,
d2
)
==
-
1
)
return
true
;
break
;
case
"<="
:
d1
=
Double
.
parseDouble
(
s1
);
d2
=
Double
.
parseDouble
(
s2
);
if
(
NumberUtil
.
compare
(
d1
,
d2
)
==
-
1
||
NumberUtil
.
compare
(
d1
,
d2
)
==
0
)
return
true
;
break
;
case
"="
:
if
(
s2
.
equals
(
s1
))
return
true
;
break
;
case
">"
:
d1
=
Double
.
parseDouble
(
s1
);
d2
=
Double
.
parseDouble
(
s2
);
if
(
NumberUtil
.
compare
(
d1
,
d2
)
==
1
)
return
true
;
break
;
case
">="
:
d1
=
Double
.
parseDouble
(
s1
);
d2
=
Double
.
parseDouble
(
s2
);
if
(
NumberUtil
.
compare
(
d1
,
d2
)
==
0
||
NumberUtil
.
compare
(
d1
,
d2
)
==
1
)
return
true
;
break
;
}
return
false
;
}
public
static
void
getIsFlowChildren
(
List
<
Router
>
listRouter
,
List
<
FlowChildren
>
listFlowChildren
)
{
// TODO Auto-generated method stub
Router
router
;
...
...
@@ -320,7 +287,7 @@ public class RouterUtils {
// 审批执行记录 持久化
public
static
void
insertogExecuteRecord
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
)
{
public
static
void
insertogExecuteRecord
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
)
throws
Exception
{
for
(
int
i
=
0
,
m
=
listFlowChildren
.
size
()
;
i
<
m
;
i
++)
{
if
(
UNEXECUTED
.
equals
(
listFlowChildren
.
get
(
i
).
getExecute
()))
{
...
...
@@ -429,7 +396,7 @@ public class RouterUtils {
* @param opinion 意见
* @param sts 状态 1执行中 2通过 3拒绝
*/
public
static
void
approving
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
,
Integer
executeRecordId
,
Integer
executorId
,
String
opinion
,
Integer
sts
,
User
redeployUser
)
{
public
static
void
approving
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
,
Integer
executeRecordId
,
Integer
executorId
,
String
opinion
,
Integer
sts
,
User
redeployUser
)
throws
Exception
{
boolean
hasNextApprover
=
false
;
...
...
src/main/resources/mapping/clazz/CommonAreaMapper.xml
0 → 100644
View file @
80a28f85
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.timer.api.dao.clazz.CommonAreaMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.timer.api.bean.clazz.CommonArea"
>
<id
column=
"code_id"
property=
"codeId"
/>
<result
column=
"parent_id"
property=
"parentId"
/>
<result
column=
"city_name"
property=
"cityName"
/>
</resultMap>
<resultMap
id=
"BaseResultMap_b"
type=
"cn.timer.api.bean.clazz.CommonArea"
>
<id
column=
"code_id"
property=
"codeId"
/>
<result
column=
"parent_id"
property=
"parentId"
/>
<result
column=
"city_name"
property=
"cityName"
/>
<collection
column=
"CommonArea_c_code_id"
property=
"commonAreas"
ofType=
"cn.timer.api.bean.clazz.CommonArea"
resultMap=
"cn.timer.api.dao.clazz.CommonAreaMapper.BaseResultMap"
columnPrefix=
"CommonArea_c_"
>
</collection>
</resultMap>
<resultMap
id=
"BaseResultMap_Tree"
type=
"cn.timer.api.bean.clazz.CommonArea"
>
<id
column=
"code_id"
property=
"codeId"
/>
<result
column=
"parent_id"
property=
"parentId"
/>
<result
column=
"city_name"
property=
"cityName"
/>
<collection
column=
"CommonArea_b_code_id"
property=
"commonAreas"
ofType=
"cn.timer.api.bean.clazz.CommonArea"
resultMap=
"cn.timer.api.dao.clazz.CommonAreaMapper.BaseResultMap_b"
columnPrefix=
"CommonArea_b_"
>
</collection>
</resultMap>
<sql
id=
"Base_Column_List"
>
code_id,
parent_id,
city_name
</sql>
<sql
id=
"Base_Column_List_Alias"
>
code_id CommonArea_code_id,
parent_id CommonArea_parent_id,
city_name CommonArea_city_name
</sql>
<sql
id=
"Base_Column_List_Alias_a"
>
a.code_id code_id,
a.parent_id parent_id,
a.city_name city_name
</sql>
<sql
id=
"Base_Column_List_Alias_b"
>
b.code_id CommonArea_b_code_id,
b.parent_id CommonArea_b_parent_id,
b.city_name CommonArea_b_city_name
</sql>
<sql
id=
"Base_Column_List_Alias_c"
>
c.code_id CommonArea_b_CommonArea_c_code_id,
c.parent_id CommonArea_b_CommonArea_c_parent_id,
c.city_name CommonArea_b_CommonArea_c_city_name
</sql>
<select
id=
"AllAreaForTree"
resultMap=
"BaseResultMap_Tree"
>
SELECT
<include
refid=
"Base_Column_List_Alias_a"
/>
,
<include
refid=
"Base_Column_List_Alias_b"
/>
,
<include
refid=
"Base_Column_List_Alias_c"
/>
FROM common_area a
LEFT JOIN common_area b ON a.code_id = b.parent_id
LEFT JOIN common_area c ON b.code_id = c.parent_id
WHERE a.parent_id = 0
</select>
<!--
<insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.clazz.CommonArea">
INSERT INTO common_area
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test ='null != codeId'>
code_id,
</if>
<if test ='null != parentId'>
parent_id,
</if>
<if test ='null != cityName'>
city_name
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test ='null != codeId'>
#{codeId},
</if>
<if test ='null != parentId'>
#{parentId},
</if>
<if test ='null != cityName'>
#{cityName}
</if>
</trim>
</insert>
<delete id="delete" >
DELETE FROM common_area
WHERE id = #{id}
</delete>
<update id="update" parameterType="cn.timer.api.bean.clazz.CommonArea">
UPDATE common_area
<set>
<if test ='null != codeId'>code_id = #{codeId},</if>
<if test ='null != parentId'>parent_id = #{parentId},</if>
<if test ='null != cityName'>city_name = #{cityName}</if>
</set>
WHERE id = #{id}
</update>
<select id="load" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM common_area
WHERE id = #{id}
</select>
<select id="pageList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM common_area
LIMIT #{offset}, #{pageSize}
</select>
<select id="pageListCount" resultType="java.lang.Integer">
SELECT count(1)
FROM common_area
</select>
-->
</mapper>
\ No newline at end of file
src/main/resources/mapping/spmk/SpmkApproveSummaryMapper.xml
View file @
80a28f85
...
...
@@ -16,6 +16,7 @@
<result
column=
"current_approver"
property=
"currentApprover"
/>
<result
column=
"history_approver"
property=
"historyApprover"
/>
<result
column=
"asso_type"
property=
"assoType"
/>
<result
column=
"digest"
property=
"digest"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"end_time"
property=
"endTime"
/>
<result
column=
"digest"
property=
"digest"
/>
...
...
@@ -37,7 +38,6 @@
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"end_time"
property=
"endTime"
/>
<result
column=
"digest"
property=
"digest"
/>
<result
column=
"gw_name"
property=
"gwName"
/>
<result
column=
"bm_id"
property=
"bmId"
/>
<result
column=
"bm_name"
property=
"bmName"
/>
...
...
src/main/resources/rebel.xml
0 → 100644
View file @
80a28f85
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
-->
<application
generated-by=
"eclipse"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://www.zeroturnaround.com"
xsi:schemaLocation=
"http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd"
>
<classpath>
<dir
name=
"C:/Users/Administrator/git/8timerapiv200/target/classes"
>
</dir>
</classpath>
</application>
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