diff --git a/agri-admin/src/main/java/com/agri/system/controller/SysRollerAirController.java b/agri-admin/src/main/java/com/agri/system/controller/SysRollerAirController.java new file mode 100644 index 0000000..ee02ef7 --- /dev/null +++ b/agri-admin/src/main/java/com/agri/system/controller/SysRollerAirController.java @@ -0,0 +1,104 @@ +package com.agri.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +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.agri.common.annotation.Log; +import com.agri.common.core.controller.BaseController; +import com.agri.common.core.domain.AjaxResult; +import com.agri.common.enums.BusinessType; +import com.agri.system.domain.SysRollerAir; +import com.agri.system.service.ISysRollerAirService; +import com.agri.common.utils.poi.ExcelUtil; +import com.agri.common.core.page.TableDataInfo; + +/** + * 自动化卷膜风口大小设置Controller + * + * @author lld + * @date 2026-03-04 + */ +@RestController +@RequestMapping("/assets/air") +public class SysRollerAirController extends BaseController +{ + @Autowired + private ISysRollerAirService sysRollerAirService; + + /** + * 查询自动化卷膜风口大小设置列表 + */ + @PreAuthorize("@ss.hasPermi('assets:air:list')") + @GetMapping("/list") + public TableDataInfo list(SysRollerAir sysRollerAir) + { + startPage(); + List list = sysRollerAirService.selectSysRollerAirList(sysRollerAir); + return getDataTable(list); + } + + /** + * 导出自动化卷膜风口大小设置列表 + */ + @PreAuthorize("@ss.hasPermi('assets:air:export')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SysRollerAir sysRollerAir) + { + List list = sysRollerAirService.selectSysRollerAirList(sysRollerAir); + ExcelUtil util = new ExcelUtil(SysRollerAir.class); + util.exportExcel(response, list, "自动化卷膜风口大小设置数据"); + } + + /** + * 获取自动化卷膜风口大小设置详细信息 + */ + @PreAuthorize("@ss.hasPermi('assets:air:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sysRollerAirService.selectSysRollerAirById(id)); + } + + /** + * 新增自动化卷膜风口大小设置 + */ + @PreAuthorize("@ss.hasPermi('assets:air:add')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysRollerAir sysRollerAir) + { + return toAjax(sysRollerAirService.insertSysRollerAir(sysRollerAir)); + } + + /** + * 修改自动化卷膜风口大小设置 + */ + @PreAuthorize("@ss.hasPermi('assets:air:edit')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysRollerAir sysRollerAir) + { + return toAjax(sysRollerAirService.updateSysRollerAir(sysRollerAir)); + } + + /** + * 删除自动化卷膜风口大小设置 + */ + @PreAuthorize("@ss.hasPermi('assets:air:remove')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysRollerAirService.deleteSysRollerAirByIds(ids)); + } +} diff --git a/agri-admin/src/main/java/com/agri/system/domain/SysRollerAir.java b/agri-admin/src/main/java/com/agri/system/domain/SysRollerAir.java new file mode 100644 index 0000000..c72692e --- /dev/null +++ b/agri-admin/src/main/java/com/agri/system/domain/SysRollerAir.java @@ -0,0 +1,139 @@ +package com.agri.system.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.baomidou.mybatisplus.annotation.TableName; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.agri.common.annotation.Excel; +import com.agri.common.core.domain.BaseEntity; + +/** + * 自动化卷膜风口大小设置对象 sys_roller_air + * + * @author lld + * @date 2026-03-04 + */ +@TableName("sys_roller_air") +public class SysRollerAir extends BaseEntity +{ + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** 设备IMEI码 */ + @Excel(name = "设备IMEI码") + private String imei; + + /** 卷膜器编号/标识 */ + @Excel(name = "卷膜器编号/标识") + private String roller; + + /** 操作类型 0-停止 1-运行 2-查询 3-重置 */ + @Excel(name = "操作类型 0-停止 1-运行 2-查询 3-重置") + private Long opType; + + /** 操作参数(JSON格式,存储风口大小等配置) */ + @Excel(name = "操作参数(JSON格式,存储风口大小等配置)") + private String payload; + + /** 客户端ID */ + @Excel(name = "客户端ID") + private String clientid; + + /** 操作执行时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + @Excel(name = "操作执行时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date opTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setImei(String imei) + { + this.imei = imei; + } + + public String getImei() + { + return imei; + } + + public void setRoller(String roller) + { + this.roller = roller; + } + + public String getRoller() + { + return roller; + } + + public void setOpType(Long opType) + { + this.opType = opType; + } + + public Long getOpType() + { + return opType; + } + + public void setPayload(String payload) + { + this.payload = payload; + } + + public String getPayload() + { + return payload; + } + + public void setClientid(String clientid) + { + this.clientid = clientid; + } + + public String getClientid() + { + return clientid; + } + + public void setOpTime(Date opTime) + { + this.opTime = opTime; + } + + public Date getOpTime() + { + return opTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("imei", getImei()) + .append("roller", getRoller()) + .append("opType", getOpType()) + .append("payload", getPayload()) + .append("clientid", getClientid()) + .append("opTime", getOpTime()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/agri-admin/src/main/java/com/agri/system/mapper/SysRollerAirMapper.java b/agri-admin/src/main/java/com/agri/system/mapper/SysRollerAirMapper.java new file mode 100644 index 0000000..c90a013 --- /dev/null +++ b/agri-admin/src/main/java/com/agri/system/mapper/SysRollerAirMapper.java @@ -0,0 +1,62 @@ +package com.agri.system.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.agri.system.domain.SysRollerAir; + +/** + * 自动化卷膜风口大小设置Mapper接口 + * + * @author lld + * @date 2026-03-04 + */ +public interface SysRollerAirMapper extends BaseMapper +{ + /** + * 查询自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 自动化卷膜风口大小设置 + */ + public SysRollerAir selectSysRollerAirById(Long id); + + /** + * 查询自动化卷膜风口大小设置列表 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 自动化卷膜风口大小设置集合 + */ + public List selectSysRollerAirList(SysRollerAir sysRollerAir); + + /** + * 新增自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int insertSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 修改自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int updateSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 删除自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 结果 + */ + public int deleteSysRollerAirById(Long id); + + /** + * 批量删除自动化卷膜风口大小设置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysRollerAirByIds(Long[] ids); +} diff --git a/agri-admin/src/main/java/com/agri/system/service/ISysRollerAirService.java b/agri-admin/src/main/java/com/agri/system/service/ISysRollerAirService.java new file mode 100644 index 0000000..f679ddf --- /dev/null +++ b/agri-admin/src/main/java/com/agri/system/service/ISysRollerAirService.java @@ -0,0 +1,61 @@ +package com.agri.system.service; + +import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; +import com.agri.system.domain.SysRollerAir; + +/** + * 自动化卷膜风口大小设置Service接口 + * + * @author lld + * @date 2026-03-04 + */ +public interface ISysRollerAirService extends IService { + /** + * 查询自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 自动化卷膜风口大小设置 + */ + public SysRollerAir selectSysRollerAirById(Long id); + + /** + * 查询自动化卷膜风口大小设置列表 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 自动化卷膜风口大小设置集合 + */ + public List selectSysRollerAirList(SysRollerAir sysRollerAir); + + /** + * 新增自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int insertSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 修改自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int updateSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 批量删除自动化卷膜风口大小设置 + * + * @param ids 需要删除的自动化卷膜风口大小设置主键集合 + * @return 结果 + */ + public int deleteSysRollerAirByIds(Long[] ids); + + /** + * 删除自动化卷膜风口大小设置信息 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 结果 + */ + public int deleteSysRollerAirById(Long id); +} diff --git a/agri-admin/src/main/java/com/agri/system/service/impl/SysRollerAirServiceImpl.java b/agri-admin/src/main/java/com/agri/system/service/impl/SysRollerAirServiceImpl.java new file mode 100644 index 0000000..abdb4f4 --- /dev/null +++ b/agri-admin/src/main/java/com/agri/system/service/impl/SysRollerAirServiceImpl.java @@ -0,0 +1,94 @@ +package com.agri.system.service.impl; + +import java.util.List; +import com.agri.common.utils.DateUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import com.agri.system.mapper.SysRollerAirMapper; +import com.agri.system.domain.SysRollerAir; +import com.agri.system.service.ISysRollerAirService; + +/** + * 自动化卷膜风口大小设置Service业务层处理 + * + * @author lld + * @date 2026-03-04 + */ +@Service +public class SysRollerAirServiceImpl extends ServiceImpl implements ISysRollerAirService +{ + + /** + * 查询自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 自动化卷膜风口大小设置 + */ + @Override + public SysRollerAir selectSysRollerAirById(Long id) + { + return baseMapper.selectSysRollerAirById(id); + } + + /** + * 查询自动化卷膜风口大小设置列表 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 自动化卷膜风口大小设置 + */ + @Override + public List selectSysRollerAirList(SysRollerAir sysRollerAir) + { + return baseMapper.selectSysRollerAirList(sysRollerAir); + } + + /** + * 新增自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + @Override + public int insertSysRollerAir(SysRollerAir sysRollerAir) + { + sysRollerAir.setCreateTime(DateUtils.getNowDate()); + return baseMapper.insertSysRollerAir(sysRollerAir); + } + + /** + * 修改自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + @Override + public int updateSysRollerAir(SysRollerAir sysRollerAir) + { + sysRollerAir.setUpdateTime(DateUtils.getNowDate()); + return baseMapper.updateSysRollerAir(sysRollerAir); + } + + /** + * 批量删除自动化卷膜风口大小设置 + * + * @param ids 需要删除的自动化卷膜风口大小设置主键 + * @return 结果 + */ + @Override + public int deleteSysRollerAirByIds(Long[] ids) + { + return baseMapper.deleteSysRollerAirByIds(ids); + } + + /** + * 删除自动化卷膜风口大小设置信息 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 结果 + */ + @Override + public int deleteSysRollerAirById(Long id) + { + return baseMapper.deleteSysRollerAirById(id); + } +} diff --git a/agri-admin/src/main/resources/application-mqtt.yml b/agri-admin/src/main/resources/application-mqtt.yml index f769be7..36bf355 100644 --- a/agri-admin/src/main/resources/application-mqtt.yml +++ b/agri-admin/src/main/resources/application-mqtt.yml @@ -5,7 +5,8 @@ spring: username: admin # Mosquitto共用账号 password: Admin#12345678 # Mosquitto密码 client-id: springboot-backend # 截取UUID前8位(自动去横线) - default-topic: dtu/+/up,dtu/+/ack,frontend/+/control/+,frontend/+/online # 后端监听的主题 + # 后端监听的主题 + default-topic: dtu/+/up,dtu/+/ack,frontend/+/control/+,frontend/+/online, frontend/+/+/config qos: 0 # 消息可靠性 timeout: 60 # 连接超时 keep-alive: 60 # 心跳间隔 diff --git a/agri-admin/src/main/resources/application.yml b/agri-admin/src/main/resources/application.yml index 2c02d41..73d6138 100644 --- a/agri-admin/src/main/resources/application.yml +++ b/agri-admin/src/main/resources/application.yml @@ -12,6 +12,10 @@ agri: addressEnabled: true # 验证码类型 math 数字计算 char 字符验证 captchaType: math + # 卷膜滚轴长度和秒数 + per-lap: + sec: 18 # 以秒为单位 + len: 2.13 # 以cm为单位 # 开启增强 knife4j: enable: true diff --git a/agri-admin/src/main/resources/mapper/assets/SysRollerAirMapper.xml b/agri-admin/src/main/resources/mapper/assets/SysRollerAirMapper.xml new file mode 100644 index 0000000..c5580a1 --- /dev/null +++ b/agri-admin/src/main/resources/mapper/assets/SysRollerAirMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + select id, imei, roller, op_type, payload, clientid, op_time, create_by, create_time, update_by, update_time from sys_roller_air + + + + + + + + insert into sys_roller_air + + imei, + roller, + op_type, + payload, + clientid, + op_time, + create_by, + create_time, + update_by, + update_time, + + + #{imei}, + #{roller}, + #{opType}, + #{payload}, + #{clientid}, + #{opTime}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update sys_roller_air + + imei = #{imei}, + roller = #{roller}, + op_type = #{opType}, + payload = #{payload}, + clientid = #{clientid}, + op_time = #{opTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from sys_roller_air where id = #{id} + + + + delete from sys_roller_air where id in + + #{id} + + + \ No newline at end of file diff --git a/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendConfigHandler.java b/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendConfigHandler.java new file mode 100644 index 0000000..d96e429 --- /dev/null +++ b/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendConfigHandler.java @@ -0,0 +1,136 @@ +package com.agri.framework.interceptor; + +import com.agri.framework.config.MqttConfig; +import com.agri.system.domain.SysRollerAir; +import com.agri.system.service.*; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.TypeReference; +import org.apache.commons.lang3.ObjectUtils; +import org.checkerframework.checker.units.qual.A; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Component +public class FrontendConfigHandler { + + private static final Logger log = LoggerFactory.getLogger(FrontendConfigHandler.class); + + @Resource + private StringRedisTemplate stringRedisTemplate; + + @Resource + private MqttConfig.MqttMessageSender mqttMessageSender; + + @Autowired + private ISysRollerAirService sysRollerAirService; + + @Value("${spring.mqtt.dtu-ctl-lock-ttl}") + private int dtuCtlLockTTL; + + @Value("${agri.per-lap.len}") + private BigDecimal perLapLen; + + @Value("${agri.per-lap.sec}") + private BigDecimal perLapSec; + /** + * 处理前端控制指令:权限校验+分布式锁+转发给设备 + */ + public void handle(String topic, String payload) throws MqttException { + // 解析前端clientId、设备ID + String[] parts = topic.split("/"); + String clientId = parts[1]; + String deviceId = parts[2]; + + // 新增:入参非空校验(JDK 8兼容) + if (!StringUtils.hasText(clientId) || !StringUtils.hasText(deviceId)) { + log.error("【指令处理】clientId或deviceId为空,topic={}", topic); + return; + } + // 解析功能码({"功能码":状态码}格式) + Map funcCodeMap = null; + try { + funcCodeMap = JSON.parseObject(payload, new TypeReference>() { + }); + } catch (Exception e) { + log.error("【指令处理】功能码解析失败,payload={}", payload, e); + return; + } + if (funcCodeMap == null || funcCodeMap.isEmpty()) { + log.warn("【指令处理】前端{}操作设备{}失败:功能码为空", clientId, deviceId); + return; + } + // 提取第一个功能码作为锁标识 + String funcType = funcCodeMap.keySet().iterator().next(); + + // 2. 分布式锁:设备ID+功能类型(避免同设备同功能并发控制) + String lockKey = "lock:" + deviceId + ":" + funcType; + Boolean lockSuccess = stringRedisTemplate.opsForValue().setIfAbsent( + lockKey, clientId, dtuCtlLockTTL, TimeUnit.SECONDS // 延长至15秒,适配设备回执场景 + ); + if (lockSuccess == null || !lockSuccess) { + String errorTopic = "frontend/" + clientId + "/dtu/" + deviceId + "/listener"; + mqttMessageSender.publish(errorTopic, "{\"msg\":\"设备" + funcType + "功能忙,请稍后重试\",\"clientId\":\""+clientId+"\"}"); + log.warn("【分布式锁】前端{}操作设备{}的{}功能失败;可能其他用户正在操作此功能", clientId, deviceId, funcType); + return; + } + // 转发前端指令 + String deviceTopic = "dtu/" + deviceId + "/down"; + mqttMessageSender.publish(deviceTopic, payload); + LocalDateTime currentTime = LocalDateTime.now(); + // 3. 记录日志 + log.info("【指令处理】前端{}于{}控制设备{}的{}功能,指令:{}", + clientId, currentTime, deviceId, funcType, payload); + + String funcName = funcType.substring(0, funcType.length() - 1); + Integer funcCode = funcCodeMap.get("funcType"); + + // 当卷膜 开 暂停,才执行的逻辑 + if (funcCode == 0 && funcType.contains("k")) { + SysRollerAir sysRollerAir = sysRollerAirService.lambdaQuery() + .eq(SysRollerAir::getImei, deviceId) + .eq(SysRollerAir::getRoller, funcName) + .eq(SysRollerAir::getOpType, 1) + .orderByDesc(SysRollerAir::getId) + .last("limit 1") + .one(); + BigDecimal ventTotalLen = BigDecimal.ZERO; + if (ObjectUtils.isNotEmpty(sysRollerAir) + && sysRollerAir.getOpTime().isBefore(currentTime)) { + + long time = Math.abs(Duration.between(currentTime, sysRollerAir.getOpTime()).getSeconds()); + BigDecimal ventTotalTime = BigDecimal.valueOf(time); + + // 除以一圈的时间乘以一圈的长度 + ventTotalLen = ventTotalTime.divide(perLapSec, 2, RoundingMode.HALF_UP) + .multiply(perLapLen).setScale(2, RoundingMode.HALF_UP); + } + String config = "{\"ventTotalLen\": " + ventTotalLen +",\"clientId\":\""+clientId+"\"}"; + // 查数据库、最后一条卷膜开暂停。计算时间发送自动关时间 + mqttMessageSender.publish("frontend/"+clientId+"/dtu/"+deviceId+"/config", config); + } + // 插入记录 + SysRollerAir rollerAir = new SysRollerAir(); + rollerAir.setImei(deviceId); + rollerAir.setRoller(funcName); + rollerAir.setOpType(funcCode); + rollerAir.setPayload(payload); + rollerAir.setClientid(clientId); + rollerAir.setOpTime(currentTime); + sysRollerAirService.save(rollerAir); + log.info("【指令转发】前端{} → 设备{}的{}功能", clientId, deviceId, funcType); + } +} diff --git a/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendControlHandler.java b/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendControlHandler.java index c39afb3..1cdd71b 100644 --- a/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendControlHandler.java +++ b/agri-framework/src/main/java/com/agri/framework/interceptor/FrontendControlHandler.java @@ -100,6 +100,13 @@ public class FrontendControlHandler { log.error("【指令处理】clientId或deviceId为空,topic={}", topic); return; } + // 1. 权限校验(示例:admin开头有全权限) + if (!checkPermission(clientId, deviceId)) { + String errorTopic = "frontend/" + clientId + "/dtu/" + deviceId + "/listener"; + mqttMessageSender.publish(errorTopic, "{\"msg\":\"无设备操作权限\"}"); + log.warn("【权限校验】前端{}操作设备{}失败", clientId, deviceId); + return; + } // 4. 转发指令到设备 String deviceTopic = "dtu/" + deviceId + "/down"; JSONObject payloadObj; @@ -134,14 +141,6 @@ public class FrontendControlHandler { // 提取第一个功能码作为锁标识 String funcType = funcCodeMap.keySet().iterator().next(); - // 1. 权限校验(示例:admin开头有全权限) - if (!checkPermission(clientId, deviceId)) { - String errorTopic = "frontend/" + clientId + "/dtu/" + deviceId + "/listener"; - mqttMessageSender.publish(errorTopic, "{\"msg\":\"无设备操作权限\"}"); - log.warn("【权限校验】前端{}操作设备{}失败", clientId, deviceId); - return; - } - // 2. 分布式锁:设备ID+功能类型(避免同设备同功能并发控制) String lockKey = "lock:" + deviceId + ":" + funcType; Boolean lockSuccess = stringRedisTemplate.opsForValue().setIfAbsent( diff --git a/agri-framework/src/main/java/com/agri/framework/web/dispatcher/MqttMessageDispatcher.java b/agri-framework/src/main/java/com/agri/framework/web/dispatcher/MqttMessageDispatcher.java index a5ec5bc..79a58f7 100644 --- a/agri-framework/src/main/java/com/agri/framework/web/dispatcher/MqttMessageDispatcher.java +++ b/agri-framework/src/main/java/com/agri/framework/web/dispatcher/MqttMessageDispatcher.java @@ -1,10 +1,7 @@ package com.agri.framework.web.dispatcher; import com.agri.common.utils.wechat.WxUtil; -import com.agri.framework.interceptor.DeviceAckHandler; -import com.agri.framework.interceptor.DeviceStatusHandler; -import com.agri.framework.interceptor.FrontendControlHandler; -import com.agri.framework.interceptor.FrontendOnlineHandler; +import com.agri.framework.interceptor.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -50,7 +47,7 @@ public class MqttMessageDispatcher { * 前端在线心跳处理器 */ @Resource - private DeviceAckHandler deviceAckHandler; + private FrontendConfigHandler frontendConfigHandler; /** * 消息分发处理:根据主题类型路由到不同处理方法 @@ -74,6 +71,9 @@ public class MqttMessageDispatcher { // 新增:前端在线心跳主题:frontend/{clientId}/online else if (topic.matches("frontend/\\w+/online")) { frontendOnlineHandler.handle(topic, payload); + } // 新增:前端在线心跳主题:frontend/{clientId}/online + else if (topic.matches("frontend/\\w+/\\w+/config")) { + frontendConfigHandler.handle(topic, payload); } } catch (Exception e) { WxUtil.pushText("【MQTT消息处理异常】\n topic: "+ topic+"\n cause: "+e); diff --git a/agri-quartz/src/main/java/com/agri/quartz/task/AgriStatusTask.java b/agri-quartz/src/main/java/com/agri/quartz/task/AgriStatusTask.java new file mode 100644 index 0000000..792041c --- /dev/null +++ b/agri-quartz/src/main/java/com/agri/quartz/task/AgriStatusTask.java @@ -0,0 +1,4 @@ +package com.agri.quartz.task; + +public class AgriStatusTask { +} diff --git a/agri-quartz/src/main/java/com/agri/quartz/task/RollerAutoTask.java b/agri-quartz/src/main/java/com/agri/quartz/task/RollerAutoTask.java new file mode 100644 index 0000000..cc71ff4 --- /dev/null +++ b/agri-quartz/src/main/java/com/agri/quartz/task/RollerAutoTask.java @@ -0,0 +1,17 @@ +package com.agri.quartz.task; + +import org.springframework.stereotype.Component; + +/** + * 卷膜自动模式定时检查 + * 每五分钟执行一次 + * 1、查询大棚列表开启自动模式的大棚,获取imei + * 2、根据imei查询dtu_data最后一分钟最后一条温度数据 + * 3、查询参数设置获取 风口总长 预留风口长度 在条件内开启指定风口,第一次开 预留风口+条件内设定的风口长度 还是得存日志、、、 + * 4、下发开启或者关闭指令 起个自动关任务 需要改自动关逻辑,自动模式,监听处不转发回执 + * todo通知用户 + */ +@Component("rollerAutoTask") +public class RollerAutoTask { + +} diff --git a/agri-system/src/main/java/com/agri/system/controller/SysAgriInfoController.java b/agri-system/src/main/java/com/agri/system/controller/SysAgriInfoController.java index 2bf2cae..9e13787 100644 --- a/agri-system/src/main/java/com/agri/system/controller/SysAgriInfoController.java +++ b/agri-system/src/main/java/com/agri/system/controller/SysAgriInfoController.java @@ -13,17 +13,11 @@ import com.agri.system.domain.SysUserAgri; import com.agri.system.domain.vo.AgriInfoView; import com.agri.system.service.ISysAgriInfoService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -130,8 +124,22 @@ public class SysAgriInfoController extends BaseController */ @PreAuthorize("@ss.hasPermi('assets:agri:addAgriFromMobile')") @PostMapping("/addAgriFromMobile") - public Map addAgriFromMobile(@RequestBody SysAgriInfo sysAgriInfo) { + public AjaxResult addAgriFromMobile(@RequestBody SysAgriInfo sysAgriInfo) { return success(sysAgriInfoService.addAgriFromMobile(sysAgriInfo)); } + + @PreAuthorize("@ss.hasPermi('assets:agri:switchAgriMode')") + @PostMapping("/switchAgriMode/{imei}") + public AjaxResult switchAgriMode(@PathVariable String imei, @RequestParam("code") Integer code) { + + if (StringUtils.isEmpty(imei) || code == null) { + return error(); + } + sysAgriInfoService.lambdaUpdate() + .eq(SysAgriInfo::getImei, imei) + .set(SysAgriInfo::getWorkMode, code) + .update(); + return success(); + } } diff --git a/agri-system/src/main/java/com/agri/system/controller/SysRollerAirController.java b/agri-system/src/main/java/com/agri/system/controller/SysRollerAirController.java new file mode 100644 index 0000000..ee02ef7 --- /dev/null +++ b/agri-system/src/main/java/com/agri/system/controller/SysRollerAirController.java @@ -0,0 +1,104 @@ +package com.agri.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +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.agri.common.annotation.Log; +import com.agri.common.core.controller.BaseController; +import com.agri.common.core.domain.AjaxResult; +import com.agri.common.enums.BusinessType; +import com.agri.system.domain.SysRollerAir; +import com.agri.system.service.ISysRollerAirService; +import com.agri.common.utils.poi.ExcelUtil; +import com.agri.common.core.page.TableDataInfo; + +/** + * 自动化卷膜风口大小设置Controller + * + * @author lld + * @date 2026-03-04 + */ +@RestController +@RequestMapping("/assets/air") +public class SysRollerAirController extends BaseController +{ + @Autowired + private ISysRollerAirService sysRollerAirService; + + /** + * 查询自动化卷膜风口大小设置列表 + */ + @PreAuthorize("@ss.hasPermi('assets:air:list')") + @GetMapping("/list") + public TableDataInfo list(SysRollerAir sysRollerAir) + { + startPage(); + List list = sysRollerAirService.selectSysRollerAirList(sysRollerAir); + return getDataTable(list); + } + + /** + * 导出自动化卷膜风口大小设置列表 + */ + @PreAuthorize("@ss.hasPermi('assets:air:export')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, SysRollerAir sysRollerAir) + { + List list = sysRollerAirService.selectSysRollerAirList(sysRollerAir); + ExcelUtil util = new ExcelUtil(SysRollerAir.class); + util.exportExcel(response, list, "自动化卷膜风口大小设置数据"); + } + + /** + * 获取自动化卷膜风口大小设置详细信息 + */ + @PreAuthorize("@ss.hasPermi('assets:air:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(sysRollerAirService.selectSysRollerAirById(id)); + } + + /** + * 新增自动化卷膜风口大小设置 + */ + @PreAuthorize("@ss.hasPermi('assets:air:add')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysRollerAir sysRollerAir) + { + return toAjax(sysRollerAirService.insertSysRollerAir(sysRollerAir)); + } + + /** + * 修改自动化卷膜风口大小设置 + */ + @PreAuthorize("@ss.hasPermi('assets:air:edit')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysRollerAir sysRollerAir) + { + return toAjax(sysRollerAirService.updateSysRollerAir(sysRollerAir)); + } + + /** + * 删除自动化卷膜风口大小设置 + */ + @PreAuthorize("@ss.hasPermi('assets:air:remove')") + @Log(title = "自动化卷膜风口大小设置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(sysRollerAirService.deleteSysRollerAirByIds(ids)); + } +} diff --git a/agri-system/src/main/java/com/agri/system/domain/SysRollerAir.java b/agri-system/src/main/java/com/agri/system/domain/SysRollerAir.java new file mode 100644 index 0000000..993921b --- /dev/null +++ b/agri-system/src/main/java/com/agri/system/domain/SysRollerAir.java @@ -0,0 +1,79 @@ +package com.agri.system.domain; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import lombok.Getter; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableName; +import com.agri.common.annotation.Excel; +import com.agri.common.core.domain.BaseEntity; + +/** + * 自动化卷膜风口大小设置对象 sys_roller_air + * + * @author lld + * @date 2026-03-04 + */ +@Data +@TableName("sys_roller_air") +public class SysRollerAir extends BaseEntity +{ + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + /** 主键ID */ + @TableId(type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** 设备IMEI码 */ + @Excel(name = "设备IMEI码") + private String imei; + + /** 卷膜器编号/标识 */ + @Excel(name = "卷膜器编号/标识") + private String roller; + + /** 操作类型 0-停止 1-运行 2-查询 3-重置 */ + @Excel(name = "操作类型 0-停止 1-运行 2-查询 3-重置") + private Integer opType; + + /** 操作参数(JSON格式,存储风口大小等配置) */ + @Excel(name = "操作参数(JSON格式,存储风口大小等配置)") + private String payload; + + /** 客户端ID */ + @Excel(name = "客户端ID") + private String clientid; + + /** 操作执行时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + @Excel(name = "操作执行时间", width = 30, dateFormat = "yyyy-MM-dd") + private LocalDateTime opTime; + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("imei", getImei()) + .append("roller", getRoller()) + .append("opType", getOpType()) + .append("payload", getPayload()) + .append("clientid", getClientid()) + .append("opTime", getOpTime()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/agri-system/src/main/java/com/agri/system/domain/SysRollerParam.java b/agri-system/src/main/java/com/agri/system/domain/SysRollerParam.java index 955d0d9..de09386 100644 --- a/agri-system/src/main/java/com/agri/system/domain/SysRollerParam.java +++ b/agri-system/src/main/java/com/agri/system/domain/SysRollerParam.java @@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.agri.common.annotation.Excel; import com.agri.common.core.domain.BaseEntity; +import java.math.BigDecimal; + /** * 卷膜参数配置对象 sys_roller_param * @@ -44,15 +46,18 @@ public class SysRollerParam extends BaseEntity /** 预留风口长度(cm) */ @Excel(name = "预留风口长度(cm)") - private Long reservedLen; + private BigDecimal reservedLen; /** 手动计算风口总长(cm) */ @Excel(name = "手动计算风口总长(cm)") - private Long manualTotalLen; + private BigDecimal manualTotalLen; /** 自动计算风口总长(cm) */ @Excel(name = "自动计算风口总长(cm)") - private Long autoTotalLen; + private BigDecimal autoTotalLen; + + @Excel(name = "最终风口总长") + private BigDecimal ventTotalLen; public void setId(String id) { @@ -94,32 +99,32 @@ public class SysRollerParam extends BaseEntity return refTempCode; } - public void setReservedLen(Long reservedLen) + public void setReservedLen(BigDecimal reservedLen) { this.reservedLen = reservedLen; } - public Long getReservedLen() + public BigDecimal getReservedLen() { return reservedLen; } - public void setManualTotalLen(Long manualTotalLen) + public void setManualTotalLen(BigDecimal manualTotalLen) { this.manualTotalLen = manualTotalLen; } - public Long getManualTotalLen() + public BigDecimal getManualTotalLen() { return manualTotalLen; } - public void setAutoTotalLen(Long autoTotalLen) + public void setAutoTotalLen(BigDecimal autoTotalLen) { this.autoTotalLen = autoTotalLen; } - public Long getAutoTotalLen() + public BigDecimal getAutoTotalLen() { return autoTotalLen; } @@ -132,6 +137,14 @@ public class SysRollerParam extends BaseEntity this.refTemp = refTemp; } + public BigDecimal getVentTotalLen() { + return ventTotalLen; + } + + public void setVentTotalLen(BigDecimal ventTotalLen) { + this.ventTotalLen = ventTotalLen; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/agri-system/src/main/java/com/agri/system/mapper/SysRollerAirMapper.java b/agri-system/src/main/java/com/agri/system/mapper/SysRollerAirMapper.java new file mode 100644 index 0000000..c90a013 --- /dev/null +++ b/agri-system/src/main/java/com/agri/system/mapper/SysRollerAirMapper.java @@ -0,0 +1,62 @@ +package com.agri.system.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.agri.system.domain.SysRollerAir; + +/** + * 自动化卷膜风口大小设置Mapper接口 + * + * @author lld + * @date 2026-03-04 + */ +public interface SysRollerAirMapper extends BaseMapper +{ + /** + * 查询自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 自动化卷膜风口大小设置 + */ + public SysRollerAir selectSysRollerAirById(Long id); + + /** + * 查询自动化卷膜风口大小设置列表 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 自动化卷膜风口大小设置集合 + */ + public List selectSysRollerAirList(SysRollerAir sysRollerAir); + + /** + * 新增自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int insertSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 修改自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int updateSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 删除自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 结果 + */ + public int deleteSysRollerAirById(Long id); + + /** + * 批量删除自动化卷膜风口大小设置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSysRollerAirByIds(Long[] ids); +} diff --git a/agri-system/src/main/java/com/agri/system/service/ISysRollerAirService.java b/agri-system/src/main/java/com/agri/system/service/ISysRollerAirService.java new file mode 100644 index 0000000..f679ddf --- /dev/null +++ b/agri-system/src/main/java/com/agri/system/service/ISysRollerAirService.java @@ -0,0 +1,61 @@ +package com.agri.system.service; + +import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; +import com.agri.system.domain.SysRollerAir; + +/** + * 自动化卷膜风口大小设置Service接口 + * + * @author lld + * @date 2026-03-04 + */ +public interface ISysRollerAirService extends IService { + /** + * 查询自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 自动化卷膜风口大小设置 + */ + public SysRollerAir selectSysRollerAirById(Long id); + + /** + * 查询自动化卷膜风口大小设置列表 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 自动化卷膜风口大小设置集合 + */ + public List selectSysRollerAirList(SysRollerAir sysRollerAir); + + /** + * 新增自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int insertSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 修改自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + public int updateSysRollerAir(SysRollerAir sysRollerAir); + + /** + * 批量删除自动化卷膜风口大小设置 + * + * @param ids 需要删除的自动化卷膜风口大小设置主键集合 + * @return 结果 + */ + public int deleteSysRollerAirByIds(Long[] ids); + + /** + * 删除自动化卷膜风口大小设置信息 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 结果 + */ + public int deleteSysRollerAirById(Long id); +} diff --git a/agri-system/src/main/java/com/agri/system/service/impl/SysAutoTermServiceImpl.java b/agri-system/src/main/java/com/agri/system/service/impl/SysAutoTermServiceImpl.java index 0ca5fa9..9beaf7d 100644 --- a/agri-system/src/main/java/com/agri/system/service/impl/SysAutoTermServiceImpl.java +++ b/agri-system/src/main/java/com/agri/system/service/impl/SysAutoTermServiceImpl.java @@ -150,13 +150,13 @@ public class SysAutoTermServiceImpl extends ServiceImpl 0) - || (config.getAutoTotalLen() != null && config.getAutoTotalLen() > 0); + boolean hasLen = (config.getManualTotalLen() != null && config.getManualTotalLen().compareTo(BigDecimal.ZERO)>0) + || (config.getAutoTotalLen() != null && config.getAutoTotalLen().compareTo(BigDecimal.ZERO)>0); if (!hasLen) { return roller + "计算风口总长和手动设置风口长度至少填写一个!"; } - if (config.getReservedLen() == null || config.getReservedLen() <= 0) { + if (config.getReservedLen() == null || config.getReservedLen().compareTo(BigDecimal.ZERO)<=0) { return roller + "预留风口长度未设置,请点击相应页签右上角设置后重试!"; } diff --git a/agri-system/src/main/java/com/agri/system/service/impl/SysRollerAirServiceImpl.java b/agri-system/src/main/java/com/agri/system/service/impl/SysRollerAirServiceImpl.java new file mode 100644 index 0000000..abdb4f4 --- /dev/null +++ b/agri-system/src/main/java/com/agri/system/service/impl/SysRollerAirServiceImpl.java @@ -0,0 +1,94 @@ +package com.agri.system.service.impl; + +import java.util.List; +import com.agri.common.utils.DateUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import com.agri.system.mapper.SysRollerAirMapper; +import com.agri.system.domain.SysRollerAir; +import com.agri.system.service.ISysRollerAirService; + +/** + * 自动化卷膜风口大小设置Service业务层处理 + * + * @author lld + * @date 2026-03-04 + */ +@Service +public class SysRollerAirServiceImpl extends ServiceImpl implements ISysRollerAirService +{ + + /** + * 查询自动化卷膜风口大小设置 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 自动化卷膜风口大小设置 + */ + @Override + public SysRollerAir selectSysRollerAirById(Long id) + { + return baseMapper.selectSysRollerAirById(id); + } + + /** + * 查询自动化卷膜风口大小设置列表 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 自动化卷膜风口大小设置 + */ + @Override + public List selectSysRollerAirList(SysRollerAir sysRollerAir) + { + return baseMapper.selectSysRollerAirList(sysRollerAir); + } + + /** + * 新增自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + @Override + public int insertSysRollerAir(SysRollerAir sysRollerAir) + { + sysRollerAir.setCreateTime(DateUtils.getNowDate()); + return baseMapper.insertSysRollerAir(sysRollerAir); + } + + /** + * 修改自动化卷膜风口大小设置 + * + * @param sysRollerAir 自动化卷膜风口大小设置 + * @return 结果 + */ + @Override + public int updateSysRollerAir(SysRollerAir sysRollerAir) + { + sysRollerAir.setUpdateTime(DateUtils.getNowDate()); + return baseMapper.updateSysRollerAir(sysRollerAir); + } + + /** + * 批量删除自动化卷膜风口大小设置 + * + * @param ids 需要删除的自动化卷膜风口大小设置主键 + * @return 结果 + */ + @Override + public int deleteSysRollerAirByIds(Long[] ids) + { + return baseMapper.deleteSysRollerAirByIds(ids); + } + + /** + * 删除自动化卷膜风口大小设置信息 + * + * @param id 自动化卷膜风口大小设置主键 + * @return 结果 + */ + @Override + public int deleteSysRollerAirById(Long id) + { + return baseMapper.deleteSysRollerAirById(id); + } +} diff --git a/agri-system/src/main/java/com/agri/system/util/RollerParamValidateUtil.java b/agri-system/src/main/java/com/agri/system/util/RollerParamValidateUtil.java index 8892e50..1400c1c 100644 --- a/agri-system/src/main/java/com/agri/system/util/RollerParamValidateUtil.java +++ b/agri-system/src/main/java/com/agri/system/util/RollerParamValidateUtil.java @@ -85,14 +85,14 @@ public class RollerParamValidateUtil { // 规则3:计算风口总长和手动设置风口长度至少填写一个! rules.add(new CheckRule("计算风口总长和手动设置风口长度至少填写一个!请填写后重试!", (rollerParam, term) -> // 前端:!((manualTotalLen>0) || (autoTotalLen>0)) - !((rollerParam.getManualTotalLen() != null && rollerParam.getManualTotalLen() > 0) - || (rollerParam.getAutoTotalLen() != null && rollerParam.getAutoTotalLen() > 0)) + !((rollerParam.getManualTotalLen() != null && rollerParam.getManualTotalLen().compareTo(BigDecimal.ZERO)>0) + || (rollerParam.getAutoTotalLen() != null && rollerParam.getAutoTotalLen().compareTo(BigDecimal.ZERO)>0)) )); // 规则4:预留风口长度未设置! rules.add(new CheckRule("预留风口长度未设置,请点击相应页签右上角设置后重试!", (rollerParam, term) -> // 前端:!(reservedLen && reservedLen > 0) - !(rollerParam.getReservedLen() != null && rollerParam.getReservedLen() > 0) + !(rollerParam.getReservedLen() != null && rollerParam.getReservedLen().compareTo(BigDecimal.ZERO) > 0) )); // 规则5:温度控制未设置! diff --git a/agri-system/src/main/resources/mapper/assets/SysRollerAirMapper.xml b/agri-system/src/main/resources/mapper/assets/SysRollerAirMapper.xml new file mode 100644 index 0000000..c5580a1 --- /dev/null +++ b/agri-system/src/main/resources/mapper/assets/SysRollerAirMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + select id, imei, roller, op_type, payload, clientid, op_time, create_by, create_time, update_by, update_time from sys_roller_air + + + + + + + + insert into sys_roller_air + + imei, + roller, + op_type, + payload, + clientid, + op_time, + create_by, + create_time, + update_by, + update_time, + + + #{imei}, + #{roller}, + #{opType}, + #{payload}, + #{clientid}, + #{opTime}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update sys_roller_air + + imei = #{imei}, + roller = #{roller}, + op_type = #{opType}, + payload = #{payload}, + clientid = #{clientid}, + op_time = #{opTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from sys_roller_air where id = #{id} + + + + delete from sys_roller_air where id in + + #{id} + + + \ No newline at end of file