Commit beeed935 LN

1

1 个父辈 4aba1dfc
package com.neotel.smfcore.common.init;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.utils.PermissionInitUtil;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.service.manager.IMessageManager;
import com.neotel.smfcore.core.message.service.po.Message;
import com.neotel.smfcore.core.order.util.OrderFileWatch;
import com.neotel.smfcore.core.shelf.TaskShelfUtil;
import com.neotel.smfcore.security.service.manager.IMenuManager;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
import com.neotel.smfcore.security.service.manager.IRoleManager;
import com.neotel.smfcore.security.service.manager.IUserManager;
import com.neotel.smfcore.security.service.po.Menu;
import com.neotel.smfcore.security.service.po.Role;
import com.neotel.smfcore.security.service.po.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
......
......@@ -141,6 +141,15 @@ public class DeviceController {
String rfidLoc = request.getParameter("rfidLoc");
String lastPosId = request.getParameter("lastPosId");
//返回值:
//100=系统更新中,暂停出入库
//101=未指定料仓 cids
//99=无可用的料仓
//107=物料已过期
//98=有出库任务
//104=未找到可用仓位
//105=查找空库位失败
lineMsg = "";
log.info("流水线[" + cids + "]获取[" + rfid + "][" + code + "]的入库库位");
Map<String, Object> resultMap = Maps.newHashMap();
......
......@@ -21,7 +21,7 @@ import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.shelf.TaskShelfUtil;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
......
......@@ -16,17 +16,17 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class ShelfInfo {
public ShelfInfo(String type,int maxNum){
shelfType=type ;
maxLocCount=maxNum;
public ShelfInfo(String type, int maxNum) {
shelfType = type;
maxLocCount = maxNum;
}
/**
* F料架位置数量,1-26是小料,27=31是大料
*/
private static int F_POS_COUNT=31;
private static int MAX_F_SMALL_NUM=26;//F料架小料位置最大编号
private static int F_POS_COUNT = 31;
private static int MAX_F_SMALL_NUM = 26;//F料架小料位置最大编号
/**
......@@ -60,15 +60,15 @@ public class ShelfInfo {
*/
private int maxLocCount = 0;
public static ShelfInfo newFShelf(){
return new ShelfInfo(SHELF_TYPE.F,31);
public static ShelfInfo newFShelf() {
return new ShelfInfo(SHELF_TYPE.F, 31);
}
/**
* 架位放置情况, key小于0表示已经放过,key>0为空的库位
*/
private Map<Integer, ShelfLoc> locMap = new ConcurrentHashMap<>();
public String tempRfid(){
public String tempRfid() {
return getOrderNo() + "-" + rfidIndex + shelfType;
}
......@@ -105,18 +105,18 @@ public class ShelfInfo {
/**
* 为不需要按顺序摆放的料盘锁定一个架位,如果已经锁定过,返回对应的架位
*/
public ShelfLoc lockOneEmptyLoc(DataLog task){
public ShelfLoc lockOneEmptyLoc(DataLog task) {
//先看看此条码是否已经锁定过
for (ShelfLoc shelfLoc : locMap.values()) {
if(shelfLoc.isLock() && shelfLoc.getBarcode().equals(task.getBarcode())){
log.info("找到条码["+task.getBarcode()+"]锁定的架位["+shelfLoc.getLoc()+"]");
if (shelfLoc.isLock() && shelfLoc.getBarcode().equals(task.getBarcode())) {
log.info("找到条码[" + task.getBarcode() + "]锁定的架位[" + shelfLoc.getLoc() + "]");
return shelfLoc;
}
}
for(int i=1; i<= maxLocCount; i++){
ShelfLoc shelfLoc = lockLocation(i,task);
if(shelfLoc != null){
for (int i = 1; i <= maxLocCount; i++) {
ShelfLoc shelfLoc = lockLocation(i, task);
if (shelfLoc != null) {
return shelfLoc;
}
}
......@@ -126,13 +126,14 @@ public class ShelfInfo {
/**
* 锁定库位,如果成功返回库位,如果失败返回null
*/
private ShelfLoc lockLocation(int loc, DataLog task){
private ShelfLoc lockLocation(int loc, DataLog task) {
ShelfLoc shelfLoc = locMap.get(loc);
if(shelfLoc != null && shelfLoc.isEmpty() && !shelfLoc.isLock() && getReelType(task) == shelfLoc.getReelType()){
log.info("为[" + task.getBarcode() + "]锁定架位"+tempRfid() + "["+loc+"]");
if (shelfLoc != null && shelfLoc.isEmpty() && !shelfLoc.isLock() && getReelType(task) == shelfLoc.getReelType()) {
log.info("为[" + task.getBarcode() + "]锁定架位" + tempRfid() + "[" + loc + "]");
//未放过料,且未锁定
shelfLoc.setBarcode(task.getBarcode());
shelfLoc.setReelType(getReelType(task));
shelfLoc.setLock(true);
locMap.put(loc, shelfLoc);
return shelfLoc;
}
......@@ -141,29 +142,29 @@ public class ShelfInfo {
/**
* 添加一个库位
* 新建任务时添加库位
*/
public int addUnLimitLoc(DataLog task){
for(int i=1; i<= maxLocCount; i++){
public int addUnLimitLoc(DataLog task) {
for (int i = 1; i <= maxLocCount; i++) {
ShelfLoc shelfLoc = locMap.get(i);
if(shelfLoc == null){
if (shelfLoc == null) {
boolean addThis = false;
if(isSmallReel(task)){
if(i<= MAX_F_SMALL_NUM){
if (isSmallReel(task)) {
if (i <= MAX_F_SMALL_NUM) {
addThis = true;
}
}else{
if(i> MAX_F_SMALL_NUM){
} else {
if (i > MAX_F_SMALL_NUM) {
addThis = true;
}
}
if(addThis){
if (addThis) {
shelfLoc = new ShelfLoc();
shelfLoc.setLoc(i);
shelfLoc.setBarcode("");
shelfLoc.setReelType(getReelType(task));
shelfLoc.setTempRfid(tempRfid());
if(ObjectUtil.isNotEmpty(realRfid)){
if (ObjectUtil.isNotEmpty(realRfid)) {
shelfLoc.setRealRfid(realRfid);
}
locMap.put(i, shelfLoc);
......@@ -179,15 +180,15 @@ public class ShelfInfo {
* @param loc
* @param barcode
*/
public boolean putInLoc(String rfid, int loc, String barcode){
if(ObjectUtil.isNotEmpty(realRfid)){
public boolean putInLoc(String rfid, int loc, String barcode) {
if (ObjectUtil.isNotEmpty(realRfid)) {
//已绑定过真实料架,必须一致才能放入
if(!this.realRfid.equals(rfid)){
if (!this.realRfid.equals(rfid)) {
return false;
}
}
if(!rfid.contains(shelfType)){
if (!rfid.contains(shelfType)) {
//未绑定过料架的,需要判断类型是否一致
return false;
}
......@@ -195,53 +196,55 @@ public class ShelfInfo {
int lockLocation = -1;
for (ShelfLoc shelfLoc : locMap.values()) {
if(shelfLoc.isLock() && shelfLoc.getBarcode().equals(barcode)){
log.info("找到条码["+barcode+"]锁定的架位["+shelfLoc.getLoc()+"]");
if (shelfLoc.isLock() && shelfLoc.getBarcode().equals(barcode)) {
log.info("找到条码[" + barcode + "]锁定的架位[" + shelfLoc.getLoc() + "]");
lockLocation = shelfLoc.getLoc();
}
}
if(lockLocation == -1){
log.error("["+tempRfid()+"]未找到["+barcode+"]锁定的位置信息");
if (lockLocation == -1) {
log.error("[" + tempRfid() + "]未找到[" + barcode + "]锁定的位置信息");
return false;
}
if(lockLocation != loc){
log.error(barcode + "放置位置["+loc+"]与锁定位置["+lockLocation+"]不一致");
if (lockLocation != loc) {
log.error(barcode + "放置位置[" + loc + "]与锁定位置[" + lockLocation + "]不一致");
return false;
}
this.setRealRfid(rfid);
ShelfLoc shelfLoc = locMap.get(loc);
if(shelfLoc == null){
log.error("未找到["+loc+"]的位置信息,当前料架位置信息:"+ locMap);
if (shelfLoc == null) {
log.error("未找到[" + loc + "]的位置信息,当前料架位置信息:" + locMap);
return false;
}
if(shelfLoc.isEmpty()){
if (shelfLoc.isEmpty()) {
boolean putInResult = shelfLoc.putIn(barcode);
locMap.put(loc, shelfLoc);
return putInResult;
}else{
log.error("料盘["+barcode+"]放入位置"+rfid+"["+loc+"]失败,此位置料盘已放入");
} else {
log.error("料盘[" + barcode + "]放入位置" + rfid + "[" + loc + "]失败,此位置料盘已放入");
return false;
}
}
public boolean isFull(){
public boolean isFull() {
for (ShelfLoc loc : locMap.values()) {
if(loc.isEmpty()){
if (loc.isEmpty()) {
return false;
}
}
return true;
}
/**
* 为 取消一个库位
*/
public boolean cancelLoc(String rfidType, DataLog task){
if(rfidType.equals(this.getShelfType())){
for(int i=maxLocCount; i> 0; i--){
public boolean cancelLoc(String rfidType, DataLog task) {
if (rfidType.equals(this.getShelfType())) {
for (int i = maxLocCount; i > 0; i--) {
ShelfLoc shelfLoc = locMap.get(i);
if(shelfLoc != null && shelfLoc.isEmpty() && !shelfLoc.isLock() && shelfLoc.getReelType() == getReelType(task)){
if (shelfLoc != null && shelfLoc.isEmpty() && !shelfLoc.isLock() && shelfLoc.getReelType() == getReelType(task)) {
//未放过料,且未锁定
shelfLoc.putIn(task.getBarcode());
return true;
......@@ -250,10 +253,19 @@ public class ShelfInfo {
}
return false;
}
public int getReelType(DataLog task){
return 0;
public int getReelType(DataLog task) {
// 物料类型:1=小料,2=大料
if (isSmallReel(task)) {
return 1;
}
return 2;
}
public boolean isSmallReel(DataLog task){
return true;
public boolean isSmallReel(DataLog task) {
if (task.getW() <= 7) {
return true;
}
return false;
}
}
......@@ -4,7 +4,7 @@ import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.shelf.TaskShelfUtil;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
import com.neotel.smfcore.core.shelf.bean.ShelfInfo;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
......
......@@ -7,7 +7,7 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.shelf.TaskShelfUtil;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
import com.neotel.smfcore.core.shelf.bean.ShelfInfo;
import com.neotel.smfcore.core.shelf.bean.ShelfLoc;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
......@@ -220,7 +220,12 @@ public class TaskShelfController {
// resultMap.put("smallTask", smallTask + "");
// resultMap.put("bigTask", bigTask + "");
return ResultBean.newOkResult(resultMap);
if(result) {
ResultBean.newOkResult(resultMap);
}else{
log.info(" getLocation barcode[" + barcode + "],rfid[" + rfid + "],loc["+rfidLoc+"] 放料到料架失败,未找到锁定位置");
return ResultBean.newErrorResult(304, "smfcore.task.locNotFind", "{0}放料到料架{0}的位置{0}失败,未找到锁定位置", new String[]{opTask.getBarcode(), rfid,rfidLoc+""});
}
} catch (Exception e) {
log.error("putShelfFinished 出错 rfid=" + rfid + ";rfidLoc=" + rfidLoc + ";barcode=" + barcode, e);
}
......
package com.neotel.smfcore.core.shelf;
package com.neotel.smfcore.core.shelf.util;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
......@@ -28,7 +28,7 @@ public class TaskShelfUtil {
public static Map<String, Map<String, ShelfInfo>> taskShelfMap =null;
/**料架所在的产线位置
*
*key=rfid,value=位置
*/
public static Map<String,String> shelfLocMap=null;
......
......@@ -34,6 +34,8 @@ public class DataLog extends BasePo implements Serializable ,Comparable<DataLog>
setNum(barcode.getAmount());
setMemo(barcode.getMemo());
setW(barcode.getPlateSize());
setH(barcode.getHeight());
setProviderNumber(barcode.getProviderNumber());
setBatchInfo(barcode.getBatch());
setPutInDate(barcode.getPutInDate());
......
......@@ -9,7 +9,7 @@
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%file:%line] - %msg%n"/>
</Console>
<RollingFile name="log" fileName="${LOG_HOME}/${LOG_NAME}.txt" filePattern="${LOG_HOME}/${LOG_NAME}.%d{yyyy-MM-dd}.txt" append="true">
<PatternLayout charset="GB18030" pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%file:%line] - %msg%n" />
<PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%file:%line] - %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy modulate="true" interval="1" />
</Policies>
......@@ -21,6 +21,7 @@
</logger>
<logger name="ro" level="WARN">
</logger>
<logger name="org.apache.kafka.clients.NetworkClient" level="ERROR" />
<root level="INFO">
<appender-ref ref="Console"/>
<appender-ref ref="log"/>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!