Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b7df5340
由
LN
编写于
2024-03-06 14:41:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
扫码亮灯修改
1 个父辈
b8d58d48
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
394 行增加
和
98 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/core/shelf/bean/ShelfInfo.java
src/main/java/com/neotel/smfcore/core/shelf/bean/ShelfLoc.java
src/main/java/com/neotel/smfcore/core/shelf/rest/AgvShelfController.java
src/main/java/com/neotel/smfcore/core/shelf/rest/TaskShelfController.java
src/main/java/com/neotel/smfcore/core/shelf/util/TaskShelfUtil.java
src/main/java/com/neotel/smfcore/custom/gree20242/CodeLightController.java
src/main/java/com/neotel/smfcore/custom/gree20242/dto/ShelfDto.java
src/main/java/com/neotel/smfcore/custom/gree20242/dto/ShelfReelDto.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
b7df534
...
@@ -25,6 +25,7 @@ import java.util.*;
...
@@ -25,6 +25,7 @@ import java.util.*;
@Component
@Component
public
class
DataInitManager
{
public
class
DataInitManager
{
public
static
boolean
Debug
=
false
;
public
static
Date
startRunTime
=
new
Date
();
public
static
Date
startRunTime
=
new
Date
();
public
static
Set
<
String
>
allPermissionSet
;
public
static
Set
<
String
>
allPermissionSet
;
...
...
src/main/java/com/neotel/smfcore/core/shelf/bean/ShelfInfo.java
查看文件 @
b7df534
...
@@ -63,18 +63,44 @@ public class ShelfInfo {
...
@@ -63,18 +63,44 @@ public class ShelfInfo {
private
int
maxLocCount
=
0
;
private
int
maxLocCount
=
0
;
/**
/**
* 如果已绑定任务都放完成,可以离开
*/
private
boolean
needLeave
=
false
;
/**
* 是否所有位置都已扫码亮灯
*/
private
boolean
lightEnd
=
false
;
/**
* 线体,目标位置
* 线体,目标位置
*/
*/
private
String
line
;
private
String
line
;
/**
* 料架状态。0=等待放料。
* 1=绑定任务已完成,离开
* 2.已到达line
* 3=所有料盘已扫码灭灯,agv可以拉空料架离开
*/
private
int
shelfState
=
0
;
public
void
NeedLeave
(){
shelfState
=
1
;
log
.
info
(
"RFID["
+
realRfid
+
"] 设置shelfState= "
+
shelfState
);
}
public
void
ArriveLine
(
String
line
)
{
shelfState
=
2
;
this
.
line
=
line
;
log
.
info
(
"RFID["
+
realRfid
+
"] 设置shelfState= "
+
shelfState
+
", line="
+
line
);
}
public
void
NeedLeaveLine
()
{
shelfState
=
3
;
log
.
info
(
"RFID["
+
realRfid
+
"] 设置shelfState= "
+
shelfState
);
}
// /**
// * 如果已绑定任务都放完成,可以离开
// */
// private boolean needLeave=false;
//
// /**
// * 是否所有位置都已扫码亮灯
// */
// private boolean lightEnd=false;
// /**
// * 线体,目标位置
// */
// private boolean inLine =false;
public
static
ShelfInfo
newFShelf
()
{
public
static
ShelfInfo
newFShelf
()
{
return
new
ShelfInfo
(
SHELF_TYPE
.
F
,
31
);
return
new
ShelfInfo
(
SHELF_TYPE
.
F
,
31
);
...
@@ -106,6 +132,10 @@ public class ShelfInfo {
...
@@ -106,6 +132,10 @@ public class ShelfInfo {
return
false
;
return
false
;
}
}
public
List
<
ShelfLoc
>
getLocList
(){
List
<
ShelfLoc
>
list
=
new
ArrayList
<>(
locMap
.
values
());
return
list
;
}
/**
/**
* 根据条码获取库位信息
* 根据条码获取库位信息
*/
*/
...
@@ -247,11 +277,11 @@ public class ShelfInfo {
...
@@ -247,11 +277,11 @@ public class ShelfInfo {
}
}
}
}
if
(
lCount
==
0
)
{
if
(
lCount
==
0
)
{
needLeave
=
true
;
NeedLeave
()
;
}
}
// }
// }
log
.
info
(
"料盘["
+
barcode
+
"]放入位置"
+
rfid
+
"["
+
loc
+
"]成功,料架是否需要离开="
+
needLeave
);
log
.
info
(
"料盘["
+
barcode
+
"]放入位置"
+
rfid
+
"["
+
loc
+
"]成功,料架是否需要离开="
+
(
shelfState
==
1
)
);
return
putInResult
;
return
putInResult
;
}
else
{
}
else
{
log
.
error
(
"料盘["
+
barcode
+
"]放入位置"
+
rfid
+
"["
+
loc
+
"]失败,此位置料盘已放入"
);
log
.
error
(
"料盘["
+
barcode
+
"]放入位置"
+
rfid
+
"["
+
loc
+
"]失败,此位置料盘已放入"
);
...
...
src/main/java/com/neotel/smfcore/core/shelf/bean/ShelfLoc.java
查看文件 @
b7df534
...
@@ -51,12 +51,12 @@ public class ShelfLoc {
...
@@ -51,12 +51,12 @@ public class ShelfLoc {
*/
*/
private
boolean
isLock
=
false
;
private
boolean
isLock
=
false
;
private
String
shelfLocation
=
null
;
//
private String shelfLocation=null;
/**
/**
*
是否已经扫码亮灯,料架所有料都扫码亮灯后,料架可离开
*
料盘是否已拿走
*/
*/
private
boolean
codeLight
=
false
;
private
boolean
reelLeave
=
false
;
/**
/**
* 判断该架位锁定的条码是否与给定的条码一样
* 判断该架位锁定的条码是否与给定的条码一样
...
@@ -94,4 +94,16 @@ public class ShelfLoc {
...
@@ -94,4 +94,16 @@ public class ShelfLoc {
public
boolean
isBigLoc
()
{
public
boolean
isBigLoc
()
{
return
reelType
==
REEL_TYPE
.
BIG
;
return
reelType
==
REEL_TYPE
.
BIG
;
}
}
public
String
getPosName
(
String
lineLoc
)
{
String
reLoc
=
lineLoc
+
"-B1-"
+
loc
;
if
(
loc
<=
13
)
{
reLoc
=
lineLoc
+
"-A1-"
+
loc
;
}
else
if
(
loc
<=
26
)
{
reLoc
=
lineLoc
+
"-A2-"
+
(
loc
-
13
);
}
else
{
reLoc
=
lineLoc
+
"-B1-"
+
(
loc
-
26
);
}
return
reLoc
;
}
}
}
src/main/java/com/neotel/smfcore/core/shelf/rest/AgvShelfController.java
查看文件 @
b7df534
...
@@ -82,11 +82,13 @@ public class AgvShelfController {
...
@@ -82,11 +82,13 @@ public class AgvShelfController {
//更新记录
//更新记录
TaskShelfUtil
.
updateShelfLoc
(
rfid
,
loc
);
TaskShelfUtil
.
updateShelfLoc
(
rfid
,
loc
);
log
.
info
(
"updateShelfLoc 更新料架【"
+
rfid
+
"】位置=【"
+
loc
+
"】"
);
TaskShelfUtil
.
OpenShelfLed
(
shelfInfo
);
if
(!
shelfInfo
.
getLine
().
equals
(
loc
)){
log
.
info
(
"updateShelfLoc 更新料架【"
+
rfid
+
"】位置=【"
+
loc
+
"】,并所有库位亮灯"
);
shelfInfo
.
setLine
(
loc
);
// if(!shelfInfo.getLine().equals(loc)){
// shelfInfo.setLine(loc);
shelfInfo
.
ArriveLine
(
loc
);
TaskShelfUtil
.
updateShelfInfo
(
shelfInfo
);
TaskShelfUtil
.
updateShelfInfo
(
shelfInfo
);
}
//
}
String
orderNo
=
shelfInfo
.
getOrderNo
();
String
orderNo
=
shelfInfo
.
getOrderNo
();
LiteOrder
order
=
liteOrderCache
.
getLiteOrder
(
orderNo
);
LiteOrder
order
=
liteOrderCache
.
getLiteOrder
(
orderNo
);
if
(
order
!=
null
)
{
if
(
order
!=
null
)
{
...
@@ -112,20 +114,30 @@ public class AgvShelfController {
...
@@ -112,20 +114,30 @@ public class AgvShelfController {
)
{
)
{
for
(
ShelfInfo
shelf
:
for
(
ShelfInfo
shelf
:
map
.
values
())
{
map
.
values
())
{
if
(
shelf
.
isLightEnd
()
)
{
if
(
shelf
.
getShelfState
()==
3
)
{
Map
<
String
,
String
>
shelfMap
=
new
HashMap
<>();
Map
<
String
,
String
>
shelfMap
=
new
HashMap
<>();
shelfMap
.
put
(
"realRfid"
,
shelf
.
getRealRfid
());
shelfMap
.
put
(
"realRfid"
,
shelf
.
getRealRfid
());
shelfMap
.
put
(
"orderNo"
,
shelf
.
getOrderNo
());
shelfMap
.
put
(
"orderNo"
,
shelf
.
getOrderNo
());
shelfMap
.
put
(
"rfidIndex"
,
shelf
.
getRfidIndex
()
+
""
);
shelfMap
.
put
(
"rfidIndex"
,
shelf
.
getRfidIndex
()
+
""
);
shelfMap
.
put
(
"line"
,
shelf
.
getLine
());
String
loc
=
TaskShelfUtil
.
getShelfLoc
(
shelf
.
getRealRfid
());
shelfMap
.
put
(
"line"
,
loc
);
result
.
add
(
shelfMap
);
result
.
add
(
shelfMap
);
}
}
}
}
}
}
ResultBean
resultBean
=
ResultBean
.
newOkResult
(
"ok"
);
ResultBean
resultBean
=
ResultBean
.
newOkResult
(
"ok"
);
// if(result.size()<=0){
// for (int i=1;i<=2;i++){
// Map<String, String> shelfMap = new HashMap<>();
// shelfMap.put("realRfid","F001"+i);
// shelfMap.put("orderNo", "OrderNo"+i);
// shelfMap.put("rfidIndex","index"+i);
// shelfMap.put("line", "L1-00"+i);
//
// result.add(shelfMap);
// }
// }
resultBean
.
setData
(
result
);
resultBean
.
setData
(
result
);
return
resultBean
;
return
resultBean
;
}
}
...
...
src/main/java/com/neotel/smfcore/core/shelf/rest/TaskShelfController.java
查看文件 @
b7df534
...
@@ -95,7 +95,8 @@ public class TaskShelfController {
...
@@ -95,7 +95,8 @@ public class TaskShelfController {
ShelfLoc
loc
=
TaskShelfUtil
.
lockShelfLoc
(
opTask
,
rfid
);
ShelfLoc
loc
=
TaskShelfUtil
.
lockShelfLoc
(
opTask
,
rfid
);
if
(
loc
==
null
)
{
if
(
loc
==
null
)
{
return
ResultBean
.
newErrorResult
(
304
,
"smfcore.taskLoc.lockLoc.fail"
,
"{0}获取位置{1}失败"
,
new
String
[]{
opTask
.
getBarcode
(),
rfid
},
resultMap
);
return
ResultBean
.
newErrorResult
(
304
,
"smfcore.taskLoc.lockLoc.fail"
,
"{0}获取位置{1}失败"
,
new
String
[]{
opTask
.
getBarcode
()+
"-"
+
opTask
.
getTempRfid
()+
"-"
+
opTask
.
getRfidLoc
(),
rfid
},
resultMap
);
}
}
String
rfidSave
=
loc
.
getRealRfid
();
String
rfidSave
=
loc
.
getRealRfid
();
if
(
ObjectUtil
.
isEmpty
(
rfidSave
))
{
if
(
ObjectUtil
.
isEmpty
(
rfidSave
))
{
...
@@ -405,7 +406,7 @@ public class TaskShelfController {
...
@@ -405,7 +406,7 @@ public class TaskShelfController {
for
(
String
tempRfid
:
for
(
String
tempRfid
:
map2
.
keySet
())
{
map2
.
keySet
())
{
ShelfInfo
shelfInfo
=
map2
.
get
(
tempRfid
);
ShelfInfo
shelfInfo
=
map2
.
get
(
tempRfid
);
msg
+=
"hSerial="
+
hSerial
+
",tempRfid="
+
tempRfid
+
",realRfid="
+
shelfInfo
.
getRealRfid
()+
",
needLeave="
+
shelfInfo
.
isNeedLeav
e
()+
"\r\n"
;
msg
+=
"hSerial="
+
hSerial
+
",tempRfid="
+
tempRfid
+
",realRfid="
+
shelfInfo
.
getRealRfid
()+
",
ShelfState="
+
shelfInfo
.
getShelfStat
e
()+
"\r\n"
;
}
}
}
}
}
}
...
...
src/main/java/com/neotel/smfcore/core/shelf/util/TaskShelfUtil.java
查看文件 @
b7df534
...
@@ -6,11 +6,15 @@ import com.neotel.smfcore.core.device.util.DataCache;
...
@@ -6,11 +6,15 @@ import com.neotel.smfcore.core.device.util.DataCache;
import
com.neotel.smfcore.core.shelf.bean.ShelfInfo
;
import
com.neotel.smfcore.core.shelf.bean.ShelfInfo
;
import
com.neotel.smfcore.core.shelf.bean.ShelfLoc
;
import
com.neotel.smfcore.core.shelf.bean.ShelfLoc
;
import
com.neotel.smfcore.core.shelf.enums.SHELF_TYPE
;
import
com.neotel.smfcore.core.shelf.enums.SHELF_TYPE
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.awt.*
;
import
java.util.*
;
import
java.util.*
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
@Slf4j
@Slf4j
public
class
TaskShelfUtil
{
public
class
TaskShelfUtil
{
...
@@ -49,12 +53,28 @@ public class TaskShelfUtil {
...
@@ -49,12 +53,28 @@ public class TaskShelfUtil {
initShelfLocMap
();
initShelfLocMap
();
}
}
public
static
String
getCid
(
String
loc
){
return
loc
;
}
private
static
void
initShelfLocMap
()
{
private
static
void
initShelfLocMap
()
{
if
(
lineShelfLocMap
==
null
)
{
if
(
lineShelfLocMap
==
null
)
{
lineShelfLocMap
=
dataCache
.
getCache
(
LINE_SHELF_LOC_MAP_KEY
);
lineShelfLocMap
=
dataCache
.
getCache
(
LINE_SHELF_LOC_MAP_KEY
);
if
(
lineShelfLocMap
==
null
){
if
(
lineShelfLocMap
==
null
){
lineShelfLocMap
=
new
ConcurrentHashMap
<>();
lineShelfLocMap
=
new
ConcurrentHashMap
<>();
}
else
{
for
(
String
rfid
:
lineShelfLocMap
.
keySet
())
{
ShelfInfo
shelfInfo
=
TaskShelfUtil
.
findShelfByRealRfid
(
rfid
);
if
(
shelfInfo
!=
null
)
{
String
loc
=
lineShelfLocMap
.
get
(
rfid
);
log
.
info
(
"initShelfLocMap 料架 rfid=["
+
rfid
+
"] loc["
+
loc
+
"] 库位亮灯"
);
OpenShelfLed
(
shelfInfo
);
}
else
{
log
.
info
(
"initShelfLocMap 未找到料架 ,rfid=["
+
rfid
+
"]"
);
}
}
}
}
}
}
...
@@ -68,10 +88,10 @@ public class TaskShelfUtil {
...
@@ -68,10 +88,10 @@ public class TaskShelfUtil {
private
static
void
saveLineShelfMap
(
Map
<
String
,
ShelfInfo
>
map
)
{
private
static
void
saveLineShelfMap
(
Map
<
String
,
ShelfInfo
>
map
)
{
dataCache
.
updateCache
(
LINE_SHELF_MAP_KEY
,
map
);
dataCache
.
updateCache
(
LINE_SHELF_MAP_KEY
,
map
);
}
}
private
static
void
AddShelfToLineMap
(
ShelfInfo
shelfInfo
){
//
private static void AddShelfToLineMap(ShelfInfo shelfInfo){
lineShelfMap
.
put
(
shelfInfo
.
getRealRfid
(),
shelfInfo
);
//
lineShelfMap.put(shelfInfo.getRealRfid(),shelfInfo);
saveLineShelfMap
(
lineShelfMap
);
//
saveLineShelfMap(lineShelfMap);
}
//
}
private
static
void
saveLineShelfLocMap
(
Map
<
String
,
String
>
map
)
{
private
static
void
saveLineShelfLocMap
(
Map
<
String
,
String
>
map
)
{
dataCache
.
updateCache
(
LINE_SHELF_LOC_MAP_KEY
,
map
);
dataCache
.
updateCache
(
LINE_SHELF_LOC_MAP_KEY
,
map
);
}
}
...
@@ -172,12 +192,13 @@ public class TaskShelfUtil {
...
@@ -172,12 +192,13 @@ public class TaskShelfUtil {
int
maxIndex
=
0
;
int
maxIndex
=
0
;
if
(
shelfMap
!=
null
)
{
if
(
shelfMap
!=
null
)
{
for
(
ShelfInfo
shelfInfo
:
shelfMap
.
values
())
{
for
(
ShelfInfo
shelfInfo
:
shelfMap
.
values
())
{
if
(
shelfInfo
.
isNeedLeave
()){
continue
;
}
if
(
shelfInfo
.
getRfidIndex
()
>
maxIndex
)
{
if
(
shelfInfo
.
getRfidIndex
()
>
maxIndex
)
{
maxIndex
=
shelfInfo
.
getRfidIndex
();
maxIndex
=
shelfInfo
.
getRfidIndex
();
}
}
if
(
shelfInfo
.
getShelfState
()>=
1
){
continue
;
}
targetLoc
=
shelfInfo
.
addUnLimitLoc
(
task
);
targetLoc
=
shelfInfo
.
addUnLimitLoc
(
task
);
if
(
targetLoc
!=
-
1
)
{
if
(
targetLoc
!=
-
1
)
{
//添加成功
//添加成功
...
@@ -328,7 +349,7 @@ public class TaskShelfUtil {
...
@@ -328,7 +349,7 @@ public class TaskShelfUtil {
});
});
ShelfInfo
minIndexShelf
=
null
;
ShelfInfo
minIndexShelf
=
null
;
for
(
ShelfInfo
shelf
:
shelfList
)
{
for
(
ShelfInfo
shelf
:
shelfList
)
{
if
(
shelf
.
isFull
()||
shelf
.
isNeedLeave
()
)
{
if
(
shelf
.
isFull
()||
shelf
.
getShelfState
()>=
1
)
{
//已经放满,查找下一个
//已经放满,查找下一个
continue
;
continue
;
}
}
...
@@ -513,7 +534,7 @@ public class TaskShelfUtil {
...
@@ -513,7 +534,7 @@ public class TaskShelfUtil {
public
static
void
updateShelfLoc
(
String
rfid
,
String
loc
){
public
static
void
updateShelfLoc
(
String
rfid
,
String
loc
){
if
(
ObjectUtil
.
isEmpty
(
loc
)){
if
(
ObjectUtil
.
isEmpty
(
loc
)){
lineShelfMap
.
remove
(
rfid
);
lineShelf
Loc
Map
.
remove
(
rfid
);
}
else
{
}
else
{
lineShelfLocMap
.
put
(
rfid
,
loc
);
lineShelfLocMap
.
put
(
rfid
,
loc
);
...
@@ -530,23 +551,98 @@ public class TaskShelfUtil {
...
@@ -530,23 +551,98 @@ public class TaskShelfUtil {
return
line
;
return
line
;
}
}
//
// /**
// * 扫码亮灯,获取库位号
// * @param barcode
// * @return
// */
// public static ShelfLoc codeLightGetLoc(String barcode) {
// for (Map<String, ShelfInfo> shelfInfoMap : taskShelfMap.values()) {
// for (ShelfInfo shelf : shelfInfoMap.values()) {
//
// ShelfLoc shelfLoc = shelf.getBarcodeLoc(barcode);
// if (shelfLoc != null && (!shelfLoc.isEmpty())) {
// //获取料架位置
// String line = getShelfLoc(shelfLoc.getRealRfid());
// shelfLoc.setShelfLocation(line);
//
// shelfLoc.setReelLeave(true);
// //TODO 标记此料已扫码
// Map<Integer, ShelfLoc> locMap = shelf.getLocMap();
// locMap.put(shelfLoc.getLoc(), shelfLoc);
// shelf.setLocMap(locMap);
//
// boolean lightEnd=true;
// for (ShelfLoc loc : locMap.values()){
// if(!loc.isEmpty()){
// if(!loc.isReelLeave()){
// lightEnd=false;
// break;
// }
// }
// }
//
// shelf.setLightEnd(lightEnd);
//
// updateShelfInfo(shelf);
// log.info("标记料架[" + shelf.getRealRfid() + "]位置[" + shelfLoc.getLoc() + "]条码[" + shelfLoc.getBarcode() + "]为已扫码亮灯,料架是否亮灯完成["+lightEnd+"]");
// return shelfLoc;
//
// }
//
// }
// }
// return null;
// }
public
static
boolean
OpenShelfLed
(
ShelfInfo
shelfInfo
)
{
List
<
ShelfLoc
>
locs
=
shelfInfo
.
getLocList
();
String
shelfLoc
=
getShelfLoc
(
shelfInfo
.
getRealRfid
());
String
cid
=
getCid
(
shelfLoc
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
)
{
log
.
error
(
"OpenShelfLed 料架"
+
shelfInfo
.
getRealRfid
()
+
" , 位置:"
+
shelfLoc
+
",cid "
+
cid
+
" 未找到对应的亮灯料架"
);
return
false
;
}
for
(
ShelfLoc
loc
:
locs
)
{
String
posname
=
loc
.
getPosName
(
shelfLoc
);
if
(
loc
.
isEmpty
()
||
ObjectUtil
.
isEmpty
(
loc
.
getBarcode
()))
{
continue
;
}
if
(
loc
.
isReelLeave
())
{
continue
;
}
else
{
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
"open"
,
posname
+
"="
+
Color
.
GREEN
.
toString
());
log
.
info
(
"亮灯料架CID:"
+
storage
.
getCid
()
+
",料架RFID:"
+
shelfInfo
.
getRealRfid
()
+
" ,库位: "
+
posname
+
" 亮灯 :"
+
Color
.
GREEN
.
toString
());
}
}
return
true
;
}
/**
/**
* 扫码亮灯,获取库位号
* 扫码亮灯,获取库位号
* @param barcode
* @param barcode
* @return
* @return
*/
*/
public
static
ShelfLoc
codeLightGetLoc
(
String
barcode
)
{
public
static
List
<
Object
>
ReelLeave
(
String
barcode
)
{
List
<
Object
>
list
=
new
ArrayList
<>();
for
(
Map
<
String
,
ShelfInfo
>
shelfInfoMap
:
taskShelfMap
.
values
())
{
for
(
Map
<
String
,
ShelfInfo
>
shelfInfoMap
:
taskShelfMap
.
values
())
{
for
(
ShelfInfo
shelf
:
shelfInfoMap
.
values
())
{
for
(
ShelfInfo
shelf
:
shelfInfoMap
.
values
())
{
if
(!(
shelf
.
getShelfState
()==
2
)){
return
null
;
}
ShelfLoc
shelfLoc
=
shelf
.
getBarcodeLoc
(
barcode
);
ShelfLoc
shelfLoc
=
shelf
.
getBarcodeLoc
(
barcode
);
if
(
shelfLoc
!=
null
&&
(!
shelfLoc
.
isEmpty
()))
{
if
(
shelfLoc
!=
null
&&
(!
shelfLoc
.
isEmpty
()))
{
//获取料架位置
//获取料架位置
String
line
=
getShelfLoc
(
shelfLoc
.
getRealRfid
());
//
String line = getShelfLoc(shelfLoc.getRealRfid());
shelfLoc
.
setShelfLocation
(
line
);
//
shelfLoc.setShelfLocation(line);
shelfLoc
.
set
CodeLight
(
true
);
shelfLoc
.
set
ReelLeave
(
true
);
//TODO 标记此料已扫码
//TODO 标记此料已扫码
Map
<
Integer
,
ShelfLoc
>
locMap
=
shelf
.
getLocMap
();
Map
<
Integer
,
ShelfLoc
>
locMap
=
shelf
.
getLocMap
();
locMap
.
put
(
shelfLoc
.
getLoc
(),
shelfLoc
);
locMap
.
put
(
shelfLoc
.
getLoc
(),
shelfLoc
);
...
@@ -555,18 +651,20 @@ public class TaskShelfUtil {
...
@@ -555,18 +651,20 @@ public class TaskShelfUtil {
boolean
lightEnd
=
true
;
boolean
lightEnd
=
true
;
for
(
ShelfLoc
loc
:
locMap
.
values
()){
for
(
ShelfLoc
loc
:
locMap
.
values
()){
if
(!
loc
.
isEmpty
()){
if
(!
loc
.
isEmpty
()){
if
(!
loc
.
is
CodeLight
()){
if
(!
loc
.
is
ReelLeave
()){
lightEnd
=
false
;
lightEnd
=
false
;
break
;
break
;
}
}
}
}
}
}
shelf
.
setLightEnd
(
lightEnd
);
shelf
.
NeedLeaveLine
(
);
updateShelfInfo
(
shelf
);
updateShelfInfo
(
shelf
);
log
.
info
(
"标记料架["
+
shelf
.
getRealRfid
()
+
"]位置["
+
shelfLoc
.
getLoc
()
+
"]条码["
+
shelfLoc
.
getBarcode
()
+
"]为已扫码亮灯,料架是否亮灯完成["
+
lightEnd
+
"]"
);
log
.
info
(
"标记料架["
+
shelf
.
getRealRfid
()
+
"]位置["
+
shelfLoc
.
getLoc
()
+
"]条码["
+
shelfLoc
.
getBarcode
()
+
"]已扫码灭灯,料盘已离开,料架是否亮灯完成["
+
lightEnd
+
"]"
);
return
shelfLoc
;
list
.
add
(
shelf
);
list
.
add
(
shelfLoc
);
// return shelfLoc;
}
}
...
...
src/main/java/com/neotel/smfcore/custom/gree20242/CodeLightController.java
查看文件 @
b7df534
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
;
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.base.Strings
;
import
com.google.common.base.Strings
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.init.DataInitManager
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.shelf.bean.ShelfInfo
;
import
com.neotel.smfcore.core.shelf.bean.ShelfLoc
;
import
com.neotel.smfcore.core.shelf.bean.ShelfLoc
;
import
com.neotel.smfcore.core.shelf.util.TaskShelfUtil
;
import
com.neotel.smfcore.core.shelf.util.TaskShelfUtil
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.custom.gree20242.dto.ShelfDto
;
import
com.neotel.smfcore.custom.gree20242.dto.ShelfReelDto
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.awt.*
;
import
java.awt.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
@Slf4j
@Slf4j
...
@@ -37,64 +47,142 @@ public class CodeLightController {
...
@@ -37,64 +47,142 @@ public class CodeLightController {
@Autowired
@Autowired
private
IStoragePosManager
storagePosManager
;
private
IStoragePosManager
storagePosManager
;
@ApiOperation
(
"扫码亮灯"
)
@Autowired
@PostMapping
(
value
=
"/lightOn"
)
private
IBarcodeManager
barcodeManager
;
@ApiOperation
(
"获取扫码亮灯页面数据"
)
@GetMapping
(
value
=
"/reelList"
)
@ResponseBody
@ResponseBody
@AnonymousAccess
@AnonymousAccess
public
ResultBean
lightOn
(
@RequestBody
Map
<
String
,
String
>
mapValues
)
{
public
List
<
ShelfDto
>
reelList
(
HttpServletRequest
servletRequest
)
{
String
code
=
mapValues
.
get
(
"code"
);
List
<
ShelfDto
>
shelfDtos
=
new
ArrayList
<>();
//扫码后,解析条码,从料架列表中查找对应位置
Map
<
String
,
String
>
lineShelfLocMap
=
TaskShelfUtil
.
lineShelfLocMap
;
for
(
String
rfid
:
Barcode
barcode
=
codeResolve
.
resolveOneValideBarcode
(
code
);
lineShelfLocMap
.
keySet
())
{
String
shelfLoc
=
lineShelfLocMap
.
get
(
rfid
);
if
(
barcode
==
null
)
{
ShelfDto
dto
=
new
ShelfDto
();
log
.
info
(
"codeLed 未找到有效条码["
+
code
+
"]"
);
dto
.
setRfid
(
rfid
);
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.error.barcode.invalid"
,
"未找到有效条码"
);
dto
.
setLoc
(
shelfLoc
);
ShelfInfo
shelfInfo
=
TaskShelfUtil
.
findShelfByRealRfid
(
rfid
);
if
(
shelfInfo
!=
null
)
{
dto
.
setOrderNo
(
shelfInfo
.
getOrderNo
());
List
<
ShelfReelDto
>
reelDtos
=
new
ArrayList
<>();
List
<
ShelfLoc
>
locs
=
shelfInfo
.
getLocList
();
//查找对应的pn
List
<
String
>
barcodeList
=
new
ArrayList
<>();
for
(
ShelfLoc
loc
:
locs
)
{
if
(
loc
.
isEmpty
()||
ObjectUtil
.
isEmpty
(
loc
.
getBarcode
())){
continue
;
}
if
(
loc
.
isReelLeave
()){
continue
;
}
else
{
ShelfReelDto
reelDto
=
new
ShelfReelDto
(
""
,
loc
.
getBarcode
(),
loc
.
getPosName
(
TaskShelfUtil
.
getShelfLoc
(
shelfInfo
.
getRealRfid
()))
)
;
reelDtos
.
add
(
reelDto
);
barcodeList
.
add
(
loc
.
getBarcode
());
}
}
Criteria
c
=
Criteria
.
where
(
"barcode"
).
in
(
barcodeList
.
toArray
());
List
<
Barcode
>
barcodes
=
barcodeManager
.
findByQuery
(
new
Query
(
c
));
for
(
int
i
=
0
;
i
<
reelDtos
.
size
();
i
++)
{
for
(
Barcode
barcode
:
barcodes
)
{
if
(
reelDtos
.
get
(
i
).
getRi
().
equals
(
barcode
.
getBarcode
()))
{
reelDtos
.
get
(
i
).
setPn
(
barcode
.
getPartNumber
());
break
;
}
}
}
dto
.
setReelList
(
reelDtos
);
shelfDtos
.
add
(
dto
);
}
}
}
ShelfLoc
loc
=
TaskShelfUtil
.
codeLightGetLoc
(
barcode
.
getBarcode
());
if
(
loc
==
null
)
{
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.light.error.noloc"
,
"未找到亮灯位置"
);
}
//找到对应的库位,给亮灯料架发送亮灯指令
if
(
shelfDtos
.
size
()<=
0
){
if
(
DataInitManager
.
Debug
){
String
cid
=
loc
.
getShelfLocation
();
for
(
int
i
=
1
;
i
<=
2
;
i
++){
String
posname
=
loc
.
getShelfLocation
()
+
"_"
+
loc
.
getLoc
();
ShelfDto
dto
=
new
ShelfDto
();
dto
.
setRfid
(
"rfid"
+
i
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
dto
.
setLoc
(
"line"
+
i
);
if
(
storage
==
null
)
{
List
<
ShelfReelDto
>
reelDtos
=
new
ArrayList
<>();
for
(
int
j
=
1
;
j
<=
10
;
j
++){
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.light.error.noStorage"
,
"未找到料架["
+
cid
+
"]"
,
new
String
[]{
cid
});
ShelfReelDto
reelDto
=
new
ShelfReelDto
(
"PN"
+
j
,
"BARCODE"
+
j
,
"PosName"
+
j
);
reelDtos
.
add
(
reelDto
);
}
dto
.
setReelList
(
reelDtos
);
shelfDtos
.
add
(
dto
);
}
}
}
}
return
shelfDtos
;
StoragePos
pos
=
storagePosManager
.
getByPosName
(
posname
);
if
(
pos
==
null
)
{
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.light.error.noStoragePos"
,
"未找到料架库位["
+
posname
+
"]"
,
new
String
[]{
posname
});
}
opPosLight
(
"open"
,
pos
,
Color
.
GREEN
.
toString
());
return
ResultBean
.
newOkResult
(
loc
);
}
}
/**
// @ApiOperation("扫码亮灯")
* 操作库位灯(开灯,或关灯)
// @PostMapping(value = "/lightOn")
*
// @ResponseBody
* @param opKey
// @AnonymousAccess
* @param pos
// public ResultBean lightOn(@RequestBody Map<String, String> mapValues) {
* @param colorStr
//
*/
// String code = mapValues.get("code");
private
void
opPosLight
(
String
opKey
,
StoragePos
pos
,
String
colorStr
)
{
// //扫码后,解析条码,从料架列表中查找对应位置
//
String
opStr
=
pos
.
getPosName
();
// Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if
(!
Strings
.
isNullOrEmpty
(
colorStr
))
{
//
opStr
=
opStr
+
"="
+
colorStr
;
// if (barcode == null) {
}
// log.info("codeLed 未找到有效条码[" + code + "]");
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
// return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码");
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
opKey
,
opStr
);
// }
log
.
info
(
"操作库位["
+
pos
.
getPosName
()
+
"]"
+
opKey
+
" : "
+
opStr
);
// List<Object> result = TaskShelfUtil.ReelLeave(barcode.getBarcode());
}
//
// if (result == null) {
// return ResultBean.newErrorResult(99, "smfcore.light.error.noloc", "未找到亮灯位置");
// }
// ShelfLoc loc=(ShelfLoc)result.get(1);
// ShelfInfo shelfInfo=(ShelfInfo)result.get(0);
//
// //找到对应的库位,给亮灯料架发送亮灯指令
//
// String shelfLoc=TaskShelfUtil.getShelfLoc(shelfInfo.getRealRfid());
// String cid = TaskShelfUtil.getCid(shelfLoc);
// String posname = loc.getPosName(shelfLoc);
//
// Storage storage = dataCache.getStorage(cid);
// if (storage == null) {
//
// return ResultBean.newErrorResult(99, "smfcore.light.error.noStorage", "未找到料架[" + cid + "]", new String[]{cid});
// }
//
// StoragePos pos = storagePosManager.getByPosName(posname);
// if (pos == null) {
// return ResultBean.newErrorResult(99, "smfcore.light.error.noStoragePos", "未找到料架库位[" + posname + "]", new String[]{posname});
// }
//
// opPosLight("open", pos, Color.GREEN.toString());
// return ResultBean.newOkResult(loc);
// }
// /**
// * 操作库位灯(开灯,或关灯)
// *
// * @param opKey
// * @param pos
// * @param colorStr
// */
// private void opPosLight(String opKey, StoragePos pos, String colorStr) {
//
// String opStr = pos.getPosName();
// if (!Strings.isNullOrEmpty(colorStr)) {
// opStr = opStr + "=" + colorStr;
// }
// Storage storage = dataCache.getStorageById(pos.getStorageId());
// DevicesStatusUtil.appendOp(storage.getCid(), opKey, opStr);
// log.info("操作库位[" + pos.getPosName() + "]" + opKey + " : " + opStr);
// }
@ApiOperation
(
"扫码灭灯"
)
@ApiOperation
(
"扫码灭灯"
)
@PostMapping
(
value
=
"/lightOff"
)
@PostMapping
(
value
=
"/lightOff"
)
...
@@ -111,14 +199,20 @@ public class CodeLightController {
...
@@ -111,14 +199,20 @@ public class CodeLightController {
log
.
info
(
"codeLed 未找到有效条码["
+
code
+
"]"
);
log
.
info
(
"codeLed 未找到有效条码["
+
code
+
"]"
);
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.error.barcode.invalid"
,
"未找到有效条码"
);
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.error.barcode.invalid"
,
"未找到有效条码"
);
}
}
ShelfLoc
loc
=
TaskShelfUtil
.
codeLightGetLoc
(
barcode
.
getBarcode
());
List
<
Object
>
result
=
TaskShelfUtil
.
ReelLeave
(
barcode
.
getBarcode
());
if
(
loc
==
null
)
{
if
(
result
==
null
)
{
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.light.error.noloc"
,
"未找到亮灯位置"
);
return
ResultBean
.
newErrorResult
(
99
,
"smfcore.light.error.noloc"
,
"未找到亮灯位置"
);
}
}
ShelfLoc
loc
=(
ShelfLoc
)
result
.
get
(
1
);
ShelfInfo
shelfInfo
=(
ShelfInfo
)
result
.
get
(
0
);
// if (loc == null) {
// return ResultBean.newErrorResult(99, "smfcore.light.error.noloc", "未找到亮灯位置");
// }
String
shelfLoc
=
TaskShelfUtil
.
getShelfLoc
(
shelfInfo
.
getRealRfid
());
String
cid
=
loc
.
getShelfLocation
(
);
String
cid
=
TaskShelfUtil
.
getCid
(
shelfLoc
);
String
posname
=
loc
.
get
ShelfLocation
()
+
"_"
+
loc
.
getLoc
(
);
String
posname
=
loc
.
get
PosName
(
shelfLoc
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
)
{
if
(
storage
==
null
)
{
...
@@ -131,8 +225,12 @@ public class CodeLightController {
...
@@ -131,8 +225,12 @@ public class CodeLightController {
}
}
//找到对应的库位,给亮灯料架发送灭灯指令
//找到对应的库位,给亮灯料架发送灭灯指令
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
"close
All"
,
"true
"
);
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
"close
"
,
posname
+
"=
"
);
return
ResultBean
.
newOkResult
(
loc
);
return
ResultBean
.
newOkResult
(
loc
);
}
}
}
}
src/main/java/com/neotel/smfcore/custom/gree20242/dto/ShelfDto.java
0 → 100644
查看文件 @
b7df534
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ShelfDto
{
@ApiModelProperty
(
"料架rfid"
)
private
String
rfid
;
@ApiModelProperty
(
"位置"
)
private
String
loc
;
@ApiModelProperty
(
"工单信息"
)
private
String
orderNo
;
@ApiModelProperty
(
"物料列表"
)
private
List
<
ShelfReelDto
>
reelList
;
}
src/main/java/com/neotel/smfcore/custom/gree20242/dto/ShelfReelDto.java
0 → 100644
查看文件 @
b7df534
package
com
.
neotel
.
smfcore
.
custom
.
gree20242
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ShelfReelDto
implements
Serializable
{
@ApiModelProperty
(
"PN"
)
private
String
pn
;
@ApiModelProperty
(
"RI"
)
private
String
ri
;
@ApiModelProperty
(
"库位号"
)
private
String
posName
;
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论