Commit 3be0048e zshaohui

工单出库逻辑修改

1 个父辈 8fde5746
......@@ -15,7 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.RestController;
//@EnableAsync
@EnableScheduling
//@EnableScheduling
@EnableKafka
@RestController
@SpringBootApplication
......
......@@ -46,7 +46,7 @@ public class MainTimer {
public void run() {
timerTask();
}
}, 5, 10, TimeUnit.SECONDS);
}, 5, 30, TimeUnit.SECONDS);
//log.info("如果是人工叫料,则每2分钟执行一次");
scheduledThreadPool.scheduleAtFixedRate(new Runnable() {
......@@ -72,18 +72,11 @@ public class MainTimer {
}
private void timerTask() {
if (!preGenerateTaskTime()) {
return;
}
lastPreGenerateTaskTime = System.currentTimeMillis();
try {
log.info("生成缺料预警任务");
//PreWarningItemCache.runTimer(0);
PreWarningItemCache.runTimer(1);
//liteOrderCache.runTimer(0);
//log.info("生成缺料预警任务");
PreWarningItemCache.runTimer();
//设备状态判断
DevicesStatusUtil.runTimer();
//其他设备状态判断
EquipStatusUtil.runTimer();
} catch (Exception e) {
......
......@@ -175,4 +175,14 @@ public class Constants {
* 工单生成个数
*/
public static final String CACHE_preGenerateTask_Times = "preGenerateTask_times";
/**
* 线体配置
*/
public static final String CACHE_lineConfigList = "CACHE_lineConfigList";
/**
* 迈征配置分钟
*/
public static final String CACHE_maiZhengMinute = "maiZhengMinute";
}
......@@ -46,24 +46,36 @@ public class HttpHelper {
ObjectMapper mapper = new ObjectMapper();
try {
String requestBody = mapper.writeValueAsString(object);
httpPost.setEntity(new StringEntity(requestBody,CONTENT_CHARSET));
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
} catch (JsonProcessingException e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
}
}
try{
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpPost);
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost);
//System.out.println(response.getStatusLine().getStatusCode() + "\n");
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
response.close();
httpClient.close();
return responseContent;
}catch (Exception e){
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -76,24 +88,37 @@ public class HttpHelper {
ObjectMapper mapper = new ObjectMapper();
try {
String requestBody = mapper.writeValueAsString(params);
httpPost.setEntity(new StringEntity(requestBody,CONTENT_CHARSET));
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
} catch (JsonProcessingException e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
}
}
try{
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpPost);
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost);
//System.out.println(response.getStatusLine().getStatusCode() + "\n");
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
response.close();
httpClient.close();
return responseContent;
}catch (Exception e){
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -122,15 +147,16 @@ public class HttpHelper {
params.add(new BasicNameValuePair(entry.getKey(),value));
}
}
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
URI uri = new URIBuilder(url).setParameters(params).build();
log.info("执行MES请求:"+uri.toString());
HttpPost httpPost = new HttpPost(uri);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
// httpPost.setEntity(new UrlEncodedFormEntity(params, CONTENT_CHARSET));
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpPost);
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
response.close();
......@@ -138,6 +164,17 @@ public class HttpHelper {
return responseContent;
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -156,9 +193,10 @@ public class HttpHelper {
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000).build();
httpget.setConfig(build);
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpget);
} catch (IOException e1) {
e1.printStackTrace();
......@@ -173,7 +211,12 @@ public class HttpHelper {
e.printStackTrace();
} finally {
try {
if (httpClient != null){
httpClient.close();
}
if (response != null) {
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -23,6 +23,7 @@ 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.OrderSetting;
import com.neotel.smfcore.core.system.rest.bean.LineConfig;
import com.neotel.smfcore.core.system.service.dao.ICacheItemDao;
import com.neotel.smfcore.core.system.service.dao.ISettingsDao;
import com.neotel.smfcore.core.system.service.po.CacheItem;
......@@ -709,4 +710,16 @@ public class DataCache {
}
return 0;
}
public int getLineConfigMinute(String line) {
List<LineConfig> lineConfigList = getCache(Constants.CACHE_lineConfigList);
if (lineConfigList != null && !lineConfigList.isEmpty()){
for (LineConfig lineConfig : lineConfigList) {
if (lineConfig.getLine().equals(line)){
return lineConfig.getMinute();
}
}
}
return 0;
}
}
......@@ -219,6 +219,9 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
*/
private Date issuanceDate;
private Date receiveDate;
/**
* 出库是否满足要求,已出库数量大于需求数量
*/
......
......@@ -13,6 +13,7 @@ import com.neotel.smfcore.core.language.service.po.LanguageMsg;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.bean.OrderSetting;
import com.neotel.smfcore.core.system.rest.bean.LineConfig;
import com.neotel.smfcore.core.system.rest.bean.dto.SettingsDto;
import com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto;
import com.neotel.smfcore.core.system.rest.bean.mapstruct.SettingsMapper;
......@@ -76,6 +77,9 @@ public class SettingsController {
String permissionPassword = dataCache.getCache(Constants.CACHE_permissionPassword);
String floor = dataCache.getCache(Constants.CACHE_floor);
Integer preGenerateTaskTimes = dataCache.getCache(Constants.CACHE_preGenerateTask_Times);
List<LineConfig> lineConfigList = dataCache.getCache(Constants.CACHE_lineConfigList);
Integer maiZhengMinute = dataCache.getCache(Constants.CACHE_maiZhengMinute);
SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob);
dto.setStopOut(stopOut);
......@@ -84,6 +88,8 @@ public class SettingsController {
dto.setPermissionPassword(permissionPassword);
dto.setFloor(floor);
dto.setPreGenerateTaskTimes(preGenerateTaskTimes);
dto.setLineConfigList(lineConfigList);
dto.setMaiZhengMinute(maiZhengMinute);
return dto;
}
......@@ -98,12 +104,24 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_permissionPassword,sysSettingsDto.getPermissionPassword());
dataCache.updateCache(Constants.CACHE_floor,sysSettingsDto.getFloor());
dataCache.updateCache(Constants.CACHE_preGenerateTask_Times,sysSettingsDto.getPreGenerateTaskTimes());
List<LineConfig> lineConfigList = sysSettingsDto.getLineConfigList();
if (lineConfigList == null){
lineConfigList = new ArrayList<>();
}
dataCache.updateCache(Constants.CACHE_lineConfigList,lineConfigList);
if (sysSettingsDto.getMaiZhengMinute() != null) {
dataCache.updateCache(Constants.CACHE_maiZhengMinute, sysSettingsDto.getMaiZhengMinute());
}
log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()
+ ",backUpMonth=" + sysSettingsDto.getBackUpMonth()
+ ",preGenerateTask=" + sysSettingsDto.getPreGenerateTask()
+ ",permissionPassword=" + sysSettingsDto.getPermissionPassword()
+ ",floor=" + sysSettingsDto.getFloor()
+",preGenerateTaskTimes=" +sysSettingsDto.getPreGenerateTaskTimes()
+",lineConfigList="+sysSettingsDto.getLineConfigList()
+",maiZhengMinute="+sysSettingsDto.getMaiZhengMinute()
);
return ResultBean.newOkResult("保存成功");
}
......
package com.neotel.smfcore.core.system.rest.bean;
import lombok.Data;
@Data
public class LineConfig {
private String line;
private int minute;
}
package com.neotel.smfcore.core.system.rest.bean.dto;
import com.neotel.smfcore.core.system.rest.bean.LineConfig;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
@Getter
@Setter
public class SysSettingsDto implements Serializable {
......@@ -30,4 +34,12 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty("楼层信息")
private String floor="";
@ApiModelProperty("线体配置")
private List<LineConfig> lineConfigList;
@ApiModelProperty("迈征配置时间")
private Integer maiZhengMinute;
}
......@@ -540,8 +540,11 @@ public class TaskService {
if (outTask != null) {
log.info(outTask.getSourceName()+"barcode为:"+outTask.getBarcode()+"面别为:"+outTask.getSide());
if(StringUtils.isNotBlank(outTask.getSide())) {
exportMap.put(cid, outTask.getSide());
}
}
return outTask;
}
......
......@@ -517,7 +517,7 @@ public class LizhenApi extends DefaultSmfApiListener {
}
}
if (items != null && !items.isEmpty()) {
return PreWarningItemCache.createAndExecuteLiteOrder(items,2,false);
return PreWarningItemCache.createAndExecuteLiteOrder(items,false);
}
}
return null;
......
......@@ -232,7 +232,12 @@ public class LizhenController {
item.setPartnumber(data.get("PARTNUMBER"));
item.setLine(data.get("LINE"));
item.setItemId(data.get("ID"));
try {
item.setPriority(Integer.valueOf(data.get("PRIORITY")));
} catch (NumberFormatException e) {
e.printStackTrace();
item.setPriority(0);
}
item.setReel(data.get("REEL"));
item.setBrand(data.get("VENDOR"));
......
......@@ -94,7 +94,7 @@ public class InnerBoxRestController {
String hSerial = request.getParameter("hSerial"); //工单序号
String outlet = request.getParameter("outlet"); //出口位置
String boxSide = request.getParameter("boxSide"); //料箱隔口
log.info("IA 出库更新任务状态--barcode:{},status:{},loc:{},hSerial:{},outlet:{},boxSide:{}", code, status, loc, hSerial, outlet, boxSide);
log.info("IA 出库更新任务状态--barcode:{},status:{},loc:{},hSerial:{},outlet:{},boxSide:{},cid:{},outlet:{}", code, status, loc, hSerial, outlet, boxSide,cid,outlet);
CodeBean codeBean = codeResolve.resolveSingleCode(code);
Barcode barcode = codeBean.getBarcode();
......@@ -121,7 +121,7 @@ public class InnerBoxRestController {
return ResultBean.newErrorResult(304, "smfcore.task.hasEnd", "任务已完成");
}
status = status.toUpperCase();
log.info("更新任务状态:{}-->{}", opTask.getStatus(), status);
//log.info("更新任务状态:{}-->{}", opTask.getStatus(), status);
//调用此接口的肯定是料盘已出仓位的
if(opTask.isExecuting()){
......
......@@ -61,6 +61,8 @@ public class PrinterRestController {
String code = paramMap.get("code");
log.info("补打印标签:"+code);
CodeBean codeBean = codeResolve.resolveSingleCode(code);
Barcode barcode = codeBean.getBarcode();
......
......@@ -19,7 +19,11 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
//@Async
......@@ -37,10 +41,21 @@ public class KafkaService {
Map<String,String> statusMap = Maps.newConcurrentMap();
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
@PostConstruct
void init(){
scheduledThreadPool.scheduleAtFixedRate(
() -> {
setMachineStatus();
setHeartbeat();
},5,60, TimeUnit.SECONDS
);
}
/**
* 设备状态发送
*/
@Scheduled(fixedRate = 1000 * 60 * 1)
//@Scheduled(fixedRate = 1000 * 60 * 2)
public void setMachineStatus() {
log.info("发送设备状态开始");
Collection<Storage> storages = dataCache.getAllStorage().values();
......@@ -111,7 +126,7 @@ public class KafkaService {
/**
* 心跳数据发送
*/
@Scheduled(fixedRate = 1000 * 60 * 5)
//@Scheduled(fixedRate = 1000 * 60 * 5)
public void setHeartbeat() {
log.info("发送心跳开始");
//根据machineId,找到设备状态,是否正常
......
......@@ -328,6 +328,7 @@ public class InnerReportController {
resultMap.put("料号", dto.getPn() == null ? "" : dto.getPn());
resultMap.put("需求卷", dto.getNeedReelCount());
resultMap.put("实发卷", dto.getOutReelCount());
resultMap.put("创建时间",dto.getCreateDate());
results.add(resultMap);
}
try {
......
package com.neotel.smfcore.custom.lizhen.third.maicheng.util;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.lizhen.third.maicheng.api.MaiZhengApi;
import com.neotel.smfcore.custom.lizhen.third.maicheng.bean.StationStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
@Service
......@@ -24,10 +23,13 @@ public class StationStatusCache {
@Autowired
private DataCache dataCache;
public static final String MAICHENG_STATIONSTATUS_CACHE = "MaiChengStationStatusCache";
public static final String MAIZHENG_STATIONSTATUS_CACHE_Map = "MaiZhengStationStatusCacheMap";
private static List<StationStatus> stationStatusList = Lists.newCopyOnWriteArrayList();
public static final String MAIZHENG_STATIONSTATUS_CACHE_Line_List = "MaiZhengStationStatusCacheLineList";
public static List<String> stationStatusLineList = new CopyOnWriteArrayList<>();
private static Map<String, String> stationStatusMap = Maps.newConcurrentMap();
@PostConstruct
public void init() {
......@@ -36,9 +38,13 @@ public class StationStatusCache {
if (statusList != null && !statusList.isEmpty()) {
updateStatusList(statusList);
} else {
List<StationStatus> statusCacheList = dataCache.getCache(MAICHENG_STATIONSTATUS_CACHE);
if (statusCacheList != null && !statusCacheList.isEmpty()) {
updateStatusList(statusCacheList);
Map<String, String> cacheMap = dataCache.getCache(MAIZHENG_STATIONSTATUS_CACHE_Map);
if (cacheMap != null) {
stationStatusMap.putAll(cacheMap);
}
List<String> cacheLineList = dataCache.getCache(MAIZHENG_STATIONSTATUS_CACHE_Line_List);
if (cacheLineList != null) {
stationStatusLineList.addAll(cacheLineList);
}
}
} catch (Exception e) {
......@@ -47,30 +53,39 @@ public class StationStatusCache {
}
public void updateStatusList(List<StationStatus> statusList) {
stationStatusList.clear();
stationStatusList.addAll(statusList);
dataCache.updateCache(MAICHENG_STATIONSTATUS_CACHE, stationStatusList);
}
stationStatusMap.clear();
stationStatusLineList.clear();
for (StationStatus stationStatus : statusList) {
String station = stationStatus.getSTATION();
String partnumber = stationStatus.getPARTNUMBER();
String slot = stationStatus.getSLOT();
String line = stationStatus.getLINE();
String side = stationStatus.getSIDE();
String key = station + "_" + partnumber + "_" + slot + "_" + line+"_"+side;
stationStatusMap.put(key, key);
public List<StationStatus> getAllStationStatus() {
List<StationStatus> statusList = new ArrayList<>();
if (stationStatusList == null || stationStatusList.isEmpty()) {
stationStatusList = dataCache.getCache(MAICHENG_STATIONSTATUS_CACHE);
}
if (stationStatusList != null && !stationStatusList.isEmpty()) {
for (StationStatus status : stationStatusList) {
String station = status.getSTATION();
String trackNumber = "";
if (StringUtils.isNotBlank(station)) {
String trackNumber = station.substring(station.length() - 1);
status.setTrackNumber(trackNumber);
trackNumber = station.substring(station.length() - 1);
}
statusList.add(status);
String cacheLine = line + "_" + side + "_" + trackNumber;
stationStatusLineList.add(cacheLine);
}
dataCache.updateCache(MAIZHENG_STATIONSTATUS_CACHE_Map, stationStatusMap);
if (stationStatusLineList != null && !stationStatusLineList.isEmpty()){
stationStatusLineList = stationStatusLineList.stream().distinct().collect(Collectors.toList());
dataCache.updateCache(MAIZHENG_STATIONSTATUS_CACHE_Line_List, stationStatusLineList);
}
}
if (statusList != null && !statusList.isEmpty()){
statusList = statusList.stream().distinct().collect(Collectors.toList());
public static Map<String, String> getStationStatusMap() {
return stationStatusMap;
}
return statusList;
public static List<String> getStationStatusLineList() {
return stationStatusLineList;
}
}
......@@ -13,7 +13,7 @@ api:
fetchGRUrl: #http://10.42.25.199:8082/api/wcs/fetchGR #gr标签
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.149:8001/Sct/CheckReelMeasure #散料量测接口
checkReelMeasure: #http://10.190.25.124:8001/Sct/CheckReelMeasure #散料量测接口
plant: 2810
werks: 2810
outerFactory:
......@@ -40,7 +40,7 @@ lizhen:
url: http://172.30.97.63:8001/smf-core/api/Mes/machineCallMaterial
F4:
name: 4F
line: B03-4FSMT-11,B03-4FSMT-01,B03-4FSMT-13,B03-4FSMT-03,B03-4FSMT-14
line: B03-4FSMT-11,B03-4FSMT-01,B03-4FSMT-13,B03-4FSMT-03,B03-4FSMT-14,B03-4FSMT-04
url: http://172.25.252.12:8001/smf-core/api/Mes/machineCallMaterial
......@@ -102,6 +102,5 @@ app:
type: ""
menu:
show: meInventory,meExpiredReport,meChangeReport,meprohibitedReport
show: #innerMaterial
hide:
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!