Commit 1674644d LN

10031自检功能合入

1 个父辈 6f517b6c
...@@ -564,12 +564,15 @@ public class StatusBean { ...@@ -564,12 +564,15 @@ public class StatusBean {
} else { } else {
locale = new Locale(language); locale = new Locale(language);
} }
String lanMsg=MessageUtils.getText(msgKey, msgParam, locale, message); String lanMsg=MessageUtils.getText(msgKey, msgParam, locale, message);
setMsg(lanMsg); if(ObjectUtil.isNotEmpty(lanMsg)){
setMsg(lanMsg);
}
}else{ }else{
String lanMsg=MessageUtils.getText(msgKey, msgParam, MessageUtils.getDefaultLocal(), message); String lanMsg=MessageUtils.getText(msgKey, msgParam, MessageUtils.getDefaultLocal(), message);
setMsg(lanMsg); if(ObjectUtil.isNotEmpty(lanMsg)){
setMsg(lanMsg);
}
} }
} }
} }
...@@ -101,7 +101,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -101,7 +101,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
@Autowired @Autowired
protected IComponentManager componentManager; protected IComponentManager componentManager;
@Autowired @Autowired
private ISelfAuditManager selfAuditManager; private SelfAuditUtil selfAuditUtil;
/** /**
* CID的服务器消息(key 为 cid) * CID的服务器消息(key 为 cid)
...@@ -178,25 +178,20 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -178,25 +178,20 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected StatusBean handleSelfAudit(StatusBean statusBean) { protected StatusBean handleSelfAudit(StatusBean statusBean) {
try { 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);
}
}
if (selfAudit != null) {
Storage storage = dataCache.getStorage(statusBean.getCid());
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);
}
//盘点是否暂停
SelfAudit selfAudit = selfAuditUtil.getCurrSelfAudit();
if (selfAudit != null) {
Storage storage = dataCache.getStorage(statusBean.getCid());
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", selfAudit.getBatchNo());
}
//如果是已结束等待处理
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())) {
statusBean.addData("selfAuditException", "true");
} }
} }
} }
} catch (Exception ex) { } catch (Exception ex) {
......
...@@ -37,6 +37,7 @@ public class VerticalBoxHandler extends BaseDeviceHandler { ...@@ -37,6 +37,7 @@ public class VerticalBoxHandler extends BaseDeviceHandler {
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) { public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
statusBean.setClientIp(request.getRemoteHost()); statusBean.setClientIp(request.getRemoteHost());
handleMsg(statusBean); handleMsg(statusBean);
statusBean=handleSelfAudit(statusBean);
// statusBean = saveStatus(statusBean); // statusBean = saveStatus(statusBean);
String cid = statusBean.getCid(); String cid = statusBean.getCid();
Collection<DataLog> queueTasks = taskService.getQueueTasks(cid); Collection<DataLog> queueTasks = taskService.getQueueTasks(cid);
......
...@@ -20,7 +20,7 @@ public enum SELFAUDIT_STATUS { ...@@ -20,7 +20,7 @@ public enum SELFAUDIT_STATUS {
FINISHED, FINISHED,
/** /**
* 已结束,未完成手动结束 * 已结束,库位有异常,需要处理后完成
*/ */
END; END;
......
...@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.selfAudit.rest; ...@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.selfAudit.rest;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.PageData; import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
...@@ -17,6 +18,7 @@ import com.neotel.smfcore.core.selfAudit.rest.dto.SelfAuditItemDto; ...@@ -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.SelfAuditItemMapper;
import com.neotel.smfcore.core.selfAudit.rest.mapstruct.SelfAuditMapper; import com.neotel.smfcore.core.selfAudit.rest.mapstruct.SelfAuditMapper;
import com.neotel.smfcore.core.selfAudit.rest.query.SelfAuditCriteria; 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.manager.ISelfAuditManager;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAudit; import com.neotel.smfcore.core.selfAudit.service.po.SelfAudit;
import com.neotel.smfcore.core.selfAudit.service.po.SelfAuditItem; import com.neotel.smfcore.core.selfAudit.service.po.SelfAuditItem;
...@@ -24,6 +26,8 @@ import com.neotel.smfcore.core.selfAudit.util.SelfAuditUtil; ...@@ -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.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.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
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;
...@@ -39,10 +43,8 @@ import org.springframework.web.bind.annotation.*; ...@@ -39,10 +43,8 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Locale;
import java.util.Map;
@Slf4j @Slf4j
@Api(tags = "盘点") @Api(tags = "盘点")
...@@ -53,6 +55,8 @@ public class SelfAuditController { ...@@ -53,6 +55,8 @@ public class SelfAuditController {
@Autowired @Autowired
private ISelfAuditManager selfAuditManager; private ISelfAuditManager selfAuditManager;
@Autowired @Autowired
private ISelfAuditItemManager selfAuditItemManager;
@Autowired
private SelfAuditMapper selfAuditMapper; private SelfAuditMapper selfAuditMapper;
@Autowired @Autowired
private SelfAuditItemMapper selfAuditItemMapper; private SelfAuditItemMapper selfAuditItemMapper;
...@@ -61,6 +65,11 @@ public class SelfAuditController { ...@@ -61,6 +65,11 @@ public class SelfAuditController {
@Autowired @Autowired
private DataCache dataCache; private DataCache dataCache;
@Autowired
private TaskService taskService;
@Autowired
private SelfAuditUtil selfAuditUtil;
@ApiOperation("开始盘点") @ApiOperation("开始盘点")
...@@ -72,65 +81,66 @@ public class SelfAuditController { ...@@ -72,65 +81,66 @@ public class SelfAuditController {
SelfAudit selfAudit = selfAuditManager.findByBatchNo(batchNo); 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()); selfAudit.setStatus(SELFAUDIT_STATUS.EXECUTING.name());
selfAuditManager.save(selfAudit);
//更新缓存 //更新缓存
SelfAuditUtil.updateShelfAudit(selfAudit); selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("OK"); 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 + " "); log.info("从dataCache删除已完成的盘点批次号:" + batchNo + " ");
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, ""); dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
} else { } 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"); Object object = mapValues.get("storageIds");
if(ObjectUtil.isEmpty(object)) { if (ObjectUtil.isEmpty(object)) {
throw new ValidateException( "smfcore.selfAudit.noStorage", "请选择要盘点的设备"); 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) { if (storageIds == null || storageIds.size() <= 0) {
throw new ValidateException( "smfcore.selfAudit.noStorage", "请选择要盘点的设备"); throw new ValidateException("smfcore.selfAudit.noStorage", "请选择要盘点的设备");
} }
log.info("开始盘点: 设备ID["+String.join( ",",storageIds)+"] 创建盘点数据"); log.info("开始盘点: 设备ID[" + String.join(",", storageIds) + "] 创建盘点数据");
List<SelfAuditItem> items=new ArrayList<>(); List<SelfAuditItem> items = new ArrayList<>();
List<String> storageIdList=new ArrayList<>(); List<String> storageIdList = new ArrayList<>();
// List<StoragePos> allPosList=new ArrayList<>(); // List<StoragePos> allPosList=new ArrayList<>();
String no = SelfAuditUtil.createBatchNo(); String no = SelfAuditUtil.createBatchNo();
for (String id : for (String id :
storageIds) { storageIds) {
Storage storage=dataCache.getStorageById(id); Storage storage = dataCache.getStorageById(id);
if(storage!=null){ if (storage != null) {
List<StoragePos> posList=storagePosManager.findByQuery(new Query(Criteria.where("storageId").is(id))); List<StoragePos> posList = storagePosManager.findByQuery(new Query(Criteria.where("storageId").is(id)));
if(posList.size()>0){ if (posList.size() > 0) {
// allPosList.addAll(posList); // allPosList.addAll(posList);
storageIdList.add(id); 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); 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()+"] "); log.info("盘点数据创建完成: 批次号[" + no + "] 设备ID[" + String.join(",", storageIdList) + "] 盘点库位数量:[" + items.size() + "] ");
audit= selfAuditManager.createSelfAudit(audit,items); 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); dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, no);
return ResultBean.newOkResult(dto); return ResultBean.newOkResult(dto);
} }
...@@ -138,37 +148,54 @@ public class SelfAuditController { ...@@ -138,37 +148,54 @@ public class SelfAuditController {
@ApiOperation("暂停盘点") @ApiOperation("暂停盘点")
@PostMapping(value = "/pause") @PostMapping(value = "/pause")
public ResultBean pause(@RequestBody Map<String, String> mapValues) { public ResultBean pause(@RequestBody Map<String, String> mapValues) {
String batchNo=mapValues.get("batchNo"); String batchNo = mapValues.get("batchNo");
SelfAudit selfAudit =getInfoByBatchNo(batchNo); SelfAudit selfAudit = getInfoByBatchNo(batchNo);
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name())
|| selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())
|| selfAudit.getStatus().equals(SELFAUDIT_STATUS.PAUSE.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()); selfAudit.setStatus(SELFAUDIT_STATUS.PAUSE.name());
selfAuditManager.save(selfAudit); // selfAuditManager.save(selfAudit);
//更新缓存 //更新缓存
SelfAuditUtil.updateShelfAudit(selfAudit); selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("OK"); return ResultBean.newOkResult("OK");
} }
@ApiOperation("结束盘点") @ApiOperation("结束盘点")
@PostMapping(value = "/finish") @PostMapping(value = "/finish")
public ResultBean finish(@RequestBody Map<String, String> mapValues) { public ResultBean finish(@RequestBody Map<String, String> mapValues) {
String batchNo=mapValues.get("batchNo"); String batchNo = mapValues.get("batchNo");
SelfAudit selfAudit =getInfoByBatchNo(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); log.info("手动结束盘点:" + batchNo + ",更改状态为 " + s);
selfAudit.setStatus(SELFAUDIT_STATUS.END.name()); selfAudit.setStatus(s);
selfAuditManager.save(selfAudit); // selfAuditManager.save(selfAudit);
//清空dataCache if (s == SELFAUDIT_STATUS.FINISHED.name()) {
log.info("手动结束盘点:"+batchNo+" 完成,从dataCache删除批次号"); //清空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"); return ResultBean.newOkResult("OK");
} }
...@@ -177,15 +204,14 @@ public class SelfAuditController { ...@@ -177,15 +204,14 @@ public class SelfAuditController {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"batchNo", batchNo}); throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"batchNo", batchNo});
} }
SelfAudit selfAudit = SelfAuditUtil.getSelfAudit(batchNo); SelfAudit selfAudit = selfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
}
if (selfAudit == null) { if (selfAudit == null) {
throw new ValidateException("smfcore.selfAudit.notExist", "未找到批次号[{0}]的盘点信息", new String[]{batchNo}); 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}); throw new ValidateException("smfcore.selfAudit.hasEnd", "[{0}]盘点已完成", new String[]{batchNo});
} }
...@@ -193,25 +219,19 @@ public class SelfAuditController { ...@@ -193,25 +219,19 @@ public class SelfAuditController {
} }
@ApiOperation("获取实时盘点信息") @ApiOperation("获取实时盘点信息")
@GetMapping(value = "/info") @GetMapping(value = "/info")
public SelfAuditDto info( ) { public SelfAuditDto info() {
//获取当前的盘点信息 //获取当前的盘点信息
String batchNo = dataCache.getCache(Constants.CACHE_SELFAUDIT_BATCHNO); SelfAudit selfAudit = selfAuditUtil.getCurrSelfAudit();
if (ObjectUtil.isNotEmpty(batchNo)) { if (selfAudit != null) {
SelfAudit selfAudit = SelfAuditUtil.getSelfAudit(batchNo);
if (selfAudit == null) { // if ( selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
selfAudit = selfAuditManager.findByBatchNo(batchNo); // log.info("从dataCache删除已完成的盘点批次号:" + selfAudit.getBatchNo() + " ");
} // dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) { // return null;
log.info("从dataCache删除已完成的盘点批次号:" + batchNo + " "); // }
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, ""); return toSelfAuditDto(selfAudit);
return null;
}
if (selfAudit != null) {
return toSelfAuditDto(selfAudit);
}
} }
//暂无盘点信息 //暂无盘点信息
return null; return null;
...@@ -248,7 +268,24 @@ public class SelfAuditController { ...@@ -248,7 +268,24 @@ public class SelfAuditController {
SelfAuditDto dto = selfAuditMapper.toDto(selfAudit); SelfAuditDto dto = selfAuditMapper.toDto(selfAudit);
List<SelfAuditItem> selfAuditItemDtos = selfAudit.getItems(); List<SelfAuditItem> selfAuditItemDtos = selfAudit.getItems();
List<SelfAuditItemDto> dtos = selfAuditItemMapper.toDto(selfAuditItemDtos); List<SelfAuditItemDto> dtos = selfAuditItemMapper.toDto(selfAuditItemDtos);
dto.setItems(dtos);
//待处理的放在最前面
List sortedList = dtos.stream().sorted(
Comparator.comparingInt(item -> {
int status = item.getItemStatus();
if (status == 3) {
return 0;
} else if (status == 4) {
return 1;
} else if (status == 2) {
return 2;
} else if (status == 1) {
return 3;
} else {
return 4;
}
})).collect(Collectors.toList());
dto.setItems(sortedList);
return dto; return dto;
} }
...@@ -256,20 +293,21 @@ public class SelfAuditController { ...@@ -256,20 +293,21 @@ public class SelfAuditController {
@RequestMapping("/detial/download") @RequestMapping("/detial/download")
@AnonymousAccess @AnonymousAccess
public void detialDownload(@RequestParam(required = false) String id, @RequestParam(required = false) String batchNo, HttpServletResponse response, HttpServletRequest request) throws IOException { 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)) { if (!ObjectUtils.isEmpty(id)) {
selfAudit = selfAuditManager.get(id); selfAudit = selfAuditManager.get(id);
} else if (!ObjectUtils.isEmpty(batchNo)) { } else if (!ObjectUtils.isEmpty(batchNo)) {
selfAudit = selfAuditManager.findByBatchNo(batchNo); selfAudit = selfAuditManager.findByBatchNo(batchNo);
} }
if (selfAudit != null) { if (selfAudit != null) {
List<List<String>> header = new ArrayList<>(); List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale(); Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.Storage.rackCid",locale,"CID"))); 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.storagePos.locationNo", locale, "库位号")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.invenBarcode",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.actualBarcode", locale, "实际条码")));
header.add(Lists.newArrayList(MessageUtils.getSmfClientMsg("smfclient.selfAudit.result",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<>(); List<List<Object>> dataList = new ArrayList<>();
for (SelfAuditItem item : selfAudit.getItems()) { for (SelfAuditItem item : selfAudit.getItems()) {
...@@ -279,20 +317,75 @@ public class SelfAuditController { ...@@ -279,20 +317,75 @@ public class SelfAuditController {
data.add(item.getPosName()); data.add(item.getPosName());
data.add(item.getBarcode()); data.add(item.getBarcode());
data.add(item.getActualBarcode()); data.add(item.getActualBarcode());
String result=""; String result = "";
if(item.getItemStatus()==2){ if (item.getItemStatus() == 2) {
if(item.getBarcode().equals(item.getActualBarcode())){ if (item.getBarcode().equals(item.getActualBarcode())) {
result="YES"; result = "YES";
}else{ } else {
result="NO"; result = "NO";
} }
} }
data.add(result); data.add(result);
dataList.add(data); 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.checkoutTest(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 { ...@@ -50,23 +50,21 @@ public class SelfAuditDeviceController {
private ISelfAuditItemManager selfAuditItemManager; private ISelfAuditItemManager selfAuditItemManager;
@Autowired @Autowired
private CodeResolve codeResolve; 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);
}
//如果已结束 SelfAudit selfAudit = selfAuditUtil.getCurrSelfAudit();
if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.END.name()) || selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) { if (selfAudit != null) {
log.info("从dataCache删除已完成的盘点批次号:" + batchNo + " "); // //如果已结束
dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, ""); // if (selfAudit.getStatus().equals(SELFAUDIT_STATUS.FINISHED.name())) {
return null; // log.info("从dataCache删除已完成的盘点批次号:" + selfAudit.getBatchNo() + " ");
} // dataCache.updateCache(Constants.CACHE_SELFAUDIT_BATCHNO, "");
// return null;
// }
return selfAudit; return selfAudit;
} }
...@@ -98,14 +96,14 @@ public class SelfAuditDeviceController { ...@@ -98,14 +96,14 @@ public class SelfAuditDeviceController {
resultMap.put("posName",item.getPosName()); resultMap.put("posName",item.getPosName());
resultMap.put("barcode",item.getBarcode()); resultMap.put("barcode",item.getBarcode());
resultMap.put("batchNo",item.getBatchNo()); resultMap.put("batchNo",item.getBatchNo());
resultMap.put("plateW",item.getPlateW()+"");
log.info("cid=["+cid+"]获取盘点["+selfAudit.getBatchNo()+"]下一个库位成功:posName["+item.getPosName()+"]barcode["+item.getBarcode()+"]"); resultMap.put("plateH", item.getPlateH()+"");
log.info("cid=["+cid+"]获取盘点["+selfAudit.getBatchNo()+"]下一个库位成功:posName["+item.getPosName()+"]barcode["+item.getBarcode()+"],["+item.getPlateW()+"X"+item.getPlateH()+"]");
return ResultBean.newOkResult(resultMap); return ResultBean.newOkResult(resultMap);
} }
} }
//根据CID获取盘点的下一个库位 //根据CID获取盘点的下一个库位
return ResultBean.newErrorResult(101, "smfcore.selfAudit.noPos", "盘点{0}未找到库位号", new String[]{selfAudit.getBatchNo()}); return ResultBean.newErrorResult(101, "smfcore.selfAudit.noPos", "盘点{0}未找到库位号", new String[]{selfAudit.getBatchNo()});
} }
@ApiOperation("盘点: 库位已出库完成 ") @ApiOperation("盘点: 库位已出库完成 ")
@PostMapping(value = "/posOutEnd") @PostMapping(value = "/posOutEnd")
...@@ -128,6 +126,7 @@ public class SelfAuditDeviceController { ...@@ -128,6 +126,7 @@ public class SelfAuditDeviceController {
for (SelfAuditItem item : for (SelfAuditItem item :
items) { items) {
if (item.getPosName().equals(posName)) { if (item.getPosName().equals(posName)) {
findOk=true;
log.info(" 盘点["+selfAudit.getBatchNo()+"]库位出库成功:posName["+item.getPosName()+"]barcode["+item.getBarcode()+"],自动生成出库任务,清空库位"); log.info(" 盘点["+selfAudit.getBatchNo()+"]库位出库成功:posName["+item.getPosName()+"]barcode["+item.getBarcode()+"],自动生成出库任务,清空库位");
StoragePos storagePos = storagePosManager.getByPosName(posName); StoragePos storagePos = storagePosManager.getByPosName(posName);
...@@ -142,7 +141,7 @@ public class SelfAuditDeviceController { ...@@ -142,7 +141,7 @@ public class SelfAuditDeviceController {
log.info(opUser + "盘点完成,清理库位[" + storagePos.getPosName() + "]中的库存" + barcode.getBarcode()); log.info(opUser + "盘点完成,清理库位[" + storagePos.getPosName() + "]中的库存" + barcode.getBarcode());
taskService.addTaskToFinished(storagePos, null, opUser + "-clear"); taskService.addTaskToFinished(storagePos, null, opUser + "-clear");
Storage storage = dataCache.getStorageById(storagePos.getStorageId()); Storage storage = dataCache.getStorageById(storagePos.getStorageId());
dataCache.reloadStorage(storage, storage.getCid()); dataCache.reloadStorage(storage, "");
} }
//更新状态 //更新状态
...@@ -159,7 +158,11 @@ public class SelfAuditDeviceController { ...@@ -159,7 +158,11 @@ public class SelfAuditDeviceController {
} }
if(findOk){ if(findOk){
selfAudit.setItems(newItems); selfAudit.setItems(newItems);
SelfAuditUtil.updateShelfAudit(selfAudit); //更改自检状态
if(selfAudit.getStatus().equals(SELFAUDIT_STATUS.NEW.name())){
selfAudit.setStatus(SELFAUDIT_STATUS.EXECUTING.name());
}
selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("ok"); return ResultBean.newOkResult("ok");
} }
log.error("盘点:posOutEnd:posName=["+posName+"]:未找到库位的盘点信息"); log.error("盘点:posOutEnd:posName=["+posName+"]:未找到库位的盘点信息");
...@@ -190,29 +193,78 @@ public class SelfAuditDeviceController { ...@@ -190,29 +193,78 @@ public class SelfAuditDeviceController {
items) { items) {
if (item.getPosName().equals(posName)) { if (item.getPosName().equals(posName)) {
findOk=true; findOk=true;
log.info(" 盘点[" + selfAudit.getBatchNo() + "]库位入库完成:posName[" + item.getPosName() + "]barcode[" + item.getBarcode() + "],actualBarcode=[" + actualBarcode + "]");
if(!barcode.equals(item.getBarcode())){
barcode=item.getBarcode();
log.info("盘点:posSelfAuditEnd:posName=[" + posName + "],纠正 barcode=[" + item.getBarcode() + "]");
}
item.setActualBarcode(actualBarcode);
//如果异常,改为3,否则改为2
if(item.getBarcode().equals(actualBarcode)){
item.setItemStatus(2);
}else{
item.setItemStatus(3);
}
selfAuditItemManager.save(item);
log.info(" 盘点[" + selfAudit.getBatchNo() + "]库位入库完成:posName[" + item.getPosName() + "]barcode[" + item.getBarcode() + "],actualBarcode=[" + actualBarcode + "],设置状态="+item.getItemStatus());
StoragePos storagePos = storagePosManager.getByPosName(posName); StoragePos storagePos = storagePosManager.getByPosName(posName);
if (storagePos != null) { if (storagePos != null) {
try { try {
if(ObjectUtil.isNotEmpty(barcode)&&barcode.equals(actualBarcode)){ if(ObjectUtil.isNotEmpty(barcode) ){
Barcode barcode1=codeResolve.resolveOneValideBarcode(barcode); if(barcode.equals(actualBarcode)) {
if(barcode1!=null){ //物料一致
log.info("盘点入库完成,条码一致,自动生成入库任务,更新库位[" + storagePos.getPosName() + "]"); Barcode barcodeIn = resolveOneValideBarcode("barcode",barcode);
taskService.addTaskToFinished(storagePos,barcode1,"selfAudit"); if (barcodeIn != null) {
log.info("盘点入库完成,条码一致,自动生成入库任务,更新库位[" + storagePos.getPosName() + "]=[" + barcodeIn.getBarcode() + "]");
taskService.addTaskToFinished(storagePos, barcodeIn, "selfAudit");
}
}else if(ObjectUtil.isNotEmpty(actualBarcode)){
//物料不一致 优先实际条码入库
Barcode barcodeIn=resolveOneValideBarcode("actualBarcode",actualBarcode);
if(barcodeIn!=null){
log.info("盘点入库完成,物料不一致,自动生成实际条码入库任务,更新库位[" + storagePos.getPosName() + "]=["+barcodeIn.getBarcode()+"]");
taskService.addTaskToFinished(storagePos,barcodeIn,"selfAudit");
}else{
barcodeIn = resolveOneValideBarcode("barcode",barcode);
if(barcodeIn!=null){
log.info("盘点入库完成,条码一致,实际条码解析失败,自动生成原条码入库任务,更新库位[" + storagePos.getPosName() + "]=["+barcodeIn.getBarcode()+"]");
taskService.addTaskToFinished(storagePos,barcodeIn,"selfAudit");
}
}
}else{
//库存有料,实际没料 原条码 入库
Barcode barcodeIn = resolveOneValideBarcode("barcode",barcode);
if (barcodeIn != null) {
log.info("盘点入库完成,库存有料,实际没料 ,原条码信息先入库,更新库位[" + storagePos.getPosName() + "]=[" + barcodeIn.getBarcode() + "]");
taskService.addTaskToFinished(storagePos, barcodeIn, "selfAudit");
}
}
} else if(ObjectUtil.isNotEmpty(actualBarcode)){
//库存没料,实际有料
//物料不一致 优先实际条码入库
Barcode barcodeIn=resolveOneValideBarcode("actualBarcode",actualBarcode);
if(barcodeIn!=null){
log.info("盘点入库完成,库存没料,实际有料,自动生成实际条码入库任务,更新库位[" + storagePos.getPosName() + "]=["+barcodeIn.getBarcode()+"]");
taskService.addTaskToFinished(storagePos,barcodeIn,"selfAudit");
}else{
log.error("盘点入库完成,库存没料,实际有料,实际条码解析失败,生成入库任务失败,库位[" + storagePos.getPosName() + "]库存仍为空");
} }
} }
//TODO //TODO 如果原来有料,默认增加一条入库任务
} catch (Exception e) { } catch (Exception e) {
throw new ValidateException("smfcore.error", "出错{0}", new String[]{e.toString()}); //只打印提示信息,还需要继续执行
log.error("盘点[" + selfAudit.getBatchNo() + "]库位入库完成:posName[" + item.getPosName() + "]处理出错:"+e.toString());
// throw new ValidateException("smfcore.error", "出错{0}", new String[]{e.toString()});
} }
} }
item.setActualBarcode(actualBarcode);
item.setItemStatus(2);
selfAuditItemManager.save(item);
} }
newItems.add(item); newItems.add(item);
} }
...@@ -220,15 +272,42 @@ public class SelfAuditDeviceController { ...@@ -220,15 +272,42 @@ public class SelfAuditDeviceController {
selfAudit.setItems(newItems); selfAudit.setItems(newItems);
selfAudit.setEndItemNum(selfAudit.getEndItemNum()+1); selfAudit.setEndItemNum(selfAudit.getEndItemNum()+1);
if(selfAudit.getEndItemNum()>=selfAudit.getTotalItemNum()){ if(selfAudit.getEndItemNum()>=selfAudit.getTotalItemNum()){
selfAudit.setStatus(SELFAUDIT_STATUS.FINISHED.name());
log.info(" 盘点[" + selfAudit.getBatchNo() + "] 已完成库位数[" + 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() + "],更改盘点状态为已结束");
}
} }
selfAuditManager.save(selfAudit); // selfAuditManager.save(selfAudit);
SelfAuditUtil.updateShelfAudit(selfAudit); selfAuditUtil.updateShelfAudit(selfAudit);
return ResultBean.newOkResult("ok"); return ResultBean.newOkResult("ok");
} }
log.info("盘点:posSelfAuditEnd:posName=[" + posName + "],barcode=[" + barcode + "],actualBarcode=[" + actualBarcode + "]:未找到库位的盘点信息"); log.info("盘点:posSelfAuditEnd:posName=[" + posName + "],barcode=[" + barcode + "],actualBarcode=[" + actualBarcode + "]:未找到库位的盘点信息");
return ResultBean.newErrorResult(99, "smfcore.selfAudit.posNotFind", "未找到库位[{0}]的盘点信息"); return ResultBean.newErrorResult(99, "smfcore.selfAudit.posNotFind", "未找到库位[{0}]的盘点信息");
} }
private Barcode resolveOneValideBarcode(String paramName,String code){
//物料不一致 优先实际条码入库
Barcode barcodeIn=null;
try{
barcodeIn=codeResolve.resolveOneValideBarcode(code);
} catch (Exception e) {
//只打印提示信息,还需要继续执行
log.error(paramName+"[" + code + "]解析出错:" + e.toString());
}
return barcodeIn;
}
} }
...@@ -29,6 +29,12 @@ public class SelfAuditItemDto implements Serializable { ...@@ -29,6 +29,12 @@ public class SelfAuditItemDto implements Serializable {
@ApiModelProperty("实际条码") @ApiModelProperty("实际条码")
private String actualBarcode; private String actualBarcode;
@ApiModelProperty("0=等待中,1=出库完成,2=盘点完成") @ApiModelProperty("盘点状态 0=等待中,1=出库完成,2=入库完成,3=数据异常待处理,4=异常已处理")
private int itemStatus=0; private int itemStatus=0;
@ApiModelProperty("盘宽")
private int plateW = 0;
@ApiModelProperty("盘高")
private int plateH = 0;
} }
...@@ -41,12 +41,23 @@ public class SelfAuditItem extends BasePo implements Serializable { ...@@ -41,12 +41,23 @@ public class SelfAuditItem extends BasePo implements Serializable {
*库存条码 *库存条码
*/ */
private String barcode; private String barcode;
/**
* 盘宽
*/
private int plateW = 0;
/**
* 盘高
*/
private int plateH = 0;
/** /**
*实际条码 *实际条码
*/ */
private String actualBarcode; private String actualBarcode;
/** /**
* 盘点状态 0=等待中,1=出库完成,2=盘点完成 * 盘点状态 0=等待中,1=出库完成,2=入库完成,3=数据异常待处理,4=异常已处理
*/ */
private int itemStatus=0; private int itemStatus=0;
...@@ -57,8 +68,12 @@ public class SelfAuditItem extends BasePo implements Serializable { ...@@ -57,8 +68,12 @@ public class SelfAuditItem extends BasePo implements Serializable {
item.setPosId(pos.getId()); item.setPosId(pos.getId());
item.setPosName(pos.getPosName()); item.setPosName(pos.getPosName());
item.setStorageId(pos.getStorageId()); item.setStorageId(pos.getStorageId());
item.setPlateH(0);
item.setPlateW(0);
if(pos.getBarcode()!=null&& pos.getBarcode().getBarcode()!=null) { if(pos.getBarcode()!=null&& pos.getBarcode().getBarcode()!=null) {
item.setBarcode(pos.getBarcode().getBarcode()); item.setBarcode(pos.getBarcode().getBarcode());
item.setPlateH(pos.getBarcode().getHeight());
item.setPlateW(pos.getBarcode().getPlateSize());
}else{ }else{
item.setBarcode(""); item.setBarcode("");
} }
......
package com.neotel.smfcore.core.selfAudit.util; 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.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.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.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Slf4j
@Service
public class SelfAuditUtil { public class SelfAuditUtil {
@Autowired
private DataCache dataCache;
@Autowired
private ISelfAuditManager selfAuditManager;
@Autowired
private ISelfAuditItemManager selfAuditItemManager;
public static String createBatchNo() { public static String createBatchNo() {
Date date = new Date(); Date date = new Date();
String dateStr = DateUtil.toDateString(date, "yyyyMMddHHmm"); String dateStr = DateUtil.toDateString(date, "yyyyMMddHHmm");
return "NO" + dateStr; return "NO" + dateStr;
} }
private static Map<String, SelfAudit> selfAuditMap=new ConcurrentHashMap<>(); private Map<String, SelfAudit> selfAuditMap=new ConcurrentHashMap<>();
public static SelfAudit getSelfAudit(String batchNo){ public SelfAudit getSelfAudit(String batchNo) {
if(selfAuditMap==null){ if (selfAuditMap == null) {
selfAuditMap=new HashMap<>(); selfAuditMap = new HashMap<>();
}
SelfAudit selfAudit = selfAuditMap.get(batchNo);
if (selfAudit == null) {
selfAudit = selfAuditManager.findByBatchNo(batchNo);
if (selfAudit != null) {
updateCache(selfAudit);
}
} }
return selfAuditMap.get(batchNo); 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;
public static void updateShelfAudit(SelfAudit selfAudit){ }
selfAuditMap.put(selfAudit.getBatchNo(),selfAudit); return null;
} }
public void onTaskStatusChange(DataLog task) {
try {
//只有出库任务才需要处理
if (task.isFinished() && task.isCheckOutTask()) {
finishedOutTask(task);
}
} catch (Exception e) {
log.error("更新判断任务状态出错", e);
}
}
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);
}
//判断是否完成
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());
}
}
} }
...@@ -357,6 +357,7 @@ smfcore.micron.apiClose=Not yet open ...@@ -357,6 +357,7 @@ smfcore.micron.apiClose=Not yet open
smfcore.api.error=api.error: error={0},message={1},detial={2} smfcore.api.error=api.error: error={0},message={1},detial={2}
smfcore.api.toXray={0}\u9700\u8981\u53BB\u70B9\u6599 smfcore.api.toXray={0}\u9700\u8981\u53BB\u70B9\u6599
smfcore.paretoChart=\u5E15\u7D2F\u6258\u56FE smfcore.paretoChart=\u5E15\u7D2F\u6258\u56FE
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.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0}
#smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1} #smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1}
#smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F #smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F
......
...@@ -355,4 +355,5 @@ smfcore.micron.nodata=No information found ...@@ -355,4 +355,5 @@ smfcore.micron.nodata=No information found
smfcore.api.fail={0} Failed to get data smfcore.api.fail={0} Failed to get data
smfcore.micron.apiClose=Not yet open smfcore.micron.apiClose=Not yet open
smfcore.api.toXray={0}Need to Xray smfcore.api.toXray={0}Need to Xray
smfcore.paretoChart=Pareto chart
\ No newline at end of file \ No newline at end of file
smfcore.paretoChart=Pareto chart
smfcore.selfAudit.hasOutTask=The location [{0}] already has a release task
\ No newline at end of file \ No newline at end of file
...@@ -350,4 +350,5 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u70B9\u6599\uFF0C\u70B9\u6599\u673A\ ...@@ -350,4 +350,5 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u70B9\u6599\uFF0C\u70B9\u6599\u673A\
smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F
smfcore.api.fail={0} Failed to get data smfcore.api.fail={0} Failed to get data
smfcore.micron.apiClose=Not yet open smfcore.micron.apiClose=Not yet open
smfcore.paretoChart=\u30D1\u30EC\u30FC\u30C8\u56F3
\ No newline at end of file \ No newline at end of file
smfcore.paretoChart=\u30D1\u30EC\u30FC\u30C8\u56F3
smfcore.selfAudit.hasOutTask=\u5E93\u4F4D[{0}]\u5DF2\u6709\u51FA\u5E93\u4EFB\u52A1
\ No newline at end of file \ No newline at end of file
...@@ -350,4 +350,5 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u70B9\u6599\uFF0C\u70B9\u6599\u673A\ ...@@ -350,4 +350,5 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u70B9\u6599\uFF0C\u70B9\u6599\u673A\
smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F
smfcore.api.fail={0} \u83B7\u53D6\u6570\u636E\u5931\u8D25 smfcore.api.fail={0} \u83B7\u53D6\u6570\u636E\u5931\u8D25
smfcore.micron.apiClose=API\u529F\u80FD\u672A\u5F00\u653E smfcore.micron.apiClose=API\u529F\u80FD\u672A\u5F00\u653E
smfcore.paretoChart=\u5E15\u7D2F\u6258\u56FE
\ No newline at end of file \ No newline at end of file
smfcore.paretoChart=\u5E15\u7D2F\u6258\u56FE
smfcore.selfAudit.hasOutTask=\u5E93\u4F4D[{0}]\u5DF2\u6709\u51FA\u5E93\u4EFB\u52A1
\ No newline at end of file \ No newline at end of file
...@@ -351,4 +351,5 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u9EDE\u6599\uFF0C\u9EDE\u6599\u6A5F\ ...@@ -351,4 +351,5 @@ smfcore.micron.xray.offline={0}\u9700\u8981\u9EDE\u6599\uFF0C\u9EDE\u6599\u6A5F\
smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F smfcore.micron.nodata=\u672A\u627E\u5230\u4FE1\u606F
smfcore.api.fail={0} \u83B7\u53D6\u6570\u636E\u5931\u8D25 smfcore.api.fail={0} \u83B7\u53D6\u6570\u636E\u5931\u8D25
smfcore.micron.apiClose=API\u529F\u80FD\u672A\u5F00\u653E smfcore.micron.apiClose=API\u529F\u80FD\u672A\u5F00\u653E
smfcore.paretoChart=\u5E15\u7D2F\u6258\u5716
\ No newline at end of file \ No newline at end of file
smfcore.paretoChart=\u5E15\u7D2F\u6258\u5716
smfcore.selfAudit.hasOutTask=\u5E93\u4F4D[{0}]\u5DF2\u6709\u51FA\u5E93\u4EFB\u52A1
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!