Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
springbooteit
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
zugs
springbooteit
Commits
451eea73
Commit
451eea73
authored
Nov 23, 2021
by
guohj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
066576da
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
646 additions
and
25 deletions
+646
-25
pom.xml
pom.xml
+12
-2
src/main/java/com/ekingwin/eit/dao/ITestDemoDao.java
src/main/java/com/ekingwin/eit/dao/ITestDemoDao.java
+10
-0
src/main/java/com/ekingwin/eit/dao/ITwoPhaseRocketMqDao.java
src/main/java/com/ekingwin/eit/dao/ITwoPhaseRocketMqDao.java
+10
-0
src/main/java/com/ekingwin/eit/dao/entity/EwoPhaseRocketMqDO.java
.../java/com/ekingwin/eit/dao/entity/EwoPhaseRocketMqDO.java
+2
-2
src/main/java/com/ekingwin/eit/dao/entity/TestDemoDO.java
src/main/java/com/ekingwin/eit/dao/entity/TestDemoDO.java
+43
-0
src/main/java/com/ekingwin/eit/dao/entity/TwoPhaseRocketMqDO.java
.../java/com/ekingwin/eit/dao/entity/TwoPhaseRocketMqDO.java
+24
-0
src/main/java/com/ekingwin/eit/dto/TestDemoDTO.java
src/main/java/com/ekingwin/eit/dto/TestDemoDTO.java
+38
-0
src/main/java/com/ekingwin/eit/dto/TwoPhaseRocketMqDTO.java
src/main/java/com/ekingwin/eit/dto/TwoPhaseRocketMqDTO.java
+37
-0
src/main/java/com/ekingwin/eit/productRocketMq/ProductPhaseRocketMq.java
...om/ekingwin/eit/productRocketMq/ProductPhaseRocketMq.java
+44
-0
src/main/java/com/ekingwin/eit/service/IEwoPhaseRocketMqService.java
...va/com/ekingwin/eit/service/IEwoPhaseRocketMqService.java
+3
-0
src/main/java/com/ekingwin/eit/service/ITestDemoService.java
src/main/java/com/ekingwin/eit/service/ITestDemoService.java
+15
-0
src/main/java/com/ekingwin/eit/service/ITwoPhaseRocketMqService.java
...va/com/ekingwin/eit/service/ITwoPhaseRocketMqService.java
+12
-0
src/main/java/com/ekingwin/eit/service/impl/EwoPhaseRocketMqServiceImpl.java
...kingwin/eit/service/impl/EwoPhaseRocketMqServiceImpl.java
+7
-2
src/main/java/com/ekingwin/eit/service/impl/TestDemoServiceImpl.java
...va/com/ekingwin/eit/service/impl/TestDemoServiceImpl.java
+85
-0
src/main/java/com/ekingwin/eit/service/impl/TwoPhaseRocketMqServiceImpl.java
...kingwin/eit/service/impl/TwoPhaseRocketMqServiceImpl.java
+185
-0
src/main/java/com/ekingwin/eit/web/EitPhaseRocketMqController.java
...java/com/ekingwin/eit/web/EitPhaseRocketMqController.java
+94
-13
src/main/resources/application-dev.properties
src/main/resources/application-dev.properties
+3
-3
src/main/resources/application-qa.properties
src/main/resources/application-qa.properties
+3
-2
src/main/resources/application.properties
src/main/resources/application.properties
+1
-1
src/main/resources/mapper/phase/TestMapper.xml
src/main/resources/mapper/phase/TestMapper.xml
+7
-0
src/main/resources/mapper/phase/TwoPhaseRocketMqMapper.xml
src/main/resources/mapper/phase/TwoPhaseRocketMqMapper.xml
+11
-0
No files found.
pom.xml
View file @
451eea73
...
...
@@ -49,7 +49,8 @@
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
<version>
1.18.6
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -67,7 +68,16 @@
<artifactId>
rocketmq-spring-boot-starter
</artifactId>
<version>
${rocketmq-spring-boot-starter-version}
</version>
</dependency>
<dependency>
<groupId>
javax.persistence
</groupId>
<artifactId>
persistence-api
</artifactId>
<version>
1.0
</version>
</dependency>
<dependency>
<groupId>
com.spring4all
</groupId>
<artifactId>
swagger-spring-boot-starter
</artifactId>
<version>
1.9.0.RELEASE
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/ekingwin/eit/dao/ITestDemoDao.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dao
;
import
com.ekingwin.eit.dao.entity.TestDemoDO
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
ITestDemoDao
{
List
<
TestDemoDO
>
getAllData
(
@Param
(
"id"
)
String
id
);
}
src/main/java/com/ekingwin/eit/dao/ITwoPhaseRocketMqDao.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dao
;
import
com.ekingwin.eit.dao.entity.TwoPhaseRocketMqDO
;
import
java.util.List
;
import
java.util.Map
;
public
interface
ITwoPhaseRocketMqDao
{
List
<
Map
<
String
,
Object
>>
getTwoAllData
();
}
src/main/java/com/ekingwin/eit/dao/entity/EwoPhaseRocketMqDO.java
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dao
.
entity
;
import
org.springframework.boot.autoconfigure.domain.EntityScan
;
import
javax.persistence.Table
;
/**
* @author zugs
*/
@
EntityScan
@
Table
(
name
=
"tm_neit_ewo_my"
)
public
class
EwoPhaseRocketMqDO
{
private
String
id
;
...
...
src/main/java/com/ekingwin/eit/dao/entity/TestDemoDO.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dao
.
entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
* @author Admin
* @project TestDemoDO
* @description
* @date 2021-11-22-14:21
*/
@Table
(
name
=
"TEST_DEMO"
)
public
class
TestDemoDO
{
@Id
private
String
id
;
private
String
name
;
private
String
context
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getContext
()
{
return
context
;
}
public
void
setContext
(
String
context
)
{
this
.
context
=
context
;
}
}
src/main/java/com/ekingwin/eit/dao/entity/TwoPhaseRocketMqDO.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dao
.
entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
/**
* @author Admin
* @project TwoPhaseRocketMqDO
* @description
* @date 2021-11-22-14:21
*/
@Table
(
name
=
"tm_neit_ewo_my"
)
public
class
TwoPhaseRocketMqDO
{
@Id
private
String
id
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
src/main/java/com/ekingwin/eit/dto/TestDemoDTO.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dto
;
/**
* @author Admin
* @project TestDemoDTO
* @description
* @date 2021-11-22-14:25
*/
public
class
TestDemoDTO
{
private
String
id
;
private
String
name
;
private
String
context
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getContext
()
{
return
context
;
}
public
void
setContext
(
String
context
)
{
this
.
context
=
context
;
}
}
src/main/java/com/ekingwin/eit/dto/TwoPhaseRocketMqDTO.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
dto
;
/**
* @author Admin
* @project TwoPhaseRocketMqDTO
* @description
* @date 2021-11-22-14:25
*/
public
class
TwoPhaseRocketMqDTO
{
private
String
id
;
private
String
name
;
private
String
context
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getContext
()
{
return
context
;
}
public
void
setContext
(
String
context
)
{
this
.
context
=
context
;
}
}
src/main/java/com/ekingwin/eit/productRocketMq/ProductPhaseRocketMq.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
productRocketMq
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.rocketmq.spring.core.RocketMQTemplate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.UUID
;
public
class
ProductPhaseRocketMq
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductPhaseRocketMq
.
class
);
// public static void main(String[] args) {
// DefaultMQProducer
// }
@Autowired
private
RocketMQTemplate
rocketMQTemplate
;
public
void
productPhaseMessage
(
String
topic
,
String
tag
,
Object
obj
){
String
key
=
"KEY_"
+
UUID
.
randomUUID
();
String
payload
=
null
;
try
{
// payload = this.getJsonString(obj);
// SendResult sendResult = rocketMQTemplate.syncSend(StringUtils.hasText(tag) ? (topic + ":" + tag) : topic,
// MessageBuilder.withPayload(payload).setHeader("PROPERTY_KEYS", key).build());
// logger.info("MessageQueue====",sendResult.getMessageQueue());
// logger.info("SendStatus====",sendResult.getSendStatus());
// logger.info("MsgId====",sendResult.getMsgId());
}
catch
(
Exception
e
)
{
logger
.
error
(
"Produce {}:{} failed: {}"
,
topic
,
tag
,
e
.
getMessage
());
logger
.
error
(
"Payload: {}"
,
payload
);
e
.
printStackTrace
();
}
}
private
String
getJsonString
(
Object
obj
)
throws
Exception
{
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
return
mapper
.
writeValueAsString
(
obj
);
}
}
src/main/java/com/ekingwin/eit/service/IEwoPhaseRocketMqService.java
View file @
451eea73
package
com
.
ekingwin
.
eit
.
service
;
import
com.ekingwin.eit.dto.EwoPhaseRocketMqDTO
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -8,6 +10,7 @@ import java.util.Map;
/**
* @author zugs
*/
public
interface
IEwoPhaseRocketMqService
{
public
List
<
Map
<
String
,
Object
>>
getEwoAllData
();
public
List
<
Map
<
String
,
Object
>>
getTest
();
...
...
src/main/java/com/ekingwin/eit/service/ITestDemoService.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
service
;
import
com.ekingwin.eit.dao.entity.TestDemoDO
;
import
com.ekingwin.eit.dto.TestDemoDTO
;
import
java.util.List
;
/**
* @author zugs
*/
public
interface
ITestDemoService
{
public
List
<
TestDemoDO
>
getAllData
(
String
id
);
}
src/main/java/com/ekingwin/eit/service/ITwoPhaseRocketMqService.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
service
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author zugs
*/
public
interface
ITwoPhaseRocketMqService
{
public
List
<
Map
<
String
,
Object
>>
getTwoAllData
();
}
src/main/java/com/ekingwin/eit/service/impl/EwoPhaseRocketMqServiceImpl.java
View file @
451eea73
...
...
@@ -3,6 +3,7 @@ package com.ekingwin.eit.service.impl;
import
com.ekingwin.eit.dao.IEwoPhaseRocketMqDao
;
import
com.ekingwin.eit.dto.EwoPhaseRocketMqDTO
;
import
com.ekingwin.eit.service.IEwoPhaseRocketMqService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
...
...
@@ -20,7 +21,7 @@ import java.util.Map;
@Service
@Primary
public
class
EwoPhaseRocketMqServiceImpl
{
public
class
EwoPhaseRocketMqServiceImpl
implements
IEwoPhaseRocketMqService
{
// private void buildDTO(Object ado, Object dto) {
// EwoPhaseRocketMqDTO adodemo=(EwoPhaseRocketMqDTO)ado;
...
...
@@ -54,7 +55,7 @@ public class EwoPhaseRocketMqServiceImpl {
}
@Override
public
List
<
Map
<
String
,
Object
>>
getEwoAllData
(){
//先得到一天之内更新的ewo数据
List
<
Map
<
String
,
Object
>>
allDatas
=
ewoPhaseRocketMqDao
.
getEwoAllData
();
...
...
@@ -121,6 +122,10 @@ public class EwoPhaseRocketMqServiceImpl {
return
ewoInfos
;
}
@Override
public
List
<
Map
<
String
,
Object
>>
getTest
()
{
return
null
;
}
public
Map
<
String
,
Object
>
handlePhaseAffect
(
String
myids
,
String
programcodeid
,
Map
<
String
,
Object
>
ewoInfo
,
String
phase
,
String
effpoint
,
String
instid
){
...
...
src/main/java/com/ekingwin/eit/service/impl/TestDemoServiceImpl.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
service
.
impl
;
import
com.ekingwin.eit.dao.ITestDemoDao
;
import
com.ekingwin.eit.dao.entity.TestDemoDO
;
import
com.ekingwin.eit.dto.TestDemoDTO
;
import
com.ekingwin.eit.service.ITestDemoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author zugs
*/
@Service
@Primary
public
class
TestDemoServiceImpl
implements
ITestDemoService
{
// public TestDemoDTO save(TestDemoDTO testdemoDTO) {
// try {
// if(StringUtils.isBlank(testdemoDTO.getId())){
// testdemoDTO.setId(String.valueOf(IdUtil.nextId()));
// }
// save(testdemoDTO, TestDemoDO.class, testdemoDao, (Object dest, Object src) ->this.buildDO(dest,src) );
// } catch (Exception e) {
// throw new BasRuntimeException(e);
// }
// TestDemoDTO newDto = new TestDemoDTO();
// newDto.setId(testdemoDTO.getId());
// return newDto;
// }
// private void buildDO(Object ado, Object dto) {
// TestDemoDO adodemo=(TestDemoDO)ado;
// TestDemoDTO dtodemo=(TestDemoDTO)dto;
// adodemo.setId(dtodemo.getId());
// adodemo.setName(dtodemo.getName());
// adodemo.setContext(dtodemo.getContext());
// }
// public void delete(String id) {
// testdemoDao.deleteByPrimaryKey(id);
// }
// public PageCriteria<TestDemoDTO> query(QueryDTO queryDTO) {
// try {
// Example example = buildQuery(queryDTO, TestDemoDO.class);
// PageCriteria<TestDemoDTO> query = query(queryDTO, () -> testdemoDao.selectByExample(example), TestDemoDTO.class);
// return query;
// } catch (BasException e) {
// System.out.println("ddddd===="+e.getMessage());
// throw new BasRuntimeException(e);
// }
// }
// public TestDemoDTO get(String id) {
// try {
// if(StringUtils.isEmpty(id)){
// return new TestDemoDTO();
// }
// return get(TestDemoDTO.class, id, testdemoDao,(Object dest, Object src) ->this.buildDTO(dest,src));
// } catch (Exception e) {
// throw new BasRuntimeException(e.getMessage(),e);
// }
// }
private
void
buildDTO
(
Object
ado
,
Object
dto
)
{
TestDemoDTO
adodemo
=(
TestDemoDTO
)
ado
;
TestDemoDO
dtodemo
=(
TestDemoDO
)
dto
;
adodemo
.
setId
(
dtodemo
.
getId
());
adodemo
.
setName
(
dtodemo
.
getName
());
adodemo
.
setContext
(
dtodemo
.
getContext
());
}
@Autowired
private
ITestDemoDao
testdemoDao
;
@Override
public
List
<
TestDemoDO
>
getAllData
(
String
id
)
{
return
testdemoDao
.
getAllData
(
id
);
}
}
src/main/java/com/ekingwin/eit/service/impl/TwoPhaseRocketMqServiceImpl.java
0 → 100644
View file @
451eea73
package
com
.
ekingwin
.
eit
.
service
.
impl
;
import
com.ekingwin.eit.dao.IEwoPhaseRocketMqDao
;
import
com.ekingwin.eit.dao.ITwoPhaseRocketMqDao
;
import
com.ekingwin.eit.dto.TwoPhaseRocketMqDTO
;
import
com.ekingwin.eit.service.ITwoPhaseRocketMqService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Service
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @author zugs
*/
@Service
@Primary
public
class
TwoPhaseRocketMqServiceImpl
implements
ITwoPhaseRocketMqService
{
//Logger logger=
@Autowired
private
ITwoPhaseRocketMqDao
twoPhaseRocketMqDao
;
@Autowired
private
IEwoPhaseRocketMqDao
ewoPhaseRocketMqDao
;
// public List<Map<String,Object>> getTwoAllData() {
// List<Map<String, Object>> ewoAllData = this.getEwoAllData();//EWO单子
// List<Map<String, Object>> twoAllData = this.getTwoAllData();//TWO单子
// return null;
// }
public
TwoPhaseRocketMqDTO
save
(
TwoPhaseRocketMqDTO
twoPhaseRocketMqDTO
)
{
return
null
;
}
public
void
delete
(
String
s
)
{
}
// public PageCriteria<TwoPhaseRocketMqDTO> query(QueryDTO queryDTO) {
// return null;
// }
public
TwoPhaseRocketMqDTO
get
(
String
s
)
{
return
null
;
}
@Override
public
List
<
Map
<
String
,
Object
>>
getTwoAllData
(){
//先得到一天之内更新的two数据
List
<
Map
<
String
,
Object
>>
allDatas
=
twoPhaseRocketMqDao
.
getTwoAllData
();
List
<
Map
<
String
,
Object
>>
twoInfos
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
Map
<
String
,
Object
>
map
:
allDatas
)
{
String
programcodes
=
map
.
get
(
"PROGRAMCODE"
)+
""
;
String
myids
=
map
.
get
(
"MY"
)+
""
;
if
(
StringUtils
.
isEmpty
(
myids
)
||
StringUtils
.
isEmpty
(
programcodes
)
||
"null"
.
equals
(
myids
)
||
"null"
.
equals
(
programcodes
)
){
continue
;
}
String
myname
=
""
;
List
<
Map
<
String
,
Object
>>
myInfos
=
ewoPhaseRocketMqDao
.
getMyInfo
(
myids
);
if
(
myInfos
!=
null
&&
myInfos
.
size
()>
0
){
myname
=
myInfos
.
get
(
0
).
get
(
"MY"
)+
""
;
}
if
(
StringUtils
.
isNotEmpty
(
programcodes
)
&&
!
"null"
.
equals
(
programcodes
)){
//系统中是一个my对应多个programcode,现在拆开
String
[]
programcodeInfos
=
programcodes
.
split
(
","
);
for
(
int
i
=
0
;
i
<
programcodeInfos
.
length
;
i
++){
String
mynametemp
=
myname
;
String
programcodeid
=
programcodeInfos
[
i
];
List
<
Map
<
String
,
Object
>>
programCodeInfo
=
ewoPhaseRocketMqDao
.
getProgramCodeInfo
(
programcodeid
);
if
(
programCodeInfo
!=
null
&&
programCodeInfo
.
size
()>
0
){
String
prgramcodename
=
programCodeInfo
.
get
(
0
).
get
(
"PROGRAMCODE"
)+
""
;
Map
<
String
,
Object
>
twoInfo
=
new
HashMap
<
String
,
Object
>()
;
twoInfo
.
put
(
"twoId"
,
map
.
get
(
"TWONO"
)+
""
+
myname
+
prgramcodename
);
twoInfo
.
put
(
"twoNo"
,
map
.
get
(
"TWONO"
)+
""
);
if
(
StringUtils
.
isNotEmpty
(
mynametemp
)){
mynametemp
=
mynametemp
.
substring
(
2
,
mynametemp
.
length
());
twoInfo
.
put
(
"modelYear"
,
"MY"
+
mynametemp
);
}
else
{
twoInfo
.
put
(
"modelYear"
,
""
);
}
//根据id查product名称
List
<
Map
<
String
,
Object
>>
product
=
new
ArrayList
<
Map
<
String
,
Object
>>();
if
(
map
.
get
(
"PRODUCT"
)!=
null
&&
StringUtils
.
isNotEmpty
(
map
.
get
(
"PRODUCT"
).
toString
())
&&
!
""
.
equals
(
map
.
get
(
"PRODUCT"
)+
""
)
){
product
=
ewoPhaseRocketMqDao
.
getProductInfo
(
map
.
get
(
"PRODUCT"
)
+
""
);
}
if
(
product
!=
null
&&
product
.
size
()>
0
){
String
productName
=
product
.
get
(
0
).
get
(
"PRODUCT"
)+
""
;
twoInfo
.
put
(
"product"
,
productName
);
}
else
{
twoInfo
.
put
(
"product"
,
""
);
}
twoInfo
.
put
(
"programCode"
,
prgramcodename
);
twoInfo
.
put
(
"implDate"
,
map
.
get
(
"IMPLDATE"
)==
null
?
""
:
map
.
get
(
"IMPLDATE"
)+
""
);
String
phaseAffect
=
map
.
get
(
"PHASEAFFECT"
)==
null
?
""
:
map
.
get
(
"PHASEAFFECT"
)+
""
;
//对断点阶段处理
twoInfo
=
this
.
handlePhaseAffect
(
myids
,
programcodeid
,
twoInfo
,
phaseAffect
);
twoInfos
.
add
(
twoInfo
);
}
}
}
else
{
continue
;
}
}
return
twoInfos
;
}
public
Map
<
String
,
Object
>
handlePhaseAffect
(
String
myids
,
String
programcodeid
,
Map
<
String
,
Object
>
twoInfo
,
String
phase
){
twoInfo
.
put
(
"phaseAffect"
,
""
);
String
tid
=
""
;
//TWO一个programcode可能有多个phashe阶段,取时间最小的那个
String
phaseaffect
=
""
;
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
if
(
StringUtils
.
isNotEmpty
(
phase
)
&&
!
"null"
.
equals
(
phase
)){
String
[]
phasedata
=
phase
.
split
(
","
);
for
(
int
j
=
0
;
j
<
phasedata
.
length
;
j
++){
String
phasedataSimpleid
=
phasedata
[
j
];
List
<
Map
<
String
,
Object
>>
PhaseaffectInfo
=
ewoPhaseRocketMqDao
.
getPhaseaffectInfo
(
myids
,
programcodeid
);
if
(
PhaseaffectInfo
!=
null
&&
PhaseaffectInfo
.
size
()>
0
){
String
phasedataids
=
PhaseaffectInfo
.
get
(
0
).
get
(
"NODEID"
)+
""
;
if
(
StringUtils
.
isNotEmpty
(
phasedataids
)){
String
[]
split
=
phasedataids
.
split
(
","
);
for
(
int
k
=
0
;
k
<
split
.
length
;
k
++){
if
(
phasedataSimpleid
.
equals
(
split
[
k
])){
List
<
Map
<
String
,
Object
>>
phaseaffectNodeInfo
=
ewoPhaseRocketMqDao
.
getPhaseaffectNodeInfo
(
phasedataSimpleid
);
if
(
phaseaffectNodeInfo
!=
null
&&
phaseaffectNodeInfo
.
size
()>
0
){
Map
<
String
,
Object
>
map
=
phaseaffectNodeInfo
.
get
(
0
);
if
(
map
==
null
){
return
twoInfo
;
}
if
(
StringUtils
.
isNotEmpty
(
tid
)){
String
nodeno
=
map
.
get
(
"NODENO"
)==
null
?
""
:
map
.
get
(
"NODENO"
)+
""
;
String
nodetype
=
map
.
get
(
"NODETYPE"
)==
null
?
""
:
map
.
get
(
"NODETYPE"
)+
""
;
String
phaseaffectTemp
=
nodetype
+
nodeno
;
String
temptid
=
map
.
get
(
"PHASEAFFECTDATE"
)==
null
?
""
:
map
.
get
(
"PHASEAFFECTDATE"
)+
""
;
if
(
StringUtils
.
isNotEmpty
(
temptid
)
&&
StringUtils
.
isNotEmpty
(
tid
)){
try
{
Date
tempDate
=
sdf
.
parse
(
temptid
);
Date
tidDate
=
sdf
.
parse
(
tid
);
if
(
tidDate
.
after
(
tempDate
)){
tid
=
temptid
;
phaseaffect
=
phaseaffectTemp
;
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
}
else
{
tid
=
map
.
get
(
"PHASEAFFECTDATE"
)==
null
?
""
:
map
.
get
(
"PHASEAFFECTDATE"
)+
""
;
String
nodeno
=
map
.
get
(
"NODENO"
)==
null
?
""
:
map
.
get
(
"NODENO"
)+
""
;
String
nodetype
=
map
.
get
(
"NODETYPE"
)==
null
?
""
:
map
.
get
(
"NODETYPE"
)+
""
;
phaseaffect
=
nodetype
+
nodeno
;
}
}
}
}
}
}
else
{
continue
;
}
}
twoInfo
.
put
(
"phaseAffect"
,
phaseaffect
);
}
else
{
twoInfo
.
put
(
"phaseAffect"
,
"DRE RCD"
);
}
return
twoInfo
;
}
}
src/main/java/com/ekingwin/eit/web/EitPhaseRocketMqController.java
View file @
451eea73
package
com
.
ekingwin
.
eit
.
web
;
import
com.ekingwin.eit.service.impl.EwoPhaseRocketMqServiceImpl
;
import
com.ekingwin.eit.service.IEwoPhaseRocketMqService
;
import
com.ekingwin.eit.service.ITwoPhaseRocketMqService
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Value
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.apache.rocketmq.spring.core.RocketMQTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.messaging.support.MessageBuilder
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -21,28 +28,102 @@ import java.util.*;
* @author zugs
*/
@RestController
@RequestMapping
(
"/eitphaserocketmq"
)
@EnableScheduling
@Api
(
tags
=
"测试接口"
)
@Slf4j
public
class
EitPhaseRocketMqController
{
// private static Logger logger = LoggerFactory.getLogger(ProductPhaseRocketMq.class);
// private static Logger logger = LoggerFactory.getLogger(ProductPhaseRocketMq.class);
@Resource
private
IEwoPhaseRocketMqService
ewoPhaseRocketMqService
;
@Autowired
private
ITwoPhaseRocketMqService
twoPhaseRocketMqService
;
@Autowired
private
EwoPhaseRocketMqServiceImpl
ewoPhaseRocketMqServic
e
;
private
RocketMQTemplate
rocketMQTemplat
e
;
@Value
(
"${eit-phase-topic}"
)
private
String
eitPhaseTopic
;
@Value
(
"${ewo-phase-tag}"
)
private
String
ewoPhaseTag
;
@Value
(
"${two-phase-tag}"
)
private
String
twoPhaseTag
;
@RequestMapping
(
value
=
"/testJob"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
"定时处理"
)
public
void
testJob
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
System
.
out
.
println
(
sdf
.
format
(
new
Date
())+
"发送成功=========="
);
ewoPhaseRocketMqService
.
getAllTuzycs
();
List
<
Map
<
String
,
Object
>>
EwoAllDatas
=
ewoPhaseRocketMqService
.
getEwoAllData
();
List
<
Map
<
String
,
Object
>>
TwoAllDatas
=
twoPhaseRocketMqService
.
getTwoAllData
();
this
.
sendMqMessage
(
EwoAllDatas
,
TwoAllDatas
);
System
.
out
.
println
(
sdf
.
format
(
new
Date
())+
"结束=========="
);
}
@RequestMapping
(
value
=
"/scheduledJob"
,
produces
=
"application/json;charset=UTF-8"
,
method
=
RequestMethod
.
POST
)
@Scheduled
(
cron
=
"0 30 5 * * ?"
)
//定为每天5:30更新
@ApiOperation
(
"每天定时处理EIT跟PCRS系统MQ接口"
)
public
void
scheduledJob
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
System
.
out
.
println
(
sdf
.
format
(
new
Date
())+
"发送开始=========="
);
List
<
Map
<
String
,
Object
>>
EwoAllDatas
=
ewoPhaseRocketMqService
.
getEwoAllData
();
List
<
Map
<
String
,
Object
>>
TwoAllDatas
=
twoPhaseRocketMqService
.
getTwoAllData
();
this
.
sendMqMessage
(
EwoAllDatas
,
TwoAllDatas
);
System
.
out
.
println
(
sdf
.
format
(
new
Date
())+
"发送结束=========="
);
}
// @RequestMapping(value = "/testJndi",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
// @Scheduled(cron="0 */1 * * * ?")//定为每天5:30更新
// @ApiOperation("测试有没有走")
// public void testJndi() {
// System.out.println("测试开始==========");
// ewoPhaseRocketMqService.getTest();
// System.out.println("测试结束==========");
// }
public
void
productPhaseMessage
(
String
topic
,
String
tag
,
Object
obj
){
String
key
=
"KEY_"
+
UUID
.
randomUUID
();
String
payload
=
null
;
try
{
payload
=
this
.
getJsonString
(
obj
);
System
.
out
.
println
(
"参数===="
+
payload
);
SendResult
sendResult
=
rocketMQTemplate
.
syncSend
(
StringUtils
.
hasText
(
tag
)
?(
topic
+
":"
+
tag
)
:
topic
,
MessageBuilder
.
withPayload
(
payload
).
setHeader
(
"PROPERTY_KEYS"
,
key
).
build
());
System
.
out
.
println
(
"tag===="
+
tag
);
System
.
out
.
println
(
"SendStatus===="
+
sendResult
.
getSendStatus
());
System
.
out
.
println
(
"MsgId===="
+
sendResult
.
getMsgId
());
System
.
out
.
println
(
"成功======="
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"失败==="
);
System
.
out
.
println
(
"Produce {}:{} failed: {}topic=="
+
topic
+
"tag"
==
tag
+
"错误消息=="
+
e
.
getMessage
());
System
.
out
.
println
(
"失败单子Payload: {}"
+
payload
);
System
.
out
.
println
(
"失败==="
+
e
);
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"ssss===222=="
);
private
String
getJsonString
(
Object
obj
)
throws
Exception
{
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
return
mapper
.
writeValueAsString
(
obj
);
}
public
void
sendMqMessage
(
List
<
Map
<
String
,
Object
>>
EwoAllDatas
,
List
<
Map
<
String
,
Object
>>
TwoAllDatas
){
System
.
out
.
println
(
"ewo数量==="
+
EwoAllDatas
.
size
());
System
.
out
.
println
(
"two数量==="
+
TwoAllDatas
.
size
());
List
<
Map
<
String
,
Object
>>
oneData
=
null
;
for
(
Map
<
String
,
Object
>
ewoAllData:
EwoAllDatas
)
{
oneData
=
new
ArrayList
<
Map
<
String
,
Object
>>();
oneData
.
add
(
ewoAllData
);
this
.
productPhaseMessage
(
eitPhaseTopic
,
ewoPhaseTag
,
oneData
);
}
for
(
Map
<
String
,
Object
>
TwoAllData:
TwoAllDatas
)
{
oneData
=
new
ArrayList
<
Map
<
String
,
Object
>>();
oneData
.
add
(
TwoAllData
);
this
.
productPhaseMessage
(
eitPhaseTopic
,
twoPhaseTag
,
oneData
);
}
}
}
src/main/resources/application-dev.properties
View file @
451eea73
...
...
@@ -8,8 +8,8 @@ spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url
=
jdbc:oracle:thin:@test4.jiucaiyun.cn:1521:orcl
spring.datasource.username
=
bas5
spring.datasource.password
=
password1
#RocketMQ
#dev:10.203.25.114:wlsadmin/Pass1234
#RocketMQ
����
rocketmq.name-server
=
10.203.109.104:9876;10.203.109.105:9876
rocketmq.producer.group
=
EIT-phaseAffect
rocketmq.producer.access-key
=
RocketMQ
...
...
@@ -22,4 +22,4 @@ rocketmq.producer.retry-next-server=true
rocketmq.producer.max-message-size
=
536870912
eit-phase-topic
=
EIT-phaseAffect-topic
ewo-phase-tag
=
EWO-phaseAffect
two-phase-tag
=
TWO-phaseAffect
\ No newline at end of file
two-phase-tag
=
TWO-phaseAffect
src/main/resources/application-qa.properties
View file @
451eea73
...
...
@@ -4,7 +4,7 @@ server.servlet.context-path=/baseit
mybatis.type-aliases-package
=
com.ekingwin.eit
mybatis.mapper-locations
=
classpath*:/mapper/**/*Mapper.xml
#RocketMQ
#RocketMQ
����
rocketmq.name-server
=
10.203.109.104:9876;10.203.109.105:9876
rocketmq.producer.group
=
EIT-phaseAffect
rocketmq.producer.access-key
=
RocketMQ
...
...
@@ -17,4 +17,5 @@ rocketmq.producer.retry-next-server=true
rocketmq.producer.max-message-size
=
536870912
eit-phase-topic
=
EIT-phaseAffect-topic
ewo-phase-tag
=
EWO-phaseAffect
two-phase-tag
=
TWO-phaseAffect
\ No newline at end of file
two-phase-tag
=
TWO-phaseAffect
#qa:10.203.111.164:wlsadmin/Pass1234
src/main/resources/application.properties
View file @
451eea73
spring.profiles.active
spring.profiles.active
=
dev
server.port
=
8026
server.servlet.context-path
=
/baseit
mybatis.type-aliases-package
=
com.ekingwin.eit
...
...
src/main/resources/mapper/phase/TestMapper.xml
0 → 100644
View file @
451eea73
<?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=
"com.ekingwin.eit.dao.ITestDemoDao"
>
<select
id=
"getAllData"
parameterType=
"String"
resultType=
"com.ekingwin.eit.dao.entity.TestDemoDO"
>
select * from TEST_DEMO where id = #{id}
</select>
</mapper>
src/main/resources/mapper/phase/TwoPhaseRocketMqMapper.xml
0 → 100644
View file @
451eea73
<?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=
"com.ekingwin.eit.dao.ITwoPhaseRocketMqDao"
>
<select
id=
"getTwoAllData"
resultType=
"java.util.Map"
>
select m.*,t.twono ,t.IMPLDATE from tm_neit_two_part2 m left join tm_neit_two t on m.instid=t.INSTID
where (sysdate -t.UPDATETIME)
<
1
</select>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment