Commit 854e05a4 LN

1568中车SP对接修改

1 个父辈 23014017
...@@ -3,6 +3,7 @@ package com.neotel.smfcore.core.solder.util; ...@@ -3,6 +3,7 @@ package com.neotel.smfcore.core.solder.util;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS; import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
...@@ -18,6 +19,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos; ...@@ -18,6 +19,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.dao.IDataLogDao; import com.neotel.smfcore.core.system.service.dao.IDataLogDao;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.zhongcheSp1568.ZhongCheSPApi;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -43,6 +45,8 @@ public class SolderBoxCache { ...@@ -43,6 +45,8 @@ public class SolderBoxCache {
@Value("${sp.disStirring:}") @Value("${sp.disStirring:}")
private String disStirring=""; private String disStirring="";
@Value("${api.taskNotifyUrl:}")
protected String taskNotifyUrl = "";
@Autowired @Autowired
private DataCache dataCache; private DataCache dataCache;
@Autowired @Autowired
...@@ -101,6 +105,10 @@ public class SolderBoxCache { ...@@ -101,6 +105,10 @@ public class SolderBoxCache {
} }
@Autowired
protected SmfApi smfApi;
@Autowired
private ZhongCheSPApi zhongCheSPApi;
public void runTimer(){ public void runTimer(){
Collection<Storage> allStorage = dataCache.getAllStorage().values(); Collection<Storage> allStorage = dataCache.getAllStorage().values();
for (Storage storage : allStorage) { for (Storage storage : allStorage) {
...@@ -132,28 +140,27 @@ public class SolderBoxCache { ...@@ -132,28 +140,27 @@ public class SolderBoxCache {
} }
}else if(isInStatus(barcode,SOLDER_STATUS.REWARMING)){ }else if(isInStatus(barcode,SOLDER_STATUS.REWARMING)){
//回温中,看回温是否完成 //回温中,看回温是否完成
if(now - barcode.getStartWarmTime() >= barcode.getWarmTime() * 60 *1000){ if(now - barcode.getStartWarmTime() >= barcode.getWarmTime() * 60 *1000) {
//回温完成,更改状态为待搅拌 //回温完成,更改状态为待搅拌
if(disStirring.trim().equalsIgnoreCase("true")){ if (disStirring.trim().equalsIgnoreCase("true")) {
log.info(barcode.getBarcode() + "到达回温时间,当前已配置为禁用搅拌功能,修改状态为待出库"); log.info(barcode.getBarcode() + "到达回温时间,当前已配置为禁用搅拌功能,修改状态为待出库");
barcode.setSolderStatus(SOLDER_STATUS.TO_BE_OUT.name()); barcode.setSolderStatus(SOLDER_STATUS.TO_BE_OUT.name());
} } else if (barcode.getMixTime() <= 0) {
else if(barcode.getMixTime() <= 0){
log.info(barcode.getBarcode() + "到达回温时间,搅拌时间为0,修改状态为待出库"); log.info(barcode.getBarcode() + "到达回温时间,搅拌时间为0,修改状态为待出库");
barcode.setSolderStatus(SOLDER_STATUS.TO_BE_OUT.name()); barcode.setSolderStatus(SOLDER_STATUS.TO_BE_OUT.name());
}else{ } else {
//判断是否自动开始搅拌 //判断是否自动开始搅拌
Boolean autoStartMixed=dataCache.getCache(Constants.CACHE_SP_AUTO_START_MIXED); Boolean autoStartMixed = dataCache.getCache(Constants.CACHE_SP_AUTO_START_MIXED);
if(autoStartMixed==null){ if (autoStartMixed == null) {
autoStartMixed=false; autoStartMixed = false;
} }
if(autoStartMixed){ if (autoStartMixed) {
log.info(barcode.getBarcode() + "到达回温时间,已配置CACHE_SP_AUTO_START_MIXED=true,自动开始搅拌,修改状态=TO_BE_MIXED"); log.info(barcode.getBarcode() + "到达回温时间,已配置CACHE_SP_AUTO_START_MIXED=true,自动开始搅拌,修改状态=TO_BE_MIXED");
barcode.setSolderStatus(SOLDER_STATUS.TO_BE_MIXED.name()); barcode.setSolderStatus(SOLDER_STATUS.TO_BE_MIXED.name());
}else{ } else {
log.info(barcode.getBarcode() + "到达回温时间,修改状态为等待搅拌,待手动开始搅拌后再开始搅拌"); log.info(barcode.getBarcode() + "到达回温时间,修改状态为等待搅拌,待手动开始搅拌后再开始搅拌");
barcode.setSolderStatus(SOLDER_STATUS.WAIT_MIXED.name()); barcode.setSolderStatus(SOLDER_STATUS.WAIT_MIXED.name());
} }
...@@ -164,6 +171,11 @@ public class SolderBoxCache { ...@@ -164,6 +171,11 @@ public class SolderBoxCache {
storagePos.setBarcode(barcode); storagePos.setBarcode(barcode);
storagePosManager.save(storagePos); storagePosManager.save(storagePos);
//通知
if (zhongCheSPApi.isForThisApi(smfApi.getApiName())) {
zhongCheSPApi.SPStatusChange(taskNotifyUrl, "HW_END", barcode, new Date());
}
} }
}else if(isInStatus(barcode,SOLDER_STATUS.TO_BE_MIXED)){ }else if(isInStatus(barcode,SOLDER_STATUS.TO_BE_MIXED)){
//待搅拌,生成搅拌任务 //待搅拌,生成搅拌任务
......
...@@ -291,19 +291,17 @@ public class ZhongCheSPApi extends BaseSmfApiListener { ...@@ -291,19 +291,17 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode()); Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
String rsType = null; String rsType = null;
if(!task.isFinished()){ // if(!task.isFinished()){
//只有结束的任务才更新 // //只有结束的任务才更新
return false ; // return false ;
} // }
if(barcode==null) { if(barcode==null) {
log.error("TaskStatusChange, 任务=" + task.getBarcode() + "/" + task.getPosName() + " 未找到条码暂不处理: "); log.error("TaskStatusChange, 任务=" + task.getBarcode() + "/" + task.getPosName() + " 未找到条码暂不处理: ");
return false; return false;
} }
if (task.isCheckOutTask()) { if (task.isCheckOutTask()) {
// 领用 - 暂不支持,需要根据业务逻辑确定具体的操作类型
// log.warn("TaskStatusChange: 领用操作暂不支持,需要进一步确认业务逻辑");
return false; return false;
} else if (task.isPutInTask()) { } else if (task.isPutInTask()&&task.isFinished()) {
StoragePos pos = storagePosManager.getByPosName(task.getPosName()); StoragePos pos = storagePosManager.getByPosName(task.getPosName());
if(pos==null) { if(pos==null) {
log.error("TaskStatusChange, 任务=" + task.getBarcode() + "/" + task.getPosName() + " 未找到库位暂不处理 "); log.error("TaskStatusChange, 任务=" + task.getBarcode() + "/" + task.getPosName() + " 未找到库位暂不处理 ");
...@@ -313,15 +311,15 @@ public class ZhongCheSPApi extends BaseSmfApiListener { ...@@ -313,15 +311,15 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
// 入库到冷藏区 // 入库到冷藏区
rsType = "LC"; // 冷藏 rsType = "LC"; // 冷藏
} }
} else if (task.isRewarmTakingTask()) { } else if (task.isRewarmPuttingTask()&&task.isFinished()) {
// 回温取料 - 可能是回温开始 rsType = "HW_BEGIN"; // 已放到回温区,回温开始
rsType = "HW_BEGIN"; // 回温开始 }
} else if (task.isRewarmPuttingTask()) { else if(task.isMixTask()&&task.isExecuting()){
// 回温放料 - 可能是回温结束 rsType = "JB_BEGIN"; // 搅拌任务开始执行,搅拌开始
rsType = "HW_END"; // 回温结束 }
}else if(task.isMixTask()){ else if(task.isMixTask()&&task.isFinished()){
// 搅拌结束: JB_END // 搅拌结束: JB_END
rsType = "JB_END"; // 搅拌结束 rsType = "JB_END"; // 搅拌任务完成,搅拌结束
} }
// 可以根据具体业务需求添加搅拌相关的逻辑 // 可以根据具体业务需求添加搅拌相关的逻辑
...@@ -332,7 +330,14 @@ public class ZhongCheSPApi extends BaseSmfApiListener { ...@@ -332,7 +330,14 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
log.warn("TaskStatusChange: 未找到对应的操作类型,task类型: " + task.getType()); log.warn("TaskStatusChange: 未找到对应的操作类型,task类型: " + task.getType());
return false; return false;
} }
return SPStatusChange(url,rsType,barcode,task.getUpdateDate());
}
public boolean SPStatusChange(String url, String rsType,Barcode barcode,Date updateTime) {
if(ObjectUtil.isEmpty(url)){
return false;
}
try { try {
// 构建请求数据使用Map // 构建请求数据使用Map
Map<String, Object> request = new HashMap<>(); Map<String, Object> request = new HashMap<>();
...@@ -348,11 +353,11 @@ public class ZhongCheSPApi extends BaseSmfApiListener { ...@@ -348,11 +353,11 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
dataItem.put("rs_qty", barcode.getAmount()); // 默认数量为1,可根据实际业务调整 dataItem.put("rs_qty", barcode.getAmount()); // 默认数量为1,可根据实际业务调整
// 格式化时间为 YYYY-MM-DD HH:mm:ss // 格式化时间为 YYYY-MM-DD HH:mm:ss
String time = DateUtil.toDateString(task.getUpdateDate(), "yyyy-MM-dd HH:mm:ss"); String time = DateUtil.toDateString(updateTime, "yyyy-MM-dd HH:mm:ss");
dataItem.put("zzzc_rs_date", time); dataItem.put("zzzc_rs_date", time);
// 如果是冷藏操作,需要传生产日期 // 如果是冷藏操作,需要传生产日期
if ("LC".equals(rsType)&&ObjectUtil.isNotEmpty(barcode.getProduceDate())) { if ("LC".equals(rsType) && ObjectUtil.isNotEmpty(barcode.getProduceDate())) {
// 这里需要根据实际业务获取生产日期,暂时使用当前日期 // 这里需要根据实际业务获取生产日期,暂时使用当前日期
dataItem.put("mf_date", DateUtil.toDateString(barcode.getProduceDate(), "yyyy-MM-dd HH:mm:ss")); dataItem.put("mf_date", DateUtil.toDateString(barcode.getProduceDate(), "yyyy-MM-dd HH:mm:ss"));
} }
...@@ -387,5 +392,6 @@ public class ZhongCheSPApi extends BaseSmfApiListener { ...@@ -387,5 +392,6 @@ public class ZhongCheSPApi extends BaseSmfApiListener {
log.error("TaskStatusChange, url=" + url + " exception: " + exception.getMessage()); log.error("TaskStatusChange, url=" + url + " exception: " + exception.getMessage());
} }
return false; return false;
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!