自动化条件保存
parent
202e81dbaa
commit
cd36d21d01
|
|
@ -34,6 +34,10 @@
|
|||
<groupId>com.agri</groupId>
|
||||
<artifactId>agri-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agri</groupId>
|
||||
<artifactId>agri-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.agri.quartz.task;
|
||||
|
||||
import com.agri.system.domain.SysDtuData;
|
||||
import com.agri.system.service.ISysDtuDataService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component("tempTask")
|
||||
public class TempTask {
|
||||
|
||||
@Autowired
|
||||
private ISysDtuDataService dtuDataService;
|
||||
|
||||
public void ryNoParams()
|
||||
{
|
||||
dtuDataService.lambdaUpdate()
|
||||
.eq(SysDtuData::getImei, "864536071851206")
|
||||
.orderByDesc(SysDtuData::getId)
|
||||
.last("limit 1")
|
||||
.set(SysDtuData::getTime, new Date())
|
||||
.set(SysDtuData::getCreateTime, new Date())
|
||||
.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
package com.agri.system.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.agri.common.utils.StringUtils;
|
||||
import com.agri.system.domain.vo.AgriTermVo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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.SysAutoTerm;
|
||||
import com.agri.system.service.ISysAutoTermService;
|
||||
import com.agri.common.utils.poi.ExcelUtil;
|
||||
import com.agri.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 卷膜运行条件Controller
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/control/autoTerm")
|
||||
public class SysAutoTermController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysAutoTermService sysAutoTermService;
|
||||
|
||||
/**
|
||||
* 查询卷膜运行条件列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
startPage();
|
||||
List<SysAutoTerm> list = sysAutoTermService.selectSysAutoTermList(sysAutoTerm);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出卷膜运行条件列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:export')")
|
||||
@Log(title = "卷膜运行条件", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
List<SysAutoTerm> list = sysAutoTermService.selectSysAutoTermList(sysAutoTerm);
|
||||
ExcelUtil<SysAutoTerm> util = new ExcelUtil<SysAutoTerm>(SysAutoTerm.class);
|
||||
util.exportExcel(response, list, "卷膜运行条件数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取卷膜运行条件详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(sysAutoTermService.selectSysAutoTermById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增卷膜运行条件
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:add')")
|
||||
@Log(title = "卷膜运行条件", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
return toAjax(sysAutoTermService.insertSysAutoTerm(sysAutoTerm));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改卷膜运行条件
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:edit')")
|
||||
@Log(title = "卷膜运行条件", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
return toAjax(sysAutoTermService.updateSysAutoTerm(sysAutoTerm));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卷膜运行条件
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:remove')")
|
||||
@Log(title = "卷膜运行条件", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(sysAutoTermService.deleteSysAutoTermByIds(ids));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:saveAgriTerm')")
|
||||
@Log(title = "保存自动化条件", businessType = BusinessType.INSERT)
|
||||
@PutMapping("/saveAgriTerm")
|
||||
public AjaxResult saveAgriTerm(@RequestBody List<AgriTermVo> agriTerms) {
|
||||
if (CollectionUtils.isEmpty(agriTerms)) {
|
||||
return error("保存失败!自动化条件设置为空!");
|
||||
} else {
|
||||
String validateTips = sysAutoTermService.validate(agriTerms);
|
||||
if (StringUtils.isNotEmpty(validateTips)) {
|
||||
return error(validateTips);
|
||||
}
|
||||
}
|
||||
sysAutoTermService.saveAgriTerm(agriTerms);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前设备下所有条件
|
||||
* @param imei
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:autoTerm:query')")
|
||||
@GetMapping("/getAgriTerm/{imei}")
|
||||
public AjaxResult getAgriTerm(@PathVariable String imei) {
|
||||
|
||||
return success(sysAutoTermService.getAgriTerm(imei));
|
||||
}
|
||||
}
|
||||
|
|
@ -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.SysRollerParam;
|
||||
import com.agri.system.service.ISysRollerParamService;
|
||||
import com.agri.common.utils.poi.ExcelUtil;
|
||||
import com.agri.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 卷膜参数配置Controller
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/control/rollerParam")
|
||||
public class SysRollerParamController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysRollerParamService sysRollerParamService;
|
||||
|
||||
/**
|
||||
* 查询卷膜参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:rollerParam:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRollerParam sysRollerParam)
|
||||
{
|
||||
startPage();
|
||||
List<SysRollerParam> list = sysRollerParamService.selectSysRollerParamList(sysRollerParam);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出卷膜参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:rollerParam:export')")
|
||||
@Log(title = "卷膜参数配置", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysRollerParam sysRollerParam)
|
||||
{
|
||||
List<SysRollerParam> list = sysRollerParamService.selectSysRollerParamList(sysRollerParam);
|
||||
ExcelUtil<SysRollerParam> util = new ExcelUtil<SysRollerParam>(SysRollerParam.class);
|
||||
util.exportExcel(response, list, "卷膜参数配置数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取卷膜参数配置详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:rollerParam:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
return success(sysRollerParamService.selectSysRollerParamById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增卷膜参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:rollerParam:add')")
|
||||
@Log(title = "卷膜参数配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysRollerParam sysRollerParam)
|
||||
{
|
||||
return toAjax(sysRollerParamService.insertSysRollerParam(sysRollerParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改卷膜参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:rollerParam:edit')")
|
||||
@Log(title = "卷膜参数配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysRollerParam sysRollerParam)
|
||||
{
|
||||
return toAjax(sysRollerParamService.updateSysRollerParam(sysRollerParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卷膜参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('control:rollerParam:remove')")
|
||||
@Log(title = "卷膜参数配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids)
|
||||
{
|
||||
return toAjax(sysRollerParamService.deleteSysRollerParamByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
package com.agri.system.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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 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_auto_term
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
@TableName("sys_auto_term")
|
||||
public class SysAutoTerm extends BaseEntity
|
||||
{
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String id;
|
||||
|
||||
/** imei */
|
||||
@Excel(name = "imei")
|
||||
private String imei;
|
||||
|
||||
/** 卷膜标识 */
|
||||
@Excel(name = "卷膜标识")
|
||||
private String roller;
|
||||
|
||||
/** 运行时间始 */
|
||||
@JsonFormat(pattern = "HH:mm",timezone = "GMT+8")
|
||||
@Excel(name = "运行时间始", width = 30)
|
||||
private Date startTime;
|
||||
|
||||
/** 运行时间止 */
|
||||
@JsonFormat(pattern = "HH:mm",timezone = "GMT+8")
|
||||
@Excel(name = "运行时间止", width = 30)
|
||||
private Date endTime;
|
||||
|
||||
/** 适宜温度 */
|
||||
@Excel(name = "适宜温度")
|
||||
private BigDecimal temp;
|
||||
|
||||
/** 开启风口大小(米) */
|
||||
@Excel(name = "开启风口大小(米)")
|
||||
private Long vent;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String 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 setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Date getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setTemp(BigDecimal temp)
|
||||
{
|
||||
this.temp = temp;
|
||||
}
|
||||
|
||||
public BigDecimal getTemp()
|
||||
{
|
||||
return temp;
|
||||
}
|
||||
|
||||
public void setVent(Long vent)
|
||||
{
|
||||
this.vent = vent;
|
||||
}
|
||||
|
||||
public Long getVent()
|
||||
{
|
||||
return vent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("imei", getImei())
|
||||
.append("roller", getRoller())
|
||||
.append("startTime", getStartTime())
|
||||
.append("endTime", getEndTime())
|
||||
.append("temp", getTemp())
|
||||
.append("vent", getVent())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
package com.agri.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
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_param
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
@TableName("sys_roller_param")
|
||||
public class SysRollerParam extends BaseEntity
|
||||
{
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String id;
|
||||
|
||||
/** imei */
|
||||
@Excel(name = "imei")
|
||||
private String imei;
|
||||
|
||||
/** 卷膜标识 */
|
||||
@Excel(name = "卷膜标识")
|
||||
private String roller;
|
||||
|
||||
/** 参考温度 */
|
||||
@Excel(name = "参考温度")
|
||||
private String refTempCode;
|
||||
/** 参考温度 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "参考温度")
|
||||
private String refTemp;
|
||||
|
||||
/** 预留风口长度(cm) */
|
||||
@Excel(name = "预留风口长度(cm)")
|
||||
private Long reservedLen;
|
||||
|
||||
/** 手动计算风口总长(cm) */
|
||||
@Excel(name = "手动计算风口总长(cm)")
|
||||
private Long manualTotalLen;
|
||||
|
||||
/** 自动计算风口总长(cm) */
|
||||
@Excel(name = "自动计算风口总长(cm)")
|
||||
private Long autoTotalLen;
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String 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 setRefTempCode(String refTempCode)
|
||||
{
|
||||
this.refTempCode = refTempCode;
|
||||
}
|
||||
|
||||
public String getRefTempCode()
|
||||
{
|
||||
return refTempCode;
|
||||
}
|
||||
|
||||
public void setReservedLen(Long reservedLen)
|
||||
{
|
||||
this.reservedLen = reservedLen;
|
||||
}
|
||||
|
||||
public Long getReservedLen()
|
||||
{
|
||||
return reservedLen;
|
||||
}
|
||||
|
||||
public void setManualTotalLen(Long manualTotalLen)
|
||||
{
|
||||
this.manualTotalLen = manualTotalLen;
|
||||
}
|
||||
|
||||
public Long getManualTotalLen()
|
||||
{
|
||||
return manualTotalLen;
|
||||
}
|
||||
|
||||
public void setAutoTotalLen(Long autoTotalLen)
|
||||
{
|
||||
this.autoTotalLen = autoTotalLen;
|
||||
}
|
||||
|
||||
public Long getAutoTotalLen()
|
||||
{
|
||||
return autoTotalLen;
|
||||
}
|
||||
|
||||
public String getRefTemp() {
|
||||
return refTemp;
|
||||
}
|
||||
|
||||
public void setRefTemp(String refTemp) {
|
||||
this.refTemp = refTemp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("imei", getImei())
|
||||
.append("roller", getRoller())
|
||||
.append("refTempCode", getRefTempCode())
|
||||
.append("reservedLen", getReservedLen())
|
||||
.append("manualTotalLen", getManualTotalLen())
|
||||
.append("autoTotalLen", getAutoTotalLen())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.agri.system.domain.vo;
|
||||
|
||||
import com.agri.system.domain.SysAutoTerm;
|
||||
import com.agri.system.domain.SysRollerParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动化条件vo
|
||||
*/
|
||||
@Data
|
||||
public class AgriTermVo {
|
||||
|
||||
private SysRollerParam config;
|
||||
|
||||
private List<SysAutoTerm> terms;
|
||||
}
|
||||
|
|
@ -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.SysAutoTerm;
|
||||
|
||||
/**
|
||||
* 卷膜运行条件Mapper接口
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
public interface SysAutoTermMapper extends BaseMapper<SysAutoTerm>
|
||||
{
|
||||
/**
|
||||
* 查询卷膜运行条件
|
||||
*
|
||||
* @param id 卷膜运行条件主键
|
||||
* @return 卷膜运行条件
|
||||
*/
|
||||
public SysAutoTerm selectSysAutoTermById(String id);
|
||||
|
||||
/**
|
||||
* 查询卷膜运行条件列表
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 卷膜运行条件集合
|
||||
*/
|
||||
public List<SysAutoTerm> selectSysAutoTermList(SysAutoTerm sysAutoTerm);
|
||||
|
||||
/**
|
||||
* 新增卷膜运行条件
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysAutoTerm(SysAutoTerm sysAutoTerm);
|
||||
|
||||
/**
|
||||
* 修改卷膜运行条件
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysAutoTerm(SysAutoTerm sysAutoTerm);
|
||||
|
||||
/**
|
||||
* 删除卷膜运行条件
|
||||
*
|
||||
* @param id 卷膜运行条件主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysAutoTermById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除卷膜运行条件
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysAutoTermByIds(String[] ids);
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package com.agri.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.agri.system.domain.SysAgriAlarmRelation;
|
||||
import com.agri.system.domain.SysDtuData;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* DTU温湿度上报数据Mapper接口
|
||||
|
|
@ -9,7 +12,7 @@ import com.agri.system.domain.SysDtuData;
|
|||
* @author agri
|
||||
* @date 2025-12-23
|
||||
*/
|
||||
public interface SysDtuDataMapper
|
||||
public interface SysDtuDataMapper extends BaseMapper<SysDtuData>
|
||||
{
|
||||
/**
|
||||
* 查询DTU温湿度上报数据
|
||||
|
|
|
|||
|
|
@ -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.SysRollerParam;
|
||||
|
||||
/**
|
||||
* 卷膜参数配置Mapper接口
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
public interface SysRollerParamMapper extends BaseMapper<SysRollerParam>
|
||||
{
|
||||
/**
|
||||
* 查询卷膜参数配置
|
||||
*
|
||||
* @param id 卷膜参数配置主键
|
||||
* @return 卷膜参数配置
|
||||
*/
|
||||
public SysRollerParam selectSysRollerParamById(String id);
|
||||
|
||||
/**
|
||||
* 查询卷膜参数配置列表
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 卷膜参数配置集合
|
||||
*/
|
||||
public List<SysRollerParam> selectSysRollerParamList(SysRollerParam sysRollerParam);
|
||||
|
||||
/**
|
||||
* 新增卷膜参数配置
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysRollerParam(SysRollerParam sysRollerParam);
|
||||
|
||||
/**
|
||||
* 修改卷膜参数配置
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysRollerParam(SysRollerParam sysRollerParam);
|
||||
|
||||
/**
|
||||
* 删除卷膜参数配置
|
||||
*
|
||||
* @param id 卷膜参数配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRollerParamById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除卷膜参数配置
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRollerParamByIds(String[] ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.agri.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.agri.system.domain.vo.AgriTermVo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.agri.system.domain.SysAutoTerm;
|
||||
|
||||
/**
|
||||
* 卷膜运行条件Service接口
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
public interface ISysAutoTermService extends IService<SysAutoTerm> {
|
||||
/**
|
||||
* 查询卷膜运行条件
|
||||
*
|
||||
* @param id 卷膜运行条件主键
|
||||
* @return 卷膜运行条件
|
||||
*/
|
||||
public SysAutoTerm selectSysAutoTermById(String id);
|
||||
|
||||
/**
|
||||
* 查询卷膜运行条件列表
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 卷膜运行条件集合
|
||||
*/
|
||||
public List<SysAutoTerm> selectSysAutoTermList(SysAutoTerm sysAutoTerm);
|
||||
|
||||
/**
|
||||
* 新增卷膜运行条件
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysAutoTerm(SysAutoTerm sysAutoTerm);
|
||||
|
||||
/**
|
||||
* 修改卷膜运行条件
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysAutoTerm(SysAutoTerm sysAutoTerm);
|
||||
|
||||
/**
|
||||
* 批量删除卷膜运行条件
|
||||
*
|
||||
* @param ids 需要删除的卷膜运行条件主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysAutoTermByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除卷膜运行条件信息
|
||||
*
|
||||
* @param id 卷膜运行条件主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysAutoTermById(String id);
|
||||
|
||||
|
||||
|
||||
boolean saveAgriTerm(List<AgriTermVo> agriTerms);
|
||||
|
||||
String validate(List<AgriTermVo> agriTerms);
|
||||
|
||||
List<AgriTermVo> getAgriTerm(String imei);
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package com.agri.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.agri.system.domain.SysAgriAlarmRelation;
|
||||
import com.agri.system.domain.SysDtuData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* DTU温湿度上报数据Service接口
|
||||
|
|
@ -9,7 +12,7 @@ import com.agri.system.domain.SysDtuData;
|
|||
* @author agri
|
||||
* @date 2025-12-23
|
||||
*/
|
||||
public interface ISysDtuDataService
|
||||
public interface ISysDtuDataService extends IService<SysDtuData>
|
||||
{
|
||||
/**
|
||||
* 查询DTU温湿度上报数据
|
||||
|
|
|
|||
|
|
@ -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.SysRollerParam;
|
||||
|
||||
/**
|
||||
* 卷膜参数配置Service接口
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
public interface ISysRollerParamService extends IService<SysRollerParam> {
|
||||
/**
|
||||
* 查询卷膜参数配置
|
||||
*
|
||||
* @param id 卷膜参数配置主键
|
||||
* @return 卷膜参数配置
|
||||
*/
|
||||
public SysRollerParam selectSysRollerParamById(String id);
|
||||
|
||||
/**
|
||||
* 查询卷膜参数配置列表
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 卷膜参数配置集合
|
||||
*/
|
||||
public List<SysRollerParam> selectSysRollerParamList(SysRollerParam sysRollerParam);
|
||||
|
||||
/**
|
||||
* 新增卷膜参数配置
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysRollerParam(SysRollerParam sysRollerParam);
|
||||
|
||||
/**
|
||||
* 修改卷膜参数配置
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysRollerParam(SysRollerParam sysRollerParam);
|
||||
|
||||
/**
|
||||
* 批量删除卷膜参数配置
|
||||
*
|
||||
* @param ids 需要删除的卷膜参数配置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRollerParamByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除卷膜参数配置信息
|
||||
*
|
||||
* @param id 卷膜参数配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRollerParamById(String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
package com.agri.system.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.agri.common.exception.ServiceException;
|
||||
import com.agri.common.utils.DateUtils;
|
||||
import com.agri.common.utils.StringUtils;
|
||||
import com.agri.system.domain.SysRollerParam;
|
||||
import com.agri.system.domain.vo.AgriTermVo;
|
||||
import com.agri.system.service.ISysRollerParamService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.agri.system.mapper.SysAutoTermMapper;
|
||||
import com.agri.system.domain.SysAutoTerm;
|
||||
import com.agri.system.service.ISysAutoTermService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 卷膜运行条件Service业务层处理
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
@Service
|
||||
public class SysAutoTermServiceImpl extends ServiceImpl<SysAutoTermMapper, SysAutoTerm> implements ISysAutoTermService
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private ISysRollerParamService rollerParamService;
|
||||
|
||||
// 温度控制条件数量上限
|
||||
private static final int MAX_TERM_COUNT = 5;
|
||||
|
||||
/**
|
||||
* 查询卷膜运行条件
|
||||
*
|
||||
* @param id 卷膜运行条件主键
|
||||
* @return 卷膜运行条件
|
||||
*/
|
||||
@Override
|
||||
public SysAutoTerm selectSysAutoTermById(String id)
|
||||
{
|
||||
return baseMapper.selectSysAutoTermById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询卷膜运行条件列表
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 卷膜运行条件
|
||||
*/
|
||||
@Override
|
||||
public List<SysAutoTerm> selectSysAutoTermList(SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
return baseMapper.selectSysAutoTermList(sysAutoTerm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增卷膜运行条件
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysAutoTerm(SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
return baseMapper.insert(sysAutoTerm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改卷膜运行条件
|
||||
*
|
||||
* @param sysAutoTerm 卷膜运行条件
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysAutoTerm(SysAutoTerm sysAutoTerm)
|
||||
{
|
||||
sysAutoTerm.setUpdateTime(DateUtils.getNowDate());
|
||||
return baseMapper.updateSysAutoTerm(sysAutoTerm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除卷膜运行条件
|
||||
*
|
||||
* @param ids 需要删除的卷膜运行条件主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysAutoTermByIds(String[] ids)
|
||||
{
|
||||
return baseMapper.deleteSysAutoTermByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卷膜运行条件信息
|
||||
*
|
||||
* @param id 卷膜运行条件主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysAutoTermById(String id)
|
||||
{
|
||||
return baseMapper.deleteSysAutoTermById(id);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean saveAgriTerm(List<AgriTermVo> agriTerms) {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("imei", agriTerms.get(0).getConfig().getImei());
|
||||
boolean isDelTermSuc = super.removeByMap(map);
|
||||
boolean isDelParamSuc = rollerParamService.removeByMap(map);
|
||||
List<SysAutoTerm> autoTerms = new ArrayList<>();
|
||||
List<SysRollerParam> rollerParams = new ArrayList<>();
|
||||
for (AgriTermVo agriTerm : agriTerms) {
|
||||
autoTerms.addAll(agriTerm.getTerms());
|
||||
rollerParams.add(agriTerm.getConfig());
|
||||
}
|
||||
boolean isSaveTermSuccess = super.saveBatch(autoTerms);
|
||||
boolean isSaveRollerSuccess = rollerParamService.saveBatch(rollerParams);
|
||||
|
||||
return isSaveTermSuccess && isSaveRollerSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String validate(List<AgriTermVo> agriTerms) {
|
||||
if (CollectionUtils.isEmpty(agriTerms)) {
|
||||
return "请设置自动化条件后重新保存重试!";
|
||||
}
|
||||
|
||||
for (AgriTermVo vo : agriTerms) {
|
||||
SysRollerParam config = vo.getConfig();
|
||||
if (config == null) {
|
||||
return "参数设置失败,请下拉刷新后重试!";
|
||||
}
|
||||
|
||||
String roller = config.getRoller();
|
||||
List<SysAutoTerm> terms = vo.getTerms();
|
||||
|
||||
// ===== 按顺序校验,一步一判断,清晰直观 =====
|
||||
if (StringUtils.isBlank(config.getRefTempCode())) {
|
||||
return roller + "参考温度未设置,请点击相应页签左上角设置后重试!";
|
||||
}
|
||||
|
||||
boolean hasLen = (config.getManualTotalLen() != null && config.getManualTotalLen() > 0)
|
||||
|| (config.getAutoTotalLen() != null && config.getAutoTotalLen() > 0);
|
||||
if (!hasLen) {
|
||||
return roller + "计算风口总长和手动设置风口长度至少填写一个!";
|
||||
}
|
||||
|
||||
if (config.getReservedLen() == null || config.getReservedLen() <= 0) {
|
||||
return roller + "预留风口长度未设置,请点击相应页签右上角设置后重试!";
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(terms)) {
|
||||
return roller + "温度控制未设置,请设置后重新尝试!";
|
||||
}
|
||||
|
||||
if (terms.size() > 5) {
|
||||
return roller + "温度控制设置条数超过上限!请调整后重试";
|
||||
}
|
||||
|
||||
for (SysAutoTerm term : terms) {
|
||||
if (term.getStartTime() == null || term.getEndTime() == null) {
|
||||
return roller + "温度控制运行时间填写不完整,请检查填写后重新尝试!";
|
||||
}
|
||||
if (term.getStartTime().after(term.getEndTime())) {
|
||||
return roller + "温度控制运行时间起不能大于止!";
|
||||
}
|
||||
if (term.getTemp() == null || term.getTemp().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return roller + "温度控制适宜温度填写不完整!";
|
||||
}
|
||||
if (term.getVent() == null || term.getVent() <= 0) {
|
||||
return roller + "温度控制风口开合大小填写不完整!";
|
||||
}
|
||||
}
|
||||
|
||||
if (checkTimeConflict(terms)) {
|
||||
return roller + "温度控制运行时间存在冲突,请检查填写后重新尝试!";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 精简版:时间冲突校验(逻辑不变,代码更紧凑)
|
||||
*/
|
||||
private static boolean checkTimeConflict(List<SysAutoTerm> terms) {
|
||||
if (terms.size() <= 1) return false;
|
||||
|
||||
for (int i = 0; i < terms.size(); i++) {
|
||||
SysAutoTerm t1 = terms.get(i);
|
||||
for (int j = i + 1; j < terms.size(); j++) {
|
||||
SysAutoTerm t2 = terms.get(j);
|
||||
// 一行判断时间重叠,精简代码
|
||||
if (!(t1.getEndTime().before(t2.getStartTime()) || t1.getStartTime().after(t2.getEndTime()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AgriTermVo> getAgriTerm(String imei) {
|
||||
|
||||
List<AgriTermVo> agriTerms = new ArrayList<>();
|
||||
List<SysAutoTerm> autoTerms = super.lambdaQuery()
|
||||
.eq(SysAutoTerm::getImei, imei)
|
||||
.orderByAsc(SysAutoTerm::getRoller)
|
||||
.list();
|
||||
List<SysRollerParam> rollerParams = rollerParamService.lambdaQuery()
|
||||
.eq(SysRollerParam::getImei, imei)
|
||||
.orderByAsc(SysRollerParam::getRoller)
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(rollerParams)) {
|
||||
return agriTerms;
|
||||
}
|
||||
Map<String, List<SysAutoTerm>> rollerMap
|
||||
= autoTerms.stream().collect(Collectors.groupingBy(SysAutoTerm::getRoller));
|
||||
for (SysRollerParam rollerParam : rollerParams) {
|
||||
rollerParam.setRefTemp(rollerParam.getRefTempCode().replace("20","温度"));
|
||||
AgriTermVo agriTerm = new AgriTermVo();
|
||||
agriTerm.setConfig(rollerParam);
|
||||
List<SysAutoTerm> terms = rollerMap.get(rollerParam.getRoller());
|
||||
if (CollectionUtils.isNotEmpty(terms)) {
|
||||
agriTerm.setTerms(terms);
|
||||
}
|
||||
agriTerms.add(agriTerm);
|
||||
}
|
||||
return agriTerms;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ 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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.agri.system.mapper.SysDtuDataMapper;
|
||||
|
|
@ -15,7 +16,7 @@ import com.agri.system.service.ISysDtuDataService;
|
|||
* @date 2025-12-23
|
||||
*/
|
||||
@Service
|
||||
public class SysDtuDataServiceImpl implements ISysDtuDataService
|
||||
public class SysDtuDataServiceImpl extends ServiceImpl<SysDtuDataMapper, SysDtuData> implements ISysDtuDataService
|
||||
{
|
||||
@Autowired
|
||||
private SysDtuDataMapper sysDtuDataMapper;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
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.SysRollerParamMapper;
|
||||
import com.agri.system.domain.SysRollerParam;
|
||||
import com.agri.system.service.ISysRollerParamService;
|
||||
|
||||
/**
|
||||
* 卷膜参数配置Service业务层处理
|
||||
*
|
||||
* @author lld
|
||||
* @date 2026-02-27
|
||||
*/
|
||||
@Service
|
||||
public class SysRollerParamServiceImpl extends ServiceImpl<SysRollerParamMapper, SysRollerParam> implements ISysRollerParamService
|
||||
{
|
||||
|
||||
/**
|
||||
* 查询卷膜参数配置
|
||||
*
|
||||
* @param id 卷膜参数配置主键
|
||||
* @return 卷膜参数配置
|
||||
*/
|
||||
@Override
|
||||
public SysRollerParam selectSysRollerParamById(String id)
|
||||
{
|
||||
return baseMapper.selectSysRollerParamById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询卷膜参数配置列表
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 卷膜参数配置
|
||||
*/
|
||||
@Override
|
||||
public List<SysRollerParam> selectSysRollerParamList(SysRollerParam sysRollerParam)
|
||||
{
|
||||
return baseMapper.selectSysRollerParamList(sysRollerParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增卷膜参数配置
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysRollerParam(SysRollerParam sysRollerParam)
|
||||
{
|
||||
return baseMapper.insert(sysRollerParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改卷膜参数配置
|
||||
*
|
||||
* @param sysRollerParam 卷膜参数配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysRollerParam(SysRollerParam sysRollerParam)
|
||||
{
|
||||
sysRollerParam.setUpdateTime(DateUtils.getNowDate());
|
||||
return baseMapper.updateSysRollerParam(sysRollerParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除卷膜参数配置
|
||||
*
|
||||
* @param ids 需要删除的卷膜参数配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysRollerParamByIds(String[] ids)
|
||||
{
|
||||
return baseMapper.deleteSysRollerParamByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卷膜参数配置信息
|
||||
*
|
||||
* @param id 卷膜参数配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysRollerParamById(String id)
|
||||
{
|
||||
return baseMapper.deleteSysRollerParamById(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
package com.agri.system.util;
|
||||
|
||||
import com.agri.common.exception.ServiceException;
|
||||
|
||||
import com.agri.system.domain.SysAutoTerm;
|
||||
import com.agri.system.domain.SysRollerParam;
|
||||
import com.agri.system.domain.vo.AgriTermVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 卷膜参数校验工具类(和前端 saveAutoTerm 1:1 对齐)
|
||||
*/
|
||||
public class RollerParamValidateUtil {
|
||||
// 条件数量上限(和前端 5 保持一致)
|
||||
private static final int MAX_TERM_COUNT = 5;
|
||||
|
||||
/**
|
||||
* 核心校验方法:完全复刻前端 saveAutoTerm 逻辑
|
||||
* @param agriTerms 对应前端 termList
|
||||
* @param filmRollerList 对应前端 this.filmRollerList(卷膜名称列表:["卷膜1","卷膜2","卷膜3"])
|
||||
*/
|
||||
public static void validate(List<AgriTermVo> agriTerms, List<String> filmRollerList) {
|
||||
// 对应前端 termMap = this.termList
|
||||
List<AgriTermVo> termMap = agriTerms;
|
||||
// 对应前端 rollerList = []
|
||||
List<String> rollerList = new ArrayList<>();
|
||||
// 对应前端 showTips = null
|
||||
String showTips = null;
|
||||
|
||||
// 1. 定义校验规则数组(完全复刻前端 checkRules)
|
||||
List<CheckRule> checkRules = buildCheckRules();
|
||||
|
||||
// 2. 外层循环:遍历每个校验规则(对应前端 for (const [_, rule] of checkRules.entries()))
|
||||
for (CheckRule rule : checkRules) {
|
||||
// 内层循环:遍历每个卷膜(对应前端 for (const [index, item] of this.filmRollerList.entries()))
|
||||
for (int index = 0; index < filmRollerList.size(); index++) {
|
||||
String filmRoller = filmRollerList.get(index); // 卷膜名称:卷膜1/卷膜2/卷膜3
|
||||
// 对应前端 term = termMap[index]['terms']
|
||||
List<SysAutoTerm> term = termMap.get(index).getTerms();
|
||||
// 对应前端 rollerParam = termMap[index]['config']
|
||||
SysRollerParam rollerParam = termMap.get(index).getConfig();
|
||||
|
||||
// 对应前端 if (!rollerParam) 逻辑
|
||||
if (rollerParam == null) {
|
||||
throw new ServiceException("参数设置失败,请下拉刷新后重试!");
|
||||
}
|
||||
// 对应前端 else if (rule.validate(rollerParam, term)) 逻辑
|
||||
else if (rule.validate(rollerParam, term)) {
|
||||
rollerList.add(filmRoller);
|
||||
showTips = rule.getTip();
|
||||
}
|
||||
}
|
||||
|
||||
// 对应前端 if (rollerList.length>0) 逻辑:校验失败则抛异常
|
||||
if (!rollerList.isEmpty()) {
|
||||
String errorMsg = String.format("【%s】%s", String.join(",", rollerList), showTips);
|
||||
throw new ServiceException(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建校验规则数组(完全复刻前端 checkRules)
|
||||
*/
|
||||
private static List<CheckRule> buildCheckRules() {
|
||||
List<CheckRule> rules = new ArrayList<>();
|
||||
|
||||
// 规则1:请设置自动化条件后重新保存重试!
|
||||
rules.add(new CheckRule("请设置自动化条件后重新保存重试!", (rollerParam, term) ->
|
||||
// 前端:rollerParam.refTemp === '请选择' && !(term && term.length > 0)
|
||||
// Java 对应:refTempCode 为空(对应前端 '请选择') + 条件为空
|
||||
StringUtils.isBlank(rollerParam.getRefTempCode()) && (CollectionUtils.isEmpty(term))
|
||||
));
|
||||
|
||||
// 规则2:参考温度未设置,请点击相应页签左上角设置后重试!
|
||||
rules.add(new CheckRule("参考温度未设置,请点击相应页签左上角设置后重试!", (rollerParam, term) ->
|
||||
// 前端:rollerParam.refTemp === '请选择'
|
||||
StringUtils.isBlank(rollerParam.getRefTempCode())
|
||||
));
|
||||
|
||||
// 规则3:计算风口总长和手动设置风口长度至少填写一个!
|
||||
rules.add(new CheckRule("计算风口总长和手动设置风口长度至少填写一个!请填写后重试!", (rollerParam, term) ->
|
||||
// 前端:!((manualTotalLen>0) || (autoTotalLen>0))
|
||||
!((rollerParam.getManualTotalLen() != null && rollerParam.getManualTotalLen() > 0)
|
||||
|| (rollerParam.getAutoTotalLen() != null && rollerParam.getAutoTotalLen() > 0))
|
||||
));
|
||||
|
||||
// 规则4:预留风口长度未设置!
|
||||
rules.add(new CheckRule("预留风口长度未设置,请点击相应页签右上角设置后重试!", (rollerParam, term) ->
|
||||
// 前端:!(reservedLen && reservedLen > 0)
|
||||
!(rollerParam.getReservedLen() != null && rollerParam.getReservedLen() > 0)
|
||||
));
|
||||
|
||||
// 规则5:温度控制未设置!
|
||||
rules.add(new CheckRule("温度控制未设置,请设置后重新尝试!", (rollerParam, term) ->
|
||||
// 前端:!(term && term.length > 0)
|
||||
CollectionUtils.isEmpty(term)
|
||||
));
|
||||
|
||||
// 规则6:温度控制设置条数超过上限!
|
||||
rules.add(new CheckRule("温度控制设置条数超过上限!请调整后重试", (rollerParam, term) ->
|
||||
// 前端:term && term.length > 5
|
||||
!CollectionUtils.isEmpty(term) && term.size() > MAX_TERM_COUNT
|
||||
));
|
||||
|
||||
// 规则7:温度控制运行时间填写不完整!
|
||||
rules.add(new CheckRule("温度控制运行时间填写不完整,请检查填写后重新尝试!", (rollerParam, term) ->
|
||||
// 前端:term.some(item => !(item.startTime && item.startTime!=='请选择时间' && item.endTime && item.endTime !== '请选择时间'))
|
||||
!CollectionUtils.isEmpty(term) && term.stream().anyMatch(item ->
|
||||
item.getStartTime() == null || item.getEndTime() == null
|
||||
)
|
||||
));
|
||||
|
||||
// 规则8:温度控制运行时间起不能大于止!
|
||||
rules.add(new CheckRule("温度控制运行时间起不能大于止,请检查填写后重新尝试!", (rollerParam, term) ->
|
||||
// 前端:term.some(item => (item.startTime > item.endTime))
|
||||
!CollectionUtils.isEmpty(term) && term.stream().anyMatch(item ->
|
||||
item.getStartTime() != null && item.getEndTime() != null
|
||||
&& item.getStartTime().after(item.getEndTime())
|
||||
)
|
||||
));
|
||||
|
||||
// 规则9:温度控制运行时间存在冲突!
|
||||
rules.add(new CheckRule("温度控制运行时间存在冲突,请检查填写后重新尝试!", (rollerParam, term) ->
|
||||
// 前端:调用 checkTimeConflict(term) 返回 isConflict
|
||||
!CollectionUtils.isEmpty(term) && checkTimeConflict(term)
|
||||
));
|
||||
|
||||
// 规则10:温度控制适宜温度填写不完整!
|
||||
rules.add(new CheckRule("温度控制适宜温度填写不完整,请填写后重新尝试!", (rollerParam, term) ->
|
||||
// 前端:term.some(item => !(item.temp && item.temp!=='选择'))
|
||||
!CollectionUtils.isEmpty(term) && term.stream().anyMatch(item ->
|
||||
item.getTemp() == null || item.getTemp().compareTo(BigDecimal.ZERO) <= 0
|
||||
)
|
||||
));
|
||||
|
||||
// 规则11:温度控制风口开合大小填写不完整!
|
||||
rules.add(new CheckRule("温度控制风口开合大小填写不完整,请填写后重新尝试!", (rollerParam, term) ->
|
||||
// 前端:term.some(item => !(item.vent && item.vent!=='选择'))
|
||||
!CollectionUtils.isEmpty(term) && term.stream().anyMatch(item ->
|
||||
item.getVent() == null || item.getVent() <= 0
|
||||
)
|
||||
));
|
||||
|
||||
return rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间冲突判断(完全复刻前端 checkTimeConflict 逻辑)
|
||||
*/
|
||||
private static boolean checkTimeConflict(List<SysAutoTerm> term) {
|
||||
if (CollectionUtils.isEmpty(term) || term.size() <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 遍历判断时间区间是否冲突
|
||||
for (int i = 0; i < term.size(); i++) {
|
||||
SysAutoTerm item1 = term.get(i);
|
||||
for (int j = i + 1; j < term.size(); j++) {
|
||||
SysAutoTerm item2 = term.get(j);
|
||||
// 前端时间冲突逻辑:判断两个时间区间是否重叠
|
||||
Date start1 = item1.getStartTime();
|
||||
Date end1 = item1.getEndTime();
|
||||
Date start2 = item2.getStartTime();
|
||||
Date end2 = item2.getEndTime();
|
||||
|
||||
if (start1 == null || end1 == null || start2 == null || end2 == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 核心冲突判断逻辑(和前端一致)
|
||||
boolean isConflict = !(end1.before(start2) || start1.after(end2));
|
||||
if (isConflict) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验规则内部类(对应前端 checkRules 里的单个规则对象)
|
||||
*/
|
||||
@FunctionalInterface
|
||||
interface ValidateFunction {
|
||||
boolean validate(SysRollerParam rollerParam, List<SysAutoTerm> term);
|
||||
}
|
||||
|
||||
static class CheckRule {
|
||||
private final String tip; // 对应前端 rule.tip
|
||||
private final ValidateFunction validate; // 对应前端 rule.validate
|
||||
|
||||
public CheckRule(String tip, ValidateFunction validate) {
|
||||
this.tip = tip;
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
public String getTip() {
|
||||
return tip;
|
||||
}
|
||||
|
||||
public boolean validate(SysRollerParam rollerParam, List<SysAutoTerm> term) {
|
||||
return validate.validate(rollerParam, term);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?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.agri.system.mapper.SysAutoTermMapper">
|
||||
|
||||
<resultMap type="SysAutoTerm" id="SysAutoTermResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="imei" column="imei" />
|
||||
<result property="roller" column="roller" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="endTime" column="end_time" />
|
||||
<result property="temp" column="temp" />
|
||||
<result property="vent" column="vent" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysAutoTermVo">
|
||||
select id, imei, roller, start_time, end_time, temp, vent, create_by, create_time, update_by, update_time from sys_auto_term
|
||||
</sql>
|
||||
|
||||
<select id="selectSysAutoTermList" parameterType="SysAutoTerm" resultMap="SysAutoTermResult">
|
||||
<include refid="selectSysAutoTermVo"/>
|
||||
<where>
|
||||
<if test="imei != null and imei != ''"> and imei like concat('%', #{imei}, '%')</if>
|
||||
<if test="roller != null and roller != ''"> and roller = #{roller}</if>
|
||||
<if test="startTime != null "> and start_time >= #{startTime}</if>
|
||||
<if test="endTime != null "> and end_time <= #{endTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysAutoTermById" parameterType="String" resultMap="SysAutoTermResult">
|
||||
<include refid="selectSysAutoTermVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysAutoTerm" parameterType="SysAutoTerm" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_auto_term
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">imei,</if>
|
||||
<if test="roller != null and roller != ''">roller,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
<if test="temp != null">temp,</if>
|
||||
<if test="vent != null">vent,</if>
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">#{imei},</if>
|
||||
<if test="roller != null and roller != ''">#{roller},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
<if test="temp != null">#{temp},</if>
|
||||
<if test="vent != null">#{vent},</if>
|
||||
#{createBy},
|
||||
#{createTime},
|
||||
#{updateBy},
|
||||
#{updateTime},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysAutoTerm" parameterType="SysAutoTerm">
|
||||
update sys_auto_term
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">imei = #{imei},</if>
|
||||
<if test="roller != null and roller != ''">roller = #{roller},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="endTime != null">end_time = #{endTime},</if>
|
||||
<if test="temp != null">temp = #{temp},</if>
|
||||
<if test="vent != null">vent = #{vent},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysAutoTermById" parameterType="String">
|
||||
delete from sys_auto_term where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysAutoTermByIds" parameterType="String">
|
||||
delete from sys_auto_term where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<?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.agri.system.mapper.SysRollerParamMapper">
|
||||
|
||||
<resultMap type="SysRollerParam" id="SysRollerParamResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="imei" column="imei" />
|
||||
<result property="roller" column="roller" />
|
||||
<result property="refTempCode" column="ref_temp_code" />
|
||||
<result property="reservedLen" column="reserved_len" />
|
||||
<result property="manualTotalLen" column="manual_total_len" />
|
||||
<result property="autoTotalLen" column="auto_total_len" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysRollerParamVo">
|
||||
select id, imei, roller, ref_temp_code, reserved_len, manual_total_len, auto_total_len, create_by, create_time, update_by, update_time from sys_roller_param
|
||||
</sql>
|
||||
|
||||
<select id="selectSysRollerParamList" parameterType="SysRollerParam" resultMap="SysRollerParamResult">
|
||||
<include refid="selectSysRollerParamVo"/>
|
||||
<where>
|
||||
<if test="imei != null and imei != ''"> and imei = #{imei}</if>
|
||||
<if test="roller != null and roller != ''"> and roller = #{roller}</if>
|
||||
<if test="refTempCode != null and refTempCode != ''"> and ref_temp_code = #{refTempCode}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysRollerParamById" parameterType="String" resultMap="SysRollerParamResult">
|
||||
<include refid="selectSysRollerParamVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysRollerParam" parameterType="SysRollerParam" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_roller_param
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">imei,</if>
|
||||
<if test="roller != null and roller != ''">roller,</if>
|
||||
<if test="refTempCode != null and refTempCode != ''">ref_temp_code,</if>
|
||||
<if test="reservedLen != null">reserved_len,</if>
|
||||
<if test="manualTotalLen != null">manual_total_len,</if>
|
||||
<if test="autoTotalLen != null">auto_total_len,</if>
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">#{imei},</if>
|
||||
<if test="roller != null and roller != ''">#{roller},</if>
|
||||
<if test="refTempCode != null and refTempCode != ''">#{refTempCode},</if>
|
||||
<if test="reservedLen != null">#{reservedLen},</if>
|
||||
<if test="manualTotalLen != null">#{manualTotalLen},</if>
|
||||
<if test="autoTotalLen != null">#{autoTotalLen},</if>
|
||||
#{createBy},
|
||||
#{createTime},
|
||||
#{updateBy},
|
||||
#{updateTime},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysRollerParam" parameterType="SysRollerParam">
|
||||
update sys_roller_param
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="imei != null and imei != ''">imei = #{imei},</if>
|
||||
<if test="roller != null and roller != ''">roller = #{roller},</if>
|
||||
<if test="refTempCode != null and refTempCode != ''">ref_temp_code = #{refTempCode},</if>
|
||||
<if test="reservedLen != null">reserved_len = #{reservedLen},</if>
|
||||
<if test="manualTotalLen != null">manual_total_len = #{manualTotalLen},</if>
|
||||
<if test="autoTotalLen != null">auto_total_len = #{autoTotalLen},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysRollerParamById" parameterType="String">
|
||||
delete from sys_roller_param where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysRollerParamByIds" parameterType="String">
|
||||
delete from sys_roller_param where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue