Commit 58fa5821 zshaohui

功能提交

1 个父辈 ce4f455b
正在显示 127 个修改的文件 包含 150 行增加9310 行删除
......@@ -8,7 +8,7 @@ import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
......
......@@ -5,7 +5,6 @@ import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.bean.BarcodeRule;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
......@@ -13,14 +12,11 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.setting.bean.ExpiredSetting;
import com.neotel.smfcore.custom.lizhen.setting.service.manager.ExpiredSettingManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.comments.CommentType;
import java.util.*;
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
......@@ -22,8 +21,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.bean.OrderSetting;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.rest.InnerBoxRestController;
import com.neotel.smfcore.security.TokenProvider;
......@@ -31,8 +29,6 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
......@@ -425,36 +421,6 @@ public class NLShelfHandler extends BaseDeviceHandler {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码",new String[]{code});
}
//校验是否可以入库
Map<String, Object> brandQty = lizhenApi.brandQty(barcode.getPartNumber(), barcode.getProvider());
if (brandQty == null || brandQty.isEmpty()) {
throw new ValidateException("smfcore.error.barcode.partNumber.invalid", "{0}不是有效的料号", new String[]{barcode.getPartNumber()});
}
Barcode barcodeApi = lizhenApi.barcodeInfo(barcode);
//如果是L开头的去量测
if (barcode.getBarcode().startsWith("L") || barcode.getBarcode().startsWith("l")) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
} else {
if (barcodeApi != null) {
//判断返回过来的物料数量与标签上的是否一致,如果不一致,则调用散料量测接口
if (barcodeApi.getAmount() != barcode.getLabelAmount()) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
}
}
}
if (barcodeApi != null){
barcode = barcodeApi;
}
Date expireDate = barcode.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
......
......@@ -11,7 +11,6 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.api.listener.ISmfApiListener;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
......@@ -23,9 +22,8 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.dao.IAlarmInfoDao;
import com.neotel.smfcore.core.system.service.po.AlarmInfo;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.virtual.service.manager.IVirInventoryManager;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
......@@ -37,12 +35,10 @@ import com.neotel.smfcore.core.storage.service.po.Storage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.beans.Beans;
import java.util.*;
......@@ -208,40 +204,12 @@ public class DeviceController {
virInventoryManager.updateStatus(dataLog);
}
}
//校验是否可以入库
Map<String, Object> brandQty = lizhenApi.brandQty(barcode.getPartNumber(), barcode.getProvider());
if (brandQty == null || brandQty.isEmpty()) {
throw new ValidateException("smfcore.error.barcode.partNumber.invalid", "{0}不是有效的料号", new String[]{barcode.getPartNumber()});
}
Barcode barcodeCanPutIn = smfApi.canPutInAfterResolve(barcode);
if (barcodeCanPutIn != null){
barcode = barcodeCanPutIn;
}
Barcode barcodeApi = lizhenApi.barcodeInfo(barcode);
//如果是L开头的去量测
if (barcode.getBarcode().startsWith("L") || barcode.getBarcode().startsWith("l")) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
throw new ValidateException("", barcode.getBarcode() + "散料未量测");
}
} else {
if (barcodeApi != null) {
//判断返回过来的物料数量与标签上的是否一致,如果不一致,则调用散料量测接口
if (barcodeApi.getAmount() != barcode.getLabelAmount()) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
throw new ValidateException("", barcode.getBarcode() + "散料未量测");
}
}
}
}
if (barcodeApi != null){
barcode = barcodeApi;
}
for (DataLog dataLog : taskService.getAllTasks()) {
// if(!dataLog.isPackageReel()){
//已经在任务当中,返回对应的信息
......
......@@ -30,12 +30,11 @@ 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.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.StorageExport;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.util.StorageExportUtil;
import com.neotel.smfcore.custom.lizhen.third.maicheng.api.MaiZhengApi;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
......
......@@ -20,29 +20,22 @@ 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.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.rest.dto.TacticsOutDto;
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.bean.MSDAppendInfo;
import com.neotel.smfcore.core.system.service.dao.IDataLogDao;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.StorageExport;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.util.StorageExportUtil;
import com.neotel.smfcore.custom.lizhen.virtual.service.manager.IVirInventoryManager;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* Created by sunke on 2021/7/13.
......
package com.neotel.smfcore.custom.lizhen;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.StringUtils;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.api.listener.DefaultSmfApiListener;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.storage.enums.DeviceType;
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.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Component
public class LizhenApi extends DefaultSmfApiListener {
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private DataCache dataCache;
@Value("${api.fetchGRUrl}")
private String fetchGRUrl;
@Value("${api.brandQtyUrl}")
private String brandQtyUrl;
@Value("${api.plant}")
private String plant;
@Value("${api.barcodeInfoUrl}")
private String barcodeInfoUrl;
@Value("${api.werks}")
private String werks;
@Value("${api.outNotifyUrlPK}")
private String outNotifyUrlPK = "";
@Value("${api.batchCheckUrl}")
private String batchCheckUrl = "";
@Value("${api.checkReelMeasure}")
private String checkReelMeasureUrl = "";
@PostConstruct
public void init(){
fetchGRUrl = dataCache.getConfigCache("fetchGRUrl",fetchGRUrl);
brandQtyUrl = dataCache.getConfigCache("brandQtyUrl",brandQtyUrl);
plant = dataCache.getConfigCache("plant",plant);
barcodeInfoUrl = dataCache.getConfigCache("barcodeInfoUrl",barcodeInfoUrl);
werks = dataCache.getConfigCache("werks",werks);
outNotifyUrlPK = dataCache.getConfigCache("api.outNotifyUrlPK",outNotifyUrlPK);
batchCheckUrl = dataCache.getConfigCache("api.batchCheckUrl",batchCheckUrl);
//checkReelMeasureUrl = dataCache.getConfigCache("api.checkReelMeasure",checkReelMeasureUrl);
}
/**
* 根据partnumber和brand获取满卷数
*
* @param partnumber
* @param brand
* @return
*/
public Map<String,Object> brandQty(String partnumber, String brand) {
log.info("brandQty--material_code:" + partnumber + ",brand:" + brand);
Map<String, Object> resultMap = new HashMap<>();
if (StringUtils.isBlank(brandQtyUrl)){
resultMap.put("qty", 0);
resultMap.put("reelSize", 0);
return resultMap;
}
int qty = 0;
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("material_code", partnumber);
paramMap.put("brand", brand);
try {
String result = HttpHelper.postJson(brandQtyUrl, paramMap);
log.info("brandQty-" + partnumber + ":请求结果为:" + result);
JSONObject jsonObject = JsonUtil.toObj(result, JSONObject.class);
String msgtx = jsonObject.getString("MSGTX");
if ("S".equals(msgtx)) {
JSONObject dataObject = jsonObject.getJSONObject("DATA");
if (dataObject != null) {
if (dataObject.getInteger("qty") != null) {
qty = dataObject.getInteger("qty");
resultMap.put("qty", qty);
}
String reelSize = dataObject.getString("reel_size");
if (StringUtils.isNotBlank(reelSize)) {
resultMap.put("reelSize", reelSize);
}
}
}
} catch (ApiException e) {
e.printStackTrace();
log.info("brandQty--" + partnumber + ":异常:" + e.getMessage());
}
return resultMap;
}
/**
* 获取gr标签
*
* @param grLabel
* @return
*/
public Map<String, String> fetchGR(GrLabel grLabel) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("plant_code", plant);
paramMap.put("gr_code", grLabel.getLabelId());
paramMap.put("gr_item", grLabel.getLabelItem());
paramMap.put("material_code", grLabel.getPartNumber());
log.info("gr标签入参为:" + JsonUtil.toJsonStr(paramMap));
Map<String, String> resultMap = new HashMap<>();
try {
String result = HttpHelper.postJson(fetchGRUrl, paramMap);
log.info("gr标签出参为:" + result);
JSONObject resultObject = JsonUtil.toObj(result, JSONObject.class);
if ("S".equals(resultObject.getString("MSGTX"))) {
JSONArray dataArrray = resultObject.getJSONArray("DATA");
if (dataArrray != null && !dataArrray.isEmpty()) {
JSONObject dataObject = dataArrray.getJSONObject(0);
String brand = dataObject.getString("brand");
resultMap.put("brand", brand);
resultMap.put("keeperCode",dataObject.getString("keeper_code"));
resultMap.put("warehouseCode",dataObject.getString("warehouse_code"));
}
}
} catch (ApiException e) {
e.printStackTrace();
log.error(grLabel.getLabelId() + "fetchGr异常:" + e.getMessage());
}
return resultMap;
}
/**
* 获取mes数量
*
* @param barcode
* @return
*/
public Barcode barcodeInfo(Barcode barcode) {
if (barcodeInfoUrl == null) {
return null;
}
log.info("获取MES物料数量入参为:" + barcode.getBarcode());
String result = "";
try {
result = HttpHelper.postJson(barcodeInfoUrl, barcode.getBarcode());
} catch (ApiException e) {
e.printStackTrace();
}
log.info("获取MES物料数量出参为:" + result);
JSONObject resultJson = JsonUtil.toObj(result, JSONObject.class);
Integer status = resultJson.getInteger("status");
if (status != null) {
if (status == 200) {
JSONObject dataJson = resultJson.getJSONObject("data");
String reelID = dataJson.get("reelID") == null ? "" : dataJson.get("reelID").toString();
//String partNum = dataJson.get("partNum") == null ? "" : dataJson.get("partNum").toString();
String partSpec = dataJson.get("partSpec") == null ? "" : dataJson.get("partSpec").toString();
int qty = dataJson.get("qty") == null ? 0 : Integer.valueOf(dataJson.get("qty").toString());
//String vendor = dataJson.get("vendor") == null ? "" : dataJson.get("vendor").toString();
//String vendorNum = dataJson.get("vendorNum") == null ? "" : dataJson.get("vendorNum").toString();
//String dataCode = dataJson.get("dataCode") == null ? "" : dataJson.get("dataCode").toString();
//String lotCode = dataJson.get("lotCode") == null ? "" : dataJson.get("lotCode").toString();
/*if (StringUtils.isBlank(reelID)) {
return null;
}
if (StringUtils.isNotBlank(reelID)){
barcode.setBarcode(reelID);
}
if (StringUtils.isNotBlank(partNum)){
barcode.setPartNumber(partNum);
}*/
if (StringUtils.isNotBlank(reelID)) {
if (qty == 0) {
throw new ValidateException("smfcore.mesApi.inCheck.ng", reelID + "mes数量返回为0,不允许进行入库");
}
if (qty != 0) {
barcode.setAmount(qty);
}
}
/*if (StringUtils.isNotBlank(vendor)){
barcode.setProvider(vendor);
}
if (StringUtils.isNotBlank(vendorNum)){
barcode.setProviderNumber(vendorNum);
}
if (StringUtils.isNotBlank(dataCode)){
barcode.setDateCode(dataCode);
}
if (StringUtils.isNotBlank(lotCode)){
barcode.setBatch(lotCode);
}*/
if (StringUtils.isNotBlank(partSpec)) {
barcode.setDescribe(partSpec);
}
return barcode;
}
}
return null;
}
/**
* 入库验证
*
* @param inCheckUrl
* @param barcode
* @return
* @throws ValidateException
*/
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
String resultStr = "false";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ipn", barcode.getPartNumber());
paramMap.put("reelId", barcode.getBarcode());
paramMap.put("wo", "");
paramMap.put("datecode", barcode.getDateCode());
paramMap.put("lot", barcode.getBatch());
paramMap.put("vendor", barcode.getProvider());
String param = JsonUtil.toJsonStr(paramMap);
log.info("禁用料接口wmsCheckReelfob入参为:" + param);
try {
String result = HttpHelper.postJson(inCheckUrl, paramMap);
log.info(barcode.getBarcode() + "禁用料接口wmsCheckReelfob出参为:" + result);
JSONObject resultJson = JsonUtil.toObj(result, JSONObject.class);
if (resultJson != null) {
if (resultJson.getString("data") != null) {
JSONObject dataJson = resultJson.getJSONObject("data");
if (dataJson.get("result") != null && dataJson.getBoolean("result") == true) {
resultStr = "";
} else {
resultStr = dataJson.get("message").toString();
}
}
}
//log.info("禁用料接口wmsCheckReelfob出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
resultStr = e.getMessage();
log.info(barcode.getBarcode() + "wmsCheckReelfob异常:" + e.getMessage());
}
//保存禁用料记录
Barcode barcodeOri = barcodeManager.findByBarcode(barcode.getBarcode());
if (barcodeOri != null){
barcodeOri.setDisableMsg(resultStr);
barcode = barcodeManager.save(barcodeOri);
StoragePos storagePos = storagePosManager.getByBarcode(barcode.getBarcode());
if (storagePos != null){
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
}
if (StringUtils.isNotBlank(resultStr)) {
throw new ValidateException("smfcore.mesApi.inCheck.ng", /*"MES验证失败:" + */barcode.getBarcode() + "验证失败:" + resultStr);
}
return barcode;
}
/**
* 保存物料接口
*
* @param inNotifyUrl
* @param task
*/
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (!task.isFinished()){
return;
}
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("pickingid", "");
dataMap.put("wo", "");
dataMap.put("reelno", task.getBarcode());
dataMap.put("ipn", task.getPartNumber());
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
if (barcode != null) {
dataMap.put("qty", barcode.getAmount());
dataMap.put("datecode", barcode.getDateCode());
dataMap.put("lot", barcode.getBatch());
dataMap.put("vendor", barcode.getProvider());
dataMap.put("batch", "");
dataMap.put("vendorcode",barcode.getProviderNumber());
}
dataMap.put("werks",werks);
dataMap.put("reelid","");
String param = JsonUtil.toJsonStr(Arrays.asList(dataMap));
log.info("保存物料入参为:" + param);
try {
String result = HttpHelper.postJson(inNotifyUrl, Arrays.asList(dataMap));
log.info("保存物料出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
log.info(barcode.getBarcode()+"保存物料异常:"+e.getMessage());
}
}
/**
* 保存物料接口
*
* @param outNotifyUrl
* @param task
*/
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.getBarcode().startsWith("CS")
|| task.getBarcode().startsWith("CM")
|| task.getBarcode().startsWith("CB")) {
return;
}
if (!task.isFinished()) {
return;
}
if (task.isBoxOut()){
return;
}
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("pickingid", "");
if (StringUtils.isNotBlank(task.getSourceName()) && StringUtils.isNotBlank(task.getLine()) && !task.isManualUpload()) {
dataMap.put("pickingid", task.getSourceName());
outNotifyUrl = outNotifyUrlPK;
log.info("出库pk不为空:"+outNotifyUrl);
}
dataMap.put("wo", "");
dataMap.put("reelno", task.getBarcode());
dataMap.put("ipn", task.getPartNumber());
dataMap.put("qty", task.getNum());
dataMap.put("datecode", task.getDateCode());
dataMap.put("lot", task.getBatchInfo());
dataMap.put("vendor", task.getProvider());
dataMap.put("batch", "");
dataMap.put("vendorcode", task.getProviderNumber());
dataMap.put("werks", werks);
dataMap.put("reelid", "");
if (outNotifyUrl == outNotifyUrlPK) {
List<Map<String, Object>> paramList = new ArrayList();
paramList.add(dataMap);
JSONObject jsonObject = new JSONObject();
jsonObject.put("data",paramList);
String param = JsonUtil.toJsonStr(jsonObject);
log.info("保存物料入参为:" + param + "地址为:" + outNotifyUrl);
try {
String result = HttpHelper.postJson(outNotifyUrl, jsonObject);
log.info("保存物料出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
log.info(task.getBarcode() + "保存物料异常:" + e.getMessage());
}
} else {
String param = JsonUtil.toJsonStr(Arrays.asList(dataMap));
log.info("保存物料入参为:" + param + "地址为:" + outNotifyUrl);
try {
String result = HttpHelper.postJson(outNotifyUrl, Arrays.asList(dataMap));
log.info("保存物料出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
log.info(task.getBarcode() + "保存物料异常:" + e.getMessage());
}
}
}
/**
* 保存物料接口
*
* @param outNotifyUrl
* @param taskList
*/
public void outTaskStatusChange(String outNotifyUrl, List<DataLog> taskList) {
List<DataLog> resultList = new ArrayList<>();
for (DataLog task : taskList) {
if (task.getBarcode().startsWith("CS")
|| task.getBarcode().startsWith("CM")
|| task.getBarcode().startsWith("CB")) {
continue;
}
if (!task.isFinished()) {
continue;
}
resultList.add(task);
}
//构造入参
List<Map<String, Object>> paramList = new ArrayList();
for (DataLog task : resultList) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("pickingid", "");
if (StringUtils.isNotBlank(task.getSourceName()) && StringUtils.isNotBlank(task.getLine()) && !task.isManualUpload()) {
dataMap.put("pickingid", task.getSourceName());
}
dataMap.put("wo", "");
dataMap.put("reelno", task.getBarcode());
dataMap.put("ipn", task.getPartNumber());
dataMap.put("qty", task.getNum());
dataMap.put("datecode", task.getDateCode());
dataMap.put("lot", task.getBatchInfo());
dataMap.put("vendor", task.getProvider());
dataMap.put("batch", "");
dataMap.put("vendorcode", task.getProviderNumber());
dataMap.put("werks", werks);
dataMap.put("reelid", "");
paramList.add(dataMap);
}
//有pickingid的任务
List<Map<String, Object>> hasPickingidList = paramList.stream().filter(item -> {
String pickingid = (String) item.get("pickingid");
return StringUtils.isNotBlank(pickingid);
}).collect(Collectors.toList());
if (hasPickingidList != null && !hasPickingidList.isEmpty()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", paramList);
String param = JsonUtil.toJsonStr(jsonObject);
log.info("保存物料入参为:" + param + "地址为:" + outNotifyUrlPK);
try {
String result = HttpHelper.postJson(outNotifyUrlPK, jsonObject);
log.info("保存物料出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
log.info("保存物料异常:" + e.getMessage());
}
}
//无picking的任务
List<Map<String, Object>> noPickingidList = paramList.stream().filter(item -> {
String pickingid = (String) item.get("pickingid");
return StringUtils.isBlank(pickingid);
}).collect(Collectors.toList());
if (noPickingidList != null && !noPickingidList.isEmpty()){
String param = JsonUtil.toJsonStr(paramList);
log.info("保存物料入参为:" + param + "地址为:" + outNotifyUrl);
try {
String result = HttpHelper.postJson(outNotifyUrl, paramList);
log.info("保存物料出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
log.info("保存物料异常:" + e.getMessage());
}
}
}
/**
* 获取到需求单数据
*
* @param fetchOrderUrl
* @param orderNumber
* @param username
* @return
*/
@Override
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username) {
log.info("收到需求单号--" + orderNumber);
String result = HttpHelper.sendGet(fetchOrderUrl + "workorder=" + orderNumber);
log.info(orderNumber + "返回数据为--" + result);
if (StringUtils.isNotBlank(result)) {
List<PreWarningItem> items = new ArrayList<>();
Map resultMap = JsonUtil.toObj(result, Map.class);
if (resultMap.get("data") != null) {
List<Map> datas = JsonUtil.toList(resultMap.get("data").toString(), Map.class);
for (Map data : datas) {
String line = data.get("LINE").toString();
String face = data.get("FACE").toString();
String machine = data.get("MACHINE").toString();
String slot = data.get("SLOT").toString();
String module = data.get("MODULE").toString();
String partNumber = data.get("ITEM_PART_NUMBER").toString();
PreWarningItem item = new PreWarningItem();
item.setLine(line);
item.setPartnumber(partNumber);
item.setSubslot("");
item.setSlot(slot);
item.setSide(face);
item.setMachinename(machine);
item.setStation(module);
items.add(item);
}
}
if (items != null && !items.isEmpty()) {
return PreWarningItemCache.createAndExecuteLiteOrder(items,false);
}
}
return null;
}
/**
* 批量禁用
*
* @param barcodeList
* @return
*/
public List<String> batchCheck(List<Barcode> barcodeList) {
List<String> resultList = new ArrayList<>();
List<Map<String, Object>> paramList = new ArrayList<>();
for (Barcode barcode : barcodeList) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ipn", barcode.getPartNumber());
paramMap.put("reelId", barcode.getBarcode());
paramMap.put("wo", "");
paramMap.put("datecode", barcode.getDateCode());
paramMap.put("lot", barcode.getBatch());
paramMap.put("vendor", barcode.getProvider());
paramMap.put("remark", "");
paramList.add(paramMap);
}
String paramStr = JSON.toJSONString(paramList);
log.info("批量禁用料,入参为:" + paramStr+",地址为:"+batchCheckUrl);
try {
String result = HttpHelper.postJson(batchCheckUrl, paramList);
log.info("批量禁用料,出参为:" + result);
JSONObject jsonObject = JSON.parseObject(result);
if (jsonObject.getInteger("status") == 200) {
JSONArray data = jsonObject.getJSONArray("data");
if (data != null && !data.isEmpty()) {
for (int i = 0; i < data.size(); i++) {
JSONObject item = data.getJSONObject(i);
resultList.add(item.getString("reelNo"));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return resultList;
}
/**
* 散料进行量测
*
* @param barcode
* @return
*/
public boolean checkReelMeasure(Barcode barcode) {
if (StringUtils.isBlank(checkReelMeasureUrl)) {
return true;
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("reelID", barcode.getBarcode());
paramMap.put("ipn", barcode.getPartNumber());
try {
log.info(barcode.getBarcode() + "散料量测接口入参为-----" + JSON.toJSONString(paramMap)+",接口地址为:"+checkReelMeasureUrl);
String result = HttpHelper.postJson(checkReelMeasureUrl, paramMap);
log.info(barcode.getBarcode() + "散料量测接口出参为-----" + result);
JSONObject jsonObject = JSON.parseObject(result);
if (jsonObject.getInteger("status") == 200) {
JSONObject data = jsonObject.getJSONObject("data");
if (data.getBoolean("result")) {
return true;
} else {
return false;
}
} else {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Lizhen");
}
}
......@@ -24,12 +24,9 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.AskReelBoxList;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
......
......@@ -6,6 +6,7 @@ import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.enums.DeviceType;
......@@ -58,6 +59,9 @@ public class AgvBoxDeviceClientController {
@Autowired
private IDataLogDao dataLogDao;
@Autowired
private CodeResolve codeResolve;
/**
* 料箱锁定的目的地
*/
......@@ -195,112 +199,32 @@ public class AgvBoxDeviceClientController {
@ResponseBody
@AnonymousAccess
public ResultBean getTarget(HttpServletRequest request) {
Map<String, String> taskData = new HashMap<>();
taskData.put("barcode", "");
taskData.put("slotCode", "");
String rfid = request.getParameter("barcode");
try {
//"barcode": "CS001"
DataLog opTask = null;
Collection<DataLog> tasks = taskService.getAllTasks();
for (DataLog task : tasks) {
if (!task.isFinished() && !task.isCancel()) {
Storage storage = dataCache.getStorageById(task.getStorageId());
if (storage.isStorage(DeviceType.AGV_BOX)) {
if (isSameBarcodeTask(rfid, task)) {
opTask = task;
break;
}
}
}
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2=" + rfid);
if (barcode != null){
List<Storage> storageList = new ArrayList<>();
Collection<Storage> storages = dataCache.getAllStorage().values();
for (Storage storage : storages) {
storageList.add(storage);
}
String target = "s0";
String barcode = "";
//"target": "1",//0=工位已有箱子;s1=工位1;s2=工位2;s3=工位3;s4=工位4;s5=工位5;其他值表示入库的目标库位
if (opTask != null) {
barcode = opTask.getBarcode();
if (opTask.isPutInTask()) {
target = opTask.getPosName();
} else {
String loc = lockRfidTarget.get(opTask.getBarcode());
if (loc != null) {
target = loc;
} else {
loc = opTask.getLoc();
if(Strings.isNotBlank(loc)){
//出空箱子时已经指定了工位,先判断该工位是否有料箱
Station station = StationCacheUtil.getStation(loc);
if(station != null){
String stationRfid = station.getCurrentRfid();
if(Strings.isBlank(stationRfid)){
//该工位无料箱, 把空箱子分配到该工位
lockRfidTarget.put(opTask.getBarcode(),station.getName());
log.info("分配用于入库物料的料箱[" + opTask.getBarcode() + "]到" + station.getName());
target = station.getName();
}
}
}else{
for (Station station : StationCacheUtil.getAllStations()) {
String stationRfid = station.getCurrentRfid();
if(Strings.isBlank(stationRfid)){
//该工位目前无料箱
/*if (lockRfidTarget.get(station.getName()) == null) {
//工位未分配过库位
log.info("分配料箱[" + opTask.getBarcode() + "]到" + station.getName());
lockRfidTarget.put(opTask.getBarcode(), station.getName());
target = station.getName();
break;
}*/
Collection<String> names = lockRfidTarget.values();
if (names != null && !names.isEmpty()){
if (!names.contains(station.getName())) {
//工位未分配过库位
log.info("分配料箱[" + opTask.getBarcode() + "]到" + station.getName());
lockRfidTarget.put(opTask.getBarcode(), station.getName());
target = station.getName();
break;
}
} else {
log.info("分配料箱[" + opTask.getBarcode() + "]到" + station.getName());
lockRfidTarget.put(opTask.getBarcode(), station.getName());
target = station.getName();
break;
}
}
}
//如果工位上都是忙碌,则均分
if ("s0".equals(target)){
Map<String,Integer> nameCountMap = new HashMap<>();
for (int i = 1; i < 6; i++) {
nameCountMap.put("s"+i,0);
}
Collection<String> names = lockRfidTarget.values();
for (String name : names) {
Integer count = nameCountMap.get(name);
count ++;
nameCountMap.put(name,count);
}
target = "s5";
int count = nameCountMap.get("s5");
for (Map.Entry<String, Integer> entry : nameCountMap.entrySet()) {
String name = entry.getKey();
Integer nameCount = entry.getValue();
if (count > nameCount){
count = nameCount;
target = name;
}
}
lockRfidTarget.put(opTask.getBarcode(),target);
}
}
}
}
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
if (pos != null){
Storage storage = dataCache.getStorageById(pos.getStorageId());
taskService.addPutInTaskToExecute(storage,barcode,pos,"");
taskData.put("barcode", barcode.getBarcode());
taskData.put("slotCode",pos.getPosName());
}
Map<String, String> taskData = new HashMap<>();
taskData.put("barcode", barcode);
taskData.put("slotCode", target);
return ResultBean.newOkResult(taskData);
} catch (Exception e) {
return ResultBean.newErrorResult(2004, "smfcore.agvBox.getTarget.fail", "获取" + rfid + "目的地失败");
}
return ResultBean.newOkResult(taskData);
}
......
package com.neotel.smfcore.custom.lizhen.agvBox.rest;
import cn.hutool.core.date.DateTime;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.BetweenData;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
......@@ -21,7 +20,7 @@ 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.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.InventoryData;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.PartitionInfo;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.Station;
......@@ -39,7 +38,6 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
......@@ -624,11 +622,7 @@ public class InventoryController {
if (!posName.startsWith(boxStr)) {
return barcode.getBarcode() + "存在料箱中:" + barcode.getPosName() + "与当前工位上的料箱:" + boxStr + "不一致";
}
//判断料号是否正确
Map<String, Object> barandMap = lizhenApi.brandQty(barcode.getPartNumber(), barcode.getProvider());
if (barandMap.get("qty") == null) {
return barcode.getPartNumber() + "MES未返回料卷数量,未找到对应的料卷数量";
}
log.info(barcode.getBarcode() + "隔口信息:" + barcode.getPosName());
//开始查询盘点数据
//盘点批次
......
......@@ -4,7 +4,6 @@ import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
......@@ -24,7 +23,7 @@ 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.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.agvBox.enums.INOUT_TYPE;
import com.neotel.smfcore.custom.lizhen.agvBox.util.BoxUtil;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
......@@ -236,37 +235,6 @@ public class OutLineController {
}
}
//校验是否可以入库
Map<String, Object> brandQty = lizhenApi.brandQty(barcode.getPartNumber(), barcode.getProvider());
if (brandQty == null || brandQty.isEmpty()) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.partNumber.invalid", "{0}不是有效的料号", new String[]{barcode.getPartNumber()});
}
//获取mes数量
Barcode barcodeApi = lizhenApi.barcodeInfo(barcode);
//如果是L开头的去量测
if (barcode.getBarcode().startsWith("L") || barcode.getBarcode().startsWith("l")) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
} else {
if (barcodeApi != null) {
//判断返回过来的物料数量与标签上的是否一致,如果不一致,则调用散料量测接口
if (barcodeApi.getAmount() != barcode.getLabelAmount()) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
}
}
}
if (barcodeApi != null){
barcode = barcodeApi;
}
barcode.setReelAmount(1);
barcode.setWarehouseCode(warehouseCode);
barcode.setPosName(boxPartition);
......
......@@ -21,7 +21,7 @@ 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.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.GrLabel;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.Station;
import com.neotel.smfcore.custom.lizhen.agvBox.enums.INOUT_TYPE;
......@@ -114,39 +114,8 @@ public class WarehouseController {
if (grLabel.getRemainingAmount() <= 0) {
return ResultBean.newErrorResult(-1, "", "Gr:" + grLabel.getLabelId() + "已经失效");
}
//得到料卷总数量与尺寸
Map<String, Object> barandMap = lizhenApi.brandQty(grLabel.getPartNumber(), grLabel.getProvider());
if (barandMap.get("qty") == null) {
return ResultBean.newErrorResult(-1, "", grLabel.getPartNumber() + "MES未返回料卷数量,未找到对应的料卷数量");
}
num = (grLabel.getRemainingAmount() / Integer.valueOf(barandMap.get("qty").toString())) + "";
//校验尺寸,如果没有返回也没有手输,返回错误
if (barandMap.get("reelSize") == null) {
if (StringUtils.isBlank(size)) {
return ResultBean.newErrorResult(-1, "", grLabel.getPartNumber() + "MES未返回物料规格,请选择对应的物料规格");
}
} else {
String reelSize = barandMap.get("reelSize").toString();
if ("7".equals(reelSize)) {
size = "7X8";
} /*else if ("13".equals(reelSize)) {
size = "13X24";
} */else if ("15".equals(reelSize)) {
size = "15X32";
}
}
//得到对应的库别
Map<String, String> fetchGrMap = lizhenApi.fetchGR(grLabel);
if (fetchGrMap.get("warehouseCode") == null) {
if (StringUtils.isBlank(warehouseCode)) {
return ResultBean.newErrorResult(-1, "", grLabel.getLabelId() + "MES未返回库别,请选择对应的库别");
}
} else {
warehouseCode = fetchGrMap.get("warehouseCode");
}
String keeperCode = fetchGrMap.get("keeperCode");
grLabel.setWarehouseCode(warehouseCode);
grLabel.setKeeperCode(keeperCode);
grLabelManager.save(grLabel);
station.setGrLabel(grLabel.getLabelId());
station.setLabelItem(grLabel.getLabelItem());
......@@ -406,37 +375,6 @@ public class WarehouseController {
}
}
//校验是否可以入库
Map<String, Object> brandQty = lizhenApi.brandQty(barcode.getPartNumber(), barcode.getProvider());
if (brandQty == null || brandQty.isEmpty()) {
return ResultBean.newErrorResult(-1,"smfcore.error.barcode.partNumber.invalid", "{0}不是有效的料号", new String[]{barcode.getPartNumber()});
}
//获取mes数量
Barcode barcodeApi = lizhenApi.barcodeInfo(barcode);
//如果是L开头的去量测
if (barcode.getBarcode().startsWith("L") || barcode.getBarcode().startsWith("l")) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
} else {
if (barcodeApi != null) {
//判断返回过来的物料数量与标签上的是否一致,如果不一致,则调用散料量测接口
if (barcodeApi.getAmount() != barcode.getLabelAmount()) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
}
}
}
if (barcodeApi != null){
barcode = barcodeApi;
}
//当前已扫描的料卷数量+1
int reelCurrentNum = station.getReelCurrentNum();
station.setReelCurrentNum(reelCurrentNum + 1);
......
package com.neotel.smfcore.custom.lizhen.api;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.api.listener.DefaultSmfApiListener;
import com.neotel.smfcore.custom.lizhen.api.bean.request.GetSpareNoRequest;
import com.neotel.smfcore.custom.lizhen.api.bean.result.GetSpareNoResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class LizhenApi extends DefaultSmfApiListener {
public static String GetSpareNoUrl;
@Value("${api.getSpareNo}")
public void setGetSpareNoUrl(String url) {
LizhenApi.GetSpareNoUrl = url;
}
/*public static GetSpareNoResult getSpareNo(GetSpareNoRequest request) {
log.info("获取入库单号请求为:" + JSON.toJSONString(request));
HttpHelper.sendGet()
}*/
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Lizhen");
}
}
package com.neotel.smfcore.custom.lizhen.api.bean;
import lombok.Data;
@Data
public class LizhenApiResult {
private String msg;
private int code;
private String data;
}
package com.neotel.smfcore.custom.lizhen.api.bean.request;
import lombok.Data;
@Data
public class GetSpareNoRequest {
//厂区
private String deptId;
//功能部门
private String functionDept;
}
package com.neotel.smfcore.custom.lizhen.api.bean.result;
import lombok.Data;
@Data
public class GetSpareNoDetail {
private String partno;
private String partname;
private int inQty;
}
package com.neotel.smfcore.custom.lizhen.api.bean.result;
import lombok.Data;
import java.util.List;
@Data
public class GetSpareNoResult {
private String createBy;
//创建时间
private String createTime; // 使用Date或LocalDateTime等日期类型
//单据号
private String spareNo;
//仓库代码
private String whCode;
//0表示待入库
private String status;
//厂区id
private int deptId;
//料号明细
private List<GetSpareNoDetail> detailList;
//仓库描述
private String whDesc;
}
......@@ -23,7 +23,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.api.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.VirImportLog;
import com.neotel.smfcore.custom.lizhen.innerBox.enums.ExtendType;
import com.neotel.smfcore.custom.lizhen.innerBox.service.manager.IVirImportLogManager;
......@@ -126,36 +126,6 @@ public class VirtualRestController {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"库位"});
}
//校验是否可以入库
Map<String, Object> brandQty = lizhenApi.brandQty(barcode.getPartNumber(), barcode.getProvider());
if (brandQty == null || brandQty.isEmpty()) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.partNumber.invalid", "{0}不是有效的料号", new String[]{barcode.getPartNumber()});
}
Barcode barcodeApi = lizhenApi.barcodeInfo(barcode);
//如果是L开头的去量测
if (barcode.getBarcode().startsWith("L") || barcode.getBarcode().startsWith("l")) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
} else {
if (barcodeApi != null) {
//判断返回过来的物料数量与标签上的是否一致,如果不一致,则调用散料量测接口
if (barcodeApi.getAmount() != barcode.getLabelAmount()) {
boolean check = lizhenApi.checkReelMeasure(barcode);
if (!check) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "散料未量测");
}
}
}
}
if (barcodeApi != null){
barcode = barcodeApi;
}
//判断是否为禁用料
try {
barcode = smfApi.canPutInAfterResolve(barcode);
......
package com.neotel.smfcore.custom.luxsan.api;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.StringUtils;
import com.neotel.smfcore.core.api.listener.DefaultSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.luxsan.api.bean.request.*;
import com.neotel.smfcore.custom.luxsan.api.bean.result.*;
import com.neotel.smfcore.custom.luxsan.api.bean.util.LuxsanApiResult;
import com.neotel.smfcore.custom.luxsan.api.enums.LuxsanApiEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class LuxsanApi extends DefaultSmfApiListener {
@Autowired
private IStoragePosManager storagePosManager;
/**
* QueryBin:储位查询
*
* @param request
* @return
*/
public static List<QueryBinResult> queryBin(QueryBinRequest request) {
try {
log.info("queryBin接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(queryBinUrl, request);
log.info("queryBin接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<QueryBinResult> resultList = JSONObject.parseArray(apiResult.getDATA(), QueryBinResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("queryBin请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的储位信息"});
}
/**
* UpdateBin:更新储位
*
* @param request
* @return
*/
public static void updateBin(UpdateBinRequest request) {
try {
log.info("updateBin接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(updateBinUrl, request);
log.info("updateBin接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("queryBin请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* Gr查询
*
* @param request
* @return
*/
public static List<QueryGrResult> queryGr(QueryGrRequest request) {
try {
log.info("queryGr接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(queryGrUrl, request);
log.info("queryGr接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<QueryGrResult> resultList = JSONObject.parseArray(apiResult.getDATA(), QueryGrResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("queryGr请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的Gr信息"});
}
/**
* 检验DC有效期
*
* @param request
* @return
*/
public static int getInDate(GetInDateRequest request) {
try {
log.info("getInDate接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(getInDateUrl, request);
log.info("getInDate接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
//判断是否过期
String data = apiResult.getDATA();
int days = NumberUtil.parseInt(data);
if (days < 0) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
return days;
} catch (ApiException e) {
log.error("getInDate请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* GR过账状态查询
*
* @param request
* @return
*/
public static List<QueryGrStatusResult> queryGrStatus(QueryGrStatusRequest request) {
try {
log.info("queryGrStatus接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(queryGrStatusUrl, request);
log.info("queryGrStatus接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<QueryGrStatusResult> resultList = JSONObject.parseArray(apiResult.getDATA(), QueryGrStatusResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (Exception e) {
log.error("queryGrStatus请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的GR过账状态信息"});
}
/**
* 按GR生成标签码并上架
*
* @param request
* @return
*/
public static NewLabelToCellResult newLabelToCell(NewLabelToCellRequest request) {
try {
log.info("newLabelToCell接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(newLabelToCellUrl, request);
log.info("newLabelToCell接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
return JSONObject.parseObject(apiResult.getDATA(), NewLabelToCellResult.class);
} catch (ApiException e) {
log.error("newLabelToCell请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 电子料入退库
*
* @param request
* @return
*/
public static List<BackToWarehouseResult> backToWarehouse(BackToWarehouseRequest request) {
try {
log.info("backToWarehouse接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(backToWarehouseUrl, request);
log.info("backToWarehouse接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<BackToWarehouseResult> resultList = JSONObject.parseArray(apiResult.getDATA(), BackToWarehouseResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("backToWarehouse请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的电子料入退库信息"});
}
/**
* Tower发料
*
* @param request
* @return
*/
public static void towerIssue(TowerIssueRequest request) {
try {
log.info("towerIssue接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(towerIssueUrl, request);
log.info("towerIssue接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("towerIssue请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* Picking发料
*
* @param request
* @return
*/
public static void pickingIssue(PickingIssueRequest request) {
try {
log.info("pickingIssue接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(pickingIssueUrl, request);
log.info("pickingIssue接口返回结果为:" + resultStr);
/*LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}*/
} catch (ApiException e) {
log.error("pickingIssue请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 料卷退PK
*
* @param request
* @return
*/
public static ReturnToPKResult returnToPK(ReturnToPKRequest request) {
try {
log.info("returnToPK接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(returnToPKUrl, request);
log.info("returnToPK接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
return JSONObject.parseObject(apiResult.getDATA(), ReturnToPKResult.class);
} catch (ApiException e) {
log.error("returnToPK请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 单据挑料
*
* @param request
* @return
*/
public static List<TicketPostResult> ticketPost(TicketPostRequest request) {
try {
log.info("ticketPost接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(ticketPostUrl, request);
log.info("ticketPost接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<TicketPostResult> resultList = JSONObject.parseArray(apiResult.getDATA(), TicketPostResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("ticketPost请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的单据挑料信息"});
}
/**
* 校验箱号信息
*
* @param request
* @return
*/
public static ValidCartonResult validCarton(ValidCartonRequest request) {
try {
log.info("validCarton接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(validCartonUrl, request);
log.info("validCarton接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
return JSONObject.parseObject(apiResult.getDATA(), ValidCartonResult.class);
} catch (ApiException e) {
log.error("validCarton请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 获取栈板信息
*
* @param request
* @return
*/
public static List<FetchPalletInfoResult> fetchPalletInfo(FetchPalletInfoRequest request) {
try {
log.info("fetchPalletInfo接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(fetchPalletInfoUrl, request);
log.info("fetchPalletInfo接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<FetchPalletInfoResult> resultList = JSONObject.parseArray(apiResult.getDATA(), FetchPalletInfoResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("fetchPalletInfo请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的获取栈板信息"});
}
/**
* 获取栈板信息
*
* @param request
* @return
*/
public static void palletUpdate(PalletUpdateRequest request) {
try {
log.info("palletUpdate接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(palletUpdateUrl, request);
log.info("palletUpdate接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("palletUpdate请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 获取可用库存
*
* @param request
* @return
*/
public static List<FetchValidInvResult> fetchValidInv(FetchValidInvRequest request) {
try {
log.info("fetchValidInv接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(fetchValidInvUrl, request);
log.info("fetchValidInv接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<FetchValidInvResult> resultList = JSONObject.parseArray(apiResult.getDATA(), FetchValidInvResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("fetchValidInv请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的可用库存信息"});
}
/**
* 栈板拆分
*
* @param request
* @return
*/
public static void palletSplit(PalletSplitRequest request) {
try {
log.info("palletSplit接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(palletSplitUrl, request);
log.info("palletSplite接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("palletSplit请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 栈板合并
*
* @param request
* @return
*/
public static PalletMergeResult palletMerge(PalletMergeRequest request) {
try {
log.info("palletMerge接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(palletMergeUrl, request);
log.info("palletMerge接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
return JSONObject.parseObject(apiResult.getDATA(), PalletMergeResult.class);
} catch (ApiException e) {
log.error("palletMerge请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 箱去向接口
*
* @param request
* @return
*/
public static CartonDstResult cartonDst(CartonDstRequest request) {
try {
log.info("cartonDst接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(cartonDstUrl, request);
log.info("cartonDst接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
return JSONObject.parseObject(apiResult.getDATA(), CartonDstResult.class);
} catch (ApiException e) {
log.error("palletMerge请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 拉取转库单据
*
* @param request
* @return
*/
public static List<FetchMoveTicketResult> fetchMoveTicket(FetchMoveTicketRequest request) {
try {
log.info("fetchMoveTicket接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(fetchMoveTicketUrl, request);
log.info("fetchMoveTicket接口请求结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<FetchMoveTicketResult> resultList = JSONObject.parseArray(apiResult.getDATA(), FetchMoveTicketResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (Exception e) {
log.error("fetchMoveTicket请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的拉取转库单据信息"});
}
/**
* 转库单据备料
*
* @param request
* @return
*/
public static void moveTicketPick(MoveTicketPickRequest request) {
try {
log.info("moveTicketPick接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(moveTicketPickUrl, request);
log.info("moveTicketPick接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("moveTicketPick请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 转库单据过账
*
* @param request
* @return
*/
public static void moveTicketPost(MoveTicketPostRequest request) {
try {
log.info("moveTicketPost接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(moveTicketPostUrl, request);
log.info("moveTicketPost接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("moveTicketPost请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* Check检查站
*
* @param request
* @return
*/
public static void checkPassStation(CheckPassStationRequest request) {
try {
log.info("checkPassStation接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(checkPassStationUrl, request);
log.info("checkPassStation接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("checkPassStation请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* PPS CHECK检查结果
*
* @param request
* @return
*/
public static void checkLabelResult(CheckLabelRequest request) {
try {
log.info("checkLabelResult接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(checkLabelResultUrl, request);
log.info("checkLabelResult接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("checkLabelResult请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 集货单锁定料箱查询
*
* @param request
* @return
*/
public static List<LockedCartonQueryResult> lockedCartonQuery(LockedCartonQueryRequest request) {
try {
log.info("lockedCartonQuery接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(lockedCartonQueryUrl, request);
log.info("lockedCartonQuery接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<LockedCartonQueryResult> resultList = JSONObject.parseArray(apiResult.getDATA(), LockedCartonQueryResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("lockedCartonQuery请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的集货单锁定料箱查询信息"});
}
/**
* 用栈板号获取箱信息清单
*
* @param request
* @return
*/
public static List<FetchPalletCartonResult> fetchPalletCarton(FetchPalletCartonRequest request) {
try {
log.info("fetchPalletCarton接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(fetchPalletCartonUrl, request);
log.info("fetchPalletCarton接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<FetchPalletCartonResult> resultList = JSONObject.parseArray(apiResult.getDATA(), FetchPalletCartonResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("fetchPalletCarton请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的用栈板号获取箱信息清单信息"});
}
/**
* PPS 按栈板获取箱清单
*
* @param request
* @return
*/
public static List<CheckPalletCartonResult> checkPalletCarton(CheckPalletCartonRequest request) {
try {
log.info("checkPalletCarton接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(checkPalletCartonUrl, request);
log.info("checkPalletCarton接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<CheckPalletCartonResult> resultList = JSONObject.parseArray(apiResult.getDATA(), CheckPalletCartonResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("checkPalletCarton请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的PPS 按栈板获取箱清单信息"});
}
/**
* 获取不可用(HOLD)库存信息
*
* @param request
* @return
*/
public static List<FetchHoldInfoResult> fetchHoldInfo(FetchHoldInfoRequest request) {
try {
log.info("fetchHoldInfo接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(fetchHoldInfoUrl, request);
log.info("fetchHoldInfo接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
List<FetchHoldInfoResult> resultList = JSONObject.parseArray(apiResult.getDATA(), FetchHoldInfoResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("fetchHoldInfo请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的获取不可用(HOLD)库存信息"});
}
/**
* 转库单据备料还原
*
* @param request
* @return
*/
public static void moveTicketRestore(MoveTicketRestoreRequest request) {
try {
log.info("moveTicketRestore接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(moveTicketRestoreUrl, request);
log.info("moveTicketRestore接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("moveTicketRestore请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
/**
* 重置转库单据
*
* @param request
* @return
*/
public static void resetMoveTicket(ResetMoveTicketRequest request) {
try {
log.info("resetMoveTicket接口请求参数为:" + JSONObject.toJSONString(request));
String resultStr = HttpHelper.postJson(resetMoveTicketUrl, request);
log.info("resetMoveTicket接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
log.error("resetMoveTicket请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
public static List<QueryPickingResult> queryPicking(QueryPickingRequest request) {
try {
log.info("queryPicking接口请求参数为:" + JSON.toJSONString(request));
String resultStr = HttpHelper.postJson(queryPickingUrl, request);
log.info("queryPicking接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
List<QueryPickingResult> resultList = JSONObject.parseArray(apiResult.getDATA(), QueryPickingResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (Exception e) {
log.error("queryPicking接口请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的查询挑料单列表信息"});
}
public static List<GetPickingItemsResult> getPickingItems(GetPickingItemsRequest request) {
try {
log.info("getPickingItems接口请求参数为:" + JSON.toJSONString(request));
String resultStr = HttpHelper.postJson(getPickingItemsUrl, request);
log.info("getPickingItems接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
List<GetPickingItemsResult> resultList = JSONObject.parseArray(apiResult.getDATA(), GetPickingItemsResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (Exception e) {
log.error("getPickingItems接口请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的获取挑料单详情信息"});
}
public static BrandQtyResult brandQtyUrl(BrandQtyRequest request) {
log.info("brandQtyUrl接口请求参数为:" + JSON.toJSONString(request));
try {
String resultStr = HttpHelper.postJson(brandQtyUrl, request);
log.info("brandQtyUrl接口返回为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
if (apiResult.getDATA() != null) {
return JSONObject.parseObject(apiResult.getDATA(), BrandQtyResult.class);
}
} catch (ApiException e) {
e.printStackTrace();
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到料号信息"});
}
public static void binMove(BinMoveRequest request) {
log.info("binMoveUrl接口请求参数为:" + JSON.toJSONString(request));
try {
String resultStr = HttpHelper.postJson(binMoveUrl, request);
log.info("binMoveUrl接口返回为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
e.printStackTrace();
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
public static List<FetchShipmentInfoResult> fetchShipmentInfo(FetchShipmentInfoRequest request) {
try {
log.info("fetchShipmentInfo接口请求参数为:" + JSON.toJSONString(request));
String resultStr = HttpHelper.postJson(fetchShipmentInfoUrl, request);
log.info("fetchShipmentInfo接口返回结果为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
List<FetchShipmentInfoResult> resultList = JSONObject.parseArray(apiResult.getDATA(), FetchShipmentInfoResult.class);
if (resultList != null && !resultList.isEmpty()) {
return resultList;
}
} catch (ApiException e) {
log.error("fetchShipmentInfo接口请求失败:" + e.getMessage());
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{"未找到对应的ODN信息"});
}
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
String resultStr = "false";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ipn", barcode.getPartNumber());
paramMap.put("reelId", barcode.getBarcode());
paramMap.put("wo", "");
paramMap.put("datecode", barcode.getDateCode());
paramMap.put("lot", barcode.getBatch());
paramMap.put("vendor", barcode.getProvider());
String param = JsonUtil.toJsonStr(paramMap);
log.info("禁用料接口wmsCheckReelfob入参为:" + param);
try {
String result = HttpHelper.postJson(inCheckUrl, paramMap);
log.info(barcode.getBarcode() + "禁用料接口wmsCheckReelfob出参为:" + result);
JSONObject resultJson = JsonUtil.toObj(result, JSONObject.class);
if (resultJson != null) {
if (resultJson.getString("data") != null) {
JSONObject dataJson = resultJson.getJSONObject("data");
if (dataJson.get("result") != null && dataJson.getBoolean("result") == true) {
resultStr = "";
} else {
resultStr = dataJson.get("message").toString();
}
}
}
//log.info("禁用料接口wmsCheckReelfob出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
resultStr = e.getMessage();
log.info(barcode.getBarcode() + "wmsCheckReelfob异常:" + e.getMessage());
}
//保存禁用料记录
/*Barcode barcodeOri = barcodeManager.findByBarcode(barcode.getBarcode());
if (barcodeOri != null){
barcodeOri.setDisableMsg(resultStr);
barcode = barcodeManager.save(barcodeOri);
StoragePos storagePos = storagePosManager.getByBarcode(barcode.getBarcode());
if (storagePos != null){
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
}*/
if (StringUtils.isNotBlank(resultStr)) {
throw new ValidateException("smfcore.mesApi.inCheck.ng", /*"MES验证失败:" + */barcode.getBarcode() + "验证失败:" + resultStr);
}
return barcode;
}
public static void shipCancelUpshelf(ShipCancelUpshelfRequest request) {
log.info("shipCancelUpshelf接口请求参数为:" + JSON.toJSONString(request));
try {
String resultStr = HttpHelper.postJson(shipCancelUpshelfUrl, request);
log.info("shipCancelUpshelf接口返回为:" + resultStr);
LuxsanApiResult apiResult = JSONObject.parseObject(resultStr, LuxsanApiResult.class);
if (LuxsanApiEnum.ERROR.equals(apiResult.getMSGTY())) {
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{apiResult.getMSGTX()});
}
} catch (ApiException e) {
e.printStackTrace();
throw new ValidateException("smfcore.api.error", "接口请求失败[{0}]", new String[]{e.getMessage()});
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
//pickingIssue(new PickingIssueRequest());
}
@Override
public boolean isForThisApi(String apiName) {
return "luxsan".equals(apiName);
}
private static String queryBinUrl;
@Value("${api.queryBin}")
public void setQueryBinUrl(String url) {
LuxsanApi.queryBinUrl = url;
}
private static String updateBinUrl;
@Value("${api.updateBin}")
public void setUpdateBinUrl(String url) {
LuxsanApi.updateBinUrl = url;
}
private static String queryGrUrl;
@Value("${api.queryGr}")
public void setQueryGrUrl(String url) {
LuxsanApi.queryGrUrl = url;
}
private static String getInDateUrl;
@Value("${api.getInDate}")
public void setGetInDateUrl(String url) {
LuxsanApi.getInDateUrl = url;
}
private static String queryGrStatusUrl;
@Value("${api.queryGrStatus}")
public void setQueryGrStatusUrl(String url) {
LuxsanApi.queryGrStatusUrl = url;
}
private static String newLabelToCellUrl;
@Value("${api.newLabelToCell}")
public void setNewLabelToCellUrl(String url) {
LuxsanApi.newLabelToCellUrl = url;
}
private static String backToWarehouseUrl;
@Value("${api.backToWarehouse}")
public void setBackToWarehouseUrl(String url) {
LuxsanApi.backToWarehouseUrl = url;
}
private static String towerIssueUrl;
@Value("${api.towerIssue}")
public void setTowerIssueUrl(String url) {
LuxsanApi.towerIssueUrl = url;
}
private static String pickingIssueUrl;
@Value("${api.pickingIssue}")
public void setPickingIssueUrl(String url) {
LuxsanApi.pickingIssueUrl = url;
}
public static String returnToPKUrl;
@Value("${api.returnToPK}")
public void setReturnToPKUrl(String url) {
LuxsanApi.returnToPKUrl = url;
}
public static String ticketPostUrl;
@Value("${api.ticketPost}")
public void setTicketPostUrl(String url) {
LuxsanApi.ticketPostUrl = url;
}
public static String validCartonUrl;
@Value("${api.validCarton}")
public void setValidCartonUrl(String url) {
LuxsanApi.validCartonUrl = url;
}
public static String fetchPalletInfoUrl;
@Value("${api.fetchPalletInfo}")
public void setFetchPalletInfoUrl(String url) {
LuxsanApi.fetchPalletInfoUrl = url;
}
public static String palletUpdateUrl;
@Value("${api.palletUpdate}")
public void setPalletUpdateUrl(String url) {
LuxsanApi.palletUpdateUrl = url;
}
public static String fetchValidInvUrl;
@Value("${api.fetchValidInv}")
public void setFetchValidInvUrl(String url) {
LuxsanApi.fetchValidInvUrl = url;
}
public static String palletSplitUrl;
@Value("${api.palletSplit}")
public void setPalletSplitUrl(String url) {
LuxsanApi.palletSplitUrl = url;
}
public static String palletMergeUrl;
@Value("${api.palletMerge}")
public void setPalletMergeUrl(String url) {
LuxsanApi.palletMergeUrl = url;
}
public static String cartonDstUrl;
@Value("${api.cartonDst}")
public void setCartonDstUrl(String url) {
LuxsanApi.cartonDstUrl = url;
}
public static String fetchMoveTicketUrl;
@Value("${api.fetchMoveTicket}")
public void setFetchMoveTicketUrl(String url) {
LuxsanApi.fetchMoveTicketUrl = url;
}
public static String moveTicketPickUrl;
@Value("${api.moveTicketPick}")
public void setMoveTicketPickUrl(String url) {
LuxsanApi.moveTicketPickUrl = url;
}
public static String moveTicketPostUrl;
@Value("${api.moveTicketPost}")
public void setMoveTicketPostUrl(String url) {
LuxsanApi.moveTicketPostUrl = url;
}
public static String checkPassStationUrl;
@Value("${api.checkPassStation}")
public void setCheckPassStationUrl(String url) {
LuxsanApi.checkPassStationUrl = url;
}
public static String checkLabelResultUrl;
@Value("${api.checkLabelResult}")
public void setCheckLabelResultUrl(String url) {
LuxsanApi.checkLabelResultUrl = url;
}
public static String lockedCartonQueryUrl;
@Value("${api.lockedCartonQuery}")
public void setLockedCartonQueryUrl(String url) {
LuxsanApi.lockedCartonQueryUrl = url;
}
public static String fetchPalletCartonUrl;
@Value("${api.fetchPalletCarton}")
public void setFetchPalletCartonUrl(String url) {
LuxsanApi.fetchPalletCartonUrl = url;
}
public static String checkPalletCartonUrl;
@Value("${api.checkPalletCarton}")
public void setCheckPalletCartonUrl(String url) {
LuxsanApi.checkPalletCartonUrl = url;
}
public static String fetchHoldInfoUrl;
@Value("${api.fetchHoldInfo}")
public void setFetchHoldInfoUrl(String url) {
LuxsanApi.fetchHoldInfoUrl = url;
}
public static String moveTicketRestoreUrl;
@Value("${api.moveTicketRestore}")
public void setMoveTicketRestoreUrl(String url) {
LuxsanApi.moveTicketRestoreUrl = url;
}
public static String resetMoveTicketUrl;
@Value("${api.resetMoveTicket}")
public void setResetMoveTicketUrl(String url) {
LuxsanApi.resetMoveTicketUrl = url;
}
public static String queryPickingUrl;
@Value("${api.queryPicking}")
public void setQueryPickingUrl(String url) {
LuxsanApi.queryPickingUrl = url;
}
public static String getPickingItemsUrl;
@Value("${api.getPickingItems}")
public void setGetPickingItemsUrl(String url) {
LuxsanApi.getPickingItemsUrl = url;
}
public static String brandQtyUrl;
@Value("${api.brandQtyUrl}")
public void setBrandQtyUrl(String url) {
LuxsanApi.brandQtyUrl = url;
}
public static String fetchShipmentInfoUrl;
@Value("${api.fetchShipmentInfo}")
public void setFetchShipmentInfoUrl(String url) {
LuxsanApi.fetchShipmentInfoUrl = url;
}
public static String binMoveUrl;
@Value("${api.binMove}")
public void setBinMoveUrl(String url){
LuxsanApi.binMoveUrl = url;
}
public static String shipCancelUpshelfUrl;
@Value("${api.shipCancelUpshelf}")
public void setShipCancelUpshelfUrl(String url) {
LuxsanApi.shipCancelUpshelfUrl = url;
}
public static String cancelOdnUrl;
@Value("${api.cancelOdn}")
public void setCancelOdnUrl(String url){
LuxsanApi.cancelOdnUrl = url;
}
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
import java.util.List;
/**
* 电子料入退库 请求
*/
@Data
public class BackToWarehouseRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 目标储位
*/
private String BIN_CODE;
/**
* 料卷清单
*/
private List<String> REEL_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
@Data
@AllArgsConstructor
public class BinMoveRequest {
private String PLANT_CODE;
private String BIN_CODE;
private List<String> REEL_LIST;
private int QTY;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class BrandQtyRequest {
private String material_code;
private String brand;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
@Data
public class BrandQtyResult {
private String id;
private String material_code;
private String brand;
private int qty;
private int reel_size;
private String create_by;
private String create_at;
private String update_by;
private String update_at;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 箱去向接口
*/
@Data
public class CartonDstRequest {
//厂区
private String PLANT;
//箱号
private String CARTON_ID;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* PPS CHECK检查结果
*/
@Data
public class CheckLabelRequest {
//箱号
private String CARTON_NO;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* PPS 按栈板获取箱清单
*/
@Data
public class CheckPalletCartonRequest {
//栈板号
private String PALLET_NO;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
@Data
public class CheckPassStationRequest {
// 出货栈板号
private String PALLET_NO;
// 箱号
private String CARTON_NO;
// SSCC/Tracking No
private String BARCODE;
// DN号
private String DN_NO;
// SHIPPINGLABEL/CARRIERLABEL打印类型
private String PRINT_TYPE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 获取不可用(HOLD)库存信息
*/
@Data
public class FetchHoldInfoRequest {
//工厂代码
private String PLANT;
//库别代码
private String WAREHOUSE_CODE;
//物料编号
private String MATERIAL_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 拉取转库单据
*/
@Data
@AllArgsConstructor
public class FetchMoveTicketRequest {
//工厂代码
private String PLANT_CODE;
//单据号
private String TICKET_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 用栈板号获取箱信息清单
*/
@Data
public class FetchPalletCartonRequest {
//库存栈板号
private String PALLET_ID;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* 获取栈板信息 请求
*/
@Data
@AllArgsConstructor
public class FetchPalletInfoRequest {
private String REQUEST_ID;
private String PLANT;
private List<String> PALLET_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class FetchShipmentInfoRequest {
/**
* 工厂代码
*/
private String PLANT_CODE;
/**
* 出货单号
*/
private String TICKET_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 获取可用库存
*/
@Data
public class FetchValidInvRequest {
private String REQ_ID;
private String MATERIAL_CODE;
private String WAREHOUSE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* GetInDate 校验DC有效期
*/
@Data
@AllArgsConstructor
public class GetInDateRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 制造商
*/
private String BRAND;
/**
* 日期编码
*/
private String DATE_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* GetPickingItems请求实体类
*/
@Data
@AllArgsConstructor
public class GetPickingItemsRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 任务类型
*/
private String PICKING_ID;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 集货单锁定料箱查询
*/
@Data
public class LockedCartonQueryRequest {
//出货单号
private String SHIPMENT_ID;
//出货栈板号
private String PALLET_NO;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
import java.util.List;
@Data
public class MoveTicketPickData {
// 工厂代码
private String PLANT_CODE;
// 单据号
private String TICKET_CODE;
// 单据行号
private String TICKET_ITEM;
// 料号
private String MATERIAL_CODE;
// 库存栈板清单
private List<String> LABEL_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 转库单据备料
*/
@Data
public class MoveTicketPickRequest {
//工厂代码
private String PLANT_CODE;
//单据号
private String TICKET_CODE;
private MoveTicketPickData DATA;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 转库单据过账
*/
@Data
public class MoveTicketPostRequest {
//工厂代码
private String PLANT_CODE;
//单据号
private String TICKET_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 转库单据备料还原
*/
@Data
public class MoveTicketRestoreRequest {
//工厂代码
private String PLANT_CODE;
//单据号
private String TICKET_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* 按GR生成标签码并上架 请求
*/
@Data
@AllArgsConstructor
public class NewLabelToCellRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 过账编码
*/
private List<String> UD_LIST;
/**
* 数量
*/
private int QTY;
/**
* 储位号
*/
private String BIN_CODE;
/**
* 料卷行
*/
private List<String> REEL_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
import java.util.List;
/**
* 栈板合并
*/
@Data
public class PalletMergeRequest {
// 合并到
private String MERGE_TO;
// 合并清单
private List<String> MERGE_LIST;
// 厂区
private String PLANT_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 栈板拆分
*/
@Data
public class PalletSplitRequest {
//库存栈板号
private String PALLET_ID;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* 栈板同库别转移
*/
@Data
public class PalletUpdateRequest {
// 请求标识
private String REQUEST_ID;
// 库存栈板号列表
private List<String> PALLET_LIST;
// 储位号
private String BIN_CODE;
// 业务类型
private String BIZ_TYPE;
/**
* 工厂代码
*/
private String PLANT_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* PickingIssue请求
*/
@Data
@AllArgsConstructor
public class PickingIssueRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 挑料单号
*/
private String PICKING_ID;
/**
* 行号
*/
private String ITEM_ID;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 库别
*/
private String WAREHOUSE_CODE;
/**
* 制造商
*/
private String BRAND;
/**
* 面别
*/
private String FACE;
/**
* 批次码
*/
private String BATCH_CODE;
/**
* 料卷清单
*/
private List<String> REEL_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* QueryBin请求
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class QueryBinRequest {
/**
* 工厂代码
*/
private String PLANT_CODE;
/**
* 存储类型
*/
private String STORAGE_TYPE;
/**
* 储位状态
*/
private int BIN_STATUS;
/**
* 储位库别
*/
private String WAREHOUSE_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* QueryGr请求实体类
*/
@Data
@AllArgsConstructor
public class QueryGrRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 供应商
*/
private String BRAND;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* GR过账状态查询 请求
*/
@Data
@AllArgsConstructor
public class QueryGrStatusRequest {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 供应商
*/
private String BRAND;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 单据号
*/
private String GR_CODE;
/**
* 单据行
*/
private String GR_ITEM;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class QueryPickingRequest {
private String PLANT_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
/**
* 重置转库单据
*/
@Data
public class ResetMoveTicketRequest {
//工厂代码
private String PLANT_CODE;
//单据号
private String TICKET_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
import java.util.List;
/**
* 料卷退PK 请求
*/
@Data
public class ReturnToPKRequest {
// 厂区
private String PLANT_CODE;
// 挑料单号
private String PICKING_ID;
// 料号
private String MATERIAL_CODE;
// 目标储位
private String BIN_CODE;
// 料卷清单
private List<String> REEL_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class ShipCancelUpshelfRequest {
//工厂代码
private String PLANT_CODE;
//ODN单号
private String TICKET_CODE;
//标签码
private String PALLET_ID;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
import java.util.List;
@Data
public class TicketPostRequest {
// 厂区
private String PLANT_CODE;
// 单据号
private String TICKET_CODE;
// 单据行
private String TICKET_ITEM;
// 料卷清单
private List<String> REEL_LIST;
// 数量
private int QTY;
// 储位号
private String BIN_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.Data;
import java.util.List;
/**
* Tower发料 请求
*/
@Data
public class TowerIssueRequest {
// 厂区
private String PLANT_CODE;
// 挑料单号
private String PICKING_ID;
// 料号
private String MATERIAL_CODE;
// 库别
private String WAREHOUSE_CODE;
// 制造商
private String BRAND;
// 面别
private String FACE;
// 批次码
private String BATCH_CODE;
// 料卷清单
private List<String> REEL_LIST;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* UpdateBin 更新储位 请求
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UpdateBinRequest {
/**
* 工厂代码
*/
private String PLANT_CODE;
/**
* 储位代码
*/
private String BIN_CODE;
/**
* 储位库别
*/
private String WAREHOUSE_CODE;
/**
* 存储类型
*/
private String STORAGE_TYPE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.request;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 校验箱号信息
*/
@Data
@AllArgsConstructor
public class ValidCartonRequest {
// 请求ID
private String REQUEST_ID;
// 卡板ID
private String CARTON_ID;
// 厂区
private String PLANT;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 电子料入退库 结果
*/
@Data
public class BackToWarehouseResult {
/**
*厂区
*/
private String PLANT_CODE;
/**
*标签码
*/
private String LABEL_ID;
/**
*料号
*/
private String MATERIAL_CODE;
/**
*库别
*/
private String WAREHOUSE_CODE;
/**
*数量
*/
private int LABEL_QTY;
/**
*厂商代码
*/
private String VENDOR_CODE;
/**
*厂商名称
*/
private String VENDOR_NAME;
/**
*版本
*/
private String VERSION;
/**
*单据日期
*/
private String GR_DATE;
/**
*异动日期
*/
private String TRAN_DATE;
/**
*状态
*/
private int STATUS;
/**
*仓管员
*/
private String KEEPER_CODE;
/**
*制造商
*/
private String BRAND;
/**
*单位
*/
private String UNIT;
/**
*批次号
*/
private String BATCH_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
@Data
public class BinMoveResult {
//厂区
private String PLANT_CODE;
// 描述: 标签码
private String LABEL_ID;
// 描述: 料号
private String MATERIAL_CODE;
// 描述: 库别
private String WAREHOUSE_CODE;
// 描述: 数量
private Integer LABEL_QTY;
// 描述: 厂商代码
private String VENDOR_CODE;
// 描述: 厂商名称
private String VENDOR_NAME;
// 描述: 版本
private String VERSION;
// 描述: 单据日期
private String GR_DATE;
// 描述: 异动日期
private String TRAN_DATE;
// 描述: 状态
private int STATUS;
// 描述: 仓管员
private String KEEPER_CODE;
// 描述: 制造商
private String BRAND;
// 描述: 单位
private String UNIT;
// 描述: 批次号
private String BATCH_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 箱去向接口
*/
@Data
public class CartonDstResult {
//目的地
private String DESTINATION;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
import java.util.List;
/**
* PPS 按栈板获取箱清单
*/
@Data
public class CheckPalletCartonResult {
// 箱号
private String CARTON_ID;
// 工厂代码
private String PLANT;
private String PART_NO;
// 库别
private String WAREHOUSE_CODE;
// 原产国
private String COO;
private List<String> PALLET_PACK_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 获取不可用(HOLD)库存信息
*/
@Data
public class FetchHoldInfoResult {
// 箱号
private String CARTON_ID;
// 工厂代码
private String PLANT_CODE;
// 批次
private String BATCH_CODE;
// 库存栈板号
private String PALLET_ID;
// 料号
private String MATERIAL_CODE;
// HOLD数量
private Integer HOLD;
// 数量(PCS)
private Integer QTY;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 拉取转库单据
*/
@Data
public class FetchMoveTicketResult {
// 单据行号
private String TICKET_ITEM;
// 料号
private String MATERIAL_CODE;
// 源工厂
private String SRC_PLANT;
// 目的工厂
private String DST_PLANT;
// 来源库别
private String SRC_WAREHOUSE;
// 目的库别
private String DST_WAREHOUSE;
// 来源批次
private String SRC_BATCH;
// 目的批次
private String DST_BATCH;
// 数量
private int QTY;
// 移动类型
private String MOVE_TYPE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 用栈板号获取箱信息清单
*/
@Data
public class FetchPalletCartonResult {
// 箱号
private String CARTON_ID;
// 工厂代码
private String PLANT;
// 料号
private String PN;
// 库存栈板号
private String PALLET_ID;
// 机种
private String MODEL_FAMILY;
// 库别
private String WAREHOUSE_CODE;
// 状态
private String STATUS;
// 是否 HOLD
private String HOLD;
// 数量(PCS)
private Integer QTY;
// 包规
private Integer FULL_QTY;
// 版本号
private String OS_VERSION;
// 原产国
private String COO;
// 包装类型
private String PACK_TYPE;
// 生产日期
private String CREATE_AT;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 获取栈板信息 结果
*/
@Data
public class FetchPalletInfoResult {
// 厂区
private String PLANT;
// 库存栈板号
private String PALLET_ID;
// 机种
private String MODEL_FAMILY;
// 库别
private String WAREHOUSE_CODE;
// 生产日期
private String CREATED_TIME;
// 储位号
private String BIN_CODE;
// 数量
private int QTY;
// 批次
private String BATCH_CODE;
// 料号
private String MATERIAL_CODE;
// 物料类型
private String MATERIAL_TYPE;
// 原产国
private String COO;
// 版本
private String OS_VERSION;
// 包装类型
private String PACK_TYPE;
// 厂区(重复字段名,可能需要根据实际情况调整)
private String PLANT_CODE;
// 状态
private int STATUS;
// 禁用
private int HOLD;
// 失败说明
private String ERROR;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
@Data
public class FetchShipmentInfoResult {
/**
* 行ID
*/
private String RTV_ID;
/**
* 工厂代码
*/
private String PLANT_CODE;
/**
* 出货单号
*/
private String TICKET_CODE;
/**
* 单据行号
*/
private String TICKET_ITEM;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 物料类型
*/
private String MATERIAL_TYPE;
/**
* 仓库代码
*/
private String WAREHOUSE_CODE;
/**
* 供应商代码
*/
private String VENDOR_CODE;
/**
* 单据数量
*/
private int QTY;
/**
* 单位
*/
private String UNIT;
/**
* 状态
*/
private String STATUS;
/**
* 原数量
*/
private int ORIGIN_QTY;
/**
* 制造商
*/
private int MANUFACTURE;
/**
* 报关模式
*/
private String IMPORT_MODE;
/**
* 进口编号
*/
private String IMPORT_CODE;
/**
* 收货工厂
*/
private String SHIP_TO;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 获取可用库存
*/
@Data
public class FetchValidInvResult {
// 料号
private String MATERIAL_CODE;
// 库存栈板号
private String PALLET_ID;
// 数量
private int QTY;
// 扣货
private int HOLD;
// 储位
private String BIN_CODE;
// 库别
private String WAREHOUSE;
// 状态
private int STATUS;
// 批次
private String BATCH_CODE;
// 时间
private String CREATED_AT;
// 原产国
private String COO;
// 版本
private String OS_VERSION;
// 包装类型
private String PACK_TYPE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* GetPickingItems结果实体类
*/
@Data
public class GetPickingItemsResult {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 行号
*/
private String ITEM_ID;
/**
* 挑料单号
*/
private String PICKING_ID;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 库别
*/
private String WAREHOUSE;
/**
* 需求数量
*/
private int REQ_QTY;
/**
* 需求卷数
*/
private int REQ_REEL;
/**
* 传承数量
*/
private int CP_QTY;
/**
* 传承卷数
*/
private int CP_REEL;
/**
* 已发数量
*/
private int ISSUED_QTY;
/**
* 已发卷数
*/
private int ISSUED_REEL;
/**
* 退回数量
*/
private int RET_QTY;
/**
* 面别
*/
private String FACE;
/**
* 批次
*/
private String BATCH_CODE;
/**
* 制造商
*/
private String BRAND;
/**
* 创建日期
*/
private String CREATE_AT;
/**
* 更新日期
*/
private String UPDATE_AT;
private String MO;
private String BIN_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 集货单锁定料箱查询
*/
@Data
public class LockedCartonQueryResult {
// 出货单号
private String SHIPMENT_ID;
// 出货栈板号
private String PALLET_NO;
// 行号
private String ROW_ID;
// 箱号
private String CARTON_ID;
// 锁定时间
private String CREATE_AT;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 按GR生成标签码并上架 返回
*/
@Data
public class NewLabelToCellResult {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 标签码
*/
private String LABEL_ID;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 库别
*/
private String WAREHOUSE_CODE;
/**
* 数量
*/
private int LABEL_QTY;
/**
* 厂商代码
*/
private String VENDOR_CODE;
/**
* 厂商名称
*/
private String VENDOR_NAME;
/**
* 版本
*/
private String VERSION;
/**
* 单据日期
*/
private String GR_DATE;
/**
* 异动日期
*/
private String TRAN_DATE;
/**
* 状态
*/
private int STATUS;
/**
* 仓管员
*/
private String KEEPER_CODE;
/**
* 制造商
*/
private String BRAND;
/**
* 单位
*/
private String UNIT;
/**
* 批次号
*/
private String BATCH_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 栈板合并
*/
@Data
public class PalletMergeResult {
// 库存栈板号
private String PALLET_ID;
// 机种
private String MODEL_FAMILY;
// 库别
private String WAREHOUSE_CODE;
// 生产日期
private String CREATED_TIME;
// 储位号
private String BIN_CODE;
// 数量
private int QTY;
// 批次
private String BATCH_CODE;
// 料号
private String MATERIAL_CODE;
// 物料类型
private String MATERIAL_TYPE;
// 原产国
private String COO;
// 版本
private String OS_VERSION;
// 包装类型
private String PACK_TYPE;
// 厂区
private String PLANT_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 栈板同库别转移
*/
@Data
public class PalletUpdateResult {
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
/**
* PickingIssue返回
*/
public class PickingIssueResult {
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* QueryBin返回
*/
@Data
public class QueryBinResult {
/**
* 储位代码
*/
private String BIN_CODE;
/**
* 储位类型
*/
private String BIN_TYPE;
/**
* 储位状态
*/
private int BIN_STATUS;
/**
* 容量
*/
private int BIN_SIZE;
/**
* 仓管员
*/
private String BIN_KEEPER;
/**
* 储位库别
*/
private String WAREHOUSE_CODE;
/**
* 存储类型
*/
private String STORAGE_TYPE;
/**
* 储位厂区
*/
private String PLANT_CODE;
/**
* 储位楼栋
*/
private String BUILDING;
/**
* 储位分类
*/
private String BIN_CATEGORY;
/**
* 储位点位
*/
private String BIN_ZONE;
/**
* 储位楼层
*/
private String BIN_FLOOR;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* QueryGr结果实体类
*/
@Data
public class QueryGrResult {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 单据号
*/
private String GR_CODE;
/**
* 单据行
*/
private String GR_ITEM;
/**
* 单据日期
*/
private String GR_DATE;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 厂商代码
*/
private String VENDOR_CODE;
/**
* 厂商名称
*/
private String VENDOR_NAME;
/**
* 制造商
*/
private String BRAND;
/**
* 仓管员
*/
private String KEEPER_CODE;
/**
* 库别
*/
private String WAREHOUSE_CODE;
/**
* 批次
*/
private String BATCH_CODE;
/**
* 数量
*/
private int GR_QTY;
/**
* 单据状态
*/
private int POST_STATUS;
/**
* 异动日期
*/
private String POST_DATE;
/**
* 原单据
*/
private String ORIGIN_GR;
/**
* 保税标识
*/
private String MATERIAL_BONDED;
/**
* A级物料
*/
private String MATERIAL_CONTROL;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* GR过账状态查询 返回
*/
@Data
public class QueryGrStatusResult {
/**
* 厂区
*/
private String PLANT_CODE;
/**
* 单据号
*/
private String GR_CODE;
/**
* 单据行
*/
private String GR_ITEM;
/**
* 单据日期
*/
private String GR_DATE;
/**
* 料号
*/
private String MATERIAL_CODE;
/**
* 厂商代码
*/
private String VENDOR_CODE;
/**
* 厂商名称
*/
private String VENDOR_NAME;
/**
* 状态
*/
private String STATUS;
/**
* 供应商
*/
private String BRAND;
/**
* 仓管员
*/
private String KEEPER_CODE;
/**
* 库别
*/
private String WAREHOUSE_CODE;
/**
* 过账代码
*/
private String UD_CODE;
/**
* 过账数量
*/
private String UD_QTY;
/**
* 单据数量
*/
private String LOT_QTY;
/**
* 过账时间
*/
private String POST_DATE;
/**
* 批次
*/
private String BATCH_CODE;
/**
* 原单据
*/
private String ORIGIN_GR;
/**
* 保税标识
*/
private String MATERIAL_BONDED;
/**
* A级物料
*/
private String MATERIAL_CONTROL;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
import java.util.Date;
/**
* 查询挑料单列表
*/
@Data
public class QueryPickingResult {
// 厂区
private String PLANT_CODE;
// 挑料单号
private String PICKING_ID;
// 线别
private String LINE;
// 状态
private Integer STATUS;
// 原单号
private String ORG_PICKING_ID;
// SMT料号
private String SMT_PN;
// 创建时间
private String CREATE_AT;
// 更新时间
private String UPDATE_AT;
// 更新工号
private String UPDATE_BY;
// 更新姓名
private String UPDATE_NAME;
//出库按钮是否置灰
private boolean checkOut = true;
//工单状态
private int orderStatus;
//当前任务盘数
private int taskReelCount = 0;
//当前任务已完成盘数
private int finishedReelCount = 0;
//工单开始时间
private Date startDate;
//工单结束时间
private Date endDate;
//工单完成时间
private Date finishDate;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* 料卷退PK 返回
*/
@Data
public class ReturnToPKResult {
// 厂区
private String PLANT_CODE;
// 标签码
private String LABEL_ID;
// 料号
private String MATERIAL_CODE;
// 库别
private String WAREHOUSE_CODE;
// 数量
private int LABEL_QTY;
// 厂商代码
private String VENDOR_CODE;
// 厂商名称
private String VENDOR_NAME;
// 版本
private String VERSION;
// 单据日期
private String GR_DATE;
// 异动日期
private String TRAN_DATE;
// 状态
private int STATUS;
// 仓管员
private String KEEPER_CODE;
// 制造商
private String BRAND;
// 单位
private String UNIT;
// 批次号
private String BATCH_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
@Data
public class TicketPostResult {
// 厂区
private String PLANT_CODE;
// 标签码
private String LABEL_ID;
// 料号
private String MATERIAL_CODE;
// 库别
private String WAREHOUSE_CODE;
// 数量
private int LABEL_QTY;
// 厂商代码
private String VENDOR_CODE;
// 厂商名称
private String VENDOR_NAME;
// 版本
private String VERSION;
// 单据日期
private String GR_DATE;
// 异动日期
private String TRAN_DATE;
// 状态
private int STATUS;
// 仓管员
private String KEEPER_CODE;
// 制造商
private String BRAND;
// 单位
private String UNIT;
// 批次号
private String BATCH_CODE;
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
/**
* UpdateBin 更新储位 返回
*/
@Data
public class UpdateBinResult {
}
package com.neotel.smfcore.custom.luxsan.api.bean.result;
import lombok.Data;
import java.util.Date;
/**
* 校验箱号信息 返回
*/
@Data
public class ValidCartonResult {
// 厂区
private String PLANT;
// 箱号
private String CARTON_ID;
// 栈板号
private String PALLET_ID;
// 料号
private String PN;
// 机种
private String MODEL_FAMILY;
// 物料类型
private String MATERIAL_TYPE;
// 状态
private int STATUS;
// 库别
private String WAREHOUSE_CODE;
// 是否HOLD
private int HOLD;
// 数量
private int QTY;
// 满箱数量
private int FULL_QTY;
// 包装类型
private String PACK_TYPE;
// 生产日期
private String CREATE_AT;
// 区域
private String REGION;
}
package com.neotel.smfcore.custom.luxsan.api.bean.util;
import lombok.Data;
@Data
public class LuxsanApiResult {
private String MSGTY;
private String MSGTX;
private String DATA;
}
package com.neotel.smfcore.custom.luxsan.api.enums;
/**
* Bin 枚举
*/
public class BinEnum {
//R:货架, P:栈板, C:箱格, B:胶框, T:料塔
public static final String STORAGE_TYPE_R = "R";
public static final String STORAGE_TYPE_P = "P";
public static final String STORAGE_TYPE_C = "C";
public static final String STORAGE_TYPE_B = "B";
public static final String STORAGE_TYPE_T = "T";
//0:空闲, 1:占用, 2:锁定
public static final int BIN_STATUS_0 = 0;
public static final int BIN_STATUS_1 = 1;
public static final int BIN_STATUS_2 = 2;
}
package com.neotel.smfcore.custom.luxsan.api.enums;
public class LuxsanApiEnum {
public static final String SUCCESS = "S";
public static final String ERROR = "E";
}
package com.neotel.smfcore.custom.luxsan.api.enums;
public class PalletEnum {
//待入库
public static final int PENDING_STORAGE = 1;
//单据分配
public static final int DOCUMENT_ALLOCATION = 2;
//已挑料
public static final int MATERIAL_PICKED = 3;
//在库库存
public static final int INVENTORY_IN_WAREHOUSE = 4;
//出货已备料
public static final int SHIPMENT_MATERIALS_PREPARED = 5;
//已过账,待上架
public static final int POSTED_AND_PENDING_SHELVING = 6;
//已出货
public static final int SHIPPED = 7;
//已经生成栈板,待过账
public static final int PENDING_POSTING = 8;
//出货取消
public static final int SHIPMENT_CANCELLATION = 9;
}
package com.neotel.smfcore.custom.luxsan.api.enums;
public class QueryGrEnum {
// -1:已撤消,0:新单据, 1:已过账/待上架
public static final int cancel = -1;
public static final int newDoc = 0;
public static final int pending = 1;
public static String getStatusName(int status) {
if (status == cancel) {
return "已撤消";
} else if (status == newDoc) {
return "新单据";
} else if (status == pending) {
return "已过账/待上架";
}
return "";
}
}
package com.neotel.smfcore.custom.luxsan.api.enums;
public class QueryGrStatusEnum {
//status: -1 Cancel:已撤消,0 New:新单据, 1 PostIn:已过账/待上架
// 2 AllocBin:已分配/待上架 3 In:已上架/已结案 4 AllocInv:已分配待下架
// 5 Picked:已下架待过账 6 PostOut:已下架已过账 7 Out:已发料已结案
// 8 AllocLack:已分配但缺料 10 LackBin:未分配无库存 11 AllocAuto:已分配未完成
public static final String cancel = "Cancel";
public static final String newDoc = "New";
public static final String postIn = "PostIn";
public static final String allocBin = "AllocBin";
public static final String in = "In";
public static final String allocInv = "AllocInv";
public static final String picked = "Picked";
public static final String postOut = "PostOut";
public static final String out = "Out";
public static final String allocLack = "AllocLack";
public static final String lackBin = "LackBin";
public static final String allocAuto = "AllocAuto";
public static String getStatusName(String status) {
if (status.equals(cancel)) {
return "已撤消";
} else if (status.equals(newDoc)) {
return "新单据";
} else if (status.equals(postIn)) {
return "已过账/待上架";
} else if (status.equals(allocBin)) {
return "已分配/待上架";
} else if (status.equals(in)) {
return "已上架/已结案";
} else if (status.equals(allocInv)) {
return "已分配待下架";
} else if (status.equals(picked)) {
return "已下架待过账";
} else if (status.equals(postOut)) {
return "已下架已过账";
} else if (status.equals(out)) {
return "已发料已结案";
} else if (status.equals(allocLack)) {
return "已分配但缺料";
} else if (status.equals(lackBin)) {
return "未分配无库存";
} else if (status.equals(allocAuto)) {
return "已分配未完成";
}
return "";
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.common.bean.request;
import lombok.Data;
@Data
public class SendTicketInfo {
// 厂区
private String PLANT_CODE;
// 单据号
private String TICKET_CODE;
// 单据行号
private String TICKET_ITEM;
// 单据类型
private String TICKET_TYPE;
// 异动类型
private String MOVE_TYPE;
// 料号
private String MATERIAL_CODE;
// 数量
private Double QTY;
// 仓管员
private String KEEPER_CODE;
// 来源厂区
private String SRC_PLANT;
// 来源库别
private String SRC_WAREHOUSE;
// 目的厂区
private String DST_PLANT;
// 目的库别
private String DST_WAREHOUSE;
// 过账数量
private Double POST_QTY;
// 过账日期
private String POST_DATE;
// 状态
private String STATUS;
// 分配数量
private Double ALLOCATE_QTY;
// 挑料数量
private Double PICKED_QTY;
// 源批次
private String SRC_BATCH;
// 目的批次
private String DST_BATCH;
}
package com.neotel.smfcore.custom.luxsan.factory_c.common.bean.result;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class WcsResult {
@JsonProperty("MSGTY")
private String MSGTY;
@JsonProperty("MSGTX")
private String MSGTX;
}
package com.neotel.smfcore.custom.luxsan.factory_c.common.controller;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.*;
import com.neotel.smfcore.custom.luxsan.api.bean.result.*;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/luxsanApi")
public class LuxsanApiController {
@ApiOperation("3 GR查询")
@RequestMapping("/queryGr")
@AnonymousAccess
public List<QueryGrResult> queryGr(@RequestBody QueryGrRequest request) {
return LuxsanApi.queryGr(request);
}
@ApiOperation("5 GR过账状态查询")
@RequestMapping("/queryGrStatus")
@AnonymousAccess
public List<QueryGrStatusResult> queryGrStatus(@RequestBody QueryGrStatusRequest request) {
return LuxsanApi.queryGrStatus(request);
}
@ApiOperation("6 按GR生成标签码并上架")
@RequestMapping("/newLabelToCell")
@AnonymousAccess
public NewLabelToCellResult newLabelToCell(@RequestBody NewLabelToCellRequest request) {
return LuxsanApi.newLabelToCell(request);
}
@ApiOperation("11 查询挑料单列表")
@RequestMapping("/queryPicking")
@AnonymousAccess
public List<QueryPickingResult> queryPicking(@RequestBody QueryPickingRequest request) {
return LuxsanApi.queryPicking(request);
}
@ApiOperation("12 获取挑料单详情")
@RequestMapping("/getPickingItems")
@AnonymousAccess
public List<GetPickingItemsResult> getPickingItems(@RequestBody GetPickingItemsRequest request) {
return LuxsanApi.getPickingItems(request);
}
@ApiOperation("14 Picking发料")
@RequestMapping("/pickingIssue")
@AnonymousAccess
public void pickingIssue(@RequestBody PickingIssueRequest request) {
LuxsanApi.pickingIssue(request);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.common.controller;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.factory_c.common.bean.request.SendTicketInfo;
import com.neotel.smfcore.custom.luxsan.factory_c.common.bean.result.WcsResult;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@Slf4j
@RequestMapping("/wcs")
@RestController
public class WcsController {
@ApiOperation("单据推送")
@RequestMapping("/SendTicketInfo")
@AnonymousAccess
public WcsResult sendTicketInfo(@RequestBody List<SendTicketInfo> paramList){
log.info("收到单据推送请求信息为:"+ JSON.toJSONString(paramList));
WcsResult wcsResult = new WcsResult();
wcsResult.setMSGTX("S");
wcsResult.setMSGTY("接收成功");
return wcsResult;
}
@ApiOperation("砍单通知自动仓")
@RequestMapping("/cancelOdn")
@AnonymousAccess
public WcsResult cancelOdn(@RequestBody Map<String, String> paramMap) {
String plantCode = paramMap.get("PLANT_CODE");
String ticketCode = paramMap.get("TICKET_CODE");
log.info("wms砍单通知自动仓,工厂代码为:" + plantCode + ",出货单为:" + ticketCode);
String msgtx = "S";
String msgty = "";
try {
String resultStr = HttpHelper.postJson(LuxsanApi.cancelOdnUrl, paramMap);
log.info("wms砍单通知自动仓,转发结果为:" + resultStr);
} catch (ApiException e) {
e.printStackTrace();
msgtx = "E";
msgty = e.getMessage();
}
WcsResult wcsResult = new WcsResult();
wcsResult.setMSGTX(msgtx);
wcsResult.setMSGTY(msgty);
return wcsResult;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean;
import lombok.Data;
/**
* 料串需要绑定的GR信息
*/
@Data
public class BindGrInfo {
//料串信息
private String materialStr;
// 厂区
private String plantCode;
// 单据号
private String grCode;
// 单据行
private String grItem;
// 单据日期
private String grDate;
// 料号
private String materialCode;
// 厂商代码
private String vendorCode;
// 厂商名称
private String vendorName;
// 状态
private String status;
// 供应商
private String brand;
// 仓管员
private String keeperCode;
// 库别
private String warehouseCode;
// 过账代码
private String udCode;
// 过账数量
private Double udQty;
// 单据数量
private Double lotQty;
// 过账时间
private String postDate;
// 批次
private String batchCode;
// 原单据
private String originGr;
// 保税标识
private String materialBonded;
// A级物料
private String materialControl;
private int h;
private int w;
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean;
import lombok.Data;
import java.util.Map;
@Data
public class CtuStatus {
//ctu Id
private String ctuId;
//key为抽屉号, value为
private Map<String,String> usageMap;
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class TicketReturn {
private String material;
private String ticketCode;
private String ticketItem;
private String warehouseCode;
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto;
import lombok.Data;
import java.util.Date;
/**
* @author sunke
* @date 2024/5/9 10:42
*/
@Data
public class CtuTask {
private String id;
/**
* 箱子号
*/
private String boxCode;
/**
* 任务类型, 入库=1或出库=2
*/
private int taskType;
/**
* 起点位置
* 料箱送到库位时,可能的值为In1_DischargeHole,In2_DischargeHole,Out1_DischargeHole,Out2_DischargeHole
* 料箱从库位取出时,值为库位号
*/
private String fromLoc;
/**
* 目的地位置
* 料箱送到库位时, 值为库位号
* 料箱从库位取出时,可能的值为In1_FeedingInlet,In2_FeedingInlet,Out1_FeedingInlet,Out2_FeedingInlet,In_FeedingInlet(入料机构入料口,不指定哪个入料机构),Out_FeedingInlet(出料机构入料口,不指定哪个出料机构)
*/
private String toLoc;
private Date createDate;
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchMoveTicketResult;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class FetchMoveTicketDto {
// 单据行号
private String ticketItem;
// 料号
private String materialCode;
// 源工厂
private String srcPlant;
// 目的工厂
private String dstPlant;
// 来源库别
private String srcWarehouse;
// 目的库别
private String dstWarehouse;
// 来源批次
private String srcBatch;
// 目的批次
private String dstBatch;
// 数量
private int qty;
// 移动类型
private String moveType;
public static FetchMoveTicketDto convertFetchMoveTicketDto(FetchMoveTicketResult result) {
FetchMoveTicketDto dto = new FetchMoveTicketDto();
dto.setTicketItem(result.getTICKET_ITEM());
dto.setMaterialCode(result.getMATERIAL_CODE());
dto.setSrcPlant(result.getSRC_PLANT());
dto.setDstPlant(result.getDST_PLANT());
dto.setSrcWarehouse(result.getSRC_WAREHOUSE());
dto.setDstWarehouse(result.getDST_WAREHOUSE());
dto.setSrcBatch(result.getSRC_BATCH());
dto.setDstBatch(result.getDST_BATCH());
dto.setQty(result.getQTY());
dto.setMoveType(result.getMOVE_TYPE());
return dto;
}
public static List<FetchMoveTicketDto> convertFetchMoveTicketDto(List<FetchMoveTicketResult> resultList) {
List<FetchMoveTicketDto> dtoList = new ArrayList<>();
for (FetchMoveTicketResult result : resultList) {
dtoList.add(convertFetchMoveTicketDto(result));
}
return dtoList;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto;
import com.google.common.collect.Lists;
import com.neotel.smfcore.custom.luxsan.api.bean.result.GetPickingItemsResult;
import lombok.Data;
import java.util.List;
@Data
public class GetPickingItemsDto {
/**
* 厂区
*/
private String plantCode;
/**
* 行号
*/
private String itemId;
/**
* 挑料单号
*/
private String pickingId;
/**
* 料号
*/
private String materialCode;
/**
* 库别
*/
private String warehouse;
/**
* 需求数量
*/
private int reqQty;
/**
* 需求卷数
*/
private int reqReel;
/**
* 传承数量
*/
private int cpQty;
/**
* 传承卷数
*/
private int cpReel;
/**
* 已发数量
*/
private int issuedQty;
/**
* 已发卷数
*/
private int issuedReel;
/**
* 退回数量
*/
private int retQty;
/**
* 面别
*/
private String face;
/**
* 批次
*/
private String batchCode;
/**
* 制造商
*/
private String brand;
/**
* 创建日期
*/
private String createAt;
/**
* 更新日期
*/
private String updateAt;
private String mo;
private String binCode;
public static GetPickingItemsDto convertGetPickingItemsResultDto(GetPickingItemsResult result){
GetPickingItemsDto getPickingItemsResultDto = new GetPickingItemsDto();
getPickingItemsResultDto.setPlantCode(result.getPLANT_CODE());
getPickingItemsResultDto.setItemId(result.getITEM_ID());
getPickingItemsResultDto.setPickingId(result.getPICKING_ID());
getPickingItemsResultDto.setMaterialCode(result.getMATERIAL_CODE());
getPickingItemsResultDto.setWarehouse(result.getWAREHOUSE());
getPickingItemsResultDto.setReqQty(result.getREQ_QTY());
getPickingItemsResultDto.setReqReel(result.getREQ_REEL());
getPickingItemsResultDto.setCpQty(result.getCP_QTY());
getPickingItemsResultDto.setCpReel(result.getCP_REEL());
getPickingItemsResultDto.setIssuedQty(result.getISSUED_QTY());
getPickingItemsResultDto.setIssuedReel(result.getISSUED_REEL());
getPickingItemsResultDto.setRetQty(result.getRET_QTY());
getPickingItemsResultDto.setFace(result.getFACE());
getPickingItemsResultDto.setBatchCode(result.getBATCH_CODE());
getPickingItemsResultDto.setBrand(result.getBRAND());
getPickingItemsResultDto.setCreateAt(result.getCREATE_AT());
getPickingItemsResultDto.setUpdateAt(result.getUPDATE_AT());
getPickingItemsResultDto.setMo(result.getMO());
getPickingItemsResultDto.setBinCode(result.getBIN_CODE());
return getPickingItemsResultDto;
}
public static List<GetPickingItemsDto> convertGetPickingItemsResultDto(List<GetPickingItemsResult> resultList) {
List<GetPickingItemsDto> getPickingItemsResultDtolist=Lists.newArrayList();
for (GetPickingItemsResult getPickingItemsResult :resultList) {
getPickingItemsResultDtolist.add(convertGetPickingItemsResultDto(getPickingItemsResult));
}
return getPickingItemsResultDtolist;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrResult;
import com.neotel.smfcore.custom.luxsan.api.enums.QueryGrEnum;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class QueryGrDto {
/**
* 厂区
*/
private String plantCode;
/**
* 单据号
*/
private String grCode;
/**
* 单据行
*/
private String grItem;
/**
* 单据日期
*/
private String grDate;
/**
* 料号
*/
private String materialCode;
/**
* 厂商代码
*/
private String vendorCode;
/**
* 厂商名称
*/
private String vendorName;
/**
* 制造商
*/
private String brand;
/**
* 仓管员
*/
private String keeperCode;
/**
* 库别
*/
private String warehouseCode;
/**
* 批次
*/
private String batchCode;
/**
* 数量
*/
private int grQty;
/**
* 单据状态
*/
private String postStatus;
/**
* 异动日期
*/
private String postDate;
/**
* 原单据
*/
private String originGr;
/**
* 保税标识
*/
private String materialBonded;
/**
* A级物料
*/
private String materialControl;
public static QueryGrDto convert(QueryGrResult result){
QueryGrDto queryGrResultDto = new QueryGrDto();
queryGrResultDto.setPlantCode(result.getPLANT_CODE());
queryGrResultDto.setGrCode(result.getGR_CODE());
queryGrResultDto.setGrItem(result.getGR_ITEM());
queryGrResultDto.setGrDate(result.getGR_DATE());
queryGrResultDto.setMaterialCode(result.getMATERIAL_CODE());
queryGrResultDto.setVendorCode(result.getVENDOR_CODE());
queryGrResultDto.setVendorName(result.getVENDOR_NAME());
queryGrResultDto.setBrand(result.getBRAND());
queryGrResultDto.setKeeperCode(result.getKEEPER_CODE());
queryGrResultDto.setWarehouseCode(result.getWAREHOUSE_CODE());
queryGrResultDto.setBatchCode(result.getBATCH_CODE());
queryGrResultDto.setGrQty(result.getGR_QTY());
queryGrResultDto.setPostStatus(QueryGrEnum.getStatusName(result.getPOST_STATUS()));
queryGrResultDto.setPostDate(result.getPOST_DATE());
queryGrResultDto.setOriginGr(result.getORIGIN_GR());
queryGrResultDto.setMaterialBonded(result.getMATERIAL_BONDED());
queryGrResultDto.setMaterialControl(result.getMATERIAL_CONTROL());
return queryGrResultDto;
}
public static List<QueryGrDto> convert(List<QueryGrResult> queryGrResultList){
List<QueryGrDto> resultList = new ArrayList<>();
for (QueryGrResult queryGrResult : queryGrResultList) {
resultList.add(convert(queryGrResult));
}
return resultList;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrStatusResult;
import com.neotel.smfcore.custom.luxsan.api.enums.QueryGrStatusEnum;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class QueryGrStatusDto {
/**
* 厂区
*/
private String plantCode;
/**
* 单据号
*/
private String grCode;
/**
* 单据行
*/
private String grItem;
/**
* 单据日期
*/
private String grDate;
/**
* 料号
*/
private String materialCode;
/**
* 厂商代码
*/
private String vendorCode;
/**
* 厂商名称
*/
private String vendorName;
/**
* 状态
*/
private String status;
/**
* 供应商
*/
private String brand;
/**
* 仓管员
*/
private String keeperCode;
/**
* 库别
*/
private String warehouseCode;
/**
* 过账代码
*/
private String udCode;
/**
* 过账数量
*/
private String udQty;
/**
* 单据数量
*/
private String lotQty;
/**
* 过账时间
*/
private String postDate;
/**
* 批次
*/
private String batchCode;
/**
* 原单据
*/
private String originGr;
/**
* 保税标识
*/
private String materialBonded;
/**
* A级物料
*/
private String materialControl;
public static QueryGrStatusDto convertQueryGrStatusResultDto(QueryGrStatusResult result){
QueryGrStatusDto queryGrStatusResultDto = new QueryGrStatusDto();
queryGrStatusResultDto.setPlantCode(result.getPLANT_CODE());
queryGrStatusResultDto.setGrCode(result.getGR_CODE());
queryGrStatusResultDto.setGrItem(result.getGR_ITEM());
queryGrStatusResultDto.setGrDate(result.getGR_DATE());
queryGrStatusResultDto.setMaterialCode(result.getMATERIAL_CODE());
queryGrStatusResultDto.setVendorCode(result.getVENDOR_CODE());
queryGrStatusResultDto.setVendorName(result.getVENDOR_NAME());
queryGrStatusResultDto.setStatus(QueryGrStatusEnum.getStatusName(result.getSTATUS()));
queryGrStatusResultDto.setBrand(result.getBRAND());
queryGrStatusResultDto.setKeeperCode(result.getKEEPER_CODE());
queryGrStatusResultDto.setWarehouseCode(result.getWAREHOUSE_CODE());
queryGrStatusResultDto.setUdCode(result.getUD_CODE());
queryGrStatusResultDto.setUdQty(result.getUD_QTY());
queryGrStatusResultDto.setLotQty(result.getLOT_QTY());
queryGrStatusResultDto.setPostDate(result.getPOST_DATE());
queryGrStatusResultDto.setBatchCode(result.getBATCH_CODE());
queryGrStatusResultDto.setOriginGr(result.getORIGIN_GR());
queryGrStatusResultDto.setMaterialBonded(result.getMATERIAL_BONDED());
queryGrStatusResultDto.setMaterialControl(result.getMATERIAL_CONTROL());
return queryGrStatusResultDto;
}
public static List<QueryGrStatusDto> convertQueryGrStatusResultDto(List<QueryGrStatusResult> queryGrStatusResultList){
List<QueryGrStatusDto> resultList = new ArrayList<>();
for (QueryGrStatusResult queryGrStatusResult : queryGrStatusResultList) {
resultList.add(convertQueryGrStatusResultDto(queryGrStatusResult));
}
return resultList;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryPickingResult;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class QueryPickingDto {
// 厂区
private String plantCode;
// 挑料单号
private String pickingId;
// 线别
private String line;
// 状态
private String status;
// 原单号
private String orgPickingId;
// SMT料号
private String smtPn;
// 创建时间
private String createAt;
// 更新时间
private String updateAt;
// 更新工号
private String updateBy;
// 更新姓名
private String updateName;
//出库按钮是否置灰
private boolean checkOut = true;
//工单状态
private int orderStatus;
//当前任务盘数
private int taskReelCount = 0;
//当前任务已完成盘数
private int finishedReelCount = 0;
//工单开始时间
private Date startDate;
//工单结束时间
private Date endDate;
//工单完成时间
private Date finishDate;
public static QueryPickingDto convertQueryPickingResultDto(QueryPickingResult result){
QueryPickingDto queryPickingResultDto = new QueryPickingDto();
queryPickingResultDto.setPlantCode(result.getPLANT_CODE());
queryPickingResultDto.setPickingId(result.getPICKING_ID());
queryPickingResultDto.setLine(result.getLINE());
queryPickingResultDto.setStatus(result.getSTATUS() == 4 ? "关闭" : "其他:可发料");
queryPickingResultDto.setOrgPickingId(result.getORG_PICKING_ID());
queryPickingResultDto.setSmtPn(result.getSMT_PN());
queryPickingResultDto.setCreateAt(result.getCREATE_AT());
queryPickingResultDto.setUpdateAt(result.getUPDATE_AT());
queryPickingResultDto.setUpdateBy(result.getUPDATE_BY());
queryPickingResultDto.setUpdateName(result.getUPDATE_NAME());
queryPickingResultDto.setOrderStatus(result.getOrderStatus());
queryPickingResultDto.setTaskReelCount(result.getTaskReelCount());
queryPickingResultDto.setFinishedReelCount(result.getFinishedReelCount());
queryPickingResultDto.setStartDate(result.getStartDate());
queryPickingResultDto.setEndDate(result.getEndDate());
queryPickingResultDto.setFinishDate(result.getFinishDate());
queryPickingResultDto.setCheckOut(result.isCheckOut());
return queryPickingResultDto;
}
public static List<QueryPickingDto> convertQueryPickingResultDto(List<QueryPickingResult> result) {
List<QueryPickingDto> resultList = new ArrayList<>();
for (QueryPickingResult queryPickingResult : result) {
resultList.add(convertQueryPickingResultDto(queryPickingResult));
}
return resultList;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.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.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.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.NewLabelToCellRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.PickingIssueRequest;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.BindGrInfo;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.CtuTask;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.LiteorderCheckType;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BinCacheUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.MaterialUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "设备通信")
@Slf4j
@RestController
@RequestMapping("/cdevice")
public class CDeviceController {
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private CodeResolve codeResolve;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IComponentManager componentManager;
@Autowired
private SmfApi smfApi;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
@Autowired
private ILiteOrderManager liteOrderManager;
@ApiOperation("获取料盘尺寸信息")
@RequestMapping("/partNumberComponent")
@AnonymousAccess
public ResultBean partNumberComponent(@RequestBody Map<String, String> paramMap) {
Map<String, Object> resultMap = new HashMap<>();
String codeStr = paramMap.get("codeStr");
//log.info(codeStr + ":获取尺寸信息");
if (MaterialUtil.bindGr(codeStr)) {
BindGrInfo bindGrInfo = MaterialUtil.getBindGrInfo(codeStr);
if (bindGrInfo != null) {
log.info(codeStr + ":绑定GR信息为:" + JSON.toJSONString(bindGrInfo));
resultMap.put("w", bindGrInfo.getW());
resultMap.put("h", bindGrInfo.getH());
}
}
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("物料放入料格")
@RequestMapping("/putInMaterialBin")
@AnonymousAccess
public synchronized ResultBean putInMaterialBin(@RequestBody Map<String, String> paramMap) {
String binCodeStr = paramMap.get("binCode"); //料格
String codeStr = paramMap.get("codeStr"); //物料条码
String materialStr = paramMap.get("materialStr"); //料串信息
//判断入参是否为空
if (StringUtils.isEmpty(binCodeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料格信息"});
}
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"物料信息"});
}
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
//判断条码是否正常
Barcode barcode = null;
try{
barcode = codeResolve.resolveOneValideBarcode(codeStr);
}catch (ValidateException ve){
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
}
log.info("料串["+materialStr+"]上的物料["+barcode.getBarcode()+"] 准备放入料格["+binCodeStr+"]");
//判断是否存在料箱中
if (StringUtils.isNotEmpty(barcode.getPosName())) {
log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
ResultBean resultBean = ResultBean.newErrorResult(101, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
resultBean.setData(barcode.getPosName());
return resultBean;
}
//判断是否绑定其他料串
if (!MaterialUtil.bindInfo(materialStr)) {
return ResultBean.newErrorResult(-1, "", materialStr + "没有任何绑定信息");
}
//调用禁用料信息
barcode = smfApi.canPutInAfterResolve(barcode);
//获取库别
String warhouseCode = MaterialUtil.getWarhouseCode(materialStr);
barcode.setWarehouseCode(warhouseCode);
String soucre = "";
if (MaterialUtil.bindGr(materialStr)) {
soucre = MaterialUtil.getBindGrInfo(materialStr).getGrCode();
}
//判断料格是否正常
Barcode boxBarcode = null;
StoragePos inPos = null;
try{
String boxStr = BoxHandleUtil.getBoxStr(binCodeStr);
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if(inPos != null){
boxBarcode = inPos.getBarcode();
//log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料["+barcode.getBarcode()+"]放入了料格中");
}
}catch (ValidateException ve){
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料格条码不正确:" + binCodeStr);
}
if(boxBarcode != null){
//判断隔口是否可以放入
if (BinCacheUtil.canPutInBinCode(binCodeStr, warhouseCode)) {
if (MaterialUtil.bindGr(materialStr)){
BindGrInfo bindGrInfo = MaterialUtil.getBindGrInfo(materialStr);
LuxsanApi.newLabelToCell(new NewLabelToCellRequest(
CommonUtil.plantCode,
Arrays.asList(bindGrInfo.getUdCode()),
barcode.getAmount(),
binCodeStr,Arrays.asList(barcode.getFullCode())
));
//将GR日期设置为生产日期
Date grDate = DateUtil.getNoTimeDate(bindGrInfo.getGrDate());
barcode.setProduceDate(grDate);
}
barcode.setPosName(binCodeStr);
barcode.setWarehouseCode(warhouseCode);
barcode.setBarSource(soucre);
barcode.setSeq(BoxHandleUtil.getSeq(boxBarcode,binCodeStr)+1);
barcode.setPutInTime(System.currentTimeMillis());
barcode = barcodeManager.save(barcode);
generatePutInTask(barcode, boxBarcode,OP_STATUS.FINISHED.name());
boxBarcode.updateSubCodes(barcode);
boxBarcode.setAmount(boxBarcode.getAmount()+barcode.getAmount());
barcodeManager.save(boxBarcode);
if(inPos != null){
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
//把当前料箱设置成正在入库的料箱
Map<String,String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_EXECUTINGPUTIN_BOX);
if (cacheMap == null){
cacheMap = new HashMap<>();
}
cacheMap.put(boxBarcode.getBarcode(),boxBarcode.getBarcode());
dataCache.updateCache(CacheNameUtil.CHCHE_EXECUTINGPUTIN_BOX,cacheMap);
return ResultBean.newOkResult("");
}
}
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCodeStr);
}
@ApiOperation("料格已放满")
@RequestMapping("/finishPutInMaterialBin")
@AnonymousAccess
public ResultBean finishPutInMaterialBin(@RequestBody Map<String, String> paramMap) {
String binCodeStr = paramMap.get("binCode");
String materialStr = paramMap.get("materialStr");
log.info("料格已经放满,收到料格信息为" + binCodeStr + ",料串信息为:" + materialStr);
String boxStr = BoxHandleUtil.getBoxStr(binCodeStr);
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
//该料格有出库时, 需要清理此字段
boxBarcode.updateExtraData(binCodeStr,"FULL");
barcodeManager.saveBarcode(boxBarcode);
StoragePos inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (inPos != null){
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
return ResultBean.newOkResult("");
}
@ApiOperation("清空料串信息")
@RequestMapping("/clearMaterialStr")
@AnonymousAccess
public ResultBean clearMaterialStr(String materialStr) {
if (MaterialUtil.bindGr(materialStr)) {
log.info(materialStr+"绑定GR信息,需要清空");
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
cacheMap.remove(materialStr);
dataCache.updateCache(CacheNameUtil.CACHE_BIND_GR, cacheMap);
}
return ResultBean.newOkResult("");
}
@ApiOperation("料箱入库,生成任务")
@RequestMapping("/boxIntoPos")
@AnonymousAccess
public synchronized ResultBean boxIntoPos(String boxStr, String boxLoc) {
log.info("["+boxLoc + "]位置的料箱入库开始生成任务:"+boxStr);
if (StringUtils.isEmpty(boxStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
// if (StringUtils.isEmpty(boxLoc)) {
// return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "料箱位置参数boxLoc不能为空");
// }
//1.判断有没有正在执行的任务
List<DataLog> taskList = taskService.getAllTasks();
for (DataLog dataLog : taskList) {
if (boxStr.startsWith(dataLog.getBarcode())) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
if (dataLog.isPutInTask()) {
return ResultBean.newOkResult(dataLog);
} else {
return ResultBean.newErrorResult(-1, "", boxStr + "已经有出库任务,请先完成出库任务");
}
}
}
}
//2.获取空库位
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
StoragePos pos = locOnePos(boxBarcode);
if(pos == null){
return ResultBean.newErrorResult(-1, "", boxStr + "未找到可用库位");
}
//4.生成入库任务
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog dataLog = taskService.addPutInTaskToExecute(storage, boxBarcode, pos, boxLoc);
Map<String,String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_EXECUTINGPUTIN_BOX);
if (cacheMap == null){
cacheMap = new HashMap<>();
}
cacheMap.remove(boxBarcode.getBarcode());
dataCache.updateCache(CacheNameUtil.CHCHE_EXECUTINGPUTIN_BOX,cacheMap);
return ResultBean.newOkResult(dataLog);
}
private StoragePos locOnePos(Barcode boxBarcode){
//判断信息是否在已经在库位中(出入库只改变料箱位置状态,不从StoragePos表中清除)
StoragePos pos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (pos != null){
return pos;
}
List<String> cidList = new ArrayList<>();
List<Storage> storageList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
storageList.add(storage);
cidList.add(storage.getCid());
}
pos = taskService.findEmptyPosForPutIn(storageList, boxBarcode, "", "");
if (pos == null) {
log.info(boxBarcode.getBarcode() + "未找到可用库位");
return null;
}else{
log.info("料箱["+boxBarcode.getBarcode()+"]信息加入库位["+pos.getPosName()+"]中");
pos.setBarcode(boxBarcode);
pos.setUsed(true);
storagePosManager.save(pos);
//3.锁定库位
Storage storage = dataCache.getStorageById(pos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(boxBarcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(pos.getPosName());
reelLocInfo.setLockPosId(pos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
log.info("[" + boxBarcode.getBarcode() + "]库位锁定失败,暂停入库");
return null;
}
}
return pos;
}
@ApiOperation("获取出库任务")
@RequestMapping("/checkOutTask")
@AnonymousAccess
public List<DataLog> boxPutIn() {
List<DataLog> needSendList = new ArrayList<>();
List<DataLog> dataLogList = taskService.getAllTasks();
for (DataLog dataLog : dataLogList) {
if (dataLog.isWait() && dataLog.isCheckOutTask()) {
needSendList.add(dataLog);
}
}
return needSendList;
}
@ApiOperation("获取每个料格出的物料信息")
@RequestMapping("/getBoxOutInfo")
@AnonymousAccess
public synchronized ResultBean getBoxOutInfo(String boxStr) {
Map<String, Long> resultMap = new HashMap<>();
Barcode barcode = codeResolve.resolveOneValideBarcode(boxStr);
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
resultMap = subCodeList.stream().filter(Barcode::isOut).collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
}
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("料格中的物料开始出库")
@RequestMapping("/reelCheckOut")
@AnonymousAccess
public synchronized ResultBean reelCheckOut(@RequestParam("boxStr") String boxStr,
@RequestParam("isNormal") boolean isNormal) {
//1.解析条码内容
//Barcode binCode = codeResolve.resolveOneValideBarcode(boxStr);
//解析料箱信息
String box = BoxHandleUtil.getBoxStr(boxStr);
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(box);
StoragePos inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if(inPos != null){
boxBarcode = inPos.getBarcode();
//log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料从料格中出库");
}
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
//2.获取要出库的code
int seq = BoxHandleUtil.getSeq(boxBarcode, boxStr);
Barcode barcode = null;
for (Barcode subCode : subCodeList) {
if (seq == subCode.getSeq() && boxStr.equals(subCode.getPosName())) {
barcode = subCode;
break;
}
}
//3.判断barcode是否为空
if (barcode == null) {
return ResultBean.newErrorResult(-1, "", "未找到可以出库的物料");
}
List<Barcode> barcodeList = new ArrayList<>();
for (Barcode subCode : subCodeList) {
if (boxStr.equals(subCode.getPosName())){
barcodeList.add(subCode);
}
}
//判断barcode是否为需要出库的
if (!barcode.isOut()){
log.info(barcode.getBarcode()+"不是要出库的料盘");
Barcode needOutBarcode = null;
for (Barcode subCode : barcodeList) {
if (subCode.isOut()){
needOutBarcode = subCode;
break;
}
}
if (needOutBarcode != null){
String orderItemId = needOutBarcode.getOrderItemId();
needOutBarcode.setOrderItemId("");
needOutBarcode.setOut(false);
log.info(needOutBarcode.getBarcode()+"需要改成不需要出库");
barcodeManager.save(needOutBarcode);
boxBarcode.updateSubCodes(needOutBarcode);
barcode.setOut(true);
barcode.setOrderItemId(orderItemId);
log.info(barcode.getBarcode()+"改成要出库,orderItemId为:"+orderItemId);
}
}
//4.开始生成出库任务
log.info(barcode.getBarcode() + "从" + boxStr + "出库,序列号为:" + seq);
DataLog dataLog = new DataLog(new Storage(), barcode, new StoragePos());
String orderItemId = barcode.getOrderItemId();
LiteOrderItem orderItem = null;
if (StringUtils.isNotEmpty(orderItemId)) {
orderItem = liteOrderItemManager.get(orderItemId);
}
String orderNo = "";
String orderId = "";
int checkType = -1;
String pkItemId = "";
String face = "";
String brand = "";
String batchCode = "";
if(orderItem != null){
orderNo = orderItem.getOrderNo();
orderId = orderItem.getOrderId();
pkItemId = orderItem.getItemId();
face = orderItem.getFace();
brand = orderItem.getBrand();
if (!"N/A".equals(orderItem.getBatchCode())){
batchCode = orderItem.getBatchCode();
}
LiteOrder order = liteOrderManager.get(orderItem.getOrderId());
if (order != null){
checkType = order.getCheckType();
}
}
dataLog.setSubSourceId(orderItemId);
dataLog.setSourceId(orderId);
dataLog.setSourceName(orderNo);
dataLog.setType(OP.CHECKOUT);
dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLog.setPosName(boxStr);
dataLog.setNormal(isNormal);
taskService.updateFinishedTask(dataLog);
//有出库,此料格就去除满格标志
boxBarcode.updateExtraData(barcode.getPosName(),null);
boxBarcode.removeFromSubCodes(barcode);
barcodeManager.save(boxBarcode);
if(inPos != null){
//为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
//清理条码档案信息
barcode.setPosName("");
barcode.setOut(false);
barcode.setOrderId("");
barcode.setOrderItemId("");
barcode.setBarSource("");
barcodeManager.saveBarcode(barcode);
//通知WMS
if (checkType == LiteorderCheckType.PICKING_CHECKOUT){
LuxsanApi.pickingIssue(new PickingIssueRequest(CommonUtil.plantCode,orderNo,pkItemId,barcode.getPartNumber()
,barcode.getWarehouseCode(),brand,face,batchCode,Arrays.asList(barcode.getBarcode())));
}
return ResultBean.newOkResult("");
}
//
@ApiOperation("修改任务状态")
@RequestMapping("/updateTaskStatus")
@AnonymousAccess
public ResultBean updateTaskStatus(@RequestBody Map<String, String> paramMap) {
String boxStr = paramMap.get("boxStr");
String statusStr = paramMap.get("statusStr");
//1.判断任务是否存在
DataLog task = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (boxStr.startsWith(dataLog.getBarcode())) {
if (!dataLog.isCancel() && !dataLog.isFinished()) {
task = dataLog;
break;
}
}
}
if (task == null) {
return ResultBean.newErrorResult(-1, "smfcore.task.notExist", "任务不存在");
}
statusStr = statusStr.toUpperCase();
String taskType = "入库";
if(task.isCheckOutTask()){
taskType = "出库";
}
log.info("更新料箱[" + boxStr + "]的"+taskType+"任务["+task.getId()+"]状态为:" + statusStr);
//2.判断更新状态和当前状态任务是否相同
if (task.getStatus().equals(statusStr)) {
return ResultBean.newErrorResult(-1, "smfcore.taskStatusHasUpdate", "任务{0}已经修改状态", new String[]{task.getBarcode()});
}
task.setStatus(statusStr);
//3.判断是出库,还是入库任务
if (task.isPutInTask()) {
if (OP_STATUS.FINISHED.name().equals(statusStr)) {
BoxHandleUtil.intoPos(task);
ReelLockPosUtil.removeReelLockPosInfo(task.getBarcode());
} else {
taskService.updateQueueTask(task);
}
} else {
//4.如果是出库任务
if (OP_STATUS.EXECUTING.name().equals(statusStr)) {
taskService.updateQueueTask(task);
} else {
if (!task.isOutFromPos()) {
BoxHandleUtil.outFromPos(task);
task.setOutFromPos(true);
}
taskService.updateFinishedTask(task);
}
}
return ResultBean.newOkResult("");
}
@ApiOperation("根据料箱获取目的地")
@RequestMapping("/getTargetByBox")
@AnonymousAccess
public ResultBean getTargetByBox(String boxStr){
if (StringUtils.isEmpty(boxStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.isPutInTask() && !dataLog.isFinished() && !dataLog.isCancel()){
if (boxStr.startsWith(dataLog.getBarcode())){
return ResultBean.newOkResult(dataLog.getPosName());
}
}
}
return ResultBean.newErrorResult(-1,"","未找到"+boxStr+"的入库库位");
}
@ApiOperation("入料机构获取可用料格")
@RequestMapping("/validBin")
@AnonymousAccess
public ResultBean validBin(@RequestBody Map<String,String> paramMap){
String stackerId = paramMap.get("stackerId");
String binListStr = paramMap.get("binList");
List<String> validBinList = new ArrayList<String>();
log.info("入料机构获取料串["+stackerId+"]的可用料格["+binListStr+"]");
BindGrInfo bindGrInfo = MaterialUtil.getBindGrInfo(stackerId);
if(bindGrInfo == null){
return ResultBean.newErrorResult(-1,"error.nobind","料串["+stackerId+"]未绑定GR");
}
Barcode stackerBarcode = new Barcode();
stackerBarcode.setBarcode(stackerId);
stackerBarcode.setPartNumber(bindGrInfo.getMaterialCode());
stackerBarcode.setProvider(bindGrInfo.getBrand());
//将GR日期设置为生产日期
Date grDate = DateUtil.getNoTimeDate(bindGrInfo.getGrDate());
stackerBarcode.setProduceDate(grDate);
String warhouseCode = MaterialUtil.getWarhouseCode(stackerId);
stackerBarcode.setWarehouseCode(warhouseCode);
String[] binList = binListStr.split(",");
for (String binId : binList) {
String boxStr = BoxHandleUtil.getBoxStr(binId);
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
//为料箱分配一个库位,直接放到库位中, 如果没有库位, 那么这个料箱不允许使用
StoragePos pos = locOnePos(boxBarcode);
if(pos != null){
String canPutIn = canMaterialPutInBin(stackerBarcode,boxBarcode,binId);
if(canPutIn.isEmpty()){
validBinList.add(binId);
}else{
log.info(canPutIn);
}
}
}
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("validBinList",validBinList);
return ResultBean.newOkResult(dataMap);
}
@ApiOperation("呼叫空箱")
@RequestMapping("/callEmptyBox")
@AnonymousAccess
public ResultBean callEmptyBox(String size,String outLet){
log.info("开始呼叫空箱,尺寸为:"+size+",出口位置为:"+outLet);
String resultStr = BoxHandleUtil.callEmptyBox(size,outLet);
if (StringUtils.isEmpty(resultStr)){
return ResultBean.newErrorResult(-1,"","未找到可用料箱");
}
return ResultBean.newOkResult(resultStr);
}
@ApiOperation("物料放入料格,生成入库任务")
@RequestMapping("/reelToBox")
@AnonymousAccess
public ResultBean reelToBox(@RequestBody Map<String, String> paramMap) {
String binCodeStr = paramMap.get("binCode"); //料格
String codeStr = paramMap.get("codeStr"); //物料条码
String materialStr = paramMap.get("materialStr"); //料串信息
//判断入参是否为空
if (StringUtils.isEmpty(binCodeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料格信息"});
}
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"物料信息"});
}
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
//判断条码是否正常
Barcode barcode = null;
try {
barcode = codeResolve.resolveOneValideBarcode(codeStr);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
}
log.info("料串[" + materialStr + "]上的物料[" + barcode.getBarcode() + "] 准备放入料格[" + binCodeStr + "]");
//判断是否存在料箱中
/*if (StringUtils.isNotEmpty(barcode.getPosName())) {
log.info(barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
ResultBean resultBean = ResultBean.newErrorResult(101, "", barcode.getBarcode() + "已经存在料格" + barcode.getPosName());
resultBean.setData(barcode.getPosName());
return resultBean;
}*/
//判断是否绑定其他料串
if (!MaterialUtil.bindInfo(materialStr)) {
return ResultBean.newErrorResult(-1, "", materialStr + "没有任何绑定信息");
}
//调用禁用料信息
barcode = smfApi.canPutInAfterResolve(barcode);
//获取库别
String warhouseCode = MaterialUtil.getWarhouseCode(materialStr);
//判断料格是否正常
Barcode boxBarcode = null;
try {
String boxStr = BoxHandleUtil.getBoxStr(binCodeStr);
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料格条码不正确:" + binCodeStr);
}
if (boxBarcode != null) {
//判断隔口是否可以放入
if (BinCacheUtil.canPutInBinCode(binCodeStr, warhouseCode)) {
//把当前料箱设置成正在入库的料箱
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_EXECUTINGPUTIN_BOX);
if (cacheMap == null) {
cacheMap = new HashMap<>();
}
cacheMap.put(boxBarcode.getBarcode(), boxBarcode.getBarcode());
dataCache.updateCache(CacheNameUtil.CHCHE_EXECUTINGPUTIN_BOX, cacheMap);
return ResultBean.newOkResult("");
}
}
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不可以放到料格:" + binCodeStr);
}
@ApiOperation("物料放入料格,完成入库任务")
@RequestMapping("/finishedReelToBox")
@AnonymousAccess
public ResultBean finishedReelToBox(@RequestBody Map<String, String> paramMap) {
String binCodeStr = paramMap.get("binCode"); //料格
String codeStr = paramMap.get("codeStr"); //物料条码
String materialStr = paramMap.get("materialStr"); //料串信息
//判断入参是否为空
if (StringUtils.isEmpty(binCodeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料格信息"});
}
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"物料信息"});
}
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
//判断条码是否正常
Barcode barcode = null;
try {
barcode = codeResolve.resolveOneValideBarcode(codeStr);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg());
}
log.info("料串["+materialStr+"]上的物料["+barcode.getBarcode()+"] 放入料格完成["+binCodeStr+"]");
//判断料格是否正常
Barcode boxBarcode = null;
StoragePos inPos = null;
try {
String boxStr = BoxHandleUtil.getBoxStr(binCodeStr);
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (inPos != null) {
boxBarcode = inPos.getBarcode();
//log.error("流程异常:料箱["+boxStr+"]在库位["+inPos.getPosName()+"],但物料["+barcode.getBarcode()+"]放入了料格中");
}
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), "料格条码不正确:" + binCodeStr);
}
DataLog task = null;
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (barcode.getBarcode().equals(queueTask.getBarcode())) {
if (queueTask.isPutInTask()) {
task = queueTask;
break;
}
}
}
if (task != null) {
if (!binCodeStr.equals(task.getPosName())){
return ResultBean.newErrorResult(-1,"",binCodeStr+"与当前任务的料格"+task.getPosName()+"不匹配");
}
barcode.setPosName(task.getPosName());
barcode.setSeq(BoxHandleUtil.getSeq(boxBarcode,binCodeStr)+1);
barcode.setPutInTime(System.currentTimeMillis());
boxBarcode.updateSubCodes(barcode);
boxBarcode.setAmount(boxBarcode.getAmount() + barcode.getAmount());
boxBarcode.setReelAmount(boxBarcode.getReelAmount() + 1);
barcodeManager.save(barcode);
barcodeManager.save(boxBarcode);
if (inPos != null) {
//流程异常时,为保证数据一致性, pos中的box barcode也需要更新
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
task.setStatus(OP_STATUS.FINISHED.name());
taskService.removeQueueTask(task);
taskService.updateFinishedTask(task);
return ResultBean.newOkResult("");
}
return ResultBean.newErrorResult(-1, "", codeStr + "未找到对应的任务");
}
@ApiOperation("修改料格已用高度")
@RequestMapping("/updateBinCodeHeigt")
@AnonymousAccess
public ResultBean updateBinCodeHeigt(@RequestBody Map<String, Integer> paramMap) {
Barcode boxBarcode = null;
for (String binCode : paramMap.keySet()) {
if (boxBarcode == null) {
String boxStr = BoxHandleUtil.getBoxStr(binCode);
boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
}
boxBarcode.updateHeightMap(binCode, paramMap.get(binCode));
}
barcodeManager.saveBarcode(boxBarcode);
StoragePos inPos = storagePosManager.getByBarcode(boxBarcode.getBarcode());
if (inPos != null) {
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
return ResultBean.newOkResult("");
}
@ApiOperation("获取料格已用高度")
@RequestMapping("/getBinCodeHeigt")
@AnonymousAccess
public ResultBean updateBinCodeHeigt(String boxStr) {
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
return ResultBean.newOkResult(boxBarcode.getHeightMap());
}
@ApiOperation("更新入料机构缓存")
@RequestMapping("updateMaterPutInCache")
@AnonymousAccess
public ResultBean updateMaterPutInCache(@RequestParam("number") String number,
@RequestParam("boxStr") String boxStr,
@RequestParam("loc") String loc) {
Map<String, Map<String, String>> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MATERIAL_PUTIN_CACHE);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
Map<String, String> usageMap = cacheMap.get(number);
if (usageMap == null) {
usageMap = new ConcurrentHashMap<>();
}
usageMap.put(boxStr, loc);
cacheMap.put(number, usageMap);
dataCache.updateCache(CacheNameUtil.CHCHE_MATERIAL_PUTIN_CACHE, cacheMap);
return ResultBean.newOkResult("");
}
@ApiOperation("移除入料机构缓存")
@RequestMapping("removeMaterPutInCache")
@AnonymousAccess
public ResultBean removeMaterPutInCache(@RequestParam("number") String number,
@RequestParam("boxStr") String boxStr) {
Map<String, Map<String, String>> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MATERIAL_PUTIN_CACHE);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
Map<String, String> usageMap = cacheMap.get(number);
if (usageMap == null) {
usageMap = new ConcurrentHashMap<>();
}
usageMap.remove(boxStr);
cacheMap.put(number, usageMap);
dataCache.updateCache(CacheNameUtil.CHCHE_MATERIAL_PUTIN_CACHE, cacheMap);
return ResultBean.newOkResult("");
}
/**
* 验证物料是否可以放入料格:
* 1 料格未满 2 料格中若有物料,必须料号,供应商,库别,过账日期一致才可放入
* @return
*/
public String canMaterialPutInBin(Barcode reelBarcode, Barcode boxBarcode, String binId){
String isBinFull = boxBarcode.getExtraData(binId);
if(isBinFull != null){
//该料格已放满, 不可以再放料
log.info("料格["+binId+"]已满,不可放入物料["+reelBarcode.getBarcode()+"]");
return "料格["+binId+"]已满,不可放入物料["+reelBarcode.getBarcode()+"]";
}
if (!BinCacheUtil.canPutInBinCode(binId, reelBarcode.getWarehouseCode())) {
return "库别["+reelBarcode.getWarehouseCode()+"]不可放入料格["+binId+"]";
}
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
if(subCodeList != null){
for (Barcode barcode : subCodeList) {
if(barcode.getPosName().equals(binId)){
//因为bin中的物料都是一样的料号,供应商,库别,过账日期,所以只需要找到Bin中的第一个物料进行比对就可以了
if(!barcode.getPartNumber().equals(reelBarcode.getPartNumber())){
return "料格中["+binId+"]物料的料号["+barcode.getPartNumber()+"]与["+reelBarcode.getBarcode()+"]的料号["+reelBarcode.getPartNumber()+"]不一致";
}
if(!barcode.getProvider().equals(reelBarcode.getProvider())){
return "料格中["+binId+"]物料的供应商["+barcode.getProvider()+"]与["+reelBarcode.getBarcode()+"]的供应商["+reelBarcode.getProvider()+"]不一致";
}
if(!barcode.getWarehouseCode().equals(reelBarcode.getWarehouseCode())){
return "料格中["+binId+"]物料的库别["+barcode.getWarehouseCode()+"]与["+reelBarcode.getBarcode()+"]的库别["+reelBarcode.getWarehouseCode()+"]不一致";
}
if(!barcode.getProduceDate().equals(reelBarcode.getProduceDate())){
return "料格中["+binId+"]物料的供应商["+barcode.getProvider()+"]与["+reelBarcode.getBarcode()+"]的供应商["+reelBarcode.getPartNumber()+"]不一致";
}
}
}
}
return "";
}
private void generatePutInTask(Barcode barcode, Barcode boxBarcode,String status) {
DataLog dataLog = new DataLog();
dataLog.setPosId(boxBarcode.getId());
dataLog.setPosName(barcode.getPosName());
dataLog.setBarcode(barcode.getBarcode());
dataLog.setW(barcode.getPlateSize());
dataLog.setH(barcode.getHeight());
dataLog.setPartNumber(barcode.getPartNumber());
dataLog.setNum(barcode.getAmount());
dataLog.setType(OP.PUT_IN);
dataLog.setStatus(status);
dataLog.setBatchInfo(barcode.getBatch());
dataLog.setSourceName(barcode.getBarSource());
dataLog.setWarehouseCode(barcode.getWarehouseCode());
taskService.updateQueueTask(dataLog);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.CtuStatus;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.CtuTask;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.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 java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Api(tags = "Ctu对接接口")
@Slf4j
@RestController
@RequestMapping("/cdevice")
public class CtuDeviceController {
@Autowired
private TaskService taskService;
@Autowired
private DataCache dataCache;
@ApiOperation("原材料CTU获取线体到架子的入库任务(入满箱或出库后回库)")
@RequestMapping("/lineToShelfTasks")
@AnonymousAccess
public ResultBean lineToShelfTasks() {
List<DataLog> allTasks = taskService.getAllTasks();
List<CtuTask> lineToShelfTaskList = new ArrayList<>();
for (DataLog dataLog : allTasks) {
if (dataLog.isPutInTask()) {
if (dataLog.isWait() || dataLog.isExecuting()) {
CtuTask ctuTask = new CtuTask();
ctuTask.setId(dataLog.getId());
ctuTask.setBoxCode(dataLog.getBarcode());
ctuTask.setTaskType(dataLog.getType());
//起始点为线体传入的boxLoc值
ctuTask.setFromLoc(dataLog.getLoc());
//目的地都为库位
ctuTask.setToLoc(dataLog.getPosName());
ctuTask.setCreateDate(dataLog.getCreateDate());
lineToShelfTaskList.add(ctuTask);
}
}
}
return ResultBean.newOkResult(lineToShelfTaskList);
}
@ApiOperation("原材料CTU获取架子到线体的出库任务(出空箱到入料机构或出库到出料机构)")
@RequestMapping("/shelfToLineTasks")
@AnonymousAccess
public ResultBean shelfToLineTasks() {
List<DataLog> allTasks = taskService.getAllTasks();
allTasks = allTasks.stream().sorted(Comparator.comparing(DataLog::getCreateDate)).collect(Collectors.toList());
List<CtuTask> shelfToLineTaskList = new ArrayList<>();
for (DataLog dataLog : allTasks) {
if (shelfToLineTaskList != null && shelfToLineTaskList.size() >= 6) {
break;
}
if (dataLog.isCheckOutTask()) {
if (dataLog.isWait() || dataLog.isExecuting()) {
CtuTask ctuTask = new CtuTask();
ctuTask.setId(dataLog.getId());
ctuTask.setBoxCode(dataLog.getBarcode());
ctuTask.setTaskType(dataLog.getType());
ctuTask.setFromLoc(dataLog.getPosName());
//手动出空箱的目的地已经设置为In_FeedingInlet, 所以其他出库的未设置目的地的设置为Out_FeedingInlet
String toLoc = dataLog.getLoc();
if (Strings.isBlank(toLoc)) {
toLoc = "Out_FeedingInlet";
}
ctuTask.setToLoc(toLoc);
ctuTask.setCreateDate(dataLog.getCreateDate());
shelfToLineTaskList.add(ctuTask);
}
}
}
return ResultBean.newOkResult(shelfToLineTaskList);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.BrandQtyRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.BrandQtyResult;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryGrRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryGrStatusRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrResult;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrStatusResult;
import com.neotel.smfcore.custom.luxsan.api.enums.QueryGrStatusEnum;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.BindGrInfo;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryGrDto;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryGrStatusDto;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/grPutIn")
public class GrPutInController {
@Autowired
private CodeResolve codeResolve;
@Autowired
private DataCache dataCache;
@Autowired
private IComponentManager componentManager;
@ApiOperation("判断料串是否已经绑定Gr信息")
@RequestMapping("/alreadyBindGr")
@AnonymousAccess
public ResultBean alreadyBindGr(String materialStr) {
//判断GR有没有绑定成功
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null) {
BindGrInfo bindGrInfo = cacheMap.get(materialStr);
if (bindGrInfo != null) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经绑定Gr信息,单据号为:" + bindGrInfo.getGrCode() + ",单据行为:" + bindGrInfo.getGrItem());
}
}
return ResultBean.newOkResult("");
}
@ApiOperation("获取Gr列表")
@RequestMapping("/grList")
@AnonymousAccess
public ResultBean grList(@RequestBody Map<String, String> paramMap) {
//料串
String materialStr = paramMap.get("materialStr");
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
//判断GR有没有绑定成功
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null) {
BindGrInfo bindGrInfo = cacheMap.get(materialStr);
if (bindGrInfo != null) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经绑定Gr信息,单据号为:" + bindGrInfo.getGrCode() + ",单据行为:" + bindGrInfo.getGrItem());
}
}
//物料
String codeStr = paramMap.get("codeStr");
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"条码信息"});
}
//解析条码为barcode
Barcode barcode = codeResolve.resolveCode(codeStr);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效");
}
//查询GR列表
QueryGrRequest request = new QueryGrRequest(CommonUtil.plantCode, barcode.getPartNumber(), barcode.getProvider());
List<QueryGrResult> queryGrResultList = LuxsanApi.queryGr(request);
return ResultBean.newOkResult(QueryGrDto.convert(queryGrResultList));
}
@ApiOperation("获取GR已过账的列表")
@RequestMapping("/grStatus")
@AnonymousAccess
public ResultBean grStatus(@RequestBody Map<String, String> paramMap) {
//料串
String materialStr = paramMap.get("materialStr");
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
//判断GR有没有绑定成功
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null) {
BindGrInfo bindGrInfo = cacheMap.get(materialStr);
if (bindGrInfo != null) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经绑定Gr信息,单据号为:" + bindGrInfo.getGrCode() + ",单据行为:" + bindGrInfo.getGrItem());
}
}
//物料
String codeStr = paramMap.get("codeStr");
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"条码信息"});
}
log.info("获取GR过账信息,料串为:"+materialStr+",物料为:"+codeStr);
//解析条码为barcode
Barcode barcode = codeResolve.resolveCode(codeStr);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noValidCode", "条码无效");
}
QueryGrStatusRequest request = new QueryGrStatusRequest(CommonUtil.plantCode, barcode.getProvider(), barcode.getPartNumber(),"","");
List<QueryGrStatusResult> queryGrStatusList = LuxsanApi.queryGrStatus(request);
return ResultBean.newOkResult(QueryGrStatusDto.convertQueryGrStatusResultDto(queryGrStatusList));
}
@ApiOperation("绑定GR信息")
@RequestMapping("/bindGr")
@AnonymousAccess
public synchronized ResultBean bindGr(@RequestBody BindGrInfo info) {
String materialStr = info.getMaterialStr();
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
if (!materialStr.startsWith("B00")){
return ResultBean.newErrorResult(-1,"","料串信息:"+materialStr+"不是有效的");
}
//判断是不是已过账状态
log.info(info.getGrCode()+"状态为:"+info.getStatus());
if (!info.getStatus().equalsIgnoreCase(QueryGrStatusEnum.getStatusName(QueryGrStatusEnum.postIn))) {
if (!info.getStatus().equalsIgnoreCase(QueryGrStatusEnum.getStatusName(QueryGrStatusEnum.lackBin))) {
return ResultBean.newErrorResult(-1, "", info.getUdCode() + "不是已过账/待上架或者未分配无库存状态,不允许绑定");
}
}
//判断GR有没有绑定成功
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null) {
BindGrInfo bindGrInfo = cacheMap.get(materialStr);
if (bindGrInfo != null) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经绑定Gr信息,单据号为:" + bindGrInfo.getGrCode() + ",单据行为:" + bindGrInfo.getGrItem());
}
} else {
cacheMap = new HashMap<>();
}
//
Component component = componentManager.findByPartNumberAndProvider(info.getMaterialCode(), info.getBrand());
if (component == null) {
BrandQtyResult result = LuxsanApi.brandQtyUrl(new BrandQtyRequest(info.getMaterialCode(), info.getBrand()));
if (result == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的尺寸信息");
}
int reelSize = result.getReel_size();
int h = 0;
if (reelSize == 7) {
h = 8;
} else if (reelSize == 13) {
h = 24;
} else if (reelSize == 15) {
h = 32;
}
info.setW(reelSize);
info.setH(h);
} else {
info.setW(component.getPlateSize());
info.setH(component.getHeight());
}
cacheMap.put(materialStr, info);
dataCache.updateCache(CacheNameUtil.CACHE_BIND_GR, cacheMap);
return ResultBean.newOkResult("");
}
@ApiOperation("GR与料串绑定信息")
@RequestMapping("/bindGrInfo")
@AnonymousAccess
public synchronized ResultBean bindGrInfo() {
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null){
return ResultBean.newOkResult(cacheMap.values());
}
return ResultBean.newOkResult(new ArrayList<>());
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
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 java.util.Map;
@Api(tags = "手动入库")
@Slf4j
@RestController
@RequestMapping("/manual")
public class ManualPutInController {
@Autowired
private DataCache dataCache;
@ApiOperation("手动入库")
@RequestMapping("/putIn")
@AnonymousAccess
public ResultBean putIn(@RequestBody Map<String, String> paramMap) {
String materialStr = paramMap.get("materialStr");
String warehouseCode = paramMap.get("warehouseCode");
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MANUAL_PUTIN);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
if (cacheMap.containsKey(materialStr)) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经在手动入库列表中");
}
cacheMap.put(materialStr, warehouseCode);
dataCache.updateCache(CacheNameUtil.CHCHE_MANUAL_PUTIN, cacheMap);
return ResultBean.newOkResult("");
}
@ApiOperation("手动入库信息")
@RequestMapping("/putInInfo")
@AnonymousAccess
public ResultBean ticketReturnMaterialInfo() {
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MANUAL_PUTIN);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
return ResultBean.newOkResult(cacheMap);
}
@ApiOperation("手动入库信息移除")
@RequestMapping("/removePutInInfo")
@AnonymousAccess
public ResultBean removePutInInfo(String materialStr) {
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MANUAL_PUTIN);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
cacheMap.remove(materialStr);
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import cn.hutool.core.date.DateUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.enums.LITEORDER_SOURCE;
import com.neotel.smfcore.core.order.rest.bean.mapstruct.OrderMapper;
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.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.GetPickingItemsRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryPickingRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.GetPickingItemsResult;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryPickingResult;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.GetPickingItemsDto;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryPickingDto;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums.LiteorderCheckType;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.CheckOutUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@RestController
@RequestMapping("/pkCheckOut")
public class PkCheckOutController {
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private OrderMapper orderMapper;
@Autowired
private TaskService taskService;
@ApiOperation("出库目的地")
@RequestMapping("/checkLoc")
//@AnonymousAccess
public ResultBean checkOutLoc() {
Map<String, String> resultMap = new HashMap<>();
resultMap.put(CheckOutUtil.loc_1F,CheckOutUtil.loc_1F);
resultMap.put(CheckOutUtil.loc_C2,CheckOutUtil.loc_C2);
resultMap.put(CheckOutUtil.loc_3F,CheckOutUtil.loc_3F);
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("查询pk列表")
@RequestMapping("/queryPicking")
//@AnonymousAccess
public ResultBean queryPicking() {
List<QueryPickingResult> pickingResultList = LuxsanApi.queryPicking(new QueryPickingRequest(CommonUtil.plantCode));
for (QueryPickingResult queryPickingResult : pickingResultList) {
String pickingId = queryPickingResult.getPICKING_ID();
LiteOrder liteOrder = liteOrderCache.getLiteOrder(pickingId);
if (liteOrder == null) {
liteOrder = liteOrderManager.findByOrderNo(pickingId);
}
if (liteOrder != null){
queryPickingResult.setOrderStatus(liteOrder.getStatus());
queryPickingResult.setTaskReelCount(liteOrder.getTaskReelCount());
queryPickingResult.setFinishedReelCount(liteOrder.getFinishedReelCount());
queryPickingResult.setStartDate(liteOrder.getStartDate());
queryPickingResult.setEndDate(liteOrder.getEndDate());
queryPickingResult.setFinishDate(liteOrder.getFinishDate());
if (!liteOrder.isTaskFinished() || liteOrder.isClosed()){
queryPickingResult.setCheckOut(false);
}
}
}
return ResultBean.newOkResult(QueryPickingDto.convertQueryPickingResultDto(pickingResultList));
}
@ApiOperation("查询pk详情")
@RequestMapping("/getPickingItems")
//@AnonymousAccess
public ResultBean getPickingItems(@RequestParam("pickingId") String pickingId) {
if (StringUtils.isEmpty(pickingId)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"pickingId"});
}
List<GetPickingItemsResult> pickingItems = LuxsanApi.getPickingItems(new GetPickingItemsRequest(CommonUtil.plantCode, pickingId));
return ResultBean.newOkResult(GetPickingItemsDto.convertGetPickingItemsResultDto(pickingItems));
}
@ApiOperation("pk出库")
@RequestMapping("/checkOut")
//@AnonymousAccess
public ResultBean checkOut(@RequestParam("pickingId") String pickingId,
@RequestParam("confirmExcess") boolean confirmExcess,
@RequestParam("loc") String loc) {
String resultStr = liteOrderCache.hasExecutingOrder();
if (StringUtils.isNotEmpty(resultStr)) {
//throw new ValidateException("","有正在执行的工单,不允许恢复");
return ResultBean.newErrorResult(-1, "", "有正在执行的工单"+resultStr+",不允许出库");
}
List<QueryPickingResult> resultList = LuxsanApi.queryPicking(new QueryPickingRequest(CommonUtil.plantCode));
for (QueryPickingResult result : resultList) {
if (result.getPICKING_ID().equals(pickingId)){
if (result.getSTATUS() == 4) {
return ResultBean.newErrorResult(-1, "", pickingId + "已经关闭,不允许发料");
}
}
}
//1.判断是否存在
LiteOrder liteOrder = liteOrderCache.getLiteOrder(pickingId);
if (liteOrder == null) {
liteOrder = liteOrderManager.findByOrderNo(pickingId);
}
if (liteOrder != null) {
if (!liteOrder.isTaskFinished() && !liteOrder.isNew()) {
return ResultBean.newErrorResult(-1, "", pickingId + "正在执行中,不允许出库");
}
//2.如果存在,改个名字
/*liteOrder.setOrderNo(liteOrder.getOrderNo() + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
liteOrderManager.createWithItems(liteOrder);*/
}
//4.循环新建工单
if(liteOrder == null) {
//3.获取pk详情
GetPickingItemsRequest request = new GetPickingItemsRequest(CommonUtil.plantCode, pickingId);
List<GetPickingItemsResult> pickingItemList = LuxsanApi.getPickingItems(request);
List<LiteOrderItem> itemList = new ArrayList<>();
for (GetPickingItemsResult pkItem : pickingItemList) {
LiteOrderItem item = new LiteOrderItem();
item.setPlantCode(pkItem.getPLANT_CODE());
item.setItemId(pkItem.getITEM_ID());
item.setPickingId(pkItem.getPICKING_ID());
item.setMaterialCode(pkItem.getMATERIAL_CODE());
item.setPn(pkItem.getMATERIAL_CODE());
item.setWarehouse(pkItem.getWAREHOUSE());
item.setWarehouseCode(pkItem.getWAREHOUSE());
item.setReqQty(pkItem.getREQ_QTY());
item.setReqReel(pkItem.getREQ_REEL());
item.setCpQty(pkItem.getCP_QTY());
item.setCpReel(pkItem.getCP_REEL());
item.setIssuedQty(pkItem.getISSUED_QTY());
item.setIssuedReel(pkItem.getISSUED_REEL());
item.setRetQty(pkItem.getRET_QTY());
item.setFace(pkItem.getFACE());
item.setBatchCode(pkItem.getBATCH_CODE());
item.setBrand(pkItem.getBRAND());
item.setCreateAt(pkItem.getCREATE_AT());
item.setUpdateAt(pkItem.getUPDATE_AT());
item.setMo(pkItem.getMO());
item.setBinCode(pkItem.getBIN_CODE());
//需要发料的数量
int needNum = pkItem.getREQ_QTY() - pkItem.getCP_QTY() - pkItem.getISSUED_QTY() + pkItem.getRET_QTY();
item.setNeedNum(needNum);
//需要发料的卷数
int needReelCount = pkItem.getREQ_REEL() - pkItem.getISSUED_REEL() - pkItem.getCP_REEL() + (pkItem.getRET_QTY() > 0 ? 1 : 0);
item.setNeedReelCount(needReelCount);
itemList.add(item);
}
//5.创建工单
LiteOrder newOrder = new LiteOrder();
newOrder.setOrderNo(pickingId);
newOrder.setSource(LITEORDER_SOURCE.OUTTER.name());
newOrder.setConfirmExcess(confirmExcess);
newOrder.setOrderItems(itemList);
newOrder.setLoc(loc);
newOrder.setCheckType(LiteorderCheckType.PICKING_CHECKOUT);
newOrder = liteOrderManager.createWithItems(newOrder);
liteOrderCache.addOrderToMap(newOrder);
}
//6.执行工单出库
String result = liteOrderCache.checkOutLiteOrderOut(pickingId, false, null);
if (StringUtils.isNotEmpty(result)){
return ResultBean.newErrorResult(-1,"", MessageUtils.getText(result,new Locale(SecurityUtils.getCurrentUserLanguage()),result));
}
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@Api(tags = "W2 1F储位移转")
@Slf4j
@RequestMapping("/storTransfer")
@RestController
public class StorTransferController {
@Autowired
private DataCache dataCache;
@ApiOperation("刷料串,进行转移")
@RequestMapping("/inputMaterial")
@AnonymousAccess
public ResultBean inputMaterial(String materialStr, String warehouseCode) {
if (StringUtils.isEmpty(materialStr)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"料串信息"});
}
if (StringUtils.isEmpty(warehouseCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"库别信息"});
}
log.info(materialStr + "进行储位转移,库别为:" + warehouseCode);
//1.判断料仓信息是否在储位转移中
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_STOR_TRANSFER);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
if (cacheMap.get(materialStr) != null) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经在储位转移列表中");
}
cacheMap.put(materialStr, warehouseCode);
dataCache.updateCache(CacheNameUtil.CHCHE_STOR_TRANSFER, cacheMap);
return ResultBean.newOkResult("");
}
@ApiOperation("储位转移信息")
@RequestMapping("/transferInfo")
@AnonymousAccess
public ResultBean transferInfo() {
//1.判断料仓信息是否在储位转移中
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_STOR_TRANSFER);
if (cacheMap == null){
cacheMap = new ConcurrentHashMap<>();
}
return ResultBean.newOkResult(cacheMap);
}
@ApiOperation("移除料串信息")
@RequestMapping("/removeMaterial")
@AnonymousAccess
public ResultBean removeMaterial(String materialStr) {
//1.判断料仓信息是否在储位转移中
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_STOR_TRANSFER);
if (cacheMap == null){
cacheMap = new ConcurrentHashMap<>();
}
cacheMap.remove(materialStr);
return ResultBean.newOkResult(cacheMap);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.util.MessageUtils;
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.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.FetchMoveTicketRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchMoveTicketResult;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.TicketReturn;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.FetchMoveTicketDto;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Api(tags = "931单据领料和932单据退料")
@Slf4j
@RestController
@RequestMapping("/ticket")
public class TicketController {
@Autowired
private DataCache dataCache;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@ApiOperation("拉取单据信息")
@RequestMapping("/fetchTicket")
@AnonymousAccess
public ResultBean fetchTicket(String ticket) {
List<FetchMoveTicketResult> ticketList = LuxsanApi.fetchMoveTicket(new FetchMoveTicketRequest(CommonUtil.plantCode, ticket));
return ResultBean.newOkResult(FetchMoveTicketDto.convertFetchMoveTicketDto(ticketList));
}
@ApiOperation("单据领料")
@RequestMapping("/checkOut")
@AnonymousAccess
public synchronized ResultBean checkOut(String ticket) {
String resultStr = liteOrderCache.hasExecutingOrder();
if (StringUtils.isNotEmpty(resultStr)) {
//throw new ValidateException("","有正在执行的工单,不允许恢复");
return ResultBean.newErrorResult(-1, "", "有正在执行的工单"+resultStr+",不允许出库");
}
if (StringUtils.isEmpty(ticket)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"单据号"});
}
//判断单据号是否存在
LiteOrder liteOrder = liteOrderCache.getLiteOrder(ticket);
if (liteOrder == null) {
liteOrder = liteOrderManager.findByOrderNo(ticket);
}
if (liteOrder != null) {
if (!liteOrder.isTaskFinished() && !liteOrder.isNew()) {
return ResultBean.newErrorResult(-1, "", "单据号" + ticket + "有正在执行的任务");
}
} else {
liteOrder = new LiteOrder();
liteOrder.setOrderNo(ticket);
List<LiteOrderItem> itemList = new ArrayList<>();
List<FetchMoveTicketResult> ticketList = LuxsanApi.fetchMoveTicket(new FetchMoveTicketRequest(CommonUtil.plantCode, ticket));
for (FetchMoveTicketResult result : ticketList) {
LiteOrderItem item = new LiteOrderItem();
item.setNeedNum(result.getQTY());
item.setWarehouseCode(result.getSRC_WAREHOUSE());
item.setPn(result.getMATERIAL_CODE());
itemList.add(item);
}
liteOrder.setOrderItems(itemList);
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
}
String result = liteOrderCache.checkOutLiteOrderOut(ticket, false, null);
if (StringUtils.isNotEmpty(result)){
return ResultBean.newErrorResult(-1,"", MessageUtils.getText(result,new Locale(SecurityUtils.getCurrentUserLanguage()),result));
}
return ResultBean.newOkResult("");
}
@ApiOperation("单据退料")
@RequestMapping("/ticketReturn")
@AnonymousAccess
public ResultBean ticketReturn(@RequestBody Map<String,String> paramMap) {
String ticket = paramMap.get("ticket");
String materialStr = paramMap.get("materialList");
String ticketItem = paramMap.get("ticketItem");
String warehouseCode = paramMap.get("warehouseCode");
Map<String, TicketReturn> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_TICKET_RETURN);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
List<String> materialList = JSONObject.parseArray(materialStr, String.class);
for (String material : materialList) {
if (cacheMap.containsKey(material)) {
return ResultBean.newErrorResult(-1, "", materialStr + "已经绑定单据:" + cacheMap.get(materialStr));
}
}
for (String material : materialList) {
cacheMap.put(material, new TicketReturn(material,ticket,ticketItem,warehouseCode));
}
dataCache.updateCache(CacheNameUtil.CHCHE_TICKET_RETURN, cacheMap);
return ResultBean.newOkResult("");
}
@ApiOperation("单据退料料串绑定信息")
@RequestMapping("/ticketReturnMaterialInfo")
@AnonymousAccess
public ResultBean ticketReturnMaterialInfo() {
Map<String, TicketReturn> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_TICKET_RETURN);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
return ResultBean.newOkResult(cacheMap.values());
}
@ApiOperation("单据退料移除料串绑定信息")
@RequestMapping("/ticketReturnRemoveMaterialInfo")
@AnonymousAccess
public ResultBean ticketReturnRemoveMaterialInfo(String materialStr) {
Map<String, TicketReturn> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_TICKET_RETURN);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
cacheMap.remove(materialStr);
return ResultBean.newOkResult("");
}
@ApiOperation("单据转库")
@RequestMapping("/ticketTransfer")
@AnonymousAccess
public ResultBean ticketTransfer(@RequestBody Map<String, String> paramMap) {
String ticketCode = paramMap.get("ticketCode");
String ticketItem = paramMap.get("ticketItem");
String materialStr = paramMap.get("materialList");
String warehouseCode = paramMap.get("warehouseCode");
log.info("收到单据号:"+ticketCode+",单据行:"+ticketItem+",料串信息为:"+materialStr+",库别为:"+warehouseCode);
List<String> materialList = JSONObject.parseArray(materialStr, String.class);
return ResultBean.newOkResult("");
}
@ApiOperation("单据转库返回结果")
@RequestMapping("/ticketTransferResult")
@AnonymousAccess
public PageData ticketTransferResult(Pageable pageable) {
PageData pageData = new PageData();
List<Map<String,Object>> content = new ArrayList<>();
for (int i = 0; i < 50; i++) {
Map<String,Object> map = new HashMap<>();
map.put("material","123");
map.put("ticketCode","ticketCode");
map.put("ticketItem","ticketItem");
map.put("binCode","binCode");
map.put("result","123");
map.put("warehouseCode","warehouseCode"+i);
content.add(map);
}
pageData.setContent(content);
pageData.setTotalElements(100);
return pageData;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.enums;
public class LiteorderCheckType {
public static final int PICKING_CHECKOUT = 1;
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryBinRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.UpdateBinRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryBinResult;
import com.neotel.smfcore.custom.luxsan.api.enums.BinEnum;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class BinCacheUtil {
private static DataCache dataCache;
private static long binCodeUpdateTime = 0L;
@Autowired
private void setDataCache(DataCache cache){
BinCacheUtil.dataCache = cache;
}
public static boolean canPutInBinCode(String binCode, String warehouseCode) {
Map<String, String> cacheMap = new HashMap<>();
if (binCodeUpdateTime == 0L || (System.currentTimeMillis() - binCodeUpdateTime >= 1000 * 60 * 60)) {
List<QueryBinResult> resultList = LuxsanApi.queryBin(new QueryBinRequest(CommonUtil.plantCode, BinEnum.STORAGE_TYPE_C, BinEnum.BIN_STATUS_0, warehouseCode));
for (QueryBinResult result : resultList) {
cacheMap.put(result.getBIN_CODE(), result.getWAREHOUSE_CODE());
}
List<QueryBinResult> useBinResultList = LuxsanApi.queryBin(new QueryBinRequest(CommonUtil.plantCode, BinEnum.STORAGE_TYPE_C, BinEnum.BIN_STATUS_1, warehouseCode));
for (QueryBinResult result : useBinResultList) {
cacheMap.put(result.getBIN_CODE(), result.getWAREHOUSE_CODE());
}
binCodeUpdateTime = System.currentTimeMillis();
dataCache.updateCache(CacheNameUtil.CHCHE_QUERY_BIN, cacheMap);
} else {
cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_QUERY_BIN);
}
//判断code是否相同
String code = cacheMap.get(binCode);
if (StringUtils.isNotEmpty(code)) {
if (code.equals(warehouseCode)) {
//binCodeUpdateTime = System.currentTimeMillis();
return true;
}/* else {
LuxsanApi.updateBin(new UpdateBinRequest(CommonUtil.plantCode, binCode, warehouseCode, BinEnum.STORAGE_TYPE_C));
cacheMap.put(binCode, warehouseCode);
dataCache.updateCache(CacheNameUtil.CHCHE_QUERY_BIN, cacheMap);
binCodeUpdateTime = System.currentTimeMillis();
return true;
}*/
}
return false;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.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.custom.lizhen.innerBox.enums.ExtendType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Slf4j
@Service
public class BoxHandleUtil {
private static IBarcodeManager barcodeManager;
@Autowired
public void setBarcodeManager(IBarcodeManager manager) {
BoxHandleUtil.barcodeManager = manager;
}
private static IStoragePosManager storagePosManager;
@Autowired
public void setStoragePosManager(IStoragePosManager manager) {
BoxHandleUtil.storagePosManager = manager;
}
private static DataCache dataCache;
@Autowired
public void setDataCache(DataCache cache) {
BoxHandleUtil.dataCache = cache;
}
private static TaskService taskService;
@Autowired
public void setTaskService(TaskService service) {
BoxHandleUtil.taskService = service;
}
public static void intoPos(DataLog opTask) {
//已完成,加入库存,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(opTask.getPosId());
//二维码状态
Barcode barcode = barcodeManager.findByBarcode(opTask.getBarcode());
if (barcode != null) {
barcode.setUsedCount(barcode.getUsedCount() + 1);
barcode.setPutInTime(System.currentTimeMillis());
barcode.setInOpor("");
barcode.setCheckOutDate(null, "");
barcode.setPosName(opTask.getPosName());
barcode.setStatus(BARCODE_STATUS.IN_STORE);
barcode = barcodeManager.save(barcode);
}
storagePos.setBarcode(barcode);
storagePos.setUsed(true);
storagePos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(storagePos);
taskService.moveTaskToFinished(opTask);
taskService.updateFinishedTask(opTask);
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()){
for (Barcode subCode : subCodeList) {
if (subCode.isOut()){
log.info(barcode.getBarcode()+"有要出库的任务,需要重新出库");
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
DataLog dataLog = new DataLog(storage, barcode, storagePos);
dataLog.setType(OP.CHECKOUT);
dataLog.setStatus(OP_STATUS.WAIT.name());
dataLog.setLoc("Out_FeedingInlet");
taskService.addTaskToExecute(dataLog);
break;
}
}
}
}
public static void outFromPos(DataLog opTask) {
//从队列里面移除操作
taskService.removeQueueTask(opTask);
StoragePos storagePos = storagePosManager.get(opTask.getPosId());
Barcode barcode = storagePos.getBarcode();
if (barcode == null) {
log.warn("任务:" + opTask.getId() + " 仓位:" + opTask.getPosName() + " 的 Barcode 为null, 之前可能处理过,结束任务后直接返回");
return;
}
barcode = barcodeManager.get(barcode.getId());
if (barcode != null) {
//二维码状态
barcode.setUsed(true);
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), "");
//barcode.setPosName("");
barcode.setOrderItemId("");
barcode.setOrderId("");
barcode.setLockName("");
barcode.setLockId("");
barcodeManager.save(barcode);
}
storagePos.setBarcode(barcode);
//storagePos.setUsed(false);
storagePosManager.save(storagePos);
log.info("出库完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]");
taskService.moveTaskToFinished(opTask);
}
public static String callEmptyBox(String size,String outLet) {
String box = "";
if ("7".equals(size)) {
box = "C07";
} else if ("13".equals(size)) {
box = "C13";
} else if ("15".equals(size)) {
box = "C15";
}
//排除掉正在使用的仓位
Criteria c = Criteria.where("barcode").exists(true).and("enabled").is(true);//可用
Collection<String> excludePosIds = taskService.excludePosIds();
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c.and("id").nin(excludePosIds);
}
c.and("barcode.partNumber").regex(Pattern.compile(QueryHelp.escapeExprSpecialWord(box), Pattern.CASE_INSENSITIVE));
c.and("barcode.status").is(BARCODE_STATUS.IN_STORE);
List<StoragePos> storagePosList = storagePosManager.findByQuery(new Query(c).with(Sort.by(Sort.Direction.ASC, "barcode.amount")));
StoragePos storagePos = null;
//隔口数量
int num = 0;
if (storagePosList != null && !storagePosList.isEmpty()) {
for (StoragePos pos : storagePosList) {
Barcode barcode = pos.getBarcode();
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList == null || subCodeList.isEmpty()) {
storagePos = pos;
break;
} else {
Map<String, Long> countMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
if ("7".equals(size)) {
int noReelNum = 0;
for (int par = 1; par < 7; par++) {
//箱子+隔口号
String binCode = barcode.getBarcode() + "-0" + par;
if (countMap.get(binCode) == null || countMap.get(binCode) == 0) {
noReelNum = noReelNum + 1;
}
}
if (num < noReelNum) {
num = noReelNum;
storagePos = pos;
}
} else if ("13".equals(size) || "15".equals(size)) {
String binCode = barcode.getBarcode() + "-01";
if (countMap.get(binCode) == null || countMap.get(binCode) == 0){
storagePos = pos;
break;
}
}
}
}
}
if (storagePos != null) {
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
String toLoc = "In_FeedingInlet";
if (StringUtils.isNotEmpty(outLet)){
if ("1".equals(outLet)){
toLoc = "In1_FeedingInlet";
} else if ("2".equals(outLet)){
toLoc = "In2_FeedingInlet";
}
}
generateTask(storage, storagePos.getBarcode(), storagePos, OP.CHECKOUT, OP_STATUS.WAIT.name(), toLoc, ExtendType.STORAGE_CHECKOUT);
return storagePos.getPosName();
}
return "";
}
private static DataLog generateTask(Storage storage, Barcode barcode, StoragePos pos, int type, String status, String loc, int extendType) {
//开始入库任务
DataLog task = new DataLog(storage, barcode, pos);
task.setType(type);
task.setStatus(status);
task.setLoc(loc);
task.setOperator(SecurityUtils.getLoginUsername());
task.setBoxPosName(pos.getPosName());
task.setExtendType(extendType);
if (barcode.getPutInTime() != -1) {
task.setFristPutInDate(new Date(barcode.getPutInTime()));
} else {
task.setFristPutInDate(barcode.getPutInDate());
}
task.setDescribe(barcode.getDescribe());
taskService.addTaskToExecute(task);
return task;
}
public static String getBoxStr(String code) {
if (code.endsWith("A") || code.endsWith("B")) {
code = code.substring(0, code.length() - 1);
code = code + "A";
}
if (code.contains("-")) {
code = code.substring(0, code.indexOf("-"));
code = code + "A";
}
return code;
}
/**
* 获取序列号
* @param boxBarcode
* @param binCode
* @return
*/
public static int getSeq(Barcode boxBarcode,String binCode) {
int seq = 0;
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()){
for (Barcode barcode : subCodeList) {
if (binCode.equals(barcode.getPosName())){
if (seq < barcode.getSeq()){
seq = barcode.getSeq();
}
}
}
}
return seq;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
public class CheckOutUtil {
public static final String loc_C2 = "C2/3F/BG";
public static final String loc_3F = "C2/3F/CG";
public static final String loc_1F = "W2/1F";
}
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.BindGrInfo;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.TicketReturn;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public class MaterialUtil {
private static DataCache dataCache;
@Autowired
private void setDataCache(DataCache cache){
MaterialUtil.dataCache = cache;
}
public static boolean bindInfo(String materialStr) {
return bindGr(materialStr) || storTransfer(materialStr) || ticketReturn(materialStr) || manualPutIn(materialStr);
}
public static String getWarhouseCode(String materialStr) {
if (bindGr(materialStr)){
BindGrInfo bindGrInfo = getBindGrInfo(materialStr);
return bindGrInfo.getWarehouseCode();
} else if (storTransfer(materialStr)){
return getStorTransferInfo(materialStr);
} else if (ticketReturn(materialStr)){
TicketReturn returnInfo = getTicketReturnInfo(materialStr);
return returnInfo.getWarehouseCode();
} else if (manualPutIn(materialStr)){
return getManualPutInInfo(materialStr);
}
return "";
}
//是否绑定gr
public static boolean bindGr(String materialStr) {
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null) {
if (cacheMap.get(materialStr) != null) {
return true;
}
}
return false;
}
public static BindGrInfo getBindGrInfo(String materialStr) {
Map<String, BindGrInfo> cacheMap = dataCache.getCache(CacheNameUtil.CACHE_BIND_GR);
if (cacheMap != null) {
if (cacheMap.get(materialStr) != null) {
return cacheMap.get(materialStr);
}
}
return null;
}
//是否储位转移
public static boolean storTransfer(String materialStr) {
//1.判断料仓信息是否在储位转移中
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_STOR_TRANSFER);
if (cacheMap == null) {
cacheMap = new ConcurrentHashMap<>();
}
if (cacheMap.get(materialStr) != null) {
return true;
}
return false;
}
public static String getStorTransferInfo(String materialStr) {
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_STOR_TRANSFER);
if (cacheMap != null) {
if (cacheMap.get(materialStr) != null) {
return cacheMap.get(materialStr);
}
}
return null;
}
//是否单据退料
public static boolean ticketReturn(String materialStr){
Map<String, TicketReturn> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_TICKET_RETURN);
if (cacheMap != null) {
if (cacheMap.get(materialStr) != null){
return true;
}
}
return false;
}
public static TicketReturn getTicketReturnInfo(String materialStr) {
Map<String, TicketReturn> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_TICKET_RETURN);
if (cacheMap != null) {
if (cacheMap.get(materialStr) != null){
return cacheMap.get(materialStr);
}
}
return null;
}
//是否手动入库
public static boolean manualPutIn(String materialStr) {
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MANUAL_PUTIN);
if (cacheMap != null) {
if (cacheMap.containsKey(materialStr)) {
return true;
}
}
return false;
}
public static String getManualPutInInfo(String materialStr) {
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_MANUAL_PUTIN);
if (cacheMap != null) {
if (cacheMap.get(materialStr) != null) {
return cacheMap.get(materialStr);
}
}
return null;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.third;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
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 java.util.HashMap;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/material/api")
public class MaterialRestController {
public static final String CACHE_MATERIAL_LOC = "CACHE_MATERIAL_LOC";
@Autowired
private DataCache dataCache;
@ApiOperation("更新料串位置")
@RequestMapping("/updateLoc")
@AnonymousAccess
public ResultBean updateLoc(@RequestBody Map<String,String> paramMap){
String materialStr = paramMap.get("materialStr");
String loc = paramMap.get("loc");
//log.info("收到料串位置更新,料串为:"+materialStr+",位置为:"+loc);
Map<String,String> cacheMap = dataCache.getCache(CACHE_MATERIAL_LOC);
if (cacheMap == null){
cacheMap = new HashMap<>();
}
cacheMap.put(materialStr,loc);
dataCache.updateCache(CACHE_MATERIAL_LOC,cacheMap);
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.third;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import lombok.extern.slf4j.Slf4j;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/thirdBarcode")
public class ThirdBarcodeController {
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private CodeResolve codeResolve;
@RequestMapping("/getBarcode")
@AnonymousAccess
public ResultBean getBarcode(@RequestBody Map<String,String> paramMap) {
String codeStr = paramMap.get("codeStr");
Barcode barcode = null;
try {
barcode = codeResolve.resolveOneValideBarcode(codeStr);
} catch (ValidateException e) {
log.error(e.getMessage());
return ResultBean.newErrorResult(-1,e.getMsgKey(),e.getMessage());
}
return ResultBean.newOkResult(barcode);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.util;
public class CacheNameUtil {
public static final String CACHE_BIND_GR = "CACHE_BIND_GR";
public static final String CHCHE_QUERY_BIN = "CHCHE_QUERY_BIN";
public static final String CHCHE_STOR_TRANSFER = "CHCHE_STOR_TRANSFER";
public static final String CHCHE_TICKET_RETURN = "CHCHE_TICKET_RETURN";
public static final String CHCHE_MANUAL_PUTIN = "CHCHE_MANUAL_PUTIN";
public static final String CHCHE_UPLOAD_CARPALLINFO = "CHCHE_UPLOAD_CARPALLINFO";
public static final String CHCHE_MANUALWORK_PUTIN = "CHCHE_MANUALWORK_PUTIN";
public static final String CHCHE_EXECUTINGPUTIN_BOX = "CHCHE_EXECUTINGPUTIN_BOX";
public static final String CHCHE_SHIPCANCELUPSHELF = "CHCHE_SHIPCANCELUPSHELF";
public static final String CHCHE_RESTOREREPLACE = "CHCHE_RESTOREREPLACE";
//CTU使用信息
public static final String CHCHE_CTUUSEINFO = "CHCHE_CTUUSEINFO";
//入料机构缓存
public static final String CHCHE_MATERIAL_PUTIN_CACHE = "CHCHE_MATERIAL_PUTIN_CACHE";
}
package com.neotel.smfcore.custom.luxsan.factory_c.util;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class CommonUtil {
public static String plantCode;
@Value("${luxsan.plantCode}")
private void setPlantCode(String code){
CommonUtil.plantCode = code;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.bean;
import lombok.Data;
import java.util.List;
@Data
public class OdnOut {
private String odn;
private List<String> boxList;
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.bean.dto;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchShipmentInfoResult;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class FetchShipmentInfoDto {
/**
* 行ID
*/
private String rtvId;
/**
* 工厂代码
*/
private String plantCode;
/**
* 出货单号
*/
private String ticketCode;
/**
* 单据行号
*/
private String ticketItem;
/**
* 料号
*/
private String materialCode;
/**
* 物料类型
*/
private String materialType;
/**
* 仓库代码
*/
private String warehouseCode;
/**
* 供应商代码
*/
private String vendorCode;
/**
* 单据数量
*/
private int qty;
/**
* 单位
*/
private String unit;
/**
* 状态
*/
private String status;
/**
* 原数量
*/
private int originQty;
/**
* 制造商
*/
private int manufacture;
/**
* 报关模式
*/
private String importMode;
/**
* 进口编号
*/
private String importCode;
/**
* 收货工厂
*/
private String shipTo;
public static FetchShipmentInfoDto convertFetchShipmentInfoDto(FetchShipmentInfoResult result) {
FetchShipmentInfoDto dto = new FetchShipmentInfoDto();
dto.setRtvId(result.getRTV_ID());
dto.setPlantCode(result.getPLANT_CODE());
dto.setTicketCode(result.getTICKET_CODE());
dto.setTicketItem(result.getTICKET_ITEM());
dto.setMaterialCode(result.getMATERIAL_CODE());
dto.setMaterialType(result.getMATERIAL_TYPE());
dto.setWarehouseCode(result.getWAREHOUSE_CODE());
dto.setVendorCode(result.getVENDOR_CODE());
dto.setQty(result.getQTY());
dto.setUnit(result.getUNIT());
dto.setStatus(result.getSTATUS());
dto.setOriginQty(result.getORIGIN_QTY());
dto.setManufacture(result.getMANUFACTURE());
dto.setImportMode(result.getIMPORT_MODE());
dto.setImportCode(result.getIMPORT_CODE());
dto.setShipTo(result.getSHIP_TO());
return dto;
}
public static List<FetchShipmentInfoDto> convertFetchShipmentInfoDto(List<FetchShipmentInfoResult> resultList){
List<FetchShipmentInfoDto> dtoResultList = new ArrayList<>();
for (FetchShipmentInfoResult result : resultList) {
dtoResultList.add(convertFetchShipmentInfoDto(result));
}
return dtoResultList;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.PalletUpdateRequest;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.TaskLocUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.WipBoxHandleUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 java.util.*;
@Slf4j
@ApiOperation("AGV设备端")
@RestController
@RequestMapping("/agvDevice")
public class AgvDeviceController {
@Autowired
private TaskService taskService;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IDataLogManager dataLogManager;
@ApiOperation("获取入库任务")
@RequestMapping("/getPutInTask")
@AnonymousAccess
public List<DataLog> getPutInTask() {
List<DataLog> dataLogList = new ArrayList<>();
for (DataLog dataLog : taskService.getAllTasks()) {
if (dataLog.isPutInTask() && dataLog.isWait()) {
dataLogList.add(dataLog);
}
}
return dataLogList;
}
@ApiOperation("获取出库任务")
@RequestMapping("/getCheckOutTask")
@AnonymousAccess
public List<DataLog> getCheckOutTask() {
List<DataLog> dataLogList = new ArrayList<>();
for (DataLog dataLog : taskService.getAllTasks()) {
if (dataLogList != null && dataLogList.size() > 6){
break;
}
if (dataLog.isCheckOutTask() && dataLog.isWait()) {
if (StringUtils.isEmpty(dataLog.getLoc())){
dataLog.setLoc(TaskLocUtil.OUT);
}
dataLogList.add(dataLog);
}
}
return dataLogList;
}
@ApiOperation("修改任务状态")
@RequestMapping("/updateTaskStatus")
@AnonymousAccess
public ResultBean updateTaskStatus(@RequestBody Map<String, String> paramMap) {
String boxStr = paramMap.get("boxStr");
String statusStr = paramMap.get("statusStr");
//1.判断任务是否存在
DataLog task = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (boxStr.startsWith(dataLog.getBarcode())) {
if (!dataLog.isCancel() && !dataLog.isFinished()) {
task = dataLog;
break;
}
}
}
if (task == null) {
return ResultBean.newErrorResult(-1, "smfcore.task.notExist", "任务不存在");
}
statusStr = statusStr.toUpperCase();
log.info("更新料箱:" + boxStr + ",任务状态为:" + statusStr);
//2.判断更新状态和当前状态任务是否相同
if (task.getStatus().equals(statusStr)) {
return ResultBean.newErrorResult(-1, "smfcore.taskStatusHasUpdate", "任务{0}已经修改状态", new String[]{task.getBarcode()});
}
task.setStatus(statusStr);
//3.判断是出库,还是入库任务
if (task.isPutInTask()) {
if (OP_STATUS.FINISHED.name().equals(statusStr)) {
finishedPutInTask(task);
//WipBoxHandleUtil.intoPos(task);
ReelLockPosUtil.removeReelLockPosInfo(task.getBarcode());
} else {
taskService.updateQueueTask(task);
}
} else {
//4.如果是出库任务
if (OP_STATUS.EXECUTING.name().equals(statusStr)) {
taskService.updateQueueTask(task);
} else {
if (!task.isOutFromPos()) {
finishedOutTask(task);
//WipBoxHandleUtil.outFromPos(task);
task.setOutFromPos(true);
}
taskService.updateFinishedTask(task);
}
}
return ResultBean.newOkResult("");
}
@ApiOperation("出库任务获取目的地")
@RequestMapping("/getLoc")
@AnonymousAccess
public ResultBean getLoc(String boxStr) {
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.isCheckOutTask()) {
if (boxStr.startsWith(dataLog.getBarcode())) {
if (StringUtils.isEmpty(dataLog.getLoc())) {
dataLog.setLoc(TaskLocUtil.OUT);
}
return ResultBean.newOkResult(dataLog.getLoc());
}
}
}
return ResultBean.newErrorResult(-1, "", "未找到料箱:" + boxStr + "的任务");
}
private void finishedOutTask(DataLog queueTask){
Barcode barcode = barcodeManager.findByBarcode(queueTask.getBarcode());
//通知WMS
PalletUpdateRequest palletUpdateRequest = new PalletUpdateRequest();
palletUpdateRequest.setREQUEST_ID(System.currentTimeMillis()+"");
palletUpdateRequest.setPALLET_LIST(Lists.newArrayList(barcode.getPalletId()));
//上架是SWC, 下架是SWCT
palletUpdateRequest.setBIN_CODE("SWCT");
palletUpdateRequest.setBIZ_TYPE("M");
palletUpdateRequest.setPLANT_CODE(CommonUtil.plantCode);
LuxsanApi.palletUpdate(palletUpdateRequest);
//已完成,从库存中清除,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(queueTask.getPosId());
if (barcode != null) {
//二维码状态
barcode.setUsed(true);
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), "");
//barcode.setPosName("");
barcode.setOrderItemId("");
barcode.setOrderId("");
barcode.setLockName("");
barcode.setLockId("");
barcodeManager.save(barcode);
}
storagePos.setBarcode(null);
storagePos.setUsed(false);
storagePosManager.save(storagePos);
queueTask.setStatus(OP_STATUS.FINISHED.name());
taskService.moveTaskToFinished(queueTask);
}
private void finishedPutInTask(DataLog queueTask){
Barcode barcode = barcodeManager.findByBarcode(queueTask.getBarcode());
//通知WMS
PalletUpdateRequest palletUpdateRequest = new PalletUpdateRequest();
palletUpdateRequest.setREQUEST_ID(System.currentTimeMillis()+"");
palletUpdateRequest.setPALLET_LIST(Lists.newArrayList(barcode.getPalletId()));
//上架是SWC, 下架是SWCT
palletUpdateRequest.setBIN_CODE("SWC");
palletUpdateRequest.setBIZ_TYPE("M");
palletUpdateRequest.setPLANT_CODE(CommonUtil.plantCode);
LuxsanApi.palletUpdate(palletUpdateRequest);
//已完成,加入库存,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(queueTask.getPosId());
if (barcode != null) {
barcode.setUsedCount(barcode.getUsedCount() + 1);
barcode.setPutInTime(System.currentTimeMillis());
barcode.setInOpor("");
barcode.setCheckOutDate(null, "");
barcode.setPosName(queueTask.getPosName());
barcode = barcodeManager.save(barcode);
}
storagePos.setBarcode(barcode);
storagePos.setUsed(true);
storagePos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(storagePos);
queueTask.setStatus(OP_STATUS.FINISHED.name());
taskService.moveTaskToFinished(queueTask);
dataLogManager.save(queueTask);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.ShipCancelUpshelfRequest;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.TaskLocUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.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 java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Api(tags = "砍单回库")
@RequestMapping("/cancelRestock")
@RestController
public class CancelRestockController {
@Autowired
private CodeResolve codeResolve;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@ApiOperation("砍单通知自动仓")
@RequestMapping("/cancelOdn")
@AnonymousAccess
public ResultBean cancelOdn(@RequestBody Map<String, String> paramMap) {
String plantCode = paramMap.get("PLANT_CODE");
String ticketCode = paramMap.get("TICKET_CODE");
log.info("wms砍单通知自动仓,工厂代码为:" + plantCode + ",出货单为:" + ticketCode);
//查找对应的任务,只把等待中的给取消
List<DataLog> dataLogList = taskService.getAllTasks();
for (DataLog dataLog : dataLogList) {
if (ticketCode.equals(dataLog.getSourceName())) {
if (dataLog.isWait()) {
boolean cancelTask = taskService.cancelTask(dataLog.getId());
log.info(dataLog.getBarcode() + "取消任务,结果为:" + cancelTask + ",odn为:" + ticketCode);
} else {
dataLog.setLoc(TaskLocUtil.NG);
if (dataLog.isOutFromPos()) {
taskService.updateFinishedTask(dataLog);
}
taskService.updateQueueTask(dataLog);
}
}
}
return ResultBean.newOkResult("");
}
@ApiOperation("砍单回库")
@RequestMapping("/shipCancelUpshelf")
@AnonymousAccess
public ResultBean shipCancelUpshelf(String boxStr) {
if (StringUtils.isEmpty(boxStr)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
log.info("砍单回库,料箱号为:" + boxStr);
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2=" + boxStr);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "条码无效");
}
//2.判断栈板号和odn是否存在
String palletId = barcode.getPalletId();
if (StringUtils.isEmpty(palletId)) {
throw new ValidateException("smfcore.valueNotFind", "未找到{0}[{1}]", new String[]{"料箱", "标签码"});
}
String odn = barcode.getOdn();
if (StringUtils.isEmpty(odn)) {
throw new ValidateException("smfcore.valueNotFind", "未找到{0}[{1}]", new String[]{"料箱", "odn"});
}
//3.调用接口,判断是否可以回库
LuxsanApi.shipCancelUpshelf(new ShipCancelUpshelfRequest(CommonUtil.plantCode, odn, palletId));
//4.加入缓存,后续不用扫码,直接上架
Map<String, String> cacheMap = dataCache.getCache(CacheNameUtil.CHCHE_SHIPCANCELUPSHELF);
if (cacheMap == null) {
cacheMap = new HashMap<>();
}
cacheMap.put(barcode.getBarcode(), barcode.getBarcode());
dataCache.updateCache(CacheNameUtil.CHCHE_SHIPCANCELUPSHELF, cacheMap);
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.FetchPalletInfoRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.PalletUpdateRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.request.ValidCartonRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchPalletInfoResult;
import com.neotel.smfcore.custom.luxsan.api.bean.result.ValidCartonResult;
import com.neotel.smfcore.custom.luxsan.api.enums.PalletEnum;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.ManualWorkUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util.TaskLocUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Api(tags = "流水线接口")
@Slf4j
@RestController
@RequestMapping("/line")
public class LineController {
@Autowired
private DataCache dataCache;
@Autowired
private CodeResolve codeResolve;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IComponentManager componentManager;
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private TaskService taskService;
/**
* 线体第一个扫码器扫码调用
*/
@ApiOperation("校验箱号")
@RequestMapping("/validCarton")
@AnonymousAccess
public ResultBean validCarton(@RequestBody Map<String, String> paramMap) {
String boxId = paramMap.get("cartonId");
log.info("线体第一个扫码枪扫描到箱号["+boxId+"]校验箱号");
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
String scanCartonId = barcode.getScanCartonId();
if(Strings.isBlank(scanCartonId)){
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.noBind", "条码未绑定CartonId");
}
//如果是人工作业 直接返回ok
if (ManualWorkUtil.bindManualWork(barcode.getBarcode())) {
return ResultBean.newOkResult("");
}
try {
ValidCartonResult result = LuxsanApi.validCarton(new ValidCartonRequest("", scanCartonId, CommonUtil.plantCode));
} catch (Exception e) {
return ResultBean.newErrorResult(-1, "", e.getMessage());
}
return ResultBean.newOkResult("");
}
/**
* 线体第二个扫码器扫码调用,判断是否过账
*/
@ApiOperation("获取是否过账完成信息")
@RequestMapping("/fetchPalletInfo")
@AnonymousAccess
public synchronized ResultBean fetchPalletInfo(@RequestBody Map<String, String> paramMap) {
String boxId = paramMap.get("cartonId");
log.info("线体第二个扫码枪扫描到箱号["+boxId+"],判断过账是否完成");
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
//如果是人工作业的,直接入库
if (ManualWorkUtil.bindManualWork(barcode.getBarcode())){
} else {
//2.请求接口判断是否过账
try {
String palletId = barcode.getScanCartonId();
FetchPalletInfoResult fetchPalletInfo = null;
List<FetchPalletInfoResult> fetchPalletList = LuxsanApi.fetchPalletInfo(new FetchPalletInfoRequest("", CommonUtil.plantCode, Arrays.asList(palletId)));
for (FetchPalletInfoResult result : fetchPalletList) {
if (palletId.equals(result.getPALLET_ID())) {
fetchPalletInfo = result;
break;
}
}
if (fetchPalletInfo != null) {
if (fetchPalletInfo.getSTATUS() != PalletEnum.POSTED_AND_PENDING_SHELVING) {
return ResultBean.newErrorResult(-1, "", fetchPalletInfo.getPALLET_ID() + "不是[6 已过账,待上架],不允许入库");
}
//设置barcode的其他参数
barcode.setPlantCode(fetchPalletInfo.getPLANT());
barcode.setCartonId(fetchPalletInfo.getPALLET_ID());
barcode.setPalletId(fetchPalletInfo.getPALLET_ID());
barcode.setPn(fetchPalletInfo.getMATERIAL_CODE());
barcode.setPartNumber(fetchPalletInfo.getMATERIAL_CODE());
Component component = componentManager.findOneByPN(barcode.getPartNumber());
if(component == null){
component = new Component();
component.setPartNumber(barcode.getPartNumber());
component.setPlateSize(Integer.valueOf(2));
component.setHeight(Integer.valueOf(2));
componentManager.save(component);
}
barcode.setModelFamily(fetchPalletInfo.getMODEL_FAMILY());
barcode.setMaterialType(fetchPalletInfo.getMATERIAL_TYPE());
barcode.setWarehouseCode(fetchPalletInfo.getWAREHOUSE_CODE());
barcode.setHold(fetchPalletInfo.getHOLD());
barcode.setQty(fetchPalletInfo.getQTY());
barcode.setAmount(fetchPalletInfo.getQTY());
//barcode.setFullQty(fetchPalletInfo.getFULL_QTY());
barcode.setPackType(fetchPalletInfo.getPACK_TYPE());
barcode.setCreateAt(fetchPalletInfo.getCREATED_TIME());
//barcode.setRegion(fetchPalletInfo.getREGION());
barcode.setStatus(fetchPalletInfo.getSTATUS());
barcode.setBatch(fetchPalletInfo.getBATCH_CODE());
barcode = barcodeManager.save(barcode);
}
} catch (Exception e) {
return ResultBean.newErrorResult(-1, "", e.getMessage());
}
}
//生成入库任务
List<Storage> storageList = new ArrayList<>();
List<String> cidList = new ArrayList<>();
for (Storage storage : dataCache.getAllStorage().values()) {
storageList.add(storage);
cidList.add(storage.getCid());
}
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
if (pos == null) {
return ResultBean.newErrorResult(-1, "", boxId + "未找到可用库位");
}
//3.锁定库位
Storage storage = dataCache.getStorageById(pos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(barcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(pos.getPosName());
reelLocInfo.setLockPosId(pos.getId());
reelLocInfo = ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, cidList);
if (reelLocInfo == null) {
return ResultBean.newErrorResult(-1, "", "[" + barcode.getBarcode() + "]库位[" + reelLocInfo.getLockPosName() + "]已被锁定,暂停入库", new String[]{});
}
//清理扫描的cartonId
barcode.setScanCartonId("");
//4.生成入库任务
String boxLoc = TaskLocUtil.IN;
taskService.addPutInTaskToExecute(storage, barcode, pos,boxLoc);
return ResultBean.newOkResult("");
}
/**
* 判断是否为最后一箱
*/
@ApiOperation("判断是否为最后一箱")
@RequestMapping("/odnReCartonQty")
@AnonymousAccess
public ResultBean odnReCartonQty(@RequestBody Map<String, String> paramMap) {
String boxId = paramMap.get("cartonId");
DataLog dataLog = dataLogManager.findOne(new Query(Criteria.where("barcode").is(boxId).and("type").is(OP.CHECKOUT)));
if (dataLog != null) {
if (dataLog.isCheckOutTask() && dataLog.isFinished()) {
String sourceId = dataLog.getSourceId();
if (StringUtils.isNotEmpty(sourceId)) {
int qty = 0;
Map<String, Object> resultMap = new HashMap<>();
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog task : allTasks) {
if (task.isCheckOutTask() && !task.isCancel() && !task.isFinished()) {
if (sourceId.equals(task.getSourceId())) {
qty++;
}
}
}
resultMap.put("odn", sourceId);
resultMap.put("qty", qty);
resultMap.put("palletId", "");
Barcode barcode = barcodeManager.findByBarcode(boxId);
if (barcode != null){
resultMap.put("palletId", barcode.getPalletId());
}
return ResultBean.newOkResult(resultMap);
}
}
}
return ResultBean.newErrorResult(-1, "", "未找到对应的信息");
}
/**
* 传入栈板和料箱信息
*/
@ApiOperation("传入栈板和料箱信息")
@RequestMapping("/uploadCarPallInfo")
@AnonymousAccess
public ResultBean uploadCarPallInfo(@RequestBody Map<String, String> paramMap) {
String boxId = paramMap.get("cartonId");
String cartonId = paramMap.get("palletId");
log.info("线体设备扫描到箱号["+boxId+"]和CartonId:" + cartonId);
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
barcode.setScanCartonId(cartonId);
barcodeManager.saveBarcode(barcode);
return ResultBean.newOkResult("");
}
@ApiOperation("手动绑定料箱和cartonId")
@RequestMapping("/bindCartonId")
@AnonymousAccess
public ResultBean bindCartonId(String boxId, String cartonId){
log.info("手动绑定箱号["+boxId+"]和CartonId:" + cartonId);
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
barcode.setScanCartonId(cartonId);
barcodeManager.saveBarcode(barcode);
return ResultBean.newOkResult("");
}
@ApiOperation("手动完成入库任务")
@RequestMapping("/finishedInTask")
@AnonymousAccess
public ResultBean finishedInTask(String boxId){
log.info("手动完成箱号["+boxId+"]的入库任务");
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
for (DataLog queueTask : taskService.getQueueTasks()) {
if(queueTask.isPutInTask() && queueTask.getBarcode().equals(boxId)){
//完成入库任务
finishedPutInTask(queueTask);
return ResultBean.newOkResult("");
}
}
return ResultBean.newErrorResult(-1,"error.noTask","未找到该料箱["+boxId+"]的入库任务");
}
@ApiOperation("手动完成出库任务")
@RequestMapping("/finishedOutTask")
@AnonymousAccess
public ResultBean bindCartonId(String boxId){
log.info("手动完成箱号["+boxId+"]的出库任务");
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2="+boxId);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "条码无效");
}
for (DataLog queueTask : taskService.getQueueTasks()) {
if(queueTask.isCheckOutTask() && queueTask.getBarcode().equals(boxId)){
//完成入库任务
finishedOutTask(queueTask);
return ResultBean.newOkResult("");
}
}
return ResultBean.newErrorResult(-1,"error.noTask","未找到该料箱["+boxId+"]的出库任务");
}
private void finishedOutTask(DataLog queueTask){
Barcode barcode = barcodeManager.findByBarcode(queueTask.getBarcode());
//通知WMS
PalletUpdateRequest palletUpdateRequest = new PalletUpdateRequest();
palletUpdateRequest.setREQUEST_ID(System.currentTimeMillis()+"");
palletUpdateRequest.setPALLET_LIST(Lists.newArrayList(barcode.getPalletId()));
//上架是SWC, 下架是SWCT
palletUpdateRequest.setBIN_CODE("SWCT");
palletUpdateRequest.setBIZ_TYPE("M");
palletUpdateRequest.setPLANT_CODE(CommonUtil.plantCode);
LuxsanApi.palletUpdate(palletUpdateRequest);
//已完成,从库存中清除,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(queueTask.getPosId());
if (barcode != null) {
//二维码状态
barcode.setUsed(true);
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), "");
//barcode.setPosName("");
barcode.setOrderItemId("");
barcode.setOrderId("");
barcode.setLockName("");
barcode.setLockId("");
barcodeManager.save(barcode);
}
storagePos.setBarcode(null);
storagePos.setUsed(false);
storagePosManager.save(storagePos);
queueTask.setStatus(OP_STATUS.FINISHED.name());
taskService.moveTaskToFinished(queueTask);
}
private void finishedPutInTask(DataLog queueTask){
Barcode barcode = barcodeManager.findByBarcode(queueTask.getBarcode());
//通知WMS
PalletUpdateRequest palletUpdateRequest = new PalletUpdateRequest();
palletUpdateRequest.setREQUEST_ID(System.currentTimeMillis()+"");
palletUpdateRequest.setPALLET_LIST(Lists.newArrayList(barcode.getPalletId()));
//上架是SWC, 下架是SWCT
palletUpdateRequest.setBIN_CODE("SWC");
palletUpdateRequest.setBIZ_TYPE("M");
palletUpdateRequest.setPLANT_CODE(CommonUtil.plantCode);
LuxsanApi.palletUpdate(palletUpdateRequest);
//已完成,加入库存,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(queueTask.getPosId());
if (barcode != null) {
barcode.setUsedCount(barcode.getUsedCount() + 1);
barcode.setPutInTime(System.currentTimeMillis());
barcode.setInOpor("");
barcode.setCheckOutDate(null, "");
barcode.setPosName(queueTask.getPosName());
barcode = barcodeManager.save(barcode);
}
storagePos.setBarcode(barcode);
storagePos.setUsed(true);
storagePos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(storagePos);
queueTask.setStatus(OP_STATUS.FINISHED.name());
taskService.moveTaskToFinished(queueTask);
dataLogManager.save(queueTask);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "人工作业")
@RequestMapping("/manualWork")
@RestController
public class ManualWorkController {
@Autowired
private CodeResolve codeResolve;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@ApiOperation("人工入库")
@RequestMapping("/putIn")
@AnonymousAccess
public ResultBean putIn(String boxStr) {
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
if (boxBarcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{boxStr});
}
//判断是否在列表中
List<String> cacheList = dataCache.getCache(CacheNameUtil.CHCHE_MANUALWORK_PUTIN);
if (cacheList == null) {
cacheList = new ArrayList<>();
}
if (cacheList.contains(boxBarcode.getBarcode())) {
return ResultBean.newErrorResult(-1, "", boxStr + "已经存在人工作业列表中");
}
//判断有没有任务
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
if (dataLog.getBarcode().equals(boxBarcode.getBarcode())) {
return ResultBean.newErrorResult(-1, "", boxStr + "已经有正在执行中的任务");
}
}
}
cacheList.add(boxBarcode.getBarcode());
dataCache.updateCache(CacheNameUtil.CHCHE_MANUALWORK_PUTIN, cacheList);
return ResultBean.newOkResult("");
}
@ApiOperation("人工入库列表")
@RequestMapping("/manualWorkList")
@AnonymousAccess
public ResultBean manualWorkList() {
List<String> cacheList = dataCache.getCache(CacheNameUtil.CHCHE_MANUALWORK_PUTIN);
if (cacheList == null) {
cacheList = new ArrayList<>();
}
return ResultBean.newOkResult(cacheList);
}
@ApiOperation("移除人工作业列表")
@RequestMapping("/removeManualWork")
@AnonymousAccess
public ResultBean removeManualWork(String boxStr) {
List<String> cacheList = dataCache.getCache(CacheNameUtil.CHCHE_MANUALWORK_PUTIN);
if (cacheList == null) {
cacheList = new ArrayList<>();
}
cacheList.remove(boxStr);
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.storage.service.dao.IStoragePosDao;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Api(tags = "odn还原补箱")
@RestController
@RequestMapping("/restoreReplace")
public class RestoreReplaceController {
@Autowired
private CodeResolve codeResolve;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private IStoragePosDao storagePosDao;
@ApiOperation("还原补箱")
@RequestMapping("/scanBox")
@AnonymousAccess
public ResultBean scanBox(String boxStr) {
if (StringUtils.isEmpty(boxStr)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"料箱信息"});
}
log.info("还原补箱,料箱号为:" + boxStr);
//1.解析条码
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2=" + boxStr);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "条码无效");
}
//2.找一个料号相同,数量相同的箱子
String partNumber = barcode.getPartNumber();
int amount = barcode.getAmount();
Criteria c = Criteria.where("barcode.partNumber").is(partNumber)
.and("id").nin(liteOrderCache.excludeOutPosIds())
.and("enabled").is(true)
.and("barcode.lockId").is(null)
.and("barcode.amount").gte(amount);
Sort s = Sort.by(Sort.Direction.ASC, "barcode.amount", "barcode.putInDate");
StoragePos pos = storagePosDao.findOne(new Query(c).with(s));
if (pos == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的料箱");
}
//3.生成出库任务,到流水线
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
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.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.FetchMoveTicketRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchMoveTicketResult;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.FetchMoveTicketDto;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Api(tags = "261&931领用")
@RequestMapping("/takeOut")
@RestController
public class TakeOutController {
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@ApiOperation("拉取单据信息")
@RequestMapping("/fetchTicket")
@AnonymousAccess
public ResultBean fetchTicket(String ticket) {
if (StringUtils.isEmpty(ticket)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"单据号"});
}
List<FetchMoveTicketResult> ticketList = LuxsanApi.fetchMoveTicket(new FetchMoveTicketRequest(CommonUtil.plantCode, ticket));
return ResultBean.newOkResult(FetchMoveTicketDto.convertFetchMoveTicketDto(ticketList));
}
@ApiOperation("单据出库")
@RequestMapping("/ticketOut")
@AnonymousAccess
public ResultBean ticketOut(String ticket) {
log.info("半成品仓单据出库:" + ticket);
if (StringUtils.isEmpty(ticket)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"单据号"});
}
//1.判断单据是否存在
LiteOrder liteOrder = liteOrderCache.getOrderSortItems(ticket);
if (liteOrder == null) {
List<FetchMoveTicketResult> ticketList = LuxsanApi.fetchMoveTicket(new FetchMoveTicketRequest(CommonUtil.plantCode, ticket));
ticketToLiteOrder(ticket,ticketList);
}
liteOrderCache.wipTicketOut(ticket);
return ResultBean.newOkResult("");
}
public LiteOrder ticketToLiteOrder(String ticket, List<FetchMoveTicketResult> ticketList) {
LiteOrder liteOrder = new LiteOrder();
liteOrder.setOrderNo(ticket);
List<LiteOrderItem> itemList = new ArrayList<>();
for (FetchMoveTicketResult ticketResult : ticketList) {
LiteOrderItem item = new LiteOrderItem();
item.setTicketItem(ticketResult.getTICKET_ITEM());
item.setPn(ticketResult.getMATERIAL_CODE());
item.setSrcPlant(ticketResult.getSRC_PLANT());
item.setDstPlant(ticketResult.getDST_PLANT());
item.setSrcWarehouse(ticketResult.getSRC_WAREHOUSE());
item.setDstWarehouse(ticketResult.getDST_WAREHOUSE());
item.setSrcBatch(ticketResult.getSRC_BATCH());
item.setDstBatch(ticketResult.getDST_BATCH());
item.setNeedNum(ticketResult.getQTY());
item.setMoveType(ticketResult.getMOVE_TYPE());
itemList.add(item);
}
liteOrder.setOrderItems(itemList);
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
return liteOrder;
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
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.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.FetchShipmentInfoRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.FetchShipmentInfoResult;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.bean.OdnOut;
import com.neotel.smfcore.custom.luxsan.factory_c.wipstor.bean.dto.FetchShipmentInfoDto;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "半成品出库")
@Slf4j
@RestController
@RequestMapping("/wipStorCheckOut")
public class WipStorCheckOutController {
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private TaskService taskService;
@Autowired
private CodeResolve codeResolve;
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private DataCache dataCache;
@ApiOperation("获取ODN详情")
@RequestMapping("/getOdnDetail")
@AnonymousAccess
public ResultBean getOdnDetail(String odn) {
List<FetchShipmentInfoResult> resultList = LuxsanApi.fetchShipmentInfo(new FetchShipmentInfoRequest(CommonUtil.plantCode, odn));
return ResultBean.newOkResult(FetchShipmentInfoDto.convertFetchShipmentInfoDto(resultList));
}
@ApiOperation("判断料箱是否在库")
@RequestMapping("boxInStor")
@AnonymousAccess
public ResultBean boxInStor(String odn, String box) {
log.info("收到odn信息为:"+odn+",料箱信息为:"+box);
Barcode barcode = codeResolve.resolveOneValideBarcode(box);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{box});
}
if (StringUtils.isEmpty(barcode.getPosName())) {
return ResultBean.newErrorResult(-1, "", box + "不在库");
}
//判断是否锁定其他工单
if (StringUtils.isNotEmpty(barcode.getLockName()) && !barcode.getLockName().equals(odn)) {
return ResultBean.newErrorResult(-1, "", box + "已经锁定odn:" + barcode.getLockName());
}
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.getBarcode().equals(box)) {
if (!dataLog.isFinished() && !dataLog.isCancel()) {
return ResultBean.newErrorResult(-1, "", box + "有正在执行中的任务");
}
}
}
return ResultBean.newOkResult("");
}
@ApiOperation("ODN出库")
@RequestMapping("/odnOut")
@AnonymousAccess
public synchronized ResultBean odnOut(@RequestBody OdnOut odnOut) {
String odn = odnOut.getOdn();
List<String> boxList = odnOut.getBoxList();
//1.判断是否正在执行中
LiteOrder liteOrder = liteOrderCache.getLiteOrder(odn);
if (liteOrder == null) {
liteOrder = liteOrderManager.findByOrderNo(odn);
}
if (liteOrder != null) {
if (!liteOrder.isTaskFinished() && !liteOrder.isNew()) {
return ResultBean.newErrorResult(-1, "", odn + "任务未结束");
}
liteOrder.setOrderNo(odn + "_bak_" + System.currentTimeMillis());
liteOrderManager.createWithItems(liteOrder);
}
//2.生成工单任务
LiteOrder newOrder = new LiteOrder();
List<LiteOrderItem> itemList = new ArrayList<>();
List<FetchShipmentInfoResult> resultList = LuxsanApi.fetchShipmentInfo(new FetchShipmentInfoRequest(CommonUtil.plantCode, odn));
for (FetchShipmentInfoResult result : resultList) {
LiteOrderItem orderItem = new LiteOrderItem();
orderItem.setPn(result.getMATERIAL_CODE());
orderItem.setRtvId(result.getRTV_ID());
orderItem.setPlantCode(result.getPLANT_CODE());
orderItem.setTicketCode(result.getTICKET_CODE());
orderItem.setTicketItem(result.getTICKET_ITEM());
orderItem.setMaterialCode(result.getMATERIAL_CODE());
orderItem.setWarehouseCode(result.getWAREHOUSE_CODE());
orderItem.setVendorCode(result.getVENDOR_CODE());
orderItem.setQty(result.getQTY());
orderItem.setUnit(result.getUNIT());
orderItem.setStatus(result.getSTATUS());
orderItem.setOriginQty(result.getORIGIN_QTY());
orderItem.setManufacture(result.getMANUFACTURE());
orderItem.setImportMode(result.getIMPORT_MODE());
orderItem.setImportCode(result.getIMPORT_CODE());
orderItem.setShipTo(result.getSHIP_TO());
orderItem.setPn(result.getMATERIAL_CODE());
orderItem.setNeedNum(result.getQTY());
itemList.add(orderItem);
}
newOrder.setOrderNo(odn);
newOrder.setOrderItems(itemList);
newOrder = liteOrderManager.createWithItems(newOrder);
liteOrderCache.addOrderToMap(newOrder);
List<String> needOutBoxList = liteOrderCache.findNeedOutBox(odn, boxList);
if (needOutBoxList == null || needOutBoxList.isEmpty()){
return ResultBean.newErrorResult(-1,"","未找到可以出库的物料");
}
return ResultBean.newOkResult(needOutBoxList);
}
@ApiOperation("取消odn出库")
@RequestMapping("/cancelOdnOut")
@AnonymousAccess
public ResultBean cancelOdnOut(String odn) {
if (StringUtils.isEmpty(odn)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"odn"});
}
List<StoragePos> posList = storagePosManager.findByQuery(new Query(Criteria.where("barcode.lockName").is(odn)));
if (posList != null && !posList.isEmpty()){
for (StoragePos storagePos : posList) {
Barcode barcode = storagePos.getBarcode();
barcode.setOrderId("");
barcode.setOrderItemId("");
barcode.setLockId("");
barcode.setLockName("");
barcodeManager.save(barcode);
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
}
return ResultBean.newOkResult("");
}
@ApiOperation("ODN确认出库")
@RequestMapping("/odnConfirmOut")
@AnonymousAccess
public synchronized ResultBean odnConfirmOut(String odn) {
//生成出库任务
List<StoragePos> posList = storagePosManager.findByQuery(new Query(Criteria.where("barcode.lockName").is(odn)));
for (StoragePos storagePos : posList) {
Storage storage = dataCache.getStorageById(storagePos.getStorageId());
Barcode barcode = storagePos.getBarcode();
DataLog dataLog = new DataLog(storage, barcode, storagePos);
dataLog.setSourceId(barcode.getLockId());
dataLog.setSourceName(barcode.getLockName());
dataLog.setSubSourceId(barcode.getOrderItemId());
dataLog.setType(OP.CHECKOUT);
dataLog.setStatus(OP_STATUS.WAIT.name());
taskService.updateQueueTask(dataLog);
}
return ResultBean.newOkResult("");
}
@ApiOperation("人员调用wms手动解绑")
@RequestMapping("/unBindPallet")
@AnonymousAccess
public ResultBean unBindPallet() {
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.factory_c.util.CacheNameUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class ManualWorkUtil {
private static DataCache dataCache;
@Autowired
public void setDataCache(DataCache cache){
ManualWorkUtil.dataCache = cache;
}
public static boolean bindManualWork(String boxStr){
List<String> cacheList = dataCache.getCache(CacheNameUtil.CHCHE_MANUALWORK_PUTIN);
if (cacheList == null) {
cacheList = new ArrayList<>();
}
return cacheList.contains(boxStr);
}
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util;
public class TaskLocUtil {
public static final String IN = "semiFinished_In";
public static final String OUT = "semiFinished_Out";
public static final String NG = "semiFinished_ng";
public static final String RR = "semiFinished_rr"; //还原补箱 restoreReplace
}
package com.neotel.smfcore.custom.luxsan.factory_c.wipstor.util;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Slf4j
@Service
public class WipBoxHandleUtil {
private static IBarcodeManager barcodeManager;
@Autowired
public void setBarcodeManager(IBarcodeManager manager) {
WipBoxHandleUtil.barcodeManager = manager;
}
private static IStoragePosManager storagePosManager;
@Autowired
public void setStoragePosManager(IStoragePosManager manager) {
WipBoxHandleUtil.storagePosManager = manager;
}
private static DataCache dataCache;
@Autowired
public void setDataCache(DataCache cache) {
WipBoxHandleUtil.dataCache = cache;
}
private static TaskService taskService;
@Autowired
public void setTaskService(TaskService service) {
WipBoxHandleUtil.taskService = service;
}
public static void intoPos(DataLog opTask) {
//已完成,加入库存,并且从完成队列中清除
StoragePos storagePos = storagePosManager.get(opTask.getPosId());
//二维码状态
Barcode barcode = barcodeManager.findByBarcode(opTask.getBarcode());
if (barcode != null) {
barcode.setUsedCount(barcode.getUsedCount() + 1);
barcode.setPutInTime(System.currentTimeMillis());
barcode.setInOpor("");
barcode.setCheckOutDate(null, "");
barcode.setPosName(opTask.getPosName());
barcode = barcodeManager.save(barcode);
}
storagePos.setBarcode(barcode);
storagePos.setUsed(true);
storagePos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(storagePos);
taskService.moveTaskToFinished(opTask);
taskService.updateFinishedTask(opTask);
}
public static void outFromPos(DataLog opTask) {
//从队列里面移除操作
taskService.removeQueueTask(opTask);
StoragePos storagePos = storagePosManager.get(opTask.getPosId());
Barcode barcode = storagePos.getBarcode();
if (barcode == null) {
log.warn("任务:" + opTask.getId() + " 仓位:" + opTask.getPosName() + " 的 Barcode 为null, 之前可能处理过,结束任务后直接返回");
return;
}
barcode = barcodeManager.get(barcode.getId());
if (barcode != null) {
//二维码状态
barcode.setUsed(true);
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), "");
barcode.setPosName("");
barcode.setOrderItemId("");
barcode.setOrderId("");
barcode.setLockName("");
barcode.setLockId("");
barcodeManager.save(barcode);
}
storagePos.setBarcode(null);
storagePos.setUsed(false);
storagePosManager.save(storagePos);
log.info("出库完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]");
taskService.moveTaskToFinished(opTask);
}
private static DataLog generateTask(Storage storage, Barcode barcode, StoragePos pos, int type, String status, String loc, int extendType) {
//开始入库任务
DataLog task = new DataLog(storage, barcode, pos);
task.setType(type);
task.setStatus(status);
task.setLoc(loc);
task.setOperator(SecurityUtils.getLoginUsername());
task.setBoxPosName(pos.getPosName());
task.setExtendType(extendType);
if (barcode.getPutInTime() != -1) {
task.setFristPutInDate(new Date(barcode.getPutInTime()));
} else {
task.setFristPutInDate(barcode.getPutInDate());
}
task.setDescribe(barcode.getDescribe());
taskService.addTaskToExecute(task);
return task;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!