Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Z
zhmes-agecal
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
zhmes-agecal
Commits
1504025b
Commit
1504025b
authored
Jun 06, 2025
by
王晓倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
断电、上电指令
parent
bbbfbcb6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
126 deletions
+163
-126
EquipmentDataCollection.java
...ong/web/controller/equipment/EquipmentDataCollection.java
+128
-88
ReceiverThread.java
...main/java/com/zehong/common/utils/TCP/ReceiverThread.java
+2
-1
TStoreyInfoMapper.java
...main/java/com/zehong/system/mapper/TStoreyInfoMapper.java
+8
-8
ITStoreyInfoService.java
...n/java/com/zehong/system/service/ITStoreyInfoService.java
+8
-8
TStoreyInfoServiceImpl.java
...om/zehong/system/service/impl/TStoreyInfoServiceImpl.java
+12
-5
TStoreyInfoMapper.xml
...em/src/main/resources/mapper/system/TStoreyInfoMapper.xml
+5
-16
No files found.
zhmes-agecal-admin/src/main/java/com/zehong/web/controller/equipment/EquipmentDataCollection.java
View file @
1504025b
...
...
@@ -60,21 +60,15 @@ public class EquipmentDataCollection {
for
(
TEquipmentInfo
info
:
equipmentInfos
){
/* 1.老化柜、标定柜通讯 */
receiveMsg
=
agingCabinetCommunication
(
info
,
sendMsg
);
if
(
receiveMsg
==
null
){
if
(
receiveMsg
==
null
||
receiveMsg
.
length
()
!=
58
){
// 记录异常数据
alarmData
.
setfAlarmType
(
"01"
);
// 01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
info
.
getfEquipmentCode
());
alarmData
.
setfAlarmData
(
"老化柜通讯失败
,无响应
"
);
alarmData
.
setfAlarmData
(
"老化柜通讯失败"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
// 更新老化柜状态(“0”空闲,“1”运行,“2”故障)
info
.
setfStatus
(
"2"
);
tEquipmentInfoService
.
updateTEquipmentInfo
(
info
);
}
else
if
(
receiveMsg
.
length
()
!=
58
)
{
// 记录异常数据
alarmData
.
setfAlarmType
(
"01"
);
// 01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
info
.
getfEquipmentCode
());
alarmData
.
setfAlarmData
(
"老化柜IP或端口号为空"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
}
else
{
// 解析服务器返回信息
// 示例:00 01 00 00 00 17 01 04 14 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
...
...
@@ -84,26 +78,53 @@ public class EquipmentDataCollection {
info
.
setfStatus
(
"0"
);
info
.
setfUpdateTime
(
new
Date
());
tEquipmentInfoService
.
updateTEquipmentInfo
(
info
);
}
else
if
(!
"0000000000000000000000000000000000000000"
.
equals
(
flag
)
&&
"0"
.
equals
(
info
.
getfStatus
())){
}
else
if
(!
"0000000000000000000000000000000000000000"
.
equals
(
flag
)
&&
"0"
.
equals
(
info
.
getfStatus
()))
{
info
.
setfStatus
(
"1"
);
info
.
setfUpdateTime
(
new
Date
());
tEquipmentInfoService
.
updateTEquipmentInfo
(
info
);
}
else
if
(
"0000000000000000000000000000000000000000"
.
equals
(
flag
)){
// 解析层状态,根据层编号修改状态
int
startIndex
;
int
endIndex
;
int
code
;
//组成老化层编号
String
status
;
TStoreyInfo
storeyInfo
=
new
TStoreyInfo
();
String
storeyCode
;
for
(
startIndex
=
18
,
endIndex
=
22
,
code
=
1
;
endIndex
<=
receiveMsg
.
length
();
startIndex
+=
4
,
endIndex
+=
4
,
code
++){
status
=
receiveMsg
.
substring
(
startIndex
,
endIndex
);
storeyInfo
.
setfStoreyCode
(
info
.
getfEquipmentCode
()
+
"-"
+
code
);
storeyCode
=
info
.
getfEquipmentCode
()
+
"-"
+
code
;
storeyInfo
=
tStoreyInfoService
.
selectTStoreyInfoByCode
(
storeyCode
);
if
(
storeyInfo
==
null
){
// 记录异常数据
alarmData
.
setfAlarmType
(
"01"
);
// 01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
info
.
getfEquipmentCode
());
alarmData
.
setfAlarmData
(
"下属"
+
storeyCode
+
"号老化层不存在"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
continue
;
}
if
(
"0000"
.
equals
(
status
)){
/* 2.老化层断电 */
// 示例:000100000006 01 功能码05 寄存器地址0000 断电0000
String
addr
=
Integer
.
toHexString
(
code
-
1
).
length
()<
2
?
"0"
+
Integer
.
toHexString
(
code
-
1
):
Integer
.
toHexString
(
code
-
1
);
String
sendMsg2
=
"000100000006010500"
+
addr
+
"0000"
;
String
receiveMsg2
=
null
;
int
num2
=
1
;
// 若上电失败将再次通讯,最多通讯3次
while
((!
sendMsg2
.
equals
(
receiveMsg2
)
||
receiveMsg2
==
null
)
&&
num2
<=
3
){
receiveMsg2
=
storeyCommunication
(
storeyInfo
,
sendMsg2
);
num2
++;
}
if
(
sendMsg2
.
equals
(
receiveMsg2
)){
// 更新老化层状态
storeyInfo
.
setfStatus
(
"4"
);
//断电
tStoreyInfoService
.
updateTStoreyInfoByCode
(
storeyInfo
);
tStoreyInfoService
.
updateTStoreyInfo
(
storeyInfo
);
}
else
{
// 记录异常数据
alarmData
.
setfAlarmType
(
"04"
);
//01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
storeyInfo
.
getfStoreyCode
());
alarmData
.
setfAlarmData
(
"上电失败"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
}
}
}
}
...
...
@@ -118,8 +139,9 @@ public class EquipmentDataCollection {
* 上料:
* 1.由页面向机械臂发送上料指令,通讯机械臂
* 2.通讯老化柜,根据响应信息获取层状态
* 3.通讯老化层,分别获取72个点位状态,开始计时
* 4.向点位写入时间,分别写入年、月、日、时、分
* 3.老化层上电
* 4.通讯老化层,分别获取72个点位状态,开始计时
* 5.向点位写入时间,分别写入年、月、日、时、分
*/
@GetMapping
(
"/agingCabinet"
)
// public void agingCabinetData(TStoreyInfo storeyInfo) throws Exception {
...
...
@@ -131,11 +153,12 @@ public class EquipmentDataCollection {
if
(
storeyInfo
==
null
)
{
throw
new
Exception
(
"无老化层信息!"
);
}
//获取老化柜信息
//
获取老化柜信息
TEquipmentInfo
equipmentInfo
=
tEquipmentInfoService
.
selectTEquipmentInfoById
(
storeyInfo
.
getfEquipmentId
());
if
(
equipmentInfo
==
null
)
{
throw
new
Exception
(
"无老化柜信息!"
);
}
TEquipmentAlarmData
alarmData
=
new
TEquipmentAlarmData
();
/* 1.机械臂通讯 */
...
...
@@ -143,19 +166,14 @@ public class EquipmentDataCollection {
/* 2.老化柜通讯 */
String
sendMsg1
=
"00010000000601040000000A"
;
String
receiveMsg1
=
agingCabinetCommunication
(
equipmentInfo
,
sendMsg1
);
TEquipmentAlarmData
alarmData
=
new
TEquipmentAlarmData
();
if
(
receiveMsg1
==
null
)
{
if
(
receiveMsg1
==
null
||
receiveMsg1
.
length
()
!=
58
)
{
// 记录异常数据
alarmData
.
setfAlarmType
(
"01"
);
//01.老化柜 02.标定柜 03.机械臂 04.老化层
alarmData
.
setfEquipmentCode
(
equipmentInfo
.
getfEquipmentCode
());
alarmData
.
setfAlarmData
(
"老化柜通讯失败
,无响应
"
);
alarmData
.
setfAlarmData
(
"老化柜通讯失败"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
throw
new
Exception
(
storeyInfo
.
getfStoreyCode
()
+
"号老化柜通讯故障!"
);
}
else
if
(
receiveMsg1
.
length
()
!=
58
){
throw
new
Exception
(
receiveMsg1
);
}
if
(
receiveMsg1
.
length
()
==
58
)
{
// 解析服务器返回信息
// 示例:00 01 00 00 00 17 01 04 14 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
String
storeyCode
=
storeyInfo
.
getfStoreyCode
();
...
...
@@ -167,17 +185,40 @@ public class EquipmentDataCollection {
for
(
startIndex
=
18
,
endIndex
=
22
,
code
=
1
;
endIndex
<=
receiveMsg1
.
length
();
startIndex
+=
4
,
endIndex
+=
4
,
flag
++){
status
=
receiveMsg1
.
substring
(
startIndex
,
endIndex
);
if
(
flag
==
code
&&
"0001"
.
equals
(
status
)){
/* 3.老化层通讯,72个点位 */
String
sendMsg2
=
"010000000601030000000A"
;
//第二个“01”位置代表点位地址
/* 3.老化层上电 */
// 示例:000100000006 01 功能码05 寄存器地址0000 上电FF00
String
addr
=
Integer
.
toHexString
(
flag
-
1
).
length
()<
2
?
"0"
+
Integer
.
toHexString
(
flag
-
1
):
Integer
.
toHexString
(
flag
-
1
);
String
sendMsg2
=
"000100000006010500"
+
addr
+
"FF00"
;
String
receiveMsg2
=
null
;
int
num2
=
1
;
//若无返回信息
将再次通讯,最多通讯3次
while
(
receiveMsg2
==
null
&&
num2
>
=
3
){
// 若上电失败
将再次通讯,最多通讯3次
while
((!
sendMsg2
.
equals
(
receiveMsg2
)
||
receiveMsg2
==
null
)
&&
num2
<
=
3
){
receiveMsg2
=
storeyCommunication
(
storeyInfo
,
sendMsg2
);
num2
++;
}
if
(
receiveMsg2
==
null
){
if
(!
sendMsg2
.
equals
(
receiveMsg2
)
||
receiveMsg2
==
null
){
// 记录异常数据
alarmData
.
setfAlarmType
(
"04"
);
//01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
storeyInfo
.
getfStoreyCode
());
alarmData
.
setfAlarmData
(
"上电失败"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
throw
new
Exception
();
}
// 老化层更新状态
// storeyInfo.setfStatus("1");
// tStoreyInfoService.updateTStoreyInfoByCode(storeyInfo);
/* 4.老化层通讯,72个点位,1-27一个端口号、28-54一个端口号、55-72一个端口号,IP不变 */
// 示例:000100000006 点位地址01 功能码03 起始位置0000 终止位置000A
String
sendMsg3
=
"00010000000601030000000A"
;
String
receiveMsg3
=
null
;
int
num3
=
1
;
// 若无返回信息将再次通讯,最多通讯3次
while
(
receiveMsg3
==
null
&&
num3
<=
3
){
receiveMsg3
=
storeyCommunication
(
storeyInfo
,
sendMsg3
);
num3
++;
}
if
(
receiveMsg3
==
null
){
// 记录异常数据
alarmData
.
setfAlarmType
(
"04"
);
//01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
storeyInfo
.
getfStoreyCode
());
...
...
@@ -186,11 +227,11 @@ public class EquipmentDataCollection {
}
// 解析服务器返回信息
// 示例:000100000017010314 浓度0000 状态0001 AD值01F7 标定AD值01F7 年07E9 月0005 日0004 时000E 分000F 秒0015
String
value
=
receiveMsg2
.
substring
(
22
,
26
);
//板子状态
String
value
=
receiveMsg3
.
substring
(
22
,
26
);
//板子状态
if
(
"0001"
.
equals
(
value
)){
/* 4
.写入时间,年、月、日、时、分 */
// 示例:0100000006 设备地址01写时间06 寄存器地址
04(年04月05日06时07分08) 年/月/日/时/分数值07E9(2025)
/* 5
.写入时间,年、月、日、时、分 */
// 示例:000100000006 设备地址01写时间06 寄存器地址00
04(年04月05日06时07分08) 年/月/日/时/分数值07E9(2025)
Calendar
cal
=
Calendar
.
getInstance
();
// 当前年
int
y
=
cal
.
get
(
Calendar
.
YEAR
);
...
...
@@ -202,25 +243,26 @@ public class EquipmentDataCollection {
int
h
=
cal
.
get
(
Calendar
.
HOUR_OF_DAY
);
// 当前分钟
int
mm
=
cal
.
get
(
Calendar
.
MINUTE
);
String
minutes
=
Integer
.
toHexString
(
mm
).
length
()<
2
?
"0"
+
Integer
.
toHexString
(
mm
):
Integer
.
toHexString
(
mm
);
;
String
hours
=
Integer
.
toHexString
(
h
).
length
()<
2
?
"0"
+
Integer
.
toHexString
(
h
):
Integer
.
toHexString
(
h
);
;
String
date
=
Integer
.
toHexString
(
d
).
length
()<
2
?
"0"
+
Integer
.
toHexString
(
d
):
Integer
.
toHexString
(
d
);
;
String
month
=
Integer
.
toHexString
(
m
).
length
()<
2
?
"0"
+
Integer
.
toHexString
(
m
):
Integer
.
toHexString
(
m
);
;
String
year
=
Integer
.
toHexString
(
Integer
.
valueOf
(
String
.
valueOf
(
y
).
substring
(
2
,
4
))
);
String
minutes
=
Integer
.
toHexString
(
mm
).
length
()<
2
?
"000"
+
Integer
.
toHexString
(
mm
):
"00"
+
Integer
.
toHexString
(
mm
)
;
String
hours
=
Integer
.
toHexString
(
h
).
length
()<
2
?
"000"
+
Integer
.
toHexString
(
h
):
"00"
+
Integer
.
toHexString
(
h
)
;
String
date
=
Integer
.
toHexString
(
d
).
length
()<
2
?
"000"
+
Integer
.
toHexString
(
d
):
"00"
+
Integer
.
toHexString
(
d
)
;
String
month
=
Integer
.
toHexString
(
m
).
length
()<
2
?
"000"
+
Integer
.
toHexString
(
m
):
"00"
+
Integer
.
toHexString
(
m
)
;
String
year
=
Integer
.
toHexString
(
y
).
length
()<
4
?
"0"
+
Integer
.
toHexString
(
y
):
Integer
.
toHexString
(
y
);
String
sendMsgYear
=
"01000000060"
+
code
+
"0604"
+
year
;
String
sendMsgYear
=
"0001000000060"
+
code
+
"060004"
+
year
;
// String sendMsgYear = "0001000000060" + "1" + "060004" + year;
String
receiveMsgYear
=
null
;
int
num3
=
1
;
//
写入时间失败将再次通讯,最多通讯3次
while
(!
sendMsgYear
.
equals
(
receiveMsgYear
)
||
receiveMsgYear
==
null
){
int
numy
=
1
;
//
写入时间失败将再次通讯,最多通讯3次
while
((!
sendMsgYear
.
equals
(
receiveMsgYear
)
||
receiveMsgYear
==
null
)
&&
numy
<=
3
){
receiveMsgYear
=
storeyCommunication
(
storeyInfo
,
sendMsgYear
);
num3
++;
numy
++;
}
if
(!
sendMsgYear
.
equals
(
receiveMsgYear
)
||
receiveMsgYear
==
null
){
// 记录异常数据
alarmData
.
setfAlarmType
(
"05"
);
//01.老化柜 02.标定柜 03.机械臂 04.老化层 05.点位
alarmData
.
setfEquipmentCode
(
storeyInfo
.
getfStoreyCode
());
alarmData
.
setfAlarmData
(
"写入时间失败
"
);
alarmData
.
setfAlarmData
(
"写入时间失败-年
"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
}
}
...
...
@@ -228,8 +270,6 @@ public class EquipmentDataCollection {
}
}
}
// 老化柜通讯
private
String
agingCabinetCommunication
(
TEquipmentInfo
equipment
,
String
sendMsg
)
{
String
receiveMsg
=
null
;
...
...
zhmes-agecal-common/src/main/java/com/zehong/common/utils/TCP/ReceiverThread.java
View file @
1504025b
...
...
@@ -34,7 +34,8 @@ public class ReceiverThread extends Thread {
// 将接收到的字节转换为十六进制字符串显示
hexResponse
=
HexUtils
.
bytesToHex
(
responseBytes
);
log
.
info
(
"收到服务器响应: "
+
hexResponse
);
if
(
hexResponse
.
length
()
>=
58
)
{
// 老化柜58,上电断电24,写时间26
if
(
hexResponse
.
length
()
==
58
||
hexResponse
.
length
()
==
24
||
hexResponse
.
length
()
==
26
)
{
break
;
}
}
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/mapper/TStoreyInfoMapper.java
View file @
1504025b
...
...
@@ -19,6 +19,14 @@ public interface TStoreyInfoMapper
*/
public
TStoreyInfo
selectTStoreyInfoById
(
Long
fStoreyId
);
/**
* 查询老化层信息
*
* @param fStoreyCode 老化层信息Code
* @return 老化层信息
*/
public
TStoreyInfo
selectTStoreyInfoByCode
(
String
fStoreyCode
);
/**
* 查询老化层信息列表
*
...
...
@@ -43,14 +51,6 @@ public interface TStoreyInfoMapper
*/
public
int
updateTStoreyInfo
(
TStoreyInfo
tStoreyInfo
);
/**
* 修改老化层信息
*
* @param tStoreyInfo 老化层信息
* @return 结果
*/
public
int
updateTStoreyInfoByCode
(
TStoreyInfo
tStoreyInfo
);
/**
* 删除老化层信息
*
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/service/ITStoreyInfoService.java
View file @
1504025b
...
...
@@ -19,6 +19,14 @@ public interface ITStoreyInfoService
*/
public
TStoreyInfo
selectTStoreyInfoById
(
Long
fStoreyId
);
/**
* 查询老化层信息
*
* @param fStoreyCode 老化层信息Code
* @return 老化层信息
*/
public
TStoreyInfo
selectTStoreyInfoByCode
(
String
fStoreyCode
);
/**
* 查询老化层信息列表
*
...
...
@@ -43,14 +51,6 @@ public interface ITStoreyInfoService
*/
public
int
updateTStoreyInfo
(
TStoreyInfo
tStoreyInfo
);
/**
* 修改老化层信息
*
* @param tStoreyInfo 老化层信息
* @return 结果
*/
public
int
updateTStoreyInfoByCode
(
TStoreyInfo
tStoreyInfo
);
/**
* 批量删除老化层信息
*
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/service/impl/TStoreyInfoServiceImpl.java
View file @
1504025b
...
...
@@ -31,6 +31,18 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return
tStoreyInfoMapper
.
selectTStoreyInfoById
(
fStoreyId
);
}
/**
* 查询老化层信息
*
* @param fStoreyCode 老化层信息Code
* @return 老化层信息
*/
@Override
public
TStoreyInfo
selectTStoreyInfoByCode
(
String
fStoreyCode
)
{
return
tStoreyInfoMapper
.
selectTStoreyInfoByCode
(
fStoreyCode
);
}
/**
* 查询老化层信息列表
*
...
...
@@ -67,11 +79,6 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return
tStoreyInfoMapper
.
updateTStoreyInfo
(
tStoreyInfo
);
}
public
int
updateTStoreyInfoByCode
(
TStoreyInfo
tStoreyInfo
)
{
return
tStoreyInfoMapper
.
updateTStoreyInfoByCode
(
tStoreyInfo
);
}
/**
* 批量删除老化层信息
*
...
...
zhmes-agecal-system/src/main/resources/mapper/system/TStoreyInfoMapper.xml
View file @
1504025b
...
...
@@ -41,6 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where f_storey_id = #{fStoreyId}
</select>
<select
id=
"selectTStoreyInfoByCode"
parameterType=
"String"
resultMap=
"TStoreyInfoResult"
>
<include
refid=
"selectTStoreyInfoVo"
/>
where f_storey_code = #{fStoreyCode}
</select>
<insert
id=
"insertTStoreyInfo"
parameterType=
"TStoreyInfo"
>
insert into t_storey_info
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
@@ -85,22 +90,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where f_storey_id = #{fStoreyId}
</update>
<update
id=
"updateTStoreyInfoByCode"
parameterType=
"TStoreyInfo"
>
update t_storey_info
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"fEquipmentId != null"
>
f_equipment_id = #{fEquipmentId},
</if>
<if
test=
"fStoreyCode != null"
>
f_storey_code = #{fStoreyCode},
</if>
<if
test=
"fTrayCode != null"
>
f_tray_code = #{fTrayCode},
</if>
<if
test=
"fIp != null"
>
f_ip = #{fIp},
</if>
<if
test=
"fStatus != null"
>
f_status = #{fStatus},
</if>
<if
test=
"fPort != null"
>
f_port = #{fPort},
</if>
<if
test=
"fUpdateTime != null"
>
f_update_time = #{fUpdateTime},
</if>
<if
test=
"fCreateTime != null"
>
f_create_time = #{fCreateTime},
</if>
<if
test=
"fAlarmTime != null"
>
f_alarm_time = #{fAlarmTime},
</if>
</trim>
where f_storey_code = #{fStoreyCode}
</update>
<delete
id=
"deleteTStoreyInfoById"
parameterType=
"Long"
>
delete from t_storey_info where f_storey_id = #{fStoreyId}
</delete>
...
...
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