mqtt修改

tags/yfai-pcn-ext-v1.0
微笑着面对明天 10 months ago
parent 4c00b71b07
commit c3e0967093

@ -9,12 +9,14 @@ import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
import java.util.List;
@ConditionalOnExpression("'${pcn.mqtt.flag:false}' == 'true'")
@Slf4j
@Configuration
public class MqttConfig {

@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
*
*/
@ -19,7 +21,8 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mqtt")
@Slf4j
public class PcnMqttController {
@Autowired
@Autowired(required = false)
private MqttService mqttService;
@GetMapping("/addTopic")

@ -27,7 +27,7 @@ public class PcnMqttCallback implements MqttCallbackExtended {
private static ExecutorService executorService = new ThreadPoolExecutor(1, 20,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(200), r -> {
new LinkedBlockingQueue<>(10000), r -> {
Thread thread = new Thread(r);
thread.setName("executorService--"+r.hashCode());
return thread;
@ -35,7 +35,7 @@ public class PcnMqttCallback implements MqttCallbackExtended {
private static ExecutorService executorServiceTwo = new ThreadPoolExecutor(1, 20,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(200), r -> {
new LinkedBlockingQueue<>(10000), r -> {
Thread thread = new Thread(r);
thread.setName("executorServiceTwo--"+r.hashCode());
return thread;

@ -157,15 +157,24 @@ public class MesEquipmentLogService implements IMesEquipmentLogService {
@Override
public void updateValue(EquipLogMqttMsg equipLogMqttMsg) {
log.info("== equipLogMqttMsg ==> messageArrived ,异步处理开始 消息内容: {}", equipLogMqttMsg);
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getStringEqualPack(equipLogMqttMsg.getKey(), "tagName", ddlPackBean);
DdlPreparedPack.getNumEqualPack(Integer.valueOf(equipLogMqttMsg.getPTCode()), "equipId", ddlPackBean);
log.info("== mesEquipmentVariable查询开始");
MesEquipmentVariable mesEquipmentVariable = equipmentVariableRepository.getByProperty(ddlPackBean);
log.info("== mesEquipmentVariable查询结束");
if (mesEquipmentVariable == null) {
LOGGER.info("tagAddress 不存在【{}】", equipLogMqttMsg.getTagAddress());
}
log.info("== MesEquipmentLog查询开始");
MesEquipmentLog equipmentLog = mesEquipmentLogExtService.queryMesEquipmentLog(mesEquipmentVariable.getOrganizeCode(), Integer.valueOf(equipLogMqttMsg.getPTCode()), mesEquipmentVariable.getId());
log.info("== MesEquipmentLog查询结束");
/*ConvertBean.serviceModelUpdate(equipmentLog, "mqtt");
equipmentLog.setEquipVariableValue(equipLogMqttMsg.getValue());
equipmentLog.setEquipVariableStatus(MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getEquipVariableStatus());
@ -174,13 +183,18 @@ public class MesEquipmentLogService implements IMesEquipmentLogService {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesEquipmentVariable.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(equipmentLog.getEquipId(), MesPcnExtConstWords.EQUIP_ID, packBean);
DdlPreparedPack.getNumEqualPack(equipmentLog.getEquipVariableId(), MesPcnExtConstWords.EQUIP_VARIABLE_ID, packBean);
log.info("== MesEquipmentLog修改开始");
mesEquipmentLogRepository.updateByProperties(new String[]{MesPcnExtConstWords.EQUIP_VARIABLE_STATUS,"equipVariableValue"}, new Object[]{MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(),equipLogMqttMsg.getValue() }, packBean);
log.info("== MesEquipmentLog修改结束");
MesEquipmentLogDetail mesEquipmentLogDetail = new MesEquipmentLogDetail();
BeanUtils.copyProperties(equipmentLog, mesEquipmentLogDetail);
ConvertBean.serviceModelInitialize(mesEquipmentLogDetail, "mqtt");
mesEquipmentLogDetailRepository.saveAll(Arrays.asList(mesEquipmentLogDetail));
log.info("== mesEquipmentLogDetail新增开始");
mesEquipmentLogDetailRepository.insert(mesEquipmentLogDetail);
log.info("== mesEquipmentLogDetail新增结束");
log.info("== equipLogMqttMsg ==> messageArrived ,异步处理结束 消息内容: {}", equipLogMqttMsg);
}
}

@ -506,10 +506,13 @@ public class MesWorkOrderService implements IMesWorkOrderService {
DdlPreparedPack.getStringEqualPack(productionRecord.getWorkCenterCode(), "workCenterCode", ddlPackBean);
MesWorkCenter mesWorkCenter = mesWorkCenterRDao.getByProperty(ddlPackBean);
if (Objects.isNull(mesWorkCenter)) {
LOGGER.error(String.format("产线【%s】不存在", productionRecord.getWorkCenterCode()));
throw new ImppBusiException(String.format("产线【%s】不存在", productionRecord.getWorkCenterCode()));
}
MesWorkOrder oldMesWorkOrder = getBestWorkOrder(productionRecord, oldMesWorkOrderList, mesWorkCenter);
if (oldMesWorkOrder == null) {
LOGGER.error(String.format("未找到匹配的加工单"));
throw new ImppBusiException(String.format("未找到匹配的加工单"));
}
//获取生产版本
@ -519,6 +522,7 @@ public class MesWorkOrderService implements IMesWorkOrderService {
DdlPreparedPack.getStringEqualPack(oldMesWorkOrder.getProductVersion(), "productVersion", ddlPackBean);
MesProductVersion mesProductVersion = mesProductVersionRDao.getByProperty(ddlPackBean);
if (null == mesProductVersion) {
LOGGER.error(String.format("物料【%s】生产版本信息不存在", productionRecord.getPartNo()));
throw new ImppBusiException(String.format("物料【%s】生产版本信息不存在", productionRecord.getPartNo()));
}
@ -528,6 +532,8 @@ public class MesWorkOrderService implements IMesWorkOrderService {
DdlPreparedPack.getStringEqualPack(mesProductVersion.getAlternativePartList(), "bomVersion", ddlPackBean);
List<MesBom> mesBoms = mesBomRDao.findByHqlWhere(ddlPackBean);
if (CollectionUtils.isEmpty(mesBoms)) {
LOGGER.error(String.format("物料【%s】生产版本【%s】对应bom信息不存在",
productionRecord.getPartNo(), mesProductVersion.getProductVersion()));
throw new ImppBusiException(String.format("物料【%s】生产版本【%s】对应bom信息不存在",
productionRecord.getPartNo(), mesProductVersion.getProductVersion()));
}

@ -13,11 +13,13 @@ import com.google.common.collect.Lists;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@ConditionalOnExpression("'${pcn.mqtt.flag:false}' == 'true'")
@Service
public class MqttServiceImpl implements MqttService {
@ -152,9 +154,9 @@ public class MqttServiceImpl implements MqttService {
@Override
public void testSendList() {
String start ="[";
for (int i=0; i<100 ; i++) {
String aa = "{\"PTCode\":\"156\",\"key\":\"aa " + i +
"\",\"value\":2,\"time\":\"2024-07-17 16:18:13\"}";
for (int i=0; i<10000 ; i++) {
String aa = "{\"PTCode\":\"300\",\"key\":\"aa499" + i +
"\",\"value\":5,\"time\":\"2024-07-17 16:18:13\"}";
start += aa;
}

Loading…
Cancel
Save