add: 联调
This commit is contained in:
@@ -44,7 +44,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
@Override
|
||||
public JSONObject getHotPointStatus(JSONArray deviceRows) {
|
||||
String api = "api/wms/querydevice";
|
||||
return AcsUtil.notifyAcs(api, deviceRows);
|
||||
return AcsUtil.notifyAcs5(api, deviceRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -200,6 +200,7 @@ public class BakingPdaServiceImpl implements BakingPdaService {
|
||||
rawOrder.setIs_baking(isBaking);
|
||||
rawOrder.setRoll_type(rollType);
|
||||
rawOrder.setWind_roll(rollCode);
|
||||
rawOrder.setBaking_temperature(temperature);
|
||||
rawOrder.setBaking_time(time);
|
||||
TaskUtils.setRawOrderCreateByDefault(rawOrder);
|
||||
rawOrder.setProduct_area("A1");
|
||||
|
||||
@@ -44,9 +44,10 @@ public class AutoCreateInHotTask {
|
||||
List<SchBasePoint> hotNotTaskPoints = pointService.getHotNotTaskPoint("A1", HX_REGION,
|
||||
null, "2");
|
||||
log.info("找到待烘烤的暂存位:{}", hotNotTaskPoints);
|
||||
//烘箱入烘箱任务行架不支持
|
||||
// 获取烘箱点位状态是暂存且需要烘烤的点位数据。
|
||||
List<StIvtHotpointivt> hotPoints = hotpointivtService.getNeedBakingPoint();
|
||||
log.info("找到待烘烤的烘箱位:{}", hotPoints);
|
||||
// List<StIvtHotpointivt> hotPoints = hotpointivtService.getNeedBakingPoint();
|
||||
// log.info("找到待烘烤的烘箱位:{}", hotPoints);
|
||||
// 合并一起
|
||||
List<NeedBakingDto> collect1 = hotNotTaskPoints.stream().map(item -> NeedBakingDto
|
||||
.builder()
|
||||
@@ -54,15 +55,16 @@ public class AutoCreateInHotTask {
|
||||
.workorder_id(item.getSource_id())
|
||||
.vehicle_code(item.getVehicle_code())
|
||||
.update_time(item.getUpdate_time()).build()).collect(Collectors.toList());
|
||||
List<NeedBakingDto> collect2 = hotPoints.stream().map(item -> NeedBakingDto
|
||||
.builder()
|
||||
.point_code(item.getPoint_code())
|
||||
.vehicle_code(item.getFull_vehicle_code())
|
||||
.workorder_id(item.getWorkorder_id())
|
||||
.update_time(item.getUpdate_time()).build()).collect(Collectors.toList());
|
||||
//烘箱入烘箱任务行架不支持
|
||||
// List<NeedBakingDto> collect2 = hotPoints.stream().map(item -> NeedBakingDto
|
||||
// .builder()
|
||||
// .point_code(item.getPoint_code())
|
||||
// .vehicle_code(item.getFull_vehicle_code())
|
||||
// .workorder_id(item.getWorkorder_id())
|
||||
// .update_time(item.getUpdate_time()).build()).collect(Collectors.toList());
|
||||
List<NeedBakingDto> combinedList = new ArrayList<>();
|
||||
combinedList.addAll(collect1);
|
||||
combinedList.addAll(collect2);
|
||||
// combinedList.addAll(collect2);
|
||||
combinedList.sort(Comparator.comparing(NeedBakingDto::getUpdate_time));
|
||||
log.info("排序后的数据 {}", combinedList);
|
||||
// 调用自动入烘箱的任务
|
||||
|
||||
@@ -4,11 +4,14 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.pdm.ivt.hot.service.IstIvtHotpointivtService;
|
||||
import org.nl.wms.pdm.ivt.hot.service.dao.StIvtHotpointivt;
|
||||
import org.nl.wms.quartz.dto.HotDeviceAndEreaDto;
|
||||
import org.nl.wms.util.URLEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -19,6 +22,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动查询烘箱温度
|
||||
*
|
||||
* @Author: lyd
|
||||
* @Date: 2024/8/9
|
||||
*/
|
||||
@@ -31,6 +35,8 @@ public class AutoQueryDeviceStatus {
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
@Autowired
|
||||
private IstIvtHotpointivtService hotpointivtService;
|
||||
@Autowired
|
||||
private ISysParamService paramService;
|
||||
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
@@ -43,7 +49,7 @@ public class AutoQueryDeviceStatus {
|
||||
if (device_rows.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
JSONArray array= JSONArray.parseArray(JSON.toJSONString(device_rows));
|
||||
JSONArray array = JSONArray.parseArray(JSON.toJSONString(device_rows));
|
||||
JSONObject jo = wmsToAcsService.getHotPointStatus(array);
|
||||
JSONArray de_rows = jo.getJSONArray("data");
|
||||
for (int i = 0; i < de_rows.size(); i++) {
|
||||
@@ -63,9 +69,27 @@ public class AutoQueryDeviceStatus {
|
||||
if (StrUtil.isEmpty(countdown_sec)) {
|
||||
countdown_sec = "0";
|
||||
}
|
||||
String last_time = countdown_house + "小时" + countdown_min + "分钟";
|
||||
redisUtils.hset(device_code, "temperature", row.getString("temperature"));
|
||||
redisUtils.hset(device_code, "last_time", last_time);
|
||||
|
||||
//实际温度小于预设关机温度,烘箱改为关机状态
|
||||
// String temperature = (String) redisUtils.hget(device_code, "temperature");
|
||||
// String hotNotuseTemperature = paramService.findByCode("HOT_NOTUSE_TEMPERATURE").getValue();
|
||||
// if (!StrUtil.equals(row.getString("temperature"), temperature) && row.getString("temperature").compareTo(hotNotuseTemperature) < 0) {
|
||||
// hotpointivtService.update(new LambdaUpdateWrapper<StIvtHotpointivt>()
|
||||
// .set(StIvtHotpointivt::getIs_used, "0")
|
||||
// .eq(StIvtHotpointivt::getPoint_code, device_code));
|
||||
// }
|
||||
//如果烘箱关机,则温度为0
|
||||
if ("0".equals(row.getString("mode"))){
|
||||
String last_time = countdown_house + "小时" + countdown_min + "分钟";
|
||||
redisUtils.hset(device_code, "temperature","0");
|
||||
redisUtils.hset(device_code, "last_time", last_time);
|
||||
}else {
|
||||
String last_time = countdown_house + "小时" + countdown_min + "分钟";
|
||||
redisUtils.hset(device_code, "temperature", row.getString("temperature"));
|
||||
redisUtils.hset(device_code, "last_time", last_time);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("获取温度出现异常:{}", e);
|
||||
|
||||
@@ -35,7 +35,8 @@ import java.util.List;
|
||||
public class AcsUtil {
|
||||
/**
|
||||
* 对数组进行拆分独自下发
|
||||
* @param api 请求路径
|
||||
*
|
||||
* @param api 请求路径
|
||||
* @param list 数据数组
|
||||
* @return acs响应
|
||||
*/
|
||||
@@ -79,10 +80,10 @@ public class AcsUtil {
|
||||
result.put("message", "网络不通,操作失败!");
|
||||
result.put("data", new JSONObject());
|
||||
log.error("ACS出现异常: {}", e);
|
||||
log.info("下发ACS任务失败,原因是:----------------------------------------+"+ msg);
|
||||
log.info("下发ACS任务失败,原因是:----------------------------------------+" + msg);
|
||||
}
|
||||
if (!StrUtil.equals(result.getString("status"), "200")) {
|
||||
log.info("下发acs任务失败,原因是:----------------------------------------+"+ result.getString("message"));
|
||||
log.info("下发acs任务失败,原因是:----------------------------------------+" + result.getString("message"));
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
} else {
|
||||
//如果向ACS下发任务,变更任务状态为下发
|
||||
@@ -98,16 +99,67 @@ public class AcsUtil {
|
||||
}
|
||||
|
||||
}
|
||||
log.info("下发acs任务,结果是:----------------------------------------+"+ result);
|
||||
log.info("下发acs任务,结果是:----------------------------------------+" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static JSONObject notifyAcs5(String api, JSONArray list) {
|
||||
log.info("下发ACS参数----------------------------------------+" + api + ",---" + list.toString());
|
||||
//判断是否连接ACS系统
|
||||
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
|
||||
JSONObject result = new JSONObject();
|
||||
if (StrUtil.equals("0", isConnect)) {
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "下发成功,但未连接ACS!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
JSONObject jo = list.getJSONObject(0);
|
||||
String product_area = jo.getString("product_area");
|
||||
if (StrUtil.isEmpty(product_area)) {
|
||||
throw new BadRequestException("区域不能为空!下发信息:" + jo);
|
||||
}
|
||||
String acs_url = URLEnum.find(product_area);
|
||||
if (StrUtil.isEmpty(acs_url)) {
|
||||
log.info(product_area);
|
||||
throw new BadRequestException("未查询到区域对应的acs地址!");
|
||||
}
|
||||
String url = acs_url + api;
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(list))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("下发acs任务成功,返回参数----------------------------------------+" + api + ",---" + result.toString());
|
||||
} catch (Exception e) {
|
||||
//acs抛异常这里
|
||||
String msg = e.getMessage();
|
||||
//ConnectException: Connection refused: connect
|
||||
//网络不通
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", "网络不通,操作失败!");
|
||||
result.put("data", new JSONObject());
|
||||
log.error("ACS出现异常: {}", e);
|
||||
log.info("下发ACS任务失败,原因是:----------------------------------------+" + msg);
|
||||
}
|
||||
if (!StrUtil.equals(result.getString("status"), "200")) {
|
||||
log.info("下发acs任务失败,原因是:----------------------------------------+" + result.getString("message"));
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
}
|
||||
|
||||
log.info("下发acs任务,结果是:----------------------------------------+" + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 原生默认请求方法: 默认执行的参数都是jsonArray
|
||||
*
|
||||
* @param api
|
||||
* @param list
|
||||
* @return
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> ResultForAcs notifyAcs2(String api, List<T> list) {
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
@@ -149,10 +201,11 @@ public class AcsUtil {
|
||||
|
||||
/**
|
||||
* 新的请求方式:对象中包含数组
|
||||
*
|
||||
* @param api
|
||||
* @param object
|
||||
* @return
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> AcsResponse notifyAcs3(String api, T object) {
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
@@ -189,9 +242,11 @@ public class AcsUtil {
|
||||
}
|
||||
return resultForAcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组一次性下发
|
||||
* @param api 请求路径
|
||||
*
|
||||
* @param api 请求路径
|
||||
* @param list 数据数组
|
||||
* @return acs响应
|
||||
*/
|
||||
|
||||
@@ -97,6 +97,9 @@ public class AutoInHotTrussTask extends AbstractTask {
|
||||
}
|
||||
// 临时测试
|
||||
// task.setPoint_code2(hxPoint.getPoint_code());
|
||||
}
|
||||
if (ObjectUtil.isEmpty(task.getPoint_code2())) {
|
||||
log.error("找不到缓存温度为:{} 的可用烘箱位置", bakingTemperature);
|
||||
break;
|
||||
}
|
||||
JSONObject param = new JSONObject();
|
||||
|
||||
@@ -70,8 +70,8 @@ public class InHotTrussTask extends AbstractTask {
|
||||
String flag = "0";
|
||||
PdmBiRawfoilworkorder order = rawfoilworkorderService.getByContainerName(orderCode);
|
||||
// TODO: 没有设置是否烘烤、时间、温度、不继续
|
||||
|
||||
if (GeneralDefinition.YES.equals(order.getIs_baking())) {
|
||||
|
||||
String bakingTemperature = order.getBaking_temperature();
|
||||
requestObj.put("baking_temperature", bakingTemperature);
|
||||
requestObj.put("baking_time", order.getBaking_time());
|
||||
@@ -90,7 +90,6 @@ public class InHotTrussTask extends AbstractTask {
|
||||
}
|
||||
// 临时测试
|
||||
// task.setPoint_code2(hotPoint.getPoint_code());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 没有烘烤位置或者没有找到对应的点就区待烘烤区, 就去待烘烤
|
||||
|
||||
@@ -10,7 +10,7 @@ nl:
|
||||
password: NLABC&ld123
|
||||
database: ldnx_lms2
|
||||
redis:
|
||||
ip: 192.168.20.15
|
||||
ip: 127.0.0.1
|
||||
port: 6379
|
||||
password: null
|
||||
database: 1
|
||||
|
||||
Reference in New Issue
Block a user