Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
8711a049
提交
8711a049
authored
2月 03, 2021
作者:
邓砥奕
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新
上级
2fdb95d8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
219 行增加
和
0 行删除
+219
-0
BackController.java
.../com/tykj/dev/device/allot/controller/BackController.java
+219
-0
没有找到文件。
dev-allot/src/main/java/com/tykj/dev/device/allot/controller/BackController.java
0 → 100644
浏览文件 @
8711a049
package
com
.
tykj
.
dev
.
device
.
allot
.
controller
;
import
com.tykj.dev.config.swagger.AutoDocument
;
import
com.tykj.dev.device.allot.service.AllotBackBillService
;
import
com.tykj.dev.device.allot.subject.domin.AllotBackBill
;
import
com.tykj.dev.device.allot.subject.vo.AllotBackReceiveVo
;
import
com.tykj.dev.device.allot.subject.vo.AllotBillSaveVo
;
import
com.tykj.dev.device.library.service.DeviceLibraryService
;
import
com.tykj.dev.device.library.service.DeviceLogService
;
import
com.tykj.dev.device.library.subject.Dto.DeviceLogDto
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
com.tykj.dev.device.library.subject.vo.FileVo
;
import
com.tykj.dev.device.task.service.TaskService
;
import
com.tykj.dev.device.task.subject.bto.TaskBto
;
import
com.tykj.dev.device.user.read.service.MessageService
;
import
com.tykj.dev.device.user.read.subject.bto.MessageBto
;
import
com.tykj.dev.device.user.subject.dao.UserDao
;
import
com.tykj.dev.device.user.subject.entity.User
;
import
com.tykj.dev.device.user.subject.service.UserPublicService
;
import
com.tykj.dev.device.user.util.UserUtils
;
import
com.tykj.dev.misc.base.ResultObj
;
import
com.tykj.dev.misc.base.StatusEnum
;
import
com.tykj.dev.misc.utils.Snowflake
;
import
com.tykj.dev.misc.utils.StringSplitUtil
;
import
com.tykj.dev.misc.utils.TaskDisposeUtil
;
import
com.tykj.dev.misc.utils.TimestampUtil
;
import
com.tykj.dev.rfid.service.InputOutputDeviceService
;
import
com.tykj.dev.socket.MyWebSocket
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author dengdiyi
*/
@RestController
@RequestMapping
(
value
=
"/back"
)
@AutoDocument
@Api
(
tags
=
"装备退回模块"
,
description
=
"装备退回接口"
)
@Slf4j
public
class
BackController
{
@Autowired
UserUtils
userUtils
;
@Autowired
AllotBackBillService
allotBackBillService
;
@Autowired
Snowflake
snowflake
;
@Autowired
UserPublicService
userPublicService
;
@Autowired
private
DeviceLibraryService
deviceLibraryService
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Autowired
private
TaskService
taskService
;
@Autowired
private
InputOutputDeviceService
inputOutputDeviceService
;
@Autowired
private
MessageService
messageService
;
@Autowired
private
UserDao
userDao
;
@Autowired
private
MyWebSocket
myWebSocket
;
@ApiOperation
(
value
=
"发起退回业务"
,
notes
=
"可以通过这个接口发起退回任务"
)
@PostMapping
(
value
=
"/addBackBill"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
addBackBill
(
@RequestBody
@Validated
AllotBillSaveVo
allotBillSaveVo
)
{
deviceLibraryService
.
isInStockOrWaitRetired
(
StringSplitUtil
.
split
(
allotBillSaveVo
.
getAllotCheckDetail
()));
//1.添加配发单
AllotBackBill
a
=
allotBillSaveVo
.
toBackDo
();
a
.
setSendUseraId
(
userUtils
.
getCurrentUserId
());
AllotBackBill
allotBackBill
=
allotBackBillService
.
addEntity
(
a
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
int
year
=
calendar
.
get
(
Calendar
.
YEAR
);
String
num
=
"NO:第"
+
year
+
"TH"
+
allotBackBill
.
getId
()
+
"号"
;
allotBackBill
.
setNum
(
num
);
//生成电子签章id
Long
signId
=
snowflake
.
creatNextId
();
Long
signId2
=
snowflake
.
creatNextId
();
allotBackBill
.
setLeftSignatureId
(
signId
.
toString
());
allotBackBill
.
setRightSignatureId
(
signId2
.
toString
());
AllotBackBill
allotBackBill1
=
allotBackBillService
.
update
(
allotBackBill
);
Integer
billId
=
allotBackBill
.
getId
();
Integer
userId
=
userUtils
.
getCurrentUserId
();
String
deviceIdDetail
=
allotBackBill
.
getBackCheckDetail
();
//2.发起任务
List
<
Integer
>
userIds
=
new
ArrayList
<>();
userIds
.
add
(
userId
);
userIds
.
add
(
0
);
TaskBto
saveEntity
;
TaskBto
taskBto
=
new
TaskBto
(
StatusEnum
.
ALLOT_BACKING
.
id
,
"退回业务"
,
null
,
"."
,
billId
,
22
,
userPublicService
.
findUnitIdByName
(
allotBillSaveVo
.
getReceiveUnit
()),
1
,
null
,
userIds
);
saveEntity
=
taskService
.
start
(
taskBto
);
List
<
FileVo
>
fileVoList
=
new
ArrayList
<>();
// fileVoList.add(new FileVo("出库确认单", allotBillEntity.getFileName(), allotBillEntity.getFileUrl()));
//存装备日志
String
[]
strings
=
deviceIdDetail
.
split
(
"x"
);
List
<
Integer
>
ids
=
new
ArrayList
<>();
for
(
String
s
:
strings
)
{
if
(
s
.
length
()
>=
2
)
{
Integer
id
=
Integer
.
parseInt
(
s
.
substring
(
0
,
s
.
length
()
-
1
));
ids
.
add
(
id
);
//改变装备状态
DeviceLibrary
deviceLibraryEntity
=
deviceLibraryService
.
getOne
(
id
);
deviceLibraryEntity
.
setLifeStatus
(
3
);
deviceLibraryEntity
.
setManageStatus
(
0
);
deviceLibraryService
.
update
(
deviceLibraryEntity
);
DeviceLogDto
deviceLogDto
=
new
DeviceLogDto
(
id
,
"对"
+
allotBackBill
.
getReceiveUnit
()
+
"发起退回"
,
fileVoList
);
deviceLogService
.
addLog
(
deviceLogDto
);
}
}
//添加出库白名单
inputOutputDeviceService
.
addWhiteDevices
(
ids
,
userUtils
.
getCurrentUnitId
(),
1
);
//发送阅知信息
List
<
Integer
>
idList
=
userPublicService
.
findOtherUser
(
userId
);
idList
.
addAll
(
userDao
.
findAllByUnitsId
(
userPublicService
.
findUnitIdByName
(
allotBackBill
.
getReceiveUnit
())).
stream
()
.
map
(
User:
:
getUserId
)
.
collect
(
Collectors
.
toList
()));
MessageBto
messageBto
=
new
MessageBto
(
saveEntity
.
getId
(),
saveEntity
.
getBusinessType
(),
"对"
+
userPublicService
.
getAreaNameByUnitName
(
allotBackBill
.
getReceiveUnit
())
+
"发起退回"
,
idList
,
1
);
messageService
.
add
(
messageBto
);
log
.
info
(
"[退回模块]:"
+
allotBackBill
.
getSendUnit
()
+
"对"
+
allotBackBill
.
getReceiveUnit
()
+
"发起退回"
);
myWebSocket
.
sendMessage1
();
return
ResponseEntity
.
ok
(
new
ResultObj
(
allotBackBill1
,
"发起成功"
));
}
@ApiOperation
(
value
=
"接收退回装备"
,
notes
=
"可以通过这个接口接收退回装备"
)
@PostMapping
(
value
=
"/receiveDevice"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
receiveDevice
(
@RequestBody
@Validated
AllotBackReceiveVo
allotBackReceiveVo
)
{
Integer
userId
=
userUtils
.
getCurrentUserId
();
//获取当前任务
TaskBto
taskBto
=
taskService
.
get
(
allotBackReceiveVo
.
getTaskId
());
TaskDisposeUtil
.
isNotSubmit
(
taskBto
.
getBillStatus
(),
StatusEnum
.
ALLOT_BACKING
);
AllotBackBill
allotBackBill
=
allotBackBillService
.
getOne
(
taskBto
.
getBillId
());
List
<
FileVo
>
fileVoList
=
new
ArrayList
<>();
fileVoList
.
add
(
new
FileVo
(
"退回单"
,
allotBackReceiveVo
.
getBillFileName
(),
allotBackReceiveVo
.
getBillFileUrl
()));
// fileVoList.add(new FileVo("入库确认单", allotReceiveVo.getReceiveFileName(), allotReceiveVo.getReceiveFileUrl()));
//更新账单状态
allotBackBill
.
setBackStatus
(
3
);
BeanUtils
.
copyProperties
(
allotBackReceiveVo
,
allotBackBill
);
allotBackBill
.
setReceiveTime
(
TimestampUtil
.
getCurrentTimestamp
());
allotBackBill
.
setReceiveUseraId
(
userId
);
allotBackBillService
.
update
(
allotBackBill
);
taskService
.
addInvolveUser
(
taskBto
,
userId
);
// //推至下一阶段
// taskService.update(taskService.moveToNext(taskBto, allotReceiveVo.getReceiveUserbId()));
taskService
.
moveToEnd
(
taskBto
);
//分隔装备id信息
String
deviceIdDetail
=
allotBackReceiveVo
.
getReceiveCheckDetail
();
String
[]
strings
=
deviceIdDetail
.
split
(
"x"
);
for
(
String
s
:
strings
)
{
if
(
s
.
length
()
>=
2
)
{
//接收无误
if
(
"1"
.
equals
(
s
.
substring
(
s
.
length
()
-
1
)))
{
Integer
id
=
Integer
.
parseInt
(
s
.
substring
(
0
,
s
.
length
()
-
1
));
//改变装备状态
DeviceLibrary
deviceLibraryEntity
=
deviceLibraryService
.
getOne
(
id
);
// deviceLibraryEntity.setLifeStatus(0);
deviceLibraryEntity
.
setLocationUnit
(
userUtils
.
getCurrentUserUnitName
());
deviceLibraryEntity
.
setLifeStatus
(
2
);
deviceLibraryEntity
.
setOwnUnit
(
userUtils
.
getCurrentUserUnitName
());
deviceLibraryEntity
.
setManageStatus
(
1
);
//存装备日志
DeviceLogDto
deviceLogDto
=
new
DeviceLogDto
(
id
,
"接收并发起入库"
,
fileVoList
);
deviceLogService
.
addLog
(
deviceLogDto
);
deviceLibraryService
.
update
(
deviceLibraryEntity
);
}
//接收缺失
if
(
"0"
.
equals
(
s
.
substring
(
s
.
length
()
-
1
)))
{
Integer
id
=
Integer
.
parseInt
(
s
.
substring
(
0
,
s
.
length
()
-
1
));
//改变装备状态
DeviceLibrary
deviceLibraryEntity
=
deviceLibraryService
.
getOne
(
id
);
deviceLibraryEntity
.
setLifeStatus
(
11
);
//存装备日志
DeviceLogDto
deviceLogDto
=
new
DeviceLogDto
(
id
,
"接收入库丢失"
,
fileVoList
);
deviceLogService
.
addLog
(
deviceLogDto
);
deviceLibraryService
.
update
(
deviceLibraryEntity
);
}
}
}
//发送阅知信息
List
<
Integer
>
ids
=
userPublicService
.
findOtherUser
(
userId
);
ids
.
addAll
(
userDao
.
findAllByUnitsId
(
userPublicService
.
findUnitIdByName
(
allotBackBill
.
getSendUnit
())).
stream
()
.
map
(
User:
:
getUserId
)
.
collect
(
Collectors
.
toList
()));
MessageBto
messageBto
=
new
MessageBto
(
taskBto
.
getId
(),
taskBto
.
getBusinessType
(),
"接收退回装备"
,
ids
,
1
);
messageService
.
add
(
messageBto
);
log
.
info
(
"[退回模块]:接收并发起入库"
);
myWebSocket
.
sendMessage1
();
return
ResponseEntity
.
ok
(
"退回接收入库"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论