jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/Bo/HerbFormulaBo.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,41 @@ package org.jeecg.modules.dry.Bo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class HerbFormulaBo { @ApiModelProperty(value = "设å¤ç¼å·") private String eqpCode; private String eqpType; @ApiModelProperty(value = "é æ¹åç§°") private String name; @ApiModelProperty(value = "缩å") private String abbr; @ApiModelProperty(value = "ç¹ç§ç©æ") private String special; @ApiModelProperty(value = "è½»è´¨ç©æ") private String light; @ApiModelProperty(value = "åå§å«æ°´ç") private Double initial; @ApiModelProperty(value = "ç®æ 嫿°´ç") private Double target; @ApiModelProperty(value = "ææé") private Integer feed; @ApiModelProperty(value = "é¢è®¡å¹²ç¥æ¶é´") private Integer et; @ApiModelProperty(value = "ç飿¸©åº¦") private Double windTemp; @ApiModelProperty(value = "åå§é£æºé¢ç") private Integer fanSpeed; @ApiModelProperty(value = "ç¿»æçç¥") private String strategy; @ApiModelProperty(value = "å·é£æ¶é¿") private Integer coolingDuration; @ApiModelProperty(value = "å¯ç¨æ å¿") private String enabled; /**ç§æ·id*/ @ApiModelProperty(value = "ç§æ·id") private Integer tenantId; } jeecg-module-dry/jeecg-module-dry-api/src/main/java/org/jeecg/modules/dry/entity/DryHerbFormula.java
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.jeecg.modules.dry.Bo.HerbFormulaBo; import org.jeecg.modules.dry.vo.HerbFormulaVo; import org.jeecg.modules.dry.vo.RealTimeDataVo; import org.springframework.format.annotation.DateTimeFormat; import org.jeecgframework.poi.excel.annotation.Excel; @@ -167,4 +169,22 @@ this.et = realTimeDataVo.getTime1(); this.tenantId = realTimeDataVo.getTenantid(); } public DryHerbFormula(HerbFormulaBo formulaBo) { this.eqpType = formulaBo.getEqpType(); this.name = formulaBo.getName(); this.abbr = formulaBo.getAbbr(); this.special = formulaBo.getSpecial(); this.light = formulaBo.getLight(); this.initial = formulaBo.getInitial(); this.target = formulaBo.getTarget(); this.feed = formulaBo.getFeed(); this.et = formulaBo.getEt(); this.windTemp = formulaBo.getWindTemp(); this.fanSpeed = formulaBo.getFanSpeed(); this.strategy = formulaBo.getStrategy(); this.coolingDuration = formulaBo.getCoolingDuration(); this.enabled = formulaBo.getEnabled(); } } jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryHerbFormulaController.java
@@ -93,6 +93,8 @@ @RequiresPermissions("dry:dry_herb_formula:add") @PostMapping(value = "/add") public Result<String> add(@RequestBody DryHerbFormula dryHerbFormula) { log.info("æ·»å åæ°ï¼" + dryHerbFormula.toString()); dryHerbFormulaService.save(dryHerbFormula); return Result.OK("æ·»å æåï¼"); } jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryRealTimeDataController.java
@@ -12,9 +12,11 @@ import org.eclipse.paho.client.mqttv3.MqttMessage; import org.jeecg.common.api.vo.Result; import org.jeecg.common.config.TenantContext; import org.jeecg.common.constant.MqttConstant; import org.jeecg.common.util.IpUtils; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.modules.dry.Bo.HerbFormulaBo; import org.jeecg.modules.dry.entity.*; import org.jeecg.modules.dry.mqtt.MqttConfig; import org.jeecg.modules.dry.mqtt.MqttUtil; @@ -278,6 +280,38 @@ } /** * drying formula upload * @param formulaBo * @return */ @ApiOperation(value = "å¹²ç¥é æ¹ä¸ä¼ ", notes = "å¹²ç¥é æ¹æ°å¢ææ´æ°") @PostMapping(value = "/saveFormula") public Result<?> saveFormula(@RequestBody HerbFormulaBo formulaBo) { TenantContext.setTenant(formulaBo.getTenantId()+""); //è·årequest HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); // è·å请æ±ä¸»æºçIPå°å String ip = IpUtils.getIpAddr(request); DryEquipment dryEquipment = dryEquipmentService.selectByTenantIdEquipmentId(formulaBo.getTenantId() + "", formulaBo.getEqpCode()); if (dryEquipment != null) { if (dryEquipment.getIp().equals(ip)) { } else { return Result.error("设å¤IPå°åæªé ç½®ï¼" + ip); } } else { return Result.error("设å¤ä¸åå¨"); } formulaBo.setEqpType(dryEquipment.getType()); dryHerbFormulaService.saveOrUpdateFormula(formulaBo); return Result.ok("ä¿åæå"); } @ApiOperation(value = "å¹²ç¥é æ¹ä¸æ¥", notes = "å¹²ç¥é æ¹è®°å½ä¸æ¥") @PostMapping(value = "/sendFormulaHistory") public Result<?> sendFormulaHistory(DryHerbFormulaHisVo hisVo) { jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/service/IDryHerbFormulaService.java
@@ -1,7 +1,9 @@ package org.jeecg.modules.dry.service; import org.jeecg.modules.dry.Bo.HerbFormulaBo; import org.jeecg.modules.dry.entity.DryHerbFormula; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.dry.vo.HerbFormulaVo; /** * @Description: å¹²ç¥é æ¹ @@ -11,4 +13,5 @@ */ public interface IDryHerbFormulaService extends IService<DryHerbFormula> { void saveOrUpdateFormula(HerbFormulaBo formulaBo); } jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/service/impl/DryHerbFormulaServiceImpl.java
@@ -1,8 +1,11 @@ package org.jeecg.modules.dry.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.jeecg.modules.dry.Bo.HerbFormulaBo; import org.jeecg.modules.dry.entity.DryHerbFormula; import org.jeecg.modules.dry.mapper.DryHerbFormulaMapper; import org.jeecg.modules.dry.service.IDryHerbFormulaService; import org.jeecg.modules.dry.vo.HerbFormulaVo; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -16,4 +19,22 @@ @Service public class DryHerbFormulaServiceImpl extends ServiceImpl<DryHerbFormulaMapper, DryHerbFormula> implements IDryHerbFormulaService { @Override public void saveOrUpdateFormula(HerbFormulaBo formulaBo) { DryHerbFormula formula = new DryHerbFormula(formulaBo); LambdaQueryWrapper<DryHerbFormula> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(DryHerbFormula::getEqpType, formula.getEqpType()); queryWrapper.eq(DryHerbFormula::getName, formula.getName()); DryHerbFormula existingFormula = baseMapper.selectOne(queryWrapper); if (existingFormula != null) { // 妿åå¨ï¼åæ´æ°è®°å½ï¼éè¦è®¾ç½®IDä»¥ç¡®ä¿æ´æ°æ£ç¡®çè®°å½ formula.setId(existingFormula.getId()); updateById(formula); } else { // 妿ä¸åå¨ï¼åæå ¥æ°è®°å½ save( formula); } } }