Commit 5897ca5c zshaohui

1.7/19 抛送库位使用情况

2.人工线功能提交
1 个父辈 2f8db4fe
......@@ -2362,8 +2362,8 @@ public class LiteOrderCache {
}
private List<StoragePos> findTargetPos(List<StoragePos> numbers, int targetNum) {
numbers.sort((a, b) -> Integer.valueOf(b.getBarcode().getQty()).compareTo(Integer.valueOf(a.getBarcode().getQty())));
Collections.sort(numbers, (s1, s2) -> Long.compare(s2.getBarcode().getPutInTime(), s1.getBarcode().getPutInTime()));
numbers.sort((a, b) -> Integer.valueOf(b.getBarcode().getQty()).compareTo(Integer.valueOf(a.getBarcode().getQty())));
int target = targetNum;
List<StoragePos> result = new ArrayList<>();
for (int i = 0; i < 3000; i++) {
......
......@@ -36,6 +36,8 @@ import com.neotel.smfcore.custom.lizhen.innerBox.bean.StorageExport;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.util.StorageExportUtil;
import com.neotel.smfcore.custom.lizhen.virtual.service.manager.IVirInventoryManager;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.TaskCurrentLoc;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.TaskLocUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -213,6 +215,7 @@ public class TaskService {
if (extendType != -1) {
task.setExtendType(extendType);
}
task.setLoc(TaskLocUtil.MW);
task.setCartonId(barcode.getCartonId());
addTaskToExecute(task);
//}
......
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
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.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
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.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.FetchPalletInfoRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.PalletUpdateRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.ValidCartonRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchPalletInfoResult;
import com.neotel.smfcore.custom.luxsan.api.bean.result.ValidCartonResult;
import com.neotel.smfcore.custom.luxsan.api.enums.PalletEnum;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.bean.ManualPutIn;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.CacheUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.ManualWorkUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.TaskLocUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Api(tags = "人工流水线接口")
@Slf4j
@RestController
@RequestMapping("/manualLine")
public class MLineController {
@Autowired
private DataCache dataCache;
@Autowired
private CodeResolve codeResolve;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IComponentManager componentManager;
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private TaskService taskService;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
/**
* 线体第一个扫码器扫码调用
*/
@ApiOperation("校验箱号")
@RequestMapping("/validCarton")
@AnonymousAccess
public ResultBean validCarton(@RequestBody Map<String, String> paramMap) {
String boxId = paramMap.get("cartonId");
log.info("线体第一个扫码枪扫描到箱号["+boxId+"]校验箱号");
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
//如果是人工作业 直接返回ok
if (ManualWorkUtil.bindManualWork(barcode.getBarcode()) || ManualWorkUtil.bindShipCancelUpShelf(barcode.getBarcode())) {
log.info(barcode.getBarcode()+"绑定人工作业或者砍单回库作业,不进行校验");
return ResultBean.newOkResult("");
}
String scanCartonId = barcode.getScanCartonId();
if(Strings.isBlank(scanCartonId)){
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noBind", "条码未绑定CartonId");
}
try {
ValidCartonResult result = LuxsanApi.validCarton(new ValidCartonRequest("", scanCartonId, CommonUtil.plantCode));
Map<String, ManualPutIn> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_WIP_MANUAL_INPUT);
if (cacheMap == null){
cacheMap = new ConcurrentHashMap<>();
}
cacheMap.put(barcode.getBarcode(), new ManualPutIn(barcode.getBarcode(), scanCartonId, 1));
dataCache.updateCache(CacheNameUtil.CHCHE_WIP_MANUAL_INPUT,cacheMap);
} catch (Exception e) {
return ResultBean.newErrorResult(-1, "", e.getMessage());
}
return ResultBean.newOkResult("");
}
/**
* 线体第二个扫码器扫码调用,判断是否过账
*/
@ApiOperation("获取是否过账完成信息")
@RequestMapping("/fetchPalletInfo")
@AnonymousAccess
public synchronized ResultBean fetchPalletInfo(@RequestBody Map<String, String> paramMap) {
String boxId = paramMap.get("cartonId");
log.info("线体第二个扫码枪扫描到箱号["+boxId+"],判断过账是否完成");
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
//判断库位是否为空
StoragePos oldPos = storagePosManager.getByBarcode(barcode.getBarcode());
if (oldPos != null){
return ResultBean.newErrorResult(-1,"",barcode.getBarcode()+"已经存在库位:"+oldPos.getPosName());
}
//判断有没有正在执行的任务
for (DataLog dataLog : taskService.getAllTasks()) {
if (dataLog.getBarcode().equals(barcode.getBarcode())){
if (!dataLog.isFinished() && !dataLog.isCancel()){
return ResultBean.newErrorResult(-1,"",boxId+"有正在执行的任务,请确认");
}
}
}
//如果是人工作业的,直接入库
if (ManualWorkUtil.bindManualWork(barcode.getBarcode()) || ManualWorkUtil.bindShipCancelUpShelf(barcode.getBarcode())){
log.info(barcode.getBarcode()+"绑定人工作业或者砍单回库作业,不进行校验");
} else {
//2.请求接口判断是否过账
try {
String palletId = barcode.getScanCartonId();
FetchPalletInfoResult fetchPalletInfo = null;
List<FetchPalletInfoResult> fetchPalletList = LuxsanApi.fetchPalletInfo(new FetchPalletInfoRequest("", CommonUtil.plantCode, Arrays.asList(palletId)));
for (FetchPalletInfoResult result : fetchPalletList) {
if (palletId.equals(result.getPALLET_ID())) {
fetchPalletInfo = result;
break;
}
}
if (fetchPalletInfo != null) {
if (fetchPalletInfo.getSTATUS() != PalletEnum.POSTED_AND_PENDING_SHELVING && fetchPalletInfo.getSTATUS() != PalletEnum.INVENTORY_IN_WAREHOUSE) {
return ResultBean.newErrorResult(-1, "", fetchPalletInfo.getPALLET_ID() + "不是[4 在库库存]/[6 已过账,待上架],不允许入库");
}
//设置barcode的其他参数
barcode.setPlantCode(fetchPalletInfo.getPLANT());
barcode.setCartonId(fetchPalletInfo.getPALLET_ID());
barcode.setPalletId(fetchPalletInfo.getPALLET_ID());
barcode.setPn(fetchPalletInfo.getMATERIAL_CODE());
barcode.setPartNumber(fetchPalletInfo.getMATERIAL_CODE());
Component component = componentManager.findOneByPN(barcode.getPartNumber());
if(component == null){
component = new Component();
component.setPartNumber(barcode.getPartNumber());
component.setPlateSize(Integer.valueOf(2));
component.setHeight(Integer.valueOf(2));
componentManager.save(component);
}
barcode.setModelFamily(fetchPalletInfo.getMODEL_FAMILY());
barcode.setMaterialType(fetchPalletInfo.getMATERIAL_TYPE());
barcode.setWarehouseCode(fetchPalletInfo.getWAREHOUSE_CODE());
barcode.setHold(fetchPalletInfo.getHOLD());
barcode.setQty(fetchPalletInfo.getQTY());
barcode.setAmount(fetchPalletInfo.getQTY());
//barcode.setFullQty(fetchPalletInfo.getFULL_QTY());
barcode.setPackType(fetchPalletInfo.getPACK_TYPE());
barcode.setCreateAt(fetchPalletInfo.getCREATED_TIME());
//barcode.setRegion(fetchPalletInfo.getREGION());
barcode.setStatus(fetchPalletInfo.getSTATUS());
barcode.setBatch(fetchPalletInfo.getBATCH_CODE());
barcode = barcodeManager.save(barcode);
}
} catch (Exception e) {
return ResultBean.newErrorResult(-1, "", e.getMessage());
}
}
//生成入库任务
List<Storage> storageList = new ArrayList<>();
List<String> cidList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
storageList.add(storage);
cidList.add(storage.getCid());
}
String modelFamily = barcode.getModelFamily();
log.info(barcode.getBarcode() + "根据机种" + modelFamily + "查询库位开始");
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
if (pos == null) {
log.info(barcode.getBarcode() + "根据机种" + modelFamily + "未找到库位信息,机种设为空,重新寻找库位");
barcode.setModelFamily("");
pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
}
if (pos == null) {
return ResultBean.newErrorResult(-1, "", boxId + "未找到可用库位");
}
log.info(barcode.getBarcode() + "查询到的库位为:"+pos.getPosName()+"库别为:"+pos.getWareHouseCode()+"机种为:"+pos.getModel());
barcode.setModelFamily(modelFamily);
//3.锁定库位
Storage storage = dataCache.getStorageById(pos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(barcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(pos.getPosName());
reelLocInfo.setLockPosId(pos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
return ResultBean.newErrorResult(-1, "", "[" + barcode.getBarcode() + "]库位[" + reelLocInfo.getLockPosName() + "]已被锁定,暂停入库", new String[]{});
}
//清理扫描的cartonId
barcode.setScanCartonId("");
barcode.setOdn("");
//4.生成入库任务
String boxLoc = TaskLocUtil.MW_IN;
taskService.addPutInTaskToExecute(storage, barcode, pos,boxLoc);
CacheUtil.clearBindInfo(barcode.getBarcode());
return ResultBean.newOkResult("");
}
}
......@@ -18,6 +18,8 @@ public class KafkaConfig {
public static final String MACHINEPARAMETER_TOPIC = "MachineParameter";
public static final String SMARTWH_TOPIC = "SmartWH";
public static final String LINE_CID = "line";
}
......@@ -3,12 +3,14 @@ package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.service;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.bean.EquipStatusBean;
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.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.util.EquipStatusUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.kafka.bean.Heartbeat;
......@@ -25,9 +27,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
//@Async
@Service
......@@ -95,6 +95,45 @@ public class KafkaService {
log.info("结束推送原材料仓tower数据");
}
@Scheduled(cron = "0 0 7,19 * * ? ")
//@Scheduled(fixedRate = 1000 * 5)
public void setPosUseInfo(){
List<String> storageIdList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
if (!storage.isVirtual()) {
storageIdList.add(storage.getId());
}
}
Query query = new Query(Criteria.where("storageId").in(storageIdList));
query.fields().include("barcode","posName");
List<Map<String,String>> dataList = new ArrayList<>();
List<StoragePos> storagePosList = storagePosManager.findByQuery(query);
for (StoragePos pos : storagePosList) {
Map<String,String> dataMap = new HashMap<>();
dataMap.put("Storage",pos.getPosName());
dataMap.put("Status",0+"");
Barcode barcode = pos.getBarcode();
if (barcode != null){
dataMap.put("Status",1+"");
}
dataList.add(dataMap);
}
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("MachineID",StorageNameConfig.semiFinishedTower);
paramMap.put("data",dataList);
String statusStr = JSON.toJSONString(paramMap);
log.info("半成品仓抛送货架使用情况:" + KafkaConfig.SMARTWH_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.SMARTWH_TOPIC, statusStr);
log.info("半成品仓抛送货架使用情况:" + JSON.toJSONString(future));
}
//@Scheduled(fixedRate = 1000 * 10)
public void sendHeartbeat() {
Heartbeat heartbeat = new Heartbeat();
......
......@@ -6,5 +6,6 @@ public class TaskLocUtil {
public static final String OUT = "semiFinished_Out";
public static final String NG = "semiFinished_ng";
public static final String MW = "semiFinished_mw"; //人工工位
public static final String MW_IN = "semiFinished_mw_in"; //人工工位
public static final String RR = "semiFinished_rr"; //还原补箱 restoreReplace
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!