Commit bb3bf610 LN

盘点功能修改,增加盘点处理操作

1 个父辈 76a758e3
......@@ -103,7 +103,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
@Autowired
protected IComponentManager componentManager;
@Autowired
private ISelfAuditManager selfAuditManager;
private SelfAuditUtil selfAuditUtil;
@Autowired
private IInOutDataManager inOutDataManager;
......@@ -183,25 +183,20 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected StatusBean handleSelfAudit(StatusBean statusBean) {
try {
String batchNo = dataCache.getCache(Constants.CACHE_SELFAUDIT_BATCHNO);
if (ObjectUtil.isNotEmpty(batchNo)) {
//盘点是否暂停
SelfAudit selfAudit = SelfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
if(selfAudit!=null){
SelfAuditUtil.updateShelfAudit(selfAudit);
}
}
//盘点是否暂停
SelfAudit selfAudit = selfAuditUtil.getCurrSelfAudit();
if (selfAudit != null) {
Storage storage = dataCache.getStorage(statusBean.getCid());
if (storage != null && selfAudit.getStorageIds().contains(storage.getId())){
if (storage != null && selfAudit.getStorageIds().contains(storage.getId())) {
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.NEW.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.EXECUTING.name())) {
statusBean.addData("selfAudit", batchNo);
statusBean.addData("selfAudit", selfAudit.getBatchNo());
}
//如果是已结束等待处理
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())) {
statusBean.addData("selfAuditException", "true");
}
}
}
} catch (Exception ex) {
......
......@@ -20,7 +20,7 @@ public enum SELFAUDIT_STATUS {
FINISHED,
/**
* 已结束,未完成手动结束
* 已结束,库位有异常,需要处理后完成
*/
END;
......
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.selfAudit.rest;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
......@@ -17,6 +18,7 @@ import com.neotel.smfcore.core.selfAudit.rest.dto.SelfAuditItemDto;
import com.neotel.smfcore.core.selfAudit.rest.mapstruct.SelfAuditItemMapper;
import com.neotel.smfcore.core.selfAudit.rest.mapstruct.SelfAuditMapper;
import com.neotel.smfcore.core.selfAudit.rest.query.SelfAuditCriteria;
import com.neotel.smfcore.core.selfAudit.service.manager.ISelfAuditItemManager;
import com.neotel.smfcore.core.selfAudit.service.manager.ISelfAuditManager;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAudit;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAuditItem;
......@@ -24,6 +26,8 @@ import com.neotel.smfcore.core.selfAudit.util.SelfAuditUtil;
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.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -53,6 +57,8 @@ public class SelfAuditController {
@Autowired
private ISelfAuditManager selfAuditManager;
@Autowired
private ISelfAuditItemManager selfAuditItemManager;
@Autowired
private SelfAuditMapper selfAuditMapper;
@Autowired
private SelfAuditItemMapper selfAuditItemMapper;
......@@ -61,6 +67,11 @@ public class SelfAuditController {
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@Autowired
private SelfAuditUtil selfAuditUtil;
@ApiOperation("开始盘点")
......@@ -72,65 +83,66 @@ public class SelfAuditController {
SelfAudit selfAudit = selfAuditManager.findByBatchNo(batchNo);
//如果当前是暂停,可以继续
if(selfAudit.getStatus().equals(SELFAUDIT_STATUS.PAUSE.name())){
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.PAUSE.name())) {
//手动继续盘点
log.info("手动继续盘点:"+batchNo);
log.info("手动继续盘点:" + batchNo);
selfAudit.setStatus(SELFAUDIT_STATUS.EXECUTING.name());
selfAuditManager.save(selfAudit);
//更新缓存
SelfAuditUtil.updateShelfAudit(selfAudit);
selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("OK");
}
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
// if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
log.info("从dataCache删除已完成的盘点批次号:" + batchNo + " ");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
} else {
throw new ValidateException( "smfcore.selfAudit.preNotEnd", "上次盘点{0}还未完成", new String[]{batchNo});
throw new ValidateException("smfcore.selfAudit.preNotEnd", "上次盘点{0}还未完成", new String[]{batchNo});
}
}
//开始新的盘点
Object object=mapValues.get("storageIds");
if(ObjectUtil.isEmpty(object)) {
throw new ValidateException( "smfcore.selfAudit.noStorage", "请选择要盘点的设备");
Object object = mapValues.get("storageIds");
if (ObjectUtil.isEmpty(object)) {
throw new ValidateException("smfcore.selfAudit.noStorage", "请选择要盘点的设备");
}
List<String> storageIds = JSON.parseArray(object.toString(),String.class);
List<String> storageIds = JSON.parseArray(object.toString(), String.class);
if (storageIds == null || storageIds.size() <= 0) {
throw new ValidateException( "smfcore.selfAudit.noStorage", "请选择要盘点的设备");
throw new ValidateException("smfcore.selfAudit.noStorage", "请选择要盘点的设备");
}
log.info("开始盘点: 设备ID["+String.join( ",",storageIds)+"] 创建盘点数据");
List<SelfAuditItem> items=new ArrayList<>();
List<String> storageIdList=new ArrayList<>();
log.info("开始盘点: 设备ID[" + String.join(",", storageIds) + "] 创建盘点数据");
List<SelfAuditItem> items = new ArrayList<>();
List<String> storageIdList = new ArrayList<>();
// List<StoragePos> allPosList=new ArrayList<>();
String no = SelfAuditUtil.createBatchNo();
for (String id :
storageIds) {
Storage storage=dataCache.getStorageById(id);
if(storage!=null){
List<StoragePos> posList=storagePosManager.findByQuery(new Query(Criteria.where("storageId").is(id)));
if(posList.size()>0){
Storage storage = dataCache.getStorageById(id);
if (storage != null) {
List<StoragePos> posList = storagePosManager.findByQuery(new Query(Criteria.where("storageId").is(id)));
if (posList.size() > 0) {
// allPosList.addAll(posList);
storageIdList.add(id);
for (StoragePos pos :posList
for (StoragePos pos : posList
) {
SelfAuditItem item = SelfAuditItem.newItem( storage.getCid(),no, pos);
SelfAuditItem item = SelfAuditItem.newItem(storage.getCid(), no, pos);
items.add(item);
}
}
}
}
SelfAudit audit = new SelfAudit(no, SELFAUDIT_STATUS.NEW.name(), items.size(),0,storageIdList,new ArrayList<>() );
SelfAudit audit = new SelfAudit(no, SELFAUDIT_STATUS.NEW.name(), items.size(), 0, storageIdList, new ArrayList<>());
log.info("盘点数据创建完成: 批次号["+no+"] 设备ID["+String.join( ",",storageIdList)+"] 盘点库位数量:["+items.size()+"] ");
audit= selfAuditManager.createSelfAudit(audit,items);
log.info("盘点数据创建完成: 批次号[" + no + "] 设备ID[" + String.join(",", storageIdList) + "] 盘点库位数量:[" + items.size() + "] ");
audit = selfAuditManager.createSelfAudit(audit, items);
SelfAuditDto dto=selfAuditMapper.toDto(audit);
SelfAuditDto dto = selfAuditMapper.toDto(audit);
//更新缓存
SelfAuditUtil.updateShelfAudit(audit);
selfAuditUtil.updateCache(audit);
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, no);
return ResultBean.newOkResult(dto);
}
......@@ -138,37 +150,54 @@ public class SelfAuditController {
@ApiOperation("暂停盘点")
@PostMapping(value = "/pause")
public ResultBean pause(@RequestBody Map<String, String> mapValues) {
String batchNo=mapValues.get("batchNo");
SelfAudit selfAudit =getInfoByBatchNo(batchNo);
String batchNo = mapValues.get("batchNo");
SelfAudit selfAudit = getInfoByBatchNo(batchNo);
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())
|| selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())
|| selfAudit.getStatus().equals(SELFAUDIT_STATUS.PAUSE.name())) {
throw new ValidateException( "smfcore.micron.operationFailure", "操作失败" );
throw new ValidateException("smfcore.micron.operationFailure", "操作失败");
}
//结束盘点
log.info("手动暂停盘点:"+batchNo);
log.info("手动暂停盘点:" + batchNo);
selfAudit.setStatus(SELFAUDIT_STATUS.PAUSE.name());
selfAuditManager.save(selfAudit);
// selfAuditManager.save(selfAudit);
//更新缓存
SelfAuditUtil.updateShelfAudit(selfAudit);
selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("OK");
}
@ApiOperation("结束盘点")
@PostMapping(value = "/finish")
public ResultBean finish(@RequestBody Map<String, String> mapValues) {
String batchNo=mapValues.get("batchNo");
SelfAudit selfAudit =getInfoByBatchNo(batchNo);
String batchNo = mapValues.get("batchNo");
SelfAudit selfAudit = getInfoByBatchNo(batchNo);
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())
|| selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
throw new ValidateException("smfcore.micron.operationFailure", "操作失败");
}
//判断是否有异常的料
boolean hasE = false;
for (SelfAuditItem item :
selfAudit.getItems()) {
if (item.getItemStatus() == 3) {
hasE = true;
}
}
String s = SELFAUDIT_STATUS.FINISHED.name();
if (hasE) {
s = SELFAUDIT_STATUS.END.name();
}
//结束盘点
log.info("手动结束盘点:"+batchNo);
selfAudit.setStatus(SELFAUDIT_STATUS.END.name());
selfAuditManager.save(selfAudit);
log.info("手动结束盘点:" + batchNo + ",更改状态为 " + s);
selfAudit.setStatus(s);
// selfAuditManager.save(selfAudit);
if (s == SELFAUDIT_STATUS.FINISHED.name()) {
//清空dataCache
log.info("手动结束盘点:"+batchNo+" 完成,从dataCache删除批次号");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO,"");
log.info("手动结束盘点:" + batchNo + " 完成,从dataCache删除批次号");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
}
//更新缓存
SelfAuditUtil.updateShelfAudit(selfAudit);
selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("OK");
}
......@@ -177,15 +206,14 @@ public class SelfAuditController {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"batchNo", batchNo});
}
SelfAudit selfAudit = SelfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
}
SelfAudit selfAudit = selfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) {
throw new ValidateException("smfcore.selfAudit.notExist", "未找到批次号[{0}]的盘点信息", new String[]{batchNo});
}
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED)) {
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED)) {
// if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED)) {
//如果已完成
throw new ValidateException("smfcore.selfAudit.hasEnd", "[{0}]盘点已完成", new String[]{batchNo});
}
......@@ -193,26 +221,20 @@ public class SelfAuditController {
}
@ApiOperation("获取实时盘点信息")
@GetMapping(value = "/info")
public SelfAuditDto info( ) {
public SelfAuditDto info() {
//获取当前的盘点信息
String batchNo = dataCache.getCache(Constants.CACHE_SELFAUDIT_BATCHNO);
if (ObjectUtil.isNotEmpty(batchNo)) {
SelfAudit selfAudit = SelfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
}
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
log.info("从dataCache删除已完成的盘点批次号:" + batchNo + " ");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
return null;
}
SelfAudit selfAudit = selfAuditUtil.getCurrSelfAudit();
if (selfAudit != null) {
// if ( selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
// log.info("从dataCache删除已完成的盘点批次号:" + selfAudit.getBatchNo() + " ");
// dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
// return null;
// }
return toSelfAuditDto(selfAudit);
}
}
//暂无盘点信息
return null;
}
......@@ -256,7 +278,7 @@ public class SelfAuditController {
@RequestMapping("/detial/download")
@AnonymousAccess
public void detialDownload(@RequestParam(required = false) String id, @RequestParam(required = false) String batchNo, HttpServletResponse response, HttpServletRequest request) throws IOException {
SelfAudit selfAudit =null;
SelfAudit selfAudit = null;
if (!ObjectUtils.isEmpty(id)) {
selfAudit = selfAuditManager.get(id);
} else if (!ObjectUtils.isEmpty(batchNo)) {
......@@ -265,11 +287,12 @@ public class SelfAuditController {
if (selfAudit != null) {
List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.Storage.rackCid",locale,"CID")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.storagePos.locationNo",locale,"库位号")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.invenBarcode",locale,"库存条码")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.actualBarcode",locale,"实际条码")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.result",locale,"结果")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.Storage.rackCid", locale, "CID")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.storagePos.locationNo", locale, "库位号")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.invenBarcode", locale, "库存条码")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.actualBarcode", locale, "实际条码")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.result", locale, "结果")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.status", locale, "状态")));
List<List<Object>> dataList = new ArrayList<>();
for (SelfAuditItem item : selfAudit.getItems()) {
......@@ -279,20 +302,75 @@ public class SelfAuditController {
data.add(item.getPosName());
data.add(item.getBarcode());
data.add(item.getActualBarcode());
String result="";
if(item.getItemStatus()==2){
if(item.getBarcode().equals(item.getActualBarcode())){
result="YES";
}else{
result="NO";
String result = "";
if (item.getItemStatus() == 2) {
if (item.getBarcode().equals(item.getActualBarcode())) {
result = "YES";
} else {
result = "NO";
}
}
data.add(result);
dataList.add(data);
}
FileUtil.downloadExcel(selfAudit.getBatchNo(), header,dataList,response);
FileUtil.downloadExcel(selfAudit.getBatchNo(), header, dataList, response);
}
}
@ApiOperation("处理盘点")
@PostMapping(value = "/process")
public ResultBean process(@RequestBody Map<String, String> mapValues) {
String batchNo = mapValues.get("batchNo");
String posName = mapValues.get("posName");
SelfAudit selfAudit = getInfoByBatchNo(batchNo);
if (!selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())) {
throw new ValidateException("smfcore.micron.operationFailure", "操作失败");
}
//自动生成出库任务
List<SelfAuditItem> newItems = new ArrayList<>();
boolean findOk = false;
for (SelfAuditItem item :
selfAudit.getItems()) {
//判断是否有异常的料
if (item.getPosName().equals(posName)) {
StoragePos pos = storagePosManager.getByPosName(item.getPosName());
Storage storage = dataCache.getStorageById(item.getStorageId());
if (storage == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"storageId", item.getStorageId()});
}
//如果料仓不可用,不能出库
if (!dataCache.StorageIsAvailable(storage)) {
throw new ValidateException("smfcore.storage.notAvailable", "料仓{0}离线或不可用,无法出库", new String[]{storage.getName()});
}
//判断是否有此库位的出库任务
List<DataLog> dataLogs = new ArrayList<>();
dataLogs.addAll(taskService.getQueueTasks());
for (DataLog log :
dataLogs) {
if (log.getPosName().equals(posName) && log.isCheckOutTask()) {
//已有出库任务,不需要重新生成
throw new ValidateException("smfcore.selfAudit.hasOutTask", "库位[{0}]已有出库任务", new String[]{item.getPosName()});
}
}
log.info("处理盘点批次【" + batchNo + "】,料仓【" + storage.getName() + "_" + storage.getCid() + "】位置仓位【" + pos.getPosName() + "】 自动生成出库任务");
String outResult = taskService.checkout(storage, pos, true, "selfAudit-clear");
if (!Strings.isNullOrEmpty(outResult)) {
throw new ValidateException("smfcore.error", outResult);
}
return ResultBean.newOkResult("ok");
}
}
return ResultBean.newOkResult("ok");
}
}
......@@ -50,23 +50,21 @@ public class SelfAuditDeviceController {
private ISelfAuditItemManager selfAuditItemManager;
@Autowired
private CodeResolve codeResolve;
@Autowired
private SelfAuditUtil selfAuditUtil;
private SelfAudit getCurrObj(){
private SelfAudit getCurrObj() {
//获取当前的盘点信息
String batchNo = dataCache.getCache(Constants.CACHE_SELFAUDIT_BATCHNO);
if (ObjectUtil.isNotEmpty(batchNo)) {
SelfAudit selfAudit = SelfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
}
//如果已结束
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
log.info("从dataCache删除已完成的盘点批次号:" + batchNo + " ");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
return null;
}
SelfAudit selfAudit = selfAuditUtil.getCurrSelfAudit();
if (selfAudit != null) {
// //如果已结束
// if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
// log.info("从dataCache删除已完成的盘点批次号:" + selfAudit.getBatchNo() + " ");
// dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
// return null;
// }
return selfAudit;
}
......@@ -158,7 +156,7 @@ public class SelfAuditDeviceController {
}
if(findOk){
selfAudit.setItems(newItems);
SelfAuditUtil.updateShelfAudit(selfAudit);
selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("ok");
}
log.error("盘点:posOutEnd:posName=["+posName+"]:未找到库位的盘点信息");
......@@ -238,7 +236,13 @@ public class SelfAuditDeviceController {
}
item.setActualBarcode(actualBarcode);
//如果异常,改为3,否则改为2
if(barcode.equals(actualBarcode)){
item.setItemStatus(2);
}else{
item.setItemStatus(3);
}
selfAuditItemManager.save(item);
}
newItems.add(item);
......@@ -247,12 +251,27 @@ public class SelfAuditDeviceController {
selfAudit.setItems(newItems);
selfAudit.setEndItemNum(selfAudit.getEndItemNum()+1);
if(selfAudit.getEndItemNum()>=selfAudit.getTotalItemNum()){
boolean hasE=false;
//判断是否有异常
for (SelfAuditItem item :
newItems) {
if(item.getItemStatus()==3){
hasE=true;
break;
}
}
if(hasE){
selfAudit.setStatus(SELFAUDIT_STATUS.END.name());
log.info(" 盘点[" + selfAudit.getBatchNo() + "] 已完成库位数[" + selfAudit.getEndItemNum() + "]总库位数[" + selfAudit.getTotalItemNum() + "],存在异常库位,更改盘点状态为完成,等待处理异常库位");
}else{
selfAudit.setStatus(SELFAUDIT_STATUS.FINISHED.name());
log.info(" 盘点[" + selfAudit.getBatchNo() + "] 已完成库位数[" + selfAudit.getEndItemNum() + "]总库位数[" + selfAudit.getTotalItemNum() + "],更改盘点状态为已完成");
log.info(" 盘点[" + selfAudit.getBatchNo() + "] 已完成库位数[" + selfAudit.getEndItemNum() + "]总库位数[" + selfAudit.getTotalItemNum() + "],更改盘点状态为已结束");
}
}
selfAuditManager.save(selfAudit);
SelfAuditUtil.updateShelfAudit(selfAudit);
// selfAuditManager.save(selfAudit);
selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("ok");
}
log.info("盘点:posSelfAuditEnd:posName=[" + posName + "],barcode=[" + barcode + "],actualBarcode=[" + actualBarcode + "]:未找到库位的盘点信息");
......
......@@ -29,6 +29,6 @@ public class SelfAuditItemDto implements Serializable {
@ApiModelProperty("实际条码")
private String actualBarcode;
@ApiModelProperty("0=等待中,1=出库完成,2=盘点完成")
@ApiModelProperty("盘点状态 0=等待中,1=出库完成,2=入库完成,3=数据异常待处理,4=异常已处理")
private int itemStatus=0;
}
......@@ -46,7 +46,7 @@ public class SelfAuditItem extends BasePo implements Serializable {
*/
private String actualBarcode;
/**
* 盘点状态 0=等待中,1=出库完成,2=盘点完成
* 盘点状态 0=等待中,1=出库完成,2=入库完成,3=数据异常待处理,4=异常已处理
*/
private int itemStatus=0;
......
package com.neotel.smfcore.core.selfAudit.util;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.selfAudit.enums.SELFAUDIT_STATUS;
import com.neotel.smfcore.core.selfAudit.service.manager.ISelfAuditItemManager;
import com.neotel.smfcore.core.selfAudit.service.manager.ISelfAuditManager;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAudit;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAuditItem;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
@Service
public class SelfAuditUtil {
@Autowired
private DataCache dataCache;
@Autowired
private ISelfAuditManager selfAuditManager;
@Autowired
private ISelfAuditItemManager selfAuditItemManager;
public static String createBatchNo() {
Date date = new Date();
String dateStr = DateUtil.toDateString(date, "yyyyMMddHHmm");
return "NO" + dateStr;
}
private static Map<String, SelfAudit> selfAuditMap=new ConcurrentHashMap<>();
private Map<String, SelfAudit> selfAuditMap=new ConcurrentHashMap<>();
public SelfAudit getSelfAudit(String batchNo) {
if (selfAuditMap == null) {
selfAuditMap = new HashMap<>();
}
SelfAudit selfAudit = selfAuditMap.get(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
if (selfAudit != null) {
updateCache(selfAudit);
}
}
return selfAudit;
}
/**
* 更新数据库,更新缓存
* @param selfAudit
*/
public void updateShelfAudit(SelfAudit selfAudit) {
selfAuditManager.save(selfAudit);
selfAuditMap.put(selfAudit.getBatchNo(), selfAudit);
}
/**
* 更新缓存
* @param selfAudit
*/
public void updateCache(SelfAudit selfAudit) {
selfAuditMap.put(selfAudit.getBatchNo(), selfAudit);
}
public SelfAudit getCurrSelfAudit() {
String batchNo = dataCache.getCache(Constants.CACHE_SELFAUDIT_BATCHNO);
if (ObjectUtil.isNotEmpty(batchNo)) {
SelfAudit selfAudit = getSelfAudit(batchNo);
if (selfAudit != null) {
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
log.info("从dataCache删除已完成的盘点批次号:" + selfAudit.getBatchNo() + " ");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
return null;
}
}
return selfAudit;
}
return null;
}
public static SelfAudit getSelfAudit(String batchNo){
if(selfAuditMap==null){
selfAuditMap=new HashMap<>();
public void onTaskStatusChange(DataLog task) {
try {
//只有出库任务才需要处理
if (task.isFinished() && task.isCheckOutTask()) {
finishedOutTask(task);
}
} catch (Exception e) {
log.error("更新判断任务状态出错", e);
}
return selfAuditMap.get(batchNo);
}
private void finishedOutTask(DataLog task) {
try {
//盘点是否暂停
SelfAudit selfAudit = getCurrSelfAudit();
if (selfAudit != null) {
//如果是已结束等待处理
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())) {
String posName = task.getPosName();
//自动生成出库任务
List<SelfAuditItem> newItems = new ArrayList<>();
boolean findOk = false;
for (SelfAuditItem item :
selfAudit.getItems()) {
if (item.getItemStatus() == 3 && item.getPosName().equals(posName)) {
//判断是否有异常的料
item.setItemStatus(4);
selfAuditItemManager.save(item);
log.info("处理盘点批次【" + selfAudit.getBatchNo() + "】, 仓位【" + posName + "】 出库任务执行完成,更改状态为4");
findOk = true;
}
newItems.add(item);
}
public static void updateShelfAudit(SelfAudit selfAudit){
selfAuditMap.put(selfAudit.getBatchNo(),selfAudit);
//判断是否完成
if (findOk) {
selfAudit.setItems(newItems);
//判断是否有异常
for (SelfAuditItem item : newItems) {
if (item.getItemStatus() == 3) {
return;
}
}
selfAudit.setStatus(SELFAUDIT_STATUS.FINISHED.name());
log.info(" 盘点[" + selfAudit.getBatchNo() + "] 已全部处理完成 更改盘点状态为已结束");
// selfAuditManager.save(selfAudit);
updateShelfAudit(selfAudit);
}
}
}
} catch (Exception ex) {
log.error("handleSelfAudit error:" + ex.getMessage());
}
}
}
......@@ -19,6 +19,7 @@ import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.selfAudit.util.SelfAuditUtil;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.rest.dto.TacticsOutDto;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
......@@ -51,6 +52,8 @@ public class TaskService {
@Autowired
protected LiteOrderCache liteOrderCache;
@Autowired
protected SelfAuditUtil selfAuditUtil;
@Autowired
private SmfApi smfApi;
......@@ -152,6 +155,7 @@ public class TaskService {
private void tiggerTaskChangeListener(DataLog task) {
liteOrderCache.onTaskStatusChange(task);
smfApi.onTaskStatusChange(task);
selfAuditUtil.onTaskStatusChange(task);
}
/**
......
......@@ -342,6 +342,7 @@ smfcore.selfAudit.pause=\u76D8\u70B9{0}\u5DF2\u6682\u505C
smfcore.shelf.error.orderError=\u4EFB\u52A1\u4E0E\u6307\u5B9A\u5DE5\u5355[{0}]\u4E0D\u4E00\u81F4
smfcore.shelf.error.storageError=\u4EFB\u52A1\u4E0E\u6307\u5B9A\u6599\u67B6[{0}]\u4E0D\u4E00\u81F4
smfcore.selfAudit.noPos=\u76D8\u70B9{0}\u672A\u627E\u5230\u5E93\u4F4D\u53F7
smfcore.selfAudit.hasOutTask=\u5E93\u4F4D[{0}]\u5DF2\u6709\u51FA\u5E93\u4EFB\u52A1
#smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0}
#smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1}
#smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F
......
......@@ -341,3 +341,4 @@ smfcore.selfAudit.pause=self audit {0} has Paused
smfcore.shelf.error.orderError=Task does not match the assigned work order [{0}]
smfcore.shelf.error.storageError=Task does not match the specified shelf [{0}]
smfcore.selfAudit.noPos=Self Audit{0}No depot number found
smfcore.selfAudit.hasOutTask=The location [{0}] already has a release task
\ No newline at end of file
......@@ -338,3 +338,4 @@ smfcore.selfAudit.pause=\u30BB\u30EB\u30D5\u30C6\u30B9\u30C8{0}\u304C\u4E2D\u65A
smfcore.shelf.error.orderError=\u4EFB\u52A1\u4E0E\u6307\u5B9A\u5DE5\u5355[{0}]\u4E0D\u4E00\u81F4
smfcore.shelf.error.storageError=\u4EFB\u52A1\u4E0E\u6307\u5B9A\u6599\u67B6[{0}]\u4E0D\u4E00\u81F4
smfcore.selfAudit.noPos=\u76D8\u70B9{0}\u672A\u627E\u5230\u5E93\u4F4D\u53F7
smfcore.selfAudit.hasOutTask=\u5E93\u4F4D[{0}]\u5DF2\u6709\u51FA\u5E93\u4EFB\u52A1
\ No newline at end of file
......@@ -338,3 +338,4 @@ smfcore.selfAudit.pause=\u76D8\u70B9{0}\u5DF2\u6682\u505C
smfcore.shelf.error.orderError=\u4EFB\u52A1\u4E0E\u6307\u5B9A\u5DE5\u5355[{0}]\u4E0D\u4E00\u81F4
smfcore.shelf.error.storageError=\u4EFB\u52A1\u4E0E\u6307\u5B9A\u6599\u67B6[{0}]\u4E0D\u4E00\u81F4
smfcore.selfAudit.noPos=\u76D8\u70B9{0}\u672A\u627E\u5230\u5E93\u4F4D\u53F7
smfcore.selfAudit.hasOutTask=\u5E93\u4F4D[{0}]\u5DF2\u6709\u51FA\u5E93\u4EFB\u52A1
\ No newline at end of file
......@@ -339,3 +339,4 @@ smfcore.selfAudit.pause=\u76E4\u9EDE{0}\u5DF2\u66AB\u505C
smfcore.shelf.error.orderError=\u4EFB\u52D9\u8207\u6307\u5B9A\u5DE5\u55AE[{0}]\u4E0D\u4E00\u81F4
smfcore.shelf.error.storageError=\u4EFB\u52D9\u8207\u6307\u5B9A\u6599\u67B6[{0}]\u4E0D\u4E00\u81F4
smfcore.selfAudit.noPos=\u76E4\u9EDE{0}\u672A\u627E\u5230\u5EAB\u4F4D\u865F
smfcore.selfAudit.hasOutTask=\u5EAB\u4F4D[{0}]\u5DF2\u6709\u51FA\u5EAB\u4EFB\u52D9
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!