Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
d5a90058
提交
d5a90058
authored
12月 10, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(盘存模块): 新增盘存模块
新增盘存模块
上级
4ad27adb
隐藏空白字符变更
内嵌
并排
正在显示
38 个修改的文件
包含
2426 行增加
和
101 行删除
+2426
-101
BusinessEnum.java
...sc/src/main/java/com/tykj/dev/misc/base/BusinessEnum.java
+1
-0
StatusEnum.java
...misc/src/main/java/com/tykj/dev/misc/base/StatusEnum.java
+9
-1
pom.xml
dev-readmachine/pom.xml
+71
-0
DevReadmachineApplication.java
...readmachine/devreadmachine/DevReadmachineApplication.java
+15
-0
ReadMachineBill.java
...ev/readmachine/devreadmachine/Entity/ReadMachineBill.java
+80
-0
ReadMachineLibrary.java
...readmachine/devreadmachine/Entity/ReadMachineLibrary.java
+105
-0
ReadDeviceVo.java
.../tykj/dev/readmachine/devreadmachine/Vo/ReadDeviceVo.java
+19
-0
SaveDefatVos.java
.../tykj/dev/readmachine/devreadmachine/Vo/SaveDefatVos.java
+27
-0
SaveReadMachineVo.java
.../dev/readmachine/devreadmachine/Vo/SaveReadMachineVo.java
+61
-0
SaveReadMachineVos.java
...dev/readmachine/devreadmachine/Vo/SaveReadMachineVos.java
+29
-0
SelectBillVo.java
.../tykj/dev/readmachine/devreadmachine/Vo/SelectBillVo.java
+27
-0
ReadMachineBillController.java
.../devreadmachine/controller/ReadMachineBillController.java
+185
-0
ReadMachineLibraryController.java
...vreadmachine/controller/ReadMachineLibraryController.java
+33
-0
ReadMachineBillDao.java
...machine/devreadmachine/repository/ReadMachineBillDao.java
+13
-0
ReadMachineLibraryDao.java
...hine/devreadmachine/repository/ReadMachineLibraryDao.java
+17
-0
ReadMachineBillService.java
...achine/devreadmachine/service/ReadMachineBillService.java
+68
-0
ReadMachineLibraryService.java
...ine/devreadmachine/service/ReadMachineLibraryService.java
+40
-0
ReadMachineBillServiceImpl.java
...vreadmachine/service/impl/ReadMachineBillServiceImpl.java
+269
-0
ReadMachineLibraryServiceImpl.java
...admachine/service/impl/ReadMachineLibraryServiceImpl.java
+61
-0
Message.java
...m/tykj/dev/readmachine/devreadmachine/socket/Message.java
+20
-0
MessageError.java
...j/dev/readmachine/devreadmachine/socket/MessageError.java
+21
-0
ReadWebSocket.java
.../dev/readmachine/devreadmachine/socket/ReadWebSocket.java
+208
-0
BackReadDetailVo.java
...v/readmachine/devreadmachine/toBack/BackReadDetailVo.java
+26
-0
BeanDtoVoUtils.java
...j/dev/readmachine/devreadmachine/util/BeanDtoVoUtils.java
+110
-0
ReadUtils.java
...m/tykj/dev/readmachine/devreadmachine/util/ReadUtils.java
+627
-0
application.properties
dev-readmachine/src/main/resources/application.properties
+1
-0
ModuleAPI_Java_2.2.0.0.jar
...machine/src/main/resources/lib/ModuleAPI_Java_2.2.0.0.jar
+0
-0
DevReadmachineApplicationTests.java
...achine/devreadmachine/DevReadmachineApplicationTests.java
+13
-0
RepairController.java
...m/tykj/dev/device/repair/controller/RepairController.java
+27
-9
InventoryThread.java
...main/java/com/tykj/dev/rfid/timeTask/InventoryThread.java
+5
-2
ReadUtils.java
...d/src/main/java/com/tykj/dev/rfid/timeTask/ReadUtils.java
+94
-86
MessageError.java
...ocket/src/main/java/com/tykj/dev/socket/MessageError.java
+21
-0
MyWebSocket.java
...socket/src/main/java/com/tykj/dev/socket/MyWebSocket.java
+59
-3
TaskBto.java
...in/java/com/tykj/dev/device/task/subject/bto/TaskBto.java
+12
-0
pom.xml
dev-taskselect/pom.xml
+5
-0
TaskSelectController.java
...ev/device/taskselect/controller/TaskSelectController.java
+29
-0
pom.xml
dev-union/pom.xml
+11
-0
pom.xml
pom.xml
+7
-0
没有找到文件。
dev-misc/src/main/java/com/tykj/dev/misc/base/BusinessEnum.java
浏览文件 @
d5a90058
...
...
@@ -121,6 +121,7 @@ public enum BusinessEnum {
SUSPENSION
(
29
,
"中止业务"
),
READMACHINE
(
30
,
"盘存"
),
;
public
Integer
id
;
...
...
dev-misc/src/main/java/com/tykj/dev/misc/base/StatusEnum.java
浏览文件 @
d5a90058
...
...
@@ -317,7 +317,15 @@ public enum StatusEnum {
SCRAP_2222
(
2222
,
"等待上传报废签收单"
),
SCRAP_2223
(
2223
,
"报废草稿"
),
SCRAP_2224
(
2224
,
"报废出库签章审核"
),
SCRAP_2225
(
2225
,
"报废出库等待盖电子签章"
);
SCRAP_2225
(
2225
,
"报废出库等待盖电子签章"
),
/**
* 盘存状态draft
*/
READ_DEAFT
(
3000
,
"保存盘存草稿"
),
READ_End
(
3001
,
"结束盘存任务"
),
;
public
Integer
id
;
...
...
dev-readmachine/pom.xml
0 → 100644
浏览文件 @
d5a90058
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<artifactId>
equip
</artifactId>
<groupId>
com.tykj
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
dev-readmachine
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
dev-readmachine
</name>
<description>
dev-readmachine
</description>
<properties>
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.tykj
</groupId>
<artifactId>
dev-library
</artifactId>
</dependency>
<dependency>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
rfid
</artifactId>
</dependency>
<dependency>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
socket
</artifactId>
</dependency>
<dependency>
<groupId>
com.zebra
</groupId>
<artifactId>
sdk1
</artifactId>
<version>
1.0.0
</version>
<scope>
system
</scope>
<systemPath>
${project.basedir}/src/main/resources/lib/ModuleAPI_Java_2.2.0.0.jar
</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/DevReadmachineApplication.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
(
scanBasePackages
=
{
"com.tykj.dev.*"
,
})
public
class
DevReadmachineApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DevReadmachineApplication
.
class
,
args
);
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Entity/ReadMachineBill.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Entity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.annotation.CreatedBy
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.annotation.LastModifiedBy
;
import
org.springframework.data.annotation.LastModifiedDate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.*
;
import
java.util.Date
;
/**
* @author zsp
* @create 2021/12/3 10:24
*/
@Data
@Entity
@EntityListeners
(
AuditingEntityListener
.
class
)
@SQLDelete
(
sql
=
"update read_machine_bill set delete_tag = 1 where id = ?"
)
@Where
(
clause
=
"delete_tag = 0"
)
@ApiModel
(
"盘存账单"
)
public
class
ReadMachineBill
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"盘存标题"
)
@Column
(
name
=
"title"
,
columnDefinition
=
"TEXT"
)
private
String
title
;
@CreatedBy
@ApiModelProperty
(
value
=
"创建用户id"
)
private
Integer
createUserId
;
@ApiModelProperty
(
value
=
"操作单位的id"
)
private
Integer
createUnitId
;
@ApiModelProperty
(
value
=
"删除标志位"
)
private
Integer
deleteTag
=
0
;
@CreatedDate
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@LastModifiedBy
@ApiModelProperty
(
value
=
"更新用户id"
)
private
Integer
updateUserId
;
@ApiModelProperty
(
value
=
"入库的数量"
)
private
Integer
readNum
;
@ApiModelProperty
(
value
=
"账单的状态"
,
notes
=
"0 是草稿 1 是已完成"
)
private
Integer
status
;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty
(
value
=
"更新时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"任务id"
)
@Transient
private
Integer
taskId
;
@ApiModelProperty
(
value
=
"操作人的名称"
)
@Transient
private
String
createUserName
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Entity/ReadMachineLibrary.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Entity
;
import
com.tykj.dev.config.cache.ConfigCache
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
com.tykj.dev.misc.utils.SpringUtils
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.annotation.LastModifiedDate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
javax.persistence.*
;
import
java.util.Date
;
/**
* @author zsp
* @create 2021/12/3 10:24
*/
@Data
@Entity
@EntityListeners
(
AuditingEntityListener
.
class
)
@SQLDelete
(
sql
=
"update read_machine_library set delete_tag = 1 where id = ?"
)
@Where
(
clause
=
"delete_tag = 0"
)
@ApiModel
(
"盘存账单"
)
public
class
ReadMachineLibrary
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"型号"
)
private
String
model
;
@ApiModelProperty
(
value
=
"删除标志位"
)
private
Integer
deleteTag
=
0
;
/**
* 密级
*/
@ApiModelProperty
(
value
=
"密级"
)
private
Integer
secretLevel
;
/**
* 装备名称
*/
@ApiModelProperty
(
value
=
"装备名称"
)
private
String
name
;
/**
* 装备序列号
*/
@ApiModelProperty
(
value
=
"装备序列号"
)
private
String
seqNumber
;
/**
* rfid卡号
*/
@ApiModelProperty
(
value
=
"rfid卡号"
)
private
String
rfidCardId
;
@ApiModelProperty
(
value
=
"readMachineId"
,
example
=
"111"
)
private
Integer
readMachineId
;
@ApiModelProperty
(
value
=
"存放位置id"
)
private
Integer
storageLocationId
;
@ApiModelProperty
(
value
=
"存放位置名称"
)
private
String
storageLocation
;
@ApiModelProperty
(
value
=
"状态"
,
notes
=
"0 是草稿或者未入库 1是入库"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"所在单位"
)
private
String
locationUnit
;
/**
* 所属单位
*/
@ApiModelProperty
(
value
=
"所属单位"
)
private
String
ownUnit
;
@ApiModelProperty
(
value
=
"生命状态"
)
private
Integer
lifeStatus
;
@CreatedDate
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty
(
value
=
"更新时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"生命状态"
)
@Transient
private
String
lifeStatusName
;
public
ReadMachineLibrary
setConfigName
(){
ConfigCache
configCache
=
SpringUtils
.
getBean
(
"initConfigCache"
);
if
(
configCache
!=
null
)
{
setLifeStatusName
(
configCache
.
getLifeStatusMap
().
get
(
this
.
lifeStatus
)==
null
?
"-"
:
configCache
.
getLifeStatusMap
().
get
(
this
.
lifeStatus
));
}
return
this
;
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Vo/ReadDeviceVo.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 12:31
*/
@Data
@ApiModel
(
"读取装备信息的vo"
)
public
class
ReadDeviceVo
{
@ApiModelProperty
(
value
=
"装备RFID集合"
)
private
List
<
String
>
rfids
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Vo/SaveDefatVos.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Vo
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 12:31
*/
@Data
@ApiModel
(
"保存草稿返回前端的vo"
)
public
class
SaveDefatVos
{
@ApiModelProperty
(
value
=
"保存盘存库的vo的集合"
)
private
List
<
ReadMachineLibrary
>
readMachineLibraries
;
@ApiModelProperty
(
value
=
"任务id"
)
private
Integer
taskId
;
@ApiModelProperty
(
value
=
"账单的id"
)
private
Integer
readMachineBillId
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Vo/SaveReadMachineVo.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Vo
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.beans.BeanUtils
;
import
java.util.Date
;
/**
* @author zsp
* @create 2021/12/3 12:31
*/
@Data
@ApiModel
(
"保存盘存库的vo"
)
public
class
SaveReadMachineVo
{
@ApiModelProperty
(
value
=
"装备的id"
)
private
Integer
deviceId
;
@ApiModelProperty
(
value
=
"装备的型号"
)
private
String
model
;
@ApiModelProperty
(
value
=
"装备的名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"装备的序列号"
)
private
String
seqNumber
;
@ApiModelProperty
(
value
=
"rfid表面号"
)
private
String
rfidCardId
;
@ApiModelProperty
(
value
=
"存放位置"
)
private
Integer
storageLocationId
;
@ApiModelProperty
(
value
=
"存放位置名称"
)
private
String
storageLocation
;
@ApiModelProperty
(
value
=
"状态"
,
notes
=
"0 是草稿或者未入库 1是入库"
)
private
Integer
status
=
0
;
@ApiModelProperty
(
value
=
"所在单位"
)
private
String
locationUnit
;
@ApiModelProperty
(
value
=
"生命状态"
)
private
Integer
lifeStatus
;
/**
* 所属单位
*/
@ApiModelProperty
(
value
=
"所属单位"
)
private
String
ownUnit
;
public
ReadMachineLibrary
toEntity
(){
ReadMachineLibrary
readMachineLibrary
=
new
ReadMachineLibrary
();
BeanUtils
.
copyProperties
(
this
,
readMachineLibrary
);
return
readMachineLibrary
;
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Vo/SaveReadMachineVos.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 12:31
*/
@Data
@ApiModel
(
"保存盘存库的vos"
)
public
class
SaveReadMachineVos
{
@ApiModelProperty
(
value
=
"保存盘存库的vo的集合"
)
private
List
<
SaveReadMachineVo
>
saveReadMachineVo
;
@ApiModelProperty
(
value
=
"任务id"
)
private
Integer
taskId
;
@ApiModelProperty
(
value
=
"标题"
)
private
String
title
;
@ApiModelProperty
(
value
=
"入库的数量"
)
private
Integer
readNum
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/Vo/SelectBillVo.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
Vo
;
import
com.tykj.dev.misc.base.CustomPage
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* @author zsp
* @create 2021/12/3 11:22
*/
@Data
@ApiModel
(
"查询账单vo"
)
public
class
SelectBillVo
extends
CustomPage
{
@ApiModelProperty
(
value
=
"开始时间"
)
private
Date
startTime
;
@ApiModelProperty
(
value
=
"结束时间"
)
private
Date
endTime
;
// @ApiModelProperty(value = "当前登录的单位id")
// private Integer unitId;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/controller/ReadMachineBillController.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.tykj.dev.config.swagger.AutoDocument
;
import
com.tykj.dev.device.library.service.DeviceLibraryService
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
com.tykj.dev.device.task.service.TaskService
;
import
com.tykj.dev.device.user.cache.UserCache
;
import
com.tykj.dev.misc.base.BusinessEnum
;
import
com.tykj.dev.misc.utils.*
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineBill
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.*
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineBillService
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineLibraryService
;
import
com.tykj.dev.readmachine.devreadmachine.socket.ReadWebSocket
;
import
com.tykj.dev.readmachine.devreadmachine.toBack.BackReadDetailVo
;
import
com.tykj.dev.rfid.timeTask.ReadUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author zsp
* @create 2021/12/3 10:59
*/
@RestController
@RequestMapping
(
value
=
"/readMachine"
)
@AutoDocument
@Api
(
tags
=
"盘存模块"
,
description
=
"盘存接口"
)
@Validated
@Slf4j
public
class
ReadMachineBillController
{
@Autowired
private
ReadMachineBillService
readMachineBillService
;
@Resource
private
DeviceLibraryService
deviceLibraryService
;
@Resource
private
ReadWebSocket
readWebSocket
;
@Resource
private
UserCache
userCache
;
@Autowired
private
ReadMachineLibraryService
readMachineLibraryService
;
private
List
<
String
>
RFIDS
=
new
ArrayList
<>();
private
List
<
String
>
existRFIDS
=
new
ArrayList
<>();
private
List
<
String
>
notExistRFIDS
=
new
ArrayList
<>();
public
static
Boolean
localFlag
=
false
;
private
List
<
DeviceLibrary
>
deviceLibraries
=
new
ArrayList
<>();
@Autowired
private
TaskService
taskService
;
@ApiOperation
(
value
=
"保存盘存接口"
,
notes
=
"保存盘存接口"
)
@PostMapping
(
value
=
"/addReadMachineBill"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
<
String
>
addReadMachineBill
(
@RequestBody
SaveReadMachineVos
saveReadMachineVos
)
{
readMachineBillService
.
saveReadMachineBill
(
saveReadMachineVos
);
return
ResponseEntity
.
ok
(
"保存成功"
);
}
@ApiOperation
(
value
=
"保存盘存草稿接口"
,
notes
=
"保存盘存草稿接口"
)
@PostMapping
(
value
=
"/saveReadMachineBillForDraft"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
<
String
>
saveReadMachineBillForDraft
(
@RequestBody
SaveReadMachineVos
saveReadMachineVos
)
{
readMachineBillService
.
saveReadMachineBillForDraft
(
saveReadMachineVos
);
return
ResponseEntity
.
ok
(
"保存草稿成功"
);
}
@ApiOperation
(
value
=
"查询账单的接口"
,
notes
=
"查询账单的接口"
)
@PostMapping
(
value
=
"/findAllBySpec"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
<
Page
<
ReadMachineBill
>>
findAllBySpec
(
@RequestBody
SelectBillVo
selectBillVo
)
{
List
<
ReadMachineBill
>
spec
=
readMachineBillService
.
findAllBySpec
(
selectBillVo
);
spec
.
forEach
(
readMachineBill
->
{
readMachineBill
.
setCreateUserName
(
userCache
.
findById
(
readMachineBill
.
getCreateUserId
()).
getName
());
readMachineBill
.
setTaskId
(
taskService
.
get
(
readMachineBill
.
getId
(),
BusinessEnum
.
READMACHINE
.
id
).
getId
());
});
Page
<
ReadMachineBill
>
perPage
=
PageUtil
.
getPerPage
(
selectBillVo
.
getPage
(),
selectBillVo
.
getSize
(),
spec
,
selectBillVo
.
getPageable
());
return
ResponseEntity
.
ok
(
perPage
);
}
@ApiOperation
(
value
=
"读取装备信息对比的接口"
,
notes
=
"读取装备信息对比的接口"
)
@GetMapping
(
value
=
"/compareDeviceDetail"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
readDeviceDetail
(
Boolean
flag
)
{
if
(
flag
)
{
if
(!
localFlag
)
{
localFlag
=
true
;
startDeviceDetail
();
}
}
else
{
localFlag
=
false
;
}
}
@ApiOperation
(
value
=
"查询详情接口"
,
notes
=
"查询详情接口"
)
@GetMapping
(
value
=
"/readDetail"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
<
BackReadDetailVo
>
readDetail
(
Integer
billId
)
{
BackReadDetailVo
backReadDetailVo
=
new
BackReadDetailVo
();
ReadMachineBill
readMachineBill
=
readMachineBillService
.
findById
(
billId
);
List
<
ReadMachineLibrary
>
readMachineLibraryList
=
readMachineLibraryService
.
findByReadMachineBillId
(
readMachineBill
.
getId
());
readMachineLibraryList
.
forEach
(
ReadMachineLibrary:
:
setConfigName
);
backReadDetailVo
.
setReadNum
(
readMachineBill
.
getReadNum
());
backReadDetailVo
.
setReadMachineLibraries
(
readMachineLibraryList
);
backReadDetailVo
.
setCreateUserName
(
userCache
.
findById
(
readMachineBill
.
getCreateUserId
()).
getName
());
return
ResponseEntity
.
ok
(
backReadDetailVo
);
}
@ApiOperation
(
value
=
"读取ISO放置的位置"
,
notes
=
"读取ISO放置的位置"
)
@GetMapping
(
value
=
"/receiveString"
)
public
ResponseEntity
<
String
>
receiveString
()
{
return
ResponseEntity
.
ok
(
System
.
getProperty
(
"java.library.path"
));
}
@ApiOperation
(
value
=
"任务不保存"
,
notes
=
"任务不保存"
)
@PostMapping
(
value
=
"/notSaveTask"
)
public
ResponseEntity
<
String
>
notSaveTask
(
@RequestBody
SaveDefatVos
saveDefatVos
)
{
readMachineBillService
.
deleteReadMachineBillForDraft
(
saveDefatVos
);
return
ResponseEntity
.
ok
(
"任务已取消"
);
}
/**
* 读取装备信息
*/
public
List
<
DeviceLibrary
>
startDeviceDetail
(){
ReadUtils
readUtils
=
new
ReadUtils
();
//先开启
readUtils
.
testinitreader
();
while
(
localFlag
){
//开始盘存
List
<
String
>
rfids
=
readUtils
.
testinventory1
();
log
.
info
(
"rfid's:{}"
,
rfids
);
RFIDS
.
clear
();
RFIDS
.
addAll
(
rfids
);
List
<
DeviceLibrary
>
deviceLibraryList
=
deviceLibraryService
.
findAllByRfids
(
RFIDS
);
List
<
String
>
existRfids
=
deviceLibraryList
.
stream
().
map
(
DeviceLibrary:
:
getRfidCardId
).
collect
(
Collectors
.
toList
());
existRFIDS
.
clear
();
existRFIDS
.
addAll
(
existRfids
);
RFIDS
.
removeAll
(
existRFIDS
);
notExistRFIDS
.
clear
();
notExistRFIDS
.
addAll
(
RFIDS
);
if
(!
notExistRFIDS
.
isEmpty
()){
notExistRFIDS
.
forEach
(
s
->
readWebSocket
.
sendMessageForReadMachineError
(
s
));
}
deviceLibraries
.
clear
();
deviceLibraries
.
addAll
(
deviceLibraryList
);
log
.
info
(
"deviceLibraries:{}"
,
deviceLibraries
.
size
());
if
(!
deviceLibraries
.
isEmpty
()){
deviceLibraries
.
forEach
(
deviceLibrary
->
{
if
(
ObjectUtil
.
isNotNull
(
deviceLibrary
)){
deviceLibrary
.
setConfigName
();
readWebSocket
.
sendMessageForReadMachine
(
deviceLibrary
);
}
});
}
}
return
deviceLibraries
;
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/controller/ReadMachineLibraryController.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
controller
;
import
com.tykj.dev.config.swagger.AutoDocument
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveReadMachineVos
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineBillService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
/**
* @author zsp
* @create 2021/12/3 10:59
*/
@RestController
@RequestMapping
(
value
=
"/readMachineLibrary"
)
@AutoDocument
@Api
(
tags
=
"盘存库模块"
,
description
=
"盘存库接口"
)
@Slf4j
public
class
ReadMachineLibraryController
{
@Resource
private
ReadMachineBillService
readMachineBillService
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/repository/ReadMachineBillDao.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
repository
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineBill
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
/**
* @author zsp
* @create 2021/12/3 10:52
*/
public
interface
ReadMachineBillDao
extends
JpaRepository
<
ReadMachineBill
,
Integer
>,
JpaSpecificationExecutor
<
ReadMachineBill
>
{
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/repository/ReadMachineLibraryDao.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
repository
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineBill
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 10:52
*/
public
interface
ReadMachineLibraryDao
extends
JpaRepository
<
ReadMachineLibrary
,
Integer
>,
JpaSpecificationExecutor
<
ReadMachineLibrary
>
{
List
<
ReadMachineLibrary
>
findAllByReadMachineId
(
Integer
readMachineId
);
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/service/ReadMachineBillService.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
service
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineBill
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveDefatVos
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveReadMachineVo
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveReadMachineVos
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SelectBillVo
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 10:59
*/
public
interface
ReadMachineBillService
{
/**
* 新增读写盘存账单
* @param readMachineBill 账单实体
* @return 账单实体
*/
ReadMachineBill
addEntity
(
ReadMachineBill
readMachineBill
);
/**
* 根据id查询账单
* @param id 账单id
* @return 账单实体
*/
ReadMachineBill
findById
(
Integer
id
);
/**
* 更新实体
* @param readMachineBill 需要修改账单的实体
* @return 更新后的实体
*/
ReadMachineBill
updateEntity
(
ReadMachineBill
readMachineBill
);
void
deleteEntity
(
Integer
id
);
/**
* 条件查询
* @param selectBillVo 查询条件的vo
* @return 账单实体的集合
*/
List
<
ReadMachineBill
>
findAllBySpec
(
SelectBillVo
selectBillVo
);
/**
* 开始盘点s
* @param saveReadMachineVos 盘点的vo
* @return 账单实体
*/
ReadMachineBill
saveReadMachineBill
(
SaveReadMachineVos
saveReadMachineVos
);
/**
* 保存草稿
* @param saveReadMachineVos 盘点的vos
* @return 账单实体
*/
SaveDefatVos
saveReadMachineBillForDraft
(
SaveReadMachineVos
saveReadMachineVos
);
/**
* 删除草稿
* @param saveDefatVos saveDefatVos
*/
void
deleteReadMachineBillForDraft
(
SaveDefatVos
saveDefatVos
);
void
readDevice
();
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/service/ReadMachineLibraryService.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
service
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 10:59
*/
public
interface
ReadMachineLibraryService
{
/**
* 新增盘存库
* @param readMachineLibrary 盘存库实体
* @return 盘存库实体
*/
ReadMachineLibrary
addEntity
(
ReadMachineLibrary
readMachineLibrary
);
void
batchDeleteEntity
(
List
<
ReadMachineLibrary
>
readMachineLibraries
);
/**
* 根据账单id查询盘存库
* @param readMachineBillId 账单id
* @return 盘存库的集合
*/
List
<
ReadMachineLibrary
>
findByReadMachineBillId
(
Integer
readMachineBillId
);
/**
* 保存全部
* @param readMachineLibraries 全部的实体
*/
void
saveAll
(
List
<
ReadMachineLibrary
>
readMachineLibraries
);
/**
* 批量更新
*/
void
batchUpdate
(
List
<
ReadMachineLibrary
>
readMachineLibraries
);
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/service/impl/ReadMachineBillServiceImpl.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.tykj.dev.device.library.service.DeviceLibraryService
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo
;
import
com.tykj.dev.device.task.service.TaskService
;
import
com.tykj.dev.device.task.subject.bto.TaskBto
;
import
com.tykj.dev.device.user.util.UserUtils
;
import
com.tykj.dev.misc.base.BusinessEnum
;
import
com.tykj.dev.misc.base.StatusEnum
;
import
com.tykj.dev.misc.utils.DeviceSeqUtil
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineBill
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveDefatVos
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveReadMachineVo
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SaveReadMachineVos
;
import
com.tykj.dev.readmachine.devreadmachine.Vo.SelectBillVo
;
import
com.tykj.dev.readmachine.devreadmachine.repository.ReadMachineBillDao
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineBillService
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineLibraryService
;
import
com.tykj.dev.readmachine.devreadmachine.util.BeanDtoVoUtils
;
import
com.tykj.dev.rfid.timeTask.ReadUtils
;
import
com.tykj.dev.socket.MyWebSocket
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.persistence.Transient
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.concurrent.CompletableFuture
;
/**
* @author zsp
* @create 2021/12/3 11:00
*/
@Service
@Slf4j
public
class
ReadMachineBillServiceImpl
implements
ReadMachineBillService
{
@Autowired
private
ReadMachineBillDao
readMachineBillDao
;
@Resource
private
UserUtils
userUtils
;
@Autowired
private
ReadMachineLibraryService
readMachineLibraryService
;
@Resource
private
TaskService
taskService
;
@Resource
private
MyWebSocket
myWebSocket
;
@Resource
private
DeviceLibraryService
deviceLibraryService
;
@Override
public
ReadMachineBill
addEntity
(
ReadMachineBill
readMachineBill
)
{
return
readMachineBillDao
.
save
(
readMachineBill
);
}
@Override
public
ReadMachineBill
findById
(
Integer
id
)
{
Optional
<
ReadMachineBill
>
byId
=
readMachineBillDao
.
findById
(
id
);
ReadMachineBill
readMachineBill
=
new
ReadMachineBill
();
if
(
byId
.
isPresent
()){
readMachineBill
=
byId
.
get
();
}
return
readMachineBill
;
}
@Override
public
ReadMachineBill
updateEntity
(
ReadMachineBill
readMachineBill
)
{
return
readMachineBillDao
.
save
(
readMachineBill
);
}
@Override
public
void
deleteEntity
(
Integer
id
)
{
readMachineBillDao
.
deleteById
(
id
);
}
@Override
public
List
<
ReadMachineBill
>
findAllBySpec
(
SelectBillVo
selectBillVo
)
{
PredicateBuilder
<
ReadMachineBill
>
predicateBuilder
=
getPredicateBuilder
(
selectBillVo
);
//查询当前登录的单位id
predicateBuilder
.
eq
(
"createUnitId"
,
userUtils
.
getCurrentUnitId
());
return
readMachineBillDao
.
findAll
(
predicateBuilder
.
build
());
}
@Override
public
ReadMachineBill
saveReadMachineBill
(
SaveReadMachineVos
saveReadMachineVos
)
{
//构建task涉及人员集合
List
<
Integer
>
userIds
=
new
ArrayList
<>();
userIds
.
add
(
userUtils
.
getCurrentUserId
());
userIds
.
add
(
0
);
List
<
ReadMachineLibrary
>
readMachineLibraries
=
new
ArrayList
<>();
//保存后的账单实体
ReadMachineBill
readMachineBill1
=
null
;
TaskBto
start
;
if
(
ObjectUtil
.
isNotNull
(
saveReadMachineVos
)){
//判断是不是从草稿进来的
if
(
saveReadMachineVos
.
getTaskId
()!=
null
){
//说明是从草稿进来的
start
=
taskService
.
get
(
saveReadMachineVos
.
getTaskId
());
readMachineLibraries
=
readMachineLibraryService
.
findByReadMachineBillId
(
start
.
getBillId
());
ReadMachineBill
readMachineBill
=
findById
(
start
.
getBillId
());
readMachineBill
.
setStatus
(
1
);
readMachineBill1
=
updateEntity
(
readMachineBill
);
}
else
{
List
<
SaveReadMachineVo
>
saveReadMachineVo
=
saveReadMachineVos
.
getSaveReadMachineVo
();
ReadMachineBill
readMachineBill
=
new
ReadMachineBill
();
readMachineBill
.
setTitle
(
saveReadMachineVos
.
getTitle
());
readMachineBill
.
setReadNum
(
saveReadMachineVos
.
getReadNum
());
readMachineBill
.
setStatus
(
1
);
readMachineBill1
=
addEntity
(
readMachineBill
);
String
content
=
"完结盘存盘点任务"
;
TaskBto
taskBto
=
new
TaskBto
(
StatusEnum
.
READ_DEAFT
.
id
,
content
,
"."
,
readMachineBill1
.
getId
(),
BusinessEnum
.
READMACHINE
.
id
,
userUtils
.
getCurrentUnitId
(),
0
,
userIds
);
start
=
taskService
.
start
(
taskBto
);
readMachineBill1
.
setTaskId
(
start
.
getId
());
if
(!
saveReadMachineVo
.
isEmpty
()){
for
(
SaveReadMachineVo
readMachineVo
:
saveReadMachineVo
)
{
ReadMachineLibrary
readMachineLibrary
=
readMachineVo
.
toEntity
();
readMachineLibrary
.
setReadMachineId
(
readMachineBill1
.
getId
());
readMachineLibraries
.
add
(
readMachineLibrary
);
}
}
}
//做异步保存
List
<
ReadMachineLibrary
>
finalReadMachineLibraries
=
readMachineLibraries
;
CompletableFuture
.
runAsync
(()->
readMachineLibraryService
.
saveAll
(
finalReadMachineLibraries
));
taskService
.
moveToEnd
(
start
);
assert
readMachineBill1
!=
null
;
readMachineBill1
.
setCreateUnitId
(
userUtils
.
getCurrentUnitId
());
readMachineBill1
=
updateEntity
(
readMachineBill1
);
}
return
readMachineBill1
;
}
@Override
public
SaveDefatVos
saveReadMachineBillForDraft
(
SaveReadMachineVos
saveReadMachineVos
)
{
SaveDefatVos
saveDefatVos
=
new
SaveDefatVos
();
List
<
ReadMachineLibrary
>
readMachineLibraries
=
new
ArrayList
<>();
if
(
saveReadMachineVos
.
getTaskId
()
==
null
){
//第一次保存
//构建task涉及人员集合
List
<
Integer
>
userIds
=
new
ArrayList
<>();
userIds
.
add
(
userUtils
.
getCurrentUserId
());
userIds
.
add
(
0
);
ReadMachineBill
readMachineBill1
=
null
;
TaskBto
start
;
if
(
ObjectUtil
.
isNotNull
(
saveReadMachineVos
)){
List
<
SaveReadMachineVo
>
saveReadMachineVo
=
saveReadMachineVos
.
getSaveReadMachineVo
();
ReadMachineBill
readMachineBill
=
new
ReadMachineBill
();
readMachineBill
.
setTitle
(
saveReadMachineVos
.
getTitle
());
readMachineBill
.
setReadNum
(
saveReadMachineVos
.
getReadNum
());
readMachineBill
.
setCreateUnitId
(
userUtils
.
getCurrentUnitId
());
readMachineBill
.
setStatus
(
0
);
readMachineBill1
=
addEntity
(
readMachineBill
);
//保存草稿
String
content
=
"保存盘存草稿"
;
TaskBto
taskBto
=
new
TaskBto
(
StatusEnum
.
READ_DEAFT
.
id
,
content
,
"."
,
readMachineBill1
.
getId
(),
BusinessEnum
.
READMACHINE
.
id
,
userUtils
.
getCurrentUnitId
(),
0
,
userIds
);
start
=
taskService
.
start
(
taskBto
);
readMachineBill1
.
setTaskId
(
start
.
getId
());
if
(!
saveReadMachineVo
.
isEmpty
()){
for
(
SaveReadMachineVo
readMachineVo
:
saveReadMachineVo
)
{
ReadMachineLibrary
readMachineLibrary
=
readMachineVo
.
toEntity
();
readMachineLibrary
.
setReadMachineId
(
readMachineBill1
.
getId
());
readMachineLibraries
.
add
(
readMachineLibrary
);
}
}
saveDefatVos
.
setTaskId
(
start
.
getId
());
saveDefatVos
.
setReadMachineLibraries
(
readMachineLibraries
);
saveDefatVos
.
setReadMachineBillId
(
readMachineBill1
.
getId
());
}
}
else
{
//更新 账单和库存
TaskBto
taskBto
=
taskService
.
get
(
saveReadMachineVos
.
getTaskId
());
ReadMachineBill
readMachineBill
=
findById
(
taskBto
.
getBillId
());
readMachineBill
.
setReadNum
(
saveReadMachineVos
.
getReadNum
());
readMachineBill
.
setStatus
(
0
);
updateEntity
(
readMachineBill
);
List
<
ReadMachineLibrary
>
saveReadMachineVo
=
readMachineLibraryService
.
findByReadMachineBillId
(
taskBto
.
getBillId
());
if
(!
saveReadMachineVo
.
isEmpty
()){
// saveReadMachineVo.forEach(saveReadMachineVo1 -> {
// ReadMachineLibrary readMachineLibrary = new ReadMachineLibrary();
// BeanUtils.copyProperties(saveReadMachineVo1,readMachineLibrary);
// readMachineLibraries.add(readMachineLibrary);
// });
readMachineLibraries
.
addAll
(
Objects
.
requireNonNull
(
BeanDtoVoUtils
.
listVo
(
saveReadMachineVo
,
ReadMachineLibrary
.
class
)));
}
saveDefatVos
.
setTaskId
(
taskBto
.
getId
());
saveDefatVos
.
setReadMachineLibraries
(
readMachineLibraries
);
saveDefatVos
.
setReadMachineBillId
(
taskBto
.
getBillId
());
}
//做异步保存
CompletableFuture
.
runAsync
(()->
readMachineLibraryService
.
batchUpdate
(
readMachineLibraries
));
return
saveDefatVos
;
}
@Override
public
void
deleteReadMachineBillForDraft
(
SaveDefatVos
saveDefatVos
)
{
Integer
taskId
=
saveDefatVos
.
getTaskId
();
taskService
.
deleteById
(
taskId
);
//账单也删除
deleteEntity
(
saveDefatVos
.
getReadMachineBillId
());
//库存也删除
CompletableFuture
.
runAsync
(()->
readMachineLibraryService
.
batchDeleteEntity
(
saveDefatVos
.
getReadMachineLibraries
()));
}
@Override
public
void
readDevice
()
{
List
<
String
>
rfids
=
startDeviceDetail
();
List
<
DeviceLibrary
>
deviceLibraries
=
deviceLibraryService
.
findAllByRfids
(
rfids
);
//可以查询出来装备的集合
List
<
DeviceLibrary
>
result
=
new
ArrayList
<>();
if
(!
deviceLibraries
.
isEmpty
()){
deviceLibraries
.
forEach
(
deviceLibrary
->
{
if
(
ObjectUtil
.
isNotNull
(
deviceLibrary
)){
result
.
add
(
deviceLibrary
);
myWebSocket
.
sendMessageForReadMachine
(
deviceLibrary
);
}
});
}
}
/**
* 读取装备信息
*/
private
List
<
String
>
startDeviceDetail
(){
ReadUtils
readUtils
=
new
ReadUtils
();
//先开启
readUtils
.
testinitreader
();
//开始盘存
List
<
String
>
rfids
=
readUtils
.
testinventory1
();
log
.
info
(
"rfids:{}"
,
rfids
);
return
rfids
;
}
/**
* 构建条件插叙构造器
* @param selectBillVo 条件查询构造器
* @return
*/
private
PredicateBuilder
<
ReadMachineBill
>
getPredicateBuilder
(
SelectBillVo
selectBillVo
)
{
PredicateBuilder
<
ReadMachineBill
>
predicateBuilder
=
Specifications
.
and
();
//根据操作时间查询
predicateBuilder
.
ge
(
selectBillVo
.
getStartTime
()!=
null
,
"createTime"
,
selectBillVo
.
getStartTime
());
predicateBuilder
.
le
(
selectBillVo
.
getEndTime
()!=
null
,
"createTime"
,
selectBillVo
.
getEndTime
());
return
predicateBuilder
;
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/service/impl/ReadMachineLibraryServiceImpl.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
service
.
impl
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
com.tykj.dev.readmachine.devreadmachine.repository.ReadMachineLibraryDao
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineLibraryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/3 11:00
*/
@Service
public
class
ReadMachineLibraryServiceImpl
implements
ReadMachineLibraryService
{
@Autowired
private
ReadMachineLibraryDao
readMachineLibraryDao
;
/**
* 新增盘存库
*
* @param readMachineLibrary 盘存库实体
* @return 盘存库实体
*/
@Override
public
ReadMachineLibrary
addEntity
(
ReadMachineLibrary
readMachineLibrary
)
{
return
readMachineLibraryDao
.
save
(
readMachineLibrary
);
}
@Override
public
void
batchDeleteEntity
(
List
<
ReadMachineLibrary
>
readMachineLibraries
)
{
readMachineLibraryDao
.
deleteAll
(
readMachineLibraries
);
}
/**
* 根据账单id查询盘存库
*
* @param readMachineBillId 账单id
* @return 盘存库的集合
*/
@Override
public
List
<
ReadMachineLibrary
>
findByReadMachineBillId
(
Integer
readMachineBillId
)
{
return
readMachineLibraryDao
.
findAllByReadMachineId
(
readMachineBillId
);
}
/**
* 保存全部
*
* @param readMachineLibraries 全部的实体
*/
@Override
public
void
saveAll
(
List
<
ReadMachineLibrary
>
readMachineLibraries
)
{
readMachineLibraryDao
.
saveAll
(
readMachineLibraries
);
}
@Override
public
void
batchUpdate
(
List
<
ReadMachineLibrary
>
readMachineLibraries
)
{
readMachineLibraryDao
.
saveAll
(
readMachineLibraries
);
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/socket/Message.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
socket
;
/**
* @author zjm
* @version 1.0.0
* @ClassName Message.java
* @Description TODO
* @createTime 2020年08月23日 12:30:00
*/
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
Message
{
private
Integer
isRequest
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/socket/MessageError.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
socket
;
/**
* zsp
*/
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
MessageError
{
private
String
rfid
;
private
String
message
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/socket/ReadWebSocket.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
socket
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tykj.dev.readmachine.devreadmachine.controller.ReadMachineBillController
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
javax.websocket.*
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author zjm
* @version 1.0.0
* @ClassName MyWebSocket.java
* @Description TODO
* @createTime 2020年08月19日 23:53:00
*/
@Slf4j
@ServerEndpoint
(
value
=
"/websocket/{userId}"
)
//接受websocket请求路径
@Component
//注册到spring容器中
@Data
public
class
ReadWebSocket
{
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
*/
private
static
ConcurrentHashMap
<
String
,
ReadWebSocket
>
webSocketMap
=
new
ConcurrentHashMap
<>();
/**
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
*/
private
Session
session
;
/**
* 接收userId
*/
private
String
userId
;
/**
* 发送自定义消息
*/
public
static
void
sendInfo
(
String
message
,
String
userId
)
throws
IOException
{
log
.
info
(
"发送消息到:"
+
userId
+
",报文:"
+
message
);
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
webSocketMap
.
containsKey
(
userId
))
{
webSocketMap
.
get
(
userId
).
sendMessage
(
message
);
}
else
{
log
.
error
(
"用户"
+
userId
+
",不在线!"
);
}
}
/**
* 连接建立成功调用的方法
*/
@OnOpen
public
void
onOpen
(
Session
session
,
@PathParam
(
"userId"
)
String
userId
)
{
this
.
session
=
session
;
this
.
userId
=
userId
;
if
(
webSocketMap
.
containsKey
(
userId
))
{
webSocketMap
.
remove
(
userId
);
webSocketMap
.
put
(
userId
,
this
);
//加入set中
}
else
{
webSocketMap
.
put
(
userId
,
this
);
//加入set中
//在线数加1
}
log
.
info
(
"用户连接:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
sendMessage
(
"连接成功"
);
}
/**
* 连接关闭调用的方法
*/
@OnClose
public
void
onClose
()
{
//从set中删除
webSocketMap
.
remove
(
userId
);
if
(
webSocketMap
.
size
()
==
0
){
ReadMachineBillController
.
localFlag
=
false
;
}
log
.
info
(
"用户退出:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
}
public
void
Close
(
String
userId
)
{
//从set中删除
webSocketMap
.
remove
(
userId
);
log
.
info
(
"用户退出:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
}
public
ReadWebSocket
getMap
(
String
userId
)
{
ReadWebSocket
myWebSocket
=
webSocketMap
.
get
(
userId
);
log
.
info
(
"用户退出:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
return
myWebSocket
;
}
/**
* 收到客户端消息后调用的方法
* @param message 客户端发送过来的消息
*/
@OnMessage
public
void
onMessage
(
String
message
,
Session
session
)
{
log
.
info
(
"用户消息:"
+
userId
+
",报文:"
+
message
);
//可以群发消息
//消息保存到数据库、redis
if
(
StringUtils
.
isNotBlank
(
message
))
{
try
{
//解析发送的报文
JSONObject
jsonObject
=
JSON
.
parseObject
(
message
);
//追加发送人(防止串改)
jsonObject
.
put
(
"fromUserId"
,
this
.
userId
);
String
toUserId
=
jsonObject
.
getString
(
"toUserId"
);
//传送给对应toUserId用户的websocket
if
(
StringUtils
.
isNotBlank
(
toUserId
)
&&
webSocketMap
.
containsKey
(
toUserId
))
{
webSocketMap
.
get
(
toUserId
).
sendMessage
(
jsonObject
.
toJSONString
());
}
else
{
log
.
error
(
"请求的userId:"
+
toUserId
+
"不在该服务器上"
);
//否则不在这个服务器上,发送到mysql或者redis
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* @param session
* @param error
*/
@OnError
public
void
onError
(
Session
session
,
Throwable
error
)
{
log
.
error
(
"用户错误:"
+
this
.
userId
+
",原因:"
+
error
.
getMessage
());
error
.
printStackTrace
();
}
/**
* 实现服务器主动推送
*/
public
void
sendMessage
(
String
message
)
{
try
{
this
.
session
.
getBasicRemote
().
sendText
(
JSONObject
.
toJSONString
(
new
Message
(
1
)));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
/**
* 实现服务器主动推送
*/
public
void
sendMessage2
(
Object
o
)
{
try
{
this
.
session
.
getBasicRemote
().
sendText
(
JSONObject
.
toJSONString
(
o
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
void
sendMessage1
()
{
for
(
String
i
:
webSocketMap
.
keySet
())
{
webSocketMap
.
get
(
i
).
sendMessage
(
"1"
);
}
}
public
void
sendMessageForReadMachine
(
Object
o
)
{
for
(
String
i
:
webSocketMap
.
keySet
())
{
webSocketMap
.
get
(
i
).
sendMessage2
(
o
);
}
}
public
void
sendMessageForReadMachine1
(
Object
o
,
Integer
userId
)
{
webSocketMap
.
get
(
String
.
valueOf
(
userId
)).
sendMessage2
(
o
);
}
public
void
sendMessageForReadMachineError
(
String
rfid
)
{
for
(
String
i
:
webSocketMap
.
keySet
())
{
webSocketMap
.
get
(
i
).
sendMessage2
(
new
MessageError
(
rfid
,
"该RFID为:"
+
rfid
+
"设备查询不到"
));
}
}
/**
* 判断是否断开连接,断开返回true,没有返回false
* @param socket
* @return
*/
// public Boolean isServerClose(Socket socket){
// try{
// socket.sendUrgentData(0xFF);//发送1个字节的紧急数据,默认情况下,服务器端没有开启紧急数据处理,不影响正常通信
// return false;
// }catch(Exception se){
// return true;
// }
// }
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/toBack/BackReadDetailVo.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
toBack
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* @author zsp
* @create 2021/12/7 9:24
*/
@Data
@ApiModel
(
"详情的返回vo"
)
public
class
BackReadDetailVo
{
@ApiModelProperty
(
value
=
"本次盘存的盘存库"
)
private
List
<
ReadMachineLibrary
>
readMachineLibraries
;
@ApiModelProperty
(
value
=
"操作人"
)
private
String
createUserName
;
@ApiModelProperty
(
value
=
"本次盘存的数量"
)
private
Integer
readNum
;
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/util/BeanDtoVoUtils.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
util
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author zsp
* @create 2021/12/7 10:15
*/
public
class
BeanDtoVoUtils
{
/**
* TODO dot ,Do ,entity 相互转换
* 同:BeanUtils.copyProperties(dtoEntity, newInstance);
*
* @param oldClass 原数据--Dto,Vo,entity
* @param newClass 转换为--Dto,Vo,entity
* @return
*/
public
static
<
E
>
E
convert
(
Object
oldClass
,
Class
<
E
>
newClass
)
{
// 判断oldClass 是否为空!
if
(
oldClass
==
null
)
{
return
null
;
}
// 判断newClass 是否为空
if
(
newClass
==
null
)
{
return
null
;
}
try
{
// 创建新的对象实例
E
newInstance
=
newClass
.
newInstance
();
// 把原对象数据拷贝到新的对象
BeanUtils
.
copyProperties
(
oldClass
,
newInstance
);
// 返回新对象
return
newInstance
;
}
catch
(
Exception
e
)
{
return
null
;
}
}
//TODO Page<Entity> 分页对象转 Page<Vo> ( list 循环)
public
static
<
T
,
V
>
Page
<
V
>
pageVo
(
Page
<
T
>
page
,
Class
<
V
>
v
)
{
try
{
List
<
T
>
tList
=
page
.
getContent
();
List
<
V
>
voList
=
new
ArrayList
<>();
for
(
T
t
:
tList
)
{
V
newv
=
(
V
)
BeanDtoVoUtils
.
convert
(
t
,
v
.
newInstance
().
getClass
());
voList
.
add
(
newv
);
}
Page
<
V
>
vs
=
new
PageImpl
<>(
voList
,
page
.
getPageable
(),
page
.
getTotalElements
());
return
vs
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
//TODO Page<Entity> 分页对象转 Page<Vo> (Stream 方式)
public
static
<
T
,
V
>
Page
<
V
>
pageVoStream
(
Page
<
T
>
page
,
Class
<
V
>
v
)
{
List
<
V
>
voList
=
page
.
getContent
().
stream
().
map
(
item
->
{
try
{
return
(
V
)
BeanDtoVoUtils
.
convert
(
item
,
v
.
newInstance
().
getClass
());
}
catch
(
InstantiationException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}).
collect
(
Collectors
.
toList
());
Page
<
V
>
vs
=
new
PageImpl
<>(
voList
,
page
.
getPageable
(),
page
.
getTotalElements
());
return
vs
;
}
//TODO list<Entity> 集合对象转list<Vo> ( list 循环)
public
static
<
T
,
V
>
List
<
V
>
listVo
(
List
<
T
>
oldList
,
Class
<
V
>
v
)
{
try
{
List
<
V
>
voList
=
new
ArrayList
<>();
for
(
T
t
:
oldList
)
{
V
newv
=
(
V
)
BeanDtoVoUtils
.
convert
(
t
,
v
.
newInstance
().
getClass
());
voList
.
add
(
newv
);
}
return
voList
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
//TODO list<Entity> 集合对象转list<Vo> (Stream 方式)
public
static
<
T
,
V
>
List
<
V
>
listVoStream
(
List
<
T
>
oldList
,
Class
<
V
>
v
)
{
List
<
V
>
voList
=
oldList
.
stream
().
map
(
item
->
{
try
{
return
(
V
)
BeanDtoVoUtils
.
convert
(
item
,
v
.
newInstance
().
getClass
());
}
catch
(
InstantiationException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}).
collect
(
Collectors
.
toList
());
return
voList
;
}
}
dev-readmachine/src/main/java/com/tykj/dev/readmachine/devreadmachine/util/ReadUtils.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
.
util
;
import
com.uhf.api.cls.Reader
;
import
com.uhf.api.cls.Reader.*
;
import
lombok.Data
;
@Data
public
class
ReadUtils
{
/**
* @param args
*/
int
AntCount
=
1
;
String
ReaderAddr
=
"192.168.101.201"
;
//读写机ip
// String ReaderAddr="192.168.0.201";
Reader
Jreader
;
public
ReadUtils
()
{
Jreader
=
new
Reader
();
}
public
void
testtran
(){
byte
[]
hex
=
new
byte
[]{(
byte
)
0xA2
,(
byte
)
0xC8
,(
byte
)
0xD4
,(
byte
)
0xE5
};
int
len
=
4
;
char
[]
str
=
new
char
[
4
*
2
];
Jreader
.
Hex2Str
(
hex
,
len
,
str
);
String
hstr
=
""
;
for
(
int
i
=
0
;
i
<
8
;
i
++)
hstr
+=(
char
)
str
[
i
];
System
.
out
.
println
(
"test tohexstr:"
+
hstr
);
String
buf
=
"0011110000001111"
;
byte
[]
binarybuf
=
new
byte
[
2
];
String
buf2
=
"abcdef08"
;
byte
[]
hexbuf
=
new
byte
[
4
];
Jreader
.
Str2Binary
(
buf
,
buf
.
length
(),
binarybuf
);
System
.
out
.
println
(
"test binary:"
);
for
(
int
i
=
0
;
i
<
binarybuf
.
length
;
i
++)
System
.
out
.
println
(
binarybuf
[
i
]);
Jreader
.
Str2Hex
(
buf2
,
8
,
hexbuf
);
System
.
out
.
println
(
"test hex:"
);
for
(
int
i
=
0
;
i
<
hexbuf
.
length
;
i
++)
System
.
out
.
println
(
hexbuf
[
i
]);
}
public
void
testpsam
(){
int
soltid
=
1
;
int
coslen
=
2
;
byte
[]
cos
=
new
byte
[]{
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
,
0x77
,(
byte
)
0x88
,(
byte
)
0x99
,
0x12
,
0x34
};
int
[]
cosresplen
=
new
int
[
1
];
byte
[]
cosresp
=
new
byte
[
cos
.
length
+
13
];
byte
[]
errcode
=
new
byte
[
4
];
READER_ERR
er
=
Jreader
.
PsamTransceiver
(
soltid
,
coslen
,
cos
,
cosresplen
,
cosresp
,
errcode
,
(
short
)
1000
);
}
public
void
testcustomcmd
()
{
//m4 qt
IMPINJM4QtPara
CustomPara
=
Jreader
.
new
IMPINJM4QtPara
();
CustomPara
.
TimeOut
=
800
;
CustomPara
.
CmdType
=
1
;
CustomPara
.
MemType
=
2
;
CustomPara
.
PersistType
=
3
;
CustomPara
.
RangeType
=
4
;
CustomPara
.
AccessPwd
=
new
byte
[]{
0x11
,
0x22
,
0x33
,
0x44
};
IMPINJM4QtResult
CustomRet
=
Jreader
.
new
IMPINJM4QtResult
();
Jreader
.
CustomCmd
(
1
,
CustomCmdType
.
IMPINJ_M4_Qt
,
CustomPara
,
CustomRet
);
//allen h3
ALIENHiggs3BlockReadLockPara
CustomPara2
=
Jreader
.
new
ALIENHiggs3BlockReadLockPara
();
CustomPara2
.
AccessPwd
=
new
byte
[]{
0x55
,
0x66
,
0x77
,(
byte
)
0x88
};
CustomPara2
.
BlkBits
=
6
;
CustomPara2
.
TimeOut
=
890
;
Jreader
.
CustomCmd
(
1
,
CustomCmdType
.
ALIEN_Higgs3_BlockReadLock
,
CustomPara2
,
null
);
//nexp eas
NXPChangeEASPara
CustomPara3
=
Jreader
.
new
NXPChangeEASPara
();
CustomPara3
.
AccessPwd
=
new
byte
[]{(
byte
)
0x99
,(
byte
)
0xaa
,(
byte
)
0xbb
,(
byte
)
0xcc
};
CustomPara3
.
isSet
=
1
;
CustomPara3
.
TimeOut
=
900
;
Jreader
.
CustomCmd
(
1
,
CustomCmdType
.
NXP_ChangeEAS
,
CustomPara3
,
null
);
//nxp easl
NXPEASAlarmPara
CustomPara4
=
Jreader
.
new
NXPEASAlarmPara
();
CustomPara4
.
DR
=
7
;
CustomPara4
.
MC
=
11
;
CustomPara4
.
TimeOut
=
950
;
CustomPara4
.
TrExt
=
17
;
NXPEASAlarmResult
CustomRet2
=
Jreader
.
new
NXPEASAlarmResult
();
Jreader
.
CustomCmd
(
1
,
CustomCmdType
.
NXP_EASAlarm
,
CustomPara4
,
CustomRet2
);
//basetype
Jreader
.
CustomCmd_BaseType
(
1
,
1
,
new
byte
[]{
0x11
,(
byte
)
0x99
,(
byte
)
0xbb
},
new
byte
[]{});
}
public
void
testreadandwrite
(){
/*
* READER_ERR WriteTagData(int ant,char bank,int address, byte[] data, int datalen, byte[] accesspasswd,short timeout);
* ant ???????????
* bank ??????? 0????????? 1???epc?? 2???tid?? 3???user??
* address ???????? ???epc?????????
* data ???????
* datalen ?????????????
* accesspwd ??????????"00000000" 8????????????
* timeout ??????????
*/
String
pwd
=
"00000000"
;
byte
[]
data
=
new
byte
[]{
0x00
,
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
,
0x77
,(
byte
)
0x88
,(
byte
)
0x99
,(
byte
)
0xaa
,(
byte
)
0xbb
};
byte
[]
pwdb
=
new
byte
[
4
];
Jreader
.
Str2Hex
(
pwd
,
pwd
.
length
(),
pwdb
);
//?????
READER_ERR
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
1
,
2
,
data
,
6
,
pwdb
,
(
short
)
1000
);
byte
[]
datar
=
new
byte
[
12
];
//??????
/*
* READER_ERR GetTagData(int ant,char bank, int address, int blkcnt,byte[] data, byte[] accesspasswd, short timeout);
* ant ???????????
* bank ??????? 0????????? 1???epc?? 2???tid?? 3???user??
* address ???????? ???epc?????????
* blkcnt ?????????
* data ??????????????ò????blkcnt*2
* accesspwd ??????????"00000000" 8????????????
* timeout ??????????
*/
er
=
Jreader
.
GetTagData
(
1
,
(
char
)
1
,
2
,
6
,
datar
,
null
,
(
short
)
1000
);
String
str1
=
""
;
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
str1
+=
Integer
.
toHexString
(
datar
[
i
]&
0xff
);
}
System
.
out
.
println
(
er
.
toString
()+
" "
+
str1
.
toUpperCase
());
byte
[]
data2
=
new
byte
[]{(
byte
)
0xFF
,
0x01
,
0x22
,
0x03
,
0x44
,
0x05
,
0x66
,
0x07
,(
byte
)
0x88
,(
byte
)
0x09
,(
byte
)
0xaa
,(
byte
)
0x0b
};
er
=
Jreader
.
WriteTagEpcEx
(
1
,
data2
,
12
,
null
,
(
short
)
1000
);
er
=
Jreader
.
GetTagData
(
1
,
(
char
)
1
,
2
,
6
,
datar
,
null
,
(
short
)
1000
);
str1
=
""
;
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
str1
+=
Integer
.
toHexString
(
datar
[
i
]&
0xff
);
}
System
.
out
.
println
(
er
.
toString
()+
" "
+
str1
.
toUpperCase
());
}
public
void
testblockop
()
{
String
pwd
=
"11000000"
;
byte
[]
data
=
new
byte
[
4
];
Jreader
.
Str2Hex
(
pwd
,
pwd
.
length
(),
data
);
//??????
READER_ERR
er
=
Jreader
.
BlockErase
(
1
,
(
char
)
1
,
2
,
12
,
data
,
(
short
)
1000
);
//????????
Jreader
.
BlockPermaLock
(
1
,
1
,
2
,
6
,
new
byte
[]{(
byte
)
0xff
,(
byte
)
0xff
},
data
,
(
short
)
1000
);
}
public
void
testinitreader
()
{
//?????????
/* ?????????????????
* src ???? ip???????????
* rtype ???????????4?????????4
* ?????????READER_ERR ,MT_OK_ERR????????????????????
*/
READER_ERR
er
=
Jreader
.
InitReader
(
ReaderAddr
,
Reader_Type
.
MODULE_ONE_ANT
);
// READER_ERR er=Jreader.InitReader_Notype(ReaderAddr,AntCount);
System
.
out
.
println
(
er
.
toString
());
/*
* ?????????????AntPowerConf
* ?????
* AntPower????
* antcnt??????????
* AntPower????
* antid ?????
* readPower ??????
* writePower ?????
*/
AntPowerConf
apcf
=
Jreader
.
new
AntPowerConf
();
apcf
.
antcnt
=
AntCount
;
for
(
int
i
=
0
;
i
<
apcf
.
antcnt
;
i
++)
{
AntPower
jaap
=
Jreader
.
new
AntPower
();
jaap
.
antid
=
i
+
1
;
jaap
.
readPower
=
2800
;
jaap
.
writePower
=
2750
;
apcf
.
Powers
[
i
]=
jaap
;
}
AntPowerConf
apcf2
=
Jreader
.
new
AntPowerConf
();
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_RF_ANTPOWER
,
apcf
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_ANTPOWER
,
apcf2
);
for
(
int
i
=
0
;
i
<
apcf2
.
antcnt
;
i
++)
{
System
.
out
.
print
(
"antid:"
+
apcf2
.
Powers
[
i
].
antid
);
System
.
out
.
print
(
" rp:"
+
apcf2
.
Powers
[
i
].
readPower
);
System
.
out
.
print
(
" wp:"
+
apcf2
.
Powers
[
i
].
writePower
);
System
.
out
.
println
();
}
Inv_Potls_ST
ipst
=
Jreader
.
new
Inv_Potls_ST
();
ipst
.
potlcnt
=
1
;
ipst
.
potls
=
new
Inv_Potl
[
1
];
for
(
int
i
=
0
;
i
<
ipst
.
potlcnt
;
i
++)
{
Inv_Potl
ipl
=
Jreader
.
new
Inv_Potl
();
ipl
.
weight
=
30
;
ipl
.
potl
=
SL_TagProtocol
.
SL_TAG_PROTOCOL_GEN2
;
ipst
.
potls
[
0
]=
ipl
;
}
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_INVPOTL
,
ipst
);
/*
* ?????????????
* ???????????1???????????0????????
*/
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_READER_IS_CHK_ANT
,
0
);
}
public
void
testinventory1
()
{
/*
*
* ???????????????????????????????????
* HoptableData_ST ??????????
* lenhtb ?????????
* htb ????int???????????????
HoptableData_ST hdst=Jreader.new HoptableData_ST();
hdst.lenhtb=2;
hdst.htb[0]=915250;
hdst.htb[1]=915750;
READER_ERR er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_FREQUENCY_HOPTABLE,hdst);
*/
/* ants ????????????????????????????
* antcnt ???????????
* timeout ??????????
* pTInfo ??????????????
* tagcnt ????????????????????????????
*/
int
[]
tagcnt
=
new
int
[
1
];
TAGINFO
[]
taginfo
=
new
TAGINFO
[
200
];
READER_ERR
er
=
Jreader
.
TagInventory
(
new
int
[]{
1
},
1
,
(
short
)
1000
,
taginfo
,
tagcnt
);
if
(
er
==
READER_ERR
.
MT_OK_ERR
)
{
for
(
int
i
=
0
;
i
<
tagcnt
[
0
];
i
++)
{
System
.
out
.
println
(
"inv1_epc:"
+
Reader
.
bytes_Hexstr
(
taginfo
[
i
].
EpcId
));
}
}
}
public
void
testinventory2
()
{
int
[]
tagcnt
=
new
int
[
1
];
TAGINFO
taginfo
=
Jreader
.
new
TAGINFO
();
READER_ERR
er
=
Jreader
.
TagInventory_Raw
(
new
int
[]{
1
},
1
,
(
short
)
1000
,
tagcnt
);
for
(
int
i
=
0
;
i
<
tagcnt
[
0
];
i
++)
{
er
=
Jreader
.
GetNextTag
(
taginfo
);
if
(
taginfo
!=
null
)
System
.
out
.
println
(
"inv2_epc:"
+
Reader
.
bytes_Hexstr
(
taginfo
.
EpcId
));
}
byte
[]
outbuf
=
new
byte
[
800
];
er
=
Jreader
.
TagInventory_Raw
(
new
int
[]{
1
},
1
,
(
short
)
1000
,
tagcnt
);
er
=
Jreader
.
GetNextTag_BaseType
(
outbuf
);
}
public
void
testdataonreader
()
{
byte
[]
data3
=
new
byte
[
100
];
READER_ERR
er
=
Jreader
.
ReadDataOnReader
(
0
,
data3
,
100
);
er
=
Jreader
.
SaveDataOnReader
(
0
,
data3
,
100
);
//???????????????
er
=
Jreader
.
EraseDataOnReader
();
}
public
void
testkilltag
()
{
String
pwd
=
"11000000"
;
byte
[]
data
=
new
byte
[
4
];
Jreader
.
Str2Hex
(
pwd
,
pwd
.
length
(),
data
);
READER_ERR
er
=
Jreader
.
KillTag
(
1
,
data
,
(
short
)
1000
);
}
public
void
testlocktag
()
{
String
pwd
=
"12340000"
;
// READER_ERR er=Jreader.Lock180006BTag(1, 2, 6, (short) 1000);
byte
[]
data
=
new
byte
[
4
];
Jreader
.
Str2Hex
(
pwd
,
pwd
.
length
(),
data
);
//?????
READER_ERR
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
0
,
2
,
data
,
2
,
null
,
(
short
)
1000
);
er
=
Jreader
.
LockTag
(
1
,
(
byte
)
Lock_Obj
.
LOCK_OBJECT_BANK1
.
value
(),
(
short
)
Lock_Type
.
BANK1_LOCK
.
value
(),
data
,
(
short
)
1000
);
//?????
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
1
,
2
,
new
byte
[]{
0x11
,
0x22
},
2
,
null
,
(
short
)
1000
);
System
.
out
.
println
(
"no pwd write"
+
er
.
toString
());
//?????
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
1
,
2
,
new
byte
[]{
0x11
,
0x22
},
2
,
data
,
(
short
)
1000
);
System
.
out
.
println
(
"pwd write"
+
er
.
toString
());
er
=
Jreader
.
LockTag
(
1
,
(
byte
)
Lock_Obj
.
LOCK_OBJECT_BANK1
.
value
(),
(
short
)
Lock_Type
.
BANK1_UNLOCK
.
value
(),
data
,
(
short
)
1000
);
}
public
void
testsetip
()
{
Reader_Ip
rip
=
Jreader
.
new
Reader_Ip
();
/*
rip.ip=new byte[]{'1','9','2','.','1','6','8','.','1','.','1','0','1'};
rip.mask=new byte[]{'2','5','5','.','2','5','5','.','2','5','5','.','0'};
rip.gateway=new byte[]{'1','9','2','.','1','6','8','.','1','.','2','5','4'};
//*/
rip
.
ip
=
"192.168.1.100"
.
getBytes
();
rip
.
mask
=
"255.255.255.0"
.
getBytes
();
rip
.
gateway
=
"192.168.1.1"
.
getBytes
();
//*/
READER_ERR
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_READER_IP
,
rip
);
}
public
void
testrparams
()
{
HoptableData_ST
hdst
=
Jreader
.
new
HoptableData_ST
();
hdst
.
lenhtb
=
5
;
hdst
.
htb
[
0
]=
915250
;
hdst
.
htb
[
1
]=
916750
;
hdst
.
htb
[
2
]=
917250
;
hdst
.
htb
[
3
]=
925750
;
hdst
.
htb
[
4
]=
926750
;
READER_ERR
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_FREQUENCY_HOPTABLE
,
hdst
);
HoptableData_ST
hdst2
=
Jreader
.
new
HoptableData_ST
();
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_FREQUENCY_HOPTABLE
,
hdst2
);
for
(
int
i
=
0
;
i
<
hdst2
.
lenhtb
;
i
++)
{
System
.
out
.
print
(
"htb:"
+
i
);
System
.
out
.
println
(
" "
+(
hdst2
.
htb
[
i
]));
}
//
Region_Conf
rcf1
=
Region_Conf
.
RG_NA
;
Region_Conf
[]
rcf2
=
new
Region_Conf
[
1
];
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_FREQUENCY_REGION
,
rcf1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_FREQUENCY_REGION
,
rcf2
);
int
[]
val1
=
new
int
[]{
250
};
int
[]
val2
=
new
int
[]{-
1
};
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_BLF
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_BLF
,
val2
);
val1
[
0
]=
496
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_MAXEPCLEN
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_MAXEPCLEN
,
val2
);
val1
[
0
]=
10
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_Q
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_Q
,
val2
);
val1
[
0
]=
2
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_SESSION
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_SESSION
,
val2
);
val1
[
0
]=
2
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_TAGENCODING
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_TAGENCODING
,
val2
);
val1
[
0
]=
1
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_TARGET
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_TARGET
,
val2
);
val1
[
0
]=
3
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_TARI
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_TARI
,
val2
);
val1
[
0
]=
1
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_WRITEMODE
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_GEN2_WRITEMODE
,
val2
);
val1
[
0
]=
2
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_ISO180006B_BLF
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_ISO180006B_BLF
,
val2
);
val1
[
0
]=
1
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_ISO180006B_DELIMITER
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_ISO180006B_DELIMITER
,
val2
);
val1
[
0
]=
2
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POTL_ISO180006B_MODULATION_DEPTH
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POTL_ISO180006B_MODULATION_DEPTH
,
val2
);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_POTL_SUPPORTEDPROTOCOLS, val1);
//er=Jreader.ParamGet(Mtr_Param.MTR_PARAM_POTL_SUPPORTEDPROTOCOLS, val2);
val1
[
0
]=
1
;
val2
[
0
]=-
1
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_POWERSAVE_MODE
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_POWERSAVE_MODE
,
val2
);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_READER_AVAILABLE_ANTPORTS, val1);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_READER_AVAILABLE_ANTPORTS
,
val2
);
ConnAnts_ST
cast
=
Jreader
.
new
ConnAnts_ST
();
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_READER_CONN_ANTS, val1);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_READER_CONN_ANTS
,
cast
);
Reader_Ip
rip2
=
Jreader
.
new
Reader_Ip
();
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_READER_IP
,
rip2
);
System
.
out
.
print
(
"ip:"
+
rip2
.
ip
.
length
+
" "
);
System
.
out
.
println
(
new
String
(
rip2
.
ip
));
System
.
out
.
println
(
new
String
(
rip2
.
mask
));
System
.
out
.
println
(
new
String
(
rip2
.
gateway
));
val1
[
0
]=
1
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_READER_IS_CHK_ANT
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_READER_IS_CHK_ANT
,
val2
);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_READER_VERSION, val1);
//er=Jreader.ParamGet(Mtr_Param.MTR_PARAM_READER_VERSION, val2);
AntPowerConf
apcf
=
Jreader
.
new
AntPowerConf
();
apcf
.
antcnt
=
1
;
for
(
int
i
=
0
;
i
<
apcf
.
antcnt
;
i
++)
{
AntPower
jaap
=
Jreader
.
new
AntPower
();
jaap
.
antid
=
i
+
1
;
jaap
.
readPower
=
2800
;
jaap
.
writePower
=
2750
;
apcf
.
Powers
[
i
]=
jaap
;
}
AntPowerConf
apcf2
=
Jreader
.
new
AntPowerConf
();
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_RF_ANTPOWER
,
apcf
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_ANTPOWER
,
apcf2
);
for
(
int
i
=
0
;
i
<
apcf2
.
antcnt
;
i
++)
{
System
.
out
.
print
(
"antid:"
+
apcf2
.
Powers
[
i
].
antid
);
System
.
out
.
print
(
" rp:"
+
apcf2
.
Powers
[
i
].
readPower
);
System
.
out
.
print
(
" wp:"
+
apcf2
.
Powers
[
i
].
writePower
);
System
.
out
.
println
();
}
val1
[
0
]=
100
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_RF_HOPTIME
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_HOPTIME
,
val2
);
val1
[
0
]=
1
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_RF_LBT_ENABLE
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_LBT_ENABLE
,
val2
);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_RF_MAXPOWER, val1);
short
[]
valso
=
new
short
[
1
];
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_MAXPOWER
,
valso
);
System
.
out
.
println
(
"max:"
+
valso
[
0
]);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_RF_MINPOWER, val1);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_MINPOWER
,
valso
);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_RF_SUPPORTEDREGIONS, val1);
//er=Jreader.ParamGet(Mtr_Param.MTR_PARAM_RF_SUPPORTEDREGIONS, val2);
//er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_RF_TEMPERATURE, val1);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_TEMPERATURE
,
val2
);
EmbededData_ST
edst
=
Jreader
.
new
EmbededData_ST
();
edst
.
startaddr
=
0
;
edst
.
bank
=
2
;
//bytecnt=0 ??????????
edst
.
bytecnt
=
2
;
edst
.
accesspwd
=
null
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_EMBEDEDDATA
,
edst
);
EmbededData_ST
edst2
=
Jreader
.
new
EmbededData_ST
();
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAG_EMBEDEDDATA
,
edst2
);
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_EMBEDEDDATA
,
null
);
EmbededSecureRead_ST
esrst
=
Jreader
.
new
EmbededSecureRead_ST
();
esrst
.
accesspwd
=
1280
;
esrst
.
address
=
2
;
esrst
.
ApIndexBitsNumInEpc
=
1
;
esrst
.
ApIndexStartBitsInEpc
=
3
;
esrst
.
bank
=
1
;
//blkcnt =0 ?????
esrst
.
blkcnt
=
2
;
esrst
.
pwdtype
=
1
;
esrst
.
tagtype
=
2
;
EmbededSecureRead_ST
esrst2
=
Jreader
.
new
EmbededSecureRead_ST
();
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_EMDSECUREREAD
,
esrst
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAG_EMDSECUREREAD
,
esrst2
);
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_EMDSECUREREAD
,
null
);
TagFilter_ST
tfst
=
Jreader
.
new
TagFilter_ST
();
tfst
.
bank
=
1
;
tfst
.
fdata
=
new
byte
[]{(
byte
)
0xE2
,(
byte
)
0x00
};
//flen 0 ????????
tfst
.
flen
=
2
;
tfst
.
isInvert
=
0
;
tfst
.
startaddr
=
2
;
TagFilter_ST
tfst2
=
Jreader
.
new
TagFilter_ST
();
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_FILTER
,
tfst
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAG_FILTER
,
tfst2
);
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_FILTER
,
null
);
Inv_Potls_ST
ipst
=
Jreader
.
new
Inv_Potls_ST
();
ipst
.
potlcnt
=
1
;
ipst
.
potls
=
new
Inv_Potl
[
1
];
for
(
int
i
=
0
;
i
<
ipst
.
potlcnt
;
i
++)
{
Inv_Potl
ipl
=
Jreader
.
new
Inv_Potl
();
ipl
.
weight
=
30
;
ipl
.
potl
=
SL_TagProtocol
.
SL_TAG_PROTOCOL_GEN2
;
ipst
.
potls
[
0
]=
ipl
;
}
Inv_Potls_ST
ipst2
=
Jreader
.
new
Inv_Potls_ST
();
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_INVPOTL
,
ipst
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAG_INVPOTL
,
ipst2
);
for
(
int
i
=
0
;
i
<
ipst2
.
potlcnt
;
i
++)
System
.
out
.
println
(
ipst2
.
potls
[
i
].
potl
);
val1
[
0
]=
1
;
val2
[
0
]=
0
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_SEARCH_MODE
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAG_SEARCH_MODE
,
val2
);
val1
[
0
]=
1
;
val2
[
0
]=
0
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAGDATA_RECORDHIGHESTRSSI
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAGDATA_RECORDHIGHESTRSSI
,
val2
);
val1
[
0
]=
1
;
val2
[
0
]=
0
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAGDATA_UNIQUEBYANT
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAGDATA_UNIQUEBYANT
,
val2
);
val1
[
0
]=
1
;
val2
[
0
]=
0
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAGDATA_UNIQUEBYEMDDATA
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TAGDATA_UNIQUEBYEMDDATA
,
val2
);
val1
[
0
]=
300
;
val2
[
0
]=
0
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TRANS_TIMEOUT
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TRANS_TIMEOUT
,
val2
);
val1
[
0
]=
1
;
val2
[
0
]=
0
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TRANSMIT_MODE
,
val1
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_TRANSMIT_MODE
,
val2
);
}
public
void
testgpio
()
{
READER_ERR
er
=
Jreader
.
SetGPO
(
1
,
1
);
er
=
Jreader
.
SetGPO
(
2
,
0
);
er
=
Jreader
.
SetGPO
(
3
,
0
);
er
=
Jreader
.
SetGPO
(
4
,
1
);
int
[]
val
=
new
int
[
1
];
er
=
Jreader
.
GetGPI
(
1
,
val
);
er
=
Jreader
.
GetGPI
(
2
,
val
);
er
=
Jreader
.
GetGPI
(
3
,
val
);
er
=
Jreader
.
GetGPI
(
4
,
val
);
}
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
// maintest mt=new maintest();
// //????????
// //启动
// mt.testinitreader();
//???????
//mt.testtran();
//????gpio
//mt.testgpio();
//???????
//mt.testrparams();
//????????
//mt.testblockop();
//???????????
//mt.testcustomcmd();
//???????????????
//mt.testdataonreader();
//????????1
//盘存
// mt.testinventory1();
//????????2
// mt.testinventory2();
//????????????
//mt.testkilltag();
//?????????
//mt.testlocktag();
//?????????
// mt.testreadandwrite();
//?????ip???
//可以修改ip
// mt.testsetip();
//????psam
//mt.testpsam();
//???????
//关闭
// mt.Jreader.CloseReader();
// System.out.println("test over");
}
}
dev-readmachine/src/main/resources/application.properties
0 → 100644
浏览文件 @
d5a90058
dev-readmachine/src/main/resources/lib/ModuleAPI_Java_2.2.0.0.jar
0 → 100644
浏览文件 @
d5a90058
File added
dev-readmachine/src/test/java/com/tykj/dev/readmachine/devreadmachine/DevReadmachineApplicationTests.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
readmachine
.
devreadmachine
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
DevReadmachineApplicationTests
{
@Test
void
contextLoads
()
{
}
}
dev-repair/src/main/java/com/tykj/dev/device/repair/controller/RepairController.java
浏览文件 @
d5a90058
...
...
@@ -339,7 +339,9 @@ public class RepairController {
});
}
Integer
userId
=
userUtils
.
getCurrentUserId
();
Integer
level
=
userUtils
.
getCurrentUnitLevel
();
// Integer level = userUtils.getCurrentUnitLevel();
Integer
unitId
=
userUtils
.
getCurrentUnitId
();
Units
units
=
unitsCache
.
findById
(
unitId
);
//添加维修单和送修单
RepairBill
repairBill
;
RepairSendBill
deviceRepairSendBillEntity
;
...
...
@@ -362,7 +364,7 @@ public class RepairController {
deviceRepairSendBillEntity
.
setScriptJson
(
JacksonUtil
.
toJSon
(
repairBillSaveVo
.
getScriptSaveVos
()));
}
//如果当前为省向国家发起的
if
(
level
==
1
)
{
if
(
units
.
getType
()
==
1
&&
units
.
getLevel
()
==
1
)
{
repairBill
.
setRepairStatus
(
4
);
//维修中
deviceRepairSendBillEntity
.
setRepairStatus
(
5
);
//维修中
}
else
{
...
...
@@ -473,17 +475,27 @@ public class RepairController {
//当前单位其他专管员id集合
List
<
Integer
>
ids
=
userPublicService
.
findOtherUser
(
userUtils
.
getCurrentUserId
());
//省向国家发起的
if
(
level
==
1
)
{
if
(
units
.
getType
()
==
1
&&
units
.
getLevel
()
==
1
)
{
ownUnit
=
userUtils
.
getCurrentUnitId
();
//直接发起的
if
(
repairBillSaveVo
.
getTaskId
()
==
null
)
{
TaskBto
taskBto
;
if
(
repairBillSaveVo
.
getReceiveUnit
().
contains
(
"中办"
)){
// taskBto = new TaskBto(StatusEnum.WAIT_UPLOAD_FILE.id, "["+repairBillSaveVo.getReceiveUnit() + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件", null, ".", repairBill1.getId(), 5, ownUnit, 1, "country", userIds);
taskBto
=
new
TaskBto
(
StatusEnum
.
WAIT_UPLOAD_FILE
.
id
,
"["
+
DeviceModelSort
.
unitNameToDisName
(
repairBillSaveVo
.
getReceiveUnit
())
+
"]型号"
+
StringSplitUtil
.
stringListToString
(
repairBillSaveVo
.
getScriptSaveVos
().
stream
().
map
(
ScriptSaveVo:
:
getModel
).
distinct
().
collect
(
Collectors
.
toList
()))
+
"共有"
+
repairBillSaveVo
.
getSendingCount
()
+
"件"
,
null
,
"."
,
repairBill1
.
getId
(),
5
,
ownUnit
,
1
,
"country"
,
userIds
);
taskBto
=
new
TaskBto
(
StatusEnum
.
WAIT_UPLOAD_FILE
.
id
,
"["
+
DeviceModelSort
.
unitNameToDisName
(
repairBillSaveVo
.
getReceiveUnit
())
+
"]型号"
+
StringSplitUtil
.
stringListToString
(
repairBillSaveVo
.
getScriptSaveVos
().
stream
()
.
map
(
ScriptSaveVo:
:
getModel
).
distinct
().
collect
(
Collectors
.
toList
()))
+
"共有"
+
repairBillSaveVo
.
getSendingCount
()
+
"件"
,
null
,
"."
,
repairBill1
.
getId
(),
5
,
ownUnit
,
1
,
"country"
,
userIds
);
}
else
{
// taskBto = new TaskBto(StatusEnum.WAIT_UPLOAD_FILE.id, "["+repairBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + StringSplitUtil.stringListToString(repairBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList())) + "共有" + repairBillSaveVo.getSendingCount() + "件", null, ".", repairBill1.getId(), 5, ownUnit, 1, "country", userIds);
taskBto
=
new
TaskBto
(
StatusEnum
.
WAIT_UPLOAD_FILE
.
id
,
"["
+
DeviceModelSort
.
unitNameToDisName
(
repairBillSaveVo
.
getReceiveUnit
())
+
"]型号"
+
StringSplitUtil
.
stringListToString
(
repairBillSaveVo
.
getScriptSaveVos
().
stream
().
map
(
ScriptSaveVo:
:
getModel
).
distinct
().
collect
(
Collectors
.
toList
()))
+
"共有"
+
repairBillSaveVo
.
getSendingCount
()
+
"件"
,
null
,
"."
,
repairBill1
.
getId
(),
5
,
ownUnit
,
1
,
"country"
,
userIds
);
taskBto
=
new
TaskBto
(
StatusEnum
.
WAIT_UPLOAD_FILE
.
id
,
"["
+
DeviceModelSort
.
unitNameToDisName
(
repairBillSaveVo
.
getReceiveUnit
())
+
"]型号"
+
StringSplitUtil
.
stringListToString
(
repairBillSaveVo
.
getScriptSaveVos
().
stream
()
.
map
(
ScriptSaveVo:
:
getModel
).
distinct
().
collect
(
Collectors
.
toList
()))
+
"共有"
+
repairBillSaveVo
.
getSendingCount
()
+
"件"
,
null
,
"."
,
repairBill1
.
getId
(),
5
,
ownUnit
,
1
,
"country"
,
userIds
);
}
saveEntity
=
taskService
.
start
(
taskBto
);
}
...
...
@@ -588,7 +600,7 @@ public class RepairController {
deviceRepairDetailService
.
save
(
repairDetail
);
}
//如果当前为省像国家发起的
if
(
level
==
1
)
{
if
(
units
.
getType
()
==
1
&&
units
.
getLevel
()
==
1
)
{
deviceLibraryEntity
.
setLifeStatus
(
4
);
deviceLibraryEntity
.
setLocationUnit
(
repairBillSaveVo
.
getReceiveUnit
());
}
else
{
...
...
@@ -607,7 +619,7 @@ public class RepairController {
String
deviceIdDetail
=
deviceRepairSendBillEntity
.
getRepairDeviceCheckDetail
();
List
<
Integer
>
idList
=
StringSplitUtil
.
split
(
deviceIdDetail
);
//如果当前为省,改变装备的所在为中办
if
(
level
==
1
)
{
if
(
units
.
getType
()
==
1
&&
units
.
getLevel
()
==
1
)
{
//获取当前业务维修详情 记录
List
<
RepairDetail
>
repairDetailEntities
=
deviceRepairDetailService
.
findByBillId
(
repairBill
.
getId
());
//改变维修详情装备所在单位为中办,状态为维修中
...
...
@@ -967,6 +979,7 @@ public class RepairController {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
saveRepairBackBill
(
@RequestBody
RepairBackBillSaveVo
repairBackBillSaveVo
)
{
Integer
currentUnitLevel
=
userUtils
.
getCurrentUnitLevel
();
Units
units
=
unitsCache
.
findById
(
userUtils
.
getCurrentUnitId
());
//第一次保存
if
(
repairBackBillSaveVo
.
getTaskId
()
==
null
)
{
Integer
userId
=
userUtils
.
getCurrentUserId
();
...
...
@@ -988,7 +1001,10 @@ public class RepairController {
//发起任务
// TaskBto taskBto = new TaskBto(StatusEnum.REPAIR_BACK_DRAFT.id, "["+repairBackBillSaveVo.getReceiveUnit().substring(0,3) + "]型号" + repairBackBillSaveVo.getScriptSaveVos().get(0).getModel() + "共有" + repairBackBillSaveVo.getSendingCount() + "件至", null, ".", repairBackBill1.getId(), BusinessEnum.REPAIR_BACK.id, userUtils.getCurrentUnitId(), 0, null, userIds);
TaskBto
taskBto
=
new
TaskBto
(
StatusEnum
.
REPAIR_BACK_DRAFT
.
id
,
"["
+
DeviceModelSort
.
unitNameToDisName
(
repairBackBillSaveVo
.
getReceiveUnit
())
+
"]型号"
+
repairBackBillSaveVo
.
getScriptSaveVos
().
get
(
0
).
getModel
()
+
"共有"
+
repairBackBillSaveVo
.
getSendingCount
()
+
"件至"
,
null
,
"."
,
repairBackBill1
.
getId
(),
BusinessEnum
.
REPAIR_BACK
.
id
,
userUtils
.
getCurrentUnitId
(),
0
,
null
,
userIds
);
if
(
currentUnitLevel
==
1
){
// if (currentUnitLevel == 1){
// taskBto.setCustomInfo("country");
// }
if
(
currentUnitLevel
==
1
&&
units
.
getType
()
==
1
){
taskBto
.
setCustomInfo
(
"country"
);
}
TaskBto
taskBto1
=
taskService
.
start
(
taskBto
);
...
...
@@ -1973,9 +1989,11 @@ public class RepairController {
//已领取装备
else
if
(
type
==
4
)
{
Integer
level
=
userUtils
.
getCurrentUnitLevel
();
Units
byId
=
unitsCache
.
findById
(
unitId
);
String
currentUserUnitName
=
userUtils
.
getCurrentUserUnitName
();
List
<
RepairDetail
>
repairDetails
;
if
(
level
==
1
)
{
// if (level == 1) {
if
(
level
==
1
&&
byId
.
getType
()
==
1
)
{
repairDetails
=
repairDetailDao
.
findAllByRepairStatus
(
5
,
repairTaskSelectVo
.
getPageable
().
getSort
());
}
else
if
(
level
==
2
)
{
...
...
dev-rfid/src/main/java/com/tykj/dev/rfid/timeTask/InventoryThread.java
浏览文件 @
d5a90058
...
...
@@ -27,6 +27,8 @@ public class InventoryThread extends Thread {
private
static
int
CURRENT_READ_POINT
=
0
;
private
final
int
ANT_COUNT
=
2
;
private
final
String
PanIP
=
"192.168.101.201"
;
/**
* 每次盘存的临时变量
*/
...
...
@@ -137,12 +139,12 @@ public class InventoryThread extends Thread {
@Override
public
void
run
()
{
mReaderHelper
=
mConnector
.
connectNet
(
"192.168.0.178"
,
4001
);
mReaderHelper
=
mConnector
.
connectNet
(
PanIP
,
8080
);
if
(
mReaderHelper
!=
null
)
{
try
{
mReaderHelper
.
registerObserver
(
mObserver
);
//默认切换到默认天线
changeAnt
(
currentAnt
);
//
changeAnt(currentAnt);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
...
...
@@ -151,6 +153,7 @@ public class InventoryThread extends Thread {
log
.
error
(
"连接天线失败"
);
mConnector
.
disConnect
();
}
readTag
();
}
/**
...
...
dev-rfid/src/main/java/com/tykj/dev/rfid/timeTask/ReadUtils.java
浏览文件 @
d5a90058
...
...
@@ -4,6 +4,9 @@ import com.uhf.api.cls.Reader;
import
com.uhf.api.cls.Reader.*
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
public
class
ReadUtils
{
...
...
@@ -104,13 +107,13 @@ public class ReadUtils {
public
void
testreadandwrite
(){
/*
* READER_ERR WriteTagData(int ant,char bank,int address, byte[] data, int datalen, byte[] accesspasswd,short timeout);
* ant
???????????
* bank
??????? 0????????? 1???epc?? 2???tid?? 3???user??
* address
???????? ???epc?????????
* data
???????
* datalen
?????????????
* accesspwd
??????????"00000000" 8????????????
* timeout
??????????
* ant
操作的单天线
* bank
表示区域 0表示保留区 1表示epc区 2表示tid区 3表示user区
* address
表示地址块, 注意epc区从第二块开始
* data
写的数据
* datalen
表示写的数据长度
* accesspwd
表示密码,默认"00000000" 8个十六进制字符
* timeout
操作超时时间
*/
String
pwd
=
"00000000"
;
...
...
@@ -124,13 +127,13 @@ public class ReadUtils {
//??????
/*
* READER_ERR GetTagData(int ant,char bank, int address, int blkcnt,byte[] data, byte[] accesspasswd, short timeout);
* ant
???????????
* bank
??????? 0????????? 1???epc?? 2???tid?? 3???user??
* address
???????? ???epc?????????
* blkcnt
?????????
* data
??????????????ò????
blkcnt*2
* accesspwd
??????????"00000000" 8????????????
* timeout
??????????
* ant
操作的单天线
* bank
表示区域 0表示保留区 1表示epc区 2表示tid区 3表示user区
* address
表示地址块, 注意epc区从第二块开始
* blkcnt
表示读块数
* data
存放数据的字节,应该不小于
blkcnt*2
* accesspwd
表示密码,默认"00000000" 8个十六进制字符
* timeout
操作超时时间
*/
er
=
Jreader
.
GetTagData
(
1
,
(
char
)
1
,
2
,
6
,
datar
,
null
,
(
short
)
1000
);
String
str1
=
""
;
...
...
@@ -161,33 +164,33 @@ public class ReadUtils {
String
pwd
=
"11000000"
;
byte
[]
data
=
new
byte
[
4
];
Jreader
.
Str2Hex
(
pwd
,
pwd
.
length
(),
data
);
//
??????
//
擦除块
READER_ERR
er
=
Jreader
.
BlockErase
(
1
,
(
char
)
1
,
2
,
12
,
data
,
(
short
)
1000
);
//
????????
//
永久锁块
Jreader
.
BlockPermaLock
(
1
,
1
,
2
,
6
,
new
byte
[]{(
byte
)
0xff
,(
byte
)
0xff
},
data
,
(
short
)
1000
);
}
public
void
testinitreader
()
{
//
?????????
/*
?????????????????
* src
???? ip???????????
* rtype
???????????4?????????
4
*
?????????READER_ERR ,MT_OK_ERR????????????????????
//
创建读写器
/*
根据天线口连接读写器
* src
是地址 ip地址或者串口号
* rtype
是天线口数,4口天线传入
4
*
返回类型:READER_ERR ,MT_OK_ERR表示正常,其他表示错误
*/
READER_ERR
er
=
Jreader
.
InitReader
(
ReaderAddr
,
Reader_Type
.
MODULE_ONE_ANT
);
//
READER_ERR er=Jreader.InitReader_Notype(ReaderAddr,AntCount);
//
READER_ERR er=Jreader.InitReader(ReaderAddr,Reader_Type.MODULE_ONE_ANT);
READER_ERR
er
=
Jreader
.
InitReader_Notype
(
ReaderAddr
,
AntCount
);
System
.
out
.
println
(
er
.
toString
());
/*
*
?????????????AntPowerConf
*
?????
* AntPower
????
* antcnt
??????????
* AntPower
????
* antid
?????
* readPower
??????
* writePower
?????
*
构建天线组功率:AntPowerConf
*
成员:
* AntPower
数组
* antcnt
表示天线个数
* AntPower
类型
* antid
天线号
* readPower
读功率
* writePower
写功率
*/
AntPowerConf
apcf
=
Jreader
.
new
AntPowerConf
();
...
...
@@ -196,15 +199,16 @@ public class ReadUtils {
{
AntPower
jaap
=
Jreader
.
new
AntPower
();
jaap
.
antid
=
i
+
1
;
jaap
.
readPower
=
2800
;
jaap
.
writePower
=
2750
;
apcf
.
Powers
[
i
]=
jaap
;
// jaap.readPower=2800;
jaap
.
readPower
=
1000
;
jaap
.
writePower
=
1000
;
// jaap.writePower=2750;
apcf
.
Powers
[
i
]=
jaap
;
}
AntPowerConf
apcf2
=
Jreader
.
new
AntPowerConf
();
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_RF_ANTPOWER
,
apcf
);
er
=
Jreader
.
ParamGet
(
Mtr_Param
.
MTR_PARAM_RF_ANTPOWER
,
apcf2
);
for
(
int
i
=
0
;
i
<
apcf2
.
antcnt
;
i
++)
{
for
(
int
i
=
0
;
i
<
apcf2
.
antcnt
;
i
++){
System
.
out
.
print
(
"antid:"
+
apcf2
.
Powers
[
i
].
antid
);
System
.
out
.
print
(
" rp:"
+
apcf2
.
Powers
[
i
].
readPower
);
System
.
out
.
print
(
" wp:"
+
apcf2
.
Powers
[
i
].
writePower
);
...
...
@@ -214,8 +218,7 @@ public class ReadUtils {
Inv_Potls_ST
ipst
=
Jreader
.
new
Inv_Potls_ST
();
ipst
.
potlcnt
=
1
;
ipst
.
potls
=
new
Inv_Potl
[
1
];
for
(
int
i
=
0
;
i
<
ipst
.
potlcnt
;
i
++)
{
for
(
int
i
=
0
;
i
<
ipst
.
potlcnt
;
i
++){
Inv_Potl
ipl
=
Jreader
.
new
Inv_Potl
();
ipl
.
weight
=
30
;
ipl
.
potl
=
SL_TagProtocol
.
SL_TAG_PROTOCOL_GEN2
;
...
...
@@ -224,21 +227,21 @@ public class ReadUtils {
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_INVPOTL
,
ipst
);
/*
*
?????????????
*
???????????1???????????0????????
*
设置是否检查天线
*
当参数值传入1的时候表示要检查,0表示不检查
*/
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_READER_IS_CHK_ANT
,
0
);
}
public
void
testinventory1
()
{
public
List
<
String
>
testinventory1
()
{
/*
*
*
???????????????????????????????????
* HoptableData_ST
??????????
* lenhtb
?????????
* htb
????int???????????????
*
设置频率,对于某天线设置频率表可以提搞读效果
* HoptableData_ST
天线频率表类
* lenhtb
表示频率表长度
* htb
数组int类型,表示具体频点
HoptableData_ST hdst=Jreader.new HoptableData_ST();
hdst.lenhtb=2;
hdst.htb[0]=915250;
...
...
@@ -246,20 +249,25 @@ public class ReadUtils {
READER_ERR er=Jreader.ParamSet(Mtr_Param.MTR_PARAM_FREQUENCY_HOPTABLE,hdst);
*/
/* ants ????????????????????????????
* antcnt ???????????
* timeout ??????????
* pTInfo ??????????????
* tagcnt ????????????????????????????
/* ants 轮询使用的天线,即连接天线口的天线
* antcnt 使用的天线个数
* timeout 读标签的时间
* pTInfo 存放标签数据的数组
* tagcnt 存放标签的个数,只需传入一个元素的数组
*/
int
[]
tagcnt
=
new
int
[
1
];
TAGINFO
[]
taginfo
=
new
TAGINFO
[
200
];
READER_ERR
er
=
Jreader
.
TagInventory
(
new
int
[]{
1
},
1
,
(
short
)
1000
,
taginfo
,
tagcnt
);
List
<
String
>
result
=
new
ArrayList
<>();
if
(
er
==
READER_ERR
.
MT_OK_ERR
)
{
for
(
int
i
=
0
;
i
<
tagcnt
[
0
];
i
++)
{
System
.
out
.
println
(
"inv1_epc:"
+
Reader
.
bytes_Hexstr
(
taginfo
[
i
].
EpcId
));
result
.
add
(
Reader
.
bytes_Hexstr
(
taginfo
[
i
].
EpcId
));
// System.out.println("inv1_epc:"+Reader.bytes_Hexstr(taginfo[i].EpcId));
}
}
return
result
;
}
public
void
testinventory2
()
{
...
...
@@ -284,8 +292,8 @@ public class ReadUtils {
byte
[]
data3
=
new
byte
[
100
];
READER_ERR
er
=
Jreader
.
ReadDataOnReader
(
0
,
data3
,
100
);
er
=
Jreader
.
SaveDataOnReader
(
0
,
data3
,
100
);
//
???????????????
//
擦除读写器上数据
er
=
Jreader
.
EraseDataOnReader
();
}
...
...
@@ -301,16 +309,16 @@ public class ReadUtils {
// READER_ERR er=Jreader.Lock180006BTag(1, 2, 6, (short) 1000);
byte
[]
data
=
new
byte
[
4
];
Jreader
.
Str2Hex
(
pwd
,
pwd
.
length
(),
data
);
//?????
//写数据
READER_ERR
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
0
,
2
,
data
,
2
,
null
,
(
short
)
1000
);
er
=
Jreader
.
LockTag
(
1
,
(
byte
)
Lock_Obj
.
LOCK_OBJECT_BANK1
.
value
(),
(
short
)
Lock_Type
.
BANK1_LOCK
.
value
(),
data
,
(
short
)
1000
);
//?????
//写数据
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
1
,
2
,
new
byte
[]{
0x11
,
0x22
},
2
,
null
,
(
short
)
1000
);
System
.
out
.
println
(
"no pwd write"
+
er
.
toString
());
//?????
//写数据
er
=
Jreader
.
WriteTagData
(
1
,
(
char
)
1
,
2
,
new
byte
[]{
0x11
,
0x22
},
2
,
data
,
(
short
)
1000
);
System
.
out
.
println
(
"pwd write"
+
er
.
toString
());
...
...
@@ -481,7 +489,7 @@ public class ReadUtils {
EmbededData_ST
edst
=
Jreader
.
new
EmbededData_ST
();
edst
.
startaddr
=
0
;
edst
.
bank
=
2
;
//bytecnt=0
??????????
//bytecnt=0
取消嵌入数据
edst
.
bytecnt
=
2
;
edst
.
accesspwd
=
null
;
er
=
Jreader
.
ParamSet
(
Mtr_Param
.
MTR_PARAM_TAG_EMBEDEDDATA
,
edst
);
...
...
@@ -497,7 +505,7 @@ public class ReadUtils {
esrst
.
ApIndexBitsNumInEpc
=
1
;
esrst
.
ApIndexStartBitsInEpc
=
3
;
esrst
.
bank
=
1
;
//blkcnt =0
?????
//blkcnt =0
取消。
esrst
.
blkcnt
=
2
;
esrst
.
pwdtype
=
1
;
esrst
.
tagtype
=
2
;
...
...
@@ -509,7 +517,7 @@ public class ReadUtils {
TagFilter_ST
tfst
=
Jreader
.
new
TagFilter_ST
();
tfst
.
bank
=
1
;
tfst
.
fdata
=
new
byte
[]{(
byte
)
0xE2
,(
byte
)
0x00
};
//flen 0
????????
//flen 0
为取消过滤
tfst
.
flen
=
2
;
tfst
.
isInvert
=
0
;
tfst
.
startaddr
=
2
;
...
...
@@ -584,44 +592,44 @@ public class ReadUtils {
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
// maintest mt=new maintest
();
// //????????
//
//启动
//
mt.testinitreader();
//???????
ReadUtils
mt
=
new
ReadUtils
();
//测试初始化
//启动
mt
.
testinitreader
();
//测试转换
//mt.testtran();
//????
gpio
//测试
gpio
//mt.testgpio();
//???????
//测试参数
//mt.testrparams();
//????????
//测试块操作
//mt.testblockop();
//???????????
//测试特殊指令
//mt.testcustomcmd();
//???????????????
//测试读写器内部数据
//mt.testdataonreader();
//????????
1
//测试盘点方式
1
//盘存
//
mt.testinventory1();
//
????????
2
mt
.
testinventory1
();
//
测试盘点方式
2
// mt.testinventory2();
//????????????
//测试销毁密码
//mt.testkilltag();
//?????????
//测试锁标签
//mt.testlocktag();
//?????????
//测试读写标签
// mt.testreadandwrite();
//?????ip???
//测试改ip地址
//可以修改ip
// mt.testsetip();
//????
psam
//测试
psam
//mt.testpsam();
//
???????
//
关闭读写器
//关闭
//
mt.Jreader.CloseReader();
//
System.out.println("test over");
mt
.
Jreader
.
CloseReader
();
System
.
out
.
println
(
"test over"
);
}
}
dev-socket/src/main/java/com/tykj/dev/socket/MessageError.java
0 → 100644
浏览文件 @
d5a90058
package
com
.
tykj
.
dev
.
socket
;
/**
* zsp
*/
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
MessageError
{
private
String
rfid
;
private
String
message
;
}
dev-socket/src/main/java/com/tykj/dev/socket/MyWebSocket.java
浏览文件 @
d5a90058
...
...
@@ -2,14 +2,17 @@ package com.tykj.dev.socket;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.websocket.*
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.net.Socket
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
...
...
@@ -20,8 +23,9 @@ import java.util.concurrent.ConcurrentHashMap;
* @createTime 2020年08月19日 23:53:00
*/
@Slf4j
@ServerEndpoint
(
value
=
"/websocket/{userId}"
)
//接受websocket请求路径
@ServerEndpoint
(
value
=
"/
public/
websocket/{userId}"
)
//接受websocket请求路径
@Component
//注册到spring容器中
@Data
public
class
MyWebSocket
{
/**
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
...
...
@@ -66,12 +70,13 @@ public class MyWebSocket {
//加入set中
//在线数加1
}
log
.
info
(
"用户连接:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
sendMessage
(
"连接成功"
);
}
/**
* 连接关闭调用的方法
*/
...
...
@@ -89,9 +94,15 @@ public class MyWebSocket {
log
.
info
(
"用户退出:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
}
public
MyWebSocket
getMap
(
String
userId
)
{
MyWebSocket
myWebSocket
=
webSocketMap
.
get
(
userId
);
log
.
info
(
"用户退出:"
+
userId
+
",当前在线人数为:"
+
webSocketMap
.
size
());
return
myWebSocket
;
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息
*/
@OnMessage
...
...
@@ -141,10 +152,55 @@ public class MyWebSocket {
}
}
/**
* 实现服务器主动推送
*/
public
void
sendMessage2
(
Object
o
)
{
try
{
this
.
session
.
getBasicRemote
().
sendText
(
JSONObject
.
toJSONString
(
o
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
void
sendMessage1
()
{
for
(
String
i
:
webSocketMap
.
keySet
())
{
webSocketMap
.
get
(
i
).
sendMessage
(
"1"
);
}
}
public
void
sendMessageForReadMachine
(
Object
o
)
{
for
(
String
i
:
webSocketMap
.
keySet
())
{
webSocketMap
.
get
(
i
).
sendMessage2
(
o
);
}
}
public
void
sendMessageForReadMachine1
(
Object
o
,
Integer
userId
)
{
webSocketMap
.
get
(
String
.
valueOf
(
userId
)).
sendMessage2
(
o
);
}
public
void
sendMessageForReadMachineError
(
String
rfid
)
{
for
(
String
i
:
webSocketMap
.
keySet
())
{
webSocketMap
.
get
(
i
).
sendMessage2
(
new
MessageError
(
rfid
,
"该RFID为:"
+
rfid
+
"设备查询不到"
));
}
}
/**
* 判断是否断开连接,断开返回true,没有返回false
* @param socket
* @return
*/
// public Boolean isServerClose(Socket socket){
// try{
// socket.sendUrgentData(0xFF);//发送1个字节的紧急数据,默认情况下,服务器端没有开启紧急数据处理,不影响正常通信
// return false;
// }catch(Exception se){
// return true;
// }
// }
}
dev-task/src/main/java/com/tykj/dev/device/task/subject/bto/TaskBto.java
浏览文件 @
d5a90058
...
...
@@ -127,6 +127,18 @@ public class TaskBto {
this
.
exhibit
=
exhibit
;
}
public
TaskBto
(
Integer
billStatus
,
String
title
,
String
nodeIdDetail
,
Integer
billId
,
Integer
businessType
,
Integer
ownUnit
,
Integer
currentPoint
,
List
<
Integer
>
involveUserIdList
)
{
this
.
billStatus
=
billStatus
;
this
.
title
=
title
;
this
.
nodeIdDetail
=
nodeIdDetail
;
this
.
billId
=
billId
;
this
.
businessType
=
businessType
;
this
.
ownUnit
=
ownUnit
;
this
.
currentPoint
=
currentPoint
;
this
.
involveUserIdList
=
involveUserIdList
;
}
/**
* bto类转化为do类
*/
...
...
dev-taskselect/pom.xml
浏览文件 @
d5a90058
...
...
@@ -63,6 +63,10 @@
<groupId>
com.tykj
</groupId>
<artifactId>
dev-sendback
</artifactId>
</dependency>
<dependency>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
dev-readmachine
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
dev-taskselect/src/main/java/com/tykj/dev/device/taskselect/controller/TaskSelectController.java
浏览文件 @
d5a90058
...
...
@@ -36,6 +36,7 @@ import com.tykj.dev.device.task.service.TaskService;
import
com.tykj.dev.device.task.subject.bto.TaskBto
;
import
com.tykj.dev.device.task.subject.domin.Task
;
import
com.tykj.dev.device.taskselect.vo.SignatureSaveVo
;
import
com.tykj.dev.device.user.cache.UserCache
;
import
com.tykj.dev.device.user.subject.service.UserPublicService
;
import
com.tykj.dev.misc.base.ResultObj
;
import
com.tykj.dev.misc.exception.ApiException
;
...
...
@@ -43,12 +44,18 @@ import com.tykj.dev.misc.utils.JacksonUtil;
import
com.tykj.dev.misc.utils.ResultUtil
;
import
com.tykj.dev.misc.utils.Snowflake
;
import
com.tykj.dev.misc.utils.StringSplitUtil
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineBill
;
import
com.tykj.dev.readmachine.devreadmachine.Entity.ReadMachineLibrary
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineBillService
;
import
com.tykj.dev.readmachine.devreadmachine.service.ReadMachineLibraryService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.checkerframework.checker.units.qual.Area
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -111,9 +118,18 @@ public class TaskSelectController {
@Autowired
private
TaskDao
taskDao
;
@Autowired
private
ReadMachineBillService
readMachineBillService
;
@Autowired
private
ReadMachineLibraryService
readMachineLibraryService
;
// @Autowired
// private DeviceLibraryDao deviceLibraryDao;
@Resource
private
UserCache
userCache
;
@ApiOperation
(
value
=
"查询业务对应页面的数据"
,
notes
=
"可以通过这个接口查询业务对应页面的数据"
)
@GetMapping
(
"/manage/detail/{id}"
)
public
ResponseEntity
selectData
(
@PathVariable
(
"id"
)
int
taskId
)
{
...
...
@@ -469,6 +485,19 @@ public class TaskSelectController {
list
.
add
(
deviceLibraries
);
return
ResponseEntity
.
ok
(
new
ResultObj
(
list
,
"查询成功"
));
case
30
:
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
ReadMachineBill
readMachineBill
=
readMachineBillService
.
findById
(
taskBto
.
getBillId
());
readMachineBill
.
setCreateUserName
(
userCache
.
findById
(
readMachineBill
.
getCreateUserId
()).
getName
());
readMachineBill
.
setTaskId
(
taskId
);
//通过盘存账单id查询盘存库
List
<
ReadMachineLibrary
>
readMachineLibraries
=
readMachineLibraryService
.
findByReadMachineBillId
(
readMachineBill
.
getId
());
map1
.
put
(
"readMachineBill"
,
readMachineBill
);
readMachineLibraries
.
forEach
(
ReadMachineLibrary:
:
setConfigName
);
map1
.
put
(
"readMachineLibraries"
,
readMachineLibraries
);
return
ResponseEntity
.
ok
(
map1
);
default
:
throw
new
ApiException
(
ResultUtil
.
failed
(
"该接口不支持当前task业务类型"
));
}
...
...
dev-union/pom.xml
浏览文件 @
d5a90058
...
...
@@ -214,6 +214,17 @@
</exclusions>
</dependency>
<dependency>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
dev-readmachine
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
union
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.tykj
</groupId>
<artifactId>
dev-destroy
</artifactId>
...
...
pom.xml
浏览文件 @
d5a90058
...
...
@@ -50,6 +50,7 @@
<module>
dev-policydocument
</module>
<module>
dev-questionbank
</module>
<module>
dev-zxing
</module>
<module>
dev-readmachine
</module>
</modules>
<properties>
...
...
@@ -254,6 +255,12 @@
<artifactId>
dev-zxing
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.tykj.dev
</groupId>
<artifactId>
dev-readmachine
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论