Commit 3265c46a zshaohui

1057-mes功能提交

1 个父辈 670fdff5
正在显示 21 个修改的文件 包含 951 行增加12 行删除
package com.neotel.smfcore.core.api.listener;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.bean.ApiResult;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.service.manager.IInListManager;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem;
import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.storage.service.manager.IStorageManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
......@@ -49,6 +40,9 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
@Autowired
protected DataCache dataCache;
@Autowired
protected IStorageManager storageManager;
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task){
......
......@@ -17,4 +17,6 @@ public interface IBarcodeManager extends IBaseManager<Barcode> {
void download(List<Barcode> list, HttpServletResponse response) throws IOException;
void deleteBarcodes(Set<String> ids);
Barcode findByPartNumber(String partNumber);
}
......@@ -96,6 +96,14 @@ public class BarcodeManagerImpl implements IBarcodeManager {
}
@Override
public Barcode findByPartNumber(String partNumber) {
if (Strings.isNullOrEmpty(partNumber)){
return null;
}
return barcodeDao.findOne(new Query(Criteria.where("partNumber").is(partNumber)));
}
@Override
public Barcode saveBarcode(Barcode resources) {
validateSave(resources);
......
......@@ -710,4 +710,8 @@ public class DataCache {
}
return 0;
}
public Collection<Map<String, InventoryItem>> getInventoryItemMapValueCollections(){
return inventoryMap.values();
}
}
......@@ -406,6 +406,13 @@ public class LiteOrderCache {
}
if (pos == null) {
// log.error("未找到可以出库的物料[" + partNumber + "]");
DataLog task = new DataLog();
task.setBarcode(orderItem.getRi());
task.setPosName(null);
task.setPosId(null);
task.setStatus(OP_STATUS.FINISHED.name());
task.setType(OP.CHECKOUT);
taskService.addTaskToExecute(task);
break;
} else {
assignNum = assignNum + pos.getBarcode().getAmount();
......
......@@ -15,4 +15,6 @@ public interface IStorageManager extends IBaseManager<Storage> {
void clearStorageGroup(String groupId);
List<ChartItem> getRunStatusData(Date fromDate, Date toDate, String partNumber);
Storage findByCid(String cid);
}
......@@ -66,4 +66,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
List<StoragePos> findPosList(String storageId, List<String> posNames);
List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException;
List<StoragePos> getInventoryPosList(List<String> storageId);
}
package com.neotel.smfcore.core.storage.service.manager.impl;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
......@@ -145,4 +146,12 @@ public class StorageManagerImpl implements IStorageManager {
//alarmInfoDao.alarmChartByBox(startDay,endDay);
return new ArrayList<>(inOutDataMap.values());
}
@Override
public Storage findByCid(String cid) {
if (Strings.isNullOrEmpty(cid)){
return null;
}
return storageDao.findOne(new Query(Criteria.where("cid").is(cid)));
}
}
......@@ -557,6 +557,18 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return new ArrayList<>();
}
@Override
public List<StoragePos> getInventoryPosList(List<String> storageIds) {
//构造查询条件
Query query = new Query();
Criteria criteria = Criteria.where("barcode").exists(true).and("enabled").is(true);
if (storageIds != null && storageIds.size() > 0) {
criteria.and("storageId").in(storageIds);
}
query.addCriteria(criteria).with(Sort.by(Sort.Direction.DESC, "createDate"));
return storagePosDao.findByQuery(query);
}
/**
* 获取下一库位的库位名(后缀数字+1)
*/
......
package com.neotel.smfcore.custom.neotelApi;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.bean.ApiResult;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.neotelApi.service.enums.REQ_TYPE;
import com.neotel.smfcore.custom.neotelApi.service.manager.InterfaceExpManager;
import com.neotel.smfcore.custom.neotelApi.service.po.InterfaceExp;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
public class NeotelApi extends BaseSmfApiListener {
@Autowired
protected InterfaceExpManager interfaceExpManager;
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("neotel");
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
String requestParams = "";
String responseInfo = "";
if (task.isFinished()) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("reelId", task.getBarcode());
paramMap.put("location", task.getPosName());
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
String fullCode = "";
if (barcode != null) {
fullCode = barcode.getFullCode();
}
int type = getType(task), w = 0, h = 0;
if (type != 2) {
w = task.getW();
h = task.getH();
}
paramMap.put("fullCode", fullCode);
paramMap.put("w", w);
paramMap.put("h", h);
try {
requestParams = JsonUtil.toJsonStr(paramMap);
log.info(task.getBarcode() + "入库通知,参数" + requestParams);
responseInfo = HttpHelper.postJson(inNotifyUrl, paramMap);
log.info(task.getBarcode() + "入库通知返回" + responseInfo);
ApiResult apiResult = JsonUtil.toObj(responseInfo, ApiResult.class);
if (apiResult.getCode() != 0) {
saveFailInterfaceExp(REQ_TYPE.INTASKSTATUSCHANGE, task.getBarcode(), inNotifyUrl, requestParams, responseInfo);
}
} catch (Exception e) {
log.error("入库通知接口出错:" + e.getMessage());
saveFailInterfaceExp(REQ_TYPE.INTASKSTATUSCHANGE, task.getBarcode(), inNotifyUrl, requestParams, e.getMessage());
}
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
String requestParams = "";
String responseInfo = "";
if (task.isFinished()) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("reelId", task.getBarcode());
paramMap.put("partNum", task.getPartNumber());
paramMap.put("qty", task.getNum() + "");
paramMap.put("boxNo", task.getCid());
paramMap.put("location", task.getPosName());
paramMap.put("hSerial", task.getSourceId());
paramMap.put("slotNum", task.getSubSourceId());
int type = getType(task), w = 0, h = 0;
if (type != 2) {
w = task.getW();
h = task.getH();
}
paramMap.put("w", w);
paramMap.put("h", h);
String status = task.getStatus();
String state = "";
if (OP_STATUS.FINISHED.name().equals(status)) {
state = "ok";
} else if (OP_STATUS.CANCEL.name().equals(status)) {
state = "cancel";
}
if (Strings.isBlank(task.getPosId()) && Strings.isBlank(task.getPosName())) {
state = "not found";
}
paramMap.put("state", state);
try {
requestParams = JsonUtil.toJsonStr(paramMap);
log.info(task.getBarcode() + "出库通知,参数" + requestParams);
responseInfo = HttpHelper.postJson(outNotifyUrl, paramMap);
log.info(task.getBarcode() + "出库通知返回" + responseInfo);
ApiResult apiResult = JsonUtil.toObj(responseInfo, ApiResult.class);
if (apiResult.getCode() != 0) {
saveFailInterfaceExp(REQ_TYPE.OUTTASKSTATUSCHANGE, task.getBarcode(), outNotifyUrl, requestParams, responseInfo);
}
} catch (Exception e) {
log.error("出库通知接口出错:" + e.getMessage());
saveFailInterfaceExp(REQ_TYPE.OUTTASKSTATUSCHANGE, task.getBarcode(), outNotifyUrl, requestParams, e.getMessage());
}
}
}
private String getData(Map<String, Object> dataMap, String dataKey) {
Object data = dataMap.get(dataKey);
if (data == null) {
return "";
} else {
return data.toString();
}
}
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("reelId", barcode.getBarcode());
paramMap.put("fullCode", barcode.getFullCode());
try {
log.info(barcode.getBarcode() + "入库验证,参数" + JsonUtil.toJsonStr(paramMap));
String result = HttpHelper.postJson(inCheckUrl, paramMap);
log.info(barcode.getBarcode() + "入库验证返回" + result);
ApiResult apiResult = JsonUtil.toObj(result, ApiResult.class);
if (apiResult.getCode() == 0) {
Map<String, Object> dataMap = (Map<String, Object>) apiResult.getData();
String partNum = getData(dataMap, "partNum");
if (Strings.isNotBlank(partNum)) {
barcode.setPartNumber(partNum);
}
String vendor = getData(dataMap, "vendor");
if (Strings.isNotBlank(vendor)) {
barcode.setProvider(vendor);
}
String qtyStr = getData(dataMap, "qty");
if (Strings.isNotBlank(qtyStr)) {
int qty = Integer.valueOf(qtyStr);
if (qty > 0) {
barcode.setAmount(qty);
}
}
String batch = getData(dataMap, "batch");
if (Strings.isNotBlank(batch)) {
barcode.setBatch(batch);
}
String produceDateStr = getData(dataMap, "produceDate");
if (Strings.isNotBlank(produceDateStr)) {
Date produceDate = DateUtil.toDate(produceDateStr, "yyyy-MM-dd HH:mm:ss");
barcode.setProduceDate(produceDate);
}
barcode = barcodeManager.saveBarcode(barcode);
return barcode;
} else {
return null;
}
} catch (Exception e) {
log.error("入库验证接口出错:" + e.getMessage());
throw new ValidateException("smfcore.mesApi.inCheck.error", "MES验证出错:" + e.getMessage());
}
}
@Override
public void onOrderStatusChange(String orderNotifyUrl, LiteOrder liteOrder) {
}
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username) {
return null;
}
private void saveFailInterfaceExp(int type, String barcode, String requestUrl, String requestParams, String responseInfo) {
InterfaceExp interfaceExp = new InterfaceExp(type, barcode, requestUrl, requestParams, responseInfo);
interfaceExpManager.save(interfaceExp);
}
private int getType(DataLog task) {
int type = 0;
//根据cid查询物料信息,能够查到,则是物料放入料箱
Barcode barcode = barcodeManager.findByPartNumber(task.getCid());
if (barcode != null) {
type = 1;
}
//判断料仓类型,是否料箱放入散料仓
Storage storage = storageManager.findByCid(task.getStorageId());
if (storage != null) {
if (storage.isXLC()) {
type = 2;
}
}
return type;
}
}
package com.neotel.smfcore.custom.neotelApi.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.api.bean.ApiResult;
import com.neotel.smfcore.custom.neotelApi.rest.bean.dto.InterfaceExpDto;
import com.neotel.smfcore.custom.neotelApi.rest.bean.query.InterfaceExpQueryCriteria;
import com.neotel.smfcore.custom.neotelApi.service.manager.InterfaceExpManager;
import com.neotel.smfcore.custom.neotelApi.service.po.InterfaceExp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/api/interfaceExp")
@RequiredArgsConstructor
@Api(tags = "接口异常处理")
public class InterfaceExpController {
@Autowired
private InterfaceExpManager interfaceExpManager;
@ApiOperation("获取异常列表")
@GetMapping("/list")
public List<InterfaceExpDto> list(InterfaceExpQueryCriteria criteria) {
Query query = QueryHelp.getQuery(criteria);
List<InterfaceExp> interfaceExps = interfaceExpManager.findByQuery(query);
List<InterfaceExpDto> interfaceExpDtos = new ArrayList<>();
for (InterfaceExp interfaceExp : interfaceExps) {
InterfaceExpDto interfaceExpDto = toDto(interfaceExp);
if (interfaceExpDto != null) {
interfaceExpDtos.add(interfaceExpDto);
}
}
return interfaceExpDtos;
}
@ApiOperation("接口重发")
@PostMapping("/reSend")
public ResultBean reSend(@RequestBody String requestId) {
if (ObjectUtil.isEmpty(requestId)) {
throw new ValidateException("smfcore.error.interfaceEx.invalid", "未找到异常接口{1}", new String[]{""});
}
InterfaceExp interfaceExp = interfaceExpManager.findByRequestId(requestId);
if (interfaceExp == null) {
throw new ValidateException("smfcore.error.interfaceEx.invalid", "未找到异常接口{0}", new String[]{requestId});
}
ApiResult apiResult = reSendInterfaceExp(interfaceExp);
if (apiResult != null && apiResult.getCode() == 0) {
return ResultBean.newOkResult("smfcore.apiOk", "发送成功", "");
} else {
return ResultBean.newErrorResult(1, "smfcore.apiError", "错误码{0}:{1}", new String[]{apiResult.getCode() + "", apiResult.getMsg()});
}
}
@ApiOperation("全部重发")
@PostMapping("/reSendAll")
public ResultBean reSend() {
List<InterfaceExp> interfaceExps = interfaceExpManager.findAll();
for (InterfaceExp interfaceExp : interfaceExps) {
reSendInterfaceExp(interfaceExp);
}
return ResultBean.newOkResult("smfcore.api.reSendAll", "已全部重发", "");
}
@ApiOperation("取消重发接口")
@PostMapping("/cancel")
public ResultBean cancelSend(@RequestBody String requestId) {
if (ObjectUtil.isEmpty(requestId)) {
throw new ValidateException("smfcore.error.interfaceEx.invalid", "未找到异常接口{1}", new String[]{""});
}
InterfaceExp interfaceExp = interfaceExpManager.findByRequestId(requestId);
if (interfaceExp == null) {
throw new ValidateException("smfcore.error.interfaceEx.invalid", "未找到异常接口{0}", new String[]{requestId});
}
if (interfaceExp.getResultType() == 2) {
throw new ValidateException("smfcore.error.interfaceEx.invalid", "此接口已返回成功,不需要取消", new String[]{requestId});
} else if (interfaceExp.getResultType() == 3) {
throw new ValidateException("smfcore.error.interfaceEx.invalid", "此接口已取消", new String[]{requestId});
}
interfaceExp.setResultType(3);
interfaceExp.setLastOperator(SecurityUtils.getCurrentUsername());
interfaceExp.setLastOperationTime(new Date());
interfaceExpManager.save(interfaceExp);
return ResultBean.newOkResult("ok");
}
private InterfaceExpDto toDto(InterfaceExp interfaceExp) {
InterfaceExpDto interfaceExpDto = new InterfaceExpDto();
interfaceExpDto.setReelId(interfaceExp.getReelId());
interfaceExpDto.setCreateDate(interfaceExp.getCreateDate());
interfaceExpDto.setType(interfaceExp.getType());
interfaceExpDto.setLastOperator(interfaceExp.getLastOperator());
interfaceExpDto.setLastOperationTime(interfaceExp.getLastOperationTime());
interfaceExpDto.setRequestCount(interfaceExp.getRequestCount());
interfaceExpDto.setRequestId(interfaceExp.getRequestId());
interfaceExpDto.setRequestParams(interfaceExp.getRequestParams());
interfaceExpDto.setResponseInfo(interfaceExp.getResponseInfo());
return interfaceExpDto;
}
private ApiResult reSendInterfaceExp(InterfaceExp interfaceExp) {
try {
String result = HttpHelper.postJson(interfaceExp.getRequestUrl(), JsonUtil.toMap(interfaceExp.getRequestParams()));
ApiResult apiResult = JsonUtil.toObj(result, ApiResult.class);
if (apiResult.getCode() != 0) {
saveFailInterfaceExp(interfaceExp, result);
}
interfaceExp.setResultType(2);
interfaceExpManager.save(interfaceExp);
return apiResult;
} catch (ApiException e) {
e.printStackTrace();
saveFailInterfaceExp(interfaceExp, e.getMessage());
}
return null;
}
private void saveFailInterfaceExp(InterfaceExp interfaceExp, String result) {
interfaceExp.setResponseInfo(result);
interfaceExp.setLastOperationTime(new Date());
interfaceExp.setLastOperator(SecurityUtils.getCurrentUsername());
interfaceExp.setRequestCount(interfaceExp.getRequestCount() + 1);
interfaceExpManager.save(interfaceExp);
}
}
package com.neotel.smfcore.custom.neotelApi.rest;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
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.storage.bean.UsageItem;
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.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.neotelApi.service.manager.InterfaceExpManager;
import com.neotel.smfcore.custom.neotelApi.service.po.InterfaceExp;
import com.neotel.smfcore.security.annotation.AnonymousPostMapping;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.management.ObjectName;
import java.util.*;
@Slf4j
@RestController
@RequestMapping("/smfcore/rest/api")
public class NeotelController {
@Autowired
protected ILiteOrderManager liteOrderManager;
@Autowired
protected LiteOrderCache liteOrderCache;
@Autowired
private DataCache dataCache;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private InterfaceExpManager interfaceExpManager;
@ApiOperation("6.1创建需求单")
@AnonymousPostMapping("/outInfo")
public ResultBean outInfo(@RequestBody List<Map<String, Object>> paramList) {
log.info("{}收到数据为:{}", "创建需求单outInfo", JsonUtil.toJsonStr(paramList));
if (!paramList.isEmpty()) {
for (Map<String, Object> paramMap : paramList) {
if (paramMap.get("hSerial") == null) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"hSerial"});
}
if (paramMap.get("outItems") == null) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"outItems"});
}
String orderNo = paramMap.get("hSerial").toString(); //需求单号
String line = paramMap.get("line") == null ? "" : paramMap.get("line").toString(); //线别
String so = paramMap.get("so") == null ? "" : paramMap.get("so").toString(); //工单号
//需求单详情数据
List<LiteOrderItem> orderItemList = new ArrayList<>();
List<Map> outItemList = JsonUtil.toList(paramMap.get("outItems").toString(), Map.class);
if (!outItemList.isEmpty()) {
for (Map outItem : outItemList) {
LiteOrderItem orderItem = new LiteOrderItem();
if (outItem.get("slotNum") != null) {
orderItem.setSlotNum(Integer.valueOf(outItem.get("slotNum").toString())); //站位编号
}
if (outItem.get("reelId") != null) {
orderItem.setRi(outItem.get("reelId").toString()); //料盘唯一码
}
orderItemList.add(orderItem);
}
}
//开始保存数据
LiteOrder liteOrder = new LiteOrder();
liteOrder.setOrderNo(orderNo);
liteOrder.setLine(line);
liteOrder.setSo(so);
liteOrder.setOrderItems(orderItemList);
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
}
return ResultBean.newOkResult("");
}
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "需求单信息不能为空");
}
@ApiOperation("6.2关闭需求单")
@AnonymousPostMapping("/closeOutInfo")
public ResultBean closeOutInfo(@RequestBody Map<String, String> paramMap) {
String orderNo = paramMap.get("hSerial"); //需求工单
if (ObjectUtils.isEmpty(orderNo)) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"hSerial"});
}
String result = liteOrderCache.closeOrder(orderNo);
if ("smfcore.order.close.success".equals(result)) {
return ResultBean.newOkResult("");
} else {
return ResultBean.newErrorResult(1, "", "关闭失败");
}
}
@ApiOperation("6.3 获取实时库存")
@AnonymousPostMapping("/inventory")
public ResultBean inventory(@RequestBody Map<String, List<String>> paramMap) {
List<String> towerIds = paramMap.get("towerIds");
List<StoragePos> storagePosList = storagePosManager.getInventoryPosList(towerIds);
if (storagePosList != null && storagePosList.size() > 0) {
List<Map<String, Object>> resultMapList = new ArrayList<>();
for (StoragePos storagePos : storagePosList) {
Map<String, Object> resultMap = new HashMap<>();
Barcode barcode = storagePos.getBarcode();
resultMap.put("reelId", barcode.getBarcode());
resultMap.put("partNum", barcode.getPartNumber());
resultMap.put("qty", barcode.getAmount());
resultMap.put("lot", barcode.getBatch());
resultMap.put("checkInTime", DateUtil.toDateString(barcode.getPutInDate(), "yyyy-MM-dd HH:mm:ss"));
resultMap.put("expireDate", DateUtil.toDateString(barcode.getExpireDate(), "yyyy-MM-dd HH:mm:ss"));
resultMap.put("towerId", storagePos.getStorageId());
resultMap.put("location", barcode.getPosName());
if (ObjectUtils.isNotEmpty(barcode.getLockId())) {
resultMap.put("hSerial", barcode.getLockId());
} else {
resultMap.put("hSerial", "");
}
resultMapList.add(resultMap);
}
return ResultBean.newOkResult(resultMapList);
}
return ResultBean.newErrorResult(1, "", "查询失败");
}
@ApiOperation("6.4 设备状态获取")
@AnonymousPostMapping("/deviceStatus")
public ResultBean deviceStatus(@RequestBody Map<String, Object> paramMap) {
Collection<Storage> storageList = Lists.newArrayList();
List<String> deviceKeyList = paramMap.get("deviceKeyList") == null ? null : JsonUtil.toList(paramMap.get("deviceKeyList").toString(), String.class);
//如果没有的话 就查询所有的
if (deviceKeyList == null || deviceKeyList.size() < 1) {
storageList.addAll(dataCache.getAllStorage().values());
} else {
for (String cid : deviceKeyList) {
Storage storage = dataCache.getStorage(cid);
storageList.add(storage);
}
}
List<Map<String, Object>> results = Lists.newArrayList();
for (Storage storage : storageList) {
StatusBean statusBean = DevicesStatusUtil.getStatusBean(storage.getCid());
Map<String, BoxStatusBean> boxStatusMap = statusBean.getBoxStatus();
int status = -1;
if (boxStatusMap != null) {
BoxStatusBean boxStatusBean = boxStatusMap.get("1");
if (boxStatusBean != null) {
status = boxStatusBean.getStatus();
}
}
int storageStatus = status;
if (status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
//离线
storageStatus = -1;
}
String msg = statusBean.getMsg();
String msgType = statusBean.getDeviceType();
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("deviceKey", storage.getType() + "." + storage.getCid());
itemMap.put("name", storage.getName());
itemMap.put("status", storageStatus);
itemMap.put("msg", msg);
itemMap.put("msgType", msgType);
itemMap.put("startTime", storage.getCreateDate());
itemMap.put("updateTime", storage.getUpdateDate());
Map<String, Object> deviceDataMap = new HashMap<>();
Map<String, Object> emptySlotMap = Maps.newHashMap();
Map<String, Object> totalSlotMap = Maps.newHashMap();
Map<String, UsageItem> usageMap = storage.getUsageMap();
for (UsageItem usageItem : usageMap.values()) {
String sizeStr = usageItem.getSizeStr();
int total = usageItem.getTotalCount();
int used = usageItem.getUsedCount();
totalSlotMap.put(sizeStr, total);
emptySlotMap.put(sizeStr, total - used);
}
deviceDataMap.put("towerId", storage.getCid());
deviceDataMap.put("status", statusBean.getStatus());
deviceDataMap.put("name", storage.getName());
deviceDataMap.put("doorReelSignal", statusBean.getDoorReelSingnal());
deviceDataMap.put("barcode", statusBean.getData().get("barcode"));
deviceDataMap.put("emptySlot", emptySlotMap);
deviceDataMap.put("totalSlot", totalSlotMap);
itemMap.put("deviceData", deviceDataMap);
results.add(itemMap);
}
return ResultBean.newOkResult(results);
}
@ApiOperation("6.5 接口异常")
@AnonymousPostMapping("/apiErrors")
public ResultBean apiErrors() {
List<InterfaceExp> interfaceExps = interfaceExpManager.findAll();
if (interfaceExps == null || interfaceExps.isEmpty()){
return ResultBean.newErrorResult(1,"smfcore.valueNotFind","接口异常信息为空");
}
List<Map<String,Object>> results = new ArrayList<>();
for (InterfaceExp interfaceExp : interfaceExps) {
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("requestId",interfaceExp.getRequestId());
resultMap.put("reelId",interfaceExp.getReelId());
resultMap.put("requsetParams",interfaceExp.getRequestParams());
resultMap.put("responseInfo",interfaceExp.getResponseInfo());
resultMap.put("createDate",interfaceExp.getCreateDate());
results.add(resultMap);
}
return ResultBean.newOkResult(results);
}
@ApiOperation("6.6 料口状态查询")
@AnonymousPostMapping("/doorInfo")
public ResultBean doorInfo() {
String result = " [\n" +
" {\n" +
" \"doorIndex\": 1,\n" +
" \"status\": \"IDLE\",\n" +
" \"hasContainer\": false,\n" +
" \"hSerial\": \"\"\n" +
" },\n" +
" {\n" +
" \"doorIndex\": 2,\n" +
" \"status\": \"IDLE\",\n" +
" \"hasContainer\": true,\n" +
" \"hSerial\": \"00001\"\n" +
" },\n" +
" {\n" +
" \"doorIndex\": 3,\n" +
" \"status\": \"NEED_EMPTY\",\n" +
" \"hasContainer\": false,\n" +
" \"hSerial\": \"\"\n" +
" },\n" +
" {\n" +
" \"doorIndex\": 4,\n" +
" \"status\": \"NEED_OUT\",\n" +
" \"hasContainer\": true,\n" +
" \"hSerial\": \"00002\"\n" +
" }\n" +
" ]";
List<Map> results = JsonUtil.toList(result, Map.class);
return ResultBean.newOkResult(results);
}
}
package com.neotel.smfcore.custom.neotelApi.rest.bean.dto;
import lombok.Data;
import java.util.Date;
@Data
public class InterfaceExpDto {
/**
* 请求id,随机生成
*/
private String requestId;
/**
* 请求类型
*/
private int type;
/**
* 请求次数
*/
private int requestCount = 1;
/**
* 料卷ID
*/
private String reelId;
/**
* 请求地址
*/
private String requestUrl;
/**
* 请求参数
*/
private String requestParams;
/**
* 响应数据
*/
private String responseInfo;
/**
* 上一次操作时间
*/
private Date lastOperationTime;
/**
* 上一次操作人
*/
private String lastOperator;
/**
* 是否发送成功,默认false
*/
private boolean isSendSuccess;
/**
* 创建时间
*/
private Date createDate;
}
package com.neotel.smfcore.custom.neotelApi.rest.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Date;
@Data
public class InterfaceExpQueryCriteria {
@QueryCondition(blurry = "requestUrl,requestParams,responseInfo,reelId,requestId")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "createDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> createDate;
}
package com.neotel.smfcore.custom.neotelApi.service.dao;
import com.neotel.smfcore.common.base.IBaseDao;
public interface InterfaceExpDao extends IBaseDao {
}
package com.neotel.smfcore.custom.neotelApi.service.dao.impl;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.custom.neotelApi.service.dao.InterfaceExpDao;
import com.neotel.smfcore.custom.neotelApi.service.po.InterfaceExp;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
@Service
public class InterfaceExpDaoImpl extends AbstractBaseDao implements InterfaceExpDao {
@Override
public Class getEntityClass() {
return InterfaceExp.class;
}
}
package com.neotel.smfcore.custom.neotelApi.service.enums;
/**
* neotel请求类型type
*/
public class REQ_TYPE {
public static int CANPUTIN = 1;
public static int INTASKSTATUSCHANGE = 1;
public static int OUTTASKSTATUSCHANGE = 2;
}
package com.neotel.smfcore.custom.neotelApi.service.manager;
import com.neotel.smfcore.common.base.IBaseManager;
import com.neotel.smfcore.custom.neotelApi.service.po.InterfaceExp;
import java.util.List;
public interface InterfaceExpManager extends IBaseManager<InterfaceExp> {
List<InterfaceExp> findAll();
InterfaceExp findByRequestId(String requestId);
}
package com.neotel.smfcore.custom.neotelApi.service.manager.impl;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.custom.neotelApi.service.dao.InterfaceExpDao;
import com.neotel.smfcore.custom.neotelApi.service.manager.InterfaceExpManager;
import com.neotel.smfcore.custom.neotelApi.service.po.InterfaceExp;
import com.neotel.smfcore.security.service.po.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class InterfaceExpManagerImpl implements InterfaceExpManager {
@Autowired
private InterfaceExpDao interfaceExpDao;
@Override
public InterfaceExp get(String id) {
return null;
}
@Override
public InterfaceExp save(InterfaceExp interfaceExp) throws ValidateException {
return interfaceExpDao.save(interfaceExp);
}
@Override
public void delete(InterfaceExp object) throws ValidateException {
}
@Override
public PageData<InterfaceExp> findByPage(Query query, Pageable pageable) {
return null;
}
@Override
public List<InterfaceExp> findByQuery(Query query) {
query.addCriteria(Criteria.where("resultType").is(1));
return interfaceExpDao.findByQuery(query);
}
@Override
public List<InterfaceExp> findAll() {
return interfaceExpDao.findAll();
}
@Override
public InterfaceExp findByRequestId(String requestId) {
Query query = new Query(Criteria.where("requestId").is(requestId).and("resultType").is(1));
return interfaceExpDao.findOne(query);
}
}
package com.neotel.smfcore.custom.neotelApi.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.core.device.util.DataCache;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.UUID;
/**
* 接口异常类
*/
@Data
public class InterfaceExp extends BasePo {
public InterfaceExp(int type, String reelId, String requestUrl, String requestParams, String responseInfo) {
this.type = type;
this.requestId = UUID.randomUUID().toString();
this.reelId = reelId;
this.requestUrl = requestUrl;
this.requestParams = requestParams;
this.responseInfo = responseInfo;
this.resultType = 1;
}
/**
* 请求id,随机生成
*/
private String requestId;
/**
* 请求次数
*/
private int requestCount = 1;
/**
* 请求类型
*/
private int type;
/**
* 料卷ID
*/
private String reelId;
/**
* 请求地址
*/
private String requestUrl;
/**
* 请求参数
*/
private String requestParams;
/**
* 响应数据
*/
private String responseInfo;
/**
* 上一次操作时间
*/
private Date lastOperationTime;
/**
* 上一次操作人
*/
private String lastOperator;
/**
* 1:失败 2:成功 3:忽略
*/
private int resultType;
}
......@@ -41,6 +41,7 @@ app:
type: ""
menu:
show:
show: ML5DispatchSelect,ML5Loading,dispatchStatus,loadingStatus,cl,mt,ml,ml2,status,reports,diagnosis,helps,miFive,SBSH1,SBSH2,SBDH1,SBDH2,SBDH3,menu,translation
#show:
hide:
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!