Commit a7ca757c authored by wanghao's avatar wanghao

1 老化过程中 获取卡号,获取IOT状态调整中

parent 12275944
......@@ -3,13 +3,15 @@ package com.zehong;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 启动程序
*
*
* @author zehong
*/
@EnableAsync
@EnableScheduling
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class ZhMesAgecalApplication
......
package com.zehong.web.controller.equipment;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.ReceivedNbFailureHistory;
import com.zehong.system.service.IReceivedNbFailureHistoryService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 获取NB码失败记录Controller
*
* @author zehong
* @date 2026-07-18
*/
@RestController
@RequestMapping("/received/nb/failure/history")
public class ReceivedNbFailureHistoryController extends BaseController
{
@Autowired
private IReceivedNbFailureHistoryService receivedNbFailureHistoryService;
/**
* 查询获取NB码失败记录列表
*/
@GetMapping("/list")
public TableDataInfo list(ReceivedNbFailureHistory receivedNbFailureHistory)
{
startPage();
List<ReceivedNbFailureHistory> list = receivedNbFailureHistoryService.selectReceivedNbFailureHistoryList(receivedNbFailureHistory);
return getDataTable(list);
}
/**
* 导出获取NB码失败记录列表
*/
@GetMapping("/export")
public AjaxResult export(ReceivedNbFailureHistory receivedNbFailureHistory)
{
List<ReceivedNbFailureHistory> list = receivedNbFailureHistoryService.selectReceivedNbFailureHistoryList(receivedNbFailureHistory);
ExcelUtil<ReceivedNbFailureHistory> util = new ExcelUtil<ReceivedNbFailureHistory>(ReceivedNbFailureHistory.class);
return util.exportExcel(list, "获取NB码失败记录数据");
}
/**
* 获取获取NB码失败记录详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(receivedNbFailureHistoryService.selectReceivedNbFailureHistoryById(id));
}
/**
* 新增获取NB码失败记录
*/
@PostMapping
public AjaxResult add(@RequestBody ReceivedNbFailureHistory receivedNbFailureHistory)
{
return toAjax(receivedNbFailureHistoryService.insertReceivedNbFailureHistory(receivedNbFailureHistory));
}
/**
* 修改获取NB码失败记录
*/
@PutMapping
public AjaxResult edit(@RequestBody ReceivedNbFailureHistory receivedNbFailureHistory)
{
return toAjax(receivedNbFailureHistoryService.updateReceivedNbFailureHistory(receivedNbFailureHistory));
}
/**
* 删除获取NB码失败记录
*/
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(receivedNbFailureHistoryService.deleteReceivedNbFailureHistoryByIds(ids));
}
}
......@@ -11,8 +11,6 @@ import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.service.ITEquipmentAlarmDataService;
import com.zehong.system.service.ITEquipmentInfoService;
import com.zehong.system.task.AgingCabinetInspectionAndPowerCheckTask;
import com.zehong.system.task.CheckPowerOnCommandEvent;
import com.zehong.system.task.PowerOffCommandEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
......
......@@ -26,7 +26,7 @@ spring:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: dev
active: test
# 文件上传
servlet:
multipart:
......
......@@ -2,7 +2,7 @@ package com.zehong.common.constant;
/**
* 通用常量信息
*
*
* @author zehong
*/
public class Constants
......@@ -61,7 +61,7 @@ public class Constants
* 登录用户 redis key
*/
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
/**
* 防重提交 redis key
*/
......@@ -130,4 +130,13 @@ public class Constants
public static final String FEED_CONVEYOR_IP_AND_PORT = "feedConveyorIpAndPort";
public static final String OUT_LET_BELT_IP_AND_PORT = "outletBeltIpAndPort";
public static final String IOT_LOGIN_USERNAME = "iot.login.username";
public static final String IOT_LOGIN_PASSWORD = "iot.login.password";
public static final String IOT_LOGIN_TOKEN = "iot.login.token";
public static final String IOT_DEVICES_SCAN = "iot.devices.scan";
}
......@@ -10,6 +10,9 @@ public class RoboticArmConstans {
// 上传MES地址的key
public static final String UPLOAD_MES_ADDRESS = "uploadMesAddress";
// MES接收到的NB码地址的key
public static final String MES_RECEIVED_NB_CODE_ADDRESS = "mesReceivedNbCodeAddress";
// 标检单地址的key
public static final String STANDARD_INSPECTION_ADDRESS = "standardInspectionAddress";
......
......@@ -212,6 +212,22 @@ public class PalletDeviceBinding extends BaseEntity
*/
private String firstUnboundDeviceFlag;
/**
* sim卡号
*/
private String simCardNo;
/**
* iot状态
* 0-异常 1-正常
*/
private Integer iotStatus;
/**
* nb编号 拿nb码就是为了处理 IOT 状态使用的,最终只保存IOT状态
*/
private String nbCode;
public String getDeviceStatus() {
return deviceStatus;
}
......@@ -540,6 +556,30 @@ public class PalletDeviceBinding extends BaseEntity
this.hasUpload = hasUpload;
}
public String getSimCardNo() {
return simCardNo;
}
public void setSimCardNo(String simCardNo) {
this.simCardNo = simCardNo;
}
public Integer getIotStatus() {
return iotStatus;
}
public void setIotStatus(Integer iotStatus) {
this.iotStatus = iotStatus;
}
public String getNbCode() {
return nbCode;
}
public void setNbCode(String nbCode) {
this.nbCode = nbCode;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
......@@ -585,6 +625,8 @@ public class PalletDeviceBinding extends BaseEntity
.append("productStandardInspectionNumber", getProductStandardInspectionNumber())
.append("standardInspectResult", getStandardInspectResult())
.append("readingMode", getReadingMode())
.append("simCardNo", getSimCardNo())
.append("iotStatus", getIotStatus())
.toString();
}
}
......@@ -161,6 +161,15 @@ public class PalletDeviceUploadFailure extends BaseEntity
/** 是否带上传 0-否 1-是*/
private String hasUpload;
/** sim卡号 */
@Excel(name = "SIM卡号")
private String simCardNo;
/** iot状态 0-异常 1-正常 */
@Excel(name = "iot状态(0-异常,1-正常)")
private Integer iotStatus;
public void setId(Long id)
{
this.id = id;
......@@ -491,6 +500,22 @@ public class PalletDeviceUploadFailure extends BaseEntity
this.hasUpload = hasUpload;
}
public String getSimCardNo() {
return simCardNo;
}
public void setSimCardNo(String simCardNo) {
this.simCardNo = simCardNo;
}
public Integer getIotStatus() {
return iotStatus;
}
public void setIotStatus(Integer iotStatus) {
this.iotStatus = iotStatus;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
......@@ -174,6 +174,14 @@ public class PalletDeviceUploadHistory extends BaseEntity
/** 标检结果 */
private String standardInspectResult;
/** sim卡号 */
@Excel(name = "SIM卡号")
private String simCardNo;
/** iot状态 0-异常 1-正常 */
@Excel(name = "iot状态(0-异常,1-正常)")
private Integer iotStatus;
public void setId(Long id)
{
this.id = id;
......@@ -485,6 +493,22 @@ public class PalletDeviceUploadHistory extends BaseEntity
this.standardInspectResult = standardInspectResult;
}
public String getSimCardNo() {
return simCardNo;
}
public void setSimCardNo(String simCardNo) {
this.simCardNo = simCardNo;
}
public Integer getIotStatus() {
return iotStatus;
}
public void setIotStatus(Integer iotStatus) {
this.iotStatus = iotStatus;
}
@Override
public String toString() {
return "PalletDeviceUploadHistory{" +
......
package com.zehong.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 获取NB码失败记录对象 t_received_nb_failure_history
*
* @author zehong
* @date 2026-07-18
*/
public class ReceivedNbFailureHistory extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 托盘编号 */
@Excel(name = "托盘编号")
private String trayCode;
/** 第几次,一共有两次 */
@Excel(name = "第几次,一共有两次")
private Integer times;
/** 失败原因: http请求报错; 请求结果是500 */
@Excel(name = "失败原因: http请求报错; 请求结果是500")
private String status;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setTrayCode(String trayCode)
{
this.trayCode = trayCode;
}
public String getTrayCode()
{
return trayCode;
}
public void setTimes(Integer times)
{
this.times = times;
}
public Integer getTimes()
{
return times;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("trayCode", getTrayCode())
.append("times", getTimes())
.append("status", getStatus())
.append("createTime", getCreateTime())
.toString();
}
}
......@@ -60,6 +60,9 @@ public class TTrayInfo extends BaseEntity
private Date estimatedEndTime;
/** 是否接收到NB码 0-未获取,1-已获取*/
private Integer hasReceivedNbCode;
public void setfTrayId(Long fTrayId)
{
this.fTrayId = fTrayId;
......@@ -148,6 +151,14 @@ public class TTrayInfo extends BaseEntity
this.estimatedEndTime = estimatedEndTime;
}
public Integer getHasReceivedNbCode() {
return hasReceivedNbCode;
}
public void setHasReceivedNbCode(Integer hasReceivedNbCode) {
this.hasReceivedNbCode = hasReceivedNbCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
package com.zehong.system.domain.vo;
/**
* @author lenovo
* @date 2026/7/18
* @description 用来给 agecal 项目回传结果的 device
*/
public class AgingDeviceResultVO {
/**
* 主板码
*/
private String motherboardCode;
/**
* NB码
*/
private String nbCode;
public String getMotherboardCode() {
return motherboardCode;
}
public void setMotherboardCode(String motherboardCode) {
this.motherboardCode = motherboardCode;
}
public String getNbCode() {
return nbCode;
}
public void setNbCode(String nbCode) {
this.nbCode = nbCode;
}
}
......@@ -42,6 +42,8 @@ public interface PalletDeviceBindingMapper
public List<PalletDeviceBinding> listByTrayCode(String trayCode);
public List<PalletDeviceBinding> listByStoreyCode(String storeyCode);
public int countErrorByTrayId(Long trayId);
public int countByTrayId(Long trayId);
......@@ -82,6 +84,8 @@ public interface PalletDeviceBindingMapper
public int batchUpdateAdAndStatus(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateNbCode(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int batchUpdateDeviceCodeAndUnbindingTime(@Param("palletDeviceBindingList") List<PalletDeviceBinding> palletDeviceBindingList);
public int unbindAllDevice(Long trayId);
......
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.ReceivedNbFailureHistory;
/**
* 获取NB码失败记录Mapper接口
*
* @author zehong
* @date 2026-07-18
*/
public interface ReceivedNbFailureHistoryMapper
{
/**
* 查询获取NB码失败记录
*
* @param id 获取NB码失败记录ID
* @return 获取NB码失败记录
*/
public ReceivedNbFailureHistory selectReceivedNbFailureHistoryById(Long id);
/**
* 查询获取NB码失败记录列表
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 获取NB码失败记录集合
*/
public List<ReceivedNbFailureHistory> selectReceivedNbFailureHistoryList(ReceivedNbFailureHistory receivedNbFailureHistory);
/**
* 新增获取NB码失败记录
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 结果
*/
public int insertReceivedNbFailureHistory(ReceivedNbFailureHistory receivedNbFailureHistory);
/**
* 修改获取NB码失败记录
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 结果
*/
public int updateReceivedNbFailureHistory(ReceivedNbFailureHistory receivedNbFailureHistory);
/**
* 删除获取NB码失败记录
*
* @param id 获取NB码失败记录ID
* @return 结果
*/
public int deleteReceivedNbFailureHistoryById(Long id);
/**
* 批量删除获取NB码失败记录
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteReceivedNbFailureHistoryByIds(Long[] ids);
}
......@@ -29,6 +29,14 @@ public interface TTrayInfoMapper
public int clearStoreyCodeByTrayId(Long trayId);
public int checkReceivedNbCodeByTrayId(Long trayId);
public int updateReceivedNbCodeByTrayId(Long trayId);
public int checkReceivedNbCodeByStoreyCode(String storeyCode);
public int updateReceivedNbCodeByStoreyCode(String storeyCode);
/**
* 查询托盘信息列表
*
......@@ -63,6 +71,8 @@ public interface TTrayInfoMapper
public int updateToBoundWhenStateIsIdle(Long trayId);
public int updateHasReceivedNbCodeByTrayId(Long trayId);
public int unbindByCode(TTrayInfo tTrayInfo);
/**
* 删除托盘信息
......
......@@ -33,8 +33,14 @@ public interface IPalletDeviceBindingService
public List<PalletDeviceBinding> listByTrayCode(String trayCode);
public List<PalletDeviceBinding> listByTrayId(Long trayId);
public List<PalletDeviceBinding> listByStoreyCode(String storeyCode);
public void batchUpdateAdAndStatus(List<PalletDeviceBinding> palletDeviceBindingList);
public void batchUpdateNbCode(List<PalletDeviceBinding> palletDeviceBindingList);
/**
* 新增托盘绑定的设备列
*
......
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.ReceivedNbFailureHistory;
/**
* 获取NB码失败记录Service接口
*
* @author zehong
* @date 2026-07-18
*/
public interface IReceivedNbFailureHistoryService
{
/**
* 查询获取NB码失败记录
*
* @param id 获取NB码失败记录ID
* @return 获取NB码失败记录
*/
public ReceivedNbFailureHistory selectReceivedNbFailureHistoryById(Long id);
/**
* 查询获取NB码失败记录列表
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 获取NB码失败记录集合
*/
public List<ReceivedNbFailureHistory> selectReceivedNbFailureHistoryList(ReceivedNbFailureHistory receivedNbFailureHistory);
/**
* 新增获取NB码失败记录
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 结果
*/
public int insertReceivedNbFailureHistory(ReceivedNbFailureHistory receivedNbFailureHistory);
/**
* 修改获取NB码失败记录
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 结果
*/
public int updateReceivedNbFailureHistory(ReceivedNbFailureHistory receivedNbFailureHistory);
/**
* 批量删除获取NB码失败记录
*
* @param ids 需要删除的获取NB码失败记录ID
* @return 结果
*/
public int deleteReceivedNbFailureHistoryByIds(Long[] ids);
/**
* 删除获取NB码失败记录信息
*
* @param id 获取NB码失败记录ID
* @return 结果
*/
public int deleteReceivedNbFailureHistoryById(Long id);
}
......@@ -12,12 +12,13 @@ import com.zehong.system.domain.*;
import com.zehong.system.mapper.*;
import com.zehong.system.service.*;
import com.zehong.system.task.DeviceTaskScheduler;
import com.zehong.system.task.event.ReceivedNbCodeEvent;
import org.quartz.SchedulerException;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -59,6 +60,9 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
@Resource
private ProductStandardInspectionMapper productStandardInspectionMapper;
@Resource
private ApplicationEventPublisher eventPublisher; // 新增事件发布器
/**
* 查询托盘绑定的设备列
*
......@@ -106,11 +110,38 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
return palletDeviceBindingMapper.listByTrayCode(trayCode);
}
@Override
public List<PalletDeviceBinding> listByTrayId(Long trayId) {
return palletDeviceBindingMapper.listByTrayId(trayId);
}
@Override
public List<PalletDeviceBinding> listByStoreyCode(String storeyCode) {
return palletDeviceBindingMapper.listByStoreyCode(storeyCode);
}
/**
* 批量更新设备码和未解除绑定时间
*
* @param palletDeviceBindingList 列表
* @return 列表
*/
@Override
public void batchUpdateAdAndStatus(List<PalletDeviceBinding> palletDeviceBindingList) {
palletDeviceBindingMapper.batchUpdateAdAndStatus(palletDeviceBindingList);
}
/**
* 批量更新设备码
*
* @param palletDeviceBindingList 列表
* @return 结果
*/
@Override
public void batchUpdateNbCode(List<PalletDeviceBinding> palletDeviceBindingList) {
palletDeviceBindingMapper.batchUpdateNbCode(palletDeviceBindingList);
}
/**
* 新增托盘绑定的设备列
*
......@@ -183,6 +214,8 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
if(i <= 0) {
throw new RuntimeException("添加失败");
}
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, null,palletDeviceBindingList.get(0).getTrayId()));
return palletDeviceBindingList;
}
......@@ -221,6 +254,8 @@ public class PalletDeviceBindingServiceImpl implements IPalletDeviceBindingServi
tTrayInfoMapper.updateToBoundWhenStateIsIdle(palletDeviceBindingList.get(0).getTrayId());
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, null,palletDeviceBindingList.get(0).getTrayId()));
log.info("主线程时间:{}",DateUtils.getTime());
return palletDeviceBindingMapper.batchUpdateDeviceCodeAndUnbindingTime(palletDeviceBindingList);
}
......
package com.zehong.system.service.impl;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.ReceivedNbFailureHistory;
import com.zehong.system.mapper.ReceivedNbFailureHistoryMapper;
import com.zehong.system.service.IReceivedNbFailureHistoryService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 获取NB码失败记录Service业务层处理
*
* @author zehong
* @date 2026-07-18
*/
@Service
public class ReceivedNbFailureHistoryServiceImpl implements IReceivedNbFailureHistoryService
{
@Resource
private ReceivedNbFailureHistoryMapper receivedNbFailureHistoryMapper;
/**
* 查询获取NB码失败记录
*
* @param id 获取NB码失败记录ID
* @return 获取NB码失败记录
*/
@Override
public ReceivedNbFailureHistory selectReceivedNbFailureHistoryById(Long id)
{
return receivedNbFailureHistoryMapper.selectReceivedNbFailureHistoryById(id);
}
/**
* 查询获取NB码失败记录列表
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 获取NB码失败记录
*/
@Override
public List<ReceivedNbFailureHistory> selectReceivedNbFailureHistoryList(ReceivedNbFailureHistory receivedNbFailureHistory)
{
return receivedNbFailureHistoryMapper.selectReceivedNbFailureHistoryList(receivedNbFailureHistory);
}
/**
* 新增获取NB码失败记录
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 结果
*/
@Override
public int insertReceivedNbFailureHistory(ReceivedNbFailureHistory receivedNbFailureHistory)
{
receivedNbFailureHistory.setCreateTime(DateUtils.getNowDate());
return receivedNbFailureHistoryMapper.insertReceivedNbFailureHistory(receivedNbFailureHistory);
}
/**
* 修改获取NB码失败记录
*
* @param receivedNbFailureHistory 获取NB码失败记录
* @return 结果
*/
@Override
public int updateReceivedNbFailureHistory(ReceivedNbFailureHistory receivedNbFailureHistory)
{
return receivedNbFailureHistoryMapper.updateReceivedNbFailureHistory(receivedNbFailureHistory);
}
/**
* 批量删除获取NB码失败记录
*
* @param ids 需要删除的获取NB码失败记录ID
* @return 结果
*/
@Override
public int deleteReceivedNbFailureHistoryByIds(Long[] ids)
{
return receivedNbFailureHistoryMapper.deleteReceivedNbFailureHistoryByIds(ids);
}
/**
* 删除获取NB码失败记录信息
*
* @param id 获取NB码失败记录ID
* @return 结果
*/
@Override
public int deleteReceivedNbFailureHistoryById(Long id)
{
return receivedNbFailureHistoryMapper.deleteReceivedNbFailureHistoryById(id);
}
}
......@@ -21,8 +21,8 @@ import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.netty.handler.NettyUdpServerHandler;
import com.zehong.system.service.IConveyorBeltIpMaintainService;
import com.zehong.system.service.websocket.RobotArmWebSocketHandler;
import com.zehong.system.task.CheckPowerOnCommandEvent;
import com.zehong.system.task.PowerOffCommandEvent;
import com.zehong.system.task.event.CheckPowerOnCommandEvent;
import com.zehong.system.task.event.PowerOffCommandEvent;
import com.zehong.system.udp.UdpCommandSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -19,7 +19,7 @@ import com.zehong.system.service.IRobotArmCommandService;
import com.zehong.system.service.ITEquipmentAlarmDataService;
import com.zehong.system.service.ITEquipmentInfoService;
import com.zehong.system.service.ITStoreyInfoService;
import com.zehong.system.task.CheckPowerOnCommandEvent;
import com.zehong.system.task.event.CheckPowerOnCommandEvent;
import com.zehong.system.task.DeviceTaskScheduler;
import com.zehong.system.task.RealTimeReadAgingDataFunction;
import org.quartz.JobKey;
......
......@@ -12,9 +12,11 @@ import com.zehong.system.mapper.TStoreyInfoMapper;
import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.service.ITEquipmentAlarmDataService;
import com.zehong.system.service.websocket.RobotArmWebSocketHandler;
import com.zehong.system.task.event.ReceivedNbCodeEvent;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
......@@ -49,6 +51,9 @@ public class AgingStageTwoProcessJob implements Job {
private Scheduler scheduler;
@Resource
private PalletDeviceBindingMapper palletDeviceBindingMapper;
@Resource
private ApplicationEventPublisher eventPublisher; // 新增事件发布器
// 全局线程池 - 避免重复创建
private static final ExecutorService GLOBAL_DEVICE_EXECUTOR = new ThreadPoolExecutor(
50, 100, 60, TimeUnit.SECONDS,
......@@ -87,6 +92,7 @@ public class AgingStageTwoProcessJob implements Job {
return;
}
eventPublisher.publishEvent(new ReceivedNbCodeEvent(this, storeyCode,null));
// 20251206 读取 继电器状态 脉冲状态 模组状态 SIM卡状态 网络状态
// 并行处理3个端口
List<CompletableFuture<Void>> portFutures = Arrays.asList(
......
package com.zehong.system.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.zehong.common.constant.RoboticArmConstans;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.SysConfig;
import com.zehong.system.domain.TEquipmentAlarmData;
import com.zehong.system.domain.TStoreyInfo;
import com.zehong.system.domain.TTrayInfo;
import com.zehong.common.utils.http.HttpUtils;
import com.zehong.system.domain.*;
import com.zehong.system.domain.vo.AgingDeviceResultVO;
import com.zehong.system.mapper.RobotArmCommandMapper;
import com.zehong.system.mapper.TStoreyInfoMapper;
import com.zehong.system.mapper.TTrayInfoMapper;
import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.service.*;
import com.zehong.system.service.websocket.RobotArmWebSocketHandler;
import com.zehong.system.task.event.CheckPowerOnCommandEvent;
import com.zehong.system.task.event.PowerOffCommandEvent;
import com.zehong.system.task.event.ReceivedNbCodeEvent;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author lenovo
......@@ -58,6 +66,12 @@ public class AllCommandHandler {
@Resource
private RobotArmWebSocketHandler robotArmWebSocketHandler;
@Resource
private IPalletDeviceBindingService palletDeviceBindingService;
@Resource
private IReceivedNbFailureHistoryService receivedNbFailureHistoryService;
// 使用常量定义索引,避免魔法数字
private static final int AGING_STAGE_INDEX = 3;
private static final int DEFAULT_HOURS = 72;
......@@ -66,7 +80,7 @@ public class AllCommandHandler {
*
* @param event event
*/
@Async
@Async("threadPoolTaskExecutor")
@EventListener(CheckPowerOnCommandEvent.class)
public void handleCheckPowerOnCommand(CheckPowerOnCommandEvent event) {
......@@ -141,7 +155,8 @@ public class AllCommandHandler {
// 返回默认值(72小时转换为毫秒)
return DEFAULT_HOURS * 60 * 60 * 1000;
}
@Async // 异步执行
@Async("threadPoolTaskExecutor")// 异步执行
@EventListener(PowerOffCommandEvent.class)
public void handlePowerOffCommand(PowerOffCommandEvent event) {
String storeyCode = event.getDeviceCode() + "-" + event.getLayer();
......@@ -186,4 +201,106 @@ public class AllCommandHandler {
alarmDataService.insertTEquipmentAlarmData(alarmData);
}
}
/**
* 接收到NB码
* @param event event
*/
@Async("threadPoolTaskExecutor")
@EventListener(ReceivedNbCodeEvent.class)
@Transactional(rollbackFor = Exception.class)
public void handleReceivedNbCode(ReceivedNbCodeEvent event) {
log.info("接收到NB码时间开始:{}", DateUtils.getTime());
List<PalletDeviceBinding> palletDeviceBindings = null;
int times = 0;
if(event.getTrayId()!=null){
// 判断一下是否获取过NB码了,如果获取过NB码了,则不处理
int i = tTrayInfoMapper.checkReceivedNbCodeByTrayId(event.getTrayId());
if(i == 1){
return;
}
palletDeviceBindings = palletDeviceBindingService.listByTrayId(event.getTrayId());
times = 1;
}
if(StringUtils.isNotBlank(event.getStoreyCode()) && palletDeviceBindings == null){
// 判断一下是否获取过NB码了,如果获取过NB码了,则不处理
int i = tTrayInfoMapper.checkReceivedNbCodeByStoreyCode(event.getStoreyCode());
if(i == 1){
return;
}
palletDeviceBindings = palletDeviceBindingService.listByStoreyCode(event.getStoreyCode());
times = 2;
}
if(palletDeviceBindings == null)
return;
//获取不为空的 设备号
List<String> collect = palletDeviceBindings.stream().filter(item -> item.getMotherboardCode() != null)
.collect(Collectors.toList()).stream().map(PalletDeviceBinding::getMotherboardCode).collect(Collectors.toList());
if(collect.size() == 0)
return;
String mesReceivedNbCodeAddress = configService.directSelectConfigByKey(RoboticArmConstans.MES_RECEIVED_NB_CODE_ADDRESS);
if(StringUtils.isBlank(mesReceivedNbCodeAddress))
return;
String motherboardCodes = String.join(",", collect);
ReceivedNbFailureHistory receivedNbFailureHistory = new ReceivedNbFailureHistory();
receivedNbFailureHistory.setTimes(times);
receivedNbFailureHistory.setTrayCode(palletDeviceBindings.get(0).getfTrayCode());
receivedNbFailureHistory.setStatus("成功");
try {
String result = HttpUtils.sendPost(mesReceivedNbCodeAddress, motherboardCodes);
if(com.zehong.common.utils.StringUtils.isNotBlank(result)) {
JSONObject jsonObject = JSON.parseObject(result);
if(jsonObject.getInteger("code") == 200) {
String data = jsonObject.getString("data");
// 重点:将JSON数组转成对象集合
List<AgingDeviceResultVO> list = JSON.parseArray(data, AgingDeviceResultVO.class);
if(list != null && list.size() > 0){
// 1. 将返回结果转成 Map:motherboardCode -> nbCode
Map<String, String> nbCodeMap = list.stream()
.collect(Collectors.toMap(
AgingDeviceResultVO::getMotherboardCode,
AgingDeviceResultVO::getNbCode,
(v1, v2) -> v2 // 如果有重复key,保留后者
));
// 2. 遍历 palletDeviceBindings,匹配设置 nbCode
palletDeviceBindings.stream()
.filter(item -> item.getMotherboardCode() != null && nbCodeMap.containsKey(item.getMotherboardCode()))
.forEach(item -> item.setNbCode(nbCodeMap.get(item.getMotherboardCode())));
}
} else {
receivedNbFailureHistory.setStatus("请求返回:" + jsonObject.getInteger("code"));
}
}
} catch (Exception e) {
receivedNbFailureHistory.setStatus("http请求失败");
}
// 更新托盘状态
if(event.getTrayId()!=null){
tTrayInfoMapper.updateReceivedNbCodeByTrayId(event.getTrayId());
} else {
tTrayInfoMapper.updateReceivedNbCodeByStoreyCode(event.getStoreyCode());
}
// 更新
palletDeviceBindingService.batchUpdateNbCode(palletDeviceBindings);
// 保存
receivedNbFailureHistoryService.insertReceivedNbFailureHistory(receivedNbFailureHistory);
log.info("接收到NB码时间结束:{}", DateUtils.getTime());
}
}
package com.zehong.system.task.event;
/**
* @author lenovo
* @date 2026/7/18
* @description IOTstatus event
*/
public class IotStatusEvent{
}
package com.zehong.system.task.event;
import org.springframework.context.ApplicationEvent;
/**
* @author lenovo
* @date 2026/7/18
* @description 获取NB码event
*/
public class ReceivedNbCodeEvent extends ApplicationEvent {
private String storeyCode;
private Long trayId;
public ReceivedNbCodeEvent(Object source) {
super(source);
}
public ReceivedNbCodeEvent(Object source, String storeyCode, Long trayId) {
super(source);
this.storeyCode = storeyCode;
this.trayId = trayId;
}
public String getStoreyCode() {
return storeyCode;
}
public void setStoreyCode(String storeyCode) {
this.storeyCode = storeyCode;
}
public Long getTrayId() {
return trayId;
}
public void setTrayId(Long trayId) {
this.trayId = trayId;
}
}
......@@ -51,6 +51,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="readingMode" column="f_reading_mode"/>
<result property="hasUpload" column="f_has_upload"/>
<result property="simCardNo" column="f_sim_card_no" />
<result property="iotStatus" column="f_iot_status" />
<result property="nbCode" column="f_nb_code"/>
</resultMap>
<sql id="selectPalletDeviceBindingVo">
......@@ -92,6 +96,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
palDeviceBinding.f_calibration_unbind_status,
palDeviceBinding.f_product_standard_inspection_number,
palDeviceBinding.f_standard_inspect_result,
palDeviceBinding.f_sim_card_no,
palDeviceBinding.f_iot_status,
palDeviceBinding.f_nb_code,
inspection.f_reading_mode,
inspection.f_has_upload
from t_pallet_device_binding palDeviceBinding
......@@ -148,6 +155,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectPalletDeviceBindingVo"/>
where trayInfo.f_tray_code = #{trayCode}
</select>
<select id="listByStoreyCode" parameterType="string" resultMap="PalletDeviceBindingResult">
<include refid="selectPalletDeviceBindingVo"/>
where palDeviceBinding.f_storey_code = #{storeyCode}
</select>
<select id="selectPalletDeviceBindingById" parameterType="Long" resultMap="PalletDeviceBindingResult">
<include refid="selectPalletDeviceBindingVo"/>
......@@ -191,6 +202,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
palDeviceBinding.f_calibration_unbind_status,
palDeviceBinding.f_product_standard_inspection_number,
palDeviceBinding.f_standard_inspect_result,
palDeviceBinding.f_sim_card_no,
palDeviceBinding.f_iot_status,
palDeviceBinding.f_nb_code,
inspection.f_reading_mode,
inspection.f_has_upload
from t_pallet_device_binding palDeviceBinding
......@@ -269,7 +283,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_sim_card_status = null,
f_network_status = null,
f_product_standard_inspection_number = null,
f_standard_inspect_result = null
f_standard_inspect_result = null,
f_sim_card_no = null,
f_iot_status = null,
f_nb_code = null
where f_tray_id = #{trayId}
</update>
<insert id="insertPalletDeviceBinding" parameterType="PalletDeviceBinding" useGeneratedKeys="true" keyProperty="palletDeviceBindingId">
......@@ -334,7 +351,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_sim_card_status = null,
f_network_status = null,
f_product_standard_inspection_number = null,
f_standard_inspect_result = null
f_standard_inspect_result = null,
f_sim_card_no = null,
f_iot_status = null,
f_nb_code = null
where f_pallet_device_binding_id = #{palletDeviceBindingId}
</update>
<update id="updatePalletDeviceBinding" parameterType="PalletDeviceBinding">
......@@ -378,6 +398,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">f_network_status = #{networkStatus},</if>
<if test="productStandardInspectionNumber != null">f_product_standard_inspection_number = #{productStandardInspectionNumber},</if>
<if test="standardInspectResult != null">f_standard_inspect_result = #{standardInspectResult},</if>
<if test="simCardNo != null">f_sim_card_no = #{simCardNo},</if>
<if test="iotStatus != null">f_iot_status = #{iotStatus},</if>
<if test="nbCode != null">f_nb_code = #{nbCode},</if>
</trim>
where f_pallet_device_binding_id = #{palletDeviceBindingId} and f_motherboard_code is not null
</update>
......@@ -406,6 +430,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where f_pallet_device_binding_id = #{item.palletDeviceBindingId} and f_motherboard_code is not null
</foreach>
</update>
<update id="batchUpdateNbCode" parameterType="list">
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=";">
UPDATE t_pallet_device_binding
SET f_nb_code = #{item.nbCode}
where f_pallet_device_binding_id = #{item.palletDeviceBindingId} and f_motherboard_code is not null
</foreach>
</update>
<update id="batchUpdateDeviceCodeAndUnbindingTime" parameterType="list">
<foreach collection="palletDeviceBindingList" item="item" index="index" separator=";">
UPDATE t_pallet_device_binding
......@@ -438,7 +469,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_network_status = null,
f_calibration_unbind_status = '0',
f_product_standard_inspection_number = null,
f_standard_inspect_result = null
f_standard_inspect_result = null,
f_sim_card_no = null,
f_iot_status = null,
f_nb_code = null
<choose>
<when test="item.motherboardCode != null">
, f_motherboard_code = #{item.motherboardCode}
......@@ -479,7 +513,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_network_status = null,
f_calibration_unbind_status = null,
f_product_standard_inspection_number = null,
f_standard_inspect_result = null
f_standard_inspect_result = null,
f_sim_card_no = null,
f_iot_status = null,
f_nb_code = null
where f_tray_id = #{trayId}
</update>
......
......@@ -42,6 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productStandardInspectionNumber" column="f_product_standard_inspection_number" />
<result property="standardInspectResult" column="f_standard_inspect_result" />
<result property="hasUpload" column="f_has_upload"/>
<result property="simCardNo" column="f_sim_card_no" />
<result property="iotStatus" column="f_iot_status" />
</resultMap>
<sql id="selectPalletDeviceUploadFailureVo">
......@@ -82,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
palDeviceBinding.f_network_status,
palDeviceBinding.f_product_standard_inspection_number,
palDeviceBinding.f_standard_inspect_result,
palDeviceBinding.f_sim_card_no,
palDeviceBinding.f_iot_status,
inspection.f_has_upload
from t_pallet_device_upload_failure palDeviceBinding
left join t_tray_info trayInfo on trayInfo.f_tray_id = palDeviceBinding.f_tray_id
......@@ -171,7 +175,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_sim_card_status,
f_network_status,
f_product_standard_inspection_number,
f_standard_inspect_result
f_standard_inspect_result,
f_sim_card_no,
f_iot_status
</trim>
values
<foreach collection="list" item="item" separator=",">
......@@ -210,7 +216,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.simCardStatus},
#{item.networkStatus},
#{item.productStandardInspectionNumber},
#{item.standardInspectResult}
#{item.standardInspectResult},
#{item.simCardNo},
#{item.iotStatus}
</trim>
</foreach>
</insert>
......@@ -251,7 +259,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_sim_card_status,
f_network_status,
f_product_standard_inspection_number,
f_standard_inspect_result
f_standard_inspect_result,
f_sim_card_no,
f_iot_status
</trim>
values
<foreach collection="list" item="item" separator=",">
......@@ -290,7 +300,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.simCardStatus},
#{item.networkStatus},
#{item.productStandardInspectionNumber},
#{item.standardInspectResult}
#{item.standardInspectResult},
#{item.simCardNo},
#{item.iotStatus}
</trim>
</foreach>
</insert>
......@@ -332,6 +344,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">f_network_status,</if>
<if test="productStandardInspectionNumber != null">f_product_standard_inspection_number,</if>
<if test="standardInspectResult != null">f_standard_inspect_result,</if>
<if test="simCardNo != null">f_sim_card_no,</if>
<if test="iotStatus != null">f_iot_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="trayId != null">#{trayId},</if>
......@@ -369,6 +384,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">#{networkStatus},</if>
<if test="productStandardInspectionNumber != null">#{productStandardInspectionNumber},</if>
<if test="standardInspectResult != null">#{standardInspectResult},</if>
<if test="simCardNo != null">#{simCardNo},</if>
<if test="iotStatus != null">#{iotStatus},</if>
</trim>
</insert>
......@@ -410,6 +427,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">f_network_status = #{networkStatus},</if>
<if test="productStandardInspectionNumber != null">f_product_standard_inspection_number = #{productStandardInspectionNumber},</if>
<if test="standardInspectResult != null">f_standard_inspect_result = #{standardInspectResult},</if>
<if test="simCardNo != null">f_sim_card_no = #{simCardNo},</if>
<if test="iotStatus != null">f_iot_status = #{iotStatus},</if>
</trim>
where f_id = #{id}
</update>
......
......@@ -43,6 +43,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="networkStatus" column="f_network_status" />
<result property="productStandardInspectionNumber" column="f_product_standard_inspection_number" />
<result property="standardInspectResult" column="f_standard_inspect_result" />
<result property="simCardNo" column="f_sim_card_no" />
<result property="iotStatus" column="f_iot_status" />
</resultMap>
<sql id="selectPalletDeviceUploadHistoryVo">
......@@ -82,7 +85,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
palDeviceBinding.f_sim_card_status,
palDeviceBinding.f_network_status,
palDeviceBinding.f_product_standard_inspection_number,
palDeviceBinding.f_standard_inspect_result
palDeviceBinding.f_standard_inspect_result,
palDeviceBinding.f_sim_card_no,
palDeviceBinding.f_iot_status
from t_pallet_device_upload_history palDeviceBinding
left join t_tray_info trayInfo on trayInfo.f_tray_id = palDeviceBinding.f_tray_id
</sql>
......@@ -140,7 +145,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_sim_card_status,
f_network_status,
f_product_standard_inspection_number,
f_standard_inspect_result
f_standard_inspect_result,
f_sim_card_no,
f_iot_status
</trim>
values
<foreach collection="list" item="item" separator=",">
......@@ -179,7 +186,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.simCardStatus},
#{item.networkStatus},
#{item.productStandardInspectionNumber},
#{item.standardInspectResult}
#{item.standardInspectResult},
#{item.simCardNo},
#{item.iotStatus}
</trim>
</foreach>
</insert>
......@@ -221,7 +230,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_sim_card_status,
f_network_status,
f_product_standard_inspection_number,
f_standard_inspect_result
f_standard_inspect_result,
f_sim_card_no,
f_iot_status
</trim>
values
<foreach collection="list" item="item" separator=",">
......@@ -260,7 +271,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.simCardStatus},
#{item.networkStatus},
#{item.productStandardInspectionNumber},
#{item.standardInspectResult}
#{item.standardInspectResult},
#{item.simCardNo},
#{item.iotStatus}
</trim>
</foreach>
</insert>
......@@ -302,6 +315,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">f_network_status,</if>
<if test="productStandardInspectionNumber != null">f_product_standard_inspection_number,</if>
<if test="standardInspectResult != null">f_standard_inspect_result,</if>
<if test="simCardNo != null">f_sim_card_no,</if>
<if test="iotStatus != null">f_iot_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="trayId != null">#{trayId},</if>
......@@ -340,6 +355,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">#{networkStatus},</if>
<if test="productStandardInspectionNumber != null">#{productStandardInspectionNumber}</if>
<if test="standardInspectResult != null">#{standardInspectResult}</if>
<if test="simCardNo != null">#{simCardNo},</if>
<if test="iotStatus != null">#{iotStatus},</if>
</trim>
</insert>
......@@ -382,6 +399,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="networkStatus != null">f_network_status = #{networkStatus},</if>
<if test="productStandardInspectionNumber != null">f_product_standard_inspection_number = #{productStandardInspectionNumber}</if>
<if test="standardInspectResult != null">f_standard_inspect_result = #{standardInspectResult}</if>
<if test="simCardNo != null">f_sim_card_no = #{simCardNo},</if>
<if test="iotStatus != null">f_iot_status = #{iotStatus},</if>
</trim>
where f_id = #{id}
</update>
......
<?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="com.zehong.system.mapper.ReceivedNbFailureHistoryMapper">
<resultMap type="ReceivedNbFailureHistory" id="ReceivedNbFailureHistoryResult">
<result property="id" column="f_id" />
<result property="trayCode" column="f_tray_code" />
<result property="times" column="f_times" />
<result property="status" column="f_status" />
<result property="createTime" column="f_create_time" />
</resultMap>
<sql id="selectReceivedNbFailureHistoryVo">
select f_id, f_tray_code, f_times, f_status, f_create_time from t_received_nb_failure_history
</sql>
<select id="selectReceivedNbFailureHistoryList" parameterType="ReceivedNbFailureHistory" resultMap="ReceivedNbFailureHistoryResult">
<include refid="selectReceivedNbFailureHistoryVo"/>
<where>
<if test="trayCode != null and trayCode != ''"> and f_tray_code = #{trayCode}</if>
</where>
</select>
<select id="selectReceivedNbFailureHistoryById" parameterType="Long" resultMap="ReceivedNbFailureHistoryResult">
<include refid="selectReceivedNbFailureHistoryVo"/>
where f_id = #{id}
</select>
<insert id="insertReceivedNbFailureHistory" parameterType="ReceivedNbFailureHistory" useGeneratedKeys="true" keyProperty="id">
insert into t_received_nb_failure_history
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="trayCode != null">f_tray_code,</if>
<if test="times != null">f_times,</if>
<if test="status != null">f_status,</if>
<if test="createTime != null">f_create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="trayCode != null">#{trayCode},</if>
<if test="times != null">#{times},</if>
<if test="status != null">#{status},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateReceivedNbFailureHistory" parameterType="ReceivedNbFailureHistory">
update t_received_nb_failure_history
<trim prefix="SET" suffixOverrides=",">
<if test="trayCode != null">f_tray_code = #{trayCode},</if>
<if test="times != null">f_times = #{times},</if>
<if test="status != null">f_status = #{status},</if>
<if test="createTime != null">f_create_time = #{createTime},</if>
</trim>
where f_id = #{id}
</update>
<delete id="deleteReceivedNbFailureHistoryById" parameterType="Long">
delete from t_received_nb_failure_history where f_id = #{id}
</delete>
<delete id="deleteReceivedNbFailureHistoryByIds" parameterType="String">
delete from t_received_nb_failure_history where f_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="fCreateTime" column="f_create_time" />
<result property="fAgingStartTime" column="f_aging_start_time" />
<result property="estimatedEndTime" column="f_estimated_end_time" />
<result property="hasReceivedNbCode" column="f_has_received_nb_code" />
</resultMap>
<sql id="selectTTrayInfoVo">
......@@ -25,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
trayInfo.f_binding_time,
trayInfo.f_unbinding_time,
trayInfo.f_create_time,
trayInfo.f_has_received_nb_code,
( SELECT count( 1 ) FROM t_pallet_device_binding WHERE f_tray_id = trayInfo.f_tray_id AND ( f_motherboard_code != '' ) AND f_unbinding_time IS NULL ) AS boardCount ,
storeyInfo.f_aging_start_time,
storeyInfo.f_estimated_end_time
......@@ -105,23 +107,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update t_tray_info
set f_status = '4' where f_status = '0' and f_tray_id = #{fTrayId}
</update>
<update id="updateHasReceivedNbCodeByTrayId" parameterType="long">
update t_tray_info
set f_has_received_nb_code = 1
where f_tray_id = #{fTrayId}
</update>
<update id="clearStoreyCodeByStoreyCode" parameterType="string">
update t_tray_info
set f_storey_code = null,
f_has_received_nb_code = 0,
f_unbinding_time = NOW()
where f_storey_code = #{storeyCode}
</update>
<update id="initStatusByTrayId" parameterType="long">
update t_tray_info
set f_status = '0'
set f_status = '0',
f_has_received_nb_code = 0
where f_tray_id = #{fTrayId}
</update>
<select id="checkReceivedNbCodeByTrayId" parameterType="long" resultType="int">
select IFNULL(f_has_received_nb_code, 0)
from t_tray_info
where f_tray_id = #{fTrayId}
</select>
<update id="updateReceivedNbCodeByTrayId" parameterType="long">
update t_tray_info
set f_has_received_nb_code = 1
where f_tray_id = #{fTrayId}
</update>
<select id="checkReceivedNbCodeByStoreyCode" parameterType="string" resultType="int">
select IFNULL(f_has_received_nb_code, 0)
from t_tray_info
where f_storey_code = #{storeyCode}
</select>
<update id="updateReceivedNbCodeByStoreyCode" parameterType="string" >
update t_tray_info
set f_has_received_nb_code = 1
where f_storey_code = #{storeyCode}
</update>
<update id="clearStoreyCodeByTrayId" parameterType="long">
update t_tray_info
set f_storey_code = null,
f_status = '0',
f_unbinding_time = null,
f_binding_time = null
f_binding_time = null,
f_has_received_nb_code = 0
where f_tray_id = #{fTrayId}
</update>
<update id="updateTTrayInfo" parameterType="TTrayInfo">
......@@ -141,7 +171,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="unbindByCode" parameterType="TTrayInfo">
update t_tray_info
set f_storey_code = null,
f_status = 2,
f_status = 2,,
f_has_received_nb_code = 0,
f_unbinding_time = #{fUnbindingTime}
where f_tray_code = #{fTrayCode}
</update>
......
import request from '@/utils/request'
// 查询获取NB码失败记录列表
export function listHistory(query) {
return request({
url: '/received/nb/failure/history/list',
method: 'get',
params: query
})
}
// 查询获取NB码失败记录详细
export function getHistory(id) {
return request({
url: '/received/nb/failure/history/' + id,
method: 'get'
})
}
// 新增获取NB码失败记录
export function addHistory(data) {
return request({
url: '/received/nb/failure/history',
method: 'post',
data: data
})
}
// 修改获取NB码失败记录
export function updateHistory(data) {
return request({
url: '/received/nb/failure/history',
method: 'put',
data: data
})
}
// 删除获取NB码失败记录
export function delHistory(id) {
return request({
url: '/received/nb/failure/history/' + id,
method: 'delete'
})
}
// 导出获取NB码失败记录
export function exportHistory(query) {
return request({
url: '/received/nb/failure/history/export',
method: 'get',
params: query
})
}
......@@ -162,6 +162,14 @@
<el-tag type="info" v-if="scope.row.networkStatus === 0">异常</el-tag>
</template>
</el-table-column>
<el-table-column label="SIM卡号" align="center" prop="simCardNo" />
<el-table-column label="IOT状态" align="center" width="120">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.iotStatus === 1">正常</el-tag>
<el-tag type="info" v-if="scope.row.iotStatus === 0">异常</el-tag>
<el-tag type="danger" v-if="scope.row.iotStatus === -9999">通讯异常</el-tag>
</template>
</el-table-column>
<el-table-column label="设置-年" align="center" prop="recordYear" />
<el-table-column label="设置-月" align="center" prop="recordMonth" />
<el-table-column label="设置-日" align="center" prop="recordDate" />
......
......@@ -152,6 +152,14 @@
<el-tag type="info" v-if="scope.row.networkStatus === 0">异常</el-tag>
</template>
</el-table-column>
<el-table-column label="SIM卡号" align="center" prop="simCardNo" />
<el-table-column label="IOT状态" align="center" width="120">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.iotStatus === 1">正常</el-tag>
<el-tag type="info" v-if="scope.row.iotStatus === 0">异常</el-tag>
<el-tag type="danger" v-if="scope.row.iotStatus === -9999">通讯异常</el-tag>
</template>
</el-table-column>
<!-- <el-table-column label="调零AD" align="center" prop="adjustmentZeroAd" />-->
<!-- <el-table-column label="调零状态" align="center" prop="zeroStatus" >-->
<!-- <template slot-scope="scope">-->
......
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="托盘编号" prop="trayCode">
<el-input
v-model="queryParams.trayCode"
placeholder="请输入托盘编号"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="historyList" @selection-change="handleSelectionChange">
<el-table-column label="托盘编号" align="center" prop="trayCode" />
<el-table-column label="第几次,一共有两次" align="center" prop="times" />
<el-table-column label="状态" align="center" prop="status" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改获取NB码失败记录对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="托盘编号" prop="trayCode">
<el-input v-model="form.trayCode" placeholder="请输入托盘编号" />
</el-form-item>
<el-form-item label="第几次,一共有两次" prop="times">
<el-input v-model="form.times" placeholder="请输入第几次,一共有两次" />
</el-form-item>
<el-form-item label="失败原因: http请求报错; 请求结果是500">
<el-radio-group v-model="form.status">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listHistory, getHistory, delHistory, addHistory, updateHistory, exportHistory } from "@/api/system/receivedNbFailureHistory";
export default {
name: "History",
components: {
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 获取NB码失败记录表格数据
historyList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
trayCode: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询获取NB码失败记录列表 */
getList() {
this.loading = true;
listHistory(this.queryParams).then(response => {
this.historyList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
trayCode: null,
times: null,
status: "0",
createTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加获取NB码失败记录";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getHistory(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改获取NB码失败记录";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateHistory(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addHistory(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除获取NB码失败记录编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delHistory(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有获取NB码失败记录数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return exportHistory(queryParams);
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
}
}
};
</script>
......@@ -192,6 +192,19 @@
<span v-else class="write-unknown">-</span>
</template>
</el-table-column>
<el-table-column label="SIM卡号" prop="simCardNo" align="center" width="150" >
<template slot-scope="scope">
<div class="device-code">{{ scope.row.simCardNo }}</div>
</template>
</el-table-column>
<el-table-column label="IOT状态" align="center" width="120">
<template slot-scope="scope">
<span v-if="scope.row.iotStatus === 1" class="write-success">正常</span>
<span v-else-if="scope.row.iotStatus === 0" class="write-failed">异常</span>
<span v-else-if="scope.row.iotStatus === -9999" class="write-failed">通讯异常</span>
<span v-else class="write-unknown">-</span>
</template>
</el-table-column>
<el-table-column label="通信年" prop="recordYear" align="center" width="100">
<template slot-scope="scope">
......@@ -405,6 +418,9 @@ export default {
<style scoped>
.tray-table >>> .el-table__fixed {
bottom: 12px; /* 根据滚动条实际高度调整 */
}
/* 通讯异常(危急 - 比危险红更强烈) */
.custom-critical-tag {
background: linear-gradient(135deg, #ff0000 0%, #990000 100%) !important;
......@@ -788,7 +804,6 @@ export default {
color: #e0f0ff;
border-radius: 6px;
}
/* 响应式设计 */
@media (max-width: 1024px) {
.search-input {
......
......@@ -84,7 +84,6 @@
:ref="`deviceCell_${index}`"
>
<div class="device-id">
<div class="device-id">
{{ (device.motherboardCode && device.calibrationUnbindStatus === '0') ? device.motherboardCode : '+' }}
<!-- 其他图标保持不变 -->
</div>
......@@ -92,7 +91,6 @@
<i v-if="isDeviceError(device)" class="error-icon fas fa-exclamation-circle"></i>
<!-- 添加重复状态图标 -->
<i v-if="device.isDuplicate" class="duplicate-icon fas fa-exclamation-triangle"></i>
</div>
<div class="position-indicator">
{{ getPositionLabel(index) }}
</div>
......@@ -1173,13 +1171,8 @@ export default {
word-break: break-all;
width: 100%;
padding: 2px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
max-height: 40px;
position: relative;
overflow: hidden; /* 仅防止溢出,但不强制截断 */
}
.device-cell.empty .device-id {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment