Commit 8802f0e5 hjh

lizhen退料接口

1 个父辈 d4e3b222
......@@ -8,11 +8,14 @@ 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.SecurityUtils;
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.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.po.LiteOrder;
......@@ -20,6 +23,7 @@ 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.manager.IDataLogManager;
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;
......@@ -27,10 +31,14 @@ 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.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -46,6 +54,9 @@ public class LizhenApi extends DefaultSmfApiListener {
private IStoragePosManager storagePosManager;
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private DataCache dataCache;
@Value("${api.fetchGRUrl}")
......@@ -64,23 +75,25 @@ public class LizhenApi extends DefaultSmfApiListener {
private String werks;
@Value("${api.outNotifyUrlPK}")
private String outNotifyUrlPK = "";
private String outNotifyUrlPK = "";
@Value("${api.batchCheckUrl}")
private String batchCheckUrl = "";
@Value("${api.checkReelMeasure}")
private String checkReelMeasureUrl = "";
@Value("${api.CommonGIRecord}")
private String CommonGIRecordUrl;
@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);
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);
}
......@@ -91,10 +104,10 @@ public class LizhenApi extends DefaultSmfApiListener {
* @param brand
* @return
*/
public Map<String,Object> brandQty(String partnumber, String brand) {
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)){
if (StringUtils.isBlank(brandQtyUrl)) {
resultMap.put("qty", 0);
resultMap.put("reelSize", 0);
return resultMap;
......@@ -153,8 +166,8 @@ public class LizhenApi extends DefaultSmfApiListener {
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"));
resultMap.put("keeperCode", dataObject.getString("keeper_code"));
resultMap.put("warehouseCode", dataObject.getString("warehouse_code"));
}
}
} catch (ApiException e) {
......@@ -277,11 +290,11 @@ public class LizhenApi extends DefaultSmfApiListener {
//保存禁用料记录
Barcode barcodeOri = barcodeManager.findByBarcode(barcode.getBarcode());
if (barcodeOri != null){
if (barcodeOri != null) {
barcodeOri.setDisableMsg(resultStr);
barcode = barcodeManager.save(barcodeOri);
StoragePos storagePos = storagePosManager.getByBarcode(barcode.getBarcode());
if (storagePos != null){
if (storagePos != null) {
storagePos.setBarcode(barcode);
storagePosManager.save(storagePos);
}
......@@ -302,34 +315,61 @@ public class LizhenApi extends DefaultSmfApiListener {
*/
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (!task.isFinished()){
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());
DataLog oldTask = dataLogManager.findOne(new Query(Criteria.where("barcode").is(task.getBarcode()).is(OP.CHECKOUT).and("createDate")
.and("status").is(OP_STATUS.FINISHED.name()).lte(new Date())).with(Sort.by(Sort.Direction.DESC, "createDate")));
if (oldTask == null) {
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());
}
} else {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("line", oldTask.getLine());
dataMap.put("reel_id", oldTask.getBarcode());
dataMap.put("rm_type", 2);
Storage storage = dataCache.getStorageById(oldTask.getStorageId());
if (storage.isVirtual()) {
dataMap.put("rm_type", 1);
}
dataMap.put("create_empno", SecurityUtils.getLoginUsername());
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
format.setTimeZone(TimeZone.getTimeZone("UTC")); // 设置为UTC时间
String nowDateStr = format.format(date);
dataMap.put("create_time", nowDateStr);
String param = JsonUtil.toJsonStr(Arrays.asList(dataMap));
log.info("退料:" + param);
try {
String result = HttpHelper.postJson(CommonGIRecordUrl, Arrays.asList(dataMap));
log.info("退料出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
log.info(oldTask.getBarcode() + "退料异常:" + e.getMessage());
}
}
}
......@@ -350,7 +390,7 @@ public class LizhenApi extends DefaultSmfApiListener {
if (!task.isFinished()) {
return;
}
if (task.isBoxOut()){
if (task.isBoxOut()) {
return;
}
Map<String, Object> dataMap = new HashMap<>();
......@@ -358,7 +398,7 @@ public class LizhenApi extends DefaultSmfApiListener {
if (StringUtils.isNotBlank(task.getSourceName()) && StringUtils.isNotBlank(task.getLine()) && !task.isManualUpload()) {
dataMap.put("pickingid", task.getSourceName());
outNotifyUrl = outNotifyUrlPK;
log.info("出库pk不为空:"+outNotifyUrl);
log.info("出库pk不为空:" + outNotifyUrl);
}
dataMap.put("wo", "");
dataMap.put("reelno", task.getBarcode());
......@@ -375,7 +415,7 @@ public class LizhenApi extends DefaultSmfApiListener {
List<Map<String, Object>> paramList = new ArrayList();
paramList.add(dataMap);
JSONObject jsonObject = new JSONObject();
jsonObject.put("data",paramList);
jsonObject.put("data", paramList);
String param = JsonUtil.toJsonStr(jsonObject);
log.info("保存物料入参为:" + param + "地址为:" + outNotifyUrl);
try {
......@@ -466,7 +506,7 @@ public class LizhenApi extends DefaultSmfApiListener {
return StringUtils.isBlank(pickingid);
}).collect(Collectors.toList());
if (noPickingidList != null && !noPickingidList.isEmpty()){
if (noPickingidList != null && !noPickingidList.isEmpty()) {
String param = JsonUtil.toJsonStr(paramList);
log.info("保存物料入参为:" + param + "地址为:" + outNotifyUrl);
try {
......@@ -517,7 +557,7 @@ public class LizhenApi extends DefaultSmfApiListener {
}
}
if (items != null && !items.isEmpty()) {
return PreWarningItemCache.createAndExecuteLiteOrder(items,false);
return PreWarningItemCache.createAndExecuteLiteOrder(items, false);
}
}
return null;
......@@ -544,7 +584,7 @@ public class LizhenApi extends DefaultSmfApiListener {
paramList.add(paramMap);
}
String paramStr = JSON.toJSONString(paramList);
log.info("批量禁用料,入参为:" + paramStr+",地址为:"+batchCheckUrl);
log.info("批量禁用料,入参为:" + paramStr + ",地址为:" + batchCheckUrl);
try {
String result = HttpHelper.postJson(batchCheckUrl, paramList);
log.info("批量禁用料,出参为:" + result);
......@@ -579,7 +619,7 @@ public class LizhenApi extends DefaultSmfApiListener {
paramMap.put("reelID", barcode.getBarcode());
paramMap.put("ipn", barcode.getPartNumber());
try {
log.info(barcode.getBarcode() + "散料量测接口入参为-----" + JSON.toJSONString(paramMap)+",接口地址为:"+checkReelMeasureUrl);
log.info(barcode.getBarcode() + "散料量测接口入参为-----" + JSON.toJSONString(paramMap) + ",接口地址为:" + checkReelMeasureUrl);
String result = HttpHelper.postJson(checkReelMeasureUrl, paramMap);
log.info(barcode.getBarcode() + "散料量测接口出参为-----" + result);
JSONObject jsonObject = JSON.parseObject(result);
......
......@@ -14,6 +14,7 @@ api:
brandQtyUrl: #http://172.30.170.199:8082/api/wcs/brandQty #gr标签满卷数
importUrl: #http://10.42.222.52:8001/smf-core/ext/forward/getDataLogs #内仓导入外仓picking虚拟仓数据
checkReelMeasure: #http://10.190.25.124:8001/Sct/CheckReelMeasure #散料量测接口
CommonGIRecord: http://localhost:4000/Sct/CommonRMRecord
plant: #2810
werks: #2810
outerFactory:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!