feat():电文信号模拟测试
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package com.fizz.business.comm.OPC;
|
package com.fizz.business.comm.OPC;
|
||||||
|
|
||||||
import com.fizz.business.anno.MyLog;
|
|
||||||
import com.fizz.business.constants.enums.ExitCutTypeEnum;
|
import com.fizz.business.constants.enums.ExitCutTypeEnum;
|
||||||
import com.fizz.business.constants.enums.OpcMessageType;
|
import com.fizz.business.constants.enums.OpcMessageType;
|
||||||
import com.fizz.business.domain.msg.*;
|
import com.fizz.business.domain.msg.*;
|
||||||
@@ -10,7 +9,6 @@ import com.kangaroohy.milo.model.ReadWriteEntity;
|
|||||||
import com.kangaroohy.milo.service.MiloService;
|
import com.kangaroohy.milo.service.MiloService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.beanutils.BeanUtils;
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
import org.apache.commons.compress.utils.Lists;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@@ -122,7 +120,7 @@ public class MessageSubscriptionRunner implements ApplicationRunner {
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ExitMeasureMessage msg = new ExitMeasureMessage();
|
ExitMeasureMessage msg = new ExitMeasureMessage();
|
||||||
writeMessage(msg,exitMoveIds);
|
writeMessage(msg,exitMeasureIds);
|
||||||
log.info("接收出口称重信号:重量 {} ", msg.getWeight());
|
log.info("接收出口称重信号:重量 {} ", msg.getWeight());
|
||||||
logDataService.logInfo("TRACK","接收出口称重信号:重量 {} ", msg.getWeight());
|
logDataService.logInfo("TRACK","接收出口称重信号:重量 {} ", msg.getWeight());
|
||||||
opcReceiverHandler.onMessageReceived(OpcMessageType.EXIT_MEASURE,msg);
|
opcReceiverHandler.onMessageReceived(OpcMessageType.EXIT_MEASURE,msg);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.fizz.business.service.impl.BeanFactory;
|
|||||||
import com.fizz.business.utils.MatmapUtil;
|
import com.fizz.business.utils.MatmapUtil;
|
||||||
import com.fizz.business.utils.WebSocketUtil;
|
import com.fizz.business.utils.WebSocketUtil;
|
||||||
import com.fizz.business.vo.CrmPdiPlanVO;
|
import com.fizz.business.vo.CrmPdiPlanVO;
|
||||||
import com.fizz.business.vo.PdiPlanVO;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -33,7 +32,7 @@ public enum L1OperateMatEnum implements IEnum<String>, IOperateMat<L1OperateMatF
|
|||||||
ONLINE("上线") {
|
ONLINE("上线") {
|
||||||
@Override
|
@Override
|
||||||
public void operate(L1OperateMatForm form) {
|
public void operate(L1OperateMatForm form) {
|
||||||
ONLINE.syncPlanStatus(form.getPlanId());
|
ONLINE.syncPlanStatus(form.getPlanId(),form.getEntryMatId());
|
||||||
MatmapUtil.setMatmap(form.getPorIdx(), form.getEntryMatId(), form.getPlanId(), form.getPlanNo());
|
MatmapUtil.setMatmap(form.getPorIdx(), form.getEntryMatId(), form.getPlanId(), form.getPlanNo());
|
||||||
// 钢卷上线时, 缓存工艺规程
|
// 钢卷上线时, 缓存工艺规程
|
||||||
// BeanFactory.getBean(RedisCacheManager.class).setCoilSetup(form.getPlanId());
|
// BeanFactory.getBean(RedisCacheManager.class).setCoilSetup(form.getPlanId());
|
||||||
@@ -56,7 +55,7 @@ public enum L1OperateMatEnum implements IEnum<String>, IOperateMat<L1OperateMatF
|
|||||||
PRODUCING("生产中") {
|
PRODUCING("生产中") {
|
||||||
@Override
|
@Override
|
||||||
public void operate(L1OperateMatForm form) {
|
public void operate(L1OperateMatForm form) {
|
||||||
PRODUCING.syncPlanStatus(form.getPlanId());
|
PRODUCING.syncPlanStatus(form.getPlanId(),form.getEntryMatId());
|
||||||
|
|
||||||
WebSocketUtil.sendSignalMsg(form);
|
WebSocketUtil.sendSignalMsg(form);
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,7 @@ public enum L1OperateMatEnum implements IEnum<String>, IOperateMat<L1OperateMatF
|
|||||||
PRODUCT("生产完成") {
|
PRODUCT("生产完成") {
|
||||||
@Override
|
@Override
|
||||||
public void operate(L1OperateMatForm form) {
|
public void operate(L1OperateMatForm form) {
|
||||||
PRODUCT.syncPlanStatus(form.getPlanId());
|
PRODUCT.syncPlanStatus(form.getPlanId(),form.getEntryMatId());
|
||||||
WebSocketUtil.sendSignalMsg(form);
|
WebSocketUtil.sendSignalMsg(form);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -110,12 +109,13 @@ public enum L1OperateMatEnum implements IEnum<String>, IOperateMat<L1OperateMatF
|
|||||||
*
|
*
|
||||||
* @param planId 计划id
|
* @param planId 计划id
|
||||||
*/
|
*/
|
||||||
private void syncPlanStatus(String planId) {
|
private void syncPlanStatus(String planId, String matId) {
|
||||||
CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class);
|
CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class);
|
||||||
|
|
||||||
planClient.changeStatus(ChangePlanStatusForm.builder()
|
planClient.changeStatus(ChangePlanStatusForm.builder()
|
||||||
.operation(this.name())
|
.operation(this.name())
|
||||||
.id(planId)
|
.id(planId)
|
||||||
|
.matId(matId)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.fizz.business.domain;
|
|||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -27,7 +26,7 @@ public class ProMatmap implements Serializable {
|
|||||||
private String positionNameCn;
|
private String positionNameCn;
|
||||||
|
|
||||||
@Schema(description = "计划id")
|
@Schema(description = "计划id")
|
||||||
private Long planId;
|
private String planId;
|
||||||
|
|
||||||
@Schema(description = "计划号")
|
@Schema(description = "计划号")
|
||||||
private String planNo;
|
private String planNo;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.fizz.business.service.hanle;
|
package com.fizz.business.service.hanle;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.fizz.business.anno.OpcMessageHandlerType;
|
import com.fizz.business.anno.OpcMessageHandlerType;
|
||||||
import com.fizz.business.constants.enums.L1OperateMatEnum;
|
import com.fizz.business.constants.enums.L1OperateMatEnum;
|
||||||
import com.fizz.business.constants.enums.OpcMessageType;
|
import com.fizz.business.constants.enums.OpcMessageType;
|
||||||
@@ -33,10 +34,11 @@ public class ExitCutHandler implements OpcMessageHandler<ExitCutMessage> {
|
|||||||
MatmapDTO trMatmap = MatmapUtil.getMatmap(TR.getIdx());
|
MatmapDTO trMatmap = MatmapUtil.getMatmap(TR.getIdx());
|
||||||
|
|
||||||
if (trMatmap == null) {
|
if (trMatmap == null) {
|
||||||
log.error("卷取机s.");
|
log.error("卷取机不存在");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("接受到出口剪切信号:{}", JSONUtil.toJsonStr(message));
|
||||||
// 2. 根据剪切类型,生成产出卷信息
|
// 2. 根据剪切类型,生成产出卷信息
|
||||||
ExitCoilInfoDTO exitCoilInfo = pdoExCoilService.genExitCoilInfo(trMatmap, message.getCutType());
|
ExitCoilInfoDTO exitCoilInfo = pdoExCoilService.genExitCoilInfo(trMatmap, message.getCutType());
|
||||||
|
|
||||||
|
|||||||
@@ -7,26 +7,28 @@ import com.fizz.business.service.CrmPdoExcoilService;
|
|||||||
import com.fizz.business.service.OpcMessageHandler;
|
import com.fizz.business.service.OpcMessageHandler;
|
||||||
import com.fizz.business.utils.MatmapUtil;
|
import com.fizz.business.utils.MatmapUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import static com.fizz.business.constants.enums.DeviceEnum.TR;
|
import static com.fizz.business.constants.enums.DeviceEnum.WEIGHT;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@OpcMessageHandlerType(OpcMessageType.EXIT_MEASURE)
|
@OpcMessageHandlerType(OpcMessageType.EXIT_MEASURE)
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class ExitMeasureHandler implements OpcMessageHandler<ExitMeasureMessage> {
|
public class ExitMeasureHandler implements OpcMessageHandler<ExitMeasureMessage> {
|
||||||
|
|
||||||
private final CrmPdoExcoilService crmPdoExcoilService;
|
private final CrmPdoExcoilService crmPdoExcoilService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ExitMeasureMessage message) {
|
public void handle(ExitMeasureMessage message) {
|
||||||
System.out.println("处理 EXIT_MEASURE 消息: " + message);
|
|
||||||
|
|
||||||
// 1. 获取卷取机 (TR) 上的成品卷号
|
// 1. 获取卷取机 (TR) 上的成品卷号
|
||||||
String exitMatId = MatmapUtil.getMatId(TR.getIdx());
|
log.info("获取到钢卷称重信息:{}.",message);
|
||||||
|
String exitMatId = MatmapUtil.getMatId(WEIGHT.getIdx());
|
||||||
|
|
||||||
if (exitMatId == null) {
|
if (exitMatId == null) {
|
||||||
System.err.println("TR device has no coil. Cannot process ExitMeasureMessage.");
|
log.error("TR device has no coil. Cannot process ExitMeasureMessage.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,23 +6,28 @@ import com.fizz.business.constants.enums.OpcMessageType;
|
|||||||
import com.fizz.business.domain.msg.ExitMovementMessage;
|
import com.fizz.business.domain.msg.ExitMovementMessage;
|
||||||
import com.fizz.business.dto.MatmapDTO;
|
import com.fizz.business.dto.MatmapDTO;
|
||||||
import com.fizz.business.service.OpcMessageHandler;
|
import com.fizz.business.service.OpcMessageHandler;
|
||||||
|
import com.fizz.business.service.ProMatmapService;
|
||||||
import com.fizz.business.utils.MatmapUtil;
|
import com.fizz.business.utils.MatmapUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@OpcMessageHandlerType(OpcMessageType.EXIT_MOVEMENT)
|
@OpcMessageHandlerType(OpcMessageType.EXIT_MOVEMENT)
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ExitMovementHandler implements OpcMessageHandler<ExitMovementMessage> {
|
public class ExitMovementHandler implements OpcMessageHandler<ExitMovementMessage> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ProMatmapService proMatmapService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ExitMovementMessage message) {
|
public void handle(ExitMovementMessage message) {
|
||||||
System.out.printf("处理 EXIT_MOVEMENT 消息: %d -> %d%n", message.getExSrc(), message.getExDesc());
|
|
||||||
|
|
||||||
// 1. 获取源位置的物料信息
|
// 1. 获取源位置的物料信息
|
||||||
int srcIndex = message.getExSrc() -1 ;
|
int srcIndex = message.getExSrc() ;
|
||||||
MatmapDTO srcMatmap = MatmapUtil.getMatmap(srcIndex);
|
MatmapDTO srcMatmap = MatmapUtil.getMatmap(srcIndex);
|
||||||
|
|
||||||
if (ObjectUtil.isNull(srcMatmap) || ObjectUtil.isNull(srcMatmap.getMatId())) {
|
if (ObjectUtil.isNull(srcMatmap) || ObjectUtil.isNull(srcMatmap.getMatId())) {
|
||||||
@@ -36,9 +41,11 @@ public class ExitMovementHandler implements OpcMessageHandler<ExitMovementMessag
|
|||||||
log.info("成功清空源位置 {} 的物料信息。{}", srcIndex,srcMatmap.getMatId());
|
log.info("成功清空源位置 {} 的物料信息。{}", srcIndex,srcMatmap.getMatId());
|
||||||
|
|
||||||
// 3. 将物料信息设置到目标位置
|
// 3. 将物料信息设置到目标位置
|
||||||
int destIndex = message.getExDesc() - 1;
|
int destIndex = message.getExDesc();
|
||||||
MatmapUtil.setMatmap(destIndex, srcMatmap.getMatId(), srcMatmap.getPlanId(), srcMatmap.getPlanNo());
|
MatmapUtil.setMatmap(destIndex, srcMatmap.getMatId(), srcMatmap.getPlanId(), srcMatmap.getPlanNo());
|
||||||
log.info("成功设置目标位置 {} 的物料信息为钢卷 {}", destIndex, srcMatmap.getMatId());
|
log.info("成功设置目标位置 {} 的物料信息为钢卷 {}", destIndex, srcMatmap.getMatId());
|
||||||
|
|
||||||
|
proMatmapService.flushMatmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fizz.business.domain.CrmPdoExcoil;
|
import com.fizz.business.domain.CrmPdoExcoil;
|
||||||
import com.fizz.business.domain.PdoExcoil;
|
|
||||||
import com.fizz.business.form.CrmPdoExcoilForm;
|
import com.fizz.business.form.CrmPdoExcoilForm;
|
||||||
import com.fizz.business.mapper.CrmPdoExcoilMapper;
|
import com.fizz.business.mapper.CrmPdoExcoilMapper;
|
||||||
import com.fizz.business.service.CrmPdoExcoilService;
|
import com.fizz.business.service.CrmPdoExcoilService;
|
||||||
@@ -32,7 +31,7 @@ public class CrmPdoExcoilServiceImpl extends ServiceImpl<CrmPdoExcoilMapper, Crm
|
|||||||
*/
|
*/
|
||||||
public CrmPdoExcoil getByExcoilId(String excoilid) {
|
public CrmPdoExcoil getByExcoilId(String excoilid) {
|
||||||
QueryWrapper<CrmPdoExcoil> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<CrmPdoExcoil> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("exit_coilid", excoilid);
|
queryWrapper.eq("exit_mat_id", excoilid);
|
||||||
return this.getOne(queryWrapper);
|
return this.getOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package com.fizz.business.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.fizz.business.constants.enums.ExitCutTypeEnum;
|
import com.fizz.business.constants.enums.ExitCutTypeEnum;
|
||||||
import com.fizz.business.domain.PdoExcoil;
|
|
||||||
import com.fizz.business.dto.ExitCoilInfoDTO;
|
import com.fizz.business.dto.ExitCoilInfoDTO;
|
||||||
import com.fizz.business.dto.MatmapDTO;
|
import com.fizz.business.dto.MatmapDTO;
|
||||||
import com.fizz.business.dto.PdoExCoilDTO;
|
import com.fizz.business.dto.PdoExCoilDTO;
|
||||||
@@ -109,12 +107,14 @@ public class PdoExCoilServiceImpl implements PdoExCoilService {
|
|||||||
* 半卷回退上报产出
|
* 半卷回退上报产出
|
||||||
* 1. 头部卷产出时,原料卷号:A01, 产出卷号: A01-1, 分卷标识: true, 尾卷标识: false
|
* 1. 头部卷产出时,原料卷号:A01, 产出卷号: A01-1, 分卷标识: true, 尾卷标识: false
|
||||||
* 2. 尾部卷产出时:原料卷号:A01,产出卷号: A01-2
|
* 2. 尾部卷产出时:原料卷号:A01,产出卷号: A01-2
|
||||||
|
*
|
||||||
* @param trMatmap
|
* @param trMatmap
|
||||||
* @param cutType
|
* @param cutType
|
||||||
* @return ExitCoilInfoDTO
|
* @return ExitCoilInfoDTO
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ExitCoilInfoDTO genExitCoilInfo(MatmapDTO trMatmap, ExitCutTypeEnum cutType) {
|
public ExitCoilInfoDTO genExitCoilInfo(MatmapDTO trMatmap, ExitCutTypeEnum cutType) {
|
||||||
|
log.info("触发出口分卷信号:{},剪切类型为:{}",trMatmap,cutType);
|
||||||
String trCoilId = trMatmap.getMatId();
|
String trCoilId = trMatmap.getMatId();
|
||||||
//准备的成品子卷号
|
//准备的成品子卷号
|
||||||
//考虑依据数据库记录分卷,避免因为平台重启导致分卷丢失或错误
|
//考虑依据数据库记录分卷,避免因为平台重启导致分卷丢失或错误
|
||||||
|
|||||||
Reference in New Issue
Block a user