rev:优化修改烘箱库存,获取烘箱温度

This commit is contained in:
2023-06-19 16:48:25 +08:00
parent 13fdfc5ad1
commit a40c4df837
10 changed files with 167 additions and 39 deletions

View File

@@ -56,6 +56,12 @@ public interface WmsToAcsService {
*/
JSONObject getPointStatus(JSONArray whereJson);
/**
* 获取烘箱设备状态
* @return
*/
JSONObject getHotPointStatus(JSONArray whereJson);
/**
* 更新任务状态
* @param arr /

View File

@@ -101,13 +101,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
// 任务处理类
try {
AbstractAcsTask bean = SpringContextHolder.getBean(processing_class);
bean.updateTaskStatus(row, status);
/*Class<?> clz = Class.forName(processing_class);
// AbstractAcsTask bean = SpringContextHolder.getBean(processing_class);
// bean.updateTaskStatus(row, status);
Class<?> clz = Class.forName(processing_class);
Object obj = clz.newInstance();
// 调用每个任务类的forceFinishInst()强制结束方法
Method m = obj.getClass().getDeclaredMethod("updateTaskStatus", JSONObject.class, String.class);
m.invoke(obj, row, status);*/
m.invoke(obj, row, status);
} catch (Exception e) {
e.printStackTrace();
message = e.getMessage();

View File

@@ -62,6 +62,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
return AcsUtil.notifyAcs(api, whereJson);
}
@Override
public JSONObject getHotPointStatus(JSONArray whereJson) {
String api = "api/wms/querydevice";
return AcsUtil.notifyAcs2(api, whereJson);
}
@Override
public JSONObject updateTask(JSONArray whereJson) {
String api = "api/wms/updateTask";

View File

@@ -0,0 +1,14 @@
package org.nl.wms.pda.mps.service.mapper;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Author: lyd
* @Description: mapper接口
* @Date: 2023/5/23
*/
public interface HotMapper extends BaseMapper<JSONObject> {
void updateHotByObject(JSONObject object);
}

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.pda.mps.service.mapper.HotMapper">
<update id="updateHotByObject" parameterType="com.alibaba.fastjson.JSONObject">
UPDATE st_ivt_hotpointivt
SET point_status = #{point_status}
,container_name = #{container_name}
,workorder_id = #{workorder_id}
,ivt_qty = #{ivt_qty}
,instorage_time = #{instorage_time}
,update_optid = #{update_optid}
,update_optname = #{update_optname}
,update_time = #{update_time}
WHERE point_code = #{point_code}
</update>
</mapper>

View File

@@ -620,9 +620,12 @@
point_code AS device_code,
product_area
FROM
st_ivt_hotpointivt
st_ivt_hotpointivt ivt
WHERE
is_used = '1'
OPTION 输入.product_area <> ""
ivt.product_area = 输入.product_area
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -39,7 +39,7 @@ public class AcsUtil {
JSONObject jo = list.getJSONObject(j);
String product_area = jo.getString("product_area");
if (jo.containsKey("class_type") && jo.getString("class_type").contains("0105")){
if (jo.containsKey("class_type") && jo.getString("class_type").contains("0105")) {
product_area = "LK";
}
if (StrUtil.isEmpty(product_area)) {
@@ -47,15 +47,17 @@ public class AcsUtil {
}
String acs_url = URLEnum.find(product_area);
if (StrUtil.isEmpty(acs_url)){
if (StrUtil.isEmpty(acs_url)) {
log.info(product_area);
throw new BadRequestException("未查询到区域对应的acs地址");
}
String url = acs_url + api;
try {
JSONArray rows = new JSONArray();
rows.add(jo);
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(list))
.body(String.valueOf(rows))
.execute().body();
result = JSONObject.parseObject(resultMsg);
log.info("ACS相应参数----------------------------------------+" + api + ",---" + result.toString());
@@ -86,6 +88,70 @@ public class AcsUtil {
}
return result;
}
public static JSONObject notifyAcs2(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 (jo.containsKey("class_type") && jo.getString("class_type").contains("0105")) {
product_area = "LK";
}
if (StrUtil.isEmpty(product_area)) {
throw new BadRequestException("区域不能为空!下发信息:" + jo.toString());
}
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) {
String msg = e.getMessage();
//ConnectException: Connection refused: connect
//网络不通
System.out.println(msg);
result.put("status", HttpStatus.BAD_REQUEST);
result.put("message", "网络不通,操作失败!");
result.put("data", new JSONObject());
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException(result.getString("message"));
} else {
//如果向ACS下发任务变更任务状态为下发
if (api.equals("api/wms/task")) {
for (int i = 0; i < list.size(); i++) {
JSONObject task_jo = list.getJSONObject(i);
HashMap<String, String> map = new HashMap<>();
map.put("task_status", TaskStatusEnum.ISSUE.getCode());
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + task_jo.getString("ext_task_id") + "'");
}
}
}
return result;
}
}

View File

@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.sch.tasks.URLEnum;
import org.springframework.stereotype.Component;
@Slf4j
@@ -18,33 +19,44 @@ public class AutoQueryDeviceStatus {
private final WmsToAcsService wmsToAcsService;
public void run() {
//通过ACS接口获取温度
JSONArray device_rows = WQL.getWO("PDA_02").addParam("flag", "15").process().getResultJSONArray(0);
JSONObject jo = wmsToAcsService.getPointStatus(device_rows);
WQLObject ivtTab = WQLObject.getWQLObject("st_ivt_hotpointivt");
JSONArray de_rows = jo.getJSONArray("data");
for (int i = 0; i < de_rows.size(); i++) {
JSONObject row = de_rows.getJSONObject(i);
String device_code = row.getString("device_code");
JSONObject point_jo = ivtTab.query("point_code = '" + device_code + "'").uniqueResult(0);
point_jo.put("temperature", row.getString("temperature"));
//获取倒计时,分,秒
String countdown_house = row.getString("countdown_house");
String countdown_min = row.getString("countdown_min");
String countdown_sec = row.getString("countdown_sec");
for (URLEnum url : URLEnum.values()) {
try {
String product_area = url.getProduct_area();
//通过ACS接口获取温度
JSONArray device_rows = WQL.getWO("PDA_02").addParam("flag", "15").addParam("product_area", product_area).process().getResultJSONArray(0);
if (device_rows.size() == 0){
continue;
}
JSONObject jo = wmsToAcsService.getHotPointStatus(device_rows);
WQLObject ivtTab = WQLObject.getWQLObject("st_ivt_hotpointivt");
JSONArray de_rows = jo.getJSONArray("data");
for (int i = 0; i < de_rows.size(); i++) {
JSONObject row = de_rows.getJSONObject(i);
String device_code = row.getString("device_code");
JSONObject point_jo = ivtTab.query("point_code = '" + device_code + "'").uniqueResult(0);
point_jo.put("temperature", row.getString("temperature"));
//获取倒计时,分,秒
String countdown_house = row.getString("countdown_house");
String countdown_min = row.getString("countdown_min");
String countdown_sec = row.getString("countdown_sec");
if (StrUtil.isEmpty(countdown_house)) {
countdown_house = "0";
if (StrUtil.isEmpty(countdown_house)) {
countdown_house = "0";
}
if (StrUtil.isEmpty(countdown_min)) {
countdown_min = "0";
}
if (StrUtil.isEmpty(countdown_sec)) {
countdown_sec = "0";
}
String last_time = countdown_house + "小时" + countdown_min + "分钟";
point_jo.put("last_time", last_time);
ivtTab.update(point_jo);
}
} catch (Exception e) {
log.info(e.getMessage());
}
if (StrUtil.isEmpty(countdown_min)) {
countdown_min = "0";
}
if (StrUtil.isEmpty(countdown_sec)) {
countdown_sec = "0";
}
String last_time = countdown_house + "小时" + countdown_min + "分钟";
point_jo.put("last_time", last_time);
ivtTab.update(point_jo);
}
}
}

View File

@@ -11,12 +11,12 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
import org.nl.wms.pda.mps.service.mapper.HotMapper;
import org.nl.wms.sch.AcsTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
@@ -185,7 +185,10 @@ public class InHotTask extends AbstractAcsTask {
jsonHotIvt.put("update_optid", currentUserId);
jsonHotIvt.put("update_optname", currentUsername);
jsonHotIvt.put("update_time", DateUtil.now());
hotIvtTab.update(jsonHotIvt);
//hotIvtTab.update(jsonHotIvt);
log.info("mybatis执行update语句");
HotMapper hotMapper = SpringContextHolder.getBean(HotMapper.class);
hotMapper.updateHotByObject(jsonHotIvt);
hot_point_code = jsonHotIvt.getString("ext_code");
}

View File

@@ -180,12 +180,13 @@ export default {
},
initStatus() {
const data = {
'region_code': this.form.flag
'product_area': this.form.flag
}
queryDeviceInfo(data).then(res => {
this.listA1 = res.data.jsonA1
this.listLk = res.data.jsonLK
this.changeFlag(this.form.flag)
// this.listA1 = res.data.jsonA1
// this.listLk = res.data.jsonLK
// this.changeFlag(this.form.flag)
this.agvList = res.data
})
},
changeFlag(val) {