Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
reyun
manager
Commits
cbf4c45d
Commit
cbf4c45d
authored
Feb 01, 2018
by
manxiaoqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app排序
parent
820915cc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
159 additions
and
4 deletions
+159
-4
workspace.xml
.idea/workspace.xml
+0
-0
ContractController.java
src/main/java/common/controller/ContractController.java
+4
-0
ContractRepository.java
src/main/java/common/repository/ContractRepository.java
+6
-0
ContractServiceImpl.java
src/main/java/common/service/impl/ContractServiceImpl.java
+2
-2
ContractSendEmailThread.java
src/main/java/common/task/ContractSendEmailThread.java
+78
-0
ContractTask.java
src/main/java/common/task/ContractTask.java
+64
-0
applicationContext-schedule.xml
src/main/resources/spring/applicationContext-schedule.xml
+5
-2
No files found.
.idea/workspace.xml
View file @
cbf4c45d
This diff is collapsed.
Click to expand it.
src/main/java/common/controller/ContractController.java
View file @
cbf4c45d
...
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
...
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
import
common.model.*
;
import
common.model.*
;
import
common.service.ContractService
;
import
common.service.ContractService
;
import
common.service.MenuService
;
import
common.service.MenuService
;
import
common.task.ContractSendEmailThread
;
import
dic.OperateObjectTypeEnum
;
import
dic.OperateObjectTypeEnum
;
import
exception.TipException
;
import
exception.TipException
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
...
@@ -177,6 +178,9 @@ public class ContractController {
...
@@ -177,6 +178,9 @@ public class ContractController {
Contract
contract1
=
service
.
create
(
loginAccount
,
contract
);
Contract
contract1
=
service
.
create
(
loginAccount
,
contract
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract
.
getContractCode
(),
"新建合同"
,
""
,
contract1
.
toString
(),
request
);
NewUserLogThread
userlog
=
new
NewUserLogThread
(
loginAccount
.
getEmail
(),
loginAccount
.
getName
(),
OperateObjectTypeEnum
.
CUSTOMER
.
getKey
(),
contract
.
getContractCode
(),
"新建合同"
,
""
,
contract1
.
toString
(),
request
);
userlog
.
start
();
userlog
.
start
();
ContractSendEmailThread
email
=
new
ContractSendEmailThread
(
contract
);
email
.
start
();
return
ResultModel
.
OK
(
contract1
);
return
ResultModel
.
OK
(
contract1
);
}
}
...
...
src/main/java/common/repository/ContractRepository.java
View file @
cbf4c45d
...
@@ -29,4 +29,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
...
@@ -29,4 +29,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query
(
value
=
"SELECT * from contract where platform = ?1 and email = ?2"
,
nativeQuery
=
true
)
@Query
(
value
=
"SELECT * from contract where platform = ?1 and email = ?2"
,
nativeQuery
=
true
)
List
<
Contract
>
findByPlatformAndEmail
(
String
platform
,
String
email
);
List
<
Contract
>
findByPlatformAndEmail
(
String
platform
,
String
email
);
@Query
(
value
=
"SELECT * from contract where start_date = ?1"
,
nativeQuery
=
true
)
List
<
Contract
>
findByStartDate
(
String
startDate
);
@Query
(
value
=
"SELECT * from contract where end_date = ?1"
,
nativeQuery
=
true
)
List
<
Contract
>
findByEndDate
(
String
endDate
);
}
}
src/main/java/common/service/impl/ContractServiceImpl.java
View file @
cbf4c45d
...
@@ -94,7 +94,7 @@ public class ContractServiceImpl implements ContractService{
...
@@ -94,7 +94,7 @@ public class ContractServiceImpl implements ContractService{
public
Contract
create
(
User
loginUser
,
Contract
resource
)
{
public
Contract
create
(
User
loginUser
,
Contract
resource
)
{
resource
.
setPayMoney
(
0L
);
resource
.
setPayMoney
(
0L
);
resource
.
setInvoice
(
0L
);
resource
.
setInvoice
(
0L
);
if
(
DateUtil
.
getBeforeDays
(
0
).
compareTo
(
resource
.
getStartDate
())
>
0
){
if
(
DateUtil
.
getBeforeDays
(
0
).
compareTo
(
resource
.
getStartDate
())
<
0
){
resource
.
setDs
(
DateUtil
.
getBeforeDays
(
0
));
resource
.
setDs
(
DateUtil
.
getBeforeDays
(
0
));
resource
.
setStatus
(
"wait"
);
resource
.
setStatus
(
"wait"
);
}
else
{
}
else
{
...
@@ -135,7 +135,7 @@ public class ContractServiceImpl implements ContractService{
...
@@ -135,7 +135,7 @@ public class ContractServiceImpl implements ContractService{
if
(!
resource
.
getStartDate
().
equals
(
contract
.
getStartDate
())){
if
(!
resource
.
getStartDate
().
equals
(
contract
.
getStartDate
())){
cc
.
setContent
(
cc
.
getContent
()
+
"开始时间变更 : "
+
contract
.
getStartDate
()
+
"-->"
+
resource
.
getStartDate
());
cc
.
setContent
(
cc
.
getContent
()
+
"开始时间变更 : "
+
contract
.
getStartDate
()
+
"-->"
+
resource
.
getStartDate
());
contract
.
setStartDate
(
resource
.
getStartDate
());
contract
.
setStartDate
(
resource
.
getStartDate
());
if
(
DateUtil
.
getBeforeDays
(
0
).
compareTo
(
resource
.
getStartDate
())
>
0
){
if
(
DateUtil
.
getBeforeDays
(
0
).
compareTo
(
resource
.
getStartDate
())
<
0
){
contract
.
setStatus
(
"wait"
);
contract
.
setStatus
(
"wait"
);
}
else
{
}
else
{
contract
.
setStatus
(
"executing"
);
contract
.
setStatus
(
"executing"
);
...
...
src/main/java/common/task/ContractSendEmailThread.java
0 → 100644
View file @
cbf4c45d
package
common
.
task
;
import
common.context.AppUtils
;
import
common.model.Contract
;
import
common.model.User
;
import
common.model.UserLog
;
import
common.repository.UserLogRepository
;
import
common.repository.UserRepository
;
import
dic.RoleTypeEnum
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
tkio.model.PackageType
;
import
tkio.repository.PackageTypeRepository
;
import
util.DateUtil
;
import
util.IPAddrUtil
;
import
util.MailUtils
;
import
util.ValidateUtil
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
/**
* Created by zxy on 2017/12/15.
*/
public
class
ContractSendEmailThread
extends
Thread
{
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
ContractSendEmailThread
.
class
);
private
PackageTypeRepository
packageTypeRepository
=
AppUtils
.
getApplicationContext
().
getBean
(
PackageTypeRepository
.
class
);
private
UserRepository
userRepository
=
AppUtils
.
getApplicationContext
().
getBean
(
UserRepository
.
class
);
private
Contract
contract
;
public
ContractSendEmailThread
(
Contract
contract
)
{
this
.
contract
=
contract
;
}
@Override
public
void
run
()
{
Map
<
Long
,
String
>
packageMap
=
getPackageMap
();
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"账号 :"
+
this
.
contract
.
getEmail
()
+
" 签约了,"
+
" 套餐 :"
+
packageMap
.
get
(
this
.
contract
.
getPriceLevel
())
+
",开始时间 "
+
this
.
contract
.
getStartDate
()
+
",结束时间 "
+
this
.
contract
.
getEndDate
());
User
user
=
userRepository
.
findOne
(
this
.
contract
.
getSale
());
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
user
.
getEmail
());
if
(!
user
.
getRoleType
().
equals
(
RoleTypeEnum
.
MANAGER
)){
List
<
User
>
userList
=
userRepository
.
findOneDepartment
(
user
.
getRole
());
for
(
User
u
:
userList
){
if
(
u
.
getRoleType
().
equals
(
RoleTypeEnum
.
MANAGER
)){
list
.
add
(
u
.
getEmail
());
}
}
}
try
{
MailUtils
.
sendSimpleEmail
(
"新建合同"
,
sb
.
toString
(),
list
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
Map
<
Long
,
String
>
getPackageMap
(){
List
<
PackageType
>
typeList
=
packageTypeRepository
.
findAll
();
Map
<
Long
,
String
>
typeMap
=
new
HashMap
<>();
if
(
ValidateUtil
.
isValid
(
typeList
)){
for
(
PackageType
s:
typeList
){
typeMap
.
put
(
s
.
getId
(),
s
.
getPackageName
());
}
}
return
typeMap
;
}
}
src/main/java/common/task/ContractTask.java
0 → 100644
View file @
cbf4c45d
package
common
.
task
;
import
com.google.common.base.Splitter
;
import
common.model.AppCategory
;
import
common.model.AppInfo
;
import
common.model.Contract
;
import
common.repository.AppCategoryRepository
;
import
common.repository.AppInfoRepository
;
import
common.repository.CityRepository
;
import
common.repository.ContractRepository
;
import
dmp.model.OtPkgDevStats
;
import
dmp.repository.OtPkgDevStatsRepository
;
import
dmp.repository.TagCrawlerAppsWandoujiaRepository
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
org.anarres.lzo.LzoAlgorithm
;
import
org.anarres.lzo.LzoDecompressor
;
import
org.anarres.lzo.LzoInputStream
;
import
org.anarres.lzo.LzoLibrary
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
util.*
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by zxy on 2017/12/26.
*/
public
class
ContractTask
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ContractTask
.
class
);
@Autowired
ContractRepository
contractRepository
;
public
void
task
(){
List
<
Contract
>
contractList
=
contractRepository
.
findByStartDate
(
DateUtil
.
getBeforeDays
(
0
));
if
(
ValidateUtil
.
isValid
(
contractList
)){
List
<
Contract
>
list
=
new
ArrayList
<>();
for
(
Contract
c
:
contractList
){
c
.
setStatus
(
"executing"
);
list
.
add
(
c
);
}
contractRepository
.
save
(
list
);
}
List
<
Contract
>
contractList2
=
contractRepository
.
findByEndDate
(
DateUtil
.
getBeforeDays
(
0
));
if
(
ValidateUtil
.
isValid
(
contractList2
)){
List
<
Contract
>
list
=
new
ArrayList
<>();
for
(
Contract
c
:
contractList2
){
c
.
setStatus
(
"end"
);
list
.
add
(
c
);
}
contractRepository
.
save
(
list
);
}
}
}
src/main/resources/spring/applicationContext-schedule.xml
View file @
cbf4c45d
...
@@ -25,9 +25,12 @@
...
@@ -25,9 +25,12 @@
<task:scheduled
ref=
"emailTask"
method=
"task"
cron=
"0 20 0 * * ?"
/>
<task:scheduled
ref=
"emailTask"
method=
"task"
cron=
"0 20 0 * * ?"
/>
</task:scheduled-tasks>
</task:scheduled-tasks>
<bean
id=
"trackAccountTask"
class=
"track.task.AccountTask"
></bean>
<bean
id=
"contractTask"
class=
"common.task.ContractTask"
></bean>
<task:scheduled-tasks>
<task:scheduled
ref=
"contractTask"
method=
"task"
cron=
"0 20 17 * * ?"
/>
</task:scheduled-tasks>
<bean
id=
"trackAccountTask"
class=
"track.task.AccountTask"
></bean>
<task:scheduled-tasks>
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled
ref=
"trackAccountTask"
method=
"task"
cron=
"0 32 0 * * ?"
/>
<task:scheduled
ref=
"trackAccountTask"
method=
"task"
cron=
"0 32 0 * * ?"
/>
...
...
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